| Index: webrtc/p2p/base/transportcontroller.h
|
| diff --git a/webrtc/p2p/base/transportcontroller.h b/webrtc/p2p/base/transportcontroller.h
|
| index cdac4b6dcb5e72a08761a593b02d2f5fae9812c5..a408421ffbddeeb6b60c41adc992b906d03231c2 100644
|
| --- a/webrtc/p2p/base/transportcontroller.h
|
| +++ b/webrtc/p2p/base/transportcontroller.h
|
| @@ -20,9 +20,7 @@
|
| #include "webrtc/base/sigslot.h"
|
| #include "webrtc/base/sslstreamadapter.h"
|
| #include "webrtc/p2p/base/candidate.h"
|
| -#include "webrtc/p2p/base/dtlstransportchannel.h"
|
| -#include "webrtc/p2p/base/jseptransport.h"
|
| -#include "webrtc/p2p/base/p2ptransportchannel.h"
|
| +#include "webrtc/p2p/base/transport.h"
|
|
|
| namespace rtc {
|
| class Thread;
|
| @@ -64,7 +62,7 @@
|
| void SetIceConfig(const IceConfig& config);
|
| void SetIceRole(IceRole ice_role);
|
|
|
| - bool GetSslRole(const std::string& transport_name, rtc::SSLRole* role) const;
|
| + bool GetSslRole(const std::string& transport_name, rtc::SSLRole* role);
|
|
|
| // Specifies the identity to use in this session.
|
| // Can only be called once.
|
| @@ -72,11 +70,10 @@
|
| const rtc::scoped_refptr<rtc::RTCCertificate>& certificate);
|
| bool GetLocalCertificate(
|
| const std::string& transport_name,
|
| - rtc::scoped_refptr<rtc::RTCCertificate>* certificate) const;
|
| - // Caller owns returned certificate. This method mainly exists for stats
|
| - // reporting.
|
| + rtc::scoped_refptr<rtc::RTCCertificate>* certificate);
|
| + // Caller owns returned certificate
|
| std::unique_ptr<rtc::SSLCertificate> GetRemoteSSLCertificate(
|
| - const std::string& transport_name) const;
|
| + const std::string& transport_name);
|
| bool SetLocalTransportDescription(const std::string& transport_name,
|
| const TransportDescription& tdesc,
|
| ContentAction action,
|
| @@ -92,12 +89,8 @@
|
| const Candidates& candidates,
|
| std::string* err);
|
| bool RemoveRemoteCandidates(const Candidates& candidates, std::string* err);
|
| - bool ReadyForRemoteCandidates(const std::string& transport_name) const;
|
| - // TODO(deadbeef): GetStats isn't const because all the way down to
|
| - // OpenSSLStreamAdapter,
|
| - // GetSslCipherSuite and GetDtlsSrtpCryptoSuite are not const. Fix this.
|
| + bool ReadyForRemoteCandidates(const std::string& transport_name);
|
| bool GetStats(const std::string& transport_name, TransportStats* stats);
|
| - void SetMetricsObserver(webrtc::MetricsObserverInterface* metrics_observer);
|
|
|
| // Creates a channel if it doesn't exist. Otherwise, increments a reference
|
| // count and returns an existing channel.
|
| @@ -112,17 +105,6 @@
|
|
|
| void use_quic() { quic_ = true; }
|
| bool quic() const { return quic_; }
|
| -
|
| - // TODO(deadbeef): Remove all for_testing methods!
|
| - const rtc::scoped_refptr<rtc::RTCCertificate>& certificate_for_testing()
|
| - const {
|
| - return certificate_;
|
| - }
|
| - std::vector<std::string> transport_names_for_testing();
|
| - std::vector<TransportChannelImpl*> channels_for_testing();
|
| - TransportChannelImpl* get_channel_for_testing(
|
| - const std::string& transport_name,
|
| - int component);
|
|
|
| // All of these signals are fired on the signalling thread.
|
|
|
| @@ -146,33 +128,31 @@
|
|
|
| sigslot::signal1<const Candidates&> SignalCandidatesRemoved;
|
|
|
| + // for unit test
|
| + const rtc::scoped_refptr<rtc::RTCCertificate>& certificate_for_testing();
|
| +
|
| sigslot::signal1<rtc::SSLHandshakeError> SignalDtlsHandshakeError;
|
|
|
| + void SetMetricsObserver(webrtc::MetricsObserverInterface* metrics_observer);
|
| +
|
| protected:
|
| - // TODO(deadbeef): Get rid of these virtual methods. Used by
|
| - // FakeTransportController currently, but FakeTransportController shouldn't
|
| - // even be functioning by subclassing TransportController.
|
| - virtual TransportChannelImpl* CreateIceTransportChannel_n(
|
| - const std::string& transport_name,
|
| - int component);
|
| - virtual TransportChannelImpl* CreateDtlsTransportChannel_n(
|
| - const std::string& transport_name,
|
| - int component,
|
| - TransportChannelImpl* ice);
|
| + // Protected and virtual so we can override it in unit tests.
|
| + virtual Transport* CreateTransport_n(const std::string& transport_name);
|
| +
|
| + // For unit tests
|
| + const std::map<std::string, Transport*>& transports() { return transports_; }
|
| + Transport* GetTransport_n(const std::string& transport_name);
|
|
|
| private:
|
| void OnMessage(rtc::Message* pmsg) override;
|
|
|
| - // This structure groups the DTLS and ICE channels, and helps keep track of
|
| - // how many external objects (BaseChannels) reference each channel.
|
| + // It's the Transport that's currently responsible for creating/destroying
|
| + // channels, but the TransportController keeps track of how many external
|
| + // objects (BaseChannels) reference each channel.
|
| struct RefCountedChannel {
|
| - RefCountedChannel() = default;
|
| - // TODO(deadbeef): Change the types of |dtls| and |ice| to
|
| - // DtlsTransportChannelWrapper and P2PTransportChannelWrapper,
|
| - // once TransportChannelImpl is removed.
|
| - explicit RefCountedChannel(TransportChannelImpl* dtls,
|
| - TransportChannelImpl* ice)
|
| - : ice_(ice), dtls_(dtls), ref_(0) {}
|
| + RefCountedChannel() : impl_(nullptr), ref_(0) {}
|
| + explicit RefCountedChannel(TransportChannelImpl* impl)
|
| + : impl_(impl), ref_(0) {}
|
|
|
| void AddRef() { ++ref_; }
|
| void DecRef() {
|
| @@ -181,51 +161,33 @@
|
| }
|
| int ref() const { return ref_; }
|
|
|
| - // Currently, all ICE-related calls still go through this DTLS channel. But
|
| - // that will change once we get rid of TransportChannelImpl, and the DTLS
|
| - // channel interface no longer includes ICE-specific methods.
|
| - const TransportChannelImpl* dtls() const { return dtls_.get(); }
|
| - TransportChannelImpl* dtls() { return dtls_.get(); }
|
| - const TransportChannelImpl* ice() const { return ice_.get(); }
|
| - TransportChannelImpl* ice() { return ice_.get(); }
|
| + TransportChannelImpl* get() const { return impl_; }
|
| + TransportChannelImpl* operator->() const { return impl_; }
|
|
|
| private:
|
| - std::unique_ptr<TransportChannelImpl> ice_;
|
| - std::unique_ptr<TransportChannelImpl> dtls_;
|
| - int ref_ = 0;
|
| + TransportChannelImpl* impl_;
|
| + int ref_;
|
| };
|
|
|
| - // Helper functions to get a channel or transport, or iterator to it (in case
|
| - // it needs to be erased).
|
| - std::vector<RefCountedChannel>::iterator GetChannelIterator_n(
|
| + std::vector<RefCountedChannel>::iterator FindChannel_n(
|
| const std::string& transport_name,
|
| int component);
|
| - std::vector<RefCountedChannel>::const_iterator GetChannelIterator_n(
|
| - const std::string& transport_name,
|
| - int component) const;
|
| - const JsepTransport* GetJsepTransport_n(
|
| - const std::string& transport_name) const;
|
| - JsepTransport* GetJsepTransport_n(const std::string& transport_name);
|
| - const RefCountedChannel* GetChannel_n(const std::string& transport_name,
|
| - int component) const;
|
| - RefCountedChannel* GetChannel_n(const std::string& transport_name,
|
| - int component);
|
| -
|
| - JsepTransport* GetOrCreateJsepTransport_n(const std::string& transport_name);
|
| - void DestroyAllChannels_n();
|
| +
|
| + Transport* GetOrCreateTransport_n(const std::string& transport_name);
|
| + void DestroyTransport_n(const std::string& transport_name);
|
| + void DestroyAllTransports_n();
|
|
|
| bool SetSslMaxProtocolVersion_n(rtc::SSLProtocolVersion version);
|
| void SetIceConfig_n(const IceConfig& config);
|
| void SetIceRole_n(IceRole ice_role);
|
| - bool GetSslRole_n(const std::string& transport_name,
|
| - rtc::SSLRole* role) const;
|
| + bool GetSslRole_n(const std::string& transport_name, rtc::SSLRole* role);
|
| bool SetLocalCertificate_n(
|
| const rtc::scoped_refptr<rtc::RTCCertificate>& certificate);
|
| bool GetLocalCertificate_n(
|
| const std::string& transport_name,
|
| - rtc::scoped_refptr<rtc::RTCCertificate>* certificate) const;
|
| + rtc::scoped_refptr<rtc::RTCCertificate>* certificate);
|
| std::unique_ptr<rtc::SSLCertificate> GetRemoteSSLCertificate_n(
|
| - const std::string& transport_name) const;
|
| + const std::string& transport_name);
|
| bool SetLocalTransportDescription_n(const std::string& transport_name,
|
| const TransportDescription& tdesc,
|
| ContentAction action,
|
| @@ -239,9 +201,8 @@
|
| const Candidates& candidates,
|
| std::string* err);
|
| bool RemoveRemoteCandidates_n(const Candidates& candidates, std::string* err);
|
| - bool ReadyForRemoteCandidates_n(const std::string& transport_name) const;
|
| + bool ReadyForRemoteCandidates_n(const std::string& transport_name);
|
| bool GetStats_n(const std::string& transport_name, TransportStats* stats);
|
| - void SetMetricsObserver_n(webrtc::MetricsObserverInterface* metrics_observer);
|
|
|
| // Handlers for signals from Transport.
|
| void OnChannelWritableState_n(rtc::PacketTransportInterface* transport);
|
| @@ -261,21 +222,24 @@
|
|
|
| rtc::Thread* const signaling_thread_ = nullptr;
|
| rtc::Thread* const network_thread_ = nullptr;
|
| + typedef std::map<std::string, Transport*> TransportMap;
|
| + TransportMap transports_;
|
| +
|
| + std::vector<RefCountedChannel> channels_;
|
| +
|
| PortAllocator* const port_allocator_ = nullptr;
|
| -
|
| - std::map<std::string, std::unique_ptr<JsepTransport>> transports_;
|
| - std::vector<RefCountedChannel> channels_;
|
| + rtc::SSLProtocolVersion ssl_max_version_ = rtc::SSL_PROTOCOL_DTLS_12;
|
|
|
| // Aggregate state for TransportChannelImpls.
|
| IceConnectionState connection_state_ = kIceConnectionConnecting;
|
| bool receiving_ = false;
|
| IceGatheringState gathering_state_ = kIceGatheringNew;
|
|
|
| + // TODO(deadbeef): Move the fields below down to the transports themselves
|
| IceConfig ice_config_;
|
| IceRole ice_role_ = ICEROLE_CONTROLLING;
|
| bool redetermine_role_on_ice_restart_;
|
| uint64_t ice_tiebreaker_ = rtc::CreateRandomId64();
|
| - rtc::SSLProtocolVersion ssl_max_version_ = rtc::SSL_PROTOCOL_DTLS_12;
|
| rtc::scoped_refptr<rtc::RTCCertificate> certificate_;
|
| rtc::AsyncInvoker invoker_;
|
| // True if QUIC is used instead of DTLS.
|
|
|