diff --git a/webrtc/p2p/base/dtlstransportchannel.cc b/webrtc/p2p/base/dtlstransportchannel.cc index de543d6483..0fa32c8b9e 100644 --- a/webrtc/p2p/base/dtlstransportchannel.cc +++ b/webrtc/p2p/base/dtlstransportchannel.cc @@ -14,6 +14,7 @@ #include "webrtc/p2p/base/dtlstransportchannel.h" #include "webrtc/p2p/base/common.h" +#include "webrtc/p2p/base/packettransportinterface.h" #include "webrtc/base/buffer.h" #include "webrtc/base/checks.h" #include "webrtc/base/dscp.h" @@ -437,9 +438,10 @@ bool DtlsTransportChannelWrapper::IsDtlsConnected() { // start the DTLS handshake // - Once the DTLS handshake completes, the state is that of the // impl again -void DtlsTransportChannelWrapper::OnWritableState(TransportChannel* channel) { +void DtlsTransportChannelWrapper::OnWritableState( + rtc::PacketTransportInterface* transport) { ASSERT(rtc::Thread::Current() == network_thread_); - ASSERT(channel == channel_); + RTC_DCHECK(transport == channel_); LOG_J(LS_VERBOSE, this) << "DTLSTransportChannelWrapper: channel writable state changed to " << channel_->writable(); @@ -471,7 +473,7 @@ void DtlsTransportChannelWrapper::OnWritableState(TransportChannel* channel) { void DtlsTransportChannelWrapper::OnReceivingState(TransportChannel* channel) { ASSERT(rtc::Thread::Current() == network_thread_); - ASSERT(channel == channel_); + RTC_DCHECK(channel == channel_); LOG_J(LS_VERBOSE, this) << "DTLSTransportChannelWrapper: channel receiving state changed to " << channel_->receiving(); @@ -482,10 +484,13 @@ void DtlsTransportChannelWrapper::OnReceivingState(TransportChannel* channel) { } void DtlsTransportChannelWrapper::OnReadPacket( - TransportChannel* channel, const char* data, size_t size, - const rtc::PacketTime& packet_time, int flags) { + rtc::PacketTransportInterface* transport, + const char* data, + size_t size, + const rtc::PacketTime& packet_time, + int flags) { ASSERT(rtc::Thread::Current() == network_thread_); - ASSERT(channel == channel_); + RTC_DCHECK(transport == channel_); ASSERT(flags == 0); if (!dtls_active_) { @@ -558,14 +563,15 @@ void DtlsTransportChannelWrapper::OnReadPacket( } void DtlsTransportChannelWrapper::OnSentPacket( - TransportChannel* channel, + rtc::PacketTransportInterface* transport, const rtc::SentPacket& sent_packet) { ASSERT(rtc::Thread::Current() == network_thread_); SignalSentPacket(this, sent_packet); } -void DtlsTransportChannelWrapper::OnReadyToSend(TransportChannel* channel) { +void DtlsTransportChannelWrapper::OnReadyToSend( + rtc::PacketTransportInterface* transport) { if (writable()) { SignalReadyToSend(this); } diff --git a/webrtc/p2p/base/dtlstransportchannel.h b/webrtc/p2p/base/dtlstransportchannel.h index 81802fd21d..aac89c9f9f 100644 --- a/webrtc/p2p/base/dtlstransportchannel.h +++ b/webrtc/p2p/base/dtlstransportchannel.h @@ -22,6 +22,10 @@ #include "webrtc/base/sslstreamadapter.h" #include "webrtc/base/stream.h" +namespace rtc { +class PacketTransportInterface; +} + namespace cricket { // A bridge between a packet-oriented/channel-type interface on @@ -203,12 +207,15 @@ class DtlsTransportChannelWrapper : public TransportChannelImpl { bool IsDtlsConnected(); private: - void OnWritableState(TransportChannel* channel); - void OnReadPacket(TransportChannel* channel, const char* data, size_t size, - const rtc::PacketTime& packet_time, int flags); - void OnSentPacket(TransportChannel* channel, + void OnWritableState(rtc::PacketTransportInterface* transport); + void OnReadPacket(rtc::PacketTransportInterface* transport, + const char* data, + size_t size, + const rtc::PacketTime& packet_time, + int flags); + void OnSentPacket(rtc::PacketTransportInterface* transport, const rtc::SentPacket& sent_packet); - void OnReadyToSend(TransportChannel* channel); + void OnReadyToSend(rtc::PacketTransportInterface* transport); void OnReceivingState(TransportChannel* channel); void OnDtlsEvent(rtc::StreamInterface* stream_, int sig, int err); bool SetupDtls(); diff --git a/webrtc/p2p/base/dtlstransportchannel_unittest.cc b/webrtc/p2p/base/dtlstransportchannel_unittest.cc index 0a6e254e8f..1d8802dd55 100644 --- a/webrtc/p2p/base/dtlstransportchannel_unittest.cc +++ b/webrtc/p2p/base/dtlstransportchannel_unittest.cc @@ -13,6 +13,7 @@ #include "webrtc/p2p/base/dtlstransport.h" #include "webrtc/p2p/base/faketransportcontroller.h" +#include "webrtc/p2p/base/packettransportinterface.h" #include "webrtc/base/common.h" #include "webrtc/base/dscp.h" #include "webrtc/base/gunit.h" @@ -364,13 +365,15 @@ class DtlsTestClient : public sigslot::has_slots<> { } // Transport channel callbacks - void OnTransportChannelWritableState(cricket::TransportChannel* channel) { - LOG(LS_INFO) << name_ << ": Channel '" << channel->component() + void OnTransportChannelWritableState( + rtc::PacketTransportInterface* transport) { + LOG(LS_INFO) << name_ << ": Channel '" << transport->debug_name() << "' is writable"; } - void OnTransportChannelReadPacket(cricket::TransportChannel* channel, - const char* data, size_t size, + void OnTransportChannelReadPacket(rtc::PacketTransportInterface* transport, + const char* data, + size_t size, const rtc::PacketTime& packet_time, int flags) { uint32_t packet_num = 0; @@ -382,7 +385,7 @@ class DtlsTestClient : public sigslot::has_slots<> { ASSERT_EQ(expected_flags, flags); } - void OnTransportChannelSentPacket(cricket::TransportChannel* channel, + void OnTransportChannelSentPacket(rtc::PacketTransportInterface* transport, const rtc::SentPacket& sent_packet) { sent_packet_ = sent_packet; } @@ -390,10 +393,12 @@ class DtlsTestClient : public sigslot::has_slots<> { rtc::SentPacket sent_packet() const { return sent_packet_; } // Hook into the raw packet stream to make sure DTLS packets are encrypted. - void OnFakeTransportChannelReadPacket(cricket::TransportChannel* channel, - const char* data, size_t size, - const rtc::PacketTime& time, - int flags) { + void OnFakeTransportChannelReadPacket( + rtc::PacketTransportInterface* transport, + const char* data, + size_t size, + const rtc::PacketTime& time, + int flags) { // Flags shouldn't be set on the underlying TransportChannel packets. ASSERT_EQ(0, flags); diff --git a/webrtc/p2p/base/p2ptransportchannel_unittest.cc b/webrtc/p2p/base/p2ptransportchannel_unittest.cc index cac6fd5829..79b51b1ef7 100644 --- a/webrtc/p2p/base/p2ptransportchannel_unittest.cc +++ b/webrtc/p2p/base/p2ptransportchannel_unittest.cc @@ -13,6 +13,7 @@ #include "webrtc/api/fakemetricsobserver.h" #include "webrtc/p2p/base/fakeportallocator.h" +#include "webrtc/p2p/base/packettransportinterface.h" #include "webrtc/p2p/base/p2ptransportchannel.h" #include "webrtc/p2p/base/testrelayserver.h" #include "webrtc/p2p/base/teststunserver.h" @@ -282,12 +283,13 @@ class P2PTransportChannelTestBase : public testing::Test, tiebreaker_(0), role_conflict_(false), save_candidates_(false) {} - bool HasChannel(TransportChannel* ch) { - return (ch == cd1_.ch_.get() || ch == cd2_.ch_.get()); + bool HasTransport(const rtc::PacketTransportInterface* transport) { + return (transport == cd1_.ch_.get() || transport == cd2_.ch_.get()); } - ChannelData* GetChannelData(TransportChannel* ch) { - if (!HasChannel(ch)) return NULL; - if (cd1_.ch_.get() == ch) + ChannelData* GetChannelData(rtc::PacketTransportInterface* transport) { + if (!HasTransport(transport)) + return NULL; + if (cd1_.ch_.get() == transport) return &cd1_; else return &cd2_; @@ -321,11 +323,11 @@ class P2PTransportChannelTestBase : public testing::Test, bool ready_to_send_ = false; }; - ChannelData* GetChannelData(TransportChannel* channel) { - if (ep1_.HasChannel(channel)) - return ep1_.GetChannelData(channel); + ChannelData* GetChannelData(rtc::PacketTransportInterface* transport) { + if (ep1_.HasTransport(transport)) + return ep1_.GetChannelData(transport); else - return ep2_.GetChannelData(channel); + return ep2_.GetChannelData(transport); } IceParameters IceParamsWithRenomination(const IceParameters& ice, @@ -676,8 +678,8 @@ class P2PTransportChannelTestBase : public testing::Test, TestSendRecv(clock); } - void OnReadyToSend(TransportChannel* ch) { - GetEndpoint(ch)->ready_to_send_ = true; + void OnReadyToSend(rtc::PacketTransportInterface* transport) { + GetEndpoint(transport)->ready_to_send_ = true; } // We pass the candidates directly to the other side. @@ -783,14 +785,16 @@ class P2PTransportChannelTestBase : public testing::Test, } } } - void OnReadPacket(TransportChannel* channel, + + void OnReadPacket(rtc::PacketTransportInterface* transport, const char* data, size_t len, const rtc::PacketTime& packet_time, int flags) { - std::list& packets = GetPacketList(channel); + std::list& packets = GetPacketList(transport); packets.push_front(std::string(data, len)); } + void OnRoleConflict(TransportChannelImpl* channel) { GetEndpoint(channel)->OnRoleConflict(true); IceRole new_role = GetEndpoint(channel)->ice_role() == ICEROLE_CONTROLLING @@ -818,10 +822,10 @@ class P2PTransportChannelTestBase : public testing::Test, ? &ch->selected_connection()->remote_candidate() : NULL; } - Endpoint* GetEndpoint(TransportChannel* ch) { - if (ep1_.HasChannel(ch)) { + Endpoint* GetEndpoint(rtc::PacketTransportInterface* transport) { + if (ep1_.HasTransport(transport)) { return &ep1_; - } else if (ep2_.HasChannel(ch)) { + } else if (ep2_.HasTransport(transport)) { return &ep2_; } else { return NULL; @@ -839,8 +843,9 @@ class P2PTransportChannelTestBase : public testing::Test, else return NULL; } - std::list& GetPacketList(TransportChannel* ch) { - return GetChannelData(ch)->ch_packets_; + std::list& GetPacketList( + rtc::PacketTransportInterface* transport) { + return GetChannelData(transport)->ch_packets_; } enum RemoteIceParameterSource { FROM_CANDIDATE, FROM_SETICEPARAMETERS }; @@ -2944,7 +2949,7 @@ class P2PTransportChannelPingTest : public testing::Test, conn->OnReadPacket(buf.Data(), buf.Length(), rtc::CreatePacketTime(0)); } - void OnReadyToSend(TransportChannel* channel) { + void OnReadyToSend(rtc::PacketTransportInterface* transport) { channel_ready_to_send_ = true; } void OnChannelStateChanged(TransportChannelImpl* channel) { diff --git a/webrtc/p2p/base/packettransportinterface.h b/webrtc/p2p/base/packettransportinterface.h index a18081cf72..c796c6c2fa 100644 --- a/webrtc/p2p/base/packettransportinterface.h +++ b/webrtc/p2p/base/packettransportinterface.h @@ -11,12 +11,78 @@ #ifndef WEBRTC_P2P_BASE_PACKETTRANSPORTINTERFACE_H_ #define WEBRTC_P2P_BASE_PACKETTRANSPORTINTERFACE_H_ +#include +#include + +#include "webrtc/base/sigslot.h" +#include "webrtc/base/socket.h" + namespace cricket { class TransportChannel; } namespace rtc { -typedef cricket::TransportChannel PacketTransportInterface; -} +struct PacketOptions; +struct PacketTime; +struct SentPacket; + +class PacketTransportInterface : public sigslot::has_slots<> { + public: + virtual ~PacketTransportInterface() {} + + // Identify the object for logging and debug purpose. + virtual const std::string debug_name() const = 0; + + // The transport has been established. + virtual bool writable() const = 0; + + // Attempts to send the given packet. + // The return value is < 0 on failure. The return value in failure case is not + // descriptive. Depending on failure cause and implementation details + // GetError() returns an descriptive errno.h error value. + // This mimics posix socket send() or sendto() behavior. + // TODO(johan): Reliable, meaningful, consistent error codes for all + // implementations would be nice. + // TODO(johan): Remove the default argument once channel code is updated. + virtual int SendPacket(const char* data, + size_t len, + const rtc::PacketOptions& options, + int flags = 0) = 0; + + // Sets a socket option. Note that not all options are + // supported by all transport types. + virtual int SetOption(rtc::Socket::Option opt, int value) = 0; + + // TODO(pthatcher): Once Chrome's MockPacketTransportInterface implements + // this, remove the default implementation. + virtual bool GetOption(rtc::Socket::Option opt, int* value) { return false; } + + // Returns the most recent error that occurred on this channel. + virtual int GetError() = 0; + + // Emitted when the writable state, represented by |writable()|, changes. + sigslot::signal1 SignalWritableState; + + // Emitted when the PacketTransportInterface is ready to send packets. "Ready + // to send" is more sensitive than the writable state; a transport may be + // writable, but temporarily not able to send packets. For example, the + // underlying transport's socket buffer may be full, as indicated by + // SendPacket's return code and/or GetError. + sigslot::signal1 SignalReadyToSend; + + // Signalled each time a packet is received on this channel. + sigslot::signal5 + SignalReadPacket; + + // Signalled each time a packet is sent on this channel. + sigslot::signal2 + SignalSentPacket; +}; + +} // namespace rtc #endif // WEBRTC_P2P_BASE_PACKETTRANSPORTINTERFACE_H_ diff --git a/webrtc/p2p/base/transportchannel.h b/webrtc/p2p/base/transportchannel.h index 9b0ac7bd5b..01270a5775 100644 --- a/webrtc/p2p/base/transportchannel.h +++ b/webrtc/p2p/base/transportchannel.h @@ -18,6 +18,7 @@ #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/transport.h" #include "webrtc/p2p/base/transportdescription.h" #include "webrtc/base/asyncpacketsocket.h" @@ -51,7 +52,7 @@ enum TransportChannelState { // between the two sides of a session. // TODO(deadbeef): This interface currently represents the unity of an ICE // transport and a DTLS transport. They need to be separated apart. -class TransportChannel : public sigslot::has_slots<> { +class TransportChannel : public rtc::PacketTransportInterface { public: TransportChannel(const std::string& transport_name, int component) : transport_name_(transport_name), @@ -68,36 +69,20 @@ class TransportChannel : public sigslot::has_slots<> { const std::string& transport_name() const { return transport_name_; } int component() const { return component_; } + const std::string debug_name() const override { + return transport_name() + " " + std::to_string(component()); + } // Returns the states of this channel. Each time one of these states changes, // a signal is raised. These states are aggregated by the TransportManager. - bool writable() const { return writable_; } + bool writable() const override { return writable_; } bool receiving() const { return receiving_; } DtlsTransportState dtls_state() const { return dtls_state_; } - sigslot::signal1 SignalWritableState; - // Emitted when the TransportChannel's ability to send has changed. - sigslot::signal1 SignalReadyToSend; sigslot::signal1 SignalReceivingState; // Emitted whenever DTLS-SRTP is setup which will require setting up a new // SRTP context. sigslot::signal2 SignalDtlsState; - // Attempts to send the given packet. The return value is < 0 on failure. - // TODO: Remove the default argument once channel code is updated. - virtual int SendPacket(const char* data, size_t len, - const rtc::PacketOptions& options, - int flags = 0) = 0; - - // Sets a socket option on this channel. Note that not all options are - // supported by all transport types. - virtual int SetOption(rtc::Socket::Option opt, int value) = 0; - // TODO(pthatcher): Once Chrome's MockTransportChannel implments - // this, remove the default implementation. - virtual bool GetOption(rtc::Socket::Option opt, int* value) { return false; } - - // Returns the most recent error that occurred on this channel. - virtual int GetError() = 0; - // Returns the current stats for this connection. virtual bool GetStats(ConnectionInfos* infos) = 0; @@ -139,13 +124,6 @@ class TransportChannel : public sigslot::has_slots<> { uint8_t* result, size_t result_len) = 0; - // Signalled each time a packet is received on this channel. - sigslot::signal5 SignalReadPacket; - - // Signalled each time a packet is sent on this channel. - sigslot::signal2 SignalSentPacket; - // Deprecated by SignalSelectedCandidatePairChanged // This signal occurs when there is a change in the way that packets are // being routed, i.e. to a different remote location. The candidate diff --git a/webrtc/p2p/base/transportcontroller.cc b/webrtc/p2p/base/transportcontroller.cc index 1dc7ca789a..9d5fb88b71 100644 --- a/webrtc/p2p/base/transportcontroller.cc +++ b/webrtc/p2p/base/transportcontroller.cc @@ -565,11 +565,11 @@ bool TransportController::GetStats_n(const std::string& transport_name, return transport->GetStats(stats); } -void TransportController::OnChannelWritableState_n(TransportChannel* channel) { +void TransportController::OnChannelWritableState_n( + rtc::PacketTransportInterface* transport) { RTC_DCHECK(network_thread_->IsCurrent()); - LOG(LS_INFO) << channel->transport_name() << " TransportChannel " - << channel->component() << " writability changed to " - << channel->writable() << "."; + LOG(LS_INFO) << " TransportChannel " << transport->debug_name() + << " writability changed to " << transport->writable() << "."; UpdateAggregateStates_n(); } diff --git a/webrtc/p2p/base/transportcontroller.h b/webrtc/p2p/base/transportcontroller.h index 5f3fccc868..86b9c1dc68 100644 --- a/webrtc/p2p/base/transportcontroller.h +++ b/webrtc/p2p/base/transportcontroller.h @@ -24,6 +24,7 @@ namespace rtc { class Thread; +class PacketTransportInterface; } namespace webrtc { class MetricsObserverInterface; @@ -204,7 +205,7 @@ class TransportController : public sigslot::has_slots<>, bool GetStats_n(const std::string& transport_name, TransportStats* stats); // Handlers for signals from Transport. - void OnChannelWritableState_n(TransportChannel* channel); + void OnChannelWritableState_n(rtc::PacketTransportInterface* transport); void OnChannelReceivingState_n(TransportChannel* channel); void OnChannelGatheringState_n(TransportChannelImpl* channel); void OnChannelCandidateGathered_n(TransportChannelImpl* channel, diff --git a/webrtc/pc/channel.cc b/webrtc/pc/channel.cc index f22bdc4ca4..d9eb9b6fac 100644 --- a/webrtc/pc/channel.cc +++ b/webrtc/pc/channel.cc @@ -24,6 +24,7 @@ #include "webrtc/base/trace_event.h" #include "webrtc/media/base/mediaconstants.h" #include "webrtc/media/base/rtputils.h" +#include "webrtc/p2p/base/packettransportinterface.h" #include "webrtc/p2p/base/transportchannel.h" #include "webrtc/pc/channelmanager.h" @@ -377,7 +378,7 @@ void BaseChannel::ConnectToTransportChannel(TransportChannel* tc) { RTC_DCHECK(network_thread_->IsCurrent()); tc->SignalWritableState.connect(this, &BaseChannel::OnWritableState); - tc->SignalReadPacket.connect(this, &BaseChannel::OnChannelRead); + tc->SignalReadPacket.connect(this, &BaseChannel::OnPacketRead); tc->SignalReadyToSend.connect(this, &BaseChannel::OnReadyToSend); tc->SignalDtlsState.connect(this, &BaseChannel::OnDtlsState); tc->SignalSelectedCandidatePairChanged.connect( @@ -527,32 +528,33 @@ bool BaseChannel::SetCryptoOptions(const rtc::CryptoOptions& crypto_options) { return true; } -void BaseChannel::OnWritableState(TransportChannel* channel) { - RTC_DCHECK(channel == transport_channel_ || - channel == rtcp_transport_channel_); +void BaseChannel::OnWritableState(rtc::PacketTransportInterface* transport) { + RTC_DCHECK(transport == transport_channel_ || + transport == rtcp_transport_channel_); RTC_DCHECK(network_thread_->IsCurrent()); UpdateWritableState_n(); } -void BaseChannel::OnChannelRead(TransportChannel* channel, - const char* data, size_t len, - const rtc::PacketTime& packet_time, - int flags) { - TRACE_EVENT0("webrtc", "BaseChannel::OnChannelRead"); - // OnChannelRead gets called from P2PSocket; now pass data to MediaEngine +void BaseChannel::OnPacketRead(rtc::PacketTransportInterface* transport, + const char* data, + size_t len, + const rtc::PacketTime& packet_time, + int flags) { + TRACE_EVENT0("webrtc", "BaseChannel::OnPacketRead"); + // OnPacketRead gets called from P2PSocket; now pass data to MediaEngine RTC_DCHECK(network_thread_->IsCurrent()); // When using RTCP multiplexing we might get RTCP packets on the RTP // transport. We feed RTP traffic into the demuxer to determine if it is RTCP. - bool rtcp = PacketIsRtcp(channel, data, len); + bool rtcp = PacketIsRtcp(transport, data, len); rtc::CopyOnWriteBuffer packet(data, len); HandlePacket(rtcp, &packet, packet_time); } -void BaseChannel::OnReadyToSend(TransportChannel* channel) { - RTC_DCHECK(channel == transport_channel_ || - channel == rtcp_transport_channel_); - SetTransportChannelReadyToSend(channel == rtcp_transport_channel_, true); +void BaseChannel::OnReadyToSend(rtc::PacketTransportInterface* transport) { + RTC_DCHECK(transport == transport_channel_ || + transport == rtcp_transport_channel_); + SetTransportChannelReadyToSend(transport == rtcp_transport_channel_, true); } void BaseChannel::OnDtlsState(TransportChannel* channel, @@ -611,9 +613,10 @@ void BaseChannel::SetTransportChannelReadyToSend(bool rtcp, bool ready) { Bind(&MediaChannel::OnReadyToSend, media_channel_, ready_to_send)); } -bool BaseChannel::PacketIsRtcp(const TransportChannel* channel, - const char* data, size_t len) { - return (channel == rtcp_transport_channel_ || +bool BaseChannel::PacketIsRtcp(const rtc::PacketTransportInterface* transport, + const char* data, + size_t len) { + return (transport == rtcp_transport_channel_ || rtcp_mux_filter_.DemuxRtcp(data, static_cast(len))); } @@ -1445,8 +1448,9 @@ void BaseChannel::FlushRtcpMessages_n() { } } -void BaseChannel::SignalSentPacket_n(TransportChannel* /* channel */, - const rtc::SentPacket& sent_packet) { +void BaseChannel::SignalSentPacket_n( + rtc::PacketTransportInterface* /* transport */, + const rtc::SentPacket& sent_packet) { RTC_DCHECK(network_thread_->IsCurrent()); invoker_.AsyncInvoke( RTC_FROM_HERE, worker_thread_, @@ -1641,15 +1645,15 @@ void VoiceChannel::GetActiveStreams_w(AudioInfo::StreamList* actives) { media_channel()->GetActiveStreams(actives); } -void VoiceChannel::OnChannelRead(TransportChannel* channel, - const char* data, size_t len, - const rtc::PacketTime& packet_time, +void VoiceChannel::OnPacketRead(rtc::PacketTransportInterface* transport, + const char* data, + size_t len, + const rtc::PacketTime& packet_time, int flags) { - BaseChannel::OnChannelRead(channel, data, len, packet_time, flags); - + BaseChannel::OnPacketRead(transport, data, len, packet_time, flags); // Set a flag when we've received an RTP packet. If we're waiting for early // media, this will disable the timeout. - if (!received_media_ && !PacketIsRtcp(channel, data, len)) { + if (!received_media_ && !PacketIsRtcp(transport, data, len)) { received_media_ = true; } } diff --git a/webrtc/pc/channel.h b/webrtc/pc/channel.h index 6ea54194fb..45918ffca0 100644 --- a/webrtc/pc/channel.h +++ b/webrtc/pc/channel.h @@ -39,6 +39,10 @@ #include "webrtc/pc/rtcpmuxfilter.h" #include "webrtc/pc/srtpfilter.h" +namespace rtc { +class PacketTransportInterface; +} + namespace webrtc { class AudioSinkInterface; } // namespace webrtc @@ -233,13 +237,13 @@ class BaseChannel const rtc::PacketOptions& options) override; // From TransportChannel - void OnWritableState(TransportChannel* channel); - virtual void OnChannelRead(TransportChannel* channel, - const char* data, - size_t len, - const rtc::PacketTime& packet_time, - int flags); - void OnReadyToSend(TransportChannel* channel); + void OnWritableState(rtc::PacketTransportInterface* transport); + virtual void OnPacketRead(rtc::PacketTransportInterface* transport, + const char* data, + size_t len, + const rtc::PacketTime& packet_time, + int flags); + void OnReadyToSend(rtc::PacketTransportInterface* transport); void OnDtlsState(TransportChannel* channel, DtlsTransportState state); @@ -249,7 +253,8 @@ class BaseChannel int last_sent_packet_id, bool ready_to_send); - bool PacketIsRtcp(const TransportChannel* channel, const char* data, + bool PacketIsRtcp(const rtc::PacketTransportInterface* transport, + const char* data, size_t len); bool SendPacket(bool rtcp, rtc::CopyOnWriteBuffer* packet, @@ -356,7 +361,7 @@ class BaseChannel bool InitNetwork_n(const std::string* bundle_transport_name); void DisconnectTransportChannels_n(); void DestroyTransportChannels_n(); - void SignalSentPacket_n(TransportChannel* channel, + void SignalSentPacket_n(rtc::PacketTransportInterface* transport, const rtc::SentPacket& sent_packet); void SignalSentPacket_w(const rtc::SentPacket& sent_packet); bool IsReadyToSendMedia_n() const; @@ -376,6 +381,7 @@ class BaseChannel // Expected to be true (as of typing this) for everything except data // channels. const bool rtcp_enabled_; + // TODO(johan): Replace TransportChannel* with rtc::PacketTransportInterface*. TransportChannel* transport_channel_ = nullptr; std::vector > socket_options_; TransportChannel* rtcp_transport_channel_ = nullptr; @@ -484,11 +490,11 @@ class VoiceChannel : public BaseChannel { private: // overrides from BaseChannel - void OnChannelRead(TransportChannel* channel, - const char* data, - size_t len, - const rtc::PacketTime& packet_time, - int flags) override; + void OnPacketRead(rtc::PacketTransportInterface* transport, + const char* data, + size_t len, + const rtc::PacketTime& packet_time, + int flags) override; void UpdateMediaSendRecvState_w() override; const ContentInfo* GetFirstContent(const SessionDescription* sdesc) override; bool SetLocalContent_w(const MediaContentDescription* content,