Explorar el Código

feat. add start & update & stop & remove channelMediaDelay

matrixbirds hace 5 años
padre
commit
32ad158661

+ 1
- 1
CHANGELOG Ver fichero

@@ -16,7 +16,7 @@
16 16
     * `mediaRelayStateChanged`, `receivedChannelMediaRelay`
17 17
   - new apis:
18 18
     * `switchChannel` switch to specified channel
19
-    * `startChannelMediaRelay`, `updateChannelMediaRelay`, `stopChannelMediaRelay` relay media streams operation for across channels.
19
+    * `startChannelMediaRelay`, `updateChannelMediaRelay`, `stopChannelMediaRelay`, `removeChannelMediaRelay` relay media streams operation for across channels.
20 20
 
21 21
 #### 2.8.0-alpha.1
22 22
   - add `string uid` api support

+ 143
- 102
android/src/main/java/com/syan/agora/AgoraModule.java Ver fichero

@@ -1110,6 +1110,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1110 1110
         AgoraManager.getInstance().init(getReactApplicationContext(), mRtcEventHandler, options);
1111 1111
         appId = options.getString("appid");
1112 1112
         rtcEngine = AgoraManager.getInstance().mRtcEngine;
1113
+        rtcEngine.setParameters("{\"rtc.log_filter\": 65535}");
1113 1114
     }
1114 1115
 
1115 1116
     @ReactMethod
@@ -1254,34 +1255,36 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1254 1255
         RtcEngine.destroy();
1255 1256
     }
1256 1257
 
1257
-
1258
-
1259 1258
     @ReactMethod
1260 1259
     public void startChannelMediaRelay(ReadableMap options, Promise promise) {
1261 1260
         ChannelMediaRelayConfiguration config = new ChannelMediaRelayConfiguration();
1262
-        ReadableMap srcOption = options.getMap("src");
1263 1261
         ChannelMediaInfo src = config.getSrcChannelMediaInfo();
1264
-        if (srcOption.hasKey("token")) {
1265
-            src.token = srcOption.getString("token");
1266
-        }
1267
-        if (srcOption.hasKey("channelName")) {
1268
-            src.channelName = srcOption.getString("channelName");
1269
-        }
1270
-        ReadableMap dstMediaInfo = options.getMap("dst");
1271
-        String dstChannelName = null;
1272
-        Integer dstUid = 0;
1273
-        String dstToken = null;
1274
-        if (dstMediaInfo.hasKey("token")) {
1275
-            dstToken = options.getString("token");
1276
-        }
1277
-        if (dstMediaInfo.hasKey("channelName")) {
1278
-            dstChannelName = options.getString("channelName");
1262
+        if (options.hasKey("src")) {
1263
+            ReadableMap srcOption = options.getMap("src");
1264
+            if (srcOption.hasKey("token")) {
1265
+                src.token = srcOption.getString("token");
1266
+            }
1267
+            if (srcOption.hasKey("channelName")) {
1268
+                src.channelName = srcOption.getString("channelName");
1269
+            }
1279 1270
         }
1280
-        if (dstMediaInfo.hasKey("uid")) {
1281
-            dstUid = options.getInt("uid");
1271
+        ReadableArray dstMediaInfo = options.getArray("channels");
1272
+        for (int i = 0; i < dstMediaInfo.size(); i++) {
1273
+            ReadableMap dst = dstMediaInfo.getMap(i);
1274
+            String channelName = null;
1275
+            String token = null;
1276
+            Integer uid = 0;
1277
+            if (dst.hasKey("token")) {
1278
+                token = token;
1279
+            }
1280
+            if (dst.hasKey("channelName")) {
1281
+                channelName = dst.getString("channelName");
1282
+            }
1283
+            if (dst.hasKey("uid")) {
1284
+                uid = dst.getInt("uid");
1285
+            }
1286
+            config.setDestChannelInfo(channelName, new ChannelMediaInfo(channelName, token, uid));
1282 1287
         }
1283
-        ChannelMediaInfo dest = new ChannelMediaInfo(dstChannelName, dstToken, dstUid);
1284
-        config.setDestChannelInfo(dest.channelName, dest);
1285 1288
         Integer res = AgoraManager.getInstance().mRtcEngine.startChannelMediaRelay(config);
1286 1289
         if (res == 0) {
1287 1290
             promise.resolve(null);
@@ -1291,31 +1294,64 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1291 1294
     }
1292 1295
 
1293 1296
     @ReactMethod
1294
-    public void updateChannelMediaRelay(ReadableMap options, Promise promise) {
1297
+    public void removeChannelMediaRelay(ReadableMap options, Promise promise) {
1295 1298
         ChannelMediaRelayConfiguration config = new ChannelMediaRelayConfiguration();
1296
-        ReadableMap srcOption = options.getMap("src");
1297 1299
         ChannelMediaInfo src = config.getSrcChannelMediaInfo();
1298
-        if (srcOption.hasKey("token")) {
1299
-            src.token = srcOption.getString("token");
1300
+        if (options.hasKey("src")) {
1301
+            ReadableMap srcOption = options.getMap("src");
1302
+            if (srcOption.hasKey("token")) {
1303
+                src.token = srcOption.getString("token");
1304
+            }
1305
+            if (srcOption.hasKey("channelName")) {
1306
+                src.channelName = srcOption.getString("channelName");
1307
+            }
1300 1308
         }
1301
-        if (srcOption.hasKey("channelName")) {
1302
-            src.channelName = srcOption.getString("channelName");
1309
+        ReadableArray dstMediaInfo = options.getArray("channels");
1310
+        for (int i = 0; i < dstMediaInfo.size(); i++) {
1311
+            ReadableMap dst = dstMediaInfo.getMap(i);
1312
+            if (dst.hasKey("channelName")) {
1313
+                channelName = dst.getString("channelName");
1314
+                config.removeDestChannelInfo(channelName);
1315
+            }
1303 1316
         }
1304
-        ReadableMap dstMediaInfo = options.getMap("dst");
1305
-        String dstChannelName = null;
1306
-        Integer dstUid = 0;
1307
-        String dstToken = null;
1308
-        if (dstMediaInfo.hasKey("token")) {
1309
-            dstToken = options.getString("token");
1317
+        Integer res = AgoraManager.getInstance().mRtcEngine.updateChannelMediaRelay(config);
1318
+        if (res == 0) {
1319
+            promise.resolve(null);
1320
+        } else {
1321
+            promise.reject("-1", res.toString());
1310 1322
         }
1311
-        if (dstMediaInfo.hasKey("channelName")) {
1312
-            dstChannelName = options.getString("channelName");
1323
+    }
1324
+
1325
+    @ReactMethod
1326
+    public void updateChannelMediaRelay(ReadableMap options, Promise promise) {
1327
+        ChannelMediaRelayConfiguration config = new ChannelMediaRelayConfiguration();
1328
+        ChannelMediaInfo src = config.getSrcChannelMediaInfo();
1329
+        if (options.hasKey("src")) {
1330
+            ReadableMap srcOption = options.getMap("src");
1331
+            if (srcOption.hasKey("token")) {
1332
+                src.token = srcOption.getString("token");
1333
+            }
1334
+            if (srcOption.hasKey("channelName")) {
1335
+                src.channelName = srcOption.getString("channelName");
1336
+            }
1313 1337
         }
1314
-        if (dstMediaInfo.hasKey("uid")) {
1315
-            dstUid = options.getInt("uid");
1338
+        ReadableArray dstMediaInfo = options.getArray("channels");
1339
+        for (int i = 0; i < dstMediaInfo.size(); i++) {
1340
+            ReadableMap dst = dstMediaInfo.getMap(i);
1341
+            String channelName = null;
1342
+            String token = null;
1343
+            Integer uid = 0;
1344
+            if (dst.hasKey("token")) {
1345
+                token = token;
1346
+            }
1347
+            if (dst.hasKey("channelName")) {
1348
+                channelName = dst.getString("channelName");
1349
+            }
1350
+            if (dst.hasKey("uid")) {
1351
+                uid = dst.getInt("uid");
1352
+            }
1353
+            config.setDestChannelInfo(src.channelName, new ChannelMediaInfo(channelName, token, uid));
1316 1354
         }
1317
-        ChannelMediaInfo dest = new ChannelMediaInfo(dstChannelName, dstToken, dstUid);
1318
-        config.setDestChannelInfo(dest.channelName, dest);
1319 1355
         Integer res = AgoraManager.getInstance().mRtcEngine.updateChannelMediaRelay(config);
1320 1356
         if (res == 0) {
1321 1357
             promise.resolve(null);
@@ -1325,8 +1361,13 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1325 1361
     }
1326 1362
 
1327 1363
     @ReactMethod
1328
-    public void stopChannelMediaRelay() {
1329
-        AgoraManager.getInstance().mRtcEngine.stopChannelMediaRelay();
1364
+    public void stopChannelMediaRelay(Promise promise) {
1365
+        Integer res = AgoraManager.getInstance().mRtcEngine.stopChannelMediaRelay();
1366
+        if (res == 0) {
1367
+            promise.resolve(null);
1368
+        } else {
1369
+            promise.reject("-1", res.toString());
1370
+        }
1330 1371
     }
1331 1372
 
1332 1373
     @ReactMethod
@@ -1475,9 +1516,9 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1475 1516
     @ReactMethod
1476 1517
     public void setCameraFocusPositionInPreview(ReadableMap options, Promise promise) {
1477 1518
         Integer res = AgoraManager.getInstance().mRtcEngine.setCameraFocusPositionInPreview(
1478
-                    (float)options.getDouble("x"),
1479
-                    (float)options.getDouble("y")
1480
-            );
1519
+                (float)options.getDouble("x"),
1520
+                (float)options.getDouble("y")
1521
+        );
1481 1522
         if (res == 0) {
1482 1523
             promise.resolve(null);
1483 1524
         } else {
@@ -1650,10 +1691,10 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1650 1691
     @ReactMethod
1651 1692
     public void createDataStream(ReadableMap options, Promise promise) {
1652 1693
         Integer res = AgoraManager.getInstance().mRtcEngine
1653
-                    .createDataStream(
1654
-                            options.getBoolean("ordered"),
1655
-                            options.getBoolean("reliable")
1656
-                            );
1694
+                .createDataStream(
1695
+                        options.getBoolean("ordered"),
1696
+                        options.getBoolean("reliable")
1697
+                );
1657 1698
         if (res == 0) {
1658 1699
             promise.resolve(null);
1659 1700
         } else {
@@ -1721,10 +1762,10 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1721 1762
     @ReactMethod
1722 1763
     public void startAudioMixing(ReadableMap options, Promise promise) {
1723 1764
         Integer res = AgoraManager.getInstance().mRtcEngine.startAudioMixing(
1724
-                    options.getString("filepath"),
1725
-                    options.getBoolean("loopback"),
1726
-                    options.getBoolean("replace"),
1727
-                    options.getInt("cycle")
1765
+                options.getString("filepath"),
1766
+                options.getBoolean("loopback"),
1767
+                options.getBoolean("replace"),
1768
+                options.getInt("cycle")
1728 1769
         );
1729 1770
         if (res == 0) {
1730 1771
             promise.resolve(null);
@@ -1846,10 +1887,10 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1846 1887
     @ReactMethod
1847 1888
     public void startAudioRecording(ReadableMap options, Promise promise) {
1848 1889
         Integer res = AgoraManager.getInstance().mRtcEngine
1849
-                    .startAudioRecording(
1850
-                            options.getString("filepath"),
1851
-                            options.getInt("quality")
1852
-        );
1890
+                .startAudioRecording(
1891
+                        options.getString("filepath"),
1892
+                        options.getInt("quality")
1893
+                );
1853 1894
         if (res == 0) {
1854 1895
             promise.resolve(null);
1855 1896
         } else {
@@ -1860,7 +1901,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1860 1901
     @ReactMethod
1861 1902
     public void stopAudioRecording(Promise promise) {
1862 1903
         Integer res = AgoraManager.getInstance().mRtcEngine
1863
-                    .stopAudioRecording();
1904
+                .stopAudioRecording();
1864 1905
         if (res == 0) {
1865 1906
             promise.resolve(null);
1866 1907
         } else {
@@ -1871,7 +1912,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1871 1912
     @ReactMethod
1872 1913
     public void stopEchoTest(Promise promise) {
1873 1914
         Integer res = AgoraManager.getInstance().mRtcEngine
1874
-                    .stopEchoTest();
1915
+                .stopEchoTest();
1875 1916
         if (res == 0) {
1876 1917
             promise.resolve(null);
1877 1918
         } else {
@@ -1882,7 +1923,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1882 1923
     @ReactMethod
1883 1924
     public void enableLastmileTest(Promise promise) {
1884 1925
         Integer res = AgoraManager.getInstance().mRtcEngine
1885
-                    .enableLastmileTest();
1926
+                .enableLastmileTest();
1886 1927
         if (res == 0) {
1887 1928
             promise.resolve(null);
1888 1929
         } else {
@@ -1893,7 +1934,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1893 1934
     @ReactMethod
1894 1935
     public void disableLastmileTest(Promise promise) {
1895 1936
         Integer res = AgoraManager.getInstance().mRtcEngine
1896
-                    .disableLastmileTest();
1937
+                .disableLastmileTest();
1897 1938
         if (res == 0) {
1898 1939
             promise.resolve(null);
1899 1940
         } else {
@@ -1904,12 +1945,12 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1904 1945
     @ReactMethod
1905 1946
     public void setRecordingAudioFrameParameters(ReadableMap options, Promise promise) {
1906 1947
         Integer res = AgoraManager.getInstance().mRtcEngine
1907
-                    .setRecordingAudioFrameParameters(
1908
-                            options.getInt("sampleRate"),
1909
-                            options.getInt("channel"),
1910
-                            options.getInt("mode"),
1911
-                            options.getInt("samplesPerCall")
1912
-        );
1948
+                .setRecordingAudioFrameParameters(
1949
+                        options.getInt("sampleRate"),
1950
+                        options.getInt("channel"),
1951
+                        options.getInt("mode"),
1952
+                        options.getInt("samplesPerCall")
1953
+                );
1913 1954
         if (res == 0) {
1914 1955
             promise.resolve(null);
1915 1956
         } else {
@@ -1920,12 +1961,12 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1920 1961
     @ReactMethod
1921 1962
     public void setPlaybackAudioFrameParameters(ReadableMap options, Promise promise) {
1922 1963
         Integer res = AgoraManager.getInstance().mRtcEngine
1923
-                    .setPlaybackAudioFrameParameters(
1924
-                            options.getInt("sampleRate"),
1925
-                            options.getInt("channel"),
1926
-                            options.getInt("mode"),
1927
-                            options.getInt("samplesPerCall")
1928
-        );
1964
+                .setPlaybackAudioFrameParameters(
1965
+                        options.getInt("sampleRate"),
1966
+                        options.getInt("channel"),
1967
+                        options.getInt("mode"),
1968
+                        options.getInt("samplesPerCall")
1969
+                );
1929 1970
         if (res == 0) {
1930 1971
             promise.resolve(null);
1931 1972
         } else {
@@ -1936,10 +1977,10 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1936 1977
     @ReactMethod
1937 1978
     public void setMixedAudioFrameParameters(WritableMap options, Promise promise) {
1938 1979
         Integer res = AgoraManager.getInstance().mRtcEngine
1939
-                    .setMixedAudioFrameParameters(
1940
-                            options.getInt("sampleRate"),
1941
-                            options.getInt("samplesPerCall")
1942
-                    );
1980
+                .setMixedAudioFrameParameters(
1981
+                        options.getInt("sampleRate"),
1982
+                        options.getInt("samplesPerCall")
1983
+                );
1943 1984
         if (res == 0) {
1944 1985
             promise.resolve(null);
1945 1986
         } else {
@@ -1960,7 +2001,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1960 2001
     @ReactMethod
1961 2002
     public void addVideoWatermark(ReadableMap options, Promise promise) {
1962 2003
         Integer res = AgoraManager.getInstance().mRtcEngine
1963
-                    .addVideoWatermark(createAgoraImage(options));
2004
+                .addVideoWatermark(createAgoraImage(options));
1964 2005
         if (res == 0) {
1965 2006
             promise.resolve(null);
1966 2007
         } else {
@@ -1971,7 +2012,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1971 2012
     @ReactMethod
1972 2013
     public void clearVideoWatermarks(Promise promise) {
1973 2014
         Integer res = AgoraManager.getInstance().mRtcEngine
1974
-                    .clearVideoWatermarks();
2015
+                .clearVideoWatermarks();
1975 2016
         if (res == 0) {
1976 2017
             promise.resolve(null);
1977 2018
         } else {
@@ -1982,7 +2023,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1982 2023
     @ReactMethod
1983 2024
     public void setLocalPublishFallbackOption(int option, Promise promise) {
1984 2025
         Integer res = AgoraManager.getInstance().mRtcEngine
1985
-                    .setLocalPublishFallbackOption(option);
2026
+                .setLocalPublishFallbackOption(option);
1986 2027
         if (res == 0) {
1987 2028
             promise.resolve(null);
1988 2029
         } else {
@@ -1993,7 +2034,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
1993 2034
     @ReactMethod
1994 2035
     public void setRemoteSubscribeFallbackOption(int option, Promise promise) {
1995 2036
         Integer res = AgoraManager.getInstance().mRtcEngine
1996
-                    .setRemoteSubscribeFallbackOption(option);
2037
+                .setRemoteSubscribeFallbackOption(option);
1997 2038
         if (res == 0) {
1998 2039
             promise.resolve(null);
1999 2040
         } else {
@@ -2004,7 +2045,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
2004 2045
     @ReactMethod
2005 2046
     public void enableDualStreamMode(boolean enabled, Promise promise) {
2006 2047
         Integer res = AgoraManager.getInstance().mRtcEngine
2007
-                    .enableDualStreamMode(enabled);
2048
+                .enableDualStreamMode(enabled);
2008 2049
         if (res == 0) {
2009 2050
             promise.resolve(null);
2010 2051
         } else {
@@ -2016,10 +2057,10 @@ public class AgoraModule extends ReactContextBaseJavaModule {
2016 2057
     @ReactMethod
2017 2058
     public void setRemoteVideoStreamType(ReadableMap options, Promise promise) {
2018 2059
         Integer res = AgoraManager.getInstance().mRtcEngine
2019
-                    .setRemoteVideoStreamType(
2020
-                            options.getInt("uid"),
2021
-                            options.getInt("streamType")
2022
-                        );
2060
+                .setRemoteVideoStreamType(
2061
+                        options.getInt("uid"),
2062
+                        options.getInt("streamType")
2063
+                );
2023 2064
         if (res == 0) {
2024 2065
             promise.resolve(null);
2025 2066
         } else {
@@ -2030,9 +2071,9 @@ public class AgoraModule extends ReactContextBaseJavaModule {
2030 2071
     @ReactMethod
2031 2072
     public void setRemoteDefaultVideoStreamType(ReadableMap options, Promise promise) {
2032 2073
         Integer res = AgoraManager.getInstance().mRtcEngine
2033
-                    .setRemoteDefaultVideoStreamType(
2034
-                            options.getInt("streamType")
2035
-                    );
2074
+                .setRemoteDefaultVideoStreamType(
2075
+                        options.getInt("streamType")
2076
+                );
2036 2077
         if (res == 0) {
2037 2078
             promise.resolve(null);
2038 2079
         } else {
@@ -2182,7 +2223,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
2182 2223
     @ReactMethod
2183 2224
     public void removeInjectStreamUrl(ReadableMap options, Promise promise) {
2184 2225
         Integer res = AgoraManager.getInstance().mRtcEngine
2185
-                    .removeInjectStreamUrl(options.getString("url"));
2226
+                .removeInjectStreamUrl(options.getString("url"));
2186 2227
         if (res == 0) {
2187 2228
             promise.resolve(null);
2188 2229
         } else {
@@ -2193,10 +2234,10 @@ public class AgoraModule extends ReactContextBaseJavaModule {
2193 2234
     @ReactMethod
2194 2235
     public void addPublishStreamUrl(ReadableMap options, Promise promise) {
2195 2236
         Integer res = AgoraManager.getInstance().mRtcEngine
2196
-                    .addPublishStreamUrl(
2197
-                            options.getString("url"),
2198
-                            options.getBoolean("enable")
2199
-                    );
2237
+                .addPublishStreamUrl(
2238
+                        options.getString("url"),
2239
+                        options.getBoolean("enable")
2240
+                );
2200 2241
         if (res == 0) {
2201 2242
             promise.resolve(null);
2202 2243
         } else {
@@ -2207,7 +2248,7 @@ public class AgoraModule extends ReactContextBaseJavaModule {
2207 2248
     @ReactMethod
2208 2249
     public void removePublishStreamUrl(ReadableMap options, Promise promise) {
2209 2250
         Integer res = AgoraManager.getInstance().mRtcEngine
2210
-                    .removePublishStreamUrl(options.getString("url"));
2251
+                .removePublishStreamUrl(options.getString("url"));
2211 2252
         if (res == 0) {
2212 2253
             promise.resolve(null);
2213 2254
         } else {
@@ -2339,13 +2380,13 @@ public class AgoraModule extends ReactContextBaseJavaModule {
2339 2380
     public void playEffect(ReadableMap options, Promise promise) {
2340 2381
         IAudioEffectManager manager = AgoraManager.getInstance().mRtcEngine.getAudioEffectManager();
2341 2382
         Integer res = manager.playEffect(
2342
-            options.getInt("soundid"),
2343
-            options.getString("filepath"),
2344
-            options.getInt("loopcount"),
2345
-            options.getDouble("pitch"),
2346
-            options.getDouble("pan"),
2347
-            options.getDouble("gain"),
2348
-            options.getBoolean("publish")
2383
+                options.getInt("soundid"),
2384
+                options.getString("filepath"),
2385
+                options.getInt("loopcount"),
2386
+                options.getDouble("pitch"),
2387
+                options.getDouble("pan"),
2388
+                options.getDouble("gain"),
2389
+                options.getBoolean("publish")
2349 2390
         );
2350 2391
         if (res == 0) {
2351 2392
             promise.resolve(null);

+ 5
- 6
ios/RCTAgora/AgoraConst.m Ver fichero

@@ -44,9 +44,6 @@ static AgoraConst *_person;
44 44
                                   AGTokenPrivilegeWillExpire,
45 45
                                   AGRequestToken,
46 46
                                   
47
-                                  AGLocalAudioStateChanged,
48
-                                  AGRemoteAudioStateChanged,
49
-                                  AGLocalAudioStats,
50 47
                                   AGAudioVolumeIndication,
51 48
                                   AGActiveSpeaker,
52 49
                                   AGFirstLocalAudioFrame,
@@ -70,6 +67,11 @@ static AgoraConst *_person;
70 67
                                   AGLocalVideoStats,
71 68
                                   AGRemoteVideoStats,
72 69
                                   AGRemoteAudioStats,
70
+                                  AGLocalAudioStateChanged,
71
+                                  AGRemoteAudioStateChanged,
72
+                                  AGLocalAudioStats,
73
+                                  AGMediaRelayStateChanged,
74
+                                  AGReceivedChannelMediaRelay,
73 75
                                   
74 76
                                   AGAudioMixingStateChanged,
75 77
                                   AGRemoteAudioMixingStart,
@@ -85,9 +87,6 @@ static AgoraConst *_person;
85 87
                                   AGReceiveStreamMessage,
86 88
                                   AGOccurStreamMessageError,
87 89
                                   
88
-                                  AGReceivedChannelMediaRelay,
89
-                                  AGMediaRelayStateChanged,
90
-                                  
91 90
                                   AGMediaEngineLoaded,
92 91
                                   AGMediaEngineStartCall,
93 92
                                   AGIntervalTest,

+ 74
- 42
ios/RCTAgora/RCTAgora.m Ver fichero

@@ -318,18 +318,21 @@ RCT_EXPORT_METHOD(startChannelMediaRelay:(NSDictionary *)options
318 318
                   resolve:(RCTPromiseResolveBlock)resolve
319 319
                   reject:(RCTPromiseRejectBlock)reject) {
320 320
   AgoraChannelMediaRelayConfiguration *config = [[AgoraChannelMediaRelayConfiguration alloc] init];
321
-  
322 321
   AgoraChannelMediaRelayInfo *src = [config sourceInfo];
323 322
   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"]];
323
+  if (srcOption != nil) {
324
+    src.channelName = srcOption[@"channelName"];
325
+    src.uid = [srcOption[@"uid"] integerValue];
326
+    src.token = srcOption[@"token"];
327
+  }
328
+  NSArray *channels = options[@"channels"];
329
+  for (NSDictionary *channel in channels) {
330
+    AgoraChannelMediaRelayInfo *dst = [[AgoraChannelMediaRelayInfo alloc] init];
331
+    dst.channelName = channel[@"channelName"];
332
+    dst.uid = [channel[@"uid"] integerValue];
333
+    dst.token = channel[@"token"];
334
+    [config setDestinationInfo:dst forChannelName:dst.channelName];
335
+  }
333 336
   NSInteger res = [self.rtcEngine startChannelMediaRelay:config];
334 337
   if (res == 0) {
335 338
     resolve(nil);
@@ -343,18 +346,47 @@ RCT_EXPORT_METHOD(updateChannelMediaRelay:(NSDictionary *)options
343 346
                   resolve:(RCTPromiseResolveBlock)resolve
344 347
                   reject:(RCTPromiseRejectBlock)reject) {
345 348
   AgoraChannelMediaRelayConfiguration *config = [[AgoraChannelMediaRelayConfiguration alloc] init];
346
-  
347 349
   AgoraChannelMediaRelayInfo *src = [config sourceInfo];
348 350
   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"]];
351
+  if (srcOption != nil) {
352
+    src.channelName = srcOption[@"channelName"];
353
+    src.uid = [srcOption[@"uid"] integerValue];
354
+    src.token = srcOption[@"token"];
355
+  }
356
+  NSArray *channels = options[@"channels"];
357
+  for (NSDictionary *channel in channels) {
358
+    AgoraChannelMediaRelayInfo *dst = [[AgoraChannelMediaRelayInfo alloc] init];
359
+    dst.channelName = channel[@"channelName"];
360
+    dst.uid = [channel[@"uid"] integerValue];
361
+    dst.token = channel[@"token"];
362
+    [config setDestinationInfo:dst forChannelName:dst.channelName];
363
+  }
364
+  NSInteger res = [self.rtcEngine updateChannelMediaRelay:config];
365
+  if (res == 0) {
366
+    resolve(nil);
367
+  } else {
368
+    reject(@(-1).stringValue, @(res).stringValue, nil);
369
+  }
370
+}
371
+
372
+// removeChannelMediaRelay
373
+RCT_EXPORT_METHOD(removeChannelMediaRelay:(NSDictionary *)options
374
+                  resolve:(RCTPromiseResolveBlock)resolve
375
+                  reject:(RCTPromiseRejectBlock)reject) {
376
+  AgoraChannelMediaRelayConfiguration *config = [[AgoraChannelMediaRelayConfiguration alloc] init];
377
+  AgoraChannelMediaRelayInfo *src = [config sourceInfo];
378
+  NSDictionary *srcOption = options[@"src"];
379
+  if (srcOption != nil) {
380
+    src.channelName = srcOption[@"channelName"];
381
+    src.uid = [srcOption[@"uid"] integerValue];
382
+    src.token = srcOption[@"token"];
383
+  }
384
+  NSArray *channels = options[@"channels"];
385
+  for (NSDictionary *channel in channels) {
386
+    if (channel[@"channelName"] != nil) {
387
+      [config removeDestinationInfoForChannelName:channel[@"channelName"]];
388
+    }
389
+  }
358 390
   NSInteger res = [self.rtcEngine updateChannelMediaRelay:config];
359 391
   if (res == 0) {
360 392
     resolve(nil);
@@ -407,9 +439,9 @@ RCT_EXPORT_METHOD(getUserInfoByUid:(NSUInteger)uid
407 439
   AgoraUserInfo *info = [self.rtcEngine getUserInfoByUid:uid withError:&code];
408 440
   if ((int)code == 0) {
409 441
     resolve(@{
410
-        @"uid": @(info.uid),
411
-        @"userAccount": info.userAccount
412
-    });
442
+              @"uid": @(info.uid),
443
+              @"userAccount": info.userAccount
444
+              });
413 445
   } else {
414 446
     reject(@(-1).stringValue, @((int)code).stringValue, nil);
415 447
   }
@@ -1864,10 +1896,10 @@ RCT_EXPORT_METHOD(registerMediaMetadataObserver
1864 1896
 
1865 1897
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didUpdatedUserInfo:(AgoraUserInfo *_Nonnull)userInfo withUid:(NSUInteger)uid {
1866 1898
   [self sendEvent:AGUserInfoUpdated params:@{
1867
-                                                 @"uid": @(uid),
1868
-                                                 @"peer": @{
1869
-                                                     @"uid": @(userInfo.uid),
1870
-                                                     @"userAccount": userInfo.userAccount
1899
+                                             @"uid": @(uid),
1900
+                                             @"peer": @{
1901
+                                                 @"uid": @(userInfo.uid),
1902
+                                                 @"userAccount": userInfo.userAccount
1871 1903
                                                  }}];
1872 1904
 }
1873 1905
 
@@ -1912,26 +1944,26 @@ RCT_EXPORT_METHOD(registerMediaMetadataObserver
1912 1944
 
1913 1945
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine localAudioStateChange:(AgoraAudioLocalState)state error:(AgoraAudioLocalError)error {
1914 1946
   [self sendEvent:AGLocalAudioStateChanged params:@{
1915
-                                               @"state": @(state),
1916
-                                               @"errorCode": @(error)
1917
-                                               }];
1947
+                                                    @"state": @(state),
1948
+                                                    @"errorCode": @(error)
1949
+                                                    }];
1918 1950
 }
1919 1951
 
1920 1952
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine remoteAudioStateChangedOfUid:(NSUInteger)uid state:(AgoraAudioRemoteState)state reason:(AgoraAudioRemoteStateReason)reason elapsed:(NSInteger)elapsed {
1921 1953
   [self sendEvent:AGRemoteAudioStateChanged params:@{
1922
-                                                    @"uid": @(uid),
1923
-                                                    @"state": @(state),
1924
-                                                    @"reason": @(reason),
1925
-                                                    @"elapsed": @(elapsed)
1926
-                                                    }];
1954
+                                                     @"uid": @(uid),
1955
+                                                     @"state": @(state),
1956
+                                                     @"reason": @(reason),
1957
+                                                     @"elapsed": @(elapsed)
1958
+                                                     }];
1927 1959
 }
1928 1960
 
1929 1961
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine localAudioStats:(AgoraRtcLocalAudioStats *_Nonnull)stats {
1930 1962
   [self sendEvent:AGLocalAudioStats params:@{
1931
-                                                     @"numChannels": @(stats.numChannels),
1932
-                                                     @"sentSampleRate": @(stats.sentSampleRate),
1933
-                                                     @"sentBitrate": @(stats.sentBitrate),
1934
-                                                     }];
1963
+                                             @"numChannels": @(stats.numChannels),
1964
+                                             @"sentSampleRate": @(stats.sentSampleRate),
1965
+                                             @"sentBitrate": @(stats.sentBitrate),
1966
+                                             }];
1935 1967
 }
1936 1968
 
1937 1969
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine reportAudioVolumeIndicationOfSpeakers:(NSArray<AgoraRtcAudioVolumeInfo*> *_Nonnull)speakers totalVolume:(NSInteger)totalVolume {
@@ -2193,13 +2225,13 @@ RCT_EXPORT_METHOD(registerMediaMetadataObserver
2193 2225
   [self sendEvent:AGMediaRelayStateChanged params:@{
2194 2226
                                                     @"state": @(state),
2195 2227
                                                     @"errorCode": @(error),
2196
-                                                   }];
2228
+                                                    }];
2197 2229
 }
2198 2230
 
2199 2231
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine didReceiveChannelMediaRelayEvent:(AgoraChannelMediaRelayEvent)event {
2200 2232
   [self sendEvent:AGReceivedChannelMediaRelay params:@{
2201
-                                                  @"event": @(event),
2202
-                                                  }];
2233
+                                                       @"event": @(event),
2234
+                                                       }];
2203 2235
 }
2204 2236
 
2205 2237
 - (void)rtcEngine:(AgoraRtcEngineKit *_Nonnull)engine receiveStreamMessageFromUid:(NSUInteger)uid streamId:(NSInteger)streamId data:(NSData *_Nonnull)data {

+ 37
- 4
lib/RtcEngine.native.d.ts Ver fichero

@@ -1,4 +1,4 @@
1
-import { Option, Callback, AgoraUserInfo, AudioMixingOption, PlayEffectOption, AudioRecordingOption, AudioFrameOption, MixedAudioFrameOption, ImageOption, VideoStreamOption, DefaultVideoStreamOption, InjectStreamOption, RemoveInjectStreamOption, PublishStreamOption, RemovePublishStreamOption, LiveTranscodingOption, PositionOption, BeautyOption, LastmileProbeConfig, CameraCapturerConfiguration } from "./types";
1
+import { Option, Callback, AgoraUserInfo, AudioMixingOption, PlayEffectOption, AudioRecordingOption, AudioFrameOption, MixedAudioFrameOption, ImageOption, VideoStreamOption, DefaultVideoStreamOption, InjectStreamOption, RemoveInjectStreamOption, PublishStreamOption, RemovePublishStreamOption, LiveTranscodingOption, PositionOption, BeautyOption, LastmileProbeConfig, CameraCapturerConfiguration, ChannelMediaConfiguration } from "./types";
2 2
 /**
3 3
  * RtcEngine is the javascript object for control agora native sdk through react native bridge.
4 4
  *
@@ -46,9 +46,42 @@ declare class RtcEngine {
46 46
      * @param token
47 47
      */
48 48
     static switchChannel(channelName: string, token?: string): Promise<any>;
49
-    static startChannelMediaRelay(): void;
50
-    static updateChannelMediaRelay(): void;
51
-    static stopChannelMediaRelay(): void;
49
+    /**
50
+     * Starts to relay media streams across channels.
51
+     *
52
+     * This method will start relay media stream across specified channels. (maximum support 4 channels)
53
+     * It will occurs event:
54
+     *  Occurs onChannelMediaRelayStateChanged
55
+     * @param config
56
+     */
57
+    static startChannelMediaRelay(config: ChannelMediaConfiguration): Promise<any>;
58
+    /**
59
+     * Remove to relay media streams across channels.
60
+     *
61
+     * This method will remove & update relay media stream across specified channels. (maximum support relay 4 channels)
62
+     * It will occurs event:
63
+     *  Occurs onChannelMediaRelayStateChanged
64
+     * @param config
65
+     */
66
+    static removeChannelMediaRelay(config: ChannelMediaConfiguration): Promise<any>;
67
+    /**
68
+     * Updates to relay media streams across channels.
69
+     *
70
+     * This method will update relay media stream across specified channels. (maximum support 4 channels)
71
+     * It will occurs event:
72
+     *  Occurs onChannelMediaRelayStateChanged
73
+     * @param config
74
+     */
75
+    static updateChannelMediaRelay(config: ChannelMediaConfiguration): Promise<any>;
76
+    /**
77
+     * Stop to relay media streams across channels.
78
+     *
79
+     * This method will stop relay media stream across specified channels.
80
+     * It will occurs event:
81
+     *  Occurs onChannelMediaRelayStateChanged
82
+     * @param config
83
+     */
84
+    static stopChannelMediaRelay(): Promise<any>;
52 85
     /**
53 86
      * Registers a user account.
54 87
      *

+ 40
- 2
lib/RtcEngine.native.js Ver fichero

@@ -49,11 +49,49 @@ class RtcEngine {
49 49
     static switchChannel(channelName, token) {
50 50
         return Agora.switchChannel({ channelName, token });
51 51
     }
52
-    static startChannelMediaRelay() {
52
+    /**
53
+     * Starts to relay media streams across channels.
54
+     *
55
+     * This method will start relay media stream across specified channels. (maximum support 4 channels)
56
+     * It will occurs event:
57
+     *  Occurs onChannelMediaRelayStateChanged
58
+     * @param config
59
+     */
60
+    static startChannelMediaRelay(config) {
61
+        return Agora.startChannelMediaRelay(config);
53 62
     }
54
-    static updateChannelMediaRelay() {
63
+    /**
64
+     * Remove to relay media streams across channels.
65
+     *
66
+     * This method will remove & update relay media stream across specified channels. (maximum support relay 4 channels)
67
+     * It will occurs event:
68
+     *  Occurs onChannelMediaRelayStateChanged
69
+     * @param config
70
+     */
71
+    static removeChannelMediaRelay(config) {
72
+        return Agora.removeChannelMediaRelay(config);
55 73
     }
74
+    /**
75
+     * Updates to relay media streams across channels.
76
+     *
77
+     * This method will update relay media stream across specified channels. (maximum support 4 channels)
78
+     * It will occurs event:
79
+     *  Occurs onChannelMediaRelayStateChanged
80
+     * @param config
81
+     */
82
+    static updateChannelMediaRelay(config) {
83
+        return Agora.updateChannelMediaRelay(config);
84
+    }
85
+    /**
86
+     * Stop to relay media streams across channels.
87
+     *
88
+     * This method will stop relay media stream across specified channels.
89
+     * It will occurs event:
90
+     *  Occurs onChannelMediaRelayStateChanged
91
+     * @param config
92
+     */
56 93
     static stopChannelMediaRelay() {
94
+        return Agora.stopChannelMediaRelay();
57 95
     }
58 96
     /**
59 97
      * Registers a user account.

+ 1
- 1
lib/RtcEngine.native.js.map
La diferencia del archivo ha sido suprimido porque es demasiado grande
Ver fichero


+ 28
- 0
lib/types.d.ts Ver fichero

@@ -1,4 +1,32 @@
1 1
 import { ViewProps } from 'react-native';
2
+/**
3
+ * ChannelMediaInfo
4
+ * @property channelName: string
5
+ * @property token: string
6
+ * @property uid: number
7
+ */
8
+export interface ChannelMediaInfo {
9
+    channelName: string;
10
+    token?: string;
11
+    uid?: number;
12
+}
13
+/**
14
+ * ChannelMediaConfiguration
15
+ * @property src: {
16
+ *    @member channelName,
17
+ *    @member token,
18
+ *    @member uid,
19
+ * }
20
+ * @property channels: {@link Array<ChannelMediaInfo>}
21
+ */
22
+export interface ChannelMediaConfiguration {
23
+    src?: {
24
+        channelName: string;
25
+        token?: string;
26
+        uid?: number;
27
+    };
28
+    channels: Array<ChannelMediaInfo>;
29
+}
2 30
 /**
3 31
  * AgoraViewMode
4 32
  * @mode hidden Uniformly scale the video until it fills the visible boundaries (cropped). One dimension of the video may have clipped contents.

+ 1
- 1
lib/types.js.map Ver fichero

@@ -1 +1 @@
1
-{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;AAEA;;;;GAIG;AACH,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,qDAAU,CAAA;IACV,+CAAO,CAAA;AACT,CAAC,EAHW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAGxB;AAUA,CAAC;AAuGF,IAAY,iBAIX;AAJD,WAAY,iBAAiB;IAC3B,kEAAa,CAAA;IACb,0DAAS,CAAA;IACT,2DAAU,CAAA;AACZ,CAAC,EAJW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAI5B;AAED,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IAC3B,6DAAU,CAAA;IACV,6DAAU,CAAA;AACZ,CAAC,EAHW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAG5B;AAED,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,qEAAkB,CAAA;IAClB,qEAAkB,CAAA;IAClB,qEAAkB,CAAA;AACpB,CAAC,EAJW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAI1B;AAED;;;GAGG;AACH,IAAY,kBAMX;AAND,WAAY,kBAAkB;IAC5B,yDAAO,CAAA;IACP,yDAAO,CAAA;IACP,6DAAS,CAAA;IACT,2DAAQ,CAAA;IACR,2DAAQ,CAAA;AACV,CAAC,EANW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAM7B"}
1
+{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";;AA+BA;;;;GAIG;AACH,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,qDAAU,CAAA;IACV,+CAAO,CAAA;AACT,CAAC,EAHW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAGxB;AAUA,CAAC;AAuGF,IAAY,iBAIX;AAJD,WAAY,iBAAiB;IAC3B,kEAAa,CAAA;IACb,0DAAS,CAAA;IACT,2DAAU,CAAA;AACZ,CAAC,EAJW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAI5B;AAED,IAAY,iBAGX;AAHD,WAAY,iBAAiB;IAC3B,6DAAU,CAAA;IACV,6DAAU,CAAA;AACZ,CAAC,EAHW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAG5B;AAED,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,qEAAkB,CAAA;IAClB,qEAAkB,CAAA;IAClB,qEAAkB,CAAA;AACpB,CAAC,EAJW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAI1B;AAED;;;GAGG;AACH,IAAY,kBAMX;AAND,WAAY,kBAAkB;IAC5B,yDAAO,CAAA;IACP,yDAAO,CAAA;IACP,6DAAS,CAAA;IACT,2DAAQ,CAAA;IACR,2DAAQ,CAAA;AACV,CAAC,EANW,kBAAkB,GAAlB,0BAAkB,KAAlB,0BAAkB,QAM7B"}

+ 43
- 6
src/RtcEngine.native.ts Ver fichero

@@ -25,7 +25,8 @@ import {
25 25
     PositionOption,
26 26
     BeautyOption,
27 27
     LastmileProbeConfig,
28
-    CameraCapturerConfiguration
28
+    CameraCapturerConfiguration,
29
+    ChannelMediaConfiguration
29 30
 } from "./types";
30 31
 
31 32
 
@@ -91,16 +92,52 @@ class RtcEngine {
91 92
         return Agora.switchChannel({channelName, token});
92 93
     }
93 94
     
94
-    public static startChannelMediaRelay() {
95
-
95
+    /**
96
+     * Starts to relay media streams across channels.
97
+     * 
98
+     * This method will start relay media stream across specified channels. (maximum support 4 channels)
99
+     * It will occurs event:
100
+     *  Occurs onChannelMediaRelayStateChanged
101
+     * @param config
102
+     */
103
+    public static startChannelMediaRelay(config: ChannelMediaConfiguration): Promise<any> {
104
+        return Agora.startChannelMediaRelay(config);
96 105
     }
97 106
 
98
-    public static updateChannelMediaRelay() {
107
+    /**
108
+     * Remove to relay media streams across channels.
109
+     * 
110
+     * This method will remove & update relay media stream across specified channels. (maximum support relay 4 channels)
111
+     * It will occurs event:
112
+     *  Occurs onChannelMediaRelayStateChanged
113
+     * @param config
114
+     */
115
+    public static removeChannelMediaRelay(config: ChannelMediaConfiguration): Promise<any> {
116
+        return Agora.removeChannelMediaRelay(config);
117
+    }
99 118
 
119
+    /**
120
+     * Updates to relay media streams across channels.
121
+     * 
122
+     * This method will update relay media stream across specified channels. (maximum support 4 channels)
123
+     * It will occurs event:
124
+     *  Occurs onChannelMediaRelayStateChanged
125
+     * @param config
126
+     */
127
+    public static updateChannelMediaRelay(config: ChannelMediaConfiguration): Promise<any> {
128
+        return Agora.updateChannelMediaRelay(config);
100 129
     }
101 130
 
102
-    public static stopChannelMediaRelay() {
103
-        
131
+    /**
132
+     * Stop to relay media streams across channels.
133
+     * 
134
+     * This method will stop relay media stream across specified channels.
135
+     * It will occurs event:
136
+     *  Occurs onChannelMediaRelayStateChanged
137
+     * @param config
138
+     */
139
+    public static stopChannelMediaRelay(): Promise<any> {
140
+        return Agora.stopChannelMediaRelay();
104 141
     }
105 142
 
106 143
     /**

+ 29
- 0
src/types.ts Ver fichero

@@ -1,5 +1,34 @@
1 1
 import { ViewProps } from 'react-native';
2 2
 
3
+/**
4
+ * ChannelMediaInfo
5
+ * @property channelName: string
6
+ * @property token: string
7
+ * @property uid: number
8
+ */
9
+export interface ChannelMediaInfo {
10
+  channelName: string
11
+  token?: string
12
+  uid?: number
13
+}
14
+/**
15
+ * ChannelMediaConfiguration
16
+ * @property src: {
17
+ *    @member channelName,
18
+ *    @member token,
19
+ *    @member uid,
20
+ * }
21
+ * @property channels: {@link Array<ChannelMediaInfo>}
22
+ */
23
+export interface ChannelMediaConfiguration {
24
+  src?: {
25
+    channelName: string
26
+    token?: string
27
+    uid?: number
28
+  }
29
+  channels: Array<ChannelMediaInfo>
30
+}
31
+
3 32
 /**
4 33
  * AgoraViewMode
5 34
  * @mode hidden Uniformly scale the video until it fills the visible boundaries (cropped). One dimension of the video may have clipped contents.