| OLD | NEW |
| 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 |
| 11 #include <memory> | 11 #include <memory> |
| 12 #include <utility> | 12 #include <utility> |
| 13 | 13 |
| 14 #include "testing/gmock/include/gmock/gmock.h" | 14 #include "testing/gmock/include/gmock/gmock.h" |
| 15 #include "webrtc/modules/audio_mixer/audio_mixer_defines.h" | 15 #include "webrtc/modules/audio_mixer/audio_mixer_defines.h" |
| 16 #include "webrtc/modules/audio_mixer/new_audio_conference_mixer.h" | 16 #include "webrtc/modules/audio_mixer/audio_mixer.h" |
| 17 | 17 |
| 18 using testing::_; | 18 using testing::_; |
| 19 using testing::Exactly; | 19 using testing::Exactly; |
| 20 using testing::Invoke; | 20 using testing::Invoke; |
| 21 using testing::Return; | 21 using testing::Return; |
| 22 | 22 |
| 23 namespace webrtc { | 23 namespace webrtc { |
| 24 | 24 |
| 25 namespace { | 25 namespace { |
| 26 | 26 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 // Creates participants from |frames| and |frame_info| and adds them | 78 // Creates participants from |frames| and |frame_info| and adds them |
| 79 // to the mixer. Compares mixed status with |expected_status| | 79 // to the mixer. Compares mixed status with |expected_status| |
| 80 void MixAndCompare( | 80 void MixAndCompare( |
| 81 const std::vector<AudioFrame>& frames, | 81 const std::vector<AudioFrame>& frames, |
| 82 const std::vector<MixerAudioSource::AudioFrameInfo>& frame_info, | 82 const std::vector<MixerAudioSource::AudioFrameInfo>& frame_info, |
| 83 const std::vector<bool>& expected_status) { | 83 const std::vector<bool>& expected_status) { |
| 84 int num_audio_sources = frames.size(); | 84 int num_audio_sources = frames.size(); |
| 85 RTC_DCHECK(frames.size() == frame_info.size()); | 85 RTC_DCHECK(frames.size() == frame_info.size()); |
| 86 RTC_DCHECK(frame_info.size() == expected_status.size()); | 86 RTC_DCHECK(frame_info.size() == expected_status.size()); |
| 87 | 87 |
| 88 std::unique_ptr<NewAudioConferenceMixer> mixer( | 88 const std::unique_ptr<AudioMixer> mixer(AudioMixer::Create(kId)); |
| 89 NewAudioConferenceMixer::Create(kId)); | |
| 90 std::vector<MockMixerAudioSource> participants(num_audio_sources); | 89 std::vector<MockMixerAudioSource> participants(num_audio_sources); |
| 91 | 90 |
| 92 for (int i = 0; i < num_audio_sources; i++) { | 91 for (int i = 0; i < num_audio_sources; i++) { |
| 93 participants[i].fake_frame()->CopyFrom(frames[i]); | 92 participants[i].fake_frame()->CopyFrom(frames[i]); |
| 94 participants[i].set_fake_info(frame_info[i]); | 93 participants[i].set_fake_info(frame_info[i]); |
| 95 } | 94 } |
| 96 | 95 |
| 97 for (int i = 0; i < num_audio_sources; i++) { | 96 for (int i = 0; i < num_audio_sources; i++) { |
| 98 EXPECT_EQ(0, mixer->SetMixabilityStatus(&participants[i], true)); | 97 EXPECT_EQ(0, mixer->SetMixabilityStatus(&participants[i], true)); |
| 99 EXPECT_CALL(participants[i], | 98 EXPECT_CALL(participants[i], |
| 100 GetAudioFrameWithMuted(_, kDefaultSampleRateHz)) | 99 GetAudioFrameWithMuted(_, kDefaultSampleRateHz)) |
| 101 .Times(Exactly(1)); | 100 .Times(Exactly(1)); |
| 102 } | 101 } |
| 103 | 102 |
| 104 mixer->Mix(kDefaultSampleRateHz, 1, &frame_for_mixing); | 103 mixer->Mix(kDefaultSampleRateHz, 1, &frame_for_mixing); |
| 105 | 104 |
| 106 for (int i = 0; i < num_audio_sources; i++) { | 105 for (int i = 0; i < num_audio_sources; i++) { |
| 107 EXPECT_EQ(participants[i].IsMixed(), expected_status[i]) | 106 EXPECT_EQ(participants[i].IsMixed(), expected_status[i]) |
| 108 << "Mixed status of AudioSource #" << i << " wrong."; | 107 << "Mixed status of AudioSource #" << i << " wrong."; |
| 109 } | 108 } |
| 110 } | 109 } |
| 111 | 110 |
| 112 TEST(AudioMixer, AnonymousAndNamed) { | 111 TEST(AudioMixer, AnonymousAndNamed) { |
| 113 // Should not matter even if partipants are more than | 112 // Should not matter even if partipants are more than |
| 114 // kMaximumAmountOfMixedAudioSources. | 113 // kMaximumAmountOfMixedAudioSources. |
| 115 constexpr int kNamed = | 114 constexpr int kNamed = AudioMixer::kMaximumAmountOfMixedAudioSources + 1; |
| 116 NewAudioConferenceMixer::kMaximumAmountOfMixedAudioSources + 1; | 115 constexpr int kAnonymous = AudioMixer::kMaximumAmountOfMixedAudioSources + 1; |
| 117 constexpr int kAnonymous = | |
| 118 NewAudioConferenceMixer::kMaximumAmountOfMixedAudioSources + 1; | |
| 119 | 116 |
| 120 std::unique_ptr<NewAudioConferenceMixer> mixer( | 117 const std::unique_ptr<AudioMixer> mixer(AudioMixer::Create(kId)); |
| 121 NewAudioConferenceMixer::Create(kId)); | |
| 122 | 118 |
| 123 MockMixerAudioSource named[kNamed]; | 119 MockMixerAudioSource named[kNamed]; |
| 124 MockMixerAudioSource anonymous[kAnonymous]; | 120 MockMixerAudioSource anonymous[kAnonymous]; |
| 125 | 121 |
| 126 for (int i = 0; i < kNamed; ++i) { | 122 for (int i = 0; i < kNamed; ++i) { |
| 127 EXPECT_EQ(0, mixer->SetMixabilityStatus(&named[i], true)); | 123 EXPECT_EQ(0, mixer->SetMixabilityStatus(&named[i], true)); |
| 128 EXPECT_TRUE(mixer->MixabilityStatus(named[i])); | 124 EXPECT_TRUE(mixer->MixabilityStatus(named[i])); |
| 129 } | 125 } |
| 130 | 126 |
| 131 for (int i = 0; i < kAnonymous; ++i) { | 127 for (int i = 0; i < kAnonymous; ++i) { |
| (...skipping 26 matching lines...) Expand all Loading... |
| 158 | 154 |
| 159 // SetMixabilityStatus(anonymous, false) will remove anonymous from both | 155 // SetMixabilityStatus(anonymous, false) will remove anonymous from both |
| 160 // anonymous and named groups. | 156 // anonymous and named groups. |
| 161 EXPECT_EQ(0, mixer->SetMixabilityStatus(&anonymous[kAnonymous - 1], false)); | 157 EXPECT_EQ(0, mixer->SetMixabilityStatus(&anonymous[kAnonymous - 1], false)); |
| 162 EXPECT_FALSE(mixer->AnonymousMixabilityStatus(anonymous[kAnonymous - 1])); | 158 EXPECT_FALSE(mixer->AnonymousMixabilityStatus(anonymous[kAnonymous - 1])); |
| 163 EXPECT_FALSE(mixer->MixabilityStatus(anonymous[kAnonymous - 1])); | 159 EXPECT_FALSE(mixer->MixabilityStatus(anonymous[kAnonymous - 1])); |
| 164 } | 160 } |
| 165 | 161 |
| 166 TEST(AudioMixer, LargestEnergyVadActiveMixed) { | 162 TEST(AudioMixer, LargestEnergyVadActiveMixed) { |
| 167 constexpr int kAudioSources = | 163 constexpr int kAudioSources = |
| 168 NewAudioConferenceMixer::kMaximumAmountOfMixedAudioSources + 3; | 164 AudioMixer::kMaximumAmountOfMixedAudioSources + 3; |
| 169 | 165 |
| 170 std::unique_ptr<NewAudioConferenceMixer> mixer( | 166 const std::unique_ptr<AudioMixer> mixer(AudioMixer::Create(kId)); |
| 171 NewAudioConferenceMixer::Create(kId)); | |
| 172 | 167 |
| 173 MockMixerAudioSource participants[kAudioSources]; | 168 MockMixerAudioSource participants[kAudioSources]; |
| 174 | 169 |
| 175 for (int i = 0; i < kAudioSources; ++i) { | 170 for (int i = 0; i < kAudioSources; ++i) { |
| 176 ResetFrame(participants[i].fake_frame()); | 171 ResetFrame(participants[i].fake_frame()); |
| 177 | 172 |
| 178 // We set the 80-th sample value since the first 80 samples may be | 173 // We set the 80-th sample value since the first 80 samples may be |
| 179 // modified by a ramped-in window. | 174 // modified by a ramped-in window. |
| 180 participants[i].fake_frame()->data_[80] = i; | 175 participants[i].fake_frame()->data_[80] = i; |
| 181 | 176 |
| 182 EXPECT_EQ(0, mixer->SetMixabilityStatus(&participants[i], true)); | 177 EXPECT_EQ(0, mixer->SetMixabilityStatus(&participants[i], true)); |
| 183 EXPECT_CALL(participants[i], GetAudioFrameWithMuted(_, _)) | 178 EXPECT_CALL(participants[i], GetAudioFrameWithMuted(_, _)) |
| 184 .Times(Exactly(1)); | 179 .Times(Exactly(1)); |
| 185 } | 180 } |
| 186 | 181 |
| 187 // Last participant gives audio frame with passive VAD, although it has the | 182 // Last participant gives audio frame with passive VAD, although it has the |
| 188 // largest energy. | 183 // largest energy. |
| 189 participants[kAudioSources - 1].fake_frame()->vad_activity_ = | 184 participants[kAudioSources - 1].fake_frame()->vad_activity_ = |
| 190 AudioFrame::kVadPassive; | 185 AudioFrame::kVadPassive; |
| 191 | 186 |
| 192 AudioFrame audio_frame; | 187 AudioFrame audio_frame; |
| 193 mixer->Mix(kDefaultSampleRateHz, | 188 mixer->Mix(kDefaultSampleRateHz, |
| 194 1, // number of channels | 189 1, // number of channels |
| 195 &audio_frame); | 190 &audio_frame); |
| 196 | 191 |
| 197 for (int i = 0; i < kAudioSources; ++i) { | 192 for (int i = 0; i < kAudioSources; ++i) { |
| 198 bool is_mixed = participants[i].IsMixed(); | 193 bool is_mixed = participants[i].IsMixed(); |
| 199 if (i == kAudioSources - 1 || | 194 if (i == kAudioSources - 1 || |
| 200 i < kAudioSources - 1 - | 195 i < kAudioSources - 1 - AudioMixer::kMaximumAmountOfMixedAudioSources) { |
| 201 NewAudioConferenceMixer::kMaximumAmountOfMixedAudioSources) { | |
| 202 EXPECT_FALSE(is_mixed) << "Mixing status of AudioSource #" << i | 196 EXPECT_FALSE(is_mixed) << "Mixing status of AudioSource #" << i |
| 203 << " wrong."; | 197 << " wrong."; |
| 204 } else { | 198 } else { |
| 205 EXPECT_TRUE(is_mixed) << "Mixing status of AudioSource #" << i | 199 EXPECT_TRUE(is_mixed) << "Mixing status of AudioSource #" << i |
| 206 << " wrong."; | 200 << " wrong."; |
| 207 } | 201 } |
| 208 } | 202 } |
| 209 } | 203 } |
| 210 | 204 |
| 211 TEST(AudioMixer, ParticipantSampleRate) { | 205 TEST(AudioMixer, ParticipantSampleRate) { |
| 212 std::unique_ptr<NewAudioConferenceMixer> mixer( | 206 const std::unique_ptr<AudioMixer> mixer(AudioMixer::Create(kId)); |
| 213 NewAudioConferenceMixer::Create(kId)); | |
| 214 | 207 |
| 215 MockMixerAudioSource participant; | 208 MockMixerAudioSource participant; |
| 216 ResetFrame(participant.fake_frame()); | 209 ResetFrame(participant.fake_frame()); |
| 217 | 210 |
| 218 EXPECT_EQ(0, mixer->SetMixabilityStatus(&participant, true)); | 211 EXPECT_EQ(0, mixer->SetMixabilityStatus(&participant, true)); |
| 219 for (auto frequency : {8000, 16000, 32000, 48000}) { | 212 for (auto frequency : {8000, 16000, 32000, 48000}) { |
| 220 EXPECT_CALL(participant, GetAudioFrameWithMuted(_, frequency)) | 213 EXPECT_CALL(participant, GetAudioFrameWithMuted(_, frequency)) |
| 221 .Times(Exactly(1)); | 214 .Times(Exactly(1)); |
| 222 mixer->Mix(frequency, 1, &frame_for_mixing); | 215 mixer->Mix(frequency, 1, &frame_for_mixing); |
| 223 EXPECT_EQ(frequency, frame_for_mixing.sample_rate_hz_); | 216 EXPECT_EQ(frequency, frame_for_mixing.sample_rate_hz_); |
| 224 } | 217 } |
| 225 } | 218 } |
| 226 | 219 |
| 227 TEST(AudioMixer, ParticipantNumberOfChannels) { | 220 TEST(AudioMixer, ParticipantNumberOfChannels) { |
| 228 std::unique_ptr<NewAudioConferenceMixer> mixer( | 221 const std::unique_ptr<AudioMixer> mixer(AudioMixer::Create(kId)); |
| 229 NewAudioConferenceMixer::Create(kId)); | |
| 230 | 222 |
| 231 MockMixerAudioSource participant; | 223 MockMixerAudioSource participant; |
| 232 ResetFrame(participant.fake_frame()); | 224 ResetFrame(participant.fake_frame()); |
| 233 | 225 |
| 234 EXPECT_EQ(0, mixer->SetMixabilityStatus(&participant, true)); | 226 EXPECT_EQ(0, mixer->SetMixabilityStatus(&participant, true)); |
| 235 for (size_t number_of_channels : {1, 2}) { | 227 for (size_t number_of_channels : {1, 2}) { |
| 236 EXPECT_CALL(participant, GetAudioFrameWithMuted(_, kDefaultSampleRateHz)) | 228 EXPECT_CALL(participant, GetAudioFrameWithMuted(_, kDefaultSampleRateHz)) |
| 237 .Times(Exactly(1)); | 229 .Times(Exactly(1)); |
| 238 mixer->Mix(kDefaultSampleRateHz, number_of_channels, &frame_for_mixing); | 230 mixer->Mix(kDefaultSampleRateHz, number_of_channels, &frame_for_mixing); |
| 239 EXPECT_EQ(number_of_channels, frame_for_mixing.num_channels_); | 231 EXPECT_EQ(number_of_channels, frame_for_mixing.num_channels_); |
| 240 } | 232 } |
| 241 } | 233 } |
| 242 | 234 |
| 243 // Test that the volume is reported as zero when the mixer input | 235 // Test that the volume is reported as zero when the mixer input |
| 244 // comprises only zero values. | 236 // comprises only zero values. |
| 245 TEST(AudioMixer, LevelIsZeroWhenMixingZeroes) { | 237 TEST(AudioMixer, LevelIsZeroWhenMixingZeroes) { |
| 246 std::unique_ptr<NewAudioConferenceMixer> mixer( | 238 const std::unique_ptr<AudioMixer> mixer(AudioMixer::Create(kId)); |
| 247 NewAudioConferenceMixer::Create(kId)); | |
| 248 | 239 |
| 249 MockMixerAudioSource participant; | 240 MockMixerAudioSource participant; |
| 250 ResetFrame(participant.fake_frame()); | 241 ResetFrame(participant.fake_frame()); |
| 251 | 242 |
| 252 EXPECT_EQ(0, mixer->SetMixabilityStatus(&participant, true)); | 243 EXPECT_EQ(0, mixer->SetMixabilityStatus(&participant, true)); |
| 253 for (int i = 0; i < 11; i++) { | 244 for (int i = 0; i < 11; i++) { |
| 254 EXPECT_CALL(participant, GetAudioFrameWithMuted(_, kDefaultSampleRateHz)) | 245 EXPECT_CALL(participant, GetAudioFrameWithMuted(_, kDefaultSampleRateHz)) |
| 255 .Times(Exactly(1)); | 246 .Times(Exactly(1)); |
| 256 mixer->Mix(kDefaultSampleRateHz, 1, &frame_for_mixing); | 247 mixer->Mix(kDefaultSampleRateHz, 1, &frame_for_mixing); |
| 257 } | 248 } |
| 258 | 249 |
| 259 EXPECT_EQ(0, mixer->GetOutputAudioLevel()); | 250 EXPECT_EQ(0, mixer->GetOutputAudioLevel()); |
| 260 EXPECT_EQ(0, mixer->GetOutputAudioLevelFullRange()); | 251 EXPECT_EQ(0, mixer->GetOutputAudioLevelFullRange()); |
| 261 } | 252 } |
| 262 | 253 |
| 263 // Test that the reported volume is maximal when the mixer | 254 // Test that the reported volume is maximal when the mixer |
| 264 // input comprises frames with maximal values. | 255 // input comprises frames with maximal values. |
| 265 TEST(AudioMixer, LevelIsMaximalWhenMixingMaximalValues) { | 256 TEST(AudioMixer, LevelIsMaximalWhenMixingMaximalValues) { |
| 266 std::unique_ptr<NewAudioConferenceMixer> mixer( | 257 const std::unique_ptr<AudioMixer> mixer(AudioMixer::Create(kId)); |
| 267 NewAudioConferenceMixer::Create(kId)); | |
| 268 | 258 |
| 269 MockMixerAudioSource participant; | 259 MockMixerAudioSource participant; |
| 270 ResetFrame(participant.fake_frame()); | 260 ResetFrame(participant.fake_frame()); |
| 271 | 261 |
| 272 // Fill participant frame data with maximal sound. | 262 // Fill participant frame data with maximal sound. |
| 273 std::fill(participant.fake_frame()->data_, | 263 std::fill(participant.fake_frame()->data_, |
| 274 participant.fake_frame()->data_ + kDefaultSampleRateHz / 100, | 264 participant.fake_frame()->data_ + kDefaultSampleRateHz / 100, |
| 275 std::numeric_limits<int16_t>::max()); | 265 std::numeric_limits<int16_t>::max()); |
| 276 | 266 |
| 277 EXPECT_EQ(0, mixer->SetMixabilityStatus(&participant, true)); | 267 EXPECT_EQ(0, mixer->SetMixabilityStatus(&participant, true)); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 289 | 279 |
| 290 // 0x7fff = 32767 is the highest full range audio level. | 280 // 0x7fff = 32767 is the highest full range audio level. |
| 291 EXPECT_EQ(std::numeric_limits<int16_t>::max(), | 281 EXPECT_EQ(std::numeric_limits<int16_t>::max(), |
| 292 mixer->GetOutputAudioLevelFullRange()); | 282 mixer->GetOutputAudioLevelFullRange()); |
| 293 } | 283 } |
| 294 | 284 |
| 295 // Maximal amount of participants are mixed one iteration, then | 285 // Maximal amount of participants are mixed one iteration, then |
| 296 // another participant with higher energy is added. | 286 // another participant with higher energy is added. |
| 297 TEST(AudioMixer, RampedOutSourcesShouldNotBeMarkedMixed) { | 287 TEST(AudioMixer, RampedOutSourcesShouldNotBeMarkedMixed) { |
| 298 constexpr int kAudioSources = | 288 constexpr int kAudioSources = |
| 299 NewAudioConferenceMixer::kMaximumAmountOfMixedAudioSources + 1; | 289 AudioMixer::kMaximumAmountOfMixedAudioSources + 1; |
| 300 | 290 |
| 301 std::unique_ptr<NewAudioConferenceMixer> mixer( | 291 const std::unique_ptr<AudioMixer> mixer(AudioMixer::Create(kId)); |
| 302 NewAudioConferenceMixer::Create(kId)); | |
| 303 MockMixerAudioSource participants[kAudioSources]; | 292 MockMixerAudioSource participants[kAudioSources]; |
| 304 | 293 |
| 305 for (int i = 0; i < kAudioSources; i++) { | 294 for (int i = 0; i < kAudioSources; i++) { |
| 306 ResetFrame(participants[i].fake_frame()); | 295 ResetFrame(participants[i].fake_frame()); |
| 307 // Set the participant audio energy to increase with the index | 296 // Set the participant audio energy to increase with the index |
| 308 // |i|. | 297 // |i|. |
| 309 participants[i].fake_frame()->data_[0] = 100 * i; | 298 participants[i].fake_frame()->data_[0] = 100 * i; |
| 310 } | 299 } |
| 311 | 300 |
| 312 // Add all participants but the loudest for mixing. | 301 // Add all participants but the loudest for mixing. |
| (...skipping 30 matching lines...) Expand all Loading... |
| 343 | 332 |
| 344 // The loudest participants should have been mixed. | 333 // The loudest participants should have been mixed. |
| 345 for (int i = 1; i < kAudioSources; i++) { | 334 for (int i = 1; i < kAudioSources; i++) { |
| 346 EXPECT_EQ(participants[i].IsMixed(), true) | 335 EXPECT_EQ(participants[i].IsMixed(), true) |
| 347 << "Mixed status of AudioSource #" << i << " wrong."; | 336 << "Mixed status of AudioSource #" << i << " wrong."; |
| 348 } | 337 } |
| 349 } | 338 } |
| 350 | 339 |
| 351 TEST(AudioMixer, MutedShouldMixAfterUnmuted) { | 340 TEST(AudioMixer, MutedShouldMixAfterUnmuted) { |
| 352 constexpr int kAudioSources = | 341 constexpr int kAudioSources = |
| 353 NewAudioConferenceMixer::kMaximumAmountOfMixedAudioSources + 1; | 342 AudioMixer::kMaximumAmountOfMixedAudioSources + 1; |
| 354 | 343 |
| 355 std::vector<AudioFrame> frames(kAudioSources); | 344 std::vector<AudioFrame> frames(kAudioSources); |
| 356 for (auto& frame : frames) { | 345 for (auto& frame : frames) { |
| 357 ResetFrame(&frame); | 346 ResetFrame(&frame); |
| 358 } | 347 } |
| 359 | 348 |
| 360 std::vector<MixerAudioSource::AudioFrameInfo> frame_info( | 349 std::vector<MixerAudioSource::AudioFrameInfo> frame_info( |
| 361 kAudioSources, MixerAudioSource::AudioFrameInfo::kNormal); | 350 kAudioSources, MixerAudioSource::AudioFrameInfo::kNormal); |
| 362 frame_info[0] = MixerAudioSource::AudioFrameInfo::kMuted; | 351 frame_info[0] = MixerAudioSource::AudioFrameInfo::kMuted; |
| 363 std::vector<bool> expected_status(kAudioSources, true); | 352 std::vector<bool> expected_status(kAudioSources, true); |
| 364 expected_status[0] = false; | 353 expected_status[0] = false; |
| 365 | 354 |
| 366 MixAndCompare(frames, frame_info, expected_status); | 355 MixAndCompare(frames, frame_info, expected_status); |
| 367 } | 356 } |
| 368 | 357 |
| 369 TEST(AudioMixer, PassiveShouldMixAfterNormal) { | 358 TEST(AudioMixer, PassiveShouldMixAfterNormal) { |
| 370 constexpr int kAudioSources = | 359 constexpr int kAudioSources = |
| 371 NewAudioConferenceMixer::kMaximumAmountOfMixedAudioSources + 1; | 360 AudioMixer::kMaximumAmountOfMixedAudioSources + 1; |
| 372 | 361 |
| 373 std::vector<AudioFrame> frames(kAudioSources); | 362 std::vector<AudioFrame> frames(kAudioSources); |
| 374 for (auto& frame : frames) { | 363 for (auto& frame : frames) { |
| 375 ResetFrame(&frame); | 364 ResetFrame(&frame); |
| 376 } | 365 } |
| 377 | 366 |
| 378 std::vector<MixerAudioSource::AudioFrameInfo> frame_info( | 367 std::vector<MixerAudioSource::AudioFrameInfo> frame_info( |
| 379 kAudioSources, MixerAudioSource::AudioFrameInfo::kNormal); | 368 kAudioSources, MixerAudioSource::AudioFrameInfo::kNormal); |
| 380 frames[0].vad_activity_ = AudioFrame::kVadPassive; | 369 frames[0].vad_activity_ = AudioFrame::kVadPassive; |
| 381 std::vector<bool> expected_status(kAudioSources, true); | 370 std::vector<bool> expected_status(kAudioSources, true); |
| 382 expected_status[0] = false; | 371 expected_status[0] = false; |
| 383 | 372 |
| 384 MixAndCompare(frames, frame_info, expected_status); | 373 MixAndCompare(frames, frame_info, expected_status); |
| 385 } | 374 } |
| 386 | 375 |
| 387 TEST(AudioMixer, ActiveShouldMixBeforeLoud) { | 376 TEST(AudioMixer, ActiveShouldMixBeforeLoud) { |
| 388 constexpr int kAudioSources = | 377 constexpr int kAudioSources = |
| 389 NewAudioConferenceMixer::kMaximumAmountOfMixedAudioSources + 1; | 378 AudioMixer::kMaximumAmountOfMixedAudioSources + 1; |
| 390 | 379 |
| 391 std::vector<AudioFrame> frames(kAudioSources); | 380 std::vector<AudioFrame> frames(kAudioSources); |
| 392 for (auto& frame : frames) { | 381 for (auto& frame : frames) { |
| 393 ResetFrame(&frame); | 382 ResetFrame(&frame); |
| 394 } | 383 } |
| 395 | 384 |
| 396 std::vector<MixerAudioSource::AudioFrameInfo> frame_info( | 385 std::vector<MixerAudioSource::AudioFrameInfo> frame_info( |
| 397 kAudioSources, MixerAudioSource::AudioFrameInfo::kNormal); | 386 kAudioSources, MixerAudioSource::AudioFrameInfo::kNormal); |
| 398 frames[0].vad_activity_ = AudioFrame::kVadPassive; | 387 frames[0].vad_activity_ = AudioFrame::kVadPassive; |
| 399 std::fill(frames[0].data_, frames[0].data_ + kDefaultSampleRateHz / 100, | 388 std::fill(frames[0].data_, frames[0].data_ + kDefaultSampleRateHz / 100, |
| 400 std::numeric_limits<int16_t>::max()); | 389 std::numeric_limits<int16_t>::max()); |
| 401 std::vector<bool> expected_status(kAudioSources, true); | 390 std::vector<bool> expected_status(kAudioSources, true); |
| 402 expected_status[0] = false; | 391 expected_status[0] = false; |
| 403 | 392 |
| 404 MixAndCompare(frames, frame_info, expected_status); | 393 MixAndCompare(frames, frame_info, expected_status); |
| 405 } | 394 } |
| 406 | 395 |
| 407 TEST(AudioMixer, UnmutedShouldMixBeforeLoud) { | 396 TEST(AudioMixer, UnmutedShouldMixBeforeLoud) { |
| 408 constexpr int kAudioSources = | 397 constexpr int kAudioSources = |
| 409 NewAudioConferenceMixer::kMaximumAmountOfMixedAudioSources + 1; | 398 AudioMixer::kMaximumAmountOfMixedAudioSources + 1; |
| 410 | 399 |
| 411 std::vector<AudioFrame> frames(kAudioSources); | 400 std::vector<AudioFrame> frames(kAudioSources); |
| 412 for (auto& frame : frames) { | 401 for (auto& frame : frames) { |
| 413 ResetFrame(&frame); | 402 ResetFrame(&frame); |
| 414 } | 403 } |
| 415 | 404 |
| 416 std::vector<MixerAudioSource::AudioFrameInfo> frame_info( | 405 std::vector<MixerAudioSource::AudioFrameInfo> frame_info( |
| 417 kAudioSources, MixerAudioSource::AudioFrameInfo::kNormal); | 406 kAudioSources, MixerAudioSource::AudioFrameInfo::kNormal); |
| 418 frame_info[0] = MixerAudioSource::AudioFrameInfo::kMuted; | 407 frame_info[0] = MixerAudioSource::AudioFrameInfo::kMuted; |
| 419 std::fill(frames[0].data_, frames[0].data_ + kDefaultSampleRateHz / 100, | 408 std::fill(frames[0].data_, frames[0].data_ + kDefaultSampleRateHz / 100, |
| 420 std::numeric_limits<int16_t>::max()); | 409 std::numeric_limits<int16_t>::max()); |
| 421 std::vector<bool> expected_status(kAudioSources, true); | 410 std::vector<bool> expected_status(kAudioSources, true); |
| 422 expected_status[0] = false; | 411 expected_status[0] = false; |
| 423 | 412 |
| 424 MixAndCompare(frames, frame_info, expected_status); | 413 MixAndCompare(frames, frame_info, expected_status); |
| 425 } | 414 } |
| 426 } // namespace webrtc | 415 } // namespace webrtc |
| OLD | NEW |