blob: 484287966216d1a55ef08b425f8be6c5c27c4ba9 [file] [log] [blame]
henrike@webrtc.org28e20752013-07-10 00:45:36 +00001/*
kjellanderb24317b2016-02-10 07:54:43 -08002 * Copyright 2012 The WebRTC project authors. All Rights Reserved.
henrike@webrtc.org28e20752013-07-10 00:45:36 +00003 *
kjellanderb24317b2016-02-10 07:54:43 -08004 * 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:36 +00009 */
10
Henrik Kjellander15583c12016-02-10 10:53:12 +010011#ifndef WEBRTC_API_PEERCONNECTION_H_
12#define WEBRTC_API_PEERCONNECTION_H_
henrike@webrtc.org28e20752013-07-10 00:45:36 +000013
14#include <string>
perkjd61bf802016-03-24 03:16:19 -070015#include <map>
kwibergd1fe2812016-04-27 06:47:29 -070016#include <memory>
perkjd61bf802016-03-24 03:16:19 -070017#include <vector>
henrike@webrtc.org28e20752013-07-10 00:45:36 +000018
Henrik Kjellander15583c12016-02-10 10:53:12 +010019#include "webrtc/api/dtlsidentitystore.h"
20#include "webrtc/api/peerconnectionfactory.h"
21#include "webrtc/api/peerconnectioninterface.h"
22#include "webrtc/api/rtpreceiverinterface.h"
23#include "webrtc/api/rtpsenderinterface.h"
24#include "webrtc/api/statscollector.h"
25#include "webrtc/api/streamcollection.h"
26#include "webrtc/api/webrtcsession.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000027
28namespace webrtc {
henrike@webrtc.org28e20752013-07-10 00:45:36 +000029
deadbeefeb459812015-12-15 19:24:43 -080030class MediaStreamObserver;
perkjf0dcfe22016-03-10 18:32:00 +010031class VideoRtpReceiver;
deadbeefab9b2d12015-10-14 11:33:11 -070032
deadbeefab9b2d12015-10-14 11:33:11 -070033// Populates |session_options| from |rtc_options|, and returns true if options
34// are valid.
deadbeef0ed85b22016-02-23 17:24:52 -080035// |session_options|->transport_options map entries must exist in order for
36// them to be populated from |rtc_options|.
htaa2a49d92016-03-04 02:51:39 -080037bool ExtractMediaSessionOptions(
deadbeefab9b2d12015-10-14 11:33:11 -070038 const PeerConnectionInterface::RTCOfferAnswerOptions& rtc_options,
htaaac2dea2016-03-10 13:35:55 -080039 bool is_offer,
deadbeefab9b2d12015-10-14 11:33:11 -070040 cricket::MediaSessionOptions* session_options);
41
42// Populates |session_options| from |constraints|, and returns true if all
43// mandatory constraints are satisfied.
deadbeef0ed85b22016-02-23 17:24:52 -080044// Assumes that |session_options|->transport_options map entries exist.
htaa2a49d92016-03-04 02:51:39 -080045// Will also set defaults if corresponding constraints are not present:
46// recv_audio=true, recv_video=true, bundle_enabled=true.
47// Other fields will be left with existing values.
48//
49// Deprecated. Will be removed once callers that use constraints are gone.
50// TODO(hta): Remove when callers are gone.
51// https://bugs.chromium.org/p/webrtc/issues/detail?id=5617
deadbeefab9b2d12015-10-14 11:33:11 -070052bool ParseConstraintsForAnswer(const MediaConstraintsInterface* constraints,
53 cricket::MediaSessionOptions* session_options);
54
Taylor Brandstetter0c7e9f52015-12-29 14:14:52 -080055// Parses the URLs for each server in |servers| to build |stun_servers| and
56// |turn_servers|.
deadbeef0a6c4ca2015-10-06 11:38:28 -070057bool ParseIceServers(const PeerConnectionInterface::IceServers& servers,
Taylor Brandstetter0c7e9f52015-12-29 14:14:52 -080058 cricket::ServerAddresses* stun_servers,
59 std::vector<cricket::RelayServerConfig>* turn_servers);
deadbeef0a6c4ca2015-10-06 11:38:28 -070060
deadbeef70ab1a12015-09-28 16:53:55 -070061// PeerConnection implements the PeerConnectionInterface interface.
deadbeefab9b2d12015-10-14 11:33:11 -070062// It uses WebRtcSession to implement the PeerConnection functionality.
henrike@webrtc.org28e20752013-07-10 00:45:36 +000063class PeerConnection : public PeerConnectionInterface,
henrike@webrtc.org28e20752013-07-10 00:45:36 +000064 public IceObserver,
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000065 public rtc::MessageHandler,
henrike@webrtc.org28e20752013-07-10 00:45:36 +000066 public sigslot::has_slots<> {
67 public:
68 explicit PeerConnection(PeerConnectionFactory* factory);
69
deadbeef653b8e02015-11-11 12:55:10 -080070 bool Initialize(
71 const PeerConnectionInterface::RTCConfiguration& configuration,
kwibergd1fe2812016-04-27 06:47:29 -070072 std::unique_ptr<cricket::PortAllocator> allocator,
73 std::unique_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
deadbeef653b8e02015-11-11 12:55:10 -080074 PeerConnectionObserver* observer);
75
deadbeefa67696b2015-09-29 11:56:26 -070076 rtc::scoped_refptr<StreamCollectionInterface> local_streams() override;
77 rtc::scoped_refptr<StreamCollectionInterface> remote_streams() override;
78 bool AddStream(MediaStreamInterface* local_stream) override;
79 void RemoveStream(MediaStreamInterface* local_stream) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000080
deadbeefe1f9d832016-01-14 15:35:42 -080081 rtc::scoped_refptr<RtpSenderInterface> AddTrack(
82 MediaStreamTrackInterface* track,
83 std::vector<MediaStreamInterface*> streams) override;
84 bool RemoveTrack(RtpSenderInterface* sender) override;
85
deadbeefab9b2d12015-10-14 11:33:11 -070086 virtual WebRtcSession* session() { return session_.get(); }
87
deadbeefa67696b2015-09-29 11:56:26 -070088 rtc::scoped_refptr<DtmfSenderInterface> CreateDtmfSender(
89 AudioTrackInterface* track) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000090
deadbeeffac06552015-11-25 11:26:01 -080091 rtc::scoped_refptr<RtpSenderInterface> CreateSender(
deadbeefbd7d8f72015-12-18 16:58:44 -080092 const std::string& kind,
93 const std::string& stream_id) override;
deadbeeffac06552015-11-25 11:26:01 -080094
deadbeef70ab1a12015-09-28 16:53:55 -070095 std::vector<rtc::scoped_refptr<RtpSenderInterface>> GetSenders()
96 const override;
97 std::vector<rtc::scoped_refptr<RtpReceiverInterface>> GetReceivers()
98 const override;
99
deadbeefa67696b2015-09-29 11:56:26 -0700100 rtc::scoped_refptr<DataChannelInterface> CreateDataChannel(
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000101 const std::string& label,
deadbeefa67696b2015-09-29 11:56:26 -0700102 const DataChannelInit* config) override;
103 bool GetStats(StatsObserver* observer,
104 webrtc::MediaStreamTrackInterface* track,
105 StatsOutputLevel level) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000106
deadbeefa67696b2015-09-29 11:56:26 -0700107 SignalingState signaling_state() override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000108
109 // TODO(bemasc): Remove ice_state() when callers are removed.
deadbeefa67696b2015-09-29 11:56:26 -0700110 IceState ice_state() override;
111 IceConnectionState ice_connection_state() override;
112 IceGatheringState ice_gathering_state() override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000113
deadbeefa67696b2015-09-29 11:56:26 -0700114 const SessionDescriptionInterface* local_description() const override;
115 const SessionDescriptionInterface* remote_description() const override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000116
117 // JSEP01
htaa2a49d92016-03-04 02:51:39 -0800118 // Deprecated, use version without constraints.
deadbeefa67696b2015-09-29 11:56:26 -0700119 void CreateOffer(CreateSessionDescriptionObserver* observer,
120 const MediaConstraintsInterface* constraints) override;
121 void CreateOffer(CreateSessionDescriptionObserver* observer,
122 const RTCOfferAnswerOptions& options) override;
htaa2a49d92016-03-04 02:51:39 -0800123 // Deprecated, use version without constraints.
deadbeefa67696b2015-09-29 11:56:26 -0700124 void CreateAnswer(CreateSessionDescriptionObserver* observer,
125 const MediaConstraintsInterface* constraints) override;
htaa2a49d92016-03-04 02:51:39 -0800126 void CreateAnswer(CreateSessionDescriptionObserver* observer,
127 const RTCOfferAnswerOptions& options) override;
deadbeefa67696b2015-09-29 11:56:26 -0700128 void SetLocalDescription(SetSessionDescriptionObserver* observer,
129 SessionDescriptionInterface* desc) override;
130 void SetRemoteDescription(SetSessionDescriptionObserver* observer,
131 SessionDescriptionInterface* desc) override;
132 bool SetConfiguration(
133 const PeerConnectionInterface::RTCConfiguration& config) override;
134 bool AddIceCandidate(const IceCandidateInterface* candidate) override;
Honghai Zhang7fb69db2016-03-14 11:59:18 -0700135 bool RemoveIceCandidates(
136 const std::vector<cricket::Candidate>& candidates) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000137
deadbeefa67696b2015-09-29 11:56:26 -0700138 void RegisterUMAObserver(UMAObserver* observer) override;
buildbot@webrtc.org1567b8c2014-05-08 19:54:16 +0000139
deadbeefa67696b2015-09-29 11:56:26 -0700140 void Close() override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000141
deadbeefab9b2d12015-10-14 11:33:11 -0700142 // Virtual for unit tests.
143 virtual const std::vector<rtc::scoped_refptr<DataChannel>>&
144 sctp_data_channels() const {
145 return sctp_data_channels_;
perkjd61bf802016-03-24 03:16:19 -0700146 }
deadbeefab9b2d12015-10-14 11:33:11 -0700147
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000148 protected:
deadbeefa67696b2015-09-29 11:56:26 -0700149 ~PeerConnection() override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000150
151 private:
deadbeefab9b2d12015-10-14 11:33:11 -0700152 struct TrackInfo {
153 TrackInfo() : ssrc(0) {}
154 TrackInfo(const std::string& stream_label,
155 const std::string track_id,
156 uint32_t ssrc)
157 : stream_label(stream_label), track_id(track_id), ssrc(ssrc) {}
deadbeefbda7e0b2015-12-08 17:13:40 -0800158 bool operator==(const TrackInfo& other) {
159 return this->stream_label == other.stream_label &&
160 this->track_id == other.track_id && this->ssrc == other.ssrc;
161 }
deadbeefab9b2d12015-10-14 11:33:11 -0700162 std::string stream_label;
163 std::string track_id;
164 uint32_t ssrc;
165 };
166 typedef std::vector<TrackInfo> TrackInfos;
167
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000168 // Implements MessageHandler.
deadbeefa67696b2015-09-29 11:56:26 -0700169 void OnMessage(rtc::Message* msg) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000170
deadbeefab9b2d12015-10-14 11:33:11 -0700171 void CreateAudioReceiver(MediaStreamInterface* stream,
perkjd61bf802016-03-24 03:16:19 -0700172 const std::string& track_id,
deadbeefab9b2d12015-10-14 11:33:11 -0700173 uint32_t ssrc);
perkjf0dcfe22016-03-10 18:32:00 +0100174
deadbeefab9b2d12015-10-14 11:33:11 -0700175 void CreateVideoReceiver(MediaStreamInterface* stream,
perkjf0dcfe22016-03-10 18:32:00 +0100176 const std::string& track_id,
deadbeefab9b2d12015-10-14 11:33:11 -0700177 uint32_t ssrc);
perkjd61bf802016-03-24 03:16:19 -0700178 void StopReceivers(cricket::MediaType media_type);
179 void DestroyReceiver(const std::string& track_id);
deadbeefab9b2d12015-10-14 11:33:11 -0700180 void DestroyAudioSender(MediaStreamInterface* stream,
181 AudioTrackInterface* audio_track,
182 uint32_t ssrc);
183 void DestroyVideoSender(MediaStreamInterface* stream,
184 VideoTrackInterface* video_track);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000185
186 // Implements IceObserver
Peter Thatcher54360512015-07-08 11:08:35 -0700187 void OnIceConnectionChange(IceConnectionState new_state) override;
188 void OnIceGatheringChange(IceGatheringState new_state) override;
189 void OnIceCandidate(const IceCandidateInterface* candidate) override;
Honghai Zhang7fb69db2016-03-14 11:59:18 -0700190 void OnIceCandidatesRemoved(
191 const std::vector<cricket::Candidate>& candidates) override;
Peter Thatcher54360512015-07-08 11:08:35 -0700192 void OnIceConnectionReceivingChange(bool receiving) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000193
194 // Signals from WebRtcSession.
deadbeefd59daf82015-10-14 15:02:44 -0700195 void OnSessionStateChange(WebRtcSession* session, WebRtcSession::State state);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000196 void ChangeSignalingState(SignalingState signaling_state);
197
deadbeefeb459812015-12-15 19:24:43 -0800198 // Signals from MediaStreamObserver.
199 void OnAudioTrackAdded(AudioTrackInterface* track,
200 MediaStreamInterface* stream);
201 void OnAudioTrackRemoved(AudioTrackInterface* track,
202 MediaStreamInterface* stream);
203 void OnVideoTrackAdded(VideoTrackInterface* track,
204 MediaStreamInterface* stream);
205 void OnVideoTrackRemoved(VideoTrackInterface* track,
206 MediaStreamInterface* stream);
207
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000208 rtc::Thread* signaling_thread() const {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000209 return factory_->signaling_thread();
210 }
211
212 void PostSetSessionDescriptionFailure(SetSessionDescriptionObserver* observer,
213 const std::string& error);
deadbeefab9b2d12015-10-14 11:33:11 -0700214 void PostCreateSessionDescriptionFailure(
215 CreateSessionDescriptionObserver* observer,
216 const std::string& error);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000217
218 bool IsClosed() const {
219 return signaling_state_ == PeerConnectionInterface::kClosed;
220 }
221
deadbeefab9b2d12015-10-14 11:33:11 -0700222 // Returns a MediaSessionOptions struct with options decided by |options|,
223 // the local MediaStreams and DataChannels.
224 virtual bool GetOptionsForOffer(
225 const PeerConnectionInterface::RTCOfferAnswerOptions& rtc_options,
226 cricket::MediaSessionOptions* session_options);
227
228 // Returns a MediaSessionOptions struct with options decided by
229 // |constraints|, the local MediaStreams and DataChannels.
htaa2a49d92016-03-04 02:51:39 -0800230 // Deprecated, use version without constraints.
deadbeefab9b2d12015-10-14 11:33:11 -0700231 virtual bool GetOptionsForAnswer(
232 const MediaConstraintsInterface* constraints,
233 cricket::MediaSessionOptions* session_options);
htaa2a49d92016-03-04 02:51:39 -0800234 virtual bool GetOptionsForAnswer(
235 const RTCOfferAnswerOptions& options,
236 cricket::MediaSessionOptions* session_options);
237
238 // Helper function for options processing.
239 // Deprecated.
240 virtual void FinishOptionsForAnswer(
241 cricket::MediaSessionOptions* session_options);
deadbeefab9b2d12015-10-14 11:33:11 -0700242
deadbeeffaac4972015-11-12 15:33:07 -0800243 // Remove all local and remote tracks of type |media_type|.
244 // Called when a media type is rejected (m-line set to port 0).
245 void RemoveTracks(cricket::MediaType media_type);
246
deadbeefbda7e0b2015-12-08 17:13:40 -0800247 // Makes sure a MediaStreamTrack is created for each StreamParam in |streams|,
248 // and existing MediaStreamTracks are removed if there is no corresponding
249 // StreamParam. If |default_track_needed| is true, a default MediaStreamTrack
250 // is created if it doesn't exist; if false, it's removed if it exists.
251 // |media_type| is the type of the |streams| and can be either audio or video.
deadbeefab9b2d12015-10-14 11:33:11 -0700252 // If a new MediaStream is created it is added to |new_streams|.
253 void UpdateRemoteStreamsList(
254 const std::vector<cricket::StreamParams>& streams,
deadbeefbda7e0b2015-12-08 17:13:40 -0800255 bool default_track_needed,
deadbeefab9b2d12015-10-14 11:33:11 -0700256 cricket::MediaType media_type,
257 StreamCollection* new_streams);
258
259 // Triggered when a remote track has been seen for the first time in a remote
260 // session description. It creates a remote MediaStreamTrackInterface
261 // implementation and triggers CreateAudioReceiver or CreateVideoReceiver.
262 void OnRemoteTrackSeen(const std::string& stream_label,
263 const std::string& track_id,
264 uint32_t ssrc,
265 cricket::MediaType media_type);
266
267 // Triggered when a remote track has been removed from a remote session
268 // description. It removes the remote track with id |track_id| from a remote
269 // MediaStream and triggers DestroyAudioReceiver or DestroyVideoReceiver.
270 void OnRemoteTrackRemoved(const std::string& stream_label,
271 const std::string& track_id,
272 cricket::MediaType media_type);
273
274 // Finds remote MediaStreams without any tracks and removes them from
275 // |remote_streams_| and notifies the observer that the MediaStreams no longer
276 // exist.
277 void UpdateEndedRemoteMediaStreams();
278
deadbeefab9b2d12015-10-14 11:33:11 -0700279 // Loops through the vector of |streams| and finds added and removed
280 // StreamParams since last time this method was called.
281 // For each new or removed StreamParam, OnLocalTrackSeen or
282 // OnLocalTrackRemoved is invoked.
283 void UpdateLocalTracks(const std::vector<cricket::StreamParams>& streams,
284 cricket::MediaType media_type);
285
286 // Triggered when a local track has been seen for the first time in a local
287 // session description.
288 // This method triggers CreateAudioSender or CreateVideoSender if the rtp
289 // streams in the local SessionDescription can be mapped to a MediaStreamTrack
290 // in a MediaStream in |local_streams_|
291 void OnLocalTrackSeen(const std::string& stream_label,
292 const std::string& track_id,
293 uint32_t ssrc,
294 cricket::MediaType media_type);
295
296 // Triggered when a local track has been removed from a local session
297 // description.
298 // This method triggers DestroyAudioSender or DestroyVideoSender if a stream
299 // has been removed from the local SessionDescription and the stream can be
300 // mapped to a MediaStreamTrack in a MediaStream in |local_streams_|.
301 void OnLocalTrackRemoved(const std::string& stream_label,
302 const std::string& track_id,
303 uint32_t ssrc,
304 cricket::MediaType media_type);
305
306 void UpdateLocalRtpDataChannels(const cricket::StreamParamsVec& streams);
307 void UpdateRemoteRtpDataChannels(const cricket::StreamParamsVec& streams);
308 void UpdateClosingRtpDataChannels(
309 const std::vector<std::string>& active_channels,
310 bool is_local_update);
311 void CreateRemoteRtpDataChannel(const std::string& label,
312 uint32_t remote_ssrc);
313
314 // Creates channel and adds it to the collection of DataChannels that will
315 // be offered in a SessionDescription.
316 rtc::scoped_refptr<DataChannel> InternalCreateDataChannel(
317 const std::string& label,
318 const InternalDataChannelInit* config);
319
320 // Checks if any data channel has been added.
321 bool HasDataChannels() const;
322
323 void AllocateSctpSids(rtc::SSLRole role);
324 void OnSctpDataChannelClosed(DataChannel* channel);
325
326 // Notifications from WebRtcSession relating to BaseChannels.
327 void OnVoiceChannelDestroyed();
328 void OnVideoChannelDestroyed();
329 void OnDataChannelCreated();
330 void OnDataChannelDestroyed();
331 // Called when the cricket::DataChannel receives a message indicating that a
332 // webrtc::DataChannel should be opened.
333 void OnDataChannelOpenMessage(const std::string& label,
334 const InternalDataChannelInit& config);
335
deadbeeffac06552015-11-25 11:26:01 -0800336 RtpSenderInterface* FindSenderById(const std::string& id);
337
deadbeef70ab1a12015-09-28 16:53:55 -0700338 std::vector<rtc::scoped_refptr<RtpSenderInterface>>::iterator
339 FindSenderForTrack(MediaStreamTrackInterface* track);
340 std::vector<rtc::scoped_refptr<RtpReceiverInterface>>::iterator
perkjd61bf802016-03-24 03:16:19 -0700341 FindReceiverForTrack(const std::string& track_id);
deadbeef70ab1a12015-09-28 16:53:55 -0700342
deadbeefab9b2d12015-10-14 11:33:11 -0700343 TrackInfos* GetRemoteTracks(cricket::MediaType media_type);
344 TrackInfos* GetLocalTracks(cricket::MediaType media_type);
345 const TrackInfo* FindTrackInfo(const TrackInfos& infos,
346 const std::string& stream_label,
347 const std::string track_id) const;
348
349 // Returns the specified SCTP DataChannel in sctp_data_channels_,
350 // or nullptr if not found.
351 DataChannel* FindDataChannelBySid(int sid) const;
352
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000353 // Storing the factory as a scoped reference pointer ensures that the memory
354 // in the PeerConnectionFactoryImpl remains available as long as the
355 // PeerConnection is running. It is passed to PeerConnection as a raw pointer.
356 // However, since the reference counting is done in the
deadbeefab9b2d12015-10-14 11:33:11 -0700357 // PeerConnectionFactoryInterface all instances created using the raw pointer
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000358 // will refer to the same reference count.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000359 rtc::scoped_refptr<PeerConnectionFactory> factory_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000360 PeerConnectionObserver* observer_;
buildbot@webrtc.org1567b8c2014-05-08 19:54:16 +0000361 UMAObserver* uma_observer_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000362 SignalingState signaling_state_;
363 // TODO(bemasc): Remove ice_state_.
364 IceState ice_state_;
365 IceConnectionState ice_connection_state_;
366 IceGatheringState ice_gathering_state_;
367
kwibergd1fe2812016-04-27 06:47:29 -0700368 std::unique_ptr<cricket::PortAllocator> port_allocator_;
369 std::unique_ptr<MediaControllerInterface> media_controller_;
deadbeefab9b2d12015-10-14 11:33:11 -0700370
zhihuang8f65cdf2016-05-06 18:40:30 -0700371 // One PeerConnection has only one RTCP CNAME.
372 // https://tools.ietf.org/html/draft-ietf-rtcweb-rtp-usage-26#section-4.9
373 std::string rtcp_cname_;
374
deadbeefab9b2d12015-10-14 11:33:11 -0700375 // Streams added via AddStream.
376 rtc::scoped_refptr<StreamCollection> local_streams_;
377 // Streams created as a result of SetRemoteDescription.
378 rtc::scoped_refptr<StreamCollection> remote_streams_;
379
kwibergd1fe2812016-04-27 06:47:29 -0700380 std::vector<std::unique_ptr<MediaStreamObserver>> stream_observers_;
deadbeefeb459812015-12-15 19:24:43 -0800381
deadbeefab9b2d12015-10-14 11:33:11 -0700382 // These lists store track info seen in local/remote descriptions.
383 TrackInfos remote_audio_tracks_;
384 TrackInfos remote_video_tracks_;
385 TrackInfos local_audio_tracks_;
386 TrackInfos local_video_tracks_;
387
388 SctpSidAllocator sid_allocator_;
389 // label -> DataChannel
390 std::map<std::string, rtc::scoped_refptr<DataChannel>> rtp_data_channels_;
391 std::vector<rtc::scoped_refptr<DataChannel>> sctp_data_channels_;
deadbeefbd292462015-12-14 18:15:29 -0800392 std::vector<rtc::scoped_refptr<DataChannel>> sctp_data_channels_to_free_;
deadbeefab9b2d12015-10-14 11:33:11 -0700393
deadbeefbda7e0b2015-12-08 17:13:40 -0800394 bool remote_peer_supports_msid_ = false;
deadbeef70ab1a12015-09-28 16:53:55 -0700395
396 std::vector<rtc::scoped_refptr<RtpSenderInterface>> senders_;
397 std::vector<rtc::scoped_refptr<RtpReceiverInterface>> receivers_;
deadbeefab9b2d12015-10-14 11:33:11 -0700398
kwibergd1fe2812016-04-27 06:47:29 -0700399 // The session_ unique_ptr is declared at the bottom of PeerConnection
deadbeefab9b2d12015-10-14 11:33:11 -0700400 // because its destruction fires signals (such as VoiceChannelDestroyed)
401 // which will trigger some final actions in PeerConnection...
kwibergd1fe2812016-04-27 06:47:29 -0700402 std::unique_ptr<WebRtcSession> session_;
deadbeefab9b2d12015-10-14 11:33:11 -0700403 // ... But stats_ depends on session_ so it should be destroyed even earlier.
kwibergd1fe2812016-04-27 06:47:29 -0700404 std::unique_ptr<StatsCollector> stats_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000405};
406
407} // namespace webrtc
408
Henrik Kjellander15583c12016-02-10 10:53:12 +0100409#endif // WEBRTC_API_PEERCONNECTION_H_