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;
|
2019-01-20 13:44:45 +01:00
|
|
|
import android.os.Process;
|
2021-08-14 11:41:59 +09:00
|
|
|
import androidx.annotation.Nullable;
|
2013-07-10 00:45:36 +00:00
|
|
|
import java.util.List;
|
2018-06-21 14:31:38 +02:00
|
|
|
import org.webrtc.Logging.Severity;
|
2018-11-16 14:55:16 +01:00
|
|
|
import org.webrtc.PeerConnection;
|
2018-04-04 17:16:03 +02:00
|
|
|
import org.webrtc.audio.AudioDeviceModule;
|
2019-02-28 13:54:29 +01:00
|
|
|
import org.webrtc.audio.JavaAudioDeviceModule;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Java wrapper for a C++ PeerConnectionFactoryInterface. Main entry point to
|
|
|
|
|
* the PeerConnection API for clients.
|
|
|
|
|
*/
|
|
|
|
|
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
|
|
|
|
2019-01-20 13:44:45 +01:00
|
|
|
/** Helper class holding both Java and C++ thread info. */
|
|
|
|
|
private static class ThreadInfo {
|
|
|
|
|
final Thread thread;
|
|
|
|
|
final int tid;
|
|
|
|
|
|
|
|
|
|
public static ThreadInfo getCurrent() {
|
|
|
|
|
return new ThreadInfo(Thread.currentThread(), Process.myTid());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ThreadInfo(Thread thread, int tid) {
|
|
|
|
|
this.thread = thread;
|
|
|
|
|
this.tid = tid;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-11 11:11:47 +02:00
|
|
|
private static volatile boolean internalTracerInitialized;
|
2019-01-20 12:43:00 +01:00
|
|
|
|
|
|
|
|
// Remove these once deprecated static printStackTrace() is gone.
|
2019-01-20 13:44:45 +01:00
|
|
|
@Nullable private static ThreadInfo staticNetworkThread;
|
|
|
|
|
@Nullable private static ThreadInfo staticWorkerThread;
|
|
|
|
|
@Nullable private static ThreadInfo staticSignalingThread;
|
2019-01-20 12:43:00 +01:00
|
|
|
|
|
|
|
|
private long nativeFactory;
|
2019-01-20 13:44:45 +01:00
|
|
|
@Nullable private volatile ThreadInfo networkThread;
|
|
|
|
|
@Nullable private volatile ThreadInfo workerThread;
|
|
|
|
|
@Nullable private volatile ThreadInfo signalingThread;
|
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 NativeLibraryLoader nativeLibraryLoader;
|
2018-06-19 16:14:50 +02:00
|
|
|
final String nativeLibraryName;
|
2018-06-21 14:31:38 +02:00
|
|
|
@Nullable Loggable loggable;
|
|
|
|
|
@Nullable Severity loggableSeverity;
|
2017-09-29 12:49:46 +02:00
|
|
|
|
|
|
|
|
private InitializationOptions(Context applicationContext, String fieldTrials,
|
2018-08-23 19:08:28 +02:00
|
|
|
boolean enableInternalTracer, NativeLibraryLoader nativeLibraryLoader,
|
|
|
|
|
String nativeLibraryName, @Nullable Loggable loggable,
|
|
|
|
|
@Nullable Severity loggableSeverity) {
|
2017-09-29 12:49:46 +02:00
|
|
|
this.applicationContext = applicationContext;
|
|
|
|
|
this.fieldTrials = fieldTrials;
|
|
|
|
|
this.enableInternalTracer = enableInternalTracer;
|
|
|
|
|
this.nativeLibraryLoader = nativeLibraryLoader;
|
2018-06-19 16:14:50 +02:00
|
|
|
this.nativeLibraryName = nativeLibraryName;
|
2018-06-21 14:31:38 +02:00
|
|
|
this.loggable = loggable;
|
|
|
|
|
this.loggableSeverity = loggableSeverity;
|
2017-09-29 12:49:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static Builder builder(Context applicationContext) {
|
|
|
|
|
return new Builder(applicationContext);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static class Builder {
|
|
|
|
|
private final Context applicationContext;
|
|
|
|
|
private String fieldTrials = "";
|
2018-09-11 11:11:47 +02:00
|
|
|
private boolean enableInternalTracer;
|
2017-09-29 12:49:46 +02:00
|
|
|
private NativeLibraryLoader nativeLibraryLoader = new NativeLibrary.DefaultLoader();
|
2018-06-19 16:14:50 +02:00
|
|
|
private String nativeLibraryName = "jingle_peerconnection_so";
|
2018-09-11 11:11:47 +02:00
|
|
|
@Nullable private Loggable loggable;
|
|
|
|
|
@Nullable private Severity loggableSeverity;
|
2017-09-29 12:49:46 +02:00
|
|
|
|
|
|
|
|
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 setNativeLibraryLoader(NativeLibraryLoader nativeLibraryLoader) {
|
|
|
|
|
this.nativeLibraryLoader = nativeLibraryLoader;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
2018-06-21 14:31:38 +02:00
|
|
|
|
2018-06-19 16:14:50 +02:00
|
|
|
public Builder setNativeLibraryName(String nativeLibraryName) {
|
|
|
|
|
this.nativeLibraryName = nativeLibraryName;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
2017-09-29 12:49:46 +02:00
|
|
|
|
2018-06-21 14:31:38 +02:00
|
|
|
public Builder setInjectableLogger(Loggable loggable, Severity severity) {
|
|
|
|
|
this.loggable = loggable;
|
|
|
|
|
this.loggableSeverity = severity;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
2017-09-29 12:49:46 +02:00
|
|
|
public PeerConnectionFactory.InitializationOptions createInitializationOptions() {
|
|
|
|
|
return new PeerConnectionFactory.InitializationOptions(applicationContext, fieldTrials,
|
2018-08-23 19:08:28 +02:00
|
|
|
enableInternalTracer, nativeLibraryLoader, nativeLibraryName, loggable,
|
|
|
|
|
loggableSeverity);
|
2017-09-29 12:49:46 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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
|
|
|
//
|
2021-07-27 12:23:39 +02: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;
|
2018-06-28 15:38:09 -07:00
|
|
|
static final int ADAPTER_TYPE_ANY = 1 << 5;
|
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 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-10-15 10:20:24 -07:00
|
|
|
|
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;
|
|
|
|
|
}
|
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-11-01 15:55:26 +01:00
|
|
|
@Nullable private Options options;
|
2019-02-28 13:54:29 +01:00
|
|
|
@Nullable private AudioDeviceModule audioDeviceModule;
|
2018-11-01 15:55:26 +01:00
|
|
|
private AudioEncoderFactoryFactory audioEncoderFactoryFactory =
|
|
|
|
|
new BuiltinAudioEncoderFactoryFactory();
|
|
|
|
|
private AudioDecoderFactoryFactory audioDecoderFactoryFactory =
|
|
|
|
|
new BuiltinAudioDecoderFactoryFactory();
|
|
|
|
|
@Nullable private VideoEncoderFactory videoEncoderFactory;
|
|
|
|
|
@Nullable private VideoDecoderFactory videoDecoderFactory;
|
|
|
|
|
@Nullable private AudioProcessingFactory audioProcessingFactory;
|
|
|
|
|
@Nullable private FecControllerFactoryFactoryInterface fecControllerFactoryFactory;
|
2019-04-18 13:40:56 +02:00
|
|
|
@Nullable private NetworkControllerFactoryFactory networkControllerFactoryFactory;
|
2019-04-10 13:48:24 +02:00
|
|
|
@Nullable private NetworkStatePredictorFactoryFactory networkStatePredictorFactoryFactory;
|
2019-11-25 12:52:47 +01:00
|
|
|
@Nullable private NetEqFactoryFactory neteqFactoryFactory;
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-01 15:55:26 +01:00
|
|
|
public Builder setAudioEncoderFactoryFactory(
|
|
|
|
|
AudioEncoderFactoryFactory audioEncoderFactoryFactory) {
|
|
|
|
|
if (audioEncoderFactoryFactory == null) {
|
|
|
|
|
throw new IllegalArgumentException(
|
|
|
|
|
"PeerConnectionFactory.Builder does not accept a null AudioEncoderFactoryFactory.");
|
|
|
|
|
}
|
|
|
|
|
this.audioEncoderFactoryFactory = audioEncoderFactoryFactory;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Builder setAudioDecoderFactoryFactory(
|
|
|
|
|
AudioDecoderFactoryFactory audioDecoderFactoryFactory) {
|
|
|
|
|
if (audioDecoderFactoryFactory == null) {
|
|
|
|
|
throw new IllegalArgumentException(
|
|
|
|
|
"PeerConnectionFactory.Builder does not accept a null AudioDecoderFactoryFactory.");
|
|
|
|
|
}
|
|
|
|
|
this.audioDecoderFactoryFactory = audioDecoderFactoryFactory;
|
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
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
2018-11-01 15:55:26 +01:00
|
|
|
public Builder setVideoEncoderFactory(VideoEncoderFactory videoEncoderFactory) {
|
|
|
|
|
this.videoEncoderFactory = videoEncoderFactory;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Builder setVideoDecoderFactory(VideoDecoderFactory videoDecoderFactory) {
|
|
|
|
|
this.videoDecoderFactory = videoDecoderFactory;
|
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
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-18 13:40:56 +02:00
|
|
|
public Builder setNetworkControllerFactoryFactory(
|
|
|
|
|
NetworkControllerFactoryFactory networkControllerFactoryFactory) {
|
|
|
|
|
this.networkControllerFactoryFactory = networkControllerFactoryFactory;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-10 18:28:00 +02:00
|
|
|
public Builder setNetworkStatePredictorFactoryFactory(
|
2019-04-10 13:48:24 +02:00
|
|
|
NetworkStatePredictorFactoryFactory networkStatePredictorFactoryFactory) {
|
|
|
|
|
this.networkStatePredictorFactoryFactory = networkStatePredictorFactoryFactory;
|
|
|
|
|
return this;
|
|
|
|
|
}
|
|
|
|
|
|
2019-11-25 12:52:47 +01:00
|
|
|
/**
|
|
|
|
|
* Sets a NetEqFactoryFactory for the PeerConnectionFactory. When using a
|
|
|
|
|
* custom NetEqFactoryFactory, the AudioDecoderFactoryFactory will be set
|
|
|
|
|
* to null. The AudioDecoderFactoryFactory should be wrapped in the
|
|
|
|
|
* NetEqFactoryFactory.
|
|
|
|
|
*/
|
|
|
|
|
public Builder setNetEqFactoryFactory(NetEqFactoryFactory neteqFactoryFactory) {
|
|
|
|
|
this.neteqFactoryFactory = neteqFactoryFactory;
|
|
|
|
|
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 PeerConnectionFactory createPeerConnectionFactory() {
|
2019-01-20 12:43:00 +01:00
|
|
|
checkInitializeHasBeenCalled();
|
2019-02-28 13:54:29 +01:00
|
|
|
if (audioDeviceModule == null) {
|
|
|
|
|
audioDeviceModule = JavaAudioDeviceModule.builder(ContextUtils.getApplicationContext())
|
|
|
|
|
.createAudioDeviceModule();
|
|
|
|
|
}
|
2019-01-20 12:43:00 +01:00
|
|
|
return nativeCreatePeerConnectionFactory(ContextUtils.getApplicationContext(), options,
|
2019-02-28 13:54:29 +01:00
|
|
|
audioDeviceModule.getNativeAudioDeviceModulePointer(),
|
2019-01-20 12:43:00 +01:00
|
|
|
audioEncoderFactoryFactory.createNativeAudioEncoderFactory(),
|
2019-11-26 12:29:05 +01:00
|
|
|
audioDecoderFactoryFactory.createNativeAudioDecoderFactory(), videoEncoderFactory,
|
|
|
|
|
videoDecoderFactory,
|
2019-01-20 12:43:00 +01:00
|
|
|
audioProcessingFactory == null ? 0 : audioProcessingFactory.createNative(),
|
|
|
|
|
fecControllerFactoryFactory == null ? 0 : fecControllerFactoryFactory.createNative(),
|
2019-04-18 13:40:56 +02:00
|
|
|
networkControllerFactoryFactory == null
|
|
|
|
|
? 0
|
|
|
|
|
: networkControllerFactoryFactory.createNativeNetworkControllerFactory(),
|
2019-04-10 13:48:24 +02:00
|
|
|
networkStatePredictorFactoryFactory == null
|
|
|
|
|
? 0
|
|
|
|
|
: networkStatePredictorFactoryFactory.createNativeNetworkStatePredictorFactory(),
|
2019-11-25 12:52:47 +01:00
|
|
|
neteqFactoryFactory == null ? 0 : neteqFactoryFactory.createNativeNetEqFactory());
|
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 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);
|
2018-06-19 16:14:50 +02:00
|
|
|
NativeLibrary.initialize(options.nativeLibraryLoader, options.nativeLibraryName);
|
2018-07-13 16:09:20 +02:00
|
|
|
nativeInitializeAndroidGlobals();
|
2018-04-25 09:44:30 +02:00
|
|
|
nativeInitializeFieldTrials(options.fieldTrials);
|
2017-11-15 14:15:24 +01:00
|
|
|
if (options.enableInternalTracer && !internalTracerInitialized) {
|
2017-09-29 12:49:46 +02:00
|
|
|
initializeInternalTracer();
|
|
|
|
|
}
|
2018-06-21 14:31:38 +02:00
|
|
|
if (options.loggable != null) {
|
|
|
|
|
Logging.injectLoggable(options.loggable, options.loggableSeverity);
|
|
|
|
|
nativeInjectLoggable(new JNILogging(options.loggable), options.loggableSeverity.ordinal());
|
|
|
|
|
} else {
|
|
|
|
|
Logging.d(TAG,
|
|
|
|
|
"PeerConnectionFactory was initialized without an injected Loggable. "
|
|
|
|
|
+ "Any existing Loggable will be deleted.");
|
|
|
|
|
Logging.deleteInjectedLoggable();
|
|
|
|
|
nativeDeleteLoggable();
|
|
|
|
|
}
|
2017-09-29 12:49:46 +02:00
|
|
|
}
|
|
|
|
|
|
2019-01-20 12:43:00 +01:00
|
|
|
private static void checkInitializeHasBeenCalled() {
|
2017-10-20 09:36:16 +02:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-16 11:40:11 +00: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) {
|
2022-06-16 11:40:11 +00: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
|
|
|
|
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
|
|
|
/**
|
2018-07-20 15:08:03 -07:00
|
|
|
* Internal helper function to pass the parameters down into the native JNI bridge.
|
2017-12-19 12:51:53 +01:00
|
|
|
*/
|
2018-03-22 13:32:44 +01:00
|
|
|
@Nullable
|
2018-07-20 15:08:03 -07:00
|
|
|
PeerConnection createPeerConnectionInternal(PeerConnection.RTCConfiguration rtcConfig,
|
|
|
|
|
MediaConstraints constraints, PeerConnection.Observer observer,
|
|
|
|
|
SSLCertificateVerifier sslCertificateVerifier) {
|
2018-09-28 14:38:21 +02:00
|
|
|
checkPeerConnectionFactoryExists();
|
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;
|
|
|
|
|
}
|
2018-07-20 15:08:03 -07:00
|
|
|
long nativePeerConnection = nativeCreatePeerConnection(
|
|
|
|
|
nativeFactory, rtcConfig, constraints, nativeObserver, sslCertificateVerifier);
|
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
|
|
|
}
|
|
|
|
|
|
2018-07-20 15:08:03 -07:00
|
|
|
/**
|
|
|
|
|
* Deprecated. PeerConnection constraints are deprecated. Supply values in rtcConfig struct
|
|
|
|
|
* instead and use the method without constraints in the signature.
|
|
|
|
|
*/
|
|
|
|
|
@Nullable
|
|
|
|
|
@Deprecated
|
|
|
|
|
public PeerConnection createPeerConnection(PeerConnection.RTCConfiguration rtcConfig,
|
|
|
|
|
MediaConstraints constraints, PeerConnection.Observer observer) {
|
|
|
|
|
return createPeerConnectionInternal(
|
|
|
|
|
rtcConfig, constraints, observer, /* sslCertificateVerifier= */ null);
|
|
|
|
|
}
|
|
|
|
|
|
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);
|
2022-01-14 10:44:03 +01:00
|
|
|
rtcConfig.sdpSemantics = PeerConnection.SdpSemantics.UNIFIED_PLAN;
|
2015-04-30 12:35:24 -07:00
|
|
|
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);
|
2022-01-14 10:44:03 +01:00
|
|
|
rtcConfig.sdpSemantics = PeerConnection.SdpSemantics.UNIFIED_PLAN;
|
2017-12-19 12:51:53 +01:00
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
|
2018-07-03 13:28:34 -07:00
|
|
|
@Nullable
|
|
|
|
|
public PeerConnection createPeerConnection(
|
|
|
|
|
PeerConnection.RTCConfiguration rtcConfig, PeerConnectionDependencies dependencies) {
|
2018-07-20 15:08:03 -07:00
|
|
|
return createPeerConnectionInternal(rtcConfig, null /* constraints */,
|
|
|
|
|
dependencies.getObserver(), dependencies.getSSLCertificateVerifier());
|
2018-07-03 13:28:34 -07:00
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
public MediaStream createLocalMediaStream(String label) {
|
2018-09-28 14:38:21 +02:00
|
|
|
checkPeerConnectionFactoryExists();
|
2017-12-20 15:12:10 +01:00
|
|
|
return new MediaStream(nativeCreateLocalMediaStream(nativeFactory, label));
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2018-11-15 12:07:32 +01:00
|
|
|
/**
|
|
|
|
|
* Create video source with given parameters. If alignTimestamps is false, the caller is
|
|
|
|
|
* responsible for aligning the frame timestamps to rtc::TimeNanos(). This can be used to achieve
|
|
|
|
|
* higher accuracy if there is a big delay between frame creation and frames being delivered to
|
|
|
|
|
* the returned video source. If alignTimestamps is true, timestamps will be aligned to
|
|
|
|
|
* rtc::TimeNanos() when they arrive to the returned video source.
|
|
|
|
|
*/
|
|
|
|
|
public VideoSource createVideoSource(boolean isScreencast, boolean alignTimestamps) {
|
2018-09-28 14:38:21 +02:00
|
|
|
checkPeerConnectionFactoryExists();
|
2018-11-15 12:07:32 +01:00
|
|
|
return new VideoSource(nativeCreateVideoSource(nativeFactory, isScreencast, alignTimestamps));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Same as above with alignTimestamps set to true.
|
|
|
|
|
*
|
|
|
|
|
* @see #createVideoSource(boolean, boolean)
|
|
|
|
|
*/
|
|
|
|
|
public VideoSource createVideoSource(boolean isScreencast) {
|
|
|
|
|
return createVideoSource(isScreencast, /* alignTimestamps= */ true);
|
2018-04-24 15:11:02 +02:00
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
public VideoTrack createVideoTrack(String id, VideoSource source) {
|
2018-09-28 14:38:21 +02:00
|
|
|
checkPeerConnectionFactoryExists();
|
|
|
|
|
return new VideoTrack(
|
|
|
|
|
nativeCreateVideoTrack(nativeFactory, id, source.getNativeVideoTrackSource()));
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|
|
|
|
|
|
2014-02-13 04:01:04 +00:00
|
|
|
public AudioSource createAudioSource(MediaConstraints constraints) {
|
2018-09-28 14:38:21 +02:00
|
|
|
checkPeerConnectionFactoryExists();
|
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) {
|
2018-09-28 14:38:21 +02:00
|
|
|
checkPeerConnectionFactoryExists();
|
|
|
|
|
return new AudioTrack(nativeCreateAudioTrack(nativeFactory, id, source.getNativeAudioSource()));
|
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) {
|
2018-09-28 14:38:21 +02:00
|
|
|
checkPeerConnectionFactoryExists();
|
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() {
|
2018-09-28 14:38:21 +02:00
|
|
|
checkPeerConnectionFactoryExists();
|
2017-12-20 15:12:10 +01:00
|
|
|
nativeStopAecDump(nativeFactory);
|
2015-11-24 09:00:36 -08:00
|
|
|
}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
public void dispose() {
|
2018-09-28 14:38:21 +02:00
|
|
|
checkPeerConnectionFactoryExists();
|
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;
|
2018-09-28 14:38:21 +02:00
|
|
|
nativeFactory = 0;
|
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() {
|
2018-09-28 14:38:21 +02:00
|
|
|
checkPeerConnectionFactoryExists();
|
2018-01-15 14:22:53 +01:00
|
|
|
return nativeGetNativePeerConnectionFactory(nativeFactory);
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-16 15:07:42 +01:00
|
|
|
/** Returns a pointer to the native OwnedFactoryAndThreads object */
|
|
|
|
|
public long getNativeOwnedFactoryAndThreads() {
|
2018-09-28 14:38:21 +02:00
|
|
|
checkPeerConnectionFactoryExists();
|
2018-01-16 15:07:42 +01:00
|
|
|
return nativeFactory;
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-28 14:38:21 +02:00
|
|
|
private void checkPeerConnectionFactoryExists() {
|
|
|
|
|
if (nativeFactory == 0) {
|
|
|
|
|
throw new IllegalStateException("PeerConnectionFactory has been disposed.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-20 13:44:45 +01:00
|
|
|
private static void printStackTrace(
|
|
|
|
|
@Nullable ThreadInfo threadInfo, boolean printNativeStackTrace) {
|
|
|
|
|
if (threadInfo == null) {
|
|
|
|
|
// Thread callbacks have not been completed yet, ignore call.
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
final String threadName = threadInfo.thread.getName();
|
|
|
|
|
StackTraceElement[] stackTraces = threadInfo.thread.getStackTrace();
|
|
|
|
|
if (stackTraces.length > 0) {
|
|
|
|
|
Logging.w(TAG, threadName + " stacktrace:");
|
|
|
|
|
for (StackTraceElement stackTrace : stackTraces) {
|
|
|
|
|
Logging.w(TAG, stackTrace.toString());
|
2015-10-07 14:50:13 -07:00
|
|
|
}
|
|
|
|
|
}
|
2019-01-20 13:44:45 +01:00
|
|
|
if (printNativeStackTrace) {
|
|
|
|
|
// Imitate output from debuggerd/tombstone so that stack trace can easily be symbolized with
|
|
|
|
|
// ndk-stack.
|
|
|
|
|
Logging.w(TAG, "*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***");
|
|
|
|
|
Logging.w(TAG,
|
|
|
|
|
"pid: " + Process.myPid() + ", tid: " + threadInfo.tid + ", name: " + threadName
|
|
|
|
|
+ " >>> WebRTC <<<");
|
|
|
|
|
nativePrintStackTrace(threadInfo.tid);
|
|
|
|
|
}
|
2015-10-09 13:58:18 -07:00
|
|
|
}
|
|
|
|
|
|
2019-01-20 12:43:00 +01:00
|
|
|
/** Deprecated, use non-static version instead. */
|
|
|
|
|
@Deprecated
|
2015-10-12 14:56:02 -07:00
|
|
|
public static void printStackTraces() {
|
2019-01-20 13:44:45 +01:00
|
|
|
printStackTrace(staticNetworkThread, /* printNativeStackTrace= */ false);
|
|
|
|
|
printStackTrace(staticWorkerThread, /* printNativeStackTrace= */ false);
|
|
|
|
|
printStackTrace(staticSignalingThread, /* printNativeStackTrace= */ false);
|
2019-01-20 12:43:00 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Print the Java stack traces for the critical threads used by PeerConnectionFactory, namely;
|
|
|
|
|
* signaling thread, worker thread, and network thread. If printNativeStackTraces is true, also
|
2022-04-05 09:26:57 +02:00
|
|
|
* attempt to print the C++ stack traces for these threads.
|
2019-01-20 12:43:00 +01:00
|
|
|
*/
|
|
|
|
|
public void printInternalStackTraces(boolean printNativeStackTraces) {
|
2019-01-20 13:44:45 +01:00
|
|
|
printStackTrace(signalingThread, printNativeStackTraces);
|
|
|
|
|
printStackTrace(workerThread, printNativeStackTraces);
|
|
|
|
|
printStackTrace(networkThread, printNativeStackTraces);
|
2015-10-12 14:56:02 -07:00
|
|
|
}
|
|
|
|
|
|
2017-12-12 12:52:54 +01:00
|
|
|
@CalledByNative
|
2019-01-20 12:43:00 +01:00
|
|
|
private void onNetworkThreadReady() {
|
2019-01-20 13:44:45 +01:00
|
|
|
networkThread = ThreadInfo.getCurrent();
|
2019-01-20 12:43:00 +01:00
|
|
|
staticNetworkThread = networkThread;
|
2016-05-17 01:52:02 -07:00
|
|
|
Logging.d(TAG, "onNetworkThreadReady");
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-12 12:52:54 +01:00
|
|
|
@CalledByNative
|
2019-01-20 12:43:00 +01:00
|
|
|
private void onWorkerThreadReady() {
|
2019-01-20 13:44:45 +01:00
|
|
|
workerThread = ThreadInfo.getCurrent();
|
2019-01-20 12:43:00 +01:00
|
|
|
staticWorkerThread = workerThread;
|
2015-10-07 14:50:13 -07:00
|
|
|
Logging.d(TAG, "onWorkerThreadReady");
|
|
|
|
|
}
|
|
|
|
|
|
2017-12-12 12:52:54 +01:00
|
|
|
@CalledByNative
|
2019-01-20 12:43:00 +01:00
|
|
|
private void onSignalingThreadReady() {
|
2019-01-20 13:44:45 +01:00
|
|
|
signalingThread = ThreadInfo.getCurrent();
|
2019-01-20 12:43:00 +01:00
|
|
|
staticSignalingThread = signalingThread;
|
2015-10-07 14:50:13 -07:00
|
|
|
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-07-13 16:09:20 +02:00
|
|
|
private static native void nativeInitializeAndroidGlobals();
|
2017-12-20 15:12:10 +01:00
|
|
|
private static native void nativeInitializeFieldTrials(String fieldTrialsInitString);
|
2022-06-16 11:40:11 +00:00
|
|
|
private static native String nativeFindFieldTrialsFullName(String name);
|
2017-12-20 15:12:10 +01:00
|
|
|
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-11-01 15:55:26 +01:00
|
|
|
|
2019-01-20 12:43:00 +01:00
|
|
|
private static native PeerConnectionFactory nativeCreatePeerConnectionFactory(Context context,
|
|
|
|
|
Options options, long nativeAudioDeviceModule, long audioEncoderFactory,
|
|
|
|
|
long audioDecoderFactory, VideoEncoderFactory encoderFactory,
|
|
|
|
|
VideoDecoderFactory decoderFactory, long nativeAudioProcessor,
|
2019-04-18 13:40:56 +02:00
|
|
|
long nativeFecControllerFactory, long nativeNetworkControllerFactory,
|
2020-06-10 17:36:17 +02:00
|
|
|
long nativeNetworkStatePredictorFactory, long neteqFactory);
|
2018-11-01 15:55:26 +01:00
|
|
|
|
2017-12-20 15:12:10 +01:00
|
|
|
private static native long nativeCreatePeerConnection(long factory,
|
2018-07-20 15:08:03 -07:00
|
|
|
PeerConnection.RTCConfiguration rtcConfig, MediaConstraints constraints, long nativeObserver,
|
|
|
|
|
SSLCertificateVerifier sslCertificateVerifier);
|
2017-12-20 15:12:10 +01:00
|
|
|
private static native long nativeCreateLocalMediaStream(long factory, String label);
|
2018-11-15 12:07:32 +01:00
|
|
|
private static native long nativeCreateVideoSource(
|
|
|
|
|
long factory, boolean is_screencast, boolean alignTimestamps);
|
2017-12-20 15:12:10 +01:00
|
|
|
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);
|
|
|
|
|
private static native void nativeFreeFactory(long factory);
|
2018-01-15 14:22:53 +01:00
|
|
|
private static native long nativeGetNativePeerConnectionFactory(long factory);
|
2018-06-21 14:31:38 +02:00
|
|
|
private static native void nativeInjectLoggable(JNILogging jniLogging, int severity);
|
|
|
|
|
private static native void nativeDeleteLoggable();
|
2019-01-20 13:44:45 +01:00
|
|
|
private static native void nativePrintStackTrace(int tid);
|
2013-07-10 00:45:36 +00:00
|
|
|
}
|