From 15ca8f6aebccc1737ed32820accb3d413f211386 Mon Sep 17 00:00:00 2001 From: johan Date: Tue, 1 Nov 2016 01:47:41 -0700 Subject: [PATCH] Let receiving() and SignalRecevingState be part of rtc::PacketTransportInterface. Writable() and the related signal are already part of rtc::PacketTransportInterface. Sense of code symmetry aesthetics dictates that receiving() and the related signal should be declared in the same place. BUG=webrtc:6531 Review-Url: https://codereview.webrtc.org/2444793003 Cr-Commit-Position: refs/heads/master@{#14865} --- webrtc/p2p/base/dtlstransportchannel.cc | 5 +++-- webrtc/p2p/base/dtlstransportchannel.h | 2 +- webrtc/p2p/base/packettransportinterface.h | 7 +++++++ webrtc/p2p/base/transportchannel.h | 3 +-- webrtc/p2p/base/transportcontroller.cc | 3 ++- webrtc/p2p/base/transportcontroller.h | 2 +- 6 files changed, 15 insertions(+), 7 deletions(-) diff --git a/webrtc/p2p/base/dtlstransportchannel.cc b/webrtc/p2p/base/dtlstransportchannel.cc index 0fa32c8b9e..6221057da4 100644 --- a/webrtc/p2p/base/dtlstransportchannel.cc +++ b/webrtc/p2p/base/dtlstransportchannel.cc @@ -471,9 +471,10 @@ void DtlsTransportChannelWrapper::OnWritableState( } } -void DtlsTransportChannelWrapper::OnReceivingState(TransportChannel* channel) { +void DtlsTransportChannelWrapper::OnReceivingState( + rtc::PacketTransportInterface* transport) { ASSERT(rtc::Thread::Current() == network_thread_); - RTC_DCHECK(channel == channel_); + RTC_DCHECK(transport == channel_); LOG_J(LS_VERBOSE, this) << "DTLSTransportChannelWrapper: channel receiving state changed to " << channel_->receiving(); diff --git a/webrtc/p2p/base/dtlstransportchannel.h b/webrtc/p2p/base/dtlstransportchannel.h index aac89c9f9f..5850813fcd 100644 --- a/webrtc/p2p/base/dtlstransportchannel.h +++ b/webrtc/p2p/base/dtlstransportchannel.h @@ -216,7 +216,7 @@ class DtlsTransportChannelWrapper : public TransportChannelImpl { void OnSentPacket(rtc::PacketTransportInterface* transport, const rtc::SentPacket& sent_packet); void OnReadyToSend(rtc::PacketTransportInterface* transport); - void OnReceivingState(TransportChannel* channel); + void OnReceivingState(rtc::PacketTransportInterface* transport); void OnDtlsEvent(rtc::StreamInterface* stream_, int sig, int err); bool SetupDtls(); void MaybeStartDtls(); diff --git a/webrtc/p2p/base/packettransportinterface.h b/webrtc/p2p/base/packettransportinterface.h index c796c6c2fa..d0665bc1db 100644 --- a/webrtc/p2p/base/packettransportinterface.h +++ b/webrtc/p2p/base/packettransportinterface.h @@ -36,6 +36,10 @@ class PacketTransportInterface : public sigslot::has_slots<> { // The transport has been established. virtual bool writable() const = 0; + // The transport has received a packet in the last X milliseconds, here X is + // configured by each implementation. + virtual bool receiving() 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 @@ -70,6 +74,9 @@ class PacketTransportInterface : public sigslot::has_slots<> { // SendPacket's return code and/or GetError. sigslot::signal1 SignalReadyToSend; + // Emitted when receiving state changes to true. + sigslot::signal1 SignalReceivingState; + // Signalled each time a packet is received on this channel. sigslot::signal5 SignalReceivingState; // Emitted whenever DTLS-SRTP is setup which will require setting up a new // SRTP context. sigslot::signal2 SignalDtlsState; diff --git a/webrtc/p2p/base/transportcontroller.cc b/webrtc/p2p/base/transportcontroller.cc index 9d5fb88b71..8dd748647b 100644 --- a/webrtc/p2p/base/transportcontroller.cc +++ b/webrtc/p2p/base/transportcontroller.cc @@ -573,7 +573,8 @@ void TransportController::OnChannelWritableState_n( UpdateAggregateStates_n(); } -void TransportController::OnChannelReceivingState_n(TransportChannel* channel) { +void TransportController::OnChannelReceivingState_n( + rtc::PacketTransportInterface* transport) { RTC_DCHECK(network_thread_->IsCurrent()); UpdateAggregateStates_n(); } diff --git a/webrtc/p2p/base/transportcontroller.h b/webrtc/p2p/base/transportcontroller.h index 86b9c1dc68..a408421ffb 100644 --- a/webrtc/p2p/base/transportcontroller.h +++ b/webrtc/p2p/base/transportcontroller.h @@ -206,7 +206,7 @@ class TransportController : public sigslot::has_slots<>, // Handlers for signals from Transport. void OnChannelWritableState_n(rtc::PacketTransportInterface* transport); - void OnChannelReceivingState_n(TransportChannel* channel); + void OnChannelReceivingState_n(rtc::PacketTransportInterface* transport); void OnChannelGatheringState_n(TransportChannelImpl* channel); void OnChannelCandidateGathered_n(TransportChannelImpl* channel, const Candidate& candidate);