Remove usage of VoEVolumeControl from WVoE and Audio[Send|Receive]Stream.
BUG=webrtc:4690
Review-Url: https://codereview.webrtc.org/2721003002
Cr-Commit-Position: refs/heads/master@{#16956}
diff --git a/webrtc/audio/audio_receive_stream.cc b/webrtc/audio/audio_receive_stream.cc
index 8dc14e8..8c073d9 100644
--- a/webrtc/audio/audio_receive_stream.cc
+++ b/webrtc/audio/audio_receive_stream.cc
@@ -207,6 +207,11 @@
return stats;
}
+int AudioReceiveStream::GetOutputLevel() const {
+ RTC_DCHECK_RUN_ON(&worker_thread_checker_);
+ return channel_proxy_->GetSpeechOutputLevel();
+}
+
void AudioReceiveStream::SetSink(std::unique_ptr<AudioSinkInterface> sink) {
RTC_DCHECK_RUN_ON(&worker_thread_checker_);
channel_proxy_->SetSink(std::move(sink));
diff --git a/webrtc/audio/audio_receive_stream.h b/webrtc/audio/audio_receive_stream.h
index e344e22..adac883 100644
--- a/webrtc/audio/audio_receive_stream.h
+++ b/webrtc/audio/audio_receive_stream.h
@@ -46,6 +46,7 @@
void Start() override;
void Stop() override;
webrtc::AudioReceiveStream::Stats GetStats() const override;
+ int GetOutputLevel() const override;
void SetSink(std::unique_ptr<AudioSinkInterface> sink) override;
void SetGain(float gain) override;
diff --git a/webrtc/audio/audio_send_stream.cc b/webrtc/audio/audio_send_stream.cc
index ec18125..2d0c99b 100644
--- a/webrtc/audio/audio_send_stream.cc
+++ b/webrtc/audio/audio_send_stream.cc
@@ -25,7 +25,7 @@
#include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h"
#include "webrtc/voice_engine/channel_proxy.h"
#include "webrtc/voice_engine/include/voe_base.h"
-#include "webrtc/voice_engine/include/voe_volume_control.h"
+#include "webrtc/voice_engine/transmit_mixer.h"
#include "webrtc/voice_engine/voice_engine_impl.h"
namespace webrtc {
@@ -193,16 +193,11 @@
}
}
- // Local speech level.
- {
- ScopedVoEInterface<VoEVolumeControl> volume(voice_engine());
- unsigned int level = 0;
- int error = volume->GetSpeechInputLevelFullRange(level);
- RTC_DCHECK_EQ(0, error);
- stats.audio_level = static_cast<int32_t>(level);
- }
-
ScopedVoEInterface<VoEBase> base(voice_engine());
+ RTC_DCHECK(base->transmit_mixer());
+ stats.audio_level = base->transmit_mixer()->AudioLevelFullRange();
+ RTC_DCHECK_LE(0, stats.audio_level);
+
RTC_DCHECK(base->audio_processing());
auto audio_processing_stats = base->audio_processing()->GetStatistics();
stats.echo_delay_median_ms = audio_processing_stats.delay_median;
diff --git a/webrtc/audio/audio_send_stream_unittest.cc b/webrtc/audio/audio_send_stream_unittest.cc
index 8e8b0e9..b1a2401 100644
--- a/webrtc/audio/audio_send_stream_unittest.cc
+++ b/webrtc/audio/audio_send_stream_unittest.cc
@@ -26,6 +26,7 @@
#include "webrtc/test/gtest.h"
#include "webrtc/test/mock_voe_channel_proxy.h"
#include "webrtc/test/mock_voice_engine.h"
+#include "webrtc/voice_engine/transmit_mixer.h"
namespace webrtc {
namespace test {
@@ -46,7 +47,7 @@
const int kEchoReturnLoss = -65;
const int kEchoReturnLossEnhancement = 101;
const float kResidualEchoLikelihood = -1.0f;
-const unsigned int kSpeechInputLevel = 96;
+const int32_t kSpeechInputLevel = 96;
const CallStatistics kCallStats = {
1345, 1678, 1901, 1234, 112, 13456, 17890, 1567, -1890, -1123};
const ReportBlock kReportBlock = {456, 780, 123, 567, 890, 132, 143, 13354};
@@ -63,6 +64,11 @@
uint32_t max_padding_bitrate_bps));
};
+class MockTransmitMixer : public voe::TransmitMixer {
+ public:
+ MOCK_CONST_METHOD0(AudioLevelFullRange, int16_t());
+};
+
struct ConfigHelper {
explicit ConfigHelper(bool audio_bwe_enabled)
: simulated_clock_(123456),
@@ -213,11 +219,14 @@
.WillRepeatedly(Return(report_blocks));
EXPECT_CALL(*channel_proxy_, GetSendCodec(_))
.WillRepeatedly(DoAll(SetArgPointee<0>(kIsacCodec), Return(true)));
- EXPECT_CALL(voice_engine_, GetSpeechInputLevelFullRange(_))
- .WillRepeatedly(DoAll(SetArgReferee<0>(kSpeechInputLevel), Return(0)));
+ EXPECT_CALL(voice_engine_, transmit_mixer())
+ .WillRepeatedly(Return(&transmit_mixer_));
EXPECT_CALL(voice_engine_, audio_processing())
.WillRepeatedly(Return(&audio_processing_));
+ EXPECT_CALL(transmit_mixer_, AudioLevelFullRange())
+ .WillRepeatedly(Return(kSpeechInputLevel));
+
// We have to set the instantaneous value, the average, min and max. We only
// care about the instantaneous value, so we set all to the same value.
audio_processing_stats_.echo_return_loss.Set(
@@ -241,6 +250,7 @@
testing::NiceMock<MockCongestionObserver> bitrate_observer_;
testing::NiceMock<MockRemoteBitrateObserver> remote_bitrate_observer_;
MockAudioProcessing audio_processing_;
+ MockTransmitMixer transmit_mixer_;
AudioProcessing::AudioProcessingStatistics audio_processing_stats_;
PacketRouter packet_router_;
CongestionController congestion_controller_;