| Index: webrtc/p2p/base/transportcontroller.cc
|
| diff --git a/webrtc/p2p/base/transportcontroller.cc b/webrtc/p2p/base/transportcontroller.cc
|
| index 8dd748647b2a9175002912062e76ec5ed1cebefe..e4dc5afa21ae775b5b6cca401a7b2d136a19d151 100644
|
| --- a/webrtc/p2p/base/transportcontroller.cc
|
| +++ b/webrtc/p2p/base/transportcontroller.cc
|
| @@ -16,14 +16,8 @@
|
| #include "webrtc/base/bind.h"
|
| #include "webrtc/base/checks.h"
|
| #include "webrtc/base/thread.h"
|
| -#include "webrtc/p2p/base/dtlstransport.h"
|
| -#include "webrtc/p2p/base/p2ptransport.h"
|
| #include "webrtc/p2p/base/port.h"
|
|
|
| -#ifdef HAVE_QUIC
|
| -#include "webrtc/p2p/quic/quictransport.h"
|
| -#endif // HAVE_QUIC
|
| -
|
| namespace cricket {
|
|
|
| enum {
|
| @@ -60,10 +54,11 @@ TransportController::TransportController(rtc::Thread* signaling_thread,
|
| true) {}
|
|
|
| TransportController::~TransportController() {
|
| + // Channel destructors may try to send packets, so this needs to happen on
|
| + // the network thread.
|
| network_thread_->Invoke<void>(
|
| RTC_FROM_HERE,
|
| - rtc::Bind(&TransportController::DestroyAllTransports_n, this));
|
| - signaling_thread_->Clear(this);
|
| + rtc::Bind(&TransportController::DestroyAllChannels_n, this));
|
| }
|
|
|
| bool TransportController::SetSslMaxProtocolVersion(
|
| @@ -86,7 +81,7 @@ void TransportController::SetIceRole(IceRole ice_role) {
|
| }
|
|
|
| bool TransportController::GetSslRole(const std::string& transport_name,
|
| - rtc::SSLRole* role) {
|
| + rtc::SSLRole* role) const {
|
| return network_thread_->Invoke<bool>(
|
| RTC_FROM_HERE, rtc::Bind(&TransportController::GetSslRole_n, this,
|
| transport_name, role));
|
| @@ -101,7 +96,7 @@ bool TransportController::SetLocalCertificate(
|
|
|
| bool TransportController::GetLocalCertificate(
|
| const std::string& transport_name,
|
| - rtc::scoped_refptr<rtc::RTCCertificate>* certificate) {
|
| + rtc::scoped_refptr<rtc::RTCCertificate>* certificate) const {
|
| return network_thread_->Invoke<bool>(
|
| RTC_FROM_HERE, rtc::Bind(&TransportController::GetLocalCertificate_n,
|
| this, transport_name, certificate));
|
| @@ -109,7 +104,7 @@ bool TransportController::GetLocalCertificate(
|
|
|
| std::unique_ptr<rtc::SSLCertificate>
|
| TransportController::GetRemoteSSLCertificate(
|
| - const std::string& transport_name) {
|
| + const std::string& transport_name) const {
|
| return network_thread_->Invoke<std::unique_ptr<rtc::SSLCertificate>>(
|
| RTC_FROM_HERE, rtc::Bind(&TransportController::GetRemoteSSLCertificate_n,
|
| this, transport_name));
|
| @@ -159,7 +154,7 @@ bool TransportController::RemoveRemoteCandidates(const Candidates& candidates,
|
| }
|
|
|
| bool TransportController::ReadyForRemoteCandidates(
|
| - const std::string& transport_name) {
|
| + const std::string& transport_name) const {
|
| return network_thread_->Invoke<bool>(
|
| RTC_FROM_HERE, rtc::Bind(&TransportController::ReadyForRemoteCandidates_n,
|
| this, transport_name));
|
| @@ -172,42 +167,70 @@ bool TransportController::GetStats(const std::string& transport_name,
|
| rtc::Bind(&TransportController::GetStats_n, this, transport_name, stats));
|
| }
|
|
|
| +void TransportController::SetMetricsObserver(
|
| + webrtc::MetricsObserverInterface* metrics_observer) {
|
| + return network_thread_->Invoke<void>(
|
| + RTC_FROM_HERE, rtc::Bind(&TransportController::SetMetricsObserver_n, this,
|
| + metrics_observer));
|
| +}
|
| +
|
| TransportChannel* TransportController::CreateTransportChannel_n(
|
| const std::string& transport_name,
|
| int component) {
|
| RTC_DCHECK(network_thread_->IsCurrent());
|
|
|
| - auto it = FindChannel_n(transport_name, component);
|
| - if (it != channels_.end()) {
|
| + RefCountedChannel* existing_channel = GetChannel_n(transport_name, component);
|
| + if (existing_channel) {
|
| // Channel already exists; increment reference count and return.
|
| - it->AddRef();
|
| - return it->get();
|
| + existing_channel->AddRef();
|
| + return existing_channel->dtls();
|
| }
|
|
|
| // Need to create a new channel.
|
| - Transport* transport = GetOrCreateTransport_n(transport_name);
|
| - TransportChannelImpl* channel = transport->CreateChannel(component);
|
| - channel->SetMetricsObserver(metrics_observer_);
|
| - channel->SignalWritableState.connect(
|
| + JsepTransport* transport = GetOrCreateJsepTransport_n(transport_name);
|
| +
|
| + // Create DTLS channel wrapping ICE channel, and configure it.
|
| + TransportChannelImpl* ice =
|
| + CreateIceTransportChannel_n(transport_name, component);
|
| + // TODO(deadbeef): To support QUIC, would need to create a
|
| + // QuicTransportChannel here. What is "dtls" in this file would then become
|
| + // "dtls or quic".
|
| + TransportChannelImpl* dtls =
|
| + CreateDtlsTransportChannel_n(transport_name, component, ice);
|
| + dtls->SetMetricsObserver(metrics_observer_);
|
| + dtls->SetIceRole(ice_role_);
|
| + dtls->SetIceTiebreaker(ice_tiebreaker_);
|
| + dtls->SetIceConfig(ice_config_);
|
| + if (certificate_) {
|
| + bool set_cert_success = dtls->SetLocalCertificate(certificate_);
|
| + RTC_DCHECK(set_cert_success);
|
| + }
|
| +
|
| + // Connect to signals offered by the channels. Currently, the DTLS channel
|
| + // forwards signals from the ICE channel, so we only need to connect to the
|
| + // DTLS channel. In the future this won't be the case.
|
| + dtls->SignalWritableState.connect(
|
| this, &TransportController::OnChannelWritableState_n);
|
| - channel->SignalReceivingState.connect(
|
| + dtls->SignalReceivingState.connect(
|
| this, &TransportController::OnChannelReceivingState_n);
|
| - channel->SignalGatheringState.connect(
|
| + dtls->SignalGatheringState.connect(
|
| this, &TransportController::OnChannelGatheringState_n);
|
| - channel->SignalCandidateGathered.connect(
|
| + dtls->SignalCandidateGathered.connect(
|
| this, &TransportController::OnChannelCandidateGathered_n);
|
| - channel->SignalCandidatesRemoved.connect(
|
| + dtls->SignalCandidatesRemoved.connect(
|
| this, &TransportController::OnChannelCandidatesRemoved_n);
|
| - channel->SignalRoleConflict.connect(
|
| + dtls->SignalRoleConflict.connect(
|
| this, &TransportController::OnChannelRoleConflict_n);
|
| - channel->SignalStateChanged.connect(
|
| + dtls->SignalStateChanged.connect(
|
| this, &TransportController::OnChannelStateChanged_n);
|
| - channel->SignalDtlsHandshakeError.connect(
|
| + dtls->SignalDtlsHandshakeError.connect(
|
| this, &TransportController::OnDtlsHandshakeError);
|
| - channels_.insert(channels_.end(), RefCountedChannel(channel))->AddRef();
|
| + channels_.insert(channels_.end(), RefCountedChannel(dtls, ice))->AddRef();
|
| + bool channel_added = transport->AddChannel(dtls, component);
|
| + RTC_DCHECK(channel_added);
|
| // Adding a channel could cause aggregate state to change.
|
| UpdateAggregateStates_n();
|
| - return channel;
|
| + return dtls;
|
| }
|
|
|
| void TransportController::DestroyTransportChannel_n(
|
| @@ -215,56 +238,68 @@ void TransportController::DestroyTransportChannel_n(
|
| int component) {
|
| RTC_DCHECK(network_thread_->IsCurrent());
|
|
|
| - auto it = FindChannel_n(transport_name, component);
|
| + auto it = GetChannelIterator_n(transport_name, component);
|
| if (it == channels_.end()) {
|
| LOG(LS_WARNING) << "Attempting to delete " << transport_name
|
| << " TransportChannel " << component
|
| << ", which doesn't exist.";
|
| return;
|
| }
|
| -
|
| it->DecRef();
|
| if (it->ref() > 0) {
|
| return;
|
| }
|
| -
|
| channels_.erase(it);
|
| - Transport* transport = GetTransport_n(transport_name);
|
| - transport->DestroyChannel(component);
|
| +
|
| + JsepTransport* t = GetJsepTransport_n(transport_name);
|
| + bool channel_removed = t->RemoveChannel(component);
|
| + RTC_DCHECK(channel_removed);
|
| // Just as we create a Transport when its first channel is created,
|
| // we delete it when its last channel is deleted.
|
| - if (!transport->HasChannels()) {
|
| - DestroyTransport_n(transport_name);
|
| + if (!t->HasChannels()) {
|
| + transports_.erase(transport_name);
|
| }
|
| +
|
| // Removing a channel could cause aggregate state to change.
|
| UpdateAggregateStates_n();
|
| }
|
|
|
| -const rtc::scoped_refptr<rtc::RTCCertificate>&
|
| -TransportController::certificate_for_testing() {
|
| - return certificate_;
|
| +std::vector<std::string> TransportController::transport_names_for_testing() {
|
| + std::vector<std::string> ret;
|
| + for (const auto& kv : transports_) {
|
| + ret.push_back(kv.first);
|
| + }
|
| + return ret;
|
| }
|
|
|
| -Transport* TransportController::CreateTransport_n(
|
| - const std::string& transport_name) {
|
| - RTC_DCHECK(network_thread_->IsCurrent());
|
| -
|
| -#ifdef HAVE_QUIC
|
| - if (quic_) {
|
| - return new QuicTransport(transport_name, port_allocator(), certificate_);
|
| +std::vector<TransportChannelImpl*> TransportController::channels_for_testing() {
|
| + std::vector<TransportChannelImpl*> ret;
|
| + for (RefCountedChannel& channel : channels_) {
|
| + ret.push_back(channel.dtls());
|
| }
|
| -#endif // HAVE_QUIC
|
| - Transport* transport = new DtlsTransport<P2PTransport>(
|
| - transport_name, port_allocator(), certificate_);
|
| - return transport;
|
| + return ret;
|
| }
|
|
|
| -Transport* TransportController::GetTransport_n(
|
| - const std::string& transport_name) {
|
| - RTC_DCHECK(network_thread_->IsCurrent());
|
| +TransportChannelImpl* TransportController::get_channel_for_testing(
|
| + const std::string& transport_name,
|
| + int component) {
|
| + RefCountedChannel* ch = GetChannel_n(transport_name, component);
|
| + return ch ? ch->dtls() : nullptr;
|
| +}
|
|
|
| - auto iter = transports_.find(transport_name);
|
| - return (iter != transports_.end()) ? iter->second : nullptr;
|
| +TransportChannelImpl* TransportController::CreateIceTransportChannel_n(
|
| + const std::string& transport_name,
|
| + int component) {
|
| + return new P2PTransportChannel(transport_name, component, port_allocator_);
|
| +}
|
| +
|
| +TransportChannelImpl* TransportController::CreateDtlsTransportChannel_n(
|
| + const std::string&,
|
| + int,
|
| + TransportChannelImpl* ice) {
|
| + DtlsTransportChannelWrapper* dtls = new DtlsTransportChannelWrapper(ice);
|
| + dtls->SetSslMaxProtocolVersion(ssl_max_version_);
|
| + return dtls;
|
| }
|
|
|
| void TransportController::OnMessage(rtc::Message* pmsg) {
|
| @@ -304,58 +339,77 @@ void TransportController::OnMessage(rtc::Message* pmsg) {
|
| }
|
|
|
| std::vector<TransportController::RefCountedChannel>::iterator
|
| -TransportController::FindChannel_n(const std::string& transport_name,
|
| - int component) {
|
| +TransportController::GetChannelIterator_n(const std::string& transport_name,
|
| + int component) {
|
| + RTC_DCHECK(network_thread_->IsCurrent());
|
| return std::find_if(
|
| channels_.begin(), channels_.end(),
|
| [transport_name, component](const RefCountedChannel& channel) {
|
| - return channel->transport_name() == transport_name &&
|
| - channel->component() == component;
|
| + return channel.dtls()->transport_name() == transport_name &&
|
| + channel.dtls()->component() == component;
|
| });
|
| }
|
|
|
| -Transport* TransportController::GetOrCreateTransport_n(
|
| - const std::string& transport_name) {
|
| +std::vector<TransportController::RefCountedChannel>::const_iterator
|
| +TransportController::GetChannelIterator_n(const std::string& transport_name,
|
| + int component) const {
|
| RTC_DCHECK(network_thread_->IsCurrent());
|
| + return std::find_if(
|
| + channels_.begin(), channels_.end(),
|
| + [transport_name, component](const RefCountedChannel& channel) {
|
| + return channel.dtls()->transport_name() == transport_name &&
|
| + channel.dtls()->component() == component;
|
| + });
|
| +}
|
|
|
| - Transport* transport = GetTransport_n(transport_name);
|
| - if (transport) {
|
| - return transport;
|
| - }
|
| +const JsepTransport* TransportController::GetJsepTransport_n(
|
| + const std::string& transport_name) const {
|
| + RTC_DCHECK(network_thread_->IsCurrent());
|
| + auto it = transports_.find(transport_name);
|
| + return (it == transports_.end()) ? nullptr : it->second.get();
|
| +}
|
|
|
| - transport = CreateTransport_n(transport_name);
|
| - // The stuff below happens outside of CreateTransport_w so that unit tests
|
| - // can override CreateTransport_w to return a different type of transport.
|
| - transport->SetSslMaxProtocolVersion(ssl_max_version_);
|
| - transport->SetIceConfig(ice_config_);
|
| - transport->SetIceRole(ice_role_);
|
| - transport->SetIceTiebreaker(ice_tiebreaker_);
|
| - if (certificate_) {
|
| - transport->SetLocalCertificate(certificate_);
|
| - }
|
| - transports_[transport_name] = transport;
|
| +JsepTransport* TransportController::GetJsepTransport_n(
|
| + const std::string& transport_name) {
|
| + RTC_DCHECK(network_thread_->IsCurrent());
|
| + auto it = transports_.find(transport_name);
|
| + return (it == transports_.end()) ? nullptr : it->second.get();
|
| +}
|
|
|
| - return transport;
|
| +const TransportController::RefCountedChannel* TransportController::GetChannel_n(
|
| + const std::string& transport_name,
|
| + int component) const {
|
| + RTC_DCHECK(network_thread_->IsCurrent());
|
| + auto it = GetChannelIterator_n(transport_name, component);
|
| + return (it == channels_.end()) ? nullptr : &(*it);
|
| }
|
|
|
| -void TransportController::DestroyTransport_n(
|
| +TransportController::RefCountedChannel* TransportController::GetChannel_n(
|
| + const std::string& transport_name,
|
| + int component) {
|
| + RTC_DCHECK(network_thread_->IsCurrent());
|
| + auto it = GetChannelIterator_n(transport_name, component);
|
| + return (it == channels_.end()) ? nullptr : &(*it);
|
| +}
|
| +
|
| +JsepTransport* TransportController::GetOrCreateJsepTransport_n(
|
| const std::string& transport_name) {
|
| RTC_DCHECK(network_thread_->IsCurrent());
|
|
|
| - auto iter = transports_.find(transport_name);
|
| - if (iter != transports_.end()) {
|
| - delete iter->second;
|
| - transports_.erase(transport_name);
|
| + JsepTransport* transport = GetJsepTransport_n(transport_name);
|
| + if (transport) {
|
| + return transport;
|
| }
|
| +
|
| + transport = new JsepTransport(transport_name, certificate_);
|
| + transports_[transport_name] = std::unique_ptr<JsepTransport>(transport);
|
| + return transport;
|
| }
|
|
|
| -void TransportController::DestroyAllTransports_n() {
|
| +void TransportController::DestroyAllChannels_n() {
|
| RTC_DCHECK(network_thread_->IsCurrent());
|
| -
|
| - for (const auto& kv : transports_) {
|
| - delete kv.second;
|
| - }
|
| transports_.clear();
|
| + channels_.clear();
|
| }
|
|
|
| bool TransportController::SetSslMaxProtocolVersion_n(
|
| @@ -373,74 +427,82 @@ bool TransportController::SetSslMaxProtocolVersion_n(
|
|
|
| void TransportController::SetIceConfig_n(const IceConfig& config) {
|
| RTC_DCHECK(network_thread_->IsCurrent());
|
| +
|
| ice_config_ = config;
|
| - for (const auto& kv : transports_) {
|
| - kv.second->SetIceConfig(ice_config_);
|
| + for (auto& channel : channels_) {
|
| + channel.dtls()->SetIceConfig(ice_config_);
|
| }
|
| }
|
|
|
| void TransportController::SetIceRole_n(IceRole ice_role) {
|
| RTC_DCHECK(network_thread_->IsCurrent());
|
| +
|
| ice_role_ = ice_role;
|
| - for (const auto& kv : transports_) {
|
| - kv.second->SetIceRole(ice_role_);
|
| + for (auto& channel : channels_) {
|
| + channel.dtls()->SetIceRole(ice_role_);
|
| }
|
| }
|
|
|
| bool TransportController::GetSslRole_n(const std::string& transport_name,
|
| - rtc::SSLRole* role) {
|
| + rtc::SSLRole* role) const {
|
| RTC_DCHECK(network_thread_->IsCurrent());
|
|
|
| - Transport* t = GetTransport_n(transport_name);
|
| + const JsepTransport* t = GetJsepTransport_n(transport_name);
|
| if (!t) {
|
| return false;
|
| }
|
| -
|
| - return t->GetSslRole(role);
|
| + t->GetSslRole(role);
|
| + return true;
|
| }
|
|
|
| bool TransportController::SetLocalCertificate_n(
|
| const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) {
|
| RTC_DCHECK(network_thread_->IsCurrent());
|
|
|
| - if (certificate_) {
|
| - return false;
|
| - }
|
| - if (!certificate) {
|
| + // Can't change a certificate, or set a null certificate.
|
| + if (certificate_ || !certificate) {
|
| return false;
|
| }
|
| certificate_ = certificate;
|
|
|
| - for (const auto& kv : transports_) {
|
| + // Set certificate both for Transport, which verifies it matches the
|
| + // fingerprint in SDP...
|
| + for (auto& kv : transports_) {
|
| kv.second->SetLocalCertificate(certificate_);
|
| }
|
| + // ... and for the DTLS channel, which needs it for the DTLS handshake.
|
| + for (auto& channel : channels_) {
|
| + bool set_cert_success = channel.dtls()->SetLocalCertificate(certificate);
|
| + RTC_DCHECK(set_cert_success);
|
| + }
|
| return true;
|
| }
|
|
|
| bool TransportController::GetLocalCertificate_n(
|
| const std::string& transport_name,
|
| - rtc::scoped_refptr<rtc::RTCCertificate>* certificate) {
|
| + rtc::scoped_refptr<rtc::RTCCertificate>* certificate) const {
|
| RTC_DCHECK(network_thread_->IsCurrent());
|
|
|
| - Transport* t = GetTransport_n(transport_name);
|
| + const JsepTransport* t = GetJsepTransport_n(transport_name);
|
| if (!t) {
|
| return false;
|
| }
|
| -
|
| return t->GetLocalCertificate(certificate);
|
| }
|
|
|
| std::unique_ptr<rtc::SSLCertificate>
|
| TransportController::GetRemoteSSLCertificate_n(
|
| - const std::string& transport_name) {
|
| + const std::string& transport_name) const {
|
| RTC_DCHECK(network_thread_->IsCurrent());
|
|
|
| - Transport* t = GetTransport_n(transport_name);
|
| - if (!t) {
|
| + // Get the certificate from the RTP channel's DTLS handshake. Should be
|
| + // identical to the RTCP channel's, since they were given the same remote
|
| + // fingerprint.
|
| + const RefCountedChannel* ch = GetChannel_n(transport_name, 1);
|
| + if (!ch) {
|
| return nullptr;
|
| }
|
| -
|
| - return t->GetRemoteSSLCertificate();
|
| + return ch->dtls()->GetRemoteSSLCertificate();
|
| }
|
|
|
| bool TransportController::SetLocalTransportDescription_n(
|
| @@ -450,7 +512,7 @@ bool TransportController::SetLocalTransportDescription_n(
|
| std::string* err) {
|
| RTC_DCHECK(network_thread_->IsCurrent());
|
|
|
| - Transport* transport = GetTransport_n(transport_name);
|
| + JsepTransport* transport = GetJsepTransport_n(transport_name);
|
| if (!transport) {
|
| // If we didn't find a transport, that's not an error;
|
| // it could have been deleted as a result of bundling.
|
| @@ -486,7 +548,15 @@ bool TransportController::SetRemoteTransportDescription_n(
|
| std::string* err) {
|
| RTC_DCHECK(network_thread_->IsCurrent());
|
|
|
| - Transport* transport = GetTransport_n(transport_name);
|
| + // If our role is ICEROLE_CONTROLLED and the remote endpoint supports only
|
| + // ice_lite, this local endpoint should take the CONTROLLING role.
|
| + // TODO(deadbeef): This is a session-level attribute, so it really shouldn't
|
| + // be in a TransportDescription in the first place...
|
| + if (ice_role_ == ICEROLE_CONTROLLED && tdesc.ice_mode == ICEMODE_LITE) {
|
| + SetIceRole_n(ICEROLE_CONTROLLING);
|
| + }
|
| +
|
| + JsepTransport* transport = GetJsepTransport_n(transport_name);
|
| if (!transport) {
|
| // If we didn't find a transport, that's not an error;
|
| // it could have been deleted as a result of bundling.
|
| @@ -500,8 +570,8 @@ bool TransportController::SetRemoteTransportDescription_n(
|
| }
|
|
|
| void TransportController::MaybeStartGathering_n() {
|
| - for (const auto& kv : transports_) {
|
| - kv.second->MaybeStartGathering();
|
| + for (auto& channel : channels_) {
|
| + channel.dtls()->MaybeStartGathering();
|
| }
|
| }
|
|
|
| @@ -511,19 +581,40 @@ bool TransportController::AddRemoteCandidates_n(
|
| std::string* err) {
|
| RTC_DCHECK(network_thread_->IsCurrent());
|
|
|
| - Transport* transport = GetTransport_n(transport_name);
|
| + // Verify each candidate before passing down to the transport layer.
|
| + if (!VerifyCandidates(candidates, err)) {
|
| + return false;
|
| + }
|
| +
|
| + JsepTransport* transport = GetJsepTransport_n(transport_name);
|
| if (!transport) {
|
| // If we didn't find a transport, that's not an error;
|
| // it could have been deleted as a result of bundling.
|
| return true;
|
| }
|
|
|
| - return transport->AddRemoteCandidates(candidates, err);
|
| + for (const Candidate& candidate : candidates) {
|
| + RefCountedChannel* channel =
|
| + GetChannel_n(transport_name, candidate.component());
|
| + if (!channel) {
|
| + *err = "Candidate has an unknown component: " + candidate.ToString() +
|
| + " for content: " + transport_name;
|
| + return false;
|
| + }
|
| + channel->dtls()->AddRemoteCandidate(candidate);
|
| + }
|
| + return true;
|
| }
|
|
|
| bool TransportController::RemoveRemoteCandidates_n(const Candidates& candidates,
|
| std::string* err) {
|
| RTC_DCHECK(network_thread_->IsCurrent());
|
| +
|
| + // Verify each candidate before passing down to the transport layer.
|
| + if (!VerifyCandidates(candidates, err)) {
|
| + return false;
|
| + }
|
| +
|
| std::map<std::string, Candidates> candidates_by_transport_name;
|
| for (const Candidate& cand : candidates) {
|
| RTC_DCHECK(!cand.transport_name().empty());
|
| @@ -531,23 +622,31 @@ bool TransportController::RemoveRemoteCandidates_n(const Candidates& candidates,
|
| }
|
|
|
| bool result = true;
|
| - for (auto kv : candidates_by_transport_name) {
|
| - Transport* transport = GetTransport_n(kv.first);
|
| + for (const auto& kv : candidates_by_transport_name) {
|
| + const std::string& transport_name = kv.first;
|
| + const Candidates& candidates = kv.second;
|
| + JsepTransport* transport = GetJsepTransport_n(transport_name);
|
| if (!transport) {
|
| // If we didn't find a transport, that's not an error;
|
| // it could have been deleted as a result of bundling.
|
| continue;
|
| }
|
| - result &= transport->RemoveRemoteCandidates(kv.second, err);
|
| + for (const Candidate& candidate : candidates) {
|
| + RefCountedChannel* channel =
|
| + GetChannel_n(transport_name, candidate.component());
|
| + if (channel) {
|
| + channel->dtls()->RemoveRemoteCandidate(candidate);
|
| + }
|
| + }
|
| }
|
| return result;
|
| }
|
|
|
| bool TransportController::ReadyForRemoteCandidates_n(
|
| - const std::string& transport_name) {
|
| + const std::string& transport_name) const {
|
| RTC_DCHECK(network_thread_->IsCurrent());
|
|
|
| - Transport* transport = GetTransport_n(transport_name);
|
| + const JsepTransport* transport = GetJsepTransport_n(transport_name);
|
| if (!transport) {
|
| return false;
|
| }
|
| @@ -558,13 +657,22 @@ bool TransportController::GetStats_n(const std::string& transport_name,
|
| TransportStats* stats) {
|
| RTC_DCHECK(network_thread_->IsCurrent());
|
|
|
| - Transport* transport = GetTransport_n(transport_name);
|
| + JsepTransport* transport = GetJsepTransport_n(transport_name);
|
| if (!transport) {
|
| return false;
|
| }
|
| return transport->GetStats(stats);
|
| }
|
|
|
| +void TransportController::SetMetricsObserver_n(
|
| + webrtc::MetricsObserverInterface* metrics_observer) {
|
| + RTC_DCHECK(network_thread_->IsCurrent());
|
| + metrics_observer_ = metrics_observer;
|
| + for (auto& channel : channels_) {
|
| + channel.dtls()->SetMetricsObserver(metrics_observer);
|
| + }
|
| +}
|
| +
|
| void TransportController::OnChannelWritableState_n(
|
| rtc::PacketTransportInterface* transport) {
|
| RTC_DCHECK(network_thread_->IsCurrent());
|
| @@ -654,19 +762,21 @@ void TransportController::UpdateAggregateStates_n() {
|
| bool any_gathering = false;
|
| bool all_done_gathering = !channels_.empty();
|
| for (const auto& channel : channels_) {
|
| - any_receiving = any_receiving || channel->receiving();
|
| - any_failed = any_failed ||
|
| - channel->GetState() == TransportChannelState::STATE_FAILED;
|
| - all_connected = all_connected && channel->writable();
|
| + any_receiving = any_receiving || channel.dtls()->receiving();
|
| + any_failed =
|
| + any_failed ||
|
| + channel.dtls()->GetState() == TransportChannelState::STATE_FAILED;
|
| + all_connected = all_connected && channel.dtls()->writable();
|
| all_completed =
|
| - all_completed && channel->writable() &&
|
| - channel->GetState() == TransportChannelState::STATE_COMPLETED &&
|
| - channel->GetIceRole() == ICEROLE_CONTROLLING &&
|
| - channel->gathering_state() == kIceGatheringComplete;
|
| + all_completed && channel.dtls()->writable() &&
|
| + channel.dtls()->GetState() == TransportChannelState::STATE_COMPLETED &&
|
| + channel.dtls()->GetIceRole() == ICEROLE_CONTROLLING &&
|
| + channel.dtls()->gathering_state() == kIceGatheringComplete;
|
| any_gathering =
|
| - any_gathering || channel->gathering_state() != kIceGatheringNew;
|
| - all_done_gathering = all_done_gathering &&
|
| - channel->gathering_state() == kIceGatheringComplete;
|
| + any_gathering || channel.dtls()->gathering_state() != kIceGatheringNew;
|
| + all_done_gathering =
|
| + all_done_gathering &&
|
| + channel.dtls()->gathering_state() == kIceGatheringComplete;
|
| }
|
|
|
| if (any_failed) {
|
| @@ -706,12 +816,4 @@ void TransportController::OnDtlsHandshakeError(rtc::SSLHandshakeError error) {
|
| SignalDtlsHandshakeError(error);
|
| }
|
|
|
| -void TransportController::SetMetricsObserver(
|
| - webrtc::MetricsObserverInterface* metrics_observer) {
|
| - metrics_observer_ = metrics_observer;
|
| - for (auto channel : channels_) {
|
| - channel->SetMetricsObserver(metrics_observer);
|
| - }
|
| -}
|
| -
|
| } // namespace cricket
|
|
|