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}
This commit is contained in:
committed by
Commit Bot
parent
9ae3c4016f
commit
40de15d9a6
@ -29,7 +29,6 @@ public class PeerConnectionFactory {
|
|||||||
private static final String VIDEO_CAPTURER_THREAD_NAME = "VideoCapturerThread";
|
private static final String VIDEO_CAPTURER_THREAD_NAME = "VideoCapturerThread";
|
||||||
|
|
||||||
private final long nativeFactory;
|
private final long nativeFactory;
|
||||||
private static boolean enableVideoHwAcceleration;
|
|
||||||
private static volatile boolean internalTracerInitialized = false;
|
private static volatile boolean internalTracerInitialized = false;
|
||||||
@Nullable private static Thread networkThread;
|
@Nullable private static Thread networkThread;
|
||||||
@Nullable private static Thread workerThread;
|
@Nullable private static Thread workerThread;
|
||||||
@ -39,20 +38,18 @@ public class PeerConnectionFactory {
|
|||||||
final Context applicationContext;
|
final Context applicationContext;
|
||||||
final String fieldTrials;
|
final String fieldTrials;
|
||||||
final boolean enableInternalTracer;
|
final boolean enableInternalTracer;
|
||||||
final boolean enableVideoHwAcceleration;
|
|
||||||
final NativeLibraryLoader nativeLibraryLoader;
|
final NativeLibraryLoader nativeLibraryLoader;
|
||||||
final String nativeLibraryName;
|
final String nativeLibraryName;
|
||||||
@Nullable Loggable loggable;
|
@Nullable Loggable loggable;
|
||||||
@Nullable Severity loggableSeverity;
|
@Nullable Severity loggableSeverity;
|
||||||
|
|
||||||
private InitializationOptions(Context applicationContext, String fieldTrials,
|
private InitializationOptions(Context applicationContext, String fieldTrials,
|
||||||
boolean enableInternalTracer, boolean enableVideoHwAcceleration,
|
boolean enableInternalTracer, NativeLibraryLoader nativeLibraryLoader,
|
||||||
NativeLibraryLoader nativeLibraryLoader, String nativeLibraryName,
|
String nativeLibraryName, @Nullable Loggable loggable,
|
||||||
@Nullable Loggable loggable, @Nullable Severity loggableSeverity) {
|
@Nullable Severity loggableSeverity) {
|
||||||
this.applicationContext = applicationContext;
|
this.applicationContext = applicationContext;
|
||||||
this.fieldTrials = fieldTrials;
|
this.fieldTrials = fieldTrials;
|
||||||
this.enableInternalTracer = enableInternalTracer;
|
this.enableInternalTracer = enableInternalTracer;
|
||||||
this.enableVideoHwAcceleration = enableVideoHwAcceleration;
|
|
||||||
this.nativeLibraryLoader = nativeLibraryLoader;
|
this.nativeLibraryLoader = nativeLibraryLoader;
|
||||||
this.nativeLibraryName = nativeLibraryName;
|
this.nativeLibraryName = nativeLibraryName;
|
||||||
this.loggable = loggable;
|
this.loggable = loggable;
|
||||||
@ -67,7 +64,6 @@ public class PeerConnectionFactory {
|
|||||||
private final Context applicationContext;
|
private final Context applicationContext;
|
||||||
private String fieldTrials = "";
|
private String fieldTrials = "";
|
||||||
private boolean enableInternalTracer = false;
|
private boolean enableInternalTracer = false;
|
||||||
private boolean enableVideoHwAcceleration = true;
|
|
||||||
private NativeLibraryLoader nativeLibraryLoader = new NativeLibrary.DefaultLoader();
|
private NativeLibraryLoader nativeLibraryLoader = new NativeLibrary.DefaultLoader();
|
||||||
private String nativeLibraryName = "jingle_peerconnection_so";
|
private String nativeLibraryName = "jingle_peerconnection_so";
|
||||||
@Nullable private Loggable loggable = null;
|
@Nullable private Loggable loggable = null;
|
||||||
@ -87,13 +83,6 @@ public class PeerConnectionFactory {
|
|||||||
return this;
|
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) {
|
public Builder setNativeLibraryLoader(NativeLibraryLoader nativeLibraryLoader) {
|
||||||
this.nativeLibraryLoader = nativeLibraryLoader;
|
this.nativeLibraryLoader = nativeLibraryLoader;
|
||||||
return this;
|
return this;
|
||||||
@ -112,8 +101,8 @@ public class PeerConnectionFactory {
|
|||||||
|
|
||||||
public PeerConnectionFactory.InitializationOptions createInitializationOptions() {
|
public PeerConnectionFactory.InitializationOptions createInitializationOptions() {
|
||||||
return new PeerConnectionFactory.InitializationOptions(applicationContext, fieldTrials,
|
return new PeerConnectionFactory.InitializationOptions(applicationContext, fieldTrials,
|
||||||
enableInternalTracer, enableVideoHwAcceleration, nativeLibraryLoader, nativeLibraryName,
|
enableInternalTracer, nativeLibraryLoader, nativeLibraryName, loggable,
|
||||||
loggable, loggableSeverity);
|
loggableSeverity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -208,22 +197,6 @@ public class PeerConnectionFactory {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public PeerConnectionFactory createPeerConnectionFactory() {
|
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,
|
return new PeerConnectionFactory(options, audioDeviceModule, encoderFactory, decoderFactory,
|
||||||
audioProcessingFactory, fecControllerFactoryFactory);
|
audioProcessingFactory, fecControllerFactoryFactory);
|
||||||
}
|
}
|
||||||
@ -241,7 +214,6 @@ public class PeerConnectionFactory {
|
|||||||
public static void initialize(InitializationOptions options) {
|
public static void initialize(InitializationOptions options) {
|
||||||
ContextUtils.initialize(options.applicationContext);
|
ContextUtils.initialize(options.applicationContext);
|
||||||
NativeLibrary.initialize(options.nativeLibraryLoader, options.nativeLibraryName);
|
NativeLibrary.initialize(options.nativeLibraryLoader, options.nativeLibraryName);
|
||||||
enableVideoHwAcceleration = options.enableVideoHwAcceleration;
|
|
||||||
nativeInitializeAndroidGlobals();
|
nativeInitializeAndroidGlobals();
|
||||||
nativeInitializeFieldTrials(options.fieldTrials);
|
nativeInitializeFieldTrials(options.fieldTrials);
|
||||||
if (options.enableInternalTracer && !internalTracerInitialized) {
|
if (options.enableInternalTracer && !internalTracerInitialized) {
|
||||||
@ -424,22 +396,6 @@ public class PeerConnectionFactory {
|
|||||||
nativeStopAecDump(nativeFactory);
|
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() {
|
public void dispose() {
|
||||||
nativeFreeFactory(nativeFactory);
|
nativeFreeFactory(nativeFactory);
|
||||||
networkThread = null;
|
networkThread = null;
|
||||||
|
|||||||
@ -671,8 +671,11 @@ public class PeerConnectionTest {
|
|||||||
// have those.
|
// have those.
|
||||||
PeerConnectionFactory.Options options = new PeerConnectionFactory.Options();
|
PeerConnectionFactory.Options options = new PeerConnectionFactory.Options();
|
||||||
options.networkIgnoreMask = 0;
|
options.networkIgnoreMask = 0;
|
||||||
PeerConnectionFactory factory =
|
PeerConnectionFactory factory = PeerConnectionFactory.builder()
|
||||||
PeerConnectionFactory.builder().setOptions(options).createPeerConnectionFactory();
|
.setOptions(options)
|
||||||
|
.setVideoEncoderFactory(new SoftwareVideoEncoderFactory())
|
||||||
|
.setVideoDecoderFactory(new SoftwareVideoDecoderFactory())
|
||||||
|
.createPeerConnectionFactory();
|
||||||
|
|
||||||
List<PeerConnection.IceServer> iceServers = new ArrayList<>();
|
List<PeerConnection.IceServer> iceServers = new ArrayList<>();
|
||||||
iceServers.add(
|
iceServers.add(
|
||||||
@ -1076,8 +1079,11 @@ public class PeerConnectionTest {
|
|||||||
// have those.
|
// have those.
|
||||||
PeerConnectionFactory.Options options = new PeerConnectionFactory.Options();
|
PeerConnectionFactory.Options options = new PeerConnectionFactory.Options();
|
||||||
options.networkIgnoreMask = 0;
|
options.networkIgnoreMask = 0;
|
||||||
PeerConnectionFactory factory =
|
PeerConnectionFactory factory = PeerConnectionFactory.builder()
|
||||||
PeerConnectionFactory.builder().setOptions(options).createPeerConnectionFactory();
|
.setOptions(options)
|
||||||
|
.setVideoEncoderFactory(new SoftwareVideoEncoderFactory())
|
||||||
|
.setVideoDecoderFactory(new SoftwareVideoDecoderFactory())
|
||||||
|
.createPeerConnectionFactory();
|
||||||
|
|
||||||
List<PeerConnection.IceServer> iceServers = new ArrayList<>();
|
List<PeerConnection.IceServer> iceServers = new ArrayList<>();
|
||||||
iceServers.add(
|
iceServers.add(
|
||||||
@ -1275,7 +1281,10 @@ public class PeerConnectionTest {
|
|||||||
@Test
|
@Test
|
||||||
@MediumTest
|
@MediumTest
|
||||||
public void testRemoteStreamUpdatedWhenTracksAddedOrRemoved() throws Exception {
|
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.
|
// This test is fine with no ICE servers.
|
||||||
List<PeerConnection.IceServer> iceServers = new ArrayList<>();
|
List<PeerConnection.IceServer> iceServers = new ArrayList<>();
|
||||||
|
|||||||
@ -16,8 +16,8 @@
|
|||||||
#include "api/video_codecs/video_decoder_factory.h"
|
#include "api/video_codecs/video_decoder_factory.h"
|
||||||
#include "api/video_codecs/video_encoder_factory.h"
|
#include "api/video_codecs/video_encoder_factory.h"
|
||||||
#include "api/videosourceproxy.h"
|
#include "api/videosourceproxy.h"
|
||||||
#include "media/engine/convert_legacy_video_factory.h"
|
|
||||||
#include "rtc_base/logging.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/androidvideotracksource.h"
|
||||||
#include "sdk/android/src/jni/videodecoderfactorywrapper.h"
|
#include "sdk/android/src/jni/videodecoderfactorywrapper.h"
|
||||||
#include "sdk/android/src/jni/videoencoderfactorywrapper.h"
|
#include "sdk/android/src/jni/videoencoderfactorywrapper.h"
|
||||||
@ -28,13 +28,17 @@ namespace jni {
|
|||||||
VideoEncoderFactory* CreateVideoEncoderFactory(
|
VideoEncoderFactory* CreateVideoEncoderFactory(
|
||||||
JNIEnv* jni,
|
JNIEnv* jni,
|
||||||
const JavaRef<jobject>& j_encoder_factory) {
|
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(
|
VideoDecoderFactory* CreateVideoDecoderFactory(
|
||||||
JNIEnv* jni,
|
JNIEnv* jni,
|
||||||
const JavaRef<jobject>& j_decoder_factory) {
|
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,
|
void* CreateVideoSource(JNIEnv* env,
|
||||||
|
|||||||
Reference in New Issue
Block a user