| 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 |
| 11 #ifndef WEBRTC_API_WEBRTCSESSION_H_ | 11 #ifndef WEBRTC_API_WEBRTCSESSION_H_ |
| 12 #define WEBRTC_API_WEBRTCSESSION_H_ | 12 #define WEBRTC_API_WEBRTCSESSION_H_ |
| 13 | 13 |
| 14 #include <memory> | 14 #include <memory> |
| 15 #include <set> | 15 #include <set> |
| 16 #include <string> | 16 #include <string> |
| 17 #include <vector> | 17 #include <vector> |
| 18 | 18 |
| 19 #include "webrtc/api/datachannel.h" | 19 #include "webrtc/api/datachannel.h" |
| 20 #include "webrtc/api/dtmfsender.h" | 20 #include "webrtc/api/dtmfsender.h" |
| 21 #include "webrtc/api/mediacontroller.h" | 21 #include "webrtc/api/mediacontroller.h" |
| 22 #include "webrtc/api/peerconnectioninterface.h" | 22 #include "webrtc/api/peerconnectioninterface.h" |
| 23 #include "webrtc/api/statstypes.h" | 23 #include "webrtc/api/statstypes.h" |
| 24 #include "webrtc/base/constructormagic.h" | 24 #include "webrtc/base/constructormagic.h" |
| 25 #include "webrtc/base/optional.h" |
| 25 #include "webrtc/base/sigslot.h" | 26 #include "webrtc/base/sigslot.h" |
| 26 #include "webrtc/base/sslidentity.h" | 27 #include "webrtc/base/sslidentity.h" |
| 27 #include "webrtc/base/thread.h" | 28 #include "webrtc/base/thread.h" |
| 28 #include "webrtc/media/base/mediachannel.h" | 29 #include "webrtc/media/base/mediachannel.h" |
| 29 #include "webrtc/p2p/base/candidate.h" | 30 #include "webrtc/p2p/base/candidate.h" |
| 30 #include "webrtc/p2p/base/transportcontroller.h" | 31 #include "webrtc/p2p/base/transportcontroller.h" |
| 31 #include "webrtc/pc/mediasession.h" | 32 #include "webrtc/pc/mediasession.h" |
| 32 | 33 |
| 33 #ifdef HAVE_QUIC | 34 #ifdef HAVE_QUIC |
| 34 #include "webrtc/api/quicdatatransport.h" | 35 #include "webrtc/api/quicdatatransport.h" |
| 35 #endif // HAVE_QUIC | 36 #endif // HAVE_QUIC |
| 36 | 37 |
| 37 namespace cricket { | 38 namespace cricket { |
| 38 | 39 |
| 39 class ChannelManager; | 40 class ChannelManager; |
| 40 class DataChannel; | 41 class RtpDataChannel; |
| 42 class SctpTransportInternal; |
| 43 class SctpTransportInternalFactory; |
| 41 class StatsReport; | 44 class StatsReport; |
| 42 class VideoChannel; | 45 class VideoChannel; |
| 43 class VoiceChannel; | 46 class VoiceChannel; |
| 44 | 47 |
| 45 #ifdef HAVE_QUIC | 48 #ifdef HAVE_QUIC |
| 46 class QuicTransportChannel; | 49 class QuicTransportChannel; |
| 47 #endif // HAVE_QUIC | 50 #endif // HAVE_QUIC |
| 48 | 51 |
| 49 } // namespace cricket | 52 } // namespace cricket |
| 50 | 53 |
| 51 namespace webrtc { | 54 namespace webrtc { |
| 52 | 55 |
| 53 class IceRestartAnswerLatch; | 56 class IceRestartAnswerLatch; |
| 54 class JsepIceCandidate; | 57 class JsepIceCandidate; |
| 55 class MediaStreamSignaling; | 58 class MediaStreamSignaling; |
| 56 class WebRtcSessionDescriptionFactory; | 59 class WebRtcSessionDescriptionFactory; |
| 57 | 60 |
| 58 extern const char kBundleWithoutRtcpMux[]; | 61 extern const char kBundleWithoutRtcpMux[]; |
| 59 extern const char kCreateChannelFailed[]; | 62 extern const char kCreateChannelFailed[]; |
| 60 extern const char kInvalidCandidates[]; | 63 extern const char kInvalidCandidates[]; |
| 61 extern const char kInvalidSdp[]; | 64 extern const char kInvalidSdp[]; |
| 62 extern const char kMlineMismatch[]; | 65 extern const char kMlineMismatch[]; |
| 63 extern const char kPushDownTDFailed[]; | 66 extern const char kPushDownTDFailed[]; |
| 64 extern const char kSdpWithoutDtlsFingerprint[]; | 67 extern const char kSdpWithoutDtlsFingerprint[]; |
| 65 extern const char kSdpWithoutSdesCrypto[]; | 68 extern const char kSdpWithoutSdesCrypto[]; |
| 66 extern const char kSdpWithoutIceUfragPwd[]; | 69 extern const char kSdpWithoutIceUfragPwd[]; |
| 67 extern const char kSdpWithoutSdesAndDtlsDisabled[]; | 70 extern const char kSdpWithoutSdesAndDtlsDisabled[]; |
| 68 extern const char kSessionError[]; | 71 extern const char kSessionError[]; |
| 69 extern const char kSessionErrorDesc[]; | 72 extern const char kSessionErrorDesc[]; |
| 70 extern const char kDtlsSetupFailureRtp[]; | 73 extern const char kDtlsSrtpSetupFailureRtp[]; |
| 71 extern const char kDtlsSetupFailureRtcp[]; | 74 extern const char kDtlsSrtpSetupFailureRtcp[]; |
| 72 extern const char kEnableBundleFailed[]; | 75 extern const char kEnableBundleFailed[]; |
| 73 | 76 |
| 74 // Maximum number of received video streams that will be processed by webrtc | 77 // Maximum number of received video streams that will be processed by webrtc |
| 75 // even if they are not signalled beforehand. | 78 // even if they are not signalled beforehand. |
| 76 extern const int kMaxUnsignalledRecvStreams; | 79 extern const int kMaxUnsignalledRecvStreams; |
| 77 | 80 |
| 78 // ICE state callback interface. | 81 // ICE state callback interface. |
| 79 class IceObserver { | 82 class IceObserver { |
| 80 public: | 83 public: |
| 81 IceObserver() {} | 84 IceObserver() {} |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 STATE_INPROGRESS, // Offer/answer exchange completed. | 154 STATE_INPROGRESS, // Offer/answer exchange completed. |
| 152 STATE_CLOSED, // Close() was called. | 155 STATE_CLOSED, // Close() was called. |
| 153 }; | 156 }; |
| 154 | 157 |
| 155 enum Error { | 158 enum Error { |
| 156 ERROR_NONE = 0, // no error | 159 ERROR_NONE = 0, // no error |
| 157 ERROR_CONTENT = 1, // channel errors in SetLocalContent/SetRemoteContent | 160 ERROR_CONTENT = 1, // channel errors in SetLocalContent/SetRemoteContent |
| 158 ERROR_TRANSPORT = 2, // transport error of some kind | 161 ERROR_TRANSPORT = 2, // transport error of some kind |
| 159 }; | 162 }; |
| 160 | 163 |
| 164 // |sctp_factory| may be null, in which case SCTP is treated as unsupported. |
| 161 WebRtcSession( | 165 WebRtcSession( |
| 162 webrtc::MediaControllerInterface* media_controller, | 166 webrtc::MediaControllerInterface* media_controller, |
| 163 rtc::Thread* network_thread, | 167 rtc::Thread* network_thread, |
| 164 rtc::Thread* worker_thread, | 168 rtc::Thread* worker_thread, |
| 165 rtc::Thread* signaling_thread, | 169 rtc::Thread* signaling_thread, |
| 166 cricket::PortAllocator* port_allocator, | 170 cricket::PortAllocator* port_allocator, |
| 167 std::unique_ptr<cricket::TransportController> transport_controller); | 171 std::unique_ptr<cricket::TransportController> transport_controller, |
| 172 std::unique_ptr<cricket::SctpTransportInternalFactory> sctp_factory); |
| 168 virtual ~WebRtcSession(); | 173 virtual ~WebRtcSession(); |
| 169 | 174 |
| 170 // These are const to allow them to be called from const methods. | 175 // These are const to allow them to be called from const methods. |
| 171 rtc::Thread* network_thread() const { return network_thread_; } | 176 rtc::Thread* network_thread() const { return network_thread_; } |
| 172 rtc::Thread* worker_thread() const { return worker_thread_; } | 177 rtc::Thread* worker_thread() const { return worker_thread_; } |
| 173 rtc::Thread* signaling_thread() const { return signaling_thread_; } | 178 rtc::Thread* signaling_thread() const { return signaling_thread_; } |
| 174 | 179 |
| 175 // The ID of this session. | 180 // The ID of this session. |
| 176 const std::string& id() const { return sid_; } | 181 const std::string& id() const { return sid_; } |
| 177 | 182 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 192 sigslot::signal2<WebRtcSession*, State> SignalState; | 197 sigslot::signal2<WebRtcSession*, State> SignalState; |
| 193 | 198 |
| 194 // Returns the last error in the session. See the enum above for details. | 199 // Returns the last error in the session. See the enum above for details. |
| 195 Error error() const { return error_; } | 200 Error error() const { return error_; } |
| 196 const std::string& error_desc() const { return error_desc_; } | 201 const std::string& error_desc() const { return error_desc_; } |
| 197 | 202 |
| 198 void RegisterIceObserver(IceObserver* observer) { | 203 void RegisterIceObserver(IceObserver* observer) { |
| 199 ice_observer_ = observer; | 204 ice_observer_ = observer; |
| 200 } | 205 } |
| 201 | 206 |
| 207 // Exposed for stats collecting. |
| 202 virtual cricket::VoiceChannel* voice_channel() { | 208 virtual cricket::VoiceChannel* voice_channel() { |
| 203 return voice_channel_.get(); | 209 return voice_channel_.get(); |
| 204 } | 210 } |
| 205 virtual cricket::VideoChannel* video_channel() { | 211 virtual cricket::VideoChannel* video_channel() { |
| 206 return video_channel_.get(); | 212 return video_channel_.get(); |
| 207 } | 213 } |
| 208 virtual cricket::DataChannel* data_channel() { | 214 // Only valid when using deprecated RTP data channels. |
| 209 return data_channel_.get(); | 215 virtual cricket::RtpDataChannel* rtp_data_channel() { |
| 216 return rtp_data_channel_.get(); |
| 217 } |
| 218 virtual rtc::Optional<std::string> sctp_content_name() const { |
| 219 return sctp_content_name_; |
| 220 } |
| 221 virtual rtc::Optional<std::string> sctp_transport_name() const { |
| 222 return sctp_transport_name_; |
| 210 } | 223 } |
| 211 | 224 |
| 212 cricket::BaseChannel* GetChannel(const std::string& content_name); | 225 cricket::BaseChannel* GetChannel(const std::string& content_name); |
| 213 | 226 |
| 214 cricket::SecurePolicy SdesPolicy() const; | 227 cricket::SecurePolicy SdesPolicy() const; |
| 215 | 228 |
| 216 // Get current ssl role from transport. | 229 // Get current SSL role used by SCTP's underlying transport. |
| 217 bool GetSslRole(const std::string& transport_name, rtc::SSLRole* role); | 230 bool GetSctpSslRole(rtc::SSLRole* role); |
| 218 | 231 // Get SSL role for an arbitrary m= section (handles bundling correctly). |
| 219 // Get current SSL role for this channel's transport. | 232 // TODO(deadbeef): This is only used internally by the session description |
| 220 // If |transport| is null, returns false. | 233 // factory, it shouldn't really be public). |
| 221 bool GetSslRole(const cricket::BaseChannel* channel, rtc::SSLRole* role); | 234 bool GetSslRole(const std::string& content_name, rtc::SSLRole* role); |
| 222 | 235 |
| 223 void CreateOffer( | 236 void CreateOffer( |
| 224 CreateSessionDescriptionObserver* observer, | 237 CreateSessionDescriptionObserver* observer, |
| 225 const PeerConnectionInterface::RTCOfferAnswerOptions& options, | 238 const PeerConnectionInterface::RTCOfferAnswerOptions& options, |
| 226 const cricket::MediaSessionOptions& session_options); | 239 const cricket::MediaSessionOptions& session_options); |
| 227 void CreateAnswer(CreateSessionDescriptionObserver* observer, | 240 void CreateAnswer(CreateSessionDescriptionObserver* observer, |
| 228 const cricket::MediaSessionOptions& session_options); | 241 const cricket::MediaSessionOptions& session_options); |
| 229 // The ownership of |desc| will be transferred after this call. | 242 // The ownership of |desc| will be transferred after this call. |
| 230 bool SetLocalDescription(SessionDescriptionInterface* desc, | 243 bool SetLocalDescription(SessionDescriptionInterface* desc, |
| 231 std::string* err_desc); | 244 std::string* err_desc); |
| 232 // The ownership of |desc| will be transferred after this call. | 245 // The ownership of |desc| will be transferred after this call. |
| 233 bool SetRemoteDescription(SessionDescriptionInterface* desc, | 246 bool SetRemoteDescription(SessionDescriptionInterface* desc, |
| 234 std::string* err_desc); | 247 std::string* err_desc); |
| 248 |
| 235 bool ProcessIceMessage(const IceCandidateInterface* ice_candidate); | 249 bool ProcessIceMessage(const IceCandidateInterface* ice_candidate); |
| 236 | 250 |
| 237 bool RemoveRemoteIceCandidates( | 251 bool RemoveRemoteIceCandidates( |
| 238 const std::vector<cricket::Candidate>& candidates); | 252 const std::vector<cricket::Candidate>& candidates); |
| 239 | 253 |
| 240 cricket::IceConfig ParseIceConfig( | 254 cricket::IceConfig ParseIceConfig( |
| 241 const PeerConnectionInterface::RTCConfiguration& config) const; | 255 const PeerConnectionInterface::RTCConfiguration& config) const; |
| 242 | 256 |
| 243 void SetIceConfig(const cricket::IceConfig& ice_config); | 257 void SetIceConfig(const cricket::IceConfig& ice_config); |
| 244 | 258 |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 319 // Returns true if the ICE restart flag above was set, and no ICE restart has | 333 // Returns true if the ICE restart flag above was set, and no ICE restart has |
| 320 // occurred yet for this transport (by applying a local description with | 334 // occurred yet for this transport (by applying a local description with |
| 321 // changed ufrag/password). If the transport has been deleted as a result of | 335 // changed ufrag/password). If the transport has been deleted as a result of |
| 322 // bundling, returns false. | 336 // bundling, returns false. |
| 323 bool NeedsIceRestart(const std::string& content_name) const; | 337 bool NeedsIceRestart(const std::string& content_name) const; |
| 324 | 338 |
| 325 // Called when an RTCCertificate is generated or retrieved by | 339 // Called when an RTCCertificate is generated or retrieved by |
| 326 // WebRTCSessionDescriptionFactory. Should happen before setLocalDescription. | 340 // WebRTCSessionDescriptionFactory. Should happen before setLocalDescription. |
| 327 void OnCertificateReady( | 341 void OnCertificateReady( |
| 328 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate); | 342 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate); |
| 329 void OnDtlsSetupFailure(cricket::BaseChannel*, bool rtcp); | 343 void OnDtlsSrtpSetupFailure(cricket::BaseChannel*, bool rtcp); |
| 330 | 344 |
| 331 // For unit test. | 345 // For unit test. |
| 332 bool waiting_for_certificate_for_testing() const; | 346 bool waiting_for_certificate_for_testing() const; |
| 333 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate_for_testing(); | 347 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate_for_testing(); |
| 334 | 348 |
| 335 void set_metrics_observer( | 349 void set_metrics_observer( |
| 336 webrtc::MetricsObserverInterface* metrics_observer) { | 350 webrtc::MetricsObserverInterface* metrics_observer) { |
| 337 metrics_observer_ = metrics_observer; | 351 metrics_observer_ = metrics_observer; |
| 338 transport_controller_->SetMetricsObserver(metrics_observer); | 352 transport_controller_->SetMetricsObserver(metrics_observer); |
| 339 } | 353 } |
| 340 | 354 |
| 341 // Called when voice_channel_, video_channel_ and data_channel_ are created | 355 // Called when voice_channel_, video_channel_ and |
| 342 // and destroyed. As a result of, for example, setting a new description. | 356 // rtp_data_channel_/sctp_transport_ are created and destroyed. As a result |
| 357 // of, for example, setting a new description. |
| 343 sigslot::signal0<> SignalVoiceChannelCreated; | 358 sigslot::signal0<> SignalVoiceChannelCreated; |
| 344 sigslot::signal0<> SignalVoiceChannelDestroyed; | 359 sigslot::signal0<> SignalVoiceChannelDestroyed; |
| 345 sigslot::signal0<> SignalVideoChannelCreated; | 360 sigslot::signal0<> SignalVideoChannelCreated; |
| 346 sigslot::signal0<> SignalVideoChannelDestroyed; | 361 sigslot::signal0<> SignalVideoChannelDestroyed; |
| 347 sigslot::signal0<> SignalDataChannelCreated; | 362 sigslot::signal0<> SignalDataChannelCreated; |
| 348 sigslot::signal0<> SignalDataChannelDestroyed; | 363 sigslot::signal0<> SignalDataChannelDestroyed; |
| 349 // Called when the whole session is destroyed. | 364 // Called when the whole session is destroyed. |
| 350 sigslot::signal0<> SignalDestroyed; | 365 sigslot::signal0<> SignalDestroyed; |
| 351 | 366 |
| 352 // Called when a valid data channel OPEN message is received. | 367 // Called when a valid data channel OPEN message is received. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 virtual void SetError(Error error, const std::string& error_desc); | 405 virtual void SetError(Error error, const std::string& error_desc); |
| 391 | 406 |
| 392 bool UpdateSessionState(Action action, cricket::ContentSource source, | 407 bool UpdateSessionState(Action action, cricket::ContentSource source, |
| 393 std::string* err_desc); | 408 std::string* err_desc); |
| 394 static Action GetAction(const std::string& type); | 409 static Action GetAction(const std::string& type); |
| 395 // Push the media parts of the local or remote session description | 410 // Push the media parts of the local or remote session description |
| 396 // down to all of the channels. | 411 // down to all of the channels. |
| 397 bool PushdownMediaDescription(cricket::ContentAction action, | 412 bool PushdownMediaDescription(cricket::ContentAction action, |
| 398 cricket::ContentSource source, | 413 cricket::ContentSource source, |
| 399 std::string* error_desc); | 414 std::string* error_desc); |
| 415 bool PushdownSctpParameters_n(cricket::ContentSource source); |
| 400 | 416 |
| 401 bool PushdownTransportDescription(cricket::ContentSource source, | 417 bool PushdownTransportDescription(cricket::ContentSource source, |
| 402 cricket::ContentAction action, | 418 cricket::ContentAction action, |
| 403 std::string* error_desc); | 419 std::string* error_desc); |
| 404 | 420 |
| 405 // Helper methods to push local and remote transport descriptions. | 421 // Helper methods to push local and remote transport descriptions. |
| 406 bool PushdownLocalTransportDescription( | 422 bool PushdownLocalTransportDescription( |
| 407 const cricket::SessionDescription* sdesc, | 423 const cricket::SessionDescription* sdesc, |
| 408 cricket::ContentAction action, | 424 cricket::ContentAction action, |
| 409 std::string* error_desc); | 425 std::string* error_desc); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 bool CreateVoiceChannel(const cricket::ContentInfo* content, | 470 bool CreateVoiceChannel(const cricket::ContentInfo* content, |
| 455 const std::string* bundle_transport); | 471 const std::string* bundle_transport); |
| 456 bool CreateVideoChannel(const cricket::ContentInfo* content, | 472 bool CreateVideoChannel(const cricket::ContentInfo* content, |
| 457 const std::string* bundle_transport); | 473 const std::string* bundle_transport); |
| 458 bool CreateDataChannel(const cricket::ContentInfo* content, | 474 bool CreateDataChannel(const cricket::ContentInfo* content, |
| 459 const std::string* bundle_transport); | 475 const std::string* bundle_transport); |
| 460 | 476 |
| 461 std::unique_ptr<SessionStats> GetStats_n( | 477 std::unique_ptr<SessionStats> GetStats_n( |
| 462 const ChannelNamePairs& channel_name_pairs); | 478 const ChannelNamePairs& channel_name_pairs); |
| 463 | 479 |
| 464 // Listens to SCTP CONTROL messages on unused SIDs and process them as OPEN | 480 bool CreateSctpTransport_n(const std::string& content_name, |
| 465 // messages. | 481 const std::string& transport_name); |
| 466 void OnDataChannelMessageReceived(cricket::DataChannel* channel, | 482 // For bundling. |
| 467 const cricket::ReceiveDataParams& params, | 483 void ChangeSctpTransport_n(const std::string& transport_name); |
| 468 const rtc::CopyOnWriteBuffer& payload); | 484 void DestroySctpTransport_n(); |
| 485 // SctpTransport signal handlers. Needed to marshal signals from the network |
| 486 // to signaling thread. |
| 487 void OnSctpTransportReadyToSendData_n(); |
| 488 // This may be called with "false" if the direction of the m= section causes |
| 489 // us to tear down the SCTP connection. |
| 490 void OnSctpTransportReadyToSendData_s(bool ready); |
| 491 void OnSctpTransportDataReceived_n(const cricket::ReceiveDataParams& params, |
| 492 const rtc::CopyOnWriteBuffer& payload); |
| 493 // Beyond just firing the signal to the signaling thread, listens to SCTP |
| 494 // CONTROL messages on unused SIDs and processes them as OPEN messages. |
| 495 void OnSctpTransportDataReceived_s(const cricket::ReceiveDataParams& params, |
| 496 const rtc::CopyOnWriteBuffer& payload); |
| 497 void OnSctpStreamClosedRemotely_n(int sid); |
| 469 | 498 |
| 470 std::string BadStateErrMsg(State state); | 499 std::string BadStateErrMsg(State state); |
| 471 void SetIceConnectionState(PeerConnectionInterface::IceConnectionState state); | 500 void SetIceConnectionState(PeerConnectionInterface::IceConnectionState state); |
| 472 void SetIceConnectionReceiving(bool receiving); | 501 void SetIceConnectionReceiving(bool receiving); |
| 473 | 502 |
| 474 bool ValidateBundleSettings(const cricket::SessionDescription* desc); | 503 bool ValidateBundleSettings(const cricket::SessionDescription* desc); |
| 475 bool HasRtcpMuxEnabled(const cricket::ContentInfo* content); | 504 bool HasRtcpMuxEnabled(const cricket::ContentInfo* content); |
| 476 // Below methods are helper methods which verifies SDP. | 505 // Below methods are helper methods which verifies SDP. |
| 477 bool ValidateSessionDescription(const SessionDescriptionInterface* sdesc, | 506 bool ValidateSessionDescription(const SessionDescriptionInterface* sdesc, |
| 478 cricket::ContentSource source, | 507 cricket::ContentSource source, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 491 // description should be used. Output |valid| is true if the candidate media | 520 // description should be used. Output |valid| is true if the candidate media |
| 492 // index is valid. | 521 // index is valid. |
| 493 bool ReadyToUseRemoteCandidate(const IceCandidateInterface* candidate, | 522 bool ReadyToUseRemoteCandidate(const IceCandidateInterface* candidate, |
| 494 const SessionDescriptionInterface* remote_desc, | 523 const SessionDescriptionInterface* remote_desc, |
| 495 bool* valid); | 524 bool* valid); |
| 496 | 525 |
| 497 // Returns true if SRTP (either using DTLS-SRTP or SDES) is required by | 526 // Returns true if SRTP (either using DTLS-SRTP or SDES) is required by |
| 498 // this session. | 527 // this session. |
| 499 bool SrtpRequired() const; | 528 bool SrtpRequired() const; |
| 500 | 529 |
| 530 // TransportController signal handlers. |
| 501 void OnTransportControllerConnectionState(cricket::IceConnectionState state); | 531 void OnTransportControllerConnectionState(cricket::IceConnectionState state); |
| 502 void OnTransportControllerReceiving(bool receiving); | 532 void OnTransportControllerReceiving(bool receiving); |
| 503 void OnTransportControllerGatheringState(cricket::IceGatheringState state); | 533 void OnTransportControllerGatheringState(cricket::IceGatheringState state); |
| 504 void OnTransportControllerCandidatesGathered( | 534 void OnTransportControllerCandidatesGathered( |
| 505 const std::string& transport_name, | 535 const std::string& transport_name, |
| 506 const std::vector<cricket::Candidate>& candidates); | 536 const std::vector<cricket::Candidate>& candidates); |
| 507 void OnTransportControllerCandidatesRemoved( | 537 void OnTransportControllerCandidatesRemoved( |
| 508 const std::vector<cricket::Candidate>& candidates); | 538 const std::vector<cricket::Candidate>& candidates); |
| 539 void OnTransportControllerDtlsHandshakeError(rtc::SSLHandshakeError error); |
| 509 | 540 |
| 510 std::string GetSessionErrorMsg(); | 541 std::string GetSessionErrorMsg(); |
| 511 | 542 |
| 512 // Invoked when TransportController connection completion is signaled. | 543 // Invoked when TransportController connection completion is signaled. |
| 513 // Reports stats for all transports in use. | 544 // Reports stats for all transports in use. |
| 514 void ReportTransportStats(); | 545 void ReportTransportStats(); |
| 515 | 546 |
| 516 // Gather the usage of IPv4/IPv6 as best connection. | 547 // Gather the usage of IPv4/IPv6 as best connection. |
| 517 void ReportBestConnectionState(const cricket::TransportStats& stats); | 548 void ReportBestConnectionState(const cricket::TransportStats& stats); |
| 518 | 549 |
| 519 void ReportNegotiatedCiphers(const cricket::TransportStats& stats); | 550 void ReportNegotiatedCiphers(const cricket::TransportStats& stats); |
| 520 | 551 |
| 521 void OnSentPacket_w(const rtc::SentPacket& sent_packet); | 552 void OnSentPacket_w(const rtc::SentPacket& sent_packet); |
| 522 | 553 |
| 523 const std::string GetTransportName(const std::string& content_name); | 554 const std::string GetTransportName(const std::string& content_name); |
| 524 | 555 |
| 525 void OnDtlsHandshakeError(rtc::SSLHandshakeError error); | |
| 526 | |
| 527 rtc::Thread* const network_thread_; | 556 rtc::Thread* const network_thread_; |
| 528 rtc::Thread* const worker_thread_; | 557 rtc::Thread* const worker_thread_; |
| 529 rtc::Thread* const signaling_thread_; | 558 rtc::Thread* const signaling_thread_; |
| 530 | 559 |
| 531 State state_ = STATE_INIT; | 560 State state_ = STATE_INIT; |
| 532 Error error_ = ERROR_NONE; | 561 Error error_ = ERROR_NONE; |
| 533 std::string error_desc_; | 562 std::string error_desc_; |
| 534 | 563 |
| 535 const std::string sid_; | 564 const std::string sid_; |
| 536 bool initial_offerer_ = false; | 565 bool initial_offerer_ = false; |
| 537 | 566 |
| 538 const std::unique_ptr<cricket::TransportController> transport_controller_; | 567 const std::unique_ptr<cricket::TransportController> transport_controller_; |
| 568 const std::unique_ptr<cricket::SctpTransportInternalFactory> sctp_factory_; |
| 539 MediaControllerInterface* media_controller_; | 569 MediaControllerInterface* media_controller_; |
| 540 std::unique_ptr<cricket::VoiceChannel> voice_channel_; | 570 std::unique_ptr<cricket::VoiceChannel> voice_channel_; |
| 541 std::unique_ptr<cricket::VideoChannel> video_channel_; | 571 std::unique_ptr<cricket::VideoChannel> video_channel_; |
| 542 std::unique_ptr<cricket::DataChannel> data_channel_; | 572 // |rtp_data_channel_| is used if in RTP data channel mode, |sctp_transport_| |
| 573 // when using SCTP. |
| 574 std::unique_ptr<cricket::RtpDataChannel> rtp_data_channel_; |
| 575 |
| 576 std::unique_ptr<cricket::SctpTransportInternal> sctp_transport_; |
| 577 // |sctp_transport_name_| keeps track of what DTLS transport the SCTP |
| 578 // transport is using (which can change due to bundling). |
| 579 rtc::Optional<std::string> sctp_transport_name_; |
| 580 // |sctp_content_name_| is the content name (MID) in SDP. |
| 581 rtc::Optional<std::string> sctp_content_name_; |
| 582 // Value cached on signaling thread. Only updated when SctpReadyToSendData |
| 583 // fires on the signaling thread. |
| 584 bool sctp_ready_to_send_data_ = false; |
| 585 // Same as signals provided by SctpTransport, but these are guaranteed to |
| 586 // fire on the signaling thread, whereas SctpTransport fires on the networking |
| 587 // thread. |
| 588 // |sctp_invoker_| is used so that any signals queued on the signaling thread |
| 589 // from the network thread are immediately discarded if the SctpTransport is |
| 590 // destroyed (due to m= section being rejected). |
| 591 // TODO(deadbeef): Use a proxy object to ensure that method calls/signals |
| 592 // are marshalled to the right thread. Could almost use proxy.h for this, |
| 593 // but it doesn't have a mechanism for marshalling sigslot::signals |
| 594 std::unique_ptr<rtc::AsyncInvoker> sctp_invoker_; |
| 595 sigslot::signal1<bool> SignalSctpReadyToSendData; |
| 596 sigslot::signal2<const cricket::ReceiveDataParams&, |
| 597 const rtc::CopyOnWriteBuffer&> |
| 598 SignalSctpDataReceived; |
| 599 sigslot::signal1<int> SignalSctpStreamClosedRemotely; |
| 600 |
| 543 cricket::ChannelManager* channel_manager_; | 601 cricket::ChannelManager* channel_manager_; |
| 544 IceObserver* ice_observer_; | 602 IceObserver* ice_observer_; |
| 545 PeerConnectionInterface::IceConnectionState ice_connection_state_; | 603 PeerConnectionInterface::IceConnectionState ice_connection_state_; |
| 546 bool ice_connection_receiving_; | 604 bool ice_connection_receiving_; |
| 547 std::unique_ptr<SessionDescriptionInterface> current_local_description_; | 605 std::unique_ptr<SessionDescriptionInterface> current_local_description_; |
| 548 std::unique_ptr<SessionDescriptionInterface> pending_local_description_; | 606 std::unique_ptr<SessionDescriptionInterface> pending_local_description_; |
| 549 std::unique_ptr<SessionDescriptionInterface> current_remote_description_; | 607 std::unique_ptr<SessionDescriptionInterface> current_remote_description_; |
| 550 std::unique_ptr<SessionDescriptionInterface> pending_remote_description_; | 608 std::unique_ptr<SessionDescriptionInterface> pending_remote_description_; |
| 551 // If the remote peer is using a older version of implementation. | 609 // If the remote peer is using a older version of implementation. |
| 552 bool older_version_remote_peer_; | 610 bool older_version_remote_peer_; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 582 | 640 |
| 583 #ifdef HAVE_QUIC | 641 #ifdef HAVE_QUIC |
| 584 std::unique_ptr<QuicDataTransport> quic_data_transport_; | 642 std::unique_ptr<QuicDataTransport> quic_data_transport_; |
| 585 #endif // HAVE_QUIC | 643 #endif // HAVE_QUIC |
| 586 | 644 |
| 587 RTC_DISALLOW_COPY_AND_ASSIGN(WebRtcSession); | 645 RTC_DISALLOW_COPY_AND_ASSIGN(WebRtcSession); |
| 588 }; | 646 }; |
| 589 } // namespace webrtc | 647 } // namespace webrtc |
| 590 | 648 |
| 591 #endif // WEBRTC_API_WEBRTCSESSION_H_ | 649 #endif // WEBRTC_API_WEBRTCSESSION_H_ |
| OLD | NEW |