android: custom initialization of the WebRTC module
Set our own audio device manager so we can tweak it if need be (enabling / disabling the HW AEC on specific devices). Switch to using the software video encoder / decoder. This may feel like a downgrade, but it has advantages: - simulcast is now working (on par with iOS) - certain devices have broken VP8 HW encoders (I'm looking at you Samsung Galaxy S7) so this fixes that
This commit is contained in:
parent
31e996ac3f
commit
49e3b03885
|
@ -29,6 +29,17 @@ import com.facebook.react.bridge.ReactApplicationContext;
|
||||||
import com.facebook.react.common.LifecycleState;
|
import com.facebook.react.common.LifecycleState;
|
||||||
import com.facebook.react.devsupport.DevInternalSettings;
|
import com.facebook.react.devsupport.DevInternalSettings;
|
||||||
import com.facebook.react.modules.core.DeviceEventManagerModule;
|
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.lang.reflect.Constructor;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -47,8 +58,7 @@ class ReactInstanceManagerHolder {
|
||||||
*/
|
*/
|
||||||
private static ReactInstanceManager reactInstanceManager;
|
private static ReactInstanceManager reactInstanceManager;
|
||||||
|
|
||||||
private static List<NativeModule> createNativeModules(
|
private static List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
||||||
ReactApplicationContext reactContext) {
|
|
||||||
List<NativeModule> nativeModules
|
List<NativeModule> nativeModules
|
||||||
= new ArrayList<>(Arrays.<NativeModule>asList(
|
= new ArrayList<>(Arrays.<NativeModule>asList(
|
||||||
new AndroidSettingsModule(reactContext),
|
new AndroidSettingsModule(reactContext),
|
||||||
|
@ -66,6 +76,21 @@ class ReactInstanceManagerHolder {
|
||||||
nativeModules.add(new RNConnectionService(reactContext));
|
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 {
|
try {
|
||||||
Class<?> amplitudeModuleClass = Class.forName("org.jitsi.meet.sdk.AmplitudeModule");
|
Class<?> amplitudeModuleClass = Class.forName("org.jitsi.meet.sdk.AmplitudeModule");
|
||||||
Constructor constructor = amplitudeModuleClass.getConstructor(ReactApplicationContext.class);
|
Constructor constructor = amplitudeModuleClass.getConstructor(ReactApplicationContext.class);
|
||||||
|
@ -77,6 +102,13 @@ class ReactInstanceManagerHolder {
|
||||||
return nativeModules;
|
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.
|
* Helper function to send an event to JavaScript.
|
||||||
*
|
*
|
||||||
|
@ -158,7 +190,6 @@ class ReactInstanceManagerHolder {
|
||||||
new com.facebook.react.shell.MainReactPackage(),
|
new com.facebook.react.shell.MainReactPackage(),
|
||||||
new com.oblador.vectoricons.VectorIconsPackage(),
|
new com.oblador.vectoricons.VectorIconsPackage(),
|
||||||
new com.ocetnik.timer.BackgroundTimerPackage(),
|
new com.ocetnik.timer.BackgroundTimerPackage(),
|
||||||
new com.oney.WebRTCModule.WebRTCModulePackage(),
|
|
||||||
new com.reactnativecommunity.asyncstorage.AsyncStoragePackage(),
|
new com.reactnativecommunity.asyncstorage.AsyncStoragePackage(),
|
||||||
new com.reactnativecommunity.webview.RNCWebViewPackage(),
|
new com.reactnativecommunity.webview.RNCWebViewPackage(),
|
||||||
new com.rnimmersive.RNImmersivePackage(),
|
new com.rnimmersive.RNImmersivePackage(),
|
||||||
|
@ -168,6 +199,10 @@ class ReactInstanceManagerHolder {
|
||||||
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
|
||||||
return ReactInstanceManagerHolder.createNativeModules(reactContext);
|
return ReactInstanceManagerHolder.createNativeModules(reactContext);
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public List<ViewManager> createViewManagers(ReactApplicationContext reactContext) {
|
||||||
|
return ReactInstanceManagerHolder.createViewManagers(reactContext);
|
||||||
|
}
|
||||||
}));
|
}));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
Loading…
Reference in New Issue