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

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

Issue 1725143003: Changed AudioEncoder::Encode to take an rtc::Buffer* instead of uint8_t* and a maximum size. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Reverted unnecessary change to buffer_unittest.cc 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
(...skipping 756 matching lines...) Expand 10 before | Expand all | Expand 10 after
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) {
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 rtc::Buffer encoded;
778 std::unique_ptr<uint8_t[]> encoded(new uint8_t[max_encoded_bytes]);
779 AudioEncoder::EncodedInfo info; 778 AudioEncoder::EncodedInfo info;
780 { 779 {
781 rtc::CritScope lock(&crit_sect_); 780 rtc::CritScope lock(&crit_sect_);
782 if (clock_->TimeInMilliseconds() < next_insert_packet_time_ms_) { 781 if (clock_->TimeInMilliseconds() < next_insert_packet_time_ms_) {
783 return true; 782 return true;
784 } 783 }
785 next_insert_packet_time_ms_ += kPacketSizeMs; 784 next_insert_packet_time_ms_ += kPacketSizeMs;
786 ++receive_packet_count_; 785 ++receive_packet_count_;
787 786
788 // Encode new frame. 787 // Encode new frame.
789 uint32_t input_timestamp = rtp_header_.header.timestamp; 788 uint32_t input_timestamp = rtp_header_.header.timestamp;
790 while (info.encoded_bytes == 0) { 789 while (info.encoded_bytes == 0) {
791 info = 790 info =
792 isac_encoder_->Encode(input_timestamp, audio_loop_.GetNextBlock(), 791 isac_encoder_->Encode(input_timestamp, audio_loop_.GetNextBlock(),
793 max_encoded_bytes, encoded.get()); 792 &encoded);
794 input_timestamp += 160; // 10 ms at 16 kHz. 793 input_timestamp += 160; // 10 ms at 16 kHz.
795 } 794 }
796 EXPECT_EQ(rtp_header_.header.timestamp + kPacketSizeSamples, 795 EXPECT_EQ(rtp_header_.header.timestamp + kPacketSizeSamples,
797 input_timestamp); 796 input_timestamp);
798 EXPECT_EQ(rtp_header_.header.timestamp, info.encoded_timestamp); 797 EXPECT_EQ(rtp_header_.header.timestamp, info.encoded_timestamp);
799 EXPECT_EQ(rtp_header_.header.payloadType, info.payload_type); 798 EXPECT_EQ(rtp_header_.header.payloadType, info.payload_type);
800 } 799 }
801 // Now we're not holding the crit sect when calling ACM. 800 // Now we're not holding the crit sect when calling ACM.
802 801
803 // Insert into ACM. 802 // Insert into ACM.
804 EXPECT_EQ(0, acm_->IncomingPacket(encoded.get(), info.encoded_bytes, 803 EXPECT_EQ(0, acm_->IncomingPacket(encoded.data(), info.encoded_bytes,
805 rtp_header_)); 804 rtp_header_));
806 805
807 // Pull audio. 806 // Pull audio.
808 for (int i = 0; i < rtc::CheckedDivExact(kPacketSizeMs, 10); ++i) { 807 for (int i = 0; i < rtc::CheckedDivExact(kPacketSizeMs, 10); ++i) {
809 AudioFrame audio_frame; 808 AudioFrame audio_frame;
810 EXPECT_EQ(0, acm_->PlayoutData10Ms(-1 /* default output frequency */, 809 EXPECT_EQ(0, acm_->PlayoutData10Ms(-1 /* default output frequency */,
811 &audio_frame)); 810 &audio_frame));
812 fake_clock_->AdvanceTimeMilliseconds(10); 811 fake_clock_->AdvanceTimeMilliseconds(10);
813 } 812 }
814 rtp_utility_->Forward(&rtp_header_); 813 rtp_utility_->Forward(&rtp_header_);
(...skipping 812 matching lines...) Expand 10 before | Expand all | Expand 10 after
1627 TEST_F(AcmSenderBitExactnessOldApi, External_Pcmu_20ms) { 1626 TEST_F(AcmSenderBitExactnessOldApi, External_Pcmu_20ms) {
1628 CodecInst codec_inst; 1627 CodecInst codec_inst;
1629 codec_inst.channels = 1; 1628 codec_inst.channels = 1;
1630 codec_inst.pacsize = 160; 1629 codec_inst.pacsize = 160;
1631 codec_inst.pltype = 0; 1630 codec_inst.pltype = 0;
1632 AudioEncoderPcmU encoder(codec_inst); 1631 AudioEncoderPcmU encoder(codec_inst);
1633 MockAudioEncoder mock_encoder; 1632 MockAudioEncoder mock_encoder;
1634 // Set expectations on the mock encoder and also delegate the calls to the 1633 // Set expectations on the mock encoder and also delegate the calls to the
1635 // real encoder. 1634 // real encoder.
1636 EXPECT_CALL(mock_encoder, MaxEncodedBytes()) 1635 EXPECT_CALL(mock_encoder, MaxEncodedBytes())
1637 .Times(AtLeast(1))
1638 .WillRepeatedly(Invoke(&encoder, &AudioEncoderPcmU::MaxEncodedBytes)); 1636 .WillRepeatedly(Invoke(&encoder, &AudioEncoderPcmU::MaxEncodedBytes));
kwiberg-webrtc 2016/02/25 00:29:04 Do you still need this one?
ossu 2016/02/25 10:39:51 Hmm... Come to think of it, probably not. I'll try
1639 EXPECT_CALL(mock_encoder, SampleRateHz()) 1637 EXPECT_CALL(mock_encoder, SampleRateHz())
1640 .Times(AtLeast(1)) 1638 .Times(AtLeast(1))
1641 .WillRepeatedly(Invoke(&encoder, &AudioEncoderPcmU::SampleRateHz)); 1639 .WillRepeatedly(Invoke(&encoder, &AudioEncoderPcmU::SampleRateHz));
1642 EXPECT_CALL(mock_encoder, NumChannels()) 1640 EXPECT_CALL(mock_encoder, NumChannels())
1643 .Times(AtLeast(1)) 1641 .Times(AtLeast(1))
1644 .WillRepeatedly(Invoke(&encoder, &AudioEncoderPcmU::NumChannels)); 1642 .WillRepeatedly(Invoke(&encoder, &AudioEncoderPcmU::NumChannels));
1645 EXPECT_CALL(mock_encoder, RtpTimestampRateHz()) 1643 EXPECT_CALL(mock_encoder, RtpTimestampRateHz())
1646 .Times(AtLeast(1)) 1644 .Times(AtLeast(1))
1647 .WillRepeatedly(Invoke(&encoder, &AudioEncoderPcmU::RtpTimestampRateHz)); 1645 .WillRepeatedly(Invoke(&encoder, &AudioEncoderPcmU::RtpTimestampRateHz));
1648 EXPECT_CALL(mock_encoder, Num10MsFramesInNextPacket()) 1646 EXPECT_CALL(mock_encoder, Num10MsFramesInNextPacket())
1649 .Times(AtLeast(1)) 1647 .Times(AtLeast(1))
1650 .WillRepeatedly( 1648 .WillRepeatedly(
1651 Invoke(&encoder, &AudioEncoderPcmU::Num10MsFramesInNextPacket)); 1649 Invoke(&encoder, &AudioEncoderPcmU::Num10MsFramesInNextPacket));
1652 EXPECT_CALL(mock_encoder, GetTargetBitrate()) 1650 EXPECT_CALL(mock_encoder, GetTargetBitrate())
1653 .Times(AtLeast(1)) 1651 .Times(AtLeast(1))
1654 .WillRepeatedly(Invoke(&encoder, &AudioEncoderPcmU::GetTargetBitrate)); 1652 .WillRepeatedly(Invoke(&encoder, &AudioEncoderPcmU::GetTargetBitrate));
1655 EXPECT_CALL(mock_encoder, EncodeInternal(_, _, _, _)) 1653 EXPECT_CALL(mock_encoder, EncodeInternal(_, _, _))
1656 .Times(AtLeast(1)) 1654 .Times(AtLeast(1))
1657 .WillRepeatedly(Invoke(&encoder, &AudioEncoderPcmU::EncodeInternal)); 1655 .WillRepeatedly(Invoke(&encoder,
1656 static_cast<
1657 AudioEncoder::EncodedInfo(AudioEncoder::*)(
1658 uint32_t,
1659 rtc::ArrayView<const int16_t>,
1660 rtc::Buffer*)>(&AudioEncoderPcmU::Encode)));
1658 EXPECT_CALL(mock_encoder, SetFec(_)) 1661 EXPECT_CALL(mock_encoder, SetFec(_))
1659 .Times(AtLeast(1)) 1662 .Times(AtLeast(1))
1660 .WillRepeatedly(Invoke(&encoder, &AudioEncoderPcmU::SetFec)); 1663 .WillRepeatedly(Invoke(&encoder, &AudioEncoderPcmU::SetFec));
1661 ASSERT_NO_FATAL_FAILURE( 1664 ASSERT_NO_FATAL_FAILURE(
1662 SetUpTestExternalEncoder(&mock_encoder, codec_inst.pltype)); 1665 SetUpTestExternalEncoder(&mock_encoder, codec_inst.pltype));
1663 Run("81a9d4c0bb72e9becc43aef124c981e9", "8f9b8750bd80fe26b6cbf6659b89f0f9", 1666 Run("81a9d4c0bb72e9becc43aef124c981e9", "8f9b8750bd80fe26b6cbf6659b89f0f9",
1664 50, test::AcmReceiveTestOldApi::kMonoOutput); 1667 50, test::AcmReceiveTestOldApi::kMonoOutput);
1665 } 1668 }
1666 1669
1667 // This test fixture is implemented to run ACM and change the desired output 1670 // This test fixture is implemented to run ACM and change the desired output
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
1777 Run(16000, 8000, 1000); 1780 Run(16000, 8000, 1000);
1778 } 1781 }
1779 1782
1780 TEST_F(AcmSwitchingOutputFrequencyOldApi, Toggle8KhzTo16Khz) { 1783 TEST_F(AcmSwitchingOutputFrequencyOldApi, Toggle8KhzTo16Khz) {
1781 Run(8000, 16000, 1000); 1784 Run(8000, 16000, 1000);
1782 } 1785 }
1783 1786
1784 #endif 1787 #endif
1785 1788
1786 } // namespace webrtc 1789 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698