| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 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 | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 #include "webrtc/pc/statscollector.h" | 25 #include "webrtc/pc/statscollector.h" |
| 26 #include "webrtc/pc/streamcollection.h" | 26 #include "webrtc/pc/streamcollection.h" |
| 27 #include "webrtc/pc/webrtcsession.h" | 27 #include "webrtc/pc/webrtcsession.h" |
| 28 | 28 |
| 29 namespace webrtc { | 29 namespace webrtc { |
| 30 | 30 |
| 31 class MediaStreamObserver; | 31 class MediaStreamObserver; |
| 32 class VideoRtpReceiver; | 32 class VideoRtpReceiver; |
| 33 class RtcEventLog; | 33 class RtcEventLog; |
| 34 | 34 |
| 35 // Populates |session_options| from |rtc_options|, and returns true if options | 35 // TODO(zhihuang): Remove this declaration when the WebRtcSession tests don't |
| 36 // are valid. | 36 // need it. |
| 37 // |session_options|->transport_options map entries must exist in order for | 37 void ExtractSharedMediaSessionOptions( |
| 38 // them to be populated from |rtc_options|. | |
| 39 bool ExtractMediaSessionOptions( | |
| 40 const PeerConnectionInterface::RTCOfferAnswerOptions& rtc_options, | 38 const PeerConnectionInterface::RTCOfferAnswerOptions& rtc_options, |
| 41 bool is_offer, | |
| 42 cricket::MediaSessionOptions* session_options); | 39 cricket::MediaSessionOptions* session_options); |
| 43 | 40 |
| 44 // Populates |session_options| from |constraints|, and returns true if all | |
| 45 // mandatory constraints are satisfied. | |
| 46 // Assumes that |session_options|->transport_options map entries exist. | |
| 47 // Will also set defaults if corresponding constraints are not present: | |
| 48 // recv_audio=true, recv_video=true, bundle_enabled=true. | |
| 49 // Other fields will be left with existing values. | |
| 50 // | |
| 51 // Deprecated. Will be removed once callers that use constraints are gone. | |
| 52 // TODO(hta): Remove when callers are gone. | |
| 53 // https://bugs.chromium.org/p/webrtc/issues/detail?id=5617 | |
| 54 bool ParseConstraintsForAnswer(const MediaConstraintsInterface* constraints, | |
| 55 cricket::MediaSessionOptions* session_options); | |
| 56 | |
| 57 // PeerConnection implements the PeerConnectionInterface interface. | 41 // PeerConnection implements the PeerConnectionInterface interface. |
| 58 // It uses WebRtcSession to implement the PeerConnection functionality. | 42 // It uses WebRtcSession to implement the PeerConnection functionality. |
| 59 class PeerConnection : public PeerConnectionInterface, | 43 class PeerConnection : public PeerConnectionInterface, |
| 60 public IceObserver, | 44 public IceObserver, |
| 61 public rtc::MessageHandler, | 45 public rtc::MessageHandler, |
| 62 public sigslot::has_slots<> { | 46 public sigslot::has_slots<> { |
| 63 public: | 47 public: |
| 64 explicit PeerConnection(PeerConnectionFactory* factory, | 48 explicit PeerConnection(PeerConnectionFactory* factory, |
| 65 std::unique_ptr<RtcEventLog> event_log, | 49 std::unique_ptr<RtcEventLog> event_log, |
| 66 std::unique_ptr<Call> call); | 50 std::unique_ptr<Call> call); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 void PostCreateSessionDescriptionFailure( | 221 void PostCreateSessionDescriptionFailure( |
| 238 CreateSessionDescriptionObserver* observer, | 222 CreateSessionDescriptionObserver* observer, |
| 239 const std::string& error); | 223 const std::string& error); |
| 240 | 224 |
| 241 bool IsClosed() const { | 225 bool IsClosed() const { |
| 242 return signaling_state_ == PeerConnectionInterface::kClosed; | 226 return signaling_state_ == PeerConnectionInterface::kClosed; |
| 243 } | 227 } |
| 244 | 228 |
| 245 // Returns a MediaSessionOptions struct with options decided by |options|, | 229 // Returns a MediaSessionOptions struct with options decided by |options|, |
| 246 // the local MediaStreams and DataChannels. | 230 // the local MediaStreams and DataChannels. |
| 247 virtual bool GetOptionsForOffer( | 231 void GetOptionsForOffer( |
| 248 const PeerConnectionInterface::RTCOfferAnswerOptions& rtc_options, | 232 const PeerConnectionInterface::RTCOfferAnswerOptions& rtc_options, |
| 249 cricket::MediaSessionOptions* session_options); | 233 cricket::MediaSessionOptions* session_options); |
| 250 | 234 |
| 251 // Returns a MediaSessionOptions struct with options decided by | 235 // Returns a MediaSessionOptions struct with options decided by |
| 252 // |constraints|, the local MediaStreams and DataChannels. | 236 // |constraints|, the local MediaStreams and DataChannels. |
| 253 // Deprecated, use version without constraints. | 237 void GetOptionsForAnswer(const RTCOfferAnswerOptions& options, |
| 254 virtual bool GetOptionsForAnswer( | 238 cricket::MediaSessionOptions* session_options); |
| 255 const MediaConstraintsInterface* constraints, | |
| 256 cricket::MediaSessionOptions* session_options); | |
| 257 virtual bool GetOptionsForAnswer( | |
| 258 const RTCOfferAnswerOptions& options, | |
| 259 cricket::MediaSessionOptions* session_options); | |
| 260 | 239 |
| 261 void InitializeOptionsForAnswer( | 240 // Generates MediaDescriptionOptions for the |session_opts| based on existing |
| 262 cricket::MediaSessionOptions* session_options); | 241 // local description or remote description. |
| 263 | 242 void GenerateMediaDescriptionOptions( |
| 264 // Helper function for options processing. | 243 const SessionDescriptionInterface* session_desc, |
| 265 // Deprecated. | 244 cricket::RtpTransceiverDirection audio_direction, |
| 266 virtual void FinishOptionsForAnswer( | 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, |
| 267 cricket::MediaSessionOptions* session_options); | 249 cricket::MediaSessionOptions* session_options); |
| 268 | 250 |
| 269 // Remove all local and remote tracks of type |media_type|. | 251 // Remove all local and remote tracks of type |media_type|. |
| 270 // Called when a media type is rejected (m-line set to port 0). | 252 // Called when a media type is rejected (m-line set to port 0). |
| 271 void RemoveTracks(cricket::MediaType media_type); | 253 void RemoveTracks(cricket::MediaType media_type); |
| 272 | 254 |
| 273 // Makes sure a MediaStreamTrack is created for each StreamParam in |streams|, | 255 // Makes sure a MediaStreamTrack is created for each StreamParam in |streams|, |
| 274 // and existing MediaStreamTracks are removed if there is no corresponding | 256 // and existing MediaStreamTracks are removed if there is no corresponding |
| 275 // StreamParam. If |default_track_needed| is true, a default MediaStreamTrack | 257 // StreamParam. If |default_track_needed| is true, a default MediaStreamTrack |
| 276 // is created if it doesn't exist; if false, it's removed if it exists. | 258 // is created if it doesn't exist; if false, it's removed if it exists. |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 void OnVoiceChannelDestroyed(); | 336 void OnVoiceChannelDestroyed(); |
| 355 void OnVideoChannelCreated(); | 337 void OnVideoChannelCreated(); |
| 356 void OnVideoChannelDestroyed(); | 338 void OnVideoChannelDestroyed(); |
| 357 void OnDataChannelCreated(); | 339 void OnDataChannelCreated(); |
| 358 void OnDataChannelDestroyed(); | 340 void OnDataChannelDestroyed(); |
| 359 // Called when the cricket::DataChannel receives a message indicating that a | 341 // Called when the cricket::DataChannel receives a message indicating that a |
| 360 // webrtc::DataChannel should be opened. | 342 // webrtc::DataChannel should be opened. |
| 361 void OnDataChannelOpenMessage(const std::string& label, | 343 void OnDataChannelOpenMessage(const std::string& label, |
| 362 const InternalDataChannelInit& config); | 344 const InternalDataChannelInit& config); |
| 363 | 345 |
| 346 bool HasRtpSender(cricket::MediaType type) const; |
| 364 RtpSenderInternal* FindSenderById(const std::string& id); | 347 RtpSenderInternal* FindSenderById(const std::string& id); |
| 365 | 348 |
| 366 std::vector<rtc::scoped_refptr< | 349 std::vector<rtc::scoped_refptr< |
| 367 RtpSenderProxyWithInternal<RtpSenderInternal>>>::iterator | 350 RtpSenderProxyWithInternal<RtpSenderInternal>>>::iterator |
| 368 FindSenderForTrack(MediaStreamTrackInterface* track); | 351 FindSenderForTrack(MediaStreamTrackInterface* track); |
| 369 std::vector<rtc::scoped_refptr< | 352 std::vector<rtc::scoped_refptr< |
| 370 RtpReceiverProxyWithInternal<RtpReceiverInternal>>>::iterator | 353 RtpReceiverProxyWithInternal<RtpReceiverInternal>>>::iterator |
| 371 FindReceiverForTrack(const std::string& track_id); | 354 FindReceiverForTrack(const std::string& track_id); |
| 372 | 355 |
| 373 TrackInfos* GetRemoteTracks(cricket::MediaType media_type); | 356 TrackInfos* GetRemoteTracks(cricket::MediaType media_type); |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 std::vector<rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>>> | 440 std::vector<rtc::scoped_refptr<RtpSenderProxyWithInternal<RtpSenderInternal>>> |
| 458 senders_; | 441 senders_; |
| 459 std::vector< | 442 std::vector< |
| 460 rtc::scoped_refptr<RtpReceiverProxyWithInternal<RtpReceiverInternal>>> | 443 rtc::scoped_refptr<RtpReceiverProxyWithInternal<RtpReceiverInternal>>> |
| 461 receivers_; | 444 receivers_; |
| 462 }; | 445 }; |
| 463 | 446 |
| 464 } // namespace webrtc | 447 } // namespace webrtc |
| 465 | 448 |
| 466 #endif // WEBRTC_PC_PEERCONNECTION_H_ | 449 #endif // WEBRTC_PC_PEERCONNECTION_H_ |
| OLD | NEW |