henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * libjingle |
jlmiller@webrtc.org | 5f93d0a | 2015-01-20 21:36:13 +0000 | [diff] [blame] | 3 | * Copyright 2012 Google Inc. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions are met: |
| 7 | * |
| 8 | * 1. Redistributions of source code must retain the above copyright notice, |
| 9 | * this list of conditions and the following disclaimer. |
| 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
| 11 | * this list of conditions and the following disclaimer in the documentation |
| 12 | * and/or other materials provided with the distribution. |
| 13 | * 3. The name of the author may not be used to endorse or promote products |
| 14 | * derived from this software without specific prior written permission. |
| 15 | * |
| 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED |
| 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO |
| 19 | * EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 20 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
| 21 | * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; |
| 22 | * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 23 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR |
| 24 | * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 25 | * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 | */ |
| 27 | |
| 28 | #ifndef TALK_APP_WEBRTC_PEERCONNECTION_H_ |
| 29 | #define TALK_APP_WEBRTC_PEERCONNECTION_H_ |
| 30 | |
| 31 | #include <string> |
| 32 | |
Henrik Boström | 5e56c59 | 2015-08-11 10:33:13 +0200 | [diff] [blame] | 33 | #include "talk/app/webrtc/dtlsidentitystore.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 34 | #include "talk/app/webrtc/peerconnectionfactory.h" |
buildbot@webrtc.org | a09a999 | 2014-08-13 17:26:08 +0000 | [diff] [blame] | 35 | #include "talk/app/webrtc/peerconnectioninterface.h" |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 36 | #include "talk/app/webrtc/rtpreceiverinterface.h" |
| 37 | #include "talk/app/webrtc/rtpsenderinterface.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 38 | #include "talk/app/webrtc/statscollector.h" |
| 39 | #include "talk/app/webrtc/streamcollection.h" |
| 40 | #include "talk/app/webrtc/webrtcsession.h" |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 41 | #include "webrtc/base/scoped_ptr.h" |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 42 | |
| 43 | namespace webrtc { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 44 | |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame^] | 45 | class RemoteMediaStreamFactory; |
| 46 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 47 | typedef std::vector<PortAllocatorFactoryInterface::StunConfiguration> |
| 48 | StunConfigurations; |
| 49 | typedef std::vector<PortAllocatorFactoryInterface::TurnConfiguration> |
| 50 | TurnConfigurations; |
| 51 | |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame^] | 52 | // Populates |session_options| from |rtc_options|, and returns true if options |
| 53 | // are valid. |
| 54 | // Send streams should already be added to |session_options| before this method |
| 55 | // is called, as this affects the values of recv_audio and recv_video. |
| 56 | bool ConvertRtcOptionsForOffer( |
| 57 | const PeerConnectionInterface::RTCOfferAnswerOptions& rtc_options, |
| 58 | cricket::MediaSessionOptions* session_options); |
| 59 | |
| 60 | // Populates |session_options| from |constraints|, and returns true if all |
| 61 | // mandatory constraints are satisfied. |
| 62 | bool ParseConstraintsForAnswer(const MediaConstraintsInterface* constraints, |
| 63 | cricket::MediaSessionOptions* session_options); |
| 64 | |
deadbeef | 0a6c4ca | 2015-10-06 11:38:28 -0700 | [diff] [blame] | 65 | // Parses the URLs for each server in |servers| to build |stun_config| and |
| 66 | // |turn_config|. |
| 67 | bool ParseIceServers(const PeerConnectionInterface::IceServers& servers, |
| 68 | StunConfigurations* stun_config, |
| 69 | TurnConfigurations* turn_config); |
| 70 | |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 71 | // PeerConnection implements the PeerConnectionInterface interface. |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame^] | 72 | // It uses WebRtcSession to implement the PeerConnection functionality. |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 73 | class PeerConnection : public PeerConnectionInterface, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 74 | public IceObserver, |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 75 | public rtc::MessageHandler, |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 76 | public sigslot::has_slots<> { |
| 77 | public: |
| 78 | explicit PeerConnection(PeerConnectionFactory* factory); |
| 79 | |
buildbot@webrtc.org | 41451d4 | 2014-05-03 05:39:45 +0000 | [diff] [blame] | 80 | bool Initialize( |
| 81 | const PeerConnectionInterface::RTCConfiguration& configuration, |
| 82 | const MediaConstraintsInterface* constraints, |
| 83 | PortAllocatorFactoryInterface* allocator_factory, |
Henrik Boström | 5e56c59 | 2015-08-11 10:33:13 +0200 | [diff] [blame] | 84 | rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, |
buildbot@webrtc.org | 41451d4 | 2014-05-03 05:39:45 +0000 | [diff] [blame] | 85 | PeerConnectionObserver* observer); |
deadbeef | a67696b | 2015-09-29 11:56:26 -0700 | [diff] [blame] | 86 | rtc::scoped_refptr<StreamCollectionInterface> local_streams() override; |
| 87 | rtc::scoped_refptr<StreamCollectionInterface> remote_streams() override; |
| 88 | bool AddStream(MediaStreamInterface* local_stream) override; |
| 89 | void RemoveStream(MediaStreamInterface* local_stream) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 90 | |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame^] | 91 | virtual WebRtcSession* session() { return session_.get(); } |
| 92 | |
deadbeef | a67696b | 2015-09-29 11:56:26 -0700 | [diff] [blame] | 93 | rtc::scoped_refptr<DtmfSenderInterface> CreateDtmfSender( |
| 94 | AudioTrackInterface* track) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 95 | |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 96 | std::vector<rtc::scoped_refptr<RtpSenderInterface>> GetSenders() |
| 97 | const override; |
| 98 | std::vector<rtc::scoped_refptr<RtpReceiverInterface>> GetReceivers() |
| 99 | const override; |
| 100 | |
deadbeef | a67696b | 2015-09-29 11:56:26 -0700 | [diff] [blame] | 101 | rtc::scoped_refptr<DataChannelInterface> CreateDataChannel( |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 102 | const std::string& label, |
deadbeef | a67696b | 2015-09-29 11:56:26 -0700 | [diff] [blame] | 103 | const DataChannelInit* config) override; |
| 104 | bool GetStats(StatsObserver* observer, |
| 105 | webrtc::MediaStreamTrackInterface* track, |
| 106 | StatsOutputLevel level) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 107 | |
deadbeef | a67696b | 2015-09-29 11:56:26 -0700 | [diff] [blame] | 108 | SignalingState signaling_state() override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 109 | |
| 110 | // TODO(bemasc): Remove ice_state() when callers are removed. |
deadbeef | a67696b | 2015-09-29 11:56:26 -0700 | [diff] [blame] | 111 | IceState ice_state() override; |
| 112 | IceConnectionState ice_connection_state() override; |
| 113 | IceGatheringState ice_gathering_state() override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 114 | |
deadbeef | a67696b | 2015-09-29 11:56:26 -0700 | [diff] [blame] | 115 | const SessionDescriptionInterface* local_description() const override; |
| 116 | const SessionDescriptionInterface* remote_description() const override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 117 | |
| 118 | // JSEP01 |
deadbeef | a67696b | 2015-09-29 11:56:26 -0700 | [diff] [blame] | 119 | void CreateOffer(CreateSessionDescriptionObserver* observer, |
| 120 | const MediaConstraintsInterface* constraints) override; |
| 121 | void CreateOffer(CreateSessionDescriptionObserver* observer, |
| 122 | const RTCOfferAnswerOptions& options) override; |
| 123 | void CreateAnswer(CreateSessionDescriptionObserver* observer, |
| 124 | const MediaConstraintsInterface* constraints) override; |
| 125 | void SetLocalDescription(SetSessionDescriptionObserver* observer, |
| 126 | SessionDescriptionInterface* desc) override; |
| 127 | void SetRemoteDescription(SetSessionDescriptionObserver* observer, |
| 128 | SessionDescriptionInterface* desc) override; |
| 129 | bool SetConfiguration( |
| 130 | const PeerConnectionInterface::RTCConfiguration& config) override; |
| 131 | bool AddIceCandidate(const IceCandidateInterface* candidate) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 132 | |
deadbeef | a67696b | 2015-09-29 11:56:26 -0700 | [diff] [blame] | 133 | void RegisterUMAObserver(UMAObserver* observer) override; |
buildbot@webrtc.org | 1567b8c | 2014-05-08 19:54:16 +0000 | [diff] [blame] | 134 | |
deadbeef | a67696b | 2015-09-29 11:56:26 -0700 | [diff] [blame] | 135 | void Close() override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 136 | |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame^] | 137 | // Virtual for unit tests. |
| 138 | virtual const std::vector<rtc::scoped_refptr<DataChannel>>& |
| 139 | sctp_data_channels() const { |
| 140 | return sctp_data_channels_; |
| 141 | }; |
| 142 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 143 | protected: |
deadbeef | a67696b | 2015-09-29 11:56:26 -0700 | [diff] [blame] | 144 | ~PeerConnection() override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 145 | |
| 146 | private: |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame^] | 147 | struct TrackInfo { |
| 148 | TrackInfo() : ssrc(0) {} |
| 149 | TrackInfo(const std::string& stream_label, |
| 150 | const std::string track_id, |
| 151 | uint32_t ssrc) |
| 152 | : stream_label(stream_label), track_id(track_id), ssrc(ssrc) {} |
| 153 | std::string stream_label; |
| 154 | std::string track_id; |
| 155 | uint32_t ssrc; |
| 156 | }; |
| 157 | typedef std::vector<TrackInfo> TrackInfos; |
| 158 | |
| 159 | struct RemotePeerInfo { |
| 160 | RemotePeerInfo() |
| 161 | : msid_supported(false), |
| 162 | default_audio_track_needed(false), |
| 163 | default_video_track_needed(false) {} |
| 164 | // True if it has been discovered that the remote peer support MSID. |
| 165 | bool msid_supported; |
| 166 | // The remote peer indicates in the session description that audio will be |
| 167 | // sent but no MSID is given. |
| 168 | bool default_audio_track_needed; |
| 169 | // The remote peer indicates in the session description that video will be |
| 170 | // sent but no MSID is given. |
| 171 | bool default_video_track_needed; |
| 172 | |
| 173 | bool IsDefaultMediaStreamNeeded() { |
| 174 | return !msid_supported && |
| 175 | (default_audio_track_needed || default_video_track_needed); |
| 176 | } |
| 177 | }; |
| 178 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 179 | // Implements MessageHandler. |
deadbeef | a67696b | 2015-09-29 11:56:26 -0700 | [diff] [blame] | 180 | void OnMessage(rtc::Message* msg) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 181 | |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame^] | 182 | void CreateAudioReceiver(MediaStreamInterface* stream, |
| 183 | AudioTrackInterface* audio_track, |
| 184 | uint32_t ssrc); |
| 185 | void CreateVideoReceiver(MediaStreamInterface* stream, |
| 186 | VideoTrackInterface* video_track, |
| 187 | uint32_t ssrc); |
| 188 | void DestroyAudioReceiver(MediaStreamInterface* stream, |
| 189 | AudioTrackInterface* audio_track); |
| 190 | void DestroyVideoReceiver(MediaStreamInterface* stream, |
| 191 | VideoTrackInterface* video_track); |
| 192 | void CreateAudioSender(MediaStreamInterface* stream, |
| 193 | AudioTrackInterface* audio_track, |
| 194 | uint32_t ssrc); |
| 195 | void CreateVideoSender(MediaStreamInterface* stream, |
| 196 | VideoTrackInterface* video_track, |
| 197 | uint32_t ssrc); |
| 198 | void DestroyAudioSender(MediaStreamInterface* stream, |
| 199 | AudioTrackInterface* audio_track, |
| 200 | uint32_t ssrc); |
| 201 | void DestroyVideoSender(MediaStreamInterface* stream, |
| 202 | VideoTrackInterface* video_track); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 203 | |
| 204 | // Implements IceObserver |
Peter Thatcher | 5436051 | 2015-07-08 11:08:35 -0700 | [diff] [blame] | 205 | void OnIceConnectionChange(IceConnectionState new_state) override; |
| 206 | void OnIceGatheringChange(IceGatheringState new_state) override; |
| 207 | void OnIceCandidate(const IceCandidateInterface* candidate) override; |
| 208 | void OnIceComplete() override; |
| 209 | void OnIceConnectionReceivingChange(bool receiving) override; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 210 | |
| 211 | // Signals from WebRtcSession. |
| 212 | void OnSessionStateChange(cricket::BaseSession* session, |
| 213 | cricket::BaseSession::State state); |
| 214 | void ChangeSignalingState(SignalingState signaling_state); |
| 215 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 216 | rtc::Thread* signaling_thread() const { |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 217 | return factory_->signaling_thread(); |
| 218 | } |
| 219 | |
| 220 | void PostSetSessionDescriptionFailure(SetSessionDescriptionObserver* observer, |
| 221 | const std::string& error); |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame^] | 222 | void PostCreateSessionDescriptionFailure( |
| 223 | CreateSessionDescriptionObserver* observer, |
| 224 | const std::string& error); |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 225 | |
| 226 | bool IsClosed() const { |
| 227 | return signaling_state_ == PeerConnectionInterface::kClosed; |
| 228 | } |
| 229 | |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame^] | 230 | // Returns a MediaSessionOptions struct with options decided by |options|, |
| 231 | // the local MediaStreams and DataChannels. |
| 232 | virtual bool GetOptionsForOffer( |
| 233 | const PeerConnectionInterface::RTCOfferAnswerOptions& rtc_options, |
| 234 | cricket::MediaSessionOptions* session_options); |
| 235 | |
| 236 | // Returns a MediaSessionOptions struct with options decided by |
| 237 | // |constraints|, the local MediaStreams and DataChannels. |
| 238 | virtual bool GetOptionsForAnswer( |
| 239 | const MediaConstraintsInterface* constraints, |
| 240 | cricket::MediaSessionOptions* session_options); |
| 241 | |
| 242 | // Makes sure a MediaStream Track is created for each StreamParam in |
| 243 | // |streams|. |media_type| is the type of the |streams| and can be either |
| 244 | // audio or video. |
| 245 | // If a new MediaStream is created it is added to |new_streams|. |
| 246 | void UpdateRemoteStreamsList( |
| 247 | const std::vector<cricket::StreamParams>& streams, |
| 248 | cricket::MediaType media_type, |
| 249 | StreamCollection* new_streams); |
| 250 | |
| 251 | // Triggered when a remote track has been seen for the first time in a remote |
| 252 | // session description. It creates a remote MediaStreamTrackInterface |
| 253 | // implementation and triggers CreateAudioReceiver or CreateVideoReceiver. |
| 254 | void OnRemoteTrackSeen(const std::string& stream_label, |
| 255 | const std::string& track_id, |
| 256 | uint32_t ssrc, |
| 257 | cricket::MediaType media_type); |
| 258 | |
| 259 | // Triggered when a remote track has been removed from a remote session |
| 260 | // description. It removes the remote track with id |track_id| from a remote |
| 261 | // MediaStream and triggers DestroyAudioReceiver or DestroyVideoReceiver. |
| 262 | void OnRemoteTrackRemoved(const std::string& stream_label, |
| 263 | const std::string& track_id, |
| 264 | cricket::MediaType media_type); |
| 265 | |
| 266 | // Finds remote MediaStreams without any tracks and removes them from |
| 267 | // |remote_streams_| and notifies the observer that the MediaStreams no longer |
| 268 | // exist. |
| 269 | void UpdateEndedRemoteMediaStreams(); |
| 270 | |
| 271 | void MaybeCreateDefaultStream(); |
| 272 | |
| 273 | // Set the MediaStreamTrackInterface::TrackState to |kEnded| on all remote |
| 274 | // tracks of type |media_type|. |
| 275 | void EndRemoteTracks(cricket::MediaType media_type); |
| 276 | |
| 277 | // Loops through the vector of |streams| and finds added and removed |
| 278 | // StreamParams since last time this method was called. |
| 279 | // For each new or removed StreamParam, OnLocalTrackSeen or |
| 280 | // OnLocalTrackRemoved is invoked. |
| 281 | void UpdateLocalTracks(const std::vector<cricket::StreamParams>& streams, |
| 282 | cricket::MediaType media_type); |
| 283 | |
| 284 | // Triggered when a local track has been seen for the first time in a local |
| 285 | // session description. |
| 286 | // This method triggers CreateAudioSender or CreateVideoSender if the rtp |
| 287 | // streams in the local SessionDescription can be mapped to a MediaStreamTrack |
| 288 | // in a MediaStream in |local_streams_| |
| 289 | void OnLocalTrackSeen(const std::string& stream_label, |
| 290 | const std::string& track_id, |
| 291 | uint32_t ssrc, |
| 292 | cricket::MediaType media_type); |
| 293 | |
| 294 | // Triggered when a local track has been removed from a local session |
| 295 | // description. |
| 296 | // This method triggers DestroyAudioSender or DestroyVideoSender if a stream |
| 297 | // has been removed from the local SessionDescription and the stream can be |
| 298 | // mapped to a MediaStreamTrack in a MediaStream in |local_streams_|. |
| 299 | void OnLocalTrackRemoved(const std::string& stream_label, |
| 300 | const std::string& track_id, |
| 301 | uint32_t ssrc, |
| 302 | cricket::MediaType media_type); |
| 303 | |
| 304 | void UpdateLocalRtpDataChannels(const cricket::StreamParamsVec& streams); |
| 305 | void UpdateRemoteRtpDataChannels(const cricket::StreamParamsVec& streams); |
| 306 | void UpdateClosingRtpDataChannels( |
| 307 | const std::vector<std::string>& active_channels, |
| 308 | bool is_local_update); |
| 309 | void CreateRemoteRtpDataChannel(const std::string& label, |
| 310 | uint32_t remote_ssrc); |
| 311 | |
| 312 | // Creates channel and adds it to the collection of DataChannels that will |
| 313 | // be offered in a SessionDescription. |
| 314 | rtc::scoped_refptr<DataChannel> InternalCreateDataChannel( |
| 315 | const std::string& label, |
| 316 | const InternalDataChannelInit* config); |
| 317 | |
| 318 | // Checks if any data channel has been added. |
| 319 | bool HasDataChannels() const; |
| 320 | |
| 321 | void AllocateSctpSids(rtc::SSLRole role); |
| 322 | void OnSctpDataChannelClosed(DataChannel* channel); |
| 323 | |
| 324 | // Notifications from WebRtcSession relating to BaseChannels. |
| 325 | void OnVoiceChannelDestroyed(); |
| 326 | void OnVideoChannelDestroyed(); |
| 327 | void OnDataChannelCreated(); |
| 328 | void OnDataChannelDestroyed(); |
| 329 | // Called when the cricket::DataChannel receives a message indicating that a |
| 330 | // webrtc::DataChannel should be opened. |
| 331 | void OnDataChannelOpenMessage(const std::string& label, |
| 332 | const InternalDataChannelInit& config); |
| 333 | |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 334 | std::vector<rtc::scoped_refptr<RtpSenderInterface>>::iterator |
| 335 | FindSenderForTrack(MediaStreamTrackInterface* track); |
| 336 | std::vector<rtc::scoped_refptr<RtpReceiverInterface>>::iterator |
| 337 | FindReceiverForTrack(MediaStreamTrackInterface* track); |
| 338 | |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame^] | 339 | TrackInfos* GetRemoteTracks(cricket::MediaType media_type); |
| 340 | TrackInfos* GetLocalTracks(cricket::MediaType media_type); |
| 341 | const TrackInfo* FindTrackInfo(const TrackInfos& infos, |
| 342 | const std::string& stream_label, |
| 343 | const std::string track_id) const; |
| 344 | |
| 345 | // Returns the specified SCTP DataChannel in sctp_data_channels_, |
| 346 | // or nullptr if not found. |
| 347 | DataChannel* FindDataChannelBySid(int sid) const; |
| 348 | |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 349 | // Storing the factory as a scoped reference pointer ensures that the memory |
| 350 | // in the PeerConnectionFactoryImpl remains available as long as the |
| 351 | // PeerConnection is running. It is passed to PeerConnection as a raw pointer. |
| 352 | // However, since the reference counting is done in the |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame^] | 353 | // PeerConnectionFactoryInterface all instances created using the raw pointer |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 354 | // will refer to the same reference count. |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 355 | rtc::scoped_refptr<PeerConnectionFactory> factory_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 356 | PeerConnectionObserver* observer_; |
buildbot@webrtc.org | 1567b8c | 2014-05-08 19:54:16 +0000 | [diff] [blame] | 357 | UMAObserver* uma_observer_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 358 | SignalingState signaling_state_; |
| 359 | // TODO(bemasc): Remove ice_state_. |
| 360 | IceState ice_state_; |
| 361 | IceConnectionState ice_connection_state_; |
| 362 | IceGatheringState ice_gathering_state_; |
| 363 | |
buildbot@webrtc.org | d4e598d | 2014-07-29 17:36:52 +0000 | [diff] [blame] | 364 | rtc::scoped_ptr<cricket::PortAllocator> port_allocator_; |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame^] | 365 | |
| 366 | // Streams added via AddStream. |
| 367 | rtc::scoped_refptr<StreamCollection> local_streams_; |
| 368 | // Streams created as a result of SetRemoteDescription. |
| 369 | rtc::scoped_refptr<StreamCollection> remote_streams_; |
| 370 | |
| 371 | // These lists store track info seen in local/remote descriptions. |
| 372 | TrackInfos remote_audio_tracks_; |
| 373 | TrackInfos remote_video_tracks_; |
| 374 | TrackInfos local_audio_tracks_; |
| 375 | TrackInfos local_video_tracks_; |
| 376 | |
| 377 | SctpSidAllocator sid_allocator_; |
| 378 | // label -> DataChannel |
| 379 | std::map<std::string, rtc::scoped_refptr<DataChannel>> rtp_data_channels_; |
| 380 | std::vector<rtc::scoped_refptr<DataChannel>> sctp_data_channels_; |
| 381 | |
| 382 | RemotePeerInfo remote_info_; |
| 383 | rtc::scoped_ptr<RemoteMediaStreamFactory> remote_stream_factory_; |
deadbeef | 70ab1a1 | 2015-09-28 16:53:55 -0700 | [diff] [blame] | 384 | |
| 385 | std::vector<rtc::scoped_refptr<RtpSenderInterface>> senders_; |
| 386 | std::vector<rtc::scoped_refptr<RtpReceiverInterface>> receivers_; |
deadbeef | ab9b2d1 | 2015-10-14 11:33:11 -0700 | [diff] [blame^] | 387 | |
| 388 | // The session_ scoped_ptr is declared at the bottom of PeerConnection |
| 389 | // because its destruction fires signals (such as VoiceChannelDestroyed) |
| 390 | // which will trigger some final actions in PeerConnection... |
| 391 | rtc::scoped_ptr<WebRtcSession> session_; |
| 392 | // ... But stats_ depends on session_ so it should be destroyed even earlier. |
| 393 | rtc::scoped_ptr<StatsCollector> stats_; |
henrike@webrtc.org | 28e2075 | 2013-07-10 00:45:36 +0000 | [diff] [blame] | 394 | }; |
| 395 | |
| 396 | } // namespace webrtc |
| 397 | |
| 398 | #endif // TALK_APP_WEBRTC_PEERCONNECTION_H_ |