tirtc-react-native 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +11 -0
- package/README.md +140 -0
- package/TiRtcReactNative.podspec +35 -0
- package/android/build.gradle +37 -0
- package/android/src/main/AndroidManifest.xml +1 -0
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcModule.kt +482 -0
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcPackage.kt +43 -0
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeErrors.kt +32 -0
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeEventBinder.kt +99 -0
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeEventSink.kt +168 -0
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeMaps.kt +49 -0
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeMetricsMaps.kt +173 -0
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeModuleSupport.kt +91 -0
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeOptions.kt +127 -0
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcReactNativeRegistry.kt +71 -0
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcVideoInputPreviewManager.kt +109 -0
- package/android/src/main/java/com/tange/ai/tirtc/reactnative/TiRtcVideoOutputViewManager.kt +109 -0
- package/ios/TiRtcReactNative+Conn.mm +112 -0
- package/ios/TiRtcReactNative+Input.mm +196 -0
- package/ios/TiRtcReactNative+Output.mm +172 -0
- package/ios/TiRtcReactNative+Private.h +28 -0
- package/ios/TiRtcReactNative.h +6 -0
- package/ios/TiRtcReactNative.mm +189 -0
- package/ios/TiRtcReactNativeErrors.h +18 -0
- package/ios/TiRtcReactNativeErrors.mm +105 -0
- package/ios/TiRtcReactNativeEventBinder.h +19 -0
- package/ios/TiRtcReactNativeEventBinder.mm +226 -0
- package/ios/TiRtcReactNativeEventSink.h +29 -0
- package/ios/TiRtcReactNativeEventSink.mm +125 -0
- package/ios/TiRtcReactNativeMaps.h +21 -0
- package/ios/TiRtcReactNativeMaps.mm +249 -0
- package/ios/TiRtcReactNativeNative.h +8 -0
- package/ios/TiRtcReactNativeOptions.h +11 -0
- package/ios/TiRtcReactNativeOptions.mm +123 -0
- package/ios/TiRtcReactNativeRegistry.h +20 -0
- package/ios/TiRtcReactNativeRegistry.mm +119 -0
- package/ios/TiRtcVideoInputPreview.h +5 -0
- package/ios/TiRtcVideoInputPreview.mm +149 -0
- package/ios/TiRtcVideoOutputView.h +5 -0
- package/ios/TiRtcVideoOutputView.mm +149 -0
- package/lib/module/audio_input.js +177 -0
- package/lib/module/audio_input.js.map +1 -0
- package/lib/module/audio_output.js +168 -0
- package/lib/module/audio_output.js.map +1 -0
- package/lib/module/conn.js +174 -0
- package/lib/module/conn.js.map +1 -0
- package/lib/module/errors.js +63 -0
- package/lib/module/errors.js.map +1 -0
- package/lib/module/events.js +37 -0
- package/lib/module/events.js.map +1 -0
- package/lib/module/index.js +9 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/logging.js +26 -0
- package/lib/module/logging.js.map +1 -0
- package/lib/module/native.js +5 -0
- package/lib/module/native.js.map +1 -0
- package/lib/module/native_object_id.js +47 -0
- package/lib/module/native_object_id.js.map +1 -0
- package/lib/module/runtime.js +27 -0
- package/lib/module/runtime.js.map +1 -0
- package/lib/module/specs/NativeTiRtc.js +3 -0
- package/lib/module/specs/NativeTiRtc.js.map +1 -0
- package/lib/module/specs/TiRtcVideoInputPreviewNativeComponent.js +24 -0
- package/lib/module/specs/TiRtcVideoOutputViewNativeComponent.js +24 -0
- package/lib/module/types.js +93 -0
- package/lib/module/types.js.map +1 -0
- package/lib/module/video_input.js +266 -0
- package/lib/module/video_input.js.map +1 -0
- package/lib/module/video_output.js +224 -0
- package/lib/module/video_output.js.map +1 -0
- package/lib/typescript/audio_input.d.ts +25 -0
- package/lib/typescript/audio_output.d.ts +25 -0
- package/lib/typescript/conn.d.ts +28 -0
- package/lib/typescript/errors.d.ts +19 -0
- package/lib/typescript/events.d.ts +6 -0
- package/lib/typescript/index.d.ts +9 -0
- package/lib/typescript/logging.d.ts +9 -0
- package/lib/typescript/native.d.ts +5 -0
- package/lib/typescript/native_object_id.d.ts +12 -0
- package/lib/typescript/runtime.d.ts +8 -0
- package/lib/typescript/specs/NativeTiRtc.d.ts +223 -0
- package/lib/typescript/specs/TiRtcVideoInputPreviewNativeComponent.d.ts +8 -0
- package/lib/typescript/specs/TiRtcVideoOutputViewNativeComponent.d.ts +8 -0
- package/lib/typescript/types.d.ts +281 -0
- package/lib/typescript/video_input.d.ts +50 -0
- package/lib/typescript/video_output.d.ts +46 -0
- package/package.json +80 -0
- package/react-native.config.js +10 -0
- package/src/audio_input.ts +205 -0
- package/src/audio_output.ts +202 -0
- package/src/conn.ts +222 -0
- package/src/errors.ts +81 -0
- package/src/events.ts +44 -0
- package/src/index.ts +61 -0
- package/src/logging.ts +33 -0
- package/src/native.ts +6 -0
- package/src/native_object_id.ts +63 -0
- package/src/runtime.ts +32 -0
- package/src/specs/NativeTiRtc.ts +256 -0
- package/src/specs/TiRtcVideoInputPreviewNativeComponent.ts +14 -0
- package/src/specs/TiRtcVideoOutputViewNativeComponent.ts +12 -0
- package/src/types.ts +340 -0
- package/src/video_input.ts +314 -0
- package/src/video_output.ts +273 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
#import "TiRtcReactNative+Private.h"
|
|
2
|
+
#import "TiRtcReactNativeErrors.h"
|
|
3
|
+
#import "TiRtcReactNativeMaps.h"
|
|
4
|
+
#import "TiRtcReactNativeOptions.h"
|
|
5
|
+
|
|
6
|
+
#pragma clang diagnostic push
|
|
7
|
+
#pragma clang diagnostic ignored "-Wobjc-protocol-method-implementation"
|
|
8
|
+
@implementation TiRtcReactNative (Output)
|
|
9
|
+
|
|
10
|
+
- (NSDictionary*)createAudioOutput {
|
|
11
|
+
return [self
|
|
12
|
+
registerObject:^id {
|
|
13
|
+
return [TiRtcAudioOutput new];
|
|
14
|
+
}
|
|
15
|
+
wire:^id(NSInteger objectId, id object) {
|
|
16
|
+
return [[self eventBinder] wireAudioOutput:(TiRtcAudioOutput*)object objectId:objectId];
|
|
17
|
+
}];
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
- (NSDictionary*)audioOutputGetState:(double)objectId {
|
|
21
|
+
TiRtcAudioOutput* output = [self audioOutput:objectId];
|
|
22
|
+
if (output == nil) {
|
|
23
|
+
return TiRtcReactNativeStateResult(TiRtcReactNativeErrorObjectReleased, nil);
|
|
24
|
+
}
|
|
25
|
+
return TiRtcReactNativeStateResult(TiRtcReactNativeErrorOK,
|
|
26
|
+
TiRtcReactNativeAudioOutputStateString(output.state));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
- (NSNumber*)audioOutputConfigure:(double)objectId
|
|
30
|
+
options:(JS::NativeTiRtc::NativeAudioOutputOptions&)options {
|
|
31
|
+
TiRtcAudioOutputOptions* nativeOptions = TiRtcReactNativeAudioOutputOptions(options);
|
|
32
|
+
return [self audioOutputCode:[self audioOutput:objectId]
|
|
33
|
+
block:^int32_t(TiRtcAudioOutput* output) {
|
|
34
|
+
return [output configure:nativeOptions];
|
|
35
|
+
}];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
- (NSNumber*)audioOutputSetVolume:(double)objectId volumePercent:(double)volumePercent {
|
|
39
|
+
if (!TiRtcReactNativeIsVolumePercent(volumePercent)) {
|
|
40
|
+
return @(TiRtcReactNativeErrorInvalidArgument);
|
|
41
|
+
}
|
|
42
|
+
return [self audioOutputCode:[self audioOutput:objectId]
|
|
43
|
+
block:^int32_t(TiRtcAudioOutput* output) {
|
|
44
|
+
return [output setVolume:(uint32_t)volumePercent];
|
|
45
|
+
}];
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
- (NSNumber*)audioOutputAttach:(double)objectId connId:(double)connId streamId:(double)streamId {
|
|
49
|
+
TiRtcConn* conn = [self conn:connId];
|
|
50
|
+
if (conn == nil) {
|
|
51
|
+
return @(TiRtcReactNativeErrorObjectReleased);
|
|
52
|
+
}
|
|
53
|
+
return [self audioOutputCode:[self audioOutput:objectId]
|
|
54
|
+
block:^int32_t(TiRtcAudioOutput* output) {
|
|
55
|
+
return [output attachWithConnection:conn
|
|
56
|
+
streamId:TiRtcReactNativeStreamId(streamId)];
|
|
57
|
+
}];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
- (NSNumber*)audioOutputDetach:(double)objectId {
|
|
61
|
+
return [self audioOutputCode:[self audioOutput:objectId]
|
|
62
|
+
block:^int32_t(TiRtcAudioOutput* output) {
|
|
63
|
+
return [output detach];
|
|
64
|
+
}];
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
- (NSDictionary*)audioOutputGetMetricsSnapshot:(double)objectId {
|
|
68
|
+
TiRtcAudioOutput* output = [self audioOutput:objectId];
|
|
69
|
+
return output == nil ? TiRtcReactNativeReleasedSnapshotResult()
|
|
70
|
+
: TiRtcReactNativeAudioMetricsResult([output getMetricsSnapshot]);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
- (NSNumber*)audioOutputResetMetricsSession:(double)objectId {
|
|
74
|
+
return [self audioOutputCode:[self audioOutput:objectId]
|
|
75
|
+
block:^int32_t(TiRtcAudioOutput* output) {
|
|
76
|
+
return [output resetMetricsSession];
|
|
77
|
+
}];
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
- (NSDictionary*)audioOutputGetDebugSnapshot:(double)objectId {
|
|
81
|
+
TiRtcAudioOutput* output = [self audioOutput:objectId];
|
|
82
|
+
return output == nil ? TiRtcReactNativeReleasedSnapshotResult()
|
|
83
|
+
: TiRtcReactNativeAudioDebugResult([output getDebugSnapshot]);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
- (NSNumber*)audioOutputDispose:(double)objectId {
|
|
87
|
+
TiRtcAudioOutput* output = [self audioOutput:objectId];
|
|
88
|
+
[output dispose];
|
|
89
|
+
return [self releaseRegisteredObject:(NSInteger)objectId object:output];
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
- (NSDictionary*)createVideoOutput {
|
|
93
|
+
return [self
|
|
94
|
+
registerObject:^id {
|
|
95
|
+
return [TiRtcVideoOutput new];
|
|
96
|
+
}
|
|
97
|
+
wire:^id(NSInteger objectId, id object) {
|
|
98
|
+
return [[self eventBinder] wireVideoOutput:(TiRtcVideoOutput*)object objectId:objectId];
|
|
99
|
+
}];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
- (NSDictionary*)videoOutputGetState:(double)objectId {
|
|
103
|
+
TiRtcVideoOutput* output = [self videoOutput:objectId];
|
|
104
|
+
if (output == nil) {
|
|
105
|
+
return TiRtcReactNativeStateResult(TiRtcReactNativeErrorObjectReleased, nil);
|
|
106
|
+
}
|
|
107
|
+
return TiRtcReactNativeStateResult(TiRtcReactNativeErrorOK,
|
|
108
|
+
TiRtcReactNativeVideoOutputStateString(output.state));
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
- (NSDictionary*)videoOutputGetRenderSize:(double)objectId {
|
|
112
|
+
TiRtcVideoOutput* output = [self videoOutput:objectId];
|
|
113
|
+
return output == nil
|
|
114
|
+
? TiRtcReactNativeSizeResult(TiRtcReactNativeErrorObjectReleased, CGSizeZero, NO)
|
|
115
|
+
: TiRtcReactNativeSizeResult(TiRtcReactNativeErrorOK, output.renderSize, YES);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
- (NSNumber*)videoOutputSetOptions:(double)objectId
|
|
119
|
+
options:(JS::NativeTiRtc::NativeVideoOutputOptions&)options {
|
|
120
|
+
TiRtcVideoOutputOptions* nativeOptions = TiRtcReactNativeVideoOutputOptions(options);
|
|
121
|
+
return [self videoOutputCode:[self videoOutput:objectId]
|
|
122
|
+
block:^int32_t(TiRtcVideoOutput* output) {
|
|
123
|
+
return [output setOptions:nativeOptions];
|
|
124
|
+
}];
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
- (NSNumber*)videoOutputAttach:(double)objectId connId:(double)connId streamId:(double)streamId {
|
|
128
|
+
TiRtcConn* conn = [self conn:connId];
|
|
129
|
+
if (conn == nil) {
|
|
130
|
+
return @(TiRtcReactNativeErrorObjectReleased);
|
|
131
|
+
}
|
|
132
|
+
return [self videoOutputCode:[self videoOutput:objectId]
|
|
133
|
+
block:^int32_t(TiRtcVideoOutput* output) {
|
|
134
|
+
return [output attachWithConnection:conn
|
|
135
|
+
streamId:TiRtcReactNativeStreamId(streamId)];
|
|
136
|
+
}];
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
- (NSNumber*)videoOutputDetach:(double)objectId {
|
|
140
|
+
return [self videoOutputCode:[self videoOutput:objectId]
|
|
141
|
+
block:^int32_t(TiRtcVideoOutput* output) {
|
|
142
|
+
return [output detach];
|
|
143
|
+
}];
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
- (NSDictionary*)videoOutputGetMetricsSnapshot:(double)objectId {
|
|
147
|
+
TiRtcVideoOutput* output = [self videoOutput:objectId];
|
|
148
|
+
return output == nil ? TiRtcReactNativeReleasedSnapshotResult()
|
|
149
|
+
: TiRtcReactNativeVideoMetricsResult([output getMetricsSnapshot]);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
- (NSNumber*)videoOutputResetMetricsSession:(double)objectId {
|
|
153
|
+
return [self videoOutputCode:[self videoOutput:objectId]
|
|
154
|
+
block:^int32_t(TiRtcVideoOutput* output) {
|
|
155
|
+
return [output resetMetricsSession];
|
|
156
|
+
}];
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
- (NSDictionary*)videoOutputGetDebugSnapshot:(double)objectId {
|
|
160
|
+
TiRtcVideoOutput* output = [self videoOutput:objectId];
|
|
161
|
+
return output == nil ? TiRtcReactNativeReleasedSnapshotResult()
|
|
162
|
+
: TiRtcReactNativeVideoDebugResult([output getDebugSnapshot]);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
- (NSNumber*)videoOutputDispose:(double)objectId {
|
|
166
|
+
TiRtcVideoOutput* output = [self videoOutput:objectId];
|
|
167
|
+
[output dispose];
|
|
168
|
+
return [self releaseRegisteredObject:(NSInteger)objectId object:output];
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
@end
|
|
172
|
+
#pragma clang diagnostic pop
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#import "TiRtcReactNative.h"
|
|
2
|
+
#import "TiRtcReactNativeEventBinder.h"
|
|
3
|
+
#import "TiRtcReactNativeNative.h"
|
|
4
|
+
#import "TiRtcReactNativeRegistry.h"
|
|
5
|
+
|
|
6
|
+
@interface TiRtcReactNative (Private)
|
|
7
|
+
|
|
8
|
+
- (TiRtcReactNativeRegistry*)registry;
|
|
9
|
+
- (TiRtcReactNativeEventBinder*)eventBinder;
|
|
10
|
+
- (NSDictionary*)registerObject:(id (^)(void))factory
|
|
11
|
+
wire:(id (^)(NSInteger objectId, id object))wire;
|
|
12
|
+
- (NSNumber*)releaseRegisteredObject:(NSInteger)objectId object:(id)object;
|
|
13
|
+
- (NSNumber*)connCode:(TiRtcConn*)conn block:(int32_t (^)(TiRtcConn* conn))block;
|
|
14
|
+
- (NSNumber*)audioOutputCode:(TiRtcAudioOutput*)output
|
|
15
|
+
block:(int32_t (^)(TiRtcAudioOutput* output))block;
|
|
16
|
+
- (NSNumber*)videoOutputCode:(TiRtcVideoOutput*)output
|
|
17
|
+
block:(int32_t (^)(TiRtcVideoOutput* output))block;
|
|
18
|
+
- (NSNumber*)audioInputCode:(TiRtcAudioInput*)input
|
|
19
|
+
block:(int32_t (^)(TiRtcAudioInput* input))block;
|
|
20
|
+
- (NSNumber*)videoInputCode:(TiRtcVideoInput*)input
|
|
21
|
+
block:(int32_t (^)(TiRtcVideoInput* input))block;
|
|
22
|
+
- (TiRtcConn*)conn:(double)objectId;
|
|
23
|
+
- (TiRtcAudioOutput*)audioOutput:(double)objectId;
|
|
24
|
+
- (TiRtcVideoOutput*)videoOutput:(double)objectId;
|
|
25
|
+
- (TiRtcAudioInput*)audioInput:(double)objectId;
|
|
26
|
+
- (TiRtcVideoInput*)videoInput:(double)objectId;
|
|
27
|
+
|
|
28
|
+
@end
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
#import "TiRtcReactNative.h"
|
|
2
|
+
|
|
3
|
+
#import <React/RCTBridgeModule.h>
|
|
4
|
+
|
|
5
|
+
#import <memory>
|
|
6
|
+
|
|
7
|
+
#import "TiRtcReactNativeErrors.h"
|
|
8
|
+
#import "TiRtcReactNativeEventBinder.h"
|
|
9
|
+
#import "TiRtcReactNativeEventSink.h"
|
|
10
|
+
#import "TiRtcReactNativeMaps.h"
|
|
11
|
+
#import "TiRtcReactNativeNative.h"
|
|
12
|
+
#import "TiRtcReactNativeOptions.h"
|
|
13
|
+
#import "TiRtcReactNativeRegistry.h"
|
|
14
|
+
|
|
15
|
+
#pragma clang diagnostic push
|
|
16
|
+
#pragma clang diagnostic ignored "-Wprotocol"
|
|
17
|
+
@implementation TiRtcReactNative {
|
|
18
|
+
TiRtcReactNativeRegistry* _registry;
|
|
19
|
+
TiRtcReactNativeEventSink* _eventSink;
|
|
20
|
+
TiRtcReactNativeEventBinder* _eventBinder;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
RCT_EXPORT_MODULE(TiRtc)
|
|
24
|
+
|
|
25
|
+
- (instancetype)init {
|
|
26
|
+
if (self = [super init]) {
|
|
27
|
+
_registry = [TiRtcReactNativeRegistry sharedRegistry];
|
|
28
|
+
__weak TiRtcReactNative* weakSelf = self;
|
|
29
|
+
_eventSink = [[TiRtcReactNativeEventSink alloc] initWithRegistry:_registry
|
|
30
|
+
emitBlock:^(NSDictionary* event) {
|
|
31
|
+
[weakSelf emitOnTiRtcEvent:event];
|
|
32
|
+
}];
|
|
33
|
+
[_registry setEventSink:_eventSink];
|
|
34
|
+
_eventBinder = [[TiRtcReactNativeEventBinder alloc] initWithEventSink:_eventSink];
|
|
35
|
+
}
|
|
36
|
+
return self;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
- (void)initialize:(JS::NativeTiRtc::NativeInitOptions&)options
|
|
40
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
41
|
+
reject:(RCTPromiseRejectBlock)reject {
|
|
42
|
+
TiRtcInitOptions* config = [TiRtcInitOptions new];
|
|
43
|
+
config.appId = options.appId() ?: @"";
|
|
44
|
+
config.endpoint = options.endpoint() ?: @"";
|
|
45
|
+
config.consoleLogEnabled = options.consoleLogEnabled();
|
|
46
|
+
resolve(@(TiRtcReactNativeNormalizeDarwin([TiRtc initialize:config])));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
- (NSNumber*)shutdown {
|
|
50
|
+
if ([_registry hasLiveObjects]) {
|
|
51
|
+
return @(TiRtcReactNativeErrorRuntimeObjectsLive);
|
|
52
|
+
}
|
|
53
|
+
return @(TiRtcReactNativeNormalizeDarwin([TiRtc shutdown]));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
- (NSString*)errorToString:(double)code {
|
|
57
|
+
return [TiRtc errorToString:(int32_t)code];
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
- (void)writeLog:(double)level tag:(NSString*)tag message:(NSString*)message {
|
|
61
|
+
NSInteger nativeLevel = 0;
|
|
62
|
+
switch ((NSInteger)level) {
|
|
63
|
+
case 0:
|
|
64
|
+
nativeLevel = 1;
|
|
65
|
+
break;
|
|
66
|
+
case 1:
|
|
67
|
+
nativeLevel = 2;
|
|
68
|
+
break;
|
|
69
|
+
case 2:
|
|
70
|
+
nativeLevel = 3;
|
|
71
|
+
break;
|
|
72
|
+
case 3:
|
|
73
|
+
nativeLevel = 4;
|
|
74
|
+
break;
|
|
75
|
+
default:
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
[TiRtcLogging logWithLevel:(TiRtcLogLevel)nativeLevel tag:tag message:message];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
- (void)uploadLogs:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject {
|
|
82
|
+
int32_t startCode = [TiRtcLogging uploadWithCompletion:^(TiRtcLogUploadResult* result) {
|
|
83
|
+
resolve(@{
|
|
84
|
+
@"code" : @(TiRtcReactNativeNormalizeDarwin(result.code)),
|
|
85
|
+
@"logId" : result.logId ?: (id)kCFNull,
|
|
86
|
+
});
|
|
87
|
+
}];
|
|
88
|
+
if (startCode != 0) {
|
|
89
|
+
resolve(@{
|
|
90
|
+
@"code" : @(TiRtcReactNativeNormalizeDarwin(startCode)),
|
|
91
|
+
@"logId" : (id)kCFNull,
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
97
|
+
(const facebook::react::ObjCTurboModule::InitParams&)params {
|
|
98
|
+
return std::make_shared<facebook::react::NativeTiRtcSpecJSI>(params);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
- (NSDictionary*)registerObject:(id (^)(void))factory
|
|
102
|
+
wire:(id (^)(NSInteger objectId, id object))wire {
|
|
103
|
+
@try {
|
|
104
|
+
id object = factory();
|
|
105
|
+
NSInteger generation = 0;
|
|
106
|
+
NSInteger objectId = [_registry addObject:object generation:&generation];
|
|
107
|
+
id delegate = wire != nil ? wire(objectId, object) : nil;
|
|
108
|
+
if (delegate != nil) {
|
|
109
|
+
[_registry setDelegate:delegate forObjectId:objectId];
|
|
110
|
+
}
|
|
111
|
+
return TiRtcReactNativeCreateResult(TiRtcReactNativeErrorOK, objectId, generation, nil);
|
|
112
|
+
} @catch (NSException* exception) {
|
|
113
|
+
return TiRtcReactNativeCreateResult(TiRtcReactNativeErrorPlatformInternal, 0, 0,
|
|
114
|
+
exception.reason);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
- (TiRtcReactNativeRegistry*)registry {
|
|
119
|
+
return _registry;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
- (TiRtcReactNativeEventBinder*)eventBinder {
|
|
123
|
+
return _eventBinder;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
- (NSNumber*)releaseRegisteredObject:(NSInteger)objectId object:(id)object {
|
|
127
|
+
if (object == nil) {
|
|
128
|
+
return @(TiRtcReactNativeErrorObjectReleased);
|
|
129
|
+
}
|
|
130
|
+
[_registry releaseObject:objectId];
|
|
131
|
+
return @(TiRtcReactNativeErrorOK);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
- (NSNumber*)connCode:(TiRtcConn*)conn block:(int32_t (^)(TiRtcConn* conn))block {
|
|
135
|
+
return conn == nil ? @(TiRtcReactNativeErrorObjectReleased)
|
|
136
|
+
: @(TiRtcReactNativeNormalizeDarwin(block(conn)));
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
- (NSNumber*)audioOutputCode:(TiRtcAudioOutput*)output
|
|
140
|
+
block:(int32_t (^)(TiRtcAudioOutput* output))block {
|
|
141
|
+
return output == nil ? @(TiRtcReactNativeErrorObjectReleased)
|
|
142
|
+
: @(TiRtcReactNativeNormalizeDarwin(block(output)));
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
- (NSNumber*)videoOutputCode:(TiRtcVideoOutput*)output
|
|
146
|
+
block:(int32_t (^)(TiRtcVideoOutput* output))block {
|
|
147
|
+
return output == nil ? @(TiRtcReactNativeErrorObjectReleased)
|
|
148
|
+
: @(TiRtcReactNativeNormalizeDarwin(block(output)));
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
- (NSNumber*)audioInputCode:(TiRtcAudioInput*)input
|
|
152
|
+
block:(int32_t (^)(TiRtcAudioInput* input))block {
|
|
153
|
+
return input == nil ? @(TiRtcReactNativeErrorObjectReleased)
|
|
154
|
+
: @(TiRtcReactNativeNormalizeDarwin(block(input)));
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
- (NSNumber*)videoInputCode:(TiRtcVideoInput*)input
|
|
158
|
+
block:(int32_t (^)(TiRtcVideoInput* input))block {
|
|
159
|
+
return input == nil ? @(TiRtcReactNativeErrorObjectReleased)
|
|
160
|
+
: @(TiRtcReactNativeNormalizeDarwin(block(input)));
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
- (TiRtcConn*)conn:(double)objectId {
|
|
164
|
+
id object = [_registry objectForId:(NSInteger)objectId];
|
|
165
|
+
return [object isKindOfClass:[TiRtcConn class]] ? (TiRtcConn*)object : nil;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
- (TiRtcAudioOutput*)audioOutput:(double)objectId {
|
|
169
|
+
id object = [_registry objectForId:(NSInteger)objectId];
|
|
170
|
+
return [object isKindOfClass:[TiRtcAudioOutput class]] ? (TiRtcAudioOutput*)object : nil;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
- (TiRtcVideoOutput*)videoOutput:(double)objectId {
|
|
174
|
+
id object = [_registry objectForId:(NSInteger)objectId];
|
|
175
|
+
return [object isKindOfClass:[TiRtcVideoOutput class]] ? (TiRtcVideoOutput*)object : nil;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
- (TiRtcAudioInput*)audioInput:(double)objectId {
|
|
179
|
+
id object = [_registry objectForId:(NSInteger)objectId];
|
|
180
|
+
return [object isKindOfClass:[TiRtcAudioInput class]] ? (TiRtcAudioInput*)object : nil;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
- (TiRtcVideoInput*)videoInput:(double)objectId {
|
|
184
|
+
id object = [_registry objectForId:(NSInteger)objectId];
|
|
185
|
+
return [object isKindOfClass:[TiRtcVideoInput class]] ? (TiRtcVideoInput*)object : nil;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
@end
|
|
189
|
+
#pragma clang diagnostic pop
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
#import <CoreGraphics/CoreGraphics.h>
|
|
2
|
+
#import <Foundation/Foundation.h>
|
|
3
|
+
|
|
4
|
+
extern const NSInteger TiRtcReactNativeErrorOK;
|
|
5
|
+
extern const NSInteger TiRtcReactNativeErrorInvalidArgument;
|
|
6
|
+
extern const NSInteger TiRtcReactNativeErrorObjectReleased;
|
|
7
|
+
extern const NSInteger TiRtcReactNativeErrorPlatformInternal;
|
|
8
|
+
extern const NSInteger TiRtcReactNativeErrorRuntimeObjectsLive;
|
|
9
|
+
|
|
10
|
+
NSInteger TiRtcReactNativeNormalizeDarwin(int32_t code);
|
|
11
|
+
NSString* TiRtcReactNativeConnStateString(NSInteger state);
|
|
12
|
+
NSString* TiRtcReactNativeInputStateString(NSInteger state);
|
|
13
|
+
NSString* TiRtcReactNativeAudioOutputStateString(NSInteger state);
|
|
14
|
+
NSString* TiRtcReactNativeVideoOutputStateString(NSInteger state);
|
|
15
|
+
uint8_t TiRtcReactNativeStreamId(double value);
|
|
16
|
+
uint32_t TiRtcReactNativeUInt32(double value);
|
|
17
|
+
BOOL TiRtcReactNativeIsVolumePercent(double value);
|
|
18
|
+
NSNumber* TiRtcReactNativeNullableNumberFromOptionalDouble(BOOL hasValue, double value);
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
#import "TiRtcReactNativeErrors.h"
|
|
2
|
+
#include <cmath>
|
|
3
|
+
|
|
4
|
+
const NSInteger TiRtcReactNativeErrorOK = 0;
|
|
5
|
+
const NSInteger TiRtcReactNativeErrorInvalidArgument = 6000;
|
|
6
|
+
const NSInteger TiRtcReactNativeErrorObjectReleased = 1008;
|
|
7
|
+
const NSInteger TiRtcReactNativeErrorPlatformInternal = 1001;
|
|
8
|
+
const NSInteger TiRtcReactNativeErrorRuntimeObjectsLive = 1007;
|
|
9
|
+
|
|
10
|
+
NSInteger TiRtcReactNativeNormalizeDarwin(int32_t code) {
|
|
11
|
+
switch (code) {
|
|
12
|
+
case 1002:
|
|
13
|
+
return TiRtcReactNativeErrorInvalidArgument;
|
|
14
|
+
case 1011:
|
|
15
|
+
return 1301;
|
|
16
|
+
case 1012:
|
|
17
|
+
return 1302;
|
|
18
|
+
case 1013:
|
|
19
|
+
return 1303;
|
|
20
|
+
case 1014:
|
|
21
|
+
return 6024;
|
|
22
|
+
default:
|
|
23
|
+
return code;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
NSString* TiRtcReactNativeConnStateString(NSInteger state) {
|
|
28
|
+
switch (state) {
|
|
29
|
+
case 1:
|
|
30
|
+
return @"connecting";
|
|
31
|
+
case 2:
|
|
32
|
+
return @"connected";
|
|
33
|
+
case 3:
|
|
34
|
+
return @"disconnected";
|
|
35
|
+
default:
|
|
36
|
+
return @"idle";
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
NSString* TiRtcReactNativeInputStateString(NSInteger state) {
|
|
41
|
+
switch (state) {
|
|
42
|
+
case 1:
|
|
43
|
+
return @"running";
|
|
44
|
+
case 2:
|
|
45
|
+
return @"stopped";
|
|
46
|
+
case 3:
|
|
47
|
+
return @"failed";
|
|
48
|
+
default:
|
|
49
|
+
return @"idle";
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
NSString* TiRtcReactNativeAudioOutputStateString(NSInteger state) {
|
|
54
|
+
switch (state) {
|
|
55
|
+
case 1:
|
|
56
|
+
return @"buffering";
|
|
57
|
+
case 2:
|
|
58
|
+
return @"playing";
|
|
59
|
+
case 3:
|
|
60
|
+
return @"failed";
|
|
61
|
+
default:
|
|
62
|
+
return @"idle";
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
NSString* TiRtcReactNativeVideoOutputStateString(NSInteger state) {
|
|
67
|
+
switch (state) {
|
|
68
|
+
case 1:
|
|
69
|
+
return @"buffering";
|
|
70
|
+
case 2:
|
|
71
|
+
return @"rendering";
|
|
72
|
+
case 3:
|
|
73
|
+
return @"failed";
|
|
74
|
+
default:
|
|
75
|
+
return @"idle";
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
uint8_t TiRtcReactNativeStreamId(double value) {
|
|
80
|
+
if (value < 0) {
|
|
81
|
+
return 0;
|
|
82
|
+
}
|
|
83
|
+
if (value > UINT8_MAX) {
|
|
84
|
+
return UINT8_MAX;
|
|
85
|
+
}
|
|
86
|
+
return (uint8_t)value;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
uint32_t TiRtcReactNativeUInt32(double value) {
|
|
90
|
+
if (value < 0) {
|
|
91
|
+
return 0;
|
|
92
|
+
}
|
|
93
|
+
if (value > UINT32_MAX) {
|
|
94
|
+
return UINT32_MAX;
|
|
95
|
+
}
|
|
96
|
+
return (uint32_t)value;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
BOOL TiRtcReactNativeIsVolumePercent(double value) {
|
|
100
|
+
return std::isfinite(value) && value >= 0 && value <= 100 && std::trunc(value) == value;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
NSNumber* TiRtcReactNativeNullableNumberFromOptionalDouble(BOOL hasValue, double value) {
|
|
104
|
+
return hasValue ? @(value) : (NSNumber*)nil;
|
|
105
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
|
|
3
|
+
@class TiRtcAudioInput;
|
|
4
|
+
@class TiRtcAudioOutput;
|
|
5
|
+
@class TiRtcConn;
|
|
6
|
+
@class TiRtcReactNativeEventSink;
|
|
7
|
+
@class TiRtcVideoInput;
|
|
8
|
+
@class TiRtcVideoOutput;
|
|
9
|
+
|
|
10
|
+
@interface TiRtcReactNativeEventBinder : NSObject
|
|
11
|
+
|
|
12
|
+
- (instancetype)initWithEventSink:(TiRtcReactNativeEventSink*)eventSink;
|
|
13
|
+
- (id)wireConn:(TiRtcConn*)conn objectId:(NSInteger)objectId;
|
|
14
|
+
- (id)wireAudioOutput:(TiRtcAudioOutput*)output objectId:(NSInteger)objectId;
|
|
15
|
+
- (id)wireVideoOutput:(TiRtcVideoOutput*)output objectId:(NSInteger)objectId;
|
|
16
|
+
- (id)wireAudioInput:(TiRtcAudioInput*)input objectId:(NSInteger)objectId;
|
|
17
|
+
- (id)wireVideoInput:(TiRtcVideoInput*)input objectId:(NSInteger)objectId;
|
|
18
|
+
|
|
19
|
+
@end
|