henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1 | /* |
kjellander | b24317b | 2016-02-10 07:54:43 -0800 | [diff] [blame] | 2 | * Copyright 2012 The WebRTC project authors. All Rights Reserved. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 3 | * |
kjellander | b24317b | 2016-02-10 07:54:43 -0800 | [diff] [blame] | 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 9 | */ |
| 10 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 11 | #ifndef PC_PEER_CONNECTION_H_ |
| 12 | #define PC_PEER_CONNECTION_H_ |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 13 | |
perkj | d61bf80 | 2016-03-24 03:16:19 -0700 | [diff] [blame] | 14 | #include <map> |
kwiberg | d1fe281 | 2016-04-27 06:47:29 -0700 | [diff] [blame] | 15 | #include <memory> |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 16 | #include <set> |
| 17 | #include <string> |
Henrik Boström | 79b6980 | 2019-07-18 11:16:56 +0200 | [diff] [blame] | 18 | #include <utility> |
perkj | d61bf80 | 2016-03-24 03:16:19 -0700 | [diff] [blame] | 19 | #include <vector> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 20 | |
Piotr (Peter) Slatala | e0c2e97 | 2018-10-08 09:43:21 -0700 | [diff] [blame] | 21 | #include "api/media_transport_interface.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 22 | #include "api/peer_connection_interface.h" |
| 23 | #include "api/turn_customizer.h" |
| 24 | #include "pc/ice_server_parsing.h" |
| 25 | #include "pc/jsep_transport_controller.h" |
| 26 | #include "pc/peer_connection_factory.h" |
| 27 | #include "pc/peer_connection_internal.h" |
| 28 | #include "pc/rtc_stats_collector.h" |
Guido Urdaneta | 1ff16c8 | 2019-05-20 19:31:53 +0200 | [diff] [blame] | 29 | #include "pc/rtp_sender.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 30 | #include "pc/rtp_transceiver.h" |
Harald Alvestrand | c85328f | 2019-02-28 07:51:00 +0100 | [diff] [blame] | 31 | #include "pc/sctp_transport.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 32 | #include "pc/stats_collector.h" |
| 33 | #include "pc/stream_collection.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 34 | #include "pc/webrtc_session_description_factory.h" |
Jonas Olsson | 0182a03 | 2019-07-09 12:31:20 +0200 | [diff] [blame] | 35 | #include "rtc_base/experiments/field_trial_parser.h" |
Karl Wiberg | 5966c50 | 2019-02-21 23:55:09 +0100 | [diff] [blame] | 36 | #include "rtc_base/race_checker.h" |
Amit Hilbuch | dbb49df | 2019-01-23 14:54:24 -0800 | [diff] [blame] | 37 | #include "rtc_base/unique_id_generator.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 38 | |
| 39 | namespace webrtc { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 40 | |
deadbeef | eb45981 | 2015-12-15 19:24:43 -0800 | [diff] [blame] | 41 | class MediaStreamObserver; |
perkj | f0dcfe2 | 2016-03-10 18:32:00 +0100 | [diff] [blame] | 42 | class VideoRtpReceiver; |
skvlad | 11a9cbf | 2016-10-07 11:53:05 -0700 | [diff] [blame] | 43 | class RtcEventLog; |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 44 | |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 45 | // PeerConnection is the implementation of the PeerConnection object as defined |
| 46 | // by the PeerConnectionInterface API surface. |
| 47 | // The class currently is solely responsible for the following: |
| 48 | // - Managing the session state machine (signaling state). |
| 49 | // - Creating and initializing lower-level objects, like PortAllocator and |
| 50 | // BaseChannels. |
| 51 | // - Owning and managing the life cycle of the RtpSender/RtpReceiver and track |
| 52 | // objects. |
| 53 | // - Tracking the current and pending local/remote session descriptions. |
| 54 | // The class currently is jointly responsible for the following: |
| 55 | // - Parsing and interpreting SDP. |
| 56 | // - Generating offers and answers based on the current state. |
| 57 | // - The ICE state machine. |
| 58 | // - Generating stats. |
Steve Anton | 2d8609c | 2018-01-23 16:38:46 -0800 | [diff] [blame] | 59 | class PeerConnection : public PeerConnectionInternal, |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 60 | public DataChannelProviderInterface, |
Bjorn Mellem | 175aa2e | 2018-11-08 11:23:22 -0800 | [diff] [blame] | 61 | public DataChannelSink, |
Zhi Huang | 365381f | 2018-04-13 16:44:34 -0700 | [diff] [blame] | 62 | public JsepTransportController::Observer, |
Guido Urdaneta | 1ff16c8 | 2019-05-20 19:31:53 +0200 | [diff] [blame] | 63 | public RtpSenderBase::SetStreamsObserver, |
Steve Anton | ad18276 | 2018-09-05 20:22:40 +0000 | [diff] [blame] | 64 | public rtc::MessageHandler, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 65 | public sigslot::has_slots<> { |
| 66 | public: |
Qingsi Wang | 1ba5dec | 2019-08-19 11:57:17 -0700 | [diff] [blame] | 67 | // A bit in the usage pattern is registered when its defining event occurs at |
| 68 | // least once. |
Harald Alvestrand | 8ebba74 | 2018-05-31 14:00:34 +0200 | [diff] [blame] | 69 | enum class UsageEvent : int { |
| 70 | TURN_SERVER_ADDED = 0x01, |
| 71 | STUN_SERVER_ADDED = 0x02, |
| 72 | DATA_ADDED = 0x04, |
| 73 | AUDIO_ADDED = 0x08, |
| 74 | VIDEO_ADDED = 0x10, |
Qingsi Wang | 1ba5dec | 2019-08-19 11:57:17 -0700 | [diff] [blame] | 75 | // |SetLocalDescription| returns successfully. |
| 76 | SET_LOCAL_DESCRIPTION_SUCCEEDED = 0x20, |
| 77 | // |SetRemoteDescription| returns successfully. |
| 78 | SET_REMOTE_DESCRIPTION_SUCCEEDED = 0x40, |
| 79 | // A local candidate (with type host, server-reflexive, or relay) is |
| 80 | // collected. |
Harald Alvestrand | 8ebba74 | 2018-05-31 14:00:34 +0200 | [diff] [blame] | 81 | CANDIDATE_COLLECTED = 0x80, |
Qingsi Wang | 1ba5dec | 2019-08-19 11:57:17 -0700 | [diff] [blame] | 82 | // A remote candidate is successfully added via |AddIceCandidate|. |
| 83 | ADD_ICE_CANDIDATE_SUCCEEDED = 0x100, |
Harald Alvestrand | 8ebba74 | 2018-05-31 14:00:34 +0200 | [diff] [blame] | 84 | ICE_STATE_CONNECTED = 0x200, |
Qingsi Wang | 7fc821d | 2018-07-12 12:54:53 -0700 | [diff] [blame] | 85 | CLOSE_CALLED = 0x400, |
Qingsi Wang | 1ba5dec | 2019-08-19 11:57:17 -0700 | [diff] [blame] | 86 | // A local candidate with private IP is collected. |
Harald Alvestrand | 056d811 | 2018-07-16 19:18:58 +0200 | [diff] [blame] | 87 | PRIVATE_CANDIDATE_COLLECTED = 0x800, |
Qingsi Wang | 1ba5dec | 2019-08-19 11:57:17 -0700 | [diff] [blame] | 88 | // A remote candidate with private IP is added, either via AddiceCandidate |
| 89 | // or from the remote description. |
Jeroen de Borst | af242c8 | 2019-04-24 13:13:48 -0700 | [diff] [blame] | 90 | REMOTE_PRIVATE_CANDIDATE_ADDED = 0x1000, |
Qingsi Wang | 1ba5dec | 2019-08-19 11:57:17 -0700 | [diff] [blame] | 91 | // A local mDNS candidate is collected. |
Jeroen de Borst | af242c8 | 2019-04-24 13:13:48 -0700 | [diff] [blame] | 92 | MDNS_CANDIDATE_COLLECTED = 0x2000, |
Qingsi Wang | 1ba5dec | 2019-08-19 11:57:17 -0700 | [diff] [blame] | 93 | // A remote mDNS candidate is added, either via AddIceCandidate or from the |
| 94 | // remote description. |
Jeroen de Borst | af242c8 | 2019-04-24 13:13:48 -0700 | [diff] [blame] | 95 | REMOTE_MDNS_CANDIDATE_ADDED = 0x4000, |
Qingsi Wang | 1ba5dec | 2019-08-19 11:57:17 -0700 | [diff] [blame] | 96 | // A local candidate with IPv6 address is collected. |
| 97 | IPV6_CANDIDATE_COLLECTED = 0x8000, |
| 98 | // A remote candidate with IPv6 address is added, either via AddIceCandidate |
| 99 | // or from the remote description. |
| 100 | REMOTE_IPV6_CANDIDATE_ADDED = 0x10000, |
| 101 | // A remote candidate (with type host, server-reflexive, or relay) is |
| 102 | // successfully added, either via AddIceCandidate or from the remote |
| 103 | // description. |
| 104 | REMOTE_CANDIDATE_ADDED = 0x20000, |
| 105 | MAX_VALUE = 0x40000, |
Harald Alvestrand | 8ebba74 | 2018-05-31 14:00:34 +0200 | [diff] [blame] | 106 | }; |
| 107 | |
zhihuang | 38ede13 | 2017-06-15 12:52:32 -0700 | [diff] [blame] | 108 | explicit PeerConnection(PeerConnectionFactory* factory, |
| 109 | std::unique_ptr<RtcEventLog> event_log, |
| 110 | std::unique_ptr<Call> call); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 111 | |
deadbeef | 653b8e0 | 2015-11-11 12:55:10 -0800 | [diff] [blame] | 112 | bool Initialize( |
| 113 | const PeerConnectionInterface::RTCConfiguration& configuration, |
Benjamin Wright | cab5888 | 2018-05-02 15:12:47 -0700 | [diff] [blame] | 114 | PeerConnectionDependencies dependencies); |
deadbeef | 653b8e0 | 2015-11-11 12:55:10 -0800 | [diff] [blame] | 115 | |
deadbeef | a67696b | 2015-09-29 11:56:26 -0700 | [diff] [blame] | 116 | rtc::scoped_refptr<StreamCollectionInterface> local_streams() override; |
| 117 | rtc::scoped_refptr<StreamCollectionInterface> remote_streams() override; |
| 118 | bool AddStream(MediaStreamInterface* local_stream) override; |
| 119 | void RemoveStream(MediaStreamInterface* local_stream) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 120 | |
Steve Anton | 2d6c76a | 2018-01-05 17:10:52 -0800 | [diff] [blame] | 121 | RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>> AddTrack( |
Steve Anton | f9381f0 | 2017-12-14 10:23:57 -0800 | [diff] [blame] | 122 | rtc::scoped_refptr<MediaStreamTrackInterface> track, |
Seth Hampson | 845e878 | 2018-03-02 11:34:10 -0800 | [diff] [blame] | 123 | const std::vector<std::string>& stream_ids) override; |
deadbeef | e1f9d83 | 2016-01-14 15:35:42 -0800 | [diff] [blame] | 124 | bool RemoveTrack(RtpSenderInterface* sender) override; |
Steve Anton | 24db573 | 2018-07-23 10:27:33 -0700 | [diff] [blame] | 125 | RTCError RemoveTrackNew( |
| 126 | rtc::scoped_refptr<RtpSenderInterface> sender) override; |
deadbeef | e1f9d83 | 2016-01-14 15:35:42 -0800 | [diff] [blame] | 127 | |
Steve Anton | 9158ef6 | 2017-11-27 13:01:52 -0800 | [diff] [blame] | 128 | RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver( |
| 129 | rtc::scoped_refptr<MediaStreamTrackInterface> track) override; |
| 130 | RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver( |
| 131 | rtc::scoped_refptr<MediaStreamTrackInterface> track, |
| 132 | const RtpTransceiverInit& init) override; |
| 133 | RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver( |
| 134 | cricket::MediaType media_type) override; |
| 135 | RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver( |
| 136 | cricket::MediaType media_type, |
| 137 | const RtpTransceiverInit& init) override; |
| 138 | |
Steve Anton | 8c0f7a7 | 2017-10-03 10:03:10 -0700 | [diff] [blame] | 139 | // Gets the DTLS SSL certificate associated with the audio transport on the |
| 140 | // remote side. This will become populated once the DTLS connection with the |
| 141 | // peer has been completed, as indicated by the ICE connection state |
| 142 | // transitioning to kIceConnectionCompleted. |
| 143 | // Note that this will be removed once we implement RTCDtlsTransport which |
| 144 | // has standardized method for getting this information. |
| 145 | // See https://www.w3.org/TR/webrtc/#rtcdtlstransport-interface |
| 146 | std::unique_ptr<rtc::SSLCertificate> GetRemoteAudioSSLCertificate(); |
| 147 | |
Zhi Huang | 70b820f | 2018-01-27 14:16:15 -0800 | [diff] [blame] | 148 | // Version of the above method that returns the full certificate chain. |
| 149 | std::unique_ptr<rtc::SSLCertChain> GetRemoteAudioSSLCertChain(); |
| 150 | |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 151 | rtc::scoped_refptr<RtpSenderInterface> CreateSender( |
deadbeef | bd7d8f7 | 2015-12-18 16:58:44 -0800 | [diff] [blame] | 152 | const std::string& kind, |
| 153 | const std::string& stream_id) override; |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 154 | |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 155 | std::vector<rtc::scoped_refptr<RtpSenderInterface>> GetSenders() |
| 156 | const override; |
| 157 | std::vector<rtc::scoped_refptr<RtpReceiverInterface>> GetReceivers() |
| 158 | const override; |
Steve Anton | 9158ef6 | 2017-11-27 13:01:52 -0800 | [diff] [blame] | 159 | std::vector<rtc::scoped_refptr<RtpTransceiverInterface>> GetTransceivers() |
| 160 | const override; |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 161 | |
deadbeef | a67696b | 2015-09-29 11:56:26 -0700 | [diff] [blame] | 162 | rtc::scoped_refptr<DataChannelInterface> CreateDataChannel( |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 163 | const std::string& label, |
deadbeef | a67696b | 2015-09-29 11:56:26 -0700 | [diff] [blame] | 164 | const DataChannelInit* config) override; |
Henrik Boström | 1df1bf8 | 2018-03-20 13:24:20 +0100 | [diff] [blame] | 165 | // WARNING: LEGACY. See peerconnectioninterface.h |
deadbeef | a67696b | 2015-09-29 11:56:26 -0700 | [diff] [blame] | 166 | bool GetStats(StatsObserver* observer, |
| 167 | webrtc::MediaStreamTrackInterface* track, |
| 168 | StatsOutputLevel level) override; |
Henrik Boström | 1df1bf8 | 2018-03-20 13:24:20 +0100 | [diff] [blame] | 169 | // Spec-complaint GetStats(). See peerconnectioninterface.h |
hbos | 74e1a4f | 2016-09-15 23:33:01 -0700 | [diff] [blame] | 170 | void GetStats(RTCStatsCollectorCallback* callback) override; |
Henrik Boström | 1df1bf8 | 2018-03-20 13:24:20 +0100 | [diff] [blame] | 171 | void GetStats( |
| 172 | rtc::scoped_refptr<RtpSenderInterface> selector, |
| 173 | rtc::scoped_refptr<RTCStatsCollectorCallback> callback) override; |
| 174 | void GetStats( |
| 175 | rtc::scoped_refptr<RtpReceiverInterface> selector, |
| 176 | rtc::scoped_refptr<RTCStatsCollectorCallback> callback) override; |
Harald Alvestrand | 8906187 | 2018-01-02 14:08:34 +0100 | [diff] [blame] | 177 | void ClearStatsCache() override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 178 | |
deadbeef | a67696b | 2015-09-29 11:56:26 -0700 | [diff] [blame] | 179 | SignalingState signaling_state() override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 180 | |
deadbeef | a67696b | 2015-09-29 11:56:26 -0700 | [diff] [blame] | 181 | IceConnectionState ice_connection_state() override; |
Jonas Olsson | 1204690 | 2018-12-06 11:25:14 +0100 | [diff] [blame] | 182 | IceConnectionState standardized_ice_connection_state() override; |
Jonas Olsson | 635474e | 2018-10-18 15:58:17 +0200 | [diff] [blame] | 183 | PeerConnectionState peer_connection_state() override; |
deadbeef | a67696b | 2015-09-29 11:56:26 -0700 | [diff] [blame] | 184 | IceGatheringState ice_gathering_state() override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 185 | |
deadbeef | a67696b | 2015-09-29 11:56:26 -0700 | [diff] [blame] | 186 | const SessionDescriptionInterface* local_description() const override; |
| 187 | const SessionDescriptionInterface* remote_description() const override; |
deadbeef | fe4a8a4 | 2016-12-20 17:56:17 -0800 | [diff] [blame] | 188 | const SessionDescriptionInterface* current_local_description() const override; |
| 189 | const SessionDescriptionInterface* current_remote_description() |
| 190 | const override; |
| 191 | const SessionDescriptionInterface* pending_local_description() const override; |
| 192 | const SessionDescriptionInterface* pending_remote_description() |
| 193 | const override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 194 | |
Henrik Boström | 79b6980 | 2019-07-18 11:16:56 +0200 | [diff] [blame] | 195 | void RestartIce() override; |
| 196 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 197 | // JSEP01 |
deadbeef | a67696b | 2015-09-29 11:56:26 -0700 | [diff] [blame] | 198 | void CreateOffer(CreateSessionDescriptionObserver* observer, |
| 199 | const RTCOfferAnswerOptions& options) override; |
hta | a2a49d9 | 2016-03-04 02:51:39 -0800 | [diff] [blame] | 200 | void CreateAnswer(CreateSessionDescriptionObserver* observer, |
| 201 | const RTCOfferAnswerOptions& options) override; |
deadbeef | a67696b | 2015-09-29 11:56:26 -0700 | [diff] [blame] | 202 | void SetLocalDescription(SetSessionDescriptionObserver* observer, |
| 203 | SessionDescriptionInterface* desc) override; |
Henrik Boström | a4ecf55 | 2017-11-23 14:17:07 +0000 | [diff] [blame] | 204 | void SetRemoteDescription(SetSessionDescriptionObserver* observer, |
| 205 | SessionDescriptionInterface* desc) override; |
Henrik Boström | 3163867 | 2017-11-23 17:48:32 +0100 | [diff] [blame] | 206 | void SetRemoteDescription( |
| 207 | std::unique_ptr<SessionDescriptionInterface> desc, |
| 208 | rtc::scoped_refptr<SetRemoteDescriptionObserverInterface> observer) |
| 209 | override; |
deadbeef | 46c7389 | 2016-11-16 19:42:04 -0800 | [diff] [blame] | 210 | PeerConnectionInterface::RTCConfiguration GetConfiguration() override; |
deadbeef | a67696b | 2015-09-29 11:56:26 -0700 | [diff] [blame] | 211 | bool SetConfiguration( |
deadbeef | 293e926 | 2017-01-11 12:28:30 -0800 | [diff] [blame] | 212 | const PeerConnectionInterface::RTCConfiguration& configuration, |
| 213 | RTCError* error) override; |
Niels Möller | 2579f0c | 2019-08-19 09:58:17 +0200 | [diff] [blame^] | 214 | RTCError SetConfiguration( |
| 215 | const PeerConnectionInterface::RTCConfiguration& configuration) override; |
deadbeef | a67696b | 2015-09-29 11:56:26 -0700 | [diff] [blame] | 216 | bool AddIceCandidate(const IceCandidateInterface* candidate) override; |
Honghai Zhang | 7fb69db | 2016-03-14 11:59:18 -0700 | [diff] [blame] | 217 | bool RemoveIceCandidates( |
| 218 | const std::vector<cricket::Candidate>& candidates) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 219 | |
Niels Möller | 0c4f7be | 2018-05-07 14:01:37 +0200 | [diff] [blame] | 220 | RTCError SetBitrate(const BitrateSettings& bitrate) override; |
zstein | 4b97980 | 2017-06-02 14:37:37 -0700 | [diff] [blame] | 221 | |
henrika | 5f6bf24 | 2017-11-01 11:06:56 +0100 | [diff] [blame] | 222 | void SetAudioPlayout(bool playout) override; |
| 223 | void SetAudioRecording(bool recording) override; |
| 224 | |
Harald Alvestrand | ad88c88 | 2018-11-28 16:47:46 +0100 | [diff] [blame] | 225 | rtc::scoped_refptr<DtlsTransportInterface> LookupDtlsTransportByMid( |
| 226 | const std::string& mid) override; |
Harald Alvestrand | 4a7b3ac | 2019-01-17 10:39:40 +0100 | [diff] [blame] | 227 | rtc::scoped_refptr<DtlsTransport> LookupDtlsTransportByMidInternal( |
| 228 | const std::string& mid); |
Harald Alvestrand | ad88c88 | 2018-11-28 16:47:46 +0100 | [diff] [blame] | 229 | |
Harald Alvestrand | c85328f | 2019-02-28 07:51:00 +0100 | [diff] [blame] | 230 | rtc::scoped_refptr<SctpTransportInterface> GetSctpTransport() const override; |
| 231 | |
Bjorn Terelius | de93943 | 2017-11-20 17:38:14 +0100 | [diff] [blame] | 232 | bool StartRtcEventLog(std::unique_ptr<RtcEventLogOutput> output, |
| 233 | int64_t output_period_ms) override; |
Niels Möller | f00ca1a | 2019-05-10 11:33:12 +0200 | [diff] [blame] | 234 | bool StartRtcEventLog(std::unique_ptr<RtcEventLogOutput> output) override; |
ivoc | 14d5dbe | 2016-07-04 07:06:55 -0700 | [diff] [blame] | 235 | void StopRtcEventLog() override; |
| 236 | |
deadbeef | a67696b | 2015-09-29 11:56:26 -0700 | [diff] [blame] | 237 | void Close() override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 238 | |
Steve Anton | 2d8609c | 2018-01-23 16:38:46 -0800 | [diff] [blame] | 239 | // PeerConnectionInternal implementation. |
Karl Wiberg | 4ae6347 | 2019-02-22 00:57:06 +0100 | [diff] [blame] | 240 | rtc::Thread* network_thread() const final { |
Steve Anton | 2d8609c | 2018-01-23 16:38:46 -0800 | [diff] [blame] | 241 | return factory_->network_thread(); |
| 242 | } |
Karl Wiberg | 4ae6347 | 2019-02-22 00:57:06 +0100 | [diff] [blame] | 243 | rtc::Thread* worker_thread() const final { return factory_->worker_thread(); } |
| 244 | rtc::Thread* signaling_thread() const final { |
Steve Anton | 2d8609c | 2018-01-23 16:38:46 -0800 | [diff] [blame] | 245 | return factory_->signaling_thread(); |
perkj | d61bf80 | 2016-03-24 03:16:19 -0700 | [diff] [blame] | 246 | } |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 247 | |
Karl Wiberg | a58e169 | 2019-03-26 13:33:43 +0100 | [diff] [blame] | 248 | std::string session_id() const override { |
| 249 | RTC_DCHECK_RUN_ON(signaling_thread()); |
| 250 | return session_id_; |
| 251 | } |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 252 | |
Steve Anton | 2d8609c | 2018-01-23 16:38:46 -0800 | [diff] [blame] | 253 | bool initial_offerer() const override { |
Karl Wiberg | 2cc368f | 2019-04-02 11:31:56 +0200 | [diff] [blame] | 254 | RTC_DCHECK_RUN_ON(signaling_thread()); |
Zhi Huang | e830e68 | 2018-03-30 10:48:35 -0700 | [diff] [blame] | 255 | return transport_controller_ && transport_controller_->initial_offerer(); |
Steve Anton | 2d8609c | 2018-01-23 16:38:46 -0800 | [diff] [blame] | 256 | } |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 257 | |
Steve Anton | 2d8609c | 2018-01-23 16:38:46 -0800 | [diff] [blame] | 258 | std::vector< |
| 259 | rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>> |
Steve Anton | b886711 | 2018-02-13 10:07:54 -0800 | [diff] [blame] | 260 | GetTransceiversInternal() const override { |
Karl Wiberg | a58e169 | 2019-03-26 13:33:43 +0100 | [diff] [blame] | 261 | RTC_DCHECK_RUN_ON(signaling_thread()); |
Steve Anton | 2d8609c | 2018-01-23 16:38:46 -0800 | [diff] [blame] | 262 | return transceivers_; |
| 263 | } |
| 264 | |
Steve Anton | 2d8609c | 2018-01-23 16:38:46 -0800 | [diff] [blame] | 265 | sigslot::signal1<DataChannel*>& SignalDataChannelCreated() override { |
| 266 | return SignalDataChannelCreated_; |
| 267 | } |
| 268 | |
| 269 | cricket::RtpDataChannel* rtp_data_channel() const override { |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 270 | return rtp_data_channel_; |
Steve Anton | 978b876 | 2017-09-29 12:15:02 -0700 | [diff] [blame] | 271 | } |
Steve Anton | 2d8609c | 2018-01-23 16:38:46 -0800 | [diff] [blame] | 272 | |
Steve Anton | be5e208 | 2018-01-24 15:29:17 -0800 | [diff] [blame] | 273 | std::vector<rtc::scoped_refptr<DataChannel>> sctp_data_channels() |
Steve Anton | 2d8609c | 2018-01-23 16:38:46 -0800 | [diff] [blame] | 274 | const override { |
Karl Wiberg | 85a4a93 | 2019-03-22 15:29:58 +0100 | [diff] [blame] | 275 | RTC_DCHECK_RUN_ON(signaling_thread()); |
Steve Anton | 2d8609c | 2018-01-23 16:38:46 -0800 | [diff] [blame] | 276 | return sctp_data_channels_; |
| 277 | } |
| 278 | |
Danil Chapovalov | 66cadcc | 2018-06-19 16:47:43 +0200 | [diff] [blame] | 279 | absl::optional<std::string> sctp_content_name() const override { |
Karl Wiberg | 2cc368f | 2019-04-02 11:31:56 +0200 | [diff] [blame] | 280 | RTC_DCHECK_RUN_ON(signaling_thread()); |
Zhi Huang | e830e68 | 2018-03-30 10:48:35 -0700 | [diff] [blame] | 281 | return sctp_mid_; |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 282 | } |
Steve Anton | 2d8609c | 2018-01-23 16:38:46 -0800 | [diff] [blame] | 283 | |
Danil Chapovalov | 66cadcc | 2018-06-19 16:47:43 +0200 | [diff] [blame] | 284 | absl::optional<std::string> sctp_transport_name() const override; |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 285 | |
Qingsi Wang | 72a43a1 | 2018-02-20 16:03:18 -0800 | [diff] [blame] | 286 | cricket::CandidateStatsList GetPooledCandidateStats() const override; |
Steve Anton | 5dfde18 | 2018-02-06 10:34:40 -0800 | [diff] [blame] | 287 | std::map<std::string, std::string> GetTransportNamesByMid() const override; |
| 288 | std::map<std::string, cricket::TransportStats> GetTransportStatsByNames( |
| 289 | const std::set<std::string>& transport_names) override; |
Steve Anton | 2d8609c | 2018-01-23 16:38:46 -0800 | [diff] [blame] | 290 | Call::Stats GetCallStats() override; |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 291 | |
Steve Anton | 2d8609c | 2018-01-23 16:38:46 -0800 | [diff] [blame] | 292 | bool GetLocalCertificate( |
| 293 | const std::string& transport_name, |
| 294 | rtc::scoped_refptr<rtc::RTCCertificate>* certificate) override; |
Taylor Brandstetter | c392866 | 2018-02-23 13:04:51 -0800 | [diff] [blame] | 295 | std::unique_ptr<rtc::SSLCertChain> GetRemoteSSLCertChain( |
Steve Anton | 2d8609c | 2018-01-23 16:38:46 -0800 | [diff] [blame] | 296 | const std::string& transport_name) override; |
| 297 | bool IceRestartPending(const std::string& content_name) const override; |
| 298 | bool NeedsIceRestart(const std::string& content_name) const override; |
| 299 | bool GetSslRole(const std::string& content_name, rtc::SSLRole* role) override; |
Steve Anton | 7464fca | 2018-01-19 11:10:37 -0800 | [diff] [blame] | 300 | |
Harald Alvestrand | 1979384 | 2018-06-25 12:03:50 +0200 | [diff] [blame] | 301 | void ReturnHistogramVeryQuicklyForTesting() { |
Karl Wiberg | f73f7d6 | 2019-04-08 15:36:53 +0200 | [diff] [blame] | 302 | RTC_DCHECK_RUN_ON(signaling_thread()); |
Harald Alvestrand | 1979384 | 2018-06-25 12:03:50 +0200 | [diff] [blame] | 303 | return_histogram_very_quickly_ = true; |
| 304 | } |
Harald Alvestrand | 7a1c7f7 | 2018-08-01 10:50:16 +0200 | [diff] [blame] | 305 | void RequestUsagePatternReportForTesting(); |
Harald Alvestrand | 1979384 | 2018-06-25 12:03:50 +0200 | [diff] [blame] | 306 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 307 | protected: |
deadbeef | a67696b | 2015-09-29 11:56:26 -0700 | [diff] [blame] | 308 | ~PeerConnection() override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 309 | |
| 310 | private: |
Henrik Boström | 3163867 | 2017-11-23 17:48:32 +0100 | [diff] [blame] | 311 | class SetRemoteDescriptionObserverAdapter; |
| 312 | friend class SetRemoteDescriptionObserverAdapter; |
Henrik Boström | 79b6980 | 2019-07-18 11:16:56 +0200 | [diff] [blame] | 313 | // Represents the [[LocalIceCredentialsToReplace]] internal slot in the spec. |
| 314 | // It makes the next CreateOffer() produce new ICE credentials even if |
| 315 | // RTCOfferAnswerOptions::ice_restart is false. |
| 316 | // https://w3c.github.io/webrtc-pc/#dfn-localufragstoreplace |
| 317 | // TODO(hbos): When JsepTransportController/JsepTransport supports rollback, |
| 318 | // move this type of logic to JsepTransportController/JsepTransport. |
| 319 | class LocalIceCredentialsToReplace; |
Henrik Boström | 3163867 | 2017-11-23 17:48:32 +0100 | [diff] [blame] | 320 | |
Steve Anton | 4171afb | 2017-11-20 10:20:22 -0800 | [diff] [blame] | 321 | struct RtpSenderInfo { |
| 322 | RtpSenderInfo() : first_ssrc(0) {} |
Seth Hampson | 845e878 | 2018-03-02 11:34:10 -0800 | [diff] [blame] | 323 | RtpSenderInfo(const std::string& stream_id, |
Steve Anton | 4171afb | 2017-11-20 10:20:22 -0800 | [diff] [blame] | 324 | const std::string sender_id, |
| 325 | uint32_t ssrc) |
Seth Hampson | 845e878 | 2018-03-02 11:34:10 -0800 | [diff] [blame] | 326 | : stream_id(stream_id), sender_id(sender_id), first_ssrc(ssrc) {} |
Steve Anton | 4171afb | 2017-11-20 10:20:22 -0800 | [diff] [blame] | 327 | bool operator==(const RtpSenderInfo& other) { |
Seth Hampson | 845e878 | 2018-03-02 11:34:10 -0800 | [diff] [blame] | 328 | return this->stream_id == other.stream_id && |
Steve Anton | 4171afb | 2017-11-20 10:20:22 -0800 | [diff] [blame] | 329 | this->sender_id == other.sender_id && |
| 330 | this->first_ssrc == other.first_ssrc; |
deadbeef | bda7e0b | 2015-12-08 17:13:40 -0800 | [diff] [blame] | 331 | } |
Seth Hampson | 845e878 | 2018-03-02 11:34:10 -0800 | [diff] [blame] | 332 | std::string stream_id; |
Steve Anton | 4171afb | 2017-11-20 10:20:22 -0800 | [diff] [blame] | 333 | std::string sender_id; |
| 334 | // An RtpSender can have many SSRCs. The first one is used as a sort of ID |
| 335 | // for communicating with the lower layers. |
| 336 | uint32_t first_ssrc; |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 337 | }; |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 338 | |
Bjorn A Mellem | 5985a04 | 2019-06-28 14:19:38 -0700 | [diff] [blame] | 339 | // Field-trial based configuration for datagram transport. |
| 340 | struct DatagramTransportConfig { |
| 341 | explicit DatagramTransportConfig(const std::string& field_trial) |
| 342 | : enabled("enabled", true), default_value("default_value", false) { |
| 343 | ParseFieldTrial({&enabled, &default_value}, field_trial); |
| 344 | } |
| 345 | |
| 346 | // Whether datagram transport support is enabled at all. Defaults to true, |
| 347 | // allowing datagram transport to be used if (a) the application provides a |
| 348 | // factory for it and (b) the configuration specifies its use. This flag |
| 349 | // provides a kill-switch to force-disable datagram transport across all |
| 350 | // applications, without code changes. |
| 351 | FieldTrialFlag enabled; |
| 352 | |
| 353 | // Whether the datagram transport is enabled or disabled by default. |
| 354 | // Defaults to false, meaning that applications must configure use of |
| 355 | // datagram transport through RTCConfiguration. If set to true, |
| 356 | // applications will use the datagram transport by default (but may still |
| 357 | // explicitly configure themselves not to use it through RTCConfiguration). |
| 358 | FieldTrialFlag default_value; |
| 359 | }; |
| 360 | |
Steve Anton | ad18276 | 2018-09-05 20:22:40 +0000 | [diff] [blame] | 361 | // Implements MessageHandler. |
| 362 | void OnMessage(rtc::Message* msg) override; |
| 363 | |
Steve Anton | afb0bb7 | 2018-02-20 11:35:37 -0800 | [diff] [blame] | 364 | // Plan B helpers for getting the voice/video media channels for the single |
| 365 | // audio/video transceiver, if it exists. |
Karl Wiberg | 5966c50 | 2019-02-21 23:55:09 +0100 | [diff] [blame] | 366 | cricket::VoiceMediaChannel* voice_media_channel() const |
| 367 | RTC_RUN_ON(signaling_thread()); |
| 368 | cricket::VideoMediaChannel* video_media_channel() const |
| 369 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | 6077675 | 2018-01-10 11:51:34 -0800 | [diff] [blame] | 370 | |
Steve Anton | 4171afb | 2017-11-20 10:20:22 -0800 | [diff] [blame] | 371 | std::vector<rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>>> |
Karl Wiberg | a58e169 | 2019-03-26 13:33:43 +0100 | [diff] [blame] | 372 | GetSendersInternal() const RTC_RUN_ON(signaling_thread()); |
Steve Anton | 4171afb | 2017-11-20 10:20:22 -0800 | [diff] [blame] | 373 | std::vector< |
| 374 | rtc::scoped_refptr<RtpReceiverProxyWithInternal<RtpReceiverInternal>>> |
Karl Wiberg | a58e169 | 2019-03-26 13:33:43 +0100 | [diff] [blame] | 375 | GetReceiversInternal() const RTC_RUN_ON(signaling_thread()); |
Steve Anton | 4171afb | 2017-11-20 10:20:22 -0800 | [diff] [blame] | 376 | |
| 377 | rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>> |
Karl Wiberg | 5966c50 | 2019-02-21 23:55:09 +0100 | [diff] [blame] | 378 | GetAudioTransceiver() const RTC_RUN_ON(signaling_thread()); |
Steve Anton | 4171afb | 2017-11-20 10:20:22 -0800 | [diff] [blame] | 379 | rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>> |
Karl Wiberg | 5966c50 | 2019-02-21 23:55:09 +0100 | [diff] [blame] | 380 | GetVideoTransceiver() const RTC_RUN_ON(signaling_thread()); |
Steve Anton | 4171afb | 2017-11-20 10:20:22 -0800 | [diff] [blame] | 381 | |
Steve Anton | afb0bb7 | 2018-02-20 11:35:37 -0800 | [diff] [blame] | 382 | rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>> |
Karl Wiberg | a58e169 | 2019-03-26 13:33:43 +0100 | [diff] [blame] | 383 | GetFirstAudioTransceiver() const RTC_RUN_ON(signaling_thread()); |
Steve Anton | afb0bb7 | 2018-02-20 11:35:37 -0800 | [diff] [blame] | 384 | |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 385 | void CreateAudioReceiver(MediaStreamInterface* stream, |
Karl Wiberg | 744310f | 2019-02-14 10:18:56 +0100 | [diff] [blame] | 386 | const RtpSenderInfo& remote_sender_info) |
| 387 | RTC_RUN_ON(signaling_thread()); |
perkj | f0dcfe2 | 2016-03-10 18:32:00 +0100 | [diff] [blame] | 388 | |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 389 | void CreateVideoReceiver(MediaStreamInterface* stream, |
Karl Wiberg | 744310f | 2019-02-14 10:18:56 +0100 | [diff] [blame] | 390 | const RtpSenderInfo& remote_sender_info) |
| 391 | RTC_RUN_ON(signaling_thread()); |
Henrik Boström | 933d8b0 | 2017-10-10 10:05:16 -0700 | [diff] [blame] | 392 | rtc::scoped_refptr<RtpReceiverInterface> RemoveAndStopReceiver( |
Karl Wiberg | 5966c50 | 2019-02-21 23:55:09 +0100 | [diff] [blame] | 393 | const RtpSenderInfo& remote_sender_info) RTC_RUN_ON(signaling_thread()); |
korniltsev.anatoly | ec390b5 | 2017-07-24 17:00:25 -0700 | [diff] [blame] | 394 | |
| 395 | // May be called either by AddStream/RemoveStream, or when a track is |
| 396 | // added/removed from a stream previously added via AddStream. |
Karl Wiberg | 5966c50 | 2019-02-21 23:55:09 +0100 | [diff] [blame] | 397 | void AddAudioTrack(AudioTrackInterface* track, MediaStreamInterface* stream) |
| 398 | RTC_RUN_ON(signaling_thread()); |
korniltsev.anatoly | ec390b5 | 2017-07-24 17:00:25 -0700 | [diff] [blame] | 399 | void RemoveAudioTrack(AudioTrackInterface* track, |
Karl Wiberg | 5966c50 | 2019-02-21 23:55:09 +0100 | [diff] [blame] | 400 | MediaStreamInterface* stream) |
| 401 | RTC_RUN_ON(signaling_thread()); |
| 402 | void AddVideoTrack(VideoTrackInterface* track, MediaStreamInterface* stream) |
| 403 | RTC_RUN_ON(signaling_thread()); |
korniltsev.anatoly | ec390b5 | 2017-07-24 17:00:25 -0700 | [diff] [blame] | 404 | void RemoveVideoTrack(VideoTrackInterface* track, |
Karl Wiberg | 5966c50 | 2019-02-21 23:55:09 +0100 | [diff] [blame] | 405 | MediaStreamInterface* stream) |
| 406 | RTC_RUN_ON(signaling_thread()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 407 | |
Steve Anton | f9381f0 | 2017-12-14 10:23:57 -0800 | [diff] [blame] | 408 | // AddTrack implementation when Unified Plan is specified. |
| 409 | RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>> AddTrackUnifiedPlan( |
| 410 | rtc::scoped_refptr<MediaStreamTrackInterface> track, |
Karl Wiberg | a58e169 | 2019-03-26 13:33:43 +0100 | [diff] [blame] | 411 | const std::vector<std::string>& stream_ids) |
| 412 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | f9381f0 | 2017-12-14 10:23:57 -0800 | [diff] [blame] | 413 | // AddTrack implementation when Plan B is specified. |
| 414 | RTCErrorOr<rtc::scoped_refptr<RtpSenderInterface>> AddTrackPlanB( |
| 415 | rtc::scoped_refptr<MediaStreamTrackInterface> track, |
Karl Wiberg | 5966c50 | 2019-02-21 23:55:09 +0100 | [diff] [blame] | 416 | const std::vector<std::string>& stream_ids) |
| 417 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | f9381f0 | 2017-12-14 10:23:57 -0800 | [diff] [blame] | 418 | |
| 419 | // Returns the first RtpTransceiver suitable for a newly added track, if such |
| 420 | // transceiver is available. |
| 421 | rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>> |
| 422 | FindFirstTransceiverForAddedTrack( |
Karl Wiberg | a58e169 | 2019-03-26 13:33:43 +0100 | [diff] [blame] | 423 | rtc::scoped_refptr<MediaStreamTrackInterface> track) |
| 424 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | f9381f0 | 2017-12-14 10:23:57 -0800 | [diff] [blame] | 425 | |
Steve Anton | f9381f0 | 2017-12-14 10:23:57 -0800 | [diff] [blame] | 426 | rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>> |
Karl Wiberg | a58e169 | 2019-03-26 13:33:43 +0100 | [diff] [blame] | 427 | FindTransceiverBySender(rtc::scoped_refptr<RtpSenderInterface> sender) |
| 428 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | f9381f0 | 2017-12-14 10:23:57 -0800 | [diff] [blame] | 429 | |
Steve Anton | 22da89f | 2018-01-25 13:58:07 -0800 | [diff] [blame] | 430 | // Internal implementation for AddTransceiver family of methods. If |
| 431 | // |fire_callback| is set, fires OnRenegotiationNeeded callback if successful. |
Steve Anton | 9158ef6 | 2017-11-27 13:01:52 -0800 | [diff] [blame] | 432 | RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver( |
| 433 | cricket::MediaType media_type, |
| 434 | rtc::scoped_refptr<MediaStreamTrackInterface> track, |
Steve Anton | 22da89f | 2018-01-25 13:58:07 -0800 | [diff] [blame] | 435 | const RtpTransceiverInit& init, |
Karl Wiberg | 744310f | 2019-02-14 10:18:56 +0100 | [diff] [blame] | 436 | bool fire_callback = true) RTC_RUN_ON(signaling_thread()); |
Steve Anton | 9158ef6 | 2017-11-27 13:01:52 -0800 | [diff] [blame] | 437 | |
Steve Anton | 02ee47c | 2018-01-10 16:26:06 -0800 | [diff] [blame] | 438 | rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>> |
| 439 | CreateSender(cricket::MediaType media_type, |
Steve Anton | 111fdfd | 2018-06-25 13:03:36 -0700 | [diff] [blame] | 440 | const std::string& id, |
Steve Anton | 02ee47c | 2018-01-10 16:26:06 -0800 | [diff] [blame] | 441 | rtc::scoped_refptr<MediaStreamTrackInterface> track, |
Florent Castelli | 892acf0 | 2018-10-01 22:47:20 +0200 | [diff] [blame] | 442 | const std::vector<std::string>& stream_ids, |
| 443 | const std::vector<RtpEncodingParameters>& send_encodings); |
Steve Anton | 02ee47c | 2018-01-10 16:26:06 -0800 | [diff] [blame] | 444 | |
| 445 | rtc::scoped_refptr<RtpReceiverProxyWithInternal<RtpReceiverInternal>> |
| 446 | CreateReceiver(cricket::MediaType media_type, const std::string& receiver_id); |
| 447 | |
Steve Anton | f9381f0 | 2017-12-14 10:23:57 -0800 | [diff] [blame] | 448 | // Create a new RtpTransceiver of the given type and add it to the list of |
| 449 | // transceivers. |
| 450 | rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>> |
Steve Anton | 02ee47c | 2018-01-10 16:26:06 -0800 | [diff] [blame] | 451 | CreateAndAddTransceiver( |
| 452 | rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>> sender, |
| 453 | rtc::scoped_refptr<RtpReceiverProxyWithInternal<RtpReceiverInternal>> |
Karl Wiberg | a58e169 | 2019-03-26 13:33:43 +0100 | [diff] [blame] | 454 | receiver) RTC_RUN_ON(signaling_thread()); |
Steve Anton | f9381f0 | 2017-12-14 10:23:57 -0800 | [diff] [blame] | 455 | |
Karl Wiberg | 744310f | 2019-02-14 10:18:56 +0100 | [diff] [blame] | 456 | void SetIceConnectionState(IceConnectionState new_state) |
| 457 | RTC_RUN_ON(signaling_thread()); |
Jonas Olsson | 635474e | 2018-10-18 15:58:17 +0200 | [diff] [blame] | 458 | void SetStandardizedIceConnectionState( |
Karl Wiberg | 744310f | 2019-02-14 10:18:56 +0100 | [diff] [blame] | 459 | PeerConnectionInterface::IceConnectionState new_state) |
| 460 | RTC_RUN_ON(signaling_thread()); |
Jonas Olsson | 635474e | 2018-10-18 15:58:17 +0200 | [diff] [blame] | 461 | void SetConnectionState( |
Karl Wiberg | 744310f | 2019-02-14 10:18:56 +0100 | [diff] [blame] | 462 | PeerConnectionInterface::PeerConnectionState new_state) |
| 463 | RTC_RUN_ON(signaling_thread()); |
Jonas Olsson | 635474e | 2018-10-18 15:58:17 +0200 | [diff] [blame] | 464 | |
Eldar Rello | da13ea2 | 2019-06-01 12:23:43 +0300 | [diff] [blame] | 465 | // Called any time the IceGatheringState changes. |
Karl Wiberg | 744310f | 2019-02-14 10:18:56 +0100 | [diff] [blame] | 466 | void OnIceGatheringChange(IceGatheringState new_state) |
| 467 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | ba81867 | 2017-11-06 10:21:57 -0800 | [diff] [blame] | 468 | // New ICE candidate has been gathered. |
Karl Wiberg | 744310f | 2019-02-14 10:18:56 +0100 | [diff] [blame] | 469 | void OnIceCandidate(std::unique_ptr<IceCandidateInterface> candidate) |
| 470 | RTC_RUN_ON(signaling_thread()); |
Eldar Rello | da13ea2 | 2019-06-01 12:23:43 +0300 | [diff] [blame] | 471 | // Gathering of an ICE candidate failed. |
| 472 | void OnIceCandidateError(const std::string& host_candidate, |
| 473 | const std::string& url, |
| 474 | int error_code, |
| 475 | const std::string& error_text) |
| 476 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | ba81867 | 2017-11-06 10:21:57 -0800 | [diff] [blame] | 477 | // Some local ICE candidates have been removed. |
Karl Wiberg | 744310f | 2019-02-14 10:18:56 +0100 | [diff] [blame] | 478 | void OnIceCandidatesRemoved(const std::vector<cricket::Candidate>& candidates) |
| 479 | RTC_RUN_ON(signaling_thread()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 480 | |
Alex Drake | 00c7ecf | 2019-08-06 10:54:47 -0700 | [diff] [blame] | 481 | void OnSelectedCandidatePairChanged( |
| 482 | const cricket::CandidatePairChangeEvent& event) |
| 483 | RTC_RUN_ON(signaling_thread()); |
| 484 | |
Steve Anton | ba81867 | 2017-11-06 10:21:57 -0800 | [diff] [blame] | 485 | // Update the state, signaling if necessary. |
Karl Wiberg | 744310f | 2019-02-14 10:18:56 +0100 | [diff] [blame] | 486 | void ChangeSignalingState(SignalingState signaling_state) |
| 487 | RTC_RUN_ON(signaling_thread()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 488 | |
deadbeef | eb45981 | 2015-12-15 19:24:43 -0800 | [diff] [blame] | 489 | // Signals from MediaStreamObserver. |
| 490 | void OnAudioTrackAdded(AudioTrackInterface* track, |
Karl Wiberg | 744310f | 2019-02-14 10:18:56 +0100 | [diff] [blame] | 491 | MediaStreamInterface* stream) |
| 492 | RTC_RUN_ON(signaling_thread()); |
deadbeef | eb45981 | 2015-12-15 19:24:43 -0800 | [diff] [blame] | 493 | void OnAudioTrackRemoved(AudioTrackInterface* track, |
Karl Wiberg | 744310f | 2019-02-14 10:18:56 +0100 | [diff] [blame] | 494 | MediaStreamInterface* stream) |
| 495 | RTC_RUN_ON(signaling_thread()); |
deadbeef | eb45981 | 2015-12-15 19:24:43 -0800 | [diff] [blame] | 496 | void OnVideoTrackAdded(VideoTrackInterface* track, |
Karl Wiberg | 744310f | 2019-02-14 10:18:56 +0100 | [diff] [blame] | 497 | MediaStreamInterface* stream) |
| 498 | RTC_RUN_ON(signaling_thread()); |
deadbeef | eb45981 | 2015-12-15 19:24:43 -0800 | [diff] [blame] | 499 | void OnVideoTrackRemoved(VideoTrackInterface* track, |
Karl Wiberg | 744310f | 2019-02-14 10:18:56 +0100 | [diff] [blame] | 500 | MediaStreamInterface* stream) |
| 501 | RTC_RUN_ON(signaling_thread()); |
deadbeef | eb45981 | 2015-12-15 19:24:43 -0800 | [diff] [blame] | 502 | |
Henrik Boström | 3163867 | 2017-11-23 17:48:32 +0100 | [diff] [blame] | 503 | void PostSetSessionDescriptionSuccess( |
| 504 | SetSessionDescriptionObserver* observer); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 505 | void PostSetSessionDescriptionFailure(SetSessionDescriptionObserver* observer, |
Steve Anton | ad18276 | 2018-09-05 20:22:40 +0000 | [diff] [blame] | 506 | RTCError&& error); |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 507 | void PostCreateSessionDescriptionFailure( |
| 508 | CreateSessionDescriptionObserver* observer, |
Harald Alvestrand | 5081c0c | 2018-03-09 15:18:03 +0100 | [diff] [blame] | 509 | RTCError error); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 510 | |
Steve Anton | 8a00691 | 2017-12-04 15:25:56 -0800 | [diff] [blame] | 511 | // Synchronous implementations of SetLocalDescription/SetRemoteDescription |
| 512 | // that return an RTCError instead of invoking a callback. |
| 513 | RTCError ApplyLocalDescription( |
| 514 | std::unique_ptr<SessionDescriptionInterface> desc); |
| 515 | RTCError ApplyRemoteDescription( |
| 516 | std::unique_ptr<SessionDescriptionInterface> desc); |
| 517 | |
Steve Anton | dcc3c02 | 2017-12-22 16:02:54 -0800 | [diff] [blame] | 518 | // Updates the local RtpTransceivers according to the JSEP rules. Called as |
| 519 | // part of setting the local/remote description. |
| 520 | RTCError UpdateTransceiversAndDataChannels( |
| 521 | cricket::ContentSource source, |
Seth Hampson | ae8a90a | 2018-02-13 15:33:48 -0800 | [diff] [blame] | 522 | const SessionDescriptionInterface& new_session, |
| 523 | const SessionDescriptionInterface* old_local_description, |
Karl Wiberg | 106d92d | 2019-02-14 10:17:47 +0100 | [diff] [blame] | 524 | const SessionDescriptionInterface* old_remote_description) |
| 525 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | dcc3c02 | 2017-12-22 16:02:54 -0800 | [diff] [blame] | 526 | |
| 527 | // Either creates or destroys the transceiver's BaseChannel according to the |
| 528 | // given media section. |
| 529 | RTCError UpdateTransceiverChannel( |
| 530 | rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>> |
| 531 | transceiver, |
| 532 | const cricket::ContentInfo& content, |
Karl Wiberg | 5966c50 | 2019-02-21 23:55:09 +0100 | [diff] [blame] | 533 | const cricket::ContentGroup* bundle_group) RTC_RUN_ON(signaling_thread()); |
Steve Anton | dcc3c02 | 2017-12-22 16:02:54 -0800 | [diff] [blame] | 534 | |
Steve Anton | fa2260d | 2017-12-28 16:38:23 -0800 | [diff] [blame] | 535 | // Either creates or destroys the local data channel according to the given |
| 536 | // media section. |
| 537 | RTCError UpdateDataChannel(cricket::ContentSource source, |
| 538 | const cricket::ContentInfo& content, |
Karl Wiberg | 106d92d | 2019-02-14 10:17:47 +0100 | [diff] [blame] | 539 | const cricket::ContentGroup* bundle_group) |
| 540 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | fa2260d | 2017-12-28 16:38:23 -0800 | [diff] [blame] | 541 | |
Steve Anton | dcc3c02 | 2017-12-22 16:02:54 -0800 | [diff] [blame] | 542 | // Associate the given transceiver according to the JSEP rules. |
| 543 | RTCErrorOr< |
| 544 | rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>> |
| 545 | AssociateTransceiver(cricket::ContentSource source, |
Seth Hampson | ae8a90a | 2018-02-13 15:33:48 -0800 | [diff] [blame] | 546 | SdpType type, |
Steve Anton | dcc3c02 | 2017-12-22 16:02:54 -0800 | [diff] [blame] | 547 | size_t mline_index, |
| 548 | const cricket::ContentInfo& content, |
Seth Hampson | ae8a90a | 2018-02-13 15:33:48 -0800 | [diff] [blame] | 549 | const cricket::ContentInfo* old_local_content, |
Karl Wiberg | 5966c50 | 2019-02-21 23:55:09 +0100 | [diff] [blame] | 550 | const cricket::ContentInfo* old_remote_content) |
| 551 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | dcc3c02 | 2017-12-22 16:02:54 -0800 | [diff] [blame] | 552 | |
| 553 | // Returns the RtpTransceiver, if found, that is associated to the given MID. |
| 554 | rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>> |
Karl Wiberg | 5966c50 | 2019-02-21 23:55:09 +0100 | [diff] [blame] | 555 | GetAssociatedTransceiver(const std::string& mid) const |
| 556 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | dcc3c02 | 2017-12-22 16:02:54 -0800 | [diff] [blame] | 557 | |
| 558 | // Returns the RtpTransceiver, if found, that was assigned to the given mline |
| 559 | // index in CreateOffer. |
| 560 | rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>> |
Karl Wiberg | 5966c50 | 2019-02-21 23:55:09 +0100 | [diff] [blame] | 561 | GetTransceiverByMLineIndex(size_t mline_index) const |
| 562 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | dcc3c02 | 2017-12-22 16:02:54 -0800 | [diff] [blame] | 563 | |
| 564 | // Returns an RtpTransciever, if available, that can be used to receive the |
| 565 | // given media type according to JSEP rules. |
| 566 | rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>> |
Karl Wiberg | 5966c50 | 2019-02-21 23:55:09 +0100 | [diff] [blame] | 567 | FindAvailableTransceiverToReceive(cricket::MediaType media_type) const |
| 568 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | dcc3c02 | 2017-12-22 16:02:54 -0800 | [diff] [blame] | 569 | |
Steve Anton | ed10bd9 | 2017-12-05 10:52:59 -0800 | [diff] [blame] | 570 | // Returns the media section in the given session description that is |
| 571 | // associated with the RtpTransceiver. Returns null if none found or this |
| 572 | // RtpTransceiver is not associated. Logic varies depending on the |
| 573 | // SdpSemantics specified in the configuration. |
| 574 | const cricket::ContentInfo* FindMediaSectionForTransceiver( |
| 575 | rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>> |
| 576 | transceiver, |
Karl Wiberg | 5966c50 | 2019-02-21 23:55:09 +0100 | [diff] [blame] | 577 | const SessionDescriptionInterface* sdesc) const |
| 578 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | ed10bd9 | 2017-12-05 10:52:59 -0800 | [diff] [blame] | 579 | |
Henrik Boström | afa07dd | 2018-12-20 11:06:02 +0100 | [diff] [blame] | 580 | // Runs the algorithm **set the associated remote streams** specified in |
| 581 | // https://w3c.github.io/webrtc-pc/#set-associated-remote-streams. |
| 582 | void SetAssociatedRemoteStreams( |
| 583 | rtc::scoped_refptr<RtpReceiverInternal> receiver, |
| 584 | const std::vector<std::string>& stream_ids, |
| 585 | std::vector<rtc::scoped_refptr<MediaStreamInterface>>* added_streams, |
Karl Wiberg | 1e1e102 | 2019-03-22 14:27:22 +0100 | [diff] [blame] | 586 | std::vector<rtc::scoped_refptr<MediaStreamInterface>>* removed_streams) |
| 587 | RTC_RUN_ON(signaling_thread()); |
Henrik Boström | afa07dd | 2018-12-20 11:06:02 +0100 | [diff] [blame] | 588 | |
Steve Anton | 0f5400a | 2018-07-17 14:25:36 -0700 | [diff] [blame] | 589 | // Runs the algorithm **process the removal of a remote track** specified in |
| 590 | // the WebRTC specification. |
| 591 | // This method will update the following lists: |
| 592 | // |remove_list| is the list of transceivers for which the receiving track is |
| 593 | // being removed. |
| 594 | // |removed_streams| is the list of streams which no longer have a receiving |
| 595 | // track so should be removed. |
| 596 | // https://w3c.github.io/webrtc-pc/#process-remote-track-removal |
| 597 | void ProcessRemovalOfRemoteTrack( |
| 598 | rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>> |
| 599 | transceiver, |
| 600 | std::vector<rtc::scoped_refptr<RtpTransceiverInterface>>* remove_list, |
Karl Wiberg | 1e1e102 | 2019-03-22 14:27:22 +0100 | [diff] [blame] | 601 | std::vector<rtc::scoped_refptr<MediaStreamInterface>>* removed_streams) |
| 602 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | 0f5400a | 2018-07-17 14:25:36 -0700 | [diff] [blame] | 603 | |
Henrik Boström | afa07dd | 2018-12-20 11:06:02 +0100 | [diff] [blame] | 604 | void RemoveRemoteStreamsIfEmpty( |
| 605 | const std::vector<rtc::scoped_refptr<MediaStreamInterface>>& |
| 606 | remote_streams, |
Karl Wiberg | 1e1e102 | 2019-03-22 14:27:22 +0100 | [diff] [blame] | 607 | std::vector<rtc::scoped_refptr<MediaStreamInterface>>* removed_streams) |
| 608 | RTC_RUN_ON(signaling_thread()); |
Henrik Boström | afa07dd | 2018-12-20 11:06:02 +0100 | [diff] [blame] | 609 | |
Steve Anton | 52d8677 | 2018-02-20 15:48:12 -0800 | [diff] [blame] | 610 | void OnNegotiationNeeded(); |
| 611 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 612 | bool IsClosed() const { |
Karl Wiberg | 8d2e228 | 2019-02-17 13:00:07 +0100 | [diff] [blame] | 613 | RTC_DCHECK_RUN_ON(signaling_thread()); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 614 | return signaling_state_ == PeerConnectionInterface::kClosed; |
| 615 | } |
| 616 | |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 617 | // Returns a MediaSessionOptions struct with options decided by |options|, |
| 618 | // the local MediaStreams and DataChannels. |
Steve Anton | dcc3c02 | 2017-12-22 16:02:54 -0800 | [diff] [blame] | 619 | void GetOptionsForOffer(const PeerConnectionInterface::RTCOfferAnswerOptions& |
| 620 | offer_answer_options, |
Karl Wiberg | 5966c50 | 2019-02-21 23:55:09 +0100 | [diff] [blame] | 621 | cricket::MediaSessionOptions* session_options) |
| 622 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | dcc3c02 | 2017-12-22 16:02:54 -0800 | [diff] [blame] | 623 | void GetOptionsForPlanBOffer( |
| 624 | const PeerConnectionInterface::RTCOfferAnswerOptions& |
| 625 | offer_answer_options, |
Karl Wiberg | 5966c50 | 2019-02-21 23:55:09 +0100 | [diff] [blame] | 626 | cricket::MediaSessionOptions* session_options) |
| 627 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | dcc3c02 | 2017-12-22 16:02:54 -0800 | [diff] [blame] | 628 | void GetOptionsForUnifiedPlanOffer( |
| 629 | const PeerConnectionInterface::RTCOfferAnswerOptions& |
| 630 | offer_answer_options, |
Karl Wiberg | 5966c50 | 2019-02-21 23:55:09 +0100 | [diff] [blame] | 631 | cricket::MediaSessionOptions* session_options) |
| 632 | RTC_RUN_ON(signaling_thread()); |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 633 | |
Karl Wiberg | 5966c50 | 2019-02-21 23:55:09 +0100 | [diff] [blame] | 634 | RTCError HandleLegacyOfferOptions(const RTCOfferAnswerOptions& options) |
| 635 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | 22da89f | 2018-01-25 13:58:07 -0800 | [diff] [blame] | 636 | void RemoveRecvDirectionFromReceivingTransceiversOfType( |
Karl Wiberg | a58e169 | 2019-03-26 13:33:43 +0100 | [diff] [blame] | 637 | cricket::MediaType media_type) RTC_RUN_ON(signaling_thread()); |
Steve Anton | 22da89f | 2018-01-25 13:58:07 -0800 | [diff] [blame] | 638 | void AddUpToOneReceivingTransceiverOfType(cricket::MediaType media_type); |
| 639 | std::vector< |
| 640 | rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>> |
Karl Wiberg | a58e169 | 2019-03-26 13:33:43 +0100 | [diff] [blame] | 641 | GetReceivingTransceiversOfType(cricket::MediaType media_type) |
| 642 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | 22da89f | 2018-01-25 13:58:07 -0800 | [diff] [blame] | 643 | |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 644 | // Returns a MediaSessionOptions struct with options decided by |
| 645 | // |constraints|, the local MediaStreams and DataChannels. |
Steve Anton | dcc3c02 | 2017-12-22 16:02:54 -0800 | [diff] [blame] | 646 | void GetOptionsForAnswer(const RTCOfferAnswerOptions& offer_answer_options, |
Karl Wiberg | 5966c50 | 2019-02-21 23:55:09 +0100 | [diff] [blame] | 647 | cricket::MediaSessionOptions* session_options) |
| 648 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | dcc3c02 | 2017-12-22 16:02:54 -0800 | [diff] [blame] | 649 | void GetOptionsForPlanBAnswer( |
| 650 | const PeerConnectionInterface::RTCOfferAnswerOptions& |
| 651 | offer_answer_options, |
Karl Wiberg | 5966c50 | 2019-02-21 23:55:09 +0100 | [diff] [blame] | 652 | cricket::MediaSessionOptions* session_options) |
| 653 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | dcc3c02 | 2017-12-22 16:02:54 -0800 | [diff] [blame] | 654 | void GetOptionsForUnifiedPlanAnswer( |
| 655 | const PeerConnectionInterface::RTCOfferAnswerOptions& |
| 656 | offer_answer_options, |
Karl Wiberg | 5966c50 | 2019-02-21 23:55:09 +0100 | [diff] [blame] | 657 | cricket::MediaSessionOptions* session_options) |
| 658 | RTC_RUN_ON(signaling_thread()); |
hta | a2a49d9 | 2016-03-04 02:51:39 -0800 | [diff] [blame] | 659 | |
zhihuang | 1c378ed | 2017-08-17 14:10:50 -0700 | [diff] [blame] | 660 | // Generates MediaDescriptionOptions for the |session_opts| based on existing |
| 661 | // local description or remote description. |
| 662 | void GenerateMediaDescriptionOptions( |
| 663 | const SessionDescriptionInterface* session_desc, |
Steve Anton | 1d03a75 | 2017-11-27 14:30:09 -0800 | [diff] [blame] | 664 | RtpTransceiverDirection audio_direction, |
| 665 | RtpTransceiverDirection video_direction, |
Danil Chapovalov | 66cadcc | 2018-06-19 16:47:43 +0200 | [diff] [blame] | 666 | absl::optional<size_t>* audio_index, |
| 667 | absl::optional<size_t>* video_index, |
| 668 | absl::optional<size_t>* data_index, |
Karl Wiberg | 85a4a93 | 2019-03-22 15:29:58 +0100 | [diff] [blame] | 669 | cricket::MediaSessionOptions* session_options) |
| 670 | RTC_RUN_ON(signaling_thread()); |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 671 | |
Steve Anton | fa2260d | 2017-12-28 16:38:23 -0800 | [diff] [blame] | 672 | // Generates the active MediaDescriptionOptions for the local data channel |
| 673 | // given the specified MID. |
| 674 | cricket::MediaDescriptionOptions GetMediaDescriptionOptionsForActiveData( |
Karl Wiberg | 85a4a93 | 2019-03-22 15:29:58 +0100 | [diff] [blame] | 675 | const std::string& mid) const RTC_RUN_ON(signaling_thread()); |
Steve Anton | fa2260d | 2017-12-28 16:38:23 -0800 | [diff] [blame] | 676 | |
| 677 | // Generates the rejected MediaDescriptionOptions for the local data channel |
| 678 | // given the specified MID. |
| 679 | cricket::MediaDescriptionOptions GetMediaDescriptionOptionsForRejectedData( |
Karl Wiberg | 85a4a93 | 2019-03-22 15:29:58 +0100 | [diff] [blame] | 680 | const std::string& mid) const RTC_RUN_ON(signaling_thread()); |
Steve Anton | fa2260d | 2017-12-28 16:38:23 -0800 | [diff] [blame] | 681 | |
| 682 | // Returns the MID for the data section associated with either the |
| 683 | // RtpDataChannel or SCTP data channel, if it has been set. If no data |
| 684 | // channels are configured this will return nullopt. |
Karl Wiberg | 2cc368f | 2019-04-02 11:31:56 +0200 | [diff] [blame] | 685 | absl::optional<std::string> GetDataMid() const RTC_RUN_ON(signaling_thread()); |
Steve Anton | fa2260d | 2017-12-28 16:38:23 -0800 | [diff] [blame] | 686 | |
Steve Anton | 4171afb | 2017-11-20 10:20:22 -0800 | [diff] [blame] | 687 | // Remove all local and remote senders of type |media_type|. |
deadbeef | faac497 | 2015-11-12 15:33:07 -0800 | [diff] [blame] | 688 | // Called when a media type is rejected (m-line set to port 0). |
Karl Wiberg | 744310f | 2019-02-14 10:18:56 +0100 | [diff] [blame] | 689 | void RemoveSenders(cricket::MediaType media_type) |
| 690 | RTC_RUN_ON(signaling_thread()); |
deadbeef | faac497 | 2015-11-12 15:33:07 -0800 | [diff] [blame] | 691 | |
deadbeef | bda7e0b | 2015-12-08 17:13:40 -0800 | [diff] [blame] | 692 | // Makes sure a MediaStreamTrack is created for each StreamParam in |streams|, |
| 693 | // and existing MediaStreamTracks are removed if there is no corresponding |
| 694 | // StreamParam. If |default_track_needed| is true, a default MediaStreamTrack |
| 695 | // is created if it doesn't exist; if false, it's removed if it exists. |
| 696 | // |media_type| is the type of the |streams| and can be either audio or video. |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 697 | // If a new MediaStream is created it is added to |new_streams|. |
Steve Anton | 4171afb | 2017-11-20 10:20:22 -0800 | [diff] [blame] | 698 | void UpdateRemoteSendersList( |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 699 | const std::vector<cricket::StreamParams>& streams, |
deadbeef | bda7e0b | 2015-12-08 17:13:40 -0800 | [diff] [blame] | 700 | bool default_track_needed, |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 701 | cricket::MediaType media_type, |
Karl Wiberg | 744310f | 2019-02-14 10:18:56 +0100 | [diff] [blame] | 702 | StreamCollection* new_streams) RTC_RUN_ON(signaling_thread()); |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 703 | |
Steve Anton | 4171afb | 2017-11-20 10:20:22 -0800 | [diff] [blame] | 704 | // Triggered when a remote sender has been seen for the first time in a remote |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 705 | // session description. It creates a remote MediaStreamTrackInterface |
| 706 | // implementation and triggers CreateAudioReceiver or CreateVideoReceiver. |
Steve Anton | 4171afb | 2017-11-20 10:20:22 -0800 | [diff] [blame] | 707 | void OnRemoteSenderAdded(const RtpSenderInfo& sender_info, |
Karl Wiberg | 744310f | 2019-02-14 10:18:56 +0100 | [diff] [blame] | 708 | cricket::MediaType media_type) |
| 709 | RTC_RUN_ON(signaling_thread()); |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 710 | |
Steve Anton | 4171afb | 2017-11-20 10:20:22 -0800 | [diff] [blame] | 711 | // Triggered when a remote sender has been removed from a remote session |
| 712 | // description. It removes the remote sender with id |sender_id| from a remote |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 713 | // MediaStream and triggers DestroyAudioReceiver or DestroyVideoReceiver. |
Steve Anton | 4171afb | 2017-11-20 10:20:22 -0800 | [diff] [blame] | 714 | void OnRemoteSenderRemoved(const RtpSenderInfo& sender_info, |
Karl Wiberg | 744310f | 2019-02-14 10:18:56 +0100 | [diff] [blame] | 715 | cricket::MediaType media_type) |
| 716 | RTC_RUN_ON(signaling_thread()); |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 717 | |
| 718 | // Finds remote MediaStreams without any tracks and removes them from |
| 719 | // |remote_streams_| and notifies the observer that the MediaStreams no longer |
| 720 | // exist. |
Karl Wiberg | 744310f | 2019-02-14 10:18:56 +0100 | [diff] [blame] | 721 | void UpdateEndedRemoteMediaStreams() RTC_RUN_ON(signaling_thread()); |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 722 | |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 723 | // Loops through the vector of |streams| and finds added and removed |
| 724 | // StreamParams since last time this method was called. |
Steve Anton | 4171afb | 2017-11-20 10:20:22 -0800 | [diff] [blame] | 725 | // For each new or removed StreamParam, OnLocalSenderSeen or |
| 726 | // OnLocalSenderRemoved is invoked. |
| 727 | void UpdateLocalSenders(const std::vector<cricket::StreamParams>& streams, |
Karl Wiberg | 5966c50 | 2019-02-21 23:55:09 +0100 | [diff] [blame] | 728 | cricket::MediaType media_type) |
| 729 | RTC_RUN_ON(signaling_thread()); |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 730 | |
Steve Anton | 4171afb | 2017-11-20 10:20:22 -0800 | [diff] [blame] | 731 | // Triggered when a local sender has been seen for the first time in a local |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 732 | // session description. |
| 733 | // This method triggers CreateAudioSender or CreateVideoSender if the rtp |
| 734 | // streams in the local SessionDescription can be mapped to a MediaStreamTrack |
| 735 | // in a MediaStream in |local_streams_| |
Steve Anton | 4171afb | 2017-11-20 10:20:22 -0800 | [diff] [blame] | 736 | void OnLocalSenderAdded(const RtpSenderInfo& sender_info, |
Karl Wiberg | 5966c50 | 2019-02-21 23:55:09 +0100 | [diff] [blame] | 737 | cricket::MediaType media_type) |
| 738 | RTC_RUN_ON(signaling_thread()); |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 739 | |
Steve Anton | 4171afb | 2017-11-20 10:20:22 -0800 | [diff] [blame] | 740 | // Triggered when a local sender has been removed from a local session |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 741 | // description. |
| 742 | // This method triggers DestroyAudioSender or DestroyVideoSender if a stream |
| 743 | // has been removed from the local SessionDescription and the stream can be |
| 744 | // mapped to a MediaStreamTrack in a MediaStream in |local_streams_|. |
Steve Anton | 4171afb | 2017-11-20 10:20:22 -0800 | [diff] [blame] | 745 | void OnLocalSenderRemoved(const RtpSenderInfo& sender_info, |
Karl Wiberg | a58e169 | 2019-03-26 13:33:43 +0100 | [diff] [blame] | 746 | cricket::MediaType media_type) |
| 747 | RTC_RUN_ON(signaling_thread()); |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 748 | |
Karl Wiberg | 85a4a93 | 2019-03-22 15:29:58 +0100 | [diff] [blame] | 749 | void UpdateLocalRtpDataChannels(const cricket::StreamParamsVec& streams) |
| 750 | RTC_RUN_ON(signaling_thread()); |
Karl Wiberg | 106d92d | 2019-02-14 10:17:47 +0100 | [diff] [blame] | 751 | void UpdateRemoteRtpDataChannels(const cricket::StreamParamsVec& streams) |
| 752 | RTC_RUN_ON(signaling_thread()); |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 753 | void UpdateClosingRtpDataChannels( |
| 754 | const std::vector<std::string>& active_channels, |
Karl Wiberg | 85a4a93 | 2019-03-22 15:29:58 +0100 | [diff] [blame] | 755 | bool is_local_update) RTC_RUN_ON(signaling_thread()); |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 756 | void CreateRemoteRtpDataChannel(const std::string& label, |
Karl Wiberg | 106d92d | 2019-02-14 10:17:47 +0100 | [diff] [blame] | 757 | uint32_t remote_ssrc) |
| 758 | RTC_RUN_ON(signaling_thread()); |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 759 | |
| 760 | // Creates channel and adds it to the collection of DataChannels that will |
| 761 | // be offered in a SessionDescription. |
| 762 | rtc::scoped_refptr<DataChannel> InternalCreateDataChannel( |
| 763 | const std::string& label, |
Karl Wiberg | 106d92d | 2019-02-14 10:17:47 +0100 | [diff] [blame] | 764 | const InternalDataChannelInit* config) RTC_RUN_ON(signaling_thread()); |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 765 | |
| 766 | // Checks if any data channel has been added. |
Karl Wiberg | 85a4a93 | 2019-03-22 15:29:58 +0100 | [diff] [blame] | 767 | bool HasDataChannels() const RTC_RUN_ON(signaling_thread()); |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 768 | |
Karl Wiberg | 85a4a93 | 2019-03-22 15:29:58 +0100 | [diff] [blame] | 769 | void AllocateSctpSids(rtc::SSLRole role) RTC_RUN_ON(signaling_thread()); |
| 770 | void OnSctpDataChannelClosed(DataChannel* channel) |
| 771 | RTC_RUN_ON(signaling_thread()); |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 772 | |
Karl Wiberg | 85a4a93 | 2019-03-22 15:29:58 +0100 | [diff] [blame] | 773 | void OnDataChannelDestroyed() RTC_RUN_ON(signaling_thread()); |
Steve Anton | ba81867 | 2017-11-06 10:21:57 -0800 | [diff] [blame] | 774 | // Called when a valid data channel OPEN message is received. |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 775 | void OnDataChannelOpenMessage(const std::string& label, |
Karl Wiberg | 106d92d | 2019-02-14 10:17:47 +0100 | [diff] [blame] | 776 | const InternalDataChannelInit& config) |
| 777 | RTC_RUN_ON(signaling_thread()); |
| 778 | |
Bjorn Mellem | 175aa2e | 2018-11-08 11:23:22 -0800 | [diff] [blame] | 779 | // Parses and handles open messages. Returns true if the message is an open |
| 780 | // message, false otherwise. |
| 781 | bool HandleOpenMessage_s(const cricket::ReceiveDataParams& params, |
| 782 | const rtc::CopyOnWriteBuffer& buffer) |
| 783 | RTC_RUN_ON(signaling_thread()); |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 784 | |
Steve Anton | 4171afb | 2017-11-20 10:20:22 -0800 | [diff] [blame] | 785 | // Returns true if the PeerConnection is configured to use Unified Plan |
| 786 | // semantics for creating offers/answers and setting local/remote |
| 787 | // descriptions. If this is true the RtpTransceiver API will also be available |
| 788 | // to the user. If this is false, Plan B semantics are assumed. |
Steve Anton | 79e7960 | 2017-11-20 10:25:56 -0800 | [diff] [blame] | 789 | // TODO(bugs.webrtc.org/8530): Flip the default to be Unified Plan once |
| 790 | // sufficient time has passed. |
Karl Wiberg | 5966c50 | 2019-02-21 23:55:09 +0100 | [diff] [blame] | 791 | bool IsUnifiedPlan() const RTC_RUN_ON(signaling_thread()) { |
Steve Anton | 79e7960 | 2017-11-20 10:25:56 -0800 | [diff] [blame] | 792 | return configuration_.sdp_semantics == SdpSemantics::kUnifiedPlan; |
| 793 | } |
Steve Anton | 4171afb | 2017-11-20 10:20:22 -0800 | [diff] [blame] | 794 | |
Steve Anton | 06817cd | 2018-12-18 15:55:30 -0800 | [diff] [blame] | 795 | // The offer/answer machinery assumes the media section MID is present and |
| 796 | // unique. To support legacy end points that do not supply a=mid lines, this |
| 797 | // method will modify the session description to add MIDs generated according |
| 798 | // to the SDP semantics. |
Karl Wiberg | 5966c50 | 2019-02-21 23:55:09 +0100 | [diff] [blame] | 799 | void FillInMissingRemoteMids(cricket::SessionDescription* remote_description) |
| 800 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | 06817cd | 2018-12-18 15:55:30 -0800 | [diff] [blame] | 801 | |
Steve Anton | 4171afb | 2017-11-20 10:20:22 -0800 | [diff] [blame] | 802 | // Is there an RtpSender of the given type? |
Karl Wiberg | 5966c50 | 2019-02-21 23:55:09 +0100 | [diff] [blame] | 803 | bool HasRtpSender(cricket::MediaType type) const |
| 804 | RTC_RUN_ON(signaling_thread()); |
deadbeef | fac0655 | 2015-11-25 11:26:01 -0800 | [diff] [blame] | 805 | |
Steve Anton | 4171afb | 2017-11-20 10:20:22 -0800 | [diff] [blame] | 806 | // Return the RtpSender with the given track attached. |
| 807 | rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>> |
Karl Wiberg | a58e169 | 2019-03-26 13:33:43 +0100 | [diff] [blame] | 808 | FindSenderForTrack(MediaStreamTrackInterface* track) const |
| 809 | RTC_RUN_ON(signaling_thread()); |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 810 | |
Steve Anton | 4171afb | 2017-11-20 10:20:22 -0800 | [diff] [blame] | 811 | // Return the RtpSender with the given id, or null if none exists. |
| 812 | rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>> |
Karl Wiberg | a58e169 | 2019-03-26 13:33:43 +0100 | [diff] [blame] | 813 | FindSenderById(const std::string& sender_id) const |
| 814 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | 4171afb | 2017-11-20 10:20:22 -0800 | [diff] [blame] | 815 | |
| 816 | // Return the RtpReceiver with the given id, or null if none exists. |
| 817 | rtc::scoped_refptr<RtpReceiverProxyWithInternal<RtpReceiverInternal>> |
Karl Wiberg | a58e169 | 2019-03-26 13:33:43 +0100 | [diff] [blame] | 818 | FindReceiverById(const std::string& receiver_id) const |
| 819 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | 4171afb | 2017-11-20 10:20:22 -0800 | [diff] [blame] | 820 | |
| 821 | std::vector<RtpSenderInfo>* GetRemoteSenderInfos( |
| 822 | cricket::MediaType media_type); |
| 823 | std::vector<RtpSenderInfo>* GetLocalSenderInfos( |
| 824 | cricket::MediaType media_type); |
| 825 | const RtpSenderInfo* FindSenderInfo(const std::vector<RtpSenderInfo>& infos, |
Emircan Uysaler | bc609ea | 2018-03-27 21:57:18 +0000 | [diff] [blame] | 826 | const std::string& stream_id, |
Steve Anton | 4171afb | 2017-11-20 10:20:22 -0800 | [diff] [blame] | 827 | const std::string sender_id) const; |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 828 | |
| 829 | // Returns the specified SCTP DataChannel in sctp_data_channels_, |
| 830 | // or nullptr if not found. |
Karl Wiberg | 85a4a93 | 2019-03-22 15:29:58 +0100 | [diff] [blame] | 831 | DataChannel* FindDataChannelBySid(int sid) const |
| 832 | RTC_RUN_ON(signaling_thread()); |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 833 | |
Taylor Brandstetter | a1c3035 | 2016-05-13 08:15:11 -0700 | [diff] [blame] | 834 | // Called when first configuring the port allocator. |
Karl Wiberg | fb3be39 | 2019-03-22 14:13:22 +0100 | [diff] [blame] | 835 | struct InitializePortAllocatorResult { |
| 836 | bool enable_ipv6; |
| 837 | }; |
| 838 | InitializePortAllocatorResult InitializePortAllocator_n( |
Harald Alvestrand | b2a7478 | 2018-06-28 13:54:07 +0200 | [diff] [blame] | 839 | const cricket::ServerAddresses& stun_servers, |
| 840 | const std::vector<cricket::RelayServerConfig>& turn_servers, |
| 841 | const RTCConfiguration& configuration); |
deadbeef | 293e926 | 2017-01-11 12:28:30 -0800 | [diff] [blame] | 842 | // Called when SetConfiguration is called to apply the supported subset |
| 843 | // of the configuration on the network thread. |
| 844 | bool ReconfigurePortAllocator_n( |
| 845 | const cricket::ServerAddresses& stun_servers, |
| 846 | const std::vector<cricket::RelayServerConfig>& turn_servers, |
| 847 | IceTransportsType type, |
| 848 | int candidate_pool_size, |
Jonas Oreland | bdcee28 | 2017-10-10 14:01:40 +0200 | [diff] [blame] | 849 | bool prune_turn_ports, |
Qingsi Wang | db53f8e | 2018-02-20 14:45:49 -0800 | [diff] [blame] | 850 | webrtc::TurnCustomizer* turn_customizer, |
Karl Wiberg | 739506e | 2019-04-03 11:37:28 +0200 | [diff] [blame] | 851 | absl::optional<int> stun_candidate_keepalive_interval, |
| 852 | bool have_local_description); |
Taylor Brandstetter | a1c3035 | 2016-05-13 08:15:11 -0700 | [diff] [blame] | 853 | |
Elad Alon | 99c3fe5 | 2017-10-13 16:29:40 +0200 | [diff] [blame] | 854 | // Starts output of an RTC event log to the given output object. |
ivoc | 14d5dbe | 2016-07-04 07:06:55 -0700 | [diff] [blame] | 855 | // This function should only be called from the worker thread. |
Bjorn Terelius | de93943 | 2017-11-20 17:38:14 +0100 | [diff] [blame] | 856 | bool StartRtcEventLog_w(std::unique_ptr<RtcEventLogOutput> output, |
| 857 | int64_t output_period_ms); |
Elad Alon | 99c3fe5 | 2017-10-13 16:29:40 +0200 | [diff] [blame] | 858 | |
Elad Alon | acb2417 | 2017-10-06 14:32:13 +0200 | [diff] [blame] | 859 | // Stops recording an RTC event log. |
ivoc | 14d5dbe | 2016-07-04 07:06:55 -0700 | [diff] [blame] | 860 | // This function should only be called from the worker thread. |
| 861 | void StopRtcEventLog_w(); |
| 862 | |
Steve Anton | 038834f | 2017-07-14 15:59:59 -0700 | [diff] [blame] | 863 | // Ensures the configuration doesn't have any parameters with invalid values, |
| 864 | // or values that conflict with other parameters. |
| 865 | // |
| 866 | // Returns RTCError::OK() if there are no issues. |
| 867 | RTCError ValidateConfiguration(const RTCConfiguration& config) const; |
| 868 | |
Steve Anton | ba81867 | 2017-11-06 10:21:57 -0800 | [diff] [blame] | 869 | cricket::ChannelManager* channel_manager() const; |
Steve Anton | ba81867 | 2017-11-06 10:21:57 -0800 | [diff] [blame] | 870 | |
Steve Anton | f847081 | 2017-12-04 10:46:21 -0800 | [diff] [blame] | 871 | enum class SessionError { |
| 872 | kNone, // No error. |
| 873 | kContent, // Error in BaseChannel SetLocalContent/SetRemoteContent. |
| 874 | kTransport, // Error from the underlying transport. |
| 875 | }; |
| 876 | |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 877 | // Returns the last error in the session. See the enum above for details. |
Karl Wiberg | a58e169 | 2019-03-26 13:33:43 +0100 | [diff] [blame] | 878 | SessionError session_error() const RTC_RUN_ON(signaling_thread()) { |
| 879 | return session_error_; |
| 880 | } |
Steve Anton | f847081 | 2017-12-04 10:46:21 -0800 | [diff] [blame] | 881 | const std::string& session_error_desc() const { return session_error_desc_; } |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 882 | |
Amit Hilbuch | dd9390c | 2018-11-13 16:26:05 -0800 | [diff] [blame] | 883 | cricket::ChannelInterface* GetChannel(const std::string& content_name); |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 884 | |
| 885 | // Get current SSL role used by SCTP's underlying transport. |
| 886 | bool GetSctpSslRole(rtc::SSLRole* role); |
| 887 | |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 888 | cricket::IceConfig ParseIceConfig( |
| 889 | const PeerConnectionInterface::RTCConfiguration& config) const; |
| 890 | |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 891 | // Implements DataChannelProviderInterface. |
| 892 | bool SendData(const cricket::SendDataParams& params, |
| 893 | const rtc::CopyOnWriteBuffer& payload, |
| 894 | cricket::SendDataResult* result) override; |
| 895 | bool ConnectDataChannel(DataChannel* webrtc_data_channel) override; |
| 896 | void DisconnectDataChannel(DataChannel* webrtc_data_channel) override; |
| 897 | void AddSctpDataStream(int sid) override; |
| 898 | void RemoveSctpDataStream(int sid) override; |
| 899 | bool ReadyToSendData() const override; |
| 900 | |
| 901 | cricket::DataChannelType data_channel_type() const; |
| 902 | |
Bjorn Mellem | 175aa2e | 2018-11-08 11:23:22 -0800 | [diff] [blame] | 903 | // Implements DataChannelSink. |
| 904 | void OnDataReceived(int channel_id, |
| 905 | DataMessageType type, |
| 906 | const rtc::CopyOnWriteBuffer& buffer) override; |
| 907 | void OnChannelClosing(int channel_id) override; |
| 908 | void OnChannelClosed(int channel_id) override; |
| 909 | |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 910 | // Called when an RTCCertificate is generated or retrieved by |
| 911 | // WebRTCSessionDescriptionFactory. Should happen before setLocalDescription. |
| 912 | void OnCertificateReady( |
| 913 | const rtc::scoped_refptr<rtc::RTCCertificate>& certificate); |
| 914 | void OnDtlsSrtpSetupFailure(cricket::BaseChannel*, bool rtcp); |
| 915 | |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 916 | // Non-const versions of local_description()/remote_description(), for use |
| 917 | // internally. |
Karl Wiberg | 739506e | 2019-04-03 11:37:28 +0200 | [diff] [blame] | 918 | SessionDescriptionInterface* mutable_local_description() |
| 919 | RTC_RUN_ON(signaling_thread()) { |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 920 | return pending_local_description_ ? pending_local_description_.get() |
| 921 | : current_local_description_.get(); |
| 922 | } |
Karl Wiberg | 739506e | 2019-04-03 11:37:28 +0200 | [diff] [blame] | 923 | SessionDescriptionInterface* mutable_remote_description() |
| 924 | RTC_RUN_ON(signaling_thread()) { |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 925 | return pending_remote_description_ ? pending_remote_description_.get() |
| 926 | : current_remote_description_.get(); |
| 927 | } |
| 928 | |
| 929 | // Updates the error state, signaling if necessary. |
Steve Anton | f847081 | 2017-12-04 10:46:21 -0800 | [diff] [blame] | 930 | void SetSessionError(SessionError error, const std::string& error_desc); |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 931 | |
Zhi Huang | e830e68 | 2018-03-30 10:48:35 -0700 | [diff] [blame] | 932 | RTCError UpdateSessionState(SdpType type, |
| 933 | cricket::ContentSource source, |
| 934 | const cricket::SessionDescription* description); |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 935 | // Push the media parts of the local or remote session description |
| 936 | // down to all of the channels. |
Karl Wiberg | 5966c50 | 2019-02-21 23:55:09 +0100 | [diff] [blame] | 937 | RTCError PushdownMediaDescription(SdpType type, cricket::ContentSource source) |
| 938 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 939 | |
Steve Anton | 8a00691 | 2017-12-04 15:25:56 -0800 | [diff] [blame] | 940 | RTCError PushdownTransportDescription(cricket::ContentSource source, |
Steve Anton | 3828c06 | 2017-12-06 10:34:51 -0800 | [diff] [blame] | 941 | SdpType type); |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 942 | |
| 943 | // Returns true and the TransportInfo of the given |content_name| |
| 944 | // from |description|. Returns false if it's not available. |
| 945 | static bool GetTransportDescription( |
| 946 | const cricket::SessionDescription* description, |
| 947 | const std::string& content_name, |
| 948 | cricket::TransportDescription* info); |
| 949 | |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 950 | // Enables media channels to allow sending of media. |
Steve Anton | ed10bd9 | 2017-12-05 10:52:59 -0800 | [diff] [blame] | 951 | // This enables media to flow on all configured audio/video channels and the |
| 952 | // RtpDataChannel. |
Karl Wiberg | a58e169 | 2019-03-26 13:33:43 +0100 | [diff] [blame] | 953 | void EnableSending() RTC_RUN_ON(signaling_thread()); |
Steve Anton | 3fe1b15 | 2017-12-12 10:20:08 -0800 | [diff] [blame] | 954 | |
Steve Anton | 8af2186 | 2017-12-15 11:20:13 -0800 | [diff] [blame] | 955 | // Destroys all BaseChannels and destroys the SCTP data channel, if present. |
Karl Wiberg | 85a4a93 | 2019-03-22 15:29:58 +0100 | [diff] [blame] | 956 | void DestroyAllChannels() RTC_RUN_ON(signaling_thread()); |
Steve Anton | 3fe1b15 | 2017-12-12 10:20:08 -0800 | [diff] [blame] | 957 | |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 958 | // Returns the media index for a local ice candidate given the content name. |
| 959 | // Returns false if the local session description does not have a media |
| 960 | // content called |content_name|. |
| 961 | bool GetLocalCandidateMediaIndex(const std::string& content_name, |
Karl Wiberg | 739506e | 2019-04-03 11:37:28 +0200 | [diff] [blame] | 962 | int* sdp_mline_index) |
| 963 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 964 | // Uses all remote candidates in |remote_desc| in this session. |
| 965 | bool UseCandidatesInSessionDescription( |
Karl Wiberg | 744310f | 2019-02-14 10:18:56 +0100 | [diff] [blame] | 966 | const SessionDescriptionInterface* remote_desc) |
| 967 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 968 | // Uses |candidate| in this session. |
Karl Wiberg | 744310f | 2019-02-14 10:18:56 +0100 | [diff] [blame] | 969 | bool UseCandidate(const IceCandidateInterface* candidate) |
| 970 | RTC_RUN_ON(signaling_thread()); |
Guido Urdaneta | 4163317 | 2019-05-23 20:12:29 +0200 | [diff] [blame] | 971 | RTCErrorOr<const cricket::ContentInfo*> FindContentInfo( |
| 972 | const SessionDescriptionInterface* description, |
| 973 | const IceCandidateInterface* candidate) RTC_RUN_ON(signaling_thread()); |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 974 | // Deletes the corresponding channel of contents that don't exist in |desc|. |
| 975 | // |desc| can be null. This means that all channels are deleted. |
Karl Wiberg | 5966c50 | 2019-02-21 23:55:09 +0100 | [diff] [blame] | 976 | void RemoveUnusedChannels(const cricket::SessionDescription* desc) |
| 977 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 978 | |
| 979 | // Allocates media channels based on the |desc|. If |desc| doesn't have |
| 980 | // the BUNDLE option, this method will disable BUNDLE in PortAllocator. |
| 981 | // This method will also delete any existing media channels before creating. |
Karl Wiberg | 5966c50 | 2019-02-21 23:55:09 +0100 | [diff] [blame] | 982 | RTCError CreateChannels(const cricket::SessionDescription& desc) |
| 983 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | dcc3c02 | 2017-12-22 16:02:54 -0800 | [diff] [blame] | 984 | |
| 985 | // If the BUNDLE policy is max-bundle, then we know for sure that all |
| 986 | // transports will be bundled from the start. This method returns the BUNDLE |
| 987 | // group if that's the case, or null if BUNDLE will be negotiated later. An |
| 988 | // error is returned if max-bundle is specified but the session description |
| 989 | // does not have a BUNDLE group. |
| 990 | RTCErrorOr<const cricket::ContentGroup*> GetEarlyBundleGroup( |
Karl Wiberg | 5966c50 | 2019-02-21 23:55:09 +0100 | [diff] [blame] | 991 | const cricket::SessionDescription& desc) const |
| 992 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 993 | |
| 994 | // Helper methods to create media channels. |
Karl Wiberg | 5966c50 | 2019-02-21 23:55:09 +0100 | [diff] [blame] | 995 | cricket::VoiceChannel* CreateVoiceChannel(const std::string& mid) |
| 996 | RTC_RUN_ON(signaling_thread()); |
| 997 | cricket::VideoChannel* CreateVideoChannel(const std::string& mid) |
| 998 | RTC_RUN_ON(signaling_thread()); |
| 999 | bool CreateDataChannel(const std::string& mid) RTC_RUN_ON(signaling_thread()); |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 1000 | |
Zhi Huang | e830e68 | 2018-03-30 10:48:35 -0700 | [diff] [blame] | 1001 | bool CreateSctpTransport_n(const std::string& mid); |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 1002 | // For bundling. |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 1003 | void DestroySctpTransport_n(); |
| 1004 | // SctpTransport signal handlers. Needed to marshal signals from the network |
| 1005 | // to signaling thread. |
| 1006 | void OnSctpTransportReadyToSendData_n(); |
| 1007 | // This may be called with "false" if the direction of the m= section causes |
| 1008 | // us to tear down the SCTP connection. |
| 1009 | void OnSctpTransportReadyToSendData_s(bool ready); |
| 1010 | void OnSctpTransportDataReceived_n(const cricket::ReceiveDataParams& params, |
| 1011 | const rtc::CopyOnWriteBuffer& payload); |
| 1012 | // Beyond just firing the signal to the signaling thread, listens to SCTP |
| 1013 | // CONTROL messages on unused SIDs and processes them as OPEN messages. |
| 1014 | void OnSctpTransportDataReceived_s(const cricket::ReceiveDataParams& params, |
| 1015 | const rtc::CopyOnWriteBuffer& payload); |
Taylor Brandstetter | cdd05f0 | 2018-05-31 13:23:32 -0700 | [diff] [blame] | 1016 | void OnSctpClosingProcedureStartedRemotely_n(int sid); |
| 1017 | void OnSctpClosingProcedureComplete_n(int sid); |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 1018 | |
Bjorn Mellem | 175aa2e | 2018-11-08 11:23:22 -0800 | [diff] [blame] | 1019 | bool SetupMediaTransportForDataChannels_n(const std::string& mid) |
| 1020 | RTC_RUN_ON(network_thread()); |
| 1021 | void OnMediaTransportStateChanged_n() RTC_RUN_ON(network_thread()); |
| 1022 | void TeardownMediaTransportForDataChannels_n() RTC_RUN_ON(network_thread()); |
| 1023 | |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 1024 | bool ValidateBundleSettings(const cricket::SessionDescription* desc); |
| 1025 | bool HasRtcpMuxEnabled(const cricket::ContentInfo* content); |
| 1026 | // Below methods are helper methods which verifies SDP. |
Steve Anton | 8a00691 | 2017-12-04 15:25:56 -0800 | [diff] [blame] | 1027 | RTCError ValidateSessionDescription(const SessionDescriptionInterface* sdesc, |
Karl Wiberg | 5966c50 | 2019-02-21 23:55:09 +0100 | [diff] [blame] | 1028 | cricket::ContentSource source) |
| 1029 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 1030 | |
Steve Anton | 3828c06 | 2017-12-06 10:34:51 -0800 | [diff] [blame] | 1031 | // Check if a call to SetLocalDescription is acceptable with a session |
| 1032 | // description of the given type. |
| 1033 | bool ExpectSetLocalDescription(SdpType type); |
| 1034 | // Check if a call to SetRemoteDescription is acceptable with a session |
| 1035 | // description of the given type. |
| 1036 | bool ExpectSetRemoteDescription(SdpType type); |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 1037 | // Verifies a=setup attribute as per RFC 5763. |
| 1038 | bool ValidateDtlsSetupAttribute(const cricket::SessionDescription* desc, |
Steve Anton | 3828c06 | 2017-12-06 10:34:51 -0800 | [diff] [blame] | 1039 | SdpType type); |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 1040 | |
| 1041 | // Returns true if we are ready to push down the remote candidate. |
| 1042 | // |remote_desc| is the new remote description, or NULL if the current remote |
| 1043 | // description should be used. Output |valid| is true if the candidate media |
| 1044 | // index is valid. |
| 1045 | bool ReadyToUseRemoteCandidate(const IceCandidateInterface* candidate, |
| 1046 | const SessionDescriptionInterface* remote_desc, |
Karl Wiberg | a58e169 | 2019-03-26 13:33:43 +0100 | [diff] [blame] | 1047 | bool* valid) RTC_RUN_ON(signaling_thread()); |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 1048 | |
| 1049 | // Returns true if SRTP (either using DTLS-SRTP or SDES) is required by |
| 1050 | // this session. |
Karl Wiberg | 739506e | 2019-04-03 11:37:28 +0200 | [diff] [blame] | 1051 | bool SrtpRequired() const RTC_RUN_ON(signaling_thread()); |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 1052 | |
Zhi Huang | e830e68 | 2018-03-30 10:48:35 -0700 | [diff] [blame] | 1053 | // JsepTransportController signal handlers. |
Karl Wiberg | 744310f | 2019-02-14 10:18:56 +0100 | [diff] [blame] | 1054 | void OnTransportControllerConnectionState(cricket::IceConnectionState state) |
| 1055 | RTC_RUN_ON(signaling_thread()); |
| 1056 | void OnTransportControllerGatheringState(cricket::IceGatheringState state) |
| 1057 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 1058 | void OnTransportControllerCandidatesGathered( |
| 1059 | const std::string& transport_name, |
Karl Wiberg | 744310f | 2019-02-14 10:18:56 +0100 | [diff] [blame] | 1060 | const std::vector<cricket::Candidate>& candidates) |
| 1061 | RTC_RUN_ON(signaling_thread()); |
Eldar Rello | da13ea2 | 2019-06-01 12:23:43 +0300 | [diff] [blame] | 1062 | void OnTransportControllerCandidateError( |
| 1063 | const cricket::IceCandidateErrorEvent& event) |
| 1064 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 1065 | void OnTransportControllerCandidatesRemoved( |
Karl Wiberg | 744310f | 2019-02-14 10:18:56 +0100 | [diff] [blame] | 1066 | const std::vector<cricket::Candidate>& candidates) |
| 1067 | RTC_RUN_ON(signaling_thread()); |
Alex Drake | 00c7ecf | 2019-08-06 10:54:47 -0700 | [diff] [blame] | 1068 | void OnTransportControllerCandidateChanged( |
| 1069 | const cricket::CandidatePairChangeEvent& event) |
| 1070 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 1071 | void OnTransportControllerDtlsHandshakeError(rtc::SSLHandshakeError error); |
| 1072 | |
Steve Anton | f847081 | 2017-12-04 10:46:21 -0800 | [diff] [blame] | 1073 | const char* SessionErrorToString(SessionError error) const; |
Karl Wiberg | a58e169 | 2019-03-26 13:33:43 +0100 | [diff] [blame] | 1074 | std::string GetSessionErrorMsg() RTC_RUN_ON(signaling_thread()); |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 1075 | |
Steve Anton | 8e20f17 | 2018-03-06 10:55:04 -0800 | [diff] [blame] | 1076 | // Report the UMA metric SdpFormatReceived for the given remote offer. |
| 1077 | void ReportSdpFormatReceived(const SessionDescriptionInterface& remote_offer); |
| 1078 | |
Steve Anton | 0ffaaa2 | 2018-02-23 10:31:30 -0800 | [diff] [blame] | 1079 | // Report inferred negotiated SDP semantics from a local/remote answer to the |
| 1080 | // UMA observer. |
| 1081 | void ReportNegotiatedSdpSemantics(const SessionDescriptionInterface& answer); |
| 1082 | |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 1083 | // Invoked when TransportController connection completion is signaled. |
| 1084 | // Reports stats for all transports in use. |
Karl Wiberg | a58e169 | 2019-03-26 13:33:43 +0100 | [diff] [blame] | 1085 | void ReportTransportStats() RTC_RUN_ON(signaling_thread()); |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 1086 | |
| 1087 | // Gather the usage of IPv4/IPv6 as best connection. |
| 1088 | void ReportBestConnectionState(const cricket::TransportStats& stats); |
| 1089 | |
Steve Anton | c7b964c | 2018-02-01 14:39:45 -0800 | [diff] [blame] | 1090 | void ReportNegotiatedCiphers(const cricket::TransportStats& stats, |
Karl Wiberg | 739506e | 2019-04-03 11:37:28 +0200 | [diff] [blame] | 1091 | const std::set<cricket::MediaType>& media_types) |
| 1092 | RTC_RUN_ON(signaling_thread()); |
Qingsi Wang | 1ba5dec | 2019-08-19 11:57:17 -0700 | [diff] [blame] | 1093 | void ReportIceCandidateCollected(const cricket::Candidate& candidate) |
| 1094 | RTC_RUN_ON(signaling_thread()); |
| 1095 | void ReportRemoteIceCandidateAdded(const cricket::Candidate& candidate) |
| 1096 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 1097 | |
Harald Alvestrand | 8ebba74 | 2018-05-31 14:00:34 +0200 | [diff] [blame] | 1098 | void NoteUsageEvent(UsageEvent event); |
Karl Wiberg | 744310f | 2019-02-14 10:18:56 +0100 | [diff] [blame] | 1099 | void ReportUsagePattern() const RTC_RUN_ON(signaling_thread()); |
Harald Alvestrand | 8ebba74 | 2018-05-31 14:00:34 +0200 | [diff] [blame] | 1100 | |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 1101 | void OnSentPacket_w(const rtc::SentPacket& sent_packet); |
| 1102 | |
Karl Wiberg | a58e169 | 2019-03-26 13:33:43 +0100 | [diff] [blame] | 1103 | const std::string GetTransportName(const std::string& content_name) |
| 1104 | RTC_RUN_ON(signaling_thread()); |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 1105 | |
Steve Anton | 6fec880 | 2017-12-04 10:37:29 -0800 | [diff] [blame] | 1106 | // Destroys and clears the BaseChannel associated with the given transceiver, |
| 1107 | // if such channel is set. |
| 1108 | void DestroyTransceiverChannel( |
| 1109 | rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>> |
| 1110 | transceiver); |
| 1111 | |
| 1112 | // Destroys the RTP data channel and/or the SCTP data channel and clears it. |
Karl Wiberg | 85a4a93 | 2019-03-22 15:29:58 +0100 | [diff] [blame] | 1113 | void DestroyDataChannel() RTC_RUN_ON(signaling_thread()); |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 1114 | |
Amit Hilbuch | dd9390c | 2018-11-13 16:26:05 -0800 | [diff] [blame] | 1115 | // Destroys the given ChannelInterface. |
| 1116 | // The channel cannot be accessed after this method is called. |
| 1117 | void DestroyChannelInterface(cricket::ChannelInterface* channel); |
Steve Anton | 6fec880 | 2017-12-04 10:37:29 -0800 | [diff] [blame] | 1118 | |
Zhi Huang | 365381f | 2018-04-13 16:44:34 -0700 | [diff] [blame] | 1119 | // JsepTransportController::Observer override. |
Taylor Brandstetter | cbaa254 | 2018-04-16 16:42:14 -0700 | [diff] [blame] | 1120 | // |
| 1121 | // Called by |transport_controller_| when processing transport information |
| 1122 | // from a session description, and the mapping from m= sections to transports |
| 1123 | // changed (as a result of BUNDLE negotiation, or m= sections being |
| 1124 | // rejected). |
Piotr (Peter) Slatala | cc8e8bb | 2018-11-15 08:26:19 -0800 | [diff] [blame] | 1125 | bool OnTransportChanged(const std::string& mid, |
| 1126 | RtpTransportInternal* rtp_transport, |
Harald Alvestrand | c85328f | 2019-02-28 07:51:00 +0100 | [diff] [blame] | 1127 | rtc::scoped_refptr<DtlsTransport> dtls_transport, |
Karl Wiberg | ac02589 | 2019-03-26 13:08:37 +0100 | [diff] [blame] | 1128 | MediaTransportInterface* media_transport) override; |
Zhi Huang | e830e68 | 2018-03-30 10:48:35 -0700 | [diff] [blame] | 1129 | |
Guido Urdaneta | 1ff16c8 | 2019-05-20 19:31:53 +0200 | [diff] [blame] | 1130 | // RtpSenderBase::SetStreamsObserver override. |
| 1131 | void OnSetStreams() override; |
| 1132 | |
Harald Alvestrand | 7a1c7f7 | 2018-08-01 10:50:16 +0200 | [diff] [blame] | 1133 | // Returns the observer. Will crash on CHECK if the observer is removed. |
Karl Wiberg | 744310f | 2019-02-14 10:18:56 +0100 | [diff] [blame] | 1134 | PeerConnectionObserver* Observer() const RTC_RUN_ON(signaling_thread()); |
Harald Alvestrand | 7a1c7f7 | 2018-08-01 10:50:16 +0200 | [diff] [blame] | 1135 | |
Benjamin Wright | 8c27cca | 2018-10-25 10:16:44 -0700 | [diff] [blame] | 1136 | // Returns the CryptoOptions for this PeerConnection. This will always |
| 1137 | // return the RTCConfiguration.crypto_options if set and will only default |
| 1138 | // back to the PeerConnectionFactory settings if nothing was set. |
Karl Wiberg | 5966c50 | 2019-02-21 23:55:09 +0100 | [diff] [blame] | 1139 | CryptoOptions GetCryptoOptions() RTC_RUN_ON(signaling_thread()); |
Benjamin Wright | 8c27cca | 2018-10-25 10:16:44 -0700 | [diff] [blame] | 1140 | |
Anton Sukhanov | 98a462c | 2018-10-17 13:15:42 -0700 | [diff] [blame] | 1141 | // Returns rtp transport, result can not be nullptr. |
Karl Wiberg | 2cc368f | 2019-04-02 11:31:56 +0200 | [diff] [blame] | 1142 | RtpTransportInternal* GetRtpTransport(const std::string& mid) |
| 1143 | RTC_RUN_ON(signaling_thread()) { |
Anton Sukhanov | 98a462c | 2018-10-17 13:15:42 -0700 | [diff] [blame] | 1144 | auto rtp_transport = transport_controller_->GetRtpTransport(mid); |
| 1145 | RTC_DCHECK(rtp_transport); |
| 1146 | return rtp_transport; |
| 1147 | } |
| 1148 | |
Guido Urdaneta | 70c2db1 | 2019-04-16 12:24:14 +0200 | [diff] [blame] | 1149 | void UpdateNegotiationNeeded(); |
| 1150 | bool CheckIfNegotiationIsNeeded(); |
| 1151 | |
Karl Wiberg | 106d92d | 2019-02-14 10:17:47 +0100 | [diff] [blame] | 1152 | sigslot::signal1<DataChannel*> SignalDataChannelCreated_ |
| 1153 | RTC_GUARDED_BY(signaling_thread()); |
Steve Anton | 2d8609c | 2018-01-23 16:38:46 -0800 | [diff] [blame] | 1154 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1155 | // Storing the factory as a scoped reference pointer ensures that the memory |
| 1156 | // in the PeerConnectionFactoryImpl remains available as long as the |
| 1157 | // PeerConnection is running. It is passed to PeerConnection as a raw pointer. |
| 1158 | // However, since the reference counting is done in the |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 1159 | // PeerConnectionFactoryInterface all instances created using the raw pointer |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1160 | // will refer to the same reference count. |
Karl Wiberg | 744310f | 2019-02-14 10:18:56 +0100 | [diff] [blame] | 1161 | const rtc::scoped_refptr<PeerConnectionFactory> factory_; |
| 1162 | PeerConnectionObserver* observer_ RTC_GUARDED_BY(signaling_thread()) = |
| 1163 | nullptr; |
terelius | 3386025 | 2017-05-12 23:37:18 -0700 | [diff] [blame] | 1164 | |
| 1165 | // The EventLog needs to outlive |call_| (and any other object that uses it). |
Karl Wiberg | b03ab71 | 2019-02-14 11:59:57 +0100 | [diff] [blame] | 1166 | std::unique_ptr<RtcEventLog> event_log_ RTC_GUARDED_BY(worker_thread()); |
| 1167 | |
| 1168 | // Points to the same thing as `event_log_`. Since it's const, we may read the |
| 1169 | // pointer (but not touch the object) from any thread. |
| 1170 | RtcEventLog* const event_log_ptr_ RTC_PT_GUARDED_BY(worker_thread()); |
terelius | 3386025 | 2017-05-12 23:37:18 -0700 | [diff] [blame] | 1171 | |
Karl Wiberg | 8d2e228 | 2019-02-17 13:00:07 +0100 | [diff] [blame] | 1172 | SignalingState signaling_state_ RTC_GUARDED_BY(signaling_thread()) = kStable; |
| 1173 | IceConnectionState ice_connection_state_ RTC_GUARDED_BY(signaling_thread()) = |
| 1174 | kIceConnectionNew; |
| 1175 | PeerConnectionInterface::IceConnectionState standardized_ice_connection_state_ |
| 1176 | RTC_GUARDED_BY(signaling_thread()) = kIceConnectionNew; |
| 1177 | PeerConnectionInterface::PeerConnectionState connection_state_ |
| 1178 | RTC_GUARDED_BY(signaling_thread()) = PeerConnectionState::kNew; |
Jonas Olsson | 635474e | 2018-10-18 15:58:17 +0200 | [diff] [blame] | 1179 | |
Karl Wiberg | 8d2e228 | 2019-02-17 13:00:07 +0100 | [diff] [blame] | 1180 | IceGatheringState ice_gathering_state_ RTC_GUARDED_BY(signaling_thread()) = |
| 1181 | kIceGatheringNew; |
Karl Wiberg | 5966c50 | 2019-02-21 23:55:09 +0100 | [diff] [blame] | 1182 | PeerConnectionInterface::RTCConfiguration configuration_ |
| 1183 | RTC_GUARDED_BY(signaling_thread()); |
| 1184 | |
Bjorn A Mellem | 5985a04 | 2019-06-28 14:19:38 -0700 | [diff] [blame] | 1185 | // Field-trial based configuration for datagram transport. |
| 1186 | const DatagramTransportConfig datagram_transport_config_; |
| 1187 | |
| 1188 | // Final, resolved value for whether datagram transport is in use. |
| 1189 | bool use_datagram_transport_ RTC_GUARDED_BY(signaling_thread()) = false; |
| 1190 | |
Karl Wiberg | 5966c50 | 2019-02-21 23:55:09 +0100 | [diff] [blame] | 1191 | // Cache configuration_.use_media_transport so that we can access it from |
| 1192 | // other threads. |
| 1193 | // TODO(bugs.webrtc.org/9987): Caching just this bool and allowing the data |
| 1194 | // it's derived from to change is not necessarily sound. Stop doing it. |
| 1195 | rtc::RaceChecker use_media_transport_race_checker_; |
| 1196 | bool use_media_transport_ RTC_GUARDED_BY(use_media_transport_race_checker_) = |
| 1197 | configuration_.use_media_transport; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1198 | |
Zach Stein | e20867f | 2018-08-02 13:20:15 -0700 | [diff] [blame] | 1199 | // TODO(zstein): |async_resolver_factory_| can currently be nullptr if it |
| 1200 | // is not injected. It should be required once chromium supplies it. |
Karl Wiberg | fb3be39 | 2019-03-22 14:13:22 +0100 | [diff] [blame] | 1201 | std::unique_ptr<AsyncResolverFactory> async_resolver_factory_ |
| 1202 | RTC_GUARDED_BY(signaling_thread()); |
| 1203 | std::unique_ptr<cricket::PortAllocator> |
| 1204 | port_allocator_; // TODO(bugs.webrtc.org/9987): Accessed on both |
| 1205 | // signaling and network thread. |
| 1206 | std::unique_ptr<rtc::SSLCertificateVerifier> |
| 1207 | tls_cert_verifier_; // TODO(bugs.webrtc.org/9987): Accessed on both |
| 1208 | // signaling and network thread. |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 1209 | |
zhihuang | 8f65cdf | 2016-05-06 18:40:30 -0700 | [diff] [blame] | 1210 | // One PeerConnection has only one RTCP CNAME. |
| 1211 | // https://tools.ietf.org/html/draft-ietf-rtcweb-rtp-usage-26#section-4.9 |
Karl Wiberg | fb3be39 | 2019-03-22 14:13:22 +0100 | [diff] [blame] | 1212 | const std::string rtcp_cname_; |
zhihuang | 8f65cdf | 2016-05-06 18:40:30 -0700 | [diff] [blame] | 1213 | |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 1214 | // Streams added via AddStream. |
Karl Wiberg | 1e1e102 | 2019-03-22 14:27:22 +0100 | [diff] [blame] | 1215 | const rtc::scoped_refptr<StreamCollection> local_streams_ |
| 1216 | RTC_GUARDED_BY(signaling_thread()); |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 1217 | // Streams created as a result of SetRemoteDescription. |
Karl Wiberg | 1e1e102 | 2019-03-22 14:27:22 +0100 | [diff] [blame] | 1218 | const rtc::scoped_refptr<StreamCollection> remote_streams_ |
| 1219 | RTC_GUARDED_BY(signaling_thread()); |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 1220 | |
Karl Wiberg | 1e1e102 | 2019-03-22 14:27:22 +0100 | [diff] [blame] | 1221 | std::vector<std::unique_ptr<MediaStreamObserver>> stream_observers_ |
| 1222 | RTC_GUARDED_BY(signaling_thread()); |
deadbeef | eb45981 | 2015-12-15 19:24:43 -0800 | [diff] [blame] | 1223 | |
Steve Anton | 4171afb | 2017-11-20 10:20:22 -0800 | [diff] [blame] | 1224 | // These lists store sender info seen in local/remote descriptions. |
Karl Wiberg | c70999e | 2019-03-22 15:14:27 +0100 | [diff] [blame] | 1225 | std::vector<RtpSenderInfo> remote_audio_sender_infos_ |
| 1226 | RTC_GUARDED_BY(signaling_thread()); |
| 1227 | std::vector<RtpSenderInfo> remote_video_sender_infos_ |
| 1228 | RTC_GUARDED_BY(signaling_thread()); |
| 1229 | std::vector<RtpSenderInfo> local_audio_sender_infos_ |
| 1230 | RTC_GUARDED_BY(signaling_thread()); |
| 1231 | std::vector<RtpSenderInfo> local_video_sender_infos_ |
| 1232 | RTC_GUARDED_BY(signaling_thread()); |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 1233 | |
Karl Wiberg | 85a4a93 | 2019-03-22 15:29:58 +0100 | [diff] [blame] | 1234 | SctpSidAllocator sid_allocator_ RTC_GUARDED_BY(signaling_thread()); |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 1235 | // label -> DataChannel |
Karl Wiberg | 85a4a93 | 2019-03-22 15:29:58 +0100 | [diff] [blame] | 1236 | std::map<std::string, rtc::scoped_refptr<DataChannel>> rtp_data_channels_ |
| 1237 | RTC_GUARDED_BY(signaling_thread()); |
| 1238 | std::vector<rtc::scoped_refptr<DataChannel>> sctp_data_channels_ |
| 1239 | RTC_GUARDED_BY(signaling_thread()); |
| 1240 | std::vector<rtc::scoped_refptr<DataChannel>> sctp_data_channels_to_free_ |
| 1241 | RTC_GUARDED_BY(signaling_thread()); |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame] | 1242 | |
Karl Wiberg | 85a4a93 | 2019-03-22 15:29:58 +0100 | [diff] [blame] | 1243 | bool remote_peer_supports_msid_ RTC_GUARDED_BY(signaling_thread()) = false; |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 1244 | |
Karl Wiberg | ac02589 | 2019-03-26 13:08:37 +0100 | [diff] [blame] | 1245 | // The unique_ptr belongs to the worker thread, but the Call object manages |
| 1246 | // its own thread safety. |
Karl Wiberg | 6cab5c8 | 2019-03-26 09:57:01 +0100 | [diff] [blame] | 1247 | std::unique_ptr<Call> call_ RTC_GUARDED_BY(worker_thread()); |
| 1248 | |
| 1249 | // Points to the same thing as `call_`. Since it's const, we may read the |
Karl Wiberg | ac02589 | 2019-03-26 13:08:37 +0100 | [diff] [blame] | 1250 | // pointer from any thread. |
| 1251 | Call* const call_ptr_; |
Karl Wiberg | 6cab5c8 | 2019-03-26 09:57:01 +0100 | [diff] [blame] | 1252 | |
| 1253 | std::unique_ptr<StatsCollector> stats_ |
| 1254 | RTC_GUARDED_BY(signaling_thread()); // A pointer is passed to senders_ |
| 1255 | rtc::scoped_refptr<RTCStatsCollector> stats_collector_ |
| 1256 | RTC_GUARDED_BY(signaling_thread()); |
terelius | 3386025 | 2017-05-12 23:37:18 -0700 | [diff] [blame] | 1257 | |
deadbeef | a601f5c | 2016-06-06 14:27:39 -0700 | [diff] [blame] | 1258 | std::vector< |
Steve Anton | 4171afb | 2017-11-20 10:20:22 -0800 | [diff] [blame] | 1259 | rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>> |
Karl Wiberg | 2cc368f | 2019-04-02 11:31:56 +0200 | [diff] [blame] | 1260 | transceivers_; // TODO(bugs.webrtc.org/9987): Accessed on both signaling |
| 1261 | // and network thread. |
| 1262 | |
Henrik Boström | 5b14778 | 2018-12-04 11:25:05 +0100 | [diff] [blame] | 1263 | // In Unified Plan, if we encounter remote SDP that does not contain an a=msid |
| 1264 | // line we create and use a stream with a random ID for our receivers. This is |
| 1265 | // to support legacy endpoints that do not support the a=msid attribute (as |
| 1266 | // opposed to streamless tracks with "a=msid:-"). |
Karl Wiberg | a58e169 | 2019-03-26 13:33:43 +0100 | [diff] [blame] | 1267 | rtc::scoped_refptr<MediaStreamInterface> missing_msid_default_stream_ |
| 1268 | RTC_GUARDED_BY(signaling_thread()); |
Amit Hilbuch | ae3df54 | 2019-01-07 12:13:08 -0800 | [diff] [blame] | 1269 | // MIDs will be generated using this generator which will keep track of |
| 1270 | // all the MIDs that have been seen over the life of the PeerConnection. |
Karl Wiberg | a58e169 | 2019-03-26 13:33:43 +0100 | [diff] [blame] | 1271 | rtc::UniqueStringGenerator mid_generator_ RTC_GUARDED_BY(signaling_thread()); |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 1272 | |
Karl Wiberg | a58e169 | 2019-03-26 13:33:43 +0100 | [diff] [blame] | 1273 | SessionError session_error_ RTC_GUARDED_BY(signaling_thread()) = |
| 1274 | SessionError::kNone; |
| 1275 | std::string session_error_desc_ RTC_GUARDED_BY(signaling_thread()); |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 1276 | |
Karl Wiberg | a58e169 | 2019-03-26 13:33:43 +0100 | [diff] [blame] | 1277 | std::string session_id_ RTC_GUARDED_BY(signaling_thread()); |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 1278 | |
Karl Wiberg | 2cc368f | 2019-04-02 11:31:56 +0200 | [diff] [blame] | 1279 | std::unique_ptr<JsepTransportController> |
| 1280 | transport_controller_; // TODO(bugs.webrtc.org/9987): Accessed on both |
| 1281 | // signaling and network thread. |
| 1282 | std::unique_ptr<cricket::SctpTransportInternalFactory> |
| 1283 | sctp_factory_; // TODO(bugs.webrtc.org/9987): Accessed on both |
| 1284 | // signaling and network thread. |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 1285 | // |rtp_data_channel_| is used if in RTP data channel mode, |sctp_transport_| |
| 1286 | // when using SCTP. |
Karl Wiberg | 2cc368f | 2019-04-02 11:31:56 +0200 | [diff] [blame] | 1287 | cricket::RtpDataChannel* rtp_data_channel_ = |
| 1288 | nullptr; // TODO(bugs.webrtc.org/9987): Accessed on both |
| 1289 | // signaling and some other thread. |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 1290 | |
Harald Alvestrand | c85328f | 2019-02-28 07:51:00 +0100 | [diff] [blame] | 1291 | cricket::SctpTransportInternal* cricket_sctp_transport() { |
| 1292 | return sctp_transport_->internal(); |
| 1293 | } |
Karl Wiberg | 2cc368f | 2019-04-02 11:31:56 +0200 | [diff] [blame] | 1294 | rtc::scoped_refptr<SctpTransport> |
| 1295 | sctp_transport_; // TODO(bugs.webrtc.org/9987): Accessed on both |
| 1296 | // signaling and network thread. |
| 1297 | |
Zhi Huang | e830e68 | 2018-03-30 10:48:35 -0700 | [diff] [blame] | 1298 | // |sctp_mid_| is the content name (MID) in SDP. |
Karl Wiberg | 2cc368f | 2019-04-02 11:31:56 +0200 | [diff] [blame] | 1299 | absl::optional<std::string> |
| 1300 | sctp_mid_; // TODO(bugs.webrtc.org/9987): Accessed on both signaling |
| 1301 | // and network thread. |
| 1302 | |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 1303 | // Value cached on signaling thread. Only updated when SctpReadyToSendData |
| 1304 | // fires on the signaling thread. |
Karl Wiberg | 2cc368f | 2019-04-02 11:31:56 +0200 | [diff] [blame] | 1305 | bool sctp_ready_to_send_data_ RTC_GUARDED_BY(signaling_thread()) = false; |
| 1306 | |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 1307 | // Same as signals provided by SctpTransport, but these are guaranteed to |
| 1308 | // fire on the signaling thread, whereas SctpTransport fires on the networking |
| 1309 | // thread. |
| 1310 | // |sctp_invoker_| is used so that any signals queued on the signaling thread |
| 1311 | // from the network thread are immediately discarded if the SctpTransport is |
| 1312 | // destroyed (due to m= section being rejected). |
| 1313 | // TODO(deadbeef): Use a proxy object to ensure that method calls/signals |
| 1314 | // are marshalled to the right thread. Could almost use proxy.h for this, |
| 1315 | // but it doesn't have a mechanism for marshalling sigslot::signals |
Karl Wiberg | 7a651c6e | 2019-04-02 13:00:46 +0200 | [diff] [blame] | 1316 | std::unique_ptr<rtc::AsyncInvoker> sctp_invoker_ |
| 1317 | RTC_GUARDED_BY(network_thread()); |
| 1318 | sigslot::signal1<bool> SignalSctpReadyToSendData |
| 1319 | RTC_GUARDED_BY(signaling_thread()); |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 1320 | sigslot::signal2<const cricket::ReceiveDataParams&, |
| 1321 | const rtc::CopyOnWriteBuffer&> |
Karl Wiberg | 7a651c6e | 2019-04-02 13:00:46 +0200 | [diff] [blame] | 1322 | SignalSctpDataReceived RTC_GUARDED_BY(signaling_thread()); |
| 1323 | sigslot::signal1<int> SignalSctpClosingProcedureStartedRemotely |
| 1324 | RTC_GUARDED_BY(signaling_thread()); |
| 1325 | sigslot::signal1<int> SignalSctpClosingProcedureComplete |
| 1326 | RTC_GUARDED_BY(signaling_thread()); |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 1327 | |
Bjorn Mellem | 175aa2e | 2018-11-08 11:23:22 -0800 | [diff] [blame] | 1328 | // Whether this peer is the caller. Set when the local description is applied. |
| 1329 | absl::optional<bool> is_caller_ RTC_GUARDED_BY(signaling_thread()); |
| 1330 | |
| 1331 | // Content name (MID) for media transport data channels in SDP. |
Karl Wiberg | d9bf720 | 2019-04-02 19:36:24 +0200 | [diff] [blame] | 1332 | absl::optional<std::string> |
| 1333 | media_transport_data_mid_; // TODO(bugs.webrtc.org/9987): Accessed on |
| 1334 | // both signaling and network thread. |
Bjorn Mellem | 175aa2e | 2018-11-08 11:23:22 -0800 | [diff] [blame] | 1335 | |
| 1336 | // Media transport used for data channels. Thread-safe. |
Karl Wiberg | d9bf720 | 2019-04-02 19:36:24 +0200 | [diff] [blame] | 1337 | MediaTransportInterface* media_transport_ = |
| 1338 | nullptr; // TODO(bugs.webrtc.org/9987): Object is thread safe, but |
| 1339 | // pointer accessed on both signaling and network thread. |
Bjorn Mellem | 175aa2e | 2018-11-08 11:23:22 -0800 | [diff] [blame] | 1340 | |
| 1341 | // Cached value of whether the media transport is ready to send. |
| 1342 | bool media_transport_ready_to_send_data_ RTC_GUARDED_BY(signaling_thread()) = |
| 1343 | false; |
| 1344 | |
| 1345 | // Used to invoke media transport signals on the signaling thread. |
Karl Wiberg | 739506e | 2019-04-03 11:37:28 +0200 | [diff] [blame] | 1346 | std::unique_ptr<rtc::AsyncInvoker> media_transport_invoker_ |
| 1347 | RTC_GUARDED_BY(network_thread()); |
Bjorn Mellem | 175aa2e | 2018-11-08 11:23:22 -0800 | [diff] [blame] | 1348 | |
| 1349 | // Identical to the signals for SCTP, but from media transport: |
| 1350 | sigslot::signal1<bool> SignalMediaTransportWritable_s |
| 1351 | RTC_GUARDED_BY(signaling_thread()); |
| 1352 | sigslot::signal2<const cricket::ReceiveDataParams&, |
| 1353 | const rtc::CopyOnWriteBuffer&> |
| 1354 | SignalMediaTransportReceivedData_s RTC_GUARDED_BY(signaling_thread()); |
| 1355 | sigslot::signal1<int> SignalMediaTransportChannelClosing_s |
| 1356 | RTC_GUARDED_BY(signaling_thread()); |
| 1357 | sigslot::signal1<int> SignalMediaTransportChannelClosed_s |
| 1358 | RTC_GUARDED_BY(signaling_thread()); |
| 1359 | |
Karl Wiberg | 739506e | 2019-04-03 11:37:28 +0200 | [diff] [blame] | 1360 | std::unique_ptr<SessionDescriptionInterface> current_local_description_ |
| 1361 | RTC_GUARDED_BY(signaling_thread()); |
| 1362 | std::unique_ptr<SessionDescriptionInterface> pending_local_description_ |
| 1363 | RTC_GUARDED_BY(signaling_thread()); |
| 1364 | std::unique_ptr<SessionDescriptionInterface> current_remote_description_ |
| 1365 | RTC_GUARDED_BY(signaling_thread()); |
| 1366 | std::unique_ptr<SessionDescriptionInterface> pending_remote_description_ |
| 1367 | RTC_GUARDED_BY(signaling_thread()); |
| 1368 | bool dtls_enabled_ RTC_GUARDED_BY(signaling_thread()) = false; |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 1369 | // Specifies which kind of data channel is allowed. This is controlled |
| 1370 | // by the chrome command-line flag and constraints: |
| 1371 | // 1. If chrome command-line switch 'enable-sctp-data-channels' is enabled, |
| 1372 | // constraint kEnableDtlsSrtp is true, and constaint kEnableRtpDataChannels is |
| 1373 | // not set or false, SCTP is allowed (DCT_SCTP); |
| 1374 | // 2. If constraint kEnableRtpDataChannels is true, RTP is allowed (DCT_RTP); |
| 1375 | // 3. If both 1&2 are false, data channel is not allowed (DCT_NONE). |
Karl Wiberg | f73f7d6 | 2019-04-08 15:36:53 +0200 | [diff] [blame] | 1376 | cricket::DataChannelType data_channel_type_ = |
| 1377 | cricket::DCT_NONE; // TODO(bugs.webrtc.org/9987): Accessed on both |
| 1378 | // signaling and network thread. |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 1379 | |
Karl Wiberg | f73f7d6 | 2019-04-08 15:36:53 +0200 | [diff] [blame] | 1380 | // List of content names for which the remote side triggered an ICE restart. |
| 1381 | std::set<std::string> pending_ice_restarts_ |
| 1382 | RTC_GUARDED_BY(signaling_thread()); |
| 1383 | |
| 1384 | std::unique_ptr<WebRtcSessionDescriptionFactory> webrtc_session_desc_factory_ |
| 1385 | RTC_GUARDED_BY(signaling_thread()); |
Steve Anton | 75737c0 | 2017-11-06 10:37:17 -0800 | [diff] [blame] | 1386 | |
| 1387 | // Member variables for caching global options. |
Karl Wiberg | f73f7d6 | 2019-04-08 15:36:53 +0200 | [diff] [blame] | 1388 | cricket::AudioOptions audio_options_ RTC_GUARDED_BY(signaling_thread()); |
| 1389 | cricket::VideoOptions video_options_ RTC_GUARDED_BY(signaling_thread()); |
Harald Alvestrand | 8ebba74 | 2018-05-31 14:00:34 +0200 | [diff] [blame] | 1390 | |
Karl Wiberg | f73f7d6 | 2019-04-08 15:36:53 +0200 | [diff] [blame] | 1391 | int usage_event_accumulator_ RTC_GUARDED_BY(signaling_thread()) = 0; |
| 1392 | bool return_histogram_very_quickly_ RTC_GUARDED_BY(signaling_thread()) = |
| 1393 | false; |
Amit Hilbuch | bcd39d4 | 2019-01-25 17:13:56 -0800 | [diff] [blame] | 1394 | |
| 1395 | // This object should be used to generate any SSRC that is not explicitly |
| 1396 | // specified by the user (or by the remote party). |
| 1397 | // The generator is not used directly, instead it is passed on to the |
| 1398 | // channel manager and the session description factory. |
Karl Wiberg | f73f7d6 | 2019-04-08 15:36:53 +0200 | [diff] [blame] | 1399 | rtc::UniqueRandomIdGenerator ssrc_generator_ |
| 1400 | RTC_GUARDED_BY(signaling_thread()); |
Jonas Oreland | a3aa9bd | 2019-04-17 07:38:40 +0200 | [diff] [blame] | 1401 | |
| 1402 | // A video bitrate allocator factory. |
| 1403 | // This can injected using the PeerConnectionDependencies, |
| 1404 | // or else the CreateBuiltinVideoBitrateAllocatorFactory() will be called. |
| 1405 | // Note that one can still choose to override this in a MediaEngine |
| 1406 | // if one wants too. |
| 1407 | std::unique_ptr<webrtc::VideoBitrateAllocatorFactory> |
| 1408 | video_bitrate_allocator_factory_; |
| 1409 | |
Henrik Boström | 79b6980 | 2019-07-18 11:16:56 +0200 | [diff] [blame] | 1410 | std::unique_ptr<LocalIceCredentialsToReplace> |
| 1411 | local_ice_credentials_to_replace_ RTC_GUARDED_BY(signaling_thread()); |
Guido Urdaneta | 70c2db1 | 2019-04-16 12:24:14 +0200 | [diff] [blame] | 1412 | bool is_negotiation_needed_ RTC_GUARDED_BY(signaling_thread()) = false; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1413 | }; |
| 1414 | |
| 1415 | } // namespace webrtc |
| 1416 | |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 1417 | #endif // PC_PEER_CONNECTION_H_ |