tirtc-react-native 2.3.1 → 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.
- 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 +585 -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 +35 -8
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeEventSink.kt +20 -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/TiRtcReactNativeStoreSupport.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+Store.mm +496 -0
- package/ios/TiRtcReactNative.h +2 -1
- package/ios/TiRtcReactNative.mm +109 -1
- package/ios/TiRtcReactNativeEventBinder.h +8 -0
- package/ios/TiRtcReactNativeEventBinder.mm +104 -0
- package/ios/TiRtcReactNativeEventSink.h +4 -0
- package/ios/TiRtcReactNativeEventSink.mm +20 -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/store.js +698 -0
- package/lib/module/store.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/store.d.ts +202 -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/store.ts +760 -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 NativeStoreRecordingRange = Readonly<{
|
|
87
|
+
startTimeMs: number;
|
|
88
|
+
endTimeMs: number;
|
|
89
|
+
}>;
|
|
90
|
+
export type NativeStoreRecordingRangesResult = Readonly<{
|
|
91
|
+
code: number;
|
|
92
|
+
recordings: ReadonlyArray<NativeStoreRecordingRange>;
|
|
93
|
+
}>;
|
|
94
|
+
export type NativeStoreRecordingDay = Readonly<{
|
|
95
|
+
date: string;
|
|
96
|
+
hasRecording: boolean;
|
|
97
|
+
}>;
|
|
98
|
+
export type NativeStoreRecordingDaysResult = Readonly<{
|
|
99
|
+
code: number;
|
|
100
|
+
days: ReadonlyArray<NativeStoreRecordingDay>;
|
|
101
|
+
}>;
|
|
102
|
+
export type NativeStoreReplayInfo = Readonly<{
|
|
103
|
+
code: number;
|
|
104
|
+
speed: number;
|
|
105
|
+
currentTimeMs: number | null;
|
|
106
|
+
}>;
|
|
107
|
+
export type NativeStoreTaskStartResult = 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
|
+
storeInitialize(options: NativeInitOptions): Promise<number>;
|
|
220
|
+
storeShutdown(): number;
|
|
221
|
+
storeCreate(token: string): NativeCreateResult;
|
|
222
|
+
storeUpdateToken(id: NativeObjectId, token: string): number;
|
|
223
|
+
storeListRecordings(id: NativeObjectId, startTimeMs: number, endTimeMs: number): Promise<NativeStoreRecordingRangesResult>;
|
|
224
|
+
storeListRecordingDays(id: NativeObjectId, startDate: string, endDate: string, timeZoneId: string): Promise<NativeStoreRecordingDaysResult>;
|
|
225
|
+
storeCreateReplay(id: NativeObjectId): NativeCreateResult;
|
|
226
|
+
storeExportRecording(id: NativeObjectId, startTimeMs: number, endTimeMs: number, videoChannelId: number, audioChannelId: number | null): NativeStoreTaskStartResult;
|
|
227
|
+
storeExportProgress(id: NativeObjectId): number;
|
|
228
|
+
storeExportResult(id: NativeObjectId): Promise<NativeMp4Result>;
|
|
229
|
+
storeExportStop(id: NativeObjectId): number;
|
|
230
|
+
storeDispose(id: NativeObjectId): number;
|
|
231
|
+
storeReplayGetInfo(id: NativeObjectId): NativeStoreReplayInfo;
|
|
232
|
+
storeReplayPlay(id: NativeObjectId, startTimeMs: number, endTimeMs: number, initialTimeMs: number | null): number;
|
|
233
|
+
storeReplayPause(id: NativeObjectId): number;
|
|
234
|
+
storeReplayResume(id: NativeObjectId): number;
|
|
235
|
+
storeReplaySeek(id: NativeObjectId, timeMs: number): number;
|
|
236
|
+
storeReplaySetSpeed(id: NativeObjectId, speed: number): number;
|
|
237
|
+
storeReplayStartRecording(id: NativeObjectId, videoChannelId: number, audioChannelId: number | null): NativeStoreTaskStartResult;
|
|
238
|
+
storeRecordingTaskStop(id: NativeObjectId): Promise<NativeMp4Result>;
|
|
239
|
+
storeReplayStop(id: NativeObjectId): number;
|
|
240
|
+
storeReplayDispose(id: NativeObjectId): number;
|
|
241
|
+
storeCreateAudioOutput(): NativeCreateResult;
|
|
242
|
+
storeAudioOutputGetState(id: NativeObjectId): NativeStateResult;
|
|
243
|
+
storeAudioOutputSetVolume(id: NativeObjectId, volumePercent: number): number;
|
|
244
|
+
storeAudioOutputAttach(outputId: NativeObjectId, replayId: NativeObjectId, channelId: number): number;
|
|
245
|
+
storeAudioOutputDetach(outputId: NativeObjectId): number;
|
|
246
|
+
storeAudioOutputDispose(id: NativeObjectId): number;
|
|
247
|
+
storeCreateVideoOutput(): NativeCreateResult;
|
|
248
|
+
storeVideoOutputGetState(id: NativeObjectId): NativeStateResult;
|
|
249
|
+
storeVideoOutputAttach(outputId: NativeObjectId, replayId: NativeObjectId, channelId: number): number;
|
|
250
|
+
storeVideoOutputDetach(outputId: NativeObjectId): number;
|
|
251
|
+
storeVideoOutputTakeSnapshot(id: NativeObjectId): Promise<NativeSnapshotResult>;
|
|
252
|
+
storeVideoOutputDispose(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,202 @@
|
|
|
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 TISTORE_ERROR_OK: 0;
|
|
7
|
+
export declare const TISTORE_ERROR_INVALID_ARGUMENT: 6000;
|
|
8
|
+
export declare const TISTORE_ERROR_NOT_INITIALIZED: 6001;
|
|
9
|
+
export declare const TISTORE_ERROR_TOKEN_EXPIRED: 6014;
|
|
10
|
+
export declare const TISTORE_ERROR_ALREADY_INITIALIZED: 6022;
|
|
11
|
+
export declare const TISTORE_ERROR_PERMISSION_DENIED: 6024;
|
|
12
|
+
export declare const TISTORE_ERROR_IN_USE: 6026;
|
|
13
|
+
export declare const TISTORE_ERROR_NOT_STARTED: 6027;
|
|
14
|
+
export declare const TISTORE_ERROR_NOT_BOUND: 6029;
|
|
15
|
+
export declare const TISTORE_ERROR_NOT_CONFIGURED: 6030;
|
|
16
|
+
export declare const TISTORE_ERROR_RESOURCE_EXHAUSTED: 6043;
|
|
17
|
+
export declare const TISTORE_ERROR_FILE_WRITE_FAILED: 6046;
|
|
18
|
+
export declare const TISTORE_ERROR_UNSUPPORTED_FORMAT: 6113;
|
|
19
|
+
export declare const TISTORE_ERROR_IO_FAILED: 6114;
|
|
20
|
+
export declare const TISTORE_ERROR_CANCELLED: 6115;
|
|
21
|
+
export declare const TISTORE_ERROR_RANGE_TOO_LARGE: 6117;
|
|
22
|
+
export declare const TISTORE_ERROR_NO_FRAME: 6118;
|
|
23
|
+
export declare const TISTORE_ERROR_NO_RECORDABLE_MEDIA: 6119;
|
|
24
|
+
export declare const TISTORE_ERROR_RECORDING_OVERRUN: 6120;
|
|
25
|
+
export declare const TISTORE_ERROR_RECORDING_UNREADABLE: 6122;
|
|
26
|
+
export declare const TISTORE_ERROR_STORE_UNAVAILABLE: 6123;
|
|
27
|
+
export declare const TISTORE_ERROR_STOPPED: 6124;
|
|
28
|
+
export type TiStoreRecordingRange = Readonly<{
|
|
29
|
+
startTimeMs: number;
|
|
30
|
+
endTimeMs: number;
|
|
31
|
+
}>;
|
|
32
|
+
export type TiStoreRecordingRangesResult = Readonly<{
|
|
33
|
+
code: number;
|
|
34
|
+
recordings: ReadonlyArray<TiStoreRecordingRange>;
|
|
35
|
+
}>;
|
|
36
|
+
export type TiStoreRecordingDay = Readonly<{
|
|
37
|
+
date: string;
|
|
38
|
+
hasRecording: boolean;
|
|
39
|
+
}>;
|
|
40
|
+
export type TiStoreRecordingDaysResult = Readonly<{
|
|
41
|
+
code: number;
|
|
42
|
+
days: ReadonlyArray<TiStoreRecordingDay>;
|
|
43
|
+
}>;
|
|
44
|
+
export declare const TiStoreReplaySpeed: {
|
|
45
|
+
readonly x1: "x1";
|
|
46
|
+
readonly x2: "x2";
|
|
47
|
+
readonly x4: "x4";
|
|
48
|
+
readonly x8: "x8";
|
|
49
|
+
};
|
|
50
|
+
export type TiStoreReplaySpeed = (typeof TiStoreReplaySpeed)[keyof typeof TiStoreReplaySpeed];
|
|
51
|
+
export declare const TiStoreAudioOutputState: {
|
|
52
|
+
readonly idle: "idle";
|
|
53
|
+
readonly buffering: "buffering";
|
|
54
|
+
readonly playing: "playing";
|
|
55
|
+
readonly failed: "failed";
|
|
56
|
+
readonly paused: "paused";
|
|
57
|
+
readonly completed: "completed";
|
|
58
|
+
};
|
|
59
|
+
export type TiStoreAudioOutputState = (typeof TiStoreAudioOutputState)[keyof typeof TiStoreAudioOutputState];
|
|
60
|
+
export declare const TiStoreVideoOutputState: {
|
|
61
|
+
readonly idle: "idle";
|
|
62
|
+
readonly buffering: "buffering";
|
|
63
|
+
readonly rendering: "rendering";
|
|
64
|
+
readonly failed: "failed";
|
|
65
|
+
readonly paused: "paused";
|
|
66
|
+
readonly completed: "completed";
|
|
67
|
+
};
|
|
68
|
+
export type TiStoreVideoOutputState = (typeof TiStoreVideoOutputState)[keyof typeof TiStoreVideoOutputState];
|
|
69
|
+
export type TiStoreStartRecordingOptions = Readonly<{
|
|
70
|
+
videoChannelId: number;
|
|
71
|
+
audioChannelId?: number;
|
|
72
|
+
}>;
|
|
73
|
+
export type TiStoreExportOptions = Readonly<{
|
|
74
|
+
startTimeMs: number;
|
|
75
|
+
endTimeMs: number;
|
|
76
|
+
videoChannelId: number;
|
|
77
|
+
audioChannelId?: number;
|
|
78
|
+
}>;
|
|
79
|
+
export type TiStoreGalleryAsset = TiRtcGalleryAsset;
|
|
80
|
+
export interface TiStoreRecordingFile {
|
|
81
|
+
readonly path: string;
|
|
82
|
+
readonly durationMs: number;
|
|
83
|
+
moveToGallery(fileName?: string): Promise<Resp<TiStoreGalleryAsset>>;
|
|
84
|
+
delete(): Promise<number>;
|
|
85
|
+
}
|
|
86
|
+
export interface TiStoreSnapshotFile {
|
|
87
|
+
readonly path: string;
|
|
88
|
+
moveToGallery(fileName?: string): Promise<Resp<TiStoreGalleryAsset>>;
|
|
89
|
+
delete(): Promise<number>;
|
|
90
|
+
}
|
|
91
|
+
export declare class TiStore {
|
|
92
|
+
private token;
|
|
93
|
+
private identity;
|
|
94
|
+
private disposed;
|
|
95
|
+
onTokenExpired: (() => void) | null;
|
|
96
|
+
constructor(token: string);
|
|
97
|
+
static init(options: Readonly<{
|
|
98
|
+
appId: string;
|
|
99
|
+
endpoint?: string;
|
|
100
|
+
consoleLogEnabled?: boolean;
|
|
101
|
+
}>): Promise<number>;
|
|
102
|
+
static shutdown(): number;
|
|
103
|
+
static errorToString(code: number): string;
|
|
104
|
+
updateToken(token: string): number;
|
|
105
|
+
listRecordings(startTimeMs: number, endTimeMs: number): Promise<TiStoreRecordingRangesResult>;
|
|
106
|
+
listRecordingDays(startDate: string, endDate: string, timeZoneId?: string): Promise<TiStoreRecordingDaysResult>;
|
|
107
|
+
createReplay(): TiStoreReplay;
|
|
108
|
+
exportRecording(options: TiStoreExportOptions, onProgress?: (progress: number) => void): Resp<TiStoreExportTask>;
|
|
109
|
+
dispose(): number;
|
|
110
|
+
private ensureIdentity;
|
|
111
|
+
}
|
|
112
|
+
export declare class TiStoreReplay {
|
|
113
|
+
private readonly store;
|
|
114
|
+
private identity;
|
|
115
|
+
private disposed;
|
|
116
|
+
private currentSpeed;
|
|
117
|
+
private currentTime;
|
|
118
|
+
onTimeChanged: ((timeMs: number) => void) | null;
|
|
119
|
+
onError: ((code: number) => void) | null;
|
|
120
|
+
onCompleted: (() => void) | null;
|
|
121
|
+
constructor(store: TiStore);
|
|
122
|
+
get speed(): TiStoreReplaySpeed;
|
|
123
|
+
get currentTimeMs(): number | null;
|
|
124
|
+
play(startTimeMs: number, endTimeMs: number, initialTimeMs?: number): number;
|
|
125
|
+
pause(): number;
|
|
126
|
+
resume(): number;
|
|
127
|
+
seek(timeMs: number): number;
|
|
128
|
+
setSpeed(speed: TiStoreReplaySpeed): number;
|
|
129
|
+
startRecording(options: TiStoreStartRecordingOptions): Resp<TiStoreRecordingTask>;
|
|
130
|
+
stop(): number;
|
|
131
|
+
dispose(): number;
|
|
132
|
+
private command;
|
|
133
|
+
private ensureIdentity;
|
|
134
|
+
private handleEvent;
|
|
135
|
+
}
|
|
136
|
+
declare abstract class StoreOutputBase {
|
|
137
|
+
protected identity: NativeIdentity | null;
|
|
138
|
+
protected disposed: boolean;
|
|
139
|
+
protected bound: boolean;
|
|
140
|
+
protected abstract create(): ReturnType<typeof NativeTiRtc.storeCreateAudioOutput>;
|
|
141
|
+
protected ensureIdentity(): NativeIdentity | number;
|
|
142
|
+
protected abstract handleEvent(event: NativeTiRtcEvent): void;
|
|
143
|
+
protected releaseIdentity(): void;
|
|
144
|
+
}
|
|
145
|
+
export declare class TiStoreAudioOutput extends StoreOutputBase {
|
|
146
|
+
private currentState;
|
|
147
|
+
onStateChanged: ((state: TiStoreAudioOutputState) => void) | null;
|
|
148
|
+
onError: ((code: number) => void) | null;
|
|
149
|
+
protected create(): Readonly<{
|
|
150
|
+
code: number;
|
|
151
|
+
objectId: import("./specs/NativeTiRtc").NativeObjectId;
|
|
152
|
+
generation: number;
|
|
153
|
+
message: string | null;
|
|
154
|
+
}>;
|
|
155
|
+
get state(): TiStoreAudioOutputState;
|
|
156
|
+
attach(replay: TiStoreReplay, channelId: number): number;
|
|
157
|
+
setVolume(volumePercent: number): number;
|
|
158
|
+
detach(): number;
|
|
159
|
+
dispose(): number;
|
|
160
|
+
protected handleEvent(event: NativeTiRtcEvent): void;
|
|
161
|
+
}
|
|
162
|
+
export type TiStoreVideoOutputViewProps = ViewProps & Readonly<{
|
|
163
|
+
output: TiStoreVideoOutput;
|
|
164
|
+
resizeMode?: 'contain' | 'cover' | 'stretch';
|
|
165
|
+
}>;
|
|
166
|
+
export declare class TiStoreVideoOutput extends StoreOutputBase {
|
|
167
|
+
private currentState;
|
|
168
|
+
onStateChanged: ((state: TiStoreVideoOutputState) => void) | null;
|
|
169
|
+
onError: ((code: number) => void) | null;
|
|
170
|
+
protected create(): Readonly<{
|
|
171
|
+
code: number;
|
|
172
|
+
objectId: import("./specs/NativeTiRtc").NativeObjectId;
|
|
173
|
+
generation: number;
|
|
174
|
+
message: string | null;
|
|
175
|
+
}>;
|
|
176
|
+
get state(): TiStoreVideoOutputState;
|
|
177
|
+
view(props?: Omit<TiStoreVideoOutputViewProps, 'output'>): React.ReactElement;
|
|
178
|
+
attach(replay: TiStoreReplay, channelId: number): number;
|
|
179
|
+
takeSnapshot(): Promise<Resp<TiStoreSnapshotFile>>;
|
|
180
|
+
detach(): number;
|
|
181
|
+
dispose(): number;
|
|
182
|
+
protected handleEvent(event: NativeTiRtcEvent): void;
|
|
183
|
+
}
|
|
184
|
+
export declare function TiStoreVideoOutputView(props: TiStoreVideoOutputViewProps): React.ReactElement;
|
|
185
|
+
export declare class TiStoreRecordingTask {
|
|
186
|
+
private readonly taskId;
|
|
187
|
+
private readonly owner;
|
|
188
|
+
private stopPromise;
|
|
189
|
+
constructor(taskId: number, owner: TiStoreReplay);
|
|
190
|
+
stop(): Promise<Resp<TiStoreRecordingFile>>;
|
|
191
|
+
}
|
|
192
|
+
export declare class TiStoreExportTask {
|
|
193
|
+
private readonly taskId;
|
|
194
|
+
private readonly owner;
|
|
195
|
+
private readonly onProgress?;
|
|
196
|
+
private resultPromise;
|
|
197
|
+
constructor(taskId: number, owner: TiStore, onProgress?: ((progress: number) => void) | undefined);
|
|
198
|
+
get progress(): number;
|
|
199
|
+
get result(): Promise<Resp<TiStoreRecordingFile>>;
|
|
200
|
+
stop(): Promise<Resp<TiStoreRecordingFile>>;
|
|
201
|
+
}
|
|
202
|
+
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
|
}
|