blob: 15ecc3f4cdac4571ca879cb8ea006192323b62d9 [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"
kwiberg6ab3db22016-05-11 05:07:26 -070027#include "webrtc/base/scoped_ptr.h"
henrike@webrtc.org28e20752013-07-10 00:45:36 +000028
29namespace webrtc {
henrike@webrtc.org28e20752013-07-10 00:45:36 +000030
deadbeefeb459812015-12-15 19:24:43 -080031class MediaStreamObserver;
perkjf0dcfe22016-03-10 18:32:00 +010032class VideoRtpReceiver;
deadbeefab9b2d12015-10-14 11:33:11 -070033
deadbeefab9b2d12015-10-14 11:33:11 -070034// Populates |session_options| from |rtc_options|, and returns true if options
35// are valid.
deadbeef0ed85b22016-02-23 17:24:52 -080036// |session_options|->transport_options map entries must exist in order for
37// them to be populated from |rtc_options|.
htaa2a49d92016-03-04 02:51:39 -080038bool ExtractMediaSessionOptions(
deadbeefab9b2d12015-10-14 11:33:11 -070039 const PeerConnectionInterface::RTCOfferAnswerOptions& rtc_options,
htaaac2dea2016-03-10 13:35:55 -080040 bool is_offer,
deadbeefab9b2d12015-10-14 11:33:11 -070041 cricket::MediaSessionOptions* session_options);
42
43// Populates |session_options| from |constraints|, and returns true if all
44// mandatory constraints are satisfied.
deadbeef0ed85b22016-02-23 17:24:52 -080045// Assumes that |session_options|->transport_options map entries exist.
htaa2a49d92016-03-04 02:51:39 -080046// Will also set defaults if corresponding constraints are not present:
47// recv_audio=true, recv_video=true, bundle_enabled=true.
48// Other fields will be left with existing values.
49//
50// Deprecated. Will be removed once callers that use constraints are gone.
51// TODO(hta): Remove when callers are gone.
52// https://bugs.chromium.org/p/webrtc/issues/detail?id=5617
deadbeefab9b2d12015-10-14 11:33:11 -070053bool ParseConstraintsForAnswer(const MediaConstraintsInterface* constraints,
54 cricket::MediaSessionOptions* session_options);
55
Taylor Brandstetter0c7e9f52015-12-29 14:14:52 -080056// Parses the URLs for each server in |servers| to build |stun_servers| and
57// |turn_servers|.
deadbeef0a6c4ca2015-10-06 11:38:28 -070058bool ParseIceServers(const PeerConnectionInterface::IceServers& servers,
Taylor Brandstetter0c7e9f52015-12-29 14:14:52 -080059 cricket::ServerAddresses* stun_servers,
60 std::vector<cricket::RelayServerConfig>* turn_servers);
deadbeef0a6c4ca2015-10-06 11:38:28 -070061
deadbeef70ab1a12015-09-28 16:53:55 -070062// PeerConnection implements the PeerConnectionInterface interface.
deadbeefab9b2d12015-10-14 11:33:11 -070063// It uses WebRtcSession to implement the PeerConnection functionality.
henrike@webrtc.org28e20752013-07-10 00:45:36 +000064class PeerConnection : public PeerConnectionInterface,
henrike@webrtc.org28e20752013-07-10 00:45:36 +000065 public IceObserver,
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +000066 public rtc::MessageHandler,
henrike@webrtc.org28e20752013-07-10 00:45:36 +000067 public sigslot::has_slots<> {
68 public:
69 explicit PeerConnection(PeerConnectionFactory* factory);
70
deadbeef653b8e02015-11-11 12:55:10 -080071 bool Initialize(
72 const PeerConnectionInterface::RTCConfiguration& configuration,
kwibergd1fe2812016-04-27 06:47:29 -070073 std::unique_ptr<cricket::PortAllocator> allocator,
74 std::unique_ptr<DtlsIdentityStoreInterface> dtls_identity_store,
deadbeef653b8e02015-11-11 12:55:10 -080075 PeerConnectionObserver* observer);
76
deadbeefa67696b2015-09-29 11:56:26 -070077 rtc::scoped_refptr<StreamCollectionInterface> local_streams() override;
78 rtc::scoped_refptr<StreamCollectionInterface> remote_streams() override;
79 bool AddStream(MediaStreamInterface* local_stream) override;
80 void RemoveStream(MediaStreamInterface* local_stream) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000081
deadbeefe1f9d832016-01-14 15:35:42 -080082 rtc::scoped_refptr<RtpSenderInterface> AddTrack(
83 MediaStreamTrackInterface* track,
84 std::vector<MediaStreamInterface*> streams) override;
85 bool RemoveTrack(RtpSenderInterface* sender) override;
86
deadbeefab9b2d12015-10-14 11:33:11 -070087 virtual WebRtcSession* session() { return session_.get(); }
88
deadbeefa67696b2015-09-29 11:56:26 -070089 rtc::scoped_refptr<DtmfSenderInterface> CreateDtmfSender(
90 AudioTrackInterface* track) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +000091
deadbeeffac06552015-11-25 11:26:01 -080092 rtc::scoped_refptr<RtpSenderInterface> CreateSender(
deadbeefbd7d8f72015-12-18 16:58:44 -080093 const std::string& kind,
94 const std::string& stream_id) override;
deadbeeffac06552015-11-25 11:26:01 -080095
deadbeef70ab1a12015-09-28 16:53:55 -070096 std::vector<rtc::scoped_refptr<RtpSenderInterface>> GetSenders()
97 const override;
98 std::vector<rtc::scoped_refptr<RtpReceiverInterface>> GetReceivers()
99 const override;
100
deadbeefa67696b2015-09-29 11:56:26 -0700101 rtc::scoped_refptr<DataChannelInterface> CreateDataChannel(
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000102 const std::string& label,
deadbeefa67696b2015-09-29 11:56:26 -0700103 const DataChannelInit* config) override;
104 bool GetStats(StatsObserver* observer,
105 webrtc::MediaStreamTrackInterface* track,
106 StatsOutputLevel level) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000107
deadbeefa67696b2015-09-29 11:56:26 -0700108 SignalingState signaling_state() override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000109
110 // TODO(bemasc): Remove ice_state() when callers are removed.
deadbeefa67696b2015-09-29 11:56:26 -0700111 IceState ice_state() override;
112 IceConnectionState ice_connection_state() override;
113 IceGatheringState ice_gathering_state() override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000114
deadbeefa67696b2015-09-29 11:56:26 -0700115 const SessionDescriptionInterface* local_description() const override;
116 const SessionDescriptionInterface* remote_description() const override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000117
118 // JSEP01
htaa2a49d92016-03-04 02:51:39 -0800119 // Deprecated, use version without constraints.
deadbeefa67696b2015-09-29 11:56:26 -0700120 void CreateOffer(CreateSessionDescriptionObserver* observer,
121 const MediaConstraintsInterface* constraints) override;
122 void CreateOffer(CreateSessionDescriptionObserver* observer,
123 const RTCOfferAnswerOptions& options) override;
htaa2a49d92016-03-04 02:51:39 -0800124 // Deprecated, use version without constraints.
deadbeefa67696b2015-09-29 11:56:26 -0700125 void CreateAnswer(CreateSessionDescriptionObserver* observer,
126 const MediaConstraintsInterface* constraints) override;
htaa2a49d92016-03-04 02:51:39 -0800127 void CreateAnswer(CreateSessionDescriptionObserver* observer,
128 const RTCOfferAnswerOptions& options) override;
deadbeefa67696b2015-09-29 11:56:26 -0700129 void SetLocalDescription(SetSessionDescriptionObserver* observer,
130 SessionDescriptionInterface* desc) override;
131 void SetRemoteDescription(SetSessionDescriptionObserver* observer,
132 SessionDescriptionInterface* desc) override;
133 bool SetConfiguration(
Taylor Brandstettera1c30352016-05-13 08:15:11 -0700134 const PeerConnectionInterface::RTCConfiguration& configuration) override;
deadbeefa67696b2015-09-29 11:56:26 -0700135 bool AddIceCandidate(const IceCandidateInterface* candidate) override;
Honghai Zhang7fb69db2016-03-14 11:59:18 -0700136 bool RemoveIceCandidates(
137 const std::vector<cricket::Candidate>& candidates) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000138
deadbeefa67696b2015-09-29 11:56:26 -0700139 void RegisterUMAObserver(UMAObserver* observer) override;
buildbot@webrtc.org1567b8c2014-05-08 19:54:16 +0000140
deadbeefa67696b2015-09-29 11:56:26 -0700141 void Close() override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000142
deadbeefab9b2d12015-10-14 11:33:11 -0700143 // 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 03:16:19 -0700147 }
deadbeefab9b2d12015-10-14 11:33:11 -0700148
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000149 protected:
deadbeefa67696b2015-09-29 11:56:26 -0700150 ~PeerConnection() override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000151
152 private:
deadbeefab9b2d12015-10-14 11:33:11 -0700153 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-08 17:13:40 -0800159 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 11:33:11 -0700163 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:36 +0000169 // Implements MessageHandler.
deadbeefa67696b2015-09-29 11:56:26 -0700170 void OnMessage(rtc::Message* msg) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000171
deadbeefab9b2d12015-10-14 11:33:11 -0700172 void CreateAudioReceiver(MediaStreamInterface* stream,
perkjd61bf802016-03-24 03:16:19 -0700173 const std::string& track_id,
deadbeefab9b2d12015-10-14 11:33:11 -0700174 uint32_t ssrc);
perkjf0dcfe22016-03-10 18:32:00 +0100175
deadbeefab9b2d12015-10-14 11:33:11 -0700176 void CreateVideoReceiver(MediaStreamInterface* stream,
perkjf0dcfe22016-03-10 18:32:00 +0100177 const std::string& track_id,
deadbeefab9b2d12015-10-14 11:33:11 -0700178 uint32_t ssrc);
perkjd61bf802016-03-24 03:16:19 -0700179 void StopReceivers(cricket::MediaType media_type);
180 void DestroyReceiver(const std::string& track_id);
deadbeefab9b2d12015-10-14 11:33:11 -0700181 void DestroyAudioSender(MediaStreamInterface* stream,
182 AudioTrackInterface* audio_track,
183 uint32_t ssrc);
184 void DestroyVideoSender(MediaStreamInterface* stream,
185 VideoTrackInterface* video_track);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000186
187 // Implements IceObserver
Peter Thatcher54360512015-07-08 11:08:35 -0700188 void OnIceConnectionChange(IceConnectionState new_state) override;
189 void OnIceGatheringChange(IceGatheringState new_state) override;
190 void OnIceCandidate(const IceCandidateInterface* candidate) override;
Honghai Zhang7fb69db2016-03-14 11:59:18 -0700191 void OnIceCandidatesRemoved(
192 const std::vector<cricket::Candidate>& candidates) override;
Peter Thatcher54360512015-07-08 11:08:35 -0700193 void OnIceConnectionReceivingChange(bool receiving) override;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000194
195 // Signals from WebRtcSession.
deadbeefd59daf82015-10-14 15:02:44 -0700196 void OnSessionStateChange(WebRtcSession* session, WebRtcSession::State state);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000197 void ChangeSignalingState(SignalingState signaling_state);
198
deadbeefeb459812015-12-15 19:24:43 -0800199 // Signals from MediaStreamObserver.
200 void OnAudioTrackAdded(AudioTrackInterface* track,
201 MediaStreamInterface* stream);
202 void OnAudioTrackRemoved(AudioTrackInterface* track,
203 MediaStreamInterface* stream);
204 void OnVideoTrackAdded(VideoTrackInterface* track,
205 MediaStreamInterface* stream);
206 void OnVideoTrackRemoved(VideoTrackInterface* track,
207 MediaStreamInterface* stream);
208
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000209 rtc::Thread* signaling_thread() const {
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000210 return factory_->signaling_thread();
211 }
212
Taylor Brandstettera1c30352016-05-13 08:15:11 -0700213 rtc::Thread* worker_thread() const { return factory_->worker_thread(); }
214
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000215 void PostSetSessionDescriptionFailure(SetSessionDescriptionObserver* observer,
216 const std::string& error);
deadbeefab9b2d12015-10-14 11:33:11 -0700217 void PostCreateSessionDescriptionFailure(
218 CreateSessionDescriptionObserver* observer,
219 const std::string& error);
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000220
221 bool IsClosed() const {
222 return signaling_state_ == PeerConnectionInterface::kClosed;
223 }
224
deadbeefab9b2d12015-10-14 11:33:11 -0700225 // Returns a MediaSessionOptions struct with options decided by |options|,
226 // the local MediaStreams and DataChannels.
227 virtual bool GetOptionsForOffer(
228 const PeerConnectionInterface::RTCOfferAnswerOptions& rtc_options,
229 cricket::MediaSessionOptions* session_options);
230
231 // Returns a MediaSessionOptions struct with options decided by
232 // |constraints|, the local MediaStreams and DataChannels.
htaa2a49d92016-03-04 02:51:39 -0800233 // Deprecated, use version without constraints.
deadbeefab9b2d12015-10-14 11:33:11 -0700234 virtual bool GetOptionsForAnswer(
235 const MediaConstraintsInterface* constraints,
236 cricket::MediaSessionOptions* session_options);
htaa2a49d92016-03-04 02:51:39 -0800237 virtual bool GetOptionsForAnswer(
238 const RTCOfferAnswerOptions& options,
239 cricket::MediaSessionOptions* session_options);
240
241 // Helper function for options processing.
242 // Deprecated.
243 virtual void FinishOptionsForAnswer(
244 cricket::MediaSessionOptions* session_options);
deadbeefab9b2d12015-10-14 11:33:11 -0700245
deadbeeffaac4972015-11-12 15:33:07 -0800246 // Remove all local and remote tracks of type |media_type|.
247 // Called when a media type is rejected (m-line set to port 0).
248 void RemoveTracks(cricket::MediaType media_type);
249
deadbeefbda7e0b2015-12-08 17:13:40 -0800250 // Makes sure a MediaStreamTrack is created for each StreamParam in |streams|,
251 // and existing MediaStreamTracks are removed if there is no corresponding
252 // StreamParam. If |default_track_needed| is true, a default MediaStreamTrack
253 // is created if it doesn't exist; if false, it's removed if it exists.
254 // |media_type| is the type of the |streams| and can be either audio or video.
deadbeefab9b2d12015-10-14 11:33:11 -0700255 // If a new MediaStream is created it is added to |new_streams|.
256 void UpdateRemoteStreamsList(
257 const std::vector<cricket::StreamParams>& streams,
deadbeefbda7e0b2015-12-08 17:13:40 -0800258 bool default_track_needed,
deadbeefab9b2d12015-10-14 11:33:11 -0700259 cricket::MediaType media_type,
260 StreamCollection* new_streams);
261
262 // Triggered when a remote track has been seen for the first time in a remote
263 // session description. It creates a remote MediaStreamTrackInterface
264 // implementation and triggers CreateAudioReceiver or CreateVideoReceiver.
265 void OnRemoteTrackSeen(const std::string& stream_label,
266 const std::string& track_id,
267 uint32_t ssrc,
268 cricket::MediaType media_type);
269
270 // Triggered when a remote track has been removed from a remote session
271 // description. It removes the remote track with id |track_id| from a remote
272 // MediaStream and triggers DestroyAudioReceiver or DestroyVideoReceiver.
273 void OnRemoteTrackRemoved(const std::string& stream_label,
274 const std::string& track_id,
275 cricket::MediaType media_type);
276
277 // Finds remote MediaStreams without any tracks and removes them from
278 // |remote_streams_| and notifies the observer that the MediaStreams no longer
279 // exist.
280 void UpdateEndedRemoteMediaStreams();
281
deadbeefab9b2d12015-10-14 11:33:11 -0700282 // Loops through the vector of |streams| and finds added and removed
283 // StreamParams since last time this method was called.
284 // For each new or removed StreamParam, OnLocalTrackSeen or
285 // OnLocalTrackRemoved is invoked.
286 void UpdateLocalTracks(const std::vector<cricket::StreamParams>& streams,
287 cricket::MediaType media_type);
288
289 // Triggered when a local track has been seen for the first time in a local
290 // session description.
291 // This method triggers CreateAudioSender or CreateVideoSender if the rtp
292 // streams in the local SessionDescription can be mapped to a MediaStreamTrack
293 // in a MediaStream in |local_streams_|
294 void OnLocalTrackSeen(const std::string& stream_label,
295 const std::string& track_id,
296 uint32_t ssrc,
297 cricket::MediaType media_type);
298
299 // Triggered when a local track has been removed from a local session
300 // description.
301 // This method triggers DestroyAudioSender or DestroyVideoSender if a stream
302 // has been removed from the local SessionDescription and the stream can be
303 // mapped to a MediaStreamTrack in a MediaStream in |local_streams_|.
304 void OnLocalTrackRemoved(const std::string& stream_label,
305 const std::string& track_id,
306 uint32_t ssrc,
307 cricket::MediaType media_type);
308
309 void UpdateLocalRtpDataChannels(const cricket::StreamParamsVec& streams);
310 void UpdateRemoteRtpDataChannels(const cricket::StreamParamsVec& streams);
311 void UpdateClosingRtpDataChannels(
312 const std::vector<std::string>& active_channels,
313 bool is_local_update);
314 void CreateRemoteRtpDataChannel(const std::string& label,
315 uint32_t remote_ssrc);
316
317 // Creates channel and adds it to the collection of DataChannels that will
318 // be offered in a SessionDescription.
319 rtc::scoped_refptr<DataChannel> InternalCreateDataChannel(
320 const std::string& label,
321 const InternalDataChannelInit* config);
322
323 // Checks if any data channel has been added.
324 bool HasDataChannels() const;
325
326 void AllocateSctpSids(rtc::SSLRole role);
327 void OnSctpDataChannelClosed(DataChannel* channel);
328
329 // Notifications from WebRtcSession relating to BaseChannels.
330 void OnVoiceChannelDestroyed();
331 void OnVideoChannelDestroyed();
332 void OnDataChannelCreated();
333 void OnDataChannelDestroyed();
334 // Called when the cricket::DataChannel receives a message indicating that a
335 // webrtc::DataChannel should be opened.
336 void OnDataChannelOpenMessage(const std::string& label,
337 const InternalDataChannelInit& config);
338
deadbeeffac06552015-11-25 11:26:01 -0800339 RtpSenderInterface* FindSenderById(const std::string& id);
340
deadbeef70ab1a12015-09-28 16:53:55 -0700341 std::vector<rtc::scoped_refptr<RtpSenderInterface>>::iterator
342 FindSenderForTrack(MediaStreamTrackInterface* track);
343 std::vector<rtc::scoped_refptr<RtpReceiverInterface>>::iterator
perkjd61bf802016-03-24 03:16:19 -0700344 FindReceiverForTrack(const std::string& track_id);
deadbeef70ab1a12015-09-28 16:53:55 -0700345
deadbeefab9b2d12015-10-14 11:33:11 -0700346 TrackInfos* GetRemoteTracks(cricket::MediaType media_type);
347 TrackInfos* GetLocalTracks(cricket::MediaType media_type);
348 const TrackInfo* FindTrackInfo(const TrackInfos& infos,
349 const std::string& stream_label,
350 const std::string track_id) const;
351
352 // Returns the specified SCTP DataChannel in sctp_data_channels_,
353 // or nullptr if not found.
354 DataChannel* FindDataChannelBySid(int sid) const;
355
Taylor Brandstettera1c30352016-05-13 08:15:11 -0700356 // Called when first configuring the port allocator.
357 bool InitializePortAllocator_w(const RTCConfiguration& configuration);
358 // Called when SetConfiguration is called. Only a subset of the configuration
359 // is applied.
360 bool ReconfigurePortAllocator_w(const RTCConfiguration& configuration);
361
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000362 // Storing the factory as a scoped reference pointer ensures that the memory
363 // in the PeerConnectionFactoryImpl remains available as long as the
364 // PeerConnection is running. It is passed to PeerConnection as a raw pointer.
365 // However, since the reference counting is done in the
deadbeefab9b2d12015-10-14 11:33:11 -0700366 // PeerConnectionFactoryInterface all instances created using the raw pointer
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000367 // will refer to the same reference count.
buildbot@webrtc.orgd4e598d2014-07-29 17:36:52 +0000368 rtc::scoped_refptr<PeerConnectionFactory> factory_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000369 PeerConnectionObserver* observer_;
buildbot@webrtc.org1567b8c2014-05-08 19:54:16 +0000370 UMAObserver* uma_observer_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000371 SignalingState signaling_state_;
372 // TODO(bemasc): Remove ice_state_.
373 IceState ice_state_;
374 IceConnectionState ice_connection_state_;
375 IceGatheringState ice_gathering_state_;
376
kwibergd1fe2812016-04-27 06:47:29 -0700377 std::unique_ptr<cricket::PortAllocator> port_allocator_;
378 std::unique_ptr<MediaControllerInterface> media_controller_;
deadbeefab9b2d12015-10-14 11:33:11 -0700379
zhihuang8f65cdf2016-05-06 18:40:30 -0700380 // One PeerConnection has only one RTCP CNAME.
381 // https://tools.ietf.org/html/draft-ietf-rtcweb-rtp-usage-26#section-4.9
382 std::string rtcp_cname_;
383
deadbeefab9b2d12015-10-14 11:33:11 -0700384 // Streams added via AddStream.
385 rtc::scoped_refptr<StreamCollection> local_streams_;
386 // Streams created as a result of SetRemoteDescription.
387 rtc::scoped_refptr<StreamCollection> remote_streams_;
388
kwibergd1fe2812016-04-27 06:47:29 -0700389 std::vector<std::unique_ptr<MediaStreamObserver>> stream_observers_;
deadbeefeb459812015-12-15 19:24:43 -0800390
deadbeefab9b2d12015-10-14 11:33:11 -0700391 // These lists store track info seen in local/remote descriptions.
392 TrackInfos remote_audio_tracks_;
393 TrackInfos remote_video_tracks_;
394 TrackInfos local_audio_tracks_;
395 TrackInfos local_video_tracks_;
396
397 SctpSidAllocator sid_allocator_;
398 // label -> DataChannel
399 std::map<std::string, rtc::scoped_refptr<DataChannel>> rtp_data_channels_;
400 std::vector<rtc::scoped_refptr<DataChannel>> sctp_data_channels_;
deadbeefbd292462015-12-14 18:15:29 -0800401 std::vector<rtc::scoped_refptr<DataChannel>> sctp_data_channels_to_free_;
deadbeefab9b2d12015-10-14 11:33:11 -0700402
deadbeefbda7e0b2015-12-08 17:13:40 -0800403 bool remote_peer_supports_msid_ = false;
deadbeef70ab1a12015-09-28 16:53:55 -0700404
405 std::vector<rtc::scoped_refptr<RtpSenderInterface>> senders_;
406 std::vector<rtc::scoped_refptr<RtpReceiverInterface>> receivers_;
deadbeefab9b2d12015-10-14 11:33:11 -0700407
kwibergd1fe2812016-04-27 06:47:29 -0700408 std::unique_ptr<WebRtcSession> session_;
kwibergd1fe2812016-04-27 06:47:29 -0700409 std::unique_ptr<StatsCollector> stats_;
henrike@webrtc.org28e20752013-07-10 00:45:36 +0000410};
411
412} // namespace webrtc
413
Henrik Kjellander15583c12016-02-10 10:53:12 +0100414#endif // WEBRTC_API_PEERCONNECTION_H_