Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * libjingle | 2 * libjingle |
| 3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
| 7 * | 7 * |
| 8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
| 9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | 22 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 23 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | 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 | 24 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF |
| 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 25 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 */ | 26 */ |
| 27 | 27 |
| 28 #ifndef TALK_APP_WEBRTC_WEBRTCSESSION_H_ | 28 #ifndef TALK_APP_WEBRTC_WEBRTCSESSION_H_ |
| 29 #define TALK_APP_WEBRTC_WEBRTCSESSION_H_ | 29 #define TALK_APP_WEBRTC_WEBRTCSESSION_H_ |
| 30 | 30 |
| 31 #include <string> | 31 #include <string> |
| 32 #include <vector> | |
| 32 | 33 |
| 33 #include "talk/app/webrtc/datachannel.h" | 34 #include "talk/app/webrtc/datachannel.h" |
| 34 #include "talk/app/webrtc/dtmfsender.h" | 35 #include "talk/app/webrtc/dtmfsender.h" |
| 35 #include "talk/app/webrtc/mediastreamprovider.h" | 36 #include "talk/app/webrtc/mediastreamprovider.h" |
| 36 #include "talk/app/webrtc/peerconnectioninterface.h" | 37 #include "talk/app/webrtc/peerconnectioninterface.h" |
| 37 #include "talk/app/webrtc/statstypes.h" | 38 #include "talk/app/webrtc/statstypes.h" |
| 38 #include "talk/media/base/mediachannel.h" | 39 #include "talk/media/base/mediachannel.h" |
| 39 #include "webrtc/p2p/base/session.h" | 40 #include "webrtc/p2p/base/session.h" |
| 40 #include "talk/session/media/mediasession.h" | 41 #include "talk/session/media/mediasession.h" |
| 41 #include "webrtc/base/sigslot.h" | 42 #include "webrtc/base/sigslot.h" |
| 42 #include "webrtc/base/sslidentity.h" | 43 #include "webrtc/base/sslidentity.h" |
| 43 #include "webrtc/base/thread.h" | 44 #include "webrtc/base/thread.h" |
| 44 | 45 |
| 45 namespace cricket { | 46 namespace cricket { |
| 46 | 47 |
| 47 class BaseChannel; | 48 class BaseChannel; |
| 48 class ChannelManager; | 49 class ChannelManager; |
| 49 class DataChannel; | 50 class DataChannel; |
| 50 class StatsReport; | 51 class StatsReport; |
| 51 class Transport; | |
| 52 class VideoCapturer; | 52 class VideoCapturer; |
| 53 class VideoChannel; | 53 class VideoChannel; |
| 54 class VoiceChannel; | 54 class VoiceChannel; |
| 55 | 55 |
| 56 } // namespace cricket | 56 } // namespace cricket |
| 57 | 57 |
| 58 namespace webrtc { | 58 namespace webrtc { |
| 59 | 59 |
| 60 class IceRestartAnswerLatch; | 60 class IceRestartAnswerLatch; |
| 61 class JsepIceCandidate; | 61 class JsepIceCandidate; |
| 62 class MediaStreamSignaling; | 62 class MediaStreamSignaling; |
| 63 class WebRtcSessionDescriptionFactory; | 63 class WebRtcSessionDescriptionFactory; |
| 64 | 64 |
| 65 extern const char kBundleWithoutRtcpMux[]; | 65 extern const char kBundleWithoutRtcpMux[]; |
| 66 extern const char kCreateChannelFailed[]; | 66 extern const char kCreateChannelFailed[]; |
| 67 extern const char kInvalidCandidates[]; | 67 extern const char kInvalidCandidates[]; |
| 68 extern const char kInvalidSdp[]; | 68 extern const char kInvalidSdp[]; |
| 69 extern const char kMlineMismatch[]; | 69 extern const char kMlineMismatch[]; |
| 70 extern const char kPushDownTDFailed[]; | 70 extern const char kPushDownTDFailed[]; |
| 71 extern const char kSdpWithoutDtlsFingerprint[]; | 71 extern const char kSdpWithoutDtlsFingerprint[]; |
| 72 extern const char kSdpWithoutSdesCrypto[]; | 72 extern const char kSdpWithoutSdesCrypto[]; |
| 73 extern const char kSdpWithoutIceUfragPwd[]; | 73 extern const char kSdpWithoutIceUfragPwd[]; |
| 74 extern const char kSdpWithoutSdesAndDtlsDisabled[]; | 74 extern const char kSdpWithoutSdesAndDtlsDisabled[]; |
| 75 extern const char kSessionError[]; | 75 extern const char kSessionError[]; |
| 76 extern const char kSessionErrorDesc[]; | 76 extern const char kSessionErrorDesc[]; |
| 77 extern const char kDtlsSetupFailureRtp[]; | 77 extern const char kDtlsSetupFailureRtp[]; |
| 78 extern const char kDtlsSetupFailureRtcp[]; | 78 extern const char kDtlsSetupFailureRtcp[]; |
| 79 extern const char kEnableBundleFailed[]; | |
| 80 | |
| 79 // Maximum number of received video streams that will be processed by webrtc | 81 // Maximum number of received video streams that will be processed by webrtc |
| 80 // even if they are not signalled beforehand. | 82 // even if they are not signalled beforehand. |
| 81 extern const int kMaxUnsignalledRecvStreams; | 83 extern const int kMaxUnsignalledRecvStreams; |
| 82 | 84 |
| 83 // ICE state callback interface. | 85 // ICE state callback interface. |
| 84 class IceObserver { | 86 class IceObserver { |
| 85 public: | 87 public: |
| 86 IceObserver() {} | 88 IceObserver() {} |
| 87 // Called any time the IceConnectionState changes | 89 // Called any time the IceConnectionState changes |
| 88 // TODO(honghaiz): Change the name to OnIceConnectionStateChange so as to | 90 // TODO(honghaiz): Change the name to OnIceConnectionStateChange so as to |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 228 bool ConnectDataChannel(DataChannel* webrtc_data_channel) override; | 230 bool ConnectDataChannel(DataChannel* webrtc_data_channel) override; |
| 229 void DisconnectDataChannel(DataChannel* webrtc_data_channel) override; | 231 void DisconnectDataChannel(DataChannel* webrtc_data_channel) override; |
| 230 void AddSctpDataStream(int sid) override; | 232 void AddSctpDataStream(int sid) override; |
| 231 void RemoveSctpDataStream(int sid) override; | 233 void RemoveSctpDataStream(int sid) override; |
| 232 bool ReadyToSendData() const override; | 234 bool ReadyToSendData() const override; |
| 233 | 235 |
| 234 // Returns stats for all channels of all transports. | 236 // Returns stats for all channels of all transports. |
| 235 // This avoids exposing the internal structures used to track them. | 237 // This avoids exposing the internal structures used to track them. |
| 236 virtual bool GetTransportStats(cricket::SessionStats* stats); | 238 virtual bool GetTransportStats(cricket::SessionStats* stats); |
| 237 | 239 |
| 240 // Get stats for a specific channel | |
| 241 bool GetChannelTransportStats(cricket::BaseChannel* ch, | |
| 242 cricket::SessionStats* stats); | |
| 243 | |
| 244 // virtual so it can be mocked in unit tests | |
| 245 virtual bool GetCertificate( | |
| 246 const std::string& content_name, | |
| 247 rtc::scoped_refptr<rtc::RTCCertificate>* certificate); | |
| 248 | |
| 249 // Caller owns returned certificate | |
| 250 virtual bool GetRemoteCertificate(const std::string& content_name, | |
| 251 rtc::SSLCertificate** cert); | |
| 252 | |
| 238 // Implements DataChannelFactory. | 253 // Implements DataChannelFactory. |
| 239 rtc::scoped_refptr<DataChannel> CreateDataChannel( | 254 rtc::scoped_refptr<DataChannel> CreateDataChannel( |
| 240 const std::string& label, | 255 const std::string& label, |
| 241 const InternalDataChannelInit* config) override; | 256 const InternalDataChannelInit* config) override; |
| 242 | 257 |
| 243 cricket::DataChannelType data_channel_type() const; | 258 cricket::DataChannelType data_channel_type() const; |
| 244 | 259 |
| 245 bool IceRestartPending() const; | 260 bool IceRestartPending() const; |
| 246 | 261 |
| 247 void ResetIceRestartLatch(); | 262 void ResetIceRestartLatch(); |
| 248 | 263 |
| 249 // Called when an RTCCertificate is generated or retrieved by | 264 // Called when an RTCCertificate is generated or retrieved by |
| 250 // WebRTCSessionDescriptionFactory. Should happen before setLocalDescription. | 265 // WebRTCSessionDescriptionFactory. Should happen before setLocalDescription. |
| 251 void OnCertificateReady( | 266 void OnCertificateReady( |
| 252 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate); | 267 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate); |
| 253 void OnDtlsSetupFailure(cricket::BaseChannel*, bool rtcp); | 268 void OnDtlsSetupFailure(cricket::BaseChannel*, bool rtcp); |
| 254 | 269 |
| 255 // For unit test. | 270 // For unit test. |
| 256 bool waiting_for_certificate_for_testing() const; | 271 bool waiting_for_certificate_for_testing() const; |
| 272 rtc::scoped_refptr<rtc::RTCCertificate> certificate_for_testing(); | |
|
pthatcher1
2015/08/31 22:01:35
This seems a little odd. Can you comment on why t
Taylor Brandstetter
2015/09/01 23:53:30
It's used for a unit test. This is just part of a
| |
| 257 | 273 |
| 258 void set_metrics_observer( | 274 void set_metrics_observer( |
| 259 webrtc::MetricsObserverInterface* metrics_observer) { | 275 webrtc::MetricsObserverInterface* metrics_observer) { |
| 260 metrics_observer_ = metrics_observer; | 276 metrics_observer_ = metrics_observer; |
| 261 } | 277 } |
| 262 | 278 |
| 263 private: | 279 private: |
| 264 // Indicates the type of SessionDescription in a call to SetLocalDescription | 280 // Indicates the type of SessionDescription in a call to SetLocalDescription |
| 265 // and SetRemoteDescription. | 281 // and SetRemoteDescription. |
| 266 enum Action { | 282 enum Action { |
| 267 kOffer, | 283 kOffer, |
| 268 kPrAnswer, | 284 kPrAnswer, |
| 269 kAnswer, | 285 kAnswer, |
| 270 }; | 286 }; |
| 271 | 287 |
| 272 // Invokes ConnectChannels() on transport proxies, which initiates ice | |
| 273 // candidates allocation. | |
| 274 bool StartCandidatesAllocation(); | |
| 275 bool UpdateSessionState(Action action, cricket::ContentSource source, | 288 bool UpdateSessionState(Action action, cricket::ContentSource source, |
| 276 std::string* err_desc); | 289 std::string* err_desc); |
| 277 static Action GetAction(const std::string& type); | 290 static Action GetAction(const std::string& type); |
| 278 // Push the media parts of the local or remote session description | 291 // Push the media parts of the local or remote session description |
| 279 // down to all of the channels. | 292 // down to all of the channels. |
| 280 bool PushdownMediaDescription(cricket::ContentAction action, | 293 bool PushdownMediaDescription(cricket::ContentAction action, |
| 281 cricket::ContentSource source, | 294 cricket::ContentSource source, |
| 282 std::string* error_desc); | 295 std::string* error_desc); |
| 283 | 296 |
| 284 | 297 cricket::BaseChannel* GetChannel(const std::string& content_name); |
| 285 // Transport related callbacks, override from cricket::BaseSession. | 298 // Cause all the BaseChannels in the bundle group to have the same |
| 286 virtual void OnTransportRequestSignaling(cricket::Transport* transport); | 299 // transport channel. |
| 287 virtual void OnTransportConnecting(cricket::Transport* transport); | 300 bool EnableBundle(const cricket::ContentGroup& bundle); |
| 288 virtual void OnTransportWritable(cricket::Transport* transport); | |
| 289 virtual void OnTransportCompleted(cricket::Transport* transport); | |
| 290 virtual void OnTransportFailed(cricket::Transport* transport); | |
| 291 virtual void OnTransportProxyCandidatesReady( | |
| 292 cricket::TransportProxy* proxy, | |
| 293 const cricket::Candidates& candidates); | |
| 294 virtual void OnCandidatesAllocationDone(); | |
| 295 void OnTransportReceiving(cricket::Transport* transport) override; | |
| 296 | 301 |
| 297 // Enables media channels to allow sending of media. | 302 // Enables media channels to allow sending of media. |
| 298 void EnableChannels(); | 303 void EnableChannels(); |
| 299 // Creates a JsepIceCandidate and adds it to the local session description | |
| 300 // and notify observers. Called when a new local candidate have been found. | |
| 301 void ProcessNewLocalCandidate(const std::string& content_name, | |
| 302 const cricket::Candidates& candidates); | |
| 303 // Returns the media index for a local ice candidate given the content name. | 304 // Returns the media index for a local ice candidate given the content name. |
| 304 // Returns false if the local session description does not have a media | 305 // Returns false if the local session description does not have a media |
| 305 // content called |content_name|. | 306 // content called |content_name|. |
| 306 bool GetLocalCandidateMediaIndex(const std::string& content_name, | 307 bool GetLocalCandidateMediaIndex(const std::string& content_name, |
| 307 int* sdp_mline_index); | 308 int* sdp_mline_index); |
| 308 // Uses all remote candidates in |remote_desc| in this session. | 309 // Uses all remote candidates in |remote_desc| in this session. |
| 309 bool UseCandidatesInSessionDescription( | 310 bool UseCandidatesInSessionDescription( |
| 310 const SessionDescriptionInterface* remote_desc); | 311 const SessionDescriptionInterface* remote_desc); |
| 311 // Uses |candidate| in this session. | 312 // Uses |candidate| in this session. |
| 312 bool UseCandidate(const IceCandidateInterface* candidate); | 313 bool UseCandidate(const IceCandidateInterface* candidate); |
| 313 // Deletes the corresponding channel of contents that don't exist in |desc|. | 314 // Deletes the corresponding channel of contents that don't exist in |desc|. |
| 314 // |desc| can be null. This means that all channels are deleted. | 315 // |desc| can be null. This means that all channels are deleted. |
| 315 void RemoveUnusedChannelsAndTransports( | 316 void RemoveUnusedChannels(const cricket::SessionDescription* desc); |
| 316 const cricket::SessionDescription* desc); | |
| 317 | 317 |
| 318 // Allocates media channels based on the |desc|. If |desc| doesn't have | 318 // Allocates media channels based on the |desc|. If |desc| doesn't have |
| 319 // the BUNDLE option, this method will disable BUNDLE in PortAllocator. | 319 // the BUNDLE option, this method will disable BUNDLE in PortAllocator. |
| 320 // This method will also delete any existing media channels before creating. | 320 // This method will also delete any existing media channels before creating. |
| 321 bool CreateChannels(const cricket::SessionDescription* desc); | 321 bool CreateChannels(const cricket::SessionDescription* desc); |
| 322 | 322 |
| 323 // Helper methods to create media channels. | 323 // Helper methods to create media channels. |
| 324 bool CreateVoiceChannel(const cricket::ContentInfo* content); | 324 bool CreateVoiceChannel(const cricket::ContentInfo* content); |
| 325 bool CreateVideoChannel(const cricket::ContentInfo* content); | 325 bool CreateVideoChannel(const cricket::ContentInfo* content); |
| 326 bool CreateDataChannel(const cricket::ContentInfo* content); | 326 bool CreateDataChannel(const cricket::ContentInfo* content); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 355 Action action); | 355 Action action); |
| 356 | 356 |
| 357 // Returns true if we are ready to push down the remote candidate. | 357 // Returns true if we are ready to push down the remote candidate. |
| 358 // |remote_desc| is the new remote description, or NULL if the current remote | 358 // |remote_desc| is the new remote description, or NULL if the current remote |
| 359 // description should be used. Output |valid| is true if the candidate media | 359 // description should be used. Output |valid| is true if the candidate media |
| 360 // index is valid. | 360 // index is valid. |
| 361 bool ReadyToUseRemoteCandidate(const IceCandidateInterface* candidate, | 361 bool ReadyToUseRemoteCandidate(const IceCandidateInterface* candidate, |
| 362 const SessionDescriptionInterface* remote_desc, | 362 const SessionDescriptionInterface* remote_desc, |
| 363 bool* valid); | 363 bool* valid); |
| 364 | 364 |
| 365 void OnTransportControllerConnectionState(cricket::IceConnectionState state); | |
| 366 void OnTransportControllerReceiving(bool receiving); | |
| 367 void OnTransportControllerGatheringState(cricket::IceGatheringState state); | |
| 368 void OnTransportControllerCandidatesGathered( | |
| 369 const std::string& transport_name, | |
| 370 const cricket::Candidates& candidates); | |
| 371 | |
| 365 std::string GetSessionErrorMsg(); | 372 std::string GetSessionErrorMsg(); |
| 366 | 373 |
| 367 // Invoked when OnTransportCompleted is signaled to gather the usage | 374 // Invoked when TransportController connection completion is signaled to |
| 368 // of IPv4/IPv6 as best connection. | 375 // gather the usage of IPv4/IPv6 as best connection. |
| 369 void ReportBestConnectionState(const cricket::TransportStats& stats); | 376 void ReportBestConnectionState(const cricket::TransportStats& stats); |
| 370 | 377 |
| 371 void ReportNegotiatedCiphers(const cricket::TransportStats& stats); | 378 void ReportNegotiatedCiphers(const cricket::TransportStats& stats); |
| 372 | 379 |
| 373 rtc::scoped_ptr<cricket::VoiceChannel> voice_channel_; | 380 rtc::scoped_ptr<cricket::VoiceChannel> voice_channel_; |
| 374 rtc::scoped_ptr<cricket::VideoChannel> video_channel_; | 381 rtc::scoped_ptr<cricket::VideoChannel> video_channel_; |
| 375 rtc::scoped_ptr<cricket::DataChannel> data_channel_; | 382 rtc::scoped_ptr<cricket::DataChannel> data_channel_; |
| 376 cricket::ChannelManager* channel_manager_; | 383 cricket::ChannelManager* channel_manager_; |
| 377 MediaStreamSignaling* mediastream_signaling_; | 384 MediaStreamSignaling* mediastream_signaling_; |
| 378 IceObserver* ice_observer_; | 385 IceObserver* ice_observer_; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 411 PeerConnectionInterface::BundlePolicy bundle_policy_; | 418 PeerConnectionInterface::BundlePolicy bundle_policy_; |
| 412 | 419 |
| 413 // Declares the RTCP mux policy for the WebRTCSession. | 420 // Declares the RTCP mux policy for the WebRTCSession. |
| 414 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy_; | 421 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy_; |
| 415 | 422 |
| 416 DISALLOW_COPY_AND_ASSIGN(WebRtcSession); | 423 DISALLOW_COPY_AND_ASSIGN(WebRtcSession); |
| 417 }; | 424 }; |
| 418 } // namespace webrtc | 425 } // namespace webrtc |
| 419 | 426 |
| 420 #endif // TALK_APP_WEBRTC_WEBRTCSESSION_H_ | 427 #endif // TALK_APP_WEBRTC_WEBRTCSESSION_H_ |
| OLD | NEW |