Android: Transform legacy codec factories into VideoCodecFactories
We want to have an easy migration path away from MediaCodecVideoEncoder and MediaCodecVideoDecoder and remove the special treatment of these in our JNI code. This CL transforms these video codecs into proper VideoCodecFactories that can be injected in the PeerConnectionFactory like any other external factory. To summarize, this CL: * Provides a trivial migration path for external clients. * Removes special treatment of the legacy factories in our JNI code. Bug: webrtc:7925 Change-Id: I7ee8a6b0ce5ac0f3dc9c06d1587b8a9e52e0b684 Reviewed-on: https://webrtc-review.googlesource.com/88442 Commit-Queue: Magnus Jedvert <magjed@webrtc.org> Reviewed-by: Sami Kalliomäki <sakal@webrtc.org> Cr-Commit-Position: refs/heads/master@{#23972}
This commit is contained in:
committed by
Commit Bot
parent
dfbced6504
commit
e26ff4b581
@ -29,6 +29,7 @@ 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;
|
||||
@ -201,6 +202,22 @@ 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);
|
||||
}
|
||||
@ -218,7 +235,8 @@ public class PeerConnectionFactory {
|
||||
public static void initialize(InitializationOptions options) {
|
||||
ContextUtils.initialize(options.applicationContext);
|
||||
NativeLibrary.initialize(options.nativeLibraryLoader, options.nativeLibraryName);
|
||||
nativeInitializeAndroidGlobals(options.enableVideoHwAcceleration);
|
||||
enableVideoHwAcceleration = options.enableVideoHwAcceleration;
|
||||
nativeInitializeAndroidGlobals();
|
||||
nativeInitializeFieldTrials(options.fieldTrials);
|
||||
if (options.enableInternalTracer && !internalTracerInitialized) {
|
||||
initializeInternalTracer();
|
||||
@ -476,7 +494,7 @@ public class PeerConnectionFactory {
|
||||
|
||||
// Must be called at least once before creating a PeerConnectionFactory
|
||||
// (for example, at application startup time).
|
||||
private static native void nativeInitializeAndroidGlobals(boolean videoHwAcceleration);
|
||||
private static native void nativeInitializeAndroidGlobals();
|
||||
private static native void nativeInitializeFieldTrials(String fieldTrialsInitString);
|
||||
private static native String nativeFindFieldTrialsFullName(String name);
|
||||
private static native void nativeInitializeInternalTracer();
|
||||
|
||||
Reference in New Issue
Block a user