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
|
|
|
|
2020-09-28 10:39:31 +02:00
|
|
|
#include <functional>
|
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"
|
2020-10-05 07:01:09 +00:00
|
|
|
#include "pc/peer_connection_message_handler.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#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"
|
2020-09-28 13:02:07 +00:00
|
|
|
#include "pc/sdp_offer_answer.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "pc/stats_collector.h"
|
|
|
|
|
#include "pc/stream_collection.h"
|
2020-09-29 11:54:05 +00:00
|
|
|
#include "pc/transceiver_list.h"
|
2020-10-09 05:43:53 +00:00
|
|
|
#include "pc/usage_pattern.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#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"
|
2020-09-28 10:39:31 +02:00
|
|
|
#include "rtc_base/task_utils/pending_task_safety_flag.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;
|
2020-09-28 13:02:07 +00:00
|
|
|
class SdpOfferAnswerHandler;
|
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,
|
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,
|
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
|
|
|
|
2020-08-03 16:36:16 -07:00
|
|
|
rtc::Thread* signaling_thread() const final {
|
|
|
|
|
return factory_->signaling_thread();
|
|
|
|
|
}
|
|
|
|
|
|
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(); }
|
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());
|
2020-09-29 11:54:05 +00:00
|
|
|
return transceivers_.List();
|
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());
|
2020-09-28 13:02:07 +00:00
|
|
|
return sdp_handler_.signaling_state() == PeerConnectionInterface::kClosed;
|
2019-12-03 14:04:21 +01:00
|
|
|
}
|
|
|
|
|
// 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
|
|
|
|
2020-08-25 10:20:11 +02:00
|
|
|
bool ShouldFireNegotiationNeededEvent(uint32_t event_id) override;
|
|
|
|
|
|
2020-09-28 13:02:07 +00:00
|
|
|
// Functions needed by SdpOfferAnswerHandler
|
|
|
|
|
StatsCollector* stats() {
|
|
|
|
|
RTC_DCHECK_RUN_ON(signaling_thread());
|
|
|
|
|
return stats_.get();
|
|
|
|
|
}
|
|
|
|
|
DataChannelController* data_channel_controller() {
|
|
|
|
|
RTC_DCHECK_RUN_ON(signaling_thread());
|
|
|
|
|
return &data_channel_controller_;
|
|
|
|
|
}
|
|
|
|
|
bool dtls_enabled() const {
|
|
|
|
|
RTC_DCHECK_RUN_ON(signaling_thread());
|
|
|
|
|
return dtls_enabled_;
|
|
|
|
|
}
|
|
|
|
|
const PeerConnectionInterface::RTCConfiguration* configuration() const {
|
|
|
|
|
RTC_DCHECK_RUN_ON(signaling_thread());
|
|
|
|
|
return &configuration_;
|
|
|
|
|
}
|
2020-10-01 16:47:23 +00:00
|
|
|
absl::optional<std::string> sctp_mid() {
|
|
|
|
|
RTC_DCHECK_RUN_ON(signaling_thread());
|
|
|
|
|
return sctp_mid_s_;
|
|
|
|
|
}
|
2020-10-05 07:01:09 +00:00
|
|
|
PeerConnectionMessageHandler* message_handler() {
|
|
|
|
|
RTC_DCHECK_RUN_ON(signaling_thread());
|
|
|
|
|
return &message_handler_;
|
|
|
|
|
}
|
2020-09-28 13:02:07 +00:00
|
|
|
|
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();
|
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:
|
2020-09-28 13:02:07 +00:00
|
|
|
// While refactoring: Allow access from SDP negotiation
|
|
|
|
|
// TOOD(https://bugs.webrtc.org/11995): Remove friendship.
|
|
|
|
|
friend class SdpOfferAnswerHandler;
|
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
|
|
|
};
|
|
|
|
|
|
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>>>
|
2020-10-01 10:23:33 +00:00
|
|
|
GetSendersInternal() const;
|
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>>
|
2020-10-01 10:23:33 +00:00
|
|
|
GetAudioTransceiver() const;
|
2017-11-20 10:20:22 -08:00
|
|
|
rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>
|
2020-10-01 10:23:33 +00:00
|
|
|
GetVideoTransceiver() const;
|
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
|
|
|
|
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.
|
2020-10-09 11:42:17 +00:00
|
|
|
void AddAudioTrack(AudioTrackInterface* track, MediaStreamInterface* stream);
|
2017-07-24 17:00:25 -07:00
|
|
|
void RemoveAudioTrack(AudioTrackInterface* track,
|
2020-10-09 11:42:17 +00:00
|
|
|
MediaStreamInterface* stream);
|
|
|
|
|
void AddVideoTrack(VideoTrackInterface* track, MediaStreamInterface* stream);
|
2017-07-24 17:00:25 -07:00
|
|
|
void RemoveVideoTrack(VideoTrackInterface* track,
|
2020-10-09 11:42:17 +00:00
|
|
|
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,
|
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,
|
2020-10-01 16:47:23 +00:00
|
|
|
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,
|
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>>
|
2020-09-28 13:02:07 +00:00
|
|
|
receiver);
|
2017-12-14 10:23:57 -08:00
|
|
|
|
2020-09-28 13:02:07 +00:00
|
|
|
void SetIceConnectionState(IceConnectionState new_state);
|
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());
|
|
|
|
|
|
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
|
|
|
|
2018-02-20 15:48:12 -08:00
|
|
|
void OnNegotiationNeeded();
|
|
|
|
|
|
2015-10-14 11:33:11 -07:00
|
|
|
|
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.
|
2020-09-28 13:02:07 +00:00
|
|
|
absl::optional<std::string> GetDataMid() const;
|
2017-12-28 16:38:23 -08: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,
|
2020-10-09 11:42:17 +00:00
|
|
|
MediaStreamInterface* stream,
|
2020-10-01 16:47:23 +00:00
|
|
|
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,
|
2020-10-09 11:42:17 +00:00
|
|
|
MediaStreamInterface* stream,
|
2020-10-01 16:47:23 +00:00
|
|
|
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,
|
2020-10-01 16:47:23 +00:00
|
|
|
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,
|
2020-10-01 16:47:23 +00:00
|
|
|
cricket::MediaType media_type);
|
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.
|
2020-09-30 22:17:18 +00:00
|
|
|
bool IsUnifiedPlan() const {
|
|
|
|
|
RTC_DCHECK_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
|
|
|
|
|
|
|
|
// 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;
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
// 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);
|
|
|
|
|
|
|
|
|
|
// 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
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
// 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 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);
|
|
|
|
|
|
2018-03-06 10:55:04 -08:00
|
|
|
// Report the UMA metric SdpFormatReceived for the given remote offer.
|
|
|
|
|
void ReportSdpFormatReceived(const SessionDescriptionInterface& remote_offer);
|
|
|
|
|
|
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());
|
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);
|
|
|
|
|
|
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.
|
2020-10-01 10:23:33 +00:00
|
|
|
CryptoOptions GetCryptoOptions();
|
2018-10-25 10:16:44 -07:00
|
|
|
|
2018-10-17 13:15:42 -07:00
|
|
|
// Returns rtp transport, result can not be nullptr.
|
2020-10-05 13:08:41 +00:00
|
|
|
RtpTransportInternal* GetRtpTransport(const std::string& mid) {
|
|
|
|
|
RTC_DCHECK_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;
|
|
|
|
|
}
|
|
|
|
|
|
2020-09-28 10:39:31 +02:00
|
|
|
std::function<void(const rtc::CopyOnWriteBuffer& packet,
|
|
|
|
|
int64_t packet_time_us)>
|
|
|
|
|
InitializeRtcpCallback();
|
|
|
|
|
|
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-02-17 13:00:07 +01:00
|
|
|
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());
|
2020-08-28 16:47:02 -07:00
|
|
|
std::unique_ptr<rtc::PacketSocketFactory> packet_socket_factory_;
|
2019-03-22 14:13:22 +01:00
|
|
|
std::unique_ptr<cricket::PortAllocator>
|
|
|
|
|
port_allocator_; // TODO(bugs.webrtc.org/9987): Accessed on both
|
|
|
|
|
// signaling and network thread.
|
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
|
|
|
|
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-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());
|
2020-09-28 10:39:31 +02:00
|
|
|
std::unique_ptr<ScopedTaskSafety> call_safety_
|
|
|
|
|
RTC_GUARDED_BY(worker_thread());
|
2019-09-18 18:22:12 +02:00
|
|
|
|
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.
|
2020-09-28 10:39:31 +02:00
|
|
|
// TODO(bugs.webrtc.org/11992): Remove this workaround (and potential dangling
|
|
|
|
|
// pointer).
|
2019-03-26 13:08:37 +01:00
|
|
|
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());
|
2020-09-29 11:54:05 +00:00
|
|
|
TransceiverList transceivers_;
|
2019-04-02 11:31:56 +02: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.
|
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
|
|
|
|
2020-09-28 13:02:07 +00:00
|
|
|
// The machinery for handling offers and answers.
|
|
|
|
|
SdpOfferAnswerHandler sdp_handler_ RTC_GUARDED_BY(signaling_thread());
|
2018-11-08 11:23:22 -08:00
|
|
|
|
2019-04-03 11:37:28 +02:00
|
|
|
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
|
|
|
// 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
|
|
|
|
2020-10-09 05:43:53 +00:00
|
|
|
UsagePattern usage_pattern_ RTC_GUARDED_BY(signaling_thread());
|
2019-04-08 15:36:53 +02:00
|
|
|
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-12-02 09:56:02 +01:00
|
|
|
DataChannelController data_channel_controller_;
|
2020-10-05 07:01:09 +00:00
|
|
|
|
|
|
|
|
// Machinery for handling messages posted to oneself
|
|
|
|
|
PeerConnectionMessageHandler message_handler_;
|
2013-07-10 00:45:36 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2019-01-11 09:11:00 -08:00
|
|
|
#endif // PC_PEER_CONNECTION_H_
|