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

Side by Side 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 participant.fake_frame()->samples_per_channel_ = 8000 / 100; 363 participant.fake_frame()->samples_per_channel_ = 8000 / 100;
364 364
365 EXPECT_EQ(0, mixer->SetMixabilityStatus(&participant, true)); 365 EXPECT_EQ(0, mixer->SetMixabilityStatus(&participant, true));
366 for (size_t number_of_channels : {1, 2}) { 366 for (size_t number_of_channels : {1, 2}) {
367 EXPECT_CALL(participant, GetAudioFrameWithMuted(_, 8000)).Times(Exactly(1)); 367 EXPECT_CALL(participant, GetAudioFrameWithMuted(_, 8000)).Times(Exactly(1));
368 mixer->Mix(8000, number_of_channels, &frame_for_mixing); 368 mixer->Mix(8000, number_of_channels, &frame_for_mixing);
369 EXPECT_EQ(number_of_channels, frame_for_mixing.num_channels_); 369 EXPECT_EQ(number_of_channels, frame_for_mixing.num_channels_);
370 } 370 }
371 } 371 }
372 372
373 // Test that the volume is reported as zero when the mixer input is
374 // frames with no sound.
375 TEST(AudioMixer, ZeroVolume) {
376 const int kId = 1;
377 std::unique_ptr<NewAudioConferenceMixer> mixer(
378 NewAudioConferenceMixer::Create(kId));
379 AudioFrame frame_for_mixing;
380
381 MockMixerAudioSource participant;
382 participant.fake_frame()->sample_rate_hz_ = 8000;
383 participant.fake_frame()->num_channels_ = 1;
384
385 // Frame duration 10ms.
386 participant.fake_frame()->samples_per_channel_ = 8000 / 100;
387
388 EXPECT_EQ(0, mixer->SetMixabilityStatus(&participant, true));
389 for (size_t i = 0; i < 11; i++) {
390 EXPECT_CALL(participant, GetAudioFrameWithMuted(_, 8000)).Times(Exactly(1));
391 mixer->Mix(8000, 1, &frame_for_mixing);
392 }
393
394 EXPECT_EQ(static_cast<uint32_t>(0), mixer->GetSpeechOutputLevel());
395 EXPECT_EQ(static_cast<uint32_t>(0), mixer->GetSpeechOutputLevelFullRange());
396 }
397
398 // Test that the volume is reported as full when the mixer input is
399 // full frames.
400 TEST(AudioMixer, FullVolume) {
401 const int kId = 1;
402 std::unique_ptr<NewAudioConferenceMixer> mixer(
403 NewAudioConferenceMixer::Create(kId));
404 AudioFrame frame_for_mixing;
405
406 MockMixerAudioSource participant;
407 participant.fake_frame()->sample_rate_hz_ = 8000;
408 participant.fake_frame()->num_channels_ = 1;
409
410 // Frame duration 10ms.
411 participant.fake_frame()->samples_per_channel_ = 8000 / 100;
412
413 // Fill participant frame data with maximal sound.
414 std::fill(participant.fake_frame()->data_,
415 participant.fake_frame()->data_ + 8000 / 100,
416 std::numeric_limits<int16_t>::max());
417
418 EXPECT_EQ(0, mixer->SetMixabilityStatus(&participant, true));
419 for (size_t i = 0; i < 11; i++) {
420 EXPECT_CALL(participant, GetAudioFrameWithMuted(_, 8000)).Times(Exactly(1));
421 mixer->Mix(8000, 1, &frame_for_mixing);
422 }
423
424 // 9 is the highest possible audio level
425 EXPECT_EQ(static_cast<uint32_t>(9), mixer->GetSpeechOutputLevel());
426
427 // 0x7fff = 32767 is the highest full range audio level.
428 EXPECT_EQ(static_cast<uint32_t>(std::numeric_limits<int16_t>::max()),
429 mixer->GetSpeechOutputLevelFullRange());
430 }
431
373 TEST_F(BothMixersTest, CompareInitialFrameAudio) { 432 TEST_F(BothMixersTest, CompareInitialFrameAudio) {
374 EXPECT_CALL(participant_, GetAudioFrameWithMuted(_, _)).Times(Exactly(1)); 433 EXPECT_CALL(participant_, GetAudioFrameWithMuted(_, _)).Times(Exactly(1));
375 434
376 // Make sure the participant is marked as 'non-mixed' so that it is 435 // Make sure the participant is marked as 'non-mixed' so that it is
377 // ramped in next round. 436 // ramped in next round.
378 ResetAudioSource(); 437 ResetAudioSource();
379 438
380 // Construct the expected sound for the first mixing round. 439 // Construct the expected sound for the first mixing round.
381 mixing_round_frame.CopyFrom(*participant_.fake_frame()); 440 mixing_round_frame.CopyFrom(*participant_.fake_frame());
382 RampIn(mixing_round_frame); 441 RampIn(mixing_round_frame);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
474 MixerParticipant::AudioFrameInfo::kMuted); 533 MixerParticipant::AudioFrameInfo::kMuted);
475 } else { 534 } else {
476 AddParticipant(&audio_frames[i], 535 AddParticipant(&audio_frames[i],
477 MixerParticipant::AudioFrameInfo::kNormal); 536 MixerParticipant::AudioFrameInfo::kNormal);
478 } 537 }
479 MixAndCompare(); 538 MixAndCompare();
480 } 539 }
481 } 540 }
482 541
483 } // namespace webrtc 542 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698