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

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

Issue 1358413003: Revert of TransportController refactoring. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: 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>
33 32
34 #include "talk/app/webrtc/datachannel.h" 33 #include "talk/app/webrtc/datachannel.h"
35 #include "talk/app/webrtc/dtmfsender.h" 34 #include "talk/app/webrtc/dtmfsender.h"
36 #include "talk/app/webrtc/mediacontroller.h" 35 #include "talk/app/webrtc/mediacontroller.h"
37 #include "talk/app/webrtc/mediastreamprovider.h" 36 #include "talk/app/webrtc/mediastreamprovider.h"
38 #include "talk/app/webrtc/peerconnectioninterface.h" 37 #include "talk/app/webrtc/peerconnectioninterface.h"
39 #include "talk/app/webrtc/statstypes.h" 38 #include "talk/app/webrtc/statstypes.h"
40 #include "talk/media/base/mediachannel.h" 39 #include "talk/media/base/mediachannel.h"
41 #include "webrtc/p2p/base/session.h" 40 #include "webrtc/p2p/base/session.h"
42 #include "talk/session/media/mediasession.h" 41 #include "talk/session/media/mediasession.h"
43 #include "webrtc/base/sigslot.h" 42 #include "webrtc/base/sigslot.h"
44 #include "webrtc/base/sslidentity.h" 43 #include "webrtc/base/sslidentity.h"
45 #include "webrtc/base/thread.h" 44 #include "webrtc/base/thread.h"
46 45
47 namespace cricket { 46 namespace cricket {
48 47
49 class BaseChannel; 48 class BaseChannel;
50 class ChannelManager; 49 class ChannelManager;
51 class DataChannel; 50 class DataChannel;
52 class StatsReport; 51 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
82 // 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
83 // even if they are not signalled beforehand. 81 // even if they are not signalled beforehand.
84 extern const int kMaxUnsignalledRecvStreams; 82 extern const int kMaxUnsignalledRecvStreams;
85 83
86 // ICE state callback interface. 84 // ICE state callback interface.
87 class IceObserver { 85 class IceObserver {
88 public: 86 public:
89 IceObserver() {} 87 IceObserver() {}
90 // Called any time the IceConnectionState changes 88 // Called any time the IceConnectionState changes
91 // TODO(honghaiz): Change the name to OnIceConnectionStateChange so as to 89 // TODO(honghaiz): Change the name to OnIceConnectionStateChange so as to
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 bool ConnectDataChannel(DataChannel* webrtc_data_channel) override; 228 bool ConnectDataChannel(DataChannel* webrtc_data_channel) override;
231 void DisconnectDataChannel(DataChannel* webrtc_data_channel) override; 229 void DisconnectDataChannel(DataChannel* webrtc_data_channel) override;
232 void AddSctpDataStream(int sid) override; 230 void AddSctpDataStream(int sid) override;
233 void RemoveSctpDataStream(int sid) override; 231 void RemoveSctpDataStream(int sid) override;
234 bool ReadyToSendData() const override; 232 bool ReadyToSendData() const override;
235 233
236 // Returns stats for all channels of all transports. 234 // Returns stats for all channels of all transports.
237 // This avoids exposing the internal structures used to track them. 235 // This avoids exposing the internal structures used to track them.
238 virtual bool GetTransportStats(cricket::SessionStats* stats); 236 virtual bool GetTransportStats(cricket::SessionStats* stats);
239 237
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
253 // Implements DataChannelFactory. 238 // Implements DataChannelFactory.
254 rtc::scoped_refptr<DataChannel> CreateDataChannel( 239 rtc::scoped_refptr<DataChannel> CreateDataChannel(
255 const std::string& label, 240 const std::string& label,
256 const InternalDataChannelInit* config) override; 241 const InternalDataChannelInit* config) override;
257 242
258 cricket::DataChannelType data_channel_type() const; 243 cricket::DataChannelType data_channel_type() const;
259 244
260 bool IceRestartPending() const; 245 bool IceRestartPending() const;
261 246
262 void ResetIceRestartLatch(); 247 void ResetIceRestartLatch();
263 248
264 // Called when an RTCCertificate is generated or retrieved by 249 // Called when an RTCCertificate is generated or retrieved by
265 // WebRTCSessionDescriptionFactory. Should happen before setLocalDescription. 250 // WebRTCSessionDescriptionFactory. Should happen before setLocalDescription.
266 void OnCertificateReady( 251 void OnCertificateReady(
267 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate); 252 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate);
268 void OnDtlsSetupFailure(cricket::BaseChannel*, bool rtcp); 253 void OnDtlsSetupFailure(cricket::BaseChannel*, bool rtcp);
269 254
270 // For unit test. 255 // For unit test.
271 bool waiting_for_certificate_for_testing() const; 256 bool waiting_for_certificate_for_testing() const;
272 const rtc::scoped_refptr<rtc::RTCCertificate>& certificate_for_testing();
273 257
274 void set_metrics_observer( 258 void set_metrics_observer(
275 webrtc::MetricsObserverInterface* metrics_observer) { 259 webrtc::MetricsObserverInterface* metrics_observer) {
276 metrics_observer_ = metrics_observer; 260 metrics_observer_ = metrics_observer;
277 } 261 }
278 262
279 private: 263 private:
280 // Indicates the type of SessionDescription in a call to SetLocalDescription 264 // Indicates the type of SessionDescription in a call to SetLocalDescription
281 // and SetRemoteDescription. 265 // and SetRemoteDescription.
282 enum Action { 266 enum Action {
283 kOffer, 267 kOffer,
284 kPrAnswer, 268 kPrAnswer,
285 kAnswer, 269 kAnswer,
286 }; 270 };
287 271
272 // Invokes ConnectChannels() on transport proxies, which initiates ice
273 // candidates allocation.
274 bool StartCandidatesAllocation();
288 bool UpdateSessionState(Action action, cricket::ContentSource source, 275 bool UpdateSessionState(Action action, cricket::ContentSource source,
289 std::string* err_desc); 276 std::string* err_desc);
290 static Action GetAction(const std::string& type); 277 static Action GetAction(const std::string& type);
291 // Push the media parts of the local or remote session description 278 // Push the media parts of the local or remote session description
292 // down to all of the channels. 279 // down to all of the channels.
293 bool PushdownMediaDescription(cricket::ContentAction action, 280 bool PushdownMediaDescription(cricket::ContentAction action,
294 cricket::ContentSource source, 281 cricket::ContentSource source,
295 std::string* error_desc); 282 std::string* error_desc);
296 283
297 cricket::BaseChannel* GetChannel(const std::string& content_name); 284
298 // Cause all the BaseChannels in the bundle group to have the same 285 // Transport related callbacks, override from cricket::BaseSession.
299 // transport channel. 286 virtual void OnTransportRequestSignaling(cricket::Transport* transport);
300 bool EnableBundle(const cricket::ContentGroup& bundle); 287 virtual void OnTransportConnecting(cricket::Transport* transport);
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;
301 296
302 // Enables media channels to allow sending of media. 297 // Enables media channels to allow sending of media.
303 void EnableChannels(); 298 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);
304 // 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.
305 // 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
306 // content called |content_name|. 305 // content called |content_name|.
307 bool GetLocalCandidateMediaIndex(const std::string& content_name, 306 bool GetLocalCandidateMediaIndex(const std::string& content_name,
308 int* sdp_mline_index); 307 int* sdp_mline_index);
309 // Uses all remote candidates in |remote_desc| in this session. 308 // Uses all remote candidates in |remote_desc| in this session.
310 bool UseCandidatesInSessionDescription( 309 bool UseCandidatesInSessionDescription(
311 const SessionDescriptionInterface* remote_desc); 310 const SessionDescriptionInterface* remote_desc);
312 // Uses |candidate| in this session. 311 // Uses |candidate| in this session.
313 bool UseCandidate(const IceCandidateInterface* candidate); 312 bool UseCandidate(const IceCandidateInterface* candidate);
314 // 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|.
315 // |desc| can be null. This means that all channels are deleted. 314 // |desc| can be null. This means that all channels are deleted.
316 void RemoveUnusedChannels(const cricket::SessionDescription* desc); 315 void RemoveUnusedChannelsAndTransports(
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
372 std::string GetSessionErrorMsg(); 365 std::string GetSessionErrorMsg();
373 366
374 // Invoked when TransportController connection completion is signaled. 367 // Invoked when OnTransportCompleted is signaled to gather the usage
375 // Reports stats for all transports in use. 368 // of IPv4/IPv6 as best connection.
376 void ReportTransportStats();
377
378 // Gather the usage of IPv4/IPv6 as best connection.
379 void ReportBestConnectionState(const cricket::TransportStats& stats); 369 void ReportBestConnectionState(const cricket::TransportStats& stats);
380 370
381 void ReportNegotiatedCiphers(const cricket::TransportStats& stats); 371 void ReportNegotiatedCiphers(const cricket::TransportStats& stats);
382 372
383 rtc::scoped_ptr<MediaControllerInterface> media_controller_; 373 rtc::scoped_ptr<MediaControllerInterface> media_controller_;
384 rtc::scoped_ptr<cricket::VoiceChannel> voice_channel_; 374 rtc::scoped_ptr<cricket::VoiceChannel> voice_channel_;
385 rtc::scoped_ptr<cricket::VideoChannel> video_channel_; 375 rtc::scoped_ptr<cricket::VideoChannel> video_channel_;
386 rtc::scoped_ptr<cricket::DataChannel> data_channel_; 376 rtc::scoped_ptr<cricket::DataChannel> data_channel_;
387 cricket::ChannelManager* channel_manager_; 377 cricket::ChannelManager* channel_manager_;
388 MediaStreamSignaling* mediastream_signaling_; 378 MediaStreamSignaling* mediastream_signaling_;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 PeerConnectionInterface::BundlePolicy bundle_policy_; 412 PeerConnectionInterface::BundlePolicy bundle_policy_;
423 413
424 // Declares the RTCP mux policy for the WebRTCSession. 414 // Declares the RTCP mux policy for the WebRTCSession.
425 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy_; 415 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy_;
426 416
427 RTC_DISALLOW_COPY_AND_ASSIGN(WebRtcSession); 417 RTC_DISALLOW_COPY_AND_ASSIGN(WebRtcSession);
428 }; 418 };
429 } // namespace webrtc 419 } // namespace webrtc
430 420
431 #endif // TALK_APP_WEBRTC_WEBRTCSESSION_H_ 421 #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