2013-07-10 00:45:36 +00:00
|
|
|
/*
|
2016-02-10 07:54:43 -08:00
|
|
|
* Copyright 2012 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
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
// This file contains the PeerConnection interface as defined in
|
2018-02-26 14:23:09 -08:00
|
|
|
// https://w3c.github.io/webrtc-pc/#peer-to-peer-connections
|
2013-07-10 00:45:36 +00:00
|
|
|
//
|
2017-02-08 01:38:21 -08:00
|
|
|
// The PeerConnectionFactory class provides factory methods to create
|
|
|
|
|
// PeerConnection, MediaStream and MediaStreamTrack objects.
|
|
|
|
|
//
|
|
|
|
|
// The following steps are needed to setup a typical call using WebRTC:
|
|
|
|
|
//
|
2013-07-10 00:45:36 +00:00
|
|
|
// 1. Create a PeerConnectionFactoryInterface. Check constructors for more
|
|
|
|
|
// information about input parameters.
|
2017-02-08 01:38:21 -08:00
|
|
|
//
|
|
|
|
|
// 2. Create a PeerConnection object. Provide a configuration struct which
|
|
|
|
|
// points to STUN and/or TURN servers used to generate ICE candidates, and
|
|
|
|
|
// provide an object that implements the PeerConnectionObserver interface,
|
|
|
|
|
// which is used to receive callbacks from the PeerConnection.
|
|
|
|
|
//
|
|
|
|
|
// 3. Create local MediaStreamTracks using the PeerConnectionFactory and add
|
|
|
|
|
// them to PeerConnection by calling AddTrack (or legacy method, AddStream).
|
|
|
|
|
//
|
|
|
|
|
// 4. Create an offer, call SetLocalDescription with it, serialize it, and send
|
|
|
|
|
// it to the remote peer
|
|
|
|
|
//
|
|
|
|
|
// 5. Once an ICE candidate has been gathered, the PeerConnection will call the
|
2013-07-10 00:45:36 +00:00
|
|
|
// observer function OnIceCandidate. The candidates must also be serialized and
|
|
|
|
|
// sent to the remote peer.
|
2017-02-08 01:38:21 -08:00
|
|
|
//
|
2013-07-10 00:45:36 +00:00
|
|
|
// 6. Once an answer is received from the remote peer, call
|
2017-02-08 01:38:21 -08:00
|
|
|
// SetRemoteDescription with the remote answer.
|
|
|
|
|
//
|
2013-07-10 00:45:36 +00:00
|
|
|
// 7. Once a remote candidate is received from the remote peer, provide it to
|
2017-02-08 01:38:21 -08:00
|
|
|
// the PeerConnection by calling AddIceCandidate.
|
|
|
|
|
//
|
|
|
|
|
// The receiver of a call (assuming the application is "call"-based) can decide
|
|
|
|
|
// to accept or reject the call; this decision will be taken by the application,
|
|
|
|
|
// not the PeerConnection.
|
|
|
|
|
//
|
|
|
|
|
// If the application decides to accept the call, it should:
|
|
|
|
|
//
|
2013-07-10 00:45:36 +00:00
|
|
|
// 1. Create PeerConnectionFactoryInterface if it doesn't exist.
|
2017-02-08 01:38:21 -08:00
|
|
|
//
|
2013-07-10 00:45:36 +00:00
|
|
|
// 2. Create a new PeerConnection.
|
2017-02-08 01:38:21 -08:00
|
|
|
//
|
2013-07-10 00:45:36 +00:00
|
|
|
// 3. Provide the remote offer to the new PeerConnection object by calling
|
2017-02-08 01:38:21 -08:00
|
|
|
// SetRemoteDescription.
|
|
|
|
|
//
|
2013-07-10 00:45:36 +00:00
|
|
|
// 4. Generate an answer to the remote offer by calling CreateAnswer and send it
|
|
|
|
|
// back to the remote peer.
|
2017-02-08 01:38:21 -08:00
|
|
|
//
|
2013-07-10 00:45:36 +00:00
|
|
|
// 5. Provide the local answer to the new PeerConnection by calling
|
2017-02-08 01:38:21 -08:00
|
|
|
// SetLocalDescription with the answer.
|
|
|
|
|
//
|
|
|
|
|
// 6. Provide the remote ICE candidates by calling AddIceCandidate.
|
|
|
|
|
//
|
|
|
|
|
// 7. Once a candidate has been gathered, the PeerConnection will call the
|
|
|
|
|
// observer function OnIceCandidate. Send these candidates to the remote peer.
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2019-01-11 09:11:00 -08:00
|
|
|
#ifndef API_PEER_CONNECTION_INTERFACE_H_
|
|
|
|
|
#define API_PEER_CONNECTION_INTERFACE_H_
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2019-06-11 14:04:16 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
|
|
2016-04-27 06:47:29 -07:00
|
|
|
#include <memory>
|
2013-07-10 00:45:36 +00:00
|
|
|
#include <string>
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "api/async_resolver_factory.h"
|
2018-02-13 15:03:43 +01:00
|
|
|
#include "api/audio/audio_mixer.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "api/audio_codecs/audio_decoder_factory.h"
|
|
|
|
|
#include "api/audio_codecs/audio_encoder_factory.h"
|
2018-01-19 11:28:54 +01:00
|
|
|
#include "api/audio_options.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "api/call/call_factory_interface.h"
|
|
|
|
|
#include "api/crypto/crypto_options.h"
|
|
|
|
|
#include "api/data_channel_interface.h"
|
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
|
|
|
#include "api/fec_controller.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "api/jsep.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "api/media_stream_interface.h"
|
2018-10-08 09:43:21 -07:00
|
|
|
#include "api/media_transport_interface.h"
|
2019-04-10 13:48:24 +02:00
|
|
|
#include "api/network_state_predictor.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "api/rtc_error.h"
|
2019-05-22 13:39:25 +02:00
|
|
|
#include "api/rtc_event_log/rtc_event_log_factory_interface.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "api/rtc_event_log_output.h"
|
|
|
|
|
#include "api/rtp_receiver_interface.h"
|
|
|
|
|
#include "api/rtp_sender_interface.h"
|
|
|
|
|
#include "api/rtp_transceiver_interface.h"
|
|
|
|
|
#include "api/set_remote_description_observer_interface.h"
|
|
|
|
|
#include "api/stats/rtc_stats_collector_callback.h"
|
|
|
|
|
#include "api/stats_types.h"
|
2019-04-01 10:33:16 +02:00
|
|
|
#include "api/task_queue/task_queue_factory.h"
|
2018-05-07 14:01:37 +02:00
|
|
|
#include "api/transport/bitrate_settings.h"
|
2018-05-18 18:05:10 +02:00
|
|
|
#include "api/transport/network_control.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "api/turn_customizer.h"
|
|
|
|
|
#include "media/base/media_config.h"
|
2018-02-14 12:20:13 +01:00
|
|
|
// TODO(bugs.webrtc.org/7447): We plan to provide a way to let applications
|
|
|
|
|
// inject a PacketSocketFactory and/or NetworkManager, and not expose
|
|
|
|
|
// PortAllocator in the PeerConnection api.
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "media/base/media_engine.h" // nogncheck
|
|
|
|
|
#include "p2p/base/port_allocator.h" // nogncheck
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "rtc_base/network.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "rtc_base/rtc_certificate.h"
|
|
|
|
|
#include "rtc_base/rtc_certificate_generator.h"
|
|
|
|
|
#include "rtc_base/socket_address.h"
|
|
|
|
|
#include "rtc_base/ssl_certificate.h"
|
|
|
|
|
#include "rtc_base/ssl_stream_adapter.h"
|
2018-10-16 14:13:50 +02:00
|
|
|
#include "rtc_base/system/rtc_export.h"
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
namespace rtc {
|
2015-03-04 22:17:38 +00:00
|
|
|
class SSLIdentity;
|
2013-07-10 00:45:36 +00:00
|
|
|
class Thread;
|
2018-06-19 15:03:05 +02:00
|
|
|
} // namespace rtc
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
class AudioDeviceModule;
|
2016-12-13 14:06:26 -08:00
|
|
|
class AudioMixer;
|
2018-02-14 12:20:13 +01:00
|
|
|
class AudioProcessing;
|
2018-11-28 16:47:46 +01:00
|
|
|
class DtlsTransportInterface;
|
2019-02-28 07:51:00 +01:00
|
|
|
class SctpTransportInterface;
|
2017-09-15 19:02:47 +02:00
|
|
|
class VideoDecoderFactory;
|
|
|
|
|
class VideoEncoderFactory;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
// MediaStream container interface.
|
2014-07-29 17:36:52 +00:00
|
|
|
class StreamCollectionInterface : public rtc::RefCountInterface {
|
2013-07-10 00:45:36 +00:00
|
|
|
public:
|
|
|
|
|
// TODO(ronghuawu): Update the function names to c++ style, e.g. find -> Find.
|
|
|
|
|
virtual size_t count() = 0;
|
|
|
|
|
virtual MediaStreamInterface* at(size_t index) = 0;
|
|
|
|
|
virtual MediaStreamInterface* find(const std::string& label) = 0;
|
2018-06-19 15:03:05 +02:00
|
|
|
virtual MediaStreamTrackInterface* FindAudioTrack(const std::string& id) = 0;
|
|
|
|
|
virtual MediaStreamTrackInterface* FindVideoTrack(const std::string& id) = 0;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
// Dtor protected as objects shouldn't be deleted via this interface.
|
2018-07-19 10:39:30 +02:00
|
|
|
~StreamCollectionInterface() override = default;
|
2013-07-10 00:45:36 +00:00
|
|
|
};
|
|
|
|
|
|
2014-07-29 17:36:52 +00:00
|
|
|
class StatsObserver : public rtc::RefCountInterface {
|
2013-07-10 00:45:36 +00:00
|
|
|
public:
|
Revert of New method StatsObserver::OnCompleteReports, passing ownership. (patchset #2 id:20001 of https://codereview.webrtc.org/2584553002/ )
Reason for revert:
The new method doesn't work as intended.
It can't pass ownership, because the StatsReports is a vector of raw pointers to StatReport objects owned by the StatsCollector.
Original issue's description:
> New method StatsObserver::OnCompleteReports, passing ownership.
>
> The new name, OnCompleteReports rather than OnComplete, is needed
> because in C++ method lookup, overriding a method hides all otherwise
> inherited methods with the same name, even if they have a different
> signature. And here, the intention is that each subclass should
> override one or the other of the two methods, and inherit the method it
> doesn't override.
>
> This cl is a prerequisite for
> https://codereview.webrtc.org/2567143003/, because the Chrome glue
> code needs to retain the stats report after the OnComplete method has
> returned.
>
> Currently, Chrome makes a copy of the stats mapping (which breaks when
> changing ValuePtr from an rtc::linked_ptr to an std::unique_ptr). After
> this cl, Chrome can be fixed to take ownership and no longer needs to
> copy anything, unblocking cl 2567143003.
>
> BUG=webrtc:6424
>
> Review-Url: https://codereview.webrtc.org/2584553002
> Cr-Commit-Position: refs/heads/master@{#15708}
> Committed: https://chromium.googlesource.com/external/webrtc/+/b36ee8d498be2fa58fde3f3f3d69a74e4d3b817d
TBR=solenberg@webrtc.org,magjed@webrtc.org,tkchin@webrtc.org,hbos@webrtc.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=webrtc:6424
Review-Url: https://codereview.webrtc.org/2641783002
Cr-Commit-Position: refs/heads/master@{#16144}
2017-01-18 05:00:34 -08:00
|
|
|
virtual void OnComplete(const StatsReports& reports) = 0;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
protected:
|
2018-07-19 10:39:30 +02:00
|
|
|
~StatsObserver() override = default;
|
2013-07-10 00:45:36 +00:00
|
|
|
};
|
|
|
|
|
|
2018-04-12 17:21:03 -07:00
|
|
|
enum class SdpSemantics { kPlanB, kUnifiedPlan };
|
2017-11-20 10:25:56 -08:00
|
|
|
|
2019-04-02 11:33:59 +02:00
|
|
|
class RTC_EXPORT PeerConnectionInterface : public rtc::RefCountInterface {
|
2013-07-10 00:45:36 +00:00
|
|
|
public:
|
2018-10-18 15:58:17 +02:00
|
|
|
// See https://w3c.github.io/webrtc-pc/#dom-rtcsignalingstate
|
2013-07-10 00:45:36 +00:00
|
|
|
enum SignalingState {
|
|
|
|
|
kStable,
|
|
|
|
|
kHaveLocalOffer,
|
|
|
|
|
kHaveLocalPrAnswer,
|
|
|
|
|
kHaveRemoteOffer,
|
|
|
|
|
kHaveRemotePrAnswer,
|
|
|
|
|
kClosed,
|
|
|
|
|
};
|
|
|
|
|
|
2018-10-18 15:58:17 +02:00
|
|
|
// See https://w3c.github.io/webrtc-pc/#dom-rtcicegatheringstate
|
2013-07-10 00:45:36 +00:00
|
|
|
enum IceGatheringState {
|
|
|
|
|
kIceGatheringNew,
|
|
|
|
|
kIceGatheringGathering,
|
|
|
|
|
kIceGatheringComplete
|
|
|
|
|
};
|
|
|
|
|
|
2018-10-18 15:58:17 +02:00
|
|
|
// See https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnectionstate
|
|
|
|
|
enum class PeerConnectionState {
|
|
|
|
|
kNew,
|
|
|
|
|
kConnecting,
|
|
|
|
|
kConnected,
|
|
|
|
|
kDisconnected,
|
|
|
|
|
kFailed,
|
|
|
|
|
kClosed,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// See https://w3c.github.io/webrtc-pc/#dom-rtciceconnectionstate
|
2013-07-10 00:45:36 +00:00
|
|
|
enum IceConnectionState {
|
|
|
|
|
kIceConnectionNew,
|
|
|
|
|
kIceConnectionChecking,
|
|
|
|
|
kIceConnectionConnected,
|
|
|
|
|
kIceConnectionCompleted,
|
|
|
|
|
kIceConnectionFailed,
|
|
|
|
|
kIceConnectionDisconnected,
|
|
|
|
|
kIceConnectionClosed,
|
2015-08-19 16:51:15 -07:00
|
|
|
kIceConnectionMax,
|
2013-07-10 00:45:36 +00:00
|
|
|
};
|
|
|
|
|
|
2017-01-09 08:35:45 -08:00
|
|
|
// TLS certificate policy.
|
|
|
|
|
enum TlsCertPolicy {
|
|
|
|
|
// For TLS based protocols, ensure the connection is secure by not
|
|
|
|
|
// circumventing certificate validation.
|
|
|
|
|
kTlsCertPolicySecure,
|
|
|
|
|
// For TLS based protocols, disregard security completely by skipping
|
|
|
|
|
// certificate validation. This is insecure and should never be used unless
|
|
|
|
|
// security is irrelevant in that particular context.
|
|
|
|
|
kTlsCertPolicyInsecureNoCheck,
|
|
|
|
|
};
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
struct IceServer {
|
2018-07-19 10:39:30 +02:00
|
|
|
IceServer();
|
|
|
|
|
IceServer(const IceServer&);
|
|
|
|
|
~IceServer();
|
|
|
|
|
|
2015-05-28 23:06:30 +02:00
|
|
|
// TODO(jbauch): Remove uri when all code using it has switched to urls.
|
2017-06-16 15:43:11 -07:00
|
|
|
// List of URIs associated with this server. Valid formats are described
|
|
|
|
|
// in RFC7064 and RFC7065, and more may be added in the future. The "host"
|
|
|
|
|
// part of the URI may contain either an IP address or a hostname.
|
2013-07-10 00:45:36 +00:00
|
|
|
std::string uri;
|
2015-05-28 23:06:30 +02:00
|
|
|
std::vector<std::string> urls;
|
2013-07-10 00:45:36 +00:00
|
|
|
std::string username;
|
|
|
|
|
std::string password;
|
2017-01-09 08:35:45 -08:00
|
|
|
TlsCertPolicy tls_cert_policy = kTlsCertPolicySecure;
|
2017-06-16 15:43:11 -07:00
|
|
|
// If the URIs in |urls| only contain IP addresses, this field can be used
|
|
|
|
|
// to indicate the hostname, which may be necessary for TLS (using the SNI
|
|
|
|
|
// extension). If |urls| itself contains the hostname, this isn't
|
|
|
|
|
// necessary.
|
|
|
|
|
std::string hostname;
|
2017-08-29 12:18:32 -07:00
|
|
|
// List of protocols to be used in the TLS ALPN extension.
|
|
|
|
|
std::vector<std::string> tls_alpn_protocols;
|
2017-09-08 12:50:41 -07:00
|
|
|
// List of elliptic curves to be used in the TLS elliptic curves extension.
|
|
|
|
|
std::vector<std::string> tls_elliptic_curves;
|
2017-01-09 08:35:45 -08:00
|
|
|
|
2016-12-10 13:15:33 -08:00
|
|
|
bool operator==(const IceServer& o) const {
|
|
|
|
|
return uri == o.uri && urls == o.urls && username == o.username &&
|
2017-06-16 15:43:11 -07:00
|
|
|
password == o.password && tls_cert_policy == o.tls_cert_policy &&
|
2017-08-29 12:18:32 -07:00
|
|
|
hostname == o.hostname &&
|
2017-09-08 12:50:41 -07:00
|
|
|
tls_alpn_protocols == o.tls_alpn_protocols &&
|
2018-09-12 10:45:38 +00:00
|
|
|
tls_elliptic_curves == o.tls_elliptic_curves;
|
2016-12-10 13:15:33 -08:00
|
|
|
}
|
|
|
|
|
bool operator!=(const IceServer& o) const { return !(*this == o); }
|
2013-07-10 00:45:36 +00:00
|
|
|
};
|
|
|
|
|
typedef std::vector<IceServer> IceServers;
|
|
|
|
|
|
2014-05-03 05:39:45 +00:00
|
|
|
enum IceTransportsType {
|
2015-01-14 23:19:06 +00:00
|
|
|
// TODO(pthatcher): Rename these kTransporTypeXXX, but update
|
|
|
|
|
// Chromium at the same time.
|
2014-05-03 05:39:45 +00:00
|
|
|
kNone,
|
|
|
|
|
kRelay,
|
|
|
|
|
kNoHost,
|
|
|
|
|
kAll
|
|
|
|
|
};
|
|
|
|
|
|
2018-02-26 14:23:09 -08:00
|
|
|
// https://tools.ietf.org/html/draft-ietf-rtcweb-jsep-24#section-4.1.1
|
2015-01-14 23:19:06 +00:00
|
|
|
enum BundlePolicy {
|
|
|
|
|
kBundlePolicyBalanced,
|
|
|
|
|
kBundlePolicyMaxBundle,
|
|
|
|
|
kBundlePolicyMaxCompat
|
|
|
|
|
};
|
|
|
|
|
|
2018-02-26 14:23:09 -08:00
|
|
|
// https://tools.ietf.org/html/draft-ietf-rtcweb-jsep-24#section-4.1.1
|
2015-05-21 07:48:41 -07:00
|
|
|
enum RtcpMuxPolicy {
|
|
|
|
|
kRtcpMuxPolicyNegotiate,
|
|
|
|
|
kRtcpMuxPolicyRequire,
|
|
|
|
|
};
|
|
|
|
|
|
2015-04-30 12:35:24 -07:00
|
|
|
enum TcpCandidatePolicy {
|
|
|
|
|
kTcpCandidatePolicyEnabled,
|
|
|
|
|
kTcpCandidatePolicyDisabled
|
|
|
|
|
};
|
|
|
|
|
|
2016-05-31 18:29:12 -07:00
|
|
|
enum CandidateNetworkPolicy {
|
|
|
|
|
kCandidateNetworkPolicyAll,
|
|
|
|
|
kCandidateNetworkPolicyLowCost
|
|
|
|
|
};
|
|
|
|
|
|
2018-06-19 15:03:05 +02:00
|
|
|
enum ContinualGatheringPolicy { GATHER_ONCE, GATHER_CONTINUALLY };
|
2015-09-28 07:57:34 -07:00
|
|
|
|
2016-09-01 15:34:01 -07:00
|
|
|
enum class RTCConfigurationType {
|
|
|
|
|
// A configuration that is safer to use, despite not having the best
|
|
|
|
|
// performance. Currently this is the default configuration.
|
|
|
|
|
kSafe,
|
|
|
|
|
// An aggressive configuration that has better performance, although it
|
|
|
|
|
// may be riskier and may need extra support in the application.
|
|
|
|
|
kAggressive
|
|
|
|
|
};
|
|
|
|
|
|
2015-08-25 09:53:21 +02:00
|
|
|
// TODO(hbos): Change into class with private data and public getters.
|
2016-04-11 23:25:29 -07:00
|
|
|
// TODO(nisse): In particular, accessing fields directly from an
|
|
|
|
|
// application is brittle, since the organization mirrors the
|
|
|
|
|
// organization of the implementation, which isn't stable. So we
|
|
|
|
|
// need getters and setters at least for fields which applications
|
|
|
|
|
// are interested in.
|
2018-10-22 17:08:37 +02:00
|
|
|
struct RTC_EXPORT RTCConfiguration {
|
2016-03-31 12:59:59 +02:00
|
|
|
// This struct is subject to reorganization, both for naming
|
|
|
|
|
// consistency, and to group settings to match where they are used
|
|
|
|
|
// in the implementation. To do that, we need getter and setter
|
|
|
|
|
// methods for all settings which are of interest to applications,
|
|
|
|
|
// Chrome in particular.
|
|
|
|
|
|
2018-07-19 10:39:30 +02:00
|
|
|
RTCConfiguration();
|
|
|
|
|
RTCConfiguration(const RTCConfiguration&);
|
|
|
|
|
explicit RTCConfiguration(RTCConfigurationType type);
|
|
|
|
|
~RTCConfiguration();
|
2016-08-30 22:07:42 -07:00
|
|
|
|
2017-01-11 12:28:30 -08:00
|
|
|
bool operator==(const RTCConfiguration& o) const;
|
|
|
|
|
bool operator!=(const RTCConfiguration& o) const;
|
|
|
|
|
|
2018-01-18 08:58:50 +01:00
|
|
|
bool dscp() const { return media_config.enable_dscp; }
|
2016-04-11 23:25:29 -07:00
|
|
|
void set_dscp(bool enable) { media_config.enable_dscp = enable; }
|
2016-03-31 12:59:59 +02:00
|
|
|
|
2018-01-18 08:58:50 +01:00
|
|
|
bool cpu_adaptation() const {
|
2018-01-18 15:25:12 +01:00
|
|
|
return media_config.video.enable_cpu_adaptation;
|
2016-04-11 23:25:29 -07:00
|
|
|
}
|
2016-03-31 12:59:59 +02:00
|
|
|
void set_cpu_adaptation(bool enable) {
|
2018-01-18 15:25:12 +01:00
|
|
|
media_config.video.enable_cpu_adaptation = enable;
|
2016-03-31 12:59:59 +02:00
|
|
|
}
|
|
|
|
|
|
2018-01-18 08:58:50 +01:00
|
|
|
bool suspend_below_min_bitrate() const {
|
2016-04-11 23:25:29 -07:00
|
|
|
return media_config.video.suspend_below_min_bitrate;
|
|
|
|
|
}
|
2016-03-31 12:59:59 +02:00
|
|
|
void set_suspend_below_min_bitrate(bool enable) {
|
2016-04-11 23:25:29 -07:00
|
|
|
media_config.video.suspend_below_min_bitrate = enable;
|
2016-03-31 12:59:59 +02:00
|
|
|
}
|
|
|
|
|
|
2018-01-18 08:58:50 +01:00
|
|
|
bool prerenderer_smoothing() const {
|
2018-01-18 15:25:12 +01:00
|
|
|
return media_config.video.enable_prerenderer_smoothing;
|
2016-04-11 23:25:29 -07:00
|
|
|
}
|
2016-03-31 12:59:59 +02:00
|
|
|
void set_prerenderer_smoothing(bool enable) {
|
2018-01-18 15:25:12 +01:00
|
|
|
media_config.video.enable_prerenderer_smoothing = enable;
|
2016-03-31 12:59:59 +02:00
|
|
|
}
|
|
|
|
|
|
2018-01-18 08:58:50 +01:00
|
|
|
bool experiment_cpu_load_estimator() const {
|
|
|
|
|
return media_config.video.experiment_cpu_load_estimator;
|
|
|
|
|
}
|
|
|
|
|
void set_experiment_cpu_load_estimator(bool enable) {
|
|
|
|
|
media_config.video.experiment_cpu_load_estimator = enable;
|
|
|
|
|
}
|
2018-05-28 10:24:22 +02:00
|
|
|
|
2018-11-09 13:17:39 -08:00
|
|
|
int audio_rtcp_report_interval_ms() const {
|
|
|
|
|
return media_config.audio.rtcp_report_interval_ms;
|
|
|
|
|
}
|
|
|
|
|
void set_audio_rtcp_report_interval_ms(int audio_rtcp_report_interval_ms) {
|
|
|
|
|
media_config.audio.rtcp_report_interval_ms =
|
|
|
|
|
audio_rtcp_report_interval_ms;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int video_rtcp_report_interval_ms() const {
|
|
|
|
|
return media_config.video.rtcp_report_interval_ms;
|
|
|
|
|
}
|
|
|
|
|
void set_video_rtcp_report_interval_ms(int video_rtcp_report_interval_ms) {
|
|
|
|
|
media_config.video.rtcp_report_interval_ms =
|
|
|
|
|
video_rtcp_report_interval_ms;
|
|
|
|
|
}
|
|
|
|
|
|
2015-09-01 09:53:56 -07:00
|
|
|
static const int kUndefined = -1;
|
|
|
|
|
// Default maximum number of packets in the audio jitter buffer.
|
2019-03-15 10:37:31 +01:00
|
|
|
static const int kAudioJitterBufferMaxPackets = 200;
|
2016-09-02 16:58:17 -07:00
|
|
|
// ICE connection receiving timeout for aggressive configuration.
|
|
|
|
|
static const int kAggressiveIceConnectionReceivingTimeout = 1000;
|
2017-02-08 01:38:21 -08:00
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// The below few fields mirror the standard RTCConfiguration dictionary:
|
2018-02-26 14:23:09 -08:00
|
|
|
// https://w3c.github.io/webrtc-pc/#rtcconfiguration-dictionary
|
2017-02-08 01:38:21 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
2015-01-14 23:19:06 +00:00
|
|
|
// TODO(pthatcher): Rename this ice_servers, but update Chromium
|
|
|
|
|
// at the same time.
|
2014-05-03 05:39:45 +00:00
|
|
|
IceServers servers;
|
2017-02-08 01:38:21 -08:00
|
|
|
// TODO(pthatcher): Rename this ice_transport_type, but update
|
|
|
|
|
// Chromium at the same time.
|
|
|
|
|
IceTransportsType type = kAll;
|
2016-05-13 08:15:11 -07:00
|
|
|
BundlePolicy bundle_policy = kBundlePolicyBalanced;
|
2016-11-23 10:30:12 -08:00
|
|
|
RtcpMuxPolicy rtcp_mux_policy = kRtcpMuxPolicyRequire;
|
2017-02-08 01:38:21 -08:00
|
|
|
std::vector<rtc::scoped_refptr<rtc::RTCCertificate>> certificates;
|
|
|
|
|
int ice_candidate_pool_size = 0;
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// The below fields correspond to constraints from the deprecated
|
|
|
|
|
// constraints interface for constructing a PeerConnection.
|
|
|
|
|
//
|
2018-06-21 13:32:56 +02:00
|
|
|
// absl::optional fields can be "missing", in which case the implementation
|
2017-02-08 01:38:21 -08:00
|
|
|
// default will be used.
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
// If set to true, don't gather IPv6 ICE candidates.
|
|
|
|
|
// TODO(deadbeef): Remove this? IPv6 support has long stopped being
|
|
|
|
|
// experimental
|
|
|
|
|
bool disable_ipv6 = false;
|
|
|
|
|
|
2017-03-07 14:40:51 -08:00
|
|
|
// If set to true, don't gather IPv6 ICE candidates on Wi-Fi.
|
|
|
|
|
// Only intended to be used on specific devices. Certain phones disable IPv6
|
|
|
|
|
// when the screen is turned off and it would be better to just disable the
|
|
|
|
|
// IPv6 ICE candidates on Wi-Fi in those cases.
|
|
|
|
|
bool disable_ipv6_on_wifi = false;
|
|
|
|
|
|
2017-07-26 16:50:11 -07:00
|
|
|
// By default, the PeerConnection will use a limited number of IPv6 network
|
|
|
|
|
// interfaces, in order to avoid too many ICE candidate pairs being created
|
|
|
|
|
// and delaying ICE completion.
|
|
|
|
|
//
|
|
|
|
|
// Can be set to INT_MAX to effectively disable the limit.
|
|
|
|
|
int max_ipv6_networks = cricket::kDefaultMaxIPv6Networks;
|
|
|
|
|
|
2018-01-25 10:30:22 +01:00
|
|
|
// Exclude link-local network interfaces
|
|
|
|
|
// from considertaion for gathering ICE candidates.
|
|
|
|
|
bool disable_link_local_networks = false;
|
|
|
|
|
|
2017-02-08 01:38:21 -08:00
|
|
|
// If set to true, use RTP data channels instead of SCTP.
|
|
|
|
|
// TODO(deadbeef): Remove this. We no longer commit to supporting RTP data
|
|
|
|
|
// channels, though some applications are still working on moving off of
|
|
|
|
|
// them.
|
|
|
|
|
bool enable_rtp_data_channel = false;
|
|
|
|
|
|
|
|
|
|
// Minimum bitrate at which screencast video tracks will be encoded at.
|
|
|
|
|
// This means adding padding bits up to this bitrate, which can help
|
|
|
|
|
// when switching from a static scene to one with motion.
|
2018-06-21 13:32:56 +02:00
|
|
|
absl::optional<int> screencast_min_bitrate;
|
2017-02-08 01:38:21 -08:00
|
|
|
|
|
|
|
|
// Use new combined audio/video bandwidth estimation?
|
2018-06-21 13:32:56 +02:00
|
|
|
absl::optional<bool> combined_audio_video_bwe;
|
2017-02-08 01:38:21 -08:00
|
|
|
|
2018-10-25 10:16:44 -07:00
|
|
|
// TODO(bugs.webrtc.org/9891) - Move to crypto_options
|
2017-02-08 01:38:21 -08:00
|
|
|
// Can be used to disable DTLS-SRTP. This should never be done, but can be
|
|
|
|
|
// useful for testing purposes, for example in setting up a loopback call
|
|
|
|
|
// with a single PeerConnection.
|
2018-06-21 13:32:56 +02:00
|
|
|
absl::optional<bool> enable_dtls_srtp;
|
2017-02-08 01:38:21 -08:00
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////
|
|
|
|
|
// The below fields are not part of the standard.
|
|
|
|
|
/////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
// Can be used to disable TCP candidate generation.
|
2016-05-13 08:15:11 -07:00
|
|
|
TcpCandidatePolicy tcp_candidate_policy = kTcpCandidatePolicyEnabled;
|
2017-02-08 01:38:21 -08:00
|
|
|
|
|
|
|
|
// Can be used to avoid gathering candidates for a "higher cost" network,
|
|
|
|
|
// if a lower cost one exists. For example, if both Wi-Fi and cellular
|
|
|
|
|
// interfaces are available, this could be used to avoid using the cellular
|
|
|
|
|
// interface.
|
2016-05-31 18:29:12 -07:00
|
|
|
CandidateNetworkPolicy candidate_network_policy =
|
|
|
|
|
kCandidateNetworkPolicyAll;
|
2017-02-08 01:38:21 -08:00
|
|
|
|
|
|
|
|
// The maximum number of packets that can be stored in the NetEq audio
|
|
|
|
|
// jitter buffer. Can be reduced to lower tolerated audio latency.
|
2016-05-13 08:15:11 -07:00
|
|
|
int audio_jitter_buffer_max_packets = kAudioJitterBufferMaxPackets;
|
2017-02-08 01:38:21 -08:00
|
|
|
|
|
|
|
|
// Whether to use the NetEq "fast mode" which will accelerate audio quicker
|
|
|
|
|
// if it falls behind.
|
2016-05-13 08:15:11 -07:00
|
|
|
bool audio_jitter_buffer_fast_accelerate = false;
|
2017-02-08 01:38:21 -08:00
|
|
|
|
2018-11-27 15:45:20 +01:00
|
|
|
// The minimum delay in milliseconds for the audio jitter buffer.
|
|
|
|
|
int audio_jitter_buffer_min_delay_ms = 0;
|
|
|
|
|
|
2019-01-10 15:58:36 +01:00
|
|
|
// Whether the audio jitter buffer adapts the delay to retransmitted
|
|
|
|
|
// packets.
|
|
|
|
|
bool audio_jitter_buffer_enable_rtx_handling = false;
|
|
|
|
|
|
2017-02-08 01:38:21 -08:00
|
|
|
// Timeout in milliseconds before an ICE candidate pair is considered to be
|
|
|
|
|
// "not receiving", after which a lower priority candidate pair may be
|
|
|
|
|
// selected.
|
|
|
|
|
int ice_connection_receiving_timeout = kUndefined;
|
|
|
|
|
|
|
|
|
|
// Interval in milliseconds at which an ICE "backup" candidate pair will be
|
|
|
|
|
// pinged. This is a candidate pair which is not actively in use, but may
|
|
|
|
|
// be switched to if the active candidate pair becomes unusable.
|
|
|
|
|
//
|
|
|
|
|
// This is relevant mainly to Wi-Fi/cell handoff; the application may not
|
|
|
|
|
// want this backup cellular candidate pair pinged frequently, since it
|
|
|
|
|
// consumes data/battery.
|
|
|
|
|
int ice_backup_candidate_pair_ping_interval = kUndefined;
|
|
|
|
|
|
|
|
|
|
// Can be used to enable continual gathering, which means new candidates
|
|
|
|
|
// will be gathered as network interfaces change. Note that if continual
|
|
|
|
|
// gathering is used, the candidate removal API should also be used, to
|
|
|
|
|
// avoid an ever-growing list of candidates.
|
2016-05-13 08:15:11 -07:00
|
|
|
ContinualGatheringPolicy continual_gathering_policy = GATHER_ONCE;
|
2017-02-08 01:38:21 -08:00
|
|
|
|
|
|
|
|
// If set to true, candidate pairs will be pinged in order of most likely
|
|
|
|
|
// to work (which means using a TURN server, generally), rather than in
|
|
|
|
|
// standard priority order.
|
2016-05-13 08:15:11 -07:00
|
|
|
bool prioritize_most_likely_ice_candidate_pairs = false;
|
2017-02-08 01:38:21 -08:00
|
|
|
|
2018-01-23 10:37:42 +01:00
|
|
|
// Implementation defined settings. A public member only for the benefit of
|
|
|
|
|
// the implementation. Applications must not access it directly, and should
|
|
|
|
|
// instead use provided accessor methods, e.g., set_cpu_adaptation.
|
2016-04-11 23:25:29 -07:00
|
|
|
struct cricket::MediaConfig media_config;
|
2017-02-08 01:38:21 -08:00
|
|
|
|
|
|
|
|
// If set to true, only one preferred TURN allocation will be used per
|
|
|
|
|
// network interface. UDP is preferred over TCP and IPv6 over IPv4. This
|
|
|
|
|
// can be used to cut down on the number of candidate pairings.
|
2016-06-30 20:52:02 -07:00
|
|
|
bool prune_turn_ports = false;
|
2017-02-08 01:38:21 -08:00
|
|
|
|
2016-07-01 11:11:13 -07:00
|
|
|
// If set to true, this means the ICE transport should presume TURN-to-TURN
|
|
|
|
|
// candidate pairs will succeed, even before a binding response is received.
|
2017-02-08 01:38:21 -08:00
|
|
|
// This can be used to optimize the initial connection time, since the DTLS
|
|
|
|
|
// handshake can begin immediately.
|
2016-07-01 11:11:13 -07:00
|
|
|
bool presume_writable_when_fully_relayed = false;
|
2017-02-08 01:38:21 -08:00
|
|
|
|
2016-08-31 08:18:11 -07:00
|
|
|
// If true, "renomination" will be added to the ice options in the transport
|
|
|
|
|
// description.
|
2017-02-08 01:38:21 -08:00
|
|
|
// See: https://tools.ietf.org/html/draft-thatcher-ice-renomination-00
|
2016-08-31 08:18:11 -07:00
|
|
|
bool enable_ice_renomination = false;
|
2017-02-08 01:38:21 -08:00
|
|
|
|
|
|
|
|
// If true, the ICE role is re-determined when the PeerConnection sets a
|
|
|
|
|
// local transport description that indicates an ICE restart.
|
|
|
|
|
//
|
|
|
|
|
// This is standard RFC5245 ICE behavior, but causes unnecessary role
|
|
|
|
|
// thrashing, so an application may wish to avoid it. This role
|
|
|
|
|
// re-determining was removed in ICEbis (ICE v2).
|
2016-08-30 22:07:42 -07:00
|
|
|
bool redetermine_role_on_ice_restart = true;
|
2017-02-08 01:38:21 -08:00
|
|
|
|
2019-05-31 16:55:33 -07:00
|
|
|
// This flag is only effective when |continual_gathering_policy| is
|
|
|
|
|
// GATHER_CONTINUALLY.
|
|
|
|
|
//
|
|
|
|
|
// If true, after the ICE transport type is changed such that new types of
|
|
|
|
|
// ICE candidates are allowed by the new transport type, e.g. from
|
|
|
|
|
// IceTransportsType::kRelay to IceTransportsType::kAll, candidates that
|
|
|
|
|
// have been gathered by the ICE transport but not matching the previous
|
|
|
|
|
// transport type and as a result not observed by PeerConnectionObserver,
|
|
|
|
|
// will be surfaced to the observer.
|
|
|
|
|
bool surface_ice_candidates_on_ice_transport_type_changed = false;
|
|
|
|
|
|
2018-03-08 14:55:14 -08:00
|
|
|
// The following fields define intervals in milliseconds at which ICE
|
|
|
|
|
// connectivity checks are sent.
|
|
|
|
|
//
|
|
|
|
|
// We consider ICE is "strongly connected" for an agent when there is at
|
|
|
|
|
// least one candidate pair that currently succeeds in connectivity check
|
|
|
|
|
// from its direction i.e. sending a STUN ping and receives a STUN ping
|
|
|
|
|
// response, AND all candidate pairs have sent a minimum number of pings for
|
|
|
|
|
// connectivity (this number is implementation-specific). Otherwise, ICE is
|
|
|
|
|
// considered in "weak connectivity".
|
|
|
|
|
//
|
|
|
|
|
// Note that the above notion of strong and weak connectivity is not defined
|
|
|
|
|
// in RFC 5245, and they apply to our current ICE implementation only.
|
|
|
|
|
//
|
|
|
|
|
// 1) ice_check_interval_strong_connectivity defines the interval applied to
|
|
|
|
|
// ALL candidate pairs when ICE is strongly connected, and it overrides the
|
|
|
|
|
// default value of this interval in the ICE implementation;
|
|
|
|
|
// 2) ice_check_interval_weak_connectivity defines the counterpart for ALL
|
|
|
|
|
// pairs when ICE is weakly connected, and it overrides the default value of
|
|
|
|
|
// this interval in the ICE implementation;
|
|
|
|
|
// 3) ice_check_min_interval defines the minimal interval (equivalently the
|
|
|
|
|
// maximum rate) that overrides the above two intervals when either of them
|
|
|
|
|
// is less.
|
2018-06-21 13:32:56 +02:00
|
|
|
absl::optional<int> ice_check_interval_strong_connectivity;
|
|
|
|
|
absl::optional<int> ice_check_interval_weak_connectivity;
|
|
|
|
|
absl::optional<int> ice_check_min_interval;
|
2017-02-08 01:38:21 -08:00
|
|
|
|
2018-03-13 10:53:57 -07:00
|
|
|
// The min time period for which a candidate pair must wait for response to
|
|
|
|
|
// connectivity checks before it becomes unwritable. This parameter
|
|
|
|
|
// overrides the default value in the ICE implementation if set.
|
2018-06-21 13:32:56 +02:00
|
|
|
absl::optional<int> ice_unwritable_timeout;
|
2018-03-13 10:53:57 -07:00
|
|
|
|
|
|
|
|
// The min number of connectivity checks that a candidate pair must sent
|
|
|
|
|
// without receiving response before it becomes unwritable. This parameter
|
|
|
|
|
// overrides the default value in the ICE implementation if set.
|
2018-06-21 13:32:56 +02:00
|
|
|
absl::optional<int> ice_unwritable_min_checks;
|
2018-03-13 10:53:57 -07:00
|
|
|
|
2018-12-06 23:30:17 -08:00
|
|
|
// The min time period for which a candidate pair must wait for response to
|
|
|
|
|
// connectivity checks it becomes inactive. This parameter overrides the
|
|
|
|
|
// default value in the ICE implementation if set.
|
|
|
|
|
absl::optional<int> ice_inactive_timeout;
|
|
|
|
|
|
2018-02-20 14:45:49 -08:00
|
|
|
// The interval in milliseconds at which STUN candidates will resend STUN
|
|
|
|
|
// binding requests to keep NAT bindings open.
|
2018-06-21 13:32:56 +02:00
|
|
|
absl::optional<int> stun_candidate_keepalive_interval;
|
2018-02-20 14:45:49 -08:00
|
|
|
|
2017-07-14 10:13:10 -07:00
|
|
|
// ICE Periodic Regathering
|
|
|
|
|
// If set, WebRTC will periodically create and propose candidates without
|
|
|
|
|
// starting a new ICE generation. The regathering happens continuously with
|
|
|
|
|
// interval specified in milliseconds by the uniform distribution [a, b].
|
2018-06-21 13:32:56 +02:00
|
|
|
absl::optional<rtc::IntervalRange> ice_regather_interval_range;
|
2017-07-14 10:13:10 -07:00
|
|
|
|
2017-10-10 14:01:40 +02:00
|
|
|
// Optional TurnCustomizer.
|
|
|
|
|
// With this class one can modify outgoing TURN messages.
|
|
|
|
|
// The object passed in must remain valid until PeerConnection::Close() is
|
|
|
|
|
// called.
|
|
|
|
|
webrtc::TurnCustomizer* turn_customizer = nullptr;
|
|
|
|
|
|
2018-02-01 10:38:40 -08:00
|
|
|
// Preferred network interface.
|
|
|
|
|
// A candidate pair on a preferred network has a higher precedence in ICE
|
|
|
|
|
// than one on an un-preferred network, regardless of priority or network
|
|
|
|
|
// cost.
|
2018-06-21 13:32:56 +02:00
|
|
|
absl::optional<rtc::AdapterType> network_preference;
|
2018-02-01 10:38:40 -08:00
|
|
|
|
2017-11-20 10:25:56 -08:00
|
|
|
// Configure the SDP semantics used by this PeerConnection. Note that the
|
|
|
|
|
// WebRTC 1.0 specification requires kUnifiedPlan semantics. The
|
|
|
|
|
// RtpTransceiver API is only available with kUnifiedPlan semantics.
|
|
|
|
|
//
|
|
|
|
|
// kPlanB will cause PeerConnection to create offers and answers with at
|
|
|
|
|
// most one audio and one video m= section with multiple RtpSenders and
|
|
|
|
|
// RtpReceivers specified as multiple a=ssrc lines within the section. This
|
2018-02-26 14:23:09 -08:00
|
|
|
// will also cause PeerConnection to ignore all but the first m= section of
|
|
|
|
|
// the same media type.
|
2017-11-20 10:25:56 -08:00
|
|
|
//
|
|
|
|
|
// kUnifiedPlan will cause PeerConnection to create offers and answers with
|
|
|
|
|
// multiple m= sections where each m= section maps to one RtpSender and one
|
2018-02-26 14:23:09 -08:00
|
|
|
// RtpReceiver (an RtpTransceiver), either both audio or both video. This
|
|
|
|
|
// will also cause PeerConnection to ignore all but the first a=ssrc lines
|
|
|
|
|
// that form a Plan B stream.
|
2017-11-20 10:25:56 -08:00
|
|
|
//
|
|
|
|
|
// For users who wish to send multiple audio/video streams and need to stay
|
2018-04-12 17:21:03 -07:00
|
|
|
// interoperable with legacy WebRTC implementations or use legacy APIs,
|
|
|
|
|
// specify kPlanB.
|
2017-11-20 10:25:56 -08:00
|
|
|
//
|
2018-04-12 17:21:03 -07:00
|
|
|
// For all other users, specify kUnifiedPlan.
|
|
|
|
|
SdpSemantics sdp_semantics = SdpSemantics::kPlanB;
|
2017-11-20 10:25:56 -08:00
|
|
|
|
2018-10-25 10:16:44 -07:00
|
|
|
// TODO(bugs.webrtc.org/9891) - Move to crypto_options or remove.
|
2018-06-12 11:41:11 -07:00
|
|
|
// Actively reset the SRTP parameters whenever the DTLS transports
|
|
|
|
|
// underneath are reset for every offer/answer negotiation.
|
|
|
|
|
// This is only intended to be a workaround for crbug.com/835958
|
|
|
|
|
// WARNING: This would cause RTP/RTCP packets decryption failure if not used
|
|
|
|
|
// correctly. This flag will be deprecated soon. Do not rely on it.
|
|
|
|
|
bool active_reset_srtp_params = false;
|
|
|
|
|
|
2018-10-08 09:43:21 -07:00
|
|
|
// If MediaTransportFactory is provided in PeerConnectionFactory, this flag
|
2019-01-25 13:31:15 -08:00
|
|
|
// informs PeerConnection that it should use the MediaTransportInterface for
|
|
|
|
|
// media (audio/video). It's invalid to set it to |true| if the
|
|
|
|
|
// MediaTransportFactory wasn't provided.
|
2018-10-08 09:43:21 -07:00
|
|
|
bool use_media_transport = false;
|
|
|
|
|
|
2018-11-02 09:07:48 -07:00
|
|
|
// If MediaTransportFactory is provided in PeerConnectionFactory, this flag
|
|
|
|
|
// informs PeerConnection that it should use the MediaTransportInterface for
|
|
|
|
|
// data channels. It's invalid to set it to |true| if the
|
|
|
|
|
// MediaTransportFactory wasn't provided. Data channels over media
|
|
|
|
|
// transport are not compatible with RTP or SCTP data channels. Setting
|
|
|
|
|
// both |use_media_transport_for_data_channels| and
|
|
|
|
|
// |enable_rtp_data_channel| is invalid.
|
|
|
|
|
bool use_media_transport_for_data_channels = false;
|
|
|
|
|
|
2019-05-20 14:39:06 -07:00
|
|
|
// If MediaTransportFactory is provided in PeerConnectionFactory, this flag
|
|
|
|
|
// informs PeerConnection that it should use the DatagramTransportInterface
|
|
|
|
|
// for packets instead DTLS. It's invalid to set it to |true| if the
|
|
|
|
|
// MediaTransportFactory wasn't provided.
|
2019-06-28 14:19:38 -07:00
|
|
|
absl::optional<bool> use_datagram_transport;
|
2019-05-20 14:39:06 -07:00
|
|
|
|
2018-10-25 10:16:44 -07:00
|
|
|
// Defines advanced optional cryptographic settings related to SRTP and
|
|
|
|
|
// frame encryption for native WebRTC. Setting this will overwrite any
|
|
|
|
|
// settings set in PeerConnectionFactory (which is deprecated).
|
|
|
|
|
absl::optional<CryptoOptions> crypto_options;
|
|
|
|
|
|
2018-11-12 10:25:48 +01:00
|
|
|
// Configure if we should include the SDP attribute extmap-allow-mixed in
|
|
|
|
|
// our offer. Although we currently do support this, it's not included in
|
|
|
|
|
// our offer by default due to a previous bug that caused the SDP parser to
|
|
|
|
|
// abort parsing if this attribute was present. This is fixed in Chrome 71.
|
|
|
|
|
// TODO(webrtc:9985): Change default to true once sufficient time has
|
|
|
|
|
// passed.
|
|
|
|
|
bool offer_extmap_allow_mixed = false;
|
|
|
|
|
|
2017-01-11 12:28:30 -08:00
|
|
|
//
|
|
|
|
|
// Don't forget to update operator== if adding something.
|
|
|
|
|
//
|
2014-05-03 05:39:45 +00:00
|
|
|
};
|
|
|
|
|
|
2017-02-08 01:38:21 -08:00
|
|
|
// See: https://www.w3.org/TR/webrtc/#idl-def-rtcofferansweroptions
|
2014-08-04 18:34:16 +00:00
|
|
|
struct RTCOfferAnswerOptions {
|
|
|
|
|
static const int kUndefined = -1;
|
|
|
|
|
static const int kMaxOfferToReceiveMedia = 1;
|
|
|
|
|
|
|
|
|
|
// The default value for constraint offerToReceiveX:true.
|
|
|
|
|
static const int kOfferToReceiveMediaTrue = 1;
|
|
|
|
|
|
2018-02-26 14:23:09 -08:00
|
|
|
// These options are left as backwards compatibility for clients who need
|
|
|
|
|
// "Plan B" semantics. Clients who have switched to "Unified Plan" semantics
|
|
|
|
|
// should use the RtpTransceiver API (AddTransceiver) instead.
|
2017-02-08 01:38:21 -08:00
|
|
|
//
|
|
|
|
|
// offer_to_receive_X set to 1 will cause a media description to be
|
|
|
|
|
// generated in the offer, even if no tracks of that type have been added.
|
|
|
|
|
// Values greater than 1 are treated the same.
|
|
|
|
|
//
|
|
|
|
|
// If set to 0, the generated directional attribute will not include the
|
|
|
|
|
// "recv" direction (meaning it will be "sendonly" or "inactive".
|
2016-08-31 08:18:11 -07:00
|
|
|
int offer_to_receive_video = kUndefined;
|
|
|
|
|
int offer_to_receive_audio = kUndefined;
|
2017-02-08 01:38:21 -08:00
|
|
|
|
2016-08-31 08:18:11 -07:00
|
|
|
bool voice_activity_detection = true;
|
|
|
|
|
bool ice_restart = false;
|
2017-02-08 01:38:21 -08:00
|
|
|
|
|
|
|
|
// If true, will offer to BUNDLE audio/video/data together. Not to be
|
|
|
|
|
// confused with RTCP mux (multiplexing RTP and RTCP together).
|
2016-08-31 08:18:11 -07:00
|
|
|
bool use_rtp_mux = true;
|
|
|
|
|
|
2019-06-04 15:38:50 +02:00
|
|
|
// If true, "a=packetization:<payload_type> raw" attribute will be offered
|
|
|
|
|
// in the SDP for all video payload and accepted in the answer if offered.
|
|
|
|
|
bool raw_packetization_for_video = false;
|
|
|
|
|
|
2018-08-24 10:58:37 +02:00
|
|
|
// This will apply to all video tracks with a Plan B SDP offer/answer.
|
|
|
|
|
int num_simulcast_layers = 1;
|
|
|
|
|
|
2019-05-14 22:00:01 +02:00
|
|
|
// If true: Use SDP format from draft-ietf-mmusic-scdp-sdp-03
|
|
|
|
|
// If false: Use SDP format from draft-ietf-mmusic-sdp-sdp-26 or later
|
|
|
|
|
bool use_obsolete_sctp_sdp = false;
|
|
|
|
|
|
2016-08-31 08:18:11 -07:00
|
|
|
RTCOfferAnswerOptions() = default;
|
2014-08-04 18:34:16 +00:00
|
|
|
|
|
|
|
|
RTCOfferAnswerOptions(int offer_to_receive_video,
|
|
|
|
|
int offer_to_receive_audio,
|
|
|
|
|
bool voice_activity_detection,
|
|
|
|
|
bool ice_restart,
|
|
|
|
|
bool use_rtp_mux)
|
|
|
|
|
: offer_to_receive_video(offer_to_receive_video),
|
|
|
|
|
offer_to_receive_audio(offer_to_receive_audio),
|
|
|
|
|
voice_activity_detection(voice_activity_detection),
|
|
|
|
|
ice_restart(ice_restart),
|
|
|
|
|
use_rtp_mux(use_rtp_mux) {}
|
|
|
|
|
};
|
|
|
|
|
|
2014-02-13 23:18:49 +00:00
|
|
|
// Used by GetStats to decide which stats to include in the stats reports.
|
|
|
|
|
// |kStatsOutputLevelStandard| includes the standard stats for Javascript API;
|
|
|
|
|
// |kStatsOutputLevelDebug| includes both the standard stats and additional
|
|
|
|
|
// stats for debugging purposes.
|
|
|
|
|
enum StatsOutputLevel {
|
|
|
|
|
kStatsOutputLevelStandard,
|
|
|
|
|
kStatsOutputLevelDebug,
|
|
|
|
|
};
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
// Accessor methods to active local streams.
|
2018-02-26 14:23:09 -08:00
|
|
|
// This method is not supported with kUnifiedPlan semantics. Please use
|
|
|
|
|
// GetSenders() instead.
|
2018-06-19 15:03:05 +02:00
|
|
|
virtual rtc::scoped_refptr<StreamCollectionInterface> local_streams() = 0;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
// Accessor methods to remote streams.
|
2018-02-26 14:23:09 -08:00
|
|
|
// This method is not supported with kUnifiedPlan semantics. Please use
|
|
|
|
|
// GetReceivers() instead.
|
2018-06-19 15:03:05 +02:00
|
|
|
virtual rtc::scoped_refptr<StreamCollectionInterface> remote_streams() = 0;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2014-11-04 13:01:33 +00:00
|
|
|
// Add a new MediaStream to be sent on this PeerConnection.
|
|
|
|
|
// Note that a SessionDescription negotiation is needed before the
|
|
|
|
|
// remote peer can receive the stream.
|
2017-02-08 01:38:21 -08:00
|
|
|
//
|
|
|
|
|
// This has been removed from the standard in favor of a track-based API. So,
|
|
|
|
|
// this is equivalent to simply calling AddTrack for each track within the
|
|
|
|
|
// stream, with the one difference that if "stream->AddTrack(...)" is called
|
|
|
|
|
// later, the PeerConnection will automatically pick up the new track. Though
|
|
|
|
|
// this functionality will be deprecated in the future.
|
2018-02-26 14:23:09 -08:00
|
|
|
//
|
|
|
|
|
// This method is not supported with kUnifiedPlan semantics. Please use
|
|
|
|
|
// AddTrack instead.
|
2014-11-06 12:16:36 +00:00
|
|
|
virtual bool AddStream(MediaStreamInterface* stream) = 0;
|
2014-11-04 11:31:29 +00:00
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
// Remove a MediaStream from this PeerConnection.
|
2017-02-08 01:38:21 -08:00
|
|
|
// Note that a SessionDescription negotiation is needed before the
|
2013-07-10 00:45:36 +00:00
|
|
|
// remote peer is notified.
|
2018-02-26 14:23:09 -08:00
|
|
|
//
|
|
|
|
|
// This method is not supported with kUnifiedPlan semantics. Please use
|
|
|
|
|
// RemoveTrack instead.
|
2013-07-10 00:45:36 +00:00
|
|
|
virtual void RemoveStream(MediaStreamInterface* stream) = 0;
|
|
|
|
|
|
2017-02-08 01:38:21 -08:00
|
|
|
// Add a new MediaStreamTrack to be sent on this PeerConnection, and return
|
2017-12-14 10:23:57 -08:00
|
|
|
// the newly created RtpSender. The RtpSender will be associated with the
|
2018-03-02 11:34:10 -08:00
|
|
|
// streams specified in the |stream_ids| list.
|
2017-02-08 01:38:21 -08:00
|
|
|
//
|
2017-12-14 10:23:57 -08:00
|
|
|
// Errors:
|
|
|
|
|
// - INVALID_PARAMETER: |track| is null, has a kind other than audio or video,
|
|
|
|
|
// or a sender already exists for the track.
|
|
|
|
|
// - INVALID_STATE: The PeerConnection is closed.
|
2018-01-05 17:10:52 -08:00
|
|
|
virtual RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>> AddTrack(
|
|
|
|
|
rtc::scoped_refptr<MediaStreamTrackInterface> track,
|
2018-07-19 10:39:30 +02:00
|
|
|
const std::vector<std::string>& stream_ids);
|
2016-01-14 15:35:42 -08:00
|
|
|
|
|
|
|
|
// Remove an RtpSender from this PeerConnection.
|
|
|
|
|
// Returns true on success.
|
2018-07-23 10:27:33 -07:00
|
|
|
// TODO(steveanton): Replace with signature that returns RTCError.
|
|
|
|
|
virtual bool RemoveTrack(RtpSenderInterface* sender);
|
|
|
|
|
|
|
|
|
|
// Plan B semantics: Removes the RtpSender from this PeerConnection.
|
|
|
|
|
// Unified Plan semantics: Stop sending on the RtpSender and mark the
|
|
|
|
|
// corresponding RtpTransceiver direction as no longer sending.
|
|
|
|
|
//
|
|
|
|
|
// Errors:
|
|
|
|
|
// - INVALID_PARAMETER: |sender| is null or (Plan B only) the sender is not
|
|
|
|
|
// associated with this PeerConnection.
|
|
|
|
|
// - INVALID_STATE: PeerConnection is closed.
|
|
|
|
|
// TODO(bugs.webrtc.org/9534): Rename to RemoveTrack once the other signature
|
|
|
|
|
// is removed.
|
|
|
|
|
virtual RTCError RemoveTrackNew(
|
|
|
|
|
rtc::scoped_refptr<RtpSenderInterface> sender);
|
2016-01-14 15:35:42 -08:00
|
|
|
|
2017-11-27 13:01:52 -08:00
|
|
|
// AddTransceiver creates a new RtpTransceiver and adds it to the set of
|
|
|
|
|
// transceivers. Adding a transceiver will cause future calls to CreateOffer
|
|
|
|
|
// to add a media description for the corresponding transceiver.
|
|
|
|
|
//
|
|
|
|
|
// The initial value of |mid| in the returned transceiver is null. Setting a
|
|
|
|
|
// new session description may change it to a non-null value.
|
|
|
|
|
//
|
|
|
|
|
// https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-addtransceiver
|
|
|
|
|
//
|
|
|
|
|
// Optionally, an RtpTransceiverInit structure can be specified to configure
|
|
|
|
|
// the transceiver from construction. If not specified, the transceiver will
|
|
|
|
|
// default to having a direction of kSendRecv and not be part of any streams.
|
|
|
|
|
//
|
|
|
|
|
// These methods are only available when Unified Plan is enabled (see
|
|
|
|
|
// RTCConfiguration).
|
|
|
|
|
//
|
|
|
|
|
// Common errors:
|
|
|
|
|
// - INTERNAL_ERROR: The configuration does not have Unified Plan enabled.
|
|
|
|
|
// TODO(steveanton): Make these pure virtual once downstream projects have
|
|
|
|
|
// updated.
|
|
|
|
|
|
|
|
|
|
// Adds a transceiver with a sender set to transmit the given track. The kind
|
|
|
|
|
// of the transceiver (and sender/receiver) will be derived from the kind of
|
|
|
|
|
// the track.
|
|
|
|
|
// Errors:
|
|
|
|
|
// - INVALID_PARAMETER: |track| is null.
|
|
|
|
|
virtual RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>
|
2018-07-19 10:39:30 +02:00
|
|
|
AddTransceiver(rtc::scoped_refptr<MediaStreamTrackInterface> track);
|
2017-11-27 13:01:52 -08:00
|
|
|
virtual RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>
|
|
|
|
|
AddTransceiver(rtc::scoped_refptr<MediaStreamTrackInterface> track,
|
2018-07-19 10:39:30 +02:00
|
|
|
const RtpTransceiverInit& init);
|
2017-11-27 13:01:52 -08:00
|
|
|
|
|
|
|
|
// Adds a transceiver with the given kind. Can either be MEDIA_TYPE_AUDIO or
|
|
|
|
|
// MEDIA_TYPE_VIDEO.
|
|
|
|
|
// Errors:
|
|
|
|
|
// - INVALID_PARAMETER: |media_type| is not MEDIA_TYPE_AUDIO or
|
|
|
|
|
// MEDIA_TYPE_VIDEO.
|
|
|
|
|
virtual RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>
|
2018-07-19 10:39:30 +02:00
|
|
|
AddTransceiver(cricket::MediaType media_type);
|
2017-11-27 13:01:52 -08:00
|
|
|
virtual RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>>
|
2018-07-19 10:39:30 +02:00
|
|
|
AddTransceiver(cricket::MediaType media_type, const RtpTransceiverInit& init);
|
2017-11-27 13:01:52 -08:00
|
|
|
|
2015-09-28 16:53:55 -07:00
|
|
|
// TODO(deadbeef): Make these pure virtual once all subclasses implement them.
|
2017-02-08 01:38:21 -08:00
|
|
|
|
|
|
|
|
// Creates a sender without a track. Can be used for "early media"/"warmup"
|
|
|
|
|
// use cases, where the application may want to negotiate video attributes
|
|
|
|
|
// before a track is available to send.
|
|
|
|
|
//
|
|
|
|
|
// The standard way to do this would be through "addTransceiver", but we
|
|
|
|
|
// don't support that API yet.
|
|
|
|
|
//
|
2015-11-25 11:26:01 -08:00
|
|
|
// |kind| must be "audio" or "video".
|
2017-02-08 01:38:21 -08:00
|
|
|
//
|
2015-12-18 16:58:44 -08:00
|
|
|
// |stream_id| is used to populate the msid attribute; if empty, one will
|
|
|
|
|
// be generated automatically.
|
2018-02-26 14:23:09 -08:00
|
|
|
//
|
|
|
|
|
// This method is not supported with kUnifiedPlan semantics. Please use
|
|
|
|
|
// AddTransceiver instead.
|
2015-11-25 11:26:01 -08:00
|
|
|
virtual rtc::scoped_refptr<RtpSenderInterface> CreateSender(
|
2015-12-18 16:58:44 -08:00
|
|
|
const std::string& kind,
|
2018-07-19 10:39:30 +02:00
|
|
|
const std::string& stream_id);
|
2015-11-25 11:26:01 -08:00
|
|
|
|
2018-02-26 14:23:09 -08:00
|
|
|
// If Plan B semantics are specified, gets all RtpSenders, created either
|
|
|
|
|
// through AddStream, AddTrack, or CreateSender. All senders of a specific
|
|
|
|
|
// media type share the same media description.
|
|
|
|
|
//
|
|
|
|
|
// If Unified Plan semantics are specified, gets the RtpSender for each
|
|
|
|
|
// RtpTransceiver.
|
2015-09-28 16:53:55 -07:00
|
|
|
virtual std::vector<rtc::scoped_refptr<RtpSenderInterface>> GetSenders()
|
2018-07-19 10:39:30 +02:00
|
|
|
const;
|
2015-09-28 16:53:55 -07:00
|
|
|
|
2018-02-26 14:23:09 -08:00
|
|
|
// If Plan B semantics are specified, gets all RtpReceivers created when a
|
|
|
|
|
// remote description is applied. All receivers of a specific media type share
|
|
|
|
|
// the same media description. It is also possible to have a media description
|
|
|
|
|
// with no associated RtpReceivers, if the directional attribute does not
|
|
|
|
|
// indicate that the remote peer is sending any media.
|
2017-02-08 01:38:21 -08:00
|
|
|
//
|
2018-02-26 14:23:09 -08:00
|
|
|
// If Unified Plan semantics are specified, gets the RtpReceiver for each
|
|
|
|
|
// RtpTransceiver.
|
2015-09-28 16:53:55 -07:00
|
|
|
virtual std::vector<rtc::scoped_refptr<RtpReceiverInterface>> GetReceivers()
|
2018-07-19 10:39:30 +02:00
|
|
|
const;
|
2015-09-28 16:53:55 -07:00
|
|
|
|
2017-11-27 13:01:52 -08:00
|
|
|
// Get all RtpTransceivers, created either through AddTransceiver, AddTrack or
|
|
|
|
|
// by a remote description applied with SetRemoteDescription.
|
2018-02-26 14:23:09 -08:00
|
|
|
//
|
2017-11-27 13:01:52 -08:00
|
|
|
// Note: This method is only available when Unified Plan is enabled (see
|
|
|
|
|
// RTCConfiguration).
|
|
|
|
|
virtual std::vector<rtc::scoped_refptr<RtpTransceiverInterface>>
|
2018-07-19 10:39:30 +02:00
|
|
|
GetTransceivers() const;
|
2017-11-27 13:01:52 -08:00
|
|
|
|
2018-03-20 13:24:20 +01:00
|
|
|
// The legacy non-compliant GetStats() API. This correspond to the
|
|
|
|
|
// callback-based version of getStats() in JavaScript. The returned metrics
|
|
|
|
|
// are UNDOCUMENTED and many of them rely on implementation-specific details.
|
|
|
|
|
// The goal is to DELETE THIS VERSION but we can't today because it is heavily
|
|
|
|
|
// relied upon by third parties. See https://crbug.com/822696.
|
|
|
|
|
//
|
|
|
|
|
// This version is wired up into Chrome. Any stats implemented are
|
|
|
|
|
// automatically exposed to the Web Platform. This has BYPASSED the Chrome
|
|
|
|
|
// release processes for years and lead to cross-browser incompatibility
|
|
|
|
|
// issues and web application reliance on Chrome-only behavior.
|
|
|
|
|
//
|
|
|
|
|
// This API is in "maintenance mode", serious regressions should be fixed but
|
|
|
|
|
// adding new stats is highly discouraged.
|
|
|
|
|
//
|
|
|
|
|
// TODO(hbos): Deprecate and remove this when third parties have migrated to
|
|
|
|
|
// the spec-compliant GetStats() API. https://crbug.com/822696
|
2014-02-13 23:18:49 +00:00
|
|
|
virtual bool GetStats(StatsObserver* observer,
|
2018-03-20 13:24:20 +01:00
|
|
|
MediaStreamTrackInterface* track, // Optional
|
2014-02-13 23:18:49 +00:00
|
|
|
StatsOutputLevel level) = 0;
|
2018-03-20 13:24:20 +01:00
|
|
|
// The spec-compliant GetStats() API. This correspond to the promise-based
|
|
|
|
|
// version of getStats() in JavaScript. Implementation status is described in
|
|
|
|
|
// api/stats/rtcstats_objects.h. For more details on stats, see spec:
|
|
|
|
|
// https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-getstats
|
|
|
|
|
// TODO(hbos): Takes shared ownership, use rtc::scoped_refptr<> instead. This
|
|
|
|
|
// requires stop overriding the current version in third party or making third
|
|
|
|
|
// party calls explicit to avoid ambiguity during switch. Make the future
|
|
|
|
|
// version abstract as soon as third party projects implement it.
|
2016-12-13 02:35:19 -08:00
|
|
|
virtual void GetStats(RTCStatsCollectorCallback* callback) {}
|
2018-03-20 13:24:20 +01:00
|
|
|
// Spec-compliant getStats() performing the stats selection algorithm with the
|
|
|
|
|
// sender. https://w3c.github.io/webrtc-pc/#dom-rtcrtpsender-getstats
|
|
|
|
|
// TODO(hbos): Make abstract as soon as third party projects implement it.
|
|
|
|
|
virtual void GetStats(
|
|
|
|
|
rtc::scoped_refptr<RtpSenderInterface> selector,
|
|
|
|
|
rtc::scoped_refptr<RTCStatsCollectorCallback> callback) {}
|
|
|
|
|
// Spec-compliant getStats() performing the stats selection algorithm with the
|
|
|
|
|
// receiver. https://w3c.github.io/webrtc-pc/#dom-rtcrtpreceiver-getstats
|
|
|
|
|
// TODO(hbos): Make abstract as soon as third party projects implement it.
|
|
|
|
|
virtual void GetStats(
|
|
|
|
|
rtc::scoped_refptr<RtpReceiverInterface> selector,
|
|
|
|
|
rtc::scoped_refptr<RTCStatsCollectorCallback> callback) {}
|
2018-02-26 14:23:09 -08:00
|
|
|
// Clear cached stats in the RTCStatsCollector.
|
2018-01-02 14:08:34 +01:00
|
|
|
// Exposed for testing while waiting for automatic cache clear to work.
|
|
|
|
|
// https://bugs.webrtc.org/8693
|
|
|
|
|
virtual void ClearStatsCache() {}
|
2014-02-13 23:18:49 +00:00
|
|
|
|
2017-02-08 01:38:21 -08:00
|
|
|
// Create a data channel with the provided config, or default config if none
|
|
|
|
|
// is provided. Note that an offer/answer negotiation is still necessary
|
|
|
|
|
// before the data channel can be used.
|
|
|
|
|
//
|
|
|
|
|
// Also, calling CreateDataChannel is the only way to get a data "m=" section
|
|
|
|
|
// in SDP, so it should be done before CreateOffer is called, if the
|
|
|
|
|
// application plans to use data channels.
|
2014-07-29 17:36:52 +00:00
|
|
|
virtual rtc::scoped_refptr<DataChannelInterface> CreateDataChannel(
|
2013-07-10 00:45:36 +00:00
|
|
|
const std::string& label,
|
|
|
|
|
const DataChannelInit* config) = 0;
|
|
|
|
|
|
2017-02-08 01:38:21 -08:00
|
|
|
// Returns the more recently applied description; "pending" if it exists, and
|
|
|
|
|
// otherwise "current". See below.
|
2013-07-10 00:45:36 +00:00
|
|
|
virtual const SessionDescriptionInterface* local_description() const = 0;
|
|
|
|
|
virtual const SessionDescriptionInterface* remote_description() const = 0;
|
2017-02-08 01:38:21 -08:00
|
|
|
|
2016-12-20 17:56:17 -08:00
|
|
|
// A "current" description the one currently negotiated from a complete
|
|
|
|
|
// offer/answer exchange.
|
2018-07-19 10:39:30 +02:00
|
|
|
virtual const SessionDescriptionInterface* current_local_description() const;
|
|
|
|
|
virtual const SessionDescriptionInterface* current_remote_description() const;
|
2017-02-08 01:38:21 -08:00
|
|
|
|
2016-12-20 17:56:17 -08:00
|
|
|
// A "pending" description is one that's part of an incomplete offer/answer
|
|
|
|
|
// exchange (thus, either an offer or a pranswer). Once the offer/answer
|
|
|
|
|
// exchange is finished, the "pending" description will become "current".
|
2018-07-19 10:39:30 +02:00
|
|
|
virtual const SessionDescriptionInterface* pending_local_description() const;
|
|
|
|
|
virtual const SessionDescriptionInterface* pending_remote_description() const;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2019-07-18 11:16:56 +02:00
|
|
|
// Tells the PeerConnection that ICE should be restarted. This triggers a need
|
|
|
|
|
// for negotiation and subsequent CreateOffer() calls will act as if
|
|
|
|
|
// RTCOfferAnswerOptions::ice_restart is true.
|
|
|
|
|
// https://w3c.github.io/webrtc-pc/#dom-rtcpeerconnection-restartice
|
|
|
|
|
// TODO(hbos): Remove default implementation when downstream projects
|
|
|
|
|
// implement this.
|
|
|
|
|
virtual void RestartIce() {}
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
// Create a new offer.
|
|
|
|
|
// The CreateSessionDescriptionObserver callback will be called when done.
|
|
|
|
|
virtual void CreateOffer(CreateSessionDescriptionObserver* observer,
|
2018-08-07 12:32:18 +02:00
|
|
|
const RTCOfferAnswerOptions& options) = 0;
|
2014-08-04 18:34:16 +00:00
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
// Create an answer to an offer.
|
|
|
|
|
// The CreateSessionDescriptionObserver callback will be called when done.
|
|
|
|
|
virtual void CreateAnswer(CreateSessionDescriptionObserver* observer,
|
2018-08-07 12:32:18 +02:00
|
|
|
const RTCOfferAnswerOptions& options) = 0;
|
2016-03-04 02:51:39 -08:00
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
// Sets the local session description.
|
2017-03-29 21:08:16 -07:00
|
|
|
// The PeerConnection takes the ownership of |desc| even if it fails.
|
2013-07-10 00:45:36 +00:00
|
|
|
// The |observer| callback will be called when done.
|
2017-03-29 21:08:16 -07:00
|
|
|
// TODO(deadbeef): Change |desc| to be a unique_ptr, to make it clear
|
|
|
|
|
// that this method always takes ownership of it.
|
2013-07-10 00:45:36 +00:00
|
|
|
virtual void SetLocalDescription(SetSessionDescriptionObserver* observer,
|
|
|
|
|
SessionDescriptionInterface* desc) = 0;
|
|
|
|
|
// Sets the remote session description.
|
2017-03-29 21:08:16 -07:00
|
|
|
// The PeerConnection takes the ownership of |desc| even if it fails.
|
2013-07-10 00:45:36 +00:00
|
|
|
// The |observer| callback will be called when done.
|
Reland "SetRemoteDescriptionObserverInterface added."
Description for changes from the original CL:
Calling legacy SRD, implemented using
SetRemoteDescriptionObserverAdapter wrapping the old observer, was
meant to have the exact same behavior as the legacy SRD implementation
which invokes the callbacks in a Post.
However, in the CL that landed and got reverted (PS1), the Adapter had
its own message handler, and callbacks would be invoked even if the PC
was destroyed.
In PS2 I've changed the Adapter to use the PeerConnection's message
handler. If the PC is destroyed, the callback will not be invoked.
This gives identical behavior to before this CL, and the legacy
behavior is covered by a new unittest.
I changed the adapter to be an implementation detail of
peerconnection.cc, therefor some stuff was moved, and the only tests
covering this is now in peerconnection_rtp_unittest.cc.
This is a reland of 6c7ec32bd63ab2b45d4d83ae1de817ee946b4d72
Original change's description:
> SetRemoteDescriptionObserverInterface added.
>
> The new observer replaced SetSessionDescriptionObserver for
> SetRemoteDescription. Unlike SetSessionDescriptionObserver,
> SetRemoteDescriptionObserverInterface is invoked synchronously so
> that the you can rely on the state of the PeerConnection to represent
> the result of the SetRemoteDescription call in the callback.
>
> The new observer succeeds or fails with an RTCError.
>
> This deprecates the need for PeerConnectionObserver::OnAdd/RemoveTrack
> and SetSessionDescriptionObserver, with the benefit that all media
> object changes can be processed in a single callback by the application
> in a synchronous callback. This will help Chromium keep objects in-sync
> across layers and threads in a non-racy and straight-forward way, see
> design doc (Proposal 2):
> https://docs.google.com/a/google.com/document/d/1-cDDC82mgU5zrHacfFz720p3xwRtuBkOPSRchh07Ho0/edit?usp=sharing
>
> An adapter for SetSessionDescriptionObserver is added to allow calling
> the old SetRemoteDescription signature and get the old behavior
> (OnSuccess/OnFailure callback in a Post) until third parties switch.
>
> Bug: webrtc:8473
> Change-Id: I3d4eb60da6dd34615f2c9f384aeaf4634e648c99
> Reviewed-on: https://webrtc-review.googlesource.com/17523
> Commit-Queue: Henrik Boström <hbos@webrtc.org>
> Reviewed-by: Peter Thatcher <pthatcher@webrtc.org>
> Reviewed-by: Guido Urdaneta <guidou@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#20841}
TBR=pthatcher@webrtc.org
Bug: webrtc:8473
Change-Id: If2b1a1929663b0e77fcc9c2ebeef043e6f73adf5
Reviewed-on: https://webrtc-review.googlesource.com/25640
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Guido Urdaneta <guidou@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20854}
2017-11-23 17:48:32 +01:00
|
|
|
// TODO(hbos): Remove when Chrome implements the new signature.
|
2013-07-10 00:45:36 +00:00
|
|
|
virtual void SetRemoteDescription(SetSessionDescriptionObserver* observer,
|
2017-11-27 09:52:02 +01:00
|
|
|
SessionDescriptionInterface* desc) {}
|
Reland "SetRemoteDescriptionObserverInterface added."
Description for changes from the original CL:
Calling legacy SRD, implemented using
SetRemoteDescriptionObserverAdapter wrapping the old observer, was
meant to have the exact same behavior as the legacy SRD implementation
which invokes the callbacks in a Post.
However, in the CL that landed and got reverted (PS1), the Adapter had
its own message handler, and callbacks would be invoked even if the PC
was destroyed.
In PS2 I've changed the Adapter to use the PeerConnection's message
handler. If the PC is destroyed, the callback will not be invoked.
This gives identical behavior to before this CL, and the legacy
behavior is covered by a new unittest.
I changed the adapter to be an implementation detail of
peerconnection.cc, therefor some stuff was moved, and the only tests
covering this is now in peerconnection_rtp_unittest.cc.
This is a reland of 6c7ec32bd63ab2b45d4d83ae1de817ee946b4d72
Original change's description:
> SetRemoteDescriptionObserverInterface added.
>
> The new observer replaced SetSessionDescriptionObserver for
> SetRemoteDescription. Unlike SetSessionDescriptionObserver,
> SetRemoteDescriptionObserverInterface is invoked synchronously so
> that the you can rely on the state of the PeerConnection to represent
> the result of the SetRemoteDescription call in the callback.
>
> The new observer succeeds or fails with an RTCError.
>
> This deprecates the need for PeerConnectionObserver::OnAdd/RemoveTrack
> and SetSessionDescriptionObserver, with the benefit that all media
> object changes can be processed in a single callback by the application
> in a synchronous callback. This will help Chromium keep objects in-sync
> across layers and threads in a non-racy and straight-forward way, see
> design doc (Proposal 2):
> https://docs.google.com/a/google.com/document/d/1-cDDC82mgU5zrHacfFz720p3xwRtuBkOPSRchh07Ho0/edit?usp=sharing
>
> An adapter for SetSessionDescriptionObserver is added to allow calling
> the old SetRemoteDescription signature and get the old behavior
> (OnSuccess/OnFailure callback in a Post) until third parties switch.
>
> Bug: webrtc:8473
> Change-Id: I3d4eb60da6dd34615f2c9f384aeaf4634e648c99
> Reviewed-on: https://webrtc-review.googlesource.com/17523
> Commit-Queue: Henrik Boström <hbos@webrtc.org>
> Reviewed-by: Peter Thatcher <pthatcher@webrtc.org>
> Reviewed-by: Guido Urdaneta <guidou@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#20841}
TBR=pthatcher@webrtc.org
Bug: webrtc:8473
Change-Id: If2b1a1929663b0e77fcc9c2ebeef043e6f73adf5
Reviewed-on: https://webrtc-review.googlesource.com/25640
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Guido Urdaneta <guidou@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20854}
2017-11-23 17:48:32 +01:00
|
|
|
// TODO(hbos): Make pure virtual when Chrome has updated its signature.
|
|
|
|
|
virtual void SetRemoteDescription(
|
|
|
|
|
std::unique_ptr<SessionDescriptionInterface> desc,
|
|
|
|
|
rtc::scoped_refptr<SetRemoteDescriptionObserverInterface> observer) {}
|
2017-02-08 01:38:21 -08:00
|
|
|
|
2016-11-16 19:42:04 -08:00
|
|
|
// TODO(deadbeef): Make this pure virtual once all Chrome subclasses of
|
|
|
|
|
// PeerConnectionInterface implement it.
|
2018-07-19 10:39:30 +02:00
|
|
|
virtual PeerConnectionInterface::RTCConfiguration GetConfiguration();
|
2017-01-11 12:28:30 -08:00
|
|
|
|
2015-09-29 11:56:26 -07:00
|
|
|
// Sets the PeerConnection's global configuration to |config|.
|
2017-01-11 12:28:30 -08:00
|
|
|
//
|
|
|
|
|
// The members of |config| that may be changed are |type|, |servers|,
|
|
|
|
|
// |ice_candidate_pool_size| and |prune_turn_ports| (though the candidate
|
|
|
|
|
// pool size can't be changed after the first call to SetLocalDescription).
|
|
|
|
|
// Note that this means the BUNDLE and RTCP-multiplexing policies cannot be
|
|
|
|
|
// changed with this method.
|
|
|
|
|
//
|
2015-09-29 11:56:26 -07:00
|
|
|
// Any changes to STUN/TURN servers or ICE candidate policy will affect the
|
|
|
|
|
// next gathering phase, and cause the next call to createOffer to generate
|
2017-01-11 12:28:30 -08:00
|
|
|
// new ICE credentials, as described in JSEP. This also occurs when
|
|
|
|
|
// |prune_turn_ports| changes, for the same reasoning.
|
|
|
|
|
//
|
|
|
|
|
// If an error occurs, returns false and populates |error| if non-null:
|
|
|
|
|
// - INVALID_MODIFICATION if |config| contains a modified parameter other
|
|
|
|
|
// than one of the parameters listed above.
|
|
|
|
|
// - INVALID_RANGE if |ice_candidate_pool_size| is out of range.
|
|
|
|
|
// - SYNTAX_ERROR if parsing an ICE server URL failed.
|
|
|
|
|
// - INVALID_PARAMETER if a TURN server is missing |username| or |password|.
|
|
|
|
|
// - INTERNAL_ERROR if an unexpected error occurred.
|
|
|
|
|
//
|
2015-09-29 11:56:26 -07:00
|
|
|
// TODO(deadbeef): Make this pure virtual once all Chrome subclasses of
|
|
|
|
|
// PeerConnectionInterface implement it.
|
2017-01-11 12:28:30 -08:00
|
|
|
virtual bool SetConfiguration(
|
|
|
|
|
const PeerConnectionInterface::RTCConfiguration& config,
|
2018-07-19 10:39:30 +02:00
|
|
|
RTCError* error);
|
|
|
|
|
|
2017-01-11 12:28:30 -08:00
|
|
|
// Version without error output param for backwards compatibility.
|
|
|
|
|
// TODO(deadbeef): Remove once chromium is updated.
|
2015-09-29 11:56:26 -07:00
|
|
|
virtual bool SetConfiguration(
|
2018-07-19 10:39:30 +02:00
|
|
|
const PeerConnectionInterface::RTCConfiguration& config);
|
2017-02-08 01:38:21 -08:00
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
// Provides a remote candidate to the ICE Agent.
|
|
|
|
|
// A copy of the |candidate| will be created and added to the remote
|
|
|
|
|
// description. So the caller of this method still has the ownership of the
|
|
|
|
|
// |candidate|.
|
|
|
|
|
virtual bool AddIceCandidate(const IceCandidateInterface* candidate) = 0;
|
|
|
|
|
|
2017-02-08 01:38:21 -08:00
|
|
|
// Removes a group of remote candidates from the ICE agent. Needed mainly for
|
|
|
|
|
// continual gathering, to avoid an ever-growing list of candidates as
|
|
|
|
|
// networks come and go.
|
2016-03-14 11:59:18 -07:00
|
|
|
virtual bool RemoveIceCandidates(
|
2018-07-19 10:39:30 +02:00
|
|
|
const std::vector<cricket::Candidate>& candidates);
|
2016-03-14 11:59:18 -07:00
|
|
|
|
2017-06-02 14:37:37 -07:00
|
|
|
// 0 <= min <= current <= max should hold for set parameters.
|
|
|
|
|
struct BitrateParameters {
|
2018-07-19 10:39:30 +02:00
|
|
|
BitrateParameters();
|
|
|
|
|
~BitrateParameters();
|
|
|
|
|
|
2018-06-21 13:32:56 +02:00
|
|
|
absl::optional<int> min_bitrate_bps;
|
|
|
|
|
absl::optional<int> current_bitrate_bps;
|
|
|
|
|
absl::optional<int> max_bitrate_bps;
|
2017-06-02 14:37:37 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// SetBitrate limits the bandwidth allocated for all RTP streams sent by
|
|
|
|
|
// this PeerConnection. Other limitations might affect these limits and
|
|
|
|
|
// are respected (for example "b=AS" in SDP).
|
|
|
|
|
//
|
|
|
|
|
// Setting |current_bitrate_bps| will reset the current bitrate estimate
|
|
|
|
|
// to the provided value.
|
2018-07-19 10:39:30 +02:00
|
|
|
virtual RTCError SetBitrate(const BitrateSettings& bitrate);
|
2018-05-07 14:01:37 +02:00
|
|
|
|
|
|
|
|
// TODO(nisse): Deprecated - use version above. These two default
|
|
|
|
|
// implementations require subclasses to implement one or the other
|
|
|
|
|
// of the methods.
|
2018-07-19 10:39:30 +02:00
|
|
|
virtual RTCError SetBitrate(const BitrateParameters& bitrate_parameters);
|
2017-06-02 14:37:37 -07:00
|
|
|
|
2017-11-01 11:06:56 +01:00
|
|
|
// Enable/disable playout of received audio streams. Enabled by default. Note
|
|
|
|
|
// that even if playout is enabled, streams will only be played out if the
|
|
|
|
|
// appropriate SDP is also applied. Setting |playout| to false will stop
|
|
|
|
|
// playout of the underlying audio device but starts a task which will poll
|
|
|
|
|
// for audio data every 10ms to ensure that audio processing happens and the
|
|
|
|
|
// audio statistics are updated.
|
|
|
|
|
// TODO(henrika): deprecate and remove this.
|
|
|
|
|
virtual void SetAudioPlayout(bool playout) {}
|
|
|
|
|
|
|
|
|
|
// Enable/disable recording of transmitted audio streams. Enabled by default.
|
|
|
|
|
// Note that even if recording is enabled, streams will only be recorded if
|
|
|
|
|
// the appropriate SDP is also applied.
|
|
|
|
|
// TODO(henrika): deprecate and remove this.
|
|
|
|
|
virtual void SetAudioRecording(bool recording) {}
|
|
|
|
|
|
2018-11-28 16:47:46 +01:00
|
|
|
// Looks up the DtlsTransport associated with a MID value.
|
|
|
|
|
// In the Javascript API, DtlsTransport is a property of a sender, but
|
|
|
|
|
// because the PeerConnection owns the DtlsTransport in this implementation,
|
|
|
|
|
// it is better to look them up on the PeerConnection.
|
2018-12-03 18:45:19 +01:00
|
|
|
// TODO(hta): Remove default implementation after updating Chrome.
|
2018-11-28 16:47:46 +01:00
|
|
|
virtual rtc::scoped_refptr<DtlsTransportInterface> LookupDtlsTransportByMid(
|
|
|
|
|
const std::string& mid);
|
|
|
|
|
|
2019-02-28 07:51:00 +01:00
|
|
|
// Returns the SCTP transport, if any.
|
|
|
|
|
// TODO(hta): Remove default implementation after updating Chrome.
|
|
|
|
|
virtual rtc::scoped_refptr<SctpTransportInterface> GetSctpTransport() const;
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
// Returns the current SignalingState.
|
|
|
|
|
virtual SignalingState signaling_state() = 0;
|
2017-10-22 11:52:32 -07:00
|
|
|
|
2018-12-06 11:25:14 +01:00
|
|
|
// Returns an aggregate state of all ICE *and* DTLS transports.
|
|
|
|
|
// This is left in place to avoid breaking native clients who expect our old,
|
|
|
|
|
// nonstandard behavior.
|
|
|
|
|
// TODO(jonasolsson): deprecate and remove this.
|
2013-07-10 00:45:36 +00:00
|
|
|
virtual IceConnectionState ice_connection_state() = 0;
|
2017-10-22 11:52:32 -07:00
|
|
|
|
2018-12-06 11:25:14 +01:00
|
|
|
// Returns an aggregated state of all ICE transports.
|
|
|
|
|
virtual IceConnectionState standardized_ice_connection_state();
|
|
|
|
|
|
|
|
|
|
// Returns an aggregated state of all ICE and DTLS transports.
|
2018-10-18 15:58:17 +02:00
|
|
|
virtual PeerConnectionState peer_connection_state();
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
virtual IceGatheringState ice_gathering_state() = 0;
|
|
|
|
|
|
2017-10-13 16:29:40 +02:00
|
|
|
// Start RtcEventLog using an existing output-sink. Takes ownership of
|
|
|
|
|
// |output| and passes it on to Call, which will take the ownership. If the
|
2017-11-20 17:38:14 +01:00
|
|
|
// operation fails the output will be closed and deallocated. The event log
|
|
|
|
|
// will send serialized events to the output object every |output_period_ms|.
|
2019-05-10 11:33:12 +02:00
|
|
|
// Applications using the event log should generally make their own trade-off
|
|
|
|
|
// regarding the output period. A long period is generally more efficient,
|
|
|
|
|
// with potential drawbacks being more bursty thread usage, and more events
|
|
|
|
|
// lost in case the application crashes. If the |output_period_ms| argument is
|
|
|
|
|
// omitted, webrtc selects a default deemed to be workable in most cases.
|
2017-11-20 17:38:14 +01:00
|
|
|
virtual bool StartRtcEventLog(std::unique_ptr<RtcEventLogOutput> output,
|
2018-07-19 10:39:30 +02:00
|
|
|
int64_t output_period_ms);
|
2019-05-10 11:33:12 +02:00
|
|
|
virtual bool StartRtcEventLog(std::unique_ptr<RtcEventLogOutput> output);
|
2017-10-13 16:29:40 +02:00
|
|
|
|
2016-07-04 07:06:55 -07:00
|
|
|
// Stops logging the RtcEventLog.
|
|
|
|
|
// TODO(ivoc): Make this pure virtual when Chrome is updated.
|
|
|
|
|
virtual void StopRtcEventLog() {}
|
|
|
|
|
|
2017-02-08 01:38:21 -08:00
|
|
|
// Terminates all media, closes the transports, and in general releases any
|
|
|
|
|
// resources used by the PeerConnection. This is an irreversible operation.
|
2017-04-20 13:19:00 -07:00
|
|
|
//
|
|
|
|
|
// Note that after this method completes, the PeerConnection will no longer
|
|
|
|
|
// use the PeerConnectionObserver interface passed in on construction, and
|
|
|
|
|
// thus the observer object can be safely destroyed.
|
2013-07-10 00:45:36 +00:00
|
|
|
virtual void Close() = 0;
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
// Dtor protected as objects shouldn't be deleted via this interface.
|
2018-07-19 10:39:30 +02:00
|
|
|
~PeerConnectionInterface() override = default;
|
2013-07-10 00:45:36 +00:00
|
|
|
};
|
|
|
|
|
|
2017-02-08 01:38:21 -08:00
|
|
|
// PeerConnection callback interface, used for RTCPeerConnection events.
|
|
|
|
|
// Application should implement these methods.
|
2013-07-10 00:45:36 +00:00
|
|
|
class PeerConnectionObserver {
|
|
|
|
|
public:
|
2018-01-11 10:02:19 +01:00
|
|
|
virtual ~PeerConnectionObserver() = default;
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
// Triggered when the SignalingState changed.
|
|
|
|
|
virtual void OnSignalingChange(
|
2016-02-09 03:09:43 -08:00
|
|
|
PeerConnectionInterface::SignalingState new_state) = 0;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
// Triggered when media is received on a new stream from remote peer.
|
2018-01-16 10:11:06 -08:00
|
|
|
virtual void OnAddStream(rtc::scoped_refptr<MediaStreamInterface> stream) {}
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2018-05-03 15:30:18 -07:00
|
|
|
// Triggered when a remote peer closes a stream.
|
2018-01-16 10:11:06 -08:00
|
|
|
virtual void OnRemoveStream(rtc::scoped_refptr<MediaStreamInterface> stream) {
|
|
|
|
|
}
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2016-05-31 13:02:21 -07:00
|
|
|
// Triggered when a remote peer opens a data channel.
|
|
|
|
|
virtual void OnDataChannel(
|
2017-03-08 06:59:45 -08:00
|
|
|
rtc::scoped_refptr<DataChannelInterface> data_channel) = 0;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2016-05-31 13:02:21 -07:00
|
|
|
// Triggered when renegotiation is needed. For example, an ICE restart
|
|
|
|
|
// has begun.
|
2014-01-13 22:04:12 +00:00
|
|
|
virtual void OnRenegotiationNeeded() = 0;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2018-12-06 11:25:14 +01:00
|
|
|
// Called any time the legacy IceConnectionState changes.
|
2017-02-08 01:38:21 -08:00
|
|
|
//
|
|
|
|
|
// Note that our ICE states lag behind the standard slightly. The most
|
|
|
|
|
// notable differences include the fact that "failed" occurs after 15
|
|
|
|
|
// seconds, not 30, and this actually represents a combination ICE + DTLS
|
|
|
|
|
// state, so it may be "failed" if DTLS fails while ICE succeeds.
|
2018-12-06 11:25:14 +01:00
|
|
|
//
|
|
|
|
|
// TODO(jonasolsson): deprecate and remove this.
|
2013-07-10 00:45:36 +00:00
|
|
|
virtual void OnIceConnectionChange(
|
2016-02-09 03:09:43 -08:00
|
|
|
PeerConnectionInterface::IceConnectionState new_state) = 0;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2018-12-06 11:25:14 +01:00
|
|
|
// Called any time the standards-compliant IceConnectionState changes.
|
|
|
|
|
virtual void OnStandardizedIceConnectionChange(
|
|
|
|
|
PeerConnectionInterface::IceConnectionState new_state) {}
|
|
|
|
|
|
2018-10-18 15:58:17 +02:00
|
|
|
// Called any time the PeerConnectionState changes.
|
|
|
|
|
virtual void OnConnectionChange(
|
|
|
|
|
PeerConnectionInterface::PeerConnectionState new_state) {}
|
|
|
|
|
|
2016-05-31 13:02:21 -07:00
|
|
|
// Called any time the IceGatheringState changes.
|
2013-07-10 00:45:36 +00:00
|
|
|
virtual void OnIceGatheringChange(
|
2016-02-09 03:09:43 -08:00
|
|
|
PeerConnectionInterface::IceGatheringState new_state) = 0;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2016-05-31 13:02:21 -07:00
|
|
|
// A new ICE candidate has been gathered.
|
2013-07-10 00:45:36 +00:00
|
|
|
virtual void OnIceCandidate(const IceCandidateInterface* candidate) = 0;
|
|
|
|
|
|
2019-06-01 12:23:43 +03:00
|
|
|
// Gathering of an ICE candidate failed.
|
|
|
|
|
// See https://w3c.github.io/webrtc-pc/#event-icecandidateerror
|
|
|
|
|
// |host_candidate| is a stringified socket address.
|
|
|
|
|
virtual void OnIceCandidateError(const std::string& host_candidate,
|
|
|
|
|
const std::string& url,
|
|
|
|
|
int error_code,
|
|
|
|
|
const std::string& error_text) {}
|
|
|
|
|
|
2016-03-14 11:59:18 -07:00
|
|
|
// Ice candidates have been removed.
|
|
|
|
|
// TODO(honghaiz): Make this a pure virtual method when all its subclasses
|
|
|
|
|
// implement it.
|
|
|
|
|
virtual void OnIceCandidatesRemoved(
|
|
|
|
|
const std::vector<cricket::Candidate>& candidates) {}
|
|
|
|
|
|
2015-07-08 11:08:35 -07:00
|
|
|
// Called when the ICE connection receiving status changes.
|
|
|
|
|
virtual void OnIceConnectionReceivingChange(bool receiving) {}
|
|
|
|
|
|
2018-02-26 14:23:09 -08:00
|
|
|
// This is called when a receiver and its track are created.
|
Reland "Added PeerConnectionObserver::OnRemoveTrack."
This reverts commit 6c0c55c31817ecfa32409424495eb68b31828c40.
Reason for revert:
Fixed the flake.
Original change's description:
> Revert "Added PeerConnectionObserver::OnRemoveTrack."
>
> This reverts commit ba97ba7af917d4152f5f3363aba1c1561c6673dc.
>
> Reason for revert: The new tests have caused several test failures on the test bots; the method FakeAudioMediaStreamTrack:GetSignalLevel, which is not supposed to be called is sometimes called anyway.
>
> Original change's description:
> > Added PeerConnectionObserver::OnRemoveTrack.
> >
> > This corresponds to processing the removal of a remote track step of
> > the spec, with processing the addition of a remote track already
> > covered by OnAddTrack.
> > https://w3c.github.io/webrtc-pc/#processing-remote-mediastreamtracks
> >
> > Bug: webrtc:8260, webrtc:8315
> > Change-Id: Ica8be92369733eb3cf1397fb60385d45a9b58700
> > Reviewed-on: https://webrtc-review.googlesource.com/4722
> > Commit-Queue: Henrik Boström <hbos@webrtc.org>
> > Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
> > Reviewed-by: Steve Anton <steveanton@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#20214}
>
> TBR=steveanton@webrtc.org,deadbeef@webrtc.org,hbos@webrtc.org
>
> Change-Id: Id2d9533e27227254769b4280a8ff10a47313e714
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: webrtc:8260, webrtc:8315
> Reviewed-on: https://webrtc-review.googlesource.com/7940
> Reviewed-by: Alex Loiko <aleloi@webrtc.org>
> Commit-Queue: Alex Loiko <aleloi@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#20218}
TBR=steveanton@webrtc.org,deadbeef@webrtc.org,aleloi@webrtc.org,hbos@webrtc.org
Change-Id: Iab7500bebf98535754b102874259de43831fff6b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:8260, webrtc:8315
Reviewed-on: https://webrtc-review.googlesource.com/8180
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20227}
2017-10-10 10:05:16 -07:00
|
|
|
// TODO(zhihuang): Make this pure virtual when all subclasses implement it.
|
2018-02-16 16:14:42 -08:00
|
|
|
// Note: This is called with both Plan B and Unified Plan semantics. Unified
|
|
|
|
|
// Plan users should prefer OnTrack, OnAddTrack is only called as backwards
|
|
|
|
|
// compatibility (and is called in the exact same situations as OnTrack).
|
2016-11-17 12:06:24 -08:00
|
|
|
virtual void OnAddTrack(
|
|
|
|
|
rtc::scoped_refptr<RtpReceiverInterface> receiver,
|
2016-12-02 15:41:10 -08:00
|
|
|
const std::vector<rtc::scoped_refptr<MediaStreamInterface>>& streams) {}
|
2016-11-17 12:06:24 -08:00
|
|
|
|
2018-02-16 16:14:42 -08:00
|
|
|
// This is called when signaling indicates a transceiver will be receiving
|
|
|
|
|
// media from the remote endpoint. This is fired during a call to
|
|
|
|
|
// SetRemoteDescription. The receiving track can be accessed by:
|
|
|
|
|
// |transceiver->receiver()->track()| and its associated streams by
|
|
|
|
|
// |transceiver->receiver()->streams()|.
|
|
|
|
|
// Note: This will only be called if Unified Plan semantics are specified.
|
|
|
|
|
// This behavior is specified in section 2.2.8.2.5 of the "Set the
|
|
|
|
|
// RTCSessionDescription" algorithm:
|
|
|
|
|
// https://w3c.github.io/webrtc-pc/#set-description
|
|
|
|
|
virtual void OnTrack(
|
|
|
|
|
rtc::scoped_refptr<RtpTransceiverInterface> transceiver) {}
|
|
|
|
|
|
2018-05-03 15:30:18 -07:00
|
|
|
// Called when signaling indicates that media will no longer be received on a
|
|
|
|
|
// track.
|
|
|
|
|
// With Plan B semantics, the given receiver will have been removed from the
|
|
|
|
|
// PeerConnection and the track muted.
|
|
|
|
|
// With Unified Plan semantics, the receiver will remain but the transceiver
|
|
|
|
|
// will have changed direction to either sendonly or inactive.
|
Reland "Added PeerConnectionObserver::OnRemoveTrack."
This reverts commit 6c0c55c31817ecfa32409424495eb68b31828c40.
Reason for revert:
Fixed the flake.
Original change's description:
> Revert "Added PeerConnectionObserver::OnRemoveTrack."
>
> This reverts commit ba97ba7af917d4152f5f3363aba1c1561c6673dc.
>
> Reason for revert: The new tests have caused several test failures on the test bots; the method FakeAudioMediaStreamTrack:GetSignalLevel, which is not supposed to be called is sometimes called anyway.
>
> Original change's description:
> > Added PeerConnectionObserver::OnRemoveTrack.
> >
> > This corresponds to processing the removal of a remote track step of
> > the spec, with processing the addition of a remote track already
> > covered by OnAddTrack.
> > https://w3c.github.io/webrtc-pc/#processing-remote-mediastreamtracks
> >
> > Bug: webrtc:8260, webrtc:8315
> > Change-Id: Ica8be92369733eb3cf1397fb60385d45a9b58700
> > Reviewed-on: https://webrtc-review.googlesource.com/4722
> > Commit-Queue: Henrik Boström <hbos@webrtc.org>
> > Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
> > Reviewed-by: Steve Anton <steveanton@webrtc.org>
> > Cr-Commit-Position: refs/heads/master@{#20214}
>
> TBR=steveanton@webrtc.org,deadbeef@webrtc.org,hbos@webrtc.org
>
> Change-Id: Id2d9533e27227254769b4280a8ff10a47313e714
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Bug: webrtc:8260, webrtc:8315
> Reviewed-on: https://webrtc-review.googlesource.com/7940
> Reviewed-by: Alex Loiko <aleloi@webrtc.org>
> Commit-Queue: Alex Loiko <aleloi@webrtc.org>
> Cr-Commit-Position: refs/heads/master@{#20218}
TBR=steveanton@webrtc.org,deadbeef@webrtc.org,aleloi@webrtc.org,hbos@webrtc.org
Change-Id: Iab7500bebf98535754b102874259de43831fff6b
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: webrtc:8260, webrtc:8315
Reviewed-on: https://webrtc-review.googlesource.com/8180
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Reviewed-by: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#20227}
2017-10-10 10:05:16 -07:00
|
|
|
// https://w3c.github.io/webrtc-pc/#process-remote-track-removal
|
|
|
|
|
// TODO(hbos,deadbeef): Make pure virtual when all subclasses implement it.
|
|
|
|
|
virtual void OnRemoveTrack(
|
|
|
|
|
rtc::scoped_refptr<RtpReceiverInterface> receiver) {}
|
2018-07-26 10:39:55 +02:00
|
|
|
|
|
|
|
|
// Called when an interesting usage is detected by WebRTC.
|
|
|
|
|
// An appropriate action is to add information about the context of the
|
|
|
|
|
// PeerConnection and write the event to some kind of "interesting events"
|
|
|
|
|
// log function.
|
|
|
|
|
// The heuristics for defining what constitutes "interesting" are
|
|
|
|
|
// implementation-defined.
|
|
|
|
|
virtual void OnInterestingUsage(int usage_pattern) {}
|
2013-07-10 00:45:36 +00:00
|
|
|
};
|
|
|
|
|
|
Created PeerConnectionDependencies to avoid creating new CreatePeerConnection overloads.
Currently CreatePeerConnection takes 3 parameters. This is going to expand to four with a new change. Every time a new parameter is added, we need to deprecate the old method, switch clients to the new one, update fake/mock classes and tests, and so on, which is a cumbersome process.
To address this, this CL introduces a PeerConnectionDependencies structure to encapsulate all mandatory and optional dependencies (where a dependency is defined as non trivial
executable code that an API user may want to provide to the native API). This allows adding a new injectable dependency by simply adding a new field to the struct, avoiding the hassle described above.
You may think we could use RTCConfiguration for this. But since RTCConfiguration is both passed in and out of the PeerConnection (using GetConfiguration/SetConfiguration), it can't carry unique_ptrs. And we don't want to inject dependencies via raw pointers, since this could lead to lifetime management bugs, where the dependency is deleted before the PeerConnection is done using it.
Bug: webrtc:7913
Change-Id: I38c3f4ce4f26b37e6fe219d1eeca271294b40db8
Reviewed-on: https://webrtc-review.googlesource.com/73663
Commit-Queue: Benjamin Wright <benwright@webrtc.org>
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23084}
2018-05-02 13:46:31 -07:00
|
|
|
// PeerConnectionDependencies holds all of PeerConnections dependencies.
|
|
|
|
|
// A dependency is distinct from a configuration as it defines significant
|
|
|
|
|
// executable code that can be provided by a user of the API.
|
|
|
|
|
//
|
|
|
|
|
// All new dependencies should be added as a unique_ptr to allow the
|
|
|
|
|
// PeerConnection object to be the definitive owner of the dependencies
|
|
|
|
|
// lifetime making injection safer.
|
|
|
|
|
struct PeerConnectionDependencies final {
|
2018-07-19 10:39:30 +02:00
|
|
|
explicit PeerConnectionDependencies(PeerConnectionObserver* observer_in);
|
Created PeerConnectionDependencies to avoid creating new CreatePeerConnection overloads.
Currently CreatePeerConnection takes 3 parameters. This is going to expand to four with a new change. Every time a new parameter is added, we need to deprecate the old method, switch clients to the new one, update fake/mock classes and tests, and so on, which is a cumbersome process.
To address this, this CL introduces a PeerConnectionDependencies structure to encapsulate all mandatory and optional dependencies (where a dependency is defined as non trivial
executable code that an API user may want to provide to the native API). This allows adding a new injectable dependency by simply adding a new field to the struct, avoiding the hassle described above.
You may think we could use RTCConfiguration for this. But since RTCConfiguration is both passed in and out of the PeerConnection (using GetConfiguration/SetConfiguration), it can't carry unique_ptrs. And we don't want to inject dependencies via raw pointers, since this could lead to lifetime management bugs, where the dependency is deleted before the PeerConnection is done using it.
Bug: webrtc:7913
Change-Id: I38c3f4ce4f26b37e6fe219d1eeca271294b40db8
Reviewed-on: https://webrtc-review.googlesource.com/73663
Commit-Queue: Benjamin Wright <benwright@webrtc.org>
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23084}
2018-05-02 13:46:31 -07:00
|
|
|
// This object is not copyable or assignable.
|
|
|
|
|
PeerConnectionDependencies(const PeerConnectionDependencies&) = delete;
|
|
|
|
|
PeerConnectionDependencies& operator=(const PeerConnectionDependencies&) =
|
|
|
|
|
delete;
|
|
|
|
|
// This object is only moveable.
|
2018-07-19 10:39:30 +02:00
|
|
|
PeerConnectionDependencies(PeerConnectionDependencies&&);
|
Created PeerConnectionDependencies to avoid creating new CreatePeerConnection overloads.
Currently CreatePeerConnection takes 3 parameters. This is going to expand to four with a new change. Every time a new parameter is added, we need to deprecate the old method, switch clients to the new one, update fake/mock classes and tests, and so on, which is a cumbersome process.
To address this, this CL introduces a PeerConnectionDependencies structure to encapsulate all mandatory and optional dependencies (where a dependency is defined as non trivial
executable code that an API user may want to provide to the native API). This allows adding a new injectable dependency by simply adding a new field to the struct, avoiding the hassle described above.
You may think we could use RTCConfiguration for this. But since RTCConfiguration is both passed in and out of the PeerConnection (using GetConfiguration/SetConfiguration), it can't carry unique_ptrs. And we don't want to inject dependencies via raw pointers, since this could lead to lifetime management bugs, where the dependency is deleted before the PeerConnection is done using it.
Bug: webrtc:7913
Change-Id: I38c3f4ce4f26b37e6fe219d1eeca271294b40db8
Reviewed-on: https://webrtc-review.googlesource.com/73663
Commit-Queue: Benjamin Wright <benwright@webrtc.org>
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23084}
2018-05-02 13:46:31 -07:00
|
|
|
PeerConnectionDependencies& operator=(PeerConnectionDependencies&&) = default;
|
2018-07-19 10:39:30 +02:00
|
|
|
~PeerConnectionDependencies();
|
Created PeerConnectionDependencies to avoid creating new CreatePeerConnection overloads.
Currently CreatePeerConnection takes 3 parameters. This is going to expand to four with a new change. Every time a new parameter is added, we need to deprecate the old method, switch clients to the new one, update fake/mock classes and tests, and so on, which is a cumbersome process.
To address this, this CL introduces a PeerConnectionDependencies structure to encapsulate all mandatory and optional dependencies (where a dependency is defined as non trivial
executable code that an API user may want to provide to the native API). This allows adding a new injectable dependency by simply adding a new field to the struct, avoiding the hassle described above.
You may think we could use RTCConfiguration for this. But since RTCConfiguration is both passed in and out of the PeerConnection (using GetConfiguration/SetConfiguration), it can't carry unique_ptrs. And we don't want to inject dependencies via raw pointers, since this could lead to lifetime management bugs, where the dependency is deleted before the PeerConnection is done using it.
Bug: webrtc:7913
Change-Id: I38c3f4ce4f26b37e6fe219d1eeca271294b40db8
Reviewed-on: https://webrtc-review.googlesource.com/73663
Commit-Queue: Benjamin Wright <benwright@webrtc.org>
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23084}
2018-05-02 13:46:31 -07:00
|
|
|
// Mandatory dependencies
|
|
|
|
|
PeerConnectionObserver* observer = nullptr;
|
|
|
|
|
// Optional dependencies
|
|
|
|
|
std::unique_ptr<cricket::PortAllocator> allocator;
|
2018-08-02 13:20:15 -07:00
|
|
|
std::unique_ptr<webrtc::AsyncResolverFactory> async_resolver_factory;
|
Created PeerConnectionDependencies to avoid creating new CreatePeerConnection overloads.
Currently CreatePeerConnection takes 3 parameters. This is going to expand to four with a new change. Every time a new parameter is added, we need to deprecate the old method, switch clients to the new one, update fake/mock classes and tests, and so on, which is a cumbersome process.
To address this, this CL introduces a PeerConnectionDependencies structure to encapsulate all mandatory and optional dependencies (where a dependency is defined as non trivial
executable code that an API user may want to provide to the native API). This allows adding a new injectable dependency by simply adding a new field to the struct, avoiding the hassle described above.
You may think we could use RTCConfiguration for this. But since RTCConfiguration is both passed in and out of the PeerConnection (using GetConfiguration/SetConfiguration), it can't carry unique_ptrs. And we don't want to inject dependencies via raw pointers, since this could lead to lifetime management bugs, where the dependency is deleted before the PeerConnection is done using it.
Bug: webrtc:7913
Change-Id: I38c3f4ce4f26b37e6fe219d1eeca271294b40db8
Reviewed-on: https://webrtc-review.googlesource.com/73663
Commit-Queue: Benjamin Wright <benwright@webrtc.org>
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23084}
2018-05-02 13:46:31 -07:00
|
|
|
std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator;
|
2018-05-08 13:12:25 -07:00
|
|
|
std::unique_ptr<rtc::SSLCertificateVerifier> tls_cert_verifier;
|
2019-04-17 07:38:40 +02:00
|
|
|
std::unique_ptr<webrtc::VideoBitrateAllocatorFactory>
|
|
|
|
|
video_bitrate_allocator_factory;
|
Created PeerConnectionDependencies to avoid creating new CreatePeerConnection overloads.
Currently CreatePeerConnection takes 3 parameters. This is going to expand to four with a new change. Every time a new parameter is added, we need to deprecate the old method, switch clients to the new one, update fake/mock classes and tests, and so on, which is a cumbersome process.
To address this, this CL introduces a PeerConnectionDependencies structure to encapsulate all mandatory and optional dependencies (where a dependency is defined as non trivial
executable code that an API user may want to provide to the native API). This allows adding a new injectable dependency by simply adding a new field to the struct, avoiding the hassle described above.
You may think we could use RTCConfiguration for this. But since RTCConfiguration is both passed in and out of the PeerConnection (using GetConfiguration/SetConfiguration), it can't carry unique_ptrs. And we don't want to inject dependencies via raw pointers, since this could lead to lifetime management bugs, where the dependency is deleted before the PeerConnection is done using it.
Bug: webrtc:7913
Change-Id: I38c3f4ce4f26b37e6fe219d1eeca271294b40db8
Reviewed-on: https://webrtc-review.googlesource.com/73663
Commit-Queue: Benjamin Wright <benwright@webrtc.org>
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23084}
2018-05-02 13:46:31 -07:00
|
|
|
};
|
|
|
|
|
|
2018-05-29 15:04:32 -07:00
|
|
|
// PeerConnectionFactoryDependencies holds all of the PeerConnectionFactory
|
|
|
|
|
// dependencies. All new dependencies should be added here instead of
|
|
|
|
|
// overloading the function. This simplifies dependency injection and makes it
|
|
|
|
|
// clear which are mandatory and optional. If possible please allow the peer
|
|
|
|
|
// connection factory to take ownership of the dependency by adding a unique_ptr
|
|
|
|
|
// to this structure.
|
|
|
|
|
struct PeerConnectionFactoryDependencies final {
|
2018-07-19 10:39:30 +02:00
|
|
|
PeerConnectionFactoryDependencies();
|
2018-05-29 15:04:32 -07:00
|
|
|
// This object is not copyable or assignable.
|
|
|
|
|
PeerConnectionFactoryDependencies(const PeerConnectionFactoryDependencies&) =
|
|
|
|
|
delete;
|
|
|
|
|
PeerConnectionFactoryDependencies& operator=(
|
|
|
|
|
const PeerConnectionFactoryDependencies&) = delete;
|
|
|
|
|
// This object is only moveable.
|
2018-07-19 10:39:30 +02:00
|
|
|
PeerConnectionFactoryDependencies(PeerConnectionFactoryDependencies&&);
|
2018-05-29 15:04:32 -07:00
|
|
|
PeerConnectionFactoryDependencies& operator=(
|
|
|
|
|
PeerConnectionFactoryDependencies&&) = default;
|
2018-07-19 10:39:30 +02:00
|
|
|
~PeerConnectionFactoryDependencies();
|
2018-05-29 15:04:32 -07:00
|
|
|
|
|
|
|
|
// Optional dependencies
|
|
|
|
|
rtc::Thread* network_thread = nullptr;
|
|
|
|
|
rtc::Thread* worker_thread = nullptr;
|
|
|
|
|
rtc::Thread* signaling_thread = nullptr;
|
2019-04-01 10:33:16 +02:00
|
|
|
std::unique_ptr<TaskQueueFactory> task_queue_factory;
|
2018-05-29 15:04:32 -07:00
|
|
|
std::unique_ptr<cricket::MediaEngineInterface> media_engine;
|
|
|
|
|
std::unique_ptr<CallFactoryInterface> call_factory;
|
|
|
|
|
std::unique_ptr<RtcEventLogFactoryInterface> event_log_factory;
|
|
|
|
|
std::unique_ptr<FecControllerFactoryInterface> fec_controller_factory;
|
2019-04-10 13:48:24 +02:00
|
|
|
std::unique_ptr<NetworkStatePredictorFactoryInterface>
|
|
|
|
|
network_state_predictor_factory;
|
2018-05-29 15:04:32 -07:00
|
|
|
std::unique_ptr<NetworkControllerFactoryInterface> network_controller_factory;
|
2018-10-08 09:43:21 -07:00
|
|
|
std::unique_ptr<MediaTransportFactory> media_transport_factory;
|
2018-05-29 15:04:32 -07:00
|
|
|
};
|
|
|
|
|
|
2017-02-08 01:38:21 -08:00
|
|
|
// PeerConnectionFactoryInterface is the factory interface used for creating
|
|
|
|
|
// PeerConnection, MediaStream and MediaStreamTrack objects.
|
|
|
|
|
//
|
|
|
|
|
// The simplest method for obtaiing one, CreatePeerConnectionFactory will
|
|
|
|
|
// create the required libjingle threads, socket and network manager factory
|
|
|
|
|
// classes for networking if none are provided, though it requires that the
|
|
|
|
|
// application runs a message loop on the thread that called the method (see
|
|
|
|
|
// explanation below)
|
|
|
|
|
//
|
|
|
|
|
// If an application decides to provide its own threads and/or implementation
|
|
|
|
|
// of networking classes, it should use the alternate
|
|
|
|
|
// CreatePeerConnectionFactory method which accepts threads as input, and use
|
|
|
|
|
// the CreatePeerConnection version that takes a PortAllocator as an argument.
|
2014-07-29 17:36:52 +00:00
|
|
|
class PeerConnectionFactoryInterface : public rtc::RefCountInterface {
|
2013-07-10 00:45:36 +00:00
|
|
|
public:
|
2013-10-25 21:18:33 +00:00
|
|
|
class Options {
|
|
|
|
|
public:
|
2018-10-11 15:33:17 -07:00
|
|
|
Options() {}
|
2017-02-08 01:38:21 -08:00
|
|
|
|
|
|
|
|
// If set to true, created PeerConnections won't enforce any SRTP
|
|
|
|
|
// requirement, allowing unsecured media. Should only be used for
|
|
|
|
|
// testing/debugging.
|
|
|
|
|
bool disable_encryption = false;
|
|
|
|
|
|
|
|
|
|
// Deprecated. The only effect of setting this to true is that
|
|
|
|
|
// CreateDataChannel will fail, which is not that useful.
|
|
|
|
|
bool disable_sctp_data_channels = false;
|
|
|
|
|
|
|
|
|
|
// If set to true, any platform-supported network monitoring capability
|
|
|
|
|
// won't be used, and instead networks will only be updated via polling.
|
|
|
|
|
//
|
|
|
|
|
// This only has an effect if a PeerConnection is created with the default
|
|
|
|
|
// PortAllocator implementation.
|
|
|
|
|
bool disable_network_monitor = false;
|
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
|
|
|
|
|
|
|
|
// Sets the network types to ignore. For instance, calling this with
|
|
|
|
|
// ADAPTER_TYPE_ETHERNET | ADAPTER_TYPE_LOOPBACK will ignore Ethernet and
|
|
|
|
|
// loopback interfaces.
|
2017-02-08 01:38:21 -08:00
|
|
|
int network_ignore_mask = rtc::kDefaultNetworkIgnoreMask;
|
2015-05-29 09:40:39 +02:00
|
|
|
|
|
|
|
|
// Sets the maximum supported protocol version. The highest version
|
|
|
|
|
// supported by both ends will be used for the connection, i.e. if one
|
|
|
|
|
// party supports DTLS 1.0 and the other DTLS 1.2, DTLS 1.0 will be used.
|
2017-02-08 01:38:21 -08:00
|
|
|
rtc::SSLProtocolVersion ssl_max_version = rtc::SSL_PROTOCOL_DTLS_12;
|
2016-08-04 05:20:32 -07:00
|
|
|
|
|
|
|
|
// Sets crypto related options, e.g. enabled cipher suites.
|
2018-10-11 15:33:17 -07:00
|
|
|
CryptoOptions crypto_options = CryptoOptions::NoGcm();
|
2013-10-25 21:18:33 +00:00
|
|
|
};
|
|
|
|
|
|
Negotiate the same SRTP crypto suites for every DTLS association formed.
Before this CL, we would negotiate:
- No crypto suites for data m= sections.
- A full set for audio m= sections.
- The full set, minus SRTP_AES128_CM_SHA1_32 for video m= sections.
However, this doesn't make sense with BUNDLE, since any DTLS
association could end up being used for any type of media. If
video is "bundled on" the audio transport (which is typical), it
will actually end up using SRTP_AES128_CM_SHA1_32.
So, this CL moves the responsibility of deciding SRTP crypto suites out
of BaseChannel and into DtlsTransport. The only two possibilities are
now "normal set" or "normal set + GCM", if enabled by the PC factory
options.
This fixes an issue (see linked bug) that was occurring when audio/video
were "bundled onto" the data transport. Since the data transport
wasn't negotiating any SRTP crypto suites, none were available to use
for audio/video, so the application would get black video/no audio.
This CL doesn't affect the SDES SRTP crypto suite negotiation;
it only affects the negotiation in the DLTS handshake, through
the use_srtp extension.
BUG=chromium:711243
Review-Url: https://codereview.webrtc.org/2815513012
Cr-Commit-Position: refs/heads/master@{#17810}
2017-04-21 03:23:33 -07:00
|
|
|
// Set the options to be used for subsequently created PeerConnections.
|
2013-10-25 21:18:33 +00:00
|
|
|
virtual void SetOptions(const Options& options) = 0;
|
2014-05-03 05:39:45 +00:00
|
|
|
|
Created PeerConnectionDependencies to avoid creating new CreatePeerConnection overloads.
Currently CreatePeerConnection takes 3 parameters. This is going to expand to four with a new change. Every time a new parameter is added, we need to deprecate the old method, switch clients to the new one, update fake/mock classes and tests, and so on, which is a cumbersome process.
To address this, this CL introduces a PeerConnectionDependencies structure to encapsulate all mandatory and optional dependencies (where a dependency is defined as non trivial
executable code that an API user may want to provide to the native API). This allows adding a new injectable dependency by simply adding a new field to the struct, avoiding the hassle described above.
You may think we could use RTCConfiguration for this. But since RTCConfiguration is both passed in and out of the PeerConnection (using GetConfiguration/SetConfiguration), it can't carry unique_ptrs. And we don't want to inject dependencies via raw pointers, since this could lead to lifetime management bugs, where the dependency is deleted before the PeerConnection is done using it.
Bug: webrtc:7913
Change-Id: I38c3f4ce4f26b37e6fe219d1eeca271294b40db8
Reviewed-on: https://webrtc-review.googlesource.com/73663
Commit-Queue: Benjamin Wright <benwright@webrtc.org>
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23084}
2018-05-02 13:46:31 -07:00
|
|
|
// The preferred way to create a new peer connection. Simply provide the
|
|
|
|
|
// configuration and a PeerConnectionDependencies structure.
|
|
|
|
|
// TODO(benwright): Make pure virtual once downstream mock PC factory classes
|
|
|
|
|
// are updated.
|
|
|
|
|
virtual rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection(
|
|
|
|
|
const PeerConnectionInterface::RTCConfiguration& configuration,
|
2018-07-19 10:39:30 +02:00
|
|
|
PeerConnectionDependencies dependencies);
|
Created PeerConnectionDependencies to avoid creating new CreatePeerConnection overloads.
Currently CreatePeerConnection takes 3 parameters. This is going to expand to four with a new change. Every time a new parameter is added, we need to deprecate the old method, switch clients to the new one, update fake/mock classes and tests, and so on, which is a cumbersome process.
To address this, this CL introduces a PeerConnectionDependencies structure to encapsulate all mandatory and optional dependencies (where a dependency is defined as non trivial
executable code that an API user may want to provide to the native API). This allows adding a new injectable dependency by simply adding a new field to the struct, avoiding the hassle described above.
You may think we could use RTCConfiguration for this. But since RTCConfiguration is both passed in and out of the PeerConnection (using GetConfiguration/SetConfiguration), it can't carry unique_ptrs. And we don't want to inject dependencies via raw pointers, since this could lead to lifetime management bugs, where the dependency is deleted before the PeerConnection is done using it.
Bug: webrtc:7913
Change-Id: I38c3f4ce4f26b37e6fe219d1eeca271294b40db8
Reviewed-on: https://webrtc-review.googlesource.com/73663
Commit-Queue: Benjamin Wright <benwright@webrtc.org>
Reviewed-by: Taylor Brandstetter <deadbeef@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#23084}
2018-05-02 13:46:31 -07:00
|
|
|
|
|
|
|
|
// Deprecated; |allocator| and |cert_generator| may be null, in which case
|
|
|
|
|
// default implementations will be used.
|
2017-04-20 13:19:00 -07:00
|
|
|
//
|
|
|
|
|
// |observer| must not be null.
|
|
|
|
|
//
|
|
|
|
|
// Note that this method does not take ownership of |observer|; it's the
|
|
|
|
|
// responsibility of the caller to delete it. It can be safely deleted after
|
|
|
|
|
// Close has been called on the returned PeerConnection, which ensures no
|
|
|
|
|
// more observer callbacks will be invoked.
|
2015-12-01 15:01:24 -08:00
|
|
|
virtual rtc::scoped_refptr<PeerConnectionInterface> CreatePeerConnection(
|
Replacing DtlsIdentityStoreInterface with RTCCertificateGeneratorInterface.
The store was used in WebRtcSessionDescriptionFactory to generate certificates,
now a generator is used instead (new API). PeerConnection[Factory][Interface],
and WebRtcSession are updated to pass generators all the way down to the
WebRtcSessionDescriptionFactory instead of stores.
The webrtc implementation of a generator, RTCCertificateGenerator, is used as
the default generator (peerconnectionfactory.cc:189) instead of the webrtc
implementation of a store, DtlsIdentityStoreImpl.
The generator is fully parameterized and does not generate RSA-1024 unless you
ask for it (which makes sense not to do beforehand since ECDSA is now default).
The store was not fully parameterized (known filed bug).
The "top" layer, PeerConnectionFactoryInterface::CreatePeerConnection, is
updated to take a generator instead of a store. But as to not break Chromium,
the old function signature taking a store is kept. It is implemented to invoke
the generator version by wrapping the store in an
RTCCertificateGeneratorStoreWrapper. As soon as Chromium is updated to use the
new function signature we can remove the old CreatePeerConnection.
Due to having multiple CreatePeerConnection signatures, some calling places
are updated to resolve the ambiguity introduced.
BUG=webrtc:5707, webrtc:5708
R=phoglund@webrtc.org, tommi@webrtc.org
TBR=tkchin@webrc.org
Review URL: https://codereview.webrtc.org/2013523002 .
Cr-Commit-Position: refs/heads/master@{#12947}
2016-05-27 14:51:55 +02:00
|
|
|
const PeerConnectionInterface::RTCConfiguration& configuration,
|
|
|
|
|
std::unique_ptr<cricket::PortAllocator> allocator,
|
Replacing DtlsIdentityStoreInterface with RTCCertificateGeneratorInterface.
The store was used in WebRtcSessionDescriptionFactory to generate certificates,
now a generator is used instead (new API). PeerConnection[Factory][Interface],
and WebRtcSession are updated to pass generators all the way down to the
WebRtcSessionDescriptionFactory instead of stores.
The webrtc implementation of a generator, RTCCertificateGenerator, is used as
the default generator (peerconnectionfactory.cc:189) instead of the webrtc
implementation of a store, DtlsIdentityStoreImpl.
The generator is fully parameterized and does not generate RSA-1024 unless you
ask for it (which makes sense not to do beforehand since ECDSA is now default).
The store was not fully parameterized (known filed bug).
The "top" layer, PeerConnectionFactoryInterface::CreatePeerConneciton, is
updated to take a generator instead of a store.
Many unittests still use a store, to allow them to continue to do so the
factory gets CreatePeerConnectionWithStore which uses the old function
signature (and invokes the new signature by wrapping the store in an
RTCCertificateGeneratorStoreWrapper). As soon as the FakeDtlsIdentityStore is
turned into a certificate generator instead of a store, the unittests will be
updated and we can remove CreatePeerConnectionWithStore.
This is a reupload of https://codereview.webrtc.org/2013523002/ with minor
changes.
BUG=webrtc:5707, webrtc:5708
R=tommi@webrtc.org
Review URL: https://codereview.webrtc.org/2017943002 .
Cr-Commit-Position: refs/heads/master@{#12984}
2016-06-01 11:44:18 +02:00
|
|
|
std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
|
2018-07-19 10:39:30 +02:00
|
|
|
PeerConnectionObserver* observer);
|
|
|
|
|
|
2018-06-28 14:09:33 +02:00
|
|
|
// Returns the capabilities of an RTP sender of type |kind|.
|
|
|
|
|
// If for some reason you pass in MEDIA_TYPE_DATA, returns an empty structure.
|
|
|
|
|
// TODO(orphis): Make pure virtual when all subclasses implement it.
|
|
|
|
|
virtual RtpCapabilities GetRtpSenderCapabilities(
|
2018-07-19 10:39:30 +02:00
|
|
|
cricket::MediaType kind) const;
|
2018-06-28 14:09:33 +02:00
|
|
|
|
|
|
|
|
// Returns the capabilities of an RTP receiver of type |kind|.
|
|
|
|
|
// If for some reason you pass in MEDIA_TYPE_DATA, returns an empty structure.
|
|
|
|
|
// TODO(orphis): Make pure virtual when all subclasses implement it.
|
|
|
|
|
virtual RtpCapabilities GetRtpReceiverCapabilities(
|
2018-07-19 10:39:30 +02:00
|
|
|
cricket::MediaType kind) const;
|
2018-06-28 14:09:33 +02:00
|
|
|
|
2018-03-02 11:34:10 -08:00
|
|
|
virtual rtc::scoped_refptr<MediaStreamInterface> CreateLocalMediaStream(
|
|
|
|
|
const std::string& stream_id) = 0;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2017-02-25 18:15:09 -08:00
|
|
|
// Creates an AudioSourceInterface.
|
2017-02-08 01:38:21 -08:00
|
|
|
// |options| decides audio processing settings.
|
2016-03-04 02:51:39 -08:00
|
|
|
virtual rtc::scoped_refptr<AudioSourceInterface> CreateAudioSource(
|
|
|
|
|
const cricket::AudioOptions& options) = 0;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
// Creates a new local VideoTrack. The same |source| can be used in several
|
|
|
|
|
// tracks.
|
2016-03-08 01:27:48 +01:00
|
|
|
virtual rtc::scoped_refptr<VideoTrackInterface> CreateVideoTrack(
|
|
|
|
|
const std::string& label,
|
|
|
|
|
VideoTrackSourceInterface* source) = 0;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2017-02-27 14:47:33 -08:00
|
|
|
// Creates an new AudioTrack. At the moment |source| can be null.
|
2018-06-19 15:03:05 +02:00
|
|
|
virtual rtc::scoped_refptr<AudioTrackInterface> CreateAudioTrack(
|
|
|
|
|
const std::string& label,
|
|
|
|
|
AudioSourceInterface* source) = 0;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2013-12-13 00:21:03 +00:00
|
|
|
// Starts AEC dump using existing file. Takes ownership of |file| and passes
|
|
|
|
|
// it on to VoiceEngine (via other objects) immediately, which will take
|
2014-01-23 22:12:45 +00:00
|
|
|
// the ownerhip. If the operation fails, the file will be closed.
|
2016-01-15 03:06:36 -08:00
|
|
|
// A maximum file size in bytes can be specified. When the file size limit is
|
|
|
|
|
// reached, logging is stopped automatically. If max_size_bytes is set to a
|
|
|
|
|
// value <= 0, no limit will be used, and logging will continue until the
|
|
|
|
|
// StopAecDump function is called.
|
2019-06-11 14:04:16 +02:00
|
|
|
// TODO(webrtc:6463): Delete default implementation when downstream mocks
|
|
|
|
|
// classes are updated.
|
|
|
|
|
virtual bool StartAecDump(FILE* file, int64_t max_size_bytes) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2013-12-13 00:21:03 +00:00
|
|
|
|
2015-10-22 03:25:41 -07:00
|
|
|
// Stops logging the AEC dump.
|
|
|
|
|
virtual void StopAecDump() = 0;
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
protected:
|
|
|
|
|
// Dtor and ctor protected as objects shouldn't be created or deleted via
|
|
|
|
|
// this interface.
|
|
|
|
|
PeerConnectionFactoryInterface() {}
|
2018-07-19 10:39:30 +02:00
|
|
|
~PeerConnectionFactoryInterface() override = default;
|
2013-07-10 00:45:36 +00:00
|
|
|
};
|
|
|
|
|
|
2019-05-20 14:36:00 +02:00
|
|
|
// CreateModularPeerConnectionFactory is implemented in the "peerconnection"
|
|
|
|
|
// build target, which doesn't pull in the implementations of every module
|
|
|
|
|
// webrtc may use.
|
2017-06-15 12:52:32 -07:00
|
|
|
//
|
|
|
|
|
// If an application knows it will only require certain modules, it can reduce
|
|
|
|
|
// webrtc's impact on its binary size by depending only on the "peerconnection"
|
|
|
|
|
// target and the modules the application requires, using
|
2019-05-20 14:36:00 +02:00
|
|
|
// CreateModularPeerConnectionFactory. For example, if an application
|
2017-06-15 12:52:32 -07:00
|
|
|
// only uses WebRTC for audio, it can pass in null pointers for the
|
|
|
|
|
// video-specific interfaces, and omit the corresponding modules from its
|
|
|
|
|
// build.
|
|
|
|
|
//
|
|
|
|
|
// If |network_thread| or |worker_thread| are null, the PeerConnectionFactory
|
|
|
|
|
// will create the necessary thread internally. If |signaling_thread| is null,
|
|
|
|
|
// the PeerConnectionFactory will use the thread on which this method is called
|
|
|
|
|
// as the signaling thread, wrapping it in an rtc::Thread object if needed.
|
2018-05-29 15:04:32 -07:00
|
|
|
rtc::scoped_refptr<PeerConnectionFactoryInterface>
|
|
|
|
|
CreateModularPeerConnectionFactory(
|
|
|
|
|
PeerConnectionFactoryDependencies dependencies);
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2019-01-11 09:11:00 -08:00
|
|
|
#endif // API_PEER_CONNECTION_INTERFACE_H_
|