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