diff --git a/sdk/android/api/org/webrtc/PeerConnectionFactory.java b/sdk/android/api/org/webrtc/PeerConnectionFactory.java index acf3a71382..8dd2429832 100644 --- a/sdk/android/api/org/webrtc/PeerConnectionFactory.java +++ b/sdk/android/api/org/webrtc/PeerConnectionFactory.java @@ -29,7 +29,6 @@ public class PeerConnectionFactory { private static final String VIDEO_CAPTURER_THREAD_NAME = "VideoCapturerThread"; private final long nativeFactory; - private static boolean enableVideoHwAcceleration; private static volatile boolean internalTracerInitialized = false; @Nullable private static Thread networkThread; @Nullable private static Thread workerThread; @@ -39,20 +38,18 @@ public class PeerConnectionFactory { final Context applicationContext; final String fieldTrials; final boolean enableInternalTracer; - final boolean enableVideoHwAcceleration; final NativeLibraryLoader nativeLibraryLoader; final String nativeLibraryName; @Nullable Loggable loggable; @Nullable Severity loggableSeverity; private InitializationOptions(Context applicationContext, String fieldTrials, - boolean enableInternalTracer, boolean enableVideoHwAcceleration, - NativeLibraryLoader nativeLibraryLoader, String nativeLibraryName, - @Nullable Loggable loggable, @Nullable Severity loggableSeverity) { + boolean enableInternalTracer, NativeLibraryLoader nativeLibraryLoader, + String nativeLibraryName, @Nullable Loggable loggable, + @Nullable Severity loggableSeverity) { this.applicationContext = applicationContext; this.fieldTrials = fieldTrials; this.enableInternalTracer = enableInternalTracer; - this.enableVideoHwAcceleration = enableVideoHwAcceleration; this.nativeLibraryLoader = nativeLibraryLoader; this.nativeLibraryName = nativeLibraryName; this.loggable = loggable; @@ -67,7 +64,6 @@ public class PeerConnectionFactory { private final Context applicationContext; private String fieldTrials = ""; private boolean enableInternalTracer = false; - private boolean enableVideoHwAcceleration = true; private NativeLibraryLoader nativeLibraryLoader = new NativeLibrary.DefaultLoader(); private String nativeLibraryName = "jingle_peerconnection_so"; @Nullable private Loggable loggable = null; @@ -87,13 +83,6 @@ public class PeerConnectionFactory { return this; } - // Deprecated, this method only affects the deprecated HW codecs and not the new ones. - @Deprecated - public Builder setEnableVideoHwAcceleration(boolean enableVideoHwAcceleration) { - this.enableVideoHwAcceleration = enableVideoHwAcceleration; - return this; - } - public Builder setNativeLibraryLoader(NativeLibraryLoader nativeLibraryLoader) { this.nativeLibraryLoader = nativeLibraryLoader; return this; @@ -112,8 +101,8 @@ public class PeerConnectionFactory { public PeerConnectionFactory.InitializationOptions createInitializationOptions() { return new PeerConnectionFactory.InitializationOptions(applicationContext, fieldTrials, - enableInternalTracer, enableVideoHwAcceleration, nativeLibraryLoader, nativeLibraryName, - loggable, loggableSeverity); + enableInternalTracer, nativeLibraryLoader, nativeLibraryName, loggable, + loggableSeverity); } } } @@ -208,22 +197,6 @@ public class PeerConnectionFactory { } public PeerConnectionFactory createPeerConnectionFactory() { - VideoEncoderFactory encoderFactory = this.encoderFactory; - VideoDecoderFactory decoderFactory = this.decoderFactory; - // For legacy reasons, we provide implicit built-in codec factories. - // TODO(bugs.webrtc.org/9181): Remove code below. All codec factories should be injected - // explicitly. - if (encoderFactory == null && decoderFactory == null && !enableVideoHwAcceleration) { - encoderFactory = new SoftwareVideoEncoderFactory(); - decoderFactory = new SoftwareVideoDecoderFactory(); - } else { - if (encoderFactory == null) { - encoderFactory = MediaCodecVideoEncoder.createFactory(); - } - if (decoderFactory == null) { - decoderFactory = MediaCodecVideoDecoder.createFactory(); - } - } return new PeerConnectionFactory(options, audioDeviceModule, encoderFactory, decoderFactory, audioProcessingFactory, fecControllerFactoryFactory); } @@ -241,7 +214,6 @@ public class PeerConnectionFactory { public static void initialize(InitializationOptions options) { ContextUtils.initialize(options.applicationContext); NativeLibrary.initialize(options.nativeLibraryLoader, options.nativeLibraryName); - enableVideoHwAcceleration = options.enableVideoHwAcceleration; nativeInitializeAndroidGlobals(); nativeInitializeFieldTrials(options.fieldTrials); if (options.enableInternalTracer && !internalTracerInitialized) { @@ -424,22 +396,6 @@ public class PeerConnectionFactory { nativeStopAecDump(nativeFactory); } - /** - * Set the EGL context used by HW Video encoding and decoding. - * - * @param localEglContext Must be the same as used by VideoCapturerAndroid and any local video - * renderer. - * @param remoteEglContext Must be the same as used by any remote video renderer. - * @deprecated Use new HW video encoded/decoder instead, and use createVideoSource(boolean - * isScreencast) instead of createVideoSource(VideoCapturer). - */ - @Deprecated - public void setVideoHwAccelerationOptions( - EglBase.Context localEglContext, EglBase.Context remoteEglContext) { - MediaCodecVideoEncoder.setEglContext(localEglContext); - MediaCodecVideoDecoder.setEglContext(remoteEglContext); - } - public void dispose() { nativeFreeFactory(nativeFactory); networkThread = null; diff --git a/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionTest.java b/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionTest.java index d186979467..863bca757a 100644 --- a/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionTest.java +++ b/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionTest.java @@ -671,8 +671,11 @@ public class PeerConnectionTest { // have those. PeerConnectionFactory.Options options = new PeerConnectionFactory.Options(); options.networkIgnoreMask = 0; - PeerConnectionFactory factory = - PeerConnectionFactory.builder().setOptions(options).createPeerConnectionFactory(); + PeerConnectionFactory factory = PeerConnectionFactory.builder() + .setOptions(options) + .setVideoEncoderFactory(new SoftwareVideoEncoderFactory()) + .setVideoDecoderFactory(new SoftwareVideoDecoderFactory()) + .createPeerConnectionFactory(); List iceServers = new ArrayList<>(); iceServers.add( @@ -1076,8 +1079,11 @@ public class PeerConnectionTest { // have those. PeerConnectionFactory.Options options = new PeerConnectionFactory.Options(); options.networkIgnoreMask = 0; - PeerConnectionFactory factory = - PeerConnectionFactory.builder().setOptions(options).createPeerConnectionFactory(); + PeerConnectionFactory factory = PeerConnectionFactory.builder() + .setOptions(options) + .setVideoEncoderFactory(new SoftwareVideoEncoderFactory()) + .setVideoDecoderFactory(new SoftwareVideoDecoderFactory()) + .createPeerConnectionFactory(); List iceServers = new ArrayList<>(); iceServers.add( @@ -1275,7 +1281,10 @@ public class PeerConnectionTest { @Test @MediumTest public void testRemoteStreamUpdatedWhenTracksAddedOrRemoved() throws Exception { - PeerConnectionFactory factory = PeerConnectionFactory.builder().createPeerConnectionFactory(); + PeerConnectionFactory factory = PeerConnectionFactory.builder() + .setVideoEncoderFactory(new SoftwareVideoEncoderFactory()) + .setVideoDecoderFactory(new SoftwareVideoDecoderFactory()) + .createPeerConnectionFactory(); // This test is fine with no ICE servers. List iceServers = new ArrayList<>(); diff --git a/sdk/android/src/jni/pc/video.cc b/sdk/android/src/jni/pc/video.cc index cb1307a367..dd10fd51cb 100644 --- a/sdk/android/src/jni/pc/video.cc +++ b/sdk/android/src/jni/pc/video.cc @@ -16,8 +16,8 @@ #include "api/video_codecs/video_decoder_factory.h" #include "api/video_codecs/video_encoder_factory.h" #include "api/videosourceproxy.h" -#include "media/engine/convert_legacy_video_factory.h" #include "rtc_base/logging.h" +#include "sdk/android/native_api/jni/java_types.h" #include "sdk/android/src/jni/androidvideotracksource.h" #include "sdk/android/src/jni/videodecoderfactorywrapper.h" #include "sdk/android/src/jni/videoencoderfactorywrapper.h" @@ -28,13 +28,17 @@ namespace jni { VideoEncoderFactory* CreateVideoEncoderFactory( JNIEnv* jni, const JavaRef& j_encoder_factory) { - return new VideoEncoderFactoryWrapper(jni, j_encoder_factory); + return IsNull(jni, j_encoder_factory) + ? nullptr + : new VideoEncoderFactoryWrapper(jni, j_encoder_factory); } VideoDecoderFactory* CreateVideoDecoderFactory( JNIEnv* jni, const JavaRef& j_decoder_factory) { - return new VideoDecoderFactoryWrapper(jni, j_decoder_factory); + return IsNull(jni, j_decoder_factory) + ? nullptr + : new VideoDecoderFactoryWrapper(jni, j_decoder_factory); } void* CreateVideoSource(JNIEnv* env,