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
|
|
|
*/
|
|
|
|
|
|
2019-01-11 09:11:00 -08:00
|
|
|
#ifndef PC_PEER_CONNECTION_H_
|
|
|
|
|
#define PC_PEER_CONNECTION_H_
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2016-03-24 03:16:19 -07:00
|
|
|
#include <map>
|
2016-04-27 06:47:29 -07:00
|
|
|
#include <memory>
|
2017-11-06 10:37:17 -08:00
|
|
|
#include <set>
|
|
|
|
|
#include <string>
|
2019-07-18 11:16:56 +02:00
|
|
|
#include <utility>
|
2016-03-24 03:16:19 -07:00
|
|
|
#include <vector>
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "api/peer_connection_interface.h"
|
2019-09-12 13:59:36 +02:00
|
|
|
#include "api/transport/data_channel_transport_interface.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "api/turn_customizer.h"
|
2019-12-03 14:04:21 +01:00
|
|
|
#include "pc/data_channel_controller.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "pc/ice_server_parsing.h"
|
|
|
|
|
#include "pc/jsep_transport_controller.h"
|
|
|
|
|
#include "pc/peer_connection_factory.h"
|
|
|
|
|
#include "pc/peer_connection_internal.h"
|
|
|
|
|
#include "pc/rtc_stats_collector.h"
|
2019-05-20 19:31:53 +02:00
|
|
|
#include "pc/rtp_sender.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "pc/rtp_transceiver.h"
|
2019-02-28 07:51:00 +01:00
|
|
|
#include "pc/sctp_transport.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "pc/stats_collector.h"
|
|
|
|
|
#include "pc/stream_collection.h"
|
|
|
|
|
#include "pc/webrtc_session_description_factory.h"
|
2019-07-09 12:31:20 +02:00
|
|
|
#include "rtc_base/experiments/field_trial_parser.h"
|
2019-10-28 12:09:49 +01:00
|
|
|
#include "rtc_base/operations_chain.h"
|
2019-02-21 23:55:09 +01:00
|
|
|
#include "rtc_base/race_checker.h"
|
2019-01-23 14:54:24 -08:00
|
|
|
#include "rtc_base/unique_id_generator.h"
|
2019-10-28 12:09:49 +01:00
|
|
|
#include "rtc_base/weak_ptr.h"
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2015-12-15 19:24:43 -08:00
|
|
|
class MediaStreamObserver;
|
2016-03-10 18:32:00 +01:00
|
|
|
class VideoRtpReceiver;
|
2016-10-07 11:53:05 -07:00
|
|
|
class RtcEventLog;
|
2015-10-14 11:33:11 -07:00
|
|
|
|
2017-11-06 10:37:17 -08:00
|
|
|
// PeerConnection is the implementation of the PeerConnection object as defined
|
|
|
|
|
// by the PeerConnectionInterface API surface.
|
|
|
|
|
// The class currently is solely responsible for the following:
|
|
|
|
|
// - Managing the session state machine (signaling state).
|
|
|
|
|
// - Creating and initializing lower-level objects, like PortAllocator and
|
|
|
|
|
// BaseChannels.
|
|
|
|
|
// - Owning and managing the life cycle of the RtpSender/RtpReceiver and track
|
|
|
|
|
// objects.
|
|
|
|
|
// - Tracking the current and pending local/remote session descriptions.
|
|
|
|
|
// The class currently is jointly responsible for the following:
|
|
|
|
|
// - Parsing and interpreting SDP.
|
|
|
|
|
// - Generating offers and answers based on the current state.
|
|
|
|
|
// - The ICE state machine.
|
|
|
|
|
// - Generating stats.
|
2018-01-23 16:38:46 -08:00
|
|
|
class PeerConnection : public PeerConnectionInternal,
|
2018-04-13 16:44:34 -07:00
|
|
|
public JsepTransportController::Observer,
|
2019-05-20 19:31:53 +02:00
|
|
|
public RtpSenderBase::SetStreamsObserver,
|
2018-09-05 20:22:40 +00:00
|
|
|
public rtc::MessageHandler,
|
2013-07-10 00:45:36 +00:00
|
|
|
public sigslot::has_slots<> {
|
|
|
|
|
public:
|
2019-08-19 11:57:17 -07:00
|
|
|
// A bit in the usage pattern is registered when its defining event occurs at
|
|
|
|
|
// least once.
|
2018-05-31 14:00:34 +02:00
|
|
|
enum class UsageEvent : int {
|
|
|
|
|
TURN_SERVER_ADDED = 0x01,
|
|
|
|
|
STUN_SERVER_ADDED = 0x02,
|
|
|
|
|
DATA_ADDED = 0x04,
|
|
|
|
|
AUDIO_ADDED = 0x08,
|
|
|
|
|
VIDEO_ADDED = 0x10,
|
2019-08-19 11:57:17 -07:00
|
|
|
// |SetLocalDescription| returns successfully.
|
|
|
|
|
SET_LOCAL_DESCRIPTION_SUCCEEDED = 0x20,
|
|
|
|
|
// |SetRemoteDescription| returns successfully.
|
|
|
|
|
SET_REMOTE_DESCRIPTION_SUCCEEDED = 0x40,
|
|
|
|
|
// A local candidate (with type host, server-reflexive, or relay) is
|
|
|
|
|
// collected.
|
2018-05-31 14:00:34 +02:00
|
|
|
CANDIDATE_COLLECTED = 0x80,
|
2019-08-19 11:57:17 -07:00
|
|
|
// A remote candidate is successfully added via |AddIceCandidate|.
|
|
|
|
|
ADD_ICE_CANDIDATE_SUCCEEDED = 0x100,
|
2018-05-31 14:00:34 +02:00
|
|
|
ICE_STATE_CONNECTED = 0x200,
|
2018-07-12 12:54:53 -07:00
|
|
|
CLOSE_CALLED = 0x400,
|
2019-08-19 11:57:17 -07:00
|
|
|
// A local candidate with private IP is collected.
|
2018-07-16 19:18:58 +02:00
|
|
|
PRIVATE_CANDIDATE_COLLECTED = 0x800,
|
2019-08-19 11:57:17 -07:00
|
|
|
// A remote candidate with private IP is added, either via AddiceCandidate
|
|
|
|
|
// or from the remote description.
|
2019-04-24 13:13:48 -07:00
|
|
|
REMOTE_PRIVATE_CANDIDATE_ADDED = 0x1000,
|
2019-08-19 11:57:17 -07:00
|
|
|
// A local mDNS candidate is collected.
|
2019-04-24 13:13:48 -07:00
|
|
|
MDNS_CANDIDATE_COLLECTED = 0x2000,
|
2019-08-19 11:57:17 -07:00
|
|
|
// A remote mDNS candidate is added, either via AddIceCandidate or from the
|
|
|
|
|
// remote description.
|
2019-04-24 13:13:48 -07:00
|
|
|
REMOTE_MDNS_CANDIDATE_ADDED = 0x4000,
|
2019-08-19 11:57:17 -07:00
|
|
|
// A local candidate with IPv6 address is collected.
|
|
|
|
|
IPV6_CANDIDATE_COLLECTED = 0x8000,
|
|
|
|
|
// A remote candidate with IPv6 address is added, either via AddIceCandidate
|
|
|
|
|
// or from the remote description.
|
|
|
|
|
REMOTE_IPV6_CANDIDATE_ADDED = 0x10000,
|
|
|
|
|
// A remote candidate (with type host, server-reflexive, or relay) is
|
|
|
|
|
// successfully added, either via AddIceCandidate or from the remote
|
|
|
|
|
// description.
|
|
|
|
|
REMOTE_CANDIDATE_ADDED = 0x20000,
|
2019-09-12 11:19:01 -07:00
|
|
|
// An explicit host-host candidate pair is selected, i.e. both the local and
|
|
|
|
|
// the remote candidates have the host type. This does not include candidate
|
|
|
|
|
// pairs formed with equivalent prflx remote candidates, e.g. a host-prflx
|
|
|
|
|
// pair where the prflx candidate has the same base as a host candidate of
|
|
|
|
|
// the remote peer.
|
|
|
|
|
DIRECT_CONNECTION_SELECTED = 0x40000,
|
|
|
|
|
MAX_VALUE = 0x80000,
|
2018-05-31 14:00:34 +02:00
|
|
|
};
|
|
|
|
|
|
2017-06-15 12:52:32 -07:00
|
|
|
explicit PeerConnection(PeerConnectionFactory* factory,
|
|
|
|
|
std::unique_ptr<RtcEventLog> event_log,
|
|
|
|
|
std::unique_ptr<Call> call);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-11-11 12:55:10 -08:00
|
|
|
bool Initialize(
|
|
|
|
|
const PeerConnectionInterface::RTCConfiguration& configuration,
|
2018-05-02 15:12:47 -07:00
|
|
|
PeerConnectionDependencies dependencies);
|
2015-11-11 12:55:10 -08:00
|
|
|
|
2015-09-29 11:56:26 -07:00
|
|
|
rtc::scoped_refptr<StreamCollectionInterface> local_streams() override;
|
|
|
|
|
rtc::scoped_refptr<StreamCollectionInterface> remote_streams() override;
|
|
|
|
|
bool AddStream(MediaStreamInterface* local_stream) override;
|
|
|
|
|
void RemoveStream(MediaStreamInterface* local_stream) override;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2018-01-05 17:10:52 -08:00
|
|
|
RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>> AddTrack(
|
2017-12-14 10:23:57 -08:00
|
|
|
rtc::scoped_refptr<MediaStreamTrackInterface> track,
|
2018-03-02 11:34:10 -08:00
|
|
|
const std::vector<std::string>& stream_ids) override;
|
2016-01-14 15:35:42 -08:00
|
|
|
bool RemoveTrack(RtpSenderInterface* sender) override;
|
2018-07-23 10:27:33 -07:00
|
|
|
RTCError RemoveTrackNew(
|
|
|
|
|
rtc::scoped_refptr<RtpSenderInterface> sender) override;
|
2016-01-14 15:35:42 -08:00
|
|
|
|
2017-11-27 13:01:52 -08:00
|
|
|
RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver(
|
|
|
|
|
rtc::scoped_refptr<MediaStreamTrackInterface> track) override;
|
|
|
|
|
RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver(
|
|
|
|
|
rtc::scoped_refptr<MediaStreamTrackInterface> track,
|
|
|
|
|
const RtpTransceiverInit& init) override;
|
|
|
|
|
RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver(
|
|
|
|
|
cricket::MediaType media_type) override;
|
|
|
|
|
RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver(
|
|
|
|
|
cricket::MediaType media_type,
|
|
|
|
|
const RtpTransceiverInit& init) override;
|
|
|
|
|
|
2017-10-03 10:03:10 -07:00
|
|
|
// Gets the DTLS SSL certificate associated with the audio transport on the
|
|
|
|
|
// remote side. This will become populated once the DTLS connection with the
|
|
|
|
|
// peer has been completed, as indicated by the ICE connection state
|
|
|
|
|
// transitioning to kIceConnectionCompleted.
|
|
|
|
|
// Note that this will be removed once we implement RTCDtlsTransport which
|
|
|
|
|
// has standardized method for getting this information.
|
|
|
|
|
// See https://www.w3.org/TR/webrtc/#rtcdtlstransport-interface
|
|
|
|
|
std::unique_ptr<rtc::SSLCertificate> GetRemoteAudioSSLCertificate();
|
|
|
|
|
|
2018-01-27 14:16:15 -08:00
|
|
|
// Version of the above method that returns the full certificate chain.
|
|
|
|
|
std::unique_ptr<rtc::SSLCertChain> GetRemoteAudioSSLCertChain();
|
|
|
|
|
|
2015-11-25 11:26:01 -08:00
|
|
|
rtc::scoped_refptr<RtpSenderInterface> CreateSender(
|
2015-12-18 16:58:44 -08:00
|
|
|
const std::string& kind,
|
|
|
|
|
const std::string& stream_id) override;
|
2015-11-25 11:26:01 -08:00
|
|
|
|
2015-09-28 16:53:55 -07:00
|
|
|
std::vector<rtc::scoped_refptr<RtpSenderInterface>> GetSenders()
|
|
|
|
|
const override;
|
|
|
|
|
std::vector<rtc::scoped_refptr<RtpReceiverInterface>> GetReceivers()
|
|
|
|
|
const override;
|
2017-11-27 13:01:52 -08:00
|
|
|
std::vector<rtc::scoped_refptr<RtpTransceiverInterface>> GetTransceivers()
|
|
|
|
|
const override;
|
2015-09-28 16:53:55 -07:00
|
|
|
|
2015-09-29 11:56:26 -07:00
|
|
|
rtc::scoped_refptr<DataChannelInterface> CreateDataChannel(
|
2013-07-10 00:45:36 +00:00
|
|
|
const std::string& label,
|
2015-09-29 11:56:26 -07:00
|
|
|
const DataChannelInit* config) override;
|
2018-03-20 13:24:20 +01:00
|
|
|
// WARNING: LEGACY. See peerconnectioninterface.h
|
2015-09-29 11:56:26 -07:00
|
|
|
bool GetStats(StatsObserver* observer,
|
|
|
|
|
webrtc::MediaStreamTrackInterface* track,
|
|
|
|
|
StatsOutputLevel level) override;
|
2018-03-20 13:24:20 +01:00
|
|
|
// Spec-complaint GetStats(). See peerconnectioninterface.h
|
2016-09-15 23:33:01 -07:00
|
|
|
void GetStats(RTCStatsCollectorCallback* callback) override;
|
2018-03-20 13:24:20 +01:00
|
|
|
void GetStats(
|
|
|
|
|
rtc::scoped_refptr<RtpSenderInterface> selector,
|
|
|
|
|
rtc::scoped_refptr<RTCStatsCollectorCallback> callback) override;
|
|
|
|
|
void GetStats(
|
|
|
|
|
rtc::scoped_refptr<RtpReceiverInterface> selector,
|
|
|
|
|
rtc::scoped_refptr<RTCStatsCollectorCallback> callback) override;
|
2018-01-02 14:08:34 +01:00
|
|
|
void ClearStatsCache() override;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-09-29 11:56:26 -07:00
|
|
|
SignalingState signaling_state() override;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-09-29 11:56:26 -07:00
|
|
|
IceConnectionState ice_connection_state() override;
|
2018-12-06 11:25:14 +01:00
|
|
|
IceConnectionState standardized_ice_connection_state() override;
|
2018-10-18 15:58:17 +02:00
|
|
|
PeerConnectionState peer_connection_state() override;
|
2015-09-29 11:56:26 -07:00
|
|
|
IceGatheringState ice_gathering_state() override;
|
2020-03-02 11:20:00 +01:00
|
|
|
absl::optional<bool> can_trickle_ice_candidates() override;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-09-29 11:56:26 -07:00
|
|
|
const SessionDescriptionInterface* local_description() const override;
|
|
|
|
|
const SessionDescriptionInterface* remote_description() const override;
|
2016-12-20 17:56:17 -08:00
|
|
|
const SessionDescriptionInterface* current_local_description() const override;
|
|
|
|
|
const SessionDescriptionInterface* current_remote_description()
|
|
|
|
|
const override;
|
|
|
|
|
const SessionDescriptionInterface* pending_local_description() const override;
|
|
|
|
|
const SessionDescriptionInterface* pending_remote_description()
|
|
|
|
|
const override;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2019-07-18 11:16:56 +02:00
|
|
|
void RestartIce() override;
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
// JSEP01
|
2015-09-29 11:56:26 -07:00
|
|
|
void CreateOffer(CreateSessionDescriptionObserver* observer,
|
|
|
|
|
const RTCOfferAnswerOptions& options) override;
|
2016-03-04 02:51:39 -08:00
|
|
|
void CreateAnswer(CreateSessionDescriptionObserver* observer,
|
|
|
|
|
const RTCOfferAnswerOptions& options) override;
|
2020-07-29 12:04:00 +02:00
|
|
|
|
|
|
|
|
void SetLocalDescription(
|
|
|
|
|
std::unique_ptr<SessionDescriptionInterface> desc,
|
|
|
|
|
rtc::scoped_refptr<SetLocalDescriptionObserverInterface> observer)
|
|
|
|
|
override;
|
|
|
|
|
void SetLocalDescription(
|
|
|
|
|
rtc::scoped_refptr<SetLocalDescriptionObserverInterface> observer)
|
|
|
|
|
override;
|
|
|
|
|
// TODO(https://crbug.com/webrtc/11798): Delete these methods in favor of the
|
|
|
|
|
// ones taking SetLocalDescriptionObserverInterface as argument.
|
2015-09-29 11:56:26 -07:00
|
|
|
void SetLocalDescription(SetSessionDescriptionObserver* observer,
|
|
|
|
|
SessionDescriptionInterface* desc) override;
|
2019-10-30 10:35:50 +01:00
|
|
|
void SetLocalDescription(SetSessionDescriptionObserver* observer) override;
|
2020-07-29 12:04:00 +02:00
|
|
|
|
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
|
|
|
void SetRemoteDescription(
|
|
|
|
|
std::unique_ptr<SessionDescriptionInterface> desc,
|
|
|
|
|
rtc::scoped_refptr<SetRemoteDescriptionObserverInterface> observer)
|
|
|
|
|
override;
|
2020-07-29 12:04:00 +02:00
|
|
|
// TODO(https://crbug.com/webrtc/11798): Delete this methods in favor of the
|
|
|
|
|
// ones taking SetRemoteDescriptionObserverInterface as argument.
|
|
|
|
|
void SetRemoteDescription(SetSessionDescriptionObserver* observer,
|
|
|
|
|
SessionDescriptionInterface* desc) override;
|
|
|
|
|
|
2016-11-16 19:42:04 -08:00
|
|
|
PeerConnectionInterface::RTCConfiguration GetConfiguration() override;
|
2019-08-19 09:58:17 +02:00
|
|
|
RTCError SetConfiguration(
|
|
|
|
|
const PeerConnectionInterface::RTCConfiguration& configuration) override;
|
2015-09-29 11:56:26 -07:00
|
|
|
bool AddIceCandidate(const IceCandidateInterface* candidate) override;
|
2019-11-06 12:36:12 +01:00
|
|
|
void AddIceCandidate(std::unique_ptr<IceCandidateInterface> candidate,
|
|
|
|
|
std::function<void(RTCError)> callback) override;
|
2016-03-14 11:59:18 -07:00
|
|
|
bool RemoveIceCandidates(
|
|
|
|
|
const std::vector<cricket::Candidate>& candidates) override;
|
2015-09-29 11:56:26 -07:00
|
|
|
|
2018-05-07 14:01:37 +02:00
|
|
|
RTCError SetBitrate(const BitrateSettings& bitrate) override;
|
2017-06-02 14:37:37 -07:00
|
|
|
|
2017-11-01 11:06:56 +01:00
|
|
|
void SetAudioPlayout(bool playout) override;
|
|
|
|
|
void SetAudioRecording(bool recording) override;
|
|
|
|
|
|
2018-11-28 16:47:46 +01:00
|
|
|
rtc::scoped_refptr<DtlsTransportInterface> LookupDtlsTransportByMid(
|
|
|
|
|
const std::string& mid) override;
|
2019-01-17 10:39:40 +01:00
|
|
|
rtc::scoped_refptr<DtlsTransport> LookupDtlsTransportByMidInternal(
|
|
|
|
|
const std::string& mid);
|
2018-11-28 16:47:46 +01:00
|
|
|
|
2019-02-28 07:51:00 +01:00
|
|
|
rtc::scoped_refptr<SctpTransportInterface> GetSctpTransport() const override;
|
|
|
|
|
|
2020-06-11 12:26:53 +02:00
|
|
|
void AddAdaptationResource(rtc::scoped_refptr<Resource> resource) override;
|
|
|
|
|
|
2017-11-20 17:38:14 +01:00
|
|
|
bool StartRtcEventLog(std::unique_ptr<RtcEventLogOutput> output,
|
|
|
|
|
int64_t output_period_ms) override;
|
2019-05-10 11:33:12 +02:00
|
|
|
bool StartRtcEventLog(std::unique_ptr<RtcEventLogOutput> output) override;
|
2016-07-04 07:06:55 -07:00
|
|
|
void StopRtcEventLog() override;
|
|
|
|
|
|
2015-09-29 11:56:26 -07:00
|
|
|
void Close() override;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2018-01-23 16:38:46 -08:00
|
|
|
// PeerConnectionInternal implementation.
|
2019-02-22 00:57:06 +01:00
|
|
|
rtc::Thread* network_thread() const final {
|
2018-01-23 16:38:46 -08:00
|
|
|
return factory_->network_thread();
|
|
|
|
|
}
|
2019-02-22 00:57:06 +01:00
|
|
|
rtc::Thread* worker_thread() const final { return factory_->worker_thread(); }
|
|
|
|
|
rtc::Thread* signaling_thread() const final {
|
2018-01-23 16:38:46 -08:00
|
|
|
return factory_->signaling_thread();
|
2016-03-24 03:16:19 -07:00
|
|
|
}
|
2015-10-14 11:33:11 -07:00
|
|
|
|
2019-03-26 13:33:43 +01:00
|
|
|
std::string session_id() const override {
|
|
|
|
|
RTC_DCHECK_RUN_ON(signaling_thread());
|
|
|
|
|
return session_id_;
|
|
|
|
|
}
|
2017-11-06 10:37:17 -08:00
|
|
|
|
2018-01-23 16:38:46 -08:00
|
|
|
bool initial_offerer() const override {
|
2019-04-02 11:31:56 +02:00
|
|
|
RTC_DCHECK_RUN_ON(signaling_thread());
|
2018-03-30 10:48:35 -07:00
|
|
|
return transport_controller_ && transport_controller_->initial_offerer();
|
2018-01-23 16:38:46 -08:00
|
|
|
}
|
2017-11-06 10:37:17 -08:00
|
|
|
|
2018-01-23 16:38:46 -08:00
|
|
|
std::vector<
|
|
|
|
|
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>>
|
2018-02-13 10:07:54 -08:00
|
|
|
GetTransceiversInternal() const override {
|
2019-03-26 13:33:43 +01:00
|
|
|
RTC_DCHECK_RUN_ON(signaling_thread());
|
2018-01-23 16:38:46 -08:00
|
|
|
return transceivers_;
|
2017-09-29 12:15:02 -07:00
|
|
|
}
|
2018-01-23 16:38:46 -08:00
|
|
|
|
2020-07-09 15:32:34 -07:00
|
|
|
sigslot::signal1<RtpDataChannel*>& SignalRtpDataChannelCreated() override {
|
|
|
|
|
return data_channel_controller_.SignalRtpDataChannelCreated();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
sigslot::signal1<SctpDataChannel*>& SignalSctpDataChannelCreated() override {
|
|
|
|
|
return data_channel_controller_.SignalSctpDataChannelCreated();
|
2017-09-29 12:15:02 -07:00
|
|
|
}
|
2018-01-23 16:38:46 -08:00
|
|
|
|
|
|
|
|
cricket::RtpDataChannel* rtp_data_channel() const override {
|
2019-12-02 09:56:02 +01:00
|
|
|
return data_channel_controller_.rtp_data_channel();
|
2017-10-23 14:49:26 -07:00
|
|
|
}
|
2017-09-29 12:15:02 -07:00
|
|
|
|
2020-07-09 15:32:34 -07:00
|
|
|
std::vector<DataChannelStats> GetDataChannelStats() const override;
|
2017-11-06 10:37:17 -08:00
|
|
|
|
2018-06-19 16:47:43 +02:00
|
|
|
absl::optional<std::string> sctp_transport_name() const override;
|
2017-11-06 10:37:17 -08:00
|
|
|
|
2018-02-20 16:03:18 -08:00
|
|
|
cricket::CandidateStatsList GetPooledCandidateStats() const override;
|
2018-02-06 10:34:40 -08:00
|
|
|
std::map<std::string, std::string> GetTransportNamesByMid() const override;
|
|
|
|
|
std::map<std::string, cricket::TransportStats> GetTransportStatsByNames(
|
|
|
|
|
const std::set<std::string>& transport_names) override;
|
2018-01-23 16:38:46 -08:00
|
|
|
Call::Stats GetCallStats() override;
|
2017-11-06 10:37:17 -08:00
|
|
|
|
2018-01-23 16:38:46 -08:00
|
|
|
bool GetLocalCertificate(
|
|
|
|
|
const std::string& transport_name,
|
|
|
|
|
rtc::scoped_refptr<rtc::RTCCertificate>* certificate) override;
|
2018-02-23 13:04:51 -08:00
|
|
|
std::unique_ptr<rtc::SSLCertChain> GetRemoteSSLCertChain(
|
2018-01-23 16:38:46 -08:00
|
|
|
const std::string& transport_name) override;
|
|
|
|
|
bool IceRestartPending(const std::string& content_name) const override;
|
|
|
|
|
bool NeedsIceRestart(const std::string& content_name) const override;
|
|
|
|
|
bool GetSslRole(const std::string& content_name, rtc::SSLRole* role) override;
|
2018-01-19 11:10:37 -08:00
|
|
|
|
2019-12-03 14:04:21 +01:00
|
|
|
// Functions needed by DataChannelController
|
|
|
|
|
void NoteDataAddedEvent() { NoteUsageEvent(UsageEvent::DATA_ADDED); }
|
|
|
|
|
// Returns the observer. Will crash on CHECK if the observer is removed.
|
|
|
|
|
PeerConnectionObserver* Observer() const;
|
|
|
|
|
bool IsClosed() const {
|
|
|
|
|
RTC_DCHECK_RUN_ON(signaling_thread());
|
|
|
|
|
return signaling_state_ == PeerConnectionInterface::kClosed;
|
|
|
|
|
}
|
|
|
|
|
// Get current SSL role used by SCTP's underlying transport.
|
|
|
|
|
bool GetSctpSslRole(rtc::SSLRole* role);
|
|
|
|
|
// Handler for the "channel closed" signal
|
2020-07-09 15:32:34 -07:00
|
|
|
void OnSctpDataChannelClosed(DataChannelInterface* channel);
|
2019-12-03 14:04:21 +01:00
|
|
|
|
|
|
|
|
// Functions made public for testing.
|
2018-06-25 12:03:50 +02:00
|
|
|
void ReturnHistogramVeryQuicklyForTesting() {
|
2019-04-08 15:36:53 +02:00
|
|
|
RTC_DCHECK_RUN_ON(signaling_thread());
|
2018-06-25 12:03:50 +02:00
|
|
|
return_histogram_very_quickly_ = true;
|
|
|
|
|
}
|
2018-08-01 10:50:16 +02:00
|
|
|
void RequestUsagePatternReportForTesting();
|
2020-02-05 12:07:33 +01:00
|
|
|
absl::optional<std::string> sctp_mid() {
|
|
|
|
|
RTC_DCHECK_RUN_ON(signaling_thread());
|
2020-02-12 07:38:21 +01:00
|
|
|
return sctp_mid_s_;
|
2020-02-05 12:07:33 +01:00
|
|
|
}
|
2018-06-25 12:03:50 +02:00
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
protected:
|
2015-09-29 11:56:26 -07:00
|
|
|
~PeerConnection() override;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
|
|
|
|
private:
|
2019-10-30 10:35:50 +01:00
|
|
|
class ImplicitCreateSessionDescriptionObserver;
|
|
|
|
|
friend class ImplicitCreateSessionDescriptionObserver;
|
2020-07-29 12:04:00 +02:00
|
|
|
class SetSessionDescriptionObserverAdapter;
|
|
|
|
|
friend class SetSessionDescriptionObserverAdapter;
|
2019-12-03 14:04:21 +01:00
|
|
|
|
2019-07-18 11:16:56 +02:00
|
|
|
// Represents the [[LocalIceCredentialsToReplace]] internal slot in the spec.
|
|
|
|
|
// It makes the next CreateOffer() produce new ICE credentials even if
|
|
|
|
|
// RTCOfferAnswerOptions::ice_restart is false.
|
|
|
|
|
// https://w3c.github.io/webrtc-pc/#dfn-localufragstoreplace
|
|
|
|
|
// TODO(hbos): When JsepTransportController/JsepTransport supports rollback,
|
|
|
|
|
// move this type of logic to JsepTransportController/JsepTransport.
|
|
|
|
|
class LocalIceCredentialsToReplace;
|
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
|
|
|
|
2017-11-20 10:20:22 -08:00
|
|
|
struct RtpSenderInfo {
|
|
|
|
|
RtpSenderInfo() : first_ssrc(0) {}
|
2018-03-02 11:34:10 -08:00
|
|
|
RtpSenderInfo(const std::string& stream_id,
|
2017-11-20 10:20:22 -08:00
|
|
|
const std::string sender_id,
|
|
|
|
|
uint32_t ssrc)
|
2018-03-02 11:34:10 -08:00
|
|
|
: stream_id(stream_id), sender_id(sender_id), first_ssrc(ssrc) {}
|
2017-11-20 10:20:22 -08:00
|
|
|
bool operator==(const RtpSenderInfo& other) {
|
2018-03-02 11:34:10 -08:00
|
|
|
return this->stream_id == other.stream_id &&
|
2017-11-20 10:20:22 -08:00
|
|
|
this->sender_id == other.sender_id &&
|
|
|
|
|
this->first_ssrc == other.first_ssrc;
|
2015-12-08 17:13:40 -08:00
|
|
|
}
|
2018-03-02 11:34:10 -08:00
|
|
|
std::string stream_id;
|
2017-11-20 10:20:22 -08:00
|
|
|
std::string sender_id;
|
|
|
|
|
// An RtpSender can have many SSRCs. The first one is used as a sort of ID
|
|
|
|
|
// for communicating with the lower layers.
|
|
|
|
|
uint32_t first_ssrc;
|
2015-10-14 11:33:11 -07:00
|
|
|
};
|
|
|
|
|
|
2019-10-09 18:29:44 +03:00
|
|
|
// Captures partial state to be used for rollback. Applicable only in
|
|
|
|
|
// Unified Plan.
|
|
|
|
|
class TransceiverStableState {
|
|
|
|
|
public:
|
|
|
|
|
TransceiverStableState() {}
|
2019-11-25 18:49:44 +02:00
|
|
|
void set_newly_created();
|
|
|
|
|
void SetMSectionIfUnset(absl::optional<std::string> mid,
|
|
|
|
|
absl::optional<size_t> mline_index);
|
|
|
|
|
void SetRemoteStreamIdsIfUnset(const std::vector<std::string>& ids);
|
2019-10-09 18:29:44 +03:00
|
|
|
absl::optional<std::string> mid() const { return mid_; }
|
|
|
|
|
absl::optional<size_t> mline_index() const { return mline_index_; }
|
2019-11-25 18:49:44 +02:00
|
|
|
absl::optional<std::vector<std::string>> remote_stream_ids() const {
|
|
|
|
|
return remote_stream_ids_;
|
|
|
|
|
}
|
|
|
|
|
bool has_m_section() const { return has_m_section_; }
|
2019-10-09 18:29:44 +03:00
|
|
|
bool newly_created() const { return newly_created_; }
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
absl::optional<std::string> mid_;
|
|
|
|
|
absl::optional<size_t> mline_index_;
|
2019-11-25 18:49:44 +02:00
|
|
|
absl::optional<std::vector<std::string>> remote_stream_ids_;
|
|
|
|
|
// Indicates that mid value from stable state has been captured and
|
|
|
|
|
// that rollback has to restore the transceiver. Also protects against
|
|
|
|
|
// subsequent overwrites.
|
|
|
|
|
bool has_m_section_ = false;
|
2019-10-09 18:29:44 +03:00
|
|
|
// Indicates that the transceiver was created as part of applying a
|
|
|
|
|
// description to track potential need for removing transceiver during
|
|
|
|
|
// rollback.
|
|
|
|
|
bool newly_created_ = false;
|
|
|
|
|
};
|
|
|
|
|
|
2018-09-05 20:22:40 +00:00
|
|
|
// Implements MessageHandler.
|
|
|
|
|
void OnMessage(rtc::Message* msg) override;
|
|
|
|
|
|
2018-02-20 11:35:37 -08:00
|
|
|
// Plan B helpers for getting the voice/video media channels for the single
|
|
|
|
|
// audio/video transceiver, if it exists.
|
2019-02-21 23:55:09 +01:00
|
|
|
cricket::VoiceMediaChannel* voice_media_channel() const
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
|
|
|
|
cricket::VideoMediaChannel* video_media_channel() const
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2018-01-10 11:51:34 -08:00
|
|
|
|
2017-11-20 10:20:22 -08:00
|
|
|
std::vector<rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>>>
|
2019-03-26 13:33:43 +01:00
|
|
|
GetSendersInternal() const RTC_RUN_ON(signaling_thread());
|
2017-11-20 10:20:22 -08:00
|
|
|
std::vector<
|
|
|
|
|
rtc::scoped_refptr<RtpReceiverProxyWithInternal<RtpReceiverInternal>>>
|
2019-03-26 13:33:43 +01:00
|
|
|
GetReceiversInternal() const RTC_RUN_ON(signaling_thread());
|
2017-11-20 10:20:22 -08:00
|
|
|
|
|
|
|
|
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>
|
2019-02-21 23:55:09 +01:00
|
|
|
GetAudioTransceiver() const RTC_RUN_ON(signaling_thread());
|
2017-11-20 10:20:22 -08:00
|
|
|
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>
|
2019-02-21 23:55:09 +01:00
|
|
|
GetVideoTransceiver() const RTC_RUN_ON(signaling_thread());
|
2017-11-20 10:20:22 -08:00
|
|
|
|
2018-02-20 11:35:37 -08:00
|
|
|
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>
|
2019-03-26 13:33:43 +01:00
|
|
|
GetFirstAudioTransceiver() const RTC_RUN_ON(signaling_thread());
|
2018-02-20 11:35:37 -08:00
|
|
|
|
2019-10-28 12:09:49 +01:00
|
|
|
// Implementation of the offer/answer exchange operations. These are chained
|
|
|
|
|
// onto the |operations_chain_| when the public CreateOffer(), CreateAnswer(),
|
|
|
|
|
// SetLocalDescription() and SetRemoteDescription() methods are invoked.
|
|
|
|
|
void DoCreateOffer(
|
|
|
|
|
const RTCOfferAnswerOptions& options,
|
|
|
|
|
rtc::scoped_refptr<CreateSessionDescriptionObserver> observer);
|
|
|
|
|
void DoCreateAnswer(
|
|
|
|
|
const RTCOfferAnswerOptions& options,
|
|
|
|
|
rtc::scoped_refptr<CreateSessionDescriptionObserver> observer);
|
|
|
|
|
void DoSetLocalDescription(
|
|
|
|
|
std::unique_ptr<SessionDescriptionInterface> desc,
|
2020-07-29 12:04:00 +02:00
|
|
|
rtc::scoped_refptr<SetLocalDescriptionObserverInterface> observer);
|
2019-10-28 12:09:49 +01:00
|
|
|
void DoSetRemoteDescription(
|
|
|
|
|
std::unique_ptr<SessionDescriptionInterface> desc,
|
|
|
|
|
rtc::scoped_refptr<SetRemoteDescriptionObserverInterface> observer);
|
|
|
|
|
|
2015-10-14 11:33:11 -07:00
|
|
|
void CreateAudioReceiver(MediaStreamInterface* stream,
|
2019-02-14 10:18:56 +01:00
|
|
|
const RtpSenderInfo& remote_sender_info)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2016-03-10 18:32:00 +01:00
|
|
|
|
2015-10-14 11:33:11 -07:00
|
|
|
void CreateVideoReceiver(MediaStreamInterface* stream,
|
2019-02-14 10:18:56 +01:00
|
|
|
const RtpSenderInfo& remote_sender_info)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
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
|
|
|
rtc::scoped_refptr<RtpReceiverInterface> RemoveAndStopReceiver(
|
2019-02-21 23:55:09 +01:00
|
|
|
const RtpSenderInfo& remote_sender_info) RTC_RUN_ON(signaling_thread());
|
2017-07-24 17:00:25 -07:00
|
|
|
|
|
|
|
|
// May be called either by AddStream/RemoveStream, or when a track is
|
|
|
|
|
// added/removed from a stream previously added via AddStream.
|
2019-02-21 23:55:09 +01:00
|
|
|
void AddAudioTrack(AudioTrackInterface* track, MediaStreamInterface* stream)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2017-07-24 17:00:25 -07:00
|
|
|
void RemoveAudioTrack(AudioTrackInterface* track,
|
2019-02-21 23:55:09 +01:00
|
|
|
MediaStreamInterface* stream)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
|
|
|
|
void AddVideoTrack(VideoTrackInterface* track, MediaStreamInterface* stream)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2017-07-24 17:00:25 -07:00
|
|
|
void RemoveVideoTrack(VideoTrackInterface* track,
|
2019-02-21 23:55:09 +01:00
|
|
|
MediaStreamInterface* stream)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2017-12-14 10:23:57 -08:00
|
|
|
// AddTrack implementation when Unified Plan is specified.
|
|
|
|
|
RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>> AddTrackUnifiedPlan(
|
|
|
|
|
rtc::scoped_refptr<MediaStreamTrackInterface> track,
|
2019-03-26 13:33:43 +01:00
|
|
|
const std::vector<std::string>& stream_ids)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2017-12-14 10:23:57 -08:00
|
|
|
// AddTrack implementation when Plan B is specified.
|
|
|
|
|
RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>> AddTrackPlanB(
|
|
|
|
|
rtc::scoped_refptr<MediaStreamTrackInterface> track,
|
2019-02-21 23:55:09 +01:00
|
|
|
const std::vector<std::string>& stream_ids)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2017-12-14 10:23:57 -08:00
|
|
|
|
|
|
|
|
// Returns the first RtpTransceiver suitable for a newly added track, if such
|
|
|
|
|
// transceiver is available.
|
|
|
|
|
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>
|
|
|
|
|
FindFirstTransceiverForAddedTrack(
|
2019-03-26 13:33:43 +01:00
|
|
|
rtc::scoped_refptr<MediaStreamTrackInterface> track)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2017-12-14 10:23:57 -08:00
|
|
|
|
|
|
|
|
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>
|
2019-03-26 13:33:43 +01:00
|
|
|
FindTransceiverBySender(rtc::scoped_refptr<RtpSenderInterface> sender)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2017-12-14 10:23:57 -08:00
|
|
|
|
2018-01-25 13:58:07 -08:00
|
|
|
// Internal implementation for AddTransceiver family of methods. If
|
|
|
|
|
// |fire_callback| is set, fires OnRenegotiationNeeded callback if successful.
|
2017-11-27 13:01:52 -08:00
|
|
|
RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver(
|
|
|
|
|
cricket::MediaType media_type,
|
|
|
|
|
rtc::scoped_refptr<MediaStreamTrackInterface> track,
|
2018-01-25 13:58:07 -08:00
|
|
|
const RtpTransceiverInit& init,
|
2019-02-14 10:18:56 +01:00
|
|
|
bool fire_callback = true) RTC_RUN_ON(signaling_thread());
|
2017-11-27 13:01:52 -08:00
|
|
|
|
2018-01-10 16:26:06 -08:00
|
|
|
rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>>
|
|
|
|
|
CreateSender(cricket::MediaType media_type,
|
2018-06-25 13:03:36 -07:00
|
|
|
const std::string& id,
|
2018-01-10 16:26:06 -08:00
|
|
|
rtc::scoped_refptr<MediaStreamTrackInterface> track,
|
2018-10-01 22:47:20 +02:00
|
|
|
const std::vector<std::string>& stream_ids,
|
|
|
|
|
const std::vector<RtpEncodingParameters>& send_encodings);
|
2018-01-10 16:26:06 -08:00
|
|
|
|
|
|
|
|
rtc::scoped_refptr<RtpReceiverProxyWithInternal<RtpReceiverInternal>>
|
|
|
|
|
CreateReceiver(cricket::MediaType media_type, const std::string& receiver_id);
|
|
|
|
|
|
2017-12-14 10:23:57 -08:00
|
|
|
// Create a new RtpTransceiver of the given type and add it to the list of
|
|
|
|
|
// transceivers.
|
|
|
|
|
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>
|
2018-01-10 16:26:06 -08:00
|
|
|
CreateAndAddTransceiver(
|
|
|
|
|
rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>> sender,
|
|
|
|
|
rtc::scoped_refptr<RtpReceiverProxyWithInternal<RtpReceiverInternal>>
|
2019-03-26 13:33:43 +01:00
|
|
|
receiver) RTC_RUN_ON(signaling_thread());
|
2017-12-14 10:23:57 -08:00
|
|
|
|
2019-02-14 10:18:56 +01:00
|
|
|
void SetIceConnectionState(IceConnectionState new_state)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2018-10-18 15:58:17 +02:00
|
|
|
void SetStandardizedIceConnectionState(
|
2019-02-14 10:18:56 +01:00
|
|
|
PeerConnectionInterface::IceConnectionState new_state)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2018-10-18 15:58:17 +02:00
|
|
|
void SetConnectionState(
|
2019-02-14 10:18:56 +01:00
|
|
|
PeerConnectionInterface::PeerConnectionState new_state)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2018-10-18 15:58:17 +02:00
|
|
|
|
2019-06-01 12:23:43 +03:00
|
|
|
// Called any time the IceGatheringState changes.
|
2019-02-14 10:18:56 +01:00
|
|
|
void OnIceGatheringChange(IceGatheringState new_state)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2017-11-06 10:21:57 -08:00
|
|
|
// New ICE candidate has been gathered.
|
2019-02-14 10:18:56 +01:00
|
|
|
void OnIceCandidate(std::unique_ptr<IceCandidateInterface> candidate)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2019-06-01 12:23:43 +03:00
|
|
|
// Gathering of an ICE candidate failed.
|
2019-12-02 22:22:07 +02:00
|
|
|
void OnIceCandidateError(const std::string& address,
|
|
|
|
|
int port,
|
2019-06-01 12:23:43 +03:00
|
|
|
const std::string& url,
|
|
|
|
|
int error_code,
|
|
|
|
|
const std::string& error_text)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2017-11-06 10:21:57 -08:00
|
|
|
// Some local ICE candidates have been removed.
|
2019-02-14 10:18:56 +01:00
|
|
|
void OnIceCandidatesRemoved(const std::vector<cricket::Candidate>& candidates)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2019-08-06 10:54:47 -07:00
|
|
|
void OnSelectedCandidatePairChanged(
|
|
|
|
|
const cricket::CandidatePairChangeEvent& event)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
|
|
|
|
|
2017-11-06 10:21:57 -08:00
|
|
|
// Update the state, signaling if necessary.
|
2019-02-14 10:18:56 +01:00
|
|
|
void ChangeSignalingState(SignalingState signaling_state)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2015-12-15 19:24:43 -08:00
|
|
|
// Signals from MediaStreamObserver.
|
|
|
|
|
void OnAudioTrackAdded(AudioTrackInterface* track,
|
2019-02-14 10:18:56 +01:00
|
|
|
MediaStreamInterface* stream)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2015-12-15 19:24:43 -08:00
|
|
|
void OnAudioTrackRemoved(AudioTrackInterface* track,
|
2019-02-14 10:18:56 +01:00
|
|
|
MediaStreamInterface* stream)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2015-12-15 19:24:43 -08:00
|
|
|
void OnVideoTrackAdded(VideoTrackInterface* track,
|
2019-02-14 10:18:56 +01:00
|
|
|
MediaStreamInterface* stream)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2015-12-15 19:24:43 -08:00
|
|
|
void OnVideoTrackRemoved(VideoTrackInterface* track,
|
2019-02-14 10:18:56 +01:00
|
|
|
MediaStreamInterface* stream)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2015-12-15 19:24:43 -08:00
|
|
|
|
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
|
|
|
void PostSetSessionDescriptionSuccess(
|
|
|
|
|
SetSessionDescriptionObserver* observer);
|
2013-07-10 00:45:36 +00:00
|
|
|
void PostSetSessionDescriptionFailure(SetSessionDescriptionObserver* observer,
|
2018-09-05 20:22:40 +00:00
|
|
|
RTCError&& error);
|
2015-10-14 11:33:11 -07:00
|
|
|
void PostCreateSessionDescriptionFailure(
|
|
|
|
|
CreateSessionDescriptionObserver* observer,
|
2018-03-09 15:18:03 +01:00
|
|
|
RTCError error);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2017-12-04 15:25:56 -08:00
|
|
|
// Synchronous implementations of SetLocalDescription/SetRemoteDescription
|
|
|
|
|
// that return an RTCError instead of invoking a callback.
|
|
|
|
|
RTCError ApplyLocalDescription(
|
|
|
|
|
std::unique_ptr<SessionDescriptionInterface> desc);
|
|
|
|
|
RTCError ApplyRemoteDescription(
|
|
|
|
|
std::unique_ptr<SessionDescriptionInterface> desc);
|
|
|
|
|
|
2017-12-22 16:02:54 -08:00
|
|
|
// Updates the local RtpTransceivers according to the JSEP rules. Called as
|
|
|
|
|
// part of setting the local/remote description.
|
|
|
|
|
RTCError UpdateTransceiversAndDataChannels(
|
|
|
|
|
cricket::ContentSource source,
|
2018-02-13 15:33:48 -08:00
|
|
|
const SessionDescriptionInterface& new_session,
|
|
|
|
|
const SessionDescriptionInterface* old_local_description,
|
2019-02-14 10:17:47 +01:00
|
|
|
const SessionDescriptionInterface* old_remote_description)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2017-12-22 16:02:54 -08:00
|
|
|
|
|
|
|
|
// Either creates or destroys the transceiver's BaseChannel according to the
|
|
|
|
|
// given media section.
|
|
|
|
|
RTCError UpdateTransceiverChannel(
|
|
|
|
|
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>
|
|
|
|
|
transceiver,
|
|
|
|
|
const cricket::ContentInfo& content,
|
2019-02-21 23:55:09 +01:00
|
|
|
const cricket::ContentGroup* bundle_group) RTC_RUN_ON(signaling_thread());
|
2017-12-22 16:02:54 -08:00
|
|
|
|
2017-12-28 16:38:23 -08:00
|
|
|
// Either creates or destroys the local data channel according to the given
|
|
|
|
|
// media section.
|
|
|
|
|
RTCError UpdateDataChannel(cricket::ContentSource source,
|
|
|
|
|
const cricket::ContentInfo& content,
|
2019-02-14 10:17:47 +01:00
|
|
|
const cricket::ContentGroup* bundle_group)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2017-12-28 16:38:23 -08:00
|
|
|
|
2017-12-22 16:02:54 -08:00
|
|
|
// Associate the given transceiver according to the JSEP rules.
|
|
|
|
|
RTCErrorOr<
|
|
|
|
|
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>>
|
|
|
|
|
AssociateTransceiver(cricket::ContentSource source,
|
2018-02-13 15:33:48 -08:00
|
|
|
SdpType type,
|
2017-12-22 16:02:54 -08:00
|
|
|
size_t mline_index,
|
|
|
|
|
const cricket::ContentInfo& content,
|
2018-02-13 15:33:48 -08:00
|
|
|
const cricket::ContentInfo* old_local_content,
|
2019-02-21 23:55:09 +01:00
|
|
|
const cricket::ContentInfo* old_remote_content)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2017-12-22 16:02:54 -08:00
|
|
|
|
|
|
|
|
// Returns the RtpTransceiver, if found, that is associated to the given MID.
|
|
|
|
|
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>
|
2019-02-21 23:55:09 +01:00
|
|
|
GetAssociatedTransceiver(const std::string& mid) const
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2017-12-22 16:02:54 -08:00
|
|
|
|
|
|
|
|
// Returns the RtpTransceiver, if found, that was assigned to the given mline
|
|
|
|
|
// index in CreateOffer.
|
|
|
|
|
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>
|
2019-02-21 23:55:09 +01:00
|
|
|
GetTransceiverByMLineIndex(size_t mline_index) const
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2017-12-22 16:02:54 -08:00
|
|
|
|
|
|
|
|
// Returns an RtpTransciever, if available, that can be used to receive the
|
|
|
|
|
// given media type according to JSEP rules.
|
|
|
|
|
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>
|
2019-02-21 23:55:09 +01:00
|
|
|
FindAvailableTransceiverToReceive(cricket::MediaType media_type) const
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2017-12-22 16:02:54 -08:00
|
|
|
|
2017-12-05 10:52:59 -08:00
|
|
|
// Returns the media section in the given session description that is
|
|
|
|
|
// associated with the RtpTransceiver. Returns null if none found or this
|
|
|
|
|
// RtpTransceiver is not associated. Logic varies depending on the
|
|
|
|
|
// SdpSemantics specified in the configuration.
|
|
|
|
|
const cricket::ContentInfo* FindMediaSectionForTransceiver(
|
|
|
|
|
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>
|
|
|
|
|
transceiver,
|
2019-02-21 23:55:09 +01:00
|
|
|
const SessionDescriptionInterface* sdesc) const
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2017-12-05 10:52:59 -08:00
|
|
|
|
2018-12-20 11:06:02 +01:00
|
|
|
// Runs the algorithm **set the associated remote streams** specified in
|
|
|
|
|
// https://w3c.github.io/webrtc-pc/#set-associated-remote-streams.
|
|
|
|
|
void SetAssociatedRemoteStreams(
|
|
|
|
|
rtc::scoped_refptr<RtpReceiverInternal> receiver,
|
|
|
|
|
const std::vector<std::string>& stream_ids,
|
|
|
|
|
std::vector<rtc::scoped_refptr<MediaStreamInterface>>* added_streams,
|
2019-03-22 14:27:22 +01:00
|
|
|
std::vector<rtc::scoped_refptr<MediaStreamInterface>>* removed_streams)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2018-12-20 11:06:02 +01:00
|
|
|
|
2018-07-17 14:25:36 -07:00
|
|
|
// Runs the algorithm **process the removal of a remote track** specified in
|
|
|
|
|
// the WebRTC specification.
|
|
|
|
|
// This method will update the following lists:
|
|
|
|
|
// |remove_list| is the list of transceivers for which the receiving track is
|
|
|
|
|
// being removed.
|
|
|
|
|
// |removed_streams| is the list of streams which no longer have a receiving
|
|
|
|
|
// track so should be removed.
|
|
|
|
|
// https://w3c.github.io/webrtc-pc/#process-remote-track-removal
|
|
|
|
|
void ProcessRemovalOfRemoteTrack(
|
|
|
|
|
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>
|
|
|
|
|
transceiver,
|
|
|
|
|
std::vector<rtc::scoped_refptr<RtpTransceiverInterface>>* remove_list,
|
2019-03-22 14:27:22 +01:00
|
|
|
std::vector<rtc::scoped_refptr<MediaStreamInterface>>* removed_streams)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2018-07-17 14:25:36 -07:00
|
|
|
|
2018-12-20 11:06:02 +01:00
|
|
|
void RemoveRemoteStreamsIfEmpty(
|
|
|
|
|
const std::vector<rtc::scoped_refptr<MediaStreamInterface>>&
|
|
|
|
|
remote_streams,
|
2019-03-22 14:27:22 +01:00
|
|
|
std::vector<rtc::scoped_refptr<MediaStreamInterface>>* removed_streams)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2018-12-20 11:06:02 +01:00
|
|
|
|
2018-02-20 15:48:12 -08:00
|
|
|
void OnNegotiationNeeded();
|
|
|
|
|
|
2015-10-14 11:33:11 -07:00
|
|
|
// Returns a MediaSessionOptions struct with options decided by |options|,
|
|
|
|
|
// the local MediaStreams and DataChannels.
|
2017-12-22 16:02:54 -08:00
|
|
|
void GetOptionsForOffer(const PeerConnectionInterface::RTCOfferAnswerOptions&
|
|
|
|
|
offer_answer_options,
|
2019-02-21 23:55:09 +01:00
|
|
|
cricket::MediaSessionOptions* session_options)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2017-12-22 16:02:54 -08:00
|
|
|
void GetOptionsForPlanBOffer(
|
|
|
|
|
const PeerConnectionInterface::RTCOfferAnswerOptions&
|
|
|
|
|
offer_answer_options,
|
2019-02-21 23:55:09 +01:00
|
|
|
cricket::MediaSessionOptions* session_options)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2017-12-22 16:02:54 -08:00
|
|
|
void GetOptionsForUnifiedPlanOffer(
|
|
|
|
|
const PeerConnectionInterface::RTCOfferAnswerOptions&
|
|
|
|
|
offer_answer_options,
|
2019-02-21 23:55:09 +01:00
|
|
|
cricket::MediaSessionOptions* session_options)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2015-10-14 11:33:11 -07:00
|
|
|
|
2019-02-21 23:55:09 +01:00
|
|
|
RTCError HandleLegacyOfferOptions(const RTCOfferAnswerOptions& options)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2018-01-25 13:58:07 -08:00
|
|
|
void RemoveRecvDirectionFromReceivingTransceiversOfType(
|
2019-03-26 13:33:43 +01:00
|
|
|
cricket::MediaType media_type) RTC_RUN_ON(signaling_thread());
|
2018-01-25 13:58:07 -08:00
|
|
|
void AddUpToOneReceivingTransceiverOfType(cricket::MediaType media_type);
|
|
|
|
|
std::vector<
|
|
|
|
|
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>>
|
2019-03-26 13:33:43 +01:00
|
|
|
GetReceivingTransceiversOfType(cricket::MediaType media_type)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2018-01-25 13:58:07 -08:00
|
|
|
|
2015-10-14 11:33:11 -07:00
|
|
|
// Returns a MediaSessionOptions struct with options decided by
|
|
|
|
|
// |constraints|, the local MediaStreams and DataChannels.
|
2017-12-22 16:02:54 -08:00
|
|
|
void GetOptionsForAnswer(const RTCOfferAnswerOptions& offer_answer_options,
|
2019-02-21 23:55:09 +01:00
|
|
|
cricket::MediaSessionOptions* session_options)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2017-12-22 16:02:54 -08:00
|
|
|
void GetOptionsForPlanBAnswer(
|
|
|
|
|
const PeerConnectionInterface::RTCOfferAnswerOptions&
|
|
|
|
|
offer_answer_options,
|
2019-02-21 23:55:09 +01:00
|
|
|
cricket::MediaSessionOptions* session_options)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2017-12-22 16:02:54 -08:00
|
|
|
void GetOptionsForUnifiedPlanAnswer(
|
|
|
|
|
const PeerConnectionInterface::RTCOfferAnswerOptions&
|
|
|
|
|
offer_answer_options,
|
2019-02-21 23:55:09 +01:00
|
|
|
cricket::MediaSessionOptions* session_options)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2017-08-17 14:10:50 -07:00
|
|
|
|
|
|
|
|
// Generates MediaDescriptionOptions for the |session_opts| based on existing
|
|
|
|
|
// local description or remote description.
|
|
|
|
|
void GenerateMediaDescriptionOptions(
|
|
|
|
|
const SessionDescriptionInterface* session_desc,
|
2017-11-27 14:30:09 -08:00
|
|
|
RtpTransceiverDirection audio_direction,
|
|
|
|
|
RtpTransceiverDirection video_direction,
|
2018-06-19 16:47:43 +02:00
|
|
|
absl::optional<size_t>* audio_index,
|
|
|
|
|
absl::optional<size_t>* video_index,
|
|
|
|
|
absl::optional<size_t>* data_index,
|
2019-03-22 15:29:58 +01:00
|
|
|
cricket::MediaSessionOptions* session_options)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2015-10-14 11:33:11 -07:00
|
|
|
|
2017-12-28 16:38:23 -08:00
|
|
|
// Generates the active MediaDescriptionOptions for the local data channel
|
|
|
|
|
// given the specified MID.
|
|
|
|
|
cricket::MediaDescriptionOptions GetMediaDescriptionOptionsForActiveData(
|
2019-03-22 15:29:58 +01:00
|
|
|
const std::string& mid) const RTC_RUN_ON(signaling_thread());
|
2017-12-28 16:38:23 -08:00
|
|
|
|
|
|
|
|
// Generates the rejected MediaDescriptionOptions for the local data channel
|
|
|
|
|
// given the specified MID.
|
|
|
|
|
cricket::MediaDescriptionOptions GetMediaDescriptionOptionsForRejectedData(
|
2019-03-22 15:29:58 +01:00
|
|
|
const std::string& mid) const RTC_RUN_ON(signaling_thread());
|
2017-12-28 16:38:23 -08:00
|
|
|
|
|
|
|
|
// Returns the MID for the data section associated with either the
|
|
|
|
|
// RtpDataChannel or SCTP data channel, if it has been set. If no data
|
|
|
|
|
// channels are configured this will return nullopt.
|
2019-04-02 11:31:56 +02:00
|
|
|
absl::optional<std::string> GetDataMid() const RTC_RUN_ON(signaling_thread());
|
2017-12-28 16:38:23 -08:00
|
|
|
|
2017-11-20 10:20:22 -08:00
|
|
|
// Remove all local and remote senders of type |media_type|.
|
2015-11-12 15:33:07 -08:00
|
|
|
// Called when a media type is rejected (m-line set to port 0).
|
2019-02-14 10:18:56 +01:00
|
|
|
void RemoveSenders(cricket::MediaType media_type)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2015-11-12 15:33:07 -08:00
|
|
|
|
2015-12-08 17:13:40 -08:00
|
|
|
// Makes sure a MediaStreamTrack is created for each StreamParam in |streams|,
|
|
|
|
|
// and existing MediaStreamTracks are removed if there is no corresponding
|
|
|
|
|
// StreamParam. If |default_track_needed| is true, a default MediaStreamTrack
|
|
|
|
|
// is created if it doesn't exist; if false, it's removed if it exists.
|
|
|
|
|
// |media_type| is the type of the |streams| and can be either audio or video.
|
2015-10-14 11:33:11 -07:00
|
|
|
// If a new MediaStream is created it is added to |new_streams|.
|
2017-11-20 10:20:22 -08:00
|
|
|
void UpdateRemoteSendersList(
|
2015-10-14 11:33:11 -07:00
|
|
|
const std::vector<cricket::StreamParams>& streams,
|
2015-12-08 17:13:40 -08:00
|
|
|
bool default_track_needed,
|
2015-10-14 11:33:11 -07:00
|
|
|
cricket::MediaType media_type,
|
2019-02-14 10:18:56 +01:00
|
|
|
StreamCollection* new_streams) RTC_RUN_ON(signaling_thread());
|
2015-10-14 11:33:11 -07:00
|
|
|
|
2017-11-20 10:20:22 -08:00
|
|
|
// Triggered when a remote sender has been seen for the first time in a remote
|
2015-10-14 11:33:11 -07:00
|
|
|
// session description. It creates a remote MediaStreamTrackInterface
|
|
|
|
|
// implementation and triggers CreateAudioReceiver or CreateVideoReceiver.
|
2017-11-20 10:20:22 -08:00
|
|
|
void OnRemoteSenderAdded(const RtpSenderInfo& sender_info,
|
2019-02-14 10:18:56 +01:00
|
|
|
cricket::MediaType media_type)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2015-10-14 11:33:11 -07:00
|
|
|
|
2017-11-20 10:20:22 -08:00
|
|
|
// Triggered when a remote sender has been removed from a remote session
|
|
|
|
|
// description. It removes the remote sender with id |sender_id| from a remote
|
2015-10-14 11:33:11 -07:00
|
|
|
// MediaStream and triggers DestroyAudioReceiver or DestroyVideoReceiver.
|
2017-11-20 10:20:22 -08:00
|
|
|
void OnRemoteSenderRemoved(const RtpSenderInfo& sender_info,
|
2019-02-14 10:18:56 +01:00
|
|
|
cricket::MediaType media_type)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2015-10-14 11:33:11 -07:00
|
|
|
|
|
|
|
|
// Finds remote MediaStreams without any tracks and removes them from
|
|
|
|
|
// |remote_streams_| and notifies the observer that the MediaStreams no longer
|
|
|
|
|
// exist.
|
2019-02-14 10:18:56 +01:00
|
|
|
void UpdateEndedRemoteMediaStreams() RTC_RUN_ON(signaling_thread());
|
2015-10-14 11:33:11 -07:00
|
|
|
|
|
|
|
|
// Loops through the vector of |streams| and finds added and removed
|
|
|
|
|
// StreamParams since last time this method was called.
|
2017-11-20 10:20:22 -08:00
|
|
|
// For each new or removed StreamParam, OnLocalSenderSeen or
|
|
|
|
|
// OnLocalSenderRemoved is invoked.
|
|
|
|
|
void UpdateLocalSenders(const std::vector<cricket::StreamParams>& streams,
|
2019-02-21 23:55:09 +01:00
|
|
|
cricket::MediaType media_type)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2015-10-14 11:33:11 -07:00
|
|
|
|
2017-11-20 10:20:22 -08:00
|
|
|
// Triggered when a local sender has been seen for the first time in a local
|
2015-10-14 11:33:11 -07:00
|
|
|
// session description.
|
|
|
|
|
// This method triggers CreateAudioSender or CreateVideoSender if the rtp
|
|
|
|
|
// streams in the local SessionDescription can be mapped to a MediaStreamTrack
|
|
|
|
|
// in a MediaStream in |local_streams_|
|
2017-11-20 10:20:22 -08:00
|
|
|
void OnLocalSenderAdded(const RtpSenderInfo& sender_info,
|
2019-02-21 23:55:09 +01:00
|
|
|
cricket::MediaType media_type)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2015-10-14 11:33:11 -07:00
|
|
|
|
2017-11-20 10:20:22 -08:00
|
|
|
// Triggered when a local sender has been removed from a local session
|
2015-10-14 11:33:11 -07:00
|
|
|
// description.
|
|
|
|
|
// This method triggers DestroyAudioSender or DestroyVideoSender if a stream
|
|
|
|
|
// has been removed from the local SessionDescription and the stream can be
|
|
|
|
|
// mapped to a MediaStreamTrack in a MediaStream in |local_streams_|.
|
2017-11-20 10:20:22 -08:00
|
|
|
void OnLocalSenderRemoved(const RtpSenderInfo& sender_info,
|
2019-03-26 13:33:43 +01:00
|
|
|
cricket::MediaType media_type)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2015-10-14 11:33:11 -07:00
|
|
|
|
2017-11-20 10:20:22 -08:00
|
|
|
// Returns true if the PeerConnection is configured to use Unified Plan
|
|
|
|
|
// semantics for creating offers/answers and setting local/remote
|
|
|
|
|
// descriptions. If this is true the RtpTransceiver API will also be available
|
|
|
|
|
// to the user. If this is false, Plan B semantics are assumed.
|
2017-11-20 10:25:56 -08:00
|
|
|
// TODO(bugs.webrtc.org/8530): Flip the default to be Unified Plan once
|
|
|
|
|
// sufficient time has passed.
|
2019-02-21 23:55:09 +01:00
|
|
|
bool IsUnifiedPlan() const RTC_RUN_ON(signaling_thread()) {
|
2017-11-20 10:25:56 -08:00
|
|
|
return configuration_.sdp_semantics == SdpSemantics::kUnifiedPlan;
|
|
|
|
|
}
|
2017-11-20 10:20:22 -08:00
|
|
|
|
2018-12-18 15:55:30 -08:00
|
|
|
// The offer/answer machinery assumes the media section MID is present and
|
|
|
|
|
// unique. To support legacy end points that do not supply a=mid lines, this
|
|
|
|
|
// method will modify the session description to add MIDs generated according
|
|
|
|
|
// to the SDP semantics.
|
2019-02-21 23:55:09 +01:00
|
|
|
void FillInMissingRemoteMids(cricket::SessionDescription* remote_description)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2018-12-18 15:55:30 -08:00
|
|
|
|
2017-11-20 10:20:22 -08:00
|
|
|
// Return the RtpSender with the given track attached.
|
|
|
|
|
rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>>
|
2019-03-26 13:33:43 +01:00
|
|
|
FindSenderForTrack(MediaStreamTrackInterface* track) const
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2017-11-20 10:20:22 -08:00
|
|
|
|
|
|
|
|
// Return the RtpSender with the given id, or null if none exists.
|
|
|
|
|
rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>>
|
2019-03-26 13:33:43 +01:00
|
|
|
FindSenderById(const std::string& sender_id) const
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2015-09-28 16:53:55 -07:00
|
|
|
|
2017-11-20 10:20:22 -08:00
|
|
|
// Return the RtpReceiver with the given id, or null if none exists.
|
|
|
|
|
rtc::scoped_refptr<RtpReceiverProxyWithInternal<RtpReceiverInternal>>
|
2019-03-26 13:33:43 +01:00
|
|
|
FindReceiverById(const std::string& receiver_id) const
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2017-11-20 10:20:22 -08:00
|
|
|
|
|
|
|
|
std::vector<RtpSenderInfo>* GetRemoteSenderInfos(
|
|
|
|
|
cricket::MediaType media_type);
|
|
|
|
|
std::vector<RtpSenderInfo>* GetLocalSenderInfos(
|
|
|
|
|
cricket::MediaType media_type);
|
|
|
|
|
const RtpSenderInfo* FindSenderInfo(const std::vector<RtpSenderInfo>& infos,
|
2018-03-27 21:57:18 +00:00
|
|
|
const std::string& stream_id,
|
2017-11-20 10:20:22 -08:00
|
|
|
const std::string sender_id) const;
|
2015-10-14 11:33:11 -07:00
|
|
|
|
|
|
|
|
// Returns the specified SCTP DataChannel in sctp_data_channels_,
|
|
|
|
|
// or nullptr if not found.
|
2020-07-09 15:32:34 -07:00
|
|
|
SctpDataChannel* FindDataChannelBySid(int sid) const
|
2019-03-22 15:29:58 +01:00
|
|
|
RTC_RUN_ON(signaling_thread());
|
2015-10-14 11:33:11 -07:00
|
|
|
|
2016-05-13 08:15:11 -07:00
|
|
|
// Called when first configuring the port allocator.
|
2019-03-22 14:13:22 +01:00
|
|
|
struct InitializePortAllocatorResult {
|
|
|
|
|
bool enable_ipv6;
|
|
|
|
|
};
|
|
|
|
|
InitializePortAllocatorResult InitializePortAllocator_n(
|
2018-06-28 13:54:07 +02:00
|
|
|
const cricket::ServerAddresses& stun_servers,
|
|
|
|
|
const std::vector<cricket::RelayServerConfig>& turn_servers,
|
|
|
|
|
const RTCConfiguration& configuration);
|
2017-01-11 12:28:30 -08:00
|
|
|
// Called when SetConfiguration is called to apply the supported subset
|
|
|
|
|
// of the configuration on the network thread.
|
|
|
|
|
bool ReconfigurePortAllocator_n(
|
|
|
|
|
const cricket::ServerAddresses& stun_servers,
|
|
|
|
|
const std::vector<cricket::RelayServerConfig>& turn_servers,
|
|
|
|
|
IceTransportsType type,
|
|
|
|
|
int candidate_pool_size,
|
2019-10-14 11:27:50 -07:00
|
|
|
PortPrunePolicy turn_port_prune_policy,
|
2018-02-20 14:45:49 -08:00
|
|
|
webrtc::TurnCustomizer* turn_customizer,
|
2019-04-03 11:37:28 +02:00
|
|
|
absl::optional<int> stun_candidate_keepalive_interval,
|
|
|
|
|
bool have_local_description);
|
2016-05-13 08:15:11 -07:00
|
|
|
|
2017-10-13 16:29:40 +02:00
|
|
|
// Starts output of an RTC event log to the given output object.
|
2016-07-04 07:06:55 -07:00
|
|
|
// This function should only be called from the worker thread.
|
2017-11-20 17:38:14 +01:00
|
|
|
bool StartRtcEventLog_w(std::unique_ptr<RtcEventLogOutput> output,
|
|
|
|
|
int64_t output_period_ms);
|
2017-10-13 16:29:40 +02:00
|
|
|
|
2017-10-06 14:32:13 +02:00
|
|
|
// Stops recording an RTC event log.
|
2016-07-04 07:06:55 -07:00
|
|
|
// This function should only be called from the worker thread.
|
|
|
|
|
void StopRtcEventLog_w();
|
|
|
|
|
|
2017-07-14 15:59:59 -07:00
|
|
|
// Ensures the configuration doesn't have any parameters with invalid values,
|
|
|
|
|
// or values that conflict with other parameters.
|
|
|
|
|
//
|
|
|
|
|
// Returns RTCError::OK() if there are no issues.
|
|
|
|
|
RTCError ValidateConfiguration(const RTCConfiguration& config) const;
|
|
|
|
|
|
2017-11-06 10:21:57 -08:00
|
|
|
cricket::ChannelManager* channel_manager() const;
|
|
|
|
|
|
2017-12-04 10:46:21 -08:00
|
|
|
enum class SessionError {
|
|
|
|
|
kNone, // No error.
|
|
|
|
|
kContent, // Error in BaseChannel SetLocalContent/SetRemoteContent.
|
|
|
|
|
kTransport, // Error from the underlying transport.
|
|
|
|
|
};
|
|
|
|
|
|
2017-11-06 10:37:17 -08:00
|
|
|
// Returns the last error in the session. See the enum above for details.
|
2019-03-26 13:33:43 +01:00
|
|
|
SessionError session_error() const RTC_RUN_ON(signaling_thread()) {
|
|
|
|
|
return session_error_;
|
|
|
|
|
}
|
2017-12-04 10:46:21 -08:00
|
|
|
const std::string& session_error_desc() const { return session_error_desc_; }
|
2017-11-06 10:37:17 -08:00
|
|
|
|
2018-11-13 16:26:05 -08:00
|
|
|
cricket::ChannelInterface* GetChannel(const std::string& content_name);
|
2017-11-06 10:37:17 -08:00
|
|
|
|
|
|
|
|
cricket::IceConfig ParseIceConfig(
|
|
|
|
|
const PeerConnectionInterface::RTCConfiguration& config) const;
|
|
|
|
|
|
|
|
|
|
cricket::DataChannelType data_channel_type() const;
|
|
|
|
|
|
|
|
|
|
// Called when an RTCCertificate is generated or retrieved by
|
|
|
|
|
// WebRTCSessionDescriptionFactory. Should happen before setLocalDescription.
|
|
|
|
|
void OnCertificateReady(
|
|
|
|
|
const rtc::scoped_refptr<rtc::RTCCertificate>& certificate);
|
|
|
|
|
void OnDtlsSrtpSetupFailure(cricket::BaseChannel*, bool rtcp);
|
|
|
|
|
|
|
|
|
|
// Non-const versions of local_description()/remote_description(), for use
|
|
|
|
|
// internally.
|
2019-04-03 11:37:28 +02:00
|
|
|
SessionDescriptionInterface* mutable_local_description()
|
|
|
|
|
RTC_RUN_ON(signaling_thread()) {
|
2017-11-06 10:37:17 -08:00
|
|
|
return pending_local_description_ ? pending_local_description_.get()
|
|
|
|
|
: current_local_description_.get();
|
|
|
|
|
}
|
2019-04-03 11:37:28 +02:00
|
|
|
SessionDescriptionInterface* mutable_remote_description()
|
|
|
|
|
RTC_RUN_ON(signaling_thread()) {
|
2017-11-06 10:37:17 -08:00
|
|
|
return pending_remote_description_ ? pending_remote_description_.get()
|
|
|
|
|
: current_remote_description_.get();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Updates the error state, signaling if necessary.
|
2017-12-04 10:46:21 -08:00
|
|
|
void SetSessionError(SessionError error, const std::string& error_desc);
|
2017-11-06 10:37:17 -08:00
|
|
|
|
2018-03-30 10:48:35 -07:00
|
|
|
RTCError UpdateSessionState(SdpType type,
|
|
|
|
|
cricket::ContentSource source,
|
|
|
|
|
const cricket::SessionDescription* description);
|
2017-11-06 10:37:17 -08:00
|
|
|
// Push the media parts of the local or remote session description
|
|
|
|
|
// down to all of the channels.
|
2019-02-21 23:55:09 +01:00
|
|
|
RTCError PushdownMediaDescription(SdpType type, cricket::ContentSource source)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2017-11-06 10:37:17 -08:00
|
|
|
|
2017-12-04 15:25:56 -08:00
|
|
|
RTCError PushdownTransportDescription(cricket::ContentSource source,
|
2017-12-06 10:34:51 -08:00
|
|
|
SdpType type);
|
2017-11-06 10:37:17 -08:00
|
|
|
|
|
|
|
|
// Returns true and the TransportInfo of the given |content_name|
|
|
|
|
|
// from |description|. Returns false if it's not available.
|
|
|
|
|
static bool GetTransportDescription(
|
|
|
|
|
const cricket::SessionDescription* description,
|
|
|
|
|
const std::string& content_name,
|
|
|
|
|
cricket::TransportDescription* info);
|
|
|
|
|
|
|
|
|
|
// Enables media channels to allow sending of media.
|
2017-12-05 10:52:59 -08:00
|
|
|
// This enables media to flow on all configured audio/video channels and the
|
|
|
|
|
// RtpDataChannel.
|
2019-03-26 13:33:43 +01:00
|
|
|
void EnableSending() RTC_RUN_ON(signaling_thread());
|
2017-12-12 10:20:08 -08:00
|
|
|
|
2017-12-15 11:20:13 -08:00
|
|
|
// Destroys all BaseChannels and destroys the SCTP data channel, if present.
|
2019-03-22 15:29:58 +01:00
|
|
|
void DestroyAllChannels() RTC_RUN_ON(signaling_thread());
|
2017-12-12 10:20:08 -08:00
|
|
|
|
2017-11-06 10:37:17 -08:00
|
|
|
// Returns the media index for a local ice candidate given the content name.
|
|
|
|
|
// Returns false if the local session description does not have a media
|
|
|
|
|
// content called |content_name|.
|
|
|
|
|
bool GetLocalCandidateMediaIndex(const std::string& content_name,
|
2019-04-03 11:37:28 +02:00
|
|
|
int* sdp_mline_index)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2017-11-06 10:37:17 -08:00
|
|
|
// Uses all remote candidates in |remote_desc| in this session.
|
|
|
|
|
bool UseCandidatesInSessionDescription(
|
2019-02-14 10:18:56 +01:00
|
|
|
const SessionDescriptionInterface* remote_desc)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2017-11-06 10:37:17 -08:00
|
|
|
// Uses |candidate| in this session.
|
2019-02-14 10:18:56 +01:00
|
|
|
bool UseCandidate(const IceCandidateInterface* candidate)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2019-05-23 20:12:29 +02:00
|
|
|
RTCErrorOr<const cricket::ContentInfo*> FindContentInfo(
|
|
|
|
|
const SessionDescriptionInterface* description,
|
|
|
|
|
const IceCandidateInterface* candidate) RTC_RUN_ON(signaling_thread());
|
2017-11-06 10:37:17 -08:00
|
|
|
// Deletes the corresponding channel of contents that don't exist in |desc|.
|
|
|
|
|
// |desc| can be null. This means that all channels are deleted.
|
2019-02-21 23:55:09 +01:00
|
|
|
void RemoveUnusedChannels(const cricket::SessionDescription* desc)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2017-11-06 10:37:17 -08:00
|
|
|
|
|
|
|
|
// Allocates media channels based on the |desc|. If |desc| doesn't have
|
|
|
|
|
// the BUNDLE option, this method will disable BUNDLE in PortAllocator.
|
|
|
|
|
// This method will also delete any existing media channels before creating.
|
2019-02-21 23:55:09 +01:00
|
|
|
RTCError CreateChannels(const cricket::SessionDescription& desc)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2017-12-22 16:02:54 -08:00
|
|
|
|
|
|
|
|
// If the BUNDLE policy is max-bundle, then we know for sure that all
|
|
|
|
|
// transports will be bundled from the start. This method returns the BUNDLE
|
|
|
|
|
// group if that's the case, or null if BUNDLE will be negotiated later. An
|
|
|
|
|
// error is returned if max-bundle is specified but the session description
|
|
|
|
|
// does not have a BUNDLE group.
|
|
|
|
|
RTCErrorOr<const cricket::ContentGroup*> GetEarlyBundleGroup(
|
2019-02-21 23:55:09 +01:00
|
|
|
const cricket::SessionDescription& desc) const
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2017-11-06 10:37:17 -08:00
|
|
|
|
|
|
|
|
// Helper methods to create media channels.
|
2019-02-21 23:55:09 +01:00
|
|
|
cricket::VoiceChannel* CreateVoiceChannel(const std::string& mid)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
|
|
|
|
cricket::VideoChannel* CreateVideoChannel(const std::string& mid)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
|
|
|
|
bool CreateDataChannel(const std::string& mid) RTC_RUN_ON(signaling_thread());
|
2017-11-06 10:37:17 -08:00
|
|
|
|
Changes to enable use of DatagramTransport as a data channel transport.
PeerConnection now has a new setting in RTCConfiguration to enable use of
datagram transport for data channels. There is also a corresponding field
trial, which has both a kill-switch and a way to change the default value.
PeerConnection's interaction with MediaTransport for data channels has been
refactored to work with DataChannelTransportInterface instead.
Adds a DataChannelState and OnStateChanged() to the DataChannelSink
callbacks. This allows PeerConnection to listen to the data channel's
state directly, instead of indirectly by monitoring media transport
state. This is necessary to enable use of non-media-transport (eg.
datagram transport) data channel transports.
For now, PeerConnection watches the state through MediaTransport as well.
This will persist until MediaTransport implements the new callback.
Datagram transport use is negotiated. As such, an offer that requests to use
datagram transport for data channels may be rejected by the answerer. If the
offer includes DTLS, the data channels will be negotiated as SCTP/DTLS data
channels with an extra x-opaque parameter for datagram transport. If the
opaque parameter is rejected (by an answerer without datagram support), the
offerer may fall back to SCTP.
If DTLS is not enabled, there is no viable fallback. In this case, the data
channels are negotiated as media transport data channels. If the receiver does
not understand the x-opaque line, it will reject these data channels, and the
offerer's data channels will be closed.
Bug: webrtc:9719
Change-Id: Ic1bf3664c4bcf9d754482df59897f5f72fe68fcc
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/147702
Commit-Queue: Bjorn Mellem <mellem@webrtc.org>
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28932}
2019-08-21 10:44:59 -07:00
|
|
|
bool SetupDataChannelTransport_n(const std::string& mid)
|
2018-11-08 11:23:22 -08:00
|
|
|
RTC_RUN_ON(network_thread());
|
Changes to enable use of DatagramTransport as a data channel transport.
PeerConnection now has a new setting in RTCConfiguration to enable use of
datagram transport for data channels. There is also a corresponding field
trial, which has both a kill-switch and a way to change the default value.
PeerConnection's interaction with MediaTransport for data channels has been
refactored to work with DataChannelTransportInterface instead.
Adds a DataChannelState and OnStateChanged() to the DataChannelSink
callbacks. This allows PeerConnection to listen to the data channel's
state directly, instead of indirectly by monitoring media transport
state. This is necessary to enable use of non-media-transport (eg.
datagram transport) data channel transports.
For now, PeerConnection watches the state through MediaTransport as well.
This will persist until MediaTransport implements the new callback.
Datagram transport use is negotiated. As such, an offer that requests to use
datagram transport for data channels may be rejected by the answerer. If the
offer includes DTLS, the data channels will be negotiated as SCTP/DTLS data
channels with an extra x-opaque parameter for datagram transport. If the
opaque parameter is rejected (by an answerer without datagram support), the
offerer may fall back to SCTP.
If DTLS is not enabled, there is no viable fallback. In this case, the data
channels are negotiated as media transport data channels. If the receiver does
not understand the x-opaque line, it will reject these data channels, and the
offerer's data channels will be closed.
Bug: webrtc:9719
Change-Id: Ic1bf3664c4bcf9d754482df59897f5f72fe68fcc
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/147702
Commit-Queue: Bjorn Mellem <mellem@webrtc.org>
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28932}
2019-08-21 10:44:59 -07:00
|
|
|
void TeardownDataChannelTransport_n() RTC_RUN_ON(network_thread());
|
2018-11-08 11:23:22 -08:00
|
|
|
|
2017-11-06 10:37:17 -08:00
|
|
|
bool ValidateBundleSettings(const cricket::SessionDescription* desc);
|
|
|
|
|
bool HasRtcpMuxEnabled(const cricket::ContentInfo* content);
|
|
|
|
|
// Below methods are helper methods which verifies SDP.
|
2017-12-04 15:25:56 -08:00
|
|
|
RTCError ValidateSessionDescription(const SessionDescriptionInterface* sdesc,
|
2019-02-21 23:55:09 +01:00
|
|
|
cricket::ContentSource source)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2017-11-06 10:37:17 -08:00
|
|
|
|
2017-12-06 10:34:51 -08:00
|
|
|
// Check if a call to SetLocalDescription is acceptable with a session
|
|
|
|
|
// description of the given type.
|
|
|
|
|
bool ExpectSetLocalDescription(SdpType type);
|
|
|
|
|
// Check if a call to SetRemoteDescription is acceptable with a session
|
|
|
|
|
// description of the given type.
|
|
|
|
|
bool ExpectSetRemoteDescription(SdpType type);
|
2017-11-06 10:37:17 -08:00
|
|
|
// Verifies a=setup attribute as per RFC 5763.
|
|
|
|
|
bool ValidateDtlsSetupAttribute(const cricket::SessionDescription* desc,
|
2017-12-06 10:34:51 -08:00
|
|
|
SdpType type);
|
2017-11-06 10:37:17 -08:00
|
|
|
|
|
|
|
|
// Returns true if we are ready to push down the remote candidate.
|
|
|
|
|
// |remote_desc| is the new remote description, or NULL if the current remote
|
|
|
|
|
// description should be used. Output |valid| is true if the candidate media
|
|
|
|
|
// index is valid.
|
|
|
|
|
bool ReadyToUseRemoteCandidate(const IceCandidateInterface* candidate,
|
|
|
|
|
const SessionDescriptionInterface* remote_desc,
|
2019-03-26 13:33:43 +01:00
|
|
|
bool* valid) RTC_RUN_ON(signaling_thread());
|
2017-11-06 10:37:17 -08:00
|
|
|
|
|
|
|
|
// Returns true if SRTP (either using DTLS-SRTP or SDES) is required by
|
|
|
|
|
// this session.
|
2019-04-03 11:37:28 +02:00
|
|
|
bool SrtpRequired() const RTC_RUN_ON(signaling_thread());
|
2017-11-06 10:37:17 -08:00
|
|
|
|
2018-03-30 10:48:35 -07:00
|
|
|
// JsepTransportController signal handlers.
|
2019-02-14 10:18:56 +01:00
|
|
|
void OnTransportControllerConnectionState(cricket::IceConnectionState state)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
|
|
|
|
void OnTransportControllerGatheringState(cricket::IceGatheringState state)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2017-11-06 10:37:17 -08:00
|
|
|
void OnTransportControllerCandidatesGathered(
|
|
|
|
|
const std::string& transport_name,
|
2019-02-14 10:18:56 +01:00
|
|
|
const std::vector<cricket::Candidate>& candidates)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2019-06-01 12:23:43 +03:00
|
|
|
void OnTransportControllerCandidateError(
|
|
|
|
|
const cricket::IceCandidateErrorEvent& event)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2017-11-06 10:37:17 -08:00
|
|
|
void OnTransportControllerCandidatesRemoved(
|
2019-02-14 10:18:56 +01:00
|
|
|
const std::vector<cricket::Candidate>& candidates)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2019-08-06 10:54:47 -07:00
|
|
|
void OnTransportControllerCandidateChanged(
|
|
|
|
|
const cricket::CandidatePairChangeEvent& event)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2017-11-06 10:37:17 -08:00
|
|
|
void OnTransportControllerDtlsHandshakeError(rtc::SSLHandshakeError error);
|
|
|
|
|
|
2017-12-04 10:46:21 -08:00
|
|
|
const char* SessionErrorToString(SessionError error) const;
|
2019-03-26 13:33:43 +01:00
|
|
|
std::string GetSessionErrorMsg() RTC_RUN_ON(signaling_thread());
|
2017-11-06 10:37:17 -08:00
|
|
|
|
2018-03-06 10:55:04 -08:00
|
|
|
// Report the UMA metric SdpFormatReceived for the given remote offer.
|
|
|
|
|
void ReportSdpFormatReceived(const SessionDescriptionInterface& remote_offer);
|
|
|
|
|
|
2018-02-23 10:31:30 -08:00
|
|
|
// Report inferred negotiated SDP semantics from a local/remote answer to the
|
|
|
|
|
// UMA observer.
|
|
|
|
|
void ReportNegotiatedSdpSemantics(const SessionDescriptionInterface& answer);
|
|
|
|
|
|
2017-11-06 10:37:17 -08:00
|
|
|
// Invoked when TransportController connection completion is signaled.
|
|
|
|
|
// Reports stats for all transports in use.
|
2019-03-26 13:33:43 +01:00
|
|
|
void ReportTransportStats() RTC_RUN_ON(signaling_thread());
|
2017-11-06 10:37:17 -08:00
|
|
|
|
|
|
|
|
// Gather the usage of IPv4/IPv6 as best connection.
|
|
|
|
|
void ReportBestConnectionState(const cricket::TransportStats& stats);
|
|
|
|
|
|
2018-02-01 14:39:45 -08:00
|
|
|
void ReportNegotiatedCiphers(const cricket::TransportStats& stats,
|
2019-04-03 11:37:28 +02:00
|
|
|
const std::set<cricket::MediaType>& media_types)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2019-08-19 11:57:17 -07:00
|
|
|
void ReportIceCandidateCollected(const cricket::Candidate& candidate)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
|
|
|
|
void ReportRemoteIceCandidateAdded(const cricket::Candidate& candidate)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2017-11-06 10:37:17 -08:00
|
|
|
|
2018-05-31 14:00:34 +02:00
|
|
|
void NoteUsageEvent(UsageEvent event);
|
2019-02-14 10:18:56 +01:00
|
|
|
void ReportUsagePattern() const RTC_RUN_ON(signaling_thread());
|
2018-05-31 14:00:34 +02:00
|
|
|
|
2017-11-06 10:37:17 -08:00
|
|
|
void OnSentPacket_w(const rtc::SentPacket& sent_packet);
|
|
|
|
|
|
2019-03-26 13:33:43 +01:00
|
|
|
const std::string GetTransportName(const std::string& content_name)
|
|
|
|
|
RTC_RUN_ON(signaling_thread());
|
2017-11-06 10:37:17 -08:00
|
|
|
|
2019-11-16 12:09:08 +01:00
|
|
|
// Functions for dealing with transports.
|
|
|
|
|
// Note that cricket code uses the term "channel" for what other code
|
|
|
|
|
// refers to as "transport".
|
|
|
|
|
|
2017-12-04 10:37:29 -08:00
|
|
|
// Destroys and clears the BaseChannel associated with the given transceiver,
|
|
|
|
|
// if such channel is set.
|
|
|
|
|
void DestroyTransceiverChannel(
|
|
|
|
|
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>
|
|
|
|
|
transceiver);
|
|
|
|
|
|
2019-11-16 12:09:08 +01:00
|
|
|
// Destroys the RTP data channel transport and/or the SCTP data channel
|
|
|
|
|
// transport and clears it.
|
|
|
|
|
void DestroyDataChannelTransport() RTC_RUN_ON(signaling_thread());
|
2017-11-06 10:37:17 -08:00
|
|
|
|
2018-11-13 16:26:05 -08:00
|
|
|
// Destroys the given ChannelInterface.
|
|
|
|
|
// The channel cannot be accessed after this method is called.
|
|
|
|
|
void DestroyChannelInterface(cricket::ChannelInterface* channel);
|
2017-12-04 10:37:29 -08:00
|
|
|
|
2018-04-13 16:44:34 -07:00
|
|
|
// JsepTransportController::Observer override.
|
2018-04-16 16:42:14 -07:00
|
|
|
//
|
|
|
|
|
// Called by |transport_controller_| when processing transport information
|
|
|
|
|
// from a session description, and the mapping from m= sections to transports
|
|
|
|
|
// changed (as a result of BUNDLE negotiation, or m= sections being
|
|
|
|
|
// rejected).
|
Changes to enable use of DatagramTransport as a data channel transport.
PeerConnection now has a new setting in RTCConfiguration to enable use of
datagram transport for data channels. There is also a corresponding field
trial, which has both a kill-switch and a way to change the default value.
PeerConnection's interaction with MediaTransport for data channels has been
refactored to work with DataChannelTransportInterface instead.
Adds a DataChannelState and OnStateChanged() to the DataChannelSink
callbacks. This allows PeerConnection to listen to the data channel's
state directly, instead of indirectly by monitoring media transport
state. This is necessary to enable use of non-media-transport (eg.
datagram transport) data channel transports.
For now, PeerConnection watches the state through MediaTransport as well.
This will persist until MediaTransport implements the new callback.
Datagram transport use is negotiated. As such, an offer that requests to use
datagram transport for data channels may be rejected by the answerer. If the
offer includes DTLS, the data channels will be negotiated as SCTP/DTLS data
channels with an extra x-opaque parameter for datagram transport. If the
opaque parameter is rejected (by an answerer without datagram support), the
offerer may fall back to SCTP.
If DTLS is not enabled, there is no viable fallback. In this case, the data
channels are negotiated as media transport data channels. If the receiver does
not understand the x-opaque line, it will reject these data channels, and the
offerer's data channels will be closed.
Bug: webrtc:9719
Change-Id: Ic1bf3664c4bcf9d754482df59897f5f72fe68fcc
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/147702
Commit-Queue: Bjorn Mellem <mellem@webrtc.org>
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28932}
2019-08-21 10:44:59 -07:00
|
|
|
bool OnTransportChanged(
|
|
|
|
|
const std::string& mid,
|
|
|
|
|
RtpTransportInternal* rtp_transport,
|
|
|
|
|
rtc::scoped_refptr<DtlsTransport> dtls_transport,
|
2019-09-23 14:53:54 -07:00
|
|
|
DataChannelTransportInterface* data_channel_transport) override;
|
2018-03-30 10:48:35 -07:00
|
|
|
|
2019-05-20 19:31:53 +02:00
|
|
|
// RtpSenderBase::SetStreamsObserver override.
|
|
|
|
|
void OnSetStreams() override;
|
|
|
|
|
|
2018-10-25 10:16:44 -07:00
|
|
|
// Returns the CryptoOptions for this PeerConnection. This will always
|
|
|
|
|
// return the RTCConfiguration.crypto_options if set and will only default
|
|
|
|
|
// back to the PeerConnectionFactory settings if nothing was set.
|
2019-02-21 23:55:09 +01:00
|
|
|
CryptoOptions GetCryptoOptions() RTC_RUN_ON(signaling_thread());
|
2018-10-25 10:16:44 -07:00
|
|
|
|
2018-10-17 13:15:42 -07:00
|
|
|
// Returns rtp transport, result can not be nullptr.
|
2019-04-02 11:31:56 +02:00
|
|
|
RtpTransportInternal* GetRtpTransport(const std::string& mid)
|
|
|
|
|
RTC_RUN_ON(signaling_thread()) {
|
2018-10-17 13:15:42 -07:00
|
|
|
auto rtp_transport = transport_controller_->GetRtpTransport(mid);
|
|
|
|
|
RTC_DCHECK(rtp_transport);
|
|
|
|
|
return rtp_transport;
|
|
|
|
|
}
|
|
|
|
|
|
2019-04-16 12:24:14 +02:00
|
|
|
void UpdateNegotiationNeeded();
|
|
|
|
|
bool CheckIfNegotiationIsNeeded();
|
2019-10-21 23:01:31 +03:00
|
|
|
|
|
|
|
|
// | sdp_type | is the type of the SDP that caused the rollback.
|
|
|
|
|
RTCError Rollback(SdpType sdp_type);
|
2019-04-16 12:24:14 +02:00
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
// Storing the factory as a scoped reference pointer ensures that the memory
|
|
|
|
|
// in the PeerConnectionFactoryImpl remains available as long as the
|
|
|
|
|
// PeerConnection is running. It is passed to PeerConnection as a raw pointer.
|
|
|
|
|
// However, since the reference counting is done in the
|
2015-10-14 11:33:11 -07:00
|
|
|
// PeerConnectionFactoryInterface all instances created using the raw pointer
|
2013-07-10 00:45:36 +00:00
|
|
|
// will refer to the same reference count.
|
2019-02-14 10:18:56 +01:00
|
|
|
const rtc::scoped_refptr<PeerConnectionFactory> factory_;
|
|
|
|
|
PeerConnectionObserver* observer_ RTC_GUARDED_BY(signaling_thread()) =
|
|
|
|
|
nullptr;
|
2017-05-12 23:37:18 -07:00
|
|
|
|
|
|
|
|
// The EventLog needs to outlive |call_| (and any other object that uses it).
|
2019-02-14 11:59:57 +01:00
|
|
|
std::unique_ptr<RtcEventLog> event_log_ RTC_GUARDED_BY(worker_thread());
|
|
|
|
|
|
|
|
|
|
// Points to the same thing as `event_log_`. Since it's const, we may read the
|
|
|
|
|
// pointer (but not touch the object) from any thread.
|
|
|
|
|
RtcEventLog* const event_log_ptr_ RTC_PT_GUARDED_BY(worker_thread());
|
2017-05-12 23:37:18 -07:00
|
|
|
|
2019-10-28 12:09:49 +01:00
|
|
|
// The operations chain is used by the offer/answer exchange methods to ensure
|
|
|
|
|
// they are executed in the right order. For example, if
|
|
|
|
|
// SetRemoteDescription() is invoked while CreateOffer() is still pending, the
|
|
|
|
|
// SRD operation will not start until CreateOffer() has completed. See
|
|
|
|
|
// https://w3c.github.io/webrtc-pc/#dfn-operations-chain.
|
|
|
|
|
rtc::scoped_refptr<rtc::OperationsChain> operations_chain_
|
|
|
|
|
RTC_GUARDED_BY(signaling_thread());
|
|
|
|
|
|
2019-02-17 13:00:07 +01:00
|
|
|
SignalingState signaling_state_ RTC_GUARDED_BY(signaling_thread()) = kStable;
|
|
|
|
|
IceConnectionState ice_connection_state_ RTC_GUARDED_BY(signaling_thread()) =
|
|
|
|
|
kIceConnectionNew;
|
|
|
|
|
PeerConnectionInterface::IceConnectionState standardized_ice_connection_state_
|
|
|
|
|
RTC_GUARDED_BY(signaling_thread()) = kIceConnectionNew;
|
|
|
|
|
PeerConnectionInterface::PeerConnectionState connection_state_
|
|
|
|
|
RTC_GUARDED_BY(signaling_thread()) = PeerConnectionState::kNew;
|
2018-10-18 15:58:17 +02:00
|
|
|
|
2019-02-17 13:00:07 +01:00
|
|
|
IceGatheringState ice_gathering_state_ RTC_GUARDED_BY(signaling_thread()) =
|
|
|
|
|
kIceGatheringNew;
|
2019-02-21 23:55:09 +01:00
|
|
|
PeerConnectionInterface::RTCConfiguration configuration_
|
|
|
|
|
RTC_GUARDED_BY(signaling_thread());
|
|
|
|
|
|
2018-08-02 13:20:15 -07:00
|
|
|
// TODO(zstein): |async_resolver_factory_| can currently be nullptr if it
|
|
|
|
|
// is not injected. It should be required once chromium supplies it.
|
2019-03-22 14:13:22 +01:00
|
|
|
std::unique_ptr<AsyncResolverFactory> async_resolver_factory_
|
|
|
|
|
RTC_GUARDED_BY(signaling_thread());
|
|
|
|
|
std::unique_ptr<cricket::PortAllocator>
|
|
|
|
|
port_allocator_; // TODO(bugs.webrtc.org/9987): Accessed on both
|
|
|
|
|
// signaling and network thread.
|
2020-03-27 18:01:19 -07:00
|
|
|
std::unique_ptr<rtc::PacketSocketFactory> packet_socket_factory_;
|
2019-11-15 12:33:05 -08:00
|
|
|
std::unique_ptr<webrtc::IceTransportFactory>
|
|
|
|
|
ice_transport_factory_; // TODO(bugs.webrtc.org/9987): Accessed on the
|
|
|
|
|
// signaling thread but the underlying raw
|
|
|
|
|
// pointer is given to
|
|
|
|
|
// |jsep_transport_controller_| and used on the
|
|
|
|
|
// network thread.
|
2019-03-22 14:13:22 +01:00
|
|
|
std::unique_ptr<rtc::SSLCertificateVerifier>
|
|
|
|
|
tls_cert_verifier_; // TODO(bugs.webrtc.org/9987): Accessed on both
|
|
|
|
|
// signaling and network thread.
|
2015-10-14 11:33:11 -07:00
|
|
|
|
2016-05-06 18:40:30 -07:00
|
|
|
// One PeerConnection has only one RTCP CNAME.
|
|
|
|
|
// https://tools.ietf.org/html/draft-ietf-rtcweb-rtp-usage-26#section-4.9
|
2019-03-22 14:13:22 +01:00
|
|
|
const std::string rtcp_cname_;
|
2016-05-06 18:40:30 -07:00
|
|
|
|
2015-10-14 11:33:11 -07:00
|
|
|
// Streams added via AddStream.
|
2019-03-22 14:27:22 +01:00
|
|
|
const rtc::scoped_refptr<StreamCollection> local_streams_
|
|
|
|
|
RTC_GUARDED_BY(signaling_thread());
|
2015-10-14 11:33:11 -07:00
|
|
|
// Streams created as a result of SetRemoteDescription.
|
2019-03-22 14:27:22 +01:00
|
|
|
const rtc::scoped_refptr<StreamCollection> remote_streams_
|
|
|
|
|
RTC_GUARDED_BY(signaling_thread());
|
2015-10-14 11:33:11 -07:00
|
|
|
|
2019-03-22 14:27:22 +01:00
|
|
|
std::vector<std::unique_ptr<MediaStreamObserver>> stream_observers_
|
|
|
|
|
RTC_GUARDED_BY(signaling_thread());
|
2015-12-15 19:24:43 -08:00
|
|
|
|
2017-11-20 10:20:22 -08:00
|
|
|
// These lists store sender info seen in local/remote descriptions.
|
2019-03-22 15:14:27 +01:00
|
|
|
std::vector<RtpSenderInfo> remote_audio_sender_infos_
|
|
|
|
|
RTC_GUARDED_BY(signaling_thread());
|
|
|
|
|
std::vector<RtpSenderInfo> remote_video_sender_infos_
|
|
|
|
|
RTC_GUARDED_BY(signaling_thread());
|
|
|
|
|
std::vector<RtpSenderInfo> local_audio_sender_infos_
|
|
|
|
|
RTC_GUARDED_BY(signaling_thread());
|
|
|
|
|
std::vector<RtpSenderInfo> local_video_sender_infos_
|
|
|
|
|
RTC_GUARDED_BY(signaling_thread());
|
2015-10-14 11:33:11 -07:00
|
|
|
|
2019-03-22 15:29:58 +01:00
|
|
|
bool remote_peer_supports_msid_ RTC_GUARDED_BY(signaling_thread()) = false;
|
2015-09-28 16:53:55 -07:00
|
|
|
|
2019-03-26 13:08:37 +01:00
|
|
|
// The unique_ptr belongs to the worker thread, but the Call object manages
|
|
|
|
|
// its own thread safety.
|
2019-03-26 09:57:01 +01:00
|
|
|
std::unique_ptr<Call> call_ RTC_GUARDED_BY(worker_thread());
|
|
|
|
|
|
2019-09-18 18:22:12 +02:00
|
|
|
rtc::AsyncInvoker rtcp_invoker_ RTC_GUARDED_BY(network_thread());
|
|
|
|
|
|
2019-03-26 09:57:01 +01:00
|
|
|
// Points to the same thing as `call_`. Since it's const, we may read the
|
2019-03-26 13:08:37 +01:00
|
|
|
// pointer from any thread.
|
|
|
|
|
Call* const call_ptr_;
|
2019-03-26 09:57:01 +01:00
|
|
|
|
|
|
|
|
std::unique_ptr<StatsCollector> stats_
|
|
|
|
|
RTC_GUARDED_BY(signaling_thread()); // A pointer is passed to senders_
|
|
|
|
|
rtc::scoped_refptr<RTCStatsCollector> stats_collector_
|
|
|
|
|
RTC_GUARDED_BY(signaling_thread());
|
2019-10-09 18:29:44 +03:00
|
|
|
// Holds changes made to transceivers during applying descriptors for
|
|
|
|
|
// potential rollback. Gets cleared once signaling state goes to stable.
|
|
|
|
|
std::map<rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>,
|
|
|
|
|
TransceiverStableState>
|
|
|
|
|
transceiver_stable_states_by_transceivers_;
|
2020-03-18 20:41:45 +02:00
|
|
|
// Used when rolling back RTP data channels.
|
|
|
|
|
bool have_pending_rtp_data_channel_ RTC_GUARDED_BY(signaling_thread()) =
|
|
|
|
|
false;
|
2019-11-25 18:49:44 +02:00
|
|
|
// Holds remote stream ids for transceivers from stable state.
|
|
|
|
|
std::map<rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>,
|
|
|
|
|
std::vector<std::string>>
|
|
|
|
|
remote_stream_ids_by_transceivers_;
|
2016-06-06 14:27:39 -07:00
|
|
|
std::vector<
|
2017-11-20 10:20:22 -08:00
|
|
|
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>>
|
2019-04-02 11:31:56 +02:00
|
|
|
transceivers_; // TODO(bugs.webrtc.org/9987): Accessed on both signaling
|
|
|
|
|
// and network thread.
|
|
|
|
|
|
2018-12-04 11:25:05 +01:00
|
|
|
// In Unified Plan, if we encounter remote SDP that does not contain an a=msid
|
|
|
|
|
// line we create and use a stream with a random ID for our receivers. This is
|
|
|
|
|
// to support legacy endpoints that do not support the a=msid attribute (as
|
|
|
|
|
// opposed to streamless tracks with "a=msid:-").
|
2019-03-26 13:33:43 +01:00
|
|
|
rtc::scoped_refptr<MediaStreamInterface> missing_msid_default_stream_
|
|
|
|
|
RTC_GUARDED_BY(signaling_thread());
|
2019-01-07 12:13:08 -08:00
|
|
|
// MIDs will be generated using this generator which will keep track of
|
|
|
|
|
// all the MIDs that have been seen over the life of the PeerConnection.
|
2019-03-26 13:33:43 +01:00
|
|
|
rtc::UniqueStringGenerator mid_generator_ RTC_GUARDED_BY(signaling_thread());
|
2017-11-06 10:37:17 -08:00
|
|
|
|
2019-03-26 13:33:43 +01:00
|
|
|
SessionError session_error_ RTC_GUARDED_BY(signaling_thread()) =
|
|
|
|
|
SessionError::kNone;
|
|
|
|
|
std::string session_error_desc_ RTC_GUARDED_BY(signaling_thread());
|
2017-11-06 10:37:17 -08:00
|
|
|
|
2019-03-26 13:33:43 +01:00
|
|
|
std::string session_id_ RTC_GUARDED_BY(signaling_thread());
|
2017-11-06 10:37:17 -08:00
|
|
|
|
2019-04-02 11:31:56 +02:00
|
|
|
std::unique_ptr<JsepTransportController>
|
|
|
|
|
transport_controller_; // TODO(bugs.webrtc.org/9987): Accessed on both
|
|
|
|
|
// signaling and network thread.
|
|
|
|
|
std::unique_ptr<cricket::SctpTransportInternalFactory>
|
|
|
|
|
sctp_factory_; // TODO(bugs.webrtc.org/9987): Accessed on both
|
|
|
|
|
// signaling and network thread.
|
2017-11-06 10:37:17 -08:00
|
|
|
|
2018-03-30 10:48:35 -07:00
|
|
|
// |sctp_mid_| is the content name (MID) in SDP.
|
Changes to enable use of DatagramTransport as a data channel transport.
PeerConnection now has a new setting in RTCConfiguration to enable use of
datagram transport for data channels. There is also a corresponding field
trial, which has both a kill-switch and a way to change the default value.
PeerConnection's interaction with MediaTransport for data channels has been
refactored to work with DataChannelTransportInterface instead.
Adds a DataChannelState and OnStateChanged() to the DataChannelSink
callbacks. This allows PeerConnection to listen to the data channel's
state directly, instead of indirectly by monitoring media transport
state. This is necessary to enable use of non-media-transport (eg.
datagram transport) data channel transports.
For now, PeerConnection watches the state through MediaTransport as well.
This will persist until MediaTransport implements the new callback.
Datagram transport use is negotiated. As such, an offer that requests to use
datagram transport for data channels may be rejected by the answerer. If the
offer includes DTLS, the data channels will be negotiated as SCTP/DTLS data
channels with an extra x-opaque parameter for datagram transport. If the
opaque parameter is rejected (by an answerer without datagram support), the
offerer may fall back to SCTP.
If DTLS is not enabled, there is no viable fallback. In this case, the data
channels are negotiated as media transport data channels. If the receiver does
not understand the x-opaque line, it will reject these data channels, and the
offerer's data channels will be closed.
Bug: webrtc:9719
Change-Id: Ic1bf3664c4bcf9d754482df59897f5f72fe68fcc
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/147702
Commit-Queue: Bjorn Mellem <mellem@webrtc.org>
Reviewed-by: Steve Anton <steveanton@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28932}
2019-08-21 10:44:59 -07:00
|
|
|
// Note: this is used as the data channel MID by both SCTP and data channel
|
|
|
|
|
// transports. It is set when either transport is initialized and unset when
|
|
|
|
|
// both transports are deleted.
|
2020-02-12 07:38:21 +01:00
|
|
|
// There is one copy on the signaling thread and another copy on the
|
|
|
|
|
// networking thread. Changes are always initiated from the signaling
|
|
|
|
|
// thread, but applied first on the networking thread via an invoke().
|
|
|
|
|
absl::optional<std::string> sctp_mid_s_ RTC_GUARDED_BY(signaling_thread());
|
|
|
|
|
absl::optional<std::string> sctp_mid_n_ RTC_GUARDED_BY(network_thread());
|
2019-04-02 11:31:56 +02:00
|
|
|
|
2018-11-08 11:23:22 -08:00
|
|
|
// Whether this peer is the caller. Set when the local description is applied.
|
|
|
|
|
absl::optional<bool> is_caller_ RTC_GUARDED_BY(signaling_thread());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2019-04-03 11:37:28 +02:00
|
|
|
std::unique_ptr<SessionDescriptionInterface> current_local_description_
|
|
|
|
|
RTC_GUARDED_BY(signaling_thread());
|
|
|
|
|
std::unique_ptr<SessionDescriptionInterface> pending_local_description_
|
|
|
|
|
RTC_GUARDED_BY(signaling_thread());
|
|
|
|
|
std::unique_ptr<SessionDescriptionInterface> current_remote_description_
|
|
|
|
|
RTC_GUARDED_BY(signaling_thread());
|
|
|
|
|
std::unique_ptr<SessionDescriptionInterface> pending_remote_description_
|
|
|
|
|
RTC_GUARDED_BY(signaling_thread());
|
|
|
|
|
bool dtls_enabled_ RTC_GUARDED_BY(signaling_thread()) = false;
|
2019-04-08 15:36:53 +02:00
|
|
|
|
2017-11-06 10:37:17 -08:00
|
|
|
// List of content names for which the remote side triggered an ICE restart.
|
2019-04-08 15:36:53 +02:00
|
|
|
std::set<std::string> pending_ice_restarts_
|
|
|
|
|
RTC_GUARDED_BY(signaling_thread());
|
2017-11-06 10:37:17 -08:00
|
|
|
|
2019-04-08 15:36:53 +02:00
|
|
|
std::unique_ptr<WebRtcSessionDescriptionFactory> webrtc_session_desc_factory_
|
|
|
|
|
RTC_GUARDED_BY(signaling_thread());
|
2017-11-06 10:37:17 -08:00
|
|
|
|
|
|
|
|
// Member variables for caching global options.
|
2019-04-08 15:36:53 +02:00
|
|
|
cricket::AudioOptions audio_options_ RTC_GUARDED_BY(signaling_thread());
|
|
|
|
|
cricket::VideoOptions video_options_ RTC_GUARDED_BY(signaling_thread());
|
2018-05-31 14:00:34 +02:00
|
|
|
|
2019-04-08 15:36:53 +02:00
|
|
|
int usage_event_accumulator_ RTC_GUARDED_BY(signaling_thread()) = 0;
|
|
|
|
|
bool return_histogram_very_quickly_ RTC_GUARDED_BY(signaling_thread()) =
|
|
|
|
|
false;
|
2019-01-25 17:13:56 -08:00
|
|
|
|
|
|
|
|
// This object should be used to generate any SSRC that is not explicitly
|
|
|
|
|
// specified by the user (or by the remote party).
|
|
|
|
|
// The generator is not used directly, instead it is passed on to the
|
|
|
|
|
// channel manager and the session description factory.
|
2019-04-08 15:36:53 +02:00
|
|
|
rtc::UniqueRandomIdGenerator ssrc_generator_
|
|
|
|
|
RTC_GUARDED_BY(signaling_thread());
|
2019-04-17 07:38:40 +02:00
|
|
|
|
|
|
|
|
// A video bitrate allocator factory.
|
|
|
|
|
// This can injected using the PeerConnectionDependencies,
|
|
|
|
|
// or else the CreateBuiltinVideoBitrateAllocatorFactory() will be called.
|
|
|
|
|
// Note that one can still choose to override this in a MediaEngine
|
|
|
|
|
// if one wants too.
|
|
|
|
|
std::unique_ptr<webrtc::VideoBitrateAllocatorFactory>
|
|
|
|
|
video_bitrate_allocator_factory_;
|
|
|
|
|
|
2019-07-18 11:16:56 +02:00
|
|
|
std::unique_ptr<LocalIceCredentialsToReplace>
|
|
|
|
|
local_ice_credentials_to_replace_ RTC_GUARDED_BY(signaling_thread());
|
2019-04-16 12:24:14 +02:00
|
|
|
bool is_negotiation_needed_ RTC_GUARDED_BY(signaling_thread()) = false;
|
2019-10-28 12:09:49 +01:00
|
|
|
|
2019-12-02 09:56:02 +01:00
|
|
|
DataChannelController data_channel_controller_;
|
2019-10-28 12:09:49 +01:00
|
|
|
rtc::WeakPtrFactory<PeerConnection> weak_ptr_factory_
|
|
|
|
|
RTC_GUARDED_BY(signaling_thread());
|
2013-07-10 00:45:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2019-01-11 09:11:00 -08:00
|
|
|
#endif // PC_PEER_CONNECTION_H_
|