theta-client-react-native 1.3.1 → 1.5.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 (154) hide show
  1. package/android/build.gradle +1 -1
  2. package/android/src/main/java/com/ricoh360/thetaclientreactnative/Converter.kt +441 -1035
  3. package/android/src/main/java/com/ricoh360/thetaclientreactnative/ThetaClientSdkModule.kt +327 -251
  4. package/ios/ConvertUtil.swift +1053 -0
  5. package/ios/ThetaClientReactNative-Bridging-Header.h +3 -0
  6. package/ios/ThetaClientReactNative.m +228 -0
  7. package/ios/ThetaClientReactNative.swift +1608 -0
  8. package/ios/ThetaClientReactNative.xcodeproj/project.pbxproj +15 -57
  9. package/lib/commonjs/capture/index.js +22 -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 +26 -3
  14. package/lib/commonjs/capture/photo-capture.js.map +1 -1
  15. package/lib/commonjs/capture/shot-count-specified-interval-capture.js +112 -0
  16. package/lib/commonjs/capture/shot-count-specified-interval-capture.js.map +1 -0
  17. package/lib/commonjs/capture/time-shift-capture.js +27 -23
  18. package/lib/commonjs/capture/time-shift-capture.js.map +1 -1
  19. package/lib/commonjs/capture/video-capture.js +33 -5
  20. package/lib/commonjs/capture/video-capture.js.map +1 -1
  21. package/lib/commonjs/index.js.map +1 -1
  22. package/lib/commonjs/theta-repository/notify-controller.js +40 -0
  23. package/lib/commonjs/theta-repository/notify-controller.js.map +1 -0
  24. package/lib/commonjs/theta-repository/options/index.js +88 -0
  25. package/lib/commonjs/theta-repository/options/index.js.map +1 -1
  26. package/lib/commonjs/theta-repository/options/option-face-detect.js +22 -0
  27. package/lib/commonjs/theta-repository/options/option-face-detect.js.map +1 -0
  28. package/lib/commonjs/theta-repository/options/option-function.js +27 -0
  29. package/lib/commonjs/theta-repository/options/option-function.js.map +1 -0
  30. package/lib/commonjs/theta-repository/options/option-gain.js +26 -0
  31. package/lib/commonjs/theta-repository/options/option-gain.js.map +1 -0
  32. package/lib/commonjs/theta-repository/options/option-image-stitching.js +38 -0
  33. package/lib/commonjs/theta-repository/options/option-image-stitching.js.map +1 -0
  34. package/lib/commonjs/theta-repository/options/option-top-bottom-correction-rotation.js +2 -0
  35. package/lib/commonjs/theta-repository/options/option-top-bottom-correction-rotation.js.map +1 -0
  36. package/lib/commonjs/theta-repository/options/option-top-bottom-correction.js +52 -0
  37. package/lib/commonjs/theta-repository/options/option-top-bottom-correction.js.map +1 -0
  38. package/lib/commonjs/theta-repository/options/option-video-stitching.js +24 -0
  39. package/lib/commonjs/theta-repository/options/option-video-stitching.js.map +1 -0
  40. package/lib/commonjs/theta-repository/options/option-visibility-reduction.js +23 -0
  41. package/lib/commonjs/theta-repository/options/option-visibility-reduction.js.map +1 -0
  42. package/lib/commonjs/theta-repository/options/options.js +18 -0
  43. package/lib/commonjs/theta-repository/options/options.js.map +1 -1
  44. package/lib/commonjs/theta-repository/theta-repository.js +26 -4
  45. package/lib/commonjs/theta-repository/theta-repository.js.map +1 -1
  46. package/lib/commonjs/theta-repository/theta-state.js +1 -13
  47. package/lib/commonjs/theta-repository/theta-state.js.map +1 -1
  48. package/lib/module/capture/index.js +2 -0
  49. package/lib/module/capture/index.js.map +1 -1
  50. package/lib/module/capture/limitless-interval-capture.js +81 -0
  51. package/lib/module/capture/limitless-interval-capture.js.map +1 -0
  52. package/lib/module/capture/photo-capture.js +26 -3
  53. package/lib/module/capture/photo-capture.js.map +1 -1
  54. package/lib/module/capture/shot-count-specified-interval-capture.js +104 -0
  55. package/lib/module/capture/shot-count-specified-interval-capture.js.map +1 -0
  56. package/lib/module/capture/time-shift-capture.js +27 -23
  57. package/lib/module/capture/time-shift-capture.js.map +1 -1
  58. package/lib/module/capture/video-capture.js +33 -5
  59. package/lib/module/capture/video-capture.js.map +1 -1
  60. package/lib/module/index.js.map +1 -1
  61. package/lib/module/theta-repository/notify-controller.js +33 -0
  62. package/lib/module/theta-repository/notify-controller.js.map +1 -0
  63. package/lib/module/theta-repository/options/index.js +8 -0
  64. package/lib/module/theta-repository/options/index.js.map +1 -1
  65. package/lib/module/theta-repository/options/option-face-detect.js +15 -0
  66. package/lib/module/theta-repository/options/option-face-detect.js.map +1 -0
  67. package/lib/module/theta-repository/options/option-function.js +20 -0
  68. package/lib/module/theta-repository/options/option-function.js.map +1 -0
  69. package/lib/module/theta-repository/options/option-gain.js +19 -0
  70. package/lib/module/theta-repository/options/option-gain.js.map +1 -0
  71. package/lib/module/theta-repository/options/option-image-stitching.js +31 -0
  72. package/lib/module/theta-repository/options/option-image-stitching.js.map +1 -0
  73. package/lib/module/theta-repository/options/option-top-bottom-correction-rotation.js +2 -0
  74. package/lib/module/theta-repository/options/option-top-bottom-correction-rotation.js.map +1 -0
  75. package/lib/module/theta-repository/options/option-top-bottom-correction.js +45 -0
  76. package/lib/module/theta-repository/options/option-top-bottom-correction.js.map +1 -0
  77. package/lib/module/theta-repository/options/option-video-stitching.js +17 -0
  78. package/lib/module/theta-repository/options/option-video-stitching.js.map +1 -0
  79. package/lib/module/theta-repository/options/option-visibility-reduction.js +16 -0
  80. package/lib/module/theta-repository/options/option-visibility-reduction.js.map +1 -0
  81. package/lib/module/theta-repository/options/options.js +18 -0
  82. package/lib/module/theta-repository/options/options.js.map +1 -1
  83. package/lib/module/theta-repository/theta-repository.js +25 -5
  84. package/lib/module/theta-repository/theta-repository.js.map +1 -1
  85. package/lib/module/theta-repository/theta-state.js +0 -12
  86. package/lib/module/theta-repository/theta-state.js.map +1 -1
  87. package/lib/typescript/capture/index.d.ts +2 -0
  88. package/lib/typescript/capture/index.d.ts.map +1 -1
  89. package/lib/typescript/capture/limitless-interval-capture.d.ts +40 -0
  90. package/lib/typescript/capture/limitless-interval-capture.d.ts.map +1 -0
  91. package/lib/typescript/capture/photo-capture.d.ts +8 -2
  92. package/lib/typescript/capture/photo-capture.d.ts.map +1 -1
  93. package/lib/typescript/capture/shot-count-specified-interval-capture.d.ts +47 -0
  94. package/lib/typescript/capture/shot-count-specified-interval-capture.d.ts.map +1 -0
  95. package/lib/typescript/capture/time-shift-capture.d.ts +4 -7
  96. package/lib/typescript/capture/time-shift-capture.d.ts.map +1 -1
  97. package/lib/typescript/capture/video-capture.d.ts +5 -1
  98. package/lib/typescript/capture/video-capture.d.ts.map +1 -1
  99. package/lib/typescript/theta-repository/notify-controller.d.ts +17 -0
  100. package/lib/typescript/theta-repository/notify-controller.d.ts.map +1 -0
  101. package/lib/typescript/theta-repository/options/index.d.ts +8 -0
  102. package/lib/typescript/theta-repository/options/index.d.ts.map +1 -1
  103. package/lib/typescript/theta-repository/options/option-face-detect.d.ts +15 -0
  104. package/lib/typescript/theta-repository/options/option-face-detect.d.ts.map +1 -0
  105. package/lib/typescript/theta-repository/options/option-function.d.ts +20 -0
  106. package/lib/typescript/theta-repository/options/option-function.d.ts.map +1 -0
  107. package/lib/typescript/theta-repository/options/option-gain.d.ts +19 -0
  108. package/lib/typescript/theta-repository/options/option-gain.d.ts.map +1 -0
  109. package/lib/typescript/theta-repository/options/option-image-stitching.d.ts +30 -0
  110. package/lib/typescript/theta-repository/options/option-image-stitching.d.ts.map +1 -0
  111. package/lib/typescript/theta-repository/options/option-top-bottom-correction-rotation.d.ts +22 -0
  112. package/lib/typescript/theta-repository/options/option-top-bottom-correction-rotation.d.ts.map +1 -0
  113. package/lib/typescript/theta-repository/options/option-top-bottom-correction.d.ts +45 -0
  114. package/lib/typescript/theta-repository/options/option-top-bottom-correction.d.ts.map +1 -0
  115. package/lib/typescript/theta-repository/options/option-video-stitching.d.ts +17 -0
  116. package/lib/typescript/theta-repository/options/option-video-stitching.d.ts.map +1 -0
  117. package/lib/typescript/theta-repository/options/option-visibility-reduction.d.ts +16 -0
  118. package/lib/typescript/theta-repository/options/option-visibility-reduction.d.ts.map +1 -0
  119. package/lib/typescript/theta-repository/options/options.d.ts +47 -0
  120. package/lib/typescript/theta-repository/options/options.d.ts.map +1 -1
  121. package/lib/typescript/theta-repository/theta-repository.d.ts +17 -2
  122. package/lib/typescript/theta-repository/theta-repository.d.ts.map +1 -1
  123. package/lib/typescript/theta-repository/theta-state.d.ts +2 -12
  124. package/lib/typescript/theta-repository/theta-state.d.ts.map +1 -1
  125. package/package.json +17 -9
  126. package/src/capture/index.ts +2 -0
  127. package/src/capture/limitless-interval-capture.ts +99 -0
  128. package/src/capture/photo-capture.ts +27 -5
  129. package/src/capture/shot-count-specified-interval-capture.ts +146 -0
  130. package/src/capture/time-shift-capture.ts +40 -33
  131. package/src/capture/video-capture.ts +49 -6
  132. package/src/theta-repository/notify-controller.ts +50 -0
  133. package/src/theta-repository/options/index.ts +8 -0
  134. package/src/theta-repository/options/option-face-detect.ts +16 -0
  135. package/src/theta-repository/options/option-function.ts +21 -0
  136. package/src/theta-repository/options/option-gain.ts +19 -0
  137. package/src/theta-repository/options/option-image-stitching.ts +32 -0
  138. package/src/theta-repository/options/option-top-bottom-correction-rotation.ts +21 -0
  139. package/src/theta-repository/options/option-top-bottom-correction.ts +46 -0
  140. package/src/theta-repository/options/option-video-stitching.ts +18 -0
  141. package/src/theta-repository/options/option-visibility-reduction.ts +17 -0
  142. package/src/theta-repository/options/options.ts +47 -0
  143. package/src/theta-repository/theta-repository.ts +29 -4
  144. package/src/theta-repository/theta-state.ts +3 -15
  145. package/theta-client-react-native.podspec +2 -2
  146. package/ios/ThetaClientReactNative.h +0 -34
  147. package/ios/ThetaClientReactNative.mm +0 -4087
  148. package/lib/commonjs/capture/notify.js +0 -12
  149. package/lib/commonjs/capture/notify.js.map +0 -1
  150. package/lib/module/capture/notify.js +0 -6
  151. package/lib/module/capture/notify.js.map +0 -1
  152. package/lib/typescript/capture/notify.d.ts +0 -13
  153. package/lib/typescript/capture/notify.d.ts.map +0 -1
  154. package/src/capture/notify.ts +0 -27
@@ -29,6 +29,12 @@ class ThetaClientReactNativeModule(
29
29
  var videoCaptureBuilder: VideoCapture.Builder? = null
30
30
  var videoCapture: VideoCapture? = null
31
31
  var videoCapturing: VideoCapturing? = null
32
+ var limitlessIntervalCaptureBuilder: LimitlessIntervalCapture.Builder? = null
33
+ var limitlessIntervalCapture: LimitlessIntervalCapture? = null
34
+ var limitlessIntervalCapturing: LimitlessIntervalCapturing? = null
35
+ var shotCountSpecifiedIntervalCaptureBuilder: ShotCountSpecifiedIntervalCapture.Builder? = null
36
+ var shotCountSpecifiedIntervalCapture: ShotCountSpecifiedIntervalCapture? = null
37
+ var shotCountSpecifiedIntervalCapturing: ShotCountSpecifiedIntervalCapturing? = null
32
38
  var theta: ThetaRepository? = null
33
39
  var listenerCount: Int = 0
34
40
 
@@ -85,6 +91,12 @@ class ThetaClientReactNativeModule(
85
91
  videoCaptureBuilder = null
86
92
  videoCapture = null
87
93
  videoCapturing = null
94
+ limitlessIntervalCaptureBuilder = null
95
+ limitlessIntervalCapture = null
96
+ limitlessIntervalCapturing = null
97
+ shotCountSpecifiedIntervalCaptureBuilder = null
98
+ shotCountSpecifiedIntervalCapture = null
99
+ shotCountSpecifiedIntervalCapturing = null
88
100
 
89
101
  theta = ThetaRepository.newInstance(
90
102
  endpoint,
@@ -249,7 +261,7 @@ class ThetaClientReactNativeModule(
249
261
  )
250
262
  val resultList = Arguments.createArray()
251
263
  fileList.forEach {
252
- resultList.pushMap(fileInfoFromTheta(it))
264
+ resultList.pushMap(toResult(fileInfo = it))
253
265
  }
254
266
  val resultMap = Arguments.createMap()
255
267
  resultMap.putArray("fileList", resultList)
@@ -350,109 +362,6 @@ class ThetaClientReactNativeModule(
350
362
  }
351
363
  }
352
364
 
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
- "fileFormat" to FileFormatConverter(),
375
- "filter" to FilterConverter(),
376
- "gpsInfo" to GpsInfoConverter(),
377
- "isGpsOn" to IsGpsOnConverter(),
378
- "iso" to IsoConverter(),
379
- "isoAutoHighLimit" to IsoAutoHighLimitConverter(),
380
- "language" to LanguageConverter(),
381
- "maxRecordableTime" to MaxRecordableTimeConverter(),
382
- "networkType" to NetworkTypeConverter(),
383
- "offDelay" to OffDelayConverter(),
384
- "password" to PasswordConverter(),
385
- "powerSaving" to PowerSavingConverter(),
386
- "preset" to PresetConverter(),
387
- "previewFormat" to PreviewFormatConverter(),
388
- "proxy" to ProxyConverter(),
389
- "remainingPictures" to RemainingPicturesConverter(),
390
- "remainingVideoSeconds" to RemainingVideoSecondsConverter(),
391
- "remainingSpace" to RemainingSpaceConverter(),
392
- "shootingMethod" to ShootingMethodConverter(),
393
- "shutterSpeed" to ShutterSpeedConverter(),
394
- "shutterVolume" to ShutterVolumeConverter(),
395
- "sleepDelay" to SleepDelayConverter(),
396
- "timeShift" to TimeShiftConverter(),
397
- "totalSpace" to TotalSpaceConverter(),
398
- "username" to UsernameConverter(),
399
- "whiteBalance" to WhiteBalanceConverter(),
400
- "whiteBalanceAutoStrength" to WhiteBalanceAutoStrengthConverter(),
401
- "wlanFrequency" to WlanFrequencyConverter(),
402
- "_gpsTagRecording" to GpsTagRecordingConverter(),
403
- )
404
-
405
- /** OptionNameEnum to option */
406
- private val optionEnumToOption = mapOf(
407
- "AiAutoThumbnail" to "aiAutoThumbnail",
408
- "Aperture" to "aperture",
409
- "Bitrate" to "bitrate",
410
- "BluetoothPower" to "bluetoothPower",
411
- "BurstMode" to "burstMode",
412
- "BurstOption" to "burstOption",
413
- "CameraControlSource" to "cameraControlSource",
414
- "CameraMode" to "cameraMode",
415
- "CaptureInterval" to "captureInterval",
416
- "CaptureMode" to "captureMode",
417
- "CaptureNumber" to "captureNumber",
418
- "ColorTemperature" to "colorTemperature",
419
- "CompositeShootingOutputInterval" to "compositeShootingOutputInterval",
420
- "CompositeShootingTime" to "compositeShootingTime",
421
- "ContinuousNumber" to "continuousNumber",
422
- "DateTimeZone" to "dateTimeZone",
423
- "ExposureCompensation" to "exposureCompensation",
424
- "ExposureDelay" to "exposureDelay",
425
- "ExposureProgram" to "exposureProgram",
426
- "FileFormat" to "fileFormat",
427
- "Filter" to "filter",
428
- "GpsInfo" to "gpsInfo",
429
- "IsGpsOn" to "isGpsOn",
430
- "Iso" to "iso",
431
- "IsoAutoHighLimit" to "isoAutoHighLimit",
432
- "Language" to "language",
433
- "MaxRecordableTime" to "maxRecordableTime",
434
- "NetworkType" to "networkType",
435
- "OffDelay" to "offDelay",
436
- "Password" to "password",
437
- "PowerSaving" to "powerSaving",
438
- "Preset" to "preset",
439
- "PreviewFormat" to "previewFormat",
440
- "Proxy" to "proxy",
441
- "RemainingPictures" to "remainingPictures",
442
- "RemainingVideoSeconds" to "remainingVideoSeconds",
443
- "RemainingSpace" to "remainingSpace",
444
- "ShootingMethod" to "shootingMethod",
445
- "ShutterSpeed" to "shutterSpeed",
446
- "ShutterVolume" to "shutterVolume",
447
- "SleepDelay" to "sleepDelay",
448
- "TimeShift" to "timeShift",
449
- "TotalSpace" to "totalSpace",
450
- "Username" to "username",
451
- "WhiteBalance" to "whiteBalance",
452
- "WhiteBalanceAutoStrength" to "whiteBalanceAutoStrength",
453
- "WlanFrequency" to "wlanFrequency",
454
- )
455
-
456
365
  /**
457
366
  * getOptions - get options from THETA via repository
458
367
  * @param optionNames option name list to get
@@ -467,18 +376,8 @@ class ThetaClientReactNativeModule(
467
376
  }
468
377
  launch {
469
378
  try {
470
- val optionNameList = mutableListOf<ThetaRepository.OptionNameEnum>()
471
- for (index in 0..(optionNames.size() - 1)) {
472
- val option = optionNames.getString(index)
473
- optionNameList.add(ThetaRepository.OptionNameEnum.valueOf(option))
474
- }
475
- val options = theta.getOptions(optionNameList)
476
- val result = Arguments.createMap()
477
- for (index in 0..(optionNames.size() - 1)) {
478
- val option = optionEnumToOption[optionNames.getString(index)]
479
- val cvt = converters[option]
480
- cvt?.setFromTheta(options, result)
481
- }
379
+ val response = theta.getOptions(toGetOptionsParam(optionNames = optionNames))
380
+ val result = toResult(options = response)
482
381
  promise.resolve(result)
483
382
  } catch (t: Throwable) {
484
383
  promise.reject(t)
@@ -501,14 +400,8 @@ class ThetaClientReactNativeModule(
501
400
  }
502
401
  launch {
503
402
  try {
504
- val thetaOptions = ThetaRepository.Options()
505
- val iterator = options.keySetIterator()
506
- while (iterator.hasNextKey()) {
507
- val key = iterator.nextKey()
508
- val cvt = converters[key]
509
- cvt?.setToTheta(thetaOptions, options)
510
- }
511
- theta.setOptions(thetaOptions)
403
+ val params = toSetOptionsParam(optionsMap = options)
404
+ theta.setOptions(params)
512
405
  promise.resolve(true)
513
406
  } catch (t: Throwable) {
514
407
  promise.reject(t)
@@ -567,11 +460,17 @@ class ThetaClientReactNativeModule(
567
460
 
568
461
  /**
569
462
  * getPhotoCaptureBuilder - get photo capture builder from repository
463
+ * @param promise promise to set result
570
464
  */
571
465
  @ReactMethod
572
- fun getPhotoCaptureBuilder() {
573
- val theta = theta ?: throw Exception(messageNotInit)
466
+ fun getPhotoCaptureBuilder(promise: Promise) {
467
+ val theta = theta
468
+ if (theta == null) {
469
+ promise.reject(Exception(messageNotInit))
470
+ return
471
+ }
574
472
  photoCaptureBuilder = theta.getPhotoCaptureBuilder()
473
+ promise.resolve(true)
575
474
  }
576
475
 
577
476
  /**
@@ -583,7 +482,8 @@ class ThetaClientReactNativeModule(
583
482
  @ReactMethod
584
483
  fun buildPhotoCapture(options: ReadableMap, promise: Promise) {
585
484
  if (theta == null) {
586
- throw Exception(messageNotInit)
485
+ promise.reject(Exception(messageNotInit))
486
+ return
587
487
  }
588
488
  if (photoCaptureBuilder == null) {
589
489
  promise.reject(Exception("no photoCaptureBuilder"))
@@ -591,13 +491,11 @@ class ThetaClientReactNativeModule(
591
491
  }
592
492
  launch {
593
493
  try {
594
- val iterator = options.keySetIterator()
595
- while (iterator.hasNextKey()) {
596
- val key = iterator.nextKey()
597
- val cvt = converters[key]
598
- cvt?.setPhotoOption(options, photoCaptureBuilder!!)
494
+ photoCaptureBuilder?.let {
495
+ setCaptureBuilderParams(optionMap = options, builder = it)
496
+ setPhotoCaptureBuilderParams(optionMap = options, builder = it)
497
+ photoCapture = it.build()
599
498
  }
600
- photoCapture = photoCaptureBuilder!!.build()
601
499
  promise.resolve(true)
602
500
  photoCaptureBuilder = null
603
501
  } catch (t: Throwable) {
@@ -622,7 +520,7 @@ class ThetaClientReactNativeModule(
622
520
  return
623
521
  }
624
522
  class TakePictureCallback : PhotoCapture.TakePictureCallback {
625
- override fun onSuccess(fileUrl: String) {
523
+ override fun onSuccess(fileUrl: String?) {
626
524
  promise.resolve(fileUrl)
627
525
  photoCapture = null
628
526
  }
@@ -641,48 +539,44 @@ class ThetaClientReactNativeModule(
641
539
  * getTimeShiftCaptureBuilder - get time-shift builder from repository
642
540
  */
643
541
  @ReactMethod
644
- fun getTimeShiftCaptureBuilder() {
645
- val theta = theta ?: throw Exception(messageNotInit)
542
+ fun getTimeShiftCaptureBuilder(promise: Promise) {
543
+ val theta = theta
544
+ if (theta == null) {
545
+ promise.reject(Exception(messageNotInit))
546
+ return
547
+ }
646
548
  timeShiftCaptureBuilder = theta.getTimeShiftCaptureBuilder()
549
+ promise.resolve(true)
647
550
  }
648
551
 
649
552
  /**
650
553
  * buildTimeShiftCapture - build time-shift
651
554
  * @param options option to execute time-shift
652
- * @param interval interval of checking time-shift status
653
555
  * @param promise Promise for buildTimeShiftCapture
654
556
  */
655
557
  @ReactMethod
656
- fun buildTimeShiftCapture(options: ReadableMap, interval: Int, promise: Promise) {
558
+ fun buildTimeShiftCapture(options: ReadableMap, promise: Promise) {
657
559
  if (theta == null) {
658
560
  promise.reject(Exception(messageNotInit))
659
561
  return
660
562
  }
661
-
662
- timeShiftCaptureBuilder?.let { builder ->
663
- launch {
664
- try {
665
- val iterator = options.keySetIterator()
666
- while (iterator.hasNextKey()) {
667
- val key = iterator.nextKey()
668
- val cvt = converters[key]
669
- cvt?.setTimeShiftOption(options, builder)
670
- }
671
-
672
- if (interval >= 0) {
673
- builder.setCheckStatusCommandInterval(interval.toLong())
674
- }
675
-
676
- timeShiftCapture = builder.build()
677
- promise.resolve(true)
678
- timeShiftCaptureBuilder = null
679
- } catch (t: Throwable) {
680
- promise.reject(t)
681
- timeShiftCaptureBuilder = null
563
+ if (timeShiftCaptureBuilder == null) {
564
+ promise.reject(Exception("no timeShiftCaptureBuilder"))
565
+ return
566
+ }
567
+ launch {
568
+ try {
569
+ timeShiftCaptureBuilder?.let {
570
+ setCaptureBuilderParams(optionMap = options, builder = it)
571
+ setTimeShiftCaptureBuilderParams(optionMap = options, builder = it)
572
+ timeShiftCapture = it.build()
682
573
  }
574
+ promise.resolve(true)
575
+ timeShiftCaptureBuilder = null
576
+ } catch (t: Throwable) {
577
+ promise.reject(t)
578
+ timeShiftCaptureBuilder = null
683
579
  }
684
- } ?: run {
685
- promise.reject(Exception("no timeShiftCaptureBuilder"))
686
580
  }
687
581
  }
688
582
 
@@ -696,28 +590,28 @@ class ThetaClientReactNativeModule(
696
590
  promise.reject(Exception(messageNotInit))
697
591
  return
698
592
  }
699
- timeShiftCapture?.let { capture ->
700
- class StartCaptureCallback : TimeShiftCapture.StartCaptureCallback {
701
- override fun onSuccess(fileUrl: String?) {
702
- promise.resolve(fileUrl)
703
- timeShiftCapture = null
704
- }
593
+ if (timeShiftCapture == null) {
594
+ promise.reject(Exception("no timeShiftCapture"))
595
+ return
596
+ }
597
+ class StartCaptureCallback : TimeShiftCapture.StartCaptureCallback {
598
+ override fun onSuccess(fileUrl: String?) {
599
+ promise.resolve(fileUrl)
600
+ timeShiftCapture = null
601
+ }
705
602
 
706
- override fun onProgress(completion: Float) {
707
- sendNotifyEvent(
708
- toNotify("TIME-SHIFT-PROGRESS", toCaptureProgressNotifyParam(value = completion))
709
- )
710
- }
603
+ override fun onProgress(completion: Float) {
604
+ sendNotifyEvent(
605
+ toNotify(NOTIFY_TIMESHIFT_PROGRESS, toCaptureProgressNotifyParam(value = completion))
606
+ )
607
+ }
711
608
 
712
- override fun onError(exception: ThetaRepository.ThetaRepositoryException) {
713
- promise.reject(exception)
714
- timeShiftCapture = null
715
- }
609
+ override fun onError(exception: ThetaRepository.ThetaRepositoryException) {
610
+ promise.reject(exception)
611
+ timeShiftCapture = null
716
612
  }
717
- timeShiftCapturing = capture.startCapture(StartCaptureCallback())
718
- } ?: run {
719
- promise.reject(Exception("no timeShiftCapture"))
720
613
  }
614
+ timeShiftCapturing = timeShiftCapture?.startCapture(StartCaptureCallback())
721
615
  }
722
616
 
723
617
  /**
@@ -734,11 +628,17 @@ class ThetaClientReactNativeModule(
734
628
 
735
629
  /**
736
630
  * getVideoCaptureBuilder - get video capture builder
631
+ * @param promise promise to set result
737
632
  */
738
633
  @ReactMethod
739
- fun getVideoCaptureBuilder() {
740
- val theta = theta ?: throw Exception(messageNotInit)
634
+ fun getVideoCaptureBuilder(promise: Promise) {
635
+ val theta = theta
636
+ if (theta == null) {
637
+ promise.reject(Exception(messageNotInit))
638
+ return
639
+ }
741
640
  videoCaptureBuilder = theta.getVideoCaptureBuilder()
641
+ promise.resolve(true)
742
642
  }
743
643
 
744
644
  /**
@@ -758,13 +658,11 @@ class ThetaClientReactNativeModule(
758
658
  }
759
659
  launch {
760
660
  try {
761
- val iterator = options.keySetIterator()
762
- while (iterator.hasNextKey()) {
763
- val key = iterator.nextKey()
764
- val cvt = converters[key]
765
- cvt?.setVideoOption(options, videoCaptureBuilder!!)
661
+ videoCaptureBuilder?.let {
662
+ setCaptureBuilderParams(optionMap = options, builder = it)
663
+ setVideoCaptureBuilderParams(optionMap = options, builder = it)
664
+ videoCapture = it.build()
766
665
  }
767
- videoCapture = videoCaptureBuilder!!.build()
768
666
  promise.resolve(true)
769
667
  videoCaptureBuilder = null
770
668
  } catch (t: Throwable) {
@@ -779,7 +677,7 @@ class ThetaClientReactNativeModule(
779
677
  * @param promise promise to set result
780
678
  */
781
679
  @ReactMethod
782
- fun startCapture(promise: Promise) {
680
+ fun startVideoCapture(promise: Promise) {
783
681
  if (theta == null) {
784
682
  promise.reject(Exception(messageNotInit))
785
683
  return
@@ -789,32 +687,257 @@ class ThetaClientReactNativeModule(
789
687
  return
790
688
  }
791
689
  class StartCaptureCallback : VideoCapture.StartCaptureCallback {
792
- override fun onSuccess(fileUrl: String) {
690
+ override fun onCaptureCompleted(fileUrl: String?) {
793
691
  promise.resolve(fileUrl)
794
692
  videoCapture = null
795
693
  videoCapturing = null
796
694
  }
797
695
 
798
- override fun onError(exception: ThetaRepository.ThetaRepositoryException) {
696
+ override fun onCaptureFailed(exception: ThetaRepository.ThetaRepositoryException) {
799
697
  promise.reject(exception)
800
698
  videoCapture = null
801
699
  videoCapturing = null
802
700
  }
701
+
702
+ override fun onStopFailed(exception: ThetaRepository.ThetaRepositoryException) {
703
+ sendNotifyEvent(
704
+ toNotify(
705
+ NOTIFY_VIDEO_CAPTURE_STOP_ERROR,
706
+ toMessageNotifyParam(exception.message ?: exception.toString())
707
+ )
708
+ )
709
+ }
803
710
  }
804
- videoCapturing = videoCapture!!.startCapture(StartCaptureCallback())
711
+ videoCapturing = videoCapture?.startCapture(StartCaptureCallback())
805
712
  }
806
713
 
807
714
  /**
808
715
  * stopCapture - stop capturing video
809
716
  */
810
717
  @ReactMethod
811
- fun stopCapture() {
718
+ fun stopVideoCapture() {
812
719
  if (theta == null) {
813
720
  throw Exception(messageNotInit)
814
721
  }
815
722
  videoCapturing?.stopCapture()
816
723
  }
817
724
 
725
+ /**
726
+ * getLimitlessIntervalCaptureBuilder - get limitless interval capture builder
727
+ * @param promise promise to set result
728
+ */
729
+ @ReactMethod
730
+ fun getLimitlessIntervalCaptureBuilder(promise: Promise) {
731
+ val theta = theta
732
+ if (theta == null) {
733
+ promise.reject(Exception(messageNotInit))
734
+ return
735
+ }
736
+ limitlessIntervalCaptureBuilder = theta.getLimitlessIntervalCaptureBuilder()
737
+ promise.resolve(true)
738
+ }
739
+
740
+ /**
741
+ * buildLimitlessIntervalCapture - build limitless interval capture
742
+ * @param options option to capture limitless interval
743
+ * @param promise promise to set result
744
+ */
745
+ @ReactMethod
746
+ fun buildLimitlessIntervalCapture(options: ReadableMap, promise: Promise) {
747
+ if (theta == null) {
748
+ promise.reject(Exception(messageNotInit))
749
+ return
750
+ }
751
+ if (limitlessIntervalCaptureBuilder == null) {
752
+ promise.reject(Exception("no limitlessIntervalCaptureBuilder"))
753
+ return
754
+ }
755
+ launch {
756
+ try {
757
+ limitlessIntervalCaptureBuilder?.let {
758
+ setCaptureBuilderParams(optionMap = options, builder = it)
759
+ setLimitlessIntervalCaptureBuilderParams(optionMap = options, builder = it)
760
+ limitlessIntervalCapture = it.build()
761
+ }
762
+ promise.resolve(true)
763
+ limitlessIntervalCaptureBuilder = null
764
+ } catch (t: Throwable) {
765
+ promise.reject(t)
766
+ limitlessIntervalCaptureBuilder = null
767
+ }
768
+ }
769
+ }
770
+
771
+ /**
772
+ * startCapture - start capture limitless interval
773
+ * @param promise promise to set result
774
+ */
775
+ @ReactMethod
776
+ fun startLimitlessIntervalCapture(promise: Promise) {
777
+ if (theta == null) {
778
+ promise.reject(Exception(messageNotInit))
779
+ return
780
+ }
781
+ if (limitlessIntervalCapture == null) {
782
+ promise.reject(Exception("no limitlessIntervalCapture"))
783
+ return
784
+ }
785
+ class StartCaptureCallback : LimitlessIntervalCapture.StartCaptureCallback {
786
+ override fun onCaptureCompleted(fileUrls: List<String>?) {
787
+ promise.resolve(fileUrls?.let {
788
+ val resultList = Arguments.createArray()
789
+ it.forEach {
790
+ resultList.pushString(it)
791
+ }
792
+ resultList
793
+ })
794
+ limitlessIntervalCapture = null
795
+ limitlessIntervalCapturing = null
796
+ }
797
+
798
+ override fun onCaptureFailed(exception: ThetaRepository.ThetaRepositoryException) {
799
+ promise.reject(exception)
800
+ limitlessIntervalCapture = null
801
+ limitlessIntervalCapturing = null
802
+ }
803
+
804
+ override fun onStopFailed(exception: ThetaRepository.ThetaRepositoryException) {
805
+ sendNotifyEvent(
806
+ toNotify(
807
+ NOTIFY_LIMITLESS_INTERVAL_CAPTURE_STOP_ERROR,
808
+ toMessageNotifyParam(exception.message ?: exception.toString())
809
+ )
810
+ )
811
+ }
812
+ }
813
+ limitlessIntervalCapturing = limitlessIntervalCapture?.startCapture(StartCaptureCallback())
814
+ }
815
+
816
+ /**
817
+ * stopCapture - stop capturing limitless interval
818
+ */
819
+ @ReactMethod
820
+ fun stopLimitlessIntervalCapture() {
821
+ if (theta == null) {
822
+ throw Exception(messageNotInit)
823
+ }
824
+ limitlessIntervalCapturing?.stopCapture()
825
+ }
826
+
827
+ /**
828
+ * getShotCountSpecifiedIntervalCaptureBuilder - get interval shooting with the shot count specified builder from repository
829
+ * @param shotCount shotCount shot count specified
830
+ * @param promise Promise for getShotCountSpecifiedIntervalCaptureBuilder
831
+ */
832
+ @ReactMethod
833
+ fun getShotCountSpecifiedIntervalCaptureBuilder(shotCount: Int, promise: Promise) {
834
+ val theta = theta
835
+ if (theta == null) {
836
+ promise.reject(Exception(messageNotInit))
837
+ return
838
+ }
839
+ shotCountSpecifiedIntervalCaptureBuilder = theta.getShotCountSpecifiedIntervalCaptureBuilder(shotCount)
840
+ promise.resolve(true)
841
+ }
842
+
843
+ /**
844
+ * buildShotCountSpecifiedIntervalCapture - build interval shooting with the shot count specified
845
+ * @param options option to execute interval shooting with the shot count specified
846
+ * @param promise Promise for buildShotCountSpecifiedIntervalCapture
847
+ */
848
+ @ReactMethod
849
+ fun buildShotCountSpecifiedIntervalCapture(options: ReadableMap, promise: Promise) {
850
+ if (theta == null) {
851
+ promise.reject(Exception(messageNotInit))
852
+ return
853
+ }
854
+ if (shotCountSpecifiedIntervalCaptureBuilder == null) {
855
+ promise.reject(Exception("no shotCountSpecifiedIntervalCaptureBuilder"))
856
+ return
857
+ }
858
+ launch {
859
+ try {
860
+ shotCountSpecifiedIntervalCaptureBuilder?.let {
861
+ setCaptureBuilderParams(optionMap = options, builder = it)
862
+ setShotCountSpecifiedIntervalCaptureBuilderParams(optionMap = options, builder = it)
863
+ shotCountSpecifiedIntervalCapture = it.build()
864
+ }
865
+ promise.resolve(true)
866
+ shotCountSpecifiedIntervalCaptureBuilder = null
867
+ } catch (t: Throwable) {
868
+ promise.reject(t)
869
+ shotCountSpecifiedIntervalCaptureBuilder = null
870
+ }
871
+ }
872
+ }
873
+
874
+ /**
875
+ * startShotCountSpecifiedIntervalCapture - start interval shooting with the shot count specified
876
+ * @param promise promise for startShotCountSpecifiedIntervalCapture
877
+ */
878
+ @ReactMethod
879
+ fun startShotCountSpecifiedIntervalCapture(promise: Promise) {
880
+ if (theta == null) {
881
+ promise.reject(Exception(messageNotInit))
882
+ return
883
+ }
884
+ if (shotCountSpecifiedIntervalCapture == null) {
885
+ promise.reject(Exception("no shotCountSpecifiedIntervalCapture"))
886
+ return
887
+ }
888
+ class StartCaptureCallback : ShotCountSpecifiedIntervalCapture.StartCaptureCallback {
889
+ override fun onCaptureCompleted(fileUrls: List<String>?) {
890
+ promise.resolve(fileUrls?.let {
891
+ val resultList = Arguments.createArray()
892
+ it.forEach {
893
+ resultList.pushString(it)
894
+ }
895
+ resultList
896
+ })
897
+ shotCountSpecifiedIntervalCapture = null
898
+ }
899
+
900
+ override fun onProgress(completion: Float) {
901
+ sendNotifyEvent(
902
+ toNotify(
903
+ NOTIFY_SHOT_COUNT_SPECIFIED_INTERVAL_PROGRESS,
904
+ toCaptureProgressNotifyParam(value = completion)
905
+ )
906
+ )
907
+ }
908
+
909
+ override fun onStopFailed(exception: ThetaRepository.ThetaRepositoryException) {
910
+ sendNotifyEvent(
911
+ toNotify(
912
+ NOTIFY_SHOT_COUNT_SPECIFIED_INTERVAL_STOP_ERROR,
913
+ toMessageNotifyParam(exception.message ?: exception.toString())
914
+ )
915
+ )
916
+ }
917
+
918
+ override fun onCaptureFailed(exception: ThetaRepository.ThetaRepositoryException) {
919
+ promise.reject(exception)
920
+ shotCountSpecifiedIntervalCapture = null
921
+ }
922
+ }
923
+ shotCountSpecifiedIntervalCapturing =
924
+ shotCountSpecifiedIntervalCapture?.startCapture(StartCaptureCallback())
925
+ }
926
+
927
+ /**
928
+ * cancelShotCountSpecifiedIntervalCapture - stop interval shooting with the shot count specified
929
+ * @param promise promise for cancelShotCountSpecifiedIntervalCapture
930
+ */
931
+ @ReactMethod
932
+ fun cancelShotCountSpecifiedIntervalCapture(promise: Promise) {
933
+ if (theta == null) {
934
+ promise.reject(Exception(messageNotInit))
935
+ return
936
+ }
937
+ shotCountSpecifiedIntervalCapturing?.cancelCapture()
938
+ promise.resolve(true)
939
+ }
940
+
818
941
  /**
819
942
  * getMetadata - retrieve meta data from THETA via repository
820
943
  * @param promise promise to set result
@@ -1002,29 +1125,8 @@ class ThetaClientReactNativeModule(
1002
1125
  }
1003
1126
  launch {
1004
1127
  try {
1005
- val result = Arguments.createArray()
1006
- theta.listAccessPoints().forEach {
1007
- val apinfo = Arguments.createMap()
1008
- apinfo.putString("ssid", it.ssid)
1009
- apinfo.putBoolean("ssidStealth", it.ssidStealth)
1010
- apinfo.putString("authMode", it.authMode.toString())
1011
- apinfo.putInt("connectionPriority", it.connectionPriority)
1012
- apinfo.putBoolean("usingDhcp", it.usingDhcp)
1013
- apinfo.putString("ipAddress", it.ipAddress)
1014
- apinfo.putString("subnetMask", it.subnetMask)
1015
- apinfo.putString("defaultGateway", it.defaultGateway)
1016
-
1017
- it.proxy?.let { proxy ->
1018
- var options = ThetaRepository.Options(proxy = proxy)
1019
- val optionsMap = Arguments.createMap()
1020
- val cvt = converters["proxy"]
1021
- cvt?.setFromTheta(options, optionsMap)
1022
- apinfo.putMap("proxy", optionsMap.getMap("proxy"))
1023
- }
1024
-
1025
- result.pushMap(apinfo)
1026
- }
1027
- promise.resolve(result)
1128
+ val response = theta.listAccessPoints()
1129
+ promise.resolve(toListAccessPointsResult(accessPointList = response))
1028
1130
  } catch (t: Throwable) {
1029
1131
  promise.reject(t)
1030
1132
  }
@@ -1064,7 +1166,7 @@ class ThetaClientReactNativeModule(
1064
1166
  ThetaRepository.AuthModeEnum.valueOf(authMode),
1065
1167
  password,
1066
1168
  connectionPriority,
1067
- convertMapToProxy(proxyMap = proxy)
1169
+ toProxy(map = proxy)
1068
1170
  )
1069
1171
  promise.resolve(true)
1070
1172
  } catch (t: Throwable) {
@@ -1115,7 +1217,7 @@ class ThetaClientReactNativeModule(
1115
1217
  ipAddress,
1116
1218
  subnetMask,
1117
1219
  defaultGateway,
1118
- convertMapToProxy(proxyMap = proxy)
1220
+ toProxy(map = proxy)
1119
1221
  )
1120
1222
  promise.resolve(true)
1121
1223
  } catch (t: Throwable) {
@@ -1146,20 +1248,6 @@ class ThetaClientReactNativeModule(
1146
1248
  }
1147
1249
  }
1148
1250
 
1149
- /**
1150
- * convert ReadableMap to ThetaRepository.Proxy
1151
- */
1152
- private fun convertMapToProxy(proxyMap: ReadableMap?): ThetaRepository.Proxy? {
1153
- return proxyMap?.let {
1154
- var options = ThetaRepository.Options()
1155
- val optionsMap = Arguments.createMap()
1156
- optionsMap.putMap("proxy", it)
1157
- val cvt = converters["proxy"]
1158
- cvt?.setToTheta(options, optionsMap)
1159
- options.proxy
1160
- } ?: null
1161
- }
1162
-
1163
1251
  /**
1164
1252
  * setBluetoothDevice - register uuid of a BLE device
1165
1253
  * @param uuid uuid to set
@@ -1198,12 +1286,7 @@ class ThetaClientReactNativeModule(
1198
1286
  launch {
1199
1287
  try {
1200
1288
  val options = theta.getMySetting(ThetaRepository.CaptureModeEnum.valueOf(captureMode))
1201
- val result = Arguments.createMap()
1202
- converters.forEach {
1203
- val cvt = it.value
1204
- cvt?.setFromTheta(options, result)
1205
- }
1206
- promise.resolve(result)
1289
+ promise.resolve(toResult(options = options))
1207
1290
  } catch (t: Throwable) {
1208
1291
  promise.reject(t)
1209
1292
  }
@@ -1231,13 +1314,7 @@ class ThetaClientReactNativeModule(
1231
1314
  optionNameList.add(ThetaRepository.OptionNameEnum.valueOf(option))
1232
1315
  }
1233
1316
  val options = theta.getMySetting(optionNameList)
1234
- val result = Arguments.createMap()
1235
- for (index in 0..(optionNames.size() - 1)) {
1236
- val option = optionEnumToOption[optionNames.getString(index)]
1237
- val cvt = converters[option]
1238
- cvt?.setFromTheta(options, result)
1239
- }
1240
- promise.resolve(result)
1317
+ promise.resolve(toResult(options = options))
1241
1318
  } catch (t: Throwable) {
1242
1319
  promise.reject(t)
1243
1320
  }
@@ -1259,13 +1336,7 @@ class ThetaClientReactNativeModule(
1259
1336
  }
1260
1337
  launch {
1261
1338
  try {
1262
- val thetaOptions = ThetaRepository.Options()
1263
- val iterator = options.keySetIterator()
1264
- while (iterator.hasNextKey()) {
1265
- val key = iterator.nextKey()
1266
- val cvt = converters[key]
1267
- cvt?.setToTheta(thetaOptions, options)
1268
- }
1339
+ val thetaOptions = toSetOptionsParam(optionsMap = options)
1269
1340
  theta.setMySetting(ThetaRepository.CaptureModeEnum.valueOf(captureMode), thetaOptions)
1270
1341
  promise.resolve(true)
1271
1342
  } catch (t: Throwable) {
@@ -1474,5 +1545,10 @@ class ThetaClientReactNativeModule(
1474
1545
  const val NAME = "ThetaClientReactNative"
1475
1546
  const val EVENT_NAME = "ThetaFrameEvent"
1476
1547
  const val EVENT_NOTIFY = "ThetaNotify"
1548
+ const val NOTIFY_TIMESHIFT_PROGRESS = "TIME-SHIFT-PROGRESS"
1549
+ const val NOTIFY_VIDEO_CAPTURE_STOP_ERROR = "VIDEO-CAPTURE-STOP-ERROR"
1550
+ const val NOTIFY_LIMITLESS_INTERVAL_CAPTURE_STOP_ERROR = "LIMITLESS-INTERVAL-CAPTURE-STOP-ERROR"
1551
+ const val NOTIFY_SHOT_COUNT_SPECIFIED_INTERVAL_PROGRESS = "SHOT-COUNT-SPECIFIED-INTERVAL-PROGRESS"
1552
+ const val NOTIFY_SHOT_COUNT_SPECIFIED_INTERVAL_STOP_ERROR = "SHOT-COUNT-SPECIFIED-INTERVAL-STOP-ERROR"
1477
1553
  }
1478
1554
  }