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

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

Issue 1921653002: Enable -Winconsistent-missing-override flag. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Rebase. 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) 2014 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2014 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 590 matching lines...) Expand 10 before | Expand all | Expand 10 after
601 class AcmIsacMtTestOldApi : public AudioCodingModuleMtTestOldApi { 601 class AcmIsacMtTestOldApi : public AudioCodingModuleMtTestOldApi {
602 protected: 602 protected:
603 static const int kNumPackets = 500; 603 static const int kNumPackets = 500;
604 static const int kNumPullCalls = 500; 604 static const int kNumPullCalls = 500;
605 605
606 AcmIsacMtTestOldApi() 606 AcmIsacMtTestOldApi()
607 : AudioCodingModuleMtTestOldApi(), last_packet_number_(0) {} 607 : AudioCodingModuleMtTestOldApi(), last_packet_number_(0) {}
608 608
609 ~AcmIsacMtTestOldApi() {} 609 ~AcmIsacMtTestOldApi() {}
610 610
611 void SetUp() { 611 void SetUp() override {
612 AudioCodingModuleTestOldApi::SetUp(); 612 AudioCodingModuleTestOldApi::SetUp();
613 RegisterCodec(); // Must be called before the threads start below. 613 RegisterCodec(); // Must be called before the threads start below.
614 614
615 // Set up input audio source to read from specified file, loop after 5 615 // Set up input audio source to read from specified file, loop after 5
616 // seconds, and deliver blocks of 10 ms. 616 // seconds, and deliver blocks of 10 ms.
617 const std::string input_file_name = 617 const std::string input_file_name =
618 webrtc::test::ResourcePath("audio_coding/speech_mono_16kHz", "pcm"); 618 webrtc::test::ResourcePath("audio_coding/speech_mono_16kHz", "pcm");
619 audio_loop_.Init(input_file_name, 5 * kSampleRateHz, kNumSamples10ms); 619 audio_loop_.Init(input_file_name, 5 * kSampleRateHz, kNumSamples10ms);
620 620
621 // Generate one packet to have something to insert. 621 // Generate one packet to have something to insert.
(...skipping 13 matching lines...) Expand all
635 static_assert(kSampleRateHz == 16000, "test designed for iSAC 16 kHz"); 635 static_assert(kSampleRateHz == 16000, "test designed for iSAC 16 kHz");
636 AudioCodingModule::Codec("ISAC", &codec_, kSampleRateHz, 1); 636 AudioCodingModule::Codec("ISAC", &codec_, kSampleRateHz, 1);
637 codec_.pltype = kPayloadType; 637 codec_.pltype = kPayloadType;
638 638
639 // Register iSAC codec in ACM, effectively unregistering the PCM16B codec 639 // Register iSAC codec in ACM, effectively unregistering the PCM16B codec
640 // registered in AudioCodingModuleTestOldApi::SetUp(); 640 // registered in AudioCodingModuleTestOldApi::SetUp();
641 ASSERT_EQ(0, acm_->RegisterReceiveCodec(codec_)); 641 ASSERT_EQ(0, acm_->RegisterReceiveCodec(codec_));
642 ASSERT_EQ(0, acm_->RegisterSendCodec(codec_)); 642 ASSERT_EQ(0, acm_->RegisterSendCodec(codec_));
643 } 643 }
644 644
645 void InsertPacket() { 645 void InsertPacket() override {
646 int num_calls = packet_cb_.num_calls(); // Store locally for thread safety. 646 int num_calls = packet_cb_.num_calls(); // Store locally for thread safety.
647 if (num_calls > last_packet_number_) { 647 if (num_calls > last_packet_number_) {
648 // Get the new payload out from the callback handler. 648 // Get the new payload out from the callback handler.
649 // Note that since we swap buffers here instead of directly inserting 649 // Note that since we swap buffers here instead of directly inserting
650 // a pointer to the data in |packet_cb_|, we avoid locking the callback 650 // a pointer to the data in |packet_cb_|, we avoid locking the callback
651 // for the duration of the IncomingPacket() call. 651 // for the duration of the IncomingPacket() call.
652 packet_cb_.SwapBuffers(&last_payload_vec_); 652 packet_cb_.SwapBuffers(&last_payload_vec_);
653 ASSERT_GT(last_payload_vec_.size(), 0u); 653 ASSERT_GT(last_payload_vec_.size(), 0u);
654 rtp_utility_->Forward(&rtp_header_); 654 rtp_utility_->Forward(&rtp_header_);
655 last_packet_number_ = num_calls; 655 last_packet_number_ = num_calls;
656 } 656 }
657 ASSERT_GT(last_payload_vec_.size(), 0u); 657 ASSERT_GT(last_payload_vec_.size(), 0u);
658 ASSERT_EQ( 658 ASSERT_EQ(
659 0, 659 0,
660 acm_->IncomingPacket( 660 acm_->IncomingPacket(
661 &last_payload_vec_[0], last_payload_vec_.size(), rtp_header_)); 661 &last_payload_vec_[0], last_payload_vec_.size(), rtp_header_));
662 } 662 }
663 663
664 void InsertAudio() { 664 void InsertAudio() override {
665 // TODO(kwiberg): Use std::copy here. Might be complications because AFAICS 665 // TODO(kwiberg): Use std::copy here. Might be complications because AFAICS
666 // this call confuses the number of samples with the number of bytes, and 666 // this call confuses the number of samples with the number of bytes, and
667 // ends up copying only half of what it should. 667 // ends up copying only half of what it should.
668 memcpy(input_frame_.data_, audio_loop_.GetNextBlock().data(), 668 memcpy(input_frame_.data_, audio_loop_.GetNextBlock().data(),
669 kNumSamples10ms); 669 kNumSamples10ms);
670 AudioCodingModuleTestOldApi::InsertAudio(); 670 AudioCodingModuleTestOldApi::InsertAudio();
671 } 671 }
672 672
673 // Override the verification function with no-op, since iSAC produces variable 673 // Override the verification function with no-op, since iSAC produces variable
674 // payload sizes. 674 // payload sizes.
675 void VerifyEncoding() override {} 675 void VerifyEncoding() override {}
676 676
677 // This method is the same as AudioCodingModuleMtTestOldApi::TestDone(), but 677 // This method is the same as AudioCodingModuleMtTestOldApi::TestDone(), but
678 // here it is using the constants defined in this class (i.e., shorter test 678 // here it is using the constants defined in this class (i.e., shorter test
679 // run). 679 // run).
680 virtual bool TestDone() { 680 bool TestDone() override {
681 if (packet_cb_.num_calls() > kNumPackets) { 681 if (packet_cb_.num_calls() > kNumPackets) {
682 rtc::CritScope lock(&crit_sect_); 682 rtc::CritScope lock(&crit_sect_);
683 if (pull_audio_count_ > kNumPullCalls) { 683 if (pull_audio_count_ > kNumPullCalls) {
684 // Both conditions for completion are met. End the test. 684 // Both conditions for completion are met. End the test.
685 return true; 685 return true;
686 } 686 }
687 } 687 }
688 return false; 688 return false;
689 } 689 }
690 690
(...skipping 30 matching lines...) Expand all
721 codec_registered_(false), 721 codec_registered_(false),
722 receive_packet_count_(0), 722 receive_packet_count_(0),
723 next_insert_packet_time_ms_(0), 723 next_insert_packet_time_ms_(0),
724 fake_clock_(new SimulatedClock(0)) { 724 fake_clock_(new SimulatedClock(0)) {
725 AudioEncoderIsac::Config config; 725 AudioEncoderIsac::Config config;
726 config.payload_type = kPayloadType; 726 config.payload_type = kPayloadType;
727 isac_encoder_.reset(new AudioEncoderIsac(config)); 727 isac_encoder_.reset(new AudioEncoderIsac(config));
728 clock_ = fake_clock_.get(); 728 clock_ = fake_clock_.get();
729 } 729 }
730 730
731 void SetUp() { 731 void SetUp() override {
732 AudioCodingModuleTestOldApi::SetUp(); 732 AudioCodingModuleTestOldApi::SetUp();
733 // Set up input audio source to read from specified file, loop after 5 733 // Set up input audio source to read from specified file, loop after 5
734 // seconds, and deliver blocks of 10 ms. 734 // seconds, and deliver blocks of 10 ms.
735 const std::string input_file_name = 735 const std::string input_file_name =
736 webrtc::test::ResourcePath("audio_coding/speech_mono_16kHz", "pcm"); 736 webrtc::test::ResourcePath("audio_coding/speech_mono_16kHz", "pcm");
737 audio_loop_.Init(input_file_name, 5 * kSampleRateHz, kNumSamples10ms); 737 audio_loop_.Init(input_file_name, 5 * kSampleRateHz, kNumSamples10ms);
738 RegisterCodec(); // Must be called before the threads start below. 738 RegisterCodec(); // Must be called before the threads start below.
739 StartThreads(); 739 StartThreads();
740 } 740 }
741 741
742 void RegisterCodec() override { 742 void RegisterCodec() override {
743 static_assert(kSampleRateHz == 16000, "test designed for iSAC 16 kHz"); 743 static_assert(kSampleRateHz == 16000, "test designed for iSAC 16 kHz");
744 AudioCodingModule::Codec("ISAC", &codec_, kSampleRateHz, 1); 744 AudioCodingModule::Codec("ISAC", &codec_, kSampleRateHz, 1);
745 codec_.pltype = kPayloadType; 745 codec_.pltype = kPayloadType;
746 746
747 // Register iSAC codec in ACM, effectively unregistering the PCM16B codec 747 // Register iSAC codec in ACM, effectively unregistering the PCM16B codec
748 // registered in AudioCodingModuleTestOldApi::SetUp(); 748 // registered in AudioCodingModuleTestOldApi::SetUp();
749 // Only register the decoder for now. The encoder is registered later. 749 // Only register the decoder for now. The encoder is registered later.
750 ASSERT_EQ(0, acm_->RegisterReceiveCodec(codec_)); 750 ASSERT_EQ(0, acm_->RegisterReceiveCodec(codec_));
751 } 751 }
752 752
753 void StartThreads() { 753 void StartThreads() {
754 receive_thread_.Start(); 754 receive_thread_.Start();
755 receive_thread_.SetPriority(rtc::kRealtimePriority); 755 receive_thread_.SetPriority(rtc::kRealtimePriority);
756 codec_registration_thread_.Start(); 756 codec_registration_thread_.Start();
757 codec_registration_thread_.SetPriority(rtc::kRealtimePriority); 757 codec_registration_thread_.SetPriority(rtc::kRealtimePriority);
758 } 758 }
759 759
760 void TearDown() { 760 void TearDown() override {
761 AudioCodingModuleTestOldApi::TearDown(); 761 AudioCodingModuleTestOldApi::TearDown();
762 receive_thread_.Stop(); 762 receive_thread_.Stop();
763 codec_registration_thread_.Stop(); 763 codec_registration_thread_.Stop();
764 } 764 }
765 765
766 EventTypeWrapper RunTest() { 766 EventTypeWrapper RunTest() {
767 return test_complete_->Wait(10 * 60 * 1000); // 10 minutes' timeout. 767 return test_complete_->Wait(10 * 60 * 1000); // 10 minutes' timeout.
768 } 768 }
769 769
770 static bool CbReceiveThread(void* context) { 770 static bool CbReceiveThread(void* context) {
(...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after
1730 if (num_packets_++ > kTestNumPackets) { 1730 if (num_packets_++ > kTestNumPackets) {
1731 EXPECT_TRUE(has_toggled_); 1731 EXPECT_TRUE(has_toggled_);
1732 return NULL; // Test ended. 1732 return NULL; // Test ended.
1733 } 1733 }
1734 1734
1735 // Get the next packet from the source. 1735 // Get the next packet from the source.
1736 return packet_source_.NextPacket(); 1736 return packet_source_.NextPacket();
1737 } 1737 }
1738 1738
1739 // Inherited from test::AudioSink. 1739 // Inherited from test::AudioSink.
1740 bool WriteArray(const int16_t* audio, size_t num_samples) { 1740 bool WriteArray(const int16_t* audio, size_t num_samples) override {
1741 // Skip checking the first output frame, since it has a number of zeros 1741 // Skip checking the first output frame, since it has a number of zeros
1742 // due to how NetEq is initialized. 1742 // due to how NetEq is initialized.
1743 if (first_output_) { 1743 if (first_output_) {
1744 first_output_ = false; 1744 first_output_ = false;
1745 return true; 1745 return true;
1746 } 1746 }
1747 for (size_t i = 0; i < num_samples; ++i) { 1747 for (size_t i = 0; i < num_samples; ++i) {
1748 EXPECT_EQ(kSampleValue, audio[i]); 1748 EXPECT_EQ(kSampleValue, audio[i]);
1749 } 1749 }
1750 if (num_samples == 1750 if (num_samples ==
(...skipping 28 matching lines...) Expand all
1779 Run(16000, 8000, 1000); 1779 Run(16000, 8000, 1000);
1780 } 1780 }
1781 1781
1782 TEST_F(AcmSwitchingOutputFrequencyOldApi, Toggle8KhzTo16Khz) { 1782 TEST_F(AcmSwitchingOutputFrequencyOldApi, Toggle8KhzTo16Khz) {
1783 Run(8000, 16000, 1000); 1783 Run(8000, 16000, 1000);
1784 } 1784 }
1785 1785
1786 #endif 1786 #endif
1787 1787
1788 } // namespace webrtc 1788 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698