blob: 5889629bab3abe71f7b848d1e4a5fb2a23f071d6 [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:361/*
kjellanderb24317b2016-02-10 15:54:432 * Copyright 2012 The WebRTC project authors. All Rights Reserved.
henrike@webrtc.org28e20752013-07-10 00:45:363 *
kjellanderb24317b2016-02-10 15:54:434 * 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.org28e20752013-07-10 00:45:369 */
10
ossu7bb87ee2017-01-23 12:56:2511#ifndef WEBRTC_PC_PEERCONNECTION_H_
12#define WEBRTC_PC_PEERCONNECTION_H_
henrike@webrtc.org28e20752013-07-10 00:45:3613
14#include <string>
perkjd61bf802016-03-24 10:16:1915#include <map>
kwibergd1fe2812016-04-27 13:47:2916#include <memory>
perkjd61bf802016-03-24 10:16:1917#include <vector>
henrike@webrtc.org28e20752013-07-10 00:45:3618
Henrik Kjellander15583c12016-02-10 09:53:1219#include "webrtc/api/peerconnectioninterface.h"
deadbeef1dcb1642017-03-30 04:08:1620#include "webrtc/pc/iceserverparsing.h"
ossu7bb87ee2017-01-23 12:56:2521#include "webrtc/pc/peerconnectionfactory.h"
22#include "webrtc/pc/rtcstatscollector.h"
23#include "webrtc/pc/rtpreceiver.h"
24#include "webrtc/pc/rtpsender.h"
25#include "webrtc/pc/statscollector.h"
26#include "webrtc/pc/streamcollection.h"
27#include "webrtc/pc/webrtcsession.h"
henrike@webrtc.org28e20752013-07-10 00:45:3628
29namespace webrtc {
henrike@webrtc.org28e20752013-07-10 00:45:3630
deadbeefeb459812015-12-16 03:24:4331class MediaStreamObserver;
perkjf0dcfe22016-03-10 17:32:0032class VideoRtpReceiver;
skvlad11a9cbf2016-10-07 18:53:0533class RtcEventLog;
deadbeefab9b2d12015-10-14 18:33:1134
zhihuang1c378ed2017-08-17 21:10:5035// TODO(zhihuang): Remove this declaration when the WebRtcSession tests don't
36// need it.
37void ExtractSharedMediaSessionOptions(
deadbeefab9b2d12015-10-14 18:33:1138 const PeerConnectionInterface::RTCOfferAnswerOptions& rtc_options,
39 cricket::MediaSessionOptions* session_options);
40
deadbeef70ab1a12015-09-28 23:53:5541// PeerConnection implements the PeerConnectionInterface interface.
deadbeefab9b2d12015-10-14 18:33:1142// It uses WebRtcSession to implement the PeerConnection functionality.
henrike@webrtc.org28e20752013-07-10 00:45:3643class PeerConnection : public PeerConnectionInterface,
henrike@webrtc.org28e20752013-07-10 00:45:3644 public IceObserver,
buildbot@webrtc.orgd4e598d2014-07-29 17:36:5245 public rtc::MessageHandler,
henrike@webrtc.org28e20752013-07-10 00:45:3646 public sigslot::has_slots<> {
47 public:
zhihuang38ede132017-06-15 19:52:3248 explicit PeerConnection(PeerConnectionFactory* factory,
49 std::unique_ptr<RtcEventLog> event_log,
50 std::unique_ptr<Call> call);
henrike@webrtc.org28e20752013-07-10 00:45:3651
deadbeef653b8e02015-11-11 20:55:1052 bool Initialize(
53 const PeerConnectionInterface::RTCConfiguration& configuration,
kwibergd1fe2812016-04-27 13:47:2954 std::unique_ptr<cricket::PortAllocator> allocator,
Henrik Boströmd03c23b2016-06-01 09:44:1855 std::unique_ptr<rtc::RTCCertificateGeneratorInterface> cert_generator,
deadbeef653b8e02015-11-11 20:55:1056 PeerConnectionObserver* observer);
57
deadbeefa67696b2015-09-29 18:56:2658 rtc::scoped_refptr<StreamCollectionInterface> local_streams() override;
59 rtc::scoped_refptr<StreamCollectionInterface> remote_streams() override;
60 bool AddStream(MediaStreamInterface* local_stream) override;
61 void RemoveStream(MediaStreamInterface* local_stream) override;
henrike@webrtc.org28e20752013-07-10 00:45:3662
deadbeefe1f9d832016-01-14 23:35:4263 rtc::scoped_refptr<RtpSenderInterface> AddTrack(
64 MediaStreamTrackInterface* track,
65 std::vector<MediaStreamInterface*> streams) override;
66 bool RemoveTrack(RtpSenderInterface* sender) override;
67
deadbeefab9b2d12015-10-14 18:33:1168 virtual WebRtcSession* session() { return session_.get(); }
69
deadbeefa67696b2015-09-29 18:56:2670 rtc::scoped_refptr<DtmfSenderInterface> CreateDtmfSender(
71 AudioTrackInterface* track) override;
henrike@webrtc.org28e20752013-07-10 00:45:3672
deadbeeffac06552015-11-25 19:26:0173 rtc::scoped_refptr<RtpSenderInterface> CreateSender(
deadbeefbd7d8f72015-12-19 00:58:4474 const std::string& kind,
75 const std::string& stream_id) override;
deadbeeffac06552015-11-25 19:26:0176
deadbeef70ab1a12015-09-28 23:53:5577 std::vector<rtc::scoped_refptr<RtpSenderInterface>> GetSenders()
78 const override;
79 std::vector<rtc::scoped_refptr<RtpReceiverInterface>> GetReceivers()
80 const override;
81
deadbeefa67696b2015-09-29 18:56:2682 rtc::scoped_refptr<DataChannelInterface> CreateDataChannel(
henrike@webrtc.org28e20752013-07-10 00:45:3683 const std::string& label,
deadbeefa67696b2015-09-29 18:56:2684 const DataChannelInit* config) override;
85 bool GetStats(StatsObserver* observer,
86 webrtc::MediaStreamTrackInterface* track,
87 StatsOutputLevel level) override;
hbos74e1a4f2016-09-16 06:33:0188 void GetStats(RTCStatsCollectorCallback* callback) override;
henrike@webrtc.org28e20752013-07-10 00:45:3689
deadbeefa67696b2015-09-29 18:56:2690 SignalingState signaling_state() override;
henrike@webrtc.org28e20752013-07-10 00:45:3691
deadbeefa67696b2015-09-29 18:56:2692 IceConnectionState ice_connection_state() override;
93 IceGatheringState ice_gathering_state() override;
henrike@webrtc.org28e20752013-07-10 00:45:3694
deadbeefa67696b2015-09-29 18:56:2695 const SessionDescriptionInterface* local_description() const override;
96 const SessionDescriptionInterface* remote_description() const override;
deadbeeffe4a8a42016-12-21 01:56:1797 const SessionDescriptionInterface* current_local_description() const override;
98 const SessionDescriptionInterface* current_remote_description()
99 const override;
100 const SessionDescriptionInterface* pending_local_description() const override;
101 const SessionDescriptionInterface* pending_remote_description()
102 const override;
henrike@webrtc.org28e20752013-07-10 00:45:36103
104 // JSEP01
htaa2a49d92016-03-04 10:51:39105 // Deprecated, use version without constraints.
deadbeefa67696b2015-09-29 18:56:26106 void CreateOffer(CreateSessionDescriptionObserver* observer,
107 const MediaConstraintsInterface* constraints) override;
108 void CreateOffer(CreateSessionDescriptionObserver* observer,
109 const RTCOfferAnswerOptions& options) override;
htaa2a49d92016-03-04 10:51:39110 // Deprecated, use version without constraints.
deadbeefa67696b2015-09-29 18:56:26111 void CreateAnswer(CreateSessionDescriptionObserver* observer,
112 const MediaConstraintsInterface* constraints) override;
htaa2a49d92016-03-04 10:51:39113 void CreateAnswer(CreateSessionDescriptionObserver* observer,
114 const RTCOfferAnswerOptions& options) override;
deadbeefa67696b2015-09-29 18:56:26115 void SetLocalDescription(SetSessionDescriptionObserver* observer,
116 SessionDescriptionInterface* desc) override;
117 void SetRemoteDescription(SetSessionDescriptionObserver* observer,
118 SessionDescriptionInterface* desc) override;
deadbeef46c73892016-11-17 03:42:04119 PeerConnectionInterface::RTCConfiguration GetConfiguration() override;
deadbeefa67696b2015-09-29 18:56:26120 bool SetConfiguration(
deadbeef293e9262017-01-11 20:28:30121 const PeerConnectionInterface::RTCConfiguration& configuration,
122 RTCError* error) override;
123 bool SetConfiguration(
124 const PeerConnectionInterface::RTCConfiguration& configuration) override {
125 return SetConfiguration(configuration, nullptr);
126 }
deadbeefa67696b2015-09-29 18:56:26127 bool AddIceCandidate(const IceCandidateInterface* candidate) override;
Honghai Zhang7fb69db2016-03-14 18:59:18128 bool RemoveIceCandidates(
129 const std::vector<cricket::Candidate>& candidates) override;
henrike@webrtc.org28e20752013-07-10 00:45:36130
deadbeefa67696b2015-09-29 18:56:26131 void RegisterUMAObserver(UMAObserver* observer) override;
buildbot@webrtc.org1567b8c2014-05-08 19:54:16132
zstein4b979802017-06-02 21:37:37133 RTCError SetBitrate(const BitrateParameters& bitrate) override;
134
ivoc14d5dbe2016-07-04 14:06:55135 bool StartRtcEventLog(rtc::PlatformFile file,
136 int64_t max_size_bytes) override;
137 void StopRtcEventLog() override;
138
deadbeefa67696b2015-09-29 18:56:26139 void Close() override;
henrike@webrtc.org28e20752013-07-10 00:45:36140
hbos82ebe022016-11-14 09:41:09141 sigslot::signal1<DataChannel*> SignalDataChannelCreated;
142
deadbeefab9b2d12015-10-14 18:33:11143 // Virtual for unit tests.
144 virtual const std::vector<rtc::scoped_refptr<DataChannel>>&
145 sctp_data_channels() const {
146 return sctp_data_channels_;
perkjd61bf802016-03-24 10:16:19147 }
deadbeefab9b2d12015-10-14 18:33:11148
henrike@webrtc.org28e20752013-07-10 00:45:36149 protected:
deadbeefa67696b2015-09-29 18:56:26150 ~PeerConnection() override;
henrike@webrtc.org28e20752013-07-10 00:45:36151
152 private:
deadbeefab9b2d12015-10-14 18:33:11153 struct TrackInfo {
154 TrackInfo() : ssrc(0) {}
155 TrackInfo(const std::string& stream_label,
156 const std::string track_id,
157 uint32_t ssrc)
158 : stream_label(stream_label), track_id(track_id), ssrc(ssrc) {}
deadbeefbda7e0b2015-12-09 01:13:40159 bool operator==(const TrackInfo& other) {
160 return this->stream_label == other.stream_label &&
161 this->track_id == other.track_id && this->ssrc == other.ssrc;
162 }
deadbeefab9b2d12015-10-14 18:33:11163 std::string stream_label;
164 std::string track_id;
165 uint32_t ssrc;
166 };
167 typedef std::vector<TrackInfo> TrackInfos;
168
henrike@webrtc.org28e20752013-07-10 00:45:36169 // Implements MessageHandler.
deadbeefa67696b2015-09-29 18:56:26170 void OnMessage(rtc::Message* msg) override;
henrike@webrtc.org28e20752013-07-10 00:45:36171
deadbeefab9b2d12015-10-14 18:33:11172 void CreateAudioReceiver(MediaStreamInterface* stream,
perkjd61bf802016-03-24 10:16:19173 const std::string& track_id,
deadbeefab9b2d12015-10-14 18:33:11174 uint32_t ssrc);
perkjf0dcfe22016-03-10 17:32:00175
deadbeefab9b2d12015-10-14 18:33:11176 void CreateVideoReceiver(MediaStreamInterface* stream,
perkjf0dcfe22016-03-10 17:32:00177 const std::string& track_id,
deadbeefab9b2d12015-10-14 18:33:11178 uint32_t ssrc);
perkjd61bf802016-03-24 10:16:19179 void DestroyReceiver(const std::string& track_id);
korniltsev.anatolyec390b52017-07-25 00:00:25180
181 // May be called either by AddStream/RemoveStream, or when a track is
182 // added/removed from a stream previously added via AddStream.
183 void AddAudioTrack(AudioTrackInterface* track, MediaStreamInterface* stream);
184 void RemoveAudioTrack(AudioTrackInterface* track,
185 MediaStreamInterface* stream);
186 void AddVideoTrack(VideoTrackInterface* track, MediaStreamInterface* stream);
187 void RemoveVideoTrack(VideoTrackInterface* track,
188 MediaStreamInterface* stream);
henrike@webrtc.org28e20752013-07-10 00:45:36189
190 // Implements IceObserver
zstein6dfd53a2017-03-06 21:49:03191 void OnIceConnectionStateChange(IceConnectionState new_state) override;
Peter Thatcher54360512015-07-08 18:08:35192 void OnIceGatheringChange(IceGatheringState new_state) override;
jbauch81bf7b02017-03-25 15:31:12193 void OnIceCandidate(
194 std::unique_ptr<IceCandidateInterface> candidate) override;
Honghai Zhang7fb69db2016-03-14 18:59:18195 void OnIceCandidatesRemoved(
196 const std::vector<cricket::Candidate>& candidates) override;
Peter Thatcher54360512015-07-08 18:08:35197 void OnIceConnectionReceivingChange(bool receiving) override;
henrike@webrtc.org28e20752013-07-10 00:45:36198
199 // Signals from WebRtcSession.
deadbeefd59daf82015-10-14 22:02:44200 void OnSessionStateChange(WebRtcSession* session, WebRtcSession::State state);
henrike@webrtc.org28e20752013-07-10 00:45:36201 void ChangeSignalingState(SignalingState signaling_state);
202
deadbeefeb459812015-12-16 03:24:43203 // Signals from MediaStreamObserver.
204 void OnAudioTrackAdded(AudioTrackInterface* track,
205 MediaStreamInterface* stream);
206 void OnAudioTrackRemoved(AudioTrackInterface* track,
207 MediaStreamInterface* stream);
208 void OnVideoTrackAdded(VideoTrackInterface* track,
209 MediaStreamInterface* stream);
210 void OnVideoTrackRemoved(VideoTrackInterface* track,
211 MediaStreamInterface* stream);
212
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52213 rtc::Thread* signaling_thread() const {
henrike@webrtc.org28e20752013-07-10 00:45:36214 return factory_->signaling_thread();
215 }
216
deadbeef91dd5672016-05-18 23:55:30217 rtc::Thread* network_thread() const { return factory_->network_thread(); }
Taylor Brandstettera1c30352016-05-13 15:15:11218
henrike@webrtc.org28e20752013-07-10 00:45:36219 void PostSetSessionDescriptionFailure(SetSessionDescriptionObserver* observer,
220 const std::string& error);
deadbeefab9b2d12015-10-14 18:33:11221 void PostCreateSessionDescriptionFailure(
222 CreateSessionDescriptionObserver* observer,
223 const std::string& error);
henrike@webrtc.org28e20752013-07-10 00:45:36224
225 bool IsClosed() const {
226 return signaling_state_ == PeerConnectionInterface::kClosed;
227 }
228
deadbeefab9b2d12015-10-14 18:33:11229 // Returns a MediaSessionOptions struct with options decided by |options|,
230 // the local MediaStreams and DataChannels.
zhihuang1c378ed2017-08-17 21:10:50231 void GetOptionsForOffer(
deadbeefab9b2d12015-10-14 18:33:11232 const PeerConnectionInterface::RTCOfferAnswerOptions& rtc_options,
233 cricket::MediaSessionOptions* session_options);
234
235 // Returns a MediaSessionOptions struct with options decided by
236 // |constraints|, the local MediaStreams and DataChannels.
zhihuang1c378ed2017-08-17 21:10:50237 void GetOptionsForAnswer(const RTCOfferAnswerOptions& options,
238 cricket::MediaSessionOptions* session_options);
htaa2a49d92016-03-04 10:51:39239
zhihuang1c378ed2017-08-17 21:10:50240 // Generates MediaDescriptionOptions for the |session_opts| based on existing
241 // local description or remote description.
242 void GenerateMediaDescriptionOptions(
243 const SessionDescriptionInterface* session_desc,
244 cricket::RtpTransceiverDirection audio_direction,
245 cricket::RtpTransceiverDirection video_direction,
246 rtc::Optional<size_t>* audio_index,
247 rtc::Optional<size_t>* video_index,
248 rtc::Optional<size_t>* data_index,
htaa2a49d92016-03-04 10:51:39249 cricket::MediaSessionOptions* session_options);
deadbeefab9b2d12015-10-14 18:33:11250
deadbeeffaac4972015-11-12 23:33:07251 // Remove all local and remote tracks of type |media_type|.
252 // Called when a media type is rejected (m-line set to port 0).
253 void RemoveTracks(cricket::MediaType media_type);
254
deadbeefbda7e0b2015-12-09 01:13:40255 // Makes sure a MediaStreamTrack is created for each StreamParam in |streams|,
256 // and existing MediaStreamTracks are removed if there is no corresponding
257 // StreamParam. If |default_track_needed| is true, a default MediaStreamTrack
258 // is created if it doesn't exist; if false, it's removed if it exists.
259 // |media_type| is the type of the |streams| and can be either audio or video.
deadbeefab9b2d12015-10-14 18:33:11260 // If a new MediaStream is created it is added to |new_streams|.
261 void UpdateRemoteStreamsList(
262 const std::vector<cricket::StreamParams>& streams,
deadbeefbda7e0b2015-12-09 01:13:40263 bool default_track_needed,
deadbeefab9b2d12015-10-14 18:33:11264 cricket::MediaType media_type,
265 StreamCollection* new_streams);
266
267 // Triggered when a remote track has been seen for the first time in a remote
268 // session description. It creates a remote MediaStreamTrackInterface
269 // implementation and triggers CreateAudioReceiver or CreateVideoReceiver.
270 void OnRemoteTrackSeen(const std::string& stream_label,
271 const std::string& track_id,
272 uint32_t ssrc,
273 cricket::MediaType media_type);
274
275 // Triggered when a remote track has been removed from a remote session
276 // description. It removes the remote track with id |track_id| from a remote
277 // MediaStream and triggers DestroyAudioReceiver or DestroyVideoReceiver.
278 void OnRemoteTrackRemoved(const std::string& stream_label,
279 const std::string& track_id,
280 cricket::MediaType media_type);
281
282 // Finds remote MediaStreams without any tracks and removes them from
283 // |remote_streams_| and notifies the observer that the MediaStreams no longer
284 // exist.
285 void UpdateEndedRemoteMediaStreams();
286
deadbeefab9b2d12015-10-14 18:33:11287 // Loops through the vector of |streams| and finds added and removed
288 // StreamParams since last time this method was called.
289 // For each new or removed StreamParam, OnLocalTrackSeen or
290 // OnLocalTrackRemoved is invoked.
291 void UpdateLocalTracks(const std::vector<cricket::StreamParams>& streams,
292 cricket::MediaType media_type);
293
294 // Triggered when a local track has been seen for the first time in a local
295 // session description.
296 // This method triggers CreateAudioSender or CreateVideoSender if the rtp
297 // streams in the local SessionDescription can be mapped to a MediaStreamTrack
298 // in a MediaStream in |local_streams_|
299 void OnLocalTrackSeen(const std::string& stream_label,
300 const std::string& track_id,
301 uint32_t ssrc,
302 cricket::MediaType media_type);
303
304 // Triggered when a local track has been removed from a local session
305 // description.
306 // This method triggers DestroyAudioSender or DestroyVideoSender if a stream
307 // has been removed from the local SessionDescription and the stream can be
308 // mapped to a MediaStreamTrack in a MediaStream in |local_streams_|.
309 void OnLocalTrackRemoved(const std::string& stream_label,
310 const std::string& track_id,
311 uint32_t ssrc,
312 cricket::MediaType media_type);
313
314 void UpdateLocalRtpDataChannels(const cricket::StreamParamsVec& streams);
315 void UpdateRemoteRtpDataChannels(const cricket::StreamParamsVec& streams);
316 void UpdateClosingRtpDataChannels(
317 const std::vector<std::string>& active_channels,
318 bool is_local_update);
319 void CreateRemoteRtpDataChannel(const std::string& label,
320 uint32_t remote_ssrc);
321
322 // Creates channel and adds it to the collection of DataChannels that will
323 // be offered in a SessionDescription.
324 rtc::scoped_refptr<DataChannel> InternalCreateDataChannel(
325 const std::string& label,
326 const InternalDataChannelInit* config);
327
328 // Checks if any data channel has been added.
329 bool HasDataChannels() const;
330
331 void AllocateSctpSids(rtc::SSLRole role);
332 void OnSctpDataChannelClosed(DataChannel* channel);
333
334 // Notifications from WebRtcSession relating to BaseChannels.
Taylor Brandstetterba29c6a2016-06-27 23:30:35335 void OnVoiceChannelCreated();
deadbeefab9b2d12015-10-14 18:33:11336 void OnVoiceChannelDestroyed();
Taylor Brandstetterba29c6a2016-06-27 23:30:35337 void OnVideoChannelCreated();
deadbeefab9b2d12015-10-14 18:33:11338 void OnVideoChannelDestroyed();
339 void OnDataChannelCreated();
340 void OnDataChannelDestroyed();
341 // Called when the cricket::DataChannel receives a message indicating that a
342 // webrtc::DataChannel should be opened.
343 void OnDataChannelOpenMessage(const std::string& label,
344 const InternalDataChannelInit& config);
345
zhihuang1c378ed2017-08-17 21:10:50346 bool HasRtpSender(cricket::MediaType type) const;
deadbeefa601f5c2016-06-06 21:27:39347 RtpSenderInternal* FindSenderById(const std::string& id);
deadbeeffac06552015-11-25 19:26:01348
deadbeefa601f5c2016-06-06 21:27:39349 std::vector<rtc::scoped_refptr<
350 RtpSenderProxyWithInternal<RtpSenderInternal>>>::iterator
deadbeef70ab1a12015-09-28 23:53:55351 FindSenderForTrack(MediaStreamTrackInterface* track);
deadbeefa601f5c2016-06-06 21:27:39352 std::vector<rtc::scoped_refptr<
353 RtpReceiverProxyWithInternal<RtpReceiverInternal>>>::iterator
perkjd61bf802016-03-24 10:16:19354 FindReceiverForTrack(const std::string& track_id);
deadbeef70ab1a12015-09-28 23:53:55355
deadbeefab9b2d12015-10-14 18:33:11356 TrackInfos* GetRemoteTracks(cricket::MediaType media_type);
357 TrackInfos* GetLocalTracks(cricket::MediaType media_type);
358 const TrackInfo* FindTrackInfo(const TrackInfos& infos,
359 const std::string& stream_label,
360 const std::string track_id) const;
361
362 // Returns the specified SCTP DataChannel in sctp_data_channels_,
363 // or nullptr if not found.
364 DataChannel* FindDataChannelBySid(int sid) const;
365
Taylor Brandstettera1c30352016-05-13 15:15:11366 // Called when first configuring the port allocator.
deadbeef91dd5672016-05-18 23:55:30367 bool InitializePortAllocator_n(const RTCConfiguration& configuration);
deadbeef293e9262017-01-11 20:28:30368 // Called when SetConfiguration is called to apply the supported subset
369 // of the configuration on the network thread.
370 bool ReconfigurePortAllocator_n(
371 const cricket::ServerAddresses& stun_servers,
372 const std::vector<cricket::RelayServerConfig>& turn_servers,
373 IceTransportsType type,
374 int candidate_pool_size,
375 bool prune_turn_ports);
Taylor Brandstettera1c30352016-05-13 15:15:11376
ivoc14d5dbe2016-07-04 14:06:55377 // Starts recording an Rtc EventLog using the supplied platform file.
378 // This function should only be called from the worker thread.
379 bool StartRtcEventLog_w(rtc::PlatformFile file, int64_t max_size_bytes);
380 // Starts recording an Rtc EventLog using the supplied platform file.
381 // This function should only be called from the worker thread.
382 void StopRtcEventLog_w();
383
Steve Anton038834f2017-07-14 22:59:59384 // Ensures the configuration doesn't have any parameters with invalid values,
385 // or values that conflict with other parameters.
386 //
387 // Returns RTCError::OK() if there are no issues.
388 RTCError ValidateConfiguration(const RTCConfiguration& config) const;
389
henrike@webrtc.org28e20752013-07-10 00:45:36390 // Storing the factory as a scoped reference pointer ensures that the memory
391 // in the PeerConnectionFactoryImpl remains available as long as the
392 // PeerConnection is running. It is passed to PeerConnection as a raw pointer.
393 // However, since the reference counting is done in the
deadbeefab9b2d12015-10-14 18:33:11394 // PeerConnectionFactoryInterface all instances created using the raw pointer
henrike@webrtc.org28e20752013-07-10 00:45:36395 // will refer to the same reference count.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52396 rtc::scoped_refptr<PeerConnectionFactory> factory_;
henrike@webrtc.org28e20752013-07-10 00:45:36397 PeerConnectionObserver* observer_;
buildbot@webrtc.org1567b8c2014-05-08 19:54:16398 UMAObserver* uma_observer_;
terelius33860252017-05-13 06:37:18399
400 // The EventLog needs to outlive |call_| (and any other object that uses it).
401 std::unique_ptr<RtcEventLog> event_log_;
402
henrike@webrtc.org28e20752013-07-10 00:45:36403 SignalingState signaling_state_;
henrike@webrtc.org28e20752013-07-10 00:45:36404 IceConnectionState ice_connection_state_;
405 IceGatheringState ice_gathering_state_;
deadbeef46c73892016-11-17 03:42:04406 PeerConnectionInterface::RTCConfiguration configuration_;
henrike@webrtc.org28e20752013-07-10 00:45:36407
kwibergd1fe2812016-04-27 13:47:29408 std::unique_ptr<cricket::PortAllocator> port_allocator_;
deadbeefab9b2d12015-10-14 18:33:11409
zhihuang8f65cdf2016-05-07 01:40:30410 // One PeerConnection has only one RTCP CNAME.
411 // https://tools.ietf.org/html/draft-ietf-rtcweb-rtp-usage-26#section-4.9
412 std::string rtcp_cname_;
413
deadbeefab9b2d12015-10-14 18:33:11414 // Streams added via AddStream.
415 rtc::scoped_refptr<StreamCollection> local_streams_;
416 // Streams created as a result of SetRemoteDescription.
417 rtc::scoped_refptr<StreamCollection> remote_streams_;
418
kwibergd1fe2812016-04-27 13:47:29419 std::vector<std::unique_ptr<MediaStreamObserver>> stream_observers_;
deadbeefeb459812015-12-16 03:24:43420
deadbeefab9b2d12015-10-14 18:33:11421 // These lists store track info seen in local/remote descriptions.
422 TrackInfos remote_audio_tracks_;
423 TrackInfos remote_video_tracks_;
424 TrackInfos local_audio_tracks_;
425 TrackInfos local_video_tracks_;
426
427 SctpSidAllocator sid_allocator_;
428 // label -> DataChannel
429 std::map<std::string, rtc::scoped_refptr<DataChannel>> rtp_data_channels_;
430 std::vector<rtc::scoped_refptr<DataChannel>> sctp_data_channels_;
deadbeefbd292462015-12-15 02:15:29431 std::vector<rtc::scoped_refptr<DataChannel>> sctp_data_channels_to_free_;
deadbeefab9b2d12015-10-14 18:33:11432
deadbeefbda7e0b2015-12-09 01:13:40433 bool remote_peer_supports_msid_ = false;
deadbeef70ab1a12015-09-28 23:53:55434
terelius33860252017-05-13 06:37:18435 std::unique_ptr<Call> call_;
436 std::unique_ptr<WebRtcSession> session_;
437 std::unique_ptr<StatsCollector> stats_; // A pointer is passed to senders_
438 rtc::scoped_refptr<RTCStatsCollector> stats_collector_;
439
deadbeefa601f5c2016-06-06 21:27:39440 std::vector<rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>>>
441 senders_;
442 std::vector<
443 rtc::scoped_refptr<RtpReceiverProxyWithInternal<RtpReceiverInternal>>>
444 receivers_;
henrike@webrtc.org28e20752013-07-10 00:45:36445};
446
447} // namespace webrtc
448
ossu7bb87ee2017-01-23 12:56:25449#endif // WEBRTC_PC_PEERCONNECTION_H_