2013-07-10 00:45:36 +00:00
|
|
|
/*
|
2016-02-10 07:54:43 -08:00
|
|
|
* Copyright 2013 The WebRTC project authors. All Rights Reserved.
|
2013-07-10 00:45:36 +00:00
|
|
|
*
|
2016-02-10 07:54:43 -08:00
|
|
|
* 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.
|
2013-07-10 00:45:36 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
package org.webrtc;
|
|
|
|
|
|
2017-05-26 01:51:53 -07:00
|
|
|
import android.content.Context;
|
2013-07-10 00:45:36 +00:00
|
|
|
import java.util.List;
|
2018-03-22 13:32:44 +01:00
|
|
|
import javax.annotation.Nullable;
|
2018-04-04 17:16:03 +02:00
|
|
|
import org.webrtc.audio.AudioDeviceModule;
|
|
|
|
|
import org.webrtc.audio.LegacyAudioDeviceModule;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Java wrapper for a C++ PeerConnectionFactoryInterface. Main entry point to
|
|
|
|
|
* the PeerConnection API for clients.
|
|
|
|
|
*/
|
2017-12-20 15:12:10 +01:00
|
|
|
@JNINamespace("webrtc::jni")
|
2013-07-10 00:45:36 +00:00
|
|
|
public class PeerConnectionFactory {
|
2017-08-23 08:50:23 -07:00
|
|
|
public static final String TRIAL_ENABLED = "Enabled";
|
2018-01-26 11:06:45 +01:00
|
|
|
@Deprecated public static final String VIDEO_FRAME_EMIT_TRIAL = "VideoFrameEmit";
|
2017-08-23 08:50:23 -07:00
|
|
|
|
2015-10-07 14:50:13 -07:00
|
|
|
private static final String TAG = "PeerConnectionFactory";
|
2017-06-02 09:51:39 +02:00
|
|
|
private static final String VIDEO_CAPTURER_THREAD_NAME = "VideoCapturerThread";
|
2017-11-15 14:15:24 +01:00
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
private final long nativeFactory;
|
2017-11-15 14:15:24 +01:00
|
|
|
private static volatile boolean internalTracerInitialized = false;
|
2018-03-22 13:32:44 +01:00
|
|
|
@Nullable private static Thread networkThread;
|
|
|
|
|
@Nullable private static Thread workerThread;
|
|
|
|
|
@Nullable private static Thread signalingThread;
|
2016-02-15 06:28:36 -08:00
|
|
|
private EglBase localEglbase;
|
|
|
|
|
private EglBase remoteEglbase;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2017-09-29 12:49:46 +02:00
|
|
|
public static class InitializationOptions {
|
|
|
|
|
final Context applicationContext;
|
|
|
|
|
final String fieldTrials;
|
|
|
|
|
final boolean enableInternalTracer;
|
|
|
|
|
final boolean enableVideoHwAcceleration;
|
|
|
|
|
final NativeLibraryLoader nativeLibraryLoader;
|
|
|
|
|
|
|
|
|
|
private InitializationOptions(Context applicationContext, String fieldTrials,
|
|
|
|
|
boolean enableInternalTracer, boolean enableVideoHwAcceleration,
|
|
|
|
|
NativeLibraryLoader nativeLibraryLoader) {
|
|
|
|
|
this.applicationContext = applicationContext;
|
|
|
|
|
this.fieldTrials = fieldTrials;
|
|
|
|
|
this.enableInternalTracer = enableInternalTracer;
|
|
|
|
|
this.enableVideoHwAcceleration = enableVideoHwAcceleration;
|
|
|
|
|
this.nativeLibraryLoader = nativeLibraryLoader;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static Builder builder(Context applicationContext) {
|
|
|
|
|
return new Builder(applicationContext);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class Builder {
|
|
|
|
|
private final Context applicationContext;
|
|
|
|
|
private String fieldTrials = "";
|
2017-11-20 14:38:19 +01:00
|
|
|
private boolean enableInternalTracer = false;
|
2017-09-29 12:49:46 +02:00
|
|
|
private boolean enableVideoHwAcceleration = true;
|
|
|
|
|
private NativeLibraryLoader nativeLibraryLoader = new NativeLibrary.DefaultLoader();
|
|
|
|
|
|
|
|
|
|
Builder(Context applicationContext) {
|
|
|
|
|
this.applicationContext = applicationContext;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Builder setFieldTrials(String fieldTrials) {
|
|
|
|
|
this.fieldTrials = fieldTrials;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Builder setEnableInternalTracer(boolean enableInternalTracer) {
|
|
|
|
|
this.enableInternalTracer = enableInternalTracer;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Builder setEnableVideoHwAcceleration(boolean enableVideoHwAcceleration) {
|
|
|
|
|
this.enableVideoHwAcceleration = enableVideoHwAcceleration;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Builder setNativeLibraryLoader(NativeLibraryLoader nativeLibraryLoader) {
|
|
|
|
|
this.nativeLibraryLoader = nativeLibraryLoader;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public PeerConnectionFactory.InitializationOptions createInitializationOptions() {
|
|
|
|
|
return new PeerConnectionFactory.InitializationOptions(applicationContext, fieldTrials,
|
|
|
|
|
enableInternalTracer, enableVideoHwAcceleration, nativeLibraryLoader);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-02-24 13:41:51 +00:00
|
|
|
public static class Options {
|
2017-07-07 03:09:51 -07:00
|
|
|
// Keep in sync with webrtc/rtc_base/network.h!
|
2018-02-01 10:38:40 -08:00
|
|
|
//
|
|
|
|
|
// These bit fields are defined for |networkIgnoreMask| below.
|
Makes libjingle_peerconnection_android_unittest run on networkless devices.
PeerConnectionTest.java currently works, but only on a device with
network interfaces up. This is not a problem for desktop, but it is a
problem when running on Android devices since the devices in the lab
generally don't have network (due to the chaotic radio environment in
the device labs, devices are simply kept in flight mode).
The test does work if one modifies this line in the file
webrtc/base/network.cc:
bool ignored = ((cursor->ifa_flags & IFF_LOOPBACK) ||
IsIgnoredNetwork(*network));
If we remove the IFF_LOOPBACK clause, the test starts working on
an Android device in flight mode. This is nice - we're running the
call and packets interact with the OS network stack, which is good
for this end-to-end test. We can't just remove the clause though since
having loopback is undesirable for everyone except the test (right)?
so we need to make this behavior configurable.
This CL takes a stab at a complete solution where we pass a boolean
all the way through the Java PeerConnectionFactory down to the
BasicNetworkManager. This comes as a heavy price in interface
changes though. It's pretty out of proportion, but fundamentally we
need some way of telling the network manager that it is on Android
and in test mode. Passing the boolean all the way through is one way.
Another way might be to put the loopback filter behind an ifdef and
link a custom libjingle_peerconnection.so with the test. That is hacky
but doesn't pollute the interfaces. Not sure how to solve that in GYP
but it could mean some duplication between the production and
test .so files.
It would have been perfect to use flags here, but then we need to
hook up gflags parsing to some main() somewhere to make sure the
flag gets parsed, and make sure to pass that flag in our tests.
I'm not sure how that can be done.
Making the loopback filtering conditional is exactly how we solved the
equivalent problem in content_browsertests in Chrome, and it worked
great.
That's all I could think of.
BUG=4181
R=perkj@webrtc.org, pthatcher@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/36769004
Cr-Commit-Position: refs/heads/master@{#8344}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8344 4adac7df-926f-26a2-2b94-8c16560cd09d
2015-02-12 09:23:59 +00:00
|
|
|
static final int ADAPTER_TYPE_UNKNOWN = 0;
|
|
|
|
|
static final int ADAPTER_TYPE_ETHERNET = 1 << 0;
|
|
|
|
|
static final int ADAPTER_TYPE_WIFI = 1 << 1;
|
|
|
|
|
static final int ADAPTER_TYPE_CELLULAR = 1 << 2;
|
|
|
|
|
static final int ADAPTER_TYPE_VPN = 1 << 3;
|
|
|
|
|
static final int ADAPTER_TYPE_LOOPBACK = 1 << 4;
|
|
|
|
|
|
|
|
|
|
public int networkIgnoreMask;
|
2015-07-08 15:25:45 -07:00
|
|
|
public boolean disableEncryption;
|
2015-10-19 09:39:32 -07:00
|
|
|
public boolean disableNetworkMonitor;
|
2018-03-23 11:50:16 -07:00
|
|
|
public boolean enableAes128Sha1_32CryptoCipher;
|
2017-12-12 12:52:54 +01:00
|
|
|
|
|
|
|
|
@CalledByNative("Options")
|
|
|
|
|
int getNetworkIgnoreMask() {
|
|
|
|
|
return networkIgnoreMask;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@CalledByNative("Options")
|
|
|
|
|
boolean getDisableEncryption() {
|
|
|
|
|
return disableEncryption;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@CalledByNative("Options")
|
|
|
|
|
boolean getDisableNetworkMonitor() {
|
|
|
|
|
return disableNetworkMonitor;
|
|
|
|
|
}
|
2018-03-23 11:50:16 -07:00
|
|
|
|
|
|
|
|
@CalledByNative("Options")
|
|
|
|
|
boolean getEnableAes128Sha1_32CryptoCipher() {
|
|
|
|
|
return enableAes128Sha1_32CryptoCipher;
|
|
|
|
|
}
|
Makes libjingle_peerconnection_android_unittest run on networkless devices.
PeerConnectionTest.java currently works, but only on a device with
network interfaces up. This is not a problem for desktop, but it is a
problem when running on Android devices since the devices in the lab
generally don't have network (due to the chaotic radio environment in
the device labs, devices are simply kept in flight mode).
The test does work if one modifies this line in the file
webrtc/base/network.cc:
bool ignored = ((cursor->ifa_flags & IFF_LOOPBACK) ||
IsIgnoredNetwork(*network));
If we remove the IFF_LOOPBACK clause, the test starts working on
an Android device in flight mode. This is nice - we're running the
call and packets interact with the OS network stack, which is good
for this end-to-end test. We can't just remove the clause though since
having loopback is undesirable for everyone except the test (right)?
so we need to make this behavior configurable.
This CL takes a stab at a complete solution where we pass a boolean
all the way through the Java PeerConnectionFactory down to the
BasicNetworkManager. This comes as a heavy price in interface
changes though. It's pretty out of proportion, but fundamentally we
need some way of telling the network manager that it is on Android
and in test mode. Passing the boolean all the way through is one way.
Another way might be to put the loopback filter behind an ifdef and
link a custom libjingle_peerconnection.so with the test. That is hacky
but doesn't pollute the interfaces. Not sure how to solve that in GYP
but it could mean some duplication between the production and
test .so files.
It would have been perfect to use flags here, but then we need to
hook up gflags parsing to some main() somewhere to make sure the
flag gets parsed, and make sure to pass that flag in our tests.
I'm not sure how that can be done.
Making the loopback filtering conditional is exactly how we solved the
equivalent problem in content_browsertests in Chrome, and it worked
great.
That's all I could think of.
BUG=4181
R=perkj@webrtc.org, pthatcher@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/36769004
Cr-Commit-Position: refs/heads/master@{#8344}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8344 4adac7df-926f-26a2-2b94-8c16560cd09d
2015-02-12 09:23:59 +00:00
|
|
|
}
|
|
|
|
|
|
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}
2018-02-20 12:50:27 +01:00
|
|
|
public static class Builder {
|
2018-03-22 13:32:44 +01:00
|
|
|
private @Nullable Options options;
|
2018-04-04 17:16:03 +02:00
|
|
|
private @Nullable AudioDeviceModule audioDeviceModule = new LegacyAudioDeviceModule();
|
2018-03-22 13:32:44 +01:00
|
|
|
private @Nullable VideoEncoderFactory encoderFactory;
|
|
|
|
|
private @Nullable VideoDecoderFactory decoderFactory;
|
|
|
|
|
private @Nullable AudioProcessingFactory audioProcessingFactory;
|
|
|
|
|
private @Nullable FecControllerFactoryFactoryInterface fecControllerFactoryFactory;
|
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}
2018-02-20 12:50:27 +01:00
|
|
|
|
|
|
|
|
private Builder() {}
|
|
|
|
|
|
|
|
|
|
public Builder setOptions(Options options) {
|
|
|
|
|
this.options = options;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-04 17:16:03 +02:00
|
|
|
public Builder setAudioDeviceModule(AudioDeviceModule audioDeviceModule) {
|
|
|
|
|
this.audioDeviceModule = audioDeviceModule;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
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}
2018-02-20 12:50:27 +01:00
|
|
|
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() {
|
2018-04-04 17:16:03 +02:00
|
|
|
return new PeerConnectionFactory(options, audioDeviceModule, encoderFactory, decoderFactory,
|
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}
2018-02-20 12:50:27 +01:00
|
|
|
audioProcessingFactory, fecControllerFactoryFactory);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static Builder builder() {
|
|
|
|
|
return new Builder();
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-29 12:49:46 +02:00
|
|
|
/**
|
|
|
|
|
* 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
|
|
|
|
|
* a PeerConnectionFactory is alive.
|
|
|
|
|
*/
|
|
|
|
|
public static void initialize(InitializationOptions options) {
|
|
|
|
|
ContextUtils.initialize(options.applicationContext);
|
|
|
|
|
NativeLibrary.initialize(options.nativeLibraryLoader);
|
2018-03-21 17:26:09 +01:00
|
|
|
nativeInitializeAndroidGlobals(options.enableVideoHwAcceleration);
|
2017-09-29 12:49:46 +02:00
|
|
|
initializeFieldTrials(options.fieldTrials);
|
2017-11-15 14:15:24 +01:00
|
|
|
if (options.enableInternalTracer && !internalTracerInitialized) {
|
2017-09-29 12:49:46 +02:00
|
|
|
initializeInternalTracer();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-10-20 09:36:16 +02:00
|
|
|
private void checkInitializeHasBeenCalled() {
|
|
|
|
|
if (!NativeLibrary.isLoaded() || ContextUtils.getApplicationContext() == null) {
|
|
|
|
|
throw new IllegalStateException(
|
|
|
|
|
"PeerConnectionFactory.initialize was not called before creating a "
|
|
|
|
|
+ "PeerConnectionFactory.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2017-11-24 11:13:39 +01:00
|
|
|
private static void initializeInternalTracer() {
|
2017-11-15 14:15:24 +01:00
|
|
|
internalTracerInitialized = true;
|
2017-12-20 15:12:10 +01:00
|
|
|
nativeInitializeInternalTracer();
|
2017-11-15 14:15:24 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void shutdownInternalTracer() {
|
|
|
|
|
internalTracerInitialized = false;
|
2017-12-20 15:12:10 +01:00
|
|
|
nativeShutdownInternalTracer();
|
2017-11-15 14:15:24 +01:00
|
|
|
}
|
|
|
|
|
|
2015-02-09 23:25:58 +00:00
|
|
|
// Field trial initialization. Must be called before PeerConnectionFactory
|
|
|
|
|
// is created.
|
2017-09-29 12:49:46 +02:00
|
|
|
// Deprecated, use PeerConnectionFactory.initialize instead.
|
2017-12-20 15:12:10 +01:00
|
|
|
@Deprecated
|
|
|
|
|
public static void initializeFieldTrials(String fieldTrialsInitString) {
|
|
|
|
|
nativeInitializeFieldTrials(fieldTrialsInitString);
|
|
|
|
|
}
|
|
|
|
|
|
2017-01-10 08:02:03 -08:00
|
|
|
// Wrapper of webrtc::field_trial::FindFullName. Develop the feature with default behaviour off.
|
|
|
|
|
// Example usage:
|
|
|
|
|
// if (PeerConnectionFactory.fieldTrialsFindFullName("WebRTCExperiment").equals("Enabled")) {
|
|
|
|
|
// method1();
|
|
|
|
|
// } else {
|
|
|
|
|
// method2();
|
|
|
|
|
// }
|
2017-01-12 01:11:57 -08:00
|
|
|
public static String fieldTrialsFindFullName(String name) {
|
2017-12-20 15:12:10 +01:00
|
|
|
return NativeLibrary.isLoaded() ? nativeFindFieldTrialsFullName(name) : "";
|
2017-01-12 01:11:57 -08:00
|
|
|
}
|
2015-12-07 23:17:15 +01:00
|
|
|
// Start/stop internal capturing of internal tracing.
|
2017-12-20 15:12:10 +01:00
|
|
|
public static boolean startInternalTracingCapture(String tracingFilename) {
|
|
|
|
|
return nativeStartInternalTracingCapture(tracingFilename);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void stopInternalTracingCapture() {
|
|
|
|
|
nativeStopInternalTracingCapture();
|
|
|
|
|
}
|
2015-02-09 23:25:58 +00:00
|
|
|
|
2016-01-14 14:45:38 -08:00
|
|
|
@Deprecated
|
2013-07-10 00:45:36 +00:00
|
|
|
public PeerConnectionFactory() {
|
2016-01-14 14:45:38 -08:00
|
|
|
this(null);
|
|
|
|
|
}
|
|
|
|
|
|
2017-04-10 15:08:02 -07:00
|
|
|
// Note: initializeAndroidGlobals must be called at least once before
|
|
|
|
|
// constructing a PeerConnectionFactory.
|
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}
2018-02-20 12:50:27 +01:00
|
|
|
@Deprecated
|
2016-01-14 14:45:38 -08:00
|
|
|
public PeerConnectionFactory(Options options) {
|
2017-06-27 13:53:38 +02:00
|
|
|
this(options, null /* encoderFactory */, null /* decoderFactory */);
|
|
|
|
|
}
|
|
|
|
|
|
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}
2018-02-20 12:50:27 +01:00
|
|
|
@Deprecated
|
2017-06-27 13:53:38 +02:00
|
|
|
public PeerConnectionFactory(
|
|
|
|
|
Options options, VideoEncoderFactory encoderFactory, VideoDecoderFactory decoderFactory) {
|
2018-02-15 20:07:11 +00:00
|
|
|
checkInitializeHasBeenCalled();
|
2018-04-04 17:16:03 +02:00
|
|
|
nativeFactory = nativeCreatePeerConnectionFactory(ContextUtils.getApplicationContext(), options,
|
|
|
|
|
0 /* audioDeviceModule */, encoderFactory, decoderFactory, 0, 0);
|
2018-02-15 20:07:11 +00:00
|
|
|
if (nativeFactory == 0) {
|
|
|
|
|
throw new RuntimeException("Failed to initialize PeerConnectionFactory!");
|
|
|
|
|
}
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
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}
2018-02-20 12:50:27 +01:00
|
|
|
@Deprecated
|
2017-10-20 09:36:16 +02:00
|
|
|
public PeerConnectionFactory(Options options, VideoEncoderFactory encoderFactory,
|
|
|
|
|
VideoDecoderFactory decoderFactory, AudioProcessingFactory audioProcessingFactory) {
|
2018-04-04 17:16:03 +02:00
|
|
|
this(options, new LegacyAudioDeviceModule(), encoderFactory, decoderFactory,
|
|
|
|
|
audioProcessingFactory, null /* fecControllerFactoryFactory */);
|
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}
2018-02-20 12:50:27 +01:00
|
|
|
}
|
|
|
|
|
|
2018-04-04 17:16:03 +02:00
|
|
|
private PeerConnectionFactory(Options options, @Nullable AudioDeviceModule audioDeviceModule,
|
|
|
|
|
@Nullable VideoEncoderFactory encoderFactory, @Nullable VideoDecoderFactory decoderFactory,
|
2018-03-22 13:32:44 +01:00
|
|
|
@Nullable AudioProcessingFactory audioProcessingFactory,
|
|
|
|
|
@Nullable FecControllerFactoryFactoryInterface fecControllerFactoryFactory) {
|
2017-10-20 09:36:16 +02:00
|
|
|
checkInitializeHasBeenCalled();
|
2018-03-21 17:26:09 +01:00
|
|
|
nativeFactory = nativeCreatePeerConnectionFactory(ContextUtils.getApplicationContext(), options,
|
2018-04-04 17:16:03 +02:00
|
|
|
audioDeviceModule == null ? 0 : audioDeviceModule.getNativeAudioDeviceModulePointer(),
|
2018-03-21 17:26:09 +01:00
|
|
|
encoderFactory, decoderFactory,
|
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}
2018-02-20 12:50:27 +01:00
|
|
|
audioProcessingFactory == null ? 0 : audioProcessingFactory.createNative(),
|
|
|
|
|
fecControllerFactoryFactory == null ? 0 : fecControllerFactoryFactory.createNative());
|
2017-10-20 09:36:16 +02:00
|
|
|
if (nativeFactory == 0) {
|
|
|
|
|
throw new RuntimeException("Failed to initialize PeerConnectionFactory!");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-22 13:34:24 +01:00
|
|
|
@CalledByNative
|
|
|
|
|
PeerConnectionFactory(long nativeFactory) {
|
|
|
|
|
checkInitializeHasBeenCalled();
|
|
|
|
|
if (nativeFactory == 0) {
|
|
|
|
|
throw new RuntimeException("Failed to initialize PeerConnectionFactory!");
|
|
|
|
|
}
|
|
|
|
|
this.nativeFactory = nativeFactory;
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-19 12:51:53 +01:00
|
|
|
/**
|
|
|
|
|
* Deprecated. PeerConnection constraints are deprecated. Supply values in rtcConfig struct
|
|
|
|
|
* instead and use the method without constraints in the signature.
|
|
|
|
|
*/
|
2018-03-22 13:32:44 +01:00
|
|
|
@Nullable
|
2017-12-19 12:51:53 +01:00
|
|
|
@Deprecated
|
2015-04-30 12:35:24 -07:00
|
|
|
public PeerConnection createPeerConnection(PeerConnection.RTCConfiguration rtcConfig,
|
2013-07-10 00:45:36 +00:00
|
|
|
MediaConstraints constraints, PeerConnection.Observer observer) {
|
2017-12-20 11:59:22 +01:00
|
|
|
long nativeObserver = PeerConnection.createNativePeerConnectionObserver(observer);
|
2013-07-10 00:45:36 +00:00
|
|
|
if (nativeObserver == 0) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
long nativePeerConnection =
|
2017-12-20 15:12:10 +01:00
|
|
|
nativeCreatePeerConnection(nativeFactory, rtcConfig, constraints, nativeObserver);
|
2013-07-10 00:45:36 +00:00
|
|
|
if (nativePeerConnection == 0) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2018-01-15 09:28:34 +01:00
|
|
|
return new PeerConnection(nativePeerConnection);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2017-12-19 12:51:53 +01:00
|
|
|
/**
|
|
|
|
|
* Deprecated. PeerConnection constraints are deprecated. Supply values in rtcConfig struct
|
|
|
|
|
* instead and use the method without constraints in the signature.
|
|
|
|
|
*/
|
2018-03-22 13:32:44 +01:00
|
|
|
@Nullable
|
2017-12-19 12:51:53 +01:00
|
|
|
@Deprecated
|
2015-04-30 12:35:24 -07:00
|
|
|
public PeerConnection createPeerConnection(List<PeerConnection.IceServer> iceServers,
|
|
|
|
|
MediaConstraints constraints, PeerConnection.Observer observer) {
|
|
|
|
|
PeerConnection.RTCConfiguration rtcConfig = new PeerConnection.RTCConfiguration(iceServers);
|
|
|
|
|
return createPeerConnection(rtcConfig, constraints, observer);
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-22 13:32:44 +01:00
|
|
|
@Nullable
|
2017-12-19 12:51:53 +01:00
|
|
|
public PeerConnection createPeerConnection(
|
|
|
|
|
List<PeerConnection.IceServer> iceServers, PeerConnection.Observer observer) {
|
|
|
|
|
PeerConnection.RTCConfiguration rtcConfig = new PeerConnection.RTCConfiguration(iceServers);
|
|
|
|
|
return createPeerConnection(rtcConfig, observer);
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-22 13:32:44 +01:00
|
|
|
@Nullable
|
2017-12-19 12:51:53 +01:00
|
|
|
public PeerConnection createPeerConnection(
|
|
|
|
|
PeerConnection.RTCConfiguration rtcConfig, PeerConnection.Observer observer) {
|
|
|
|
|
return createPeerConnection(rtcConfig, null /* constraints */, observer);
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
public MediaStream createLocalMediaStream(String label) {
|
2017-12-20 15:12:10 +01:00
|
|
|
return new MediaStream(nativeCreateLocalMediaStream(nativeFactory, label));
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2016-07-20 16:13:08 +02:00
|
|
|
public VideoSource createVideoSource(VideoCapturer capturer) {
|
|
|
|
|
final EglBase.Context eglContext =
|
|
|
|
|
localEglbase == null ? null : localEglbase.getEglBaseContext();
|
2017-06-02 09:51:39 +02:00
|
|
|
final SurfaceTextureHelper surfaceTextureHelper =
|
|
|
|
|
SurfaceTextureHelper.create(VIDEO_CAPTURER_THREAD_NAME, eglContext);
|
2016-08-31 18:50:52 -07:00
|
|
|
long nativeAndroidVideoTrackSource =
|
2017-12-20 15:12:10 +01:00
|
|
|
nativeCreateVideoSource(nativeFactory, surfaceTextureHelper, capturer.isScreencast());
|
2016-07-20 16:13:08 +02:00
|
|
|
VideoCapturer.CapturerObserver capturerObserver =
|
2017-04-06 04:31:26 -07:00
|
|
|
new AndroidVideoTrackSourceObserver(nativeAndroidVideoTrackSource);
|
2017-06-02 09:51:39 +02:00
|
|
|
capturer.initialize(
|
|
|
|
|
surfaceTextureHelper, ContextUtils.getApplicationContext(), capturerObserver);
|
2016-07-20 16:13:08 +02:00
|
|
|
return new VideoSource(nativeAndroidVideoTrackSource);
|
|
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
public VideoTrack createVideoTrack(String id, VideoSource source) {
|
2017-12-20 15:12:10 +01:00
|
|
|
return new VideoTrack(nativeCreateVideoTrack(nativeFactory, id, source.nativeSource));
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2014-02-13 04:01:04 +00:00
|
|
|
public AudioSource createAudioSource(MediaConstraints constraints) {
|
2017-12-20 15:12:10 +01:00
|
|
|
return new AudioSource(nativeCreateAudioSource(nativeFactory, constraints));
|
2014-02-13 04:01:04 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public AudioTrack createAudioTrack(String id, AudioSource source) {
|
2017-12-20 15:12:10 +01:00
|
|
|
return new AudioTrack(nativeCreateAudioTrack(nativeFactory, id, source.nativeSource));
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2015-11-24 09:00:36 -08:00
|
|
|
// Starts recording an AEC dump. Ownership of the file is transfered to the
|
|
|
|
|
// native code. If an AEC dump is already in progress, it will be stopped and
|
|
|
|
|
// a new one will start using the provided file.
|
2016-01-15 03:06:36 -08:00
|
|
|
public boolean startAecDump(int file_descriptor, int filesize_limit_bytes) {
|
2017-12-20 15:12:10 +01:00
|
|
|
return nativeStartAecDump(nativeFactory, file_descriptor, filesize_limit_bytes);
|
2015-11-24 09:00:36 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Stops recording an AEC dump. If no AEC dump is currently being recorded,
|
|
|
|
|
// this call will have no effect.
|
|
|
|
|
public void stopAecDump() {
|
2017-12-20 15:12:10 +01:00
|
|
|
nativeStopAecDump(nativeFactory);
|
2015-11-24 09:00:36 -08:00
|
|
|
}
|
|
|
|
|
|
2016-01-14 14:45:38 -08:00
|
|
|
@Deprecated
|
Makes libjingle_peerconnection_android_unittest run on networkless devices.
PeerConnectionTest.java currently works, but only on a device with
network interfaces up. This is not a problem for desktop, but it is a
problem when running on Android devices since the devices in the lab
generally don't have network (due to the chaotic radio environment in
the device labs, devices are simply kept in flight mode).
The test does work if one modifies this line in the file
webrtc/base/network.cc:
bool ignored = ((cursor->ifa_flags & IFF_LOOPBACK) ||
IsIgnoredNetwork(*network));
If we remove the IFF_LOOPBACK clause, the test starts working on
an Android device in flight mode. This is nice - we're running the
call and packets interact with the OS network stack, which is good
for this end-to-end test. We can't just remove the clause though since
having loopback is undesirable for everyone except the test (right)?
so we need to make this behavior configurable.
This CL takes a stab at a complete solution where we pass a boolean
all the way through the Java PeerConnectionFactory down to the
BasicNetworkManager. This comes as a heavy price in interface
changes though. It's pretty out of proportion, but fundamentally we
need some way of telling the network manager that it is on Android
and in test mode. Passing the boolean all the way through is one way.
Another way might be to put the loopback filter behind an ifdef and
link a custom libjingle_peerconnection.so with the test. That is hacky
but doesn't pollute the interfaces. Not sure how to solve that in GYP
but it could mean some duplication between the production and
test .so files.
It would have been perfect to use flags here, but then we need to
hook up gflags parsing to some main() somewhere to make sure the
flag gets parsed, and make sure to pass that flag in our tests.
I'm not sure how that can be done.
Making the loopback filtering conditional is exactly how we solved the
equivalent problem in content_browsertests in Chrome, and it worked
great.
That's all I could think of.
BUG=4181
R=perkj@webrtc.org, pthatcher@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/36769004
Cr-Commit-Position: refs/heads/master@{#8344}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8344 4adac7df-926f-26a2-2b94-8c16560cd09d
2015-02-12 09:23:59 +00:00
|
|
|
public void setOptions(Options options) {
|
2017-12-20 15:12:10 +01:00
|
|
|
nativeSetOptions(nativeFactory, options);
|
Makes libjingle_peerconnection_android_unittest run on networkless devices.
PeerConnectionTest.java currently works, but only on a device with
network interfaces up. This is not a problem for desktop, but it is a
problem when running on Android devices since the devices in the lab
generally don't have network (due to the chaotic radio environment in
the device labs, devices are simply kept in flight mode).
The test does work if one modifies this line in the file
webrtc/base/network.cc:
bool ignored = ((cursor->ifa_flags & IFF_LOOPBACK) ||
IsIgnoredNetwork(*network));
If we remove the IFF_LOOPBACK clause, the test starts working on
an Android device in flight mode. This is nice - we're running the
call and packets interact with the OS network stack, which is good
for this end-to-end test. We can't just remove the clause though since
having loopback is undesirable for everyone except the test (right)?
so we need to make this behavior configurable.
This CL takes a stab at a complete solution where we pass a boolean
all the way through the Java PeerConnectionFactory down to the
BasicNetworkManager. This comes as a heavy price in interface
changes though. It's pretty out of proportion, but fundamentally we
need some way of telling the network manager that it is on Android
and in test mode. Passing the boolean all the way through is one way.
Another way might be to put the loopback filter behind an ifdef and
link a custom libjingle_peerconnection.so with the test. That is hacky
but doesn't pollute the interfaces. Not sure how to solve that in GYP
but it could mean some duplication between the production and
test .so files.
It would have been perfect to use flags here, but then we need to
hook up gflags parsing to some main() somewhere to make sure the
flag gets parsed, and make sure to pass that flag in our tests.
I'm not sure how that can be done.
Making the loopback filtering conditional is exactly how we solved the
equivalent problem in content_browsertests in Chrome, and it worked
great.
That's all I could think of.
BUG=4181
R=perkj@webrtc.org, pthatcher@webrtc.org
Review URL: https://webrtc-codereview.appspot.com/36769004
Cr-Commit-Position: refs/heads/master@{#8344}
git-svn-id: http://webrtc.googlecode.com/svn/trunk@8344 4adac7df-926f-26a2-2b94-8c16560cd09d
2015-02-12 09:23:59 +00:00
|
|
|
}
|
|
|
|
|
|
2015-11-20 01:31:25 -08:00
|
|
|
/** Set the EGL context used by HW Video encoding and decoding.
|
|
|
|
|
*
|
2016-02-15 06:28:36 -08:00
|
|
|
* @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.
|
2015-11-20 01:31:25 -08:00
|
|
|
*/
|
2016-02-15 06:28:36 -08:00
|
|
|
public void setVideoHwAccelerationOptions(
|
|
|
|
|
EglBase.Context localEglContext, EglBase.Context remoteEglContext) {
|
2016-02-18 11:35:48 +01:00
|
|
|
if (localEglbase != null) {
|
|
|
|
|
Logging.w(TAG, "Egl context already set.");
|
|
|
|
|
localEglbase.release();
|
|
|
|
|
}
|
|
|
|
|
if (remoteEglbase != null) {
|
|
|
|
|
Logging.w(TAG, "Egl context already set.");
|
|
|
|
|
remoteEglbase.release();
|
2016-02-15 06:28:36 -08:00
|
|
|
}
|
|
|
|
|
localEglbase = EglBase.create(localEglContext);
|
|
|
|
|
remoteEglbase = EglBase.create(remoteEglContext);
|
2017-12-20 15:12:10 +01:00
|
|
|
nativeSetVideoHwAccelerationOptions(
|
2016-02-15 06:28:36 -08:00
|
|
|
nativeFactory, localEglbase.getEglBaseContext(), remoteEglbase.getEglBaseContext());
|
2015-09-01 15:04:13 -07:00
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
public void dispose() {
|
2017-12-20 15:12:10 +01:00
|
|
|
nativeFreeFactory(nativeFactory);
|
2016-05-17 01:52:02 -07:00
|
|
|
networkThread = null;
|
2015-10-07 14:50:13 -07:00
|
|
|
workerThread = null;
|
2016-05-17 01:52:02 -07:00
|
|
|
signalingThread = null;
|
2016-02-15 06:28:36 -08:00
|
|
|
if (localEglbase != null)
|
|
|
|
|
localEglbase.release();
|
|
|
|
|
if (remoteEglbase != null)
|
|
|
|
|
remoteEglbase.release();
|
2015-10-07 14:50:13 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void threadsCallbacks() {
|
2017-12-20 15:12:10 +01:00
|
|
|
nativeInvokeThreadsCallbacks(nativeFactory);
|
2015-10-07 14:50:13 -07:00
|
|
|
}
|
|
|
|
|
|
2018-01-15 14:22:53 +01:00
|
|
|
/** Returns a pointer to the native webrtc::PeerConnectionFactoryInterface. */
|
|
|
|
|
public long getNativePeerConnectionFactory() {
|
|
|
|
|
return nativeGetNativePeerConnectionFactory(nativeFactory);
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-16 15:07:42 +01:00
|
|
|
/** Returns a pointer to the native OwnedFactoryAndThreads object */
|
|
|
|
|
public long getNativeOwnedFactoryAndThreads() {
|
|
|
|
|
return nativeFactory;
|
|
|
|
|
}
|
|
|
|
|
|
2018-03-22 13:32:44 +01:00
|
|
|
private static void printStackTrace(@Nullable Thread thread, String threadName) {
|
2015-10-12 14:56:02 -07:00
|
|
|
if (thread != null) {
|
|
|
|
|
StackTraceElement[] stackTraces = thread.getStackTrace();
|
|
|
|
|
if (stackTraces.length > 0) {
|
|
|
|
|
Logging.d(TAG, threadName + " stacks trace:");
|
|
|
|
|
for (StackTraceElement stackTrace : stackTraces) {
|
|
|
|
|
Logging.d(TAG, stackTrace.toString());
|
|
|
|
|
}
|
2015-10-07 14:50:13 -07:00
|
|
|
}
|
|
|
|
|
}
|
2015-10-09 13:58:18 -07:00
|
|
|
}
|
|
|
|
|
|
2015-10-12 14:56:02 -07:00
|
|
|
public static void printStackTraces() {
|
2016-05-17 01:52:02 -07:00
|
|
|
printStackTrace(networkThread, "Network thread");
|
2015-10-12 14:56:02 -07:00
|
|
|
printStackTrace(workerThread, "Worker thread");
|
|
|
|
|
printStackTrace(signalingThread, "Signaling thread");
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-12 12:52:54 +01:00
|
|
|
@CalledByNative
|
2016-05-17 01:52:02 -07:00
|
|
|
private static void onNetworkThreadReady() {
|
|
|
|
|
networkThread = Thread.currentThread();
|
|
|
|
|
Logging.d(TAG, "onNetworkThreadReady");
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-12 12:52:54 +01:00
|
|
|
@CalledByNative
|
2015-10-07 14:50:13 -07:00
|
|
|
private static void onWorkerThreadReady() {
|
|
|
|
|
workerThread = Thread.currentThread();
|
|
|
|
|
Logging.d(TAG, "onWorkerThreadReady");
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-12 12:52:54 +01:00
|
|
|
@CalledByNative
|
2015-10-07 14:50:13 -07:00
|
|
|
private static void onSignalingThreadReady() {
|
|
|
|
|
signalingThread = Thread.currentThread();
|
|
|
|
|
Logging.d(TAG, "onSignalingThreadReady");
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2017-12-20 15:12:10 +01:00
|
|
|
// Must be called at least once before creating a PeerConnectionFactory
|
|
|
|
|
// (for example, at application startup time).
|
2018-03-21 17:26:09 +01:00
|
|
|
private static native void nativeInitializeAndroidGlobals(boolean videoHwAcceleration);
|
2017-12-20 15:12:10 +01:00
|
|
|
private static native void nativeInitializeFieldTrials(String fieldTrialsInitString);
|
|
|
|
|
private static native String nativeFindFieldTrialsFullName(String name);
|
|
|
|
|
// Internal tracing initialization. Must be called before PeerConnectionFactory is created to
|
|
|
|
|
// prevent racing with tracing code.
|
|
|
|
|
// Deprecated, use PeerConnectionFactory.initialize instead.
|
|
|
|
|
private static native void nativeInitializeInternalTracer();
|
|
|
|
|
// Internal tracing shutdown, called to prevent resource leaks. Must be called after
|
|
|
|
|
// PeerConnectionFactory is gone to prevent races with code performing tracing.
|
|
|
|
|
private static native void nativeShutdownInternalTracer();
|
|
|
|
|
private static native boolean nativeStartInternalTracingCapture(String tracingFilename);
|
|
|
|
|
private static native void nativeStopInternalTracingCapture();
|
2018-03-21 17:26:09 +01:00
|
|
|
private static native long nativeCreatePeerConnectionFactory(Context context, Options options,
|
2018-04-04 17:16:03 +02:00
|
|
|
long nativeAudioDeviceModule, VideoEncoderFactory encoderFactory,
|
|
|
|
|
VideoDecoderFactory decoderFactory, long nativeAudioProcessor,
|
|
|
|
|
long nativeFecControllerFactory);
|
2017-12-20 15:12:10 +01:00
|
|
|
private static native long nativeCreatePeerConnection(long factory,
|
2015-04-30 12:35:24 -07:00
|
|
|
PeerConnection.RTCConfiguration rtcConfig, MediaConstraints constraints, long nativeObserver);
|
2017-12-20 15:12:10 +01:00
|
|
|
private static native long nativeCreateLocalMediaStream(long factory, String label);
|
|
|
|
|
private static native long nativeCreateVideoSource(
|
|
|
|
|
long factory, SurfaceTextureHelper surfaceTextureHelper, boolean is_screencast);
|
|
|
|
|
private static native long nativeCreateVideoTrack(
|
|
|
|
|
long factory, String id, long nativeVideoSource);
|
|
|
|
|
private static native long nativeCreateAudioSource(long factory, MediaConstraints constraints);
|
|
|
|
|
private static native long nativeCreateAudioTrack(long factory, String id, long nativeSource);
|
|
|
|
|
private static native boolean nativeStartAecDump(
|
|
|
|
|
long factory, int file_descriptor, int filesize_limit_bytes);
|
|
|
|
|
private static native void nativeStopAecDump(long factory);
|
|
|
|
|
@Deprecated public native void nativeSetOptions(long factory, Options options);
|
|
|
|
|
private static native void nativeSetVideoHwAccelerationOptions(
|
|
|
|
|
long factory, Object localEGLContext, Object remoteEGLContext);
|
|
|
|
|
private static native void nativeInvokeThreadsCallbacks(long factory);
|
|
|
|
|
private static native void nativeFreeFactory(long factory);
|
2018-01-15 14:22:53 +01:00
|
|
|
private static native long nativeGetNativePeerConnectionFactory(long factory);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|