OLD | NEW |
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 |
11 #include <string.h> | 11 #include <string.h> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "webrtc/base/md5digest.h" | 15 #include "webrtc/base/md5digest.h" |
| 16 #include "webrtc/base/platform_thread.h" |
16 #include "webrtc/base/scoped_ptr.h" | 17 #include "webrtc/base/scoped_ptr.h" |
17 #include "webrtc/base/thread_annotations.h" | 18 #include "webrtc/base/thread_annotations.h" |
18 #include "webrtc/modules/audio_coding/codecs/audio_encoder.h" | 19 #include "webrtc/modules/audio_coding/codecs/audio_encoder.h" |
19 #include "webrtc/modules/audio_coding/codecs/g711/audio_decoder_pcm.h" | 20 #include "webrtc/modules/audio_coding/codecs/g711/audio_decoder_pcm.h" |
20 #include "webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.h" | 21 #include "webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.h" |
21 #include "webrtc/modules/audio_coding/codecs/isac/main/include/audio_encoder_isa
c.h" | 22 #include "webrtc/modules/audio_coding/codecs/isac/main/include/audio_encoder_isa
c.h" |
22 #include "webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h" | 23 #include "webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h" |
23 #include "webrtc/modules/audio_coding/main/acm2/acm_receive_test_oldapi.h" | 24 #include "webrtc/modules/audio_coding/main/acm2/acm_receive_test_oldapi.h" |
24 #include "webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.h" | 25 #include "webrtc/modules/audio_coding/main/acm2/acm_send_test_oldapi.h" |
25 #include "webrtc/modules/audio_coding/main/include/audio_coding_module.h" | 26 #include "webrtc/modules/audio_coding/main/include/audio_coding_module.h" |
26 #include "webrtc/modules/audio_coding/main/include/audio_coding_module_typedefs.
h" | 27 #include "webrtc/modules/audio_coding/main/include/audio_coding_module_typedefs.
h" |
27 #include "webrtc/modules/audio_coding/neteq/audio_decoder_impl.h" | 28 #include "webrtc/modules/audio_coding/neteq/audio_decoder_impl.h" |
28 #include "webrtc/modules/audio_coding/neteq/mock/mock_audio_decoder.h" | 29 #include "webrtc/modules/audio_coding/neteq/mock/mock_audio_decoder.h" |
29 #include "webrtc/modules/audio_coding/neteq/tools/audio_checksum.h" | 30 #include "webrtc/modules/audio_coding/neteq/tools/audio_checksum.h" |
30 #include "webrtc/modules/audio_coding/neteq/tools/audio_loop.h" | 31 #include "webrtc/modules/audio_coding/neteq/tools/audio_loop.h" |
31 #include "webrtc/modules/audio_coding/neteq/tools/constant_pcm_packet_source.h" | 32 #include "webrtc/modules/audio_coding/neteq/tools/constant_pcm_packet_source.h" |
32 #include "webrtc/modules/audio_coding/neteq/tools/input_audio_file.h" | 33 #include "webrtc/modules/audio_coding/neteq/tools/input_audio_file.h" |
33 #include "webrtc/modules/audio_coding/neteq/tools/output_audio_file.h" | 34 #include "webrtc/modules/audio_coding/neteq/tools/output_audio_file.h" |
34 #include "webrtc/modules/audio_coding/neteq/tools/packet.h" | 35 #include "webrtc/modules/audio_coding/neteq/tools/packet.h" |
35 #include "webrtc/modules/audio_coding/neteq/tools/rtp_file_source.h" | 36 #include "webrtc/modules/audio_coding/neteq/tools/rtp_file_source.h" |
36 #include "webrtc/modules/include/module_common_types.h" | 37 #include "webrtc/modules/include/module_common_types.h" |
37 #include "webrtc/system_wrappers/include/clock.h" | 38 #include "webrtc/system_wrappers/include/clock.h" |
38 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" | 39 #include "webrtc/system_wrappers/include/critical_section_wrapper.h" |
39 #include "webrtc/system_wrappers/include/event_wrapper.h" | 40 #include "webrtc/system_wrappers/include/event_wrapper.h" |
40 #include "webrtc/system_wrappers/include/sleep.h" | 41 #include "webrtc/system_wrappers/include/sleep.h" |
41 #include "webrtc/system_wrappers/include/thread_wrapper.h" | |
42 #include "webrtc/test/testsupport/fileutils.h" | 42 #include "webrtc/test/testsupport/fileutils.h" |
43 #include "webrtc/test/testsupport/gtest_disable.h" | 43 #include "webrtc/test/testsupport/gtest_disable.h" |
44 | 44 |
45 using ::testing::AtLeast; | 45 using ::testing::AtLeast; |
46 using ::testing::Invoke; | 46 using ::testing::Invoke; |
47 using ::testing::_; | 47 using ::testing::_; |
48 | 48 |
49 namespace webrtc { | 49 namespace webrtc { |
50 | 50 |
51 namespace { | 51 namespace { |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 | 450 |
451 // A multi-threaded test for ACM. This base class is using the PCM16b 16 kHz | 451 // A multi-threaded test for ACM. This base class is using the PCM16b 16 kHz |
452 // codec, while the derive class AcmIsacMtTest is using iSAC. | 452 // codec, while the derive class AcmIsacMtTest is using iSAC. |
453 class AudioCodingModuleMtTestOldApi : public AudioCodingModuleTestOldApi { | 453 class AudioCodingModuleMtTestOldApi : public AudioCodingModuleTestOldApi { |
454 protected: | 454 protected: |
455 static const int kNumPackets = 500; | 455 static const int kNumPackets = 500; |
456 static const int kNumPullCalls = 500; | 456 static const int kNumPullCalls = 500; |
457 | 457 |
458 AudioCodingModuleMtTestOldApi() | 458 AudioCodingModuleMtTestOldApi() |
459 : AudioCodingModuleTestOldApi(), | 459 : AudioCodingModuleTestOldApi(), |
460 send_thread_(ThreadWrapper::CreateThread(CbSendThread, this, "send")), | 460 send_thread_(PlatformThread::CreateThread(CbSendThread, this, "send")), |
461 insert_packet_thread_(ThreadWrapper::CreateThread( | 461 insert_packet_thread_(PlatformThread::CreateThread(CbInsertPacketThread, |
462 CbInsertPacketThread, this, "insert_packet")), | 462 this, |
463 pull_audio_thread_(ThreadWrapper::CreateThread( | 463 "insert_packet")), |
464 CbPullAudioThread, this, "pull_audio")), | 464 pull_audio_thread_(PlatformThread::CreateThread(CbPullAudioThread, |
| 465 this, |
| 466 "pull_audio")), |
465 test_complete_(EventWrapper::Create()), | 467 test_complete_(EventWrapper::Create()), |
466 send_count_(0), | 468 send_count_(0), |
467 insert_packet_count_(0), | 469 insert_packet_count_(0), |
468 pull_audio_count_(0), | 470 pull_audio_count_(0), |
469 crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), | 471 crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), |
470 next_insert_packet_time_ms_(0), | 472 next_insert_packet_time_ms_(0), |
471 fake_clock_(new SimulatedClock(0)) { | 473 fake_clock_(new SimulatedClock(0)) { |
472 clock_ = fake_clock_.get(); | 474 clock_ = fake_clock_.get(); |
473 } | 475 } |
474 | 476 |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 return true; | 566 return true; |
565 } | 567 } |
566 ++pull_audio_count_; | 568 ++pull_audio_count_; |
567 } | 569 } |
568 // Now we're not holding the crit sect when calling ACM. | 570 // Now we're not holding the crit sect when calling ACM. |
569 PullAudio(); | 571 PullAudio(); |
570 fake_clock_->AdvanceTimeMilliseconds(10); | 572 fake_clock_->AdvanceTimeMilliseconds(10); |
571 return true; | 573 return true; |
572 } | 574 } |
573 | 575 |
574 rtc::scoped_ptr<ThreadWrapper> send_thread_; | 576 rtc::scoped_ptr<PlatformThread> send_thread_; |
575 rtc::scoped_ptr<ThreadWrapper> insert_packet_thread_; | 577 rtc::scoped_ptr<PlatformThread> insert_packet_thread_; |
576 rtc::scoped_ptr<ThreadWrapper> pull_audio_thread_; | 578 rtc::scoped_ptr<PlatformThread> pull_audio_thread_; |
577 const rtc::scoped_ptr<EventWrapper> test_complete_; | 579 const rtc::scoped_ptr<EventWrapper> test_complete_; |
578 int send_count_; | 580 int send_count_; |
579 int insert_packet_count_; | 581 int insert_packet_count_; |
580 int pull_audio_count_ GUARDED_BY(crit_sect_); | 582 int pull_audio_count_ GUARDED_BY(crit_sect_); |
581 const rtc::scoped_ptr<CriticalSectionWrapper> crit_sect_; | 583 const rtc::scoped_ptr<CriticalSectionWrapper> crit_sect_; |
582 int64_t next_insert_packet_time_ms_ GUARDED_BY(crit_sect_); | 584 int64_t next_insert_packet_time_ms_ GUARDED_BY(crit_sect_); |
583 rtc::scoped_ptr<SimulatedClock> fake_clock_; | 585 rtc::scoped_ptr<SimulatedClock> fake_clock_; |
584 }; | 586 }; |
585 | 587 |
586 TEST_F(AudioCodingModuleMtTestOldApi, DISABLED_ON_IOS(DoTest)) { | 588 TEST_F(AudioCodingModuleMtTestOldApi, DISABLED_ON_IOS(DoTest)) { |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 class AcmReRegisterIsacMtTestOldApi : public AudioCodingModuleTestOldApi { | 696 class AcmReRegisterIsacMtTestOldApi : public AudioCodingModuleTestOldApi { |
695 protected: | 697 protected: |
696 static const int kRegisterAfterNumPackets = 5; | 698 static const int kRegisterAfterNumPackets = 5; |
697 static const int kNumPackets = 10; | 699 static const int kNumPackets = 10; |
698 static const int kPacketSizeMs = 30; | 700 static const int kPacketSizeMs = 30; |
699 static const int kPacketSizeSamples = kPacketSizeMs * 16; | 701 static const int kPacketSizeSamples = kPacketSizeMs * 16; |
700 | 702 |
701 AcmReRegisterIsacMtTestOldApi() | 703 AcmReRegisterIsacMtTestOldApi() |
702 : AudioCodingModuleTestOldApi(), | 704 : AudioCodingModuleTestOldApi(), |
703 receive_thread_( | 705 receive_thread_( |
704 ThreadWrapper::CreateThread(CbReceiveThread, this, "receive")), | 706 PlatformThread::CreateThread(CbReceiveThread, this, "receive")), |
705 codec_registration_thread_( | 707 codec_registration_thread_( |
706 ThreadWrapper::CreateThread(CbCodecRegistrationThread, | 708 PlatformThread::CreateThread(CbCodecRegistrationThread, |
707 this, | 709 this, |
708 "codec_registration")), | 710 "codec_registration")), |
709 test_complete_(EventWrapper::Create()), | 711 test_complete_(EventWrapper::Create()), |
710 crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), | 712 crit_sect_(CriticalSectionWrapper::CreateCriticalSection()), |
711 codec_registered_(false), | 713 codec_registered_(false), |
712 receive_packet_count_(0), | 714 receive_packet_count_(0), |
713 next_insert_packet_time_ms_(0), | 715 next_insert_packet_time_ms_(0), |
714 fake_clock_(new SimulatedClock(0)) { | 716 fake_clock_(new SimulatedClock(0)) { |
715 AudioEncoderIsac::Config config; | 717 AudioEncoderIsac::Config config; |
716 config.payload_type = kPayloadType; | 718 config.payload_type = kPayloadType; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 // Register the iSAC encoder. | 824 // Register the iSAC encoder. |
823 EXPECT_EQ(0, acm_->RegisterSendCodec(codec_)); | 825 EXPECT_EQ(0, acm_->RegisterSendCodec(codec_)); |
824 codec_registered_ = true; | 826 codec_registered_ = true; |
825 } | 827 } |
826 if (codec_registered_ && receive_packet_count_ > kNumPackets) { | 828 if (codec_registered_ && receive_packet_count_ > kNumPackets) { |
827 test_complete_->Set(); | 829 test_complete_->Set(); |
828 } | 830 } |
829 return true; | 831 return true; |
830 } | 832 } |
831 | 833 |
832 rtc::scoped_ptr<ThreadWrapper> receive_thread_; | 834 rtc::scoped_ptr<PlatformThread> receive_thread_; |
833 rtc::scoped_ptr<ThreadWrapper> codec_registration_thread_; | 835 rtc::scoped_ptr<PlatformThread> codec_registration_thread_; |
834 const rtc::scoped_ptr<EventWrapper> test_complete_; | 836 const rtc::scoped_ptr<EventWrapper> test_complete_; |
835 const rtc::scoped_ptr<CriticalSectionWrapper> crit_sect_; | 837 const rtc::scoped_ptr<CriticalSectionWrapper> crit_sect_; |
836 bool codec_registered_ GUARDED_BY(crit_sect_); | 838 bool codec_registered_ GUARDED_BY(crit_sect_); |
837 int receive_packet_count_ GUARDED_BY(crit_sect_); | 839 int receive_packet_count_ GUARDED_BY(crit_sect_); |
838 int64_t next_insert_packet_time_ms_ GUARDED_BY(crit_sect_); | 840 int64_t next_insert_packet_time_ms_ GUARDED_BY(crit_sect_); |
839 rtc::scoped_ptr<AudioEncoderIsac> isac_encoder_; | 841 rtc::scoped_ptr<AudioEncoderIsac> isac_encoder_; |
840 rtc::scoped_ptr<SimulatedClock> fake_clock_; | 842 rtc::scoped_ptr<SimulatedClock> fake_clock_; |
841 test::AudioLoop audio_loop_; | 843 test::AudioLoop audio_loop_; |
842 }; | 844 }; |
843 | 845 |
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1766 Run(16000, 8000, 1000); | 1768 Run(16000, 8000, 1000); |
1767 } | 1769 } |
1768 | 1770 |
1769 TEST_F(AcmSwitchingOutputFrequencyOldApi, Toggle8KhzTo16Khz) { | 1771 TEST_F(AcmSwitchingOutputFrequencyOldApi, Toggle8KhzTo16Khz) { |
1770 Run(8000, 16000, 1000); | 1772 Run(8000, 16000, 1000); |
1771 } | 1773 } |
1772 | 1774 |
1773 #endif | 1775 #endif |
1774 | 1776 |
1775 } // namespace webrtc | 1777 } // namespace webrtc |
OLD | NEW |