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

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

Issue 1694073002: Replace scoped_ptr with unique_ptr in webrtc/modules/audio_coding/ (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@up-actest
Patch Set: Created 4 years, 10 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
11 #include <stdio.h> 11 #include <stdio.h>
12 #include <string.h> 12 #include <string.h>
13 #include <memory>
13 #include <vector> 14 #include <vector>
14 15
15 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
16 #include "webrtc/base/criticalsection.h" 17 #include "webrtc/base/criticalsection.h"
17 #include "webrtc/base/md5digest.h" 18 #include "webrtc/base/md5digest.h"
18 #include "webrtc/base/platform_thread.h" 19 #include "webrtc/base/platform_thread.h"
19 #include "webrtc/base/scoped_ptr.h"
20 #include "webrtc/base/thread_annotations.h" 20 #include "webrtc/base/thread_annotations.h"
21 #include "webrtc/modules/audio_coding/acm2/acm_receive_test_oldapi.h" 21 #include "webrtc/modules/audio_coding/acm2/acm_receive_test_oldapi.h"
22 #include "webrtc/modules/audio_coding/acm2/acm_send_test_oldapi.h" 22 #include "webrtc/modules/audio_coding/acm2/acm_send_test_oldapi.h"
23 #include "webrtc/modules/audio_coding/codecs/audio_encoder.h" 23 #include "webrtc/modules/audio_coding/codecs/audio_encoder.h"
24 #include "webrtc/modules/audio_coding/codecs/g711/audio_decoder_pcm.h" 24 #include "webrtc/modules/audio_coding/codecs/g711/audio_decoder_pcm.h"
25 #include "webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.h" 25 #include "webrtc/modules/audio_coding/codecs/g711/audio_encoder_pcm.h"
26 #include "webrtc/modules/audio_coding/codecs/isac/main/include/audio_encoder_isa c.h" 26 #include "webrtc/modules/audio_coding/codecs/isac/main/include/audio_encoder_isa c.h"
27 #include "webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h" 27 #include "webrtc/modules/audio_coding/codecs/mock/mock_audio_encoder.h"
28 #include "webrtc/modules/audio_coding/include/audio_coding_module.h" 28 #include "webrtc/modules/audio_coding/include/audio_coding_module.h"
29 #include "webrtc/modules/audio_coding/include/audio_coding_module_typedefs.h" 29 #include "webrtc/modules/audio_coding/include/audio_coding_module_typedefs.h"
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 EXPECT_TRUE(last_length == 2 * codec_.pacsize || last_length == 0) 218 EXPECT_TRUE(last_length == 2 * codec_.pacsize || last_length == 0)
219 << "Last encoded packet was " << last_length << " bytes."; 219 << "Last encoded packet was " << last_length << " bytes.";
220 } 220 }
221 221
222 virtual void InsertAudioAndVerifyEncoding() { 222 virtual void InsertAudioAndVerifyEncoding() {
223 InsertAudio(); 223 InsertAudio();
224 VerifyEncoding(); 224 VerifyEncoding();
225 } 225 }
226 226
227 const int id_; 227 const int id_;
228 rtc::scoped_ptr<RtpUtility> rtp_utility_; 228 std::unique_ptr<RtpUtility> rtp_utility_;
229 rtc::scoped_ptr<AudioCodingModule> acm_; 229 std::unique_ptr<AudioCodingModule> acm_;
230 PacketizationCallbackStubOldApi packet_cb_; 230 PacketizationCallbackStubOldApi packet_cb_;
231 WebRtcRTPHeader rtp_header_; 231 WebRtcRTPHeader rtp_header_;
232 AudioFrame input_frame_; 232 AudioFrame input_frame_;
233 CodecInst codec_; 233 CodecInst codec_;
234 Clock* clock_; 234 Clock* clock_;
235 }; 235 };
236 236
237 // Check if the statistics are initialized correctly. Before any call to ACM 237 // Check if the statistics are initialized correctly. Before any call to ACM
238 // all fields have to be zero. 238 // all fields have to be zero.
239 #if defined(WEBRTC_ANDROID) 239 #if defined(WEBRTC_ANDROID)
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 } 568 }
569 // Now we're not holding the crit sect when calling ACM. 569 // Now we're not holding the crit sect when calling ACM.
570 PullAudio(); 570 PullAudio();
571 fake_clock_->AdvanceTimeMilliseconds(10); 571 fake_clock_->AdvanceTimeMilliseconds(10);
572 return true; 572 return true;
573 } 573 }
574 574
575 rtc::PlatformThread send_thread_; 575 rtc::PlatformThread send_thread_;
576 rtc::PlatformThread insert_packet_thread_; 576 rtc::PlatformThread insert_packet_thread_;
577 rtc::PlatformThread pull_audio_thread_; 577 rtc::PlatformThread pull_audio_thread_;
578 const rtc::scoped_ptr<EventWrapper> test_complete_; 578 const std::unique_ptr<EventWrapper> test_complete_;
579 int send_count_; 579 int send_count_;
580 int insert_packet_count_; 580 int insert_packet_count_;
581 int pull_audio_count_ GUARDED_BY(crit_sect_); 581 int pull_audio_count_ GUARDED_BY(crit_sect_);
582 rtc::CriticalSection crit_sect_; 582 rtc::CriticalSection crit_sect_;
583 int64_t next_insert_packet_time_ms_ GUARDED_BY(crit_sect_); 583 int64_t next_insert_packet_time_ms_ GUARDED_BY(crit_sect_);
584 rtc::scoped_ptr<SimulatedClock> fake_clock_; 584 std::unique_ptr<SimulatedClock> fake_clock_;
585 }; 585 };
586 586
587 #if defined(WEBRTC_IOS) 587 #if defined(WEBRTC_IOS)
588 #define MAYBE_DoTest DISABLED_DoTest 588 #define MAYBE_DoTest DISABLED_DoTest
589 #else 589 #else
590 #define MAYBE_DoTest DoTest 590 #define MAYBE_DoTest DoTest
591 #endif 591 #endif
592 TEST_F(AudioCodingModuleMtTestOldApi, MAYBE_DoTest) { 592 TEST_F(AudioCodingModuleMtTestOldApi, MAYBE_DoTest) {
593 EXPECT_EQ(kEventSignaled, RunTest()); 593 EXPECT_EQ(kEventSignaled, RunTest());
594 } 594 }
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
768 } 768 }
769 769
770 static bool CbReceiveThread(void* context) { 770 static bool CbReceiveThread(void* context) {
771 return reinterpret_cast<AcmReRegisterIsacMtTestOldApi*>(context) 771 return reinterpret_cast<AcmReRegisterIsacMtTestOldApi*>(context)
772 ->CbReceiveImpl(); 772 ->CbReceiveImpl();
773 } 773 }
774 774
775 bool CbReceiveImpl() { 775 bool CbReceiveImpl() {
776 SleepMs(1); 776 SleepMs(1);
777 const size_t max_encoded_bytes = isac_encoder_->MaxEncodedBytes(); 777 const size_t max_encoded_bytes = isac_encoder_->MaxEncodedBytes();
778 rtc::scoped_ptr<uint8_t[]> encoded(new uint8_t[max_encoded_bytes]); 778 std::unique_ptr<uint8_t[]> encoded(new uint8_t[max_encoded_bytes]);
779 AudioEncoder::EncodedInfo info; 779 AudioEncoder::EncodedInfo info;
780 { 780 {
781 rtc::CritScope lock(&crit_sect_); 781 rtc::CritScope lock(&crit_sect_);
782 if (clock_->TimeInMilliseconds() < next_insert_packet_time_ms_) { 782 if (clock_->TimeInMilliseconds() < next_insert_packet_time_ms_) {
783 return true; 783 return true;
784 } 784 }
785 next_insert_packet_time_ms_ += kPacketSizeMs; 785 next_insert_packet_time_ms_ += kPacketSizeMs;
786 ++receive_packet_count_; 786 ++receive_packet_count_;
787 787
788 // Encode new frame. 788 // Encode new frame.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
834 codec_registered_ = true; 834 codec_registered_ = true;
835 } 835 }
836 if (codec_registered_ && receive_packet_count_ > kNumPackets) { 836 if (codec_registered_ && receive_packet_count_ > kNumPackets) {
837 test_complete_->Set(); 837 test_complete_->Set();
838 } 838 }
839 return true; 839 return true;
840 } 840 }
841 841
842 rtc::PlatformThread receive_thread_; 842 rtc::PlatformThread receive_thread_;
843 rtc::PlatformThread codec_registration_thread_; 843 rtc::PlatformThread codec_registration_thread_;
844 const rtc::scoped_ptr<EventWrapper> test_complete_; 844 const std::unique_ptr<EventWrapper> test_complete_;
845 rtc::CriticalSection crit_sect_; 845 rtc::CriticalSection crit_sect_;
846 bool codec_registered_ GUARDED_BY(crit_sect_); 846 bool codec_registered_ GUARDED_BY(crit_sect_);
847 int receive_packet_count_ GUARDED_BY(crit_sect_); 847 int receive_packet_count_ GUARDED_BY(crit_sect_);
848 int64_t next_insert_packet_time_ms_ GUARDED_BY(crit_sect_); 848 int64_t next_insert_packet_time_ms_ GUARDED_BY(crit_sect_);
849 rtc::scoped_ptr<AudioEncoderIsac> isac_encoder_; 849 std::unique_ptr<AudioEncoderIsac> isac_encoder_;
850 rtc::scoped_ptr<SimulatedClock> fake_clock_; 850 std::unique_ptr<SimulatedClock> fake_clock_;
851 test::AudioLoop audio_loop_; 851 test::AudioLoop audio_loop_;
852 }; 852 };
853 853
854 #if defined(WEBRTC_IOS) 854 #if defined(WEBRTC_IOS)
855 #define MAYBE_DoTest DISABLED_DoTest 855 #define MAYBE_DoTest DISABLED_DoTest
856 #else 856 #else
857 #define MAYBE_DoTest DoTest 857 #define MAYBE_DoTest DoTest
858 #endif 858 #endif
859 #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX) 859 #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)
860 TEST_F(AcmReRegisterIsacMtTestOldApi, MAYBE_DoTest) { 860 TEST_F(AcmReRegisterIsacMtTestOldApi, MAYBE_DoTest) {
(...skipping 29 matching lines...) Expand all
890 int sample_rate_hz; 890 int sample_rate_hz;
891 int num_channels; 891 int num_channels;
892 std::string name; 892 std::string name;
893 }; 893 };
894 894
895 void Run(int output_freq_hz, 895 void Run(int output_freq_hz,
896 const std::string& checksum_ref, 896 const std::string& checksum_ref,
897 const std::vector<ExternalDecoder>& external_decoders) { 897 const std::vector<ExternalDecoder>& external_decoders) {
898 const std::string input_file_name = 898 const std::string input_file_name =
899 webrtc::test::ResourcePath("audio_coding/neteq_universal_new", "rtp"); 899 webrtc::test::ResourcePath("audio_coding/neteq_universal_new", "rtp");
900 rtc::scoped_ptr<test::RtpFileSource> packet_source( 900 std::unique_ptr<test::RtpFileSource> packet_source(
901 test::RtpFileSource::Create(input_file_name)); 901 test::RtpFileSource::Create(input_file_name));
902 #ifdef WEBRTC_ANDROID 902 #ifdef WEBRTC_ANDROID
903 // Filter out iLBC and iSAC-swb since they are not supported on Android. 903 // Filter out iLBC and iSAC-swb since they are not supported on Android.
904 packet_source->FilterOutPayloadType(102); // iLBC. 904 packet_source->FilterOutPayloadType(102); // iLBC.
905 packet_source->FilterOutPayloadType(104); // iSAC-swb. 905 packet_source->FilterOutPayloadType(104); // iSAC-swb.
906 #endif 906 #endif
907 907
908 test::AudioChecksum checksum; 908 test::AudioChecksum checksum;
909 const std::string output_file_name = 909 const std::string output_file_name =
910 webrtc::test::OutputPath() + 910 webrtc::test::OutputPath() +
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
1192 codec_frame_size_rtp_timestamps)); 1192 codec_frame_size_rtp_timestamps));
1193 } 1193 }
1194 1194
1195 void SetUpTestExternalEncoder(AudioEncoder* external_speech_encoder, 1195 void SetUpTestExternalEncoder(AudioEncoder* external_speech_encoder,
1196 int payload_type) { 1196 int payload_type) {
1197 ASSERT_TRUE(SetUpSender()); 1197 ASSERT_TRUE(SetUpSender());
1198 ASSERT_TRUE( 1198 ASSERT_TRUE(
1199 RegisterExternalSendCodec(external_speech_encoder, payload_type)); 1199 RegisterExternalSendCodec(external_speech_encoder, payload_type));
1200 } 1200 }
1201 1201
1202 rtc::scoped_ptr<test::AcmSendTestOldApi> send_test_; 1202 std::unique_ptr<test::AcmSendTestOldApi> send_test_;
1203 rtc::scoped_ptr<test::InputAudioFile> audio_source_; 1203 std::unique_ptr<test::InputAudioFile> audio_source_;
1204 uint32_t frame_size_rtp_timestamps_; 1204 uint32_t frame_size_rtp_timestamps_;
1205 int packet_count_; 1205 int packet_count_;
1206 uint8_t payload_type_; 1206 uint8_t payload_type_;
1207 uint16_t last_sequence_number_; 1207 uint16_t last_sequence_number_;
1208 uint32_t last_timestamp_; 1208 uint32_t last_timestamp_;
1209 rtc::Md5Digest payload_checksum_; 1209 rtc::Md5Digest payload_checksum_;
1210 }; 1210 };
1211 1211
1212 #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX) 1212 #if defined(WEBRTC_CODEC_ISAC) || defined(WEBRTC_CODEC_ISACFX)
1213 TEST_F(AcmSenderBitExactnessOldApi, IsacWb30ms) { 1213 TEST_F(AcmSenderBitExactnessOldApi, IsacWb30ms) {
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
1483 int channels, 1483 int channels,
1484 int payload_type, 1484 int payload_type,
1485 int codec_frame_size_samples, 1485 int codec_frame_size_samples,
1486 int codec_frame_size_rtp_timestamps) { 1486 int codec_frame_size_rtp_timestamps) {
1487 ASSERT_TRUE(SetUpSender()); 1487 ASSERT_TRUE(SetUpSender());
1488 ASSERT_TRUE(RegisterSendCodec(codec_name, codec_sample_rate_hz, channels, 1488 ASSERT_TRUE(RegisterSendCodec(codec_name, codec_sample_rate_hz, channels,
1489 payload_type, codec_frame_size_samples, 1489 payload_type, codec_frame_size_samples,
1490 codec_frame_size_rtp_timestamps)); 1490 codec_frame_size_rtp_timestamps));
1491 } 1491 }
1492 1492
1493 rtc::scoped_ptr<test::AcmSendTestOldApi> send_test_; 1493 std::unique_ptr<test::AcmSendTestOldApi> send_test_;
1494 rtc::scoped_ptr<test::InputAudioFile> audio_source_; 1494 std::unique_ptr<test::InputAudioFile> audio_source_;
1495 }; 1495 };
1496 1496
1497 TEST_F(AcmSetBitRateOldApi, Opus_48khz_20ms_10kbps) { 1497 TEST_F(AcmSetBitRateOldApi, Opus_48khz_20ms_10kbps) {
1498 ASSERT_NO_FATAL_FAILURE(SetUpTest("opus", 48000, 1, 107, 960, 960)); 1498 ASSERT_NO_FATAL_FAILURE(SetUpTest("opus", 48000, 1, 107, 960, 960));
1499 #if defined(WEBRTC_ANDROID) 1499 #if defined(WEBRTC_ANDROID)
1500 Run(10000, 9288); 1500 Run(10000, 9288);
1501 #else 1501 #else
1502 Run(10000, 9024); 1502 Run(10000, 9024);
1503 #endif // WEBRTC_ANDROID 1503 #endif // WEBRTC_ANDROID
1504 1504
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
1777 Run(16000, 8000, 1000); 1777 Run(16000, 8000, 1000);
1778 } 1778 }
1779 1779
1780 TEST_F(AcmSwitchingOutputFrequencyOldApi, Toggle8KhzTo16Khz) { 1780 TEST_F(AcmSwitchingOutputFrequencyOldApi, Toggle8KhzTo16Khz) {
1781 Run(8000, 16000, 1000); 1781 Run(8000, 16000, 1000);
1782 } 1782 }
1783 1783
1784 #endif 1784 #endif
1785 1785
1786 } // namespace webrtc 1786 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698