From 05b9803c8ef344ac3dc8fb59504b87a227a0d39d Mon Sep 17 00:00:00 2001 From: solenberg Date: Tue, 14 Jun 2016 08:59:48 -0700 Subject: [PATCH] Removed unused GetOutputVolume() and SetOutputVolume() from MediaEngineInterface. BUG=webrtc:4690 Review-Url: https://codereview.webrtc.org/2059403002 Cr-Commit-Position: refs/heads/master@{#13135} --- webrtc/media/base/fakemediaengine.h | 14 +-------- webrtc/media/base/mediaengine.h | 13 -------- webrtc/media/engine/webrtcvoiceengine.cc | 21 ------------- webrtc/media/engine/webrtcvoiceengine.h | 2 -- webrtc/pc/channelmanager.cc | 40 ------------------------ webrtc/pc/channelmanager.h | 3 -- webrtc/pc/channelmanager_unittest.cc | 35 --------------------- 7 files changed, 1 insertion(+), 127 deletions(-) diff --git a/webrtc/media/base/fakemediaengine.h b/webrtc/media/base/fakemediaengine.h index b2ec1243c9..3edda5e376 100644 --- a/webrtc/media/base/fakemediaengine.h +++ b/webrtc/media/base/fakemediaengine.h @@ -739,8 +739,7 @@ class FakeVoiceEngine : public FakeBaseEngine { FakeVoiceEngine( webrtc::AudioDeviceModule* adm, const rtc::scoped_refptr& - audio_decoder_factory) - : output_volume_(-1) { + audio_decoder_factory) { // Add a fake audio codec. Note that the name must not be "" as there are // sanity checks against that. codecs_.push_back(AudioCodec(101, "fake_audio_codec", 0, 0, 1)); @@ -773,15 +772,6 @@ class FakeVoiceEngine : public FakeBaseEngine { const std::vector& recv_codecs() { return codecs_; } void SetCodecs(const std::vector& codecs) { codecs_ = codecs; } - bool GetOutputVolume(int* level) { - *level = output_volume_; - return true; - } - bool SetOutputVolume(int level) { - output_volume_ = level; - return true; - } - int GetInputLevel() { return 0; } bool StartAecDump(rtc::PlatformFile file, int64_t max_size_bytes) { @@ -799,7 +789,6 @@ class FakeVoiceEngine : public FakeBaseEngine { private: std::vector channels_; std::vector codecs_; - int output_volume_; friend class FakeMediaEngine; }; @@ -893,7 +882,6 @@ class FakeMediaEngine : return video_.GetChannel(index); } - int output_volume() const { return voice_.output_volume_; } bool capture() const { return video_.capture_; } bool options_changed() const { return video_.options_changed_; diff --git a/webrtc/media/base/mediaengine.h b/webrtc/media/base/mediaengine.h index 9204fc129c..0e2b7efa86 100644 --- a/webrtc/media/base/mediaengine.h +++ b/webrtc/media/base/mediaengine.h @@ -72,12 +72,6 @@ class MediaEngineInterface { const MediaConfig& config, const VideoOptions& options) = 0; - // Device configuration - // Gets the current speaker volume, as a value between 0 and 255. - virtual bool GetOutputVolume(int* level) = 0; - // Sets the current speaker volume, as a value between 0 and 255. - virtual bool SetOutputVolume(int level) = 0; - // Gets the current microphone level, as a value between 0 and 10. virtual int GetInputLevel() = 0; @@ -154,13 +148,6 @@ class CompositeMediaEngine : public MediaEngineInterface { return video_.CreateChannel(call, config, options); } - virtual bool GetOutputVolume(int* level) { - return voice_.GetOutputVolume(level); - } - virtual bool SetOutputVolume(int level) { - return voice_.SetOutputVolume(level); - } - virtual int GetInputLevel() { return voice_.GetInputLevel(); } diff --git a/webrtc/media/engine/webrtcvoiceengine.cc b/webrtc/media/engine/webrtcvoiceengine.cc index 4d94d2dcc0..9fbfd494eb 100644 --- a/webrtc/media/engine/webrtcvoiceengine.cc +++ b/webrtc/media/engine/webrtcvoiceengine.cc @@ -866,27 +866,6 @@ void WebRtcVoiceEngine::SetDefaultDevices() { #endif // !WEBRTC_IOS } -bool WebRtcVoiceEngine::GetOutputVolume(int* level) { - RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); - unsigned int ulevel; - if (voe_wrapper_->volume()->GetSpeakerVolume(ulevel) == -1) { - LOG_RTCERR1(GetSpeakerVolume, level); - return false; - } - *level = ulevel; - return true; -} - -bool WebRtcVoiceEngine::SetOutputVolume(int level) { - RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); - RTC_DCHECK(level >= 0 && level <= 255); - if (voe_wrapper_->volume()->SetSpeakerVolume(level) == -1) { - LOG_RTCERR1(SetSpeakerVolume, level); - return false; - } - return true; -} - int WebRtcVoiceEngine::GetInputLevel() { RTC_DCHECK(worker_thread_checker_.CalledOnValidThread()); unsigned int ulevel; diff --git a/webrtc/media/engine/webrtcvoiceengine.h b/webrtc/media/engine/webrtcvoiceengine.h index 71dd391d0d..3b3f0f325c 100644 --- a/webrtc/media/engine/webrtcvoiceengine.h +++ b/webrtc/media/engine/webrtcvoiceengine.h @@ -61,8 +61,6 @@ class WebRtcVoiceEngine final : public webrtc::TraceCallback { const MediaConfig& config, const AudioOptions& options); - bool GetOutputVolume(int* level); - bool SetOutputVolume(int level); int GetInputLevel(); const std::vector& send_codecs() const; diff --git a/webrtc/pc/channelmanager.cc b/webrtc/pc/channelmanager.cc index afac930cd0..fba1040317 100644 --- a/webrtc/pc/channelmanager.cc +++ b/webrtc/pc/channelmanager.cc @@ -32,8 +32,6 @@ namespace cricket { using rtc::Bind; -static const int kNotSetOutputVolume = -1; - static DataEngineInterface* ConstructDataEngine() { #ifdef HAVE_SCTP return new HybridDataEngine(new RtpDataEngine(), new SctpDataEngine()); @@ -64,7 +62,6 @@ void ChannelManager::Construct(MediaEngineInterface* me, main_thread_ = rtc::Thread::Current(); worker_thread_ = worker_thread; network_thread_ = network_thread; - audio_output_volume_ = kNotSetOutputVolume; capturing_ = false; enable_rtx_ = false; } @@ -156,18 +153,6 @@ bool ChannelManager::Init() { initialized_ = worker_thread_->Invoke( RTC_FROM_HERE, Bind(&ChannelManager::InitMediaEngine_w, this)); ASSERT(initialized_); - if (!initialized_) { - return false; - } - - // If audio_output_volume_ has been set via SetOutputVolume(), set the - // audio output volume of the engine. - if (kNotSetOutputVolume != audio_output_volume_ && - !SetOutputVolume(audio_output_volume_)) { - LOG(LS_WARNING) << "Failed to SetOutputVolume to " - << audio_output_volume_; - } - return initialized_; } @@ -391,31 +376,6 @@ void ChannelManager::DestroyDataChannel_w(DataChannel* data_channel) { delete data_channel; } -bool ChannelManager::GetOutputVolume(int* level) { - if (!initialized_) { - return false; - } - return worker_thread_->Invoke( - RTC_FROM_HERE, - Bind(&MediaEngineInterface::GetOutputVolume, media_engine_.get(), level)); -} - -bool ChannelManager::SetOutputVolume(int level) { - bool ret = level >= 0 && level <= 255; - if (initialized_) { - ret &= worker_thread_->Invoke( - RTC_FROM_HERE, Bind(&MediaEngineInterface::SetOutputVolume, - media_engine_.get(), level)); - } - - if (ret) { - audio_output_volume_ = level; - } - - return ret; -} - - bool ChannelManager::StartAecDump(rtc::PlatformFile file, int64_t max_size_bytes) { return worker_thread_->Invoke( diff --git a/webrtc/pc/channelmanager.h b/webrtc/pc/channelmanager.h index 16adf875d3..34188e6e58 100644 --- a/webrtc/pc/channelmanager.h +++ b/webrtc/pc/channelmanager.h @@ -121,8 +121,6 @@ class ChannelManager { return (!voice_channels_.empty() || !video_channels_.empty()); } - bool GetOutputVolume(int* level); - bool SetOutputVolume(int level); // RTX will be enabled/disabled in engines that support it. The supporting // engines will start offering an RTX codec. Must be called before Init(). bool SetVideoRtxEnabled(bool enable); @@ -192,7 +190,6 @@ class ChannelManager { VideoChannels video_channels_; DataChannels data_channels_; - int audio_output_volume_; bool enable_rtx_; bool capturing_; diff --git a/webrtc/pc/channelmanager_unittest.cc b/webrtc/pc/channelmanager_unittest.cc index e5e7b4f7de..e4e243c8b5 100644 --- a/webrtc/pc/channelmanager_unittest.cc +++ b/webrtc/pc/channelmanager_unittest.cc @@ -169,41 +169,6 @@ TEST_F(ChannelManagerTest, NoTransportChannelTest) { cm_->Terminate(); } -TEST_F(ChannelManagerTest, GetSetOutputVolumeBeforeInit) { - int level; - // Before init, SetOutputVolume() remembers the volume but does not change the - // volume of the engine. GetOutputVolume() should fail. - EXPECT_EQ(-1, fme_->output_volume()); - EXPECT_FALSE(cm_->GetOutputVolume(&level)); - EXPECT_FALSE(cm_->SetOutputVolume(-1)); // Invalid volume. - EXPECT_TRUE(cm_->SetOutputVolume(99)); - EXPECT_EQ(-1, fme_->output_volume()); - - // Init() will apply the remembered volume. - EXPECT_TRUE(cm_->Init()); - EXPECT_TRUE(cm_->GetOutputVolume(&level)); - EXPECT_EQ(99, level); - EXPECT_EQ(level, fme_->output_volume()); - - EXPECT_TRUE(cm_->SetOutputVolume(60)); - EXPECT_TRUE(cm_->GetOutputVolume(&level)); - EXPECT_EQ(60, level); - EXPECT_EQ(level, fme_->output_volume()); -} - -TEST_F(ChannelManagerTest, GetSetOutputVolume) { - int level; - EXPECT_TRUE(cm_->Init()); - EXPECT_TRUE(cm_->GetOutputVolume(&level)); - EXPECT_EQ(level, fme_->output_volume()); - - EXPECT_FALSE(cm_->SetOutputVolume(-1)); // Invalid volume. - EXPECT_TRUE(cm_->SetOutputVolume(60)); - EXPECT_EQ(60, fme_->output_volume()); - EXPECT_TRUE(cm_->GetOutputVolume(&level)); - EXPECT_EQ(60, level); -} - TEST_F(ChannelManagerTest, SetVideoRtxEnabled) { std::vector codecs; const VideoCodec rtx_codec(96, "rtx", 0, 0, 0);