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 <cstring> | |
ivoc
2016/08/31 14:34:25
I think we generally use the <string.h> style for
aleloi
2016/08/31 15:16:22
Seems like that. 21 matches for cstring and 243 fo
| |
11 #include <memory> | 12 #include <memory> |
12 #include <utility> | 13 #include <utility> |
13 | 14 |
14 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
15 #include "webrtc/modules/audio_mixer/audio_mixer_defines.h" | 16 #include "webrtc/modules/audio_mixer/audio_mixer_defines.h" |
16 #include "webrtc/modules/audio_mixer/audio_mixer.h" | 17 #include "webrtc/modules/audio_mixer/audio_mixer.h" |
17 | 18 |
18 using testing::_; | 19 using testing::_; |
19 using testing::Exactly; | 20 using testing::Exactly; |
20 using testing::Invoke; | 21 using testing::Invoke; |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
195 i < kAudioSources - 1 - AudioMixer::kMaximumAmountOfMixedAudioSources) { | 196 i < kAudioSources - 1 - AudioMixer::kMaximumAmountOfMixedAudioSources) { |
196 EXPECT_FALSE(is_mixed) << "Mixing status of AudioSource #" << i | 197 EXPECT_FALSE(is_mixed) << "Mixing status of AudioSource #" << i |
197 << " wrong."; | 198 << " wrong."; |
198 } else { | 199 } else { |
199 EXPECT_TRUE(is_mixed) << "Mixing status of AudioSource #" << i | 200 EXPECT_TRUE(is_mixed) << "Mixing status of AudioSource #" << i |
200 << " wrong."; | 201 << " wrong."; |
201 } | 202 } |
202 } | 203 } |
203 } | 204 } |
204 | 205 |
206 TEST(AudioMixer, FrameNotModifiedForSingleParticipant) { | |
207 const std::unique_ptr<AudioMixer> mixer(AudioMixer::Create(kId)); | |
208 | |
209 MockMixerAudioSource participant; | |
210 | |
211 ResetFrame(participant.fake_frame()); | |
212 const int n_samples = participant.fake_frame()->samples_per_channel_; | |
213 | |
214 // Modify the frame so that it's not zero. | |
215 for (int j = 0; j < n_samples; j++) { | |
216 participant.fake_frame()->data_[j] = j; | |
217 } | |
218 | |
219 EXPECT_EQ(0, mixer->SetMixabilityStatus(&participant, true)); | |
220 EXPECT_CALL(participant, GetAudioFrameWithMuted(_, _)).Times(Exactly(2)); | |
221 | |
222 AudioFrame audio_frame; | |
223 // Two mix iteration to compare after the ramp-up step. | |
224 for (int i = 0; i < 2; i++) { | |
225 mixer->Mix(kDefaultSampleRateHz, | |
226 1, // number of channels | |
227 &audio_frame); | |
228 } | |
229 | |
230 EXPECT_EQ(std::memcmp(participant.fake_frame()->data_, audio_frame.data_, | |
ivoc
2016/08/31 14:34:24
Please change the order, i.e. EXPECT_EQ(0, std::me
aleloi
2016/08/31 15:16:22
Done. I also changed in a few other tests.
| |
231 n_samples), | |
232 0); | |
233 } | |
234 | |
235 TEST(AudioMixer, FrameNotModifiedForSingleAnonymousParticipant) { | |
aleloi
2016/08/31 11:07:46
This test compares mixer output in the anonymous c
| |
236 const std::unique_ptr<AudioMixer> mixer(AudioMixer::Create(kId)); | |
237 | |
238 MockMixerAudioSource participant; | |
239 | |
240 ResetFrame(participant.fake_frame()); | |
241 const int n_samples = participant.fake_frame()->samples_per_channel_; | |
242 | |
243 // Modify the frame so that it's not zero. | |
244 for (int j = 0; j < n_samples; j++) { | |
245 participant.fake_frame()->data_[j] = j; | |
246 } | |
247 | |
248 EXPECT_EQ(0, mixer->SetMixabilityStatus(&participant, true)); | |
249 EXPECT_EQ(0, mixer->SetAnonymousMixabilityStatus(&participant, true)); | |
250 EXPECT_CALL(participant, GetAudioFrameWithMuted(_, _)).Times(Exactly(2)); | |
251 | |
252 AudioFrame audio_frame; | |
253 // Two mix iteration to compare after the ramp-up step. | |
254 for (int i = 0; i < 2; i++) { | |
255 mixer->Mix(kDefaultSampleRateHz, | |
256 1, // number of channels | |
257 &audio_frame); | |
258 } | |
259 | |
260 EXPECT_EQ(std::memcmp(participant.fake_frame()->data_, audio_frame.data_, | |
ivoc
2016/08/31 14:34:24
Same here.
aleloi
2016/08/31 15:16:22
Done.
| |
261 n_samples), | |
262 0); | |
263 } | |
264 | |
205 TEST(AudioMixer, ParticipantSampleRate) { | 265 TEST(AudioMixer, ParticipantSampleRate) { |
206 const std::unique_ptr<AudioMixer> mixer(AudioMixer::Create(kId)); | 266 const std::unique_ptr<AudioMixer> mixer(AudioMixer::Create(kId)); |
207 | 267 |
208 MockMixerAudioSource participant; | 268 MockMixerAudioSource participant; |
209 ResetFrame(participant.fake_frame()); | 269 ResetFrame(participant.fake_frame()); |
210 | 270 |
211 EXPECT_EQ(0, mixer->SetMixabilityStatus(&participant, true)); | 271 EXPECT_EQ(0, mixer->SetMixabilityStatus(&participant, true)); |
212 for (auto frequency : {8000, 16000, 32000, 48000}) { | 272 for (auto frequency : {8000, 16000, 32000, 48000}) { |
213 EXPECT_CALL(participant, GetAudioFrameWithMuted(_, frequency)) | 273 EXPECT_CALL(participant, GetAudioFrameWithMuted(_, frequency)) |
214 .Times(Exactly(1)); | 274 .Times(Exactly(1)); |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
406 kAudioSources, MixerAudioSource::AudioFrameInfo::kNormal); | 466 kAudioSources, MixerAudioSource::AudioFrameInfo::kNormal); |
407 frame_info[0] = MixerAudioSource::AudioFrameInfo::kMuted; | 467 frame_info[0] = MixerAudioSource::AudioFrameInfo::kMuted; |
408 std::fill(frames[0].data_, frames[0].data_ + kDefaultSampleRateHz / 100, | 468 std::fill(frames[0].data_, frames[0].data_ + kDefaultSampleRateHz / 100, |
409 std::numeric_limits<int16_t>::max()); | 469 std::numeric_limits<int16_t>::max()); |
410 std::vector<bool> expected_status(kAudioSources, true); | 470 std::vector<bool> expected_status(kAudioSources, true); |
411 expected_status[0] = false; | 471 expected_status[0] = false; |
412 | 472 |
413 MixAndCompare(frames, frame_info, expected_status); | 473 MixAndCompare(frames, frame_info, expected_status); |
414 } | 474 } |
415 } // namespace webrtc | 475 } // namespace webrtc |
OLD | NEW |