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

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

Issue 1350523003: TransportController refactoring. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing Mac test. Created 5 years, 3 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 11 matching lines...) Expand all
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/mediacontroller.h" 36 #include "talk/app/webrtc/mediacontroller.h"
36 #include "talk/app/webrtc/mediastreamprovider.h" 37 #include "talk/app/webrtc/mediastreamprovider.h"
37 #include "talk/app/webrtc/peerconnectioninterface.h" 38 #include "talk/app/webrtc/peerconnectioninterface.h"
38 #include "talk/app/webrtc/statstypes.h" 39 #include "talk/app/webrtc/statstypes.h"
39 #include "talk/media/base/mediachannel.h" 40 #include "talk/media/base/mediachannel.h"
40 #include "webrtc/p2p/base/session.h" 41 #include "webrtc/p2p/base/session.h"
41 #include "talk/session/media/mediasession.h" 42 #include "talk/session/media/mediasession.h"
42 #include "webrtc/base/sigslot.h" 43 #include "webrtc/base/sigslot.h"
43 #include "webrtc/base/sslidentity.h" 44 #include "webrtc/base/sslidentity.h"
44 #include "webrtc/base/thread.h" 45 #include "webrtc/base/thread.h"
45 46
46 namespace cricket { 47 namespace cricket {
47 48
48 class BaseChannel; 49 class BaseChannel;
49 class ChannelManager; 50 class ChannelManager;
50 class DataChannel; 51 class DataChannel;
51 class StatsReport; 52 class StatsReport;
52 class Transport;
53 class VideoCapturer; 53 class VideoCapturer;
54 class VideoChannel; 54 class VideoChannel;
55 class VoiceChannel; 55 class VoiceChannel;
56 56
57 } // namespace cricket 57 } // namespace cricket
58 58
59 namespace webrtc { 59 namespace webrtc {
60 60
61 class IceRestartAnswerLatch; 61 class IceRestartAnswerLatch;
62 class JsepIceCandidate; 62 class JsepIceCandidate;
63 class MediaStreamSignaling; 63 class MediaStreamSignaling;
64 class WebRtcSessionDescriptionFactory; 64 class WebRtcSessionDescriptionFactory;
65 65
66 extern const char kBundleWithoutRtcpMux[]; 66 extern const char kBundleWithoutRtcpMux[];
67 extern const char kCreateChannelFailed[]; 67 extern const char kCreateChannelFailed[];
68 extern const char kInvalidCandidates[]; 68 extern const char kInvalidCandidates[];
69 extern const char kInvalidSdp[]; 69 extern const char kInvalidSdp[];
70 extern const char kMlineMismatch[]; 70 extern const char kMlineMismatch[];
71 extern const char kPushDownTDFailed[]; 71 extern const char kPushDownTDFailed[];
72 extern const char kSdpWithoutDtlsFingerprint[]; 72 extern const char kSdpWithoutDtlsFingerprint[];
73 extern const char kSdpWithoutSdesCrypto[]; 73 extern const char kSdpWithoutSdesCrypto[];
74 extern const char kSdpWithoutIceUfragPwd[]; 74 extern const char kSdpWithoutIceUfragPwd[];
75 extern const char kSdpWithoutSdesAndDtlsDisabled[]; 75 extern const char kSdpWithoutSdesAndDtlsDisabled[];
76 extern const char kSessionError[]; 76 extern const char kSessionError[];
77 extern const char kSessionErrorDesc[]; 77 extern const char kSessionErrorDesc[];
78 extern const char kDtlsSetupFailureRtp[]; 78 extern const char kDtlsSetupFailureRtp[];
79 extern const char kDtlsSetupFailureRtcp[]; 79 extern const char kDtlsSetupFailureRtcp[];
80 extern const char kEnableBundleFailed[];
81
80 // Maximum number of received video streams that will be processed by webrtc 82 // Maximum number of received video streams that will be processed by webrtc
81 // even if they are not signalled beforehand. 83 // even if they are not signalled beforehand.
82 extern const int kMaxUnsignalledRecvStreams; 84 extern const int kMaxUnsignalledRecvStreams;
83 85
84 // ICE state callback interface. 86 // ICE state callback interface.
85 class IceObserver { 87 class IceObserver {
86 public: 88 public:
87 IceObserver() {} 89 IceObserver() {}
88 // Called any time the IceConnectionState changes 90 // Called any time the IceConnectionState changes
89 // TODO(honghaiz): Change the name to OnIceConnectionStateChange so as to 91 // TODO(honghaiz): Change the name to OnIceConnectionStateChange so as to
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 GetLocalCertificate(
246 const std::string& transport_name,
247 rtc::scoped_refptr<rtc::RTCCertificate>* certificate);
248
249 // Caller owns returned certificate
250 virtual bool GetRemoteSSLCertificate(const std::string& transport_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 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate_for_testing();
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
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.
368 // of IPv4/IPv6 as best connection. 375 // Reports stats for all transports in use.
376 void ReportTransportStats();
377
378 // Gather the usage of IPv4/IPv6 as best connection.
369 void ReportBestConnectionState(const cricket::TransportStats& stats); 379 void ReportBestConnectionState(const cricket::TransportStats& stats);
370 380
371 void ReportNegotiatedCiphers(const cricket::TransportStats& stats); 381 void ReportNegotiatedCiphers(const cricket::TransportStats& stats);
372 382
373 rtc::scoped_ptr<MediaControllerInterface> media_controller_; 383 rtc::scoped_ptr<MediaControllerInterface> media_controller_;
374 rtc::scoped_ptr<cricket::VoiceChannel> voice_channel_; 384 rtc::scoped_ptr<cricket::VoiceChannel> voice_channel_;
375 rtc::scoped_ptr<cricket::VideoChannel> video_channel_; 385 rtc::scoped_ptr<cricket::VideoChannel> video_channel_;
376 rtc::scoped_ptr<cricket::DataChannel> data_channel_; 386 rtc::scoped_ptr<cricket::DataChannel> data_channel_;
377 cricket::ChannelManager* channel_manager_; 387 cricket::ChannelManager* channel_manager_;
378 MediaStreamSignaling* mediastream_signaling_; 388 MediaStreamSignaling* mediastream_signaling_;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
412 PeerConnectionInterface::BundlePolicy bundle_policy_; 422 PeerConnectionInterface::BundlePolicy bundle_policy_;
413 423
414 // Declares the RTCP mux policy for the WebRTCSession. 424 // Declares the RTCP mux policy for the WebRTCSession.
415 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy_; 425 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy_;
416 426
417 RTC_DISALLOW_COPY_AND_ASSIGN(WebRtcSession); 427 RTC_DISALLOW_COPY_AND_ASSIGN(WebRtcSession);
418 }; 428 };
419 } // namespace webrtc 429 } // namespace webrtc
420 430
421 #endif // TALK_APP_WEBRTC_WEBRTCSESSION_H_ 431 #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