Revert "Revert "Enables PeerConnectionFactory using external fec controller""

This reverts commit 00733015fafbbc61ddc12dfdc88b21a9fcd9d122.

Reason for revert: The reason for a downstream test failure on the original commit and a workaround has been found. Solution is to keep a PeerConnectionFactory constructor implementation as the same as before.

Original change's description:
> Revert "Enables PeerConnectionFactory using external fec controller"
>
> This reverts commit 4f07bdb25567d8ef528311e0b50a62c61d543fc3.
>
> Reason for revert: Speculatively reverting, because downstream test is now hitting "PeerConnectionFactory.initialize was not called before creating a PeerConnectionFactory" error, even though it did call initialize. I don't see how any change in this CL could cause that, but it's the only CL on the blamelist, and it does modify PeerConnectionFactory.java
>
> Original change's description:
> > 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}
>
> TBR=sakal@webrtc.org,kwiberg@webrtc.org,nisse@webrtc.org,stefan@webrtc.org,yinwa@webrtc.org
>
> Change-Id: I95868c35d6f9973e0ebf563814cd71d0fcbd433d
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: webrtc:8799
> Reviewed-on: https://webrtc-review.googlesource.com/54080
> Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
> Commit-Queue: Taylor Brandstetter <deadbeef@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#22040}

TBR=deadbeef@webrtc.org,sakal@webrtc.org,kwiberg@webrtc.org,nisse@webrtc.org,stefan@webrtc.org,yinwa@webrtc.org

Bug: webrtc:8799
Change-Id: If9f3292bfcc739782967530c49f006d0abbc38a8
Reviewed-on: https://webrtc-review.googlesource.com/55400
Commit-Queue: Ying Wang <yinwa@webrtc.org>
Reviewed-by: Ying Wang <yinwa@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#22100}
This commit is contained in:
Ying Wang
2018-02-20 12:50:27 +01:00
committed by Commit Bot
parent 439f0bc69a
commit 0dd1b0a4b2
24 changed files with 314 additions and 97 deletions

View File

@ -0,0 +1,22 @@
/*
* Copyright 2018 The WebRTC project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
package org.webrtc;
/**
* Factory for creating webrtc::FecControllerFactory instances.
*/
public interface FecControllerFactoryFactoryInterface {
/**
* Dynamically allocates a webrtc::FecControllerFactory instance and returns a pointer to it.
* The caller takes ownership of the object.
*/
public long createNative();
}

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,36 @@ 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);
nativeFactory =
nativeCreatePeerConnectionFactory(options, encoderFactory, decoderFactory, 0, 0);
if (nativeFactory == 0) {
throw new RuntimeException("Failed to initialize PeerConnectionFactory!");
}
}
@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 +462,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);