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

Unified Diff: webrtc/p2p/base/dtlstransportchannel.h

Issue 2639203004: Revert of make the DtlsTransportWrapper inherit form DtlsTransportInternal (Closed)
Patch Set: 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/p2p/BUILD.gn ('k') | webrtc/p2p/base/dtlstransportchannel.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/p2p/base/dtlstransportchannel.h
diff --git a/webrtc/p2p/base/dtlstransportchannel.h b/webrtc/p2p/base/dtlstransportchannel.h
index 0ab9a9270371e8677943a56268782c73896be2e4..a8d5d5bcfab720080f91830ab407a5f073724d13 100644
--- a/webrtc/p2p/base/dtlstransportchannel.h
+++ b/webrtc/p2p/base/dtlstransportchannel.h
@@ -20,8 +20,8 @@
#include "webrtc/base/constructormagic.h"
#include "webrtc/base/sslstreamadapter.h"
#include "webrtc/base/stream.h"
-#include "webrtc/p2p/base/dtlstransportinternal.h"
#include "webrtc/p2p/base/icetransportinternal.h"
+#include "webrtc/p2p/base/transportchannelimpl.h"
namespace rtc {
class PacketTransportInterface;
@@ -33,7 +33,7 @@
// the bottom and a StreamInterface on the top.
class StreamInterfaceChannel : public rtc::StreamInterface {
public:
- explicit StreamInterfaceChannel(IceTransportInternal* ice_transport);
+ explicit StreamInterfaceChannel(IceTransportInternal* channel);
// Push in a packet; this gets pulled out from Read().
bool OnPacketReceived(const char* data, size_t size);
@@ -51,7 +51,7 @@
int* error) override;
private:
- IceTransportInternal* ice_transport_; // owned by DtlsTransport
+ IceTransportInternal* channel_; // owned by DtlsTransportChannelWrapper
rtc::StreamState state_;
rtc::BufferQueue packets_;
@@ -64,51 +64,47 @@
// (e.g a P2PTransportChannel)
// Here's the way this works:
//
-// DtlsTransport {
+// DtlsTransportChannelWrapper {
// SSLStreamAdapter* dtls_ {
// StreamInterfaceChannel downward_ {
-// IceTransportInternal* ice_transport_;
+// TransportChannelImpl* channel_;
// }
// }
// }
//
-// - Data which comes into DtlsTransport from the underlying
-// ice_transport_ via OnReadPacket() is checked for whether it is DTLS
-// or not, and if it is, is passed to DtlsTransport::HandleDtlsPacket,
-// which pushes it into to downward_. dtls_ is listening for events on
-// downward_, so it immediately calls downward_->Read().
-//
-// - Data written to DtlsTransport is passed either to downward_ or directly
-// to ice_transport_, depending on whether DTLS is negotiated and whether
-// the flags include PF_SRTP_BYPASS
-//
-// - The SSLStreamAdapter writes to downward_->Write() which translates it
-// into packet writes on ice_transport_.
-class DtlsTransport : public DtlsTransportInternal {
+// - Data which comes into DtlsTransportChannelWrapper from the underlying
+// channel_ via OnReadPacket() is checked for whether it is DTLS
+// or not, and if it is, is passed to DtlsTransportChannelWrapper::
+// HandleDtlsPacket, which pushes it into to downward_.
+// dtls_ is listening for events on downward_, so it immediately calls
+// downward_->Read().
+//
+// - Data written to DtlsTransportChannelWrapper is passed either to
+// downward_ or directly to channel_, depending on whether DTLS is
+// negotiated and whether the flags include PF_SRTP_BYPASS
+//
+// - The SSLStreamAdapter writes to downward_->Write()
+// which translates it into packet writes on channel_.
+class DtlsTransportChannelWrapper : public TransportChannelImpl {
public:
- // The parameters here is:
- // ice_transport -- the ice transport we are wrapping
- explicit DtlsTransport(IceTransportInternal* ice_transport);
- ~DtlsTransport() override;
-
- DtlsTransportState dtls_state() const override { return dtls_state_; }
-
- const std::string& transport_name() const override { return transport_name_; }
-
- int component() const override { return component_; }
+ // The parameters here are:
+ // channel -- the TransportChannel we are wrapping
+ explicit DtlsTransportChannelWrapper(IceTransportInternal* channel);
+ ~DtlsTransportChannelWrapper() override;
+
+ void SetIceRole(IceRole role) override { channel_->SetIceRole(role); }
+ IceRole GetIceRole() const override { return channel_->GetIceRole(); }
+ bool SetLocalCertificate(
+ const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) override;
+ rtc::scoped_refptr<rtc::RTCCertificate> GetLocalCertificate() const override;
+
+ bool SetRemoteFingerprint(const std::string& digest_alg,
+ const uint8_t* digest,
+ size_t digest_len) override;
// Returns false if no local certificate was set, or if the peer doesn't
// support DTLS.
bool IsDtlsActive() const override { return dtls_active_; }
-
- bool SetLocalCertificate(
- const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) override;
- rtc::scoped_refptr<rtc::RTCCertificate> GetLocalCertificate() const override;
-
- bool SetRemoteFingerprint(const std::string& digest_alg,
- const uint8_t* digest,
- size_t digest_len) override;
-
// Called to send a packet (via DTLS, if turned on).
int SendPacket(const char* data,
@@ -116,8 +112,16 @@
const rtc::PacketOptions& options,
int flags) override;
+ // TransportChannel calls that we forward to the wrapped transport.
+ int SetOption(rtc::Socket::Option opt, int value) override {
+ return channel_->SetOption(opt, value);
+ }
bool GetOption(rtc::Socket::Option opt, int* value) override {
- return ice_transport_->GetOption(opt, value);
+ return channel_->GetOption(opt, value);
+ }
+ int GetError() override { return channel_->GetError(); }
+ bool GetStats(ConnectionInfos* infos) override {
+ return channel_->GetStats(infos);
}
virtual bool SetSslMaxProtocolVersion(rtc::SSLProtocolVersion version);
@@ -140,9 +144,9 @@
// use by the remote peer, for use in external identity verification.
std::unique_ptr<rtc::SSLCertificate> GetRemoteSSLCertificate() const override;
- // Once DTLS has established (i.e., this ice_transport is writable), this
- // method extracts the keys negotiated during the DTLS handshake, for use in
- // external encryption. DTLS-SRTP uses this to extract the needed SRTP keys.
+ // Once DTLS has established (i.e., this channel is writable), this method
+ // extracts the keys negotiated during the DTLS handshake, for use in external
+ // encryption. DTLS-SRTP uses this to extract the needed SRTP keys.
// See the SSLStreamAdapter documentation for info on the specific parameters.
bool ExportKeyingMaterial(const std::string& label,
const uint8_t* context,
@@ -157,39 +161,49 @@
: false;
}
- IceTransportInternal* ice_transport() override { return ice_transport_; }
+ // TransportChannelImpl calls.
+ IceTransportState GetState() const override { return channel_->GetState(); }
+ void SetIceTiebreaker(uint64_t tiebreaker) override {
+ channel_->SetIceTiebreaker(tiebreaker);
+ }
+ void SetIceParameters(const IceParameters& ice_params) override {
+ channel_->SetIceParameters(ice_params);
+ }
+ void SetRemoteIceParameters(const IceParameters& ice_params) override {
+ channel_->SetRemoteIceParameters(ice_params);
+ }
+ void SetRemoteIceMode(IceMode mode) override {
+ channel_->SetRemoteIceMode(mode);
+ }
+
+ void MaybeStartGathering() override { channel_->MaybeStartGathering(); }
+
+ IceGatheringState gathering_state() const override {
+ return channel_->gathering_state();
+ }
+
+ void AddRemoteCandidate(const Candidate& candidate) override {
+ channel_->AddRemoteCandidate(candidate);
+ }
+ void RemoveRemoteCandidate(const Candidate& candidate) override {
+ channel_->RemoveRemoteCandidate(candidate);
+ }
+
+ void SetMetricsObserver(webrtc::MetricsObserverInterface* observer) override {
+ channel_->SetMetricsObserver(observer);
+ }
+
+ void SetIceConfig(const IceConfig& config) override {
+ channel_->SetIceConfig(config);
+ }
+
+ // Needed by DtlsTransport.
+ IceTransportInternal* channel() { return channel_; }
// For informational purposes. Tells if the DTLS handshake has finished.
// This may be true even if writable() is false, if the remote fingerprint
// has not yet been verified.
bool IsDtlsConnected();
-
- bool receiving() const override { return receiving_; }
-
- bool writable() const override { return writable_; }
-
- int GetError() override { return ice_transport_->GetError(); }
-
- int SetOption(rtc::Socket::Option opt, int value) override {
- return ice_transport_->SetOption(opt, value);
- }
-
- bool SetSrtpCiphers(const std::vector<std::string>& ciphers) override {
- std::vector<int> crypto_suites;
- for (const auto cipher : ciphers) {
- crypto_suites.push_back(rtc::SrtpCryptoSuiteFromName(cipher));
- }
- return SetSrtpCryptoSuites(crypto_suites);
- }
-
- std::string ToString() const {
- const char RECEIVING_ABBREV[2] = {'_', 'R'};
- const char WRITABLE_ABBREV[2] = {'_', 'W'};
- std::stringstream ss;
- ss << "DtlsTransport[" << transport_name_ << "|" << component_ << "|"
- << RECEIVING_ABBREV[receiving()] << WRITABLE_ABBREV[writable()] << "]";
- return ss.str();
- }
private:
void OnWritableState(rtc::PacketTransportInterface* transport);
@@ -206,22 +220,25 @@
bool SetupDtls();
void MaybeStartDtls();
bool HandleDtlsPacket(const char* data, size_t size);
+ void OnGatheringState(IceTransportInternal* channel);
+ void OnCandidateGathered(IceTransportInternal* channel, const Candidate& c);
+ void OnCandidatesRemoved(IceTransportInternal* channel,
+ const Candidates& candidates);
+ void OnRoleConflict(IceTransportInternal* channel);
+ void OnRouteChange(IceTransportInternal* channel, const Candidate& candidate);
+ void OnSelectedCandidatePairChanged(
+ IceTransportInternal* channel,
+ CandidatePairInterface* selected_candidate_pair,
+ int last_sent_packet_id,
+ bool ready_to_send);
+ void OnChannelStateChanged(IceTransportInternal* channel);
void OnDtlsHandshakeError(rtc::SSLHandshakeError error);
- void set_receiving(bool receiving);
- void set_writable(bool writable);
- // Sets the DTLS state, signaling if necessary.
- void set_dtls_state(DtlsTransportState state);
-
- std::string transport_name_;
- int component_;
- DtlsTransportState dtls_state_ = DTLS_TRANSPORT_NEW;
rtc::Thread* network_thread_; // Everything should occur on this thread.
- // Underlying ice_transport, not owned by this class.
- IceTransportInternal* const ice_transport_;
+ // Underlying channel, not owned by this class.
+ IceTransportInternal* const channel_;
std::unique_ptr<rtc::SSLStreamAdapter> dtls_; // The DTLS stream
- StreamInterfaceChannel*
- downward_; // Wrapper for ice_transport_, owned by dtls_.
+ StreamInterfaceChannel* downward_; // Wrapper for channel_, owned by dtls_.
std::vector<int> srtp_ciphers_; // SRTP ciphers to use with DTLS.
bool dtls_active_ = false;
rtc::scoped_refptr<rtc::RTCCertificate> local_certificate_;
@@ -232,13 +249,11 @@
// Cached DTLS ClientHello packet that was received before we started the
// DTLS handshake. This could happen if the hello was received before the
- // ice transport became writable, or before a remote fingerprint was received.
+ // transport channel became writable, or before a remote fingerprint was
+ // received.
rtc::Buffer cached_client_hello_;
- bool receiving_ = false;
- bool writable_ = false;
-
- RTC_DISALLOW_COPY_AND_ASSIGN(DtlsTransport);
+ RTC_DISALLOW_COPY_AND_ASSIGN(DtlsTransportChannelWrapper);
};
} // namespace cricket
« no previous file with comments | « webrtc/p2p/BUILD.gn ('k') | webrtc/p2p/base/dtlstransportchannel.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698