Index: webrtc/p2p/base/dtlstransportchannel.h |
diff --git a/webrtc/p2p/base/dtlstransportchannel.h b/webrtc/p2p/base/dtlstransportchannel.h |
index 5850813fcd6002d36b556572b31e9e1ead0b765d..370dbcb29f3887f73b3d82d148d4f295fa18c784 100644 |
--- a/webrtc/p2p/base/dtlstransportchannel.h |
+++ b/webrtc/p2p/base/dtlstransportchannel.h |
@@ -15,12 +15,12 @@ |
#include <string> |
#include <vector> |
-#include "webrtc/p2p/base/transportchannelimpl.h" |
#include "webrtc/base/buffer.h" |
#include "webrtc/base/bufferqueue.h" |
#include "webrtc/base/constructormagic.h" |
#include "webrtc/base/sslstreamadapter.h" |
#include "webrtc/base/stream.h" |
+#include "webrtc/p2p/base/dtlstransportinternal.h" |
namespace rtc { |
class PacketTransportInterface; |
@@ -66,7 +66,7 @@ class StreamInterfaceChannel : public rtc::StreamInterface { |
// DtlsTransportChannelWrapper { |
// SSLStreamAdapter* dtls_ { |
// StreamInterfaceChannel downward_ { |
-// TransportChannelImpl* channel_; |
+// IceTransportInternal* channel_; |
// } |
// } |
// } |
@@ -84,15 +84,23 @@ class StreamInterfaceChannel : public rtc::StreamInterface { |
// |
// - The SSLStreamAdapter writes to downward_->Write() |
// which translates it into packet writes on channel_. |
-class DtlsTransportChannelWrapper : public TransportChannelImpl { |
+class DtlsTransportChannelWrapper : public DtlsTransportInternal { |
public: |
// The parameters here are: |
// channel -- the TransportChannel we are wrapping |
explicit DtlsTransportChannelWrapper(TransportChannelImpl* channel); |
~DtlsTransportChannelWrapper() override; |
- void SetIceRole(IceRole role) override { channel_->SetIceRole(role); } |
- IceRole GetIceRole() const override { return channel_->GetIceRole(); } |
+ DtlsTransportState dtls_state() const override { return dtls_state_; } |
+ |
+ const std::string& transport_name() const override { return transport_name_; } |
+ |
+ int component() const override { return component_; } |
+ |
+ // 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; |
@@ -101,9 +109,6 @@ class DtlsTransportChannelWrapper : public TransportChannelImpl { |
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_; } |
// Called to send a packet (via DTLS, if turned on). |
int SendPacket(const char* data, |
@@ -111,17 +116,9 @@ class DtlsTransportChannelWrapper : public TransportChannelImpl { |
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 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); |
@@ -160,51 +157,39 @@ class DtlsTransportChannelWrapper : public TransportChannelImpl { |
: false; |
} |
- // TransportChannelImpl calls. |
- TransportChannelState 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); |
- } |
+ TransportChannelImpl* ice_transport() override { return channel_; } |
Taylor Brandstetter
2017/01/03 23:21:59
Can this be IceTransportInternal instead now (assu
Zhi Huang
2017/01/10 18:30:51
Yes, I'll merge the IceTransportInternal change in
|
- void MaybeStartGathering() override { channel_->MaybeStartGathering(); } |
+ // 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(); |
- IceGatheringState gathering_state() const override { |
- return channel_->gathering_state(); |
- } |
+ bool receiving() const override { return receiving_; } |
- void AddRemoteCandidate(const Candidate& candidate) override { |
- channel_->AddRemoteCandidate(candidate); |
- } |
- void RemoveRemoteCandidate(const Candidate& candidate) override { |
- channel_->RemoveRemoteCandidate(candidate); |
- } |
+ bool writable() const override { return writable_; } |
- void SetMetricsObserver(webrtc::MetricsObserverInterface* observer) override { |
- channel_->SetMetricsObserver(observer); |
- } |
+ int GetError() override { return channel_->GetError(); } |
Taylor Brandstetter
2017/01/03 23:21:59
Since this and SetOption just pass through to the
Zhi Huang
2017/01/10 18:30:51
These functions are from the PacketTransportInterf
|
- void SetIceConfig(const IceConfig& config) override { |
- channel_->SetIceConfig(config); |
+ int SetOption(rtc::Socket::Option opt, int value) override { |
+ return channel_->SetOption(opt, value); |
} |
- // Needed by DtlsTransport. |
- TransportChannelImpl* channel() { return channel_; } |
+ 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); |
+ } |
- // 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(); |
+ 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); |
@@ -221,20 +206,15 @@ class DtlsTransportChannelWrapper : public TransportChannelImpl { |
bool SetupDtls(); |
void MaybeStartDtls(); |
bool HandleDtlsPacket(const char* data, size_t size); |
- void OnGatheringState(TransportChannelImpl* channel); |
- void OnCandidateGathered(TransportChannelImpl* channel, const Candidate& c); |
- void OnCandidatesRemoved(TransportChannelImpl* channel, |
- const Candidates& candidates); |
- void OnRoleConflict(TransportChannelImpl* channel); |
- void OnRouteChange(TransportChannel* channel, const Candidate& candidate); |
- void OnSelectedCandidatePairChanged( |
- TransportChannel* channel, |
- CandidatePairInterface* selected_candidate_pair, |
- int last_sent_packet_id, |
- bool ready_to_send); |
- void OnChannelStateChanged(TransportChannelImpl* 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 channel, not owned by this class. |
TransportChannelImpl* const channel_; |
@@ -254,6 +234,9 @@ class DtlsTransportChannelWrapper : public TransportChannelImpl { |
// received. |
rtc::Buffer cached_client_hello_; |
+ bool receiving_ = false; |
+ bool writable_ = false; |
+ |
RTC_DISALLOW_COPY_AND_ASSIGN(DtlsTransportChannelWrapper); |
}; |