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

Side by Side Diff: webrtc/modules/audio_coding/acm2/acm_receiver_unittest_oldapi.cc

Issue 1976913002: Add muted_output parameter to ACM (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 7 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) 2013 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2013 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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 RentACodec::CodecId::kISACSWB}; 278 RentACodec::CodecId::kISACSWB};
279 AddSetOfCodecs(kCodecId); 279 AddSetOfCodecs(kCodecId);
280 280
281 AudioFrame frame; 281 AudioFrame frame;
282 const int kOutSampleRateHz = 8000; // Different than codec sample rate. 282 const int kOutSampleRateHz = 8000; // Different than codec sample rate.
283 for (const auto codec_id : kCodecId) { 283 for (const auto codec_id : kCodecId) {
284 const CodecIdInst codec(codec_id); 284 const CodecIdInst codec(codec_id);
285 const int num_10ms_frames = codec.inst.pacsize / (codec.inst.plfreq / 100); 285 const int num_10ms_frames = codec.inst.pacsize / (codec.inst.plfreq / 100);
286 InsertOnePacketOfSilence(codec.id); 286 InsertOnePacketOfSilence(codec.id);
287 for (int k = 0; k < num_10ms_frames; ++k) { 287 for (int k = 0; k < num_10ms_frames; ++k) {
288 EXPECT_EQ(0, receiver_->GetAudio(kOutSampleRateHz, &frame)); 288 bool muted;
289 EXPECT_EQ(0, receiver_->GetAudio(kOutSampleRateHz, &frame, &muted));
289 } 290 }
290 EXPECT_EQ(codec.inst.plfreq, receiver_->last_output_sample_rate_hz()); 291 EXPECT_EQ(codec.inst.plfreq, receiver_->last_output_sample_rate_hz());
291 } 292 }
292 } 293 }
293 294
294 class AcmReceiverTestFaxModeOldApi : public AcmReceiverTestOldApi { 295 class AcmReceiverTestFaxModeOldApi : public AcmReceiverTestOldApi {
295 protected: 296 protected:
296 AcmReceiverTestFaxModeOldApi() { 297 AcmReceiverTestFaxModeOldApi() {
297 config_.neteq_config.playout_mode = kPlayoutFax; 298 config_.neteq_config.playout_mode = kPlayoutFax;
298 } 299 }
(...skipping 20 matching lines...) Expand all
319 output_sample_rate_hz > 16000 ? AudioFrame::kVadActive 320 output_sample_rate_hz > 16000 ? AudioFrame::kVadActive
320 : AudioFrame::kVadPassive; 321 : AudioFrame::kVadPassive;
321 322
322 // Expect the first output timestamp to be 5*fs/8000 samples before the 323 // Expect the first output timestamp to be 5*fs/8000 samples before the
323 // first inserted timestamp (because of NetEq's look-ahead). (This value is 324 // first inserted timestamp (because of NetEq's look-ahead). (This value is
324 // defined in Expand::overlap_length_.) 325 // defined in Expand::overlap_length_.)
325 uint32_t expected_output_ts = last_packet_send_timestamp_ - 326 uint32_t expected_output_ts = last_packet_send_timestamp_ -
326 rtc::CheckedDivExact(5 * output_sample_rate_hz, 8000); 327 rtc::CheckedDivExact(5 * output_sample_rate_hz, 8000);
327 328
328 AudioFrame frame; 329 AudioFrame frame;
329 EXPECT_EQ(0, receiver_->GetAudio(output_sample_rate_hz, &frame)); 330 bool muted;
331 EXPECT_EQ(0, receiver_->GetAudio(output_sample_rate_hz, &frame, &muted));
330 // Expect timestamp = 0 before first packet is inserted. 332 // Expect timestamp = 0 before first packet is inserted.
331 EXPECT_EQ(0u, frame.timestamp_); 333 EXPECT_EQ(0u, frame.timestamp_);
332 for (int i = 0; i < 5; ++i) { 334 for (int i = 0; i < 5; ++i) {
333 InsertOnePacketOfSilence(codec.id); 335 InsertOnePacketOfSilence(codec.id);
334 for (int k = 0; k < num_10ms_frames; ++k) { 336 for (int k = 0; k < num_10ms_frames; ++k) {
335 EXPECT_EQ(0, receiver_->GetAudio(output_sample_rate_hz, &frame)); 337 EXPECT_EQ(0,
338 receiver_->GetAudio(output_sample_rate_hz, &frame, &muted));
336 EXPECT_EQ(expected_output_ts, frame.timestamp_); 339 EXPECT_EQ(expected_output_ts, frame.timestamp_);
337 expected_output_ts += 10 * samples_per_ms; 340 expected_output_ts += 10 * samples_per_ms;
338 EXPECT_EQ(10 * samples_per_ms, frame.samples_per_channel_); 341 EXPECT_EQ(10 * samples_per_ms, frame.samples_per_channel_);
339 EXPECT_EQ(output_sample_rate_hz, frame.sample_rate_hz_); 342 EXPECT_EQ(output_sample_rate_hz, frame.sample_rate_hz_);
340 EXPECT_EQ(output_channels, frame.num_channels_); 343 EXPECT_EQ(output_channels, frame.num_channels_);
341 EXPECT_EQ(AudioFrame::kNormalSpeech, frame.speech_type_); 344 EXPECT_EQ(AudioFrame::kNormalSpeech, frame.speech_type_);
342 EXPECT_EQ(expected_vad_activity, frame.vad_activity_); 345 EXPECT_EQ(expected_vad_activity, frame.vad_activity_);
346 EXPECT_FALSE(muted);
343 } 347 }
344 } 348 }
345 } 349 }
346 }; 350 };
347 351
348 #if defined(WEBRTC_ANDROID) 352 #if defined(WEBRTC_ANDROID)
349 #define MAYBE_VerifyAudioFramePCMU DISABLED_VerifyAudioFramePCMU 353 #define MAYBE_VerifyAudioFramePCMU DISABLED_VerifyAudioFramePCMU
350 #else 354 #else
351 #define MAYBE_VerifyAudioFramePCMU VerifyAudioFramePCMU 355 #define MAYBE_VerifyAudioFramePCMU VerifyAudioFramePCMU
352 #endif 356 #endif
(...skipping 28 matching lines...) Expand all
381 EXPECT_TRUE(config_.neteq_config.enable_post_decode_vad); 385 EXPECT_TRUE(config_.neteq_config.enable_post_decode_vad);
382 const CodecIdInst codec(RentACodec::CodecId::kPCM16Bwb); 386 const CodecIdInst codec(RentACodec::CodecId::kPCM16Bwb);
383 ASSERT_EQ( 387 ASSERT_EQ(
384 0, receiver_->AddCodec(codec.id, codec.inst.pltype, codec.inst.channels, 388 0, receiver_->AddCodec(codec.id, codec.inst.pltype, codec.inst.channels,
385 codec.inst.plfreq, nullptr, "")); 389 codec.inst.plfreq, nullptr, ""));
386 const int kNumPackets = 5; 390 const int kNumPackets = 5;
387 const int num_10ms_frames = codec.inst.pacsize / (codec.inst.plfreq / 100); 391 const int num_10ms_frames = codec.inst.pacsize / (codec.inst.plfreq / 100);
388 AudioFrame frame; 392 AudioFrame frame;
389 for (int n = 0; n < kNumPackets; ++n) { 393 for (int n = 0; n < kNumPackets; ++n) {
390 InsertOnePacketOfSilence(codec.id); 394 InsertOnePacketOfSilence(codec.id);
391 for (int k = 0; k < num_10ms_frames; ++k) 395 for (int k = 0; k < num_10ms_frames; ++k) {
392 ASSERT_EQ(0, receiver_->GetAudio(codec.inst.plfreq, &frame)); 396 bool muted;
397 ASSERT_EQ(0, receiver_->GetAudio(codec.inst.plfreq, &frame, &muted));
398 }
393 } 399 }
394 EXPECT_EQ(AudioFrame::kVadPassive, frame.vad_activity_); 400 EXPECT_EQ(AudioFrame::kVadPassive, frame.vad_activity_);
395 } 401 }
396 402
397 class AcmReceiverTestPostDecodeVadPassiveOldApi : public AcmReceiverTestOldApi { 403 class AcmReceiverTestPostDecodeVadPassiveOldApi : public AcmReceiverTestOldApi {
398 protected: 404 protected:
399 AcmReceiverTestPostDecodeVadPassiveOldApi() { 405 AcmReceiverTestPostDecodeVadPassiveOldApi() {
400 config_.neteq_config.enable_post_decode_vad = false; 406 config_.neteq_config.enable_post_decode_vad = false;
401 } 407 }
402 }; 408 };
403 409
404 #if defined(WEBRTC_ANDROID) 410 #if defined(WEBRTC_ANDROID)
405 #define MAYBE_PostdecodingVad DISABLED_PostdecodingVad 411 #define MAYBE_PostdecodingVad DISABLED_PostdecodingVad
406 #else 412 #else
407 #define MAYBE_PostdecodingVad PostdecodingVad 413 #define MAYBE_PostdecodingVad PostdecodingVad
408 #endif 414 #endif
409 TEST_F(AcmReceiverTestPostDecodeVadPassiveOldApi, MAYBE_PostdecodingVad) { 415 TEST_F(AcmReceiverTestPostDecodeVadPassiveOldApi, MAYBE_PostdecodingVad) {
410 EXPECT_FALSE(config_.neteq_config.enable_post_decode_vad); 416 EXPECT_FALSE(config_.neteq_config.enable_post_decode_vad);
411 const CodecIdInst codec(RentACodec::CodecId::kPCM16Bwb); 417 const CodecIdInst codec(RentACodec::CodecId::kPCM16Bwb);
412 ASSERT_EQ( 418 ASSERT_EQ(
413 0, receiver_->AddCodec(codec.id, codec.inst.pltype, codec.inst.channels, 419 0, receiver_->AddCodec(codec.id, codec.inst.pltype, codec.inst.channels,
414 codec.inst.plfreq, nullptr, "")); 420 codec.inst.plfreq, nullptr, ""));
415 const int kNumPackets = 5; 421 const int kNumPackets = 5;
416 const int num_10ms_frames = codec.inst.pacsize / (codec.inst.plfreq / 100); 422 const int num_10ms_frames = codec.inst.pacsize / (codec.inst.plfreq / 100);
417 AudioFrame frame; 423 AudioFrame frame;
418 for (int n = 0; n < kNumPackets; ++n) { 424 for (int n = 0; n < kNumPackets; ++n) {
419 InsertOnePacketOfSilence(codec.id); 425 InsertOnePacketOfSilence(codec.id);
420 for (int k = 0; k < num_10ms_frames; ++k) 426 for (int k = 0; k < num_10ms_frames; ++k) {
421 ASSERT_EQ(0, receiver_->GetAudio(codec.inst.plfreq, &frame)); 427 bool muted;
428 ASSERT_EQ(0, receiver_->GetAudio(codec.inst.plfreq, &frame, &muted));
429 }
422 } 430 }
423 EXPECT_EQ(AudioFrame::kVadUnknown, frame.vad_activity_); 431 EXPECT_EQ(AudioFrame::kVadUnknown, frame.vad_activity_);
424 } 432 }
425 433
426 #if defined(WEBRTC_ANDROID) 434 #if defined(WEBRTC_ANDROID)
427 #define MAYBE_LastAudioCodec DISABLED_LastAudioCodec 435 #define MAYBE_LastAudioCodec DISABLED_LastAudioCodec
428 #else 436 #else
429 #define MAYBE_LastAudioCodec LastAudioCodec 437 #define MAYBE_LastAudioCodec LastAudioCodec
430 #endif 438 #endif
431 #if defined(WEBRTC_CODEC_ISAC) 439 #if defined(WEBRTC_CODEC_ISAC)
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
490 receiver_->last_packet_sample_rate_hz()); 498 receiver_->last_packet_sample_rate_hz());
491 EXPECT_EQ(0, receiver_->LastAudioCodec(&codec)); 499 EXPECT_EQ(0, receiver_->LastAudioCodec(&codec));
492 EXPECT_TRUE(CodecsEqual(c.inst, codec)); 500 EXPECT_TRUE(CodecsEqual(c.inst, codec));
493 } 501 }
494 } 502 }
495 #endif 503 #endif
496 504
497 } // namespace acm2 505 } // namespace acm2
498 506
499 } // namespace webrtc 507 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698