Android PeerConnectionFactory: Build without video codecs by default
This change was announced here:
https://groups.google.com/d/msgid/discuss-webrtc/f264646c-8b8f-4243-8748-d9e957d3186f%40googlegroups.com
Bug: webrtc:7925
Change-Id: I5b4e6e733128f2c498c8e4faa912a4ae1238764b
Reviewed-on: https://webrtc-review.googlesource.com/92384
Commit-Queue: Magnus Jedvert <magjed@webrtc.org>
Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#24410}diff --git a/sdk/android/api/org/webrtc/PeerConnectionFactory.java b/sdk/android/api/org/webrtc/PeerConnectionFactory.java
index acf3a71..8dd2429 100644
--- a/sdk/android/api/org/webrtc/PeerConnectionFactory.java
+++ b/sdk/android/api/org/webrtc/PeerConnectionFactory.java
@@ -29,7 +29,6 @@
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 @@
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 @@
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 @@
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 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 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 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 @@
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 d186979..863bca7 100644
--- a/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionTest.java
+++ b/sdk/android/instrumentationtests/src/org/webrtc/PeerConnectionTest.java
@@ -671,8 +671,11 @@
// 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<PeerConnection.IceServer> iceServers = new ArrayList<>();
iceServers.add(
@@ -1076,8 +1079,11 @@
// 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<PeerConnection.IceServer> iceServers = new ArrayList<>();
iceServers.add(
@@ -1275,7 +1281,10 @@
@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<PeerConnection.IceServer> iceServers = new ArrayList<>();
diff --git a/sdk/android/src/jni/pc/video.cc b/sdk/android/src/jni/pc/video.cc
index cb1307a..dd10fd5 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 @@
VideoEncoderFactory* CreateVideoEncoderFactory(
JNIEnv* jni,
const JavaRef<jobject>& 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<jobject>& 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,