@byteplus/react-native-rtc 1.1.1 → 1.3.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 +88 -57
- package/android/build.gradle +23 -14
- package/android/proguard-rules.pro +1 -1
- package/android/src/live/java/com/volcengine/reactnative/vertc/live/VertcLive.java +76 -8
- package/android/src/main/java/com/volcengine/reactnative/vertc/NativeVariableManager.java +0 -5
- package/android/src/main/java/com/volcengine/reactnative/vertc/ScreenCaptureHelper.java +13 -18
- package/android/src/main/java/com/volcengine/reactnative/vertc/VertcApiEngineManager.java +5 -5
- package/android/src/main/java/com/volcengine/reactnative/vertc/VertcHelper.java +30 -0
- package/android/src/main/java/com/volcengine/reactnative/vertc/VertcImpl.java +68 -0
- package/android/src/main/java/com/volcengine/reactnative/vertc/events/ClassHelper.java +24 -3
- package/android/src/main/java/com/volcengine/reactnative/vertc/events/IRTCRoomEventHandlerImpl.java +90 -11
- package/android/src/main/java/com/volcengine/reactnative/vertc/events/IRTCVideoEventHandlerImpl.java +65 -4
- package/android/src/newarch/com/volcengine/reactnative/vertc/VertcModule.java +86 -0
- package/android/src/{main/java → oldarch}/com/volcengine/reactnative/vertc/VertcModule.java +11 -17
- package/ios/core/RTCHeader.h +1 -0
- package/ios/core/VertcHelper.h +9 -3
- package/ios/core/VertcHelper.m +72 -1
- package/ios/live/VertcLive.m +164 -12
- package/ios/new_arch_core/RCTVertc.h +23 -0
- package/ios/new_arch_core/RCTVertc.mm +89 -0
- package/ios/new_arch_core/VertcImpl.h +33 -0
- package/ios/new_arch_core/VertcImpl.m +53 -0
- package/ios/new_arch_core/VertcViewManager.m +51 -0
- package/lib/commonjs/index.js +1609 -806
- package/lib/module/index.js +1608 -808
- package/lib/typescript/codegen/android/api.d.ts +152 -8
- package/lib/typescript/codegen/android/callback.d.ts +13 -5
- package/lib/typescript/codegen/android/keytype.d.ts +105 -7
- package/lib/typescript/codegen/ios/api.d.ts +152 -16
- package/lib/typescript/codegen/ios/callback.d.ts +65 -5
- package/lib/typescript/codegen/ios/keytype.d.ts +171 -5
- package/lib/typescript/codegen/pack/api.d.ts +94 -83
- package/lib/typescript/codegen/pack/callback.d.ts +158 -40
- package/lib/typescript/codegen/pack/keytype.d.ts +121 -21
- package/lib/typescript/interface.d.ts +43 -10
- package/lib/typescript/module.d.ts +7 -0
- package/lib/typescript/platforms/android/vertc.d.ts +4 -1
- package/lib/typescript/platforms/ios/vertc.d.ts +2 -1
- package/lib/typescript/platforms/turboModule/NativeVertc.d.ts +26 -0
- package/lib/typescript/platforms/turboModule/index.d.ts +4 -0
- package/lib/typescript/proxy.d.ts +1 -1
- package/lib/typescript/util.d.ts +1 -0
- package/package.json +11 -2
- package/react-native-rtc.podspec +35 -31
- package/src/platforms/turboModule/NativeVertc.ts +33 -0
- package/src/platforms/turboModule/index.ts +1 -0
- /package/android/src/{main/java → oldarch}/com/volcengine/reactnative/vertc/VertcModuleSpec.java +0 -0
- /package/ios/{core → original_arch_core}/VertcModule.h +0 -0
- /package/ios/{core → original_arch_core}/VertcModule.m +0 -0
- /package/ios/{core → original_arch_core}/VertcViewManager.m +0 -0
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
|
|
4
4
|
package com.volcengine.reactnative.vertc.events;
|
|
5
5
|
|
|
6
|
+
import com.ss.bytertc.engine.RTCRoomConfig;
|
|
7
|
+
import com.ss.bytertc.engine.data.AudioPropertiesInfo;
|
|
8
|
+
import com.ss.bytertc.engine.data.PublishState;
|
|
9
|
+
import com.ss.bytertc.engine.data.PublishStateChangeReason;
|
|
10
|
+
import com.ss.bytertc.engine.data.RemoteVideoConfig;
|
|
11
|
+
import com.ss.bytertc.engine.data.SubscribeState;
|
|
12
|
+
import com.ss.bytertc.engine.data.SubscribeStateChangeReason;
|
|
6
13
|
import com.ss.bytertc.engine.handler.IRTCRoomEventHandler;
|
|
7
14
|
import com.ss.bytertc.engine.handler.IRTCVideoEventHandler;
|
|
8
15
|
import com.ss.bytertc.engine.SysStats;
|
|
@@ -30,7 +37,6 @@ import com.ss.bytertc.engine.data.VideoDenoiseModeChangedReason;
|
|
|
30
37
|
import com.ss.bytertc.engine.data.VideoFrameInfo;
|
|
31
38
|
import com.ss.bytertc.engine.data.VideoSuperResolutionMode;
|
|
32
39
|
import com.ss.bytertc.engine.data.VideoSuperResolutionModeChangedReason;
|
|
33
|
-
import com.ss.bytertc.engine.handler.IRTCVideoEventHandler;
|
|
34
40
|
import com.ss.bytertc.engine.type.AudioDeviceType;
|
|
35
41
|
import com.ss.bytertc.engine.type.AudioDumpStatus;
|
|
36
42
|
import com.ss.bytertc.engine.type.AudioRecordingErrorCode;
|
|
@@ -45,6 +51,8 @@ import com.ss.bytertc.engine.type.LocalProxyState;
|
|
|
45
51
|
import com.ss.bytertc.engine.type.LocalProxyType;
|
|
46
52
|
import com.ss.bytertc.engine.type.LocalVideoStreamError;
|
|
47
53
|
import com.ss.bytertc.engine.type.LocalVideoStreamState;
|
|
54
|
+
import com.ss.bytertc.engine.type.MediaDeviceError;
|
|
55
|
+
import com.ss.bytertc.engine.type.MediaDeviceState;
|
|
48
56
|
import com.ss.bytertc.engine.type.NetworkDetectionLinkType;
|
|
49
57
|
import com.ss.bytertc.engine.type.NetworkDetectionStopReason;
|
|
50
58
|
import com.ss.bytertc.engine.type.PerformanceAlarmMode;
|
|
@@ -67,7 +75,6 @@ import com.ss.bytertc.engine.UserInfo;
|
|
|
67
75
|
import com.ss.bytertc.engine.data.AVSyncState;
|
|
68
76
|
import com.ss.bytertc.engine.data.ForwardStreamEventInfo;
|
|
69
77
|
import com.ss.bytertc.engine.data.ForwardStreamStateInfo;
|
|
70
|
-
import com.ss.bytertc.engine.handler.IRTCRoomEventHandler;
|
|
71
78
|
import com.ss.bytertc.engine.type.LocalStreamStats;
|
|
72
79
|
import com.ss.bytertc.engine.type.MediaStreamType;
|
|
73
80
|
import com.ss.bytertc.engine.type.NetworkQualityStats;
|
|
@@ -83,7 +90,11 @@ import com.volcengine.VolcApiEngine.BeanFactory;
|
|
|
83
90
|
import com.volcengine.VolcApiEngine.runtime.Util;
|
|
84
91
|
|
|
85
92
|
public class ClassHelper {
|
|
86
|
-
|
|
93
|
+
private static boolean initialized = false;
|
|
94
|
+
public static synchronized void init() {
|
|
95
|
+
if (initialized) {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
87
98
|
BeanFactory.register(IRTCVideoEventHandler.class, IRTCVideoEventHandlerImpl.class);
|
|
88
99
|
BeanFactory.register(IRTCRoomEventHandler.class, IRTCRoomEventHandlerImpl.class);
|
|
89
100
|
Util.JsonAbleClass.add(SysStats.class);
|
|
@@ -160,5 +171,15 @@ public class ClassHelper {
|
|
|
160
171
|
Util.JsonAbleClass.add(SubtitleMessage.class);
|
|
161
172
|
Util.JsonAbleClass.add(SubtitleState.class);
|
|
162
173
|
Util.JsonAbleClass.add(UserVisibilityChangeError.class);
|
|
174
|
+
Util.JsonAbleClass.add(PublishStateChangeReason.class);
|
|
175
|
+
Util.JsonAbleClass.add(PublishState.class);
|
|
176
|
+
Util.JsonAbleClass.add(SubscribeStateChangeReason.class);
|
|
177
|
+
Util.JsonAbleClass.add(SubscribeState.class);
|
|
178
|
+
Util.JsonAbleClass.add(RemoteVideoConfig.class);
|
|
179
|
+
Util.JsonAbleClass.add(RTCRoomConfig.class);
|
|
180
|
+
Util.JsonAbleClass.add(MediaDeviceState.class);
|
|
181
|
+
Util.JsonAbleClass.add(MediaDeviceError.class);
|
|
182
|
+
Util.JsonAbleClass.add(AudioPropertiesInfo.class);
|
|
183
|
+
initialized = true;
|
|
163
184
|
}
|
|
164
185
|
}
|
package/android/src/main/java/com/volcengine/reactnative/vertc/events/IRTCRoomEventHandlerImpl.java
CHANGED
|
@@ -3,12 +3,18 @@
|
|
|
3
3
|
|
|
4
4
|
package com.volcengine.reactnative.vertc.events;
|
|
5
5
|
|
|
6
|
+
import android.util.Log;
|
|
7
|
+
|
|
6
8
|
import com.ss.bytertc.engine.RTCStream;
|
|
7
9
|
import com.ss.bytertc.engine.SubscribeConfig;
|
|
8
10
|
import com.ss.bytertc.engine.UserInfo;
|
|
9
11
|
import com.ss.bytertc.engine.data.AVSyncState;
|
|
10
12
|
import com.ss.bytertc.engine.data.ForwardStreamEventInfo;
|
|
11
13
|
import com.ss.bytertc.engine.data.ForwardStreamStateInfo;
|
|
14
|
+
import com.ss.bytertc.engine.data.PublishState;
|
|
15
|
+
import com.ss.bytertc.engine.data.PublishStateChangeReason;
|
|
16
|
+
import com.ss.bytertc.engine.data.SubscribeState;
|
|
17
|
+
import com.ss.bytertc.engine.data.SubscribeStateChangeReason;
|
|
12
18
|
import com.ss.bytertc.engine.handler.IRTCRoomEventHandler;
|
|
13
19
|
import com.ss.bytertc.engine.type.LocalStreamStats;
|
|
14
20
|
import com.ss.bytertc.engine.type.MediaStreamType;
|
|
@@ -19,11 +25,17 @@ import com.ss.bytertc.engine.type.SetRoomExtraInfoResult;
|
|
|
19
25
|
import com.ss.bytertc.engine.type.StreamRemoveReason;
|
|
20
26
|
import com.ss.bytertc.engine.type.SubtitleErrorCode;
|
|
21
27
|
import com.ss.bytertc.engine.type.SubtitleMessage;
|
|
28
|
+
import com.ss.bytertc.engine.type.SubtitleMode;
|
|
22
29
|
import com.ss.bytertc.engine.type.SubtitleState;
|
|
23
30
|
import com.ss.bytertc.engine.type.UserVisibilityChangeError;
|
|
24
31
|
import com.volcengine.VolcApiEngine.BeanFactory;
|
|
25
32
|
|
|
33
|
+
import java.lang.reflect.Array;
|
|
26
34
|
import java.nio.ByteBuffer;
|
|
35
|
+
import java.util.ArrayList;
|
|
36
|
+
import java.util.Arrays;
|
|
37
|
+
import java.util.HashMap;
|
|
38
|
+
import java.util.Map;
|
|
27
39
|
|
|
28
40
|
public class IRTCRoomEventHandlerImpl extends IRTCRoomEventHandler implements BeanFactory.EventReceiver {
|
|
29
41
|
public BeanFactory.EventEmitter ee;
|
|
@@ -93,23 +105,64 @@ public class IRTCRoomEventHandlerImpl extends IRTCRoomEventHandler implements Be
|
|
|
93
105
|
}
|
|
94
106
|
|
|
95
107
|
@Override
|
|
96
|
-
public void
|
|
97
|
-
this.ee.sendEvent("
|
|
108
|
+
public void onUserPublishStreamVideo(String roomId, String uid, boolean isPublish) {
|
|
109
|
+
this.ee.sendEvent("onUserPublishStreamVideo", roomId, uid, isPublish);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
@Override
|
|
113
|
+
public void onUserPublishStreamAudio(String roomId, String uid, boolean isPublish) {
|
|
114
|
+
this.ee.sendEvent("onUserPublishStreamAudio", roomId, uid, isPublish);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
@Override
|
|
118
|
+
public void onUserPublishScreenVideo(String roomId, String uid, boolean isPublish) {
|
|
119
|
+
this.ee.sendEvent("onUserPublishScreenVideo", roomId, uid, isPublish);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
@Override
|
|
123
|
+
public void onUserPublishScreenAudio(String roomId, String uid, boolean isPublish) {
|
|
124
|
+
this.ee.sendEvent("onUserPublishScreenAudio", roomId, uid, isPublish);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
@Override
|
|
128
|
+
public void onVideoPublishStateChanged(String roomId, String uid, PublishState state, PublishStateChangeReason reason) {
|
|
129
|
+
this.ee.sendEvent("onVideoPublishStateChanged", roomId, uid, state, reason);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
@Override
|
|
133
|
+
public void onAudioPublishStateChanged(String roomId, String uid, PublishState state, PublishStateChangeReason reason) {
|
|
134
|
+
this.ee.sendEvent("onAudioPublishStateChanged", roomId, uid, state, reason);
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
@Override
|
|
138
|
+
public void onScreenVideoPublishStateChanged(String roomId, String uid, PublishState state, PublishStateChangeReason reason) {
|
|
139
|
+
this.ee.sendEvent("onScreenVideoPublishStateChanged", roomId, uid, state, reason);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
@Override
|
|
143
|
+
public void onScreenAudioPublishStateChanged(String roomId, String uid, PublishState state, PublishStateChangeReason reason) {
|
|
144
|
+
this.ee.sendEvent("onScreenAudioPublishStateChanged", roomId, uid, state, reason);
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
@Override
|
|
149
|
+
public void onVideoSubscribeStateChanged(String roomId, String uid, SubscribeState state, SubscribeStateChangeReason reason) {
|
|
150
|
+
this.ee.sendEvent("onVideoSubscribeStateChanged", roomId, uid, state, reason);
|
|
98
151
|
}
|
|
99
152
|
|
|
100
153
|
@Override
|
|
101
|
-
public void
|
|
102
|
-
this.ee.sendEvent("
|
|
154
|
+
public void onAudioSubscribeStateChanged(String roomId, String uid, SubscribeState state, SubscribeStateChangeReason reason) {
|
|
155
|
+
this.ee.sendEvent("onAudioSubscribeStateChanged", roomId, uid, state, reason);
|
|
103
156
|
}
|
|
104
157
|
|
|
105
158
|
@Override
|
|
106
|
-
public void
|
|
107
|
-
this.ee.sendEvent("
|
|
159
|
+
public void onScreenVideoSubscribeStateChanged(String roomId, String uid, SubscribeState state, SubscribeStateChangeReason reason) {
|
|
160
|
+
this.ee.sendEvent("onScreenVideoSubscribeStateChanged", roomId, uid, state, reason);
|
|
108
161
|
}
|
|
109
162
|
|
|
110
163
|
@Override
|
|
111
|
-
public void
|
|
112
|
-
this.ee.sendEvent("
|
|
164
|
+
public void onScreenAudioSubscribeStateChanged(String roomId, String uid, SubscribeState state, SubscribeStateChangeReason reason) {
|
|
165
|
+
this.ee.sendEvent("onScreenAudioSubscribeStateChanged", roomId, uid, state, reason);
|
|
113
166
|
}
|
|
114
167
|
|
|
115
168
|
@Override
|
|
@@ -184,12 +237,27 @@ public class IRTCRoomEventHandlerImpl extends IRTCRoomEventHandler implements Be
|
|
|
184
237
|
|
|
185
238
|
@Override
|
|
186
239
|
public void onForwardStreamStateChanged(ForwardStreamStateInfo[] stateInfos) {
|
|
187
|
-
|
|
240
|
+
ArrayList<Object> res = new ArrayList<>();
|
|
241
|
+
for (ForwardStreamStateInfo info : stateInfos) {
|
|
242
|
+
Map<String, Object> data = new HashMap<>();
|
|
243
|
+
data.put("roomId", info.roomId);
|
|
244
|
+
data.put("state", info.state);
|
|
245
|
+
data.put("error", info.error);
|
|
246
|
+
res.add(data);
|
|
247
|
+
}
|
|
248
|
+
this.ee.sendEvent("onForwardStreamStateChanged", res);
|
|
188
249
|
}
|
|
189
250
|
|
|
190
251
|
@Override
|
|
191
252
|
public void onForwardStreamEvent(ForwardStreamEventInfo[] eventInfos) {
|
|
192
|
-
|
|
253
|
+
ArrayList<Object> res = new ArrayList<>();
|
|
254
|
+
for (ForwardStreamEventInfo info : eventInfos) {
|
|
255
|
+
Map<String, Object> data = new HashMap<>();
|
|
256
|
+
data.put("roomId", info.roomId);
|
|
257
|
+
data.put("event", info.event);
|
|
258
|
+
res.add(data);
|
|
259
|
+
}
|
|
260
|
+
this.ee.sendEvent("onForwardStreamEvent", res);
|
|
193
261
|
}
|
|
194
262
|
|
|
195
263
|
@Override
|
|
@@ -219,6 +287,17 @@ public class IRTCRoomEventHandlerImpl extends IRTCRoomEventHandler implements Be
|
|
|
219
287
|
|
|
220
288
|
@Override
|
|
221
289
|
public void onSubtitleMessageReceived(SubtitleMessage[] subtitles) {
|
|
222
|
-
|
|
290
|
+
ArrayList<Object> res = new ArrayList<>();
|
|
291
|
+
for (SubtitleMessage subtitle : subtitles) {
|
|
292
|
+
Map<String, Object> data = new HashMap<>();
|
|
293
|
+
data.put("userId", subtitle.userId);
|
|
294
|
+
data.put("mode", subtitle.mode);
|
|
295
|
+
data.put("text", subtitle.text);
|
|
296
|
+
data.put("language", subtitle.language);
|
|
297
|
+
data.put("sequence", subtitle.sequence);
|
|
298
|
+
data.put("definite", subtitle.definite);
|
|
299
|
+
res.add(data);
|
|
300
|
+
}
|
|
301
|
+
this.ee.sendEvent("onSubtitleMessageReceived", res);
|
|
223
302
|
}
|
|
224
303
|
}
|
package/android/src/main/java/com/volcengine/reactnative/vertc/events/IRTCVideoEventHandlerImpl.java
CHANGED
|
@@ -64,6 +64,9 @@ import com.volcengine.VolcApiEngine.BeanFactory;
|
|
|
64
64
|
import org.json.JSONObject;
|
|
65
65
|
|
|
66
66
|
import java.nio.ByteBuffer;
|
|
67
|
+
import java.util.ArrayList;
|
|
68
|
+
import java.util.HashMap;
|
|
69
|
+
import java.util.Map;
|
|
67
70
|
|
|
68
71
|
public class IRTCVideoEventHandlerImpl extends IRTCVideoEventHandler implements BeanFactory.EventReceiver {
|
|
69
72
|
public BeanFactory.EventEmitter ee;
|
|
@@ -274,12 +277,14 @@ public class IRTCVideoEventHandlerImpl extends IRTCVideoEventHandler implements
|
|
|
274
277
|
|
|
275
278
|
@Override
|
|
276
279
|
public void onAudioDeviceStateChanged(String deviceID, AudioDeviceType deviceType, int deviceState, int deviceError) {
|
|
277
|
-
|
|
280
|
+
int deviceTypeInt = deviceType.value();
|
|
281
|
+
this.ee.sendEvent("onAudioDeviceStateChanged", deviceID, deviceTypeInt, deviceState, deviceError);
|
|
278
282
|
}
|
|
279
283
|
|
|
280
284
|
@Override
|
|
281
285
|
public void onVideoDeviceStateChanged(String deviceID, VideoDeviceType deviceType, int deviceState, int deviceError) {
|
|
282
|
-
|
|
286
|
+
int deviceTypeInt = deviceType.value();
|
|
287
|
+
this.ee.sendEvent("onVideoDeviceStateChanged", deviceID, deviceTypeInt, deviceState, deviceError);
|
|
283
288
|
}
|
|
284
289
|
|
|
285
290
|
@Override
|
|
@@ -339,7 +344,33 @@ public class IRTCVideoEventHandlerImpl extends IRTCVideoEventHandler implements
|
|
|
339
344
|
|
|
340
345
|
@Override
|
|
341
346
|
public void onLocalAudioPropertiesReport(LocalAudioPropertiesInfo[] audioPropertiesInfos) {
|
|
342
|
-
|
|
347
|
+
android.os.Handler mainHandler =
|
|
348
|
+
new android.os.Handler(android.os.Looper.getMainLooper());
|
|
349
|
+
mainHandler.post(() -> {
|
|
350
|
+
try {
|
|
351
|
+
ArrayList<Object> res = new ArrayList<>();
|
|
352
|
+
for (LocalAudioPropertiesInfo info : audioPropertiesInfos) {
|
|
353
|
+
Map<String, Object> data = new HashMap<>();
|
|
354
|
+
Map<String, Object> props = new HashMap<>();
|
|
355
|
+
ArrayList<Number> spectrum = new ArrayList<>(info.audioPropertiesInfo.spectrum.length);
|
|
356
|
+
for (int i = 0; i < info.audioPropertiesInfo.spectrum.length; i++) {
|
|
357
|
+
spectrum.add(info.audioPropertiesInfo.spectrum[i]);
|
|
358
|
+
}
|
|
359
|
+
data.put("streamIndex", info.streamIndex);
|
|
360
|
+
props.put("linearVolume", info.audioPropertiesInfo.linearVolume);
|
|
361
|
+
props.put("nonlinearVolume", info.audioPropertiesInfo.nonlinearVolume);
|
|
362
|
+
props.put("spectrum", spectrum);
|
|
363
|
+
props.put("vad", info.audioPropertiesInfo.vad);
|
|
364
|
+
props.put("voicePitch", info.audioPropertiesInfo.voicePitch);
|
|
365
|
+
props.put("deviceLoopDelay", info.audioPropertiesInfo.deviceLoopDelay);
|
|
366
|
+
data.put("audioPropertiesInfo", props);
|
|
367
|
+
res.add(data);
|
|
368
|
+
}
|
|
369
|
+
this.ee.sendEvent("onLocalAudioPropertiesReport", res);
|
|
370
|
+
} catch (Exception e) {
|
|
371
|
+
e.printStackTrace();
|
|
372
|
+
}
|
|
373
|
+
});
|
|
343
374
|
}
|
|
344
375
|
|
|
345
376
|
@Override
|
|
@@ -349,7 +380,37 @@ public class IRTCVideoEventHandlerImpl extends IRTCVideoEventHandler implements
|
|
|
349
380
|
|
|
350
381
|
@Override
|
|
351
382
|
public void onRemoteAudioPropertiesReport(RemoteAudioPropertiesInfo[] audioPropertiesInfos, int totalRemoteVolume) {
|
|
352
|
-
|
|
383
|
+
android.os.Handler mainHandler =
|
|
384
|
+
new android.os.Handler(android.os.Looper.getMainLooper());
|
|
385
|
+
mainHandler.post(() -> {
|
|
386
|
+
try {
|
|
387
|
+
ArrayList<Object> res = new ArrayList<>();
|
|
388
|
+
for (RemoteAudioPropertiesInfo info : audioPropertiesInfos) {
|
|
389
|
+
Map<String, Object> data = new HashMap<>();
|
|
390
|
+
Map<String, Object> streamKey = new HashMap<>();
|
|
391
|
+
Map<String, Object> props = new HashMap<>();
|
|
392
|
+
ArrayList<Number> spectrum = new ArrayList<>(info.audioPropertiesInfo.spectrum.length);
|
|
393
|
+
for (int i = 0; i < info.audioPropertiesInfo.spectrum.length; i++) {
|
|
394
|
+
spectrum.add(info.audioPropertiesInfo.spectrum[i]);
|
|
395
|
+
}
|
|
396
|
+
streamKey.put("roomId", info.streamKey.roomId);
|
|
397
|
+
streamKey.put("userId", info.streamKey.userId);
|
|
398
|
+
streamKey.put("streamIndex", info.streamKey.streamIndex);
|
|
399
|
+
data.put("streamKey", streamKey);
|
|
400
|
+
props.put("linearVolume", info.audioPropertiesInfo.linearVolume);
|
|
401
|
+
props.put("nonlinearVolume", info.audioPropertiesInfo.nonlinearVolume);
|
|
402
|
+
props.put("spectrum", spectrum);
|
|
403
|
+
props.put("vad", info.audioPropertiesInfo.vad);
|
|
404
|
+
props.put("voicePitch", info.audioPropertiesInfo.voicePitch);
|
|
405
|
+
props.put("deviceLoopDelay", info.audioPropertiesInfo.deviceLoopDelay);
|
|
406
|
+
data.put("audioPropertiesInfo", props);
|
|
407
|
+
res.add(data);
|
|
408
|
+
}
|
|
409
|
+
this.ee.sendEvent("onRemoteAudioPropertiesReport", res, totalRemoteVolume);
|
|
410
|
+
} catch (Exception e) {
|
|
411
|
+
e.printStackTrace();
|
|
412
|
+
}
|
|
413
|
+
});
|
|
353
414
|
}
|
|
354
415
|
|
|
355
416
|
@Override
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// Copyright © 2022 BytePlusRTC All rights reserved.
|
|
2
|
+
// SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
package com.volcengine.reactnative.vertc;
|
|
5
|
+
|
|
6
|
+
import android.util.Log;
|
|
7
|
+
|
|
8
|
+
import androidx.annotation.NonNull;
|
|
9
|
+
import androidx.annotation.Nullable;
|
|
10
|
+
|
|
11
|
+
import com.facebook.react.bridge.Arguments;
|
|
12
|
+
import com.facebook.react.bridge.Callback;
|
|
13
|
+
import com.facebook.react.bridge.ReactApplicationContext;
|
|
14
|
+
import com.facebook.react.bridge.ReactContext;
|
|
15
|
+
import com.facebook.react.bridge.WritableMap;
|
|
16
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
|
17
|
+
import com.volcengine.VolcApiEngine.IEventReceiver;
|
|
18
|
+
|
|
19
|
+
public class VertcModule extends NativeVertcSpec implements IEventReceiver {
|
|
20
|
+
|
|
21
|
+
public static final String TAG = "VertcModule";
|
|
22
|
+
private VertcImpl impl;
|
|
23
|
+
// unused yet.
|
|
24
|
+
private int listenerCount = 0;
|
|
25
|
+
public static ReactApplicationContext reactApplicationContext = null;
|
|
26
|
+
|
|
27
|
+
public VertcModule(ReactApplicationContext reactContext) {
|
|
28
|
+
super(reactContext);
|
|
29
|
+
ScreenCaptureHelper.registerReactApplicationContext(reactContext);
|
|
30
|
+
this.impl = new VertcImpl(reactContext, this);
|
|
31
|
+
reactApplicationContext = reactContext;
|
|
32
|
+
VertcApiEngineManager.instance.init(this.impl);
|
|
33
|
+
Log.d(TAG, "VertcModule init");
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@Override
|
|
37
|
+
public boolean newApiEngine() {
|
|
38
|
+
boolean res = this.impl.newApiEngine();
|
|
39
|
+
NativeVariableManager.init(this.impl.apiEngine.msgClient, reactApplicationContext);
|
|
40
|
+
Log.d(TAG, "ApiEngine init");
|
|
41
|
+
return res;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
@Override
|
|
45
|
+
public void OnEvent(String event, String data) {
|
|
46
|
+
final WritableMap map = Arguments.createMap();
|
|
47
|
+
map.putString("event", event);
|
|
48
|
+
map.putString("data", data);
|
|
49
|
+
super.getReactApplicationContext()
|
|
50
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
51
|
+
.emit(VertcImpl.EVENT_NAME, map);
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
private void sendEvent(ReactContext reactContext, String eventName,
|
|
55
|
+
@Nullable WritableMap params) {
|
|
56
|
+
reactContext
|
|
57
|
+
.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class)
|
|
58
|
+
.emit(eventName, params);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
@Override
|
|
62
|
+
public String callSync(String params) {
|
|
63
|
+
return impl.callApiSync(params);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
@Override
|
|
67
|
+
public void call(String params, Callback callback) {
|
|
68
|
+
impl.callApi(params, callback);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
@Override
|
|
72
|
+
public void addListener(String eventType) {
|
|
73
|
+
listenerCount += 1;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
@Override
|
|
77
|
+
public void removeListeners(double count) {
|
|
78
|
+
listenerCount -= (int) count;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
@Override
|
|
82
|
+
@NonNull
|
|
83
|
+
public String getName() {
|
|
84
|
+
return VertcImpl.NAME;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
@@ -20,43 +20,38 @@ import com.ss.bytertc.engine.RTCVideo;
|
|
|
20
20
|
import com.ss.bytertc.engine.engineimpl.RTCVideoImpl;
|
|
21
21
|
import com.volcengine.VolcApiEngine.IEventReceiver;
|
|
22
22
|
import com.volcengine.VolcApiEngine.VolcApiEngine;
|
|
23
|
-
import com.volcengine.reactnative.vertc.events.ClassHelper;
|
|
24
23
|
|
|
25
24
|
@ReactModule(name = VertcModuleSpec.NAME)
|
|
26
25
|
public class VertcModule extends VertcModuleSpec implements IEventReceiver {
|
|
27
26
|
public static ReactApplicationContext reactApplicationContext = null;
|
|
28
27
|
|
|
29
|
-
|
|
28
|
+
private VertcImpl impl;
|
|
30
29
|
|
|
31
30
|
VertcModule(ReactApplicationContext context) {
|
|
32
31
|
super(context);
|
|
33
|
-
VertcApiEngineManager.instance.init(this);
|
|
34
32
|
reactApplicationContext = context;
|
|
33
|
+
ScreenCaptureHelper.registerReactApplicationContext(context);
|
|
34
|
+
this.impl = new VertcImpl(context, this);
|
|
35
|
+
VertcApiEngineManager.instance.init(this.impl);
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
@Override
|
|
38
39
|
public String getName() {
|
|
39
|
-
return
|
|
40
|
+
return VertcImpl.NAME + "Module";
|
|
40
41
|
}
|
|
41
42
|
|
|
42
43
|
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
43
44
|
public boolean newApiEngine() {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
ClassHelper.init();
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return false;
|
|
45
|
+
boolean res = this.impl.newApiEngine();
|
|
46
|
+
NativeVariableManager.init(this.impl.apiEngine.msgClient, context);
|
|
47
|
+
return res;
|
|
52
48
|
}
|
|
53
49
|
|
|
54
50
|
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
55
51
|
public String callApiSync(ReadableMap arg) {
|
|
56
52
|
try {
|
|
57
|
-
newApiEngine();
|
|
58
53
|
String params = arg.getString("params");
|
|
59
|
-
return this.
|
|
54
|
+
return this.impl.callApiSync(params);
|
|
60
55
|
} catch (Exception e) {
|
|
61
56
|
e.printStackTrace();
|
|
62
57
|
throw new RuntimeException(e);
|
|
@@ -66,10 +61,9 @@ public class VertcModule extends VertcModuleSpec implements IEventReceiver {
|
|
|
66
61
|
@ReactMethod(isBlockingSynchronousMethod = false)
|
|
67
62
|
public void callApi(ReadableMap arg, Callback callback) {
|
|
68
63
|
try {
|
|
69
|
-
newApiEngine();
|
|
70
64
|
String params = arg.getString("params");
|
|
71
|
-
this.
|
|
72
|
-
callback.invoke(
|
|
65
|
+
this.impl.callApi(params, args -> {
|
|
66
|
+
callback.invoke(args);
|
|
73
67
|
});
|
|
74
68
|
} catch (Exception e) {
|
|
75
69
|
e.printStackTrace();
|
package/ios/core/RTCHeader.h
CHANGED
package/ios/core/VertcHelper.h
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
#import "RTCHeader.h"
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
NS_ASSUME_NONNULL_BEGIN
|
|
11
11
|
@interface VertcHelper : NSObject
|
|
12
12
|
|
|
13
13
|
+ (instancetype) getInstance;
|
|
@@ -19,5 +19,11 @@
|
|
|
19
19
|
error:(NSInteger)errorCode;
|
|
20
20
|
|
|
21
21
|
- (int) invokeStartPushSingleStreamToCDN:(ByteRTCVideo *)rtc taskId:(NSString *_Nonnull)taskID singleStream:(ByteRTCPushSingleStreamParam *_Nonnull)singleStream;
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
- (void)schedualTimerWithIdentifier:(NSString *)name
|
|
23
|
+
interval:(NSTimeInterval)interval
|
|
24
|
+
queue:(dispatch_queue_t)queue
|
|
25
|
+
repeats:(BOOL)repeats
|
|
26
|
+
action:(dispatch_block_t)action;
|
|
27
|
+
- (void)cancelTimerWithName:(NSString *)name;
|
|
28
|
+
@end
|
|
29
|
+
NS_ASSUME_NONNULL_END
|
package/ios/core/VertcHelper.m
CHANGED
|
@@ -9,7 +9,10 @@
|
|
|
9
9
|
#import "RTCHeader.h"
|
|
10
10
|
#import <VertcHelper.h>
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
@interface VertcHelper ()
|
|
13
|
+
@property (nonatomic, strong) NSMutableDictionary *timerList;
|
|
14
|
+
@property (nonatomic, strong) NSRecursiveLock *lock;
|
|
15
|
+
@end
|
|
13
16
|
#pragma mark - Helper
|
|
14
17
|
@implementation VertcHelper
|
|
15
18
|
|
|
@@ -22,6 +25,14 @@
|
|
|
22
25
|
return instance;
|
|
23
26
|
}
|
|
24
27
|
|
|
28
|
+
- (instancetype)init {
|
|
29
|
+
if (self = [super init]) {
|
|
30
|
+
self.timerList = [NSMutableDictionary dictionary];
|
|
31
|
+
self.lock = [[NSRecursiveLock alloc] init];
|
|
32
|
+
}
|
|
33
|
+
return self;
|
|
34
|
+
}
|
|
35
|
+
|
|
25
36
|
+ (bool)isUnionLiveModeEnable {
|
|
26
37
|
#ifdef ENABLE_UNION_FOR_RTC_WITH_LIVE
|
|
27
38
|
return true;
|
|
@@ -46,4 +57,64 @@
|
|
|
46
57
|
return res;
|
|
47
58
|
}
|
|
48
59
|
|
|
60
|
+
- (int)invokeSetAudioScene:(ByteRTCVideo *)rtc scene:(ByteRTCAudioSceneType)scene {
|
|
61
|
+
int res = [rtc setAudioScene:scene];
|
|
62
|
+
return res;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
- (void)schedualTimerWithIdentifier:(NSString *)name
|
|
66
|
+
interval:(NSTimeInterval)interval
|
|
67
|
+
queue:(dispatch_queue_t)queue
|
|
68
|
+
repeats:(BOOL)repeats
|
|
69
|
+
action:(dispatch_block_t)action {
|
|
70
|
+
if (!name || name.length == 0 || !action) {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
[_lock lock];
|
|
74
|
+
if (!queue) {
|
|
75
|
+
queue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
dispatch_source_t timer = [self.timerList objectForKey:name];
|
|
79
|
+
if (!timer) {
|
|
80
|
+
timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, queue);
|
|
81
|
+
dispatch_resume(timer);
|
|
82
|
+
[self.timerList setValue:timer forKey:name];
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
dispatch_source_set_timer(timer, dispatch_time(DISPATCH_TIME_NOW, interval * NSEC_PER_SEC), interval * NSEC_PER_SEC, 0.01 * NSEC_PER_SEC);
|
|
86
|
+
__weak __typeof(self)weakSelf = self;
|
|
87
|
+
dispatch_source_set_event_handler(timer, ^{
|
|
88
|
+
action();
|
|
89
|
+
__strong __typeof(weakSelf)self = weakSelf;
|
|
90
|
+
if (!repeats) {
|
|
91
|
+
[self cancelTimerWithName:name];
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
[_lock unlock];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
- (void)cancelTimerWithName:(NSString *)name {
|
|
98
|
+
[_lock lock];
|
|
99
|
+
if (name == nil) {
|
|
100
|
+
[_lock unlock];
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
dispatch_source_t timer = [self.timerList objectForKey:name];
|
|
104
|
+
if (timer) {
|
|
105
|
+
[self.timerList removeObjectForKey:name];
|
|
106
|
+
dispatch_source_cancel(timer);
|
|
107
|
+
}
|
|
108
|
+
[_lock unlock];
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
- (void)cancelAllTimers {
|
|
112
|
+
[_lock lock];
|
|
113
|
+
for (dispatch_source_t timer in self.timerList) {
|
|
114
|
+
dispatch_source_cancel(timer);
|
|
115
|
+
}
|
|
116
|
+
[self.timerList removeAllObjects];
|
|
117
|
+
[_lock unlock];
|
|
118
|
+
}
|
|
49
119
|
@end
|
|
120
|
+
|