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
@@ -0,0 +1,1053 @@
1
+ import THETAClient
2
+ import UIKit
3
+
4
+ let KEY_CLIENT_MODE = "clientMode"
5
+ let KEY_NOTIFY_NAME = "name"
6
+ let KEY_NOTIFY_PARAMS = "params"
7
+ let KEY_NOTIFY_PARAM_COMPLETION = "completion"
8
+ let KEY_NOTIFY_PARAM_IMAGE = "image"
9
+ let KEY_NOTIFY_PARAM_MESSAGE = "message"
10
+ let KEY_DATETIME = "dateTime"
11
+ let KEY_LANGUAGE = "language"
12
+ let KEY_OFF_DELAY = "offDelay"
13
+ let KEY_SLEEP_DELAY = "sleepDelay"
14
+ let KEY_SHUTTER_VOLUME = "shutterVolume"
15
+ let KEY_CONNECT_TIMEOUT = "connectTimeout"
16
+ let KEY_REQUEST_TIMEOUT = "requestTimeout"
17
+ let KEY_SOCKET_TIMEOUT = "socketTimeout"
18
+ let KEY_THETA_MODEL = "thetaModel"
19
+ let KEY_TIMESHIFT = "timeShift"
20
+ let KEY_APERTURE = "aperture"
21
+ let KEY_CAPTURE_INTERVAL = "captureInterval"
22
+ let KEY_COLOR_TEMPERATURE = "colorTemperature"
23
+ let KEY_EXPOSURE_COMPENSATION = "exposureCompensation"
24
+ let KEY_EXPOSURE_DELAY = "exposureDelay"
25
+ let KEY_EXPOSURE_PROGRAM = "exposureProgram"
26
+ let KEY_GPS_INFO = "gpsInfo"
27
+ let KEY_GPS_TAG_RECORDING = "_gpsTagRecording"
28
+ let KEY_ISO = "iso"
29
+ let KEY_ISO_AUTO_HIGH_LIMIT = "isoAutoHighLimit"
30
+ let KEY_WHITE_BALANCE = "whiteBalance"
31
+ let KEY_FILE_FORMAT = "fileFormat"
32
+ let KEY_FILTER = "filter"
33
+ let KEY_FILE_LIST = "fileList"
34
+ let KEY_PRESET = "preset"
35
+ let KEY_GPS_LATITUDE = "latitude"
36
+ let KEY_GPS_LONGITUDE = "longitude"
37
+ let KEY_GPS_ALTITUDE = "altitude"
38
+ let KEY_GPS_DATE_TIME_ZONE = "dateTimeZone"
39
+ let KEY_MAX_RECORDABLE_TIME = "maxRecordableTime"
40
+ let KEY_TOTAL_ENTRIES = "totalEntries"
41
+ let KEY_TIMESHIFT_IS_FRONT_FIRST = "isFrontFirst"
42
+ let KEY_TIMESHIFT_FIRST_INTERVAL = "firstInterval"
43
+ let KEY_TIMESHIFT_SECOND_INTERVAL = "secondInterval"
44
+ let KEY_PROXY_USE = "use"
45
+ let KEY_PROXY_URL = "url"
46
+ let KEY_PROXY_PORT = "port"
47
+ let KEY_PROXY_USER_ID = "userid"
48
+ let KEY_PROXY_PASSWORD = "password"
49
+ let KEY_BURST_CAPTURE_NUM = "burstCaptureNum"
50
+ let KEY_BURST_BRACKET_STEP = "burstBracketStep"
51
+ let KEY_BURST_COMPENSATION = "burstCompensation"
52
+ let KEY_BURST_MAX_EXPOSURE_TIME = "burstMaxExposureTime"
53
+ let KEY_BURST_ENABLE_ISO_CONTROL = "burstEnableIsoControl"
54
+ let KEY_BURST_ORDER = "burstOrder"
55
+ let KEY_TOP_BOTTOM_CORRECTION_ROTATION_PITCH = "pitch"
56
+ let KEY_TOP_BOTTOM_CORRECTION_ROTATION_ROLL = "roll"
57
+ let KEY_TOP_BOTTOM_CORRECTION_ROTATION_YAW = "yaw"
58
+ let KEY_TIMESHIFT_CAPTURE_INTERVAL = "_capture_interval"
59
+
60
+ public class ConvertUtil: NSObject {}
61
+
62
+ // MARK: - Options convert
63
+
64
+ let optionItemNameToEnum = [
65
+ // TODO: Add items when adding options
66
+ "aiAutoThumbnail": ThetaRepository.OptionNameEnum.aiautothumbnail,
67
+ "aperture": ThetaRepository.OptionNameEnum.aperture,
68
+ "bitrate": ThetaRepository.OptionNameEnum.bitrate,
69
+ "bluetoothPower": ThetaRepository.OptionNameEnum.bluetoothpower,
70
+ "burstMode": ThetaRepository.OptionNameEnum.burstmode,
71
+ "burstOption": ThetaRepository.OptionNameEnum.burstoption,
72
+ "cameraControlSource": ThetaRepository.OptionNameEnum.cameracontrolsource,
73
+ "cameraMode": ThetaRepository.OptionNameEnum.cameramode,
74
+ "captureInterval": ThetaRepository.OptionNameEnum.captureinterval,
75
+ "captureMode": ThetaRepository.OptionNameEnum.capturemode,
76
+ "captureNumber": ThetaRepository.OptionNameEnum.capturenumber,
77
+ "colorTemperature": ThetaRepository.OptionNameEnum.colortemperature,
78
+ "compositeShootingOutputInterval": ThetaRepository.OptionNameEnum
79
+ .compositeshootingoutputinterval,
80
+ "compositeShootingTime": ThetaRepository.OptionNameEnum.compositeshootingtime,
81
+ "continuousNumber": ThetaRepository.OptionNameEnum.continuousnumber,
82
+ "dateTimeZone": ThetaRepository.OptionNameEnum.datetimezone,
83
+ "exposureCompensation": ThetaRepository.OptionNameEnum.exposurecompensation,
84
+ "exposureDelay": ThetaRepository.OptionNameEnum.exposuredelay,
85
+ "exposureProgram": ThetaRepository.OptionNameEnum.exposureprogram,
86
+ "faceDetect": ThetaRepository.OptionNameEnum.facedetect,
87
+ "fileFormat": ThetaRepository.OptionNameEnum.fileformat,
88
+ "filter": ThetaRepository.OptionNameEnum.filter,
89
+ "function": ThetaRepository.OptionNameEnum.function,
90
+ "gain": ThetaRepository.OptionNameEnum.gain,
91
+ "gpsInfo": ThetaRepository.OptionNameEnum.gpsinfo,
92
+ "imageStitching": ThetaRepository.OptionNameEnum.imagestitching,
93
+ "isGpsOn": ThetaRepository.OptionNameEnum.isgpson,
94
+ "iso": ThetaRepository.OptionNameEnum.iso,
95
+ "isoAutoHighLimit": ThetaRepository.OptionNameEnum.isoautohighlimit,
96
+ "language": ThetaRepository.OptionNameEnum.language,
97
+ "latestEnabledExposureDelayTime": ThetaRepository.OptionNameEnum.latestenabledexposuredelaytime,
98
+ "maxRecordableTime": ThetaRepository.OptionNameEnum.maxrecordabletime,
99
+ "networkType": ThetaRepository.OptionNameEnum.networktype,
100
+ "offDelay": ThetaRepository.OptionNameEnum.offdelay,
101
+ "password": ThetaRepository.OptionNameEnum.password,
102
+ "powerSaving": ThetaRepository.OptionNameEnum.powersaving,
103
+ "preset": ThetaRepository.OptionNameEnum.preset,
104
+ "previewFormat": ThetaRepository.OptionNameEnum.previewformat,
105
+ "proxy": ThetaRepository.OptionNameEnum.proxy,
106
+ "remainingPictures": ThetaRepository.OptionNameEnum.remainingpictures,
107
+ "remainingVideoSeconds": ThetaRepository.OptionNameEnum.remainingvideoseconds,
108
+ "remainingSpace": ThetaRepository.OptionNameEnum.remainingspace,
109
+ "shootingMethod": ThetaRepository.OptionNameEnum.shootingmethod,
110
+ "shutterSpeed": ThetaRepository.OptionNameEnum.shutterspeed,
111
+ "shutterVolume": ThetaRepository.OptionNameEnum.shuttervolume,
112
+ "sleepDelay": ThetaRepository.OptionNameEnum.sleepdelay,
113
+ "timeShift": ThetaRepository.OptionNameEnum.timeshift,
114
+ "topBottomCorrection": ThetaRepository.OptionNameEnum.topbottomcorrection,
115
+ "topBottomCorrectionRotation": ThetaRepository.OptionNameEnum.topbottomcorrectionrotation,
116
+ "totalSpace": ThetaRepository.OptionNameEnum.totalspace,
117
+ "username": ThetaRepository.OptionNameEnum.username,
118
+ "videoStitching": ThetaRepository.OptionNameEnum.videostitching,
119
+ "visibilityReduction": ThetaRepository.OptionNameEnum.visibilityreduction,
120
+ "whiteBalance": ThetaRepository.OptionNameEnum.whitebalance,
121
+ "whiteBalanceAutoStrength": ThetaRepository.OptionNameEnum.whitebalanceautostrength,
122
+ "wlanFrequency": ThetaRepository.OptionNameEnum.wlanfrequency,
123
+ ]
124
+
125
+ let optionNameEnumToItemName = {
126
+ var map = [ThetaRepository.OptionNameEnum: String]()
127
+ optionItemNameToEnum.forEach { tuple in
128
+ map[tuple.value] = tuple.key
129
+ }
130
+ return map
131
+ }()
132
+
133
+ func convertGetOptionsParam(params: [String]) -> [ThetaRepository.OptionNameEnum] {
134
+ var array: [ThetaRepository.OptionNameEnum] = []
135
+ let values = ThetaRepository.OptionNameEnum.values()
136
+ for name in params {
137
+ if let nameEnum = getEnumValue(values: values, name: name) {
138
+ array.append(nameEnum)
139
+ }
140
+ }
141
+ return array
142
+ }
143
+
144
+ func convertSetOptionsParam(params: [String: Any]) -> ThetaRepository.Options {
145
+ let options = ThetaRepository.Options()
146
+ params.forEach { key, value in
147
+ if let nameEnum = optionItemNameToEnum[key] {
148
+ setOptionsValue(options: options, name: nameEnum.name, value: value)
149
+ }
150
+ }
151
+ return options
152
+ }
153
+
154
+ func setOptionsValue(options: ThetaRepository.Options, name: String, value: Any) {
155
+ // TODO: Add items when adding options
156
+ switch name {
157
+ case ThetaRepository.OptionNameEnum.aiautothumbnail.name:
158
+ options.aiAutoThumbnail = getEnumValue(
159
+ values: ThetaRepository.AiAutoThumbnailEnum.values(), name: value as! String
160
+ )!
161
+ case ThetaRepository.OptionNameEnum.aperture.name:
162
+ options.aperture = getEnumValue(
163
+ values: ThetaRepository.ApertureEnum.values(), name: value as! String
164
+ )!
165
+ case ThetaRepository.OptionNameEnum.bitrate.name:
166
+ options.bitrate = toBitrate(value: value)
167
+ case ThetaRepository.OptionNameEnum.bluetoothpower.name:
168
+ options.bluetoothPower = getEnumValue(
169
+ values: ThetaRepository.BluetoothPowerEnum.values(), name: value as! String
170
+ )!
171
+ case ThetaRepository.OptionNameEnum.burstmode.name:
172
+ options.burstMode = getEnumValue(
173
+ values: ThetaRepository.BurstModeEnum.values(), name: value as! String
174
+ )!
175
+ case ThetaRepository.OptionNameEnum.burstoption.name:
176
+ if let params = value as? [String: Any] {
177
+ options.burstOption = toBurstOption(params: params)
178
+ }
179
+ case ThetaRepository.OptionNameEnum.cameracontrolsource.name:
180
+ options.cameraControlSource = getEnumValue(
181
+ values: ThetaRepository.CameraControlSourceEnum.values(), name: value as! String
182
+ )!
183
+ case ThetaRepository.OptionNameEnum.cameramode.name:
184
+ options.cameraMode = getEnumValue(
185
+ values: ThetaRepository.CameraModeEnum.values(), name: value as! String
186
+ )!
187
+ case ThetaRepository.OptionNameEnum.captureinterval.name:
188
+ options.captureInterval = KotlinInt(integerLiteral: value as! Int)
189
+ case ThetaRepository.OptionNameEnum.capturemode.name:
190
+ options.captureMode = getEnumValue(
191
+ values: ThetaRepository.CaptureModeEnum.values(), name: value as! String
192
+ )!
193
+ case ThetaRepository.OptionNameEnum.capturenumber.name:
194
+ options.captureNumber = KotlinInt(integerLiteral: value as! Int)
195
+ case ThetaRepository.OptionNameEnum.colortemperature.name:
196
+ options.colorTemperature = KotlinInt(integerLiteral: value as! Int)
197
+ case ThetaRepository.OptionNameEnum.compositeshootingoutputinterval.name:
198
+ options.compositeShootingOutputInterval = KotlinInt(integerLiteral: value as! Int)
199
+ case ThetaRepository.OptionNameEnum.compositeshootingtime.name:
200
+ options.compositeShootingTime = KotlinInt(integerLiteral: value as! Int)
201
+ case ThetaRepository.OptionNameEnum.continuousnumber.name:
202
+ options.continuousNumber = getEnumValue(
203
+ values: ThetaRepository.ContinuousNumberEnum.values(), name: value as! String
204
+ )!
205
+ case ThetaRepository.OptionNameEnum.datetimezone.name:
206
+ options.dateTimeZone = value as? String
207
+ case ThetaRepository.OptionNameEnum.exposurecompensation.name:
208
+ options.exposureCompensation = getEnumValue(
209
+ values: ThetaRepository.ExposureCompensationEnum.values(), name: value as! String
210
+ )!
211
+ case ThetaRepository.OptionNameEnum.exposuredelay.name:
212
+ options.exposureDelay = getEnumValue(
213
+ values: ThetaRepository.ExposureDelayEnum.values(), name: value as! String
214
+ )!
215
+ case ThetaRepository.OptionNameEnum.exposureprogram.name:
216
+ options.exposureProgram = getEnumValue(
217
+ values: ThetaRepository.ExposureProgramEnum.values(), name: value as! String
218
+ )!
219
+ case ThetaRepository.OptionNameEnum.facedetect.name:
220
+ options.faceDetect = getEnumValue(
221
+ values: ThetaRepository.FaceDetectEnum.values(), name: value as! String
222
+ )!
223
+ case ThetaRepository.OptionNameEnum.fileformat.name:
224
+ options.fileFormat = getEnumValue(
225
+ values: ThetaRepository.FileFormatEnum.values(), name: value as! String
226
+ )!
227
+ case ThetaRepository.OptionNameEnum.filter.name:
228
+ options.filter = getEnumValue(
229
+ values: ThetaRepository.FilterEnum.values(), name: value as! String
230
+ )!
231
+ case ThetaRepository.OptionNameEnum.function.name:
232
+ options.function = getEnumValue(
233
+ values: ThetaRepository.ShootingFunctionEnum.values(), name: value as! String
234
+ )!
235
+ case ThetaRepository.OptionNameEnum.gain.name:
236
+ options.gain = getEnumValue(
237
+ values: ThetaRepository.GainEnum.values(), name: value as! String
238
+ )!
239
+ case ThetaRepository.OptionNameEnum.gpsinfo.name:
240
+ options.gpsInfo = toGpsInfo(params: value as! [String: Any])
241
+ case ThetaRepository.OptionNameEnum.imagestitching.name:
242
+ options.imageStitching = getEnumValue(
243
+ values: ThetaRepository.ImageStitchingEnum.values(), name: value as! String
244
+ )!
245
+ case ThetaRepository.OptionNameEnum.isgpson.name:
246
+ options.isGpsOn = (value as! Bool) ? true : false
247
+ case ThetaRepository.OptionNameEnum.iso.name:
248
+ options.iso = getEnumValue(
249
+ values: ThetaRepository.IsoEnum.values(), name: value as! String
250
+ )!
251
+ case ThetaRepository.OptionNameEnum.isoautohighlimit.name:
252
+ options.isoAutoHighLimit = getEnumValue(
253
+ values: ThetaRepository.IsoAutoHighLimitEnum.values(), name: value as! String
254
+ )!
255
+ case ThetaRepository.OptionNameEnum.language.name:
256
+ options.language = getEnumValue(
257
+ values: ThetaRepository.LanguageEnum.values(), name: value as! String
258
+ )!
259
+ case ThetaRepository.OptionNameEnum.latestenabledexposuredelaytime.name:
260
+ options.latestEnabledExposureDelayTime = getEnumValue(
261
+ values: ThetaRepository.ExposureDelayEnum.values(), name: value as! String
262
+ )!
263
+ case ThetaRepository.OptionNameEnum.maxrecordabletime.name:
264
+ options.maxRecordableTime = getEnumValue(
265
+ values: ThetaRepository.MaxRecordableTimeEnum.values(), name: value as! String
266
+ )!
267
+ case ThetaRepository.OptionNameEnum.networktype.name:
268
+ options.networkType = getEnumValue(
269
+ values: ThetaRepository.NetworkTypeEnum.values(), name: value as! String
270
+ )!
271
+ case ThetaRepository.OptionNameEnum.offdelay.name:
272
+ options.offDelay = getEnumValue(
273
+ values: ThetaRepository.OffDelayEnum.values(), name: value as! String
274
+ )!
275
+ case ThetaRepository.OptionNameEnum.password.name:
276
+ options.password = value as? String
277
+ case ThetaRepository.OptionNameEnum.powersaving.name:
278
+ options.powerSaving = getEnumValue(
279
+ values: ThetaRepository.PowerSavingEnum.values(), name: value as! String
280
+ )!
281
+ case ThetaRepository.OptionNameEnum.preset.name:
282
+ options.preset = getEnumValue(
283
+ values: ThetaRepository.PresetEnum.values(), name: value as! String
284
+ )!
285
+ case ThetaRepository.OptionNameEnum.previewformat.name:
286
+ options.previewFormat = getEnumValue(
287
+ values: ThetaRepository.PreviewFormatEnum.values(), name: value as! String
288
+ )!
289
+ case ThetaRepository.OptionNameEnum.proxy.name:
290
+ if let params = value as? [String: Any] {
291
+ options.proxy = toProxy(params: params)
292
+ }
293
+ case ThetaRepository.OptionNameEnum.remainingpictures.name:
294
+ options.remainingPictures = KotlinInt(integerLiteral: value as! Int)
295
+ case ThetaRepository.OptionNameEnum.remainingvideoseconds.name:
296
+ options.remainingVideoSeconds = KotlinInt(integerLiteral: value as! Int)
297
+ case ThetaRepository.OptionNameEnum.remainingspace.name:
298
+ options.remainingSpace = KotlinLong(integerLiteral: value as! Int)
299
+ case ThetaRepository.OptionNameEnum.shootingmethod.name:
300
+ options.shootingMethod = getEnumValue(
301
+ values: ThetaRepository.ShootingMethodEnum.values(), name: value as! String
302
+ )!
303
+ case ThetaRepository.OptionNameEnum.shutterspeed.name:
304
+ options.shutterSpeed = getEnumValue(
305
+ values: ThetaRepository.ShutterSpeedEnum.values(), name: value as! String
306
+ )!
307
+ case ThetaRepository.OptionNameEnum.shuttervolume.name:
308
+ options.shutterVolume = KotlinInt(integerLiteral: value as! Int)
309
+ case ThetaRepository.OptionNameEnum.sleepdelay.name:
310
+ options.sleepDelay = getEnumValue(
311
+ values: ThetaRepository.SleepDelayEnum.values(), name: value as! String
312
+ )!
313
+ case ThetaRepository.OptionNameEnum.timeshift.name:
314
+ if let params = value as? [String: Any] {
315
+ options.timeShift = toTimeShift(params: params)
316
+ }
317
+ case ThetaRepository.OptionNameEnum.topbottomcorrection.name:
318
+ options.topBottomCorrection = getEnumValue(values: ThetaRepository.TopBottomCorrectionOptionEnum.values(), name: value as! String)!
319
+ case ThetaRepository.OptionNameEnum.topbottomcorrectionrotation.name:
320
+ options.topBottomCorrectionRotation = toTopBottomCorrectionRotation(params: value as! [String: Any])
321
+ case ThetaRepository.OptionNameEnum.totalspace.name:
322
+ options.totalSpace = KotlinLong(integerLiteral: value as! Int)
323
+ case ThetaRepository.OptionNameEnum.username.name:
324
+ options.username = value as? String
325
+ case ThetaRepository.OptionNameEnum.videostitching.name:
326
+ options.videoStitching = getEnumValue(
327
+ values: ThetaRepository.VideoStitchingEnum.values(), name: value as! String
328
+ )!
329
+ case ThetaRepository.OptionNameEnum.visibilityreduction.name:
330
+ options.visibilityReduction = getEnumValue(
331
+ values: ThetaRepository.VisibilityReductionEnum.values(), name: value as! String
332
+ )!
333
+ case ThetaRepository.OptionNameEnum.whitebalance.name:
334
+ options.whiteBalance = getEnumValue(
335
+ values: ThetaRepository.WhiteBalanceEnum.values(), name: value as! String
336
+ )!
337
+ case ThetaRepository.OptionNameEnum.whitebalanceautostrength.name:
338
+ options.whiteBalanceAutoStrength = getEnumValue(
339
+ values: ThetaRepository.WhiteBalanceAutoStrengthEnum.values(), name: value as! String
340
+ )!
341
+ case ThetaRepository.OptionNameEnum.wlanfrequency.name:
342
+ options.wlanFrequency = getEnumValue(
343
+ values: ThetaRepository.WlanFrequencyEnum.values(), name: value as! String
344
+ )!
345
+ default: break
346
+ }
347
+ }
348
+
349
+ func convertResult(options: ThetaRepository.Options) -> [String: Any] {
350
+ var result = [String: Any]()
351
+ let nameList = ThetaRepository.OptionNameEnum.values()
352
+ for i in 0 ..< nameList.size {
353
+ if let name = nameList.get(index: i),
354
+ let key = optionNameEnumToItemName[name]
355
+ {
356
+ if let value = try? options.getValue(name: name) {
357
+ if let enumValue = value as? KotlinEnum<AnyObject> {
358
+ result[key] = enumValue.name
359
+ } else if value is KotlinBoolean {
360
+ result[key] = value as! Bool ? true : false
361
+ } else if value is NSNumber || value is String {
362
+ result[key] = value
363
+ } else if let bitrate = value as? ThetaRepository.BitrateNumber {
364
+ result[key] = bitrate.value
365
+ } else if value is ThetaRepository.BurstOption,
366
+ let burstOption = value as? ThetaRepository.BurstOption
367
+ {
368
+ result[key] = convertResult(burstOption: burstOption)
369
+ } else if value is ThetaRepository.GpsInfo {
370
+ let gpsInfo = value as! ThetaRepository.GpsInfo
371
+ result[key] = convertResult(gpsInfo: gpsInfo)
372
+ } else if value is ThetaRepository.Proxy,
373
+ let proxy = value as? ThetaRepository.Proxy
374
+ {
375
+ result[key] = convertResult(proxy: proxy)
376
+ } else if value is ThetaRepository.TimeShiftSetting,
377
+ let timeshift = value as? ThetaRepository.TimeShiftSetting
378
+ {
379
+ result[key] = convertResult(timeshift: timeshift)
380
+ } else if value is ThetaRepository.TopBottomCorrectionRotation, let rotation = value as? ThetaRepository.TopBottomCorrectionRotation {
381
+ result[key] = convertResult(rotation: rotation)
382
+ } else if let offDelay = value as? ThetaRepository.OffDelaySec {
383
+ result[key] =
384
+ offDelay.sec == 0 ? ThetaRepository.OffDelayEnum.disable.name : offDelay.sec
385
+ } else if let sleepDelay = value as? ThetaRepository.SleepDelaySec {
386
+ result[key] =
387
+ sleepDelay.sec == 0
388
+ ? ThetaRepository.SleepDelayEnum.disable.name : sleepDelay.sec
389
+ }
390
+ // TODO: Add class item when adding options
391
+ }
392
+ }
393
+ }
394
+ return result
395
+ }
396
+
397
+ // MARK: - Notify event
398
+
399
+ func toNotify(name: String, params: [String: Any]?) -> [String: Any] {
400
+ var result: [String: Any] = [
401
+ KEY_NOTIFY_NAME: name,
402
+ ]
403
+ if let params = params {
404
+ result[KEY_NOTIFY_PARAMS] = params
405
+ }
406
+ return result
407
+ }
408
+
409
+ func toCaptureProgressNotifyParam(value: Float) -> [String: Any] {
410
+ return [
411
+ KEY_NOTIFY_PARAM_COMPLETION: value,
412
+ ]
413
+ }
414
+
415
+ func toMessageNotifyParam(value: String) -> [String: Any] {
416
+ return [
417
+ KEY_NOTIFY_PARAM_MESSAGE: value,
418
+ ]
419
+ }
420
+
421
+ // MARK: - Capture builder
422
+
423
+ func setCaptureBuilderParams<T>(params: [String: Any], builder: CaptureBuilder<T>) {
424
+ if let value = params[KEY_APERTURE] as? String {
425
+ if let enumValue = getEnumValue(values: ThetaRepository.ApertureEnum.values(), name: value)
426
+ {
427
+ builder.setAperture(aperture: enumValue)
428
+ }
429
+ }
430
+ if let value = params[KEY_COLOR_TEMPERATURE] as? Int32 {
431
+ builder.setColorTemperature(kelvin: value)
432
+ }
433
+ if let value = params[KEY_EXPOSURE_COMPENSATION] as? String {
434
+ if let enumValue = getEnumValue(
435
+ values: ThetaRepository.ExposureCompensationEnum.values(), name: value
436
+ ) {
437
+ builder.setExposureCompensation(value: enumValue)
438
+ }
439
+ }
440
+ if let value = params[KEY_EXPOSURE_DELAY] as? String {
441
+ if let enumValue = getEnumValue(
442
+ values: ThetaRepository.ExposureDelayEnum.values(), name: value
443
+ ) {
444
+ builder.setExposureDelay(delay: enumValue)
445
+ }
446
+ }
447
+ if let value = params[KEY_EXPOSURE_PROGRAM] as? String {
448
+ if let enumValue = getEnumValue(
449
+ values: ThetaRepository.ExposureProgramEnum.values(), name: value
450
+ ) {
451
+ builder.setExposureProgram(program: enumValue)
452
+ }
453
+ }
454
+ if let value = params[KEY_GPS_INFO] as? [String: Any] {
455
+ if let gpsInfo = toGpsInfo(params: value) {
456
+ builder.setGpsInfo(gpsInfo: gpsInfo)
457
+ }
458
+ }
459
+ if let value = params[KEY_GPS_TAG_RECORDING] as? String {
460
+ if let enumValue = getEnumValue(
461
+ values: ThetaRepository.GpsTagRecordingEnum.values(), name: value
462
+ ) {
463
+ builder.setGpsTagRecording(value: enumValue)
464
+ }
465
+ }
466
+ if let value = params[KEY_ISO] as? String {
467
+ if let enumValue = getEnumValue(values: ThetaRepository.IsoEnum.values(), name: value) {
468
+ builder.setIso(iso: enumValue)
469
+ }
470
+ }
471
+ if let value = params[KEY_ISO_AUTO_HIGH_LIMIT] as? String {
472
+ if let enumValue = getEnumValue(
473
+ values: ThetaRepository.IsoAutoHighLimitEnum.values(), name: value
474
+ ) {
475
+ builder.setIsoAutoHighLimit(iso: enumValue)
476
+ }
477
+ }
478
+ if let value = params[KEY_WHITE_BALANCE] as? String {
479
+ if let enumValue = getEnumValue(
480
+ values: ThetaRepository.WhiteBalanceEnum.values(), name: value
481
+ ) {
482
+ builder.setWhiteBalance(whiteBalance: enumValue)
483
+ }
484
+ }
485
+ }
486
+
487
+ func setPhotoCaptureBuilderParams(params: [String: Any], builder: PhotoCapture.Builder) {
488
+ if let value = params[KEY_FILTER] as? String {
489
+ if let enumValue = getEnumValue(values: ThetaRepository.FilterEnum.values(), name: value) {
490
+ builder.setFilter(filter: enumValue)
491
+ }
492
+ }
493
+ if let value = params[KEY_FILE_FORMAT] as? String {
494
+ if let enumValue = getEnumValue(
495
+ values: ThetaRepository.PhotoFileFormatEnum.values(), name: value
496
+ ) {
497
+ builder.setFileFormat(fileFormat: enumValue)
498
+ }
499
+ }
500
+ if let value = params[KEY_PRESET] as? String {
501
+ if let enumValue = getEnumValue(values: ThetaRepository.PresetEnum.values(), name: value) {
502
+ builder.setPreset(preset: enumValue)
503
+ }
504
+ }
505
+ }
506
+
507
+ func setTimeShiftCaptureBuilderParams(params: [String: Any], builder: TimeShiftCapture.Builder) {
508
+ if let interval = params[KEY_TIMESHIFT_CAPTURE_INTERVAL] as? Int,
509
+ interval >= 0
510
+ {
511
+ builder.setCheckStatusCommandInterval(timeMillis: Int64(interval))
512
+ }
513
+ if let timeShiftParams = params[KEY_TIMESHIFT] as? [String: Any] {
514
+ let timeShift = toTimeShift(params: timeShiftParams)
515
+ if let isFrontFirst = timeShift.isFrontFirst {
516
+ builder.setIsFrontFirst(isFrontFirst: isFrontFirst.boolValue)
517
+ }
518
+ if let firstInterval = timeShift.firstInterval {
519
+ builder.setFirstInterval(interval: firstInterval)
520
+ }
521
+ if let secondInterval = timeShift.secondInterval {
522
+ builder.setSecondInterval(interval: secondInterval)
523
+ }
524
+ }
525
+ }
526
+
527
+ func setVideoCaptureBuilderParams(params: [String: Any], builder: VideoCapture.Builder) {
528
+ if let value = params[KEY_MAX_RECORDABLE_TIME] as? String {
529
+ if let enumValue = getEnumValue(
530
+ values: ThetaRepository.MaxRecordableTimeEnum.values(), name: value
531
+ ) {
532
+ builder.setMaxRecordableTime(time: enumValue)
533
+ }
534
+ }
535
+ if let value = params[KEY_FILE_FORMAT] as? String {
536
+ if let enumValue = getEnumValue(
537
+ values: ThetaRepository.VideoFileFormatEnum.values(), name: value
538
+ ) {
539
+ builder.setFileFormat(fileFormat: enumValue)
540
+ }
541
+ }
542
+ }
543
+
544
+ func setLimitlessIntervalCaptureBuilderParams(params: [String: Any], builder: LimitlessIntervalCapture.Builder) {
545
+ if let value = params[KEY_CAPTURE_INTERVAL] as? Int32 {
546
+ builder.setCaptureInterval(interval: value)
547
+ }
548
+ }
549
+
550
+ func setShotCountSpecifiedIntervalCaptureBuilderParams(params: [String: Any], builder: ShotCountSpecifiedIntervalCapture.Builder) {
551
+ if let interval = params[KEY_TIMESHIFT_CAPTURE_INTERVAL] as? Int,
552
+ interval >= 0
553
+ {
554
+ builder.setCheckStatusCommandInterval(timeMillis: Int64(interval))
555
+ }
556
+ if let value = params[KEY_CAPTURE_INTERVAL] as? Int32 {
557
+ builder.setCaptureInterval(interval: value)
558
+ }
559
+ }
560
+
561
+ // MARK: - Utility
562
+
563
+ func getEnumValue<T, E: KotlinEnum<T>>(values: KotlinArray<E>, name: String) -> E? {
564
+ for i in 0 ..< values.size {
565
+ let item = values.get(index: i)!
566
+ if item.name == name {
567
+ return item
568
+ }
569
+ }
570
+ return nil
571
+ }
572
+
573
+ func convertKotlinBooleanToBool(value: Any?) -> Bool? {
574
+ guard let value = value else { return nil }
575
+ guard value is KotlinBoolean, let numVal = value as? NSNumber else { return false }
576
+
577
+ return numVal.boolValue
578
+ }
579
+
580
+ func toKotlinInt(value: Any?) -> KotlinInt? {
581
+ guard let value = value as? Int else {
582
+ return nil
583
+ }
584
+ return KotlinInt(integerLiteral: value)
585
+ }
586
+
587
+ func toKotlinBoolean(value: Any?) -> KotlinBoolean? {
588
+ guard let value = value as? Bool else {
589
+ return nil
590
+ }
591
+ return KotlinBoolean(booleanLiteral: value)
592
+ }
593
+
594
+ // MARK: - Convert to react-native object
595
+
596
+ func convertResult(fileInfoList: [ThetaRepository.FileInfo]) -> [[String: Any]] {
597
+ var resultList = [[String: Any]]()
598
+ fileInfoList.forEach { fileInfo in
599
+ var item = [
600
+ "name": fileInfo.name,
601
+ "fileUrl": fileInfo.fileUrl,
602
+ "size": fileInfo.size,
603
+ "dateTime": fileInfo.dateTime,
604
+ "thumbnailUrl": fileInfo.thumbnailUrl,
605
+ ]
606
+ if let dateTimeZone = fileInfo.dateTimeZone {
607
+ item["dateTimeZone"] = dateTimeZone
608
+ }
609
+ if let lat = fileInfo.lat {
610
+ item["lat"] = lat.floatValue
611
+ }
612
+ if let lng = fileInfo.lng {
613
+ item["lng"] = lng.floatValue
614
+ }
615
+ if let width = fileInfo.width {
616
+ item["width"] = width.intValue
617
+ }
618
+ if let height = fileInfo.height {
619
+ item["height"] = height.intValue
620
+ }
621
+ if let intervalCaptureGroupId = fileInfo.intervalCaptureGroupId {
622
+ item["intervalCaptureGroupId"] = intervalCaptureGroupId
623
+ }
624
+ if let compositeShootingGroupId = fileInfo.compositeShootingGroupId {
625
+ item["compositeShootingGroupId"] = compositeShootingGroupId
626
+ }
627
+ if let autoBracketGroupId = fileInfo.autoBracketGroupId {
628
+ item["autoBracketGroupId"] = autoBracketGroupId
629
+ }
630
+ if let recordTime = fileInfo.recordTime {
631
+ item["recordTime"] = recordTime.intValue
632
+ }
633
+ if let isProcessed = fileInfo.isProcessed {
634
+ item["isProcessed"] = isProcessed.boolValue
635
+ }
636
+ if let previewUrl = fileInfo.previewUrl {
637
+ item["previewUrl"] = previewUrl
638
+ }
639
+ if let codec = fileInfo.codec {
640
+ item["codec"] = codec.name
641
+ }
642
+ if let projectionType = fileInfo.projectionType {
643
+ item["projectionType"] = projectionType.name
644
+ }
645
+ if let continuousShootingGroupId = fileInfo.continuousShootingGroupId {
646
+ item["continuousShootingGroupId"] = continuousShootingGroupId
647
+ }
648
+ if let frameRate = fileInfo.frameRate {
649
+ item["frameRate"] = frameRate.intValue
650
+ }
651
+ if let favorite = fileInfo.favorite {
652
+ item["favorite"] = favorite.boolValue
653
+ }
654
+ if let imageDescription = fileInfo.imageDescription {
655
+ item["imageDescription"] = imageDescription
656
+ }
657
+ if let storageID = fileInfo.storageID {
658
+ item["storageID"] = storageID
659
+ }
660
+ resultList.append(item)
661
+ }
662
+ return resultList
663
+ }
664
+
665
+ func convertResult(thetaInfo: ThetaRepository.ThetaInfo) -> [String: Any?] {
666
+ return [
667
+ "manufacturer": thetaInfo.manufacturer,
668
+ "model": thetaInfo.model,
669
+ "serialNumber": thetaInfo.serialNumber,
670
+ "wlanMacAddress": thetaInfo.wlanMacAddress,
671
+ "bluetoothMacAddress": thetaInfo.bluetoothMacAddress,
672
+ "firmwareVersion": thetaInfo.firmwareVersion,
673
+ "supportUrl": thetaInfo.supportUrl,
674
+ "hasGps": thetaInfo.hasGps,
675
+ "hasGyro": thetaInfo.hasGyro,
676
+ "uptime": thetaInfo.uptime,
677
+ "api": thetaInfo.api,
678
+ "endpoints": [
679
+ "httpPort": thetaInfo.endpoints.httpPort,
680
+ "httpUpdatesPort": thetaInfo.endpoints.httpUpdatesPort,
681
+ ],
682
+ "apiLevel": thetaInfo.apiLevel,
683
+ ]
684
+ }
685
+
686
+ func convertResult(cameraErrorList: [ThetaRepository.CameraErrorEnum]?) -> [String]? {
687
+ guard let cameraErrorList = cameraErrorList else {
688
+ return nil
689
+ }
690
+ var result: [String] = []
691
+ cameraErrorList.forEach { error in
692
+ result.append(error.name)
693
+ }
694
+ return result
695
+ }
696
+
697
+ func convertResult(thetaState: ThetaRepository.ThetaState) -> [String: Any?] {
698
+ return [
699
+ "fingerprint": thetaState.fingerprint,
700
+ "batteryLevel": thetaState.batteryLevel,
701
+ "storageUri": thetaState.storageUri,
702
+ "storageID": thetaState.storageID,
703
+ "captureStatus": thetaState.captureStatus.name,
704
+ "recordedTime": thetaState.recordedTime,
705
+ "recordableTime": thetaState.recordableTime,
706
+ "capturedPictures": thetaState.capturedPictures,
707
+ "compositeShootingElapsedTime": thetaState.compositeShootingElapsedTime,
708
+ "latestFileUrl": thetaState.latestFileUrl,
709
+ "chargingState": thetaState.chargingState.name,
710
+ "apiVersion": thetaState.apiVersion,
711
+ "isPluginRunning": convertKotlinBooleanToBool(value: thetaState.isPluginRunning),
712
+ "isPluginWebServer": convertKotlinBooleanToBool(value: thetaState.isPluginWebServer),
713
+ "function": thetaState.function?.name,
714
+ "isMySettingChanged": convertKotlinBooleanToBool(value: thetaState.isMySettingChanged),
715
+ "currentMicrophone": thetaState.currentMicrophone?.name,
716
+ "isSdCard": convertKotlinBooleanToBool(value: thetaState.isSdCard),
717
+ "cameraError": convertResult(cameraErrorList: thetaState.cameraError),
718
+ "isBatteryInsert": convertKotlinBooleanToBool(value: thetaState.isBatteryInsert),
719
+ ]
720
+ }
721
+
722
+ func convertResult(burstOption: ThetaRepository.BurstOption) -> [String: Any] {
723
+ var result: [String: Any] = [:]
724
+ if let burstCaptureNum = burstOption.burstCaptureNum {
725
+ result[KEY_BURST_CAPTURE_NUM] = burstCaptureNum.value.name
726
+ }
727
+ if let burstBracketStep = burstOption.burstBracketStep {
728
+ result[KEY_BURST_BRACKET_STEP] = burstBracketStep.value.name
729
+ }
730
+ if let burstCompensation = burstOption.burstCompensation {
731
+ result[KEY_BURST_COMPENSATION] = burstCompensation.value.name
732
+ }
733
+ if let burstMaxExposureTime = burstOption.burstMaxExposureTime {
734
+ result[KEY_BURST_MAX_EXPOSURE_TIME] = burstMaxExposureTime.value.name
735
+ }
736
+ if let burstEnableIsoControl = burstOption.burstEnableIsoControl {
737
+ result[KEY_BURST_ENABLE_ISO_CONTROL] = burstEnableIsoControl.value.name
738
+ }
739
+ if let burstOrder = burstOption.burstOrder {
740
+ result[KEY_BURST_ORDER] = burstOrder.value.name
741
+ }
742
+ return result
743
+ }
744
+
745
+ func convertResult(gpsInfo: ThetaRepository.GpsInfo) -> [String: Any] {
746
+ return [
747
+ "latitude": gpsInfo.latitude,
748
+ "longitude": gpsInfo.longitude,
749
+ "altitude": gpsInfo.altitude,
750
+ "dateTimeZone": gpsInfo.dateTimeZone,
751
+ ]
752
+ }
753
+
754
+ func convertResult(proxy: ThetaRepository.Proxy) -> [String: Any] {
755
+ var result: [String: Any] = [:]
756
+ result[KEY_PROXY_USE] = proxy.use
757
+ if let url = proxy.url {
758
+ result[KEY_PROXY_URL] = url
759
+ }
760
+ if let port = proxy.port {
761
+ result[KEY_PROXY_PORT] = port
762
+ }
763
+ if let userId = proxy.userid {
764
+ result[KEY_PROXY_USER_ID] = userId
765
+ }
766
+ if let password = proxy.password {
767
+ result[KEY_PROXY_PASSWORD] = password
768
+ }
769
+ return result
770
+ }
771
+
772
+ func convertResult(timeshift: ThetaRepository.TimeShiftSetting) -> [String: Any] {
773
+ var result: [String: Any] = [:]
774
+ if let isFrontFirst = convertKotlinBooleanToBool(value: timeshift.isFrontFirst) {
775
+ result[KEY_TIMESHIFT_IS_FRONT_FIRST] = isFrontFirst
776
+ }
777
+ if let firstInterval = timeshift.firstInterval?.name {
778
+ result[KEY_TIMESHIFT_FIRST_INTERVAL] = firstInterval
779
+ }
780
+ if let secondInterval = timeshift.secondInterval?.name {
781
+ result[KEY_TIMESHIFT_SECOND_INTERVAL] = secondInterval
782
+ }
783
+ return result
784
+ }
785
+
786
+ func convertResult(rotation: ThetaRepository.TopBottomCorrectionRotation) -> [String: Any] {
787
+ return [
788
+ KEY_TOP_BOTTOM_CORRECTION_ROTATION_PITCH: rotation.pitch,
789
+ KEY_TOP_BOTTOM_CORRECTION_ROTATION_ROLL: rotation.roll,
790
+ KEY_TOP_BOTTOM_CORRECTION_ROTATION_YAW: rotation.yaw,
791
+ ]
792
+ }
793
+
794
+ func convertResult(exif: ThetaRepository.Exif) -> [String: Any] {
795
+ var result = [String: Any]()
796
+ result["exifVersion"] = exif.exifVersion
797
+ result["dateTime"] = exif.dateTime
798
+ if let imageWidth = exif.imageWidth {
799
+ result["imageWidth"] = imageWidth
800
+ }
801
+ if let imageLength = exif.imageLength {
802
+ result["imageLength"] = imageLength
803
+ }
804
+ if let gpsLatitude = exif.gpsLatitude {
805
+ result["gpsLatitude"] = gpsLatitude
806
+ }
807
+ if let gpsLongitude = exif.gpsLongitude {
808
+ result["gpsLongitude"] = gpsLongitude
809
+ }
810
+ return result
811
+ }
812
+
813
+ func convertResult(xmp: ThetaRepository.Xmp) -> [String: Any] {
814
+ var result = [String: Any]()
815
+ result["fullPanoWidthPixels"] = xmp.fullPanoWidthPixels
816
+ result["fullPanoHeightPixels"] = xmp.fullPanoHeightPixels
817
+ if let poseHeadingDegrees = xmp.poseHeadingDegrees {
818
+ result["poseHeadingDegrees"] = poseHeadingDegrees
819
+ }
820
+ return result
821
+ }
822
+
823
+ func convertResult(metadata: KotlinPair<ThetaRepository.Exif, ThetaRepository.Xmp>) -> [String: Any]
824
+ {
825
+ return [
826
+ "exif": convertResult(exif: metadata.first!),
827
+ "xmp": convertResult(xmp: metadata.second!),
828
+ ]
829
+ }
830
+
831
+ func convertResult(accessPointList: [ThetaRepository.AccessPoint]) -> [[String: Any]] {
832
+ var resultList = [[String: Any]]()
833
+ accessPointList.forEach { accessPoint in
834
+ var result = [String: Any]()
835
+ result["ssid"] = accessPoint.ssid
836
+ result["ssidStealth"] = accessPoint.ssidStealth
837
+ result["authMode"] = accessPoint.authMode.name
838
+ result["connectionPriority"] = accessPoint.connectionPriority
839
+ result["usingDhcp"] = accessPoint.usingDhcp
840
+ if let ipAddress = accessPoint.ipAddress {
841
+ result["ipAddress"] = ipAddress
842
+ }
843
+ if let subnetMask = accessPoint.subnetMask {
844
+ result["subnetMask"] = subnetMask
845
+ }
846
+ if let defaultGateway = accessPoint.defaultGateway {
847
+ result["defaultGateway"] = defaultGateway
848
+ }
849
+ if let proxy = accessPoint.proxy {
850
+ result["proxy"] = convertResult(proxy: proxy)
851
+ }
852
+ resultList.append(result)
853
+ }
854
+ return resultList
855
+ }
856
+
857
+ func toPluginInfosResult(pluginInfoList: [ThetaRepository.PluginInfo]) -> [[String: Any]] {
858
+ var resultList = [[String: Any]]()
859
+ pluginInfoList.forEach { pluginInfo in
860
+ let item = [
861
+ "name": pluginInfo.name,
862
+ "packageName": pluginInfo.packageName,
863
+ "version": pluginInfo.version,
864
+ "isPreInstalled": pluginInfo.isPreInstalled,
865
+ "isRunning": pluginInfo.isRunning,
866
+ "isForeground": pluginInfo.isForeground,
867
+ "isBoot": pluginInfo.isBoot,
868
+ "hasWebServer": pluginInfo.hasWebServer,
869
+ "exitStatus": pluginInfo.exitStatus,
870
+ "message": pluginInfo.message,
871
+ ]
872
+ resultList.append(item)
873
+ }
874
+ return resultList
875
+ }
876
+
877
+ // MARK: - Convert to theta-client object
878
+
879
+ func toBitrate(value: Any) -> ThetaRepositoryBitrate? {
880
+ if value is NSNumber, let intVal = value as? Int32 {
881
+ return ThetaRepository.BitrateNumber(value: intVal)
882
+ } else if let name = value as? String,
883
+ let enumValue = getEnumValue(values: ThetaRepository.BitrateEnum.values(), name: name)
884
+ {
885
+ return enumValue
886
+ } else if let str = value as? String {
887
+ return ThetaRepository.BitrateEnum.companion.get(str: str)
888
+ } else {
889
+ return nil
890
+ }
891
+ }
892
+
893
+ func toBurstOption(params: [String: Any]) -> ThetaRepository.BurstOption {
894
+ var burstCaptureNum: ThetaRepository.BurstCaptureNumEnum? = nil
895
+ if let name = params["burstCaptureNum"] as? String {
896
+ burstCaptureNum = getEnumValue(
897
+ values: ThetaRepository.BurstCaptureNumEnum.values(), name: name
898
+ )
899
+ }
900
+
901
+ var burstBracketStep: ThetaRepository.BurstBracketStepEnum? = nil
902
+ if let name = params["burstBracketStep"] as? String {
903
+ burstBracketStep = getEnumValue(
904
+ values: ThetaRepository.BurstBracketStepEnum.values(), name: name
905
+ )
906
+ }
907
+
908
+ var burstCompensation: ThetaRepository.BurstCompensationEnum? = nil
909
+ if let name = params["burstCompensation"] as? String {
910
+ burstCompensation = getEnumValue(
911
+ values: ThetaRepository.BurstCompensationEnum.values(), name: name
912
+ )
913
+ }
914
+
915
+ var burstMaxExposureTime: ThetaRepository.BurstMaxExposureTimeEnum? = nil
916
+ if let name = params["burstMaxExposureTime"] as? String {
917
+ burstMaxExposureTime = getEnumValue(
918
+ values: ThetaRepository.BurstMaxExposureTimeEnum.values(), name: name
919
+ )
920
+ }
921
+
922
+ var burstEnableIsoControl: ThetaRepository.BurstEnableIsoControlEnum? = nil
923
+ if let name = params["burstEnableIsoControl"] as? String {
924
+ burstEnableIsoControl = getEnumValue(
925
+ values: ThetaRepository.BurstEnableIsoControlEnum.values(), name: name
926
+ )
927
+ }
928
+
929
+ var burstOrder: ThetaRepository.BurstOrderEnum? = nil
930
+ if let name = params["burstOrder"] as? String {
931
+ burstOrder = getEnumValue(values: ThetaRepository.BurstOrderEnum.values(), name: name)
932
+ }
933
+
934
+ return ThetaRepository.BurstOption(
935
+ burstCaptureNum: burstCaptureNum,
936
+ burstBracketStep: burstBracketStep,
937
+ burstCompensation: burstCompensation,
938
+ burstMaxExposureTime: burstMaxExposureTime,
939
+ burstEnableIsoControl: burstEnableIsoControl,
940
+ burstOrder: burstOrder
941
+ )
942
+ }
943
+
944
+ func toGpsInfo(params: [String: Any]) -> ThetaRepository.GpsInfo? {
945
+ guard let latitude = params[KEY_GPS_LATITUDE] as? Double,
946
+ let longitude = params[KEY_GPS_LONGITUDE] as? Double,
947
+ let altitude = params[KEY_GPS_ALTITUDE] as? Double,
948
+ let dateTimeZone = params[KEY_GPS_DATE_TIME_ZONE] as? String
949
+ else { return nil }
950
+
951
+ return ThetaRepository.GpsInfo(
952
+ latitude: Float(latitude),
953
+ longitude: Float(longitude),
954
+ altitude: Float(altitude),
955
+ dateTimeZone: dateTimeZone
956
+ )
957
+ }
958
+
959
+ func toProxy(params: [String: Any]) -> ThetaRepository.Proxy {
960
+ return ThetaRepository.Proxy(
961
+ use: params["use"] as? Bool ?? false,
962
+ url: params["url"] as? String,
963
+ port: toKotlinInt(value: params["port"]),
964
+ userid: params["userid"] as? String,
965
+ password: params["password"] as? String
966
+ )
967
+ }
968
+
969
+ func toTimeShift(params: [String: Any]) -> ThetaRepository.TimeShiftSetting {
970
+ var firstInterval: ThetaRepository.TimeShiftIntervalEnum? = nil
971
+ if let name = params["firstInterval"] as? String {
972
+ firstInterval = getEnumValue(
973
+ values: ThetaRepository.TimeShiftIntervalEnum.values(), name: name
974
+ )
975
+ }
976
+
977
+ var secondInterval: ThetaRepository.TimeShiftIntervalEnum? = nil
978
+ if let name = params["secondInterval"] as? String {
979
+ secondInterval = getEnumValue(
980
+ values: ThetaRepository.TimeShiftIntervalEnum.values(), name: name
981
+ )
982
+ }
983
+
984
+ return ThetaRepository.TimeShiftSetting(
985
+ isFrontFirst: toKotlinBoolean(value: params["isFrontFirst"]),
986
+ firstInterval: firstInterval,
987
+ secondInterval: secondInterval
988
+ )
989
+ }
990
+
991
+ func toTopBottomCorrectionRotation(params: [String: Any]) -> ThetaRepository.TopBottomCorrectionRotation? {
992
+ guard let pitch = params[KEY_TOP_BOTTOM_CORRECTION_ROTATION_PITCH] as? Double,
993
+ let roll = params[KEY_TOP_BOTTOM_CORRECTION_ROTATION_ROLL] as? Double,
994
+ let yaw = params[KEY_TOP_BOTTOM_CORRECTION_ROTATION_YAW] as? Double else { return nil }
995
+
996
+ return ThetaRepository.TopBottomCorrectionRotation(
997
+ pitch: Float(pitch),
998
+ roll: Float(roll),
999
+ yaw: Float(yaw)
1000
+ )
1001
+ }
1002
+
1003
+ func toDigestAuth(params: [String: String?]?) -> DigestAuth? {
1004
+ guard let params = params,
1005
+ let username = params["username"] as? String
1006
+ else { return nil }
1007
+
1008
+ let password = params["password"] as? String
1009
+ return DigestAuth(username: username, password: password)
1010
+ }
1011
+
1012
+ func toConfig(params: [String: Any]) -> ThetaRepository.Config {
1013
+ let config = ThetaRepository.Config()
1014
+ params.forEach { key, value in
1015
+ switch key {
1016
+ case KEY_DATETIME:
1017
+ config.dateTime = value as? String
1018
+ case KEY_LANGUAGE:
1019
+ config.language = getEnumValue(
1020
+ values: ThetaRepository.LanguageEnum.values(), name: value as? String ?? ""
1021
+ )
1022
+ case KEY_OFF_DELAY:
1023
+ config.offDelay = getEnumValue(
1024
+ values: ThetaRepository.OffDelayEnum.values(), name: value as? String ?? ""
1025
+ )
1026
+ case KEY_SLEEP_DELAY:
1027
+ config.sleepDelay = getEnumValue(
1028
+ values: ThetaRepository.SleepDelayEnum.values(), name: value as? String ?? ""
1029
+ )
1030
+ case KEY_SHUTTER_VOLUME:
1031
+ if let value = value as? Int {
1032
+ config.shutterVolume = KotlinInt(integerLiteral: value)
1033
+ }
1034
+ case KEY_CLIENT_MODE:
1035
+ config.clientMode = toDigestAuth(params: value as? [String: String?])
1036
+ default:
1037
+ break
1038
+ }
1039
+ }
1040
+ return config
1041
+ }
1042
+
1043
+ func toTimeout(params: [String: Any]) -> ThetaRepository.Timeout? {
1044
+ guard let connectTimeout = params[KEY_CONNECT_TIMEOUT] as? Int64,
1045
+ let requestTimeout = params[KEY_REQUEST_TIMEOUT] as? Int64,
1046
+ let socketTimeout = params[KEY_SOCKET_TIMEOUT] as? Int64
1047
+ else { return nil }
1048
+ return ThetaRepository.Timeout(
1049
+ connectTimeout: connectTimeout,
1050
+ requestTimeout: requestTimeout,
1051
+ socketTimeout: socketTimeout
1052
+ )
1053
+ }