|
@@ -34,6 +34,8 @@ import io.agora.rtc.models.UserInfo;
|
34
|
34
|
import io.agora.rtc.video.AgoraImage;
|
35
|
35
|
import io.agora.rtc.video.BeautyOptions;
|
36
|
36
|
import io.agora.rtc.video.CameraCapturerConfiguration;
|
|
37
|
+import io.agora.rtc.video.ChannelMediaInfo;
|
|
38
|
+import io.agora.rtc.video.ChannelMediaRelayConfiguration;
|
37
|
39
|
import io.agora.rtc.video.VideoEncoderConfiguration;
|
38
|
40
|
|
39
|
41
|
import static com.facebook.react.bridge.UiThreadUtil.runOnUiThread;
|
|
@@ -276,7 +278,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
|
276
|
278
|
public void run() {
|
277
|
279
|
WritableMap map = Arguments.createMap();
|
278
|
280
|
map.putString("message", "AgoraWarning");
|
279
|
|
- map.putInt("code", code);
|
|
281
|
+ map.putInt("errorCode", code);
|
280
|
282
|
sendEvent(getReactApplicationContext(), AGWarning, map);
|
281
|
283
|
}
|
282
|
284
|
});
|
|
@@ -289,7 +291,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
|
289
|
291
|
public void run() {
|
290
|
292
|
WritableMap map = Arguments.createMap();
|
291
|
293
|
map.putString("message", "AgoraError");
|
292
|
|
- map.putInt("code", code);
|
|
294
|
+ map.putInt("errorCode", code);
|
293
|
295
|
sendEvent(getReactApplicationContext(), AGError, map);
|
294
|
296
|
}
|
295
|
297
|
});
|
|
@@ -301,7 +303,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
|
301
|
303
|
@Override
|
302
|
304
|
public void run() {
|
303
|
305
|
WritableMap map = Arguments.createMap();
|
304
|
|
- map.putInt("error", code);
|
|
306
|
+ map.putInt("errorCode", code);
|
305
|
307
|
map.putString("api", api);
|
306
|
308
|
map.putString("result", result);
|
307
|
309
|
if (code != 0) {
|
|
@@ -350,8 +352,12 @@ public class AgoraModule extends ReactContextBaseJavaModule {
|
350
|
352
|
statsMap.putInt("duration", stats.totalDuration);
|
351
|
353
|
statsMap.putInt("txBytes", stats.txBytes);
|
352
|
354
|
statsMap.putInt("rxBytes", stats.rxBytes);
|
353
|
|
- // statsMap.putInt("txKBitRate", stats.txKBitRate);
|
354
|
|
- // statsMap.putInt("rxKBitRate", stats.rxKBitRate);
|
|
355
|
+ statsMap.putInt("txAudioBytes", stats.txAudioBytes);
|
|
356
|
+ statsMap.putInt("txVideoBytes", stats.txVideoBytes);
|
|
357
|
+ statsMap.putInt("rxAudioBytes", stats.rxAudioBytes);
|
|
358
|
+ statsMap.putInt("rxVideoBytes", stats.rxVideoBytes);
|
|
359
|
+ statsMap.putInt("txKBitRate", stats.txKBitRate);
|
|
360
|
+ statsMap.putInt("rxKBitRate", stats.rxKBitRate);
|
355
|
361
|
statsMap.putInt("txAudioKBitRate", stats.txAudioKBitRate);
|
356
|
362
|
statsMap.putInt("rxAudioKBitRate", stats.rxAudioKBitRate);
|
357
|
363
|
statsMap.putInt("txVideoKBitRate", stats.txVideoKBitRate);
|
|
@@ -574,24 +580,6 @@ public class AgoraModule extends ReactContextBaseJavaModule {
|
574
|
580
|
});
|
575
|
581
|
}
|
576
|
582
|
|
577
|
|
- /**
|
578
|
|
- * onFirstRemoteVideoDecoded
|
579
|
|
- */
|
580
|
|
- @Override
|
581
|
|
- public void onFirstRemoteVideoDecoded(final int uid, final int width, final int height, final int elapsed) {
|
582
|
|
- runOnUiThread(new Runnable() {
|
583
|
|
- @Override
|
584
|
|
- public void run() {
|
585
|
|
- WritableMap map = Arguments.createMap();
|
586
|
|
- map.putInt("uid", uid);
|
587
|
|
- map.putInt("width", width);
|
588
|
|
- map.putInt("height", height);
|
589
|
|
- map.putInt("elapsed", elapsed);
|
590
|
|
- sendEvent(getReactApplicationContext(), AGFirstRemoteVideoDecoded, map);
|
591
|
|
- }
|
592
|
|
- });
|
593
|
|
- }
|
594
|
|
-
|
595
|
583
|
@Override
|
596
|
584
|
public void onFirstRemoteVideoFrame(final int uid, final int width, final int height, final int elapsed) {
|
597
|
585
|
runOnUiThread(new Runnable() {
|
|
@@ -621,81 +609,73 @@ public class AgoraModule extends ReactContextBaseJavaModule {
|
621
|
609
|
}
|
622
|
610
|
|
623
|
611
|
@Override
|
624
|
|
- public void onUserMuteVideo(final int uid, final boolean muted) {
|
|
612
|
+ public void onVideoSizeChanged(final int uid, final int width, final int height, final int rotation) {
|
625
|
613
|
runOnUiThread(new Runnable() {
|
626
|
614
|
@Override
|
627
|
615
|
public void run() {
|
628
|
616
|
WritableMap map = Arguments.createMap();
|
629
|
|
- map.putBoolean("muted", muted);
|
630
|
617
|
map.putInt("uid", uid);
|
631
|
|
- sendEvent(getReactApplicationContext(), AGUserMuteVideo, map);
|
|
618
|
+ map.putInt("width", width);
|
|
619
|
+ map.putInt("height", height);
|
|
620
|
+ map.putInt("rotation", rotation);
|
|
621
|
+ sendEvent(getReactApplicationContext(), AGVideoSizeChanged, map);
|
632
|
622
|
}
|
633
|
623
|
});
|
634
|
624
|
}
|
635
|
625
|
|
636
|
626
|
@Override
|
637
|
|
- public void onUserEnableVideo(final int uid, final boolean enabled) {
|
|
627
|
+ public void onRtmpStreamingStateChanged(final String url, final int state, final int errCode) {
|
638
|
628
|
runOnUiThread(new Runnable() {
|
639
|
629
|
@Override
|
640
|
630
|
public void run() {
|
641
|
631
|
WritableMap map = Arguments.createMap();
|
642
|
|
- map.putBoolean("enabled", enabled);
|
643
|
|
- map.putInt("uid", uid);
|
644
|
|
- sendEvent(getReactApplicationContext(), AGUserEnableVideo, map);
|
|
632
|
+ map.putString("url", url);
|
|
633
|
+ map.putInt("state", state);
|
|
634
|
+ map.putInt("errorCode", errCode);
|
|
635
|
+ sendEvent(getReactApplicationContext(), AGRtmpStreamingStateChanged, map);
|
645
|
636
|
}
|
646
|
637
|
});
|
647
|
638
|
}
|
648
|
639
|
|
649
|
640
|
@Override
|
650
|
|
- public void onUserEnableLocalVideo(final int uid, final boolean enabled) {
|
|
641
|
+ public void onNetworkTypeChanged(final int type) {
|
651
|
642
|
runOnUiThread(new Runnable() {
|
652
|
643
|
@Override
|
653
|
644
|
public void run() {
|
654
|
645
|
WritableMap map = Arguments.createMap();
|
655
|
|
- map.putBoolean("enabled", enabled);
|
656
|
|
- map.putInt("uid", uid);
|
657
|
|
- sendEvent(getReactApplicationContext(), AGUserEnableLocalVideo, map);
|
|
646
|
+ map.putInt("type", type);
|
|
647
|
+ sendEvent(getReactApplicationContext(), AGNetworkTypeChanged, map);
|
658
|
648
|
}
|
659
|
649
|
});
|
660
|
650
|
}
|
661
|
651
|
|
662
|
|
- @Override
|
663
|
|
- public void onVideoSizeChanged(final int uid, final int width, final int height, final int rotation) {
|
664
|
|
- runOnUiThread(new Runnable() {
|
665
|
|
- @Override
|
666
|
|
- public void run() {
|
667
|
|
- WritableMap map = Arguments.createMap();
|
668
|
|
- map.putInt("uid", uid);
|
669
|
|
- map.putInt("width", width);
|
670
|
|
- map.putInt("height", height);
|
671
|
|
- map.putInt("rotation", rotation);
|
672
|
|
- sendEvent(getReactApplicationContext(), AGVideoSizeChanged, map);
|
673
|
|
- }
|
674
|
|
- });
|
675
|
|
- }
|
676
|
652
|
|
677
|
653
|
@Override
|
678
|
|
- public void onRtmpStreamingStateChanged(final String url, final int state, final int errCode) {
|
|
654
|
+ public void onLocalAudioStateChanged(final int state, final int errCode) {
|
679
|
655
|
runOnUiThread(new Runnable() {
|
680
|
656
|
@Override
|
681
|
657
|
public void run() {
|
682
|
658
|
WritableMap map = Arguments.createMap();
|
683
|
|
- map.putString("url", url);
|
684
|
659
|
map.putInt("state", state);
|
685
|
660
|
map.putInt("errorCode", errCode);
|
686
|
|
- sendEvent(getReactApplicationContext(), AGRtmpStreamingStateChanged, map);
|
|
661
|
+ sendEvent(getReactApplicationContext(), AGLocalAudioStateChanged, map);
|
687
|
662
|
}
|
688
|
663
|
});
|
689
|
664
|
}
|
690
|
|
-
|
691
|
665
|
@Override
|
692
|
|
- public void onNetworkTypeChanged(final int type) {
|
|
666
|
+ public void onRemoteAudioStateChanged(final int uid,
|
|
667
|
+ final int state,
|
|
668
|
+ final int reason,
|
|
669
|
+ final int elapsed) {
|
693
|
670
|
runOnUiThread(new Runnable() {
|
694
|
671
|
@Override
|
695
|
672
|
public void run() {
|
696
|
673
|
WritableMap map = Arguments.createMap();
|
697
|
|
- map.putInt("type", type);
|
698
|
|
- sendEvent(getReactApplicationContext(), AGNetworkTypeChanged, map);
|
|
674
|
+ map.putInt("uid", uid);
|
|
675
|
+ map.putInt("state", state);
|
|
676
|
+ map.putInt("uid", reason);
|
|
677
|
+ map.putInt("elapsed", elapsed);
|
|
678
|
+ sendEvent(getReactApplicationContext(), AGRemoteAudioStateChanged, map);
|
699
|
679
|
}
|
700
|
680
|
});
|
701
|
681
|
}
|
|
@@ -714,13 +694,18 @@ public class AgoraModule extends ReactContextBaseJavaModule {
|
714
|
694
|
}
|
715
|
695
|
|
716
|
696
|
@Override
|
717
|
|
- public void onRemoteVideoStateChanged(final int uid, final int state) {
|
|
697
|
+ public void onRemoteVideoStateChanged(final int uid,
|
|
698
|
+ final int state,
|
|
699
|
+ final int reason,
|
|
700
|
+ final int elapsed) {
|
718
|
701
|
runOnUiThread(new Runnable() {
|
719
|
702
|
@Override
|
720
|
703
|
public void run() {
|
721
|
704
|
WritableMap map = Arguments.createMap();
|
722
|
705
|
map.putInt("uid", uid);
|
723
|
706
|
map.putInt("state", state);
|
|
707
|
+ map.putInt("reason", reason);
|
|
708
|
+ map.putInt("elapsed", elapsed);
|
724
|
709
|
sendEvent(getReactApplicationContext(), AGRemoteVideoStateChanged, map);
|
725
|
710
|
}
|
726
|
711
|
});
|
|
@@ -829,7 +814,13 @@ public class AgoraModule extends ReactContextBaseJavaModule {
|
829
|
814
|
statsMap.putInt("duration", stats.totalDuration);
|
830
|
815
|
statsMap.putInt("txBytes", stats.txBytes);
|
831
|
816
|
statsMap.putInt("rxBytes", stats.rxBytes);
|
832
|
|
- statsMap.putInt("txAudioKBitRate", stats.txAudioKBitRate);
|
|
817
|
+ statsMap.putInt("txAudioBytes", stats.txAudioBytes);
|
|
818
|
+ statsMap.putInt("txVideoBytes", stats.txVideoBytes);
|
|
819
|
+ statsMap.putInt("rxAudioBytes", stats.rxAudioBytes);
|
|
820
|
+ statsMap.putInt("rxVideoBytes", stats.rxVideoBytes);
|
|
821
|
+ statsMap.putInt("txKBitRate", stats.txKBitRate);
|
|
822
|
+ statsMap.putInt("rxKBitRate", stats.rxKBitRate);
|
|
823
|
+ statsMap.putInt("rxVideoKBitRate", stats.rxVideoKBitRate);
|
833
|
824
|
statsMap.putInt("rxAudioKBitRate", stats.rxAudioKBitRate);
|
834
|
825
|
statsMap.putInt("txVideoKBitRate", stats.txVideoKBitRate);
|
835
|
826
|
statsMap.putInt("rxVideoKBitRate", stats.rxVideoKBitRate);
|
|
@@ -884,6 +875,14 @@ public class AgoraModule extends ReactContextBaseJavaModule {
|
884
|
875
|
statsMap.putInt("sentFrameRate", stats.sentFrameRate);
|
885
|
876
|
statsMap.putInt("encoderOutputFrameRate", stats.encoderOutputFrameRate);
|
886
|
877
|
statsMap.putInt("rendererOutputFrameRate", stats.rendererOutputFrameRate);
|
|
878
|
+ statsMap.putInt("targetBitrate", stats.targetBitrate);
|
|
879
|
+ statsMap.putInt("targetFrameRate", stats.targetFrameRate);
|
|
880
|
+ statsMap.putInt("qualityAdaptIndication", stats.qualityAdaptIndication);
|
|
881
|
+ statsMap.putInt("encodedBitrate", stats.encodedBitrate);
|
|
882
|
+ statsMap.putInt("encodedFrameWidth", stats.encodedFrameWidth);
|
|
883
|
+ statsMap.putInt("encodedFrameHeight", stats.encodedFrameHeight);
|
|
884
|
+ statsMap.putInt("encodedFrameCount", stats.encodedFrameCount);
|
|
885
|
+ statsMap.putInt("codecType", stats.codecType);
|
887
|
886
|
WritableMap map = Arguments.createMap();
|
888
|
887
|
map.putMap("stats", statsMap);
|
889
|
888
|
sendEvent(getReactApplicationContext(), AGLocalVideoStats, map);
|
|
@@ -901,7 +900,9 @@ public class AgoraModule extends ReactContextBaseJavaModule {
|
901
|
900
|
statsMap.putInt("width", stats.width);
|
902
|
901
|
statsMap.putInt("height", stats.height);
|
903
|
902
|
statsMap.putInt("receivedBitrate", stats.receivedBitrate);
|
|
903
|
+ statsMap.putInt("decoderOutputFrameRate", stats.decoderOutputFrameRate);
|
904
|
904
|
statsMap.putInt("rendererOutputFrameRate", stats.rendererOutputFrameRate);
|
|
905
|
+ statsMap.putInt("packetLossRate", stats.packetLossRate);
|
905
|
906
|
statsMap.putInt("rxStreamType", stats.rxStreamType);
|
906
|
907
|
statsMap.putInt("totalFrozenTime", stats.totalFrozenTime);
|
907
|
908
|
statsMap.putInt("frozenRate", stats.frozenRate);
|
|
@@ -912,46 +913,6 @@ public class AgoraModule extends ReactContextBaseJavaModule {
|
912
|
913
|
});
|
913
|
914
|
}
|
914
|
915
|
|
915
|
|
- @Override
|
916
|
|
- public void onRemoteAudioTransportStats(final int uid,
|
917
|
|
- final int delay,
|
918
|
|
- final int lost,
|
919
|
|
- final int rxKBitRate) {
|
920
|
|
- runOnUiThread(new Runnable() {
|
921
|
|
- @Override
|
922
|
|
- public void run() {
|
923
|
|
- WritableMap statsMap = Arguments.createMap();
|
924
|
|
- statsMap.putInt("uid", uid);
|
925
|
|
- statsMap.putInt("delay", delay);
|
926
|
|
- statsMap.putInt("lost", lost);
|
927
|
|
- statsMap.putInt("rxKBitRate", rxKBitRate);
|
928
|
|
- WritableMap map = Arguments.createMap();
|
929
|
|
- map.putMap("stats", statsMap);
|
930
|
|
- sendEvent(getReactApplicationContext(), AGAudioTransportStatsOfUid, map);
|
931
|
|
- }
|
932
|
|
- });
|
933
|
|
- }
|
934
|
|
-
|
935
|
|
- @Override
|
936
|
|
- public void onRemoteVideoTransportStats(final int uid,
|
937
|
|
- final int delay,
|
938
|
|
- final int lost,
|
939
|
|
- final int rxKBitRate) {
|
940
|
|
- runOnUiThread(new Runnable() {
|
941
|
|
- @Override
|
942
|
|
- public void run() {
|
943
|
|
- WritableMap statsMap = Arguments.createMap();
|
944
|
|
- statsMap.putInt("uid", uid);
|
945
|
|
- statsMap.putInt("delay", delay);
|
946
|
|
- statsMap.putInt("lost", lost);
|
947
|
|
- statsMap.putInt("rxKBitRate", rxKBitRate);
|
948
|
|
- WritableMap map = Arguments.createMap();
|
949
|
|
- map.putMap("stats", statsMap);
|
950
|
|
- sendEvent(getReactApplicationContext(), AGVideoTransportStatsOfUid, map);
|
951
|
|
- }
|
952
|
|
- });
|
953
|
|
- }
|
954
|
|
-
|
955
|
916
|
@Override
|
956
|
917
|
public void onAudioMixingStateChanged(final int state, final int errorCode) {
|
957
|
918
|
runOnUiThread(new Runnable() {
|
|
@@ -984,7 +945,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
|
984
|
945
|
public void run() {
|
985
|
946
|
WritableMap map = Arguments.createMap();
|
986
|
947
|
map.putString("url", url);
|
987
|
|
- map.putInt("code", errorCode);
|
|
948
|
+ map.putInt("errorCode", errorCode);
|
988
|
949
|
sendEvent(getReactApplicationContext(), AGStreamPublished, map);
|
989
|
950
|
}
|
990
|
951
|
});
|
|
@@ -1054,7 +1015,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
|
1054
|
1015
|
WritableMap map = Arguments.createMap();
|
1055
|
1016
|
map.putInt("uid", uid);
|
1056
|
1017
|
map.putInt("streamId", streamId);
|
1057
|
|
- map.putInt("error", error);
|
|
1018
|
+ map.putInt("errorCode", error);
|
1058
|
1019
|
map.putInt("missed", missed);
|
1059
|
1020
|
map.putInt("cached", cached);
|
1060
|
1021
|
sendEvent(getReactApplicationContext(), AGOccurStreamMessageError, map);
|
|
@@ -1112,6 +1073,48 @@ public class AgoraModule extends ReactContextBaseJavaModule {
|
1112
|
1073
|
}
|
1113
|
1074
|
});
|
1114
|
1075
|
}
|
|
1076
|
+
|
|
1077
|
+ @Override
|
|
1078
|
+ public void onChannelMediaRelayEvent(final int code) {
|
|
1079
|
+ super.onChannelMediaRelayEvent(code);
|
|
1080
|
+ runOnUiThread(new Runnable() {
|
|
1081
|
+ @Override
|
|
1082
|
+ public void run() {
|
|
1083
|
+ WritableMap map = Arguments.createMap();
|
|
1084
|
+ map.putInt("errorCode", code);
|
|
1085
|
+ sendEvent(getReactApplicationContext(), AGReceivedChannelMediaRelay, map);
|
|
1086
|
+ }
|
|
1087
|
+ });
|
|
1088
|
+ }
|
|
1089
|
+
|
|
1090
|
+ @Override
|
|
1091
|
+ public void onChannelMediaRelayStateChanged(final int state, final int code) {
|
|
1092
|
+ super.onChannelMediaRelayStateChanged(state, code);
|
|
1093
|
+ runOnUiThread(new Runnable() {
|
|
1094
|
+ @Override
|
|
1095
|
+ public void run() {
|
|
1096
|
+ WritableMap map = Arguments.createMap();
|
|
1097
|
+ map.putInt("state", state);
|
|
1098
|
+ map.putInt("errorCode", code);
|
|
1099
|
+ sendEvent(getReactApplicationContext(), AGMediaRelayStateChanged, map);
|
|
1100
|
+ }
|
|
1101
|
+ });
|
|
1102
|
+ }
|
|
1103
|
+
|
|
1104
|
+ @Override
|
|
1105
|
+ public void onLocalAudioStats(final LocalAudioStats rtcStats) {
|
|
1106
|
+ super.onLocalAudioStats(rtcStats);
|
|
1107
|
+ runOnUiThread(new Runnable() {
|
|
1108
|
+ @Override
|
|
1109
|
+ public void run() {
|
|
1110
|
+ WritableMap map = Arguments.createMap();
|
|
1111
|
+ map.putInt("numChannels", rtcStats.numChannels);
|
|
1112
|
+ map.putInt("sentSampleRate", rtcStats.sentSampleRate);
|
|
1113
|
+ map.putInt("sentBitrate", rtcStats.sentBitrate);
|
|
1114
|
+ sendEvent(getReactApplicationContext(), AGLocalAudioStats, map);
|
|
1115
|
+ }
|
|
1116
|
+ });
|
|
1117
|
+ }
|
1115
|
1118
|
};
|
1116
|
1119
|
|
1117
|
1120
|
@ReactMethod
|
|
@@ -1162,10 +1165,14 @@ public class AgoraModule extends ReactContextBaseJavaModule {
|
1162
|
1165
|
}
|
1163
|
1166
|
}
|
1164
|
1167
|
|
|
1168
|
+ private String channelName = null;
|
|
1169
|
+
|
1165
|
1170
|
@ReactMethod
|
1166
|
1171
|
public void joinChannel(ReadableMap options, Promise promise) {
|
1167
|
1172
|
Integer res = AgoraManager.getInstance().joinChannel(options);
|
1168
|
1173
|
if (res == 0) {
|
|
1174
|
+ String channelName = options.getString("channelName");
|
|
1175
|
+ this.channelName = channelName;
|
1169
|
1176
|
promise.resolve(null);
|
1170
|
1177
|
} else {
|
1171
|
1178
|
promise.reject("-1", res.toString());
|
|
@@ -1188,8 +1195,10 @@ public class AgoraModule extends ReactContextBaseJavaModule {
|
1188
|
1195
|
if (options.hasKey("token")) {
|
1189
|
1196
|
token = options.getString("token");
|
1190
|
1197
|
}
|
|
1198
|
+ String channelName = options.getString("channelName");
|
1191
|
1199
|
Integer res = rtcEngine.joinChannelWithUserAccount(token, options.getString("channelName"), options.getString("userAccount"));
|
1192
|
1200
|
if (res == 0) {
|
|
1201
|
+ this.channelName = channelName;
|
1193
|
1202
|
promise.resolve(null);
|
1194
|
1203
|
} else {
|
1195
|
1204
|
promise.reject("-1", res.toString());
|
|
@@ -1224,6 +1233,24 @@ public class AgoraModule extends ReactContextBaseJavaModule {
|
1224
|
1233
|
}
|
1225
|
1234
|
}
|
1226
|
1235
|
|
|
1236
|
+ @ReactMethod
|
|
1237
|
+ public void switchChannel(ReadableMap options, Promise promise) {
|
|
1238
|
+ String token = null;
|
|
1239
|
+ String channel = null;
|
|
1240
|
+ if (options.hasKey("token")) {
|
|
1241
|
+ token = options.getString("token");
|
|
1242
|
+ }
|
|
1243
|
+ if (options.hasKey("channelName")) {
|
|
1244
|
+ channel = options.getString("channelName");
|
|
1245
|
+ }
|
|
1246
|
+ Integer res = AgoraManager.getInstance().mRtcEngine.switchChannel(token, channel);
|
|
1247
|
+ if (res == 0) {
|
|
1248
|
+ promise.resolve(null);
|
|
1249
|
+ } else {
|
|
1250
|
+ promise.reject("-1", res.toString());
|
|
1251
|
+ }
|
|
1252
|
+ }
|
|
1253
|
+
|
1227
|
1254
|
@ReactMethod
|
1228
|
1255
|
public void leaveChannel(Promise promise) {
|
1229
|
1256
|
Integer res = AgoraManager.getInstance().leaveChannel();
|
|
@@ -1239,6 +1266,81 @@ public class AgoraModule extends ReactContextBaseJavaModule {
|
1239
|
1266
|
RtcEngine.destroy();
|
1240
|
1267
|
}
|
1241
|
1268
|
|
|
1269
|
+
|
|
1270
|
+
|
|
1271
|
+ @ReactMethod
|
|
1272
|
+ public void startChannelMediaRelay(ReadableMap options, Promise promise) {
|
|
1273
|
+ ChannelMediaRelayConfiguration config = new ChannelMediaRelayConfiguration();
|
|
1274
|
+ ReadableMap srcOption = options.getMap("src");
|
|
1275
|
+ ChannelMediaInfo src = config.getSrcChannelMediaInfo();
|
|
1276
|
+ if (srcOption.hasKey("token")) {
|
|
1277
|
+ src.token = srcOption.getString("token");
|
|
1278
|
+ }
|
|
1279
|
+ if (srcOption.hasKey("channelName")) {
|
|
1280
|
+ src.channelName = srcOption.getString("channelName");
|
|
1281
|
+ }
|
|
1282
|
+ ReadableMap dstMediaInfo = options.getMap("dst");
|
|
1283
|
+ String dstChannelName = null;
|
|
1284
|
+ Integer dstUid = 0;
|
|
1285
|
+ String dstToken = null;
|
|
1286
|
+ if (dstMediaInfo.hasKey("token")) {
|
|
1287
|
+ dstToken = options.getString("token");
|
|
1288
|
+ }
|
|
1289
|
+ if (dstMediaInfo.hasKey("channelName")) {
|
|
1290
|
+ dstChannelName = options.getString("channelName");
|
|
1291
|
+ }
|
|
1292
|
+ if (dstMediaInfo.hasKey("uid")) {
|
|
1293
|
+ dstUid = options.getInt("uid");
|
|
1294
|
+ }
|
|
1295
|
+ ChannelMediaInfo dest = new ChannelMediaInfo(dstChannelName, dstToken, dstUid);
|
|
1296
|
+ config.setDestChannelInfo(dest.channelName, dest);
|
|
1297
|
+ Integer res = AgoraManager.getInstance().mRtcEngine.startChannelMediaRelay(config);
|
|
1298
|
+ if (res == 0) {
|
|
1299
|
+ promise.resolve(null);
|
|
1300
|
+ } else {
|
|
1301
|
+ promise.reject("-1", res.toString());
|
|
1302
|
+ }
|
|
1303
|
+ }
|
|
1304
|
+
|
|
1305
|
+ @ReactMethod
|
|
1306
|
+ public void updateChannelMediaRelay(ReadableMap options, Promise promise) {
|
|
1307
|
+ ChannelMediaRelayConfiguration config = new ChannelMediaRelayConfiguration();
|
|
1308
|
+ ReadableMap srcOption = options.getMap("src");
|
|
1309
|
+ ChannelMediaInfo src = config.getSrcChannelMediaInfo();
|
|
1310
|
+ if (srcOption.hasKey("token")) {
|
|
1311
|
+ src.token = srcOption.getString("token");
|
|
1312
|
+ }
|
|
1313
|
+ if (srcOption.hasKey("channelName")) {
|
|
1314
|
+ src.channelName = srcOption.getString("channelName");
|
|
1315
|
+ }
|
|
1316
|
+ ReadableMap dstMediaInfo = options.getMap("dst");
|
|
1317
|
+ String dstChannelName = null;
|
|
1318
|
+ Integer dstUid = 0;
|
|
1319
|
+ String dstToken = null;
|
|
1320
|
+ if (dstMediaInfo.hasKey("token")) {
|
|
1321
|
+ dstToken = options.getString("token");
|
|
1322
|
+ }
|
|
1323
|
+ if (dstMediaInfo.hasKey("channelName")) {
|
|
1324
|
+ dstChannelName = options.getString("channelName");
|
|
1325
|
+ }
|
|
1326
|
+ if (dstMediaInfo.hasKey("uid")) {
|
|
1327
|
+ dstUid = options.getInt("uid");
|
|
1328
|
+ }
|
|
1329
|
+ ChannelMediaInfo dest = new ChannelMediaInfo(dstChannelName, dstToken, dstUid);
|
|
1330
|
+ config.setDestChannelInfo(dest.channelName, dest);
|
|
1331
|
+ Integer res = AgoraManager.getInstance().mRtcEngine.updateChannelMediaRelay(config);
|
|
1332
|
+ if (res == 0) {
|
|
1333
|
+ promise.resolve(null);
|
|
1334
|
+ } else {
|
|
1335
|
+ promise.reject("-1", res.toString());
|
|
1336
|
+ }
|
|
1337
|
+ }
|
|
1338
|
+
|
|
1339
|
+ @ReactMethod
|
|
1340
|
+ public void stopChannelMediaRelay() {
|
|
1341
|
+ AgoraManager.getInstance().mRtcEngine.stopChannelMediaRelay();
|
|
1342
|
+ }
|
|
1343
|
+
|
1242
|
1344
|
@ReactMethod
|
1243
|
1345
|
public void startPreview(Promise promise) {
|
1244
|
1346
|
Integer res = AgoraManager.getInstance().startPreview();
|