henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 1 | /* |
kjellander | b24317b | 2016-02-10 15:54:43 | [diff] [blame] | 2 | * Copyright 2012 The WebRTC project authors. All Rights Reserved. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 3 | * |
kjellander | b24317b | 2016-02-10 15:54:43 | [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 | [diff] [blame] | 9 | */ |
| 10 | |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 11 | #ifndef PC_PEERCONNECTION_H_ |
| 12 | #define PC_PEERCONNECTION_H_ |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 13 | |
perkj | d61bf80 | 2016-03-24 10:16:19 | [diff] [blame] | 14 | #include <map> |
kwiberg | d1fe281 | 2016-04-27 13:47:29 | [diff] [blame] | 15 | #include <memory> |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 16 | #include <set> |
| 17 | #include <string> |
perkj | d61bf80 | 2016-03-24 10:16:19 | [diff] [blame] | 18 | #include <vector> |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 19 | |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 20 | #include "api/peerconnectioninterface.h" |
Jonas Oreland | bdcee28 | 2017-10-10 12:01:40 | [diff] [blame] | 21 | #include "api/turncustomizer.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 22 | #include "pc/iceserverparsing.h" |
| 23 | #include "pc/peerconnectionfactory.h" |
| 24 | #include "pc/rtcstatscollector.h" |
Steve Anton | 4171afb | 2017-11-20 18:20:22 | [diff] [blame] | 25 | #include "pc/rtptransceiver.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 26 | #include "pc/statscollector.h" |
| 27 | #include "pc/streamcollection.h" |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 28 | #include "pc/webrtcsessiondescriptionfactory.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 29 | |
| 30 | namespace webrtc { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 31 | |
deadbeef | eb45981 | 2015-12-16 03:24:43 | [diff] [blame] | 32 | class MediaStreamObserver; |
perkj | f0dcfe2 | 2016-03-10 17:32:00 | [diff] [blame] | 33 | class VideoRtpReceiver; |
skvlad | 11a9cbf | 2016-10-07 18:53:05 | [diff] [blame] | 34 | class RtcEventLog; |
deadbeef | ab9b2d1 | 2015-10-14 18:33:11 | [diff] [blame] | 35 | |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 36 | // Statistics for all the transports of the session. |
| 37 | // TODO(pthatcher): Think of a better name for this. We already have |
| 38 | // a TransportStats in transport.h. Perhaps TransportsStats? |
| 39 | struct SessionStats { |
| 40 | std::map<std::string, std::string> proxy_to_transport; |
| 41 | std::map<std::string, cricket::TransportStats> transport_stats; |
| 42 | }; |
Steve Anton | ba81867 | 2017-11-06 18:21:57 | [diff] [blame] | 43 | |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 44 | struct ChannelNamePair { |
| 45 | ChannelNamePair(const std::string& content_name, |
| 46 | const std::string& transport_name) |
| 47 | : content_name(content_name), transport_name(transport_name) {} |
| 48 | std::string content_name; |
| 49 | std::string transport_name; |
| 50 | }; |
| 51 | |
| 52 | struct ChannelNamePairs { |
| 53 | rtc::Optional<ChannelNamePair> voice; |
| 54 | rtc::Optional<ChannelNamePair> video; |
| 55 | rtc::Optional<ChannelNamePair> data; |
| 56 | }; |
| 57 | |
| 58 | // PeerConnection is the implementation of the PeerConnection object as defined |
| 59 | // by the PeerConnectionInterface API surface. |
| 60 | // The class currently is solely responsible for the following: |
| 61 | // - Managing the session state machine (signaling state). |
| 62 | // - Creating and initializing lower-level objects, like PortAllocator and |
| 63 | // BaseChannels. |
| 64 | // - Owning and managing the life cycle of the RtpSender/RtpReceiver and track |
| 65 | // objects. |
| 66 | // - Tracking the current and pending local/remote session descriptions. |
| 67 | // The class currently is jointly responsible for the following: |
| 68 | // - Parsing and interpreting SDP. |
| 69 | // - Generating offers and answers based on the current state. |
| 70 | // - The ICE state machine. |
| 71 | // - Generating stats. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 72 | class PeerConnection : public PeerConnectionInterface, |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 73 | public DataChannelProviderInterface, |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 | [diff] [blame] | 74 | public rtc::MessageHandler, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 75 | public sigslot::has_slots<> { |
| 76 | public: |
zhihuang | 38ede13 | 2017-06-15 19:52:32 | [diff] [blame] | 77 | explicit PeerConnection(PeerConnectionFactory* factory, |
| 78 | std::unique_ptr<RtcEventLog> event_log, |
| 79 | std::unique_ptr<Call> call); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 80 | |
deadbeef | 653b8e0 | 2015-11-11 20:55:10 | [diff] [blame] | 81 | bool Initialize( |
| 82 | const PeerConnectionInterface::RTCConfiguration& configuration, |
kwiberg | d1fe281 | 2016-04-27 13:47:29 | [diff] [blame] | 83 | std::unique_ptr<cricket::PortAllocator> allocator, |
Henrik Boström | d03c23b | 2016-06-01 09:44:18 | [diff] [blame] | 84 | std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator, |
deadbeef | 653b8e0 | 2015-11-11 20:55:10 | [diff] [blame] | 85 | PeerConnectionObserver* observer); |
| 86 | |
deadbeef | a67696b | 2015-09-29 18:56:26 | [diff] [blame] | 87 | rtc::scoped_refptr<StreamCollectionInterface> local_streams() override; |
| 88 | rtc::scoped_refptr<StreamCollectionInterface> remote_streams() override; |
| 89 | bool AddStream(MediaStreamInterface* local_stream) override; |
| 90 | void RemoveStream(MediaStreamInterface* local_stream) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 91 | |
deadbeef | e1f9d83 | 2016-01-14 23:35:42 | [diff] [blame] | 92 | rtc::scoped_refptr<RtpSenderInterface> AddTrack( |
| 93 | MediaStreamTrackInterface* track, |
| 94 | std::vector<MediaStreamInterface*> streams) override; |
| 95 | bool RemoveTrack(RtpSenderInterface* sender) override; |
| 96 | |
Steve Anton | 9158ef6 | 2017-11-27 21:01:52 | [diff] [blame] | 97 | RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver( |
| 98 | rtc::scoped_refptr<MediaStreamTrackInterface> track) override; |
| 99 | RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver( |
| 100 | rtc::scoped_refptr<MediaStreamTrackInterface> track, |
| 101 | const RtpTransceiverInit& init) override; |
| 102 | RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver( |
| 103 | cricket::MediaType media_type) override; |
| 104 | RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver( |
| 105 | cricket::MediaType media_type, |
| 106 | const RtpTransceiverInit& init) override; |
| 107 | |
Steve Anton | 8c0f7a7 | 2017-10-03 17:03:10 | [diff] [blame] | 108 | // Gets the DTLS SSL certificate associated with the audio transport on the |
| 109 | // remote side. This will become populated once the DTLS connection with the |
| 110 | // peer has been completed, as indicated by the ICE connection state |
| 111 | // transitioning to kIceConnectionCompleted. |
| 112 | // Note that this will be removed once we implement RTCDtlsTransport which |
| 113 | // has standardized method for getting this information. |
| 114 | // See https://www.w3.org/TR/webrtc/#rtcdtlstransport-interface |
| 115 | std::unique_ptr<rtc::SSLCertificate> GetRemoteAudioSSLCertificate(); |
| 116 | |
deadbeef | a67696b | 2015-09-29 18:56:26 | [diff] [blame] | 117 | rtc::scoped_refptr<DtmfSenderInterface> CreateDtmfSender( |
| 118 | AudioTrackInterface* track) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 119 | |
deadbeef | fac0655 | 2015-11-25 19:26:01 | [diff] [blame] | 120 | rtc::scoped_refptr<RtpSenderInterface> CreateSender( |
deadbeef | bd7d8f7 | 2015-12-19 00:58:44 | [diff] [blame] | 121 | const std::string& kind, |
| 122 | const std::string& stream_id) override; |
deadbeef | fac0655 | 2015-11-25 19:26:01 | [diff] [blame] | 123 | |
deadbeef | 70ab1a1 | 2015-09-28 23:53:55 | [diff] [blame] | 124 | std::vector<rtc::scoped_refptr<RtpSenderInterface>> GetSenders() |
| 125 | const override; |
| 126 | std::vector<rtc::scoped_refptr<RtpReceiverInterface>> GetReceivers() |
| 127 | const override; |
Steve Anton | 9158ef6 | 2017-11-27 21:01:52 | [diff] [blame] | 128 | std::vector<rtc::scoped_refptr<RtpTransceiverInterface>> GetTransceivers() |
| 129 | const override; |
deadbeef | 70ab1a1 | 2015-09-28 23:53:55 | [diff] [blame] | 130 | |
deadbeef | a67696b | 2015-09-29 18:56:26 | [diff] [blame] | 131 | rtc::scoped_refptr<DataChannelInterface> CreateDataChannel( |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 132 | const std::string& label, |
deadbeef | a67696b | 2015-09-29 18:56:26 | [diff] [blame] | 133 | const DataChannelInit* config) override; |
| 134 | bool GetStats(StatsObserver* observer, |
| 135 | webrtc::MediaStreamTrackInterface* track, |
| 136 | StatsOutputLevel level) override; |
hbos | 74e1a4f | 2016-09-16 06:33:01 | [diff] [blame] | 137 | void GetStats(RTCStatsCollectorCallback* callback) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 138 | |
deadbeef | a67696b | 2015-09-29 18:56:26 | [diff] [blame] | 139 | SignalingState signaling_state() override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 140 | |
deadbeef | a67696b | 2015-09-29 18:56:26 | [diff] [blame] | 141 | IceConnectionState ice_connection_state() override; |
| 142 | IceGatheringState ice_gathering_state() override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 143 | |
deadbeef | a67696b | 2015-09-29 18:56:26 | [diff] [blame] | 144 | const SessionDescriptionInterface* local_description() const override; |
| 145 | const SessionDescriptionInterface* remote_description() const override; |
deadbeef | fe4a8a4 | 2016-12-21 01:56:17 | [diff] [blame] | 146 | const SessionDescriptionInterface* current_local_description() const override; |
| 147 | const SessionDescriptionInterface* current_remote_description() |
| 148 | const override; |
| 149 | const SessionDescriptionInterface* pending_local_description() const override; |
| 150 | const SessionDescriptionInterface* pending_remote_description() |
| 151 | const override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 152 | |
| 153 | // JSEP01 |
hta | a2a49d9 | 2016-03-04 10:51:39 | [diff] [blame] | 154 | // Deprecated, use version without constraints. |
deadbeef | a67696b | 2015-09-29 18:56:26 | [diff] [blame] | 155 | void CreateOffer(CreateSessionDescriptionObserver* observer, |
| 156 | const MediaConstraintsInterface* constraints) override; |
| 157 | void CreateOffer(CreateSessionDescriptionObserver* observer, |
| 158 | const RTCOfferAnswerOptions& options) override; |
hta | a2a49d9 | 2016-03-04 10:51:39 | [diff] [blame] | 159 | // Deprecated, use version without constraints. |
deadbeef | a67696b | 2015-09-29 18:56:26 | [diff] [blame] | 160 | void CreateAnswer(CreateSessionDescriptionObserver* observer, |
| 161 | const MediaConstraintsInterface* constraints) override; |
hta | a2a49d9 | 2016-03-04 10:51:39 | [diff] [blame] | 162 | void CreateAnswer(CreateSessionDescriptionObserver* observer, |
| 163 | const RTCOfferAnswerOptions& options) override; |
deadbeef | a67696b | 2015-09-29 18:56:26 | [diff] [blame] | 164 | void SetLocalDescription(SetSessionDescriptionObserver* observer, |
| 165 | SessionDescriptionInterface* desc) override; |
Henrik Boström | a4ecf55 | 2017-11-23 14:17:07 | [diff] [blame] | 166 | void SetRemoteDescription(SetSessionDescriptionObserver* observer, |
| 167 | SessionDescriptionInterface* desc) override; |
Henrik Boström | 3163867 | 2017-11-23 16:48:32 | [diff] [blame] | 168 | void SetRemoteDescription( |
| 169 | std::unique_ptr<SessionDescriptionInterface> desc, |
| 170 | rtc::scoped_refptr<SetRemoteDescriptionObserverInterface> observer) |
| 171 | override; |
deadbeef | 46c7389 | 2016-11-17 03:42:04 | [diff] [blame] | 172 | PeerConnectionInterface::RTCConfiguration GetConfiguration() override; |
deadbeef | a67696b | 2015-09-29 18:56:26 | [diff] [blame] | 173 | bool SetConfiguration( |
deadbeef | 293e926 | 2017-01-11 20:28:30 | [diff] [blame] | 174 | const PeerConnectionInterface::RTCConfiguration& configuration, |
| 175 | RTCError* error) override; |
| 176 | bool SetConfiguration( |
| 177 | const PeerConnectionInterface::RTCConfiguration& configuration) override { |
| 178 | return SetConfiguration(configuration, nullptr); |
| 179 | } |
deadbeef | a67696b | 2015-09-29 18:56:26 | [diff] [blame] | 180 | bool AddIceCandidate(const IceCandidateInterface* candidate) override; |
Honghai Zhang | 7fb69db | 2016-03-14 18:59:18 | [diff] [blame] | 181 | bool RemoveIceCandidates( |
| 182 | const std::vector<cricket::Candidate>& candidates) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 183 | |
deadbeef | a67696b | 2015-09-29 18:56:26 | [diff] [blame] | 184 | void RegisterUMAObserver(UMAObserver* observer) override; |
buildbot@webrtc.org | 1567b8c | 2014-05-08 19:54:16 | [diff] [blame] | 185 | |
zstein | 4b97980 | 2017-06-02 21:37:37 | [diff] [blame] | 186 | RTCError SetBitrate(const BitrateParameters& bitrate) override; |
| 187 | |
Alex Narest | 78609d5 | 2017-10-20 08:37:47 | [diff] [blame] | 188 | void SetBitrateAllocationStrategy( |
| 189 | std::unique_ptr<rtc::BitrateAllocationStrategy> |
| 190 | bitrate_allocation_strategy) override; |
| 191 | |
henrika | 5f6bf24 | 2017-11-01 10:06:56 | [diff] [blame] | 192 | void SetAudioPlayout(bool playout) override; |
| 193 | void SetAudioRecording(bool recording) override; |
| 194 | |
Elad Alon | 99c3fe5 | 2017-10-13 14:29:40 | [diff] [blame] | 195 | RTC_DEPRECATED bool StartRtcEventLog(rtc::PlatformFile file, |
| 196 | int64_t max_size_bytes) override; |
Bjorn Terelius | de93943 | 2017-11-20 16:38:14 | [diff] [blame] | 197 | bool StartRtcEventLog(std::unique_ptr<RtcEventLogOutput> output, |
| 198 | int64_t output_period_ms) override; |
ivoc | 14d5dbe | 2016-07-04 14:06:55 | [diff] [blame] | 199 | void StopRtcEventLog() override; |
| 200 | |
deadbeef | a67696b | 2015-09-29 18:56:26 | [diff] [blame] | 201 | void Close() override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 202 | |
hbos | 82ebe02 | 2016-11-14 09:41:09 | [diff] [blame] | 203 | sigslot::signal1<DataChannel*> SignalDataChannelCreated; |
| 204 | |
deadbeef | ab9b2d1 | 2015-10-14 18:33:11 | [diff] [blame] | 205 | // Virtual for unit tests. |
| 206 | virtual const std::vector<rtc::scoped_refptr<DataChannel>>& |
| 207 | sctp_data_channels() const { |
| 208 | return sctp_data_channels_; |
perkj | d61bf80 | 2016-03-24 10:16:19 | [diff] [blame] | 209 | } |
deadbeef | ab9b2d1 | 2015-10-14 18:33:11 | [diff] [blame] | 210 | |
Steve Anton | 978b876 | 2017-09-29 19:15:02 | [diff] [blame] | 211 | rtc::Thread* network_thread() const { return factory_->network_thread(); } |
| 212 | rtc::Thread* worker_thread() const { return factory_->worker_thread(); } |
| 213 | rtc::Thread* signaling_thread() const { return factory_->signaling_thread(); } |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 214 | |
| 215 | // The SDP session ID as defined by RFC 3264. |
| 216 | virtual const std::string& session_id() const { return session_id_; } |
| 217 | |
| 218 | // Returns true if we were the initial offerer. |
| 219 | bool initial_offerer() const { return initial_offerer_ && *initial_offerer_; } |
| 220 | |
| 221 | // Returns stats for all channels of all transports. |
| 222 | // This avoids exposing the internal structures used to track them. |
| 223 | // The parameterless version creates |ChannelNamePairs| from |voice_channel|, |
| 224 | // |video_channel| and |voice_channel| if available - this requires it to be |
| 225 | // called on the signaling thread - and invokes the other |GetStats|. The |
| 226 | // other |GetStats| can be invoked on any thread; if not invoked on the |
| 227 | // network thread a thread hop will happen. |
| 228 | std::unique_ptr<SessionStats> GetSessionStats_s(); |
Steve Anton | 978b876 | 2017-09-29 19:15:02 | [diff] [blame] | 229 | virtual std::unique_ptr<SessionStats> GetSessionStats( |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 230 | const ChannelNamePairs& channel_name_pairs); |
| 231 | |
| 232 | // virtual so it can be mocked in unit tests |
Steve Anton | 978b876 | 2017-09-29 19:15:02 | [diff] [blame] | 233 | virtual bool GetLocalCertificate( |
| 234 | const std::string& transport_name, |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 235 | rtc::scoped_refptr<rtc::RTCCertificate>* certificate); |
Steve Anton | 978b876 | 2017-09-29 19:15:02 | [diff] [blame] | 236 | virtual std::unique_ptr<rtc::SSLCertificate> GetRemoteSSLCertificate( |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 237 | const std::string& transport_name); |
| 238 | |
| 239 | virtual Call::Stats GetCallStats(); |
| 240 | |
| 241 | // Exposed for stats collecting. |
| 242 | // TODO(steveanton): Switch callers to use the plural form and remove these. |
Steve Anton | 4171afb | 2017-11-20 18:20:22 | [diff] [blame] | 243 | virtual cricket::VoiceChannel* voice_channel() const { |
Steve Anton | 3fe1b15 | 2017-12-12 18:20:08 | [diff] [blame^] | 244 | if (IsUnifiedPlan()) { |
| 245 | // TODO(steveanton): Change stats collection to work with transceivers. |
| 246 | return nullptr; |
| 247 | } |
Steve Anton | 4171afb | 2017-11-20 18:20:22 | [diff] [blame] | 248 | return static_cast<cricket::VoiceChannel*>( |
| 249 | GetAudioTransceiver()->internal()->channel()); |
Steve Anton | 978b876 | 2017-09-29 19:15:02 | [diff] [blame] | 250 | } |
Steve Anton | 4171afb | 2017-11-20 18:20:22 | [diff] [blame] | 251 | virtual cricket::VideoChannel* video_channel() const { |
Steve Anton | 3fe1b15 | 2017-12-12 18:20:08 | [diff] [blame^] | 252 | if (IsUnifiedPlan()) { |
| 253 | // TODO(steveanton): Change stats collection to work with transceivers. |
| 254 | return nullptr; |
| 255 | } |
Steve Anton | 4171afb | 2017-11-20 18:20:22 | [diff] [blame] | 256 | return static_cast<cricket::VideoChannel*>( |
| 257 | GetVideoTransceiver()->internal()->channel()); |
Steve Anton | d5585ca | 2017-10-23 21:49:26 | [diff] [blame] | 258 | } |
Steve Anton | 978b876 | 2017-09-29 19:15:02 | [diff] [blame] | 259 | |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 260 | // Only valid when using deprecated RTP data channels. |
| 261 | virtual cricket::RtpDataChannel* rtp_data_channel() { |
| 262 | return rtp_data_channel_; |
Steve Anton | 978b876 | 2017-09-29 19:15:02 | [diff] [blame] | 263 | } |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 264 | virtual rtc::Optional<std::string> sctp_content_name() const { |
| 265 | return sctp_content_name_; |
| 266 | } |
| 267 | virtual rtc::Optional<std::string> sctp_transport_name() const { |
| 268 | return sctp_transport_name_; |
| 269 | } |
| 270 | |
| 271 | // Get the id used as a media stream track's "id" field from ssrc. |
| 272 | virtual bool GetLocalTrackIdBySsrc(uint32_t ssrc, std::string* track_id); |
| 273 | virtual bool GetRemoteTrackIdBySsrc(uint32_t ssrc, std::string* track_id); |
| 274 | |
| 275 | // Returns true if there was an ICE restart initiated by the remote offer. |
| 276 | bool IceRestartPending(const std::string& content_name) const; |
| 277 | |
| 278 | // Returns true if the ICE restart flag above was set, and no ICE restart has |
| 279 | // occurred yet for this transport (by applying a local description with |
| 280 | // changed ufrag/password). If the transport has been deleted as a result of |
| 281 | // bundling, returns false. |
| 282 | bool NeedsIceRestart(const std::string& content_name) const; |
| 283 | |
| 284 | // Get SSL role for an arbitrary m= section (handles bundling correctly). |
| 285 | // TODO(deadbeef): This is only used internally by the session description |
| 286 | // factory, it shouldn't really be public). |
| 287 | bool GetSslRole(const std::string& content_name, rtc::SSLRole* role); |
| 288 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 289 | protected: |
deadbeef | a67696b | 2015-09-29 18:56:26 | [diff] [blame] | 290 | ~PeerConnection() override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 291 | |
| 292 | private: |
Henrik Boström | 3163867 | 2017-11-23 16:48:32 | [diff] [blame] | 293 | class SetRemoteDescriptionObserverAdapter; |
| 294 | friend class SetRemoteDescriptionObserverAdapter; |
| 295 | |
Steve Anton | 4171afb | 2017-11-20 18:20:22 | [diff] [blame] | 296 | struct RtpSenderInfo { |
| 297 | RtpSenderInfo() : first_ssrc(0) {} |
| 298 | RtpSenderInfo(const std::string& stream_label, |
| 299 | const std::string sender_id, |
| 300 | uint32_t ssrc) |
| 301 | : stream_label(stream_label), sender_id(sender_id), first_ssrc(ssrc) {} |
| 302 | bool operator==(const RtpSenderInfo& other) { |
deadbeef | bda7e0b | 2015-12-09 01:13:40 | [diff] [blame] | 303 | return this->stream_label == other.stream_label && |
Steve Anton | 4171afb | 2017-11-20 18:20:22 | [diff] [blame] | 304 | this->sender_id == other.sender_id && |
| 305 | this->first_ssrc == other.first_ssrc; |
deadbeef | bda7e0b | 2015-12-09 01:13:40 | [diff] [blame] | 306 | } |
deadbeef | ab9b2d1 | 2015-10-14 18:33:11 | [diff] [blame] | 307 | std::string stream_label; |
Steve Anton | 4171afb | 2017-11-20 18:20:22 | [diff] [blame] | 308 | std::string sender_id; |
| 309 | // An RtpSender can have many SSRCs. The first one is used as a sort of ID |
| 310 | // for communicating with the lower layers. |
| 311 | uint32_t first_ssrc; |
deadbeef | ab9b2d1 | 2015-10-14 18:33:11 | [diff] [blame] | 312 | }; |
deadbeef | ab9b2d1 | 2015-10-14 18:33:11 | [diff] [blame] | 313 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 314 | // Implements MessageHandler. |
deadbeef | a67696b | 2015-09-29 18:56:26 | [diff] [blame] | 315 | void OnMessage(rtc::Message* msg) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 316 | |
Steve Anton | 4171afb | 2017-11-20 18:20:22 | [diff] [blame] | 317 | std::vector<rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>>> |
| 318 | GetSendersInternal() const; |
| 319 | std::vector< |
| 320 | rtc::scoped_refptr<RtpReceiverProxyWithInternal<RtpReceiverInternal>>> |
| 321 | GetReceiversInternal() const; |
| 322 | |
| 323 | rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>> |
| 324 | GetAudioTransceiver() const; |
| 325 | rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>> |
| 326 | GetVideoTransceiver() const; |
| 327 | |
deadbeef | ab9b2d1 | 2015-10-14 18:33:11 | [diff] [blame] | 328 | void CreateAudioReceiver(MediaStreamInterface* stream, |
Steve Anton | 4171afb | 2017-11-20 18:20:22 | [diff] [blame] | 329 | const RtpSenderInfo& remote_sender_info); |
perkj | f0dcfe2 | 2016-03-10 17:32:00 | [diff] [blame] | 330 | |
deadbeef | ab9b2d1 | 2015-10-14 18:33:11 | [diff] [blame] | 331 | void CreateVideoReceiver(MediaStreamInterface* stream, |
Steve Anton | 4171afb | 2017-11-20 18:20:22 | [diff] [blame] | 332 | const RtpSenderInfo& remote_sender_info); |
Henrik Boström | 933d8b0 | 2017-10-10 17:05:16 | [diff] [blame] | 333 | rtc::scoped_refptr<RtpReceiverInterface> RemoveAndStopReceiver( |
Steve Anton | 4171afb | 2017-11-20 18:20:22 | [diff] [blame] | 334 | const RtpSenderInfo& remote_sender_info); |
korniltsev.anatoly | ec390b5 | 2017-07-25 00:00:25 | [diff] [blame] | 335 | |
| 336 | // May be called either by AddStream/RemoveStream, or when a track is |
| 337 | // added/removed from a stream previously added via AddStream. |
| 338 | void AddAudioTrack(AudioTrackInterface* track, MediaStreamInterface* stream); |
| 339 | void RemoveAudioTrack(AudioTrackInterface* track, |
| 340 | MediaStreamInterface* stream); |
| 341 | void AddVideoTrack(VideoTrackInterface* track, MediaStreamInterface* stream); |
| 342 | void RemoveVideoTrack(VideoTrackInterface* track, |
| 343 | MediaStreamInterface* stream); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 344 | |
Steve Anton | 9158ef6 | 2017-11-27 21:01:52 | [diff] [blame] | 345 | RTCErrorOr<rtc::scoped_refptr<RtpTransceiverInterface>> AddTransceiver( |
| 346 | cricket::MediaType media_type, |
| 347 | rtc::scoped_refptr<MediaStreamTrackInterface> track, |
| 348 | const RtpTransceiverInit& init); |
| 349 | |
Steve Anton | ba81867 | 2017-11-06 18:21:57 | [diff] [blame] | 350 | void SetIceConnectionState(IceConnectionState new_state); |
| 351 | // Called any time the IceGatheringState changes |
| 352 | void OnIceGatheringChange(IceGatheringState new_state); |
| 353 | // New ICE candidate has been gathered. |
| 354 | void OnIceCandidate(std::unique_ptr<IceCandidateInterface> candidate); |
| 355 | // Some local ICE candidates have been removed. |
Honghai Zhang | 7fb69db | 2016-03-14 18:59:18 | [diff] [blame] | 356 | void OnIceCandidatesRemoved( |
Steve Anton | ba81867 | 2017-11-06 18:21:57 | [diff] [blame] | 357 | const std::vector<cricket::Candidate>& candidates); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 358 | |
Steve Anton | ba81867 | 2017-11-06 18:21:57 | [diff] [blame] | 359 | // Update the state, signaling if necessary. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 360 | void ChangeSignalingState(SignalingState signaling_state); |
| 361 | |
deadbeef | eb45981 | 2015-12-16 03:24:43 | [diff] [blame] | 362 | // Signals from MediaStreamObserver. |
| 363 | void OnAudioTrackAdded(AudioTrackInterface* track, |
| 364 | MediaStreamInterface* stream); |
| 365 | void OnAudioTrackRemoved(AudioTrackInterface* track, |
| 366 | MediaStreamInterface* stream); |
| 367 | void OnVideoTrackAdded(VideoTrackInterface* track, |
| 368 | MediaStreamInterface* stream); |
| 369 | void OnVideoTrackRemoved(VideoTrackInterface* track, |
| 370 | MediaStreamInterface* stream); |
| 371 | |
Henrik Boström | 3163867 | 2017-11-23 16:48:32 | [diff] [blame] | 372 | void PostSetSessionDescriptionSuccess( |
| 373 | SetSessionDescriptionObserver* observer); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 374 | void PostSetSessionDescriptionFailure(SetSessionDescriptionObserver* observer, |
| 375 | const std::string& error); |
deadbeef | ab9b2d1 | 2015-10-14 18:33:11 | [diff] [blame] | 376 | void PostCreateSessionDescriptionFailure( |
| 377 | CreateSessionDescriptionObserver* observer, |
| 378 | const std::string& error); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 379 | |
Steve Anton | 8a00691 | 2017-12-04 23:25:56 | [diff] [blame] | 380 | // Synchronous implementations of SetLocalDescription/SetRemoteDescription |
| 381 | // that return an RTCError instead of invoking a callback. |
| 382 | RTCError ApplyLocalDescription( |
| 383 | std::unique_ptr<SessionDescriptionInterface> desc); |
| 384 | RTCError ApplyRemoteDescription( |
| 385 | std::unique_ptr<SessionDescriptionInterface> desc); |
| 386 | |
Steve Anton | ed10bd9 | 2017-12-05 18:52:59 | [diff] [blame] | 387 | // Returns the media section in the given session description that is |
| 388 | // associated with the RtpTransceiver. Returns null if none found or this |
| 389 | // RtpTransceiver is not associated. Logic varies depending on the |
| 390 | // SdpSemantics specified in the configuration. |
| 391 | const cricket::ContentInfo* FindMediaSectionForTransceiver( |
| 392 | rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>> |
| 393 | transceiver, |
| 394 | const SessionDescriptionInterface* sdesc) const; |
| 395 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 396 | bool IsClosed() const { |
| 397 | return signaling_state_ == PeerConnectionInterface::kClosed; |
| 398 | } |
| 399 | |
deadbeef | ab9b2d1 | 2015-10-14 18:33:11 | [diff] [blame] | 400 | // Returns a MediaSessionOptions struct with options decided by |options|, |
| 401 | // the local MediaStreams and DataChannels. |
zhihuang | 1c378ed | 2017-08-17 21:10:50 | [diff] [blame] | 402 | void GetOptionsForOffer( |
deadbeef | ab9b2d1 | 2015-10-14 18:33:11 | [diff] [blame] | 403 | const PeerConnectionInterface::RTCOfferAnswerOptions& rtc_options, |
| 404 | cricket::MediaSessionOptions* session_options); |
| 405 | |
| 406 | // Returns a MediaSessionOptions struct with options decided by |
| 407 | // |constraints|, the local MediaStreams and DataChannels. |
zhihuang | 1c378ed | 2017-08-17 21:10:50 | [diff] [blame] | 408 | void GetOptionsForAnswer(const RTCOfferAnswerOptions& options, |
| 409 | cricket::MediaSessionOptions* session_options); |
hta | a2a49d9 | 2016-03-04 10:51:39 | [diff] [blame] | 410 | |
zhihuang | 1c378ed | 2017-08-17 21:10:50 | [diff] [blame] | 411 | // Generates MediaDescriptionOptions for the |session_opts| based on existing |
| 412 | // local description or remote description. |
| 413 | void GenerateMediaDescriptionOptions( |
| 414 | const SessionDescriptionInterface* session_desc, |
Steve Anton | 1d03a75 | 2017-11-27 22:30:09 | [diff] [blame] | 415 | RtpTransceiverDirection audio_direction, |
| 416 | RtpTransceiverDirection video_direction, |
zhihuang | 1c378ed | 2017-08-17 21:10:50 | [diff] [blame] | 417 | rtc::Optional<size_t>* audio_index, |
| 418 | rtc::Optional<size_t>* video_index, |
| 419 | rtc::Optional<size_t>* data_index, |
hta | a2a49d9 | 2016-03-04 10:51:39 | [diff] [blame] | 420 | cricket::MediaSessionOptions* session_options); |
deadbeef | ab9b2d1 | 2015-10-14 18:33:11 | [diff] [blame] | 421 | |
Steve Anton | 4171afb | 2017-11-20 18:20:22 | [diff] [blame] | 422 | // Remove all local and remote senders of type |media_type|. |
deadbeef | faac497 | 2015-11-12 23:33:07 | [diff] [blame] | 423 | // Called when a media type is rejected (m-line set to port 0). |
Steve Anton | 4171afb | 2017-11-20 18:20:22 | [diff] [blame] | 424 | void RemoveSenders(cricket::MediaType media_type); |
deadbeef | faac497 | 2015-11-12 23:33:07 | [diff] [blame] | 425 | |
deadbeef | bda7e0b | 2015-12-09 01:13:40 | [diff] [blame] | 426 | // Makes sure a MediaStreamTrack is created for each StreamParam in |streams|, |
| 427 | // and existing MediaStreamTracks are removed if there is no corresponding |
| 428 | // StreamParam. If |default_track_needed| is true, a default MediaStreamTrack |
| 429 | // is created if it doesn't exist; if false, it's removed if it exists. |
| 430 | // |media_type| is the type of the |streams| and can be either audio or video. |
deadbeef | ab9b2d1 | 2015-10-14 18:33:11 | [diff] [blame] | 431 | // If a new MediaStream is created it is added to |new_streams|. |
Steve Anton | 4171afb | 2017-11-20 18:20:22 | [diff] [blame] | 432 | void UpdateRemoteSendersList( |
deadbeef | ab9b2d1 | 2015-10-14 18:33:11 | [diff] [blame] | 433 | const std::vector<cricket::StreamParams>& streams, |
deadbeef | bda7e0b | 2015-12-09 01:13:40 | [diff] [blame] | 434 | bool default_track_needed, |
deadbeef | ab9b2d1 | 2015-10-14 18:33:11 | [diff] [blame] | 435 | cricket::MediaType media_type, |
| 436 | StreamCollection* new_streams); |
| 437 | |
Steve Anton | 4171afb | 2017-11-20 18:20:22 | [diff] [blame] | 438 | // Triggered when a remote sender has been seen for the first time in a remote |
deadbeef | ab9b2d1 | 2015-10-14 18:33:11 | [diff] [blame] | 439 | // session description. It creates a remote MediaStreamTrackInterface |
| 440 | // implementation and triggers CreateAudioReceiver or CreateVideoReceiver. |
Steve Anton | 4171afb | 2017-11-20 18:20:22 | [diff] [blame] | 441 | void OnRemoteSenderAdded(const RtpSenderInfo& sender_info, |
| 442 | cricket::MediaType media_type); |
deadbeef | ab9b2d1 | 2015-10-14 18:33:11 | [diff] [blame] | 443 | |
Steve Anton | 4171afb | 2017-11-20 18:20:22 | [diff] [blame] | 444 | // Triggered when a remote sender has been removed from a remote session |
| 445 | // description. It removes the remote sender with id |sender_id| from a remote |
deadbeef | ab9b2d1 | 2015-10-14 18:33:11 | [diff] [blame] | 446 | // MediaStream and triggers DestroyAudioReceiver or DestroyVideoReceiver. |
Steve Anton | 4171afb | 2017-11-20 18:20:22 | [diff] [blame] | 447 | void OnRemoteSenderRemoved(const RtpSenderInfo& sender_info, |
| 448 | cricket::MediaType media_type); |
deadbeef | ab9b2d1 | 2015-10-14 18:33:11 | [diff] [blame] | 449 | |
| 450 | // Finds remote MediaStreams without any tracks and removes them from |
| 451 | // |remote_streams_| and notifies the observer that the MediaStreams no longer |
| 452 | // exist. |
| 453 | void UpdateEndedRemoteMediaStreams(); |
| 454 | |
deadbeef | ab9b2d1 | 2015-10-14 18:33:11 | [diff] [blame] | 455 | // Loops through the vector of |streams| and finds added and removed |
| 456 | // StreamParams since last time this method was called. |
Steve Anton | 4171afb | 2017-11-20 18:20:22 | [diff] [blame] | 457 | // For each new or removed StreamParam, OnLocalSenderSeen or |
| 458 | // OnLocalSenderRemoved is invoked. |
| 459 | void UpdateLocalSenders(const std::vector<cricket::StreamParams>& streams, |
| 460 | cricket::MediaType media_type); |
deadbeef | ab9b2d1 | 2015-10-14 18:33:11 | [diff] [blame] | 461 | |
Steve Anton | 4171afb | 2017-11-20 18:20:22 | [diff] [blame] | 462 | // Triggered when a local sender has been seen for the first time in a local |
deadbeef | ab9b2d1 | 2015-10-14 18:33:11 | [diff] [blame] | 463 | // session description. |
| 464 | // This method triggers CreateAudioSender or CreateVideoSender if the rtp |
| 465 | // streams in the local SessionDescription can be mapped to a MediaStreamTrack |
| 466 | // in a MediaStream in |local_streams_| |
Steve Anton | 4171afb | 2017-11-20 18:20:22 | [diff] [blame] | 467 | void OnLocalSenderAdded(const RtpSenderInfo& sender_info, |
| 468 | cricket::MediaType media_type); |
deadbeef | ab9b2d1 | 2015-10-14 18:33:11 | [diff] [blame] | 469 | |
Steve Anton | 4171afb | 2017-11-20 18:20:22 | [diff] [blame] | 470 | // Triggered when a local sender has been removed from a local session |
deadbeef | ab9b2d1 | 2015-10-14 18:33:11 | [diff] [blame] | 471 | // description. |
| 472 | // This method triggers DestroyAudioSender or DestroyVideoSender if a stream |
| 473 | // has been removed from the local SessionDescription and the stream can be |
| 474 | // mapped to a MediaStreamTrack in a MediaStream in |local_streams_|. |
Steve Anton | 4171afb | 2017-11-20 18:20:22 | [diff] [blame] | 475 | void OnLocalSenderRemoved(const RtpSenderInfo& sender_info, |
| 476 | cricket::MediaType media_type); |
deadbeef | ab9b2d1 | 2015-10-14 18:33:11 | [diff] [blame] | 477 | |
| 478 | void UpdateLocalRtpDataChannels(const cricket::StreamParamsVec& streams); |
| 479 | void UpdateRemoteRtpDataChannels(const cricket::StreamParamsVec& streams); |
| 480 | void UpdateClosingRtpDataChannels( |
| 481 | const std::vector<std::string>& active_channels, |
| 482 | bool is_local_update); |
| 483 | void CreateRemoteRtpDataChannel(const std::string& label, |
| 484 | uint32_t remote_ssrc); |
| 485 | |
| 486 | // Creates channel and adds it to the collection of DataChannels that will |
| 487 | // be offered in a SessionDescription. |
| 488 | rtc::scoped_refptr<DataChannel> InternalCreateDataChannel( |
| 489 | const std::string& label, |
| 490 | const InternalDataChannelInit* config); |
| 491 | |
| 492 | // Checks if any data channel has been added. |
| 493 | bool HasDataChannels() const; |
| 494 | |
| 495 | void AllocateSctpSids(rtc::SSLRole role); |
| 496 | void OnSctpDataChannelClosed(DataChannel* channel); |
| 497 | |
deadbeef | ab9b2d1 | 2015-10-14 18:33:11 | [diff] [blame] | 498 | void OnDataChannelDestroyed(); |
Steve Anton | ba81867 | 2017-11-06 18:21:57 | [diff] [blame] | 499 | // Called when a valid data channel OPEN message is received. |
deadbeef | ab9b2d1 | 2015-10-14 18:33:11 | [diff] [blame] | 500 | void OnDataChannelOpenMessage(const std::string& label, |
| 501 | const InternalDataChannelInit& config); |
| 502 | |
Steve Anton | 4171afb | 2017-11-20 18:20:22 | [diff] [blame] | 503 | // Returns true if the PeerConnection is configured to use Unified Plan |
| 504 | // semantics for creating offers/answers and setting local/remote |
| 505 | // descriptions. If this is true the RtpTransceiver API will also be available |
| 506 | // to the user. If this is false, Plan B semantics are assumed. |
Steve Anton | 79e7960 | 2017-11-20 18:25:56 | [diff] [blame] | 507 | // TODO(bugs.webrtc.org/8530): Flip the default to be Unified Plan once |
| 508 | // sufficient time has passed. |
| 509 | bool IsUnifiedPlan() const { |
| 510 | return configuration_.sdp_semantics == SdpSemantics::kUnifiedPlan; |
| 511 | } |
Steve Anton | 4171afb | 2017-11-20 18:20:22 | [diff] [blame] | 512 | |
| 513 | // Is there an RtpSender of the given type? |
zhihuang | 1c378ed | 2017-08-17 21:10:50 | [diff] [blame] | 514 | bool HasRtpSender(cricket::MediaType type) const; |
deadbeef | fac0655 | 2015-11-25 19:26:01 | [diff] [blame] | 515 | |
Steve Anton | 4171afb | 2017-11-20 18:20:22 | [diff] [blame] | 516 | // Return the RtpSender with the given track attached. |
| 517 | rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>> |
| 518 | FindSenderForTrack(MediaStreamTrackInterface* track) const; |
deadbeef | 70ab1a1 | 2015-09-28 23:53:55 | [diff] [blame] | 519 | |
Steve Anton | 4171afb | 2017-11-20 18:20:22 | [diff] [blame] | 520 | // Return the RtpSender with the given id, or null if none exists. |
| 521 | rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>> |
| 522 | FindSenderById(const std::string& sender_id) const; |
| 523 | |
| 524 | // Return the RtpReceiver with the given id, or null if none exists. |
| 525 | rtc::scoped_refptr<RtpReceiverProxyWithInternal<RtpReceiverInternal>> |
| 526 | FindReceiverById(const std::string& receiver_id) const; |
| 527 | |
| 528 | std::vector<RtpSenderInfo>* GetRemoteSenderInfos( |
| 529 | cricket::MediaType media_type); |
| 530 | std::vector<RtpSenderInfo>* GetLocalSenderInfos( |
| 531 | cricket::MediaType media_type); |
| 532 | const RtpSenderInfo* FindSenderInfo(const std::vector<RtpSenderInfo>& infos, |
| 533 | const std::string& stream_label, |
| 534 | const std::string sender_id) const; |
deadbeef | ab9b2d1 | 2015-10-14 18:33:11 | [diff] [blame] | 535 | |
| 536 | // Returns the specified SCTP DataChannel in sctp_data_channels_, |
| 537 | // or nullptr if not found. |
| 538 | DataChannel* FindDataChannelBySid(int sid) const; |
| 539 | |
Taylor Brandstetter | a1c3035 | 2016-05-13 15:15:11 | [diff] [blame] | 540 | // Called when first configuring the port allocator. |
deadbeef | 91dd567 | 2016-05-18 23:55:30 | [diff] [blame] | 541 | bool InitializePortAllocator_n(const RTCConfiguration& configuration); |
deadbeef | 293e926 | 2017-01-11 20:28:30 | [diff] [blame] | 542 | // Called when SetConfiguration is called to apply the supported subset |
| 543 | // of the configuration on the network thread. |
| 544 | bool ReconfigurePortAllocator_n( |
| 545 | const cricket::ServerAddresses& stun_servers, |
| 546 | const std::vector<cricket::RelayServerConfig>& turn_servers, |
| 547 | IceTransportsType type, |
| 548 | int candidate_pool_size, |
Jonas Oreland | bdcee28 | 2017-10-10 12:01:40 | [diff] [blame] | 549 | bool prune_turn_ports, |
| 550 | webrtc::TurnCustomizer* turn_customizer); |
Taylor Brandstetter | a1c3035 | 2016-05-13 15:15:11 | [diff] [blame] | 551 | |
Elad Alon | 99c3fe5 | 2017-10-13 14:29:40 | [diff] [blame] | 552 | // Starts output of an RTC event log to the given output object. |
ivoc | 14d5dbe | 2016-07-04 14:06:55 | [diff] [blame] | 553 | // This function should only be called from the worker thread. |
Bjorn Terelius | de93943 | 2017-11-20 16:38:14 | [diff] [blame] | 554 | bool StartRtcEventLog_w(std::unique_ptr<RtcEventLogOutput> output, |
| 555 | int64_t output_period_ms); |
Elad Alon | 99c3fe5 | 2017-10-13 14:29:40 | [diff] [blame] | 556 | |
Elad Alon | acb2417 | 2017-10-06 12:32:13 | [diff] [blame] | 557 | // Stops recording an RTC event log. |
ivoc | 14d5dbe | 2016-07-04 14:06:55 | [diff] [blame] | 558 | // This function should only be called from the worker thread. |
| 559 | void StopRtcEventLog_w(); |
| 560 | |
Steve Anton | 038834f | 2017-07-14 22:59:59 | [diff] [blame] | 561 | // Ensures the configuration doesn't have any parameters with invalid values, |
| 562 | // or values that conflict with other parameters. |
| 563 | // |
| 564 | // Returns RTCError::OK() if there are no issues. |
| 565 | RTCError ValidateConfiguration(const RTCConfiguration& config) const; |
| 566 | |
Steve Anton | ba81867 | 2017-11-06 18:21:57 | [diff] [blame] | 567 | cricket::ChannelManager* channel_manager() const; |
| 568 | MetricsObserverInterface* metrics_observer() const; |
| 569 | |
Steve Anton | f847081 | 2017-12-04 18:46:21 | [diff] [blame] | 570 | enum class SessionError { |
| 571 | kNone, // No error. |
| 572 | kContent, // Error in BaseChannel SetLocalContent/SetRemoteContent. |
| 573 | kTransport, // Error from the underlying transport. |
| 574 | }; |
| 575 | |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 576 | // Returns the last error in the session. See the enum above for details. |
Steve Anton | f847081 | 2017-12-04 18:46:21 | [diff] [blame] | 577 | SessionError session_error() const { return session_error_; } |
| 578 | const std::string& session_error_desc() const { return session_error_desc_; } |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 579 | |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 580 | cricket::BaseChannel* GetChannel(const std::string& content_name); |
| 581 | |
| 582 | // Get current SSL role used by SCTP's underlying transport. |
| 583 | bool GetSctpSslRole(rtc::SSLRole* role); |
| 584 | |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 585 | cricket::IceConfig ParseIceConfig( |
| 586 | const PeerConnectionInterface::RTCConfiguration& config) const; |
| 587 | |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 588 | // Implements DataChannelProviderInterface. |
| 589 | bool SendData(const cricket::SendDataParams& params, |
| 590 | const rtc::CopyOnWriteBuffer& payload, |
| 591 | cricket::SendDataResult* result) override; |
| 592 | bool ConnectDataChannel(DataChannel* webrtc_data_channel) override; |
| 593 | void DisconnectDataChannel(DataChannel* webrtc_data_channel) override; |
| 594 | void AddSctpDataStream(int sid) override; |
| 595 | void RemoveSctpDataStream(int sid) override; |
| 596 | bool ReadyToSendData() const override; |
| 597 | |
| 598 | cricket::DataChannelType data_channel_type() const; |
| 599 | |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 600 | // Called when an RTCCertificate is generated or retrieved by |
| 601 | // WebRTCSessionDescriptionFactory. Should happen before setLocalDescription. |
| 602 | void OnCertificateReady( |
| 603 | const rtc::scoped_refptr<rtc::RTCCertificate>& certificate); |
| 604 | void OnDtlsSrtpSetupFailure(cricket::BaseChannel*, bool rtcp); |
| 605 | |
| 606 | cricket::TransportController* transport_controller() const { |
| 607 | return transport_controller_.get(); |
| 608 | } |
| 609 | |
| 610 | // Return all managed, non-null channels. |
| 611 | std::vector<cricket::BaseChannel*> Channels() const; |
| 612 | |
| 613 | // Non-const versions of local_description()/remote_description(), for use |
| 614 | // internally. |
| 615 | SessionDescriptionInterface* mutable_local_description() { |
| 616 | return pending_local_description_ ? pending_local_description_.get() |
| 617 | : current_local_description_.get(); |
| 618 | } |
| 619 | SessionDescriptionInterface* mutable_remote_description() { |
| 620 | return pending_remote_description_ ? pending_remote_description_.get() |
| 621 | : current_remote_description_.get(); |
| 622 | } |
| 623 | |
| 624 | // Updates the error state, signaling if necessary. |
Steve Anton | f847081 | 2017-12-04 18:46:21 | [diff] [blame] | 625 | void SetSessionError(SessionError error, const std::string& error_desc); |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 626 | |
Steve Anton | 3828c06 | 2017-12-06 18:34:51 | [diff] [blame] | 627 | RTCError UpdateSessionState(SdpType type, cricket::ContentSource source); |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 628 | // Push the media parts of the local or remote session description |
| 629 | // down to all of the channels. |
Steve Anton | 3828c06 | 2017-12-06 18:34:51 | [diff] [blame] | 630 | RTCError PushdownMediaDescription(SdpType type, |
Steve Anton | 8a00691 | 2017-12-04 23:25:56 | [diff] [blame] | 631 | cricket::ContentSource source); |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 632 | bool PushdownSctpParameters_n(cricket::ContentSource source); |
| 633 | |
Steve Anton | 8a00691 | 2017-12-04 23:25:56 | [diff] [blame] | 634 | RTCError PushdownTransportDescription(cricket::ContentSource source, |
Steve Anton | 3828c06 | 2017-12-06 18:34:51 | [diff] [blame] | 635 | SdpType type); |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 636 | |
| 637 | // Returns true and the TransportInfo of the given |content_name| |
| 638 | // from |description|. Returns false if it's not available. |
| 639 | static bool GetTransportDescription( |
| 640 | const cricket::SessionDescription* description, |
| 641 | const std::string& content_name, |
| 642 | cricket::TransportDescription* info); |
| 643 | |
Steve Anton | eda6ccd | 2017-12-04 18:21:55 | [diff] [blame] | 644 | // Returns the transport name for the given media section identified by |mid|. |
| 645 | // If BUNDLE is enabled and the media section is part of the bundle group, |
| 646 | // the transport name will be the first mid in the bundle group. Otherwise, |
| 647 | // the transport name will be the mid of the media section. |
| 648 | std::string GetTransportNameForMediaSection( |
| 649 | const std::string& mid, |
| 650 | const cricket::ContentGroup* bundle_group) const; |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 651 | |
| 652 | // Cause all the BaseChannels in the bundle group to have the same |
| 653 | // transport channel. |
| 654 | bool EnableBundle(const cricket::ContentGroup& bundle); |
| 655 | |
| 656 | // Enables media channels to allow sending of media. |
Steve Anton | ed10bd9 | 2017-12-05 18:52:59 | [diff] [blame] | 657 | // This enables media to flow on all configured audio/video channels and the |
| 658 | // RtpDataChannel. |
| 659 | void EnableSending(); |
Steve Anton | 3fe1b15 | 2017-12-12 18:20:08 | [diff] [blame^] | 660 | |
| 661 | // Stops all RtpTransceivers, destroys all BaseChannels and destroys the |
| 662 | // SCTP data channel. |
| 663 | void StopAndDestroyChannels(); |
| 664 | |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 665 | // Returns the media index for a local ice candidate given the content name. |
| 666 | // Returns false if the local session description does not have a media |
| 667 | // content called |content_name|. |
| 668 | bool GetLocalCandidateMediaIndex(const std::string& content_name, |
| 669 | int* sdp_mline_index); |
| 670 | // Uses all remote candidates in |remote_desc| in this session. |
| 671 | bool UseCandidatesInSessionDescription( |
| 672 | const SessionDescriptionInterface* remote_desc); |
| 673 | // Uses |candidate| in this session. |
| 674 | bool UseCandidate(const IceCandidateInterface* candidate); |
| 675 | // Deletes the corresponding channel of contents that don't exist in |desc|. |
| 676 | // |desc| can be null. This means that all channels are deleted. |
| 677 | void RemoveUnusedChannels(const cricket::SessionDescription* desc); |
| 678 | |
| 679 | // Allocates media channels based on the |desc|. If |desc| doesn't have |
| 680 | // the BUNDLE option, this method will disable BUNDLE in PortAllocator. |
| 681 | // This method will also delete any existing media channels before creating. |
Steve Anton | 8a00691 | 2017-12-04 23:25:56 | [diff] [blame] | 682 | RTCError CreateChannels(const cricket::SessionDescription* desc); |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 683 | |
| 684 | // Helper methods to create media channels. |
Steve Anton | eda6ccd | 2017-12-04 18:21:55 | [diff] [blame] | 685 | cricket::VoiceChannel* CreateVoiceChannel(const std::string& mid, |
| 686 | const std::string& transport_name); |
| 687 | cricket::VideoChannel* CreateVideoChannel(const std::string& mid, |
| 688 | const std::string& transport_name); |
| 689 | bool CreateDataChannel(const std::string& mid, |
| 690 | const std::string& transport_name); |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 691 | |
| 692 | std::unique_ptr<SessionStats> GetSessionStats_n( |
| 693 | const ChannelNamePairs& channel_name_pairs); |
| 694 | |
| 695 | bool CreateSctpTransport_n(const std::string& content_name, |
| 696 | const std::string& transport_name); |
| 697 | // For bundling. |
| 698 | void ChangeSctpTransport_n(const std::string& transport_name); |
| 699 | void DestroySctpTransport_n(); |
| 700 | // SctpTransport signal handlers. Needed to marshal signals from the network |
| 701 | // to signaling thread. |
| 702 | void OnSctpTransportReadyToSendData_n(); |
| 703 | // This may be called with "false" if the direction of the m= section causes |
| 704 | // us to tear down the SCTP connection. |
| 705 | void OnSctpTransportReadyToSendData_s(bool ready); |
| 706 | void OnSctpTransportDataReceived_n(const cricket::ReceiveDataParams& params, |
| 707 | const rtc::CopyOnWriteBuffer& payload); |
| 708 | // Beyond just firing the signal to the signaling thread, listens to SCTP |
| 709 | // CONTROL messages on unused SIDs and processes them as OPEN messages. |
| 710 | void OnSctpTransportDataReceived_s(const cricket::ReceiveDataParams& params, |
| 711 | const rtc::CopyOnWriteBuffer& payload); |
| 712 | void OnSctpStreamClosedRemotely_n(int sid); |
| 713 | |
| 714 | bool ValidateBundleSettings(const cricket::SessionDescription* desc); |
| 715 | bool HasRtcpMuxEnabled(const cricket::ContentInfo* content); |
| 716 | // Below methods are helper methods which verifies SDP. |
Steve Anton | 8a00691 | 2017-12-04 23:25:56 | [diff] [blame] | 717 | RTCError ValidateSessionDescription(const SessionDescriptionInterface* sdesc, |
| 718 | cricket::ContentSource source); |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 719 | |
Steve Anton | 3828c06 | 2017-12-06 18:34:51 | [diff] [blame] | 720 | // Check if a call to SetLocalDescription is acceptable with a session |
| 721 | // description of the given type. |
| 722 | bool ExpectSetLocalDescription(SdpType type); |
| 723 | // Check if a call to SetRemoteDescription is acceptable with a session |
| 724 | // description of the given type. |
| 725 | bool ExpectSetRemoteDescription(SdpType type); |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 726 | // Verifies a=setup attribute as per RFC 5763. |
| 727 | bool ValidateDtlsSetupAttribute(const cricket::SessionDescription* desc, |
Steve Anton | 3828c06 | 2017-12-06 18:34:51 | [diff] [blame] | 728 | SdpType type); |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 729 | |
| 730 | // Returns true if we are ready to push down the remote candidate. |
| 731 | // |remote_desc| is the new remote description, or NULL if the current remote |
| 732 | // description should be used. Output |valid| is true if the candidate media |
| 733 | // index is valid. |
| 734 | bool ReadyToUseRemoteCandidate(const IceCandidateInterface* candidate, |
| 735 | const SessionDescriptionInterface* remote_desc, |
| 736 | bool* valid); |
| 737 | |
| 738 | // Returns true if SRTP (either using DTLS-SRTP or SDES) is required by |
| 739 | // this session. |
| 740 | bool SrtpRequired() const; |
| 741 | |
| 742 | // TransportController signal handlers. |
| 743 | void OnTransportControllerConnectionState(cricket::IceConnectionState state); |
| 744 | void OnTransportControllerGatheringState(cricket::IceGatheringState state); |
| 745 | void OnTransportControllerCandidatesGathered( |
| 746 | const std::string& transport_name, |
| 747 | const std::vector<cricket::Candidate>& candidates); |
| 748 | void OnTransportControllerCandidatesRemoved( |
| 749 | const std::vector<cricket::Candidate>& candidates); |
| 750 | void OnTransportControllerDtlsHandshakeError(rtc::SSLHandshakeError error); |
| 751 | |
Steve Anton | f847081 | 2017-12-04 18:46:21 | [diff] [blame] | 752 | const char* SessionErrorToString(SessionError error) const; |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 753 | std::string GetSessionErrorMsg(); |
| 754 | |
| 755 | // Invoked when TransportController connection completion is signaled. |
| 756 | // Reports stats for all transports in use. |
| 757 | void ReportTransportStats(); |
| 758 | |
| 759 | // Gather the usage of IPv4/IPv6 as best connection. |
| 760 | void ReportBestConnectionState(const cricket::TransportStats& stats); |
| 761 | |
| 762 | void ReportNegotiatedCiphers(const cricket::TransportStats& stats); |
| 763 | |
| 764 | void OnSentPacket_w(const rtc::SentPacket& sent_packet); |
| 765 | |
| 766 | const std::string GetTransportName(const std::string& content_name); |
| 767 | |
| 768 | void DestroyRtcpTransport_n(const std::string& transport_name); |
Steve Anton | 6fec880 | 2017-12-04 18:37:29 | [diff] [blame] | 769 | |
| 770 | // Destroys and clears the BaseChannel associated with the given transceiver, |
| 771 | // if such channel is set. |
| 772 | void DestroyTransceiverChannel( |
| 773 | rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>> |
| 774 | transceiver); |
| 775 | |
| 776 | // Destroys the RTP data channel and/or the SCTP data channel and clears it. |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 777 | void DestroyDataChannel(); |
| 778 | |
Steve Anton | 6fec880 | 2017-12-04 18:37:29 | [diff] [blame] | 779 | // Destroys the given BaseChannel. The channel cannot be accessed after this |
| 780 | // method is called. |
| 781 | void DestroyBaseChannel(cricket::BaseChannel* channel); |
| 782 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 783 | // Storing the factory as a scoped reference pointer ensures that the memory |
| 784 | // in the PeerConnectionFactoryImpl remains available as long as the |
| 785 | // PeerConnection is running. It is passed to PeerConnection as a raw pointer. |
| 786 | // However, since the reference counting is done in the |
deadbeef | ab9b2d1 | 2015-10-14 18:33:11 | [diff] [blame] | 787 | // PeerConnectionFactoryInterface all instances created using the raw pointer |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 788 | // will refer to the same reference count. |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 | [diff] [blame] | 789 | rtc::scoped_refptr<PeerConnectionFactory> factory_; |
Steve Anton | ba81867 | 2017-11-06 18:21:57 | [diff] [blame] | 790 | PeerConnectionObserver* observer_ = nullptr; |
| 791 | UMAObserver* uma_observer_ = nullptr; |
terelius | 3386025 | 2017-05-13 06:37:18 | [diff] [blame] | 792 | |
| 793 | // The EventLog needs to outlive |call_| (and any other object that uses it). |
| 794 | std::unique_ptr<RtcEventLog> event_log_; |
| 795 | |
Steve Anton | ba81867 | 2017-11-06 18:21:57 | [diff] [blame] | 796 | SignalingState signaling_state_ = kStable; |
| 797 | IceConnectionState ice_connection_state_ = kIceConnectionNew; |
| 798 | IceGatheringState ice_gathering_state_ = kIceGatheringNew; |
deadbeef | 46c7389 | 2016-11-17 03:42:04 | [diff] [blame] | 799 | PeerConnectionInterface::RTCConfiguration configuration_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 800 | |
kwiberg | d1fe281 | 2016-04-27 13:47:29 | [diff] [blame] | 801 | std::unique_ptr<cricket::PortAllocator> port_allocator_; |
deadbeef | ab9b2d1 | 2015-10-14 18:33:11 | [diff] [blame] | 802 | |
zhihuang | 8f65cdf | 2016-05-07 01:40:30 | [diff] [blame] | 803 | // One PeerConnection has only one RTCP CNAME. |
| 804 | // https://tools.ietf.org/html/draft-ietf-rtcweb-rtp-usage-26#section-4.9 |
| 805 | std::string rtcp_cname_; |
| 806 | |
deadbeef | ab9b2d1 | 2015-10-14 18:33:11 | [diff] [blame] | 807 | // Streams added via AddStream. |
| 808 | rtc::scoped_refptr<StreamCollection> local_streams_; |
| 809 | // Streams created as a result of SetRemoteDescription. |
| 810 | rtc::scoped_refptr<StreamCollection> remote_streams_; |
| 811 | |
kwiberg | d1fe281 | 2016-04-27 13:47:29 | [diff] [blame] | 812 | std::vector<std::unique_ptr<MediaStreamObserver>> stream_observers_; |
deadbeef | eb45981 | 2015-12-16 03:24:43 | [diff] [blame] | 813 | |
Steve Anton | 4171afb | 2017-11-20 18:20:22 | [diff] [blame] | 814 | // These lists store sender info seen in local/remote descriptions. |
| 815 | std::vector<RtpSenderInfo> remote_audio_sender_infos_; |
| 816 | std::vector<RtpSenderInfo> remote_video_sender_infos_; |
| 817 | std::vector<RtpSenderInfo> local_audio_sender_infos_; |
| 818 | std::vector<RtpSenderInfo> local_video_sender_infos_; |
deadbeef | ab9b2d1 | 2015-10-14 18:33:11 | [diff] [blame] | 819 | |
| 820 | SctpSidAllocator sid_allocator_; |
| 821 | // label -> DataChannel |
| 822 | std::map<std::string, rtc::scoped_refptr<DataChannel>> rtp_data_channels_; |
| 823 | std::vector<rtc::scoped_refptr<DataChannel>> sctp_data_channels_; |
deadbeef | bd29246 | 2015-12-15 02:15:29 | [diff] [blame] | 824 | std::vector<rtc::scoped_refptr<DataChannel>> sctp_data_channels_to_free_; |
deadbeef | ab9b2d1 | 2015-10-14 18:33:11 | [diff] [blame] | 825 | |
deadbeef | bda7e0b | 2015-12-09 01:13:40 | [diff] [blame] | 826 | bool remote_peer_supports_msid_ = false; |
deadbeef | 70ab1a1 | 2015-09-28 23:53:55 | [diff] [blame] | 827 | |
terelius | 3386025 | 2017-05-13 06:37:18 | [diff] [blame] | 828 | std::unique_ptr<Call> call_; |
terelius | 3386025 | 2017-05-13 06:37:18 | [diff] [blame] | 829 | std::unique_ptr<StatsCollector> stats_; // A pointer is passed to senders_ |
| 830 | rtc::scoped_refptr<RTCStatsCollector> stats_collector_; |
| 831 | |
deadbeef | a601f5c | 2016-06-06 21:27:39 | [diff] [blame] | 832 | std::vector< |
Steve Anton | 4171afb | 2017-11-20 18:20:22 | [diff] [blame] | 833 | rtc::scoped_refptr<RtpTransceiverProxyWithInternal<RtpTransceiver>>> |
| 834 | transceivers_; |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 835 | |
Steve Anton | f847081 | 2017-12-04 18:46:21 | [diff] [blame] | 836 | SessionError session_error_ = SessionError::kNone; |
| 837 | std::string session_error_desc_; |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 838 | |
| 839 | std::string session_id_; |
| 840 | rtc::Optional<bool> initial_offerer_; |
| 841 | |
| 842 | std::unique_ptr<cricket::TransportController> transport_controller_; |
| 843 | std::unique_ptr<cricket::SctpTransportInternalFactory> sctp_factory_; |
Steve Anton | 75737c0 | 2017-11-06 18:37:17 | [diff] [blame] | 844 | // |rtp_data_channel_| is used if in RTP data channel mode, |sctp_transport_| |
| 845 | // when using SCTP. |
| 846 | cricket::RtpDataChannel* rtp_data_channel_ = nullptr; |
| 847 | |
| 848 | std::unique_ptr<cricket::SctpTransportInternal> sctp_transport_; |
| 849 | // |sctp_transport_name_| keeps track of what DTLS transport the SCTP |
| 850 | // transport is using (which can change due to bundling). |
| 851 | rtc::Optional<std::string> sctp_transport_name_; |
| 852 | // |sctp_content_name_| is the content name (MID) in SDP. |
| 853 | rtc::Optional<std::string> sctp_content_name_; |
| 854 | // Value cached on signaling thread. Only updated when SctpReadyToSendData |
| 855 | // fires on the signaling thread. |
| 856 | bool sctp_ready_to_send_data_ = false; |
| 857 | // Same as signals provided by SctpTransport, but these are guaranteed to |
| 858 | // fire on the signaling thread, whereas SctpTransport fires on the networking |
| 859 | // thread. |
| 860 | // |sctp_invoker_| is used so that any signals queued on the signaling thread |
| 861 | // from the network thread are immediately discarded if the SctpTransport is |
| 862 | // destroyed (due to m= section being rejected). |
| 863 | // TODO(deadbeef): Use a proxy object to ensure that method calls/signals |
| 864 | // are marshalled to the right thread. Could almost use proxy.h for this, |
| 865 | // but it doesn't have a mechanism for marshalling sigslot::signals |
| 866 | std::unique_ptr<rtc::AsyncInvoker> sctp_invoker_; |
| 867 | sigslot::signal1<bool> SignalSctpReadyToSendData; |
| 868 | sigslot::signal2<const cricket::ReceiveDataParams&, |
| 869 | const rtc::CopyOnWriteBuffer&> |
| 870 | SignalSctpDataReceived; |
| 871 | sigslot::signal1<int> SignalSctpStreamClosedRemotely; |
| 872 | |
| 873 | std::unique_ptr<SessionDescriptionInterface> current_local_description_; |
| 874 | std::unique_ptr<SessionDescriptionInterface> pending_local_description_; |
| 875 | std::unique_ptr<SessionDescriptionInterface> current_remote_description_; |
| 876 | std::unique_ptr<SessionDescriptionInterface> pending_remote_description_; |
| 877 | bool dtls_enabled_ = false; |
| 878 | // Specifies which kind of data channel is allowed. This is controlled |
| 879 | // by the chrome command-line flag and constraints: |
| 880 | // 1. If chrome command-line switch 'enable-sctp-data-channels' is enabled, |
| 881 | // constraint kEnableDtlsSrtp is true, and constaint kEnableRtpDataChannels is |
| 882 | // not set or false, SCTP is allowed (DCT_SCTP); |
| 883 | // 2. If constraint kEnableRtpDataChannels is true, RTP is allowed (DCT_RTP); |
| 884 | // 3. If both 1&2 are false, data channel is not allowed (DCT_NONE). |
| 885 | cricket::DataChannelType data_channel_type_ = cricket::DCT_NONE; |
| 886 | // List of content names for which the remote side triggered an ICE restart. |
| 887 | std::set<std::string> pending_ice_restarts_; |
| 888 | |
| 889 | std::unique_ptr<WebRtcSessionDescriptionFactory> webrtc_session_desc_factory_; |
| 890 | |
| 891 | // Member variables for caching global options. |
| 892 | cricket::AudioOptions audio_options_; |
| 893 | cricket::VideoOptions video_options_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 | [diff] [blame] | 894 | }; |
| 895 | |
| 896 | } // namespace webrtc |
| 897 | |
Mirko Bonadei | 92ea95e | 2017-09-15 04:47:31 | [diff] [blame] | 898 | #endif // PC_PEERCONNECTION_H_ |