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

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: Made local variable const. 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..0359b8051a705420bb15288bfff8b38e583c700f 100644
--- a/webrtc/modules/audio_mixer/test/audio_mixer_unittest.cc
+++ b/webrtc/modules/audio_mixer/test/audio_mixer_unittest.cc
@@ -77,13 +77,14 @@ class MockMixerAudioSource : public MixerAudioSource {
}
private:
- AudioFrame fake_frame_;
+ AudioFrame fake_frame_, output_frame_;
AudioFrameInfo fake_audio_frame_info_;
AudioFrameWithMuted FakeAudioFrameWithMuted(const int32_t id,
int sample_rate_hz) {
+ output_frame_.CopyFrom(fake_frame_);
return {
- fake_frame(), // audio_frame_pointer
- fake_info(), // audio_frame_info
+ &output_frame_, // audio_frame_pointer
+ fake_info(), // audio_frame_info
};
}
};
@@ -274,10 +275,10 @@ TEST(AudioMixer, AnonymousAndNamed) {
}
TEST(AudioMixer, LargestEnergyVadActiveMixed) {
- const int kId = 1;
- const int kAudioSources =
+ constexpr int kId = 1;
+ constexpr int kAudioSources =
NewAudioConferenceMixer::kMaximumAmountOfMixedAudioSources + 3;
- const int kSampleRateHz = 32000;
+ constexpr int kSampleRateHz = 32000;
std::unique_ptr<NewAudioConferenceMixer> mixer(
NewAudioConferenceMixer::Create(kId));
@@ -328,7 +329,7 @@ TEST(AudioMixer, LargestEnergyVadActiveMixed) {
}
TEST(AudioMixer, ParticipantSampleRate) {
- const int kId = 1;
+ constexpr int kId = 1;
std::unique_ptr<NewAudioConferenceMixer> mixer(
NewAudioConferenceMixer::Create(kId));
AudioFrame frame_for_mixing;
@@ -350,7 +351,7 @@ TEST(AudioMixer, ParticipantSampleRate) {
}
TEST(AudioMixer, ParticipantNumberOfChannels) {
- const int kId = 1;
+ constexpr int kId = 1;
std::unique_ptr<NewAudioConferenceMixer> mixer(
NewAudioConferenceMixer::Create(kId));
AudioFrame frame_for_mixing;
@@ -370,6 +371,69 @@ TEST(AudioMixer, ParticipantNumberOfChannels) {
}
}
+// Test that the volume is reported as zero when the mixer input
+// comprises only zero values.
+TEST(AudioMixer, LevelIsZeroWhenMixingZeroes) {
+ constexpr int kId = 1;
+ constexpr int kSampleRateHz = 8000;
+ std::unique_ptr<NewAudioConferenceMixer> mixer(
+ NewAudioConferenceMixer::Create(kId));
+ AudioFrame frame_for_mixing;
+
+ MockMixerAudioSource participant;
+ participant.fake_frame()->sample_rate_hz_ = kSampleRateHz;
+ participant.fake_frame()->num_channels_ = 1;
+
+ // Frame duration 10ms.
+ participant.fake_frame()->samples_per_channel_ = kSampleRateHz / 100;
+
+ EXPECT_EQ(0, mixer->SetMixabilityStatus(&participant, true));
+ for (size_t i = 0; i < 11; i++) {
+ EXPECT_CALL(participant, GetAudioFrameWithMuted(_, kSampleRateHz))
+ .Times(Exactly(1));
+ mixer->Mix(8000, 1, &frame_for_mixing);
+ }
+
+ EXPECT_EQ(0, mixer->GetOutputAudioLevel());
+ EXPECT_EQ(0, mixer->GetOutputAudioLevelFullRange());
+}
+
+// Test that the reported volume is maximal when the mixer
+// input comprises frames with maximal values.
+TEST(AudioMixer, LevelIsMaximalWhenMixingMaximalValues) {
+ constexpr int kId = 1;
+ constexpr int kSampleRateHz = 8000;
+ std::unique_ptr<NewAudioConferenceMixer> mixer(
+ NewAudioConferenceMixer::Create(kId));
+ AudioFrame frame_for_mixing;
+
+ MockMixerAudioSource participant;
+ participant.fake_frame()->sample_rate_hz_ = kSampleRateHz;
+ participant.fake_frame()->num_channels_ = 1;
+
+ // Frame duration 10ms.
+ participant.fake_frame()->samples_per_channel_ = kSampleRateHz / 100;
+
+ // Fill participant frame data with maximal sound.
+ std::fill(participant.fake_frame()->data_,
+ participant.fake_frame()->data_ + kSampleRateHz / 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(_, kSampleRateHz))
+ .Times(Exactly(1));
+ mixer->Mix(8000, 1, &frame_for_mixing);
+ }
+
+ // 9 is the highest possible audio level
+ EXPECT_EQ(9, mixer->GetOutputAudioLevel());
+
+ // 0x7fff = 32767 is the highest full range audio level.
+ EXPECT_EQ(std::numeric_limits<int16_t>::max(),
+ mixer->GetOutputAudioLevelFullRange());
+}
+
TEST_F(BothMixersTest, CompareInitialFrameAudio) {
EXPECT_CALL(participant_, GetAudioFrameWithMuted(_, _)).Times(Exactly(1));
« no previous file with comments | « webrtc/modules/audio_mixer/new_audio_conference_mixer_impl.cc ('k') | webrtc/voice_engine/level_indicator.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698