tirtc-react-native 2.3.1 → 2.4.0-alpha.4
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 +23 -7
- package/TiRtcReactNative.podspec +1 -1
- package/android/build.gradle +1 -1
- package/android/src/main/AndroidManifest.xml +2 -1
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcModule.kt +622 -28
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeCleanup.kt +115 -0
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeEventBinder.kt +32 -8
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeEventSink.kt +16 -0
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeMaps.kt +62 -0
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeModuleSupport.kt +6 -6
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeRegistry.kt +27 -0
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeStorageSupport.kt +64 -0
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcVideoOutputViewManager.kt +17 -2
- package/ios/TiRtcReactNative+Conn.mm +173 -2
- package/ios/TiRtcReactNative+Input.mm +18 -4
- package/ios/TiRtcReactNative+Output.mm +41 -4
- package/ios/TiRtcReactNative+Private.h +4 -0
- package/ios/TiRtcReactNative+Storage.mm +513 -0
- package/ios/TiRtcReactNative.h +2 -1
- package/ios/TiRtcReactNative.mm +109 -1
- package/ios/TiRtcReactNativeEventBinder.h +8 -0
- package/ios/TiRtcReactNativeEventBinder.mm +102 -0
- package/ios/TiRtcReactNativeEventSink.h +3 -0
- package/ios/TiRtcReactNativeEventSink.mm +16 -0
- package/ios/TiRtcReactNativeRegistry.h +5 -0
- package/ios/TiRtcReactNativeRegistry.mm +43 -0
- package/ios/TiRtcVideoOutputView.mm +11 -0
- package/lib/module/audio_input.js +33 -17
- package/lib/module/audio_input.js.map +1 -1
- package/lib/module/audio_output.js +27 -10
- package/lib/module/audio_output.js.map +1 -1
- package/lib/module/conn.js +31 -7
- package/lib/module/conn.js.map +1 -1
- package/lib/module/errors.js +4 -3
- package/lib/module/errors.js.map +1 -1
- package/lib/module/index.js +2 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/logging.js +9 -1
- package/lib/module/logging.js.map +1 -1
- package/lib/module/logging_internal.js +27 -0
- package/lib/module/logging_internal.js.map +1 -0
- package/lib/module/recording.js +210 -0
- package/lib/module/recording.js.map +1 -0
- package/lib/module/runtime.js +13 -5
- package/lib/module/runtime.js.map +1 -1
- package/lib/module/specs/NativeTiRtc.js.map +1 -1
- package/lib/module/storage.js +706 -0
- package/lib/module/storage.js.map +1 -0
- package/lib/module/video_input.js +40 -22
- package/lib/module/video_input.js.map +1 -1
- package/lib/module/video_output.js +51 -10
- package/lib/module/video_output.js.map +1 -1
- package/lib/typescript/audio_input.d.ts +1 -0
- package/lib/typescript/conn.d.ts +2 -0
- package/lib/typescript/errors.d.ts +3 -2
- package/lib/typescript/index.d.ts +4 -0
- package/lib/typescript/logging_internal.d.ts +2 -0
- package/lib/typescript/recording.d.ts +53 -0
- package/lib/typescript/runtime.d.ts +2 -0
- package/lib/typescript/specs/NativeTiRtc.d.ts +88 -0
- package/lib/typescript/storage.d.ts +204 -0
- package/lib/typescript/video_input.d.ts +1 -0
- package/lib/typescript/video_output.d.ts +3 -0
- package/package.json +1 -1
- package/src/audio_input.ts +85 -59
- package/src/audio_output.ts +30 -17
- package/src/conn.ts +46 -28
- package/src/errors.ts +4 -3
- package/src/index.ts +54 -0
- package/src/logging.ts +7 -1
- package/src/logging_internal.ts +23 -0
- package/src/recording.ts +271 -0
- package/src/runtime.ts +14 -5
- package/src/specs/NativeTiRtc.ts +123 -0
- package/src/storage.ts +769 -0
- package/src/video_input.ts +97 -62
- package/src/video_output.ts +54 -16
|
@@ -43,6 +43,29 @@ export type NativeVideoInputOptions = Readonly<{
|
|
|
43
43
|
bitrateKbps: number;
|
|
44
44
|
cameraFacing: 'front' | 'back';
|
|
45
45
|
}>;
|
|
46
|
+
export type NativeRecordingOptions = Readonly<{
|
|
47
|
+
videoStreamId: number;
|
|
48
|
+
audioStreamId: number | null;
|
|
49
|
+
}>;
|
|
50
|
+
export type NativeRecordingStartResult = Readonly<{
|
|
51
|
+
code: number;
|
|
52
|
+
taskId: NativeObjectId | null;
|
|
53
|
+
}>;
|
|
54
|
+
export type NativeMp4Result = Readonly<{
|
|
55
|
+
code: number;
|
|
56
|
+
fileId: NativeObjectId | null;
|
|
57
|
+
filePath: string | null;
|
|
58
|
+
durationMs: number | null;
|
|
59
|
+
}>;
|
|
60
|
+
export type NativeSnapshotResult = Readonly<{
|
|
61
|
+
code: number;
|
|
62
|
+
fileId: NativeObjectId | null;
|
|
63
|
+
filePath: string | null;
|
|
64
|
+
}>;
|
|
65
|
+
export type NativeGalleryResult = Readonly<{
|
|
66
|
+
code: number;
|
|
67
|
+
uri: string | null;
|
|
68
|
+
}>;
|
|
46
69
|
export type NativeStateResult = Readonly<{
|
|
47
70
|
code: number;
|
|
48
71
|
state: string | null;
|
|
@@ -60,6 +83,31 @@ export type NativeLoggingUploadResult = Readonly<{
|
|
|
60
83
|
code: number;
|
|
61
84
|
logId: string | null;
|
|
62
85
|
}>;
|
|
86
|
+
export type NativeTiCloudStorageRecordingRange = Readonly<{
|
|
87
|
+
startTimeMs: number;
|
|
88
|
+
endTimeMs: number;
|
|
89
|
+
}>;
|
|
90
|
+
export type NativeTiCloudStorageRecordingRangesResult = Readonly<{
|
|
91
|
+
code: number;
|
|
92
|
+
recordings: ReadonlyArray<NativeTiCloudStorageRecordingRange>;
|
|
93
|
+
}>;
|
|
94
|
+
export type NativeTiCloudStorageRecordingDay = Readonly<{
|
|
95
|
+
date: string;
|
|
96
|
+
hasRecording: boolean;
|
|
97
|
+
}>;
|
|
98
|
+
export type NativeTiCloudStorageRecordingDaysResult = Readonly<{
|
|
99
|
+
code: number;
|
|
100
|
+
days: ReadonlyArray<NativeTiCloudStorageRecordingDay>;
|
|
101
|
+
}>;
|
|
102
|
+
export type NativeTiCloudStorageReplayInfo = Readonly<{
|
|
103
|
+
code: number;
|
|
104
|
+
speed: number;
|
|
105
|
+
currentTimeMs: number | null;
|
|
106
|
+
}>;
|
|
107
|
+
export type NativeTiCloudStorageTaskStartResult = Readonly<{
|
|
108
|
+
code: number;
|
|
109
|
+
taskId: NativeObjectId | null;
|
|
110
|
+
}>;
|
|
63
111
|
export type NativeTiRtcEvent = Readonly<{
|
|
64
112
|
type: string;
|
|
65
113
|
objectId: NativeObjectId;
|
|
@@ -168,6 +216,40 @@ interface Spec extends TurboModule {
|
|
|
168
216
|
errorToString(code: number): string;
|
|
169
217
|
writeLog(level: number, tag: string, message: string): void;
|
|
170
218
|
uploadLogs(): Promise<NativeLoggingUploadResult>;
|
|
219
|
+
tiCloudStorageInitialize(options: NativeInitOptions): Promise<number>;
|
|
220
|
+
tiCloudStorageShutdown(): number;
|
|
221
|
+
tiCloudStorageCreate(token: string): NativeCreateResult;
|
|
222
|
+
tiCloudStorageUpdateToken(id: NativeObjectId, token: string): number;
|
|
223
|
+
tiCloudStorageListRecordings(id: NativeObjectId, startTimeMs: number, endTimeMs: number): Promise<NativeTiCloudStorageRecordingRangesResult>;
|
|
224
|
+
tiCloudStorageListRecordingDays(id: NativeObjectId, startDate: string, endDate: string, timeZoneId: string): Promise<NativeTiCloudStorageRecordingDaysResult>;
|
|
225
|
+
tiCloudStorageCreateReplay(id: NativeObjectId): NativeCreateResult;
|
|
226
|
+
tiCloudStorageExportRecording(id: NativeObjectId, startTimeMs: number, endTimeMs: number, videoChannelId: number, audioChannelId: number | null): NativeTiCloudStorageTaskStartResult;
|
|
227
|
+
tiCloudStorageExportProgress(id: NativeObjectId): number;
|
|
228
|
+
tiCloudStorageExportResult(id: NativeObjectId): Promise<NativeMp4Result>;
|
|
229
|
+
tiCloudStorageExportStop(id: NativeObjectId): number;
|
|
230
|
+
tiCloudStorageDispose(id: NativeObjectId): number;
|
|
231
|
+
tiCloudStorageReplayGetInfo(id: NativeObjectId): NativeTiCloudStorageReplayInfo;
|
|
232
|
+
tiCloudStorageReplayPlay(id: NativeObjectId, startTimeMs: number, endTimeMs: number, initialTimeMs: number | null): number;
|
|
233
|
+
tiCloudStorageReplayPause(id: NativeObjectId): number;
|
|
234
|
+
tiCloudStorageReplayResume(id: NativeObjectId): number;
|
|
235
|
+
tiCloudStorageReplaySeek(id: NativeObjectId, timeMs: number): number;
|
|
236
|
+
tiCloudStorageReplaySetSpeed(id: NativeObjectId, speed: number): number;
|
|
237
|
+
tiCloudStorageReplayStartRecording(id: NativeObjectId, videoChannelId: number, audioChannelId: number | null): NativeTiCloudStorageTaskStartResult;
|
|
238
|
+
tiCloudStorageRecordingTaskStop(id: NativeObjectId): Promise<NativeMp4Result>;
|
|
239
|
+
tiCloudStorageReplayStop(id: NativeObjectId): number;
|
|
240
|
+
tiCloudStorageReplayDispose(id: NativeObjectId): number;
|
|
241
|
+
tiCloudStorageCreateAudioOutput(): NativeCreateResult;
|
|
242
|
+
tiCloudStorageAudioOutputGetState(id: NativeObjectId): NativeStateResult;
|
|
243
|
+
tiCloudStorageAudioOutputSetVolume(id: NativeObjectId, volumePercent: number): number;
|
|
244
|
+
tiCloudStorageAudioOutputAttach(outputId: NativeObjectId, replayId: NativeObjectId, channelId: number): number;
|
|
245
|
+
tiCloudStorageAudioOutputDetach(outputId: NativeObjectId): number;
|
|
246
|
+
tiCloudStorageAudioOutputDispose(id: NativeObjectId): number;
|
|
247
|
+
tiCloudStorageCreateVideoOutput(): NativeCreateResult;
|
|
248
|
+
tiCloudStorageVideoOutputGetState(id: NativeObjectId): NativeStateResult;
|
|
249
|
+
tiCloudStorageVideoOutputAttach(outputId: NativeObjectId, replayId: NativeObjectId, channelId: number): number;
|
|
250
|
+
tiCloudStorageVideoOutputDetach(outputId: NativeObjectId): number;
|
|
251
|
+
tiCloudStorageVideoOutputTakeSnapshot(id: NativeObjectId): Promise<NativeSnapshotResult>;
|
|
252
|
+
tiCloudStorageVideoOutputDispose(id: NativeObjectId): number;
|
|
171
253
|
createConn(): NativeCreateResult;
|
|
172
254
|
connGetState(id: NativeObjectId): NativeStateResult;
|
|
173
255
|
connConnect(id: NativeObjectId, remoteId: string, token: string): number;
|
|
@@ -179,6 +261,11 @@ interface Spec extends TurboModule {
|
|
|
179
261
|
connSubscribeAudio(id: NativeObjectId, streamId: number): number;
|
|
180
262
|
connUnsubscribeAudio(id: NativeObjectId, streamId: number): number;
|
|
181
263
|
connRequestKeyFrame(id: NativeObjectId, streamId: number): number;
|
|
264
|
+
connStartRecording(id: NativeObjectId, options: NativeRecordingOptions): NativeRecordingStartResult;
|
|
265
|
+
recordingTaskStop(id: NativeObjectId): Promise<NativeMp4Result>;
|
|
266
|
+
mediaFileMoveToGallery(id: NativeObjectId, fileName: string | null): Promise<NativeGalleryResult>;
|
|
267
|
+
mediaFileDelete(id: NativeObjectId): Promise<number>;
|
|
268
|
+
mediaFileRelease(id: NativeObjectId): void;
|
|
182
269
|
connGetMetricsSnapshot(id: NativeObjectId): NativeConnMetricsResult;
|
|
183
270
|
connDispose(id: NativeObjectId): number;
|
|
184
271
|
createAudioOutput(): NativeCreateResult;
|
|
@@ -200,6 +287,7 @@ interface Spec extends TurboModule {
|
|
|
200
287
|
videoOutputGetMetricsSnapshot(id: NativeObjectId): NativeVideoOutputMetricsResult;
|
|
201
288
|
videoOutputResetMetricsSession(id: NativeObjectId): number;
|
|
202
289
|
videoOutputGetDebugSnapshot(id: NativeObjectId): NativeVideoOutputDebugSnapshotResult;
|
|
290
|
+
videoOutputTakeSnapshot(id: NativeObjectId): Promise<NativeSnapshotResult>;
|
|
203
291
|
videoOutputDispose(id: NativeObjectId): number;
|
|
204
292
|
createAudioInput(): NativeCreateResult;
|
|
205
293
|
audioInputGetState(id: NativeObjectId): NativeStateResult;
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { type ViewProps } from 'react-native';
|
|
3
|
+
import { NativeTiRtc, type NativeTiRtcEvent } from './native';
|
|
4
|
+
import { type NativeIdentity } from './native_object_id';
|
|
5
|
+
import { type Resp, type TiRtcGalleryAsset } from './recording';
|
|
6
|
+
export declare const TI_CLOUD_STORAGE_ERROR_OK: 0;
|
|
7
|
+
export declare const TI_CLOUD_STORAGE_ERROR_INVALID_ARGUMENT: 6000;
|
|
8
|
+
export declare const TI_CLOUD_STORAGE_ERROR_NOT_INITIALIZED: 6001;
|
|
9
|
+
export declare const TI_CLOUD_STORAGE_ERROR_TOKEN_EXPIRED: 6014;
|
|
10
|
+
export declare const TI_CLOUD_STORAGE_ERROR_ALREADY_INITIALIZED: 6022;
|
|
11
|
+
export declare const TI_CLOUD_STORAGE_ERROR_PERMISSION_DENIED: 6024;
|
|
12
|
+
export declare const TI_CLOUD_STORAGE_ERROR_IN_USE: 6026;
|
|
13
|
+
export declare const TI_CLOUD_STORAGE_ERROR_NOT_STARTED: 6027;
|
|
14
|
+
export declare const TI_CLOUD_STORAGE_ERROR_NOT_BOUND: 6029;
|
|
15
|
+
export declare const TI_CLOUD_STORAGE_ERROR_NOT_CONFIGURED: 6030;
|
|
16
|
+
export declare const TI_CLOUD_STORAGE_ERROR_RESOURCE_EXHAUSTED: 6043;
|
|
17
|
+
export declare const TI_CLOUD_STORAGE_ERROR_FILE_WRITE_FAILED: 6046;
|
|
18
|
+
export declare const TI_CLOUD_STORAGE_ERROR_UNSUPPORTED_FORMAT: 6113;
|
|
19
|
+
export declare const TI_CLOUD_STORAGE_ERROR_IO_FAILED: 6114;
|
|
20
|
+
export declare const TI_CLOUD_STORAGE_ERROR_CANCELLED: 6115;
|
|
21
|
+
export declare const TI_CLOUD_STORAGE_ERROR_RANGE_TOO_LARGE: 6117;
|
|
22
|
+
export declare const TI_CLOUD_STORAGE_ERROR_NO_FRAME: 6118;
|
|
23
|
+
export declare const TI_CLOUD_STORAGE_ERROR_NO_RECORDABLE_MEDIA: 6119;
|
|
24
|
+
export declare const TI_CLOUD_STORAGE_ERROR_RECORDING_OVERRUN: 6120;
|
|
25
|
+
export declare const TI_CLOUD_STORAGE_ERROR_RECORDING_UNREADABLE: 6122;
|
|
26
|
+
export declare const TI_CLOUD_STORAGE_ERROR_UNAVAILABLE: 6123;
|
|
27
|
+
export declare const TI_CLOUD_STORAGE_ERROR_STOPPED: 6124;
|
|
28
|
+
export type TiCloudStorageRecordingRange = Readonly<{
|
|
29
|
+
startTimeMs: number;
|
|
30
|
+
endTimeMs: number;
|
|
31
|
+
}>;
|
|
32
|
+
export type TiCloudStorageRecordingRangesResult = Readonly<{
|
|
33
|
+
code: number;
|
|
34
|
+
recordings: ReadonlyArray<TiCloudStorageRecordingRange>;
|
|
35
|
+
}>;
|
|
36
|
+
export type TiCloudStorageRecordingDay = Readonly<{
|
|
37
|
+
date: string;
|
|
38
|
+
hasRecording: boolean;
|
|
39
|
+
}>;
|
|
40
|
+
export type TiCloudStorageRecordingDaysResult = Readonly<{
|
|
41
|
+
code: number;
|
|
42
|
+
days: ReadonlyArray<TiCloudStorageRecordingDay>;
|
|
43
|
+
}>;
|
|
44
|
+
export declare const TiCloudStorageReplaySpeed: {
|
|
45
|
+
readonly x0_125: "x0_125";
|
|
46
|
+
readonly x0_25: "x0_25";
|
|
47
|
+
readonly x0_5: "x0_5";
|
|
48
|
+
readonly x1: "x1";
|
|
49
|
+
readonly x2: "x2";
|
|
50
|
+
readonly x4: "x4";
|
|
51
|
+
readonly x8: "x8";
|
|
52
|
+
};
|
|
53
|
+
export type TiCloudStorageReplaySpeed = (typeof TiCloudStorageReplaySpeed)[keyof typeof TiCloudStorageReplaySpeed];
|
|
54
|
+
export declare const TiCloudStorageAudioOutputState: {
|
|
55
|
+
readonly idle: "idle";
|
|
56
|
+
readonly buffering: "buffering";
|
|
57
|
+
readonly playing: "playing";
|
|
58
|
+
readonly failed: "failed";
|
|
59
|
+
readonly paused: "paused";
|
|
60
|
+
readonly completed: "completed";
|
|
61
|
+
};
|
|
62
|
+
export type TiCloudStorageAudioOutputState = (typeof TiCloudStorageAudioOutputState)[keyof typeof TiCloudStorageAudioOutputState];
|
|
63
|
+
export declare const TiCloudStorageVideoOutputState: {
|
|
64
|
+
readonly idle: "idle";
|
|
65
|
+
readonly buffering: "buffering";
|
|
66
|
+
readonly rendering: "rendering";
|
|
67
|
+
readonly failed: "failed";
|
|
68
|
+
readonly paused: "paused";
|
|
69
|
+
readonly completed: "completed";
|
|
70
|
+
};
|
|
71
|
+
export type TiCloudStorageVideoOutputState = (typeof TiCloudStorageVideoOutputState)[keyof typeof TiCloudStorageVideoOutputState];
|
|
72
|
+
export type TiCloudStorageStartRecordingOptions = Readonly<{
|
|
73
|
+
videoChannelId: number;
|
|
74
|
+
audioChannelId?: number;
|
|
75
|
+
}>;
|
|
76
|
+
export type TiCloudStorageExportOptions = Readonly<{
|
|
77
|
+
startTimeMs: number;
|
|
78
|
+
endTimeMs: number;
|
|
79
|
+
videoChannelId: number;
|
|
80
|
+
audioChannelId?: number;
|
|
81
|
+
}>;
|
|
82
|
+
export type TiCloudStorageGalleryAsset = TiRtcGalleryAsset;
|
|
83
|
+
export interface TiCloudStorageRecordingFile {
|
|
84
|
+
readonly path: string;
|
|
85
|
+
readonly durationMs: number;
|
|
86
|
+
moveToGallery(fileName?: string): Promise<Resp<TiCloudStorageGalleryAsset>>;
|
|
87
|
+
delete(): Promise<number>;
|
|
88
|
+
}
|
|
89
|
+
export interface TiCloudStorageSnapshotFile {
|
|
90
|
+
readonly path: string;
|
|
91
|
+
moveToGallery(fileName?: string): Promise<Resp<TiCloudStorageGalleryAsset>>;
|
|
92
|
+
delete(): Promise<number>;
|
|
93
|
+
}
|
|
94
|
+
export declare class TiCloudStorage {
|
|
95
|
+
private token;
|
|
96
|
+
private identity;
|
|
97
|
+
private disposed;
|
|
98
|
+
constructor(token: string);
|
|
99
|
+
static init(options: Readonly<{
|
|
100
|
+
appId: string;
|
|
101
|
+
endpoint?: string;
|
|
102
|
+
consoleLogEnabled?: boolean;
|
|
103
|
+
}>): Promise<number>;
|
|
104
|
+
static shutdown(): number;
|
|
105
|
+
static errorToString(code: number): string;
|
|
106
|
+
updateToken(token: string): number;
|
|
107
|
+
listRecordings(startTimeMs: number, endTimeMs: number): Promise<TiCloudStorageRecordingRangesResult>;
|
|
108
|
+
listRecordingDays(startDate: string, endDate: string, timeZoneId?: string): Promise<TiCloudStorageRecordingDaysResult>;
|
|
109
|
+
createReplay(): TiCloudStorageReplay;
|
|
110
|
+
exportRecording(options: TiCloudStorageExportOptions, onProgress?: (progress: number) => void): Resp<TiCloudStorageExportTask>;
|
|
111
|
+
dispose(): number;
|
|
112
|
+
private ensureIdentity;
|
|
113
|
+
}
|
|
114
|
+
export declare class TiCloudStorageReplay {
|
|
115
|
+
private readonly cloudStorage;
|
|
116
|
+
private identity;
|
|
117
|
+
private disposed;
|
|
118
|
+
private currentSpeed;
|
|
119
|
+
private currentTime;
|
|
120
|
+
onTimeChanged: ((timeMs: number) => void) | null;
|
|
121
|
+
onError: ((code: number) => void) | null;
|
|
122
|
+
onCompleted: (() => void) | null;
|
|
123
|
+
constructor(cloudStorage: TiCloudStorage);
|
|
124
|
+
get speed(): TiCloudStorageReplaySpeed;
|
|
125
|
+
get currentTimeMs(): number | null;
|
|
126
|
+
play(startTimeMs: number, endTimeMs: number, initialTimeMs?: number): number;
|
|
127
|
+
pause(): number;
|
|
128
|
+
resume(): number;
|
|
129
|
+
seek(timeMs: number): number;
|
|
130
|
+
setSpeed(speed: TiCloudStorageReplaySpeed): number;
|
|
131
|
+
startRecording(options: TiCloudStorageStartRecordingOptions): Resp<TiCloudStorageRecordingTask>;
|
|
132
|
+
stop(): number;
|
|
133
|
+
dispose(): number;
|
|
134
|
+
private command;
|
|
135
|
+
private ensureIdentity;
|
|
136
|
+
private handleEvent;
|
|
137
|
+
}
|
|
138
|
+
declare abstract class TiCloudStorageOutputBase {
|
|
139
|
+
protected identity: NativeIdentity | null;
|
|
140
|
+
protected disposed: boolean;
|
|
141
|
+
protected bound: boolean;
|
|
142
|
+
protected abstract create(): ReturnType<typeof NativeTiRtc.tiCloudStorageCreateAudioOutput>;
|
|
143
|
+
protected ensureIdentity(): NativeIdentity | number;
|
|
144
|
+
protected abstract handleEvent(event: NativeTiRtcEvent): void;
|
|
145
|
+
protected releaseIdentity(): void;
|
|
146
|
+
}
|
|
147
|
+
export declare class TiCloudStorageAudioOutput extends TiCloudStorageOutputBase {
|
|
148
|
+
private currentState;
|
|
149
|
+
onStateChanged: ((state: TiCloudStorageAudioOutputState) => void) | null;
|
|
150
|
+
onError: ((code: number) => void) | null;
|
|
151
|
+
protected create(): Readonly<{
|
|
152
|
+
code: number;
|
|
153
|
+
objectId: import("./specs/NativeTiRtc").NativeObjectId;
|
|
154
|
+
generation: number;
|
|
155
|
+
message: string | null;
|
|
156
|
+
}>;
|
|
157
|
+
get state(): TiCloudStorageAudioOutputState;
|
|
158
|
+
attach(replay: TiCloudStorageReplay, channelId: number): number;
|
|
159
|
+
setVolume(volumePercent: number): number;
|
|
160
|
+
detach(): number;
|
|
161
|
+
dispose(): number;
|
|
162
|
+
protected handleEvent(event: NativeTiRtcEvent): void;
|
|
163
|
+
}
|
|
164
|
+
export type TiCloudStorageVideoOutputViewProps = ViewProps & Readonly<{
|
|
165
|
+
output: TiCloudStorageVideoOutput;
|
|
166
|
+
resizeMode?: 'contain' | 'cover' | 'stretch';
|
|
167
|
+
}>;
|
|
168
|
+
export declare class TiCloudStorageVideoOutput extends TiCloudStorageOutputBase {
|
|
169
|
+
private currentState;
|
|
170
|
+
onStateChanged: ((state: TiCloudStorageVideoOutputState) => void) | null;
|
|
171
|
+
onError: ((code: number) => void) | null;
|
|
172
|
+
protected create(): Readonly<{
|
|
173
|
+
code: number;
|
|
174
|
+
objectId: import("./specs/NativeTiRtc").NativeObjectId;
|
|
175
|
+
generation: number;
|
|
176
|
+
message: string | null;
|
|
177
|
+
}>;
|
|
178
|
+
get state(): TiCloudStorageVideoOutputState;
|
|
179
|
+
view(props?: Omit<TiCloudStorageVideoOutputViewProps, 'output'>): React.ReactElement;
|
|
180
|
+
attach(replay: TiCloudStorageReplay, channelId: number): number;
|
|
181
|
+
takeSnapshot(): Promise<Resp<TiCloudStorageSnapshotFile>>;
|
|
182
|
+
detach(): number;
|
|
183
|
+
dispose(): number;
|
|
184
|
+
protected handleEvent(event: NativeTiRtcEvent): void;
|
|
185
|
+
}
|
|
186
|
+
export declare function TiCloudStorageVideoOutputView(props: TiCloudStorageVideoOutputViewProps): React.ReactElement;
|
|
187
|
+
export declare class TiCloudStorageRecordingTask {
|
|
188
|
+
private readonly taskId;
|
|
189
|
+
private readonly owner;
|
|
190
|
+
private stopPromise;
|
|
191
|
+
constructor(taskId: number, owner: TiCloudStorageReplay);
|
|
192
|
+
stop(): Promise<Resp<TiCloudStorageRecordingFile>>;
|
|
193
|
+
}
|
|
194
|
+
export declare class TiCloudStorageExportTask {
|
|
195
|
+
private readonly taskId;
|
|
196
|
+
private readonly owner;
|
|
197
|
+
private readonly onProgress?;
|
|
198
|
+
private resultPromise;
|
|
199
|
+
constructor(taskId: number, owner: TiCloudStorage, onProgress?: ((progress: number) => void) | undefined);
|
|
200
|
+
get progress(): number;
|
|
201
|
+
get result(): Promise<Resp<TiCloudStorageRecordingFile>>;
|
|
202
|
+
stop(): Promise<Resp<TiCloudStorageRecordingFile>>;
|
|
203
|
+
}
|
|
204
|
+
export {};
|
|
@@ -33,6 +33,7 @@ export declare class TiRtcVideoInput {
|
|
|
33
33
|
preview(props?: VideoInputPreviewPropsWithoutOwner): React.ReactElement;
|
|
34
34
|
dispose(): Promise<number>;
|
|
35
35
|
private enqueue;
|
|
36
|
+
private logged;
|
|
36
37
|
private ensureIdentity;
|
|
37
38
|
private adoptIdentity;
|
|
38
39
|
private refreshActualConfig;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
import { TiRtcConn } from './conn';
|
|
3
|
+
import { type Resp, type TiRtcSnapshotFile } from './recording';
|
|
3
4
|
import type { TiRtcOnVideoOutputError, TiRtcOnVideoOutputRenderSizeChanged, TiRtcOnVideoOutputStateChanged, TiRtcSize, TiRtcVideoOutputDebugSnapshotResult, TiRtcVideoOutputMetricsResult, TiRtcVideoOutputOptions, TiRtcVideoOutputState, TiRtcVideoOutputViewProps } from './types';
|
|
4
5
|
type VideoOutputViewPropsWithoutOwner = Omit<TiRtcVideoOutputViewProps, 'output'>;
|
|
5
6
|
export declare class TiRtcVideoOutput {
|
|
@@ -8,10 +9,12 @@ export declare class TiRtcVideoOutput {
|
|
|
8
9
|
private createCode;
|
|
9
10
|
private currentState;
|
|
10
11
|
private currentRenderSize;
|
|
12
|
+
private snapshotInFlight;
|
|
11
13
|
private options;
|
|
12
14
|
onStateChanged: TiRtcOnVideoOutputStateChanged | null;
|
|
13
15
|
onRenderSizeChanged: TiRtcOnVideoOutputRenderSizeChanged | null;
|
|
14
16
|
onError: TiRtcOnVideoOutputError | null;
|
|
17
|
+
takeSnapshot(): Promise<Resp<TiRtcSnapshotFile>>;
|
|
15
18
|
constructor();
|
|
16
19
|
get state(): TiRtcVideoOutputState;
|
|
17
20
|
get renderSize(): TiRtcSize | null;
|
package/package.json
CHANGED
package/src/audio_input.ts
CHANGED
|
@@ -2,21 +2,17 @@ import {
|
|
|
2
2
|
isPlainObject,
|
|
3
3
|
isUInt8,
|
|
4
4
|
normalizeCreateResult,
|
|
5
|
-
|
|
5
|
+
returnNotInitializedIfDisposed,
|
|
6
6
|
TIRTC_ERROR_INVALID_ARGUMENT,
|
|
7
7
|
TIRTC_ERROR_OK,
|
|
8
|
-
|
|
8
|
+
TIRTC_ERROR_NOT_INITIALIZED,
|
|
9
9
|
} from './errors';
|
|
10
10
|
import {registerNativeEventHandler, unregisterNativeEventHandler} from './events';
|
|
11
11
|
import {clearNativeIdentity, readNativeIdentity, setNativeIdentity, type NativeIdentity} from './native_object_id';
|
|
12
12
|
import {NativeTiRtc, type NativeTiRtcEvent} from './native';
|
|
13
|
+
import {logRtcOutcome, logRtcState} from './logging_internal';
|
|
13
14
|
import {TiRtcConn} from './conn';
|
|
14
|
-
import type {
|
|
15
|
-
TiRtcAudioInputOptions,
|
|
16
|
-
TiRtcInputState,
|
|
17
|
-
TiRtcOnInputError,
|
|
18
|
-
TiRtcOnInputStateChanged,
|
|
19
|
-
} from './types';
|
|
15
|
+
import type {TiRtcAudioInputOptions, TiRtcInputState, TiRtcOnInputError, TiRtcOnInputStateChanged} from './types';
|
|
20
16
|
|
|
21
17
|
export class TiRtcAudioInput {
|
|
22
18
|
private identity: NativeIdentity | null = null;
|
|
@@ -40,8 +36,12 @@ export class TiRtcAudioInput {
|
|
|
40
36
|
const result = normalizeCreateResult(NativeTiRtc.createAudioInput());
|
|
41
37
|
this.createCode = result.code;
|
|
42
38
|
if (result.code === TIRTC_ERROR_OK) {
|
|
43
|
-
this.adoptIdentity({
|
|
39
|
+
this.adoptIdentity({
|
|
40
|
+
objectId: result.objectId,
|
|
41
|
+
generation: result.generation,
|
|
42
|
+
});
|
|
44
43
|
}
|
|
44
|
+
logRtcOutcome('audio_input_create', result.code);
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
get state(): TiRtcInputState {
|
|
@@ -87,32 +87,41 @@ export class TiRtcAudioInput {
|
|
|
87
87
|
if (connIdentity === null) {
|
|
88
88
|
return Promise.resolve(TIRTC_ERROR_INVALID_ARGUMENT);
|
|
89
89
|
}
|
|
90
|
-
return this.
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
90
|
+
return this.logged(
|
|
91
|
+
'audio_input_attach',
|
|
92
|
+
this.enqueue(async () => {
|
|
93
|
+
const identity = this.ensureIdentity();
|
|
94
|
+
if (typeof identity === 'number') {
|
|
95
|
+
return identity;
|
|
96
|
+
}
|
|
97
|
+
return NativeTiRtc.audioInputAttach(identity.objectId, connIdentity.objectId, streamId);
|
|
98
|
+
}),
|
|
99
|
+
);
|
|
97
100
|
}
|
|
98
101
|
|
|
99
102
|
start(): Promise<number> {
|
|
100
|
-
return this.
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
103
|
+
return this.logged(
|
|
104
|
+
'audio_input_start',
|
|
105
|
+
this.enqueue(async () => {
|
|
106
|
+
const identity = this.ensureIdentity();
|
|
107
|
+
if (typeof identity === 'number') {
|
|
108
|
+
return identity;
|
|
109
|
+
}
|
|
110
|
+
return NativeTiRtc.audioInputStart(identity.objectId);
|
|
111
|
+
}),
|
|
112
|
+
);
|
|
107
113
|
}
|
|
108
114
|
|
|
109
115
|
stop(): Promise<number> {
|
|
110
|
-
return this.
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
+
return this.logged(
|
|
117
|
+
'audio_input_stop',
|
|
118
|
+
this.enqueue(async () => {
|
|
119
|
+
if (this.identity === null) {
|
|
120
|
+
return TIRTC_ERROR_OK;
|
|
121
|
+
}
|
|
122
|
+
return NativeTiRtc.audioInputStop(this.identity.objectId);
|
|
123
|
+
}),
|
|
124
|
+
);
|
|
116
125
|
}
|
|
117
126
|
|
|
118
127
|
detach(connection: TiRtcConn): Promise<number> {
|
|
@@ -120,47 +129,53 @@ export class TiRtcAudioInput {
|
|
|
120
129
|
if (connIdentity === null) {
|
|
121
130
|
return Promise.resolve(TIRTC_ERROR_INVALID_ARGUMENT);
|
|
122
131
|
}
|
|
123
|
-
return this.
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
132
|
+
return this.logged(
|
|
133
|
+
'audio_input_detach',
|
|
134
|
+
this.enqueue(async () => {
|
|
135
|
+
if (this.identity === null) {
|
|
136
|
+
return TIRTC_ERROR_OK;
|
|
137
|
+
}
|
|
138
|
+
return NativeTiRtc.audioInputDetach(this.identity.objectId, connIdentity.objectId);
|
|
139
|
+
}),
|
|
140
|
+
);
|
|
129
141
|
}
|
|
130
142
|
|
|
131
143
|
dispose(): Promise<number> {
|
|
132
144
|
if (this.disposed) {
|
|
133
145
|
return Promise.resolve(TIRTC_ERROR_OK);
|
|
134
146
|
}
|
|
135
|
-
return this.
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
this.
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
147
|
+
return this.logged(
|
|
148
|
+
'audio_input_dispose',
|
|
149
|
+
this.enqueue(async () => {
|
|
150
|
+
if (this.identity === null) {
|
|
151
|
+
this.disposed = true;
|
|
152
|
+
this.clearCallbacks();
|
|
153
|
+
this.currentState = 'stopped';
|
|
154
|
+
return TIRTC_ERROR_OK;
|
|
155
|
+
}
|
|
156
|
+
const identity = this.identity;
|
|
157
|
+
const code = await NativeTiRtc.audioInputDispose(identity.objectId);
|
|
158
|
+
if (code === TIRTC_ERROR_OK) {
|
|
159
|
+
this.disposed = true;
|
|
160
|
+
this.identity = null;
|
|
161
|
+
unregisterNativeEventHandler(identity);
|
|
162
|
+
clearNativeIdentity(this);
|
|
163
|
+
this.clearCallbacks();
|
|
164
|
+
this.currentState = 'stopped';
|
|
165
|
+
}
|
|
166
|
+
return code;
|
|
167
|
+
}, true),
|
|
168
|
+
);
|
|
154
169
|
}
|
|
155
170
|
|
|
156
171
|
private enqueue(operation: () => Promise<number>, allowDisposed = false): Promise<number> {
|
|
157
|
-
const released =
|
|
172
|
+
const released = returnNotInitializedIfDisposed(this.disposed);
|
|
158
173
|
if (released !== null && !allowDisposed) {
|
|
159
174
|
return Promise.resolve(released);
|
|
160
175
|
}
|
|
161
176
|
const next = this.queue.then(async () => {
|
|
162
177
|
if (this.disposed && !allowDisposed) {
|
|
163
|
-
return
|
|
178
|
+
return TIRTC_ERROR_NOT_INITIALIZED;
|
|
164
179
|
}
|
|
165
180
|
return operation();
|
|
166
181
|
});
|
|
@@ -168,8 +183,15 @@ export class TiRtcAudioInput {
|
|
|
168
183
|
return next;
|
|
169
184
|
}
|
|
170
185
|
|
|
186
|
+
private logged(operation: string, result: Promise<number>): Promise<number> {
|
|
187
|
+
return result.then((code) => {
|
|
188
|
+
logRtcOutcome(operation, code);
|
|
189
|
+
return code;
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
|
|
171
193
|
private ensureIdentity(): NativeIdentity | number {
|
|
172
|
-
const released =
|
|
194
|
+
const released = returnNotInitializedIfDisposed(this.disposed);
|
|
173
195
|
if (released !== null) {
|
|
174
196
|
return released;
|
|
175
197
|
}
|
|
@@ -196,10 +218,14 @@ export class TiRtcAudioInput {
|
|
|
196
218
|
return;
|
|
197
219
|
}
|
|
198
220
|
if (event.type === 'audioInputStateChanged' && event.state !== undefined) {
|
|
199
|
-
|
|
221
|
+
const nextState = event.state as TiRtcInputState;
|
|
222
|
+
if (this.currentState !== nextState) logRtcState('audio_input_state', nextState);
|
|
223
|
+
this.currentState = nextState;
|
|
200
224
|
this.onStateChanged?.(this.currentState);
|
|
201
225
|
} else if (event.type === 'audioInputError') {
|
|
202
|
-
|
|
226
|
+
const code = event.code ?? TIRTC_ERROR_INVALID_ARGUMENT;
|
|
227
|
+
logRtcOutcome('audio_input', code);
|
|
228
|
+
this.onError?.(code, event.message ?? null);
|
|
203
229
|
}
|
|
204
230
|
}
|
|
205
231
|
}
|