| 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 03994ad2c7d3ae79c995c009221ecc03ca85d000..dce5279f765a4ac8c009111243944dd68e2a49a3 100644
|
| --- a/webrtc/modules/audio_mixer/test/audio_mixer_unittest.cc
|
| +++ b/webrtc/modules/audio_mixer/test/audio_mixer_unittest.cc
|
| @@ -59,6 +59,8 @@ class MockMixerAudioSource : public AudioMixer::Source {
|
|
|
| MOCK_METHOD1(GetAudioFrameWithMuted, AudioFrameWithMuted(int sample_rate_hz));
|
|
|
| + MOCK_METHOD0(ssrc, int());
|
| +
|
| AudioFrame* fake_frame() { return &fake_frame_; }
|
| AudioFrameInfo fake_info() { return fake_audio_frame_info_; }
|
| void set_fake_info(const AudioFrameInfo audio_frame_info) {
|
| @@ -87,7 +89,7 @@ void MixAndCompare(
|
| RTC_DCHECK(frames.size() == frame_info.size());
|
| RTC_DCHECK(frame_info.size() == expected_status.size());
|
|
|
| - const std::unique_ptr<AudioMixerImpl> mixer(AudioMixerImpl::Create());
|
| + const auto mixer = AudioMixerImpl::Create();
|
| std::vector<MockMixerAudioSource> participants(num_audio_sources);
|
|
|
| for (int i = 0; i < num_audio_sources; i++) {
|
| @@ -96,7 +98,7 @@ void MixAndCompare(
|
| }
|
|
|
| for (int i = 0; i < num_audio_sources; i++) {
|
| - EXPECT_EQ(0, mixer->SetMixabilityStatus(&participants[i], true));
|
| + EXPECT_TRUE(mixer->AddSource(&participants[i]));
|
| EXPECT_CALL(participants[i], GetAudioFrameWithMuted(kDefaultSampleRateHz))
|
| .Times(Exactly(1));
|
| }
|
| @@ -112,9 +114,9 @@ void MixAndCompare(
|
|
|
| TEST(AudioMixer, LargestEnergyVadActiveMixed) {
|
| constexpr int kAudioSources =
|
| - AudioMixer::kMaximumAmountOfMixedAudioSources + 3;
|
| + AudioMixerImpl::kMaximumAmountOfMixedAudioSources + 3;
|
|
|
| - const std::unique_ptr<AudioMixerImpl> mixer(AudioMixerImpl::Create());
|
| + const auto mixer = AudioMixerImpl::Create();
|
|
|
| MockMixerAudioSource participants[kAudioSources];
|
|
|
| @@ -125,7 +127,7 @@ TEST(AudioMixer, LargestEnergyVadActiveMixed) {
|
| // modified by a ramped-in window.
|
| participants[i].fake_frame()->data_[80] = i;
|
|
|
| - EXPECT_EQ(0, mixer->SetMixabilityStatus(&participants[i], true));
|
| + EXPECT_TRUE(mixer->AddSource(&participants[i]));
|
| EXPECT_CALL(participants[i], GetAudioFrameWithMuted(_)).Times(Exactly(1));
|
| }
|
|
|
| @@ -143,7 +145,8 @@ TEST(AudioMixer, LargestEnergyVadActiveMixed) {
|
| bool is_mixed =
|
| mixer->GetAudioSourceMixabilityStatusForTest(&participants[i]);
|
| if (i == kAudioSources - 1 ||
|
| - i < kAudioSources - 1 - AudioMixer::kMaximumAmountOfMixedAudioSources) {
|
| + i < kAudioSources - 1 -
|
| + AudioMixerImpl::kMaximumAmountOfMixedAudioSources) {
|
| EXPECT_FALSE(is_mixed) << "Mixing status of AudioSource #" << i
|
| << " wrong.";
|
| } else {
|
| @@ -154,7 +157,7 @@ TEST(AudioMixer, LargestEnergyVadActiveMixed) {
|
| }
|
|
|
| TEST(AudioMixer, FrameNotModifiedForSingleParticipant) {
|
| - const std::unique_ptr<AudioMixer> mixer(AudioMixer::Create());
|
| + const auto mixer = AudioMixerImpl::Create();
|
|
|
| MockMixerAudioSource participant;
|
|
|
| @@ -166,7 +169,7 @@ TEST(AudioMixer, FrameNotModifiedForSingleParticipant) {
|
| participant.fake_frame()->data_[j] = j;
|
| }
|
|
|
| - EXPECT_EQ(0, mixer->SetMixabilityStatus(&participant, true));
|
| + EXPECT_TRUE(mixer->AddSource(&participant));
|
| EXPECT_CALL(participant, GetAudioFrameWithMuted(_)).Times(Exactly(2));
|
|
|
| AudioFrame audio_frame;
|
| @@ -182,12 +185,12 @@ TEST(AudioMixer, FrameNotModifiedForSingleParticipant) {
|
| }
|
|
|
| TEST(AudioMixer, ParticipantSampleRate) {
|
| - const std::unique_ptr<AudioMixer> mixer(AudioMixer::Create());
|
| + const auto mixer = AudioMixerImpl::Create();
|
|
|
| MockMixerAudioSource participant;
|
| ResetFrame(participant.fake_frame());
|
|
|
| - EXPECT_EQ(0, mixer->SetMixabilityStatus(&participant, true));
|
| + EXPECT_TRUE(mixer->AddSource(&participant));
|
| for (auto frequency : {8000, 16000, 32000, 48000}) {
|
| EXPECT_CALL(participant, GetAudioFrameWithMuted(frequency))
|
| .Times(Exactly(1));
|
| @@ -199,12 +202,12 @@ TEST(AudioMixer, ParticipantSampleRate) {
|
| }
|
|
|
| TEST(AudioMixer, ParticipantNumberOfChannels) {
|
| - const std::unique_ptr<AudioMixer> mixer(AudioMixer::Create());
|
| + const auto mixer = AudioMixerImpl::Create();
|
|
|
| MockMixerAudioSource participant;
|
| ResetFrame(participant.fake_frame());
|
|
|
| - EXPECT_EQ(0, mixer->SetMixabilityStatus(&participant, true));
|
| + EXPECT_TRUE(mixer->AddSource(&participant));
|
| for (size_t number_of_channels : {1, 2}) {
|
| EXPECT_CALL(participant, GetAudioFrameWithMuted(kDefaultSampleRateHz))
|
| .Times(Exactly(1));
|
| @@ -217,9 +220,9 @@ TEST(AudioMixer, ParticipantNumberOfChannels) {
|
| // another participant with higher energy is added.
|
| TEST(AudioMixer, RampedOutSourcesShouldNotBeMarkedMixed) {
|
| constexpr int kAudioSources =
|
| - AudioMixer::kMaximumAmountOfMixedAudioSources + 1;
|
| + AudioMixerImpl::kMaximumAmountOfMixedAudioSources + 1;
|
|
|
| - const std::unique_ptr<AudioMixerImpl> mixer(AudioMixerImpl::Create());
|
| + const auto mixer = AudioMixerImpl::Create();
|
| MockMixerAudioSource participants[kAudioSources];
|
|
|
| for (int i = 0; i < kAudioSources; i++) {
|
| @@ -231,7 +234,7 @@ TEST(AudioMixer, RampedOutSourcesShouldNotBeMarkedMixed) {
|
|
|
| // Add all participants but the loudest for mixing.
|
| for (int i = 0; i < kAudioSources - 1; i++) {
|
| - EXPECT_EQ(0, mixer->SetMixabilityStatus(&participants[i], true));
|
| + EXPECT_TRUE(mixer->AddSource(&participants[i]));
|
| EXPECT_CALL(participants[i], GetAudioFrameWithMuted(kDefaultSampleRateHz))
|
| .Times(Exactly(1));
|
| }
|
| @@ -246,8 +249,7 @@ TEST(AudioMixer, RampedOutSourcesShouldNotBeMarkedMixed) {
|
| }
|
|
|
| // Add new participant with higher energy.
|
| - EXPECT_EQ(0,
|
| - mixer->SetMixabilityStatus(&participants[kAudioSources - 1], true));
|
| + EXPECT_TRUE(mixer->AddSource(&participants[kAudioSources - 1]));
|
| for (int i = 0; i < kAudioSources; i++) {
|
| EXPECT_CALL(participants[i], GetAudioFrameWithMuted(kDefaultSampleRateHz))
|
| .Times(Exactly(1));
|
| @@ -273,17 +275,16 @@ TEST(AudioMixer, ConstructFromOtherThread) {
|
| std::unique_ptr<rtc::Thread> init_thread = rtc::Thread::Create();
|
| std::unique_ptr<rtc::Thread> participant_thread = rtc::Thread::Create();
|
| init_thread->Start();
|
| - std::unique_ptr<AudioMixer> mixer(
|
| - init_thread->Invoke<std::unique_ptr<AudioMixer>>(
|
| - RTC_FROM_HERE, &AudioMixer::Create));
|
| + const auto mixer = init_thread->Invoke<rtc::scoped_refptr<AudioMixer>>(
|
| + RTC_FROM_HERE, &AudioMixerImpl::Create);
|
| MockMixerAudioSource participant;
|
|
|
| ResetFrame(participant.fake_frame());
|
|
|
| participant_thread->Start();
|
| - EXPECT_EQ(0, participant_thread->Invoke<int>(
|
| - RTC_FROM_HERE, rtc::Bind(&AudioMixer::SetMixabilityStatus,
|
| - mixer.get(), &participant, true)));
|
| + EXPECT_TRUE(participant_thread->Invoke<int>(
|
| + RTC_FROM_HERE,
|
| + rtc::Bind(&AudioMixer::AddSource, mixer.get(), &participant)));
|
|
|
| EXPECT_CALL(participant, GetAudioFrameWithMuted(kDefaultSampleRateHz))
|
| .Times(Exactly(1));
|
| @@ -294,7 +295,7 @@ TEST(AudioMixer, ConstructFromOtherThread) {
|
|
|
| TEST(AudioMixer, MutedShouldMixAfterUnmuted) {
|
| constexpr int kAudioSources =
|
| - AudioMixer::kMaximumAmountOfMixedAudioSources + 1;
|
| + AudioMixerImpl::kMaximumAmountOfMixedAudioSources + 1;
|
|
|
| std::vector<AudioFrame> frames(kAudioSources);
|
| for (auto& frame : frames) {
|
| @@ -312,7 +313,7 @@ TEST(AudioMixer, MutedShouldMixAfterUnmuted) {
|
|
|
| TEST(AudioMixer, PassiveShouldMixAfterNormal) {
|
| constexpr int kAudioSources =
|
| - AudioMixer::kMaximumAmountOfMixedAudioSources + 1;
|
| + AudioMixerImpl::kMaximumAmountOfMixedAudioSources + 1;
|
|
|
| std::vector<AudioFrame> frames(kAudioSources);
|
| for (auto& frame : frames) {
|
| @@ -330,7 +331,7 @@ TEST(AudioMixer, PassiveShouldMixAfterNormal) {
|
|
|
| TEST(AudioMixer, ActiveShouldMixBeforeLoud) {
|
| constexpr int kAudioSources =
|
| - AudioMixer::kMaximumAmountOfMixedAudioSources + 1;
|
| + AudioMixerImpl::kMaximumAmountOfMixedAudioSources + 1;
|
|
|
| std::vector<AudioFrame> frames(kAudioSources);
|
| for (auto& frame : frames) {
|
| @@ -350,7 +351,7 @@ TEST(AudioMixer, ActiveShouldMixBeforeLoud) {
|
|
|
| TEST(AudioMixer, UnmutedShouldMixBeforeLoud) {
|
| constexpr int kAudioSources =
|
| - AudioMixer::kMaximumAmountOfMixedAudioSources + 1;
|
| + AudioMixerImpl::kMaximumAmountOfMixedAudioSources + 1;
|
|
|
| std::vector<AudioFrame> frames(kAudioSources);
|
| for (auto& frame : frames) {
|
|
|