Revert of Make P2PTransportChannel inherit from IceTransportInternal. (patchset #3 id:80001 of https://codereview.webrtc.org/2590063002/ )

Reason for revert:
Breaks Chromium WebRTC FYI bots:
https://build.chromium.org/p/chromium.webrtc.fyi/builders/Linux%20Builder/builds/12337
The error was masked by another breaking change that was committer earlier. This is the first build showing the error.

Original issue's description:
> Make P2PTransportChannel inherit from IceTransportInternal.
>
> Make P2PTransportChannel inherit from IceTransportInternal instead of
> TransportChannelImpl and TransportChannel, so that the DTLS-related methods can
> be separated from P2PTransportChannel.
>
> BUG=none
>
> Review-Url: https://codereview.webrtc.org/2590063002
> Cr-Commit-Position: refs/heads/master@{#15743}
> Committed: 12749d89d9

TBR=deadbeef@webrtc.org,zhihuang@webrtc.org
# Skipping CQ checks because original CL landed less than 1 days ago.
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=none

Review-Url: https://codereview.webrtc.org/2594343002
Cr-Commit-Position: refs/heads/master@{#15751}
This commit is contained in:
kjellander 2016-12-21 23:52:00 -08:00 committed by Commit bot
parent d943c48454
commit c37ad499da
15 changed files with 202 additions and 421 deletions

View File

@ -50,10 +50,11 @@ static bool IsRtpPacket(const char* data, size_t len) {
return (len >= kMinRtpPacketLen && (u[0] & 0xC0) == 0x80);
}
StreamInterfaceChannel::StreamInterfaceChannel(IceTransportInternal* channel)
StreamInterfaceChannel::StreamInterfaceChannel(TransportChannel* channel)
: channel_(channel),
state_(rtc::SS_OPEN),
packets_(kMaxPendingPackets, kMaxDtlsPacketLen) {}
packets_(kMaxPendingPackets, kMaxDtlsPacketLen) {
}
rtc::StreamResult StreamInterfaceChannel::Read(void* buffer,
size_t buffer_len,
@ -102,7 +103,7 @@ void StreamInterfaceChannel::Close() {
}
DtlsTransportChannelWrapper::DtlsTransportChannelWrapper(
IceTransportInternal* channel)
TransportChannelImpl* channel)
: TransportChannelImpl(channel->transport_name(), channel->component()),
network_thread_(rtc::Thread::Current()),
channel_(channel),
@ -683,39 +684,39 @@ bool DtlsTransportChannelWrapper::HandleDtlsPacket(const char* data,
}
void DtlsTransportChannelWrapper::OnGatheringState(
IceTransportInternal* channel) {
TransportChannelImpl* channel) {
ASSERT(channel == channel_);
SignalGatheringState(this);
}
void DtlsTransportChannelWrapper::OnCandidateGathered(
IceTransportInternal* channel,
TransportChannelImpl* channel,
const Candidate& c) {
ASSERT(channel == channel_);
SignalCandidateGathered(this, c);
}
void DtlsTransportChannelWrapper::OnCandidatesRemoved(
IceTransportInternal* channel,
TransportChannelImpl* channel,
const Candidates& candidates) {
ASSERT(channel == channel_);
SignalCandidatesRemoved(this, candidates);
}
void DtlsTransportChannelWrapper::OnRoleConflict(
IceTransportInternal* channel) {
TransportChannelImpl* channel) {
ASSERT(channel == channel_);
SignalRoleConflict(this);
}
void DtlsTransportChannelWrapper::OnRouteChange(IceTransportInternal* channel,
const Candidate& candidate) {
void DtlsTransportChannelWrapper::OnRouteChange(
TransportChannel* channel, const Candidate& candidate) {
ASSERT(channel == channel_);
SignalRouteChange(this, candidate);
}
void DtlsTransportChannelWrapper::OnSelectedCandidatePairChanged(
IceTransportInternal* channel,
TransportChannel* channel,
CandidatePairInterface* selected_candidate_pair,
int last_sent_packet_id,
bool ready_to_send) {
@ -725,7 +726,7 @@ void DtlsTransportChannelWrapper::OnSelectedCandidatePairChanged(
}
void DtlsTransportChannelWrapper::OnChannelStateChanged(
IceTransportInternal* channel) {
TransportChannelImpl* channel) {
ASSERT(channel == channel_);
SignalStateChanged(this);
}

View File

@ -15,13 +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/icetransportinternal.h"
#include "webrtc/p2p/base/transportchannelimpl.h"
namespace rtc {
class PacketTransportInterface;
@ -29,11 +28,11 @@ class PacketTransportInterface;
namespace cricket {
// A bridge between a packet-oriented/transport-type interface on
// A bridge between a packet-oriented/channel-type interface on
// the bottom and a StreamInterface on the top.
class StreamInterfaceChannel : public rtc::StreamInterface {
public:
explicit StreamInterfaceChannel(IceTransportInternal* channel);
explicit StreamInterfaceChannel(TransportChannel* channel);
// Push in a packet; this gets pulled out from Read().
bool OnPacketReceived(const char* data, size_t size);
@ -51,7 +50,7 @@ class StreamInterfaceChannel : public rtc::StreamInterface {
int* error) override;
private:
IceTransportInternal* channel_; // owned by DtlsTransportChannelWrapper
TransportChannel* channel_; // owned by DtlsTransportChannelWrapper
rtc::StreamState state_;
rtc::BufferQueue packets_;
@ -89,7 +88,7 @@ class DtlsTransportChannelWrapper : public TransportChannelImpl {
public:
// The parameters here are:
// channel -- the TransportChannel we are wrapping
explicit DtlsTransportChannelWrapper(IceTransportInternal* channel);
explicit DtlsTransportChannelWrapper(TransportChannelImpl* channel);
~DtlsTransportChannelWrapper() override;
void SetIceRole(IceRole role) override { channel_->SetIceRole(role); }
@ -162,7 +161,9 @@ class DtlsTransportChannelWrapper : public TransportChannelImpl {
}
// TransportChannelImpl calls.
IceTransportState GetState() const override { return channel_->GetState(); }
TransportChannelState GetState() const override {
return channel_->GetState();
}
void SetIceTiebreaker(uint64_t tiebreaker) override {
channel_->SetIceTiebreaker(tiebreaker);
}
@ -198,7 +199,7 @@ class DtlsTransportChannelWrapper : public TransportChannelImpl {
}
// Needed by DtlsTransport.
IceTransportInternal* channel() { return channel_; }
TransportChannelImpl* 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
@ -220,23 +221,23 @@ class DtlsTransportChannelWrapper : public TransportChannelImpl {
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,
void OnGatheringState(TransportChannelImpl* channel);
void OnCandidateGathered(TransportChannelImpl* channel, const Candidate& c);
void OnCandidatesRemoved(TransportChannelImpl* channel,
const Candidates& candidates);
void OnRoleConflict(IceTransportInternal* channel);
void OnRouteChange(IceTransportInternal* channel, const Candidate& candidate);
void OnRoleConflict(TransportChannelImpl* channel);
void OnRouteChange(TransportChannel* channel, const Candidate& candidate);
void OnSelectedCandidatePairChanged(
IceTransportInternal* channel,
TransportChannel* channel,
CandidatePairInterface* selected_candidate_pair,
int last_sent_packet_id,
bool ready_to_send);
void OnChannelStateChanged(IceTransportInternal* channel);
void OnChannelStateChanged(TransportChannelImpl* channel);
void OnDtlsHandshakeError(rtc::SSLHandshakeError error);
rtc::Thread* network_thread_; // Everything should occur on this thread.
// Underlying channel, not owned by this class.
IceTransportInternal* const channel_;
TransportChannelImpl* const channel_;
std::unique_ptr<rtc::SSLStreamAdapter> dtls_; // The DTLS stream
StreamInterfaceChannel* downward_; // Wrapper for channel_, owned by dtls_.
std::vector<int> srtp_ciphers_; // SRTP ciphers to use with DTLS.

View File

@ -88,8 +88,8 @@ class DtlsTestClient : public sigslot::has_slots<> {
transport_.reset(
new cricket::JsepTransport("dtls content name", certificate_));
for (int i = 0; i < count; ++i) {
cricket::FakeIceTransport* fake_ice_channel =
new cricket::FakeIceTransport(transport_->mid(), i);
cricket::FakeTransportChannel* fake_ice_channel =
new cricket::FakeTransportChannel(transport_->mid(), i);
fake_ice_channel->SetAsync(true);
fake_ice_channel->SetAsyncDelay(async_delay_ms);
// Hook the raw packets so that we can verify they are encrypted.
@ -111,14 +111,14 @@ class DtlsTestClient : public sigslot::has_slots<> {
channels_.push_back(
std::unique_ptr<cricket::DtlsTransportChannelWrapper>(channel));
fake_channels_.push_back(
std::unique_ptr<cricket::FakeIceTransport>(fake_ice_channel));
std::unique_ptr<cricket::FakeTransportChannel>(fake_ice_channel));
transport_->AddChannel(channel, i);
}
}
cricket::JsepTransport* transport() { return transport_.get(); }
cricket::FakeIceTransport* GetFakeChannel(int component) {
cricket::FakeTransportChannel* GetFakeChannel(int component) {
for (const auto& ch : fake_channels_) {
if (ch->component() == component) {
return ch.get();
@ -434,7 +434,7 @@ class DtlsTestClient : public sigslot::has_slots<> {
private:
std::string name_;
rtc::scoped_refptr<rtc::RTCCertificate> certificate_;
std::vector<std::unique_ptr<cricket::FakeIceTransport>> fake_channels_;
std::vector<std::unique_ptr<cricket::FakeTransportChannel>> fake_channels_;
std::vector<std::unique_ptr<cricket::DtlsTransportChannelWrapper>> channels_;
std::unique_ptr<cricket::JsepTransport> transport_;
size_t packet_size_ = 0u;
@ -639,8 +639,8 @@ class DtlsTransportChannelTest : public DtlsTransportChannelTestBase,
// Test that transport negotiation of ICE, no DTLS works properly.
TEST_F(DtlsTransportChannelTest, TestChannelSetupIce) {
Negotiate();
cricket::FakeIceTransport* channel1 = client1_.GetFakeChannel(0);
cricket::FakeIceTransport* channel2 = client2_.GetFakeChannel(0);
cricket::FakeTransportChannel* channel1 = client1_.GetFakeChannel(0);
cricket::FakeTransportChannel* channel2 = client2_.GetFakeChannel(0);
ASSERT_TRUE(channel1 != NULL);
ASSERT_TRUE(channel2 != NULL);
EXPECT_EQ(cricket::ICEROLE_CONTROLLING, channel1->GetIceRole());

View File

@ -16,6 +16,10 @@
#include <string>
#include <vector>
#include "webrtc/p2p/base/candidatepairinterface.h"
#include "webrtc/p2p/base/transportchannel.h"
#include "webrtc/p2p/base/transportcontroller.h"
#include "webrtc/p2p/base/transportchannelimpl.h"
#include "webrtc/base/bind.h"
#include "webrtc/base/buffer.h"
#include "webrtc/base/fakesslidentity.h"
@ -23,11 +27,6 @@
#include "webrtc/base/sigslot.h"
#include "webrtc/base/sslfingerprint.h"
#include "webrtc/base/thread.h"
#include "webrtc/p2p/base/candidatepairinterface.h"
#include "webrtc/p2p/base/icetransportinternal.h"
#include "webrtc/p2p/base/transportchannel.h"
#include "webrtc/p2p/base/transportchannelimpl.h"
#include "webrtc/p2p/base/transportcontroller.h"
#ifdef HAVE_QUIC
#include "webrtc/p2p/quic/quictransport.h"
@ -42,227 +41,6 @@ struct PacketMessageData : public rtc::MessageData {
};
} // namespace
class FakeIceTransport : public IceTransportInternal,
public rtc::MessageHandler {
public:
explicit FakeIceTransport(const std::string& name, int component)
: name_(name), component_(component) {}
~FakeIceTransport() { Reset(); }
const std::string& transport_name() const override { return name_; }
int component() const override { return component_; }
uint64_t IceTiebreaker() const { return tiebreaker_; }
IceMode remote_ice_mode() const { return remote_ice_mode_; }
const std::string& ice_ufrag() const { return ice_ufrag_; }
const std::string& ice_pwd() const { return ice_pwd_; }
const std::string& remote_ice_ufrag() const { return remote_ice_ufrag_; }
const std::string& remote_ice_pwd() const { return remote_ice_pwd_; }
// If async, will send packets by "Post"-ing to message queue instead of
// synchronously "Send"-ing.
void SetAsync(bool async) { async_ = async; }
void SetAsyncDelay(int delay_ms) { async_delay_ms_ = delay_ms; }
IceTransportState GetState() const override {
if (connection_count_ == 0) {
return had_connection_ ? IceTransportState::STATE_FAILED
: IceTransportState::STATE_INIT;
}
if (connection_count_ == 1) {
return IceTransportState::STATE_COMPLETED;
}
return IceTransportState::STATE_CONNECTING;
}
void SetIceRole(IceRole role) override { role_ = role; }
IceRole GetIceRole() const override { return role_; }
void SetIceTiebreaker(uint64_t tiebreaker) override {
tiebreaker_ = tiebreaker;
}
void SetIceParameters(const IceParameters& ice_params) override {
ice_ufrag_ = ice_params.ufrag;
ice_pwd_ = ice_params.pwd;
}
void SetRemoteIceParameters(const IceParameters& params) override {
remote_ice_ufrag_ = params.ufrag;
remote_ice_pwd_ = params.pwd;
}
void SetRemoteIceMode(IceMode mode) override { remote_ice_mode_ = mode; }
void MaybeStartGathering() override {
if (gathering_state_ == kIceGatheringNew) {
gathering_state_ = kIceGatheringGathering;
SignalGatheringState(this);
}
}
IceGatheringState gathering_state() const override {
return gathering_state_;
}
void Reset() {
if (state_ != STATE_INIT) {
state_ = STATE_INIT;
if (dest_) {
dest_->state_ = STATE_INIT;
dest_->dest_ = nullptr;
dest_ = nullptr;
}
}
}
void SetWritable(bool writable) { set_writable(writable); }
void set_writable(bool writable) {
if (writable_ == writable) {
return;
}
LOG(INFO) << "set_writable from:" << writable_ << " to " << writable;
writable_ = writable;
if (writable_) {
SignalReadyToSend(this);
}
SignalWritableState(this);
}
bool writable() const override { return writable_; }
// Simulates the two transports connecting to each other.
// If |asymmetric| is true this method only affects this FakeIceTransport.
// If false, it affects |dest| as well.
void SetDestination(FakeIceTransport* dest, bool asymmetric = false) {
if (state_ == STATE_INIT && dest) {
// This simulates the delivery of candidates.
dest_ = dest;
state_ = STATE_CONNECTED;
set_writable(true);
if (!asymmetric) {
dest->SetDestination(this, true);
}
} else if (state_ == STATE_CONNECTED && !dest) {
// Simulates loss of connectivity, by asymmetrically forgetting dest_.
dest_ = nullptr;
state_ = STATE_INIT;
set_writable(false);
}
}
void SetConnectionCount(size_t connection_count) {
size_t old_connection_count = connection_count_;
connection_count_ = connection_count;
if (connection_count)
had_connection_ = true;
// In this fake transport channel, |connection_count_| determines the
// transport channel state.
if (connection_count_ < old_connection_count)
SignalStateChanged(this);
}
void SetCandidatesGatheringComplete() {
if (gathering_state_ != kIceGatheringComplete) {
gathering_state_ = kIceGatheringComplete;
SignalGatheringState(this);
}
}
void SetReceiving(bool receiving) { set_receiving(receiving); }
void set_receiving(bool receiving) {
if (receiving_ == receiving) {
return;
}
receiving_ = receiving;
SignalReceivingState(this);
}
bool receiving() const override { return receiving_; }
void SetIceConfig(const IceConfig& config) override { ice_config_ = config; }
int receiving_timeout() const { return ice_config_.receiving_timeout; }
bool gather_continually() const { return ice_config_.gather_continually(); }
int SendPacket(const char* data,
size_t len,
const rtc::PacketOptions& options,
int flags) override {
if (state_ != STATE_CONNECTED) {
return -1;
}
if (flags != PF_SRTP_BYPASS && flags != 0) {
return -1;
}
PacketMessageData* packet = new PacketMessageData(data, len);
if (async_) {
if (async_delay_ms_) {
rtc::Thread::Current()->PostDelayed(RTC_FROM_HERE, async_delay_ms_,
this, 0, packet);
} else {
rtc::Thread::Current()->Post(RTC_FROM_HERE, this, 0, packet);
}
} else {
rtc::Thread::Current()->Send(RTC_FROM_HERE, this, 0, packet);
}
rtc::SentPacket sent_packet(options.packet_id, rtc::TimeMillis());
SignalSentPacket(this, sent_packet);
return static_cast<int>(len);
}
int SetOption(rtc::Socket::Option opt, int value) override { return true; }
bool GetOption(rtc::Socket::Option opt, int* value) override { return true; }
int GetError() override { return 0; }
void AddRemoteCandidate(const Candidate& candidate) override {
remote_candidates_.push_back(candidate);
}
void RemoveRemoteCandidate(const Candidate& candidate) override {}
const Candidates& remote_candidates() const { return remote_candidates_; }
void OnMessage(rtc::Message* msg) override {
PacketMessageData* data = static_cast<PacketMessageData*>(msg->pdata);
dest_->SignalReadPacket(dest_, data->packet.data<char>(),
data->packet.size(), rtc::CreatePacketTime(0), 0);
delete data;
}
bool GetStats(ConnectionInfos* infos) override {
ConnectionInfo info;
infos->clear();
infos->push_back(info);
return true;
}
void SetMetricsObserver(webrtc::MetricsObserverInterface* observer) override {
}
private:
std::string name_;
int component_;
enum State { STATE_INIT, STATE_CONNECTED };
FakeIceTransport* dest_ = nullptr;
State state_ = STATE_INIT;
bool async_ = false;
int async_delay_ms_ = 0;
Candidates remote_candidates_;
IceConfig ice_config_;
IceRole role_ = ICEROLE_UNKNOWN;
uint64_t tiebreaker_ = 0;
std::string ice_ufrag_;
std::string ice_pwd_;
std::string remote_ice_ufrag_;
std::string remote_ice_pwd_;
IceMode remote_ice_mode_ = ICEMODE_FULL;
size_t connection_count_ = 0;
IceGatheringState gathering_state_ = kIceGatheringNew;
bool had_connection_ = false;
bool writable_ = false;
bool receiving_ = false;
};
// Fake transport channel class, which can be passed to anything that needs a
// transport channel. Can be informed of another FakeTransportChannel via
// SetDestination.
@ -290,17 +68,17 @@ class FakeTransportChannel : public TransportChannelImpl,
void SetAsync(bool async) { async_ = async; }
void SetAsyncDelay(int delay_ms) { async_delay_ms_ = delay_ms; }
IceTransportState GetState() const override {
TransportChannelState GetState() const override {
if (connection_count_ == 0) {
return had_connection_ ? IceTransportState::STATE_FAILED
: IceTransportState::STATE_INIT;
return had_connection_ ? TransportChannelState::STATE_FAILED
: TransportChannelState::STATE_INIT;
}
if (connection_count_ == 1) {
return IceTransportState::STATE_COMPLETED;
return TransportChannelState::STATE_COMPLETED;
}
return IceTransportState::STATE_CONNECTING;
return TransportChannelState::STATE_CONNECTING;
}
void SetIceRole(IceRole role) override { role_ = role; }
@ -669,7 +447,7 @@ class FakeTransportController : public TransportController {
// The ICE channel is never actually used by TransportController directly,
// since (currently) the DTLS channel pretends to be both ICE + DTLS. This
// will change when we get rid of TransportChannelImpl.
IceTransportInternal* CreateIceTransportChannel_n(
TransportChannelImpl* CreateIceTransportChannel_n(
const std::string& transport_name,
int component) override {
return nullptr;
@ -678,7 +456,7 @@ class FakeTransportController : public TransportController {
TransportChannelImpl* CreateDtlsTransportChannel_n(
const std::string& transport_name,
int component,
IceTransportInternal*) override {
TransportChannelImpl*) override {
return new FakeTransportChannel(transport_name, component);
}

View File

@ -25,12 +25,11 @@ class MetricsObserverInterface;
namespace cricket {
// TODO(zhihuang): replace it with PeerConnectionInterface::IceConnectionState.
enum class IceTransportState {
enum class TransportState {
STATE_INIT,
STATE_CONNECTING, // Will enter this state once a connection is created
STATE_COMPLETED,
STATE_FAILED
STATE_FAILEDs
};
// TODO(zhihuang): Remove this once it's no longer used in
@ -45,9 +44,9 @@ enum IceProtocolType {
// the IceTransportInterface will be split from this class.
class IceTransportInternal : public rtc::PacketTransportInterface {
public:
virtual ~IceTransportInternal(){};
virtual ~IceTransportInternal();
virtual IceTransportState GetState() const = 0;
virtual TransportState GetState() const = 0;
virtual const std::string& transport_name() const = 0;
@ -96,9 +95,6 @@ class IceTransportInternal : public rtc::PacketTransportInterface {
virtual IceGatheringState gathering_state() const = 0;
// Returns the current stats for this connection.
virtual bool GetStats(ConnectionInfos* infos) = 0;
sigslot::signal1<IceTransportInternal*> SignalGatheringState;
// Handles sending and receiving of candidates.
@ -123,20 +119,11 @@ class IceTransportInternal : public rtc::PacketTransportInterface {
sigslot::signal4<IceTransportInternal*, CandidatePairInterface*, int, bool>
SignalSelectedCandidatePairChanged;
// Invoked when there is conflict in the ICE role between local and remote
// agents.
sigslot::signal1<IceTransportInternal*> SignalRoleConflict;
// Emitted whenever the transport state changed.
sigslot::signal1<IceTransportInternal*> SignalStateChanged;
// Invoked when the transport is being destroyed.
sigslot::signal1<IceTransportInternal*> SignalDestroyed;
// Debugging description of this transport.
std::string debug_name() const override {
return transport_name() + " " + std::to_string(component());
}
std::string ToString() const;
};
} // namespace cricket

View File

@ -17,15 +17,15 @@
#include <vector>
#include "webrtc/base/constructormagic.h"
#include "webrtc/base/messagequeue.h"
#include "webrtc/base/optional.h"
#include "webrtc/base/rtccertificate.h"
#include "webrtc/base/sigslot.h"
#include "webrtc/base/sslstreamadapter.h"
#include "webrtc/p2p/base/candidate.h"
#include "webrtc/p2p/base/p2pconstants.h"
#include "webrtc/p2p/base/sessiondescription.h"
#include "webrtc/p2p/base/transportinfo.h"
#include "webrtc/base/messagequeue.h"
#include "webrtc/base/rtccertificate.h"
#include "webrtc/base/sigslot.h"
#include "webrtc/base/sslstreamadapter.h"
namespace cricket {
@ -335,6 +335,8 @@ class JsepTransport : public sigslot::has_slots<> {
std::string* error_desc) const;
private:
TransportChannelImpl* GetChannel(int component);
// Negotiates the transport parameters based on the current local and remote
// transport description, such as the ICE role to use, and whether DTLS
// should be activated.

View File

@ -100,8 +100,7 @@ static constexpr int b_is_better = -1;
P2PTransportChannel::P2PTransportChannel(const std::string& transport_name,
int component,
PortAllocator* allocator)
: transport_name_(transport_name),
component_(component),
: TransportChannelImpl(transport_name, component),
allocator_(allocator),
network_thread_(rtc::Thread::Current()),
incoming_only_(false),
@ -272,15 +271,15 @@ void P2PTransportChannel::SetIceTiebreaker(uint64_t tiebreaker) {
tiebreaker_ = tiebreaker;
}
IceTransportState P2PTransportChannel::GetState() const {
TransportChannelState P2PTransportChannel::GetState() const {
return state_;
}
// A channel is considered ICE completed once there is at most one active
// connection per network and at least one active connection.
IceTransportState P2PTransportChannel::ComputeState() const {
TransportChannelState P2PTransportChannel::ComputeState() const {
if (!had_connection_) {
return IceTransportState::STATE_INIT;
return TransportChannelState::STATE_INIT;
}
std::vector<Connection*> active_connections;
@ -290,7 +289,7 @@ IceTransportState P2PTransportChannel::ComputeState() const {
}
}
if (active_connections.empty()) {
return IceTransportState::STATE_FAILED;
return TransportChannelState::STATE_FAILED;
}
std::set<rtc::Network*> networks;
@ -302,11 +301,11 @@ IceTransportState P2PTransportChannel::ComputeState() const {
LOG_J(LS_VERBOSE, this) << "Ice not completed yet for this channel as "
<< network->ToString()
<< " has more than 1 connection.";
return IceTransportState::STATE_CONNECTING;
return TransportChannelState::STATE_CONNECTING;
}
}
return IceTransportState::STATE_COMPLETED;
return TransportChannelState::STATE_COMPLETED;
}
void P2PTransportChannel::SetIceParameters(const IceParameters& ice_params) {
@ -1400,38 +1399,33 @@ void P2PTransportChannel::SwitchSelectedConnection(Connection* conn) {
// change, it should be called after all the connection states have changed. For
// example, we call this at the end of SortConnectionsAndUpdateState.
void P2PTransportChannel::UpdateState() {
IceTransportState state = ComputeState();
TransportChannelState state = ComputeState();
if (state_ != state) {
LOG_J(LS_INFO, this) << "Transport channel state changed from "
<< static_cast<int>(state_) << " to "
<< static_cast<int>(state);
LOG_J(LS_INFO, this) << "Transport channel state changed from " << state_
<< " to " << state;
// Check that the requested transition is allowed. Note that
// P2PTransportChannel does not (yet) implement a direct mapping of the ICE
// states from the standard; the difference is covered by
// TransportController and PeerConnection.
switch (state_) {
case IceTransportState::STATE_INIT:
case STATE_INIT:
// TODO(deadbeef): Once we implement end-of-candidates signaling,
// we shouldn't go from INIT to COMPLETED.
RTC_DCHECK(state == IceTransportState::STATE_CONNECTING ||
state == IceTransportState::STATE_COMPLETED);
RTC_DCHECK(state == STATE_CONNECTING || state == STATE_COMPLETED);
break;
case IceTransportState::STATE_CONNECTING:
RTC_DCHECK(state == IceTransportState::STATE_COMPLETED ||
state == IceTransportState::STATE_FAILED);
case STATE_CONNECTING:
RTC_DCHECK(state == STATE_COMPLETED || state == STATE_FAILED);
break;
case IceTransportState::STATE_COMPLETED:
case STATE_COMPLETED:
// TODO(deadbeef): Once we implement end-of-candidates signaling,
// we shouldn't go from COMPLETED to CONNECTING.
// Though we *can* go from COMPlETED to FAILED, if consent expires.
RTC_DCHECK(state == IceTransportState::STATE_CONNECTING ||
state == IceTransportState::STATE_FAILED);
RTC_DCHECK(state == STATE_CONNECTING || state == STATE_FAILED);
break;
case IceTransportState::STATE_FAILED:
case STATE_FAILED:
// TODO(deadbeef): Once we implement end-of-candidates signaling,
// we shouldn't go from FAILED to CONNECTING or COMPLETED.
RTC_DCHECK(state == IceTransportState::STATE_CONNECTING ||
state == IceTransportState::STATE_COMPLETED);
RTC_DCHECK(state == STATE_CONNECTING || state == STATE_COMPLETED);
break;
default:
RTC_DCHECK(false);
@ -1547,8 +1541,8 @@ void P2PTransportChannel::OnCheckAndPing() {
// A connection is considered a backup connection if the channel state
// is completed, the connection is not the selected connection and it is active.
bool P2PTransportChannel::IsBackupConnection(const Connection* conn) const {
return state_ == IceTransportState::STATE_COMPLETED &&
conn != selected_connection_ && conn->active();
return state_ == STATE_COMPLETED && conn != selected_connection_ &&
conn->active();
}
// Is the connection in a state for us to even consider pinging the other side?
@ -2028,25 +2022,4 @@ Connection* P2PTransportChannel::MorePingable(Connection* conn1,
}));
}
void P2PTransportChannel::set_writable(bool writable) {
if (writable_ == writable) {
return;
}
LOG_J(LS_VERBOSE, this) << "set_writable from:" << writable_ << " to "
<< writable;
writable_ = writable;
if (writable_) {
SignalReadyToSend(this);
}
SignalWritableState(this);
}
void P2PTransportChannel::set_receiving(bool receiving) {
if (receiving_ == receiving) {
return;
}
receiving_ = receiving;
SignalReceivingState(this);
}
} // namespace cricket

View File

@ -26,14 +26,14 @@
#include <string>
#include <vector>
#include "webrtc/base/asyncpacketsocket.h"
#include "webrtc/base/constructormagic.h"
#include "webrtc/base/sigslot.h"
#include "webrtc/p2p/base/candidate.h"
#include "webrtc/p2p/base/candidatepairinterface.h"
#include "webrtc/p2p/base/icetransportinternal.h"
#include "webrtc/p2p/base/portallocator.h"
#include "webrtc/p2p/base/portinterface.h"
#include "webrtc/p2p/base/transportchannelimpl.h"
#include "webrtc/base/asyncpacketsocket.h"
#include "webrtc/base/sigslot.h"
namespace cricket {
@ -60,7 +60,7 @@ class RemoteCandidate : public Candidate {
// P2PTransportChannel manages the candidates and connection process to keep
// two P2P clients connected to each other.
class P2PTransportChannel : public IceTransportInternal,
class P2PTransportChannel : public TransportChannelImpl,
public rtc::MessageHandler {
public:
P2PTransportChannel(const std::string& transport_name,
@ -69,11 +69,7 @@ class P2PTransportChannel : public IceTransportInternal,
virtual ~P2PTransportChannel();
// From TransportChannelImpl:
IceTransportState GetState() const override;
const std::string& transport_name() const override { return transport_name_; }
int component() const override { return component_; }
bool writable() const override { return writable_; }
bool receiving() const override { return receiving_; }
TransportChannelState GetState() const override;
void SetIceRole(IceRole role) override;
IceRole GetIceRole() const override { return ice_role_; }
void SetIceTiebreaker(uint64_t tiebreaker) override;
@ -122,6 +118,57 @@ class P2PTransportChannel : public IceTransportInternal,
IceMode remote_ice_mode() const { return remote_ice_mode_; }
// DTLS methods.
bool IsDtlsActive() const override { return false; }
// Default implementation.
bool GetSslRole(rtc::SSLRole* role) const override { return false; }
bool SetSslRole(rtc::SSLRole role) override { return false; }
// Set up the ciphers to use for DTLS-SRTP.
bool SetSrtpCryptoSuites(const std::vector<int>& ciphers) override {
return false;
}
// Find out which DTLS-SRTP cipher was negotiated.
bool GetSrtpCryptoSuite(int* cipher) override { return false; }
// Find out which DTLS cipher was negotiated.
bool GetSslCipherSuite(int* cipher) override { return false; }
// Returns null because the channel is not encrypted by default.
rtc::scoped_refptr<rtc::RTCCertificate> GetLocalCertificate() const override {
return nullptr;
}
std::unique_ptr<rtc::SSLCertificate> GetRemoteSSLCertificate()
const override {
return nullptr;
}
// Allows key material to be extracted for external encryption.
bool ExportKeyingMaterial(const std::string& label,
const uint8_t* context,
size_t context_len,
bool use_context,
uint8_t* result,
size_t result_len) override {
return false;
}
bool SetLocalCertificate(
const rtc::scoped_refptr<rtc::RTCCertificate>& certificate) override {
return false;
}
// Set DTLS Remote fingerprint. Must be after local identity set.
bool SetRemoteFingerprint(const std::string& digest_alg,
const uint8_t* digest,
size_t digest_len) override {
return false;
}
void PruneAllPorts();
int receiving_timeout() const { return config_.receiving_timeout; }
int check_receiving_interval() const { return check_receiving_interval_; }
@ -146,15 +193,6 @@ class P2PTransportChannel : public IceTransportInternal,
return remote_candidates_;
}
std::string ToString() const {
const char RECEIVING_ABBREV[2] = {'_', 'R'};
const char WRITABLE_ABBREV[2] = {'_', 'W'};
std::stringstream ss;
ss << "Channel[" << transport_name_ << "|" << component_ << "|"
<< RECEIVING_ABBREV[receiving_] << WRITABLE_ABBREV[writable_] << "]";
return ss.str();
}
private:
rtc::Thread* thread() const { return network_thread_; }
bool IsGettingPorts() { return allocator_session()->IsGettingPorts(); }
@ -201,7 +239,7 @@ class P2PTransportChannel : public IceTransportInternal,
void UpdateState();
void HandleAllTimedOut();
void MaybeStopPortAllocatorSessions();
IceTransportState ComputeState() const;
TransportChannelState ComputeState() const;
Connection* GetBestConnectionOnNetwork(rtc::Network* network) const;
bool CreateConnections(const Candidate& remote_candidate,
@ -309,13 +347,6 @@ class P2PTransportChannel : public IceTransportInternal,
: static_cast<uint32_t>(remote_ice_parameters_.size() - 1);
}
// Sets the writable state, signaling if necessary.
void set_writable(bool writable);
// Sets the receiving state, signaling if necessary.
void set_receiving(bool receiving);
std::string transport_name_;
int component_;
PortAllocator* allocator_;
rtc::Thread* network_thread_;
bool incoming_only_;
@ -356,15 +387,13 @@ class P2PTransportChannel : public IceTransportInternal,
int check_receiving_interval_;
int64_t last_ping_sent_ms_ = 0;
int weak_ping_interval_ = WEAK_PING_INTERVAL;
IceTransportState state_ = IceTransportState::STATE_INIT;
TransportChannelState state_ = TransportChannelState::STATE_INIT;
IceConfig config_;
int last_sent_packet_id_ = -1; // -1 indicates no packet was sent before.
bool started_pinging_ = false;
// The value put in the "nomination" attribute for the next nominated
// connection. A zero-value indicates the connection will not be nominated.
uint32_t nomination_ = 0;
bool receiving_ = false;
bool writable_ = false;
webrtc::MetricsObserverInterface* metrics_observer_ = nullptr;

View File

@ -34,7 +34,6 @@
#include "webrtc/base/ssladapter.h"
#include "webrtc/base/thread.h"
#include "webrtc/base/virtualsocketserver.h"
#include "webrtc/p2p/base/icetransportinternal.h"
namespace {
@ -272,11 +271,11 @@ class P2PTransportChannelTestBase : public testing::Test,
};
struct CandidatesData : public rtc::MessageData {
CandidatesData(IceTransportInternal* ch, const Candidate& c)
CandidatesData(TransportChannel* ch, const Candidate& c)
: channel(ch), candidates(1, c) {}
CandidatesData(IceTransportInternal* ch, const std::vector<Candidate>& cc)
CandidatesData(TransportChannel* ch, const std::vector<Candidate>& cc)
: channel(ch), candidates(cc) {}
IceTransportInternal* channel;
TransportChannel* channel;
Candidates candidates;
};
@ -686,7 +685,7 @@ class P2PTransportChannelTestBase : public testing::Test,
}
// We pass the candidates directly to the other side.
void OnCandidateGathered(IceTransportInternal* ch, const Candidate& c) {
void OnCandidateGathered(TransportChannelImpl* ch, const Candidate& c) {
if (force_relay_ && c.type() != RELAY_PORT_TYPE)
return;
@ -699,7 +698,7 @@ class P2PTransportChannelTestBase : public testing::Test,
}
}
void OnSelectedCandidatePairChanged(
IceTransportInternal* transport_channel,
TransportChannel* transport_channel,
CandidatePairInterface* selected_candidate_pair,
int last_sent_packet_id,
bool ready_to_send) {
@ -720,7 +719,7 @@ class P2PTransportChannelTestBase : public testing::Test,
GetEndpoint(endpoint)->save_candidates_ = true;
}
void OnCandidatesRemoved(IceTransportInternal* ch,
void OnCandidatesRemoved(TransportChannelImpl* ch,
const std::vector<Candidate>& candidates) {
// Candidate removals are not paused.
CandidatesData* candidates_data = new CandidatesData(ch, candidates);
@ -798,7 +797,7 @@ class P2PTransportChannelTestBase : public testing::Test,
packets.push_front(std::string(data, len));
}
void OnRoleConflict(IceTransportInternal* channel) {
void OnRoleConflict(TransportChannelImpl* channel) {
GetEndpoint(channel)->OnRoleConflict(true);
IceRole new_role = GetEndpoint(channel)->ice_role() == ICEROLE_CONTROLLING
? ICEROLE_CONTROLLED
@ -806,11 +805,11 @@ class P2PTransportChannelTestBase : public testing::Test,
channel->SetIceRole(new_role);
}
int SendData(IceTransportInternal* channel, const char* data, size_t len) {
int SendData(TransportChannel* channel, const char* data, size_t len) {
rtc::PacketOptions options;
return channel->SendPacket(data, len, options, 0);
}
bool CheckDataOnChannel(IceTransportInternal* channel,
bool CheckDataOnChannel(TransportChannel* channel,
const char* data,
int len) {
return GetChannelData(channel)->CheckData(data, len);
@ -834,7 +833,7 @@ class P2PTransportChannelTestBase : public testing::Test,
return NULL;
}
}
P2PTransportChannel* GetRemoteChannel(IceTransportInternal* ch) {
P2PTransportChannel* GetRemoteChannel(TransportChannel* ch) {
if (ch == ep1_ch1())
return ep2_ch1();
else if (ch == ep1_ch2())
@ -2657,8 +2656,7 @@ TEST_F(P2PTransportChannelMultihomedTest, TestPingBackupConnectionRate) {
CreateIceConfig(2000, GATHER_ONCE, backup_ping_interval));
// After the state becomes COMPLETED, the backup connection will be pinged
// once every |backup_ping_interval| milliseconds.
ASSERT_TRUE_WAIT(ep2_ch1()->GetState() == IceTransportState::STATE_COMPLETED,
1000);
ASSERT_TRUE_WAIT(ep2_ch1()->GetState() == STATE_COMPLETED, 1000);
const std::vector<Connection*>& connections = ep2_ch1()->connections();
ASSERT_EQ(2U, connections.size());
Connection* backup_conn = connections[1];
@ -2684,9 +2682,9 @@ TEST_F(P2PTransportChannelMultihomedTest, TestGetState) {
CreateChannels();
// Both transport channels will reach STATE_COMPLETED quickly.
EXPECT_EQ_SIMULATED_WAIT(IceTransportState::STATE_COMPLETED,
EXPECT_EQ_SIMULATED_WAIT(TransportChannelState::STATE_COMPLETED,
ep1_ch1()->GetState(), kShortTimeout, clock);
EXPECT_EQ_SIMULATED_WAIT(IceTransportState::STATE_COMPLETED,
EXPECT_EQ_SIMULATED_WAIT(TransportChannelState::STATE_COMPLETED,
ep2_ch1()->GetState(), kShortTimeout, clock);
}
@ -2768,13 +2766,13 @@ TEST_F(P2PTransportChannelMultihomedTest,
// backup connection created using this new interface.
AddAddress(0, cellular[0], "test_cellular0", rtc::ADAPTER_TYPE_CELLULAR);
EXPECT_TRUE_WAIT(
ep1_ch1()->GetState() == IceTransportState::STATE_COMPLETED &&
ep1_ch1()->GetState() == STATE_COMPLETED &&
(conn = GetConnectionWithLocalAddress(ep1_ch1(), cellular[0])) !=
nullptr &&
conn != ep1_ch1()->selected_connection() && conn->writable(),
kDefaultTimeout);
EXPECT_TRUE_WAIT(
ep2_ch1()->GetState() == IceTransportState::STATE_COMPLETED &&
ep2_ch1()->GetState() == STATE_COMPLETED &&
(conn = GetConnectionWithRemoteAddress(ep2_ch1(), cellular[0])) !=
nullptr &&
conn != ep2_ch1()->selected_connection() && conn->receiving(),
@ -2990,7 +2988,7 @@ class P2PTransportChannelPingTest : public testing::Test,
return conn;
}
int SendData(IceTransportInternal& channel,
int SendData(TransportChannel& channel,
const char* data,
size_t len,
int packet_id) {
@ -3024,7 +3022,7 @@ class P2PTransportChannelPingTest : public testing::Test,
}
void OnSelectedCandidatePairChanged(
IceTransportInternal* transport_channel,
TransportChannel* transport_channel,
CandidatePairInterface* selected_candidate_pair,
int last_sent_packet_id,
bool ready_to_send) {
@ -3058,7 +3056,7 @@ class P2PTransportChannelPingTest : public testing::Test,
void OnReadyToSend(rtc::PacketTransportInterface* transport) {
channel_ready_to_send_ = true;
}
void OnChannelStateChanged(IceTransportInternal* channel) {
void OnChannelStateChanged(TransportChannelImpl* channel) {
channel_state_ = channel->GetState();
}
@ -3068,7 +3066,7 @@ class P2PTransportChannelPingTest : public testing::Test,
int last_sent_packet_id() { return last_sent_packet_id_; }
bool channel_ready_to_send() { return channel_ready_to_send_; }
void reset_channel_ready_to_send() { channel_ready_to_send_ = false; }
IceTransportState channel_state() { return channel_state_; }
TransportChannelState channel_state() { return channel_state_; }
int reset_selected_candidate_pair_switches() {
int switches = selected_candidate_pair_switches_;
selected_candidate_pair_switches_ = 0;
@ -3083,7 +3081,7 @@ class P2PTransportChannelPingTest : public testing::Test,
int selected_candidate_pair_switches_ = 0;
int last_sent_packet_id_ = -1;
bool channel_ready_to_send_ = false;
IceTransportState channel_state_ = IceTransportState::STATE_INIT;
TransportChannelState channel_state_ = STATE_INIT;
};
TEST_F(P2PTransportChannelPingTest, TestTriggeredChecks) {
@ -3319,8 +3317,7 @@ TEST_F(P2PTransportChannelPingTest, TestSignalStateChanged) {
// Pruning the connection reduces the set of active connections and changes
// the channel state.
conn1->Prune();
EXPECT_EQ_WAIT(IceTransportState::STATE_FAILED, channel_state(),
kDefaultTimeout);
EXPECT_EQ_WAIT(STATE_FAILED, channel_state(), kDefaultTimeout);
}
// Test adding remote candidates with different ufrags. If a remote candidate
@ -3971,7 +3968,7 @@ TEST_F(P2PTransportChannelPingTest, TestGetState) {
P2PTransportChannel ch("test channel", 1, &pa);
PrepareChannel(&ch);
ch.MaybeStartGathering();
EXPECT_EQ(IceTransportState::STATE_INIT, ch.GetState());
EXPECT_EQ(TransportChannelState::STATE_INIT, ch.GetState());
ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "1.1.1.1", 1, 100));
ch.AddRemoteCandidate(CreateUdpCandidate(LOCAL_PORT_TYPE, "2.2.2.2", 2, 1));
Connection* conn1 = WaitForConnectionTo(&ch, "1.1.1.1", 1, &clock);
@ -3979,14 +3976,14 @@ TEST_F(P2PTransportChannelPingTest, TestGetState) {
ASSERT_TRUE(conn1 != nullptr);
ASSERT_TRUE(conn2 != nullptr);
// Now there are two connections, so the transport channel is connecting.
EXPECT_EQ(IceTransportState::STATE_CONNECTING, ch.GetState());
EXPECT_EQ(TransportChannelState::STATE_CONNECTING, ch.GetState());
// |conn1| becomes writable and receiving; it then should prune |conn2|.
conn1->ReceivedPingResponse(LOW_RTT, "id");
EXPECT_TRUE_SIMULATED_WAIT(conn2->pruned(), kShortTimeout, clock);
EXPECT_EQ(IceTransportState::STATE_COMPLETED, ch.GetState());
EXPECT_EQ(TransportChannelState::STATE_COMPLETED, ch.GetState());
conn1->Prune(); // All connections are pruned.
// Need to wait until the channel state is updated.
EXPECT_EQ_SIMULATED_WAIT(IceTransportState::STATE_FAILED, ch.GetState(),
EXPECT_EQ_SIMULATED_WAIT(TransportChannelState::STATE_FAILED, ch.GetState(),
kShortTimeout, clock);
}
@ -4021,7 +4018,7 @@ TEST_F(P2PTransportChannelPingTest, TestConnectionPrunedAgain) {
EXPECT_TRUE_SIMULATED_WAIT(!conn2->active(), kDefaultTimeout, clock);
// |conn2| should not send a ping yet.
EXPECT_EQ(Connection::STATE_WAITING, conn2->state());
EXPECT_EQ(IceTransportState::STATE_COMPLETED, ch.GetState());
EXPECT_EQ(TransportChannelState::STATE_COMPLETED, ch.GetState());
// Wait for |conn1| becoming not receiving.
EXPECT_TRUE_SIMULATED_WAIT(!conn1->receiving(), kMediumTimeout, clock);
// Make sure conn2 is not deleted.
@ -4032,14 +4029,14 @@ TEST_F(P2PTransportChannelPingTest, TestConnectionPrunedAgain) {
conn2->ReceivedPingResponse(LOW_RTT, "id");
EXPECT_EQ_SIMULATED_WAIT(conn2, ch.selected_connection(), kDefaultTimeout,
clock);
EXPECT_EQ(IceTransportState::STATE_CONNECTING, ch.GetState());
EXPECT_EQ(TransportChannelState::STATE_CONNECTING, ch.GetState());
// When |conn1| comes back again, |conn2| will be pruned again.
conn1->ReceivedPingResponse(LOW_RTT, "id");
EXPECT_EQ_SIMULATED_WAIT(conn1, ch.selected_connection(), kDefaultTimeout,
clock);
EXPECT_TRUE_SIMULATED_WAIT(!conn2->active(), kDefaultTimeout, clock);
EXPECT_EQ(IceTransportState::STATE_COMPLETED, ch.GetState());
EXPECT_EQ(TransportChannelState::STATE_COMPLETED, ch.GetState());
}
// Test that if all connections in a channel has timed out on writing, they

View File

@ -31,7 +31,7 @@ class PacketTransportInterface : public sigslot::has_slots<> {
virtual ~PacketTransportInterface() {}
// Identify the object for logging and debug purpose.
virtual std::string debug_name() const = 0;
virtual const std::string debug_name() const = 0;
// The transport has been established.
virtual bool writable() const = 0;

View File

@ -15,20 +15,19 @@
#include <string>
#include <vector>
#include "webrtc/base/constructormagic.h"
#include "webrtc/p2p/base/candidate.h"
#include "webrtc/p2p/base/candidatepairinterface.h"
#include "webrtc/p2p/base/packettransportinterface.h"
#include "webrtc/p2p/base/jseptransport.h"
#include "webrtc/p2p/base/transportdescription.h"
#include "webrtc/base/asyncpacketsocket.h"
#include "webrtc/base/basictypes.h"
#include "webrtc/base/constructormagic.h"
#include "webrtc/base/dscp.h"
#include "webrtc/base/sigslot.h"
#include "webrtc/base/socket.h"
#include "webrtc/base/sslidentity.h"
#include "webrtc/base/sslstreamadapter.h"
#include "webrtc/p2p/base/candidate.h"
#include "webrtc/p2p/base/candidatepairinterface.h"
#include "webrtc/p2p/base/jseptransport.h"
#include "webrtc/p2p/base/icetransportinternal.h"
#include "webrtc/p2p/base/packettransportinterface.h"
#include "webrtc/p2p/base/transportdescription.h"
namespace cricket {
@ -41,6 +40,14 @@ enum PacketFlags {
// crypto provided by the transport (e.g. DTLS)
};
// Used to indicate channel's connection state.
enum TransportChannelState {
STATE_INIT,
STATE_CONNECTING, // Will enter this state once a connection is created
STATE_COMPLETED,
STATE_FAILED
};
// A TransportChannel represents one logical stream of packets that are sent
// between the two sides of a session.
// TODO(deadbeef): This interface currently represents the unity of an ICE
@ -56,13 +63,13 @@ class TransportChannel : public rtc::PacketTransportInterface {
// TODO(guoweis) - Make this pure virtual once all subclasses of
// TransportChannel have this defined.
virtual IceTransportState GetState() const {
return IceTransportState::STATE_CONNECTING;
virtual TransportChannelState GetState() const {
return TransportChannelState::STATE_CONNECTING;
}
const std::string& transport_name() const { return transport_name_; }
int component() const { return component_; }
std::string debug_name() const override {
const std::string debug_name() const override {
return transport_name() + " " + std::to_string(component());
}

View File

@ -14,7 +14,6 @@
#include <string>
#include "webrtc/base/constructormagic.h"
#include "webrtc/p2p/base/icetransportinternal.h"
#include "webrtc/p2p/base/transportchannel.h"
namespace buzz { class XmlElement; }
@ -27,6 +26,12 @@ namespace cricket {
class Candidate;
// TODO(pthatcher): Remove this once it's no longer used in
// remoting/protocol/libjingle_transport_factory.cc
enum IceProtocolType {
ICEPROTO_RFC5245 // Standard RFC 5245 version of ICE.
};
// Base class for real implementations of TransportChannel. This includes some
// methods called only by Transport, which do not need to be exposed to the
// client.

View File

@ -47,7 +47,7 @@ class TransportController::ChannelPair {
// TODO(deadbeef): Change the types of |dtls| and |ice| to
// DtlsTransportChannelWrapper and P2PTransportChannelWrapper,
// once TransportChannelImpl is removed.
ChannelPair(TransportChannelImpl* dtls, IceTransportInternal* ice)
ChannelPair(TransportChannelImpl* dtls, TransportChannelImpl* ice)
: ice_(ice), dtls_(dtls) {}
// Currently, all ICE-related calls still go through this DTLS channel. But
@ -55,11 +55,11 @@ class TransportController::ChannelPair {
// channel interface no longer includes ICE-specific methods.
const TransportChannelImpl* dtls() const { return dtls_.get(); }
TransportChannelImpl* dtls() { return dtls_.get(); }
const IceTransportInternal* ice() const { return ice_.get(); }
IceTransportInternal* ice() { return ice_.get(); }
const TransportChannelImpl* ice() const { return ice_.get(); }
TransportChannelImpl* ice() { return ice_.get(); }
private:
std::unique_ptr<IceTransportInternal> ice_;
std::unique_ptr<TransportChannelImpl> ice_;
std::unique_ptr<TransportChannelImpl> dtls_;
RTC_DISALLOW_COPY_AND_ASSIGN(ChannelPair);
@ -243,7 +243,7 @@ TransportChannel* TransportController::CreateTransportChannel_n(
JsepTransport* transport = GetOrCreateJsepTransport(transport_name);
// Create DTLS channel wrapping ICE channel, and configure it.
IceTransportInternal* ice =
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
@ -341,7 +341,7 @@ TransportChannelImpl* TransportController::get_channel_for_testing(
return ch ? ch->dtls() : nullptr;
}
IceTransportInternal* TransportController::CreateIceTransportChannel_n(
TransportChannelImpl* TransportController::CreateIceTransportChannel_n(
const std::string& transport_name,
int component) {
return new P2PTransportChannel(transport_name, component, port_allocator_);
@ -350,7 +350,7 @@ IceTransportInternal* TransportController::CreateIceTransportChannel_n(
TransportChannelImpl* TransportController::CreateDtlsTransportChannel_n(
const std::string&,
int,
IceTransportInternal* ice) {
TransportChannelImpl* ice) {
DtlsTransportChannelWrapper* dtls = new DtlsTransportChannelWrapper(ice);
dtls->SetSslMaxProtocolVersion(ssl_max_version_);
return dtls;
@ -822,12 +822,13 @@ void TransportController::UpdateAggregateStates_n() {
bool all_done_gathering = !channels_.empty();
for (const auto& channel : channels_) {
any_receiving = any_receiving || channel->dtls()->receiving();
any_failed = any_failed ||
channel->dtls()->GetState() == IceTransportState::STATE_FAILED;
any_failed =
any_failed ||
channel->dtls()->GetState() == TransportChannelState::STATE_FAILED;
all_connected = all_connected && channel->dtls()->writable();
all_completed =
all_completed && channel->dtls()->writable() &&
channel->dtls()->GetState() == IceTransportState::STATE_COMPLETED &&
channel->dtls()->GetState() == TransportChannelState::STATE_COMPLETED &&
channel->dtls()->GetIceRole() == ICEROLE_CONTROLLING &&
channel->dtls()->gathering_state() == kIceGatheringComplete;
any_gathering =

View File

@ -164,13 +164,13 @@ class TransportController : public sigslot::has_slots<>,
// TODO(deadbeef): Get rid of these virtual methods. Used by
// FakeTransportController currently, but FakeTransportController shouldn't
// even be functioning by subclassing TransportController.
virtual IceTransportInternal* CreateIceTransportChannel_n(
virtual TransportChannelImpl* CreateIceTransportChannel_n(
const std::string& transport_name,
int component);
virtual TransportChannelImpl* CreateDtlsTransportChannel_n(
const std::string& transport_name,
int component,
IceTransportInternal* ice);
TransportChannelImpl* ice);
private:
void OnMessage(rtc::Message* pmsg) override;

View File

@ -35,7 +35,7 @@ class UdpTransportChannel : public rtc::PacketTransportInterface {
UdpTransportChannel(const std::string& transport_name, rtc::SocketServer* ss);
~UdpTransportChannel();
std::string debug_name() const override { return transport_name_; }
const std::string debug_name() const override { return transport_name_; }
bool receiving() const override {
// TODO(johan): Implement method and signal.