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