tirtc-react-native 2.5.0-alpha.1 → 2.5.2
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 +39 -6
- package/TiRtcReactNative.podspec +1 -1
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcModule.kt +137 -14
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeCleanup.kt +54 -19
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeCloudStorageCallbacks.kt +60 -0
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeEventBinder.kt +2 -0
- 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 +112 -5
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeOptions.kt +2 -7
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeRegistry.kt +3 -0
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeStorageSupport.kt +46 -22
- package/ios/TiRtcReactNative+Conn.mm +61 -0
- package/ios/TiRtcReactNative+Output.mm +1 -7
- package/ios/TiRtcReactNative+Private.h +1 -0
- package/ios/TiRtcReactNative+Storage.mm +133 -35
- package/ios/TiRtcReactNative.mm +137 -48
- package/ios/TiRtcReactNativeCloudStorageCallbacks.h +13 -0
- package/ios/TiRtcReactNativeCloudStorageCallbacks.mm +67 -0
- package/ios/TiRtcReactNativeEventBinder.h +4 -0
- package/ios/TiRtcReactNativeEventBinder.mm +11 -0
- package/ios/TiRtcReactNativeEventSink.h +5 -0
- package/ios/TiRtcReactNativeEventSink.mm +18 -0
- package/ios/TiRtcReactNativeMaps.h +6 -0
- package/ios/TiRtcReactNativeMaps.mm +47 -0
- package/ios/TiRtcReactNativeOptions.mm +2 -6
- package/lib/module/audio_input.js +23 -4
- package/lib/module/audio_input.js.map +1 -1
- package/lib/module/build_identity.js +1 -1
- package/lib/module/conn.js +19 -0
- package/lib/module/conn.js.map +1 -1
- package/lib/module/events.js +16 -9
- package/lib/module/events.js.map +1 -1
- package/lib/module/index.js +3 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/raw_dump.js +53 -0
- package/lib/module/raw_dump.js.map +1 -0
- package/lib/module/specs/NativeTiRtc.js.map +1 -1
- package/lib/module/storage.js +185 -33
- package/lib/module/storage.js.map +1 -1
- package/lib/module/types.js +0 -4
- package/lib/module/types.js.map +1 -1
- package/lib/module/video_input.js +16 -6
- package/lib/module/video_input.js.map +1 -1
- package/lib/typescript/conn.d.ts +2 -0
- package/lib/typescript/index.d.ts +5 -3
- package/lib/typescript/native.d.ts +1 -1
- package/lib/typescript/raw_dump.d.ts +35 -0
- package/lib/typescript/specs/NativeTiRtc.d.ts +74 -2
- package/lib/typescript/storage.d.ts +82 -3
- package/lib/typescript/types.d.ts +5 -6
- package/package.json +2 -2
- package/src/audio_input.ts +30 -11
- package/src/conn.ts +23 -0
- package/src/events.ts +14 -9
- package/src/index.ts +17 -1
- package/src/native.ts +7 -1
- package/src/raw_dump.ts +84 -0
- package/src/specs/NativeTiRtc.ts +79 -2
- package/src/storage.ts +256 -39
- package/src/types.ts +5 -8
- package/src/video_input.ts +22 -12
package/ios/TiRtcReactNative.mm
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
#import "TiRtcReactNativeCloudStorageCallbacks.h"
|
|
1
2
|
#import "TiRtcReactNative.h"
|
|
2
3
|
#import "TiRtcReactNative+Private.h"
|
|
3
4
|
|
|
@@ -17,6 +18,7 @@
|
|
|
17
18
|
extern "C" int32_t ti_rtc_transport_log(int32_t level, const char* tag, const char* message);
|
|
18
19
|
|
|
19
20
|
@protocol TiRtcReactNativeMediaFile <NSObject>
|
|
21
|
+
@property(nonatomic, readonly) NSString* path;
|
|
20
22
|
- (void)deleteWithCompletion:(void (^)(int32_t code))completion;
|
|
21
23
|
@end
|
|
22
24
|
|
|
@@ -38,12 +40,86 @@ static void TiRtcReactNativeDeleteForInvalidation(id file, dispatch_group_t grou
|
|
|
38
40
|
}];
|
|
39
41
|
}
|
|
40
42
|
|
|
43
|
+
static void TiRtcReactNativeReleaseOwners(NSMutableArray* objects, int64_t delayMs) {
|
|
44
|
+
BOOL (^released)(NSString*, int32_t) = ^BOOL(NSString* operation, int32_t code) {
|
|
45
|
+
if (code == 0 || code == TiRtcReactNativeErrorObjectReleased) return YES;
|
|
46
|
+
if (delayMs == 10 || code != [TiCloudStorageErrorCode inUse])
|
|
47
|
+
TiRtcReactNativeLogInvalidationFailure(operation, code);
|
|
48
|
+
// Keep ownership while a released JS waiter finishes unwinding its Native task.
|
|
49
|
+
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, delayMs * NSEC_PER_MSEC),
|
|
50
|
+
dispatch_get_main_queue(), ^{
|
|
51
|
+
TiRtcReactNativeReleaseOwners(objects, MIN(INT64_C(1000), delayMs * 2));
|
|
52
|
+
});
|
|
53
|
+
return NO;
|
|
54
|
+
};
|
|
55
|
+
for (TiCloudStorageReplay* replay in [objects copy]) {
|
|
56
|
+
if ([replay isKindOfClass:[TiCloudStorageReplay class]] &&
|
|
57
|
+
!released(@"ti-cloud-storage-replay-stop", [replay stop])) return;
|
|
58
|
+
}
|
|
59
|
+
for (TiCloudStorageAudioOutput* output in [objects copy]) {
|
|
60
|
+
if (![output isKindOfClass:[TiCloudStorageAudioOutput class]]) continue;
|
|
61
|
+
if (!released(@"ti-cloud-storage-audio-detach", [output detach])) return;
|
|
62
|
+
if (!released(@"ti-cloud-storage-audio-dispose", [output dispose])) return;
|
|
63
|
+
[objects removeObjectIdenticalTo:output];
|
|
64
|
+
}
|
|
65
|
+
for (TiCloudStorageVideoOutput* output in [objects copy]) {
|
|
66
|
+
if (![output isKindOfClass:[TiCloudStorageVideoOutput class]]) continue;
|
|
67
|
+
if (!released(@"ti-cloud-storage-video-detach", [output detach])) return;
|
|
68
|
+
if (!released(@"ti-cloud-storage-video-view-detach", [output detachView])) return;
|
|
69
|
+
if (!released(@"ti-cloud-storage-video-dispose", [output dispose])) return;
|
|
70
|
+
[objects removeObjectIdenticalTo:output];
|
|
71
|
+
}
|
|
72
|
+
for (TiRtcAudioOutput* output in [objects copy]) {
|
|
73
|
+
if (![output isKindOfClass:[TiRtcAudioOutput class]]) continue;
|
|
74
|
+
if (!released(@"audio_output_dispose", [output dispose])) return;
|
|
75
|
+
[objects removeObjectIdenticalTo:output];
|
|
76
|
+
}
|
|
77
|
+
for (TiRtcVideoOutput* output in [objects copy]) {
|
|
78
|
+
if (![output isKindOfClass:[TiRtcVideoOutput class]]) continue;
|
|
79
|
+
if (!released(@"video_output_dispose", [output dispose])) return;
|
|
80
|
+
[objects removeObjectIdenticalTo:output];
|
|
81
|
+
}
|
|
82
|
+
for (TiRtcAudioInput* input in [objects copy]) {
|
|
83
|
+
if (![input isKindOfClass:[TiRtcAudioInput class]]) continue;
|
|
84
|
+
if (!released(@"audio_input_dispose", [input dispose])) return;
|
|
85
|
+
[objects removeObjectIdenticalTo:input];
|
|
86
|
+
}
|
|
87
|
+
for (TiRtcVideoInput* input in [objects copy]) {
|
|
88
|
+
if (![input isKindOfClass:[TiRtcVideoInput class]]) continue;
|
|
89
|
+
if (!released(@"video_input_dispose", [input dispose])) return;
|
|
90
|
+
[objects removeObjectIdenticalTo:input];
|
|
91
|
+
}
|
|
92
|
+
for (TiCloudStorageReplay* replay in [objects copy]) {
|
|
93
|
+
if (![replay isKindOfClass:[TiCloudStorageReplay class]]) continue;
|
|
94
|
+
if (!released(@"ti-cloud-storage-replay-dispose", [replay dispose])) return;
|
|
95
|
+
[objects removeObjectIdenticalTo:replay];
|
|
96
|
+
}
|
|
97
|
+
for (TiRtcConn* conn in [objects copy]) {
|
|
98
|
+
if (![conn isKindOfClass:[TiRtcConn class]]) continue;
|
|
99
|
+
if (!released(@"conn_disconnect", [conn disconnect])) return;
|
|
100
|
+
if (!released(@"conn_dispose", [conn dispose])) return;
|
|
101
|
+
[objects removeObjectIdenticalTo:conn];
|
|
102
|
+
}
|
|
103
|
+
for (TiCloudStorage* cloudStorage in [objects copy]) {
|
|
104
|
+
if (![cloudStorage isKindOfClass:[TiCloudStorage class]]) continue;
|
|
105
|
+
if (!released(@"ti-cloud-storage-dispose", [cloudStorage dispose])) return;
|
|
106
|
+
[objects removeObjectIdenticalTo:cloudStorage];
|
|
107
|
+
}
|
|
108
|
+
if (!released(@"ti-cloud-storage-shutdown", [TiCloudStorage shutdown])) return;
|
|
109
|
+
if (!released(@"runtime_shutdown", [TiRtc shutdown])) return;
|
|
110
|
+
[TiRtcLogging logWithLevel:TiRtcLogLevelInfo tag:@"TIRTC_REACT_NATIVE"
|
|
111
|
+
message:@"[module_invalidate] native owners released"];
|
|
112
|
+
|
|
113
|
+
}
|
|
114
|
+
|
|
41
115
|
#pragma clang diagnostic push
|
|
42
116
|
#pragma clang diagnostic ignored "-Wprotocol"
|
|
43
117
|
@implementation TiRtcReactNative {
|
|
44
118
|
TiRtcReactNativeRegistry* _registry;
|
|
45
119
|
TiRtcReactNativeEventSink* _eventSink;
|
|
46
120
|
TiRtcReactNativeEventBinder* _eventBinder;
|
|
121
|
+
TiRtcReactNativeCloudStorageCallbacks* _cloudStorageCallbacks;
|
|
122
|
+
NSLock* _lifecycleLock;
|
|
47
123
|
std::atomic_bool _invalidated;
|
|
48
124
|
}
|
|
49
125
|
|
|
@@ -52,14 +128,28 @@ RCT_EXPORT_MODULE(TiRtc)
|
|
|
52
128
|
- (instancetype)init {
|
|
53
129
|
if (self = [super init]) {
|
|
54
130
|
_invalidated.store(false);
|
|
131
|
+
_lifecycleLock = [NSLock new];
|
|
55
132
|
_registry = [TiRtcReactNativeRegistry sharedRegistry];
|
|
56
133
|
__weak TiRtcReactNative* weakSelf = self;
|
|
134
|
+
_cloudStorageCallbacks = [[TiRtcReactNativeCloudStorageCallbacks alloc] initWithWake:^{
|
|
135
|
+
TiRtcReactNative* strongSelf = weakSelf;
|
|
136
|
+
if (strongSelf != nil && !strongSelf->_invalidated.load()) {
|
|
137
|
+
[strongSelf emitOnTiRtcEvent:@{@"type": @"tiCloudStorageCallbackReady",
|
|
138
|
+
@"objectId": @0, @"generation": @0}];
|
|
139
|
+
}
|
|
140
|
+
}];
|
|
57
141
|
_eventSink = [[TiRtcReactNativeEventSink alloc] initWithRegistry:_registry
|
|
58
142
|
emitBlock:^(NSDictionary* event) {
|
|
59
143
|
TiRtcReactNative* strongSelf = weakSelf;
|
|
60
144
|
if (strongSelf != nil &&
|
|
61
145
|
!strongSelf->_invalidated.load()) {
|
|
62
|
-
|
|
146
|
+
NSString* type = event[@"type"];
|
|
147
|
+
if ([type hasPrefix:@"tiCloudStorageReplay"] ||
|
|
148
|
+
[type hasPrefix:@"tiCloudStorageExport"]) {
|
|
149
|
+
[strongSelf->_cloudStorageCallbacks deliver:event];
|
|
150
|
+
} else {
|
|
151
|
+
[strongSelf emitOnTiRtcEvent:event];
|
|
152
|
+
}
|
|
63
153
|
}
|
|
64
154
|
}];
|
|
65
155
|
[_registry setEventSink:_eventSink];
|
|
@@ -69,9 +159,15 @@ RCT_EXPORT_MODULE(TiRtc)
|
|
|
69
159
|
}
|
|
70
160
|
|
|
71
161
|
- (void)invalidate {
|
|
72
|
-
|
|
162
|
+
[_lifecycleLock lock];
|
|
163
|
+
if (_invalidated.exchange(true)) {
|
|
164
|
+
[_lifecycleLock unlock];
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
[_cloudStorageCallbacks invalidate];
|
|
73
168
|
NSArray* objects = [_registry drainObjects];
|
|
74
169
|
NSArray* files = [_registry drainTransientObjects];
|
|
170
|
+
[_lifecycleLock unlock];
|
|
75
171
|
dispatch_group_t pending = dispatch_group_create();
|
|
76
172
|
for (id file in files) TiRtcReactNativeDeleteForInvalidation(file, pending);
|
|
77
173
|
for (id object in objects) {
|
|
@@ -97,55 +193,18 @@ RCT_EXPORT_MODULE(TiRtc)
|
|
|
97
193
|
}
|
|
98
194
|
}
|
|
99
195
|
dispatch_group_notify(pending, dispatch_get_main_queue(), ^{
|
|
100
|
-
|
|
101
|
-
if (![output isKindOfClass:[TiCloudStorageAudioOutput class]]) continue;
|
|
102
|
-
TiRtcReactNativeLogInvalidationFailure(@"ti-cloud-storage-audio-detach", [output detach]);
|
|
103
|
-
TiRtcReactNativeLogInvalidationFailure(@"ti-cloud-storage-audio-dispose", [output dispose]);
|
|
104
|
-
}
|
|
105
|
-
for (TiCloudStorageVideoOutput* output in objects) {
|
|
106
|
-
if (![output isKindOfClass:[TiCloudStorageVideoOutput class]]) continue;
|
|
107
|
-
TiRtcReactNativeLogInvalidationFailure(@"ti-cloud-storage-video-detach", [output detach]);
|
|
108
|
-
TiRtcReactNativeLogInvalidationFailure(@"ti-cloud-storage-video-view-detach", [output detachView]);
|
|
109
|
-
TiRtcReactNativeLogInvalidationFailure(@"ti-cloud-storage-video-dispose", [output dispose]);
|
|
110
|
-
}
|
|
111
|
-
for (TiRtcAudioOutput* output in objects) {
|
|
112
|
-
if ([output isKindOfClass:[TiRtcAudioOutput class]])
|
|
113
|
-
TiRtcReactNativeLogInvalidationFailure(@"audio_output_dispose", [output dispose]);
|
|
114
|
-
}
|
|
115
|
-
for (TiRtcVideoOutput* output in objects) {
|
|
116
|
-
if ([output isKindOfClass:[TiRtcVideoOutput class]])
|
|
117
|
-
TiRtcReactNativeLogInvalidationFailure(@"video_output_dispose", [output dispose]);
|
|
118
|
-
}
|
|
119
|
-
for (TiRtcAudioInput* input in objects) {
|
|
120
|
-
if ([input isKindOfClass:[TiRtcAudioInput class]])
|
|
121
|
-
TiRtcReactNativeLogInvalidationFailure(@"audio_input_dispose", [input dispose]);
|
|
122
|
-
}
|
|
123
|
-
for (TiRtcVideoInput* input in objects) {
|
|
124
|
-
if ([input isKindOfClass:[TiRtcVideoInput class]])
|
|
125
|
-
TiRtcReactNativeLogInvalidationFailure(@"video_input_dispose", [input dispose]);
|
|
126
|
-
}
|
|
127
|
-
for (TiCloudStorageReplay* replay in objects) {
|
|
128
|
-
if (![replay isKindOfClass:[TiCloudStorageReplay class]]) continue;
|
|
129
|
-
TiRtcReactNativeLogInvalidationFailure(@"ti-cloud-storage-replay-stop", [replay stop]);
|
|
130
|
-
TiRtcReactNativeLogInvalidationFailure(@"ti-cloud-storage-replay-dispose", [replay dispose]);
|
|
131
|
-
}
|
|
132
|
-
for (TiRtcConn* conn in objects) {
|
|
133
|
-
if (![conn isKindOfClass:[TiRtcConn class]]) continue;
|
|
134
|
-
TiRtcReactNativeLogInvalidationFailure(@"conn_disconnect", [conn disconnect]);
|
|
135
|
-
TiRtcReactNativeLogInvalidationFailure(@"conn_dispose", [conn dispose]);
|
|
136
|
-
}
|
|
137
|
-
for (TiCloudStorage* cloudStorage in objects) {
|
|
138
|
-
if ([cloudStorage isKindOfClass:[TiCloudStorage class]])
|
|
139
|
-
TiRtcReactNativeLogInvalidationFailure(@"ti-cloud-storage-dispose", [cloudStorage dispose]);
|
|
140
|
-
}
|
|
141
|
-
TiRtcReactNativeLogInvalidationFailure(@"ti-cloud-storage-shutdown", [TiCloudStorage shutdown]);
|
|
142
|
-
TiRtcReactNativeLogInvalidationFailure(@"runtime_shutdown", [TiRtc shutdown]);
|
|
143
|
-
[TiRtcLogging logWithLevel:TiRtcLogLevelInfo
|
|
144
|
-
tag:@"TIRTC_REACT_NATIVE"
|
|
145
|
-
message:@"[module_invalidate] native owners released"];
|
|
196
|
+
TiRtcReactNativeReleaseOwners([objects mutableCopy], 10);
|
|
146
197
|
});
|
|
147
198
|
}
|
|
148
199
|
|
|
200
|
+
- (NSDictionary*)tiCloudStorageTakeCallback {
|
|
201
|
+
return [_cloudStorageCallbacks take];
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
- (NSNumber*)tiCloudStorageAcknowledgeCallback:(double)deliveryId {
|
|
205
|
+
return [_cloudStorageCallbacks acknowledge:deliveryId];
|
|
206
|
+
}
|
|
207
|
+
|
|
149
208
|
- (void)initialize:(JS::NativeTiRtc::NativeInitOptions&)options
|
|
150
209
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
151
210
|
reject:(RCTPromiseRejectBlock)reject {
|
|
@@ -241,6 +300,36 @@ RCT_EXPORT_MODULE(TiRtc)
|
|
|
241
300
|
return @(TiRtcReactNativeErrorOK);
|
|
242
301
|
}
|
|
243
302
|
|
|
303
|
+
- (NSDictionary*)snapshotResultWithCode:(int32_t)code file:(id)file {
|
|
304
|
+
if (file == nil) {
|
|
305
|
+
return @{
|
|
306
|
+
@"code" : @(TiRtcReactNativeNormalizeDarwin(code)),
|
|
307
|
+
@"fileId" : (id)kCFNull,
|
|
308
|
+
@"filePath" : (id)kCFNull,
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
[_lifecycleLock lock];
|
|
313
|
+
if (_invalidated.load()) {
|
|
314
|
+
[_lifecycleLock unlock];
|
|
315
|
+
dispatch_group_t pending = dispatch_group_create();
|
|
316
|
+
TiRtcReactNativeDeleteForInvalidation(file, pending);
|
|
317
|
+
return @{
|
|
318
|
+
@"code" : @(TiRtcReactNativeErrorObjectReleased),
|
|
319
|
+
@"fileId" : (id)kCFNull,
|
|
320
|
+
@"filePath" : (id)kCFNull,
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
NSInteger fileId = [_registry addTransientObject:file];
|
|
324
|
+
NSDictionary* result = @{
|
|
325
|
+
@"code" : @(TiRtcReactNativeNormalizeDarwin(code)),
|
|
326
|
+
@"fileId" : @(fileId),
|
|
327
|
+
@"filePath" : [(id<TiRtcReactNativeMediaFile>)file path] ?: (id)kCFNull,
|
|
328
|
+
};
|
|
329
|
+
[_lifecycleLock unlock];
|
|
330
|
+
return result;
|
|
331
|
+
}
|
|
332
|
+
|
|
244
333
|
- (NSNumber*)connCode:(TiRtcConn*)conn block:(int32_t (^)(TiRtcConn* conn))block {
|
|
245
334
|
return conn == nil ? @(TiRtcReactNativeErrorObjectReleased)
|
|
246
335
|
: @(TiRtcReactNativeNormalizeDarwin(block(conn)));
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
|
|
3
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
4
|
+
|
|
5
|
+
@interface TiRtcReactNativeCloudStorageCallbacks : NSObject
|
|
6
|
+
- (instancetype)initWithWake:(void (^)(void))wake;
|
|
7
|
+
- (void)deliver:(NSDictionary*)event;
|
|
8
|
+
- (nullable NSDictionary*)take;
|
|
9
|
+
- (NSNumber*)acknowledge:(double)deliveryId;
|
|
10
|
+
- (void)invalidate;
|
|
11
|
+
@end
|
|
12
|
+
|
|
13
|
+
NS_ASSUME_NONNULL_END
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
#import "TiRtcReactNativeCloudStorageCallbacks.h"
|
|
2
|
+
|
|
3
|
+
@implementation TiRtcReactNativeCloudStorageCallbacks {
|
|
4
|
+
NSCondition* _condition;
|
|
5
|
+
void (^_wake)(void);
|
|
6
|
+
NSDictionary* _pending;
|
|
7
|
+
uint64_t _sequence;
|
|
8
|
+
BOOL _claimed;
|
|
9
|
+
BOOL _closed;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
- (instancetype)initWithWake:(void (^)(void))wake {
|
|
13
|
+
if (self = [super init]) {
|
|
14
|
+
_condition = [NSCondition new];
|
|
15
|
+
_wake = [wake copy];
|
|
16
|
+
}
|
|
17
|
+
return self;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
- (void)deliver:(NSDictionary*)event {
|
|
21
|
+
[_condition lock];
|
|
22
|
+
if (_closed) {
|
|
23
|
+
[_condition unlock];
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
// The public SDK supplies one shared serial background callback queue.
|
|
27
|
+
NSAssert(_pending == nil, @"Cloud Storage callbacks require serial SDK delivery");
|
|
28
|
+
_pending = event;
|
|
29
|
+
_claimed = NO;
|
|
30
|
+
uint64_t deliveryId = ++_sequence;
|
|
31
|
+
[_condition unlock];
|
|
32
|
+
_wake();
|
|
33
|
+
[_condition lock];
|
|
34
|
+
while (!_closed && _pending != nil && _sequence == deliveryId) [_condition wait];
|
|
35
|
+
[_condition unlock];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
- (NSDictionary*)take {
|
|
39
|
+
[_condition lock];
|
|
40
|
+
NSDictionary* value = nil;
|
|
41
|
+
if (!_closed && !_claimed && _pending != nil) {
|
|
42
|
+
_claimed = YES;
|
|
43
|
+
value = @{@"deliveryId": @(_sequence), @"event": _pending};
|
|
44
|
+
}
|
|
45
|
+
[_condition unlock];
|
|
46
|
+
return value;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
- (NSNumber*)acknowledge:(double)deliveryId {
|
|
50
|
+
[_condition lock];
|
|
51
|
+
if (!_closed && _claimed && deliveryId == (double)_sequence) {
|
|
52
|
+
_pending = nil;
|
|
53
|
+
_claimed = NO;
|
|
54
|
+
[_condition broadcast];
|
|
55
|
+
}
|
|
56
|
+
[_condition unlock];
|
|
57
|
+
return @0;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
- (void)invalidate {
|
|
61
|
+
[_condition lock];
|
|
62
|
+
_closed = YES;
|
|
63
|
+
_pending = nil;
|
|
64
|
+
[_condition broadcast];
|
|
65
|
+
[_condition unlock];
|
|
66
|
+
}
|
|
67
|
+
@end
|
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
@class TiCloudStorageAudioOutput;
|
|
11
11
|
@class TiCloudStorageReplay;
|
|
12
12
|
@class TiCloudStorageVideoOutput;
|
|
13
|
+
@class TiCloudStorageRecordingGap;
|
|
14
|
+
@class TiCloudStorageExportProgress;
|
|
13
15
|
|
|
14
16
|
@interface TiRtcReactNativeEventBinder : NSObject
|
|
15
17
|
|
|
@@ -23,5 +25,7 @@
|
|
|
23
25
|
- (id)wireCloudStorageReplay:(TiCloudStorageReplay*)replay objectId:(NSInteger)objectId;
|
|
24
26
|
- (id)wireCloudStorageAudioOutput:(TiCloudStorageAudioOutput*)output objectId:(NSInteger)objectId;
|
|
25
27
|
- (id)wireCloudStorageVideoOutput:(TiCloudStorageVideoOutput*)output objectId:(NSInteger)objectId;
|
|
28
|
+
- (void)cloudStorageExportProgress:(TiCloudStorageExportProgress*)progress objectId:(NSInteger)objectId;
|
|
29
|
+
- (void)cloudStorageExportRecordingGap:(TiCloudStorageRecordingGap*)gap objectId:(NSInteger)objectId;
|
|
26
30
|
|
|
27
31
|
@end
|
|
@@ -308,9 +308,20 @@
|
|
|
308
308
|
replay.onTimeChanged = ^(int64_t timeMs) { [sink tiCloudStorageReplayTimeChanged:objectId timestampMs:timeMs]; };
|
|
309
309
|
replay.onCompleted = ^{ [sink tiCloudStorageReplayCompleted:objectId]; };
|
|
310
310
|
replay.onError = ^(int32_t code) { [sink tiCloudStorageReplayError:objectId code:code]; };
|
|
311
|
+
replay.onRecordingGap = ^(TiCloudStorageRecordingGap* gap) {
|
|
312
|
+
[sink tiCloudStorageReplayRecordingGap:objectId gap:gap];
|
|
313
|
+
};
|
|
311
314
|
return nil;
|
|
312
315
|
}
|
|
313
316
|
|
|
317
|
+
- (void)cloudStorageExportProgress:(TiCloudStorageExportProgress*)progress objectId:(NSInteger)objectId {
|
|
318
|
+
[_eventSink tiCloudStorageExportProgress:objectId progress:progress];
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
- (void)cloudStorageExportRecordingGap:(TiCloudStorageRecordingGap*)gap objectId:(NSInteger)objectId {
|
|
322
|
+
[_eventSink tiCloudStorageExportRecordingGap:objectId gap:gap];
|
|
323
|
+
}
|
|
324
|
+
|
|
314
325
|
- (id)wireCloudStorageAudioOutput:(TiCloudStorageAudioOutput*)output objectId:(NSInteger)objectId {
|
|
315
326
|
TiRtcReactNativeCloudStorageAudioOutputDelegate* delegate =
|
|
316
327
|
[[TiRtcReactNativeCloudStorageAudioOutputDelegate alloc] initWithObjectId:objectId eventSink:_eventSink];
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
typedef void (^TiRtcReactNativeEmitBlock)(NSDictionary* event);
|
|
5
5
|
|
|
6
6
|
@class TiRtcReactNativeRegistry;
|
|
7
|
+
@class TiCloudStorageRecordingGap;
|
|
8
|
+
@class TiCloudStorageExportProgress;
|
|
7
9
|
|
|
8
10
|
@interface TiRtcReactNativeEventSink : NSObject
|
|
9
11
|
|
|
@@ -18,6 +20,9 @@ typedef void (^TiRtcReactNativeEmitBlock)(NSDictionary* event);
|
|
|
18
20
|
- (void)tiCloudStorageReplayTimeChanged:(NSInteger)objectId timestampMs:(int64_t)timestampMs;
|
|
19
21
|
- (void)tiCloudStorageReplayCompleted:(NSInteger)objectId;
|
|
20
22
|
- (void)tiCloudStorageReplayError:(NSInteger)objectId code:(int32_t)code;
|
|
23
|
+
- (void)tiCloudStorageReplayRecordingGap:(NSInteger)objectId gap:(TiCloudStorageRecordingGap*)gap;
|
|
24
|
+
- (void)tiCloudStorageExportProgress:(NSInteger)objectId progress:(TiCloudStorageExportProgress*)progress;
|
|
25
|
+
- (void)tiCloudStorageExportRecordingGap:(NSInteger)objectId gap:(TiCloudStorageRecordingGap*)gap;
|
|
21
26
|
- (void)audioOutputStateChanged:(NSInteger)objectId state:(NSString*)state;
|
|
22
27
|
- (void)audioOutputError:(NSInteger)objectId code:(int32_t)code message:(NSString*)message;
|
|
23
28
|
- (void)videoOutputStateChanged:(NSInteger)objectId state:(NSString*)state;
|
|
@@ -59,6 +59,24 @@
|
|
|
59
59
|
[self emit:event];
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
- (void)tiCloudStorageReplayRecordingGap:(NSInteger)objectId gap:(TiCloudStorageRecordingGap*)gap {
|
|
63
|
+
NSMutableDictionary* event = [self base:@"tiCloudStorageReplayRecordingGap" objectId:objectId];
|
|
64
|
+
event[@"recordingGap"] = TiRtcReactNativeCloudStorageRecordingGap(gap);
|
|
65
|
+
[self emit:event];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
- (void)tiCloudStorageExportProgress:(NSInteger)objectId progress:(TiCloudStorageExportProgress*)progress {
|
|
69
|
+
NSMutableDictionary* event = [self base:@"tiCloudStorageExportProgress" objectId:objectId];
|
|
70
|
+
event[@"exportProgress"] = TiRtcReactNativeCloudStorageExportProgress(progress);
|
|
71
|
+
[self emit:event];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
- (void)tiCloudStorageExportRecordingGap:(NSInteger)objectId gap:(TiCloudStorageRecordingGap*)gap {
|
|
75
|
+
NSMutableDictionary* event = [self base:@"tiCloudStorageExportRecordingGap" objectId:objectId];
|
|
76
|
+
event[@"recordingGap"] = TiRtcReactNativeCloudStorageRecordingGap(gap);
|
|
77
|
+
[self emit:event];
|
|
78
|
+
}
|
|
79
|
+
|
|
62
80
|
- (void)audioOutputStateChanged:(NSInteger)objectId state:(NSString*)state {
|
|
63
81
|
NSMutableDictionary* event = [self base:@"audioOutputStateChanged" objectId:objectId];
|
|
64
82
|
event[@"state"] = state;
|
|
@@ -6,6 +6,9 @@
|
|
|
6
6
|
@class TiRtcConnMetricsResult;
|
|
7
7
|
@class TiRtcVideoOutputDebugSnapshotResult;
|
|
8
8
|
@class TiRtcVideoOutputMetricsResult;
|
|
9
|
+
@class TiCloudStorageRecordingGap;
|
|
10
|
+
@class TiCloudStorageExportProgress;
|
|
11
|
+
@class TiCloudStorageExportReport;
|
|
9
12
|
|
|
10
13
|
NSDictionary* TiRtcReactNativeCreateResult(NSInteger code, NSInteger objectId, NSInteger generation,
|
|
11
14
|
NSString* message);
|
|
@@ -19,3 +22,6 @@ NSDictionary* TiRtcReactNativeVideoDebugResult(TiRtcVideoOutputDebugSnapshotResu
|
|
|
19
22
|
NSDictionary* TiRtcReactNativeReleasedSnapshotResult(void);
|
|
20
23
|
NSArray<NSNumber*>* TiRtcReactNativeByteArray(NSData* data);
|
|
21
24
|
NSData* TiRtcReactNativeDataFromArray(NSArray* array);
|
|
25
|
+
NSDictionary* TiRtcReactNativeCloudStorageRecordingGap(TiCloudStorageRecordingGap* gap);
|
|
26
|
+
NSDictionary* TiRtcReactNativeCloudStorageExportProgress(TiCloudStorageExportProgress* progress);
|
|
27
|
+
NSDictionary* TiRtcReactNativeCloudStorageExportReport(TiCloudStorageExportReport* report);
|
|
@@ -247,3 +247,50 @@ NSData* TiRtcReactNativeDataFromArray(NSArray* array) {
|
|
|
247
247
|
}
|
|
248
248
|
return data;
|
|
249
249
|
}
|
|
250
|
+
|
|
251
|
+
static NSDictionary* TiRtcReactNativeCloudStorageRange(TiCloudStorageRecordingRange* range) {
|
|
252
|
+
return @{ @"startTimeMs" : @(range.startTimeMs), @"endTimeMs" : @(range.endTimeMs) };
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
NSDictionary* TiRtcReactNativeCloudStorageRecordingGap(TiCloudStorageRecordingGap* gap) {
|
|
256
|
+
NSMutableArray* tracks = [NSMutableArray arrayWithCapacity:gap.tracks.count];
|
|
257
|
+
for (TiCloudStorageRecordingTrack* track in gap.tracks) {
|
|
258
|
+
[tracks addObject:@{ @"kind" : @(track.kind), @"channelId" : @(track.channelId) }];
|
|
259
|
+
}
|
|
260
|
+
NSMutableArray* reasons = [NSMutableArray arrayWithCapacity:gap.reasons.count];
|
|
261
|
+
for (NSNumber* reason in gap.reasons) [reasons addObject:@(reason.integerValue)];
|
|
262
|
+
return @{ @"range" : TiRtcReactNativeCloudStorageRange(gap.range), @"tracks" : tracks, @"reasons" : reasons };
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
NSDictionary* TiRtcReactNativeCloudStorageExportProgress(TiCloudStorageExportProgress* progress) {
|
|
266
|
+
return @{ @"fraction" : @(progress.fraction), @"coveredDurationMs" : @(progress.coveredDurationMs) };
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
NSDictionary* TiRtcReactNativeCloudStorageExportReport(TiCloudStorageExportReport* report) {
|
|
270
|
+
NSMutableArray* segments = [NSMutableArray arrayWithCapacity:report.segments.count];
|
|
271
|
+
for (TiCloudStorageExportSegment* segment in report.segments) {
|
|
272
|
+
[segments addObject:@{
|
|
273
|
+
@"sourceRange" : TiRtcReactNativeCloudStorageRange(segment.sourceRange),
|
|
274
|
+
@"outputStartMs" : @(segment.outputStartMs),
|
|
275
|
+
@"outputEndMs" : @(segment.outputEndMs),
|
|
276
|
+
}];
|
|
277
|
+
}
|
|
278
|
+
NSMutableArray* gaps = [NSMutableArray arrayWithCapacity:report.gaps.count];
|
|
279
|
+
for (TiCloudStorageRecordingGap* gap in report.gaps) {
|
|
280
|
+
[gaps addObject:TiRtcReactNativeCloudStorageRecordingGap(gap)];
|
|
281
|
+
}
|
|
282
|
+
NSMutableArray* unprocessed = [NSMutableArray arrayWithCapacity:report.unprocessedRanges.count];
|
|
283
|
+
for (TiCloudStorageRecordingRange* range in report.unprocessedRanges) {
|
|
284
|
+
[unprocessed addObject:TiRtcReactNativeCloudStorageRange(range)];
|
|
285
|
+
}
|
|
286
|
+
return @{
|
|
287
|
+
@"requestedRange" : TiRtcReactNativeCloudStorageRange(report.requestedRange),
|
|
288
|
+
@"coveredDurationMs" : @(report.coveredDurationMs),
|
|
289
|
+
@"segments" : segments,
|
|
290
|
+
@"gaps" : gaps,
|
|
291
|
+
@"unprocessedRanges" : unprocessed,
|
|
292
|
+
@"complete" : @(report.complete),
|
|
293
|
+
@"termination" : @(report.termination),
|
|
294
|
+
@"cause" : @(TiRtcReactNativeNormalizeDarwin(report.cause)),
|
|
295
|
+
};
|
|
296
|
+
}
|
|
@@ -74,6 +74,7 @@ TiRtcVideoOutputOptions* TiRtcReactNativeVideoOutputOptions(
|
|
|
74
74
|
TiRtcAudioInputOptions* TiRtcReactNativeAudioInputOptions(
|
|
75
75
|
JS::NativeTiRtc::NativeAudioInputOptions& options) {
|
|
76
76
|
TiRtcAudioInputOptions* nativeOptions = [TiRtcAudioInputOptions new];
|
|
77
|
+
nativeOptions.media = (NSInteger)options.media();
|
|
77
78
|
NSString* codec = options.codec();
|
|
78
79
|
if ([codec isEqualToString:@"aac"]) {
|
|
79
80
|
nativeOptions.codec = TiRtcAudioCodecAac;
|
|
@@ -99,12 +100,7 @@ TiRtcAudioInputOptions* TiRtcReactNativeAudioInputOptions(
|
|
|
99
100
|
TiRtcVideoInputOptions* TiRtcReactNativeVideoInputOptions(
|
|
100
101
|
JS::NativeTiRtc::NativeVideoInputOptions& options) {
|
|
101
102
|
TiRtcVideoInputOptions* nativeOptions = [TiRtcVideoInputOptions new];
|
|
102
|
-
|
|
103
|
-
if ([codec isEqualToString:@"mjpeg"]) {
|
|
104
|
-
nativeOptions.codec = TiRtcVideoEncoderCodecMjpeg;
|
|
105
|
-
} else {
|
|
106
|
-
nativeOptions.codec = TiRtcVideoEncoderCodecH264;
|
|
107
|
-
}
|
|
103
|
+
nativeOptions.media = (NSInteger)options.media();
|
|
108
104
|
nativeOptions.width = (uint32_t)MAX(0, options.width());
|
|
109
105
|
nativeOptions.height = (uint32_t)MAX(0, options.height());
|
|
110
106
|
NSString* frameRate = options.frameRate();
|
|
@@ -11,6 +11,7 @@ export class TiRtcAudioInput {
|
|
|
11
11
|
this.queue = Promise.resolve();
|
|
12
12
|
this.currentState = 'idle';
|
|
13
13
|
this.options = {
|
|
14
|
+
media: -1,
|
|
14
15
|
codec: 'g711a',
|
|
15
16
|
sampleRate: 'rate16k',
|
|
16
17
|
channels: 'mono',
|
|
@@ -43,8 +44,19 @@ export class TiRtcAudioInput {
|
|
|
43
44
|
if (!isPlainObject(options)) {
|
|
44
45
|
return Promise.resolve(TIRTC_ERROR_INVALID_ARGUMENT);
|
|
45
46
|
}
|
|
47
|
+
const media = options.media === undefined ? -1 : options.media;
|
|
48
|
+
const source = media === -1 ? (options.codec === undefined ? 'default' : 'legacy') : 'media';
|
|
49
|
+
const rawLegacy = options.codec === undefined ? 'omitted' :
|
|
50
|
+
['g711a', 'aac', 'pcm', 'opus', 'amr'].includes(options.codec) ? options.codec : 'invalid';
|
|
51
|
+
const legacyCodec = options.codec ?? 'g711a';
|
|
52
|
+
if (!Number.isInteger(media) || ![-1, 1, 2, 3, 4, 5].includes(media) ||
|
|
53
|
+
(media === -1 && !['g711a', 'aac', 'pcm', 'opus', 'amr'].includes(legacyCodec))) {
|
|
54
|
+
logRtcOutcome('audio_input_set_options', TIRTC_ERROR_INVALID_ARGUMENT, ` nano_media=${typeof media === 'number' ? media : typeof media} legacy_codec=${rawLegacy} source=${source}`);
|
|
55
|
+
return Promise.resolve(TIRTC_ERROR_INVALID_ARGUMENT);
|
|
56
|
+
}
|
|
46
57
|
const normalized = {
|
|
47
|
-
|
|
58
|
+
media,
|
|
59
|
+
codec: media === -1 ? legacyCodec : 'g711a',
|
|
48
60
|
sampleRate: options.sampleRate ?? 'rate16k',
|
|
49
61
|
channels: options.channels ?? 'mono',
|
|
50
62
|
aecMode: options.aecMode ?? 'disabled',
|
|
@@ -57,6 +69,7 @@ export class TiRtcAudioInput {
|
|
|
57
69
|
return identity;
|
|
58
70
|
}
|
|
59
71
|
const code = await NativeTiRtc.audioInputSetOptions(identity.objectId, normalized);
|
|
72
|
+
logRtcOutcome('audio_input_set_options', code, ` nano_media=${media} legacy_codec=${rawLegacy} source=${source} sample_rate=${['rate8k', 'rate16k'].includes(normalized.sampleRate) ? normalized.sampleRate : 'invalid'} channels=${normalized.channels === 'mono' ? 'mono' : 'invalid'}`);
|
|
60
73
|
if (code === TIRTC_ERROR_OK) {
|
|
61
74
|
this.options = normalized;
|
|
62
75
|
}
|
|
@@ -80,13 +93,19 @@ export class TiRtcAudioInput {
|
|
|
80
93
|
}));
|
|
81
94
|
}
|
|
82
95
|
start() {
|
|
83
|
-
return this.
|
|
96
|
+
return this.enqueue(async () => {
|
|
84
97
|
const identity = this.ensureIdentity();
|
|
85
98
|
if (typeof identity === 'number') {
|
|
99
|
+
logRtcOutcome('audio_input_start', identity);
|
|
86
100
|
return identity;
|
|
87
101
|
}
|
|
88
|
-
|
|
89
|
-
|
|
102
|
+
const wasRunning = this.state === 'running';
|
|
103
|
+
const code = await NativeTiRtc.audioInputStart(identity.objectId);
|
|
104
|
+
if (code !== TIRTC_ERROR_OK || !wasRunning) {
|
|
105
|
+
logRtcOutcome('audio_input_start', code, ` object_id=${identity.objectId} nano_media=${this.options.media} legacy_codec=${this.options.codec} sample_rate=${this.options.sampleRate} channels=${this.options.channels}`);
|
|
106
|
+
}
|
|
107
|
+
return code;
|
|
108
|
+
});
|
|
90
109
|
}
|
|
91
110
|
stop() {
|
|
92
111
|
return this.logged('audio_input_stop', this.enqueue(async () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audio_input.js","sourceRoot":"","sources":["../../src/audio_input.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,OAAO,EACP,qBAAqB,EACrB,8BAA8B,EAC9B,4BAA4B,EAC5B,cAAc,EACd,2BAA2B,GAC5B,MAAM,UAAU,CAAC;AAClB,OAAO,EAAC,0BAA0B,EAAE,4BAA4B,EAAC,MAAM,UAAU,CAAC;AAClF,OAAO,EAAC,mBAAmB,EAAE,kBAAkB,EAAE,iBAAiB,EAAsB,MAAM,oBAAoB,CAAC;AACnH,OAAO,EAAC,WAAW,EAAwB,MAAM,UAAU,CAAC;AAC5D,OAAO,EAAC,aAAa,EAAE,WAAW,EAAC,MAAM,oBAAoB,CAAC;AAI9D,MAAM,OAAO,eAAe;
|
|
1
|
+
{"version":3,"file":"audio_input.js","sourceRoot":"","sources":["../../src/audio_input.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,OAAO,EACP,qBAAqB,EACrB,8BAA8B,EAC9B,4BAA4B,EAC5B,cAAc,EACd,2BAA2B,GAC5B,MAAM,UAAU,CAAC;AAClB,OAAO,EAAC,0BAA0B,EAAE,4BAA4B,EAAC,MAAM,UAAU,CAAC;AAClF,OAAO,EAAC,mBAAmB,EAAE,kBAAkB,EAAE,iBAAiB,EAAsB,MAAM,oBAAoB,CAAC;AACnH,OAAO,EAAC,WAAW,EAAwB,MAAM,UAAU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AAC,OAAO,CAAC,CAAC;IACzE,CAAC;IAEO,cAAc;QACpB,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;IACtB,CAAC;IAEO,WAAW,CAAC,KAAuB;QACzC,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,OAAO;QACT,CAAC;QACD,IAAI,KAAK,CAAC,IAAI,KAAK,wBAAwB,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;YACzE,MAAM,SAAS,GAAG,KAAK,CAAC,KAAwB,CAAC;YACjD,IAAI,IAAI,CAAC,YAAY,KAAK,SAAS;gBAAE,WAAW,CAAC,mBAAmB,EAAE,SAAS,CAAC,CAAC;YACjF,IAAI,CAAC,YAAY,GAAG,SAAS,CAAC;YAC9B,IAAI,CAAC,cAAc,EAAE,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC3C,CAAC;aAAM,IAAI,KAAK,CAAC,IAAI,KAAK,iBAAiB,EAAE,CAAC;YAC5C,MAAM,IAAI,GAAG,KAAK,CAAC,IAAI,IAAI,4BAA4B,CAAC;YACxD,aAAa,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;YACnC,IAAI,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,OAAO,IAAI,IAAI,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export const buildIdentity = {"releaseVersion":"2.5.
|
|
1
|
+
export const buildIdentity = {"releaseVersion":"2.5.2","buildTimeUtc":"2026-09-23T16:27:57Z","sourceRevision":"e24c1834b8d2ce7ca2a77561a1511d3208750c72","sourceDirty":0};
|
package/lib/module/conn.js
CHANGED
|
@@ -5,6 +5,7 @@ import { NativeTiRtc } from './native';
|
|
|
5
5
|
import { logRtcOutcome, logRtcState } from './logging_internal';
|
|
6
6
|
import { toNativeBytes } from './errors';
|
|
7
7
|
import { recordingFailure, startRecording, validateStartRecordingOptions, } from './recording';
|
|
8
|
+
import { createRawDumpFromNative, normalizeRawDumpIds, } from './raw_dump';
|
|
8
9
|
export class TiRtcConn {
|
|
9
10
|
constructor() {
|
|
10
11
|
this.identity = null;
|
|
@@ -32,6 +33,24 @@ export class TiRtcConn {
|
|
|
32
33
|
const identity = this.ensureIdentity();
|
|
33
34
|
return typeof identity === 'number' ? recordingFailure(identity) : startRecording(identity.objectId, options);
|
|
34
35
|
}
|
|
36
|
+
async startRawDump(options) {
|
|
37
|
+
if (options === null || typeof options !== 'object')
|
|
38
|
+
return recordingFailure(TIRTC_ERROR_INVALID_ARGUMENT);
|
|
39
|
+
const audio = normalizeRawDumpIds(options.audioStreamIds ?? [], 15);
|
|
40
|
+
const video = normalizeRawDumpIds(options.videoStreamIds ?? [], 15);
|
|
41
|
+
const uplinkAudio = normalizeRawDumpIds(options.uplinkAudioStreamIds ?? [], 15);
|
|
42
|
+
if (audio === null || video === null || uplinkAudio === null ||
|
|
43
|
+
(audio.length === 0 && video.length === 0 && uplinkAudio.length === 0)) {
|
|
44
|
+
return recordingFailure(TIRTC_ERROR_INVALID_ARGUMENT);
|
|
45
|
+
}
|
|
46
|
+
const identity = this.ensureIdentity();
|
|
47
|
+
if (typeof identity === 'number')
|
|
48
|
+
return recordingFailure(identity);
|
|
49
|
+
const result = await NativeTiRtc.connStartRawDump(identity.objectId, audio, video, uplinkAudio);
|
|
50
|
+
return result.code === 0 && result.dumpId !== null
|
|
51
|
+
? { success: true, code: null, message: null, data: createRawDumpFromNative(result.dumpId) }
|
|
52
|
+
: recordingFailure(result.code);
|
|
53
|
+
}
|
|
35
54
|
get state() {
|
|
36
55
|
if (this.identity !== null && !this.disposed) {
|
|
37
56
|
const result = NativeTiRtc.connGetState(this.identity.objectId);
|