theta-client-react-native 1.3.1 → 1.4.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 (104) hide show
  1. package/android/build.gradle +1 -1
  2. package/android/src/main/java/com/ricoh360/thetaclientreactnative/Converter.kt +81 -0
  3. package/android/src/main/java/com/ricoh360/thetaclientreactnative/ThetaClientSdkModule.kt +55 -19
  4. package/ios/ConvertUtil.swift +989 -0
  5. package/ios/ThetaClientReactNative-Bridging-Header.h +3 -0
  6. package/ios/ThetaClientReactNative.m +201 -0
  7. package/ios/ThetaClientReactNative.swift +1337 -0
  8. package/ios/ThetaClientReactNative.xcodeproj/project.pbxproj +15 -57
  9. package/lib/commonjs/capture/photo-capture.js +19 -1
  10. package/lib/commonjs/capture/photo-capture.js.map +1 -1
  11. package/lib/commonjs/capture/time-shift-capture.js +27 -23
  12. package/lib/commonjs/capture/time-shift-capture.js.map +1 -1
  13. package/lib/commonjs/capture/video-capture.js +33 -5
  14. package/lib/commonjs/capture/video-capture.js.map +1 -1
  15. package/lib/commonjs/index.js.map +1 -1
  16. package/lib/commonjs/theta-repository/notify-controller.js +40 -0
  17. package/lib/commonjs/theta-repository/notify-controller.js.map +1 -0
  18. package/lib/commonjs/theta-repository/options/index.js +44 -0
  19. package/lib/commonjs/theta-repository/options/index.js.map +1 -1
  20. package/lib/commonjs/theta-repository/options/option-face-detect.js +22 -0
  21. package/lib/commonjs/theta-repository/options/option-face-detect.js.map +1 -0
  22. package/lib/commonjs/theta-repository/options/option-function.js +27 -0
  23. package/lib/commonjs/theta-repository/options/option-function.js.map +1 -0
  24. package/lib/commonjs/theta-repository/options/option-gain.js +26 -0
  25. package/lib/commonjs/theta-repository/options/option-gain.js.map +1 -0
  26. package/lib/commonjs/theta-repository/options/option-image-stitching.js +38 -0
  27. package/lib/commonjs/theta-repository/options/option-image-stitching.js.map +1 -0
  28. package/lib/commonjs/theta-repository/options/options.js +8 -0
  29. package/lib/commonjs/theta-repository/options/options.js.map +1 -1
  30. package/lib/commonjs/theta-repository/theta-repository.js +2 -3
  31. package/lib/commonjs/theta-repository/theta-repository.js.map +1 -1
  32. package/lib/commonjs/theta-repository/theta-state.js +1 -13
  33. package/lib/commonjs/theta-repository/theta-state.js.map +1 -1
  34. package/lib/module/capture/photo-capture.js +19 -1
  35. package/lib/module/capture/photo-capture.js.map +1 -1
  36. package/lib/module/capture/time-shift-capture.js +27 -23
  37. package/lib/module/capture/time-shift-capture.js.map +1 -1
  38. package/lib/module/capture/video-capture.js +33 -5
  39. package/lib/module/capture/video-capture.js.map +1 -1
  40. package/lib/module/index.js.map +1 -1
  41. package/lib/module/theta-repository/notify-controller.js +33 -0
  42. package/lib/module/theta-repository/notify-controller.js.map +1 -0
  43. package/lib/module/theta-repository/options/index.js +4 -0
  44. package/lib/module/theta-repository/options/index.js.map +1 -1
  45. package/lib/module/theta-repository/options/option-face-detect.js +15 -0
  46. package/lib/module/theta-repository/options/option-face-detect.js.map +1 -0
  47. package/lib/module/theta-repository/options/option-function.js +20 -0
  48. package/lib/module/theta-repository/options/option-function.js.map +1 -0
  49. package/lib/module/theta-repository/options/option-gain.js +19 -0
  50. package/lib/module/theta-repository/options/option-gain.js.map +1 -0
  51. package/lib/module/theta-repository/options/option-image-stitching.js +31 -0
  52. package/lib/module/theta-repository/options/option-image-stitching.js.map +1 -0
  53. package/lib/module/theta-repository/options/options.js +8 -0
  54. package/lib/module/theta-repository/options/options.js.map +1 -1
  55. package/lib/module/theta-repository/theta-repository.js +2 -3
  56. package/lib/module/theta-repository/theta-repository.js.map +1 -1
  57. package/lib/module/theta-repository/theta-state.js +0 -12
  58. package/lib/module/theta-repository/theta-state.js.map +1 -1
  59. package/lib/typescript/capture/photo-capture.d.ts +7 -1
  60. package/lib/typescript/capture/photo-capture.d.ts.map +1 -1
  61. package/lib/typescript/capture/time-shift-capture.d.ts +4 -7
  62. package/lib/typescript/capture/time-shift-capture.d.ts.map +1 -1
  63. package/lib/typescript/capture/video-capture.d.ts +5 -1
  64. package/lib/typescript/capture/video-capture.d.ts.map +1 -1
  65. package/lib/typescript/theta-repository/notify-controller.d.ts +17 -0
  66. package/lib/typescript/theta-repository/notify-controller.d.ts.map +1 -0
  67. package/lib/typescript/theta-repository/options/index.d.ts +4 -0
  68. package/lib/typescript/theta-repository/options/index.d.ts.map +1 -1
  69. package/lib/typescript/theta-repository/options/option-face-detect.d.ts +15 -0
  70. package/lib/typescript/theta-repository/options/option-face-detect.d.ts.map +1 -0
  71. package/lib/typescript/theta-repository/options/option-function.d.ts +20 -0
  72. package/lib/typescript/theta-repository/options/option-function.d.ts.map +1 -0
  73. package/lib/typescript/theta-repository/options/option-gain.d.ts +19 -0
  74. package/lib/typescript/theta-repository/options/option-gain.d.ts.map +1 -0
  75. package/lib/typescript/theta-repository/options/option-image-stitching.d.ts +30 -0
  76. package/lib/typescript/theta-repository/options/option-image-stitching.d.ts.map +1 -0
  77. package/lib/typescript/theta-repository/options/options.d.ts +20 -0
  78. package/lib/typescript/theta-repository/options/options.d.ts.map +1 -1
  79. package/lib/typescript/theta-repository/theta-repository.d.ts.map +1 -1
  80. package/lib/typescript/theta-repository/theta-state.d.ts +1 -11
  81. package/lib/typescript/theta-repository/theta-state.d.ts.map +1 -1
  82. package/package.json +14 -8
  83. package/src/capture/photo-capture.ts +20 -3
  84. package/src/capture/time-shift-capture.ts +40 -33
  85. package/src/capture/video-capture.ts +49 -6
  86. package/src/theta-repository/notify-controller.ts +50 -0
  87. package/src/theta-repository/options/index.ts +4 -0
  88. package/src/theta-repository/options/option-face-detect.ts +16 -0
  89. package/src/theta-repository/options/option-function.ts +21 -0
  90. package/src/theta-repository/options/option-gain.ts +19 -0
  91. package/src/theta-repository/options/option-image-stitching.ts +32 -0
  92. package/src/theta-repository/options/options.ts +20 -0
  93. package/src/theta-repository/theta-repository.ts +3 -3
  94. package/src/theta-repository/theta-state.ts +2 -14
  95. package/theta-client-react-native.podspec +2 -2
  96. package/ios/ThetaClientReactNative.h +0 -34
  97. package/ios/ThetaClientReactNative.mm +0 -4087
  98. package/lib/commonjs/capture/notify.js +0 -12
  99. package/lib/commonjs/capture/notify.js.map +0 -1
  100. package/lib/module/capture/notify.js +0 -6
  101. package/lib/module/capture/notify.js.map +0 -1
  102. package/lib/typescript/capture/notify.d.ts +0 -13
  103. package/lib/typescript/capture/notify.d.ts.map +0 -1
  104. package/src/capture/notify.ts +0 -27
@@ -135,7 +135,7 @@ dependencies {
135
135
  implementation "com.facebook.react:react-native:+"
136
136
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
137
137
  implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4-native-mt"
138
- implementation "com.ricoh360.thetaclient:theta-client:1.3.1"
138
+ implementation "com.ricoh360.thetaclient:theta-client:1.4.0"
139
139
 
140
140
  // From node_modules
141
141
  }
@@ -13,6 +13,7 @@ import com.ricoh360.thetaclient.capture.VideoCapture
13
13
  const val KEY_NOTIFY_NAME = "name"
14
14
  const val KEY_NOTIFY_PARAMS = "params"
15
15
  const val KEY_NOTIFY_PARAM_COMPLETION = "completion"
16
+ const val KEY_NOTIFY_PARAM_MESSAGE = "message"
16
17
 
17
18
  fun toNotify(
18
19
  name: String,
@@ -32,6 +33,12 @@ fun toCaptureProgressNotifyParam(value: Float): WritableMap {
32
33
  return result
33
34
  }
34
35
 
36
+ fun toMessageNotifyParam(value: String): WritableMap {
37
+ val result = Arguments.createMap()
38
+ result.putString(KEY_NOTIFY_PARAM_MESSAGE, value)
39
+ return result
40
+ }
41
+
35
42
  /**
36
43
  * convert option interface
37
44
  */
@@ -401,6 +408,23 @@ class ExposureProgramConverter : OptionConverter {
401
408
  }
402
409
  };
403
410
 
411
+ /**
412
+ * FaceDetectConverter
413
+ */
414
+ class FaceDetectConverter : OptionConverter {
415
+ override fun setToTheta(options: ThetaRepository.Options, objects: ReadableMap) {
416
+ objects.getString("faceDetect")?.let {
417
+ options.faceDetect = ThetaRepository.FaceDetectEnum.valueOf(it)
418
+ }
419
+ }
420
+
421
+ override fun setFromTheta(options: ThetaRepository.Options, objects: WritableMap) {
422
+ options.faceDetect?.let {
423
+ objects.putString("faceDetect", it.toString())
424
+ }
425
+ }
426
+ }
427
+
404
428
  /**
405
429
  * FileFormatConverter
406
430
  */
@@ -453,6 +477,40 @@ class FilterConverter : OptionConverter {
453
477
  }
454
478
  }
455
479
 
480
+ /**
481
+ * FunctionConverter
482
+ */
483
+ class FunctionConverter : OptionConverter {
484
+ override fun setToTheta(options: ThetaRepository.Options, objects: ReadableMap) {
485
+ objects.getString("function")?.let {
486
+ options.function = ThetaRepository.ShootingFunctionEnum.valueOf(it)
487
+ }
488
+ }
489
+
490
+ override fun setFromTheta(options: ThetaRepository.Options, objects: WritableMap) {
491
+ options.function?.let {
492
+ objects.putString("function", it.toString())
493
+ }
494
+ }
495
+ }
496
+
497
+ /**
498
+ * GainConverter
499
+ */
500
+ class GainConverter : OptionConverter {
501
+ override fun setToTheta(options: ThetaRepository.Options, objects: ReadableMap) {
502
+ objects.getString("gain")?.let {
503
+ options.gain = ThetaRepository.GainEnum.valueOf(it)
504
+ }
505
+ }
506
+
507
+ override fun setFromTheta(options: ThetaRepository.Options, objects: WritableMap) {
508
+ options.gain?.let {
509
+ objects.putString("gain", it.toString())
510
+ }
511
+ }
512
+ }
513
+
456
514
  /**
457
515
  * GpsTagRecordingConverter
458
516
  */
@@ -476,6 +534,23 @@ class GpsTagRecordingConverter : OptionConverter {
476
534
  }
477
535
  }
478
536
 
537
+ /**
538
+ * ImageStitchingConverter
539
+ */
540
+ class ImageStitchingConverter : OptionConverter {
541
+ override fun setToTheta(options: ThetaRepository.Options, objects: ReadableMap) {
542
+ objects.getString("imageStitching")?.let {
543
+ options.imageStitching = ThetaRepository.ImageStitchingEnum.valueOf(it)
544
+ }
545
+ }
546
+
547
+ override fun setFromTheta(options: ThetaRepository.Options, objects: WritableMap) {
548
+ options.imageStitching?.let {
549
+ objects.putString("imageStitching", it.toString())
550
+ }
551
+ }
552
+ }
553
+
479
554
  /**
480
555
  * IsoConverter
481
556
  */
@@ -661,6 +736,12 @@ class PresetConverter : OptionConverter {
661
736
  objects.putString("preset", it.toString())
662
737
  }
663
738
  }
739
+
740
+ override fun setPhotoOption(objects: ReadableMap, builder: PhotoCapture.Builder) {
741
+ objects.getString("preset")?.let {
742
+ builder.setPreset(ThetaRepository.PresetEnum.valueOf(it))
743
+ }
744
+ }
664
745
  }
665
746
 
666
747
  /**
@@ -371,9 +371,13 @@ class ThetaClientReactNativeModule(
371
371
  "exposureCompensation" to ExposureCompensationConverter(),
372
372
  "exposureDelay" to ExposureDelayConverter(),
373
373
  "exposureProgram" to ExposureProgramConverter(),
374
+ "faceDetect" to FaceDetectConverter(),
374
375
  "fileFormat" to FileFormatConverter(),
375
376
  "filter" to FilterConverter(),
377
+ "function" to FunctionConverter(),
378
+ "gain" to GainConverter(),
376
379
  "gpsInfo" to GpsInfoConverter(),
380
+ "imageStitching" to ImageStitchingConverter(),
377
381
  "isGpsOn" to IsGpsOnConverter(),
378
382
  "iso" to IsoConverter(),
379
383
  "isoAutoHighLimit" to IsoAutoHighLimitConverter(),
@@ -423,9 +427,13 @@ class ThetaClientReactNativeModule(
423
427
  "ExposureCompensation" to "exposureCompensation",
424
428
  "ExposureDelay" to "exposureDelay",
425
429
  "ExposureProgram" to "exposureProgram",
430
+ "FaceDetect" to "faceDetect",
426
431
  "FileFormat" to "fileFormat",
427
432
  "Filter" to "filter",
433
+ "Function" to "function",
434
+ "Gain" to "gain",
428
435
  "GpsInfo" to "gpsInfo",
436
+ "ImageStitching" to "imageStitching",
429
437
  "IsGpsOn" to "isGpsOn",
430
438
  "Iso" to "iso",
431
439
  "IsoAutoHighLimit" to "isoAutoHighLimit",
@@ -567,11 +575,16 @@ class ThetaClientReactNativeModule(
567
575
 
568
576
  /**
569
577
  * getPhotoCaptureBuilder - get photo capture builder from repository
578
+ * @param promise promise to set result
570
579
  */
571
580
  @ReactMethod
572
- fun getPhotoCaptureBuilder() {
573
- val theta = theta ?: throw Exception(messageNotInit)
574
- photoCaptureBuilder = theta.getPhotoCaptureBuilder()
581
+ fun getPhotoCaptureBuilder(promise: Promise) {
582
+ if (theta == null) {
583
+ promise.reject(Exception(messageNotInit))
584
+ return
585
+ }
586
+ photoCaptureBuilder = theta?.getPhotoCaptureBuilder()
587
+ promise.resolve(true)
575
588
  }
576
589
 
577
590
  /**
@@ -583,7 +596,8 @@ class ThetaClientReactNativeModule(
583
596
  @ReactMethod
584
597
  fun buildPhotoCapture(options: ReadableMap, promise: Promise) {
585
598
  if (theta == null) {
586
- throw Exception(messageNotInit)
599
+ promise.reject(Exception(messageNotInit))
600
+ return
587
601
  }
588
602
  if (photoCaptureBuilder == null) {
589
603
  promise.reject(Exception("no photoCaptureBuilder"))
@@ -641,19 +655,22 @@ class ThetaClientReactNativeModule(
641
655
  * getTimeShiftCaptureBuilder - get time-shift builder from repository
642
656
  */
643
657
  @ReactMethod
644
- fun getTimeShiftCaptureBuilder() {
645
- val theta = theta ?: throw Exception(messageNotInit)
646
- timeShiftCaptureBuilder = theta.getTimeShiftCaptureBuilder()
658
+ fun getTimeShiftCaptureBuilder(promise: Promise) {
659
+ if (theta == null) {
660
+ promise.reject(Exception(messageNotInit))
661
+ return
662
+ }
663
+ timeShiftCaptureBuilder = theta?.getTimeShiftCaptureBuilder()
664
+ promise.resolve(true)
647
665
  }
648
666
 
649
667
  /**
650
668
  * buildTimeShiftCapture - build time-shift
651
669
  * @param options option to execute time-shift
652
- * @param interval interval of checking time-shift status
653
670
  * @param promise Promise for buildTimeShiftCapture
654
671
  */
655
672
  @ReactMethod
656
- fun buildTimeShiftCapture(options: ReadableMap, interval: Int, promise: Promise) {
673
+ fun buildTimeShiftCapture(options: ReadableMap, promise: Promise) {
657
674
  if (theta == null) {
658
675
  promise.reject(Exception(messageNotInit))
659
676
  return
@@ -669,8 +686,11 @@ class ThetaClientReactNativeModule(
669
686
  cvt?.setTimeShiftOption(options, builder)
670
687
  }
671
688
 
672
- if (interval >= 0) {
673
- builder.setCheckStatusCommandInterval(interval.toLong())
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
+ }
674
694
  }
675
695
 
676
696
  timeShiftCapture = builder.build()
@@ -705,7 +725,7 @@ class ThetaClientReactNativeModule(
705
725
 
706
726
  override fun onProgress(completion: Float) {
707
727
  sendNotifyEvent(
708
- toNotify("TIME-SHIFT-PROGRESS", toCaptureProgressNotifyParam(value = completion))
728
+ toNotify(NOTIFY_TIMESHIFT_PROGRESS, toCaptureProgressNotifyParam(value = completion))
709
729
  )
710
730
  }
711
731
 
@@ -734,11 +754,16 @@ class ThetaClientReactNativeModule(
734
754
 
735
755
  /**
736
756
  * getVideoCaptureBuilder - get video capture builder
757
+ * @param promise promise to set result
737
758
  */
738
759
  @ReactMethod
739
- fun getVideoCaptureBuilder() {
740
- val theta = theta ?: throw Exception(messageNotInit)
741
- videoCaptureBuilder = theta.getVideoCaptureBuilder()
760
+ fun getVideoCaptureBuilder(promise: Promise) {
761
+ if (theta == null) {
762
+ promise.reject(Exception(messageNotInit))
763
+ return
764
+ }
765
+ videoCaptureBuilder = theta?.getVideoCaptureBuilder()
766
+ promise.resolve(true)
742
767
  }
743
768
 
744
769
  /**
@@ -779,7 +804,7 @@ class ThetaClientReactNativeModule(
779
804
  * @param promise promise to set result
780
805
  */
781
806
  @ReactMethod
782
- fun startCapture(promise: Promise) {
807
+ fun startVideoCapture(promise: Promise) {
783
808
  if (theta == null) {
784
809
  promise.reject(Exception(messageNotInit))
785
810
  return
@@ -789,17 +814,26 @@ class ThetaClientReactNativeModule(
789
814
  return
790
815
  }
791
816
  class StartCaptureCallback : VideoCapture.StartCaptureCallback {
792
- override fun onSuccess(fileUrl: String) {
817
+ override fun onCaptureCompleted(fileUrl: String?) {
793
818
  promise.resolve(fileUrl)
794
819
  videoCapture = null
795
820
  videoCapturing = null
796
821
  }
797
822
 
798
- override fun onError(exception: ThetaRepository.ThetaRepositoryException) {
823
+ override fun onCaptureFailed(exception: ThetaRepository.ThetaRepositoryException) {
799
824
  promise.reject(exception)
800
825
  videoCapture = null
801
826
  videoCapturing = null
802
827
  }
828
+
829
+ override fun onStopFailed(exception: ThetaRepository.ThetaRepositoryException) {
830
+ sendNotifyEvent(
831
+ toNotify(
832
+ NOTIFY_VIDEO_CAPTURE_STOP_ERROR,
833
+ toMessageNotifyParam(exception.message ?: exception.toString())
834
+ )
835
+ )
836
+ }
803
837
  }
804
838
  videoCapturing = videoCapture!!.startCapture(StartCaptureCallback())
805
839
  }
@@ -808,7 +842,7 @@ class ThetaClientReactNativeModule(
808
842
  * stopCapture - stop capturing video
809
843
  */
810
844
  @ReactMethod
811
- fun stopCapture() {
845
+ fun stopVideoCapture() {
812
846
  if (theta == null) {
813
847
  throw Exception(messageNotInit)
814
848
  }
@@ -1474,5 +1508,7 @@ class ThetaClientReactNativeModule(
1474
1508
  const val NAME = "ThetaClientReactNative"
1475
1509
  const val EVENT_NAME = "ThetaFrameEvent"
1476
1510
  const val EVENT_NOTIFY = "ThetaNotify"
1511
+ const val NOTIFY_TIMESHIFT_PROGRESS = "TIME-SHIFT-PROGRESS"
1512
+ const val NOTIFY_VIDEO_CAPTURE_STOP_ERROR = "VIDEO-CAPTURE-STOP-ERROR"
1477
1513
  }
1478
1514
  }