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

Unified Diff: webrtc/api/webrtcsession.h

Issue 2564333002: Reland of: Separating SCTP code from BaseChannel/MediaChannel. (Closed)
Patch Set: Merge with master. Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « webrtc/api/webrtcsdp.cc ('k') | webrtc/api/webrtcsession.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/api/webrtcsession.h
diff --git a/webrtc/api/webrtcsession.h b/webrtc/api/webrtcsession.h
index ef31560509879ec3abeb4705ee1c20a0ecb1cc72..e346112cba3d9d6c2e8b7efd8c551a2b0b156d0a 100644
--- a/webrtc/api/webrtcsession.h
+++ b/webrtc/api/webrtcsession.h
@@ -22,6 +22,7 @@
#include "webrtc/api/peerconnectioninterface.h"
#include "webrtc/api/statstypes.h"
#include "webrtc/base/constructormagic.h"
+#include "webrtc/base/optional.h"
#include "webrtc/base/sigslot.h"
#include "webrtc/base/sslidentity.h"
#include "webrtc/base/thread.h"
@@ -37,7 +38,9 @@
namespace cricket {
class ChannelManager;
-class DataChannel;
+class RtpDataChannel;
+class SctpTransportInternal;
+class SctpTransportInternalFactory;
class StatsReport;
class VideoChannel;
class VoiceChannel;
@@ -67,8 +70,8 @@ extern const char kSdpWithoutIceUfragPwd[];
extern const char kSdpWithoutSdesAndDtlsDisabled[];
extern const char kSessionError[];
extern const char kSessionErrorDesc[];
-extern const char kDtlsSetupFailureRtp[];
-extern const char kDtlsSetupFailureRtcp[];
+extern const char kDtlsSrtpSetupFailureRtp[];
+extern const char kDtlsSrtpSetupFailureRtcp[];
extern const char kEnableBundleFailed[];
// Maximum number of received video streams that will be processed by webrtc
@@ -158,13 +161,15 @@ class WebRtcSession :
ERROR_TRANSPORT = 2, // transport error of some kind
};
+ // |sctp_factory| may be null, in which case SCTP is treated as unsupported.
WebRtcSession(
webrtc::MediaControllerInterface* media_controller,
rtc::Thread* network_thread,
rtc::Thread* worker_thread,
rtc::Thread* signaling_thread,
cricket::PortAllocator* port_allocator,
- std::unique_ptr<cricket::TransportController> transport_controller);
+ std::unique_ptr<cricket::TransportController> transport_controller,
+ std::unique_ptr<cricket::SctpTransportInternalFactory> sctp_factory);
virtual ~WebRtcSession();
// These are const to allow them to be called from const methods.
@@ -199,26 +204,34 @@ class WebRtcSession :
ice_observer_ = observer;
}
+ // Exposed for stats collecting.
virtual cricket::VoiceChannel* voice_channel() {
return voice_channel_.get();
}
virtual cricket::VideoChannel* video_channel() {
return video_channel_.get();
}
- virtual cricket::DataChannel* data_channel() {
- return data_channel_.get();
+ // Only valid when using deprecated RTP data channels.
+ virtual cricket::RtpDataChannel* rtp_data_channel() {
+ return rtp_data_channel_.get();
+ }
+ virtual rtc::Optional<std::string> sctp_content_name() const {
+ return sctp_content_name_;
+ }
+ virtual rtc::Optional<std::string> sctp_transport_name() const {
+ return sctp_transport_name_;
}
cricket::BaseChannel* GetChannel(const std::string& content_name);
cricket::SecurePolicy SdesPolicy() const;
- // Get current ssl role from transport.
- bool GetSslRole(const std::string& transport_name, rtc::SSLRole* role);
-
- // Get current SSL role for this channel's transport.
- // If |transport| is null, returns false.
- bool GetSslRole(const cricket::BaseChannel* channel, rtc::SSLRole* role);
+ // Get current SSL role used by SCTP's underlying transport.
+ bool GetSctpSslRole(rtc::SSLRole* role);
+ // Get SSL role for an arbitrary m= section (handles bundling correctly).
+ // TODO(deadbeef): This is only used internally by the session description
+ // factory, it shouldn't really be public).
+ bool GetSslRole(const std::string& content_name, rtc::SSLRole* role);
void CreateOffer(
CreateSessionDescriptionObserver* observer,
@@ -232,6 +245,7 @@ class WebRtcSession :
// The ownership of |desc| will be transferred after this call.
bool SetRemoteDescription(SessionDescriptionInterface* desc,
std::string* err_desc);
+
bool ProcessIceMessage(const IceCandidateInterface* ice_candidate);
bool RemoveRemoteIceCandidates(
@@ -326,7 +340,7 @@ class WebRtcSession :
// WebRTCSessionDescriptionFactory. Should happen before setLocalDescription.
void OnCertificateReady(
const rtc::scoped_refptr<rtc::RTCCertificate>& certificate);
- void OnDtlsSetupFailure(cricket::BaseChannel*, bool rtcp);
+ void OnDtlsSrtpSetupFailure(cricket::BaseChannel*, bool rtcp);
// For unit test.
bool waiting_for_certificate_for_testing() const;
@@ -338,8 +352,9 @@ class WebRtcSession :
transport_controller_->SetMetricsObserver(metrics_observer);
}
- // Called when voice_channel_, video_channel_ and data_channel_ are created
- // and destroyed. As a result of, for example, setting a new description.
+ // Called when voice_channel_, video_channel_ and
+ // rtp_data_channel_/sctp_transport_ are created and destroyed. As a result
+ // of, for example, setting a new description.
sigslot::signal0<> SignalVoiceChannelCreated;
sigslot::signal0<> SignalVoiceChannelDestroyed;
sigslot::signal0<> SignalVideoChannelCreated;
@@ -397,6 +412,7 @@ class WebRtcSession :
bool PushdownMediaDescription(cricket::ContentAction action,
cricket::ContentSource source,
std::string* error_desc);
+ bool PushdownSctpParameters_n(cricket::ContentSource source);
bool PushdownTransportDescription(cricket::ContentSource source,
cricket::ContentAction action,
@@ -461,11 +477,24 @@ class WebRtcSession :
std::unique_ptr<SessionStats> GetStats_n(
const ChannelNamePairs& channel_name_pairs);
- // Listens to SCTP CONTROL messages on unused SIDs and process them as OPEN
- // messages.
- void OnDataChannelMessageReceived(cricket::DataChannel* channel,
- const cricket::ReceiveDataParams& params,
- const rtc::CopyOnWriteBuffer& payload);
+ bool CreateSctpTransport_n(const std::string& content_name,
+ const std::string& transport_name);
+ // For bundling.
+ void ChangeSctpTransport_n(const std::string& transport_name);
+ void DestroySctpTransport_n();
+ // SctpTransport signal handlers. Needed to marshal signals from the network
+ // to signaling thread.
+ void OnSctpTransportReadyToSendData_n();
+ // This may be called with "false" if the direction of the m= section causes
+ // us to tear down the SCTP connection.
+ void OnSctpTransportReadyToSendData_s(bool ready);
+ void OnSctpTransportDataReceived_n(const cricket::ReceiveDataParams& params,
+ const rtc::CopyOnWriteBuffer& payload);
+ // Beyond just firing the signal to the signaling thread, listens to SCTP
+ // CONTROL messages on unused SIDs and processes them as OPEN messages.
+ void OnSctpTransportDataReceived_s(const cricket::ReceiveDataParams& params,
+ const rtc::CopyOnWriteBuffer& payload);
+ void OnSctpStreamClosedRemotely_n(int sid);
std::string BadStateErrMsg(State state);
void SetIceConnectionState(PeerConnectionInterface::IceConnectionState state);
@@ -498,6 +527,7 @@ class WebRtcSession :
// this session.
bool SrtpRequired() const;
+ // TransportController signal handlers.
void OnTransportControllerConnectionState(cricket::IceConnectionState state);
void OnTransportControllerReceiving(bool receiving);
void OnTransportControllerGatheringState(cricket::IceGatheringState state);
@@ -506,6 +536,7 @@ class WebRtcSession :
const std::vector<cricket::Candidate>& candidates);
void OnTransportControllerCandidatesRemoved(
const std::vector<cricket::Candidate>& candidates);
+ void OnTransportControllerDtlsHandshakeError(rtc::SSLHandshakeError error);
std::string GetSessionErrorMsg();
@@ -522,8 +553,6 @@ class WebRtcSession :
const std::string GetTransportName(const std::string& content_name);
- void OnDtlsHandshakeError(rtc::SSLHandshakeError error);
-
rtc::Thread* const network_thread_;
rtc::Thread* const worker_thread_;
rtc::Thread* const signaling_thread_;
@@ -536,10 +565,39 @@ class WebRtcSession :
bool initial_offerer_ = false;
const std::unique_ptr<cricket::TransportController> transport_controller_;
+ const std::unique_ptr<cricket::SctpTransportInternalFactory> sctp_factory_;
MediaControllerInterface* media_controller_;
std::unique_ptr<cricket::VoiceChannel> voice_channel_;
std::unique_ptr<cricket::VideoChannel> video_channel_;
- std::unique_ptr<cricket::DataChannel> data_channel_;
+ // |rtp_data_channel_| is used if in RTP data channel mode, |sctp_transport_|
+ // when using SCTP.
+ std::unique_ptr<cricket::RtpDataChannel> rtp_data_channel_;
+
+ std::unique_ptr<cricket::SctpTransportInternal> sctp_transport_;
+ // |sctp_transport_name_| keeps track of what DTLS transport the SCTP
+ // transport is using (which can change due to bundling).
+ rtc::Optional<std::string> sctp_transport_name_;
+ // |sctp_content_name_| is the content name (MID) in SDP.
+ rtc::Optional<std::string> sctp_content_name_;
+ // Value cached on signaling thread. Only updated when SctpReadyToSendData
+ // fires on the signaling thread.
+ bool sctp_ready_to_send_data_ = false;
+ // Same as signals provided by SctpTransport, but these are guaranteed to
+ // fire on the signaling thread, whereas SctpTransport fires on the networking
+ // thread.
+ // |sctp_invoker_| is used so that any signals queued on the signaling thread
+ // from the network thread are immediately discarded if the SctpTransport is
+ // destroyed (due to m= section being rejected).
+ // TODO(deadbeef): Use a proxy object to ensure that method calls/signals
+ // are marshalled to the right thread. Could almost use proxy.h for this,
+ // but it doesn't have a mechanism for marshalling sigslot::signals
+ std::unique_ptr<rtc::AsyncInvoker> sctp_invoker_;
+ sigslot::signal1<bool> SignalSctpReadyToSendData;
+ sigslot::signal2<const cricket::ReceiveDataParams&,
+ const rtc::CopyOnWriteBuffer&>
+ SignalSctpDataReceived;
+ sigslot::signal1<int> SignalSctpStreamClosedRemotely;
+
cricket::ChannelManager* channel_manager_;
IceObserver* ice_observer_;
PeerConnectionInterface::IceConnectionState ice_connection_state_;
« no previous file with comments | « webrtc/api/webrtcsdp.cc ('k') | webrtc/api/webrtcsession.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698