From f120cba82d984fd3301ba7e17aae08535ff904ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20M=C3=B6ller?= Date: Tue, 30 Jan 2018 09:33:03 +0100 Subject: [PATCH] Delete AudioMonitor and related code. Bug: webrtc:8760 Change-Id: I0b11ec66b0f2576f52866864ba046191034a4d2d Reviewed-on: https://webrtc-review.googlesource.com/39003 Commit-Queue: Niels Moller Reviewed-by: Fredrik Solenberg Reviewed-by: Taylor Brandstetter Reviewed-by: Noah Richards Cr-Commit-Position: refs/heads/master@{#21801} --- audio/audio_level.cc | 27 +------- audio/audio_level.h | 4 +- audio/audio_receive_stream.cc | 5 -- audio/audio_receive_stream.h | 1 - audio/audio_state.cc | 3 - audio/audio_state_unittest.cc | 2 - audio/channel.cc | 4 -- audio/channel.h | 18 ++--- audio/channel_proxy.cc | 5 -- audio/channel_proxy.h | 1 - audio/mock_voe_channel_proxy.h | 1 - call/audio_receive_stream.h | 2 - call/audio_state.h | 2 - media/base/fakemediaengine.h | 3 - media/base/mediachannel.h | 5 -- media/base/mediaengine.h | 4 -- media/engine/fakewebrtccall.h | 1 - media/engine/webrtcvoiceengine.cc | 36 ---------- media/engine/webrtcvoiceengine.h | 4 -- pc/BUILD.gn | 2 - pc/audiomonitor.cc | 105 ------------------------------ pc/audiomonitor.h | 31 +-------- pc/channel.cc | 35 +--------- pc/channel.h | 10 --- pc/currentspeakermonitor.cc | 1 + pc/voicechannel.h | 16 ----- 26 files changed, 17 insertions(+), 311 deletions(-) delete mode 100644 pc/audiomonitor.cc delete mode 100644 pc/voicechannel.h diff --git a/audio/audio_level.cc b/audio/audio_level.cc index fe2a240a10..ca5252200a 100644 --- a/audio/audio_level.cc +++ b/audio/audio_level.cc @@ -16,25 +16,13 @@ namespace webrtc { namespace voe { -// Number of bars on the indicator. -// Note that the number of elements is specified because we are indexing it -// in the range of 0-32 -constexpr int8_t kPermutation[33] = {0, 1, 2, 3, 4, 4, 5, 5, 5, 5, 6, - 6, 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, - 9, 9, 9, 9, 9, 9, 9, 9, 9, 9, 9}; - AudioLevel::AudioLevel() - : abs_max_(0), count_(0), current_level_(0), current_level_full_range_(0) { + : abs_max_(0), count_(0), current_level_full_range_(0) { WebRtcSpl_Init(); } AudioLevel::~AudioLevel() {} -int8_t AudioLevel::Level() const { - rtc::CritScope cs(&crit_sect_); - return current_level_; -} - int16_t AudioLevel::LevelFullRange() const { rtc::CritScope cs(&crit_sect_); return current_level_full_range_; @@ -44,7 +32,6 @@ void AudioLevel::Clear() { rtc::CritScope cs(&crit_sect_); abs_max_ = 0; count_ = 0; - current_level_ = 0; current_level_full_range_ = 0; } @@ -78,18 +65,6 @@ void AudioLevel::ComputeLevel(const AudioFrame& audioFrame, double duration) { count_ = 0; - // Highest value for a int16_t is 0x7fff = 32767 - // Divide with 1000 to get in the range of 0-32 which is the range of the - // permutation vector - int32_t position = abs_max_ / 1000; - - // Make it less likely that the bar stays at position 0. I.e. only if it's - // in the range 0-250 (instead of 0-1000) - if ((position == 0) && (abs_max_ > 250)) { - position = 1; - } - current_level_ = kPermutation[position]; - // Decay the absolute maximum (divide by 4) abs_max_ >>= 2; } diff --git a/audio/audio_level.h b/audio/audio_level.h index 883641ac79..3bbe5fdd20 100644 --- a/audio/audio_level.h +++ b/audio/audio_level.h @@ -25,8 +25,7 @@ class AudioLevel { ~AudioLevel(); // Called on "API thread(s)" from APIs like VoEBase::CreateChannel(), - // VoEBase::StopSend(), VoEVolumeControl::GetSpeechOutputLevel(). - int8_t Level() const; + // VoEBase::StopSend() int16_t LevelFullRange() const; void Clear(); // See the description for "totalAudioEnergy" in the WebRTC stats spec @@ -46,7 +45,6 @@ class AudioLevel { int16_t abs_max_ RTC_GUARDED_BY(crit_sect_); int16_t count_ RTC_GUARDED_BY(crit_sect_); - int8_t current_level_ RTC_GUARDED_BY(crit_sect_); int16_t current_level_full_range_ RTC_GUARDED_BY(crit_sect_); double total_energy_ RTC_GUARDED_BY(crit_sect_) = 0.0; diff --git a/audio/audio_receive_stream.cc b/audio/audio_receive_stream.cc index c5e2b16c20..b04f008a39 100644 --- a/audio/audio_receive_stream.cc +++ b/audio/audio_receive_stream.cc @@ -221,11 +221,6 @@ webrtc::AudioReceiveStream::Stats AudioReceiveStream::GetStats() const { return stats; } -int AudioReceiveStream::GetOutputLevel() const { - RTC_DCHECK_RUN_ON(&worker_thread_checker_); - return channel_proxy_->GetSpeechOutputLevel(); -} - void AudioReceiveStream::SetSink(AudioSinkInterface* sink) { RTC_DCHECK_RUN_ON(&worker_thread_checker_); channel_proxy_->SetSink(sink); diff --git a/audio/audio_receive_stream.h b/audio/audio_receive_stream.h index 7d0eed9cb2..295f5f7aa6 100644 --- a/audio/audio_receive_stream.h +++ b/audio/audio_receive_stream.h @@ -61,7 +61,6 @@ class AudioReceiveStream final : public webrtc::AudioReceiveStream, void Start() override; void Stop() override; webrtc::AudioReceiveStream::Stats GetStats() const override; - int GetOutputLevel() const override; void SetSink(AudioSinkInterface* sink) override; void SetGain(float gain) override; std::vector GetSources() const override; diff --git a/audio/audio_state.cc b/audio/audio_state.cc index 3d38c8934c..d738884e8d 100644 --- a/audio/audio_state.cc +++ b/audio/audio_state.cc @@ -149,9 +149,6 @@ AudioState::Stats AudioState::GetAudioInputStats() const { result.audio_level = audio_level.LevelFullRange(); RTC_DCHECK_LE(0, result.audio_level); RTC_DCHECK_GE(32767, result.audio_level); - result.quantized_audio_level = audio_level.Level(); - RTC_DCHECK_LE(0, result.quantized_audio_level); - RTC_DCHECK_GE(9, result.quantized_audio_level); result.total_energy = audio_level.TotalEnergy(); result.total_duration = audio_level.TotalDuration(); return result; diff --git a/audio/audio_state_unittest.cc b/audio/audio_state_unittest.cc index b4452add9a..e825ec6116 100644 --- a/audio/audio_state_unittest.cc +++ b/audio/audio_state_unittest.cc @@ -234,7 +234,6 @@ TEST(AudioStateTest, InputLevelStats) { kNumChannels, kSampleRate, 0, 0, 0, false, new_mic_level); auto stats = audio_state->GetAudioInputStats(); EXPECT_EQ(0, stats.audio_level); - EXPECT_EQ(0, stats.quantized_audio_level); EXPECT_THAT(stats.total_energy, testing::DoubleEq(0.0)); EXPECT_THAT(stats.total_duration, testing::DoubleEq(0.01)); } @@ -250,7 +249,6 @@ TEST(AudioStateTest, InputLevelStats) { } auto stats = audio_state->GetAudioInputStats(); EXPECT_EQ(32767, stats.audio_level); - EXPECT_EQ(9, stats.quantized_audio_level); EXPECT_THAT(stats.total_energy, testing::DoubleEq(0.01)); EXPECT_THAT(stats.total_duration, testing::DoubleEq(0.11)); } diff --git a/audio/channel.cc b/audio/channel.cc index ac4b917e16..3472a2417f 100644 --- a/audio/channel.cc +++ b/audio/channel.cc @@ -1011,10 +1011,6 @@ int32_t Channel::ReceivedRTCPPacket(const uint8_t* data, size_t length) { return 0; } -int Channel::GetSpeechOutputLevel() const { - return _outputAudioLevel.Level(); -} - int Channel::GetSpeechOutputLevelFullRange() const { return _outputAudioLevel.LevelFullRange(); } diff --git a/audio/channel.h b/audio/channel.h index c5d243cac4..7290ce8f09 100644 --- a/audio/channel.h +++ b/audio/channel.h @@ -34,6 +34,10 @@ #include "rtc_base/task_queue.h" #include "rtc_base/thread_checker.h" +// TODO(solenberg, nisse): This file contains a few NOLINT marks, to silence +// warnings about use of unsigned short, and non-const reference arguments. +// These need cleanup, in a separate cl. + namespace rtc { class TimestampWrapAroundHandler; } @@ -57,7 +61,7 @@ class TelephoneEventHandler; struct SenderInfo; struct CallStatistics { - unsigned short fractionLost; + unsigned short fractionLost; // NOLINT unsigned int cumulativeLost; unsigned int extendedMax; unsigned int jitterSamples; @@ -174,7 +178,7 @@ class Channel void StopSend(); // Codecs - int32_t GetRecCodec(CodecInst& codec); + int32_t GetRecCodec(CodecInst& codec); // NOLINT void SetBitRate(int bitrate_bps, int64_t probing_interval_ms); bool EnableAudioNetworkAdaptor(const std::string& config_string); void DisableAudioNetworkAdaptor(); @@ -190,7 +194,6 @@ class Channel // Muting, Volume and Level. void SetInputMute(bool enable); void SetChannelOutputVolumeScaling(float scaling); - int GetSpeechOutputLevel() const; int GetSpeechOutputLevelFullRange() const; // See description of "totalAudioEnergy" in the WebRTC stats spec: // https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats-totalaudioenergy @@ -198,14 +201,14 @@ class Channel double GetTotalOutputDuration() const; // Stats. - int GetNetworkStatistics(NetworkStatistics& stats); + int GetNetworkStatistics(NetworkStatistics& stats); // NOLINT void GetDecodingCallStatistics(AudioDecodingCallStats* stats) const; ANAStats GetANAStatistics() const; // Audio+Video Sync. uint32_t GetDelayEstimate() const; int SetMinimumPlayoutDelay(int delayMs); - int GetPlayoutTimestamp(unsigned int& timestamp); + int GetPlayoutTimestamp(unsigned int& timestamp); // NOLINT int GetRtpRtcp(RtpRtcp** rtpRtcpModule, RtpReceiver** rtp_receiver) const; // DTMF. @@ -226,7 +229,7 @@ class Channel void SetRTCPStatus(bool enable); int SetRTCP_CNAME(const char cName[256]); int GetRemoteRTCPReportBlocks(std::vector* report_blocks); - int GetRTPStatistics(CallStatistics& stats); + int GetRTPStatistics(CallStatistics& stats); // NOLINT void SetNACKStatus(bool enable, int maxNumberOfPackets); // From AudioPacketizationCallback in the ACM @@ -265,7 +268,6 @@ class Channel bool Playing() const { return channel_state_.Get().playing; } bool Sending() const { return channel_state_.Get().sending; } RtpRtcp* RtpRtcpModulePtr() const { return _rtpRtcpModule.get(); } - int8_t OutputEnergyLevel() const { return _outputAudioLevel.Level(); } // ProcessAndEncodeAudio() posts a task on the shared encoder task queue, // which in turn calls (on the queue) ProcessAndEncodeAudioOnTaskQueue() where @@ -309,7 +311,7 @@ class Channel void Init(); void Terminate(); - int GetRemoteSSRC(unsigned int& ssrc); + int GetRemoteSSRC(unsigned int& ssrc); // NOLINT void OnUplinkPacketLossRate(float packet_loss_rate); bool InputMute() const; diff --git a/audio/channel_proxy.cc b/audio/channel_proxy.cc index cdfe0902b5..1a546f6a37 100644 --- a/audio/channel_proxy.cc +++ b/audio/channel_proxy.cc @@ -137,11 +137,6 @@ ANAStats ChannelProxy::GetANAStatistics() const { return channel_->GetANAStatistics(); } -int ChannelProxy::GetSpeechOutputLevel() const { - RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); - return channel_->GetSpeechOutputLevel(); -} - int ChannelProxy::GetSpeechOutputLevelFullRange() const { RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); return channel_->GetSpeechOutputLevelFullRange(); diff --git a/audio/channel_proxy.h b/audio/channel_proxy.h index f5f603ba75..e11bd2d930 100644 --- a/audio/channel_proxy.h +++ b/audio/channel_proxy.h @@ -78,7 +78,6 @@ class ChannelProxy : public RtpPacketSinkInterface { virtual NetworkStatistics GetNetworkStatistics() const; virtual AudioDecodingCallStats GetDecodingCallStatistics() const; virtual ANAStats GetANAStatistics() const; - virtual int GetSpeechOutputLevel() const; virtual int GetSpeechOutputLevelFullRange() const; // See description of "totalAudioEnergy" in the WebRTC stats spec: // https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats-totalaudioenergy diff --git a/audio/mock_voe_channel_proxy.h b/audio/mock_voe_channel_proxy.h index d512ad45e0..2f6754eea8 100644 --- a/audio/mock_voe_channel_proxy.h +++ b/audio/mock_voe_channel_proxy.h @@ -54,7 +54,6 @@ class MockVoEChannelProxy : public voe::ChannelProxy { MOCK_CONST_METHOD0(GetNetworkStatistics, NetworkStatistics()); MOCK_CONST_METHOD0(GetDecodingCallStatistics, AudioDecodingCallStats()); MOCK_CONST_METHOD0(GetANAStatistics, ANAStats()); - MOCK_CONST_METHOD0(GetSpeechOutputLevel, int()); MOCK_CONST_METHOD0(GetSpeechOutputLevelFullRange, int()); MOCK_CONST_METHOD0(GetTotalOutputEnergy, double()); MOCK_CONST_METHOD0(GetTotalOutputDuration, double()); diff --git a/call/audio_receive_stream.h b/call/audio_receive_stream.h index 4667498434..9b5eef0bc7 100644 --- a/call/audio_receive_stream.h +++ b/call/audio_receive_stream.h @@ -124,8 +124,6 @@ class AudioReceiveStream { virtual void Stop() = 0; virtual Stats GetStats() const = 0; - // TODO(solenberg): Remove, once AudioMonitor is gone. - virtual int GetOutputLevel() const = 0; // Sets an audio sink that receives unmixed audio from the receive stream. // Ownership of the sink is managed by the caller. diff --git a/call/audio_state.h b/call/audio_state.h index 9c40187068..e947beb00c 100644 --- a/call/audio_state.h +++ b/call/audio_state.h @@ -39,8 +39,6 @@ class AudioState : public rtc::RefCountInterface { struct Stats { // Audio peak level (max(abs())), linearly on the interval [0,32767]. int32_t audio_level = -1; - // Audio peak level (max(abs())), logarithmically on the interval [0,9]. - int8_t quantized_audio_level = -1; // See: https://w3c.github.io/webrtc-stats/#dom-rtcmediastreamtrackstats-totalaudioenergy double total_energy = 0.0f; double total_duration = 0.0f; diff --git a/media/base/fakemediaengine.h b/media/base/fakemediaengine.h index 46cc3dab1c..efe0c9c4aa 100644 --- a/media/base/fakemediaengine.h +++ b/media/base/fakemediaengine.h @@ -382,9 +382,6 @@ class FakeVoiceMediaChannel : public RtpHelper { return true; } - virtual bool GetActiveStreams(StreamList* streams) { return true; } - virtual int GetOutputLevel() { return 0; } - virtual bool CanInsertDtmf() { for (std::vector::const_iterator it = send_codecs_.begin(); it != send_codecs_.end(); ++it) { diff --git a/media/base/mediachannel.h b/media/base/mediachannel.h index af2434f121..d6205c2154 100644 --- a/media/base/mediachannel.h +++ b/media/base/mediachannel.h @@ -670,11 +670,6 @@ class VoiceMediaChannel : public MediaChannel { bool enable, const AudioOptions* options, AudioSource* source) = 0; - // Gets current energy levels for all incoming streams. - typedef std::vector> StreamList; - virtual bool GetActiveStreams(StreamList* actives) = 0; - // Get the current energy level of the stream sent to the speaker. - virtual int GetOutputLevel() = 0; // Set speaker output volume of the specified ssrc. virtual bool SetOutputVolume(uint32_t ssrc, double volume) = 0; // Returns if the telephone-event has been negotiated. diff --git a/media/base/mediaengine.h b/media/base/mediaengine.h index cb0d37ddfd..920ed85854 100644 --- a/media/base/mediaengine.h +++ b/media/base/mediaengine.h @@ -68,9 +68,6 @@ class MediaEngineInterface { const MediaConfig& config, const VideoOptions& options) = 0; - // Gets the current microphone level, as a value between 0 and 10. - virtual int GetInputLevel() = 0; - virtual const std::vector& audio_send_codecs() = 0; virtual const std::vector& audio_recv_codecs() = 0; virtual RtpCapabilities GetAudioCapabilities() = 0; @@ -119,7 +116,6 @@ class CompositeMediaEngine : public MediaEngineInterface { return video().CreateChannel(call, config, options); } - virtual int GetInputLevel() { return voice().GetInputLevel(); } virtual const std::vector& audio_send_codecs() { return voice().send_codecs(); } diff --git a/media/engine/fakewebrtccall.h b/media/engine/fakewebrtccall.h index cd9f1eb2cb..d38a27b3f8 100644 --- a/media/engine/fakewebrtccall.h +++ b/media/engine/fakewebrtccall.h @@ -100,7 +100,6 @@ class FakeAudioReceiveStream final : public webrtc::AudioReceiveStream { void Stop() override { started_ = false; } webrtc::AudioReceiveStream::Stats GetStats() const override; - int GetOutputLevel() const override { return 0; } void SetSink(webrtc::AudioSinkInterface* sink) override; void SetGain(float gain) override; std::vector GetSources() const override { diff --git a/media/engine/webrtcvoiceengine.cc b/media/engine/webrtcvoiceengine.cc index 91618f8c7c..d96bb1d019 100644 --- a/media/engine/webrtcvoiceengine.cc +++ b/media/engine/webrtcvoiceengine.cc @@ -593,12 +593,6 @@ bool WebRtcVoiceEngine::ApplyOptions(const AudioOptions& options_in) { return true; } -// TODO(solenberg): Remove, once AudioMonitor is gone. -int WebRtcVoiceEngine::GetInputLevel() { - RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); - return audio_state()->GetAudioInputStats().quantized_audio_level; -} - const std::vector& WebRtcVoiceEngine::send_codecs() const { RTC_DCHECK(signal_thread_checker_.CalledOnValidThread()); return send_codecs_; @@ -1193,12 +1187,6 @@ class WebRtcVoiceMediaChannel::WebRtcAudioReceiveStream { return stream_->GetStats(); } - int GetOutputLevel() const { - RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); - RTC_DCHECK(stream_); - return stream_->GetOutputLevel(); - } - void SetRawAudioSink(std::unique_ptr sink) { RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); raw_audio_sink_ = std::move(sink); @@ -1923,30 +1911,6 @@ bool WebRtcVoiceMediaChannel::SetLocalSource(uint32_t ssrc, return true; } -// TODO(solenberg): Remove, once AudioMonitor is gone. -bool WebRtcVoiceMediaChannel::GetActiveStreams( - AudioInfo::StreamList* actives) { - RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); - actives->clear(); - for (const auto& ch : recv_streams_) { - int level = ch.second->GetOutputLevel(); - if (level > 0) { - actives->push_back(std::make_pair(ch.first, level)); - } - } - return true; -} - -// TODO(solenberg): Remove, once AudioMonitor is gone. -int WebRtcVoiceMediaChannel::GetOutputLevel() { - RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); - int highest = 0; - for (const auto& ch : recv_streams_) { - highest = std::max(ch.second->GetOutputLevel(), highest); - } - return highest; -} - bool WebRtcVoiceMediaChannel::SetOutputVolume(uint32_t ssrc, double volume) { RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); std::vector ssrcs(1, ssrc); diff --git a/media/engine/webrtcvoiceengine.h b/media/engine/webrtcvoiceengine.h index 083c1eb45b..0c7baf5970 100644 --- a/media/engine/webrtcvoiceengine.h +++ b/media/engine/webrtcvoiceengine.h @@ -59,8 +59,6 @@ class WebRtcVoiceEngine final { const MediaConfig& config, const AudioOptions& options); - int GetInputLevel(); - const std::vector& send_codecs() const; const std::vector& recv_codecs() const; RtpCapabilities GetCapabilities() const; @@ -174,8 +172,6 @@ class WebRtcVoiceMediaChannel final : public VoiceMediaChannel, bool RemoveSendStream(uint32_t ssrc) override; bool AddRecvStream(const StreamParams& sp) override; bool RemoveRecvStream(uint32_t ssrc) override; - bool GetActiveStreams(StreamList* actives) override; - int GetOutputLevel() override; // SSRC=0 will apply the new volume to current and future unsignaled streams. bool SetOutputVolume(uint32_t ssrc, double volume) override; diff --git a/pc/BUILD.gn b/pc/BUILD.gn index a65b60380e..47b963b4b5 100644 --- a/pc/BUILD.gn +++ b/pc/BUILD.gn @@ -29,7 +29,6 @@ rtc_static_library("rtc_pc_base") { visibility = [ "*" ] defines = [] sources = [ - "audiomonitor.cc", "audiomonitor.h", "bundlefilter.cc", "bundlefilter.h", @@ -65,7 +64,6 @@ rtc_static_library("rtc_pc_base") { "srtptransport.h", "transportcontroller.cc", "transportcontroller.h", - "voicechannel.h", ] deps = [ diff --git a/pc/audiomonitor.cc b/pc/audiomonitor.cc deleted file mode 100644 index a5bffd7b58..0000000000 --- a/pc/audiomonitor.cc +++ /dev/null @@ -1,105 +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 -#include "pc/audiomonitor.h" -#include "pc/voicechannel.h" - -namespace cricket { - -const uint32_t MSG_MONITOR_POLL = 1; -const uint32_t MSG_MONITOR_START = 2; -const uint32_t MSG_MONITOR_STOP = 3; -const uint32_t MSG_MONITOR_SIGNAL = 4; - -AudioMonitor::AudioMonitor(VoiceChannel *voice_channel, - rtc::Thread *monitor_thread) { - voice_channel_ = voice_channel; - monitoring_thread_ = monitor_thread; - monitoring_ = false; -} - -AudioMonitor::~AudioMonitor() { - voice_channel_->worker_thread()->Clear(this); - monitoring_thread_->Clear(this); -} - -void AudioMonitor::Start(int milliseconds) { - rate_ = milliseconds; - if (rate_ < 100) - rate_ = 100; - voice_channel_->worker_thread()->Post(RTC_FROM_HERE, this, MSG_MONITOR_START); -} - -void AudioMonitor::Stop() { - voice_channel_->worker_thread()->Post(RTC_FROM_HERE, this, MSG_MONITOR_STOP); -} - -void AudioMonitor::OnMessage(rtc::Message *message) { - rtc::CritScope cs(&crit_); - - switch (message->message_id) { - case MSG_MONITOR_START: - assert(rtc::Thread::Current() == voice_channel_->worker_thread()); - if (!monitoring_) { - monitoring_ = true; - PollVoiceChannel(); - } - break; - - case MSG_MONITOR_STOP: - assert(rtc::Thread::Current() == voice_channel_->worker_thread()); - if (monitoring_) { - monitoring_ = false; - voice_channel_->worker_thread()->Clear(this); - } - break; - - case MSG_MONITOR_POLL: - assert(rtc::Thread::Current() == voice_channel_->worker_thread()); - PollVoiceChannel(); - break; - - case MSG_MONITOR_SIGNAL: - { - assert(rtc::Thread::Current() == monitoring_thread_); - AudioInfo info = audio_info_; - crit_.Leave(); - SignalUpdate(this, info); - crit_.Enter(); - } - break; - } -} - -void AudioMonitor::PollVoiceChannel() { - rtc::CritScope cs(&crit_); - assert(rtc::Thread::Current() == voice_channel_->worker_thread()); - - // Gather connection infos - audio_info_.input_level = voice_channel_->GetInputLevel_w(); - audio_info_.output_level = voice_channel_->GetOutputLevel_w(); - voice_channel_->GetActiveStreams_w(&audio_info_.active_streams); - - // Signal the monitoring thread, start another poll timer - monitoring_thread_->Post(RTC_FROM_HERE, this, MSG_MONITOR_SIGNAL); - voice_channel_->worker_thread()->PostDelayed(RTC_FROM_HERE, rate_, this, - MSG_MONITOR_POLL); -} - -VoiceChannel *AudioMonitor::voice_channel() { - return voice_channel_; -} - -rtc::Thread *AudioMonitor::monitor_thread() { - return monitoring_thread_; -} - -} // namespace cricket diff --git a/pc/audiomonitor.h b/pc/audiomonitor.h index 26212afc72..61edd32c1c 100644 --- a/pc/audiomonitor.h +++ b/pc/audiomonitor.h @@ -14,14 +14,11 @@ #include #include +// For ConnectionInfo/ConnectionInfos #include "p2p/base/port.h" -#include "rtc_base/sigslot.h" -#include "rtc_base/thread.h" namespace cricket { -class VoiceChannel; - struct AudioInfo { int input_level; int output_level; @@ -29,32 +26,6 @@ struct AudioInfo { StreamList active_streams; // ssrcs contributing to output_level }; -class AudioMonitor : public rtc::MessageHandler, - public sigslot::has_slots<> { - public: - AudioMonitor(VoiceChannel* voice_channel, rtc::Thread *monitor_thread); - ~AudioMonitor(); - - void Start(int cms); - void Stop(); - - VoiceChannel* voice_channel(); - rtc::Thread *monitor_thread(); - - sigslot::signal2 SignalUpdate; - - protected: - void OnMessage(rtc::Message *message); - void PollVoiceChannel(); - - AudioInfo audio_info_; - VoiceChannel* voice_channel_; - rtc::Thread* monitoring_thread_; - rtc::CriticalSection crit_; - uint32_t rate_; - bool monitoring_; -}; - } // namespace cricket #endif // PC_AUDIOMONITOR_H_ diff --git a/pc/channel.cc b/pc/channel.cc index 0c1434d615..e6c8da7ec3 100644 --- a/pc/channel.cc +++ b/pc/channel.cc @@ -1134,7 +1134,8 @@ void BaseChannel::ActivateRtcpMux() { VoiceChannel::VoiceChannel(rtc::Thread* worker_thread, rtc::Thread* network_thread, rtc::Thread* signaling_thread, - MediaEngineInterface* media_engine, + // TODO(nisse): Delete unused argument. + MediaEngineInterface* /* media_engine */, std::unique_ptr media_channel, const std::string& content_name, bool rtcp_mux_required, @@ -1145,12 +1146,10 @@ VoiceChannel::VoiceChannel(rtc::Thread* worker_thread, std::move(media_channel), content_name, rtcp_mux_required, - srtp_required), - media_engine_(media_engine) {} + srtp_required) {} VoiceChannel::~VoiceChannel() { TRACE_EVENT0("webrtc", "VoiceChannel::~VoiceChannel"); - StopAudioMonitor(); // this can't be done in the base class, since it calls a virtual DisableMedia_w(); Deinit(); @@ -1186,34 +1185,6 @@ bool VoiceChannel::GetStats(VoiceMediaInfo* stats) { media_channel(), stats)); } -void VoiceChannel::StartAudioMonitor(int cms) { - audio_monitor_.reset(new AudioMonitor(this, rtc::Thread::Current())); - audio_monitor_->Start(cms); -} - -void VoiceChannel::StopAudioMonitor() { - if (audio_monitor_) { - audio_monitor_->Stop(); - audio_monitor_.reset(); - } -} - -bool VoiceChannel::IsAudioMonitorRunning() const { - return (audio_monitor_.get() != NULL); -} - -int VoiceChannel::GetInputLevel_w() { - return media_engine_->GetInputLevel(); -} - -int VoiceChannel::GetOutputLevel_w() { - return media_channel()->GetOutputLevel(); -} - -void VoiceChannel::GetActiveStreams_w(AudioInfo::StreamList* actives) { - media_channel()->GetActiveStreams(actives); -} - void VoiceChannel::OnPacketReceived(bool rtcp, rtc::CopyOnWriteBuffer* packet, const rtc::PacketTime& packet_time) { diff --git a/pc/channel.h b/pc/channel.h index 3fb19972b9..339c785024 100644 --- a/pc/channel.h +++ b/pc/channel.h @@ -471,14 +471,6 @@ class VoiceChannel : public BaseChannel { // Get statistics about the current media session. bool GetStats(VoiceMediaInfo* stats); - // Monitoring functions - void StartAudioMonitor(int cms); - void StopAudioMonitor(); - bool IsAudioMonitorRunning() const; - - int GetInputLevel_w(); - int GetOutputLevel_w(); - void GetActiveStreams_w(AudioInfo::StreamList* actives); webrtc::RtpParameters GetRtpSendParameters_w(uint32_t ssrc) const; webrtc::RTCError SetRtpSendParameters_w(uint32_t ssrc, webrtc::RtpParameters parameters); @@ -501,9 +493,7 @@ class VoiceChannel : public BaseChannel { void OnMessage(rtc::Message* pmsg) override; static const int kEarlyMediaTimeout = 1000; - MediaEngineInterface* media_engine_; bool received_media_ = false; - std::unique_ptr audio_monitor_; // Last AudioSendParameters sent down to the media_channel() via // SetSendParameters. diff --git a/pc/currentspeakermonitor.cc b/pc/currentspeakermonitor.cc index e210a45d61..2b58419698 100644 --- a/pc/currentspeakermonitor.cc +++ b/pc/currentspeakermonitor.cc @@ -15,6 +15,7 @@ #include "media/base/streamparams.h" #include "pc/audiomonitor.h" #include "rtc_base/logging.h" +#include "rtc_base/timeutils.h" namespace cricket { diff --git a/pc/voicechannel.h b/pc/voicechannel.h deleted file mode 100644 index 852ef17354..0000000000 --- a/pc/voicechannel.h +++ /dev/null @@ -1,16 +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 PC_VOICECHANNEL_H_ -#define PC_VOICECHANNEL_H_ - -#include "pc/channel.h" - -#endif // PC_VOICECHANNEL_H_