Explorar el Código

feat. upgrade to 2.9.0 native sdk android & ios. stage 1

matrixbirds hace 5 años
padre
commit
b425b57dc4

+ 1
- 1
android/build.gradle Ver fichero

@@ -61,7 +61,7 @@ dependencies {
61 61
     def androidSupportVersion = rootProject.hasProperty("androidSupportVersion")  ? rootProject.androidSupportVersion : DEFAULT_ANDROID_SUPPORT_VERSION
62 62
     // from internet
63 63
     implementation "com.android.support:appcompat-v7:$androidSupportVersion"
64
-    implementation "io.agora.rtc:full-sdk:2.8.2"
64
+    implementation "io.agora.rtc:full-sdk:2.9.0"
65 65
     // from node_modules
66 66
     implementation "com.facebook.react:react-native:+"
67 67
 }

+ 5
- 6
android/src/main/java/com/syan/agora/AgoraConst.java Ver fichero

@@ -25,12 +25,8 @@ public class AgoraConst {
25 25
     public final static String AGFirstLocalAudioFrame = "firstLocalAudioFrame";
26 26
     public final static String AGFirstRemoteAudioFrame = "firstRemoteAudioFrame";
27 27
     public final static String AGFirstLocalVideoFrame = "firstLocalVideoFrame";
28
-    public final static String AGFirstRemoteVideoDecoded = "firstRemoteVideoDecoded";
29 28
     public final static String AGFirstRemoteVideoFrame = "firstRemoteVideoFrame";
30 29
     public final static String AGUserMuteAudio = "userMuteAudio";
31
-    public final static String AGUserMuteVideo = "userMuteVideo";
32
-    public final static String AGUserEnableVideo = "userEnableVideo";
33
-    public final static String AGUserEnableLocalVideo = "userEnableLocalVideo";
34 30
     public final static String AGVideoSizeChanged = "videoSizeChanged";
35 31
     public final static String AGRtmpStreamingStateChanged = "rtmpStreamingStateChanged";
36 32
     public final static String AGNetworkTypeChanged = "networkTypeChanged";
@@ -44,6 +40,11 @@ public class AgoraConst {
44 40
     public final static String AGAudioRouteChanged = "audioRouteChanged";
45 41
     public final static String AGCameraFocusAreaChanged = "cameraFocusAreaChanged";
46 42
     public final static String AGCameraExposureAreaChanged = "cameraExposureAreaChanged";
43
+    public final static String AGRemoteAudioStateChanged = "remoteAudioStateChanged";
44
+    public final static String AGLocalAudioStateChanged = "localAudioStateChanged";
45
+    public final static String AGLocalAudioStats = "localAudioStats";
46
+    public final static String AGMediaRelayStateChanged = "mediaRelayStateChanged";
47
+    public final static String AGReceivedChannelMediaRelay = "receivedChannelMediaRelay";
47 48
 
48 49
     public final static String AGRtcStats = "rtcStats";
49 50
     public final static String AGLastmileQuality = "lastmileQuality";
@@ -51,8 +52,6 @@ public class AgoraConst {
51 52
     public final static String AGLocalVideoStats = "localVideoStats";
52 53
     public final static String AGRemoteVideoStats = "remoteVideoStats";
53 54
     public final static String AGRemoteAudioStats = "remoteAudioStats";
54
-    public final static String AGAudioTransportStatsOfUid = "audioTransportStatsOfUid";
55
-    public final static String AGVideoTransportStatsOfUid = "videoTransportStatsOfUid";
56 55
 
57 56
     public final static String AGRemoteAudioMixingStart = "remoteAudioMixingStart";
58 57
     public final static String AGRemoteAudioMixingFinish = "remoteAudioMixingFinish";

+ 201
- 99
android/src/main/java/com/syan/agora/AgoraModule.java Ver fichero

@@ -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();

+ 0
- 1
android/src/main/java/com/syan/agora/AgoraVideoView.java Ver fichero

@@ -50,7 +50,6 @@ public class AgoraVideoView extends LinearLayout {
50 50
     private Integer renderMode = 1;
51 51
     private Integer remoteUid;
52 52
     private boolean zOrderMediaOverlay;
53
-    private SurfaceView surfaceView;
54 53
 
55 54
     public AgoraVideoView(Context context) {
56 55
         super(context);

+ 3
- 0
ios/RCTAgora/AgoraConst.h Ver fichero

@@ -68,6 +68,9 @@ static NSString *AGStreamInjectedStatus = @"streamInjectedStatus";
68 68
 static NSString *AGReceiveStreamMessage = @"receiveStreamMessage";
69 69
 static NSString *AGOccurStreamMessageError = @"occurStreamMessageError";
70 70
 
71
+static NSString *AGReceivedChannelMediaRelay = @"receivedChannelMediaRelay";
72
+static NSString *AGMediaRelayStateChanged = @"mediaRelayStateChanged";
73
+
71 74
 static NSString *AGMediaEngineLoaded = @"mediaEngineLoaded";
72 75
 static NSString *AGMediaEngineStartCall = @"mediaEngineStartCall";
73 76
 

+ 3
- 0
ios/RCTAgora/AgoraConst.m Ver fichero

@@ -85,6 +85,9 @@ static AgoraConst *_person;
85 85
                                   AGReceiveStreamMessage,
86 86
                                   AGOccurStreamMessageError,
87 87
                                   
88
+                                  AGReceivedChannelMediaRelay,
89
+                                  AGMediaRelayStateChanged,
90
+                                  
88 91
                                   AGMediaEngineLoaded,
89 92
                                   AGMediaEngineStartCall,
90 93
                                   AGIntervalTest,

+ 87
- 11
ios/RCTAgora/RCTAgora.m Ver fichero

@@ -48,7 +48,7 @@
48 48
   return toSend;
49 49
 }
50 50
 
51
-- (void)receiveMetadata:(NSData *_Nonnull)data fromUser:(NSUInteger)uid atTimestamp:(NSTimeInterval)timestamp {
51
+- (void)receiveMetadata:(NSData *_Nonnull)data fromUser:(NSInteger)uid atTimestamp:(NSTimeInterval)timestamp {
52 52
   NSString *dataStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
53 53
   [self sendEvent:AGMediaMetaDataReceived params:@{
54 54
                                                    @"uid": @(uid),
@@ -313,6 +313,67 @@ RCT_EXPORT_METHOD(switchChannel:(NSDictionary *)options
313 313
   }
314 314
 }
315 315
 
316
+// startChannelMediaRelay
317
+RCT_EXPORT_METHOD(startChannelMediaRelay:(NSDictionary *)options
318
+                  resolve:(RCTPromiseResolveBlock)resolve
319
+                  reject:(RCTPromiseRejectBlock)reject) {
320
+  AgoraChannelMediaRelayConfiguration *config = [[AgoraChannelMediaRelayConfiguration alloc] init];
321
+  
322
+  AgoraChannelMediaRelayInfo *src = [config sourceInfo];
323
+  NSDictionary *srcOption = options[@"src"];
324
+  src.channelName = srcOption[@"channelName"];
325
+  src.uid = [srcOption[@"uid"] integerValue];
326
+  src.token = srcOption[@"token"];
327
+  AgoraChannelMediaRelayInfo *dst = [[AgoraChannelMediaRelayInfo alloc] init];
328
+  NSDictionary *dstOption = options[@"dst"];
329
+  dst.channelName = dstOption[@"channelName"];
330
+  dst.uid = [dstOption[@"uid"] integerValue];
331
+  dst.token = dstOption[@"token"];
332
+  [config setDestinationInfo:dst forChannelName:dstOption[@"channelName"]];
333
+  NSInteger res = [self.rtcEngine startChannelMediaRelay:config];
334
+  if (res == 0) {
335
+    resolve(nil);
336
+  } else {
337
+    reject(@(-1).stringValue, @(res).stringValue, nil);
338
+  }
339
+}
340
+
341
+// updateChannelMediaRelay
342
+RCT_EXPORT_METHOD(updateChannelMediaRelay:(NSDictionary *)options
343
+                  resolve:(RCTPromiseResolveBlock)resolve
344
+                  reject:(RCTPromiseRejectBlock)reject) {
345
+  AgoraChannelMediaRelayConfiguration *config = [[AgoraChannelMediaRelayConfiguration alloc] init];
346
+  
347
+  AgoraChannelMediaRelayInfo *src = [config sourceInfo];
348
+  NSDictionary *srcOption = options[@"src"];
349
+  src.channelName = srcOption[@"channelName"];
350
+  src.uid = [srcOption[@"uid"] integerValue];
351
+  src.token = srcOption[@"token"];
352
+  AgoraChannelMediaRelayInfo *dst = [[AgoraChannelMediaRelayInfo alloc] init];
353
+  NSDictionary *dstOption = options[@"dst"];
354
+  dst.channelName = dstOption[@"channelName"];
355
+  dst.uid = [dstOption[@"uid"] integerValue];
356
+  dst.token = dstOption[@"token"];
357
+  [config setDestinationInfo:dst forChannelName:dstOption[@"channelName"]];
358
+  NSInteger res = [self.rtcEngine updateChannelMediaRelay:config];
359
+  if (res == 0) {
360
+    resolve(nil);
361
+  } else {
362
+    reject(@(-1).stringValue, @(res).stringValue, nil);
363
+  }
364
+}
365
+
366
+// stopChannelMediaRelay
367
+RCT_EXPORT_METHOD(stopChannelMediaRelay:(RCTPromiseResolveBlock)resolve
368
+                  reject:(RCTPromiseRejectBlock)reject) {
369
+  NSInteger res = [self.rtcEngine stopChannelMediaRelay];
370
+  if (res == 0) {
371
+    resolve(nil);
372
+  } else {
373
+    reject(@(-1).stringValue, @(res).stringValue, nil);
374
+  }
375
+}
376
+
316 377
 // register user account
317 378
 RCT_EXPORT_METHOD(registerLocalUserAccount:(NSDictionary *)options
318 379
                   resolve:(RCTPromiseResolveBlock)resolve
@@ -927,7 +988,7 @@ RCT_EXPORT_METHOD(setEffectsVolume
927 988
 
928 989
 // set volume of effect
929 990
 RCT_EXPORT_METHOD(setVolumeOfEffect
930
-                  :(NSInteger) soundId
991
+                  :(int) soundId
931 992
                   volume:(double)volume
932 993
                   resolve:(RCTPromiseResolveBlock)resolve
933 994
                   reject:(RCTPromiseRejectBlock)reject) {
@@ -1717,11 +1778,11 @@ RCT_EXPORT_METHOD(registerMediaMetadataObserver
1717 1778
 #pragma mark - <AgoraRtcEngineDelegate>
1718 1779
 // EVENT CALLBACKS
1719 1780
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didOccurWarning:(AgoraWarningCode)warningCode {
1720
-  [self sendEvent:AGWarning params:@{@"message": @"AgoraWarning", @"code": @(warningCode)}];
1781
+  [self sendEvent:AGWarning params:@{@"message": @"AgoraWarning", @"errorCode": @(warningCode)}];
1721 1782
 }
1722 1783
 
1723 1784
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didOccurError:(AgoraErrorCode)errorCode {
1724
-  [self sendEvent:AGError params:@{@"message": @"AgoraError", @"code": @(errorCode)}];
1785
+  [self sendEvent:AGError params:@{@"message": @"AgoraError", @"errorCode": @(errorCode)}];
1725 1786
 }
1726 1787
 
1727 1788
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didApiCallExecute:(NSInteger)error api:(NSString *_Nonnull)api result:(NSString *_Nonnull)result {
@@ -1729,13 +1790,13 @@ RCT_EXPORT_METHOD(registerMediaMetadataObserver
1729 1790
     [self sendEvent:AGError  params:@{
1730 1791
                                       @"api": api,
1731 1792
                                       @"result": result,
1732
-                                      @"error": @(error)
1793
+                                      @"errorCode": @(error)
1733 1794
                                       }];
1734 1795
   } else {
1735 1796
     [self sendEvent:AGApiCallExecute  params:@{
1736 1797
                                                @"api": api,
1737 1798
                                                @"result": result,
1738
-                                               @"error": @(error)
1799
+                                               @"errorCode": @(error)
1739 1800
                                                }];
1740 1801
   }
1741 1802
 }
@@ -1852,7 +1913,7 @@ RCT_EXPORT_METHOD(registerMediaMetadataObserver
1852 1913
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine localAudioStateChange:(AgoraAudioLocalState)state error:(AgoraAudioLocalError)error {
1853 1914
   [self sendEvent:AGLocalAudioStateChanged params:@{
1854 1915
                                                @"state": @(state),
1855
-                                               @"error": @(error)
1916
+                                               @"errorCode": @(error)
1856 1917
                                                }];
1857 1918
 }
1858 1919
 
@@ -1945,10 +2006,12 @@ RCT_EXPORT_METHOD(registerMediaMetadataObserver
1945 2006
                                               }];
1946 2007
 }
1947 2008
 
1948
-- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine remoteVideoStateChangedOfUid:(NSUInteger)uid state:(AgoraVideoRemoteState)state {
2009
+- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine remoteVideoStateChangedOfUid:(NSUInteger)uid state:(AgoraVideoRemoteState)state reason:(AgoraVideoRemoteStateReason)reason elapsed:(NSInteger)elapsed {
1949 2010
   [self sendEvent:AGRemoteVideoStateChanged params:@{
1950 2011
                                                      @"uid": @(uid),
1951
-                                                     @"state": @(state)
2012
+                                                     @"state": @(state),
2013
+                                                     @"reason": @(reason),
2014
+                                                     @"elapsed": @(elapsed)
1952 2015
                                                      }];
1953 2016
 }
1954 2017
 
@@ -2087,7 +2150,7 @@ RCT_EXPORT_METHOD(registerMediaMetadataObserver
2087 2150
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine streamPublishedWithUrl:(NSString *_Nonnull)url errorCode:(AgoraErrorCode)errorCode {
2088 2151
   [self sendEvent:AGStreamPublished params:@{
2089 2152
                                              @"url": url,
2090
-                                             @"code": @(errorCode)
2153
+                                             @"errorCode": @(errorCode)
2091 2154
                                              }];
2092 2155
 }
2093 2156
 
@@ -2126,6 +2189,19 @@ RCT_EXPORT_METHOD(registerMediaMetadataObserver
2126 2189
                                                   }];
2127 2190
 }
2128 2191
 
2192
+- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine channelMediaRelayStateDidChange:(AgoraChannelMediaRelayState)state error:(AgoraChannelMediaRelayError)error {
2193
+  [self sendEvent:AGMediaRelayStateChanged params:@{
2194
+                                                    @"state": @(state),
2195
+                                                    @"errorCode": @(error),
2196
+                                                   }];
2197
+}
2198
+
2199
+- (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didReceiveChannelMediaRelayEvent:(AgoraChannelMediaRelayEvent)event {
2200
+  [self sendEvent:AGReceivedChannelMediaRelay params:@{
2201
+                                                  @"event": @(event),
2202
+                                                  }];
2203
+}
2204
+
2129 2205
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine receiveStreamMessageFromUid:(NSUInteger)uid streamId:(NSInteger)streamId data:(NSData *_Nonnull)data {
2130 2206
   NSString *_data = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
2131 2207
   [self sendEvent:AGReceiveStreamMessage params:@{
@@ -2138,7 +2214,7 @@ RCT_EXPORT_METHOD(registerMediaMetadataObserver
2138 2214
   [self sendEvent:AGOccurStreamMessageError params:@{
2139 2215
                                                      @"uid": @(uid),
2140 2216
                                                      @"streamId": @(streamId),
2141
-                                                     @"error": @(error),
2217
+                                                     @"errorCode": @(error),
2142 2218
                                                      @"missed": @(missed),
2143 2219
                                                      @"cached": @(cached)
2144 2220
                                                      }];