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 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 107 | 107 |
| 108 protected: | 108 protected: |
| 109 ~IceObserver() {} | 109 ~IceObserver() {} |
| 110 | 110 |
| 111 private: | 111 private: |
| 112 RTC_DISALLOW_COPY_AND_ASSIGN(IceObserver); | 112 RTC_DISALLOW_COPY_AND_ASSIGN(IceObserver); |
| 113 }; | 113 }; |
| 114 | 114 |
| 115 class WebRtcSession : public cricket::BaseSession, | 115 class WebRtcSession : public cricket::BaseSession, |
| 116 public AudioProviderInterface, | 116 public AudioProviderInterface, |
| 117 public DataChannelFactory, | |
| 118 public VideoProviderInterface, | 117 public VideoProviderInterface, |
| 119 public DtmfProviderInterface, | 118 public DtmfProviderInterface, |
| 120 public DataChannelProviderInterface { | 119 public DataChannelProviderInterface { |
| 121 public: | 120 public: |
| 122 WebRtcSession(cricket::ChannelManager* channel_manager, | 121 WebRtcSession(cricket::ChannelManager* channel_manager, |
| 123 rtc::Thread* signaling_thread, | 122 rtc::Thread* signaling_thread, |
| 124 rtc::Thread* worker_thread, | 123 rtc::Thread* worker_thread, |
| 125 cricket::PortAllocator* port_allocator, | 124 cricket::PortAllocator* port_allocator); |
| 126 MediaStreamSignaling* mediastream_signaling); | |
| 127 virtual ~WebRtcSession(); | 125 virtual ~WebRtcSession(); |
| 128 | 126 |
| 129 bool Initialize( | 127 bool Initialize( |
| 130 const PeerConnectionFactoryInterface::Options& options, | 128 const PeerConnectionFactoryInterface::Options& options, |
| 131 const MediaConstraintsInterface* constraints, | 129 const MediaConstraintsInterface* constraints, |
| 132 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, | 130 rtc::scoped_ptr<DtlsIdentityStoreInterface> dtls_identity_store, |
| 133 const PeerConnectionInterface::RTCConfiguration& rtc_configuration); | 131 const PeerConnectionInterface::RTCConfiguration& rtc_configuration); |
| 134 // Deletes the voice, video and data channel and changes the session state | 132 // Deletes the voice, video and data channel and changes the session state |
| 135 // to STATE_RECEIVEDTERMINATE. | 133 // to STATE_RECEIVEDTERMINATE. |
| 136 void Terminate(); | 134 void Terminate(); |
| 137 | 135 |
| 138 void RegisterIceObserver(IceObserver* observer) { | 136 void RegisterIceObserver(IceObserver* observer) { |
| 139 ice_observer_ = observer; | 137 ice_observer_ = observer; |
| 140 } | 138 } |
| 141 | 139 |
| 142 virtual cricket::VoiceChannel* voice_channel() { | 140 virtual cricket::VoiceChannel* voice_channel() { |
| 143 return voice_channel_.get(); | 141 return voice_channel_.get(); |
| 144 } | 142 } |
| 145 virtual cricket::VideoChannel* video_channel() { | 143 virtual cricket::VideoChannel* video_channel() { |
| 146 return video_channel_.get(); | 144 return video_channel_.get(); |
| 147 } | 145 } |
| 148 virtual cricket::DataChannel* data_channel() { | 146 virtual cricket::DataChannel* data_channel() { |
| 149 return data_channel_.get(); | 147 return data_channel_.get(); |
| 150 } | 148 } |
| 151 | 149 |
| 152 virtual const MediaStreamSignaling* mediastream_signaling() const { | |
| 153 return mediastream_signaling_; | |
| 154 } | |
| 155 | |
| 156 void SetSdesPolicy(cricket::SecurePolicy secure_policy); | 150 void SetSdesPolicy(cricket::SecurePolicy secure_policy); |
| 157 cricket::SecurePolicy SdesPolicy() const; | 151 cricket::SecurePolicy SdesPolicy() const; |
| 158 | 152 |
| 159 // Get current ssl role from transport. | 153 // Get current ssl role from transport. |
| 160 bool GetSslRole(rtc::SSLRole* role); | 154 bool GetSslRole(rtc::SSLRole* role); |
| 161 | 155 |
| 162 // Generic error message callback from WebRtcSession. | 156 // Generic error message callback from WebRtcSession. |
| 163 // TODO - It may be necessary to supply error code as well. | 157 // TODO - It may be necessary to supply error code as well. |
| 164 sigslot::signal0<> SignalError; | 158 sigslot::signal0<> SignalError; |
| 165 | 159 |
| 166 void CreateOffer( | 160 void CreateOffer( |
| 167 CreateSessionDescriptionObserver* observer, | 161 CreateSessionDescriptionObserver* observer, |
| 168 const PeerConnectionInterface::RTCOfferAnswerOptions& options); | 162 const PeerConnectionInterface::RTCOfferAnswerOptions& options, |
| 163 const cricket::MediaSessionOptions& session_options); | |
| 169 void CreateAnswer(CreateSessionDescriptionObserver* observer, | 164 void CreateAnswer(CreateSessionDescriptionObserver* observer, |
| 170 const MediaConstraintsInterface* constraints); | 165 const MediaConstraintsInterface* constraints, |
| 166 const cricket::MediaSessionOptions& session_options); | |
| 171 // The ownership of |desc| will be transferred after this call. | 167 // The ownership of |desc| will be transferred after this call. |
| 172 bool SetLocalDescription(SessionDescriptionInterface* desc, | 168 bool SetLocalDescription(SessionDescriptionInterface* desc, |
| 173 std::string* err_desc); | 169 std::string* err_desc); |
| 174 // The ownership of |desc| will be transferred after this call. | 170 // The ownership of |desc| will be transferred after this call. |
| 175 bool SetRemoteDescription(SessionDescriptionInterface* desc, | 171 bool SetRemoteDescription(SessionDescriptionInterface* desc, |
| 176 std::string* err_desc); | 172 std::string* err_desc); |
| 177 bool ProcessIceMessage(const IceCandidateInterface* ice_candidate); | 173 bool ProcessIceMessage(const IceCandidateInterface* ice_candidate); |
| 178 | 174 |
| 179 bool SetIceTransports(PeerConnectionInterface::IceTransportsType type); | 175 bool SetIceTransports(PeerConnectionInterface::IceTransportsType type); |
| 180 | 176 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 246 | 242 |
| 247 // virtual so it can be mocked in unit tests | 243 // virtual so it can be mocked in unit tests |
| 248 virtual bool GetLocalCertificate( | 244 virtual bool GetLocalCertificate( |
| 249 const std::string& transport_name, | 245 const std::string& transport_name, |
| 250 rtc::scoped_refptr<rtc::RTCCertificate>* certificate); | 246 rtc::scoped_refptr<rtc::RTCCertificate>* certificate); |
| 251 | 247 |
| 252 // Caller owns returned certificate | 248 // Caller owns returned certificate |
| 253 virtual bool GetRemoteSSLCertificate(const std::string& transport_name, | 249 virtual bool GetRemoteSSLCertificate(const std::string& transport_name, |
| 254 rtc::SSLCertificate** cert); | 250 rtc::SSLCertificate** cert); |
| 255 | 251 |
| 256 // Implements DataChannelFactory. | |
| 257 rtc::scoped_refptr<DataChannel> CreateDataChannel( | |
| 258 const std::string& label, | |
| 259 const InternalDataChannelInit* config) override; | |
| 260 | |
| 261 cricket::DataChannelType data_channel_type() const; | 252 cricket::DataChannelType data_channel_type() const; |
| 262 | 253 |
| 263 bool IceRestartPending() const; | 254 bool IceRestartPending() const; |
| 264 | 255 |
| 265 void ResetIceRestartLatch(); | 256 void ResetIceRestartLatch(); |
| 266 | 257 |
| 267 // Called when an RTCCertificate is generated or retrieved by | 258 // Called when an RTCCertificate is generated or retrieved by |
| 268 // WebRTCSessionDescriptionFactory. Should happen before setLocalDescription. | 259 // WebRTCSessionDescriptionFactory. Should happen before setLocalDescription. |
| 269 void OnCertificateReady( | 260 void OnCertificateReady( |
| 270 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate); | 261 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate); |
| 271 void OnDtlsSetupFailure(cricket::BaseChannel*, bool rtcp); | 262 void OnDtlsSetupFailure(cricket::BaseChannel*, bool rtcp); |
| 272 | 263 |
| 273 // For unit test. | 264 // For unit test. |
| 274 bool waiting_for_certificate_for_testing() const; | 265 bool waiting_for_certificate_for_testing() const; |
| 275 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate_for_testing(); | 266 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate_for_testing(); |
| 276 | 267 |
| 277 void set_metrics_observer( | 268 void set_metrics_observer( |
| 278 webrtc::MetricsObserverInterface* metrics_observer) { | 269 webrtc::MetricsObserverInterface* metrics_observer) { |
| 279 metrics_observer_ = metrics_observer; | 270 metrics_observer_ = metrics_observer; |
| 280 } | 271 } |
| 281 | 272 |
| 273 sigslot::signal0<> SignalVoiceChannelDestroyed; | |
| 274 sigslot::signal0<> SignalVideoChannelDestroyed; | |
| 275 sigslot::signal0<> SignalDataChannelCreated; | |
| 276 sigslot::signal0<> SignalDataChannelDestroyed; | |
|
pthatcher1
2015/10/07 02:50:51
Can you comment when these will be fired?
Taylor Brandstetter
2015/10/09 19:54:09
Done. I also added "SignalVoiceChannelCreated" and
| |
| 277 sigslot::signal2<const std::string&, const InternalDataChannelInit&> | |
| 278 SignalDataChannelCreationRequested; | |
|
pthatcher1
2015/10/07 02:50:51
Can you comment what the parameters of this?
Taylor Brandstetter
2015/10/09 19:54:09
Done.
| |
| 279 | |
| 282 private: | 280 private: |
| 283 // Indicates the type of SessionDescription in a call to SetLocalDescription | 281 // Indicates the type of SessionDescription in a call to SetLocalDescription |
| 284 // and SetRemoteDescription. | 282 // and SetRemoteDescription. |
| 285 enum Action { | 283 enum Action { |
| 286 kOffer, | 284 kOffer, |
| 287 kPrAnswer, | 285 kPrAnswer, |
| 288 kAnswer, | 286 kAnswer, |
| 289 }; | 287 }; |
| 290 | 288 |
| 291 bool UpdateSessionState(Action action, cricket::ContentSource source, | 289 bool UpdateSessionState(Action action, cricket::ContentSource source, |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 381 // Gather the usage of IPv4/IPv6 as best connection. | 379 // Gather the usage of IPv4/IPv6 as best connection. |
| 382 void ReportBestConnectionState(const cricket::TransportStats& stats); | 380 void ReportBestConnectionState(const cricket::TransportStats& stats); |
| 383 | 381 |
| 384 void ReportNegotiatedCiphers(const cricket::TransportStats& stats); | 382 void ReportNegotiatedCiphers(const cricket::TransportStats& stats); |
| 385 | 383 |
| 386 rtc::scoped_ptr<MediaControllerInterface> media_controller_; | 384 rtc::scoped_ptr<MediaControllerInterface> media_controller_; |
| 387 rtc::scoped_ptr<cricket::VoiceChannel> voice_channel_; | 385 rtc::scoped_ptr<cricket::VoiceChannel> voice_channel_; |
| 388 rtc::scoped_ptr<cricket::VideoChannel> video_channel_; | 386 rtc::scoped_ptr<cricket::VideoChannel> video_channel_; |
| 389 rtc::scoped_ptr<cricket::DataChannel> data_channel_; | 387 rtc::scoped_ptr<cricket::DataChannel> data_channel_; |
| 390 cricket::ChannelManager* channel_manager_; | 388 cricket::ChannelManager* channel_manager_; |
| 391 MediaStreamSignaling* mediastream_signaling_; | |
| 392 IceObserver* ice_observer_; | 389 IceObserver* ice_observer_; |
| 393 PeerConnectionInterface::IceConnectionState ice_connection_state_; | 390 PeerConnectionInterface::IceConnectionState ice_connection_state_; |
| 394 bool ice_connection_receiving_; | 391 bool ice_connection_receiving_; |
| 395 rtc::scoped_ptr<SessionDescriptionInterface> local_desc_; | 392 rtc::scoped_ptr<SessionDescriptionInterface> local_desc_; |
| 396 rtc::scoped_ptr<SessionDescriptionInterface> remote_desc_; | 393 rtc::scoped_ptr<SessionDescriptionInterface> remote_desc_; |
| 397 // Candidates that arrived before the remote description was set. | 394 // Candidates that arrived before the remote description was set. |
| 398 std::vector<IceCandidateInterface*> saved_candidates_; | 395 std::vector<IceCandidateInterface*> saved_candidates_; |
| 399 // If the remote peer is using a older version of implementation. | 396 // If the remote peer is using a older version of implementation. |
| 400 bool older_version_remote_peer_; | 397 bool older_version_remote_peer_; |
| 401 bool dtls_enabled_; | 398 bool dtls_enabled_; |
| 402 // Specifies which kind of data channel is allowed. This is controlled | 399 // Specifies which kind of data channel is allowed. This is controlled |
| 403 // by the chrome command-line flag and constraints: | 400 // by the chrome command-line flag and constraints: |
| 404 // 1. If chrome command-line switch 'enable-sctp-data-channels' is enabled, | 401 // 1. If chrome command-line switch 'enable-sctp-data-channels' is enabled, |
| 405 // constraint kEnableDtlsSrtp is true, and constaint kEnableRtpDataChannels is | 402 // constraint kEnableDtlsSrtp is true, and constaint kEnableRtpDataChannels is |
| 406 // not set or false, SCTP is allowed (DCT_SCTP); | 403 // not set or false, SCTP is allowed (DCT_SCTP); |
| 407 // 2. If constraint kEnableRtpDataChannels is true, RTP is allowed (DCT_RTP); | 404 // 2. If constraint kEnableRtpDataChannels is true, RTP is allowed (DCT_RTP); |
| 408 // 3. If both 1&2 are false, data channel is not allowed (DCT_NONE). | 405 // 3. If both 1&2 are false, data channel is not allowed (DCT_NONE). |
| 409 cricket::DataChannelType data_channel_type_; | 406 cricket::DataChannelType data_channel_type_; |
| 410 rtc::scoped_ptr<IceRestartAnswerLatch> ice_restart_latch_; | 407 rtc::scoped_ptr<IceRestartAnswerLatch> ice_restart_latch_; |
| 411 | 408 |
| 412 rtc::scoped_ptr<WebRtcSessionDescriptionFactory> | 409 rtc::scoped_ptr<WebRtcSessionDescriptionFactory> |
| 413 webrtc_session_desc_factory_; | 410 webrtc_session_desc_factory_; |
| 414 | 411 |
| 415 sigslot::signal0<> SignalVoiceChannelDestroyed; | |
| 416 sigslot::signal0<> SignalVideoChannelDestroyed; | |
| 417 sigslot::signal0<> SignalDataChannelDestroyed; | |
| 418 | |
| 419 // Member variables for caching global options. | 412 // Member variables for caching global options. |
| 420 cricket::AudioOptions audio_options_; | 413 cricket::AudioOptions audio_options_; |
| 421 cricket::VideoOptions video_options_; | 414 cricket::VideoOptions video_options_; |
| 422 MetricsObserverInterface* metrics_observer_; | 415 MetricsObserverInterface* metrics_observer_; |
| 423 | 416 |
| 424 // Declares the bundle policy for the WebRTCSession. | 417 // Declares the bundle policy for the WebRTCSession. |
| 425 PeerConnectionInterface::BundlePolicy bundle_policy_; | 418 PeerConnectionInterface::BundlePolicy bundle_policy_; |
| 426 | 419 |
| 427 // Declares the RTCP mux policy for the WebRTCSession. | 420 // Declares the RTCP mux policy for the WebRTCSession. |
| 428 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy_; | 421 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy_; |
| 429 | 422 |
| 430 RTC_DISALLOW_COPY_AND_ASSIGN(WebRtcSession); | 423 RTC_DISALLOW_COPY_AND_ASSIGN(WebRtcSession); |
| 431 }; | 424 }; |
| 432 } // namespace webrtc | 425 } // namespace webrtc |
| 433 | 426 |
| 434 #endif // TALK_APP_WEBRTC_WEBRTCSESSION_H_ | 427 #endif // TALK_APP_WEBRTC_WEBRTCSESSION_H_ |
| OLD | NEW |