Add AudioReceiveStream::SetGain() method and use that in WVoMC::SetOutputVolume().
Removes the need to use VoEVolume::SetChannelOutputVolumeScaling().
BUG=webrtc:4690
Review-Url: https://codereview.webrtc.org/2062193002
Cr-Commit-Position: refs/heads/master@{#13194}
diff --git a/webrtc/audio/audio_receive_stream.cc b/webrtc/audio/audio_receive_stream.cc
index 15e4f61..c933f78 100644
--- a/webrtc/audio/audio_receive_stream.cc
+++ b/webrtc/audio/audio_receive_stream.cc
@@ -210,6 +210,11 @@
channel_proxy_->SetSink(std::move(sink));
}
+void AudioReceiveStream::SetGain(float gain) {
+ RTC_DCHECK(thread_checker_.CalledOnValidThread());
+ channel_proxy_->SetChannelOutputVolumeScaling(gain);
+}
+
const webrtc::AudioReceiveStream::Config& AudioReceiveStream::config() const {
RTC_DCHECK(thread_checker_.CalledOnValidThread());
return config_;
diff --git a/webrtc/audio/audio_receive_stream.h b/webrtc/audio/audio_receive_stream.h
index d99956c..284f98e 100644
--- a/webrtc/audio/audio_receive_stream.h
+++ b/webrtc/audio/audio_receive_stream.h
@@ -41,6 +41,7 @@
void Stop() override;
webrtc::AudioReceiveStream::Stats GetStats() const override;
void SetSink(std::unique_ptr<AudioSinkInterface> sink) override;
+ void SetGain(float gain) override;
void SignalNetworkState(NetworkState state);
bool DeliverRtcp(const uint8_t* packet, size_t length);
diff --git a/webrtc/audio/audio_receive_stream_unittest.cc b/webrtc/audio/audio_receive_stream_unittest.cc
index 2e789f9..8e26dd9 100644
--- a/webrtc/audio/audio_receive_stream_unittest.cc
+++ b/webrtc/audio/audio_receive_stream_unittest.cc
@@ -30,6 +30,7 @@
namespace {
using testing::_;
+using testing::FloatEq;
using testing::Return;
using testing::ReturnRef;
@@ -92,12 +93,12 @@
EXPECT_CALL(*channel_proxy_,
SetReceiveAudioLevelIndicationStatus(true, kAudioLevelId))
.Times(1);
- EXPECT_CALL(*channel_proxy_, EnableReceiveTransportSequenceNumber(
- kTransportSequenceNumberId))
- .Times(1);
EXPECT_CALL(*channel_proxy_,
- RegisterReceiverCongestionControlObjects(&packet_router_))
- .Times(1);
+ EnableReceiveTransportSequenceNumber(kTransportSequenceNumberId))
+ .Times(1);
+ EXPECT_CALL(*channel_proxy_,
+ RegisterReceiverCongestionControlObjects(&packet_router_))
+ .Times(1);
EXPECT_CALL(congestion_controller_, packet_router())
.WillOnce(Return(&packet_router_));
EXPECT_CALL(*channel_proxy_, ResetCongestionControlObjects())
@@ -303,7 +304,6 @@
EXPECT_TRUE(recv_stream.DeliverRtcp(&rtcp_packet[0], rtcp_packet.size()));
}
-
TEST(AudioReceiveStreamTest, GetStats) {
ConfigHelper helper;
internal::AudioReceiveStream recv_stream(
@@ -345,5 +345,14 @@
EXPECT_EQ(kCallStats.capture_start_ntp_time_ms_,
stats.capture_start_ntp_time_ms);
}
+
+TEST(AudioReceiveStreamTest, SetGain) {
+ ConfigHelper helper;
+ internal::AudioReceiveStream recv_stream(
+ helper.congestion_controller(), helper.config(), helper.audio_state());
+ EXPECT_CALL(*helper.channel_proxy(),
+ SetChannelOutputVolumeScaling(FloatEq(0.765f)));
+ recv_stream.SetGain(0.765f);
+}
} // namespace test
} // namespace webrtc