tirtc-react-native 2.3.0 → 2.4.0-alpha.3

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 (77) hide show
  1. package/README.md +23 -7
  2. package/TiRtcReactNative.podspec +1 -1
  3. package/android/build.gradle +1 -1
  4. package/android/src/main/AndroidManifest.xml +2 -1
  5. package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcModule.kt +585 -28
  6. package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeCleanup.kt +115 -0
  7. package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeEventBinder.kt +35 -8
  8. package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeEventSink.kt +20 -0
  9. package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeMaps.kt +62 -0
  10. package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeModuleSupport.kt +6 -6
  11. package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeRegistry.kt +27 -0
  12. package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeStoreSupport.kt +64 -0
  13. package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcVideoOutputViewManager.kt +17 -2
  14. package/ios/TiRtcReactNative+Conn.mm +173 -2
  15. package/ios/TiRtcReactNative+Input.mm +18 -4
  16. package/ios/TiRtcReactNative+Output.mm +41 -4
  17. package/ios/TiRtcReactNative+Private.h +4 -0
  18. package/ios/TiRtcReactNative+Store.mm +496 -0
  19. package/ios/TiRtcReactNative.h +2 -1
  20. package/ios/TiRtcReactNative.mm +109 -1
  21. package/ios/TiRtcReactNativeEventBinder.h +8 -0
  22. package/ios/TiRtcReactNativeEventBinder.mm +104 -0
  23. package/ios/TiRtcReactNativeEventSink.h +4 -0
  24. package/ios/TiRtcReactNativeEventSink.mm +20 -0
  25. package/ios/TiRtcReactNativeRegistry.h +5 -0
  26. package/ios/TiRtcReactNativeRegistry.mm +43 -0
  27. package/ios/TiRtcVideoOutputView.mm +11 -0
  28. package/lib/module/audio_input.js +33 -17
  29. package/lib/module/audio_input.js.map +1 -1
  30. package/lib/module/audio_output.js +27 -10
  31. package/lib/module/audio_output.js.map +1 -1
  32. package/lib/module/conn.js +31 -7
  33. package/lib/module/conn.js.map +1 -1
  34. package/lib/module/errors.js +4 -3
  35. package/lib/module/errors.js.map +1 -1
  36. package/lib/module/index.js +2 -0
  37. package/lib/module/index.js.map +1 -1
  38. package/lib/module/logging.js +9 -1
  39. package/lib/module/logging.js.map +1 -1
  40. package/lib/module/logging_internal.js +27 -0
  41. package/lib/module/logging_internal.js.map +1 -0
  42. package/lib/module/recording.js +210 -0
  43. package/lib/module/recording.js.map +1 -0
  44. package/lib/module/runtime.js +13 -5
  45. package/lib/module/runtime.js.map +1 -1
  46. package/lib/module/specs/NativeTiRtc.js.map +1 -1
  47. package/lib/module/store.js +698 -0
  48. package/lib/module/store.js.map +1 -0
  49. package/lib/module/video_input.js +40 -22
  50. package/lib/module/video_input.js.map +1 -1
  51. package/lib/module/video_output.js +51 -10
  52. package/lib/module/video_output.js.map +1 -1
  53. package/lib/typescript/audio_input.d.ts +1 -0
  54. package/lib/typescript/conn.d.ts +2 -0
  55. package/lib/typescript/errors.d.ts +3 -2
  56. package/lib/typescript/index.d.ts +4 -0
  57. package/lib/typescript/logging_internal.d.ts +2 -0
  58. package/lib/typescript/recording.d.ts +53 -0
  59. package/lib/typescript/runtime.d.ts +2 -0
  60. package/lib/typescript/specs/NativeTiRtc.d.ts +88 -0
  61. package/lib/typescript/store.d.ts +202 -0
  62. package/lib/typescript/video_input.d.ts +1 -0
  63. package/lib/typescript/video_output.d.ts +3 -0
  64. package/package.json +1 -1
  65. package/src/audio_input.ts +85 -59
  66. package/src/audio_output.ts +30 -17
  67. package/src/conn.ts +46 -28
  68. package/src/errors.ts +4 -3
  69. package/src/index.ts +54 -0
  70. package/src/logging.ts +7 -1
  71. package/src/logging_internal.ts +23 -0
  72. package/src/recording.ts +271 -0
  73. package/src/runtime.ts +14 -5
  74. package/src/specs/NativeTiRtc.ts +123 -0
  75. package/src/store.ts +760 -0
  76. package/src/video_input.ts +97 -62
  77. package/src/video_output.ts +54 -16
package/src/runtime.ts CHANGED
@@ -1,25 +1,34 @@
1
1
  import {isPlainObject, TIRTC_ERROR_INVALID_ARGUMENT} from './errors';
2
2
  import {NativeTiRtc} from './native';
3
+ import {logRtcOutcome} from './logging_internal';
3
4
  import type {TiRtcInitOptions} from './types';
4
5
 
5
6
  export class TiRtc {
6
7
  private constructor() {}
7
8
 
8
- static initialize(config: TiRtcInitOptions): Promise<number> {
9
+ static init(config: TiRtcInitOptions): Promise<number> {
9
10
  if (!isPlainObject(config)) {
10
11
  return Promise.resolve(TIRTC_ERROR_INVALID_ARGUMENT);
11
12
  }
12
13
  return NativeTiRtc.initialize({
13
14
  appId: typeof config.appId === 'string' ? config.appId : '',
14
15
  endpoint: typeof config.endpoint === 'string' ? config.endpoint : '',
15
- consoleLogEnabled: typeof config.consoleLogEnabled === 'boolean'
16
- ? config.consoleLogEnabled
17
- : false,
16
+ consoleLogEnabled: typeof config.consoleLogEnabled === 'boolean' ? config.consoleLogEnabled : false,
17
+ }).then((code) => {
18
+ logRtcOutcome('runtime_initialize', code);
19
+ return code;
18
20
  });
19
21
  }
20
22
 
23
+ /** @deprecated Use {@link TiRtc.init}. */
24
+ static initialize(config: TiRtcInitOptions): Promise<number> {
25
+ return TiRtc.init(config);
26
+ }
27
+
21
28
  static shutdown(): number {
22
- return NativeTiRtc.shutdown();
29
+ const code = NativeTiRtc.shutdown();
30
+ logRtcOutcome('runtime_shutdown', code);
31
+ return code;
23
32
  }
24
33
 
25
34
  static errorToString(code: number): string {
@@ -53,6 +53,34 @@ export type NativeVideoInputOptions = Readonly<{
53
53
  cameraFacing: 'front' | 'back';
54
54
  }>;
55
55
 
56
+ export type NativeRecordingOptions = Readonly<{
57
+ videoStreamId: number;
58
+ audioStreamId: number | null;
59
+ }>;
60
+
61
+ export type NativeRecordingStartResult = Readonly<{
62
+ code: number;
63
+ taskId: NativeObjectId | null;
64
+ }>;
65
+
66
+ export type NativeMp4Result = Readonly<{
67
+ code: number;
68
+ fileId: NativeObjectId | null;
69
+ filePath: string | null;
70
+ durationMs: number | null;
71
+ }>;
72
+
73
+ export type NativeSnapshotResult = Readonly<{
74
+ code: number;
75
+ fileId: NativeObjectId | null;
76
+ filePath: string | null;
77
+ }>;
78
+
79
+ export type NativeGalleryResult = Readonly<{
80
+ code: number;
81
+ uri: string | null;
82
+ }>;
83
+
56
84
  export type NativeStateResult = Readonly<{
57
85
  code: number;
58
86
  state: string | null;
@@ -74,6 +102,37 @@ export type NativeLoggingUploadResult = Readonly<{
74
102
  logId: string | null;
75
103
  }>;
76
104
 
105
+ export type NativeStoreRecordingRange = Readonly<{
106
+ startTimeMs: number;
107
+ endTimeMs: number;
108
+ }>;
109
+
110
+ export type NativeStoreRecordingRangesResult = Readonly<{
111
+ code: number;
112
+ recordings: ReadonlyArray<NativeStoreRecordingRange>;
113
+ }>;
114
+
115
+ export type NativeStoreRecordingDay = Readonly<{
116
+ date: string;
117
+ hasRecording: boolean;
118
+ }>;
119
+
120
+ export type NativeStoreRecordingDaysResult = Readonly<{
121
+ code: number;
122
+ days: ReadonlyArray<NativeStoreRecordingDay>;
123
+ }>;
124
+
125
+ export type NativeStoreReplayInfo = Readonly<{
126
+ code: number;
127
+ speed: number;
128
+ currentTimeMs: number | null;
129
+ }>;
130
+
131
+ export type NativeStoreTaskStartResult = Readonly<{
132
+ code: number;
133
+ taskId: NativeObjectId | null;
134
+ }>;
135
+
77
136
  export type NativeTiRtcEvent = Readonly<{
78
137
  type: string;
79
138
  objectId: NativeObjectId;
@@ -192,6 +251,61 @@ interface Spec extends TurboModule {
192
251
  writeLog(level: number, tag: string, message: string): void;
193
252
  uploadLogs(): Promise<NativeLoggingUploadResult>;
194
253
 
254
+ storeInitialize(options: NativeInitOptions): Promise<number>;
255
+ storeShutdown(): number;
256
+ storeCreate(token: string): NativeCreateResult;
257
+ storeUpdateToken(id: NativeObjectId, token: string): number;
258
+ storeListRecordings(
259
+ id: NativeObjectId,
260
+ startTimeMs: number,
261
+ endTimeMs: number,
262
+ ): Promise<NativeStoreRecordingRangesResult>;
263
+ storeListRecordingDays(
264
+ id: NativeObjectId,
265
+ startDate: string,
266
+ endDate: string,
267
+ timeZoneId: string,
268
+ ): Promise<NativeStoreRecordingDaysResult>;
269
+ storeCreateReplay(id: NativeObjectId): NativeCreateResult;
270
+ storeExportRecording(
271
+ id: NativeObjectId,
272
+ startTimeMs: number,
273
+ endTimeMs: number,
274
+ videoChannelId: number,
275
+ audioChannelId: number | null,
276
+ ): NativeStoreTaskStartResult;
277
+ storeExportProgress(id: NativeObjectId): number;
278
+ storeExportResult(id: NativeObjectId): Promise<NativeMp4Result>;
279
+ storeExportStop(id: NativeObjectId): number;
280
+ storeDispose(id: NativeObjectId): number;
281
+
282
+ storeReplayGetInfo(id: NativeObjectId): NativeStoreReplayInfo;
283
+ storeReplayPlay(id: NativeObjectId, startTimeMs: number, endTimeMs: number, initialTimeMs: number | null): number;
284
+ storeReplayPause(id: NativeObjectId): number;
285
+ storeReplayResume(id: NativeObjectId): number;
286
+ storeReplaySeek(id: NativeObjectId, timeMs: number): number;
287
+ storeReplaySetSpeed(id: NativeObjectId, speed: number): number;
288
+ storeReplayStartRecording(
289
+ id: NativeObjectId,
290
+ videoChannelId: number,
291
+ audioChannelId: number | null,
292
+ ): NativeStoreTaskStartResult;
293
+ storeRecordingTaskStop(id: NativeObjectId): Promise<NativeMp4Result>;
294
+ storeReplayStop(id: NativeObjectId): number;
295
+ storeReplayDispose(id: NativeObjectId): number;
296
+ storeCreateAudioOutput(): NativeCreateResult;
297
+ storeAudioOutputGetState(id: NativeObjectId): NativeStateResult;
298
+ storeAudioOutputSetVolume(id: NativeObjectId, volumePercent: number): number;
299
+ storeAudioOutputAttach(outputId: NativeObjectId, replayId: NativeObjectId, channelId: number): number;
300
+ storeAudioOutputDetach(outputId: NativeObjectId): number;
301
+ storeAudioOutputDispose(id: NativeObjectId): number;
302
+ storeCreateVideoOutput(): NativeCreateResult;
303
+ storeVideoOutputGetState(id: NativeObjectId): NativeStateResult;
304
+ storeVideoOutputAttach(outputId: NativeObjectId, replayId: NativeObjectId, channelId: number): number;
305
+ storeVideoOutputDetach(outputId: NativeObjectId): number;
306
+ storeVideoOutputTakeSnapshot(id: NativeObjectId): Promise<NativeSnapshotResult>;
307
+ storeVideoOutputDispose(id: NativeObjectId): number;
308
+
195
309
  createConn(): NativeCreateResult;
196
310
  connGetState(id: NativeObjectId): NativeStateResult;
197
311
  connConnect(id: NativeObjectId, remoteId: string, token: string): number;
@@ -208,6 +322,14 @@ interface Spec extends TurboModule {
208
322
  connSubscribeAudio(id: NativeObjectId, streamId: number): number;
209
323
  connUnsubscribeAudio(id: NativeObjectId, streamId: number): number;
210
324
  connRequestKeyFrame(id: NativeObjectId, streamId: number): number;
325
+ connStartRecording(
326
+ id: NativeObjectId,
327
+ options: NativeRecordingOptions,
328
+ ): NativeRecordingStartResult;
329
+ recordingTaskStop(id: NativeObjectId): Promise<NativeMp4Result>;
330
+ mediaFileMoveToGallery(id: NativeObjectId, fileName: string | null): Promise<NativeGalleryResult>;
331
+ mediaFileDelete(id: NativeObjectId): Promise<number>;
332
+ mediaFileRelease(id: NativeObjectId): void;
211
333
  connGetMetricsSnapshot(id: NativeObjectId): NativeConnMetricsResult;
212
334
  connDispose(id: NativeObjectId): number;
213
335
 
@@ -231,6 +353,7 @@ interface Spec extends TurboModule {
231
353
  videoOutputGetMetricsSnapshot(id: NativeObjectId): NativeVideoOutputMetricsResult;
232
354
  videoOutputResetMetricsSession(id: NativeObjectId): number;
233
355
  videoOutputGetDebugSnapshot(id: NativeObjectId): NativeVideoOutputDebugSnapshotResult;
356
+ videoOutputTakeSnapshot(id: NativeObjectId): Promise<NativeSnapshotResult>;
234
357
  videoOutputDispose(id: NativeObjectId): number;
235
358
 
236
359
  createAudioInput(): NativeCreateResult;