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 |
(...skipping 1056 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1067 int frame_size_rtp_timestamps) { | 1067 int frame_size_rtp_timestamps) { |
1068 payload_type_ = payload_type; | 1068 payload_type_ = payload_type; |
1069 frame_size_rtp_timestamps_ = frame_size_rtp_timestamps; | 1069 frame_size_rtp_timestamps_ = frame_size_rtp_timestamps; |
1070 return send_test_->RegisterCodec(payload_name, | 1070 return send_test_->RegisterCodec(payload_name, |
1071 sampling_freq_hz, | 1071 sampling_freq_hz, |
1072 channels, | 1072 channels, |
1073 payload_type, | 1073 payload_type, |
1074 frame_size_samples); | 1074 frame_size_samples); |
1075 } | 1075 } |
1076 | 1076 |
1077 bool RegisterExternalSendCodec(AudioEncoderMutable* external_speech_encoder, | 1077 bool RegisterExternalSendCodec(AudioEncoder* external_speech_encoder, |
1078 int payload_type) { | 1078 int payload_type) { |
1079 payload_type_ = payload_type; | 1079 payload_type_ = payload_type; |
1080 frame_size_rtp_timestamps_ = | 1080 frame_size_rtp_timestamps_ = |
1081 external_speech_encoder->Num10MsFramesInNextPacket() * | 1081 external_speech_encoder->Num10MsFramesInNextPacket() * |
1082 external_speech_encoder->RtpTimestampRateHz() / 100; | 1082 external_speech_encoder->RtpTimestampRateHz() / 100; |
1083 return send_test_->RegisterExternalCodec(external_speech_encoder); | 1083 return send_test_->RegisterExternalCodec(external_speech_encoder); |
1084 } | 1084 } |
1085 | 1085 |
1086 // Runs the test. SetUpSender() and RegisterSendCodec() must have been called | 1086 // Runs the test. SetUpSender() and RegisterSendCodec() must have been called |
1087 // before calling this method. | 1087 // before calling this method. |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1169 int codec_frame_size_rtp_timestamps) { | 1169 int codec_frame_size_rtp_timestamps) { |
1170 ASSERT_TRUE(SetUpSender()); | 1170 ASSERT_TRUE(SetUpSender()); |
1171 ASSERT_TRUE(RegisterSendCodec(codec_name, | 1171 ASSERT_TRUE(RegisterSendCodec(codec_name, |
1172 codec_sample_rate_hz, | 1172 codec_sample_rate_hz, |
1173 channels, | 1173 channels, |
1174 payload_type, | 1174 payload_type, |
1175 codec_frame_size_samples, | 1175 codec_frame_size_samples, |
1176 codec_frame_size_rtp_timestamps)); | 1176 codec_frame_size_rtp_timestamps)); |
1177 } | 1177 } |
1178 | 1178 |
1179 void SetUpTestExternalEncoder(AudioEncoderMutable* external_speech_encoder, | 1179 void SetUpTestExternalEncoder(AudioEncoder* external_speech_encoder, |
1180 int payload_type) { | 1180 int payload_type) { |
1181 ASSERT_TRUE(SetUpSender()); | 1181 ASSERT_TRUE(SetUpSender()); |
1182 ASSERT_TRUE( | 1182 ASSERT_TRUE( |
1183 RegisterExternalSendCodec(external_speech_encoder, payload_type)); | 1183 RegisterExternalSendCodec(external_speech_encoder, payload_type)); |
1184 } | 1184 } |
1185 | 1185 |
1186 rtc::scoped_ptr<test::AcmSendTestOldApi> send_test_; | 1186 rtc::scoped_ptr<test::AcmSendTestOldApi> send_test_; |
1187 rtc::scoped_ptr<test::InputAudioFile> audio_source_; | 1187 rtc::scoped_ptr<test::InputAudioFile> audio_source_; |
1188 uint32_t frame_size_rtp_timestamps_; | 1188 uint32_t frame_size_rtp_timestamps_; |
1189 int packet_count_; | 1189 int packet_count_; |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1594 TEST_F(AcmChangeBitRateOldApi, Pcm16_8khz_10ms_32kbps) { | 1594 TEST_F(AcmChangeBitRateOldApi, Pcm16_8khz_10ms_32kbps) { |
1595 ASSERT_NO_FATAL_FAILURE(SetUpTest("L16", 8000, 1, 107, 80, 80)); | 1595 ASSERT_NO_FATAL_FAILURE(SetUpTest("L16", 8000, 1, 107, 80, 80)); |
1596 Run(32000, 64000, 64000); | 1596 Run(32000, 64000, 64000); |
1597 } | 1597 } |
1598 | 1598 |
1599 TEST_F(AcmSenderBitExactnessOldApi, External_Pcmu_20ms) { | 1599 TEST_F(AcmSenderBitExactnessOldApi, External_Pcmu_20ms) { |
1600 CodecInst codec_inst; | 1600 CodecInst codec_inst; |
1601 codec_inst.channels = 1; | 1601 codec_inst.channels = 1; |
1602 codec_inst.pacsize = 160; | 1602 codec_inst.pacsize = 160; |
1603 codec_inst.pltype = 0; | 1603 codec_inst.pltype = 0; |
1604 AudioEncoderMutablePcmU encoder(codec_inst); | 1604 AudioEncoderPcmU encoder(codec_inst); |
1605 MockAudioEncoderMutable mock_encoder; | 1605 MockAudioEncoder mock_encoder; |
1606 // Set expectations on the mock encoder and also delegate the calls to the | 1606 // Set expectations on the mock encoder and also delegate the calls to the |
1607 // real encoder. | 1607 // real encoder. |
| 1608 EXPECT_CALL(mock_encoder, MaxEncodedBytes()) |
| 1609 .Times(AtLeast(1)) |
| 1610 .WillRepeatedly(Invoke(&encoder, &AudioEncoderPcmU::MaxEncodedBytes)); |
| 1611 EXPECT_CALL(mock_encoder, SampleRateHz()) |
| 1612 .Times(AtLeast(1)) |
| 1613 .WillRepeatedly(Invoke(&encoder, &AudioEncoderPcmU::SampleRateHz)); |
| 1614 EXPECT_CALL(mock_encoder, NumChannels()) |
| 1615 .Times(AtLeast(1)) |
| 1616 .WillRepeatedly(Invoke(&encoder, &AudioEncoderPcmU::NumChannels)); |
| 1617 EXPECT_CALL(mock_encoder, RtpTimestampRateHz()) |
| 1618 .Times(AtLeast(1)) |
| 1619 .WillRepeatedly(Invoke(&encoder, &AudioEncoderPcmU::RtpTimestampRateHz)); |
1608 EXPECT_CALL(mock_encoder, Num10MsFramesInNextPacket()) | 1620 EXPECT_CALL(mock_encoder, Num10MsFramesInNextPacket()) |
1609 .Times(AtLeast(1)) | 1621 .Times(AtLeast(1)) |
1610 .WillRepeatedly(Invoke( | 1622 .WillRepeatedly( |
1611 &encoder, &AudioEncoderMutablePcmU::Num10MsFramesInNextPacket)); | 1623 Invoke(&encoder, &AudioEncoderPcmU::Num10MsFramesInNextPacket)); |
1612 EXPECT_CALL(mock_encoder, Max10MsFramesInAPacket()) | 1624 EXPECT_CALL(mock_encoder, Max10MsFramesInAPacket()) |
1613 .Times(AtLeast(1)) | 1625 .Times(AtLeast(1)) |
1614 .WillRepeatedly( | 1626 .WillRepeatedly( |
1615 Invoke(&encoder, &AudioEncoderMutablePcmU::Max10MsFramesInAPacket)); | 1627 Invoke(&encoder, &AudioEncoderPcmU::Max10MsFramesInAPacket)); |
1616 EXPECT_CALL(mock_encoder, SampleRateHz()) | 1628 EXPECT_CALL(mock_encoder, GetTargetBitrate()) |
1617 .Times(AtLeast(1)) | 1629 .Times(AtLeast(1)) |
1618 .WillRepeatedly(Invoke(&encoder, &AudioEncoderMutablePcmU::SampleRateHz)); | 1630 .WillRepeatedly(Invoke(&encoder, &AudioEncoderPcmU::GetTargetBitrate)); |
1619 EXPECT_CALL(mock_encoder, NumChannels()) | |
1620 .Times(AtLeast(1)) | |
1621 .WillRepeatedly(Invoke(&encoder, &AudioEncoderMutablePcmU::NumChannels)); | |
1622 EXPECT_CALL(mock_encoder, MaxEncodedBytes()) | |
1623 .Times(AtLeast(1)) | |
1624 .WillRepeatedly( | |
1625 Invoke(&encoder, &AudioEncoderMutablePcmU::MaxEncodedBytes)); | |
1626 EXPECT_CALL(mock_encoder, EncodeInternal(_, _, _, _)) | 1631 EXPECT_CALL(mock_encoder, EncodeInternal(_, _, _, _)) |
1627 .Times(AtLeast(1)) | 1632 .Times(AtLeast(1)) |
1628 .WillRepeatedly( | 1633 .WillRepeatedly(Invoke(&encoder, &AudioEncoderPcmU::EncodeInternal)); |
1629 Invoke(&encoder, &AudioEncoderMutablePcmU::EncodeInternal)); | |
1630 EXPECT_CALL(mock_encoder, GetTargetBitrate()) | |
1631 .Times(AtLeast(1)) | |
1632 .WillRepeatedly(Invoke( | |
1633 &encoder, &AudioEncoderMutablePcmU::GetTargetBitrate)); | |
1634 ASSERT_NO_FATAL_FAILURE( | 1634 ASSERT_NO_FATAL_FAILURE( |
1635 SetUpTestExternalEncoder(&mock_encoder, codec_inst.pltype)); | 1635 SetUpTestExternalEncoder(&mock_encoder, codec_inst.pltype)); |
1636 Run("81a9d4c0bb72e9becc43aef124c981e9", "8f9b8750bd80fe26b6cbf6659b89f0f9", | 1636 Run("81a9d4c0bb72e9becc43aef124c981e9", "8f9b8750bd80fe26b6cbf6659b89f0f9", |
1637 50, test::AcmReceiveTestOldApi::kMonoOutput); | 1637 50, test::AcmReceiveTestOldApi::kMonoOutput); |
1638 } | 1638 } |
1639 | 1639 |
1640 // This test fixture is implemented to run ACM and change the desired output | 1640 // This test fixture is implemented to run ACM and change the desired output |
1641 // frequency during the call. The input packets are simply PCM16b-wb encoded | 1641 // frequency during the call. The input packets are simply PCM16b-wb encoded |
1642 // payloads with a constant value of |kSampleValue|. The test fixture itself | 1642 // payloads with a constant value of |kSampleValue|. The test fixture itself |
1643 // acts as PacketSource in between the receive test class and the constant- | 1643 // acts as PacketSource in between the receive test class and the constant- |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1747 Run(16000, 8000, 1000); | 1747 Run(16000, 8000, 1000); |
1748 } | 1748 } |
1749 | 1749 |
1750 TEST_F(AcmSwitchingOutputFrequencyOldApi, Toggle8KhzTo16Khz) { | 1750 TEST_F(AcmSwitchingOutputFrequencyOldApi, Toggle8KhzTo16Khz) { |
1751 Run(8000, 16000, 1000); | 1751 Run(8000, 16000, 1000); |
1752 } | 1752 } |
1753 | 1753 |
1754 #endif | 1754 #endif |
1755 | 1755 |
1756 } // namespace webrtc | 1756 } // namespace webrtc |
OLD | NEW |