theta-client-react-native 1.4.0 → 1.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/android/build.gradle +2 -2
  2. package/android/src/main/java/com/ricoh360/thetaclientreactnative/Converter.kt +492 -1093
  3. package/android/src/main/java/com/ricoh360/thetaclientreactnative/ThetaClientSdkModule.kt +423 -253
  4. package/ios/ConvertUtil.swift +195 -2
  5. package/ios/ThetaClientReactNative.m +41 -0
  6. package/ios/ThetaClientReactNative.swift +427 -3
  7. package/lib/commonjs/capture/composite-interval-capture.js +112 -0
  8. package/lib/commonjs/capture/composite-interval-capture.js.map +1 -0
  9. package/lib/commonjs/capture/index.js +33 -0
  10. package/lib/commonjs/capture/index.js.map +1 -1
  11. package/lib/commonjs/capture/limitless-interval-capture.js +89 -0
  12. package/lib/commonjs/capture/limitless-interval-capture.js.map +1 -0
  13. package/lib/commonjs/capture/photo-capture.js +7 -2
  14. package/lib/commonjs/capture/photo-capture.js.map +1 -1
  15. package/lib/commonjs/capture/shot-count-specified-interval-capture.js +113 -0
  16. package/lib/commonjs/capture/shot-count-specified-interval-capture.js.map +1 -0
  17. package/lib/commonjs/capture/time-shift-capture.js +9 -1
  18. package/lib/commonjs/capture/time-shift-capture.js.map +1 -1
  19. package/lib/commonjs/theta-repository/options/index.js +55 -0
  20. package/lib/commonjs/theta-repository/options/index.js.map +1 -1
  21. package/lib/commonjs/theta-repository/options/option-auto-bracket.js +6 -0
  22. package/lib/commonjs/theta-repository/options/option-auto-bracket.js.map +1 -0
  23. package/lib/commonjs/theta-repository/options/option-top-bottom-correction-rotation.js +2 -0
  24. package/lib/commonjs/theta-repository/options/option-top-bottom-correction-rotation.js.map +1 -0
  25. package/lib/commonjs/theta-repository/options/option-top-bottom-correction.js +52 -0
  26. package/lib/commonjs/theta-repository/options/option-top-bottom-correction.js.map +1 -0
  27. package/lib/commonjs/theta-repository/options/option-video-stitching.js +24 -0
  28. package/lib/commonjs/theta-repository/options/option-video-stitching.js.map +1 -0
  29. package/lib/commonjs/theta-repository/options/option-visibility-reduction.js +23 -0
  30. package/lib/commonjs/theta-repository/options/option-visibility-reduction.js.map +1 -0
  31. package/lib/commonjs/theta-repository/options/options.js +12 -0
  32. package/lib/commonjs/theta-repository/options/options.js.map +1 -1
  33. package/lib/commonjs/theta-repository/theta-repository.js +36 -1
  34. package/lib/commonjs/theta-repository/theta-repository.js.map +1 -1
  35. package/lib/module/capture/composite-interval-capture.js +104 -0
  36. package/lib/module/capture/composite-interval-capture.js.map +1 -0
  37. package/lib/module/capture/index.js +3 -0
  38. package/lib/module/capture/index.js.map +1 -1
  39. package/lib/module/capture/limitless-interval-capture.js +81 -0
  40. package/lib/module/capture/limitless-interval-capture.js.map +1 -0
  41. package/lib/module/capture/photo-capture.js +7 -2
  42. package/lib/module/capture/photo-capture.js.map +1 -1
  43. package/lib/module/capture/shot-count-specified-interval-capture.js +105 -0
  44. package/lib/module/capture/shot-count-specified-interval-capture.js.map +1 -0
  45. package/lib/module/capture/time-shift-capture.js +9 -1
  46. package/lib/module/capture/time-shift-capture.js.map +1 -1
  47. package/lib/module/theta-repository/options/index.js +5 -0
  48. package/lib/module/theta-repository/options/index.js.map +1 -1
  49. package/lib/module/theta-repository/options/option-auto-bracket.js +2 -0
  50. package/lib/module/theta-repository/options/option-auto-bracket.js.map +1 -0
  51. package/lib/module/theta-repository/options/option-top-bottom-correction-rotation.js +2 -0
  52. package/lib/module/theta-repository/options/option-top-bottom-correction-rotation.js.map +1 -0
  53. package/lib/module/theta-repository/options/option-top-bottom-correction.js +45 -0
  54. package/lib/module/theta-repository/options/option-top-bottom-correction.js.map +1 -0
  55. package/lib/module/theta-repository/options/option-video-stitching.js +17 -0
  56. package/lib/module/theta-repository/options/option-video-stitching.js.map +1 -0
  57. package/lib/module/theta-repository/options/option-visibility-reduction.js +16 -0
  58. package/lib/module/theta-repository/options/option-visibility-reduction.js.map +1 -0
  59. package/lib/module/theta-repository/options/options.js +12 -0
  60. package/lib/module/theta-repository/options/options.js.map +1 -1
  61. package/lib/module/theta-repository/theta-repository.js +34 -2
  62. package/lib/module/theta-repository/theta-repository.js.map +1 -1
  63. package/lib/typescript/capture/composite-interval-capture.d.ts +47 -0
  64. package/lib/typescript/capture/composite-interval-capture.d.ts.map +1 -0
  65. package/lib/typescript/capture/index.d.ts +3 -0
  66. package/lib/typescript/capture/index.d.ts.map +1 -1
  67. package/lib/typescript/capture/limitless-interval-capture.d.ts +40 -0
  68. package/lib/typescript/capture/limitless-interval-capture.d.ts.map +1 -0
  69. package/lib/typescript/capture/photo-capture.d.ts +1 -1
  70. package/lib/typescript/capture/photo-capture.d.ts.map +1 -1
  71. package/lib/typescript/capture/shot-count-specified-interval-capture.d.ts +48 -0
  72. package/lib/typescript/capture/shot-count-specified-interval-capture.d.ts.map +1 -0
  73. package/lib/typescript/capture/time-shift-capture.d.ts +2 -1
  74. package/lib/typescript/capture/time-shift-capture.d.ts.map +1 -1
  75. package/lib/typescript/theta-repository/options/index.d.ts +5 -0
  76. package/lib/typescript/theta-repository/options/index.d.ts.map +1 -1
  77. package/lib/typescript/theta-repository/options/option-auto-bracket.d.ts +36 -0
  78. package/lib/typescript/theta-repository/options/option-auto-bracket.d.ts.map +1 -0
  79. package/lib/typescript/theta-repository/options/option-top-bottom-correction-rotation.d.ts +22 -0
  80. package/lib/typescript/theta-repository/options/option-top-bottom-correction-rotation.d.ts.map +1 -0
  81. package/lib/typescript/theta-repository/options/option-top-bottom-correction.d.ts +45 -0
  82. package/lib/typescript/theta-repository/options/option-top-bottom-correction.d.ts.map +1 -0
  83. package/lib/typescript/theta-repository/options/option-video-stitching.d.ts +17 -0
  84. package/lib/typescript/theta-repository/options/option-video-stitching.d.ts.map +1 -0
  85. package/lib/typescript/theta-repository/options/option-visibility-reduction.d.ts +16 -0
  86. package/lib/typescript/theta-repository/options/option-visibility-reduction.d.ts.map +1 -0
  87. package/lib/typescript/theta-repository/options/options.d.ts +32 -0
  88. package/lib/typescript/theta-repository/options/options.d.ts.map +1 -1
  89. package/lib/typescript/theta-repository/theta-repository.d.ts +25 -2
  90. package/lib/typescript/theta-repository/theta-repository.d.ts.map +1 -1
  91. package/lib/typescript/theta-repository/theta-state.d.ts +1 -1
  92. package/lib/typescript/theta-repository/theta-state.d.ts.map +1 -1
  93. package/package.json +5 -3
  94. package/src/capture/composite-interval-capture.ts +140 -0
  95. package/src/capture/index.ts +3 -0
  96. package/src/capture/limitless-interval-capture.ts +99 -0
  97. package/src/capture/photo-capture.ts +7 -2
  98. package/src/capture/shot-count-specified-interval-capture.ts +147 -0
  99. package/src/capture/time-shift-capture.ts +19 -1
  100. package/src/theta-repository/options/index.ts +5 -0
  101. package/src/theta-repository/options/option-auto-bracket.ts +48 -0
  102. package/src/theta-repository/options/option-top-bottom-correction-rotation.ts +21 -0
  103. package/src/theta-repository/options/option-top-bottom-correction.ts +46 -0
  104. package/src/theta-repository/options/option-video-stitching.ts +18 -0
  105. package/src/theta-repository/options/option-visibility-reduction.ts +17 -0
  106. package/src/theta-repository/options/options.ts +32 -0
  107. package/src/theta-repository/theta-repository.ts +40 -1
  108. package/src/theta-repository/theta-state.ts +1 -1
  109. package/theta-client-react-native.podspec +1 -1
@@ -4,7 +4,6 @@ import com.facebook.react.bridge.*
4
4
  import com.facebook.react.modules.core.DeviceEventManagerModule
5
5
  import com.ricoh360.thetaclient.ThetaRepository
6
6
  import com.ricoh360.thetaclient.capture.*
7
- import io.ktor.utils.io.core.*
8
7
  import kotlinx.coroutines.*
9
8
  import java.util.*
10
9
  import kotlin.coroutines.*
@@ -29,6 +28,15 @@ class ThetaClientReactNativeModule(
29
28
  var videoCaptureBuilder: VideoCapture.Builder? = null
30
29
  var videoCapture: VideoCapture? = null
31
30
  var videoCapturing: VideoCapturing? = null
31
+ var limitlessIntervalCaptureBuilder: LimitlessIntervalCapture.Builder? = null
32
+ var limitlessIntervalCapture: LimitlessIntervalCapture? = null
33
+ var limitlessIntervalCapturing: LimitlessIntervalCapturing? = null
34
+ var shotCountSpecifiedIntervalCaptureBuilder: ShotCountSpecifiedIntervalCapture.Builder? = null
35
+ var shotCountSpecifiedIntervalCapture: ShotCountSpecifiedIntervalCapture? = null
36
+ var shotCountSpecifiedIntervalCapturing: ShotCountSpecifiedIntervalCapturing? = null
37
+ var compositeIntervalCaptureBuilder: CompositeIntervalCapture.Builder? = null
38
+ var compositeIntervalCapture: CompositeIntervalCapture? = null
39
+ var compositeIntervalCapturing: CompositeIntervalCapturing? = null
32
40
  var theta: ThetaRepository? = null
33
41
  var listenerCount: Int = 0
34
42
 
@@ -85,6 +93,15 @@ class ThetaClientReactNativeModule(
85
93
  videoCaptureBuilder = null
86
94
  videoCapture = null
87
95
  videoCapturing = null
96
+ limitlessIntervalCaptureBuilder = null
97
+ limitlessIntervalCapture = null
98
+ limitlessIntervalCapturing = null
99
+ shotCountSpecifiedIntervalCaptureBuilder = null
100
+ shotCountSpecifiedIntervalCapture = null
101
+ shotCountSpecifiedIntervalCapturing = null
102
+ compositeIntervalCaptureBuilder = null
103
+ compositeIntervalCapture = null
104
+ compositeIntervalCapturing = null
88
105
 
89
106
  theta = ThetaRepository.newInstance(
90
107
  endpoint,
@@ -249,7 +266,7 @@ class ThetaClientReactNativeModule(
249
266
  )
250
267
  val resultList = Arguments.createArray()
251
268
  fileList.forEach {
252
- resultList.pushMap(fileInfoFromTheta(it))
269
+ resultList.pushMap(toResult(fileInfo = it))
253
270
  }
254
271
  val resultMap = Arguments.createMap()
255
272
  resultMap.putArray("fileList", resultList)
@@ -350,117 +367,6 @@ class ThetaClientReactNativeModule(
350
367
  }
351
368
  }
352
369
 
353
- /** option converter */
354
- private val converters = mapOf(
355
- "aiAutoThumbnail" to AiAutoThumbnailConverter(),
356
- "aperture" to ApertureConverter(),
357
- "bitrate" to BitrateConverter(),
358
- "bluetoothPower" to BluetoothPowerConverter(),
359
- "burstMode" to BurstModeConverter(),
360
- "burstOption" to BurstOptionConverter(),
361
- "cameraControlSource" to CameraControlSourceConverter(),
362
- "cameraMode" to CameraModeConverter(),
363
- "captureInterval" to CaptureIntervalConverter(),
364
- "captureMode" to CaptureModeConverter(),
365
- "captureNumber" to CaptureNumberConverter(),
366
- "colorTemperature" to ColorTemperatureConverter(),
367
- "compositeShootingOutputInterval" to CompositeShootingOutputIntervalConverter(),
368
- "compositeShootingTime" to CompositeShootingTimeConverter(),
369
- "continuousNumber" to ContinuousNumberConverter(),
370
- "dateTimeZone" to DateTimeZoneConverter(),
371
- "exposureCompensation" to ExposureCompensationConverter(),
372
- "exposureDelay" to ExposureDelayConverter(),
373
- "exposureProgram" to ExposureProgramConverter(),
374
- "faceDetect" to FaceDetectConverter(),
375
- "fileFormat" to FileFormatConverter(),
376
- "filter" to FilterConverter(),
377
- "function" to FunctionConverter(),
378
- "gain" to GainConverter(),
379
- "gpsInfo" to GpsInfoConverter(),
380
- "imageStitching" to ImageStitchingConverter(),
381
- "isGpsOn" to IsGpsOnConverter(),
382
- "iso" to IsoConverter(),
383
- "isoAutoHighLimit" to IsoAutoHighLimitConverter(),
384
- "language" to LanguageConverter(),
385
- "maxRecordableTime" to MaxRecordableTimeConverter(),
386
- "networkType" to NetworkTypeConverter(),
387
- "offDelay" to OffDelayConverter(),
388
- "password" to PasswordConverter(),
389
- "powerSaving" to PowerSavingConverter(),
390
- "preset" to PresetConverter(),
391
- "previewFormat" to PreviewFormatConverter(),
392
- "proxy" to ProxyConverter(),
393
- "remainingPictures" to RemainingPicturesConverter(),
394
- "remainingVideoSeconds" to RemainingVideoSecondsConverter(),
395
- "remainingSpace" to RemainingSpaceConverter(),
396
- "shootingMethod" to ShootingMethodConverter(),
397
- "shutterSpeed" to ShutterSpeedConverter(),
398
- "shutterVolume" to ShutterVolumeConverter(),
399
- "sleepDelay" to SleepDelayConverter(),
400
- "timeShift" to TimeShiftConverter(),
401
- "totalSpace" to TotalSpaceConverter(),
402
- "username" to UsernameConverter(),
403
- "whiteBalance" to WhiteBalanceConverter(),
404
- "whiteBalanceAutoStrength" to WhiteBalanceAutoStrengthConverter(),
405
- "wlanFrequency" to WlanFrequencyConverter(),
406
- "_gpsTagRecording" to GpsTagRecordingConverter(),
407
- )
408
-
409
- /** OptionNameEnum to option */
410
- private val optionEnumToOption = mapOf(
411
- "AiAutoThumbnail" to "aiAutoThumbnail",
412
- "Aperture" to "aperture",
413
- "Bitrate" to "bitrate",
414
- "BluetoothPower" to "bluetoothPower",
415
- "BurstMode" to "burstMode",
416
- "BurstOption" to "burstOption",
417
- "CameraControlSource" to "cameraControlSource",
418
- "CameraMode" to "cameraMode",
419
- "CaptureInterval" to "captureInterval",
420
- "CaptureMode" to "captureMode",
421
- "CaptureNumber" to "captureNumber",
422
- "ColorTemperature" to "colorTemperature",
423
- "CompositeShootingOutputInterval" to "compositeShootingOutputInterval",
424
- "CompositeShootingTime" to "compositeShootingTime",
425
- "ContinuousNumber" to "continuousNumber",
426
- "DateTimeZone" to "dateTimeZone",
427
- "ExposureCompensation" to "exposureCompensation",
428
- "ExposureDelay" to "exposureDelay",
429
- "ExposureProgram" to "exposureProgram",
430
- "FaceDetect" to "faceDetect",
431
- "FileFormat" to "fileFormat",
432
- "Filter" to "filter",
433
- "Function" to "function",
434
- "Gain" to "gain",
435
- "GpsInfo" to "gpsInfo",
436
- "ImageStitching" to "imageStitching",
437
- "IsGpsOn" to "isGpsOn",
438
- "Iso" to "iso",
439
- "IsoAutoHighLimit" to "isoAutoHighLimit",
440
- "Language" to "language",
441
- "MaxRecordableTime" to "maxRecordableTime",
442
- "NetworkType" to "networkType",
443
- "OffDelay" to "offDelay",
444
- "Password" to "password",
445
- "PowerSaving" to "powerSaving",
446
- "Preset" to "preset",
447
- "PreviewFormat" to "previewFormat",
448
- "Proxy" to "proxy",
449
- "RemainingPictures" to "remainingPictures",
450
- "RemainingVideoSeconds" to "remainingVideoSeconds",
451
- "RemainingSpace" to "remainingSpace",
452
- "ShootingMethod" to "shootingMethod",
453
- "ShutterSpeed" to "shutterSpeed",
454
- "ShutterVolume" to "shutterVolume",
455
- "SleepDelay" to "sleepDelay",
456
- "TimeShift" to "timeShift",
457
- "TotalSpace" to "totalSpace",
458
- "Username" to "username",
459
- "WhiteBalance" to "whiteBalance",
460
- "WhiteBalanceAutoStrength" to "whiteBalanceAutoStrength",
461
- "WlanFrequency" to "wlanFrequency",
462
- )
463
-
464
370
  /**
465
371
  * getOptions - get options from THETA via repository
466
372
  * @param optionNames option name list to get
@@ -475,18 +381,8 @@ class ThetaClientReactNativeModule(
475
381
  }
476
382
  launch {
477
383
  try {
478
- val optionNameList = mutableListOf<ThetaRepository.OptionNameEnum>()
479
- for (index in 0..(optionNames.size() - 1)) {
480
- val option = optionNames.getString(index)
481
- optionNameList.add(ThetaRepository.OptionNameEnum.valueOf(option))
482
- }
483
- val options = theta.getOptions(optionNameList)
484
- val result = Arguments.createMap()
485
- for (index in 0..(optionNames.size() - 1)) {
486
- val option = optionEnumToOption[optionNames.getString(index)]
487
- val cvt = converters[option]
488
- cvt?.setFromTheta(options, result)
489
- }
384
+ val response = theta.getOptions(toGetOptionsParam(optionNames = optionNames))
385
+ val result = toResult(options = response)
490
386
  promise.resolve(result)
491
387
  } catch (t: Throwable) {
492
388
  promise.reject(t)
@@ -509,14 +405,8 @@ class ThetaClientReactNativeModule(
509
405
  }
510
406
  launch {
511
407
  try {
512
- val thetaOptions = ThetaRepository.Options()
513
- val iterator = options.keySetIterator()
514
- while (iterator.hasNextKey()) {
515
- val key = iterator.nextKey()
516
- val cvt = converters[key]
517
- cvt?.setToTheta(thetaOptions, options)
518
- }
519
- theta.setOptions(thetaOptions)
408
+ val params = toSetOptionsParam(optionsMap = options)
409
+ theta.setOptions(params)
520
410
  promise.resolve(true)
521
411
  } catch (t: Throwable) {
522
412
  promise.reject(t)
@@ -579,11 +469,12 @@ class ThetaClientReactNativeModule(
579
469
  */
580
470
  @ReactMethod
581
471
  fun getPhotoCaptureBuilder(promise: Promise) {
472
+ val theta = theta
582
473
  if (theta == null) {
583
474
  promise.reject(Exception(messageNotInit))
584
475
  return
585
476
  }
586
- photoCaptureBuilder = theta?.getPhotoCaptureBuilder()
477
+ photoCaptureBuilder = theta.getPhotoCaptureBuilder()
587
478
  promise.resolve(true)
588
479
  }
589
480
 
@@ -605,13 +496,11 @@ class ThetaClientReactNativeModule(
605
496
  }
606
497
  launch {
607
498
  try {
608
- val iterator = options.keySetIterator()
609
- while (iterator.hasNextKey()) {
610
- val key = iterator.nextKey()
611
- val cvt = converters[key]
612
- cvt?.setPhotoOption(options, photoCaptureBuilder!!)
499
+ photoCaptureBuilder?.let {
500
+ setCaptureBuilderParams(optionMap = options, builder = it)
501
+ setPhotoCaptureBuilderParams(optionMap = options, builder = it)
502
+ photoCapture = it.build()
613
503
  }
614
- photoCapture = photoCaptureBuilder!!.build()
615
504
  promise.resolve(true)
616
505
  photoCaptureBuilder = null
617
506
  } catch (t: Throwable) {
@@ -636,7 +525,7 @@ class ThetaClientReactNativeModule(
636
525
  return
637
526
  }
638
527
  class TakePictureCallback : PhotoCapture.TakePictureCallback {
639
- override fun onSuccess(fileUrl: String) {
528
+ override fun onSuccess(fileUrl: String?) {
640
529
  promise.resolve(fileUrl)
641
530
  photoCapture = null
642
531
  }
@@ -656,11 +545,12 @@ class ThetaClientReactNativeModule(
656
545
  */
657
546
  @ReactMethod
658
547
  fun getTimeShiftCaptureBuilder(promise: Promise) {
548
+ val theta = theta
659
549
  if (theta == null) {
660
550
  promise.reject(Exception(messageNotInit))
661
551
  return
662
552
  }
663
- timeShiftCaptureBuilder = theta?.getTimeShiftCaptureBuilder()
553
+ timeShiftCaptureBuilder = theta.getTimeShiftCaptureBuilder()
664
554
  promise.resolve(true)
665
555
  }
666
556
 
@@ -675,34 +565,23 @@ class ThetaClientReactNativeModule(
675
565
  promise.reject(Exception(messageNotInit))
676
566
  return
677
567
  }
678
-
679
- timeShiftCaptureBuilder?.let { builder ->
680
- launch {
681
- try {
682
- val iterator = options.keySetIterator()
683
- while (iterator.hasNextKey()) {
684
- val key = iterator.nextKey()
685
- val cvt = converters[key]
686
- cvt?.setTimeShiftOption(options, builder)
687
- }
688
-
689
- val interval = if (options.hasKey("_capture_interval")) options.getInt("_capture_interval") else null
690
- interval?.let {
691
- if (it >= 0) {
692
- builder.setCheckStatusCommandInterval(it.toLong())
693
- }
694
- }
695
-
696
- timeShiftCapture = builder.build()
697
- promise.resolve(true)
698
- timeShiftCaptureBuilder = null
699
- } catch (t: Throwable) {
700
- promise.reject(t)
701
- timeShiftCaptureBuilder = null
568
+ if (timeShiftCaptureBuilder == null) {
569
+ promise.reject(Exception("no timeShiftCaptureBuilder"))
570
+ return
571
+ }
572
+ launch {
573
+ try {
574
+ timeShiftCaptureBuilder?.let {
575
+ setCaptureBuilderParams(optionMap = options, builder = it)
576
+ setTimeShiftCaptureBuilderParams(optionMap = options, builder = it)
577
+ timeShiftCapture = it.build()
702
578
  }
579
+ promise.resolve(true)
580
+ timeShiftCaptureBuilder = null
581
+ } catch (t: Throwable) {
582
+ promise.reject(t)
583
+ timeShiftCaptureBuilder = null
703
584
  }
704
- } ?: run {
705
- promise.reject(Exception("no timeShiftCaptureBuilder"))
706
585
  }
707
586
  }
708
587
 
@@ -716,28 +595,37 @@ class ThetaClientReactNativeModule(
716
595
  promise.reject(Exception(messageNotInit))
717
596
  return
718
597
  }
719
- timeShiftCapture?.let { capture ->
720
- class StartCaptureCallback : TimeShiftCapture.StartCaptureCallback {
721
- override fun onSuccess(fileUrl: String?) {
722
- promise.resolve(fileUrl)
723
- timeShiftCapture = null
724
- }
598
+ if (timeShiftCapture == null) {
599
+ promise.reject(Exception("no timeShiftCapture"))
600
+ return
601
+ }
602
+ class StartCaptureCallback : TimeShiftCapture.StartCaptureCallback {
603
+ override fun onCaptureCompleted(fileUrl: String?) {
604
+ promise.resolve(fileUrl)
605
+ timeShiftCapture = null
606
+ }
725
607
 
726
- override fun onProgress(completion: Float) {
727
- sendNotifyEvent(
728
- toNotify(NOTIFY_TIMESHIFT_PROGRESS, toCaptureProgressNotifyParam(value = completion))
729
- )
730
- }
608
+ override fun onProgress(completion: Float) {
609
+ sendNotifyEvent(
610
+ toNotify(NOTIFY_TIMESHIFT_PROGRESS, toCaptureProgressNotifyParam(value = completion))
611
+ )
612
+ }
731
613
 
732
- override fun onError(exception: ThetaRepository.ThetaRepositoryException) {
733
- promise.reject(exception)
734
- timeShiftCapture = null
735
- }
614
+ override fun onCaptureFailed(exception: ThetaRepository.ThetaRepositoryException) {
615
+ promise.reject(exception)
616
+ timeShiftCapture = null
617
+ }
618
+
619
+ override fun onStopFailed(exception: ThetaRepository.ThetaRepositoryException) {
620
+ sendNotifyEvent(
621
+ toNotify(
622
+ NOTIFY_TIMESHIFT_STOP_ERROR,
623
+ toMessageNotifyParam(exception.message ?: exception.toString())
624
+ )
625
+ )
736
626
  }
737
- timeShiftCapturing = capture.startCapture(StartCaptureCallback())
738
- } ?: run {
739
- promise.reject(Exception("no timeShiftCapture"))
740
627
  }
628
+ timeShiftCapturing = timeShiftCapture?.startCapture(StartCaptureCallback())
741
629
  }
742
630
 
743
631
  /**
@@ -758,11 +646,12 @@ class ThetaClientReactNativeModule(
758
646
  */
759
647
  @ReactMethod
760
648
  fun getVideoCaptureBuilder(promise: Promise) {
649
+ val theta = theta
761
650
  if (theta == null) {
762
651
  promise.reject(Exception(messageNotInit))
763
652
  return
764
653
  }
765
- videoCaptureBuilder = theta?.getVideoCaptureBuilder()
654
+ videoCaptureBuilder = theta.getVideoCaptureBuilder()
766
655
  promise.resolve(true)
767
656
  }
768
657
 
@@ -783,13 +672,11 @@ class ThetaClientReactNativeModule(
783
672
  }
784
673
  launch {
785
674
  try {
786
- val iterator = options.keySetIterator()
787
- while (iterator.hasNextKey()) {
788
- val key = iterator.nextKey()
789
- val cvt = converters[key]
790
- cvt?.setVideoOption(options, videoCaptureBuilder!!)
675
+ videoCaptureBuilder?.let {
676
+ setCaptureBuilderParams(optionMap = options, builder = it)
677
+ setVideoCaptureBuilderParams(optionMap = options, builder = it)
678
+ videoCapture = it.build()
791
679
  }
792
- videoCapture = videoCaptureBuilder!!.build()
793
680
  promise.resolve(true)
794
681
  videoCaptureBuilder = null
795
682
  } catch (t: Throwable) {
@@ -835,7 +722,7 @@ class ThetaClientReactNativeModule(
835
722
  )
836
723
  }
837
724
  }
838
- videoCapturing = videoCapture!!.startCapture(StartCaptureCallback())
725
+ videoCapturing = videoCapture?.startCapture(StartCaptureCallback())
839
726
  }
840
727
 
841
728
  /**
@@ -849,6 +736,335 @@ class ThetaClientReactNativeModule(
849
736
  videoCapturing?.stopCapture()
850
737
  }
851
738
 
739
+ /**
740
+ * getLimitlessIntervalCaptureBuilder - get limitless interval capture builder
741
+ * @param promise promise to set result
742
+ */
743
+ @ReactMethod
744
+ fun getLimitlessIntervalCaptureBuilder(promise: Promise) {
745
+ val theta = theta
746
+ if (theta == null) {
747
+ promise.reject(Exception(messageNotInit))
748
+ return
749
+ }
750
+ limitlessIntervalCaptureBuilder = theta.getLimitlessIntervalCaptureBuilder()
751
+ promise.resolve(true)
752
+ }
753
+
754
+ /**
755
+ * buildLimitlessIntervalCapture - build limitless interval capture
756
+ * @param options option to capture limitless interval
757
+ * @param promise promise to set result
758
+ */
759
+ @ReactMethod
760
+ fun buildLimitlessIntervalCapture(options: ReadableMap, promise: Promise) {
761
+ if (theta == null) {
762
+ promise.reject(Exception(messageNotInit))
763
+ return
764
+ }
765
+ if (limitlessIntervalCaptureBuilder == null) {
766
+ promise.reject(Exception("no limitlessIntervalCaptureBuilder"))
767
+ return
768
+ }
769
+ launch {
770
+ try {
771
+ limitlessIntervalCaptureBuilder?.let {
772
+ setCaptureBuilderParams(optionMap = options, builder = it)
773
+ setLimitlessIntervalCaptureBuilderParams(optionMap = options, builder = it)
774
+ limitlessIntervalCapture = it.build()
775
+ }
776
+ promise.resolve(true)
777
+ limitlessIntervalCaptureBuilder = null
778
+ } catch (t: Throwable) {
779
+ promise.reject(t)
780
+ limitlessIntervalCaptureBuilder = null
781
+ }
782
+ }
783
+ }
784
+
785
+ /**
786
+ * startCapture - start capture limitless interval
787
+ * @param promise promise to set result
788
+ */
789
+ @ReactMethod
790
+ fun startLimitlessIntervalCapture(promise: Promise) {
791
+ if (theta == null) {
792
+ promise.reject(Exception(messageNotInit))
793
+ return
794
+ }
795
+ if (limitlessIntervalCapture == null) {
796
+ promise.reject(Exception("no limitlessIntervalCapture"))
797
+ return
798
+ }
799
+ class StartCaptureCallback : LimitlessIntervalCapture.StartCaptureCallback {
800
+ override fun onCaptureCompleted(fileUrls: List<String>?) {
801
+ promise.resolve(fileUrls?.let {
802
+ val resultList = Arguments.createArray()
803
+ it.forEach {
804
+ resultList.pushString(it)
805
+ }
806
+ resultList
807
+ })
808
+ limitlessIntervalCapture = null
809
+ limitlessIntervalCapturing = null
810
+ }
811
+
812
+ override fun onCaptureFailed(exception: ThetaRepository.ThetaRepositoryException) {
813
+ promise.reject(exception)
814
+ limitlessIntervalCapture = null
815
+ limitlessIntervalCapturing = null
816
+ }
817
+
818
+ override fun onStopFailed(exception: ThetaRepository.ThetaRepositoryException) {
819
+ sendNotifyEvent(
820
+ toNotify(
821
+ NOTIFY_LIMITLESS_INTERVAL_CAPTURE_STOP_ERROR,
822
+ toMessageNotifyParam(exception.message ?: exception.toString())
823
+ )
824
+ )
825
+ }
826
+ }
827
+ limitlessIntervalCapturing = limitlessIntervalCapture?.startCapture(StartCaptureCallback())
828
+ }
829
+
830
+ /**
831
+ * stopCapture - stop capturing limitless interval
832
+ */
833
+ @ReactMethod
834
+ fun stopLimitlessIntervalCapture() {
835
+ if (theta == null) {
836
+ throw Exception(messageNotInit)
837
+ }
838
+ limitlessIntervalCapturing?.stopCapture()
839
+ }
840
+
841
+ /**
842
+ * getShotCountSpecifiedIntervalCaptureBuilder - get interval shooting with the shot count specified builder from repository
843
+ * @param shotCount shotCount shot count specified
844
+ * @param promise Promise for getShotCountSpecifiedIntervalCaptureBuilder
845
+ */
846
+ @ReactMethod
847
+ fun getShotCountSpecifiedIntervalCaptureBuilder(shotCount: Int, promise: Promise) {
848
+ val theta = theta
849
+ if (theta == null) {
850
+ promise.reject(Exception(messageNotInit))
851
+ return
852
+ }
853
+ shotCountSpecifiedIntervalCaptureBuilder = theta.getShotCountSpecifiedIntervalCaptureBuilder(shotCount)
854
+ promise.resolve(true)
855
+ }
856
+
857
+ /**
858
+ * buildShotCountSpecifiedIntervalCapture - build interval shooting with the shot count specified
859
+ * @param options option to execute interval shooting with the shot count specified
860
+ * @param promise Promise for buildShotCountSpecifiedIntervalCapture
861
+ */
862
+ @ReactMethod
863
+ fun buildShotCountSpecifiedIntervalCapture(options: ReadableMap, promise: Promise) {
864
+ if (theta == null) {
865
+ promise.reject(Exception(messageNotInit))
866
+ return
867
+ }
868
+ if (shotCountSpecifiedIntervalCaptureBuilder == null) {
869
+ promise.reject(Exception("no shotCountSpecifiedIntervalCaptureBuilder"))
870
+ return
871
+ }
872
+ launch {
873
+ try {
874
+ shotCountSpecifiedIntervalCaptureBuilder?.let {
875
+ setCaptureBuilderParams(optionMap = options, builder = it)
876
+ setShotCountSpecifiedIntervalCaptureBuilderParams(optionMap = options, builder = it)
877
+ shotCountSpecifiedIntervalCapture = it.build()
878
+ }
879
+ promise.resolve(true)
880
+ shotCountSpecifiedIntervalCaptureBuilder = null
881
+ } catch (t: Throwable) {
882
+ promise.reject(t)
883
+ shotCountSpecifiedIntervalCaptureBuilder = null
884
+ }
885
+ }
886
+ }
887
+
888
+ /**
889
+ * startShotCountSpecifiedIntervalCapture - start interval shooting with the shot count specified
890
+ * @param promise promise for startShotCountSpecifiedIntervalCapture
891
+ */
892
+ @ReactMethod
893
+ fun startShotCountSpecifiedIntervalCapture(promise: Promise) {
894
+ if (theta == null) {
895
+ promise.reject(Exception(messageNotInit))
896
+ return
897
+ }
898
+ if (shotCountSpecifiedIntervalCapture == null) {
899
+ promise.reject(Exception("no shotCountSpecifiedIntervalCapture"))
900
+ return
901
+ }
902
+ class StartCaptureCallback : ShotCountSpecifiedIntervalCapture.StartCaptureCallback {
903
+ override fun onCaptureCompleted(fileUrls: List<String>?) {
904
+ promise.resolve(fileUrls?.let {
905
+ val resultList = Arguments.createArray()
906
+ it.forEach {
907
+ resultList.pushString(it)
908
+ }
909
+ resultList
910
+ })
911
+ shotCountSpecifiedIntervalCapture = null
912
+ }
913
+
914
+ override fun onProgress(completion: Float) {
915
+ sendNotifyEvent(
916
+ toNotify(
917
+ NOTIFY_SHOT_COUNT_SPECIFIED_INTERVAL_PROGRESS,
918
+ toCaptureProgressNotifyParam(value = completion)
919
+ )
920
+ )
921
+ }
922
+
923
+ override fun onStopFailed(exception: ThetaRepository.ThetaRepositoryException) {
924
+ sendNotifyEvent(
925
+ toNotify(
926
+ NOTIFY_SHOT_COUNT_SPECIFIED_INTERVAL_STOP_ERROR,
927
+ toMessageNotifyParam(exception.message ?: exception.toString())
928
+ )
929
+ )
930
+ }
931
+
932
+ override fun onCaptureFailed(exception: ThetaRepository.ThetaRepositoryException) {
933
+ promise.reject(exception)
934
+ shotCountSpecifiedIntervalCapture = null
935
+ }
936
+ }
937
+ shotCountSpecifiedIntervalCapturing =
938
+ shotCountSpecifiedIntervalCapture?.startCapture(StartCaptureCallback())
939
+ }
940
+
941
+ /**
942
+ * cancelShotCountSpecifiedIntervalCapture - stop interval shooting with the shot count specified
943
+ * @param promise promise for cancelShotCountSpecifiedIntervalCapture
944
+ */
945
+ @ReactMethod
946
+ fun cancelShotCountSpecifiedIntervalCapture(promise: Promise) {
947
+ if (theta == null) {
948
+ promise.reject(Exception(messageNotInit))
949
+ return
950
+ }
951
+ shotCountSpecifiedIntervalCapturing?.cancelCapture()
952
+ promise.resolve(true)
953
+ }
954
+
955
+ /**
956
+ * getCompositeIntervalCaptureBuilder - get interval composite shooting builder from repository
957
+ * @param shootingTimeSec Shooting time for interval composite shooting (sec)
958
+ * @param promise Promise for getCompositeIntervalCaptureBuilder
959
+ */
960
+ @ReactMethod
961
+ fun getCompositeIntervalCaptureBuilder(shootingTimeSec: Int, promise: Promise) {
962
+ val theta = theta
963
+ if (theta == null) {
964
+ promise.reject(Exception(messageNotInit))
965
+ return
966
+ }
967
+ compositeIntervalCaptureBuilder = theta.getCompositeIntervalCaptureBuilder(shootingTimeSec)
968
+ promise.resolve(true)
969
+ }
970
+
971
+ /**
972
+ * buildCompositeIntervalCapture - build interval composite shooting
973
+ * @param options option to execute interval shooting with the shot count specified
974
+ * @param promise Promise for buildCompositeIntervalCapture
975
+ */
976
+ @ReactMethod
977
+ fun buildCompositeIntervalCapture(options: ReadableMap, promise: Promise) {
978
+ if (theta == null) {
979
+ promise.reject(Exception(messageNotInit))
980
+ return
981
+ }
982
+ if (compositeIntervalCaptureBuilder == null) {
983
+ promise.reject(Exception("no compositeIntervalCaptureBuilder"))
984
+ return
985
+ }
986
+ launch {
987
+ try {
988
+ compositeIntervalCaptureBuilder?.let {
989
+ setCaptureBuilderParams(optionMap = options, builder = it)
990
+ setCompositeIntervalCaptureBuilderParams(optionMap = options, builder = it)
991
+ compositeIntervalCapture = it.build()
992
+ }
993
+ promise.resolve(true)
994
+ compositeIntervalCaptureBuilder = null
995
+ } catch (t: Throwable) {
996
+ promise.reject(t)
997
+ compositeIntervalCaptureBuilder = null
998
+ }
999
+ }
1000
+ }
1001
+
1002
+ /**
1003
+ * startCompositeIntervalCapture - start interval composite shooting
1004
+ * @param promise promise for startCompositeIntervalCapture
1005
+ */
1006
+ @ReactMethod
1007
+ fun startCompositeIntervalCapture(promise: Promise) {
1008
+ if (theta == null) {
1009
+ promise.reject(Exception(messageNotInit))
1010
+ return
1011
+ }
1012
+ if (compositeIntervalCapture == null) {
1013
+ promise.reject(Exception("no compositeIntervalCapture"))
1014
+ return
1015
+ }
1016
+ class StartCaptureCallback : CompositeIntervalCapture.StartCaptureCallback {
1017
+ override fun onCaptureCompleted(fileUrls: List<String>?) {
1018
+ promise.resolve(fileUrls?.let {
1019
+ val resultList = Arguments.createArray()
1020
+ it.forEach {
1021
+ resultList.pushString(it)
1022
+ }
1023
+ resultList
1024
+ })
1025
+ compositeIntervalCapture = null
1026
+ }
1027
+
1028
+ override fun onProgress(completion: Float) {
1029
+ sendNotifyEvent(
1030
+ toNotify(
1031
+ NOTIFY_COMPOSITE_INTERVAL_PROGRESS,
1032
+ toCaptureProgressNotifyParam(value = completion)
1033
+ )
1034
+ )
1035
+ }
1036
+
1037
+ override fun onStopFailed(exception: ThetaRepository.ThetaRepositoryException) {
1038
+ sendNotifyEvent(
1039
+ toNotify(
1040
+ NOTIFY_COMPOSITE_INTERVAL_STOP_ERROR,
1041
+ toMessageNotifyParam(exception.message ?: exception.toString())
1042
+ )
1043
+ )
1044
+ }
1045
+
1046
+ override fun onCaptureFailed(exception: ThetaRepository.ThetaRepositoryException) {
1047
+ promise.reject(exception)
1048
+ compositeIntervalCapture = null
1049
+ }
1050
+ }
1051
+ compositeIntervalCapturing = compositeIntervalCapture?.startCapture(StartCaptureCallback())
1052
+ }
1053
+
1054
+ /**
1055
+ * cancelCompositeIntervalCapture - stop interval composite shooting
1056
+ * @param promise promise for cancelCompositeIntervalCapture
1057
+ */
1058
+ @ReactMethod
1059
+ fun cancelCompositeIntervalCapture(promise: Promise) {
1060
+ if (theta == null) {
1061
+ promise.reject(Exception(messageNotInit))
1062
+ return
1063
+ }
1064
+ compositeIntervalCapturing?.cancelCapture()
1065
+ promise.resolve(true)
1066
+ }
1067
+
852
1068
  /**
853
1069
  * getMetadata - retrieve meta data from THETA via repository
854
1070
  * @param promise promise to set result
@@ -1036,29 +1252,8 @@ class ThetaClientReactNativeModule(
1036
1252
  }
1037
1253
  launch {
1038
1254
  try {
1039
- val result = Arguments.createArray()
1040
- theta.listAccessPoints().forEach {
1041
- val apinfo = Arguments.createMap()
1042
- apinfo.putString("ssid", it.ssid)
1043
- apinfo.putBoolean("ssidStealth", it.ssidStealth)
1044
- apinfo.putString("authMode", it.authMode.toString())
1045
- apinfo.putInt("connectionPriority", it.connectionPriority)
1046
- apinfo.putBoolean("usingDhcp", it.usingDhcp)
1047
- apinfo.putString("ipAddress", it.ipAddress)
1048
- apinfo.putString("subnetMask", it.subnetMask)
1049
- apinfo.putString("defaultGateway", it.defaultGateway)
1050
-
1051
- it.proxy?.let { proxy ->
1052
- var options = ThetaRepository.Options(proxy = proxy)
1053
- val optionsMap = Arguments.createMap()
1054
- val cvt = converters["proxy"]
1055
- cvt?.setFromTheta(options, optionsMap)
1056
- apinfo.putMap("proxy", optionsMap.getMap("proxy"))
1057
- }
1058
-
1059
- result.pushMap(apinfo)
1060
- }
1061
- promise.resolve(result)
1255
+ val response = theta.listAccessPoints()
1256
+ promise.resolve(toListAccessPointsResult(accessPointList = response))
1062
1257
  } catch (t: Throwable) {
1063
1258
  promise.reject(t)
1064
1259
  }
@@ -1098,7 +1293,7 @@ class ThetaClientReactNativeModule(
1098
1293
  ThetaRepository.AuthModeEnum.valueOf(authMode),
1099
1294
  password,
1100
1295
  connectionPriority,
1101
- convertMapToProxy(proxyMap = proxy)
1296
+ toProxy(map = proxy)
1102
1297
  )
1103
1298
  promise.resolve(true)
1104
1299
  } catch (t: Throwable) {
@@ -1149,7 +1344,7 @@ class ThetaClientReactNativeModule(
1149
1344
  ipAddress,
1150
1345
  subnetMask,
1151
1346
  defaultGateway,
1152
- convertMapToProxy(proxyMap = proxy)
1347
+ toProxy(map = proxy)
1153
1348
  )
1154
1349
  promise.resolve(true)
1155
1350
  } catch (t: Throwable) {
@@ -1180,20 +1375,6 @@ class ThetaClientReactNativeModule(
1180
1375
  }
1181
1376
  }
1182
1377
 
1183
- /**
1184
- * convert ReadableMap to ThetaRepository.Proxy
1185
- */
1186
- private fun convertMapToProxy(proxyMap: ReadableMap?): ThetaRepository.Proxy? {
1187
- return proxyMap?.let {
1188
- var options = ThetaRepository.Options()
1189
- val optionsMap = Arguments.createMap()
1190
- optionsMap.putMap("proxy", it)
1191
- val cvt = converters["proxy"]
1192
- cvt?.setToTheta(options, optionsMap)
1193
- options.proxy
1194
- } ?: null
1195
- }
1196
-
1197
1378
  /**
1198
1379
  * setBluetoothDevice - register uuid of a BLE device
1199
1380
  * @param uuid uuid to set
@@ -1232,12 +1413,7 @@ class ThetaClientReactNativeModule(
1232
1413
  launch {
1233
1414
  try {
1234
1415
  val options = theta.getMySetting(ThetaRepository.CaptureModeEnum.valueOf(captureMode))
1235
- val result = Arguments.createMap()
1236
- converters.forEach {
1237
- val cvt = it.value
1238
- cvt?.setFromTheta(options, result)
1239
- }
1240
- promise.resolve(result)
1416
+ promise.resolve(toResult(options = options))
1241
1417
  } catch (t: Throwable) {
1242
1418
  promise.reject(t)
1243
1419
  }
@@ -1265,13 +1441,7 @@ class ThetaClientReactNativeModule(
1265
1441
  optionNameList.add(ThetaRepository.OptionNameEnum.valueOf(option))
1266
1442
  }
1267
1443
  val options = theta.getMySetting(optionNameList)
1268
- val result = Arguments.createMap()
1269
- for (index in 0..(optionNames.size() - 1)) {
1270
- val option = optionEnumToOption[optionNames.getString(index)]
1271
- val cvt = converters[option]
1272
- cvt?.setFromTheta(options, result)
1273
- }
1274
- promise.resolve(result)
1444
+ promise.resolve(toResult(options = options))
1275
1445
  } catch (t: Throwable) {
1276
1446
  promise.reject(t)
1277
1447
  }
@@ -1293,13 +1463,7 @@ class ThetaClientReactNativeModule(
1293
1463
  }
1294
1464
  launch {
1295
1465
  try {
1296
- val thetaOptions = ThetaRepository.Options()
1297
- val iterator = options.keySetIterator()
1298
- while (iterator.hasNextKey()) {
1299
- val key = iterator.nextKey()
1300
- val cvt = converters[key]
1301
- cvt?.setToTheta(thetaOptions, options)
1302
- }
1466
+ val thetaOptions = toSetOptionsParam(optionsMap = options)
1303
1467
  theta.setMySetting(ThetaRepository.CaptureModeEnum.valueOf(captureMode), thetaOptions)
1304
1468
  promise.resolve(true)
1305
1469
  } catch (t: Throwable) {
@@ -1509,6 +1673,12 @@ class ThetaClientReactNativeModule(
1509
1673
  const val EVENT_NAME = "ThetaFrameEvent"
1510
1674
  const val EVENT_NOTIFY = "ThetaNotify"
1511
1675
  const val NOTIFY_TIMESHIFT_PROGRESS = "TIME-SHIFT-PROGRESS"
1676
+ const val NOTIFY_TIMESHIFT_STOP_ERROR = "TIME-SHIFT-STOP-ERROR"
1512
1677
  const val NOTIFY_VIDEO_CAPTURE_STOP_ERROR = "VIDEO-CAPTURE-STOP-ERROR"
1678
+ const val NOTIFY_LIMITLESS_INTERVAL_CAPTURE_STOP_ERROR = "LIMITLESS-INTERVAL-CAPTURE-STOP-ERROR"
1679
+ const val NOTIFY_SHOT_COUNT_SPECIFIED_INTERVAL_PROGRESS = "SHOT-COUNT-SPECIFIED-INTERVAL-PROGRESS"
1680
+ const val NOTIFY_SHOT_COUNT_SPECIFIED_INTERVAL_STOP_ERROR = "SHOT-COUNT-SPECIFIED-INTERVAL-STOP-ERROR"
1681
+ const val NOTIFY_COMPOSITE_INTERVAL_PROGRESS = "COMPOSITE-INTERVAL-PROGRESS"
1682
+ const val NOTIFY_COMPOSITE_INTERVAL_STOP_ERROR = "COMPOSITE-INTERVAL-STOP-ERROR"
1513
1683
  }
1514
1684
  }