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
|
|
|
*/
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#ifndef PC_PEERCONNECTION_H_
|
|
|
|
|
#define PC_PEERCONNECTION_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>
|
2016-03-24 03:16:19 -07:00
|
|
|
#include <vector>
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "api/peerconnectioninterface.h"
|
2017-10-10 14:01:40 +02:00
|
|
|
#include "api/turncustomizer.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "pc/iceserverparsing.h"
|
2018-03-30 10:48:35 -07:00
|
|
|
#include "pc/jseptransportcontroller.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "pc/peerconnectionfactory.h"
|
2018-01-23 16:38:46 -08:00
|
|
|
#include "pc/peerconnectioninternal.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "pc/rtcstatscollector.h"
|
2017-11-20 10:20:22 -08:00
|
|
|
#include "pc/rtptransceiver.h"
|
2017-09-15 06:47:31 +02:00
|
|
|
#include "pc/statscollector.h"
|
|
|
|
|
#include "pc/streamcollection.h"
|
2017-11-06 10:37:17 -08:00
|
|
|
#include "pc/webrtcsessiondescriptionfactory.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,
|
2017-11-06 10:37:17 -08:00
|
|
|
public DataChannelProviderInterface,
|
2018-04-13 16:44:34 -07:00
|
|
|
public JsepTransportController::Observer,
|
2014-07-29 17:36:52 +00:00
|
|
|
public rtc::MessageHandler,
|
2013-07-10 00:45:36 +00:00
|
|
|
public sigslot::has_slots<> {
|
|
|
|
|
public:
|
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,
|
2016-04-27 06:47:29 -07:00
|
|
|
std::unique_ptr<cricket::PortAllocator> allocator,
|
Replacing DtlsIdentityStoreInterface with RTCCertificateGeneratorInterface.
The store was used in WebRtcSessionDescriptionFactory to generate certificates,
now a generator is used instead (new API). PeerConnection[Factory][Interface],
and WebRtcSession are updated to pass generators all the way down to the
WebRtcSessionDescriptionFactory instead of stores.
The webrtc implementation of a generator, RTCCertificateGenerator, is used as
the default generator (peerconnectionfactory.cc:189) instead of the webrtc
implementation of a store, DtlsIdentityStoreImpl.
The generator is fully parameterized and does not generate RSA-1024 unless you
ask for it (which makes sense not to do beforehand since ECDSA is now default).
The store was not fully parameterized (known filed bug).
The "top" layer, PeerConnectionFactoryInterface::CreatePeerConneciton, is
updated to take a generator instead of a store.
Many unittests still use a store, to allow them to continue to do so the
factory gets CreatePeerConnectionWithStore which uses the old function
signature (and invokes the new signature by wrapping the store in an
RTCCertificateGeneratorStoreWrapper). As soon as the FakeDtlsIdentityStore is
turned into a certificate generator instead of a store, the unittests will be
updated and we can remove CreatePeerConnectionWithStore.
This is a reupload of https://codereview.webrtc.org/2013523002/ with minor
changes.
BUG=webrtc:5707, webrtc:5708
R=tommi@webrtc.org
Review URL: https://codereview.webrtc.org/2017943002 .
Cr-Commit-Position: refs/heads/master@{#12984}
2016-06-01 11:44:18 +02:00
|
|
|
std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
|
2015-11-11 12:55:10 -08:00
|
|
|
PeerConnectionObserver* observer);
|
|
|
|
|
|
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
|
|
|
rtc::scoped_refptr<RtpSenderInterface> AddTrack(
|
|
|
|
|
MediaStreamTrackInterface* track,
|
|
|
|
|
std::vector<MediaStreamInterface*> streams) override;
|
|
|
|
|
bool RemoveTrack(RtpSenderInterface* sender) override;
|
|
|
|
|
|
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-09-29 11:56:26 -07:00
|
|
|
rtc::scoped_refptr<DtmfSenderInterface> CreateDtmfSender(
|
|
|
|
|
AudioTrackInterface* track) override;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
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;
|
|
|
|
|
IceGatheringState ice_gathering_state() 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
|
|
|
|
|
|
|
|
// JSEP01
|
2016-03-04 02:51:39 -08:00
|
|
|
// Deprecated, use version without constraints.
|
2015-09-29 11:56:26 -07:00
|
|
|
void CreateOffer(CreateSessionDescriptionObserver* observer,
|
|
|
|
|
const MediaConstraintsInterface* constraints) override;
|
|
|
|
|
void CreateOffer(CreateSessionDescriptionObserver* observer,
|
|
|
|
|
const RTCOfferAnswerOptions& options) override;
|
2016-03-04 02:51:39 -08:00
|
|
|
// Deprecated, use version without constraints.
|
2015-09-29 11:56:26 -07:00
|
|
|
void CreateAnswer(CreateSessionDescriptionObserver* observer,
|
|
|
|
|
const MediaConstraintsInterface* constraints) override;
|
2016-03-04 02:51:39 -08:00
|
|
|
void CreateAnswer(CreateSessionDescriptionObserver* observer,
|
|
|
|
|
const RTCOfferAnswerOptions& options) override;
|
2015-09-29 11:56:26 -07:00
|
|
|
void SetLocalDescription(SetSessionDescriptionObserver* observer,
|
|
|
|
|
SessionDescriptionInterface* desc) override;
|
2017-11-23 14:17:07 +00:00
|
|
|
void SetRemoteDescription(SetSessionDescriptionObserver* observer,
|
|
|
|
|
SessionDescriptionInterface* desc) override;
|
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;
|
2016-11-16 19:42:04 -08:00
|
|
|
PeerConnectionInterface::RTCConfiguration GetConfiguration() override;
|
2015-09-29 11:56:26 -07:00
|
|
|
bool SetConfiguration(
|
2017-01-11 12:28:30 -08:00
|
|
|
const PeerConnectionInterface::RTCConfiguration& configuration,
|
|
|
|
|
RTCError* error) override;
|
|
|
|
|
bool SetConfiguration(
|
|
|
|
|
const PeerConnectionInterface::RTCConfiguration& configuration) override {
|
|
|
|
|
return SetConfiguration(configuration, nullptr);
|
|
|
|
|
}
|
2015-09-29 11:56:26 -07:00
|
|
|
bool AddIceCandidate(const IceCandidateInterface* candidate) 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
|
|
|
|
|
|
|
|
void RegisterUMAObserver(UMAObserver* observer) override;
|
|
|
|
|
|
2017-06-02 14:37:37 -07:00
|
|
|
RTCError SetBitrate(const BitrateParameters& bitrate) override;
|
|
|
|
|
|
2017-10-20 10:37:47 +02:00
|
|
|
void SetBitrateAllocationStrategy(
|
|
|
|
|
std::unique_ptr<rtc::BitrateAllocationStrategy>
|
|
|
|
|
bitrate_allocation_strategy) override;
|
|
|
|
|
|
2017-11-01 11:06:56 +01:00
|
|
|
void SetAudioPlayout(bool playout) override;
|
|
|
|
|
void SetAudioRecording(bool recording) override;
|
|
|
|
|
|
2017-10-13 16:29:40 +02:00
|
|
|
RTC_DEPRECATED bool StartRtcEventLog(rtc::PlatformFile file,
|
|
|
|
|
int64_t max_size_bytes) override;
|
2017-11-20 17:38:14 +01:00
|
|
|
bool StartRtcEventLog(std::unique_ptr<RtcEventLogOutput> output,
|
|
|
|
|
int64_t output_period_ms) 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.
|
|
|
|
|
rtc::Thread* network_thread() const override {
|
|
|
|
|
return factory_->network_thread();
|
|
|
|
|
}
|
|
|
|
|
rtc::Thread* worker_thread() const override {
|
|
|
|
|
return factory_->worker_thread();
|
|
|
|
|
}
|
|
|
|
|
rtc::Thread* signaling_thread() const override {
|
|
|
|
|
return factory_->signaling_thread();
|
2016-03-24 03:16:19 -07:00
|
|
|
}
|
2015-10-14 11:33:11 -07:00
|
|
|
|
2018-01-24 15:29:17 -08:00
|
|
|
std::string session_id() const override { return session_id_; }
|
2017-11-06 10:37:17 -08:00
|
|
|
|
2018-01-23 16:38:46 -08:00
|
|
|
bool initial_offerer() const override {
|
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 {
|
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
|
|
|
|
|
|
|
|
bool GetLocalTrackIdBySsrc(uint32_t ssrc, std::string* track_id) override;
|
|
|
|
|
bool GetRemoteTrackIdBySsrc(uint32_t ssrc, std::string* track_id) override;
|
|
|
|
|
|
|
|
|
|
sigslot::signal1<DataChannel*>& SignalDataChannelCreated() override {
|
|
|
|
|
return SignalDataChannelCreated_;
|
2017-09-29 12:15:02 -07:00
|
|
|
}
|
2018-01-23 16:38:46 -08:00
|
|
|
|
|
|
|
|
cricket::RtpDataChannel* rtp_data_channel() const override {
|
|
|
|
|
return rtp_data_channel_;
|
2017-10-23 14:49:26 -07:00
|
|
|
}
|
2017-09-29 12:15:02 -07:00
|
|
|
|
2018-01-24 15:29:17 -08:00
|
|
|
std::vector<rtc::scoped_refptr<DataChannel>> sctp_data_channels()
|
2018-01-23 16:38:46 -08:00
|
|
|
const override {
|
|
|
|
|
return sctp_data_channels_;
|
|
|
|
|
}
|
2017-11-06 10:37:17 -08:00
|
|
|
|
2018-01-23 16:38:46 -08:00
|
|
|
rtc::Optional<std::string> sctp_content_name() const override {
|
2018-03-30 10:48:35 -07:00
|
|
|
return sctp_mid_;
|
2018-01-23 16:38:46 -08:00
|
|
|
}
|
2017-11-06 10:37:17 -08:00
|
|
|
|
2018-03-30 10:48:35 -07:00
|
|
|
rtc::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
|
|
|
|
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:
|
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
|
|
|
class SetRemoteDescriptionObserverAdapter;
|
|
|
|
|
friend class SetRemoteDescriptionObserverAdapter;
|
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
// Implements MessageHandler.
|
2015-09-29 11:56:26 -07:00
|
|
|
void OnMessage(rtc::Message* msg) override;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
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.
|
|
|
|
|
cricket::VoiceMediaChannel* voice_media_channel() const;
|
|
|
|
|
cricket::VideoMediaChannel* video_media_channel() const;
|
2018-01-10 11:51:34 -08:00
|
|
|
|
2017-11-20 10:20:22 -08:00
|
|
|
std::vector<rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>>>
|
|
|
|
|
GetSendersInternal() const;
|
|
|
|
|
std::vector<
|
|
|
|
|
rtc::scoped_refptr<RtpReceiverProxyWithInternal<RtpReceiverInternal>>>
|
|
|
|
|
GetReceiversInternal() const;
|
|
|
|
|
|
|
|
|
|
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>
|
|
|
|
|
GetAudioTransceiver() const;
|
|
|
|
|
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>
|
|
|
|
|
GetVideoTransceiver() const;
|
|
|
|
|
|
2018-02-20 11:35:37 -08:00
|
|
|
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>
|
|
|
|
|
GetFirstAudioTransceiver() const;
|
|
|
|
|
|
2015-10-14 11:33:11 -07:00
|
|
|
void CreateAudioReceiver(MediaStreamInterface* stream,
|
2017-11-20 10:20:22 -08:00
|
|
|
const RtpSenderInfo& remote_sender_info);
|
2016-03-10 18:32:00 +01:00
|
|
|
|
2015-10-14 11:33:11 -07:00
|
|
|
void CreateVideoReceiver(MediaStreamInterface* stream,
|
2017-11-20 10:20:22 -08:00
|
|
|
const RtpSenderInfo& remote_sender_info);
|
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(
|
2017-11-20 10:20:22 -08:00
|
|
|
const RtpSenderInfo& remote_sender_info);
|
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.
|
|
|
|
|
void AddAudioTrack(AudioTrackInterface* track, MediaStreamInterface* stream);
|
|
|
|
|
void RemoveAudioTrack(AudioTrackInterface* track,
|
|
|
|
|
MediaStreamInterface* stream);
|
|
|
|
|
void AddVideoTrack(VideoTrackInterface* track, MediaStreamInterface* stream);
|
|
|
|
|
void RemoveVideoTrack(VideoTrackInterface* track,
|
|
|
|
|
MediaStreamInterface* stream);
|
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,
|
2018-03-02 11:34:10 -08:00
|
|
|
const std::vector<std::string>& stream_ids);
|
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,
|
2018-03-02 11:34:10 -08:00
|
|
|
const std::vector<std::string>& stream_ids);
|
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(
|
|
|
|
|
rtc::scoped_refptr<MediaStreamTrackInterface> track);
|
|
|
|
|
|
|
|
|
|
// RemoveTrack that returns an RTCError.
|
|
|
|
|
RTCError RemoveTrackInternal(rtc::scoped_refptr<RtpSenderInterface> sender);
|
|
|
|
|
|
|
|
|
|
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>
|
|
|
|
|
FindTransceiverBySender(rtc::scoped_refptr<RtpSenderInterface> sender);
|
|
|
|
|
|
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,
|
|
|
|
|
bool fire_callback = true);
|
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,
|
|
|
|
|
rtc::scoped_refptr<MediaStreamTrackInterface> track,
|
2018-03-02 11:34:10 -08:00
|
|
|
const std::vector<std::string>& stream_ids);
|
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>>
|
|
|
|
|
receiver);
|
2017-12-14 10:23:57 -08:00
|
|
|
|
2017-11-06 10:21:57 -08:00
|
|
|
void SetIceConnectionState(IceConnectionState new_state);
|
|
|
|
|
// Called any time the IceGatheringState changes
|
|
|
|
|
void OnIceGatheringChange(IceGatheringState new_state);
|
|
|
|
|
// New ICE candidate has been gathered.
|
|
|
|
|
void OnIceCandidate(std::unique_ptr<IceCandidateInterface> candidate);
|
|
|
|
|
// Some local ICE candidates have been removed.
|
2016-03-14 11:59:18 -07:00
|
|
|
void OnIceCandidatesRemoved(
|
2017-11-06 10:21:57 -08:00
|
|
|
const std::vector<cricket::Candidate>& candidates);
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2017-11-06 10:21:57 -08:00
|
|
|
// Update the state, signaling if necessary.
|
2013-07-10 00:45:36 +00:00
|
|
|
void ChangeSignalingState(SignalingState signaling_state);
|
|
|
|
|
|
2015-12-15 19:24:43 -08:00
|
|
|
// Signals from MediaStreamObserver.
|
|
|
|
|
void OnAudioTrackAdded(AudioTrackInterface* track,
|
|
|
|
|
MediaStreamInterface* stream);
|
|
|
|
|
void OnAudioTrackRemoved(AudioTrackInterface* track,
|
|
|
|
|
MediaStreamInterface* stream);
|
|
|
|
|
void OnVideoTrackAdded(VideoTrackInterface* track,
|
|
|
|
|
MediaStreamInterface* stream);
|
|
|
|
|
void OnVideoTrackRemoved(VideoTrackInterface* track,
|
|
|
|
|
MediaStreamInterface* stream);
|
|
|
|
|
|
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-03-09 15:18:03 +01: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,
|
|
|
|
|
const SessionDescriptionInterface* old_remote_description);
|
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,
|
|
|
|
|
const cricket::ContentGroup* bundle_group);
|
|
|
|
|
|
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,
|
|
|
|
|
const cricket::ContentGroup* bundle_group);
|
|
|
|
|
|
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,
|
|
|
|
|
const cricket::ContentInfo* old_remote_content);
|
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>>
|
|
|
|
|
GetAssociatedTransceiver(const std::string& mid) const;
|
|
|
|
|
|
|
|
|
|
// Returns the RtpTransceiver, if found, that was assigned to the given mline
|
|
|
|
|
// index in CreateOffer.
|
|
|
|
|
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>
|
|
|
|
|
GetTransceiverByMLineIndex(size_t mline_index) const;
|
|
|
|
|
|
|
|
|
|
// Returns an RtpTransciever, if available, that can be used to receive the
|
|
|
|
|
// given media type according to JSEP rules.
|
|
|
|
|
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>
|
|
|
|
|
FindAvailableTransceiverToReceive(cricket::MediaType media_type) const;
|
|
|
|
|
|
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,
|
|
|
|
|
const SessionDescriptionInterface* sdesc) const;
|
|
|
|
|
|
2018-02-20 15:48:12 -08:00
|
|
|
void OnNegotiationNeeded();
|
|
|
|
|
|
2013-07-10 00:45:36 +00:00
|
|
|
bool IsClosed() const {
|
|
|
|
|
return signaling_state_ == PeerConnectionInterface::kClosed;
|
|
|
|
|
}
|
|
|
|
|
|
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,
|
|
|
|
|
cricket::MediaSessionOptions* session_options);
|
|
|
|
|
void GetOptionsForPlanBOffer(
|
|
|
|
|
const PeerConnectionInterface::RTCOfferAnswerOptions&
|
|
|
|
|
offer_answer_options,
|
|
|
|
|
cricket::MediaSessionOptions* session_options);
|
|
|
|
|
void GetOptionsForUnifiedPlanOffer(
|
|
|
|
|
const PeerConnectionInterface::RTCOfferAnswerOptions&
|
|
|
|
|
offer_answer_options,
|
2015-10-14 11:33:11 -07:00
|
|
|
cricket::MediaSessionOptions* session_options);
|
|
|
|
|
|
2018-01-25 13:58:07 -08:00
|
|
|
RTCError HandleLegacyOfferOptions(const RTCOfferAnswerOptions& options);
|
|
|
|
|
void RemoveRecvDirectionFromReceivingTransceiversOfType(
|
|
|
|
|
cricket::MediaType media_type);
|
|
|
|
|
void AddUpToOneReceivingTransceiverOfType(cricket::MediaType media_type);
|
|
|
|
|
std::vector<
|
|
|
|
|
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>>
|
|
|
|
|
GetReceivingTransceiversOfType(cricket::MediaType media_type);
|
|
|
|
|
|
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,
|
2017-08-17 14:10:50 -07:00
|
|
|
cricket::MediaSessionOptions* session_options);
|
2017-12-22 16:02:54 -08:00
|
|
|
void GetOptionsForPlanBAnswer(
|
|
|
|
|
const PeerConnectionInterface::RTCOfferAnswerOptions&
|
|
|
|
|
offer_answer_options,
|
|
|
|
|
cricket::MediaSessionOptions* session_options);
|
|
|
|
|
void GetOptionsForUnifiedPlanAnswer(
|
|
|
|
|
const PeerConnectionInterface::RTCOfferAnswerOptions&
|
|
|
|
|
offer_answer_options,
|
|
|
|
|
cricket::MediaSessionOptions* session_options);
|
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,
|
2017-08-17 14:10:50 -07:00
|
|
|
rtc::Optional<size_t>* audio_index,
|
|
|
|
|
rtc::Optional<size_t>* video_index,
|
|
|
|
|
rtc::Optional<size_t>* data_index,
|
2016-03-04 02:51:39 -08:00
|
|
|
cricket::MediaSessionOptions* session_options);
|
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(
|
|
|
|
|
const std::string& mid) const;
|
|
|
|
|
|
|
|
|
|
// Generates the rejected MediaDescriptionOptions for the local data channel
|
|
|
|
|
// given the specified MID.
|
|
|
|
|
cricket::MediaDescriptionOptions GetMediaDescriptionOptionsForRejectedData(
|
|
|
|
|
const std::string& mid) const;
|
|
|
|
|
|
|
|
|
|
// 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.
|
|
|
|
|
rtc::Optional<std::string> GetDataMid() const;
|
|
|
|
|
|
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).
|
2017-11-20 10:20:22 -08:00
|
|
|
void RemoveSenders(cricket::MediaType media_type);
|
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,
|
|
|
|
|
StreamCollection* new_streams);
|
|
|
|
|
|
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,
|
|
|
|
|
cricket::MediaType media_type);
|
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,
|
|
|
|
|
cricket::MediaType media_type);
|
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.
|
|
|
|
|
void UpdateEndedRemoteMediaStreams();
|
|
|
|
|
|
|
|
|
|
// 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,
|
|
|
|
|
cricket::MediaType media_type);
|
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,
|
|
|
|
|
cricket::MediaType media_type);
|
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,
|
|
|
|
|
cricket::MediaType media_type);
|
2015-10-14 11:33:11 -07:00
|
|
|
|
|
|
|
|
void UpdateLocalRtpDataChannels(const cricket::StreamParamsVec& streams);
|
|
|
|
|
void UpdateRemoteRtpDataChannels(const cricket::StreamParamsVec& streams);
|
|
|
|
|
void UpdateClosingRtpDataChannels(
|
|
|
|
|
const std::vector<std::string>& active_channels,
|
|
|
|
|
bool is_local_update);
|
|
|
|
|
void CreateRemoteRtpDataChannel(const std::string& label,
|
|
|
|
|
uint32_t remote_ssrc);
|
|
|
|
|
|
|
|
|
|
// Creates channel and adds it to the collection of DataChannels that will
|
|
|
|
|
// be offered in a SessionDescription.
|
|
|
|
|
rtc::scoped_refptr<DataChannel> InternalCreateDataChannel(
|
|
|
|
|
const std::string& label,
|
|
|
|
|
const InternalDataChannelInit* config);
|
|
|
|
|
|
|
|
|
|
// Checks if any data channel has been added.
|
|
|
|
|
bool HasDataChannels() const;
|
|
|
|
|
|
|
|
|
|
void AllocateSctpSids(rtc::SSLRole role);
|
|
|
|
|
void OnSctpDataChannelClosed(DataChannel* channel);
|
|
|
|
|
|
|
|
|
|
void OnDataChannelDestroyed();
|
2017-11-06 10:21:57 -08:00
|
|
|
// Called when a valid data channel OPEN message is received.
|
2015-10-14 11:33:11 -07:00
|
|
|
void OnDataChannelOpenMessage(const std::string& label,
|
|
|
|
|
const InternalDataChannelInit& config);
|
|
|
|
|
|
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.
|
|
|
|
|
bool IsUnifiedPlan() const {
|
|
|
|
|
return configuration_.sdp_semantics == SdpSemantics::kUnifiedPlan;
|
|
|
|
|
}
|
2017-11-20 10:20:22 -08:00
|
|
|
|
|
|
|
|
// Is there an RtpSender of the given type?
|
2017-08-17 14:10:50 -07:00
|
|
|
bool HasRtpSender(cricket::MediaType type) const;
|
2015-11-25 11:26:01 -08:00
|
|
|
|
2017-11-20 10:20:22 -08:00
|
|
|
// Return the RtpSender with the given track attached.
|
|
|
|
|
rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>>
|
|
|
|
|
FindSenderForTrack(MediaStreamTrackInterface* track) const;
|
|
|
|
|
|
|
|
|
|
// Return the RtpSender with the given id, or null if none exists.
|
|
|
|
|
rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>>
|
|
|
|
|
FindSenderById(const std::string& sender_id) const;
|
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>>
|
|
|
|
|
FindReceiverById(const std::string& receiver_id) const;
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
DataChannel* FindDataChannelBySid(int sid) const;
|
|
|
|
|
|
2016-05-13 08:15:11 -07:00
|
|
|
// Called when first configuring the port allocator.
|
2016-05-18 16:55:30 -07:00
|
|
|
bool InitializePortAllocator_n(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,
|
2017-10-10 14:01:40 +02:00
|
|
|
bool prune_turn_ports,
|
2018-02-20 14:45:49 -08:00
|
|
|
webrtc::TurnCustomizer* turn_customizer,
|
|
|
|
|
rtc::Optional<int> stun_candidate_keepalive_interval);
|
2016-05-13 08:15:11 -07:00
|
|
|
|
2018-04-11 16:57:45 -07:00
|
|
|
void SetMetricObserver_n(UMAObserver* observer);
|
|
|
|
|
|
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;
|
|
|
|
|
MetricsObserverInterface* metrics_observer() 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.
|
2017-12-04 10:46:21 -08:00
|
|
|
SessionError session_error() const { return session_error_; }
|
|
|
|
|
const std::string& session_error_desc() const { return session_error_desc_; }
|
2017-11-06 10:37:17 -08:00
|
|
|
|
|
|
|
|
cricket::BaseChannel* GetChannel(const std::string& content_name);
|
|
|
|
|
|
|
|
|
|
// Get current SSL role used by SCTP's underlying transport.
|
|
|
|
|
bool GetSctpSslRole(rtc::SSLRole* role);
|
|
|
|
|
|
|
|
|
|
cricket::IceConfig ParseIceConfig(
|
|
|
|
|
const PeerConnectionInterface::RTCConfiguration& config) const;
|
|
|
|
|
|
|
|
|
|
// Implements DataChannelProviderInterface.
|
|
|
|
|
bool SendData(const cricket::SendDataParams& params,
|
|
|
|
|
const rtc::CopyOnWriteBuffer& payload,
|
|
|
|
|
cricket::SendDataResult* result) override;
|
|
|
|
|
bool ConnectDataChannel(DataChannel* webrtc_data_channel) override;
|
|
|
|
|
void DisconnectDataChannel(DataChannel* webrtc_data_channel) override;
|
|
|
|
|
void AddSctpDataStream(int sid) override;
|
|
|
|
|
void RemoveSctpDataStream(int sid) override;
|
|
|
|
|
bool ReadyToSendData() const override;
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
SessionDescriptionInterface* mutable_local_description() {
|
|
|
|
|
return pending_local_description_ ? pending_local_description_.get()
|
|
|
|
|
: current_local_description_.get();
|
|
|
|
|
}
|
|
|
|
|
SessionDescriptionInterface* mutable_remote_description() {
|
|
|
|
|
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.
|
2017-12-06 10:34:51 -08:00
|
|
|
RTCError PushdownMediaDescription(SdpType type,
|
2017-12-04 15:25:56 -08:00
|
|
|
cricket::ContentSource source);
|
2017-11-06 10:37:17 -08:00
|
|
|
bool PushdownSctpParameters_n(cricket::ContentSource source);
|
|
|
|
|
|
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.
|
|
|
|
|
void EnableSending();
|
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.
|
|
|
|
|
void DestroyAllChannels();
|
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,
|
|
|
|
|
int* sdp_mline_index);
|
|
|
|
|
// Uses all remote candidates in |remote_desc| in this session.
|
|
|
|
|
bool UseCandidatesInSessionDescription(
|
|
|
|
|
const SessionDescriptionInterface* remote_desc);
|
|
|
|
|
// Uses |candidate| in this session.
|
|
|
|
|
bool UseCandidate(const IceCandidateInterface* candidate);
|
|
|
|
|
// Deletes the corresponding channel of contents that don't exist in |desc|.
|
|
|
|
|
// |desc| can be null. This means that all channels are deleted.
|
|
|
|
|
void RemoveUnusedChannels(const cricket::SessionDescription* desc);
|
|
|
|
|
|
|
|
|
|
// 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.
|
2017-12-22 16:02:54 -08:00
|
|
|
RTCError CreateChannels(const cricket::SessionDescription& desc);
|
|
|
|
|
|
|
|
|
|
// 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(
|
|
|
|
|
const cricket::SessionDescription& desc) const;
|
2017-11-06 10:37:17 -08:00
|
|
|
|
|
|
|
|
// Helper methods to create media channels.
|
2018-03-30 10:48:35 -07:00
|
|
|
cricket::VoiceChannel* CreateVoiceChannel(const std::string& mid);
|
|
|
|
|
cricket::VideoChannel* CreateVideoChannel(const std::string& mid);
|
|
|
|
|
bool CreateDataChannel(const std::string& mid);
|
|
|
|
|
|
|
|
|
|
bool CreateSctpTransport_n(const std::string& mid);
|
2017-11-06 10:37:17 -08:00
|
|
|
// For bundling.
|
|
|
|
|
void DestroySctpTransport_n();
|
|
|
|
|
// SctpTransport signal handlers. Needed to marshal signals from the network
|
|
|
|
|
// to signaling thread.
|
|
|
|
|
void OnSctpTransportReadyToSendData_n();
|
|
|
|
|
// This may be called with "false" if the direction of the m= section causes
|
|
|
|
|
// us to tear down the SCTP connection.
|
|
|
|
|
void OnSctpTransportReadyToSendData_s(bool ready);
|
|
|
|
|
void OnSctpTransportDataReceived_n(const cricket::ReceiveDataParams& params,
|
|
|
|
|
const rtc::CopyOnWriteBuffer& payload);
|
|
|
|
|
// Beyond just firing the signal to the signaling thread, listens to SCTP
|
|
|
|
|
// CONTROL messages on unused SIDs and processes them as OPEN messages.
|
|
|
|
|
void OnSctpTransportDataReceived_s(const cricket::ReceiveDataParams& params,
|
|
|
|
|
const rtc::CopyOnWriteBuffer& payload);
|
|
|
|
|
void OnSctpStreamClosedRemotely_n(int sid);
|
|
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
cricket::ContentSource source);
|
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,
|
|
|
|
|
bool* valid);
|
|
|
|
|
|
|
|
|
|
// Returns true if SRTP (either using DTLS-SRTP or SDES) is required by
|
|
|
|
|
// this session.
|
|
|
|
|
bool SrtpRequired() const;
|
|
|
|
|
|
2018-03-30 10:48:35 -07:00
|
|
|
// JsepTransportController signal handlers.
|
2017-11-06 10:37:17 -08:00
|
|
|
void OnTransportControllerConnectionState(cricket::IceConnectionState state);
|
|
|
|
|
void OnTransportControllerGatheringState(cricket::IceGatheringState state);
|
|
|
|
|
void OnTransportControllerCandidatesGathered(
|
|
|
|
|
const std::string& transport_name,
|
|
|
|
|
const std::vector<cricket::Candidate>& candidates);
|
|
|
|
|
void OnTransportControllerCandidatesRemoved(
|
|
|
|
|
const std::vector<cricket::Candidate>& candidates);
|
|
|
|
|
void OnTransportControllerDtlsHandshakeError(rtc::SSLHandshakeError error);
|
|
|
|
|
|
2017-12-04 10:46:21 -08:00
|
|
|
const char* SessionErrorToString(SessionError error) const;
|
2017-11-06 10:37:17 -08:00
|
|
|
std::string GetSessionErrorMsg();
|
|
|
|
|
|
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.
|
|
|
|
|
void ReportTransportStats();
|
|
|
|
|
|
|
|
|
|
// 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,
|
|
|
|
|
const std::set<cricket::MediaType>& media_types);
|
2017-11-06 10:37:17 -08:00
|
|
|
|
|
|
|
|
void OnSentPacket_w(const rtc::SentPacket& sent_packet);
|
|
|
|
|
|
|
|
|
|
const std::string GetTransportName(const std::string& content_name);
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
// Destroys the RTP data channel and/or the SCTP data channel and clears it.
|
2017-11-06 10:37:17 -08:00
|
|
|
void DestroyDataChannel();
|
|
|
|
|
|
2017-12-04 10:37:29 -08:00
|
|
|
// Destroys the given BaseChannel. The channel cannot be accessed after this
|
|
|
|
|
// method is called.
|
|
|
|
|
void DestroyBaseChannel(cricket::BaseChannel* channel);
|
|
|
|
|
|
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).
|
|
|
|
|
bool OnTransportChanged(
|
2018-04-13 16:44:34 -07:00
|
|
|
const std::string& mid,
|
2018-04-16 16:42:14 -07:00
|
|
|
RtpTransportInternal* rtp_transport,
|
2018-04-13 16:44:34 -07:00
|
|
|
cricket::DtlsTransportInternal* dtls_transport) override;
|
2018-03-30 10:48:35 -07:00
|
|
|
|
2018-01-23 16:38:46 -08:00
|
|
|
sigslot::signal1<DataChannel*> SignalDataChannelCreated_;
|
|
|
|
|
|
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.
|
2014-07-29 17:36:52 +00:00
|
|
|
rtc::scoped_refptr<PeerConnectionFactory> factory_;
|
2017-11-06 10:21:57 -08:00
|
|
|
PeerConnectionObserver* observer_ = nullptr;
|
2018-01-03 17:14:20 -08:00
|
|
|
rtc::scoped_refptr<UMAObserver> uma_observer_ = nullptr;
|
2017-05-12 23:37:18 -07:00
|
|
|
|
|
|
|
|
// The EventLog needs to outlive |call_| (and any other object that uses it).
|
|
|
|
|
std::unique_ptr<RtcEventLog> event_log_;
|
|
|
|
|
|
2017-11-06 10:21:57 -08:00
|
|
|
SignalingState signaling_state_ = kStable;
|
|
|
|
|
IceConnectionState ice_connection_state_ = kIceConnectionNew;
|
|
|
|
|
IceGatheringState ice_gathering_state_ = kIceGatheringNew;
|
2016-11-16 19:42:04 -08:00
|
|
|
PeerConnectionInterface::RTCConfiguration configuration_;
|
2013-07-10 00:45:36 +00:00
|
|
|
|
2016-04-27 06:47:29 -07:00
|
|
|
std::unique_ptr<cricket::PortAllocator> port_allocator_;
|
2018-04-11 16:57:45 -07:00
|
|
|
int port_allocator_flags_ = 0;
|
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
|
|
|
|
|
std::string rtcp_cname_;
|
|
|
|
|
|
2015-10-14 11:33:11 -07:00
|
|
|
// Streams added via AddStream.
|
|
|
|
|
rtc::scoped_refptr<StreamCollection> local_streams_;
|
|
|
|
|
// Streams created as a result of SetRemoteDescription.
|
|
|
|
|
rtc::scoped_refptr<StreamCollection> remote_streams_;
|
|
|
|
|
|
2016-04-27 06:47:29 -07:00
|
|
|
std::vector<std::unique_ptr<MediaStreamObserver>> stream_observers_;
|
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.
|
|
|
|
|
std::vector<RtpSenderInfo> remote_audio_sender_infos_;
|
|
|
|
|
std::vector<RtpSenderInfo> remote_video_sender_infos_;
|
|
|
|
|
std::vector<RtpSenderInfo> local_audio_sender_infos_;
|
|
|
|
|
std::vector<RtpSenderInfo> local_video_sender_infos_;
|
2015-10-14 11:33:11 -07:00
|
|
|
|
|
|
|
|
SctpSidAllocator sid_allocator_;
|
|
|
|
|
// label -> DataChannel
|
|
|
|
|
std::map<std::string, rtc::scoped_refptr<DataChannel>> rtp_data_channels_;
|
|
|
|
|
std::vector<rtc::scoped_refptr<DataChannel>> sctp_data_channels_;
|
2015-12-14 18:15:29 -08:00
|
|
|
std::vector<rtc::scoped_refptr<DataChannel>> sctp_data_channels_to_free_;
|
2015-10-14 11:33:11 -07:00
|
|
|
|
2015-12-08 17:13:40 -08:00
|
|
|
bool remote_peer_supports_msid_ = false;
|
2015-09-28 16:53:55 -07:00
|
|
|
|
2017-05-12 23:37:18 -07:00
|
|
|
std::unique_ptr<Call> call_;
|
|
|
|
|
std::unique_ptr<StatsCollector> stats_; // A pointer is passed to senders_
|
|
|
|
|
rtc::scoped_refptr<RTCStatsCollector> stats_collector_;
|
|
|
|
|
|
2016-06-06 14:27:39 -07:00
|
|
|
std::vector<
|
2017-11-20 10:20:22 -08:00
|
|
|
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>>
|
|
|
|
|
transceivers_;
|
2017-12-22 16:02:54 -08:00
|
|
|
// MIDs that have been seen either by SetLocalDescription or
|
|
|
|
|
// SetRemoteDescription over the life of the PeerConnection.
|
|
|
|
|
std::set<std::string> seen_mids_;
|
2017-11-06 10:37:17 -08:00
|
|
|
|
2017-12-04 10:46:21 -08:00
|
|
|
SessionError session_error_ = SessionError::kNone;
|
|
|
|
|
std::string session_error_desc_;
|
2017-11-06 10:37:17 -08:00
|
|
|
|
|
|
|
|
std::string session_id_;
|
|
|
|
|
|
2018-03-30 10:48:35 -07:00
|
|
|
std::unique_ptr<JsepTransportController> transport_controller_;
|
2017-11-06 10:37:17 -08:00
|
|
|
std::unique_ptr<cricket::SctpTransportInternalFactory> sctp_factory_;
|
|
|
|
|
// |rtp_data_channel_| is used if in RTP data channel mode, |sctp_transport_|
|
|
|
|
|
// when using SCTP.
|
|
|
|
|
cricket::RtpDataChannel* rtp_data_channel_ = nullptr;
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<cricket::SctpTransportInternal> sctp_transport_;
|
2018-03-30 10:48:35 -07:00
|
|
|
// |sctp_mid_| is the content name (MID) in SDP.
|
|
|
|
|
rtc::Optional<std::string> sctp_mid_;
|
2017-11-06 10:37:17 -08:00
|
|
|
// Value cached on signaling thread. Only updated when SctpReadyToSendData
|
|
|
|
|
// fires on the signaling thread.
|
|
|
|
|
bool sctp_ready_to_send_data_ = false;
|
|
|
|
|
// Same as signals provided by SctpTransport, but these are guaranteed to
|
|
|
|
|
// fire on the signaling thread, whereas SctpTransport fires on the networking
|
|
|
|
|
// thread.
|
|
|
|
|
// |sctp_invoker_| is used so that any signals queued on the signaling thread
|
|
|
|
|
// from the network thread are immediately discarded if the SctpTransport is
|
|
|
|
|
// destroyed (due to m= section being rejected).
|
|
|
|
|
// TODO(deadbeef): Use a proxy object to ensure that method calls/signals
|
|
|
|
|
// are marshalled to the right thread. Could almost use proxy.h for this,
|
|
|
|
|
// but it doesn't have a mechanism for marshalling sigslot::signals
|
|
|
|
|
std::unique_ptr<rtc::AsyncInvoker> sctp_invoker_;
|
|
|
|
|
sigslot::signal1<bool> SignalSctpReadyToSendData;
|
|
|
|
|
sigslot::signal2<const cricket::ReceiveDataParams&,
|
|
|
|
|
const rtc::CopyOnWriteBuffer&>
|
|
|
|
|
SignalSctpDataReceived;
|
|
|
|
|
sigslot::signal1<int> SignalSctpStreamClosedRemotely;
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<SessionDescriptionInterface> current_local_description_;
|
|
|
|
|
std::unique_ptr<SessionDescriptionInterface> pending_local_description_;
|
|
|
|
|
std::unique_ptr<SessionDescriptionInterface> current_remote_description_;
|
|
|
|
|
std::unique_ptr<SessionDescriptionInterface> pending_remote_description_;
|
|
|
|
|
bool dtls_enabled_ = false;
|
|
|
|
|
// Specifies which kind of data channel is allowed. This is controlled
|
|
|
|
|
// by the chrome command-line flag and constraints:
|
|
|
|
|
// 1. If chrome command-line switch 'enable-sctp-data-channels' is enabled,
|
|
|
|
|
// constraint kEnableDtlsSrtp is true, and constaint kEnableRtpDataChannels is
|
|
|
|
|
// not set or false, SCTP is allowed (DCT_SCTP);
|
|
|
|
|
// 2. If constraint kEnableRtpDataChannels is true, RTP is allowed (DCT_RTP);
|
|
|
|
|
// 3. If both 1&2 are false, data channel is not allowed (DCT_NONE).
|
|
|
|
|
cricket::DataChannelType data_channel_type_ = cricket::DCT_NONE;
|
|
|
|
|
// List of content names for which the remote side triggered an ICE restart.
|
|
|
|
|
std::set<std::string> pending_ice_restarts_;
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<WebRtcSessionDescriptionFactory> webrtc_session_desc_factory_;
|
|
|
|
|
|
|
|
|
|
// Member variables for caching global options.
|
|
|
|
|
cricket::AudioOptions audio_options_;
|
|
|
|
|
cricket::VideoOptions video_options_;
|
2013-07-10 00:45:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2017-09-15 06:47:31 +02:00
|
|
|
#endif // PC_PEERCONNECTION_H_
|