Skip to content

Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.

android: custom initialization of the WebRTC module

Saúl Ibarra Corretgé49e3b03885bd
diff --git a/android/sdk/src/main/java/org/jitsi/meet/sdk/ReactInstanceManagerHolder.java b/android/sdk/src/main/java/org/jitsi/meet/sdk/ReactInstanceManagerHolder.java
index 736085d714..5fe1fcbf77 100644
--- a/android/sdk/src/main/java/org/jitsi/meet/sdk/ReactInstanceManagerHolder.java
+++ b/android/sdk/src/main/java/org/jitsi/meet/sdk/ReactInstanceManagerHolder.java
@@ -29,6 +29,17 @@ import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.common.LifecycleState;
import com.facebook.react.devsupport.DevInternalSettings;
import com.facebook.react.modules.core.DeviceEventManagerModule;
+import com.facebook.react.uimanager.ViewManager;
+import com.oney.WebRTCModule.RTCVideoViewManager;
+import com.oney.WebRTCModule.WebRTCModule;
+
+import org.webrtc.SoftwareVideoDecoderFactory;
+import org.webrtc.SoftwareVideoEncoderFactory;
+import org.webrtc.VideoDecoderFactory;
+import org.webrtc.VideoEncoderFactory;
+import org.webrtc.audio.AudioDeviceModule;
+import org.webrtc.audio.JavaAudioDeviceModule;
+import org.webrtc.voiceengine.WebRtcAudioManager;
import java.lang.reflect.Constructor;
import java.util.ArrayList;
@@ -47,8 +58,7 @@ class ReactInstanceManagerHolder {
*/
private static ReactInstanceManager reactInstanceManager;
- private static List<NativeModule> createNativeModules(
- ReactApplicationContext reactContext) {
+ private static List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
List<NativeModule> nativeModules
= new ArrayList<>(Arrays.<NativeModule>asList(
new AndroidSettingsModule(reactContext),
@@ -66,6 +76,21 @@ class ReactInstanceManagerHolder {
nativeModules.add(new RNConnectionService(reactContext));
}
+ // Initialize the WebRTC module by hand, since we want to override some
+ // initialization options.
+ WebRTCModule.Options options = new WebRTCModule.Options();
+
+ AudioDeviceModule adm = JavaAudioDeviceModule.builder(reactContext)
+ .createAudioDeviceModule();
+ VideoDecoderFactory videoDecoderFactory = new SoftwareVideoDecoderFactory();
+ VideoEncoderFactory videoEncoderFactory = new SoftwareVideoEncoderFactory();
+
+ options.setAudioDeviceModule(adm);
+ options.setVideoDecoderFactory(videoDecoderFactory);
+ options.setVideoEncoderFactory(videoEncoderFactory);
+
+ nativeModules.add(new WebRTCModule(reactContext, options));
+
try {
Class<?> amplitudeModuleClass = Class.forName("org.jitsi.meet.sdk.AmplitudeModule");
Constructor constructor = amplitudeModuleClass.getConstructor(ReactApplicationContext.class);
@@ -77,6 +102,13 @@ class ReactInstanceManagerHolder {
return nativeModules;
}
+ private static List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
+ return Arrays.<ViewManager>asList(
+ // WebRTC, see createNativeModules for details.
+ new RTCVideoViewManager()
+ );
+ }
+
/**
* Helper function to send an event to JavaScript.
*
@@ -158,7 +190,6 @@ class ReactInstanceManagerHolder {
new com.facebook.react.shell.MainReactPackage(),
new com.oblador.vectoricons.VectorIconsPackage(),
new com.ocetnik.timer.BackgroundTimerPackage(),
- new com.oney.WebRTCModule.WebRTCModulePackage(),
new com.reactnativecommunity.asyncstorage.AsyncStoragePackage(),
new com.reactnativecommunity.webview.RNCWebViewPackage(),
new com.rnimmersive.RNImmersivePackage(),
@@ -168,6 +199,10 @@ class ReactInstanceManagerHolder {
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
return ReactInstanceManagerHolder.createNativeModules(reactContext);
}
+ @Override
+ public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
+ return ReactInstanceManagerHolder.createViewManagers(reactContext);
+ }
}));
try {