Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1094)

Side by Side Diff: talk/app/webrtc/webrtcsession.h

Issue 1404473005: Reland of Moving MediaStreamSignaling logic into PeerConnection. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Getting rid of unneeded RTC_DCHECK. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « talk/app/webrtc/statscollector_unittest.cc ('k') | talk/app/webrtc/webrtcsession.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 240
245 // virtual so it can be mocked in unit tests 241 // virtual so it can be mocked in unit tests
246 virtual bool GetLocalCertificate( 242 virtual bool GetLocalCertificate(
247 const std::string& transport_name, 243 const std::string& transport_name,
248 rtc::scoped_refptr<rtc::RTCCertificate>* certificate); 244 rtc::scoped_refptr<rtc::RTCCertificate>* certificate);
249 245
250 // Caller owns returned certificate 246 // Caller owns returned certificate
251 virtual bool GetRemoteSSLCertificate(const std::string& transport_name, 247 virtual bool GetRemoteSSLCertificate(const std::string& transport_name,
252 rtc::SSLCertificate** cert); 248 rtc::SSLCertificate** cert);
253 249
254 // Implements DataChannelFactory.
255 rtc::scoped_refptr<DataChannel> CreateDataChannel(
256 const std::string& label,
257 const InternalDataChannelInit* config) override;
258
259 cricket::DataChannelType data_channel_type() const; 250 cricket::DataChannelType data_channel_type() const;
260 251
261 bool IceRestartPending() const; 252 bool IceRestartPending() const;
262 253
263 void ResetIceRestartLatch(); 254 void ResetIceRestartLatch();
264 255
265 // Called when an RTCCertificate is generated or retrieved by 256 // Called when an RTCCertificate is generated or retrieved by
266 // WebRTCSessionDescriptionFactory. Should happen before setLocalDescription. 257 // WebRTCSessionDescriptionFactory. Should happen before setLocalDescription.
267 void OnCertificateReady( 258 void OnCertificateReady(
268 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate); 259 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate);
269 void OnDtlsSetupFailure(cricket::BaseChannel*, bool rtcp); 260 void OnDtlsSetupFailure(cricket::BaseChannel*, bool rtcp);
270 261
271 // For unit test. 262 // For unit test.
272 bool waiting_for_certificate_for_testing() const; 263 bool waiting_for_certificate_for_testing() const;
273 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate_for_testing(); 264 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate_for_testing();
274 265
275 void set_metrics_observer( 266 void set_metrics_observer(
276 webrtc::MetricsObserverInterface* metrics_observer) { 267 webrtc::MetricsObserverInterface* metrics_observer) {
277 metrics_observer_ = metrics_observer; 268 metrics_observer_ = metrics_observer;
278 } 269 }
279 270
271 // Called when voice_channel_, video_channel_ and data_channel_ are created
272 // and destroyed. As a result of, for example, setting a new description.
273 sigslot::signal0<> SignalVoiceChannelCreated;
274 sigslot::signal0<> SignalVoiceChannelDestroyed;
275 sigslot::signal0<> SignalVideoChannelCreated;
276 sigslot::signal0<> SignalVideoChannelDestroyed;
277 sigslot::signal0<> SignalDataChannelCreated;
278 sigslot::signal0<> SignalDataChannelDestroyed;
279
280 // Called when a valid data channel OPEN message is received.
281 // std::string represents the data channel label.
282 sigslot::signal2<const std::string&, const InternalDataChannelInit&>
283 SignalDataChannelOpenMessage;
284
280 private: 285 private:
281 // Indicates the type of SessionDescription in a call to SetLocalDescription 286 // Indicates the type of SessionDescription in a call to SetLocalDescription
282 // and SetRemoteDescription. 287 // and SetRemoteDescription.
283 enum Action { 288 enum Action {
284 kOffer, 289 kOffer,
285 kPrAnswer, 290 kPrAnswer,
286 kAnswer, 291 kAnswer,
287 }; 292 };
288 293
289 bool UpdateSessionState(Action action, cricket::ContentSource source, 294 bool UpdateSessionState(Action action, cricket::ContentSource source,
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 // Gather the usage of IPv4/IPv6 as best connection. 384 // Gather the usage of IPv4/IPv6 as best connection.
380 void ReportBestConnectionState(const cricket::TransportStats& stats); 385 void ReportBestConnectionState(const cricket::TransportStats& stats);
381 386
382 void ReportNegotiatedCiphers(const cricket::TransportStats& stats); 387 void ReportNegotiatedCiphers(const cricket::TransportStats& stats);
383 388
384 rtc::scoped_ptr<MediaControllerInterface> media_controller_; 389 rtc::scoped_ptr<MediaControllerInterface> media_controller_;
385 rtc::scoped_ptr<cricket::VoiceChannel> voice_channel_; 390 rtc::scoped_ptr<cricket::VoiceChannel> voice_channel_;
386 rtc::scoped_ptr<cricket::VideoChannel> video_channel_; 391 rtc::scoped_ptr<cricket::VideoChannel> video_channel_;
387 rtc::scoped_ptr<cricket::DataChannel> data_channel_; 392 rtc::scoped_ptr<cricket::DataChannel> data_channel_;
388 cricket::ChannelManager* channel_manager_; 393 cricket::ChannelManager* channel_manager_;
389 MediaStreamSignaling* mediastream_signaling_;
390 IceObserver* ice_observer_; 394 IceObserver* ice_observer_;
391 PeerConnectionInterface::IceConnectionState ice_connection_state_; 395 PeerConnectionInterface::IceConnectionState ice_connection_state_;
392 bool ice_connection_receiving_; 396 bool ice_connection_receiving_;
393 rtc::scoped_ptr<SessionDescriptionInterface> local_desc_; 397 rtc::scoped_ptr<SessionDescriptionInterface> local_desc_;
394 rtc::scoped_ptr<SessionDescriptionInterface> remote_desc_; 398 rtc::scoped_ptr<SessionDescriptionInterface> remote_desc_;
395 // Candidates that arrived before the remote description was set. 399 // Candidates that arrived before the remote description was set.
396 std::vector<IceCandidateInterface*> saved_candidates_; 400 std::vector<IceCandidateInterface*> saved_candidates_;
397 // If the remote peer is using a older version of implementation. 401 // If the remote peer is using a older version of implementation.
398 bool older_version_remote_peer_; 402 bool older_version_remote_peer_;
399 bool dtls_enabled_; 403 bool dtls_enabled_;
400 // Specifies which kind of data channel is allowed. This is controlled 404 // Specifies which kind of data channel is allowed. This is controlled
401 // by the chrome command-line flag and constraints: 405 // by the chrome command-line flag and constraints:
402 // 1. If chrome command-line switch 'enable-sctp-data-channels' is enabled, 406 // 1. If chrome command-line switch 'enable-sctp-data-channels' is enabled,
403 // constraint kEnableDtlsSrtp is true, and constaint kEnableRtpDataChannels is 407 // constraint kEnableDtlsSrtp is true, and constaint kEnableRtpDataChannels is
404 // not set or false, SCTP is allowed (DCT_SCTP); 408 // not set or false, SCTP is allowed (DCT_SCTP);
405 // 2. If constraint kEnableRtpDataChannels is true, RTP is allowed (DCT_RTP); 409 // 2. If constraint kEnableRtpDataChannels is true, RTP is allowed (DCT_RTP);
406 // 3. If both 1&2 are false, data channel is not allowed (DCT_NONE). 410 // 3. If both 1&2 are false, data channel is not allowed (DCT_NONE).
407 cricket::DataChannelType data_channel_type_; 411 cricket::DataChannelType data_channel_type_;
408 rtc::scoped_ptr<IceRestartAnswerLatch> ice_restart_latch_; 412 rtc::scoped_ptr<IceRestartAnswerLatch> ice_restart_latch_;
409 413
410 rtc::scoped_ptr<WebRtcSessionDescriptionFactory> 414 rtc::scoped_ptr<WebRtcSessionDescriptionFactory>
411 webrtc_session_desc_factory_; 415 webrtc_session_desc_factory_;
412 416
413 sigslot::signal0<> SignalVoiceChannelDestroyed;
414 sigslot::signal0<> SignalVideoChannelDestroyed;
415 sigslot::signal0<> SignalDataChannelDestroyed;
416
417 // Member variables for caching global options. 417 // Member variables for caching global options.
418 cricket::AudioOptions audio_options_; 418 cricket::AudioOptions audio_options_;
419 cricket::VideoOptions video_options_; 419 cricket::VideoOptions video_options_;
420 MetricsObserverInterface* metrics_observer_; 420 MetricsObserverInterface* metrics_observer_;
421 421
422 // Declares the bundle policy for the WebRTCSession. 422 // Declares the bundle policy for the WebRTCSession.
423 PeerConnectionInterface::BundlePolicy bundle_policy_; 423 PeerConnectionInterface::BundlePolicy bundle_policy_;
424 424
425 // Declares the RTCP mux policy for the WebRTCSession. 425 // Declares the RTCP mux policy for the WebRTCSession.
426 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy_; 426 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy_;
427 427
428 RTC_DISALLOW_COPY_AND_ASSIGN(WebRtcSession); 428 RTC_DISALLOW_COPY_AND_ASSIGN(WebRtcSession);
429 }; 429 };
430 } // namespace webrtc 430 } // namespace webrtc
431 431
432 #endif // TALK_APP_WEBRTC_WEBRTCSESSION_H_ 432 #endif // TALK_APP_WEBRTC_WEBRTCSESSION_H_
OLDNEW
« no previous file with comments | « talk/app/webrtc/statscollector_unittest.cc ('k') | talk/app/webrtc/webrtcsession.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698