|
@@ -25,9 +25,12 @@ import io.agora.rtc.Constants;
|
25
|
25
|
import io.agora.rtc.IAudioEffectManager;
|
26
|
26
|
import io.agora.rtc.IRtcEngineEventHandler;
|
27
|
27
|
import io.agora.rtc.RtcEngine;
|
|
28
|
+import io.agora.rtc.internal.LastmileProbeConfig;
|
28
|
29
|
import io.agora.rtc.live.LiveInjectStreamConfig;
|
29
|
30
|
import io.agora.rtc.live.LiveTranscoding;
|
30
|
31
|
import io.agora.rtc.video.AgoraImage;
|
|
32
|
+import io.agora.rtc.video.BeautyOptions;
|
|
33
|
+import io.agora.rtc.video.CameraCapturerConfiguration;
|
31
|
34
|
import io.agora.rtc.video.VideoEncoderConfiguration;
|
32
|
35
|
|
33
|
36
|
import static com.facebook.react.bridge.UiThreadUtil.runOnUiThread;
|
|
@@ -1451,9 +1454,11 @@ public class AgoraModule extends ReactContextBaseJavaModule {
|
1451
|
1454
|
}
|
1452
|
1455
|
|
1453
|
1456
|
@ReactMethod
|
1454
|
|
- public void setLog(String filePath, int level, Promise promise) {
|
|
1457
|
+ public void setLog(String filePath, int level, int size, Promise promise) {
|
1455
|
1458
|
try {
|
1456
|
1459
|
int res = 0;
|
|
1460
|
+ res = AgoraManager.getInstance().mRtcEngine.setLogFileSize(size);
|
|
1461
|
+ if (res != 0) throw new ReactNativeAgoraException("setLogFileSize Failed", res);
|
1457
|
1462
|
res = AgoraManager.getInstance().mRtcEngine.setLogFilter(level);
|
1458
|
1463
|
if (res != 0) throw new ReactNativeAgoraException("setLogFilter Failed", res);
|
1459
|
1464
|
res = AgoraManager.getInstance().mRtcEngine.setLogFile(filePath);
|
|
@@ -1794,20 +1799,21 @@ public class AgoraModule extends ReactContextBaseJavaModule {
|
1794
|
1799
|
}
|
1795
|
1800
|
}
|
1796
|
1801
|
|
1797
|
|
- @ReactMethod
|
1798
|
|
- public void startEchoTest(Promise promise) {
|
1799
|
|
- try {
|
1800
|
|
- int res = AgoraManager.getInstance().mRtcEngine
|
1801
|
|
- .startEchoTest();
|
1802
|
|
- if (res != 0) throw new ReactNativeAgoraException("startEchoTest Failed", res);
|
1803
|
|
- WritableMap map = Arguments.createMap();
|
1804
|
|
- map.putBoolean("success", true);
|
1805
|
|
- map.putInt("value", res);
|
1806
|
|
- promise.resolve(map);
|
1807
|
|
- } catch (Exception e) {
|
1808
|
|
- promise.reject("131009", e);
|
1809
|
|
- }
|
1810
|
|
- }
|
|
1802
|
+// deprecated
|
|
1803
|
+// @ReactMethod
|
|
1804
|
+// public void startEchoTest(Promise promise) {
|
|
1805
|
+// try {
|
|
1806
|
+// int res = AgoraManager.getInstance().mRtcEngine
|
|
1807
|
+// .startEchoTest();
|
|
1808
|
+// if (res != 0) throw new ReactNativeAgoraException("startEchoTest Failed", res);
|
|
1809
|
+// WritableMap map = Arguments.createMap();
|
|
1810
|
+// map.putBoolean("success", true);
|
|
1811
|
+// map.putInt("value", res);
|
|
1812
|
+// promise.resolve(map);
|
|
1813
|
+// } catch (Exception e) {
|
|
1814
|
+// promise.reject("131009", e);
|
|
1815
|
+// }
|
|
1816
|
+// }
|
1811
|
1817
|
|
1812
|
1818
|
@ReactMethod
|
1813
|
1819
|
public void stopEchoTest(Promise promise) {
|
|
@@ -2458,12 +2464,18 @@ public class AgoraModule extends ReactContextBaseJavaModule {
|
2458
|
2464
|
}
|
2459
|
2465
|
|
2460
|
2466
|
@ReactMethod
|
2461
|
|
- public void sendStreamMessage(int streamId, String data, Promise promise) {
|
|
2467
|
+ public void sendMessage(ReadableMap options, Promise promise) {
|
2462
|
2468
|
try {
|
2463
|
|
- int res = AgoraManager.getInstance().mRtcEngine.sendStreamMessage(streamId, data.getBytes());
|
|
2469
|
+ boolean reliable = options.getBoolean("reliable");
|
|
2470
|
+ boolean ordered = options.getBoolean("ordered");
|
|
2471
|
+ String data = options.getString("data");
|
|
2472
|
+ int streamID = AgoraManager.getInstance().mRtcEngine.createDataStream(reliable, ordered);
|
|
2473
|
+ if (streamID < 0) throw new ReactNativeAgoraException("createDataStream Failed", streamID);
|
|
2474
|
+ int res = AgoraManager.getInstance().mRtcEngine.sendStreamMessage(streamID, data.getBytes("utf8"));
|
2464
|
2475
|
if (res != 0) throw new ReactNativeAgoraException("sendStreamMessage Failed", res);
|
2465
|
2476
|
WritableMap map = Arguments.createMap();
|
2466
|
2477
|
map.putBoolean("success", true);
|
|
2478
|
+ map.putInt("streamID", streamID);
|
2467
|
2479
|
promise.resolve(map);
|
2468
|
2480
|
} catch (Exception e) {
|
2469
|
2481
|
promise.reject(e);
|
|
@@ -2480,14 +2492,28 @@ public class AgoraModule extends ReactContextBaseJavaModule {
|
2480
|
2492
|
}
|
2481
|
2493
|
}
|
2482
|
2494
|
|
|
2495
|
+// deprecated
|
|
2496
|
+// @ReactMethod
|
|
2497
|
+// public void setVideoQualityParameters(boolean quality, Promise promise) {
|
|
2498
|
+// try {
|
|
2499
|
+// int res = AgoraManager.getInstance().mRtcEngine.setVideoQualityParameters(quality);
|
|
2500
|
+// if (res != 0) throw new ReactNativeAgoraException("sendStreamMessage Failed", res);
|
|
2501
|
+// WritableMap map = Arguments.createMap();
|
|
2502
|
+// map.putBoolean("success", true);
|
|
2503
|
+// map.putInt("value", res);
|
|
2504
|
+// promise.resolve(map);
|
|
2505
|
+// } catch (Exception e) {
|
|
2506
|
+// promise.reject(e);
|
|
2507
|
+// }
|
|
2508
|
+// }
|
|
2509
|
+
|
2483
|
2510
|
@ReactMethod
|
2484
|
|
- public void setVideoQualityParameters(boolean quality, Promise promise) {
|
|
2511
|
+ public void setLocalVideoMirrorMode(int mode, Promise promise) {
|
2485
|
2512
|
try {
|
2486
|
|
- int res = AgoraManager.getInstance().mRtcEngine.setVideoQualityParameters(quality);
|
2487
|
|
- if (res != 0) throw new ReactNativeAgoraException("sendStreamMessage Failed", res);
|
|
2513
|
+ int res = AgoraManager.getInstance().mRtcEngine.setLocalVideoMirrorMode(mode);
|
|
2514
|
+ if (res != 0) throw new ReactNativeAgoraException("setLocalVideoMirrorMode Failed", res);
|
2488
|
2515
|
WritableMap map = Arguments.createMap();
|
2489
|
2516
|
map.putBoolean("success", true);
|
2490
|
|
- map.putInt("value", res);
|
2491
|
2517
|
promise.resolve(map);
|
2492
|
2518
|
} catch (Exception e) {
|
2493
|
2519
|
promise.reject(e);
|
|
@@ -2495,10 +2521,67 @@ public class AgoraModule extends ReactContextBaseJavaModule {
|
2495
|
2521
|
}
|
2496
|
2522
|
|
2497
|
2523
|
@ReactMethod
|
2498
|
|
- public void setLocalVideoMirrorMode(int mode, Promise promise) {
|
|
2524
|
+ public void setBeautyEffectOptions(boolean enabled, ReadableMap options, Promise promise) {
|
2499
|
2525
|
try {
|
2500
|
|
- int res = AgoraManager.getInstance().mRtcEngine.setLocalVideoMirrorMode(mode);
|
2501
|
|
- if (res != 0) throw new ReactNativeAgoraException("setLocalVideoMirrorMode Failed", res);
|
|
2526
|
+ BeautyOptions beautyOption = new BeautyOptions();
|
|
2527
|
+ beautyOption.lighteningContrastLevel = options.getInt("lighteningContrastLevel");
|
|
2528
|
+ beautyOption.lighteningLevel = (float) options.getDouble("lighteningLevel");
|
|
2529
|
+ beautyOption.smoothnessLevel = (float) options.getDouble("smoothnessLevel");
|
|
2530
|
+ beautyOption.rednessLevel = (float) options.getDouble("rednessLevel");
|
|
2531
|
+ int res = AgoraManager.getInstance().mRtcEngine.setBeautyEffectOptions(true, beautyOption);
|
|
2532
|
+ if (res != 0) throw new ReactNativeAgoraException("setBeautyEffectOptions Failed", res);
|
|
2533
|
+ WritableMap map = Arguments.createMap();
|
|
2534
|
+ map.putBoolean("success", true);
|
|
2535
|
+ promise.resolve(map);
|
|
2536
|
+ } catch (Exception e) {
|
|
2537
|
+ promise.reject(e);
|
|
2538
|
+ }
|
|
2539
|
+ }
|
|
2540
|
+
|
|
2541
|
+ @ReactMethod
|
|
2542
|
+ public void setLocalVoiceChanger(int voiceChanger, Promise promise) {
|
|
2543
|
+ try {
|
|
2544
|
+ int res = AgoraManager.getInstance().mRtcEngine.setLocalVoiceChanger(voiceChanger);
|
|
2545
|
+ if (res != 0) throw new ReactNativeAgoraException("setLocalVoiceChanger Failed", res);
|
|
2546
|
+ WritableMap map = Arguments.createMap();
|
|
2547
|
+ map.putBoolean("success", true);
|
|
2548
|
+ promise.resolve(map);
|
|
2549
|
+ } catch (Exception e) {
|
|
2550
|
+ promise.reject(e);
|
|
2551
|
+ }
|
|
2552
|
+ }
|
|
2553
|
+
|
|
2554
|
+ @ReactMethod
|
|
2555
|
+ public void setLocalVoiceReverbPreset(int preset, Promise promise) {
|
|
2556
|
+ try {
|
|
2557
|
+ int res = AgoraManager.getInstance().mRtcEngine.setLocalVoiceReverbPreset(preset);
|
|
2558
|
+ if (res != 0) throw new ReactNativeAgoraException("setLocalVoiceReverbPreset Failed", res);
|
|
2559
|
+ WritableMap map = Arguments.createMap();
|
|
2560
|
+ map.putBoolean("success", true);
|
|
2561
|
+ promise.resolve(map);
|
|
2562
|
+ } catch (Exception e) {
|
|
2563
|
+ promise.reject(e);
|
|
2564
|
+ }
|
|
2565
|
+ }
|
|
2566
|
+
|
|
2567
|
+ @ReactMethod
|
|
2568
|
+ public void enableSoundPositionIndication(boolean enabled, Promise promise) {
|
|
2569
|
+ try {
|
|
2570
|
+ int res = AgoraManager.getInstance().mRtcEngine.enableSoundPositionIndication(enabled);
|
|
2571
|
+ if (res != 0) throw new ReactNativeAgoraException("enableSoundPositionIndication Failed", res);
|
|
2572
|
+ WritableMap map = Arguments.createMap();
|
|
2573
|
+ map.putBoolean("success", true);
|
|
2574
|
+ promise.resolve(map);
|
|
2575
|
+ } catch (Exception e) {
|
|
2576
|
+ promise.reject(e);
|
|
2577
|
+ }
|
|
2578
|
+ }
|
|
2579
|
+
|
|
2580
|
+ @ReactMethod
|
|
2581
|
+ public void setRemoteVoicePosition(int uid, int pan, int gain, Promise promise) {
|
|
2582
|
+ try {
|
|
2583
|
+ int res = AgoraManager.getInstance().mRtcEngine.setRemoteVoicePosition(uid, pan, gain);
|
|
2584
|
+ if (res != 0) throw new ReactNativeAgoraException("setRemoteVoicePosition Failed", res);
|
2502
|
2585
|
WritableMap map = Arguments.createMap();
|
2503
|
2586
|
map.putBoolean("success", true);
|
2504
|
2587
|
promise.resolve(map);
|
|
@@ -2507,6 +2590,97 @@ public class AgoraModule extends ReactContextBaseJavaModule {
|
2507
|
2590
|
}
|
2508
|
2591
|
}
|
2509
|
2592
|
|
|
2593
|
+ @ReactMethod
|
|
2594
|
+ public void startLastmileProbeTest(ReadableMap config, Promise promise) {
|
|
2595
|
+ try {
|
|
2596
|
+ LastmileProbeConfig probeConfig = new LastmileProbeConfig();
|
|
2597
|
+ probeConfig.probeUplink = config.getBoolean("probeUplink");
|
|
2598
|
+ probeConfig.probeDownlink = config.getBoolean("probeDownlink");
|
|
2599
|
+ probeConfig.expectedDownlinkBitrate = config.getInt("expectedDownlinkBitrate");
|
|
2600
|
+ probeConfig.expectedUplinkBitrate = config.getInt("expectedUplinkBitrate");
|
|
2601
|
+ int res = AgoraManager.getInstance().mRtcEngine.startLastmileProbeTest(probeConfig);
|
|
2602
|
+ if (res != 0) throw new ReactNativeAgoraException("startLastmileProbeTest Failed", res);
|
|
2603
|
+ WritableMap map = Arguments.createMap();
|
|
2604
|
+ map.putBoolean("success", true);
|
|
2605
|
+ promise.resolve(map);
|
|
2606
|
+ } catch (Exception e) {
|
|
2607
|
+ promise.reject(e);
|
|
2608
|
+ }
|
|
2609
|
+ }
|
|
2610
|
+
|
|
2611
|
+ @ReactMethod
|
|
2612
|
+ public void stopLastmileProbeTest(Promise promise) {
|
|
2613
|
+ try {
|
|
2614
|
+ int res = AgoraManager.getInstance().mRtcEngine.stopLastmileProbeTest();
|
|
2615
|
+ if (res != 0) throw new ReactNativeAgoraException("stopLastmileProbeTest Failed", res);
|
|
2616
|
+ WritableMap map = Arguments.createMap();
|
|
2617
|
+ map.putBoolean("success", true);
|
|
2618
|
+ promise.resolve(map);
|
|
2619
|
+ } catch (Exception e) {
|
|
2620
|
+ promise.reject(e);
|
|
2621
|
+ }
|
|
2622
|
+ }
|
|
2623
|
+
|
|
2624
|
+ @ReactMethod
|
|
2625
|
+ public void setRemoteUserPriority(int uid, int userPrority, Promise promise) {
|
|
2626
|
+ try {
|
|
2627
|
+ int res = AgoraManager.getInstance().mRtcEngine.setRemoteUserPriority(uid, userPrority);
|
|
2628
|
+ if (res != 0) throw new ReactNativeAgoraException("setRemoteUserPriority Failed", res);
|
|
2629
|
+ WritableMap map = Arguments.createMap();
|
|
2630
|
+ map.putBoolean("success", true);
|
|
2631
|
+ promise.resolve(map);
|
|
2632
|
+ } catch (Exception e) {
|
|
2633
|
+ promise.reject(e);
|
|
2634
|
+ }
|
|
2635
|
+ }
|
|
2636
|
+
|
|
2637
|
+ @ReactMethod
|
|
2638
|
+ public void startEchoTestWithInterval(int interval, Promise promise) {
|
|
2639
|
+ try {
|
|
2640
|
+ int res = AgoraManager.getInstance().mRtcEngine.startEchoTest(interval);
|
|
2641
|
+ if (res != 0) throw new ReactNativeAgoraException("startEchoTestWithInterval Failed", res);
|
|
2642
|
+ WritableMap map = Arguments.createMap();
|
|
2643
|
+ map.putBoolean("success", true);
|
|
2644
|
+ promise.resolve(map);
|
|
2645
|
+ } catch (Exception e) {
|
|
2646
|
+ promise.reject(e);
|
|
2647
|
+ }
|
|
2648
|
+ }
|
|
2649
|
+
|
|
2650
|
+ @ReactMethod
|
|
2651
|
+ public void setCameraCapturerConfiguration(ReadableMap options, Promise promise) {
|
|
2652
|
+ try {
|
|
2653
|
+ CameraCapturerConfiguration.CAPTURER_OUTPUT_PREFERENCE preference = CameraCapturerConfiguration.CAPTURER_OUTPUT_PREFERENCE.CAPTURER_OUTPUT_PREFERENCE_AUTO;
|
|
2654
|
+ switch (options.getInt("preference")) {
|
|
2655
|
+ case 0: {
|
|
2656
|
+ preference = CameraCapturerConfiguration.CAPTURER_OUTPUT_PREFERENCE.CAPTURER_OUTPUT_PREFERENCE_AUTO;
|
|
2657
|
+ break;
|
|
2658
|
+ }
|
|
2659
|
+ case 1: {
|
|
2660
|
+ preference = CameraCapturerConfiguration.CAPTURER_OUTPUT_PREFERENCE.CAPTURER_OUTPUT_PREFERENCE_PERFORMANCE;
|
|
2661
|
+ break;
|
|
2662
|
+ }
|
|
2663
|
+ case 2: {
|
|
2664
|
+ preference = CameraCapturerConfiguration.CAPTURER_OUTPUT_PREFERENCE.CAPTURER_OUTPUT_PREFERENCE_PREVIEW;
|
|
2665
|
+ break;
|
|
2666
|
+ }
|
|
2667
|
+ }
|
|
2668
|
+ CameraCapturerConfiguration config = new CameraCapturerConfiguration(preference);
|
|
2669
|
+
|
|
2670
|
+ int res = AgoraManager.getInstance().mRtcEngine.setCameraCapturerConfiguration(config);
|
|
2671
|
+ if (res != 0) throw new ReactNativeAgoraException("setCameraCapturerConfiguration Failed", res);
|
|
2672
|
+ WritableMap map = Arguments.createMap();
|
|
2673
|
+ map.putBoolean("success", true);
|
|
2674
|
+ promise.resolve(map);
|
|
2675
|
+ } catch (Exception e) {
|
|
2676
|
+ promise.reject(e);
|
|
2677
|
+ }
|
|
2678
|
+ }
|
|
2679
|
+
|
|
2680
|
+
|
|
2681
|
+
|
|
2682
|
+ @ReactMethod
|
|
2683
|
+
|
2510
|
2684
|
private void sendEvent(ReactContext reactContext,
|
2511
|
2685
|
String eventName,
|
2512
|
2686
|
@Nullable WritableMap params) {
|