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

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

Issue 1246913005: TransportController refactoring (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Fixing problems with "failed" state; a channel isn't failed if it's never added a connection 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
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/mediastreamprovider.h" 36 #include "talk/app/webrtc/mediastreamprovider.h"
36 #include "talk/app/webrtc/peerconnectioninterface.h" 37 #include "talk/app/webrtc/peerconnectioninterface.h"
37 #include "talk/app/webrtc/statstypes.h" 38 #include "talk/app/webrtc/statstypes.h"
38 #include "talk/media/base/mediachannel.h" 39 #include "talk/media/base/mediachannel.h"
39 #include "webrtc/p2p/base/session.h" 40 #include "webrtc/p2p/base/session.h"
40 #include "talk/session/media/mediasession.h" 41 #include "talk/session/media/mediasession.h"
41 #include "webrtc/base/sigslot.h" 42 #include "webrtc/base/sigslot.h"
42 #include "webrtc/base/thread.h" 43 #include "webrtc/base/thread.h"
43 44
44 namespace cricket { 45 namespace cricket {
45 46
46 class BaseChannel; 47 class BaseChannel;
47 class ChannelManager; 48 class ChannelManager;
48 class DataChannel; 49 class DataChannel;
49 class StatsReport; 50 class StatsReport;
50 class Transport;
51 class VideoCapturer; 51 class VideoCapturer;
52 class VideoChannel; 52 class VideoChannel;
53 class VoiceChannel; 53 class VoiceChannel;
54 54
55 } // namespace cricket 55 } // namespace cricket
56 56
57 namespace webrtc { 57 namespace webrtc {
58 58
59 class IceRestartAnswerLatch; 59 class IceRestartAnswerLatch;
60 class JsepIceCandidate; 60 class JsepIceCandidate;
61 class MediaStreamSignaling; 61 class MediaStreamSignaling;
62 class WebRtcSessionDescriptionFactory; 62 class WebRtcSessionDescriptionFactory;
63 63
64 extern const char kBundleWithoutRtcpMux[]; 64 extern const char kBundleWithoutRtcpMux[];
65 extern const char kCreateChannelFailed[]; 65 extern const char kCreateChannelFailed[];
66 extern const char kInvalidCandidates[]; 66 extern const char kInvalidCandidates[];
67 extern const char kInvalidSdp[]; 67 extern const char kInvalidSdp[];
68 extern const char kMlineMismatch[]; 68 extern const char kMlineMismatch[];
69 extern const char kPushDownTDFailed[]; 69 extern const char kPushDownTDFailed[];
70 extern const char kSdpWithoutDtlsFingerprint[]; 70 extern const char kSdpWithoutDtlsFingerprint[];
71 extern const char kSdpWithoutSdesCrypto[]; 71 extern const char kSdpWithoutSdesCrypto[];
72 extern const char kSdpWithoutIceUfragPwd[]; 72 extern const char kSdpWithoutIceUfragPwd[];
73 extern const char kSdpWithoutSdesAndDtlsDisabled[]; 73 extern const char kSdpWithoutSdesAndDtlsDisabled[];
74 extern const char kSessionError[]; 74 extern const char kSessionError[];
75 extern const char kSessionErrorDesc[]; 75 extern const char kSessionErrorDesc[];
76 extern const char kDtlsSetupFailureRtp[]; 76 extern const char kDtlsSetupFailureRtp[];
77 extern const char kDtlsSetupFailureRtcp[]; 77 extern const char kDtlsSetupFailureRtcp[];
78 extern const char kEnableBundleFailed[];
79
78 // 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
79 // even if they are not signalled beforehand. 81 // even if they are not signalled beforehand.
80 extern const int kMaxUnsignalledRecvStreams; 82 extern const int kMaxUnsignalledRecvStreams;
81 83
82 // ICE state callback interface. 84 // ICE state callback interface.
83 class IceObserver { 85 class IceObserver {
84 public: 86 public:
85 IceObserver() {} 87 IceObserver() {}
86 // Called any time the IceConnectionState changes 88 // Called any time the IceConnectionState changes
87 // TODO(honghaiz): Change the name to OnIceConnectionStateChange so as to 89 // TODO(honghaiz): Change the name to OnIceConnectionStateChange so as to
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 bool ConnectDataChannel(DataChannel* webrtc_data_channel) override; 229 bool ConnectDataChannel(DataChannel* webrtc_data_channel) override;
228 void DisconnectDataChannel(DataChannel* webrtc_data_channel) override; 230 void DisconnectDataChannel(DataChannel* webrtc_data_channel) override;
229 void AddSctpDataStream(int sid) override; 231 void AddSctpDataStream(int sid) override;
230 void RemoveSctpDataStream(int sid) override; 232 void RemoveSctpDataStream(int sid) override;
231 bool ReadyToSendData() const override; 233 bool ReadyToSendData() const override;
232 234
233 // Returns stats for all channels of all transports. 235 // Returns stats for all channels of all transports.
234 // This avoids exposing the internal structures used to track them. 236 // This avoids exposing the internal structures used to track them.
235 virtual bool GetTransportStats(cricket::SessionStats* stats); 237 virtual bool GetTransportStats(cricket::SessionStats* stats);
236 238
239 // Get stats for a specific channel
240 bool GetChannelTransportStats(cricket::BaseChannel* ch,
241 cricket::SessionStats* stats);
242
243 // Caller owns returned identity
244 virtual bool GetIdentity(const std::string& content_name,
245 rtc::SSLIdentity** identity);
246
247 // Caller owns returned certificate
248 virtual bool GetRemoteCertificate(const std::string& content_name,
249 rtc::SSLCertificate** cert);
250
237 // Implements DataChannelFactory. 251 // Implements DataChannelFactory.
238 rtc::scoped_refptr<DataChannel> CreateDataChannel( 252 rtc::scoped_refptr<DataChannel> CreateDataChannel(
239 const std::string& label, 253 const std::string& label,
240 const InternalDataChannelInit* config) override; 254 const InternalDataChannelInit* config) override;
241 255
242 cricket::DataChannelType data_channel_type() const; 256 cricket::DataChannelType data_channel_type() const;
243 257
244 bool IceRestartPending() const; 258 bool IceRestartPending() const;
245 259
246 void ResetIceRestartLatch(); 260 void ResetIceRestartLatch();
(...skipping 13 matching lines...) Expand all
260 274
261 private: 275 private:
262 // Indicates the type of SessionDescription in a call to SetLocalDescription 276 // Indicates the type of SessionDescription in a call to SetLocalDescription
263 // and SetRemoteDescription. 277 // and SetRemoteDescription.
264 enum Action { 278 enum Action {
265 kOffer, 279 kOffer,
266 kPrAnswer, 280 kPrAnswer,
267 kAnswer, 281 kAnswer,
268 }; 282 };
269 283
270 // Invokes ConnectChannels() on transport proxies, which initiates ice
271 // candidates allocation.
272 bool StartCandidatesAllocation();
273 bool UpdateSessionState(Action action, cricket::ContentSource source, 284 bool UpdateSessionState(Action action, cricket::ContentSource source,
274 std::string* err_desc); 285 std::string* err_desc);
275 static Action GetAction(const std::string& type); 286 static Action GetAction(const std::string& type);
276 // Push the media parts of the local or remote session description 287 // Push the media parts of the local or remote session description
277 // down to all of the channels. 288 // down to all of the channels.
278 bool PushdownMediaDescription(cricket::ContentAction action, 289 bool PushdownMediaDescription(cricket::ContentAction action,
279 cricket::ContentSource source, 290 cricket::ContentSource source,
280 std::string* error_desc); 291 std::string* error_desc);
281 292
282 293 cricket::BaseChannel* GetChannel(const std::string& content_name);
283 // Transport related callbacks, override from cricket::BaseSession. 294 // Cause all the BaseChannels in the bundle group to have the same
284 virtual void OnTransportRequestSignaling(cricket::Transport* transport); 295 // transport channel.
285 virtual void OnTransportConnecting(cricket::Transport* transport); 296 bool EnableBundle(const cricket::ContentGroup& bundle);
286 virtual void OnTransportWritable(cricket::Transport* transport);
287 virtual void OnTransportCompleted(cricket::Transport* transport);
288 virtual void OnTransportFailed(cricket::Transport* transport);
289 virtual void OnTransportProxyCandidatesReady(
290 cricket::TransportProxy* proxy,
291 const cricket::Candidates& candidates);
292 virtual void OnCandidatesAllocationDone();
293 void OnTransportReceiving(cricket::Transport* transport) override;
294 297
295 // Enables media channels to allow sending of media. 298 // Enables media channels to allow sending of media.
296 void EnableChannels(); 299 void EnableChannels();
297 // Creates a JsepIceCandidate and adds it to the local session description
298 // and notify observers. Called when a new local candidate have been found.
299 void ProcessNewLocalCandidate(const std::string& content_name,
300 const cricket::Candidates& candidates);
301 // Returns the media index for a local ice candidate given the content name. 300 // Returns the media index for a local ice candidate given the content name.
302 // Returns false if the local session description does not have a media 301 // Returns false if the local session description does not have a media
303 // content called |content_name|. 302 // content called |content_name|.
304 bool GetLocalCandidateMediaIndex(const std::string& content_name, 303 bool GetLocalCandidateMediaIndex(const std::string& content_name,
305 int* sdp_mline_index); 304 int* sdp_mline_index);
306 // Uses all remote candidates in |remote_desc| in this session. 305 // Uses all remote candidates in |remote_desc| in this session.
307 bool UseCandidatesInSessionDescription( 306 bool UseCandidatesInSessionDescription(
308 const SessionDescriptionInterface* remote_desc); 307 const SessionDescriptionInterface* remote_desc);
309 // Uses |candidate| in this session. 308 // Uses |candidate| in this session.
310 bool UseCandidate(const IceCandidateInterface* candidate); 309 bool UseCandidate(const IceCandidateInterface* candidate);
311 // Deletes the corresponding channel of contents that don't exist in |desc|. 310 // Deletes the corresponding channel of contents that don't exist in |desc|.
312 // |desc| can be null. This means that all channels are deleted. 311 // |desc| can be null. This means that all channels are deleted.
313 void RemoveUnusedChannelsAndTransports( 312 void RemoveUnusedChannels(const cricket::SessionDescription* desc);
314 const cricket::SessionDescription* desc);
315 313
316 // Allocates media channels based on the |desc|. If |desc| doesn't have 314 // Allocates media channels based on the |desc|. If |desc| doesn't have
317 // the BUNDLE option, this method will disable BUNDLE in PortAllocator. 315 // the BUNDLE option, this method will disable BUNDLE in PortAllocator.
318 // This method will also delete any existing media channels before creating. 316 // This method will also delete any existing media channels before creating.
319 bool CreateChannels(const cricket::SessionDescription* desc); 317 bool CreateChannels(const cricket::SessionDescription* desc);
320 318
321 // Helper methods to create media channels. 319 // Helper methods to create media channels.
322 bool CreateVoiceChannel(const cricket::ContentInfo* content); 320 bool CreateVoiceChannel(const cricket::ContentInfo* content);
323 bool CreateVideoChannel(const cricket::ContentInfo* content); 321 bool CreateVideoChannel(const cricket::ContentInfo* content);
324 bool CreateDataChannel(const cricket::ContentInfo* content); 322 bool CreateDataChannel(const cricket::ContentInfo* content);
(...skipping 28 matching lines...) Expand all
353 Action action); 351 Action action);
354 352
355 // Returns true if we are ready to push down the remote candidate. 353 // Returns true if we are ready to push down the remote candidate.
356 // |remote_desc| is the new remote description, or NULL if the current remote 354 // |remote_desc| is the new remote description, or NULL if the current remote
357 // description should be used. Output |valid| is true if the candidate media 355 // description should be used. Output |valid| is true if the candidate media
358 // index is valid. 356 // index is valid.
359 bool ReadyToUseRemoteCandidate(const IceCandidateInterface* candidate, 357 bool ReadyToUseRemoteCandidate(const IceCandidateInterface* candidate,
360 const SessionDescriptionInterface* remote_desc, 358 const SessionDescriptionInterface* remote_desc,
361 bool* valid); 359 bool* valid);
362 360
361 void OnTransportControllerConnectionState(cricket::IceConnectionState state);
362 void OnTransportControllerReceiving(bool receiving);
363 void OnTransportControllerGatheringState(cricket::IceGatheringState state);
364 void OnTransportControllerCandidatesGathered(
365 const std::string& transport_name,
366 const cricket::Candidates& candidates);
367
363 std::string GetSessionErrorMsg(); 368 std::string GetSessionErrorMsg();
364 369
365 // Invoked when OnTransportCompleted is signaled to gather the usage 370 // Invoked when TransportController completion is signaled to gather the usage
366 // of IPv4/IPv6 as best connection. 371 // of IPv4/IPv6 as best connection.
367 void ReportBestConnectionState(const cricket::TransportStats& stats); 372 void ReportBestConnectionState(const cricket::TransportStats& stats);
368 373
369 void ReportNegotiatedCiphers(const cricket::TransportStats& stats); 374 void ReportNegotiatedCiphers(const cricket::TransportStats& stats);
370 375
371 rtc::scoped_ptr<cricket::VoiceChannel> voice_channel_; 376 rtc::scoped_ptr<cricket::VoiceChannel> voice_channel_;
372 rtc::scoped_ptr<cricket::VideoChannel> video_channel_; 377 rtc::scoped_ptr<cricket::VideoChannel> video_channel_;
373 rtc::scoped_ptr<cricket::DataChannel> data_channel_; 378 rtc::scoped_ptr<cricket::DataChannel> data_channel_;
374 cricket::ChannelManager* channel_manager_; 379 cricket::ChannelManager* channel_manager_;
375 MediaStreamSignaling* mediastream_signaling_; 380 MediaStreamSignaling* mediastream_signaling_;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 PeerConnectionInterface::BundlePolicy bundle_policy_; 414 PeerConnectionInterface::BundlePolicy bundle_policy_;
410 415
411 // Declares the RTCP mux policy for the WebRTCSession. 416 // Declares the RTCP mux policy for the WebRTCSession.
412 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy_; 417 PeerConnectionInterface::RtcpMuxPolicy rtcp_mux_policy_;
413 418
414 DISALLOW_COPY_AND_ASSIGN(WebRtcSession); 419 DISALLOW_COPY_AND_ASSIGN(WebRtcSession);
415 }; 420 };
416 } // namespace webrtc 421 } // namespace webrtc
417 422
418 #endif // TALK_APP_WEBRTC_WEBRTCSESSION_H_ 423 #endif // TALK_APP_WEBRTC_WEBRTCSESSION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698