OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 config.num_channels = 2; | 468 config.num_channels = 2; |
469 config.payload_type = payload_type_; | 469 config.payload_type = payload_type_; |
470 config.application = AudioEncoderOpus::kAudio; | 470 config.application = AudioEncoderOpus::kAudio; |
471 audio_encoder_.reset(new AudioEncoderOpus(config)); | 471 audio_encoder_.reset(new AudioEncoderOpus(config)); |
472 } | 472 } |
473 }; | 473 }; |
474 | 474 |
475 TEST_F(AudioDecoderPcmUTest, EncodeDecode) { | 475 TEST_F(AudioDecoderPcmUTest, EncodeDecode) { |
476 int tolerance = 251; | 476 int tolerance = 251; |
477 double mse = 1734.0; | 477 double mse = 1734.0; |
478 EXPECT_TRUE(CodecSupported(kDecoderPCMu)); | |
479 EncodeDecodeTest(data_length_, tolerance, mse); | 478 EncodeDecodeTest(data_length_, tolerance, mse); |
480 ReInitTest(); | 479 ReInitTest(); |
481 EXPECT_FALSE(decoder_->HasDecodePlc()); | 480 EXPECT_FALSE(decoder_->HasDecodePlc()); |
482 } | 481 } |
483 | 482 |
484 namespace { | 483 namespace { |
485 int SetAndGetTargetBitrate(AudioEncoder* audio_encoder, int rate) { | 484 int SetAndGetTargetBitrate(AudioEncoder* audio_encoder, int rate) { |
486 audio_encoder->SetTargetBitrate(rate); | 485 audio_encoder->SetTargetBitrate(rate); |
487 return audio_encoder->GetTargetBitrate(); | 486 return audio_encoder->GetTargetBitrate(); |
488 } | 487 } |
489 void TestSetAndGetTargetBitratesWithFixedCodec(AudioEncoder* audio_encoder, | 488 void TestSetAndGetTargetBitratesWithFixedCodec(AudioEncoder* audio_encoder, |
490 int fixed_rate) { | 489 int fixed_rate) { |
491 EXPECT_EQ(fixed_rate, SetAndGetTargetBitrate(audio_encoder, 32000)); | 490 EXPECT_EQ(fixed_rate, SetAndGetTargetBitrate(audio_encoder, 32000)); |
492 EXPECT_EQ(fixed_rate, SetAndGetTargetBitrate(audio_encoder, fixed_rate - 1)); | 491 EXPECT_EQ(fixed_rate, SetAndGetTargetBitrate(audio_encoder, fixed_rate - 1)); |
493 EXPECT_EQ(fixed_rate, SetAndGetTargetBitrate(audio_encoder, fixed_rate)); | 492 EXPECT_EQ(fixed_rate, SetAndGetTargetBitrate(audio_encoder, fixed_rate)); |
494 EXPECT_EQ(fixed_rate, SetAndGetTargetBitrate(audio_encoder, fixed_rate + 1)); | 493 EXPECT_EQ(fixed_rate, SetAndGetTargetBitrate(audio_encoder, fixed_rate + 1)); |
495 } | 494 } |
496 } // namespace | 495 } // namespace |
497 | 496 |
498 TEST_F(AudioDecoderPcmUTest, SetTargetBitrate) { | 497 TEST_F(AudioDecoderPcmUTest, SetTargetBitrate) { |
499 TestSetAndGetTargetBitratesWithFixedCodec(audio_encoder_.get(), 64000); | 498 TestSetAndGetTargetBitratesWithFixedCodec(audio_encoder_.get(), 64000); |
500 } | 499 } |
501 | 500 |
502 TEST_F(AudioDecoderPcmATest, EncodeDecode) { | 501 TEST_F(AudioDecoderPcmATest, EncodeDecode) { |
503 int tolerance = 308; | 502 int tolerance = 308; |
504 double mse = 1931.0; | 503 double mse = 1931.0; |
505 EXPECT_TRUE(CodecSupported(kDecoderPCMa)); | |
506 EncodeDecodeTest(data_length_, tolerance, mse); | 504 EncodeDecodeTest(data_length_, tolerance, mse); |
507 ReInitTest(); | 505 ReInitTest(); |
508 EXPECT_FALSE(decoder_->HasDecodePlc()); | 506 EXPECT_FALSE(decoder_->HasDecodePlc()); |
509 } | 507 } |
510 | 508 |
511 TEST_F(AudioDecoderPcmATest, SetTargetBitrate) { | 509 TEST_F(AudioDecoderPcmATest, SetTargetBitrate) { |
512 TestSetAndGetTargetBitratesWithFixedCodec(audio_encoder_.get(), 64000); | 510 TestSetAndGetTargetBitratesWithFixedCodec(audio_encoder_.get(), 64000); |
513 } | 511 } |
514 | 512 |
515 TEST_F(AudioDecoderPcm16BTest, EncodeDecode) { | 513 TEST_F(AudioDecoderPcm16BTest, EncodeDecode) { |
516 int tolerance = 0; | 514 int tolerance = 0; |
517 double mse = 0.0; | 515 double mse = 0.0; |
518 EXPECT_TRUE(CodecSupported(kDecoderPCM16B)); | |
519 EXPECT_TRUE(CodecSupported(kDecoderPCM16Bwb)); | |
520 EXPECT_TRUE(CodecSupported(kDecoderPCM16Bswb32kHz)); | |
521 EXPECT_TRUE(CodecSupported(kDecoderPCM16Bswb48kHz)); | |
522 EncodeDecodeTest(2 * data_length_, tolerance, mse); | 516 EncodeDecodeTest(2 * data_length_, tolerance, mse); |
523 ReInitTest(); | 517 ReInitTest(); |
524 EXPECT_FALSE(decoder_->HasDecodePlc()); | 518 EXPECT_FALSE(decoder_->HasDecodePlc()); |
525 } | 519 } |
526 | 520 |
527 TEST_F(AudioDecoderPcm16BTest, SetTargetBitrate) { | 521 TEST_F(AudioDecoderPcm16BTest, SetTargetBitrate) { |
528 TestSetAndGetTargetBitratesWithFixedCodec(audio_encoder_.get(), | 522 TestSetAndGetTargetBitratesWithFixedCodec(audio_encoder_.get(), |
529 codec_input_rate_hz_ * 16); | 523 codec_input_rate_hz_ * 16); |
530 } | 524 } |
531 | 525 |
532 TEST_F(AudioDecoderIlbcTest, EncodeDecode) { | 526 TEST_F(AudioDecoderIlbcTest, EncodeDecode) { |
533 int tolerance = 6808; | 527 int tolerance = 6808; |
534 double mse = 2.13e6; | 528 double mse = 2.13e6; |
535 int delay = 80; // Delay from input to output. | 529 int delay = 80; // Delay from input to output. |
536 EXPECT_TRUE(CodecSupported(kDecoderILBC)); | |
537 EncodeDecodeTest(500, tolerance, mse, delay); | 530 EncodeDecodeTest(500, tolerance, mse, delay); |
538 ReInitTest(); | 531 ReInitTest(); |
539 EXPECT_TRUE(decoder_->HasDecodePlc()); | 532 EXPECT_TRUE(decoder_->HasDecodePlc()); |
540 DecodePlcTest(); | 533 DecodePlcTest(); |
541 } | 534 } |
542 | 535 |
543 TEST_F(AudioDecoderIlbcTest, SetTargetBitrate) { | 536 TEST_F(AudioDecoderIlbcTest, SetTargetBitrate) { |
544 TestSetAndGetTargetBitratesWithFixedCodec(audio_encoder_.get(), 13333); | 537 TestSetAndGetTargetBitratesWithFixedCodec(audio_encoder_.get(), 13333); |
545 } | 538 } |
546 | 539 |
547 TEST_F(AudioDecoderIsacFloatTest, EncodeDecode) { | 540 TEST_F(AudioDecoderIsacFloatTest, EncodeDecode) { |
548 int tolerance = 3399; | 541 int tolerance = 3399; |
549 double mse = 434951.0; | 542 double mse = 434951.0; |
550 int delay = 48; // Delay from input to output. | 543 int delay = 48; // Delay from input to output. |
551 EXPECT_TRUE(CodecSupported(kDecoderISAC)); | |
552 EncodeDecodeTest(0, tolerance, mse, delay); | 544 EncodeDecodeTest(0, tolerance, mse, delay); |
553 ReInitTest(); | 545 ReInitTest(); |
554 EXPECT_FALSE(decoder_->HasDecodePlc()); | 546 EXPECT_FALSE(decoder_->HasDecodePlc()); |
555 } | 547 } |
556 | 548 |
557 TEST_F(AudioDecoderIsacFloatTest, SetTargetBitrate) { | 549 TEST_F(AudioDecoderIsacFloatTest, SetTargetBitrate) { |
558 TestSetAndGetTargetBitratesWithFixedCodec(audio_encoder_.get(), 32000); | 550 TestSetAndGetTargetBitratesWithFixedCodec(audio_encoder_.get(), 32000); |
559 } | 551 } |
560 | 552 |
561 TEST_F(AudioDecoderIsacSwbTest, EncodeDecode) { | 553 TEST_F(AudioDecoderIsacSwbTest, EncodeDecode) { |
562 int tolerance = 19757; | 554 int tolerance = 19757; |
563 double mse = 8.18e6; | 555 double mse = 8.18e6; |
564 int delay = 160; // Delay from input to output. | 556 int delay = 160; // Delay from input to output. |
565 EXPECT_TRUE(CodecSupported(kDecoderISACswb)); | |
566 EncodeDecodeTest(0, tolerance, mse, delay); | 557 EncodeDecodeTest(0, tolerance, mse, delay); |
567 ReInitTest(); | 558 ReInitTest(); |
568 EXPECT_FALSE(decoder_->HasDecodePlc()); | 559 EXPECT_FALSE(decoder_->HasDecodePlc()); |
569 } | 560 } |
570 | 561 |
571 TEST_F(AudioDecoderIsacSwbTest, SetTargetBitrate) { | 562 TEST_F(AudioDecoderIsacSwbTest, SetTargetBitrate) { |
572 TestSetAndGetTargetBitratesWithFixedCodec(audio_encoder_.get(), 32000); | 563 TestSetAndGetTargetBitratesWithFixedCodec(audio_encoder_.get(), 32000); |
573 } | 564 } |
574 | 565 |
575 // Fails Android ARM64. https://code.google.com/p/webrtc/issues/detail?id=4198 | 566 // Fails Android ARM64. https://code.google.com/p/webrtc/issues/detail?id=4198 |
576 #if defined(WEBRTC_ANDROID) && defined(WEBRTC_ARCH_ARM64) | 567 #if defined(WEBRTC_ANDROID) && defined(WEBRTC_ARCH_ARM64) |
577 #define MAYBE_EncodeDecode DISABLED_EncodeDecode | 568 #define MAYBE_EncodeDecode DISABLED_EncodeDecode |
578 #else | 569 #else |
579 #define MAYBE_EncodeDecode EncodeDecode | 570 #define MAYBE_EncodeDecode EncodeDecode |
580 #endif | 571 #endif |
581 TEST_F(AudioDecoderIsacFixTest, MAYBE_EncodeDecode) { | 572 TEST_F(AudioDecoderIsacFixTest, MAYBE_EncodeDecode) { |
582 int tolerance = 11034; | 573 int tolerance = 11034; |
583 double mse = 3.46e6; | 574 double mse = 3.46e6; |
584 int delay = 54; // Delay from input to output. | 575 int delay = 54; // Delay from input to output. |
585 EXPECT_TRUE(CodecSupported(kDecoderISAC)); | |
586 #ifdef WEBRTC_ANDROID | 576 #ifdef WEBRTC_ANDROID |
587 static const int kEncodedBytes = 685; | 577 static const int kEncodedBytes = 685; |
588 #else | 578 #else |
589 static const int kEncodedBytes = 671; | 579 static const int kEncodedBytes = 671; |
590 #endif | 580 #endif |
591 EncodeDecodeTest(kEncodedBytes, tolerance, mse, delay); | 581 EncodeDecodeTest(kEncodedBytes, tolerance, mse, delay); |
592 ReInitTest(); | 582 ReInitTest(); |
593 EXPECT_FALSE(decoder_->HasDecodePlc()); | 583 EXPECT_FALSE(decoder_->HasDecodePlc()); |
594 } | 584 } |
595 | 585 |
596 TEST_F(AudioDecoderIsacFixTest, SetTargetBitrate) { | 586 TEST_F(AudioDecoderIsacFixTest, SetTargetBitrate) { |
597 TestSetAndGetTargetBitratesWithFixedCodec(audio_encoder_.get(), 32000); | 587 TestSetAndGetTargetBitratesWithFixedCodec(audio_encoder_.get(), 32000); |
598 } | 588 } |
599 | 589 |
600 TEST_F(AudioDecoderG722Test, EncodeDecode) { | 590 TEST_F(AudioDecoderG722Test, EncodeDecode) { |
601 int tolerance = 6176; | 591 int tolerance = 6176; |
602 double mse = 238630.0; | 592 double mse = 238630.0; |
603 int delay = 22; // Delay from input to output. | 593 int delay = 22; // Delay from input to output. |
604 EXPECT_TRUE(CodecSupported(kDecoderG722)); | |
605 EncodeDecodeTest(data_length_ / 2, tolerance, mse, delay); | 594 EncodeDecodeTest(data_length_ / 2, tolerance, mse, delay); |
606 ReInitTest(); | 595 ReInitTest(); |
607 EXPECT_FALSE(decoder_->HasDecodePlc()); | 596 EXPECT_FALSE(decoder_->HasDecodePlc()); |
608 } | 597 } |
609 | 598 |
610 TEST_F(AudioDecoderG722Test, SetTargetBitrate) { | 599 TEST_F(AudioDecoderG722Test, SetTargetBitrate) { |
611 TestSetAndGetTargetBitratesWithFixedCodec(audio_encoder_.get(), 64000); | 600 TestSetAndGetTargetBitratesWithFixedCodec(audio_encoder_.get(), 64000); |
612 } | 601 } |
613 | 602 |
614 TEST_F(AudioDecoderG722StereoTest, CreateAndDestroy) { | |
615 EXPECT_TRUE(CodecSupported(kDecoderG722_2ch)); | |
616 } | |
617 | |
618 TEST_F(AudioDecoderG722StereoTest, EncodeDecode) { | 603 TEST_F(AudioDecoderG722StereoTest, EncodeDecode) { |
619 int tolerance = 6176; | 604 int tolerance = 6176; |
620 int channel_diff_tolerance = 0; | 605 int channel_diff_tolerance = 0; |
621 double mse = 238630.0; | 606 double mse = 238630.0; |
622 int delay = 22; // Delay from input to output. | 607 int delay = 22; // Delay from input to output. |
623 EXPECT_TRUE(CodecSupported(kDecoderG722_2ch)); | |
624 EncodeDecodeTest(data_length_, tolerance, mse, delay, channel_diff_tolerance); | 608 EncodeDecodeTest(data_length_, tolerance, mse, delay, channel_diff_tolerance); |
625 ReInitTest(); | 609 ReInitTest(); |
626 EXPECT_FALSE(decoder_->HasDecodePlc()); | 610 EXPECT_FALSE(decoder_->HasDecodePlc()); |
627 } | 611 } |
628 | 612 |
629 TEST_F(AudioDecoderG722StereoTest, SetTargetBitrate) { | 613 TEST_F(AudioDecoderG722StereoTest, SetTargetBitrate) { |
630 TestSetAndGetTargetBitratesWithFixedCodec(audio_encoder_.get(), 128000); | 614 TestSetAndGetTargetBitratesWithFixedCodec(audio_encoder_.get(), 128000); |
631 } | 615 } |
632 | 616 |
633 TEST_F(AudioDecoderOpusTest, EncodeDecode) { | 617 TEST_F(AudioDecoderOpusTest, EncodeDecode) { |
634 int tolerance = 6176; | 618 int tolerance = 6176; |
635 double mse = 238630.0; | 619 double mse = 238630.0; |
636 int delay = 22; // Delay from input to output. | 620 int delay = 22; // Delay from input to output. |
637 EXPECT_TRUE(CodecSupported(kDecoderOpus)); | |
638 EncodeDecodeTest(0, tolerance, mse, delay); | 621 EncodeDecodeTest(0, tolerance, mse, delay); |
639 ReInitTest(); | 622 ReInitTest(); |
640 EXPECT_FALSE(decoder_->HasDecodePlc()); | 623 EXPECT_FALSE(decoder_->HasDecodePlc()); |
641 } | 624 } |
642 | 625 |
643 namespace { | 626 namespace { |
644 void TestOpusSetTargetBitrates(AudioEncoder* audio_encoder) { | 627 void TestOpusSetTargetBitrates(AudioEncoder* audio_encoder) { |
645 EXPECT_EQ(500, SetAndGetTargetBitrate(audio_encoder, 499)); | 628 EXPECT_EQ(500, SetAndGetTargetBitrate(audio_encoder, 499)); |
646 EXPECT_EQ(500, SetAndGetTargetBitrate(audio_encoder, 500)); | 629 EXPECT_EQ(500, SetAndGetTargetBitrate(audio_encoder, 500)); |
647 EXPECT_EQ(32000, SetAndGetTargetBitrate(audio_encoder, 32000)); | 630 EXPECT_EQ(32000, SetAndGetTargetBitrate(audio_encoder, 32000)); |
648 EXPECT_EQ(512000, SetAndGetTargetBitrate(audio_encoder, 512000)); | 631 EXPECT_EQ(512000, SetAndGetTargetBitrate(audio_encoder, 512000)); |
649 EXPECT_EQ(512000, SetAndGetTargetBitrate(audio_encoder, 513000)); | 632 EXPECT_EQ(512000, SetAndGetTargetBitrate(audio_encoder, 513000)); |
650 } | 633 } |
651 } // namespace | 634 } // namespace |
652 | 635 |
653 TEST_F(AudioDecoderOpusTest, SetTargetBitrate) { | 636 TEST_F(AudioDecoderOpusTest, SetTargetBitrate) { |
654 TestOpusSetTargetBitrates(audio_encoder_.get()); | 637 TestOpusSetTargetBitrates(audio_encoder_.get()); |
655 } | 638 } |
656 | 639 |
657 TEST_F(AudioDecoderOpusStereoTest, EncodeDecode) { | 640 TEST_F(AudioDecoderOpusStereoTest, EncodeDecode) { |
658 int tolerance = 6176; | 641 int tolerance = 6176; |
659 int channel_diff_tolerance = 0; | 642 int channel_diff_tolerance = 0; |
660 double mse = 238630.0; | 643 double mse = 238630.0; |
661 int delay = 22; // Delay from input to output. | 644 int delay = 22; // Delay from input to output. |
662 EXPECT_TRUE(CodecSupported(kDecoderOpus_2ch)); | |
663 EncodeDecodeTest(0, tolerance, mse, delay, channel_diff_tolerance); | 645 EncodeDecodeTest(0, tolerance, mse, delay, channel_diff_tolerance); |
664 ReInitTest(); | 646 ReInitTest(); |
665 EXPECT_FALSE(decoder_->HasDecodePlc()); | 647 EXPECT_FALSE(decoder_->HasDecodePlc()); |
666 } | 648 } |
667 | 649 |
668 TEST_F(AudioDecoderOpusStereoTest, SetTargetBitrate) { | 650 TEST_F(AudioDecoderOpusStereoTest, SetTargetBitrate) { |
669 TestOpusSetTargetBitrates(audio_encoder_.get()); | 651 TestOpusSetTargetBitrates(audio_encoder_.get()); |
670 } | 652 } |
671 | 653 |
| 654 namespace { |
| 655 #ifdef WEBRTC_CODEC_ILBC |
| 656 const bool has_ilbc = true; |
| 657 #else |
| 658 const bool has_ilbc = false; |
| 659 #endif |
| 660 #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX) |
| 661 const bool has_isac = true; |
| 662 #else |
| 663 const bool has_isac = false; |
| 664 #endif |
| 665 #ifdef WEBRTC_CODEC_ISAC |
| 666 const bool has_isac_swb = true; |
| 667 #else |
| 668 const bool has_isac_swb = false; |
| 669 #endif |
| 670 #ifdef WEBRTC_CODEC_G722 |
| 671 const bool has_g722 = true; |
| 672 #else |
| 673 const bool has_g722 = false; |
| 674 #endif |
| 675 #ifdef WEBRTC_CODEC_OPUS |
| 676 const bool has_opus = true; |
| 677 #else |
| 678 const bool has_opus = false; |
| 679 #endif |
| 680 } // namespace |
| 681 |
672 TEST(AudioDecoder, CodecSampleRateHz) { | 682 TEST(AudioDecoder, CodecSampleRateHz) { |
673 EXPECT_EQ(8000, CodecSampleRateHz(kDecoderPCMu)); | 683 EXPECT_EQ(8000, CodecSampleRateHz(kDecoderPCMu)); |
674 EXPECT_EQ(8000, CodecSampleRateHz(kDecoderPCMa)); | 684 EXPECT_EQ(8000, CodecSampleRateHz(kDecoderPCMa)); |
675 EXPECT_EQ(8000, CodecSampleRateHz(kDecoderPCMu_2ch)); | 685 EXPECT_EQ(8000, CodecSampleRateHz(kDecoderPCMu_2ch)); |
676 EXPECT_EQ(8000, CodecSampleRateHz(kDecoderPCMa_2ch)); | 686 EXPECT_EQ(8000, CodecSampleRateHz(kDecoderPCMa_2ch)); |
677 EXPECT_EQ(8000, CodecSampleRateHz(kDecoderILBC)); | 687 EXPECT_EQ(has_ilbc ? 8000 : -1, CodecSampleRateHz(kDecoderILBC)); |
678 EXPECT_EQ(16000, CodecSampleRateHz(kDecoderISAC)); | 688 EXPECT_EQ(has_isac ? 16000 : -1, CodecSampleRateHz(kDecoderISAC)); |
679 EXPECT_EQ(32000, CodecSampleRateHz(kDecoderISACswb)); | 689 EXPECT_EQ(has_isac_swb ? 32000 : -1, CodecSampleRateHz(kDecoderISACswb)); |
680 EXPECT_EQ(32000, CodecSampleRateHz(kDecoderISACfb)); | 690 EXPECT_EQ(has_isac_swb ? 32000 : -1, CodecSampleRateHz(kDecoderISACfb)); |
681 EXPECT_EQ(8000, CodecSampleRateHz(kDecoderPCM16B)); | 691 EXPECT_EQ(8000, CodecSampleRateHz(kDecoderPCM16B)); |
682 EXPECT_EQ(16000, CodecSampleRateHz(kDecoderPCM16Bwb)); | 692 EXPECT_EQ(16000, CodecSampleRateHz(kDecoderPCM16Bwb)); |
683 EXPECT_EQ(32000, CodecSampleRateHz(kDecoderPCM16Bswb32kHz)); | 693 EXPECT_EQ(32000, CodecSampleRateHz(kDecoderPCM16Bswb32kHz)); |
684 EXPECT_EQ(48000, CodecSampleRateHz(kDecoderPCM16Bswb48kHz)); | 694 EXPECT_EQ(48000, CodecSampleRateHz(kDecoderPCM16Bswb48kHz)); |
685 EXPECT_EQ(8000, CodecSampleRateHz(kDecoderPCM16B_2ch)); | 695 EXPECT_EQ(8000, CodecSampleRateHz(kDecoderPCM16B_2ch)); |
686 EXPECT_EQ(16000, CodecSampleRateHz(kDecoderPCM16Bwb_2ch)); | 696 EXPECT_EQ(16000, CodecSampleRateHz(kDecoderPCM16Bwb_2ch)); |
687 EXPECT_EQ(32000, CodecSampleRateHz(kDecoderPCM16Bswb32kHz_2ch)); | 697 EXPECT_EQ(32000, CodecSampleRateHz(kDecoderPCM16Bswb32kHz_2ch)); |
688 EXPECT_EQ(48000, CodecSampleRateHz(kDecoderPCM16Bswb48kHz_2ch)); | 698 EXPECT_EQ(48000, CodecSampleRateHz(kDecoderPCM16Bswb48kHz_2ch)); |
689 EXPECT_EQ(8000, CodecSampleRateHz(kDecoderPCM16B_5ch)); | 699 EXPECT_EQ(8000, CodecSampleRateHz(kDecoderPCM16B_5ch)); |
690 EXPECT_EQ(16000, CodecSampleRateHz(kDecoderG722)); | 700 EXPECT_EQ(has_g722 ? 16000 : -1, CodecSampleRateHz(kDecoderG722)); |
691 EXPECT_EQ(16000, CodecSampleRateHz(kDecoderG722_2ch)); | 701 EXPECT_EQ(has_g722 ? 16000 : -1, CodecSampleRateHz(kDecoderG722_2ch)); |
692 EXPECT_EQ(-1, CodecSampleRateHz(kDecoderRED)); | 702 EXPECT_EQ(-1, CodecSampleRateHz(kDecoderRED)); |
693 EXPECT_EQ(-1, CodecSampleRateHz(kDecoderAVT)); | 703 EXPECT_EQ(-1, CodecSampleRateHz(kDecoderAVT)); |
694 EXPECT_EQ(8000, CodecSampleRateHz(kDecoderCNGnb)); | 704 EXPECT_EQ(8000, CodecSampleRateHz(kDecoderCNGnb)); |
695 EXPECT_EQ(16000, CodecSampleRateHz(kDecoderCNGwb)); | 705 EXPECT_EQ(16000, CodecSampleRateHz(kDecoderCNGwb)); |
696 EXPECT_EQ(32000, CodecSampleRateHz(kDecoderCNGswb32kHz)); | 706 EXPECT_EQ(32000, CodecSampleRateHz(kDecoderCNGswb32kHz)); |
697 EXPECT_EQ(48000, CodecSampleRateHz(kDecoderOpus)); | 707 EXPECT_EQ(has_opus ? 48000 : -1, CodecSampleRateHz(kDecoderOpus)); |
698 EXPECT_EQ(48000, CodecSampleRateHz(kDecoderOpus_2ch)); | 708 EXPECT_EQ(has_opus ? 48000 : -1, CodecSampleRateHz(kDecoderOpus_2ch)); |
699 // TODO(tlegrand): Change 32000 to 48000 below once ACM has 48 kHz support. | 709 // TODO(tlegrand): Change 32000 to 48000 below once ACM has 48 kHz support. |
700 EXPECT_EQ(32000, CodecSampleRateHz(kDecoderCNGswb48kHz)); | 710 EXPECT_EQ(32000, CodecSampleRateHz(kDecoderCNGswb48kHz)); |
701 EXPECT_EQ(-1, CodecSampleRateHz(kDecoderArbitrary)); | 711 EXPECT_EQ(-1, CodecSampleRateHz(kDecoderArbitrary)); |
702 } | 712 } |
703 | 713 |
704 TEST(AudioDecoder, CodecSupported) { | 714 TEST(AudioDecoder, CodecSupported) { |
705 EXPECT_TRUE(CodecSupported(kDecoderPCMu)); | 715 EXPECT_TRUE(CodecSupported(kDecoderPCMu)); |
706 EXPECT_TRUE(CodecSupported(kDecoderPCMa)); | 716 EXPECT_TRUE(CodecSupported(kDecoderPCMa)); |
707 EXPECT_TRUE(CodecSupported(kDecoderPCMu_2ch)); | 717 EXPECT_TRUE(CodecSupported(kDecoderPCMu_2ch)); |
708 EXPECT_TRUE(CodecSupported(kDecoderPCMa_2ch)); | 718 EXPECT_TRUE(CodecSupported(kDecoderPCMa_2ch)); |
709 EXPECT_TRUE(CodecSupported(kDecoderILBC)); | 719 EXPECT_EQ(has_ilbc, CodecSupported(kDecoderILBC)); |
710 EXPECT_TRUE(CodecSupported(kDecoderISAC)); | 720 EXPECT_EQ(has_isac, CodecSupported(kDecoderISAC)); |
711 EXPECT_TRUE(CodecSupported(kDecoderISACswb)); | 721 EXPECT_EQ(has_isac_swb, CodecSupported(kDecoderISACswb)); |
712 EXPECT_TRUE(CodecSupported(kDecoderISACfb)); | 722 EXPECT_EQ(has_isac_swb, CodecSupported(kDecoderISACfb)); |
713 EXPECT_TRUE(CodecSupported(kDecoderPCM16B)); | 723 EXPECT_TRUE(CodecSupported(kDecoderPCM16B)); |
714 EXPECT_TRUE(CodecSupported(kDecoderPCM16Bwb)); | 724 EXPECT_TRUE(CodecSupported(kDecoderPCM16Bwb)); |
715 EXPECT_TRUE(CodecSupported(kDecoderPCM16Bswb32kHz)); | 725 EXPECT_TRUE(CodecSupported(kDecoderPCM16Bswb32kHz)); |
716 EXPECT_TRUE(CodecSupported(kDecoderPCM16Bswb48kHz)); | 726 EXPECT_TRUE(CodecSupported(kDecoderPCM16Bswb48kHz)); |
717 EXPECT_TRUE(CodecSupported(kDecoderPCM16B_2ch)); | 727 EXPECT_TRUE(CodecSupported(kDecoderPCM16B_2ch)); |
718 EXPECT_TRUE(CodecSupported(kDecoderPCM16Bwb_2ch)); | 728 EXPECT_TRUE(CodecSupported(kDecoderPCM16Bwb_2ch)); |
719 EXPECT_TRUE(CodecSupported(kDecoderPCM16Bswb32kHz_2ch)); | 729 EXPECT_TRUE(CodecSupported(kDecoderPCM16Bswb32kHz_2ch)); |
720 EXPECT_TRUE(CodecSupported(kDecoderPCM16Bswb48kHz_2ch)); | 730 EXPECT_TRUE(CodecSupported(kDecoderPCM16Bswb48kHz_2ch)); |
721 EXPECT_TRUE(CodecSupported(kDecoderPCM16B_5ch)); | 731 EXPECT_TRUE(CodecSupported(kDecoderPCM16B_5ch)); |
722 EXPECT_TRUE(CodecSupported(kDecoderG722)); | 732 EXPECT_EQ(has_g722, CodecSupported(kDecoderG722)); |
723 EXPECT_TRUE(CodecSupported(kDecoderG722_2ch)); | 733 EXPECT_EQ(has_g722, CodecSupported(kDecoderG722_2ch)); |
724 EXPECT_TRUE(CodecSupported(kDecoderRED)); | 734 EXPECT_TRUE(CodecSupported(kDecoderRED)); |
725 EXPECT_TRUE(CodecSupported(kDecoderAVT)); | 735 EXPECT_TRUE(CodecSupported(kDecoderAVT)); |
726 EXPECT_TRUE(CodecSupported(kDecoderCNGnb)); | 736 EXPECT_TRUE(CodecSupported(kDecoderCNGnb)); |
727 EXPECT_TRUE(CodecSupported(kDecoderCNGwb)); | 737 EXPECT_TRUE(CodecSupported(kDecoderCNGwb)); |
728 EXPECT_TRUE(CodecSupported(kDecoderCNGswb32kHz)); | 738 EXPECT_TRUE(CodecSupported(kDecoderCNGswb32kHz)); |
729 EXPECT_TRUE(CodecSupported(kDecoderCNGswb48kHz)); | 739 EXPECT_TRUE(CodecSupported(kDecoderCNGswb48kHz)); |
730 EXPECT_TRUE(CodecSupported(kDecoderArbitrary)); | 740 EXPECT_TRUE(CodecSupported(kDecoderArbitrary)); |
731 EXPECT_TRUE(CodecSupported(kDecoderOpus)); | 741 EXPECT_EQ(has_opus, CodecSupported(kDecoderOpus)); |
732 EXPECT_TRUE(CodecSupported(kDecoderOpus_2ch)); | 742 EXPECT_EQ(has_opus, CodecSupported(kDecoderOpus_2ch)); |
733 } | 743 } |
734 | 744 |
735 } // namespace webrtc | 745 } // namespace webrtc |
OLD | NEW |