Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(484)

Unified Diff: webrtc/modules/audio_mixer/test/audio_mixer_unittest.cc

Issue 2230823004: Added a level indicator to new mixer. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@mixer_gn_fixes
Patch Set: Fixed audio mixer volume tests, inited SPL. Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/audio_mixer/test/audio_mixer_unittest.cc
diff --git a/webrtc/modules/audio_mixer/test/audio_mixer_unittest.cc b/webrtc/modules/audio_mixer/test/audio_mixer_unittest.cc
index 38f2b2ebff569981ea4b902f08748c9c316ab957..41de3e24d13540dffc51bc93af78439769ee6a28 100644
--- a/webrtc/modules/audio_mixer/test/audio_mixer_unittest.cc
+++ b/webrtc/modules/audio_mixer/test/audio_mixer_unittest.cc
@@ -370,6 +370,65 @@ TEST(AudioMixer, ParticipantNumberOfChannels) {
}
}
+// Test that the volume is reported as zero when the mixer input is
+// frames with no sound.
+TEST(AudioMixer, ZeroVolume) {
+ const int kId = 1;
+ std::unique_ptr<NewAudioConferenceMixer> mixer(
+ NewAudioConferenceMixer::Create(kId));
+ AudioFrame frame_for_mixing;
+
+ MockMixerAudioSource participant;
+ participant.fake_frame()->sample_rate_hz_ = 8000;
+ participant.fake_frame()->num_channels_ = 1;
+
+ // Frame duration 10ms.
+ participant.fake_frame()->samples_per_channel_ = 8000 / 100;
+
+ EXPECT_EQ(0, mixer->SetMixabilityStatus(&participant, true));
+ for (size_t i = 0; i < 11; i++) {
+ EXPECT_CALL(participant, GetAudioFrameWithMuted(_, 8000)).Times(Exactly(1));
+ mixer->Mix(8000, 1, &frame_for_mixing);
+ }
+
+ EXPECT_EQ(static_cast<uint32_t>(0), mixer->GetSpeechOutputLevel());
+ EXPECT_EQ(static_cast<uint32_t>(0), mixer->GetSpeechOutputLevelFullRange());
+}
+
+// Test that the volume is reported as full when the mixer input is
+// full frames.
+TEST(AudioMixer, FullVolume) {
+ const int kId = 1;
+ std::unique_ptr<NewAudioConferenceMixer> mixer(
+ NewAudioConferenceMixer::Create(kId));
+ AudioFrame frame_for_mixing;
+
+ MockMixerAudioSource participant;
+ participant.fake_frame()->sample_rate_hz_ = 8000;
+ participant.fake_frame()->num_channels_ = 1;
+
+ // Frame duration 10ms.
+ participant.fake_frame()->samples_per_channel_ = 8000 / 100;
+
+ // Fill participant frame data with maximal sound.
+ std::fill(participant.fake_frame()->data_,
+ participant.fake_frame()->data_ + 8000 / 100,
+ std::numeric_limits<int16_t>::max());
+
+ EXPECT_EQ(0, mixer->SetMixabilityStatus(&participant, true));
+ for (size_t i = 0; i < 11; i++) {
+ EXPECT_CALL(participant, GetAudioFrameWithMuted(_, 8000)).Times(Exactly(1));
+ mixer->Mix(8000, 1, &frame_for_mixing);
+ }
+
+ // 9 is the highest possible audio level
+ EXPECT_EQ(static_cast<uint32_t>(9), mixer->GetSpeechOutputLevel());
+
+ // 0x7fff = 32767 is the highest full range audio level.
+ EXPECT_EQ(static_cast<uint32_t>(std::numeric_limits<int16_t>::max()),
+ mixer->GetSpeechOutputLevelFullRange());
+}
+
TEST_F(BothMixersTest, CompareInitialFrameAudio) {
EXPECT_CALL(participant_, GetAudioFrameWithMuted(_, _)).Times(Exactly(1));

Powered by Google App Engine
This is Rietveld 408576698