Enables PeerConnectionFactory using external fec controller

Bug: webrtc:8799
Change-Id: Ieb2cf6163b9a83844ab9ed4822b4a7f1db4c24b8
Reviewed-on: https://webrtc-review.googlesource.com/43961
Commit-Queue: Ying Wang <yinwa@webrtc.org>
Reviewed-by: Stefan Holmer <stefan@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22038}
This commit is contained in:
Ying Wang
2018-02-15 17:06:32 +01:00
committed by Commit Bot
parent 5af97ee3ad
commit 4f07bdb255
24 changed files with 313 additions and 101 deletions

View File

@ -124,6 +124,55 @@ public class PeerConnectionFactory {
}
}
public static class Builder {
private Options options;
private VideoEncoderFactory encoderFactory;
private VideoDecoderFactory decoderFactory;
private AudioProcessingFactory audioProcessingFactory;
private FecControllerFactoryFactoryInterface fecControllerFactoryFactory;
private Builder() {}
public Builder setOptions(Options options) {
this.options = options;
return this;
}
public Builder setVideoEncoderFactory(VideoEncoderFactory encoderFactory) {
this.encoderFactory = encoderFactory;
return this;
}
public Builder setVideoDecoderFactory(VideoDecoderFactory decoderFactory) {
this.decoderFactory = decoderFactory;
return this;
}
public Builder setAudioProcessingFactory(AudioProcessingFactory audioProcessingFactory) {
if (audioProcessingFactory == null) {
throw new NullPointerException(
"PeerConnectionFactory builder does not accept a null AudioProcessingFactory.");
}
this.audioProcessingFactory = audioProcessingFactory;
return this;
}
public Builder setFecControllerFactoryFactoryInterface(
FecControllerFactoryFactoryInterface fecControllerFactoryFactory) {
this.fecControllerFactoryFactory = fecControllerFactoryFactory;
return this;
}
public PeerConnectionFactory createPeerConnectionFactory() {
return new PeerConnectionFactory(options, encoderFactory, decoderFactory,
audioProcessingFactory, fecControllerFactoryFactory);
}
}
public static Builder builder() {
return new Builder();
}
/**
* Loads and initializes WebRTC. This must be called at least once before creating a
* PeerConnectionFactory. Replaces all the old initialization methods. Must not be called while
@ -191,28 +240,32 @@ public class PeerConnectionFactory {
// Note: initializeAndroidGlobals must be called at least once before
// constructing a PeerConnectionFactory.
@Deprecated
public PeerConnectionFactory(Options options) {
this(options, null /* encoderFactory */, null /* decoderFactory */);
}
@Deprecated
public PeerConnectionFactory(
Options options, VideoEncoderFactory encoderFactory, VideoDecoderFactory decoderFactory) {
checkInitializeHasBeenCalled();
nativeFactory = nativeCreatePeerConnectionFactory(options, encoderFactory, decoderFactory);
if (nativeFactory == 0) {
throw new RuntimeException("Failed to initialize PeerConnectionFactory!");
}
this(options, encoderFactory, decoderFactory, null /* audioProcessingFactory */,
null /* fecControllerFactoryFactory */);
}
@Deprecated
public PeerConnectionFactory(Options options, VideoEncoderFactory encoderFactory,
VideoDecoderFactory decoderFactory, AudioProcessingFactory audioProcessingFactory) {
this(options, encoderFactory, decoderFactory, audioProcessingFactory,
null /* fecControllerFactoryFactory */);
}
private PeerConnectionFactory(Options options, VideoEncoderFactory encoderFactory,
VideoDecoderFactory decoderFactory, AudioProcessingFactory audioProcessingFactory,
FecControllerFactoryFactoryInterface fecControllerFactoryFactory) {
checkInitializeHasBeenCalled();
if (audioProcessingFactory == null) {
throw new NullPointerException(
"PeerConnectionFactory constructor does not accept a null AudioProcessingFactory.");
}
nativeFactory = nativeCreatePeerConnectionFactoryWithAudioProcessing(
options, encoderFactory, decoderFactory, audioProcessingFactory.createNative());
nativeFactory = nativeCreatePeerConnectionFactory(options, encoderFactory, decoderFactory,
audioProcessingFactory == null ? 0 : audioProcessingFactory.createNative(),
fecControllerFactoryFactory == null ? 0 : fecControllerFactoryFactory.createNative());
if (nativeFactory == 0) {
throw new RuntimeException("Failed to initialize PeerConnectionFactory!");
}
@ -405,11 +458,9 @@ public class PeerConnectionFactory {
private static native void nativeShutdownInternalTracer();
private static native boolean nativeStartInternalTracingCapture(String tracingFilename);
private static native void nativeStopInternalTracingCapture();
private static native long nativeCreatePeerConnectionFactory(
Options options, VideoEncoderFactory encoderFactory, VideoDecoderFactory decoderFactory);
private static native long nativeCreatePeerConnectionFactoryWithAudioProcessing(Options options,
private static native long nativeCreatePeerConnectionFactory(Options options,
VideoEncoderFactory encoderFactory, VideoDecoderFactory decoderFactory,
long nativeAudioProcessor);
long nativeAudioProcessor, long nativeFecControllerFactory);
private static native long nativeCreatePeerConnection(long factory,
PeerConnection.RTCConfiguration rtcConfig, MediaConstraints constraints, long nativeObserver);
private static native long nativeCreateLocalMediaStream(long factory, String label);