tirtc-react-native 2.4.0-alpha.3 → 2.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 (34) hide show
  1. package/README.md +6 -6
  2. package/TiRtcReactNative.podspec +1 -1
  3. package/android/build.gradle +1 -1
  4. package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcModule.kt +146 -109
  5. package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeCleanup.kt +23 -23
  6. package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeEventBinder.kt +21 -24
  7. package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeEventSink.kt +6 -10
  8. package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeMaps.kt +5 -5
  9. package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeRegistry.kt +11 -11
  10. package/android/src/main/java/com/tange/ai/tirtc/reactnative/{TiRtcReactNativeStoreSupport.kt → TiRtcReactNativeStorageSupport.kt} +9 -9
  11. package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcVideoOutputViewManager.kt +2 -2
  12. package/ios/TiRtcReactNative+Conn.mm +5 -5
  13. package/ios/TiRtcReactNative+Storage.mm +513 -0
  14. package/ios/TiRtcReactNative.mm +19 -19
  15. package/ios/TiRtcReactNativeEventBinder.h +8 -8
  16. package/ios/TiRtcReactNativeEventBinder.mm +31 -33
  17. package/ios/TiRtcReactNativeEventSink.h +3 -4
  18. package/ios/TiRtcReactNativeEventSink.mm +6 -10
  19. package/ios/TiRtcVideoOutputView.mm +4 -4
  20. package/lib/module/index.js +1 -1
  21. package/lib/module/index.js.map +1 -1
  22. package/lib/module/{store.js → storage.js} +184 -176
  23. package/lib/module/storage.js.map +1 -0
  24. package/lib/typescript/index.d.ts +2 -2
  25. package/lib/typescript/specs/NativeTiRtc.d.ts +42 -42
  26. package/lib/typescript/storage.d.ts +204 -0
  27. package/package.json +1 -1
  28. package/src/index.ts +44 -44
  29. package/src/specs/NativeTiRtc.ts +47 -47
  30. package/src/storage.ts +769 -0
  31. package/ios/TiRtcReactNative+Store.mm +0 -496
  32. package/lib/module/store.js.map +0 -1
  33. package/lib/typescript/store.d.ts +0 -202
  34. package/src/store.ts +0 -760
package/README.md CHANGED
@@ -1,16 +1,16 @@
1
1
  # TiRTC React Native SDK
2
2
 
3
- `tirtc-react-native` is the TiRTC and TiStore React Native New Architecture package for Android and iOS.
3
+ `tirtc-react-native` is the TiRTC and Ti Cloud Storage React Native New Architecture package for Android and iOS.
4
4
 
5
5
  ```sh
6
6
  npm install tirtc-react-native
7
7
  ```
8
8
 
9
- The package ships ESM JavaScript, TypeScript declarations, Codegen specs, Android native wrapper code and iOS native wrapper code. RTC and Store use the same native Runtime delivery but keep separate initialization and resource lifecycles. The package requires React Native `>=0.80.0`, Android `com.tange.ai:tirtc:2.4.0-alpha.3`, and iOS `TiRTC` `2.4.0-alpha.3` with iOS minimum `15.1`.
9
+ The package ships ESM JavaScript, TypeScript declarations, Codegen specs, Android native wrapper code and iOS native wrapper code. RTC and CloudStorage use the same native Runtime delivery but keep separate initialization and resource lifecycles. The package requires React Native `>=0.80.0`, Android `com.tange.ai:tirtc:2.4.0`, and iOS `TiRTC` `2.4.0` with iOS minimum `15.1`.
10
10
 
11
11
  The iOS package supports arm64 devices and Apple Silicon iOS Simulator. Simulator validation covers build, launch, connection, downlink audio, and downlink video; capture and iOS behavioral qualification remain real-device gates.
12
12
 
13
- Version `2.4.0-alpha.3` is an alpha React Native release aligned with the TiRTC 2.4.0-alpha.3 Android and Darwin SDKs.
13
+ Version `2.4.0` is the stable React Native release aligned with the TiRTC 2.4.0 Android and Darwin SDKs.
14
14
 
15
15
  ## Imports
16
16
 
@@ -121,7 +121,7 @@ export function LocalPreview() {
121
121
 
122
122
  ## Saving Temporary Media
123
123
 
124
- RTC recordings, RTC snapshots, Store recordings, and Store snapshots return temporary cache file objects. Publish one to the Android or iOS system media library with an optional final filename:
124
+ RTC recordings, RTC snapshots, CloudStorage recordings, and CloudStorage snapshots return temporary cache file objects. Publish one to the Android or iOS system media library with an optional final filename:
125
125
 
126
126
  ```ts
127
127
  const result = await file.moveToGallery(
@@ -139,7 +139,7 @@ Constructors create native owner identities, so outputs and inputs can attach to
139
139
 
140
140
  ## Release
141
141
 
142
- Version `2.4.0-alpha.3` is the current React Native package for TiRTC client media output and talkback. It supports React Native New Architecture apps on Android and iOS and pins Android `com.tange.ai:tirtc:2.4.0-alpha.3` and iOS `TiRTC` `2.4.0-alpha.3`.
142
+ Version `2.4.0` is the current stable React Native package for TiRTC and Ti Cloud Storage. It supports React Native New Architecture apps on Android and iOS and pins Android `com.tange.ai:tirtc:2.4.0` and iOS `TiRTC` `2.4.0`.
143
143
 
144
144
  ## License
145
145
 
@@ -159,7 +159,7 @@ The external application sample is published under `react-native/` in
159
159
  `tirtc-api-samples`. The owner-local projection and recovery entry is:
160
160
 
161
161
  ```sh
162
- ./scripts/publish_api_samples.sh --version 2.4.0-alpha.3
162
+ ./scripts/publish_api_samples.sh --version 2.4.0
163
163
  ```
164
164
 
165
165
  Use `--no-push` for a complete local projection/build rehearsal without writing
@@ -13,7 +13,7 @@ Pod::Spec.new do |s|
13
13
  s.source = { :git => 'https://gitlab.tange-ai.com/tirtc-nexus/tirtc.git', :tag => s.version.to_s }
14
14
  s.source_files = 'ios/**/*.{h,m,mm,swift}'
15
15
  s.dependency 'React-Core'
16
- s.dependency 'TiRTC', '2.4.0-alpha.3'
16
+ s.dependency 'TiRTC', '2.4.0'
17
17
 
18
18
  if respond_to?(:install_modules_dependencies, true)
19
19
  install_modules_dependencies(s)
@@ -29,7 +29,7 @@ repositories {
29
29
 
30
30
  dependencies {
31
31
  implementation "com.facebook.react:react-android"
32
- implementation "com.tange.ai:tirtc:${safeExtGet("tirtcAndroidVersion", "2.4.0-alpha.3")}"
32
+ implementation "com.tange.ai:tirtc:${safeExtGet("tirtcAndroidVersion", "2.4.0")}"
33
33
  }
34
34
 
35
35
  def safeExtGet(prop, fallback) {
@@ -5,6 +5,8 @@ import android.content.ContentValues
5
5
  import android.content.pm.PackageManager
6
6
  import android.os.Build
7
7
  import android.os.Environment
8
+ import android.os.Handler
9
+ import android.os.Looper
8
10
  import android.provider.MediaStore
9
11
  import com.facebook.react.bridge.Promise
10
12
  import com.facebook.react.bridge.ReactApplicationContext
@@ -23,16 +25,17 @@ import com.tange.ai.tirtc.TiRtcRecordingFile
23
25
  import com.tange.ai.tirtc.TiRtcSnapshotFile
24
26
  import com.tange.ai.tirtc.TiRtcVideoInput
25
27
  import com.tange.ai.tirtc.TiRtcVideoOutput
26
- import com.tange.ai.tirtc.TiStore
27
- import com.tange.ai.tirtc.TiStoreAudioOutput
28
- import com.tange.ai.tirtc.TiStoreExportRequest
29
- import com.tange.ai.tirtc.TiStoreRecordingFile
30
- import com.tange.ai.tirtc.TiStoreRecordingResult
31
- import com.tange.ai.tirtc.TiStoreReplaySpeed
32
- import com.tange.ai.tirtc.TiStoreSnapshotFile
33
- import com.tange.ai.tirtc.TiStoreVideoOutput
28
+ import com.tange.ai.tirtc.TiCloudStorage
29
+ import com.tange.ai.tirtc.TiCloudStorageAudioOutput
30
+ import com.tange.ai.tirtc.TiCloudStorageExportRequest
31
+ import com.tange.ai.tirtc.TiCloudStorageRecordingFile
32
+ import com.tange.ai.tirtc.TiCloudStorageRecordingResult
33
+ import com.tange.ai.tirtc.TiCloudStorageReplaySpeed
34
+ import com.tange.ai.tirtc.TiCloudStorageSnapshotFile
35
+ import com.tange.ai.tirtc.TiCloudStorageVideoOutput
34
36
  import java.util.concurrent.ConcurrentHashMap
35
37
  import java.util.concurrent.ArrayBlockingQueue
38
+ import java.util.concurrent.CountDownLatch
36
39
  import java.util.concurrent.RejectedExecutionException
37
40
  import java.util.concurrent.ThreadPoolExecutor
38
41
  import java.util.concurrent.TimeUnit
@@ -56,6 +59,7 @@ class TiRtcModule(
56
59
  private val eventBinder = TiRtcReactNativeEventBinder(events)
57
60
  private val nextMediaFileId = AtomicInteger(1)
58
61
  private val mediaFiles = ConcurrentHashMap<Int, Any>()
62
+ private val mainHandler = Handler(Looper.getMainLooper())
59
63
 
60
64
  init {
61
65
  registry.bindEventSink(events)
@@ -117,8 +121,8 @@ class TiRtcModule(
117
121
  }
118
122
 
119
123
  @ReactMethod
120
- override fun storeInitialize(options: ReadableMap, promise: Promise) {
121
- val code = TiStore.init(
124
+ override fun tiCloudStorageInitialize(options: ReadableMap, promise: Promise) {
125
+ val code = TiCloudStorage.init(
122
126
  reactContext,
123
127
  options.getString("appId") ?: "",
124
128
  options.getString("endpoint") ?: "",
@@ -127,74 +131,74 @@ class TiRtcModule(
127
131
  promise.resolve(code.toDouble())
128
132
  }
129
133
 
130
- override fun storeShutdown(): Double = TiStore.shutdown().toDouble()
134
+ override fun tiCloudStorageShutdown(): Double = TiCloudStorage.shutdown().toDouble()
131
135
 
132
- override fun storeCreate(token: String): WritableMap =
136
+ override fun tiCloudStorageCreate(token: String): WritableMap =
133
137
  registerReactNativeObject(
134
138
  registry,
135
- factory = { TiStore(token) },
136
- onRegistered = { entry, value -> eventBinder.wireStore(entry.id, value as TiStore) },
139
+ factory = { TiCloudStorage(token) },
140
+ onRegistered = { entry, value -> eventBinder.wireCloudStorage(entry.id, value as TiCloudStorage) },
137
141
  )
138
142
 
139
- override fun storeUpdateToken(id: Double, token: String): Double =
140
- registry.store(id.toInt())?.updateToken(token).normalized()
143
+ override fun tiCloudStorageUpdateToken(id: Double, token: String): Double =
144
+ registry.cloudStorage(id.toInt())?.updateToken(token).normalized()
141
145
 
142
146
  @ReactMethod
143
- override fun storeListRecordings(id: Double, startTimeMs: Double, endTimeMs: Double, promise: Promise) {
144
- val store = registry.store(id.toInt())
145
- if (store == null) {
146
- promise.resolve(storeRecordingsResult(TiRtcReactNativeErrors.OBJECT_RELEASED, emptyList()))
147
+ override fun tiCloudStorageListRecordings(id: Double, startTimeMs: Double, endTimeMs: Double, promise: Promise) {
148
+ val cloudStorage = registry.cloudStorage(id.toInt())
149
+ if (cloudStorage == null) {
150
+ promise.resolve(tiCloudStorageRecordingsResult(TiRtcReactNativeErrors.OBJECT_RELEASED, emptyList()))
147
151
  return
148
152
  }
149
- store.listRecordings(startTimeMs.toLong(), endTimeMs.toLong()) { result ->
153
+ cloudStorage.listRecordings(startTimeMs.toLong(), endTimeMs.toLong()) { result ->
150
154
  reactContext.runOnJSQueueThread {
151
- promise.resolve(storeRecordingsResult(result.code, result.recordings))
155
+ promise.resolve(tiCloudStorageRecordingsResult(result.code, result.recordings))
152
156
  }
153
157
  }
154
158
  }
155
159
 
156
160
  @ReactMethod
157
- override fun storeListRecordingDays(
161
+ override fun tiCloudStorageListRecordingDays(
158
162
  id: Double,
159
163
  startDate: String,
160
164
  endDate: String,
161
165
  timeZoneId: String,
162
166
  promise: Promise,
163
167
  ) {
164
- val store = registry.store(id.toInt())
165
- if (store == null) {
166
- promise.resolve(storeRecordingDaysResult(TiRtcReactNativeErrors.OBJECT_RELEASED, emptyList()))
168
+ val cloudStorage = registry.cloudStorage(id.toInt())
169
+ if (cloudStorage == null) {
170
+ promise.resolve(tiCloudStorageRecordingDaysResult(TiRtcReactNativeErrors.OBJECT_RELEASED, emptyList()))
167
171
  return
168
172
  }
169
- store.listRecordingDays(startDate, endDate, timeZoneId) { result ->
173
+ cloudStorage.listRecordingDays(startDate, endDate, timeZoneId) { result ->
170
174
  reactContext.runOnJSQueueThread {
171
- promise.resolve(storeRecordingDaysResult(result.code, result.days))
175
+ promise.resolve(tiCloudStorageRecordingDaysResult(result.code, result.days))
172
176
  }
173
177
  }
174
178
  }
175
179
 
176
- override fun storeCreateReplay(id: Double): WritableMap {
177
- val store = registry.store(id.toInt())
180
+ override fun tiCloudStorageCreateReplay(id: Double): WritableMap {
181
+ val cloudStorage = registry.cloudStorage(id.toInt())
178
182
  ?: return createResult(TiRtcReactNativeErrors.OBJECT_RELEASED, 0, 0)
179
183
  return registerReactNativeObject(
180
184
  registry,
181
- factory = { store.createReplay() },
182
- onRegistered = { entry, value -> eventBinder.wireStoreReplay(entry.id, value as com.tange.ai.tirtc.TiStoreReplay) },
185
+ factory = { cloudStorage.createReplay() },
186
+ onRegistered = { entry, value -> eventBinder.wireCloudStorageReplay(entry.id, value as com.tange.ai.tirtc.TiCloudStorageReplay) },
183
187
  )
184
188
  }
185
189
 
186
- override fun storeExportRecording(
190
+ override fun tiCloudStorageExportRecording(
187
191
  id: Double,
188
192
  startTimeMs: Double,
189
193
  endTimeMs: Double,
190
194
  videoChannelId: Double,
191
195
  audioChannelId: Double?,
192
196
  ): WritableMap {
193
- val store = registry.store(id.toInt())
197
+ val cloudStorage = registry.cloudStorage(id.toInt())
194
198
  ?: return recordingStartResult(TiRtcReactNativeErrors.OBJECT_RELEASED, null)
195
- val bridge = StoreExportBridge(::resolveStoreRecording)
196
- val started = store.exportRecording(
197
- TiStoreExportRequest(
199
+ val bridge = CloudStorageExportBridge(::resolveCloudStorageRecording)
200
+ val started = cloudStorage.exportRecording(
201
+ TiCloudStorageExportRequest(
198
202
  startTimeMs.toLong(),
199
203
  endTimeMs.toLong(),
200
204
  videoChannelId.toInt(),
@@ -209,71 +213,77 @@ class TiRtcModule(
209
213
  return recordingStartResult(started.code, entry.id)
210
214
  }
211
215
 
212
- override fun storeExportProgress(id: Double): Double =
213
- registry.storeExportTask(id.toInt())?.task?.progress ?: 0.0
216
+ override fun tiCloudStorageExportProgress(id: Double): Double =
217
+ registry.tiCloudStorageExportTask(id.toInt())?.task?.progress ?: 0.0
214
218
 
215
219
  @ReactMethod
216
- override fun storeExportResult(id: Double, promise: Promise) {
217
- registry.storeExportTask(id.toInt())?.await(promise)
220
+ override fun tiCloudStorageExportResult(id: Double, promise: Promise) {
221
+ registry.tiCloudStorageExportTask(id.toInt())?.await(promise)
218
222
  ?: promise.resolve(mp4Result(TiRtcReactNativeErrors.OBJECT_RELEASED, null, null, null))
219
223
  }
220
224
 
221
- override fun storeExportStop(id: Double): Double =
222
- registry.storeExportTask(id.toInt())?.task?.stop().normalized()
225
+ override fun tiCloudStorageExportStop(id: Double): Double =
226
+ registry.tiCloudStorageExportTask(id.toInt())?.task?.stop().normalized()
223
227
 
224
- override fun storeDispose(id: Double): Double {
228
+ override fun tiCloudStorageDispose(id: Double): Double {
225
229
  val objectId = id.toInt()
226
- val code = registry.store(objectId)?.dispose().normalized()
230
+ val code = registry.cloudStorage(objectId)?.dispose().normalized()
227
231
  if (code.toInt() == TiRtcReactNativeErrors.OK) registry.release(objectId)
228
232
  return code
229
233
  }
230
234
 
231
- override fun storeReplayGetInfo(id: Double): WritableMap {
232
- val replay = registry.storeReplay(id.toInt())
233
- ?: return storeReplayInfoResult(TiRtcReactNativeErrors.OBJECT_RELEASED, 0, null)
235
+ override fun tiCloudStorageReplayGetInfo(id: Double): WritableMap {
236
+ val replay = registry.tiCloudStorageReplay(id.toInt())
237
+ ?: return tiCloudStorageReplayInfoResult(TiRtcReactNativeErrors.OBJECT_RELEASED, 0, null)
234
238
  val speed = when (replay.speed) {
235
- TiStoreReplaySpeed.X1 -> 0
236
- TiStoreReplaySpeed.X2 -> 1
237
- TiStoreReplaySpeed.X4 -> 2
238
- TiStoreReplaySpeed.X8 -> 3
239
+ TiCloudStorageReplaySpeed.X0_125 -> 6
240
+ TiCloudStorageReplaySpeed.X0_25 -> 5
241
+ TiCloudStorageReplaySpeed.X0_5 -> 4
242
+ TiCloudStorageReplaySpeed.X1 -> 0
243
+ TiCloudStorageReplaySpeed.X2 -> 1
244
+ TiCloudStorageReplaySpeed.X4 -> 2
245
+ TiCloudStorageReplaySpeed.X8 -> 3
239
246
  }
240
- return storeReplayInfoResult(0, speed, replay.currentTimeMs)
247
+ return tiCloudStorageReplayInfoResult(0, speed, replay.currentTimeMs)
241
248
  }
242
249
 
243
- override fun storeReplayPlay(
250
+ override fun tiCloudStorageReplayPlay(
244
251
  id: Double,
245
252
  startTimeMs: Double,
246
253
  endTimeMs: Double,
247
254
  initialTimeMs: Double?,
248
255
  ): Double {
249
- val replay = registry.storeReplay(id.toInt()) ?: return TiRtcReactNativeErrors.OBJECT_RELEASED.toDouble()
256
+ val replay = registry.tiCloudStorageReplay(id.toInt()) ?: return TiRtcReactNativeErrors.OBJECT_RELEASED.toDouble()
250
257
  return replay.play(startTimeMs.toLong(), endTimeMs.toLong(), initialTimeMs?.toLong()).toDouble()
251
258
  }
252
259
 
253
- override fun storeReplayPause(id: Double): Double = registry.storeReplay(id.toInt())?.pause().normalized()
260
+ override fun tiCloudStorageReplayPause(id: Double): Double = registry.tiCloudStorageReplay(id.toInt())?.pause().normalized()
254
261
 
255
- override fun storeReplayResume(id: Double): Double = registry.storeReplay(id.toInt())?.resume().normalized()
262
+ override fun tiCloudStorageReplayResume(id: Double): Double = registry.tiCloudStorageReplay(id.toInt())?.resume().normalized()
256
263
 
257
- override fun storeReplaySeek(id: Double, timeMs: Double): Double =
258
- registry.storeReplay(id.toInt())?.seek(timeMs.toLong()).normalized()
264
+ override fun tiCloudStorageReplaySeek(id: Double, timeMs: Double): Double =
265
+ registry.tiCloudStorageReplay(id.toInt())?.seek(timeMs.toLong()).normalized()
259
266
 
260
- override fun storeReplaySetSpeed(id: Double, speed: Double): Double {
267
+ override fun tiCloudStorageReplaySetSpeed(id: Double, speed: Double): Double {
261
268
  val value = when (speed.toInt()) {
262
- 0 -> TiStoreReplaySpeed.X1
263
- 1 -> TiStoreReplaySpeed.X2
264
- 2 -> TiStoreReplaySpeed.X4
265
- 3 -> TiStoreReplaySpeed.X8
269
+ 6 -> TiCloudStorageReplaySpeed.X0_125
270
+ 5 -> TiCloudStorageReplaySpeed.X0_25
271
+ 4 -> TiCloudStorageReplaySpeed.X0_5
272
+ 0 -> TiCloudStorageReplaySpeed.X1
273
+ 1 -> TiCloudStorageReplaySpeed.X2
274
+ 2 -> TiCloudStorageReplaySpeed.X4
275
+ 3 -> TiCloudStorageReplaySpeed.X8
266
276
  else -> return TiRtcReactNativeErrors.INVALID_ARGUMENT.toDouble()
267
277
  }
268
- return registry.storeReplay(id.toInt())?.setSpeed(value).normalized()
278
+ return registry.tiCloudStorageReplay(id.toInt())?.setSpeed(value).normalized()
269
279
  }
270
280
 
271
- override fun storeReplayStartRecording(
281
+ override fun tiCloudStorageReplayStartRecording(
272
282
  id: Double,
273
283
  videoChannelId: Double,
274
284
  audioChannelId: Double?,
275
285
  ): WritableMap {
276
- val replay = registry.storeReplay(id.toInt())
286
+ val replay = registry.tiCloudStorageReplay(id.toInt())
277
287
  ?: return recordingStartResult(TiRtcReactNativeErrors.OBJECT_RELEASED, null)
278
288
  val result = replay.startRecording(videoChannelId.toInt(), audioChannelId?.toInt())
279
289
  val entry = result.task?.let(registry::add)
@@ -281,85 +291,85 @@ class TiRtcModule(
281
291
  }
282
292
 
283
293
  @ReactMethod
284
- override fun storeRecordingTaskStop(id: Double, promise: Promise) {
294
+ override fun tiCloudStorageRecordingTaskStop(id: Double, promise: Promise) {
285
295
  val objectId = id.toInt()
286
- val task = registry.storeRecordingTask(objectId)
296
+ val task = registry.tiCloudStorageRecordingTask(objectId)
287
297
  if (task == null) {
288
298
  promise.resolve(mp4Result(TiRtcReactNativeErrors.OBJECT_RELEASED, null, null, null))
289
299
  return
290
300
  }
291
301
  task.stop { result ->
292
302
  registry.release(objectId)
293
- resolveStoreRecording(promise, result)
303
+ resolveCloudStorageRecording(promise, result)
294
304
  }
295
305
  }
296
306
 
297
- override fun storeReplayStop(id: Double): Double = registry.storeReplay(id.toInt())?.stop().normalized()
307
+ override fun tiCloudStorageReplayStop(id: Double): Double = registry.tiCloudStorageReplay(id.toInt())?.stop().normalized()
298
308
 
299
- override fun storeReplayDispose(id: Double): Double {
309
+ override fun tiCloudStorageReplayDispose(id: Double): Double {
300
310
  val objectId = id.toInt()
301
- val code = registry.storeReplay(objectId)?.dispose().normalized()
311
+ val code = registry.tiCloudStorageReplay(objectId)?.dispose().normalized()
302
312
  if (code.toInt() == TiRtcReactNativeErrors.OK) registry.release(objectId)
303
313
  return code
304
314
  }
305
315
 
306
- override fun storeCreateAudioOutput(): WritableMap =
316
+ override fun tiCloudStorageCreateAudioOutput(): WritableMap =
307
317
  registerReactNativeObject(
308
318
  registry,
309
- factory = { TiStoreAudioOutput() },
310
- onRegistered = { entry, value -> eventBinder.wireStoreAudioOutput(entry.id, value as TiStoreAudioOutput) },
319
+ factory = { TiCloudStorageAudioOutput() },
320
+ onRegistered = { entry, value -> eventBinder.wireCloudStorageAudioOutput(entry.id, value as TiCloudStorageAudioOutput) },
311
321
  )
312
322
 
313
- override fun storeAudioOutputGetState(id: Double): WritableMap {
314
- val output = registry.storeAudioOutput(id.toInt())
323
+ override fun tiCloudStorageAudioOutputGetState(id: Double): WritableMap {
324
+ val output = registry.tiCloudStorageAudioOutput(id.toInt())
315
325
  ?: return stateResult(TiRtcReactNativeErrors.OBJECT_RELEASED, null)
316
326
  return stateResult(0, output.state.name.lowercase())
317
327
  }
318
328
 
319
- override fun storeAudioOutputSetVolume(id: Double, volumePercent: Double): Double =
320
- registry.storeAudioOutput(id.toInt())?.setVolume(volumePercent.toInt()).normalized()
329
+ override fun tiCloudStorageAudioOutputSetVolume(id: Double, volumePercent: Double): Double =
330
+ registry.tiCloudStorageAudioOutput(id.toInt())?.setVolume(volumePercent.toInt()).normalized()
321
331
 
322
- override fun storeAudioOutputAttach(outputId: Double, replayId: Double, channelId: Double): Double {
323
- val replay = registry.storeReplay(replayId.toInt())
332
+ override fun tiCloudStorageAudioOutputAttach(outputId: Double, replayId: Double, channelId: Double): Double {
333
+ val replay = registry.tiCloudStorageReplay(replayId.toInt())
324
334
  ?: return TiRtcReactNativeErrors.OBJECT_RELEASED.toDouble()
325
- return registry.storeAudioOutput(outputId.toInt())?.attach(replay, channelId.toInt()).normalized()
335
+ return registry.tiCloudStorageAudioOutput(outputId.toInt())?.attach(replay, channelId.toInt()).normalized()
326
336
  }
327
337
 
328
- override fun storeAudioOutputDetach(outputId: Double): Double =
329
- registry.storeAudioOutput(outputId.toInt())?.detach().normalized()
338
+ override fun tiCloudStorageAudioOutputDetach(outputId: Double): Double =
339
+ registry.tiCloudStorageAudioOutput(outputId.toInt())?.detach().normalized()
330
340
 
331
- override fun storeAudioOutputDispose(id: Double): Double {
341
+ override fun tiCloudStorageAudioOutputDispose(id: Double): Double {
332
342
  val objectId = id.toInt()
333
- val code = registry.storeAudioOutput(objectId)?.dispose().normalized()
343
+ val code = registry.tiCloudStorageAudioOutput(objectId)?.dispose().normalized()
334
344
  if (code.toInt() == TiRtcReactNativeErrors.OK) registry.release(objectId)
335
345
  return code
336
346
  }
337
347
 
338
- override fun storeCreateVideoOutput(): WritableMap =
348
+ override fun tiCloudStorageCreateVideoOutput(): WritableMap =
339
349
  registerReactNativeObject(
340
350
  registry,
341
- factory = { TiStoreVideoOutput() },
342
- onRegistered = { entry, value -> eventBinder.wireStoreVideoOutput(entry.id, value as TiStoreVideoOutput) },
351
+ factory = { TiCloudStorageVideoOutput() },
352
+ onRegistered = { entry, value -> eventBinder.wireCloudStorageVideoOutput(entry.id, value as TiCloudStorageVideoOutput) },
343
353
  )
344
354
 
345
- override fun storeVideoOutputGetState(id: Double): WritableMap {
346
- val output = registry.storeVideoOutput(id.toInt())
355
+ override fun tiCloudStorageVideoOutputGetState(id: Double): WritableMap {
356
+ val output = registry.tiCloudStorageVideoOutput(id.toInt())
347
357
  ?: return stateResult(TiRtcReactNativeErrors.OBJECT_RELEASED, null)
348
358
  return stateResult(0, output.state.name.lowercase())
349
359
  }
350
360
 
351
- override fun storeVideoOutputAttach(outputId: Double, replayId: Double, channelId: Double): Double {
352
- val replay = registry.storeReplay(replayId.toInt())
361
+ override fun tiCloudStorageVideoOutputAttach(outputId: Double, replayId: Double, channelId: Double): Double {
362
+ val replay = registry.tiCloudStorageReplay(replayId.toInt())
353
363
  ?: return TiRtcReactNativeErrors.OBJECT_RELEASED.toDouble()
354
- return registry.storeVideoOutput(outputId.toInt())?.attach(replay, channelId.toInt()).normalized()
364
+ return registry.tiCloudStorageVideoOutput(outputId.toInt())?.attach(replay, channelId.toInt()).normalized()
355
365
  }
356
366
 
357
- override fun storeVideoOutputDetach(outputId: Double): Double =
358
- registry.storeVideoOutput(outputId.toInt())?.detach().normalized()
367
+ override fun tiCloudStorageVideoOutputDetach(outputId: Double): Double =
368
+ registry.tiCloudStorageVideoOutput(outputId.toInt())?.detach().normalized()
359
369
 
360
370
  @ReactMethod
361
- override fun storeVideoOutputTakeSnapshot(id: Double, promise: Promise) {
362
- val output = registry.storeVideoOutput(id.toInt())
371
+ override fun tiCloudStorageVideoOutputTakeSnapshot(id: Double, promise: Promise) {
372
+ val output = registry.tiCloudStorageVideoOutput(id.toInt())
363
373
  if (output == null) {
364
374
  promise.resolve(mediaSnapshotResult(TiRtcReactNativeErrors.OBJECT_RELEASED, null, null))
365
375
  return
@@ -374,14 +384,40 @@ class TiRtcModule(
374
384
  }
375
385
  }
376
386
 
377
- override fun storeVideoOutputDispose(id: Double): Double {
387
+ override fun tiCloudStorageVideoOutputDispose(id: Double): Double {
378
388
  val objectId = id.toInt()
379
- val code = registry.storeVideoOutput(objectId)?.dispose().normalized()
389
+ val output = registry.tiCloudStorageVideoOutput(objectId) ?: return TiRtcReactNativeErrors.OBJECT_RELEASED.toDouble()
390
+ val detachCode = detachCloudStorageVideoView(output)
391
+ val nativeCode = if (detachCode == TiRtcReactNativeErrors.OK) output.dispose() else detachCode
392
+ val code = TiRtcReactNativeErrors.normalizeAndroid(nativeCode).toDouble()
380
393
  if (code.toInt() == TiRtcReactNativeErrors.OK) registry.release(objectId)
381
394
  return code
382
395
  }
383
396
 
384
- private fun resolveStoreRecording(promise: Promise, result: TiStoreRecordingResult) {
397
+ private fun detachCloudStorageVideoView(output: TiCloudStorageVideoOutput): Int {
398
+ if (Looper.myLooper() == Looper.getMainLooper()) return output.detachView()
399
+ val result = AtomicInteger(TiRtcReactNativeErrors.PLATFORM_INTERNAL)
400
+ val completed = CountDownLatch(1)
401
+ if (!mainHandler.post {
402
+ result.set(output.detachView())
403
+ completed.countDown()
404
+ }
405
+ ) {
406
+ return TiRtcReactNativeErrors.PLATFORM_INTERNAL
407
+ }
408
+ return try {
409
+ if (completed.await(VIEW_DETACH_TIMEOUT_SECONDS, TimeUnit.SECONDS)) {
410
+ result.get()
411
+ } else {
412
+ TiRtcReactNativeErrors.PLATFORM_INTERNAL
413
+ }
414
+ } catch (_: InterruptedException) {
415
+ Thread.currentThread().interrupt()
416
+ TiRtcReactNativeErrors.PLATFORM_INTERNAL
417
+ }
418
+ }
419
+
420
+ private fun resolveCloudStorageRecording(promise: Promise, result: TiCloudStorageRecordingResult) {
385
421
  val fileId = result.file?.let { file ->
386
422
  nextMediaFileId.getAndIncrement().also { mediaFiles[it] = file }
387
423
  }
@@ -485,14 +521,14 @@ class TiRtcModule(
485
521
  val path = when (mediaFile) {
486
522
  is TiRtcRecordingFile -> mediaFile.path
487
523
  is TiRtcSnapshotFile -> mediaFile.path
488
- is TiStoreRecordingFile -> mediaFile.path
489
- is TiStoreSnapshotFile -> mediaFile.path
524
+ is TiCloudStorageRecordingFile -> mediaFile.path
525
+ is TiCloudStorageSnapshotFile -> mediaFile.path
490
526
  else -> {
491
527
  promise.resolve(galleryResult(TiRtcReactNativeErrors.OBJECT_RELEASED, null))
492
528
  return
493
529
  }
494
530
  }
495
- val video = mediaFile is TiRtcRecordingFile || mediaFile is TiStoreRecordingFile
531
+ val video = mediaFile is TiRtcRecordingFile || mediaFile is TiCloudStorageRecordingFile
496
532
  val normalizedName = normalizeGalleryFileName(fileName, video)
497
533
  if (normalizedName == null) {
498
534
  promise.resolve(galleryResult(ERROR_INVALID_ARGUMENT, null))
@@ -610,8 +646,8 @@ class TiRtcModule(
610
646
  when (mediaFile) {
611
647
  is TiRtcRecordingFile -> mediaFile.delete(onDelete)
612
648
  is TiRtcSnapshotFile -> mediaFile.delete(onDelete)
613
- is TiStoreRecordingFile -> mediaFile.delete(onDelete)
614
- is TiStoreSnapshotFile -> mediaFile.delete(onDelete)
649
+ is TiCloudStorageRecordingFile -> mediaFile.delete(onDelete)
650
+ is TiCloudStorageSnapshotFile -> mediaFile.delete(onDelete)
615
651
  }
616
652
  }
617
653
 
@@ -626,8 +662,8 @@ class TiRtcModule(
626
662
  when (mediaFile) {
627
663
  is TiRtcRecordingFile -> mediaFile.delete(callback)
628
664
  is TiRtcSnapshotFile -> mediaFile.delete(callback)
629
- is TiStoreRecordingFile -> mediaFile.delete(callback)
630
- is TiStoreSnapshotFile -> mediaFile.delete(callback)
665
+ is TiCloudStorageRecordingFile -> mediaFile.delete(callback)
666
+ is TiCloudStorageSnapshotFile -> mediaFile.delete(callback)
631
667
  else -> promise.resolve(TiRtcReactNativeErrors.OBJECT_RELEASED.toDouble())
632
668
  }
633
669
  }
@@ -989,6 +1025,7 @@ class TiRtcModule(
989
1025
  companion object {
990
1026
  const val NAME = "TiRtc"
991
1027
  private const val TAG = "TiRtcReactNative"
1028
+ private const val VIEW_DETACH_TIMEOUT_SECONDS = 5L
992
1029
  private const val ERROR_INVALID_ARGUMENT = 6000
993
1030
  private const val ERROR_PERMISSION_DENIED = 6024
994
1031
  private const val ERROR_RESOURCE_EXHAUSTED = 6043
@@ -12,13 +12,13 @@ import com.tange.ai.tirtc.TiRtcRecordingTask
12
12
  import com.tange.ai.tirtc.TiRtcSnapshotFile
13
13
  import com.tange.ai.tirtc.TiRtcVideoInput
14
14
  import com.tange.ai.tirtc.TiRtcVideoOutput
15
- import com.tange.ai.tirtc.TiStore
16
- import com.tange.ai.tirtc.TiStoreAudioOutput
17
- import com.tange.ai.tirtc.TiStoreRecordingFile
18
- import com.tange.ai.tirtc.TiStoreRecordingTask
19
- import com.tange.ai.tirtc.TiStoreReplay
20
- import com.tange.ai.tirtc.TiStoreSnapshotFile
21
- import com.tange.ai.tirtc.TiStoreVideoOutput
15
+ import com.tange.ai.tirtc.TiCloudStorage
16
+ import com.tange.ai.tirtc.TiCloudStorageAudioOutput
17
+ import com.tange.ai.tirtc.TiCloudStorageRecordingFile
18
+ import com.tange.ai.tirtc.TiCloudStorageRecordingTask
19
+ import com.tange.ai.tirtc.TiCloudStorageReplay
20
+ import com.tange.ai.tirtc.TiCloudStorageSnapshotFile
21
+ import com.tange.ai.tirtc.TiCloudStorageVideoOutput
22
22
  import java.util.concurrent.atomic.AtomicInteger
23
23
 
24
24
  internal object TiRtcReactNativeCleanup {
@@ -44,8 +44,8 @@ internal object TiRtcReactNativeCleanup {
44
44
  when (file) {
45
45
  is TiRtcRecordingFile -> file.delete(completed)
46
46
  is TiRtcSnapshotFile -> file.delete(completed)
47
- is TiStoreRecordingFile -> file.delete(completed)
48
- is TiStoreSnapshotFile -> file.delete(completed)
47
+ is TiCloudStorageRecordingFile -> file.delete(completed)
48
+ is TiCloudStorageSnapshotFile -> file.delete(completed)
49
49
  else -> finish()
50
50
  }
51
51
  }
@@ -60,14 +60,14 @@ internal object TiRtcReactNativeCleanup {
60
60
  finish()
61
61
  }
62
62
  }
63
- is TiStoreRecordingTask -> {
63
+ is TiCloudStorageRecordingTask -> {
64
64
  retain()
65
65
  value.stop { result ->
66
66
  delete(result.file)
67
67
  finish()
68
68
  }
69
69
  }
70
- is StoreExportBridge -> {
70
+ is CloudStorageExportBridge -> {
71
71
  retain()
72
72
  value.invalidate { result ->
73
73
  delete(result?.file)
@@ -80,29 +80,29 @@ internal object TiRtcReactNativeCleanup {
80
80
  }
81
81
 
82
82
  private fun releaseOwners(objects: List<Any>) {
83
- objects.filterIsInstance<TiStoreAudioOutput>().forEach { output ->
84
- logFailure("store_audio_detach", output.detach())
85
- logFailure("store_audio_dispose", output.dispose())
83
+ objects.filterIsInstance<TiCloudStorageAudioOutput>().forEach { output ->
84
+ logFailure("ti-cloud-storage-audio-detach", output.detach())
85
+ logFailure("ti-cloud-storage-audio-dispose", output.dispose())
86
86
  }
87
- objects.filterIsInstance<TiStoreVideoOutput>().forEach { output ->
88
- logFailure("store_video_detach", output.detach())
89
- logFailure("store_video_view_detach", output.detachView())
90
- logFailure("store_video_dispose", output.dispose())
87
+ objects.filterIsInstance<TiCloudStorageVideoOutput>().forEach { output ->
88
+ logFailure("ti-cloud-storage-video-detach", output.detach())
89
+ logFailure("ti-cloud-storage-video-view-detach", output.detachView())
90
+ logFailure("ti-cloud-storage-video-dispose", output.dispose())
91
91
  }
92
92
  objects.filterIsInstance<TiRtcAudioOutput>().forEach { logFailure("audio_output_dispose", it.dispose()) }
93
93
  objects.filterIsInstance<TiRtcVideoOutput>().forEach { logFailure("video_output_dispose", it.dispose()) }
94
94
  objects.filterIsInstance<TiRtcAudioInput>().forEach { logFailure("audio_input_dispose", it.dispose()) }
95
95
  objects.filterIsInstance<TiRtcVideoInput>().forEach { logFailure("video_input_dispose", it.dispose()) }
96
- objects.filterIsInstance<TiStoreReplay>().forEach { replay ->
97
- logFailure("store_replay_stop", replay.stop())
98
- logFailure("store_replay_dispose", replay.dispose())
96
+ objects.filterIsInstance<TiCloudStorageReplay>().forEach { replay ->
97
+ logFailure("ti-cloud-storage-replay-stop", replay.stop())
98
+ logFailure("ti-cloud-storage-replay-dispose", replay.dispose())
99
99
  }
100
100
  objects.filterIsInstance<TiRtcConn>().forEach { conn ->
101
101
  logFailure("conn_disconnect", conn.disconnect())
102
102
  logFailure("conn_dispose", conn.dispose())
103
103
  }
104
- objects.filterIsInstance<TiStore>().forEach { logFailure("store_dispose", it.dispose()) }
105
- logFailure("store_shutdown", TiStore.shutdown())
104
+ objects.filterIsInstance<TiCloudStorage>().forEach { logFailure("ti-cloud-storage-dispose", it.dispose()) }
105
+ logFailure("ti-cloud-storage-shutdown", TiCloudStorage.shutdown())
106
106
  logFailure("runtime_shutdown", TiRtc.shutdown())
107
107
  TiRtcLogging.i(TAG, "[module_invalidate] native owners released")
108
108
  }