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/thread.h" | 43 #include "webrtc/base/thread.h" |
| 43 | 44 |
| 44 namespace cricket { | 45 namespace cricket { |
| 45 | 46 |
| 46 class BaseChannel; | 47 class BaseChannel; |
| 47 class ChannelManager; | 48 class ChannelManager; |
| 48 class DataChannel; | 49 class DataChannel; |
| 49 class StatsReport; | 50 class StatsReport; |
| 50 class Transport; | |
| 51 class VideoCapturer; | 51 class VideoCapturer; |
| 52 class VideoChannel; | 52 class VideoChannel; |
| 53 class VoiceChannel; | 53 class VoiceChannel; |
| 54 | 54 |
| 55 } // namespace cricket | 55 } // namespace cricket |
| 56 | 56 |
| 57 namespace webrtc { | 57 namespace webrtc { |
| 58 | 58 |
| 59 class IceRestartAnswerLatch; | 59 class IceRestartAnswerLatch; |
| 60 class JsepIceCandidate; | 60 class JsepIceCandidate; |
| 61 class MediaStreamSignaling; | 61 class MediaStreamSignaling; |
| 62 class WebRtcSessionDescriptionFactory; | 62 class WebRtcSessionDescriptionFactory; |
| 63 | 63 |
| 64 extern const char kBundleWithoutRtcpMux[]; | 64 extern const char kBundleWithoutRtcpMux[]; |
| 65 extern const char kCreateChannelFailed[]; | 65 extern const char kCreateChannelFailed[]; |
| 66 extern const char kInvalidCandidates[]; | 66 extern const char kInvalidCandidates[]; |
| 67 extern const char kInvalidSdp[]; | 67 extern const char kInvalidSdp[]; |
| 68 extern const char kMlineMismatch[]; | 68 extern const char kMlineMismatch[]; |
| 69 extern const char kPushDownTDFailed[]; | 69 extern const char kPushDownTDFailed[]; |
| 70 extern const char kSdpWithoutDtlsFingerprint[]; | 70 extern const char kSdpWithoutDtlsFingerprint[]; |
| 71 extern const char kSdpWithoutSdesCrypto[]; | 71 extern const char kSdpWithoutSdesCrypto[]; |
| 72 extern const char kSdpWithoutIceUfragPwd[]; | 72 extern const char kSdpWithoutIceUfragPwd[]; |
| 73 extern const char kSdpWithoutSdesAndDtlsDisabled[]; | 73 extern const char kSdpWithoutSdesAndDtlsDisabled[]; |
| 74 extern const char kSessionError[]; | 74 extern const char kSessionError[]; |
| 75 extern const char kSessionErrorDesc[]; | 75 extern const char kSessionErrorDesc[]; |
| 76 extern const char kDtlsSetupFailureRtp[]; | 76 extern const char kDtlsSetupFailureRtp[]; |
| 77 extern const char kDtlsSetupFailureRtcp[]; | 77 extern const char kDtlsSetupFailureRtcp[]; |
| 78 extern const char kEnableBundleFailed[]; | |
| 79 | |
| 78 // Maximum number of received video streams that will be processed by webrtc | 80 // Maximum number of received video streams that will be processed by webrtc |
| 79 // even if they are not signalled beforehand. | 81 // even if they are not signalled beforehand. |
| 80 extern const int kMaxUnsignalledRecvStreams; | 82 extern const int kMaxUnsignalledRecvStreams; |
| 81 | 83 |
| 82 // ICE state callback interface. | 84 // ICE state callback interface. |
| 83 class IceObserver { | 85 class IceObserver { |
| 84 public: | 86 public: |
| 85 IceObserver() {} | 87 IceObserver() {} |
| 86 // Called any time the IceConnectionState changes | 88 // Called any time the IceConnectionState changes |
| 87 // TODO(honghaiz): Change the name to OnIceConnectionStateChange so as to | 89 // TODO(honghaiz): Change the name to OnIceConnectionStateChange so as to |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 bool ConnectDataChannel(DataChannel* webrtc_data_channel) override; | 229 bool ConnectDataChannel(DataChannel* webrtc_data_channel) override; |
| 228 void DisconnectDataChannel(DataChannel* webrtc_data_channel) override; | 230 void DisconnectDataChannel(DataChannel* webrtc_data_channel) override; |
| 229 void AddSctpDataStream(int sid) override; | 231 void AddSctpDataStream(int sid) override; |
| 230 void RemoveSctpDataStream(int sid) override; | 232 void RemoveSctpDataStream(int sid) override; |
| 231 bool ReadyToSendData() const override; | 233 bool ReadyToSendData() const override; |
| 232 | 234 |
| 233 // Returns stats for all channels of all transports. | 235 // Returns stats for all channels of all transports. |
| 234 // This avoids exposing the internal structures used to track them. | 236 // This avoids exposing the internal structures used to track them. |
| 235 virtual bool GetTransportStats(cricket::SessionStats* stats); | 237 virtual bool GetTransportStats(cricket::SessionStats* stats); |
| 236 | 238 |
| 239 // Get stats for a specific channel | |
| 240 bool GetChannelTransportStats(cricket::BaseChannel* ch, | |
| 241 cricket::SessionStats* stats); | |
| 242 | |
| 243 // Caller owns returned identity | |
| 244 virtual bool GetIdentity(const std::string& content_name, | |
| 245 rtc::SSLIdentity** identity); | |
| 246 | |
| 247 // Caller owns returned certificate | |
| 248 virtual bool GetRemoteCertificate(const std::string& content_name, | |
| 249 rtc::SSLCertificate** cert); | |
| 250 | |
| 237 // Implements DataChannelFactory. | 251 // Implements DataChannelFactory. |
| 238 rtc::scoped_refptr<DataChannel> CreateDataChannel( | 252 rtc::scoped_refptr<DataChannel> CreateDataChannel( |
| 239 const std::string& label, | 253 const std::string& label, |
| 240 const InternalDataChannelInit* config) override; | 254 const InternalDataChannelInit* config) override; |
| 241 | 255 |
| 242 cricket::DataChannelType data_channel_type() const; | 256 cricket::DataChannelType data_channel_type() const; |
| 243 | 257 |
| 244 bool IceRestartPending() const; | 258 bool IceRestartPending() const; |
| 245 | 259 |
| 246 void ResetIceRestartLatch(); | 260 void ResetIceRestartLatch(); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 260 | 274 |
| 261 private: | 275 private: |
| 262 // Indicates the type of SessionDescription in a call to SetLocalDescription | 276 // Indicates the type of SessionDescription in a call to SetLocalDescription |
| 263 // and SetRemoteDescription. | 277 // and SetRemoteDescription. |
| 264 enum Action { | 278 enum Action { |
| 265 kOffer, | 279 kOffer, |
| 266 kPrAnswer, | 280 kPrAnswer, |
| 267 kAnswer, | 281 kAnswer, |
| 268 }; | 282 }; |
| 269 | 283 |
| 270 // Invokes ConnectChannels() on transport proxies, which initiates ice | 284 // Pushes remote candidates to transport channels, which initiates ice |
| 271 // candidates allocation. | 285 // candidates allocation. |
|
pthatcher1
2015/08/18 22:32:47
Hmmm... I'm not sure this is the way we want this
Taylor Brandstetter
2015/08/25 01:04:05
Done.
| |
| 272 bool StartCandidatesAllocation(); | 286 bool StartGatheringCandidates(); |
| 273 bool UpdateSessionState(Action action, cricket::ContentSource source, | 287 bool UpdateSessionState(Action action, cricket::ContentSource source, |
| 274 std::string* err_desc); | 288 std::string* err_desc); |
| 275 static Action GetAction(const std::string& type); | 289 static Action GetAction(const std::string& type); |
| 276 // Push the media parts of the local or remote session description | 290 // Push the media parts of the local or remote session description |
| 277 // down to all of the channels. | 291 // down to all of the channels. |
| 278 bool PushdownMediaDescription(cricket::ContentAction action, | 292 bool PushdownMediaDescription(cricket::ContentAction action, |
| 279 cricket::ContentSource source, | 293 cricket::ContentSource source, |
| 280 std::string* error_desc); | 294 std::string* error_desc); |
| 281 | 295 |
| 282 | 296 cricket::BaseChannel* GetChannel(const std::string& content_name); |
| 283 // Transport related callbacks, override from cricket::BaseSession. | 297 // Cause all the BaseChannels in the bundle group to have the same |
| 284 virtual void OnTransportRequestSignaling(cricket::Transport* transport); | 298 // transport channel. |
| 285 virtual void OnTransportConnecting(cricket::Transport* transport); | 299 bool EnableBundle(const cricket::ContentGroup& bundle); |
| 286 virtual void OnTransportWritable(cricket::Transport* transport); | |
| 287 virtual void OnTransportCompleted(cricket::Transport* transport); | |
| 288 virtual void OnTransportFailed(cricket::Transport* transport); | |
| 289 virtual void OnTransportProxyCandidatesReady( | |
| 290 cricket::TransportProxy* proxy, | |
| 291 const cricket::Candidates& candidates); | |
| 292 virtual void OnCandidatesAllocationDone(); | |
| 293 void OnTransportReceiving(cricket::Transport* transport) override; | |
| 294 | 300 |
| 295 // Enables media channels to allow sending of media. | 301 // Enables media channels to allow sending of media. |
| 296 void EnableChannels(); | 302 void EnableChannels(); |
| 297 // Creates a JsepIceCandidate and adds it to the local session description | |
| 298 // and notify observers. Called when a new local candidate have been found. | |
| 299 void ProcessNewLocalCandidate(const std::string& content_name, | |
| 300 const cricket::Candidates& candidates); | |
| 301 // Returns the media index for a local ice candidate given the content name. | 303 // Returns the media index for a local ice candidate given the content name. |
| 302 // Returns false if the local session description does not have a media | 304 // Returns false if the local session description does not have a media |
| 303 // content called |content_name|. | 305 // content called |content_name|. |
| 304 bool GetLocalCandidateMediaIndex(const std::string& content_name, | 306 bool GetLocalCandidateMediaIndex(const std::string& content_name, |
| 305 int* sdp_mline_index); | 307 int* sdp_mline_index); |
| 306 // Uses all remote candidates in |remote_desc| in this session. | 308 // Uses all remote candidates in |remote_desc| in this session. |
| 307 bool UseCandidatesInSessionDescription( | 309 bool UseCandidatesInSessionDescription( |
| 308 const SessionDescriptionInterface* remote_desc); | 310 const SessionDescriptionInterface* remote_desc); |
| 309 // Uses |candidate| in this session. | 311 // Uses |candidate| in this session. |
| 310 bool UseCandidate(const IceCandidateInterface* candidate); | 312 bool UseCandidate(const IceCandidateInterface* candidate); |
| 311 // Deletes the corresponding channel of contents that don't exist in |desc|. | 313 // Deletes the corresponding channel of contents that don't exist in |desc|. |
| 312 // |desc| can be null. This means that all channels are deleted. | 314 // |desc| can be null. This means that all channels are deleted. |
| 313 void RemoveUnusedChannelsAndTransports( | 315 void RemoveUnusedChannels(const cricket::SessionDescription* desc); |
| 314 const cricket::SessionDescription* desc); | |
| 315 | 316 |
| 316 // Allocates media channels based on the |desc|. If |desc| doesn't have | 317 // Allocates media channels based on the |desc|. If |desc| doesn't have |
| 317 // the BUNDLE option, this method will disable BUNDLE in PortAllocator. | 318 // the BUNDLE option, this method will disable BUNDLE in PortAllocator. |
| 318 // This method will also delete any existing media channels before creating. | 319 // This method will also delete any existing media channels before creating. |
| 319 bool CreateChannels(const cricket::SessionDescription* desc); | 320 bool CreateChannels(const cricket::SessionDescription* desc); |
| 320 | 321 |
| 321 // Helper methods to create media channels. | 322 // Helper methods to create media channels. |
| 322 bool CreateVoiceChannel(const cricket::ContentInfo* content); | 323 bool CreateVoiceChannel(const cricket::ContentInfo* content); |
| 323 bool CreateVideoChannel(const cricket::ContentInfo* content); | 324 bool CreateVideoChannel(const cricket::ContentInfo* content); |
| 324 bool CreateDataChannel(const cricket::ContentInfo* content); | 325 bool CreateDataChannel(const cricket::ContentInfo* content); |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 353 Action action); | 354 Action action); |
| 354 | 355 |
| 355 // Returns true if we are ready to push down the remote candidate. | 356 // Returns true if we are ready to push down the remote candidate. |
| 356 // |remote_desc| is the new remote description, or NULL if the current remote | 357 // |remote_desc| is the new remote description, or NULL if the current remote |
| 357 // description should be used. Output |valid| is true if the candidate media | 358 // description should be used. Output |valid| is true if the candidate media |
| 358 // index is valid. | 359 // index is valid. |
| 359 bool ReadyToUseRemoteCandidate(const IceCandidateInterface* candidate, | 360 bool ReadyToUseRemoteCandidate(const IceCandidateInterface* candidate, |
| 360 const SessionDescriptionInterface* remote_desc, | 361 const SessionDescriptionInterface* remote_desc, |
| 361 bool* valid); | 362 bool* valid); |
| 362 | 363 |
| 364 void OnTransportControllerConnectionState(cricket::ConnectionState state); | |
| 365 void OnTransportControllerReceiving(bool receiving); | |
| 366 void OnTransportControllerGatheringState(cricket::GatheringState state); | |
| 367 void OnTransportControllerCandidatesGathered( | |
| 368 const std::string& transport_name, | |
| 369 const cricket::Candidates& candidates); | |
| 370 | |
| 363 std::string GetSessionErrorMsg(); | 371 std::string GetSessionErrorMsg(); |
| 364 | 372 |
| 365 // Invoked when OnTransportCompleted is signaled to gather the usage | 373 // Invoked when TransportController completion is signaled to gather the usage |
| 366 // of IPv4/IPv6 as best connection. | 374 // of IPv4/IPv6 as best connection. |
| 367 void ReportBestConnectionState(const cricket::TransportStats& stats); | 375 void ReportBestConnectionState(const cricket::TransportStats& stats); |
| 368 | 376 |
| 369 void ReportNegotiatedCiphers(const cricket::TransportStats& stats); | 377 void ReportNegotiatedCiphers(const cricket::TransportStats& stats); |
| 370 | 378 |
| 371 rtc::scoped_ptr<cricket::VoiceChannel> voice_channel_; | 379 rtc::scoped_ptr<cricket::VoiceChannel> voice_channel_; |
| 372 rtc::scoped_ptr<cricket::VideoChannel> video_channel_; | 380 rtc::scoped_ptr<cricket::VideoChannel> video_channel_; |
| 373 rtc::scoped_ptr<cricket::DataChannel> data_channel_; | 381 rtc::scoped_ptr<cricket::DataChannel> data_channel_; |
| 374 cricket::ChannelManager* channel_manager_; | 382 cricket::ChannelManager* channel_manager_; |
| 375 MediaStreamSignaling* mediastream_signaling_; | 383 MediaStreamSignaling* mediastream_signaling_; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 409 PeerConnectionInterface::BundlePolicy bundle_policy_; | 417 PeerConnectionInterface::BundlePolicy bundle_policy_; |
| 410 | 418 |
| 411 // Declares the RTCP mux policy for the WebRTCSession. | 419 // Declares the RTCP mux policy for the WebRTCSession. |
| 412 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy_; | 420 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy_; |
| 413 | 421 |
| 414 DISALLOW_COPY_AND_ASSIGN(WebRtcSession); | 422 DISALLOW_COPY_AND_ASSIGN(WebRtcSession); |
| 415 }; | 423 }; |
| 416 } // namespace webrtc | 424 } // namespace webrtc |
| 417 | 425 |
| 418 #endif // TALK_APP_WEBRTC_WEBRTCSESSION_H_ | 426 #endif // TALK_APP_WEBRTC_WEBRTCSESSION_H_ |
| OLD | NEW |