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.
- package/README.md +6 -6
- package/TiRtcReactNative.podspec +1 -1
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcModule.kt +146 -109
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeCleanup.kt +23 -23
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeEventBinder.kt +21 -24
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeEventSink.kt +6 -10
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeMaps.kt +5 -5
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeRegistry.kt +11 -11
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/{TiRtcReactNativeStoreSupport.kt → TiRtcReactNativeStorageSupport.kt} +9 -9
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcVideoOutputViewManager.kt +2 -2
- package/ios/TiRtcReactNative+Conn.mm +5 -5
- package/ios/TiRtcReactNative+Storage.mm +513 -0
- package/ios/TiRtcReactNative.mm +19 -19
- package/ios/TiRtcReactNativeEventBinder.h +8 -8
- package/ios/TiRtcReactNativeEventBinder.mm +31 -33
- package/ios/TiRtcReactNativeEventSink.h +3 -4
- package/ios/TiRtcReactNativeEventSink.mm +6 -10
- package/ios/TiRtcVideoOutputView.mm +4 -4
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/{store.js → storage.js} +184 -176
- package/lib/module/storage.js.map +1 -0
- package/lib/typescript/index.d.ts +2 -2
- package/lib/typescript/specs/NativeTiRtc.d.ts +42 -42
- package/lib/typescript/storage.d.ts +204 -0
- package/package.json +1 -1
- package/src/index.ts +44 -44
- package/src/specs/NativeTiRtc.ts +47 -47
- package/src/storage.ts +769 -0
- package/ios/TiRtcReactNative+Store.mm +0 -496
- package/lib/module/store.js.map +0 -1
- package/lib/typescript/store.d.ts +0 -202
- 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
|
|
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
|
|
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
|
|
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,
|
|
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
|
|
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
|
|
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
|
package/TiRtcReactNative.podspec
CHANGED
|
@@ -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
|
|
16
|
+
s.dependency 'TiRTC', '2.4.0'
|
|
17
17
|
|
|
18
18
|
if respond_to?(:install_modules_dependencies, true)
|
|
19
19
|
install_modules_dependencies(s)
|
package/android/build.gradle
CHANGED
|
@@ -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
|
|
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.
|
|
27
|
-
import com.tange.ai.tirtc.
|
|
28
|
-
import com.tange.ai.tirtc.
|
|
29
|
-
import com.tange.ai.tirtc.
|
|
30
|
-
import com.tange.ai.tirtc.
|
|
31
|
-
import com.tange.ai.tirtc.
|
|
32
|
-
import com.tange.ai.tirtc.
|
|
33
|
-
import com.tange.ai.tirtc.
|
|
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
|
|
121
|
-
val code =
|
|
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
|
|
134
|
+
override fun tiCloudStorageShutdown(): Double = TiCloudStorage.shutdown().toDouble()
|
|
131
135
|
|
|
132
|
-
override fun
|
|
136
|
+
override fun tiCloudStorageCreate(token: String): WritableMap =
|
|
133
137
|
registerReactNativeObject(
|
|
134
138
|
registry,
|
|
135
|
-
factory = {
|
|
136
|
-
onRegistered = { entry, value -> eventBinder.
|
|
139
|
+
factory = { TiCloudStorage(token) },
|
|
140
|
+
onRegistered = { entry, value -> eventBinder.wireCloudStorage(entry.id, value as TiCloudStorage) },
|
|
137
141
|
)
|
|
138
142
|
|
|
139
|
-
override fun
|
|
140
|
-
registry.
|
|
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
|
|
144
|
-
val
|
|
145
|
-
if (
|
|
146
|
-
promise.resolve(
|
|
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
|
-
|
|
153
|
+
cloudStorage.listRecordings(startTimeMs.toLong(), endTimeMs.toLong()) { result ->
|
|
150
154
|
reactContext.runOnJSQueueThread {
|
|
151
|
-
promise.resolve(
|
|
155
|
+
promise.resolve(tiCloudStorageRecordingsResult(result.code, result.recordings))
|
|
152
156
|
}
|
|
153
157
|
}
|
|
154
158
|
}
|
|
155
159
|
|
|
156
160
|
@ReactMethod
|
|
157
|
-
override fun
|
|
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
|
|
165
|
-
if (
|
|
166
|
-
promise.resolve(
|
|
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
|
-
|
|
173
|
+
cloudStorage.listRecordingDays(startDate, endDate, timeZoneId) { result ->
|
|
170
174
|
reactContext.runOnJSQueueThread {
|
|
171
|
-
promise.resolve(
|
|
175
|
+
promise.resolve(tiCloudStorageRecordingDaysResult(result.code, result.days))
|
|
172
176
|
}
|
|
173
177
|
}
|
|
174
178
|
}
|
|
175
179
|
|
|
176
|
-
override fun
|
|
177
|
-
val
|
|
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 = {
|
|
182
|
-
onRegistered = { entry, value -> eventBinder.
|
|
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
|
|
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
|
|
197
|
+
val cloudStorage = registry.cloudStorage(id.toInt())
|
|
194
198
|
?: return recordingStartResult(TiRtcReactNativeErrors.OBJECT_RELEASED, null)
|
|
195
|
-
val bridge =
|
|
196
|
-
val started =
|
|
197
|
-
|
|
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
|
|
213
|
-
registry.
|
|
216
|
+
override fun tiCloudStorageExportProgress(id: Double): Double =
|
|
217
|
+
registry.tiCloudStorageExportTask(id.toInt())?.task?.progress ?: 0.0
|
|
214
218
|
|
|
215
219
|
@ReactMethod
|
|
216
|
-
override fun
|
|
217
|
-
registry.
|
|
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
|
|
222
|
-
registry.
|
|
225
|
+
override fun tiCloudStorageExportStop(id: Double): Double =
|
|
226
|
+
registry.tiCloudStorageExportTask(id.toInt())?.task?.stop().normalized()
|
|
223
227
|
|
|
224
|
-
override fun
|
|
228
|
+
override fun tiCloudStorageDispose(id: Double): Double {
|
|
225
229
|
val objectId = id.toInt()
|
|
226
|
-
val code = registry.
|
|
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
|
|
232
|
-
val replay = registry.
|
|
233
|
-
?: return
|
|
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
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
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
|
|
247
|
+
return tiCloudStorageReplayInfoResult(0, speed, replay.currentTimeMs)
|
|
241
248
|
}
|
|
242
249
|
|
|
243
|
-
override fun
|
|
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.
|
|
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
|
|
260
|
+
override fun tiCloudStorageReplayPause(id: Double): Double = registry.tiCloudStorageReplay(id.toInt())?.pause().normalized()
|
|
254
261
|
|
|
255
|
-
override fun
|
|
262
|
+
override fun tiCloudStorageReplayResume(id: Double): Double = registry.tiCloudStorageReplay(id.toInt())?.resume().normalized()
|
|
256
263
|
|
|
257
|
-
override fun
|
|
258
|
-
registry.
|
|
264
|
+
override fun tiCloudStorageReplaySeek(id: Double, timeMs: Double): Double =
|
|
265
|
+
registry.tiCloudStorageReplay(id.toInt())?.seek(timeMs.toLong()).normalized()
|
|
259
266
|
|
|
260
|
-
override fun
|
|
267
|
+
override fun tiCloudStorageReplaySetSpeed(id: Double, speed: Double): Double {
|
|
261
268
|
val value = when (speed.toInt()) {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
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.
|
|
278
|
+
return registry.tiCloudStorageReplay(id.toInt())?.setSpeed(value).normalized()
|
|
269
279
|
}
|
|
270
280
|
|
|
271
|
-
override fun
|
|
281
|
+
override fun tiCloudStorageReplayStartRecording(
|
|
272
282
|
id: Double,
|
|
273
283
|
videoChannelId: Double,
|
|
274
284
|
audioChannelId: Double?,
|
|
275
285
|
): WritableMap {
|
|
276
|
-
val replay = registry.
|
|
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
|
|
294
|
+
override fun tiCloudStorageRecordingTaskStop(id: Double, promise: Promise) {
|
|
285
295
|
val objectId = id.toInt()
|
|
286
|
-
val task = registry.
|
|
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
|
-
|
|
303
|
+
resolveCloudStorageRecording(promise, result)
|
|
294
304
|
}
|
|
295
305
|
}
|
|
296
306
|
|
|
297
|
-
override fun
|
|
307
|
+
override fun tiCloudStorageReplayStop(id: Double): Double = registry.tiCloudStorageReplay(id.toInt())?.stop().normalized()
|
|
298
308
|
|
|
299
|
-
override fun
|
|
309
|
+
override fun tiCloudStorageReplayDispose(id: Double): Double {
|
|
300
310
|
val objectId = id.toInt()
|
|
301
|
-
val code = registry.
|
|
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
|
|
316
|
+
override fun tiCloudStorageCreateAudioOutput(): WritableMap =
|
|
307
317
|
registerReactNativeObject(
|
|
308
318
|
registry,
|
|
309
|
-
factory = {
|
|
310
|
-
onRegistered = { entry, value -> eventBinder.
|
|
319
|
+
factory = { TiCloudStorageAudioOutput() },
|
|
320
|
+
onRegistered = { entry, value -> eventBinder.wireCloudStorageAudioOutput(entry.id, value as TiCloudStorageAudioOutput) },
|
|
311
321
|
)
|
|
312
322
|
|
|
313
|
-
override fun
|
|
314
|
-
val output = registry.
|
|
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
|
|
320
|
-
registry.
|
|
329
|
+
override fun tiCloudStorageAudioOutputSetVolume(id: Double, volumePercent: Double): Double =
|
|
330
|
+
registry.tiCloudStorageAudioOutput(id.toInt())?.setVolume(volumePercent.toInt()).normalized()
|
|
321
331
|
|
|
322
|
-
override fun
|
|
323
|
-
val replay = registry.
|
|
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.
|
|
335
|
+
return registry.tiCloudStorageAudioOutput(outputId.toInt())?.attach(replay, channelId.toInt()).normalized()
|
|
326
336
|
}
|
|
327
337
|
|
|
328
|
-
override fun
|
|
329
|
-
registry.
|
|
338
|
+
override fun tiCloudStorageAudioOutputDetach(outputId: Double): Double =
|
|
339
|
+
registry.tiCloudStorageAudioOutput(outputId.toInt())?.detach().normalized()
|
|
330
340
|
|
|
331
|
-
override fun
|
|
341
|
+
override fun tiCloudStorageAudioOutputDispose(id: Double): Double {
|
|
332
342
|
val objectId = id.toInt()
|
|
333
|
-
val code = registry.
|
|
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
|
|
348
|
+
override fun tiCloudStorageCreateVideoOutput(): WritableMap =
|
|
339
349
|
registerReactNativeObject(
|
|
340
350
|
registry,
|
|
341
|
-
factory = {
|
|
342
|
-
onRegistered = { entry, value -> eventBinder.
|
|
351
|
+
factory = { TiCloudStorageVideoOutput() },
|
|
352
|
+
onRegistered = { entry, value -> eventBinder.wireCloudStorageVideoOutput(entry.id, value as TiCloudStorageVideoOutput) },
|
|
343
353
|
)
|
|
344
354
|
|
|
345
|
-
override fun
|
|
346
|
-
val output = registry.
|
|
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
|
|
352
|
-
val replay = registry.
|
|
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.
|
|
364
|
+
return registry.tiCloudStorageVideoOutput(outputId.toInt())?.attach(replay, channelId.toInt()).normalized()
|
|
355
365
|
}
|
|
356
366
|
|
|
357
|
-
override fun
|
|
358
|
-
registry.
|
|
367
|
+
override fun tiCloudStorageVideoOutputDetach(outputId: Double): Double =
|
|
368
|
+
registry.tiCloudStorageVideoOutput(outputId.toInt())?.detach().normalized()
|
|
359
369
|
|
|
360
370
|
@ReactMethod
|
|
361
|
-
override fun
|
|
362
|
-
val output = registry.
|
|
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
|
|
387
|
+
override fun tiCloudStorageVideoOutputDispose(id: Double): Double {
|
|
378
388
|
val objectId = id.toInt()
|
|
379
|
-
val
|
|
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
|
|
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
|
|
489
|
-
is
|
|
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
|
|
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
|
|
614
|
-
is
|
|
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
|
|
630
|
-
is
|
|
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.
|
|
16
|
-
import com.tange.ai.tirtc.
|
|
17
|
-
import com.tange.ai.tirtc.
|
|
18
|
-
import com.tange.ai.tirtc.
|
|
19
|
-
import com.tange.ai.tirtc.
|
|
20
|
-
import com.tange.ai.tirtc.
|
|
21
|
-
import com.tange.ai.tirtc.
|
|
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
|
|
48
|
-
is
|
|
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
|
|
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
|
|
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<
|
|
84
|
-
logFailure("
|
|
85
|
-
logFailure("
|
|
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<
|
|
88
|
-
logFailure("
|
|
89
|
-
logFailure("
|
|
90
|
-
logFailure("
|
|
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<
|
|
97
|
-
logFailure("
|
|
98
|
-
logFailure("
|
|
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<
|
|
105
|
-
logFailure("
|
|
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
|
}
|