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

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: Updated comments in volume test. 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..710fb3cca00da49755dfb9fe696e648576eecb73 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
minyue-webrtc 2016/08/11 10:27:33 is -> comprises only
aleloi 2016/08/11 12:15:20 Done.
+// frames with no sound.
minyue-webrtc 2016/08/11 10:27:33 no sound -> zero values
aleloi 2016/08/11 12:15:20 Done.
+TEST(AudioMixer, ZeroVolume) {
minyue-webrtc 2016/08/11 10:27:33 ZeroVolume -> LevelIsZeroWhenMixingZeros
aleloi 2016/08/11 12:15:20 Done.
+ 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;
minyue-webrtc 2016/08/11 10:27:33 define kSampleRate and use it to replace 8000
aleloi 2016/08/11 12:15:19 Done.
aleloi 2016/08/11 12:15:19 Done.
+ 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 < 10; 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
minyue-webrtc 2016/08/11 10:27:33 comprises frames with max values of int16_t.
minyue-webrtc 2016/08/11 10:27:33 maximum
aleloi 2016/08/11 12:15:20 Done.
aleloi 2016/08/11 12:15:20 Done.
+// full frames.
+TEST(AudioMixer, FullVolume) {
minyue-webrtc 2016/08/11 10:27:33 curious, what if one participant is zero and anoth
minyue-webrtc 2016/08/11 10:27:33 FullVolume -> LevelIsMaxWhenMixingMaxValues
aleloi 2016/08/11 12:15:20 Thanks! I thought about how to name the tests, but
aleloi 2016/08/11 12:15:20 It should be max, or one off from max due to round
aleloi 2016/08/11 12:25:22 Thinking on it again, I see that I was probably wr
+ 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 < 10; 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