From e2a931886f5072b06373cd6ea384861120e82c09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Wed, 17 Jan 2018 14:18:27 +0100 Subject: [PATCH] Delete ConnectionMonitor. Bug: webrtc:8760 Change-Id: I345659eebc04704bedd46e1b04959cd63785aa62 Reviewed-on: https://webrtc-review.googlesource.com/40201 Reviewed-by: Noah Richards Reviewed-by: Taylor Brandstetter Commit-Queue: Niels Moller Cr-Commit-Position: refs/heads/master@{#21667} --- p2p/BUILD.gn | 2 - p2p/client/socketmonitor.cc | 96 ------------------------------------- p2p/client/socketmonitor.h | 63 ------------------------ pc/channel.cc | 46 ------------------ pc/channel.h | 34 +------------ 5 files changed, 1 insertion(+), 240 deletions(-) delete mode 100644 p2p/client/socketmonitor.cc delete mode 100644 p2p/client/socketmonitor.h diff --git a/p2p/BUILD.gn b/p2p/BUILD.gn index 9ab79e470b..814cea9412 100644 --- a/p2p/BUILD.gn +++ b/p2p/BUILD.gn @@ -79,8 +79,6 @@ rtc_static_library("rtc_p2p") { "client/basicportallocator.cc", "client/basicportallocator.h", "client/relayportfactoryinterface.h", - "client/socketmonitor.cc", - "client/socketmonitor.h", "client/turnportfactory.cc", "client/turnportfactory.h", ] diff --git a/p2p/client/socketmonitor.cc b/p2p/client/socketmonitor.cc deleted file mode 100644 index 6bfa186fae..0000000000 --- a/p2p/client/socketmonitor.cc +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2004 The WebRTC Project Authors. All rights reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#include "p2p/client/socketmonitor.h" - -#include "rtc_base/checks.h" - -namespace cricket { - -enum { - MSG_MONITOR_POLL, - MSG_MONITOR_START, - MSG_MONITOR_STOP, - MSG_MONITOR_SIGNAL -}; - -ConnectionMonitor::ConnectionMonitor(ConnectionStatsGetter* stats_getter, - rtc::Thread* network_thread, - rtc::Thread* monitoring_thread) { - stats_getter_ = stats_getter; - network_thread_ = network_thread; - monitoring_thread_ = monitoring_thread; - monitoring_ = false; -} - -ConnectionMonitor::~ConnectionMonitor() { - network_thread_->Clear(this); - monitoring_thread_->Clear(this); -} - -void ConnectionMonitor::Start(int milliseconds) { - rate_ = milliseconds; - if (rate_ < 250) - rate_ = 250; - network_thread_->Post(RTC_FROM_HERE, this, MSG_MONITOR_START); -} - -void ConnectionMonitor::Stop() { - network_thread_->Post(RTC_FROM_HERE, this, MSG_MONITOR_STOP); -} - -void ConnectionMonitor::OnMessage(rtc::Message *message) { - rtc::CritScope cs(&crit_); - switch (message->message_id) { - case MSG_MONITOR_START: - RTC_DCHECK(rtc::Thread::Current() == network_thread_); - if (!monitoring_) { - monitoring_ = true; - PollConnectionStats_w(); - } - break; - - case MSG_MONITOR_STOP: - RTC_DCHECK(rtc::Thread::Current() == network_thread_); - if (monitoring_) { - monitoring_ = false; - network_thread_->Clear(this); - } - break; - - case MSG_MONITOR_POLL: - RTC_DCHECK(rtc::Thread::Current() == network_thread_); - PollConnectionStats_w(); - break; - - case MSG_MONITOR_SIGNAL: { - RTC_DCHECK(rtc::Thread::Current() == monitoring_thread_); - std::vector infos = connection_infos_; - crit_.Leave(); - SignalUpdate(this, infos); - crit_.Enter(); - break; - } - } -} - -void ConnectionMonitor::PollConnectionStats_w() { - RTC_DCHECK(rtc::Thread::Current() == network_thread_); - rtc::CritScope cs(&crit_); - - // Gather connection infos - stats_getter_->GetConnectionStats(&connection_infos_); - - // Signal the monitoring thread, start another poll timer - monitoring_thread_->Post(RTC_FROM_HERE, this, MSG_MONITOR_SIGNAL); - network_thread_->PostDelayed(RTC_FROM_HERE, rate_, this, MSG_MONITOR_POLL); -} - -} // namespace cricket diff --git a/p2p/client/socketmonitor.h b/p2p/client/socketmonitor.h deleted file mode 100644 index 3428b0335b..0000000000 --- a/p2p/client/socketmonitor.h +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright 2004 The WebRTC Project Authors. All rights reserved. - * - * Use of this source code is governed by a BSD-style license - * that can be found in the LICENSE file in the root of the source - * tree. An additional intellectual property rights grant can be found - * in the file PATENTS. All contributing project authors may - * be found in the AUTHORS file in the root of the source tree. - */ - -#ifndef P2P_CLIENT_SOCKETMONITOR_H_ -#define P2P_CLIENT_SOCKETMONITOR_H_ - -#include - -#include "p2p/base/port.h" // for ConnectionInfos -#include "rtc_base/criticalsection.h" -#include "rtc_base/sigslot.h" -#include "rtc_base/thread.h" - -// TODO(pthatcher): Move these to connectionmonitor.h and -// connectionmonitor.cc, or just move them into channel.cc - -namespace cricket { - -class ConnectionStatsGetter { - public: - virtual ~ConnectionStatsGetter() {} - virtual bool GetConnectionStats(ConnectionInfos* infos) = 0; -}; - -class ConnectionMonitor : public rtc::MessageHandler, - public sigslot::has_slots<> { - public: - ConnectionMonitor(ConnectionStatsGetter* stats_getter, - rtc::Thread* network_thread, - rtc::Thread* monitoring_thread); - ~ConnectionMonitor() override; - - void Start(int cms); - void Stop(); - - sigslot::signal2&> SignalUpdate; - - protected: - void OnMessage(rtc::Message* message) override; - - private: - void PollConnectionStats_w(); - - std::vector connection_infos_; - ConnectionStatsGetter* stats_getter_; - rtc::Thread* network_thread_; - rtc::Thread* monitoring_thread_; - rtc::CriticalSection crit_; - uint32_t rate_; - bool monitoring_; -}; - -} // namespace cricket - -#endif // P2P_CLIENT_SOCKETMONITOR_H_ diff --git a/pc/channel.cc b/pc/channel.cc index 954cdce845..0c1434d615 100644 --- a/pc/channel.cc +++ b/pc/channel.cc @@ -120,7 +120,6 @@ BaseChannel::~BaseChannel() { TRACE_EVENT0("webrtc", "BaseChannel::~BaseChannel"); RTC_DCHECK_RUN_ON(worker_thread_); Deinit(); - StopConnectionMonitor(); // Eats any outstanding messages or packets. worker_thread_->Clear(&invoker_); worker_thread_->Clear(this); @@ -403,35 +402,6 @@ bool BaseChannel::SetRemoteContent(const MediaContentDescription* content, Bind(&BaseChannel::SetRemoteContent_w, this, content, type, error_desc)); } -void BaseChannel::StartConnectionMonitor(int cms) { - // We pass in the BaseChannel instead of the rtp_dtls_transport_ - // because if the rtp_dtls_transport_ changes, the ConnectionMonitor - // would be pointing to the wrong TransportChannel. - // We pass in the network thread because on that thread connection monitor - // will call BaseChannel::GetConnectionStats which must be called on the - // network thread. - connection_monitor_.reset( - new ConnectionMonitor(this, network_thread(), rtc::Thread::Current())); - connection_monitor_->SignalUpdate.connect( - this, &BaseChannel::OnConnectionMonitorUpdate); - connection_monitor_->Start(cms); -} - -void BaseChannel::StopConnectionMonitor() { - if (connection_monitor_) { - connection_monitor_->Stop(); - connection_monitor_.reset(); - } -} - -bool BaseChannel::GetConnectionStats(ConnectionInfos* infos) { - RTC_DCHECK(network_thread_->IsCurrent()); - if (!rtp_dtls_transport_) { - return false; - } - return rtp_dtls_transport_->ice_transport()->GetStats(infos); -} - bool BaseChannel::NeedsRtcpTransport() { // If this BaseChannel doesn't require RTCP mux and we haven't fully // negotiated RTCP mux, we need an RTCP transport. @@ -1397,11 +1367,6 @@ void VoiceChannel::OnMessage(rtc::Message *pmsg) { } } -void VoiceChannel::OnConnectionMonitorUpdate( - ConnectionMonitor* monitor, const std::vector& infos) { - SignalConnectionMonitor(this, infos); -} - VideoChannel::VideoChannel(rtc::Thread* worker_thread, rtc::Thread* network_thread, rtc::Thread* signaling_thread, @@ -1553,11 +1518,6 @@ bool VideoChannel::SetRemoteContent_w(const MediaContentDescription* content, return true; } -void VideoChannel::OnConnectionMonitorUpdate( - ConnectionMonitor* monitor, const std::vector &infos) { - SignalConnectionMonitor(this, infos); -} - RtpDataChannel::RtpDataChannel(rtc::Thread* worker_thread, rtc::Thread* network_thread, rtc::Thread* signaling_thread, @@ -1780,12 +1740,6 @@ void RtpDataChannel::OnMessage(rtc::Message* pmsg) { } } -void RtpDataChannel::OnConnectionMonitorUpdate( - ConnectionMonitor* monitor, - const std::vector& infos) { - SignalConnectionMonitor(this, infos); -} - void RtpDataChannel::OnDataReceived(const ReceiveDataParams& params, const char* data, size_t len) { diff --git a/pc/channel.h b/pc/channel.h index 75299d5dbf..00747eb2ed 100644 --- a/pc/channel.h +++ b/pc/channel.h @@ -28,7 +28,6 @@ #include "media/base/streamparams.h" #include "p2p/base/dtlstransportinternal.h" #include "p2p/base/packettransportinternal.h" -#include "p2p/client/socketmonitor.h" #include "pc/audiomonitor.h" #include "pc/dtlssrtptransport.h" #include "pc/mediasession.h" @@ -72,8 +71,7 @@ class MediaContentDescription; class BaseChannel : public rtc::MessageHandler, public sigslot::has_slots<>, - public MediaChannel::NetworkInterface, - public ConnectionStatsGetter { + public MediaChannel::NetworkInterface { public: // If |srtp_required| is true, the channel will not send or receive any // RTP/RTCP packets without using SRTP (either using SDES or DTLS-SRTP). @@ -153,12 +151,6 @@ class BaseChannel bool AddSendStream(const StreamParams& sp); bool RemoveSendStream(uint32_t ssrc); - // Monitoring - void StartConnectionMonitor(int cms); - void StopConnectionMonitor(); - // For ConnectionStatsGetter, used by ConnectionMonitor - bool GetConnectionStats(ConnectionInfos* infos) override; - const std::vector& local_streams() const { return local_streams_; } @@ -357,10 +349,6 @@ class BaseChannel // From MessageHandler void OnMessage(rtc::Message* pmsg) override; - // Handled in derived classes - virtual void OnConnectionMonitorUpdate(ConnectionMonitor* monitor, - const std::vector& infos) = 0; - // Helper function template for invoking methods on the worker thread. template T InvokeOnWorker(const rtc::Location& posted_from, const FunctorT& functor) { @@ -401,7 +389,6 @@ class BaseChannel rtc::AsyncInvoker invoker_; const std::string content_name_; - std::unique_ptr connection_monitor_; // Won't be set when using raw packet transports. SDP-specific thing. std::string transport_name_; @@ -485,9 +472,6 @@ class VoiceChannel : public BaseChannel { bool GetStats(VoiceMediaInfo* stats); // Monitoring functions - sigslot::signal2&> - SignalConnectionMonitor; - void StartAudioMonitor(int cms); void StopAudioMonitor(); bool IsAudioMonitorRunning() const; @@ -514,9 +498,6 @@ class VoiceChannel : public BaseChannel { void HandleEarlyMediaTimeout(); void OnMessage(rtc::Message* pmsg) override; - void OnConnectionMonitorUpdate( - ConnectionMonitor* monitor, - const std::vector& infos) override; static const int kEarlyMediaTimeout = 1000; MediaEngineInterface* media_engine_; @@ -552,9 +533,6 @@ class VideoChannel : public BaseChannel { // Get statistics about the current media session. bool GetStats(VideoMediaInfo* stats); - sigslot::signal2&> - SignalConnectionMonitor; - cricket::MediaType media_type() override { return cricket::MEDIA_TYPE_VIDEO; } private: @@ -568,10 +546,6 @@ class VideoChannel : public BaseChannel { std::string* error_desc) override; bool GetStats_w(VideoMediaInfo* stats); - void OnConnectionMonitorUpdate( - ConnectionMonitor* monitor, - const std::vector& infos) override; - // Last VideoSendParameters sent down to the media_channel() via // SetSendParameters. VideoSendParameters last_send_params_; @@ -608,9 +582,6 @@ class RtpDataChannel : public BaseChannel { return ready_to_send_data_; } - sigslot::signal2&> - SignalConnectionMonitor; - sigslot::signal2 SignalDataReceived; // Signal for notifying when the channel becomes ready to send data. @@ -670,9 +641,6 @@ class RtpDataChannel : public BaseChannel { void UpdateMediaSendRecvState_w() override; void OnMessage(rtc::Message* pmsg) override; - void OnConnectionMonitorUpdate( - ConnectionMonitor* monitor, - const std::vector& infos) override; void OnDataReceived( const ReceiveDataParams& params, const char* data, size_t len); void OnDataChannelReadyToSend(bool writable);