OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 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 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
449 size_t Channels() const override { return 1; } | 449 size_t Channels() const override { return 1; } |
450 | 450 |
451 uint16_t next_value() const { return next_value_; } | 451 uint16_t next_value() const { return next_value_; } |
452 | 452 |
453 private: | 453 private: |
454 int16_t next_value_; | 454 int16_t next_value_; |
455 } decoder_; | 455 } decoder_; |
456 | 456 |
457 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( | 457 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
458 &decoder_, NetEqDecoder::kDecoderPCM16B, | 458 &decoder_, NetEqDecoder::kDecoderPCM16B, |
459 kPayloadType, kSampleRateHz)); | 459 "dummy name", kPayloadType, kSampleRateHz)); |
460 | 460 |
461 // Insert one packet. | 461 // Insert one packet. |
462 EXPECT_EQ(NetEq::kOK, | 462 EXPECT_EQ(NetEq::kOK, |
463 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 463 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
464 | 464 |
465 // Pull audio once. | 465 // Pull audio once. |
466 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); | 466 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); |
467 int16_t output[kMaxOutputSize]; | 467 int16_t output[kMaxOutputSize]; |
468 size_t samples_per_channel; | 468 size_t samples_per_channel; |
469 int num_channels; | 469 int num_channels; |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
528 // The below expectation will make the mock decoder write | 528 // The below expectation will make the mock decoder write |
529 // |kPayloadLengthSamples| zeros to the output array, and mark it as speech. | 529 // |kPayloadLengthSamples| zeros to the output array, and mark it as speech. |
530 EXPECT_CALL(mock_decoder, | 530 EXPECT_CALL(mock_decoder, |
531 Decode(Pointee(0), kPayloadLengthBytes, kSampleRateHz, _, _, _)) | 531 Decode(Pointee(0), kPayloadLengthBytes, kSampleRateHz, _, _, _)) |
532 .WillOnce(DoAll(SetArrayArgument<4>(dummy_output, | 532 .WillOnce(DoAll(SetArrayArgument<4>(dummy_output, |
533 dummy_output + kPayloadLengthSamples), | 533 dummy_output + kPayloadLengthSamples), |
534 SetArgPointee<5>(AudioDecoder::kSpeech), | 534 SetArgPointee<5>(AudioDecoder::kSpeech), |
535 Return(kPayloadLengthSamples))); | 535 Return(kPayloadLengthSamples))); |
536 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( | 536 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
537 &mock_decoder, NetEqDecoder::kDecoderPCM16B, | 537 &mock_decoder, NetEqDecoder::kDecoderPCM16B, |
538 kPayloadType, kSampleRateHz)); | 538 "dummy name", kPayloadType, kSampleRateHz)); |
539 | 539 |
540 // Insert one packet. | 540 // Insert one packet. |
541 EXPECT_EQ(NetEq::kOK, | 541 EXPECT_EQ(NetEq::kOK, |
542 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 542 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
543 | 543 |
544 // Pull audio once. | 544 // Pull audio once. |
545 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); | 545 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); |
546 int16_t output[kMaxOutputSize]; | 546 int16_t output[kMaxOutputSize]; |
547 size_t samples_per_channel; | 547 size_t samples_per_channel; |
548 int num_channels; | 548 int num_channels; |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
710 | 710 |
711 EXPECT_CALL(mock_decoder, Decode(Pointee(2), kPayloadLengthBytes, | 711 EXPECT_CALL(mock_decoder, Decode(Pointee(2), kPayloadLengthBytes, |
712 kSampleRateKhz * 1000, _, _, _)) | 712 kSampleRateKhz * 1000, _, _, _)) |
713 .WillOnce(DoAll(SetArrayArgument<4>(dummy_output, | 713 .WillOnce(DoAll(SetArrayArgument<4>(dummy_output, |
714 dummy_output + kPayloadLengthSamples), | 714 dummy_output + kPayloadLengthSamples), |
715 SetArgPointee<5>(AudioDecoder::kSpeech), | 715 SetArgPointee<5>(AudioDecoder::kSpeech), |
716 Return(kPayloadLengthSamples))); | 716 Return(kPayloadLengthSamples))); |
717 | 717 |
718 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( | 718 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
719 &mock_decoder, NetEqDecoder::kDecoderOpus, | 719 &mock_decoder, NetEqDecoder::kDecoderOpus, |
720 kPayloadType, kSampleRateKhz * 1000)); | 720 "dummy name", kPayloadType, kSampleRateKhz * 1000)); |
721 | 721 |
722 // Insert one packet (decoder will return speech). | 722 // Insert one packet (decoder will return speech). |
723 EXPECT_EQ(NetEq::kOK, | 723 EXPECT_EQ(NetEq::kOK, |
724 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 724 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
725 | 725 |
726 // Insert second packet (decoder will return CNG). | 726 // Insert second packet (decoder will return CNG). |
727 payload[0] = 1; | 727 payload[0] = 1; |
728 rtp_header.header.sequenceNumber++; | 728 rtp_header.header.sequenceNumber++; |
729 rtp_header.header.timestamp += kPayloadLengthSamples; | 729 rtp_header.header.timestamp += kPayloadLengthSamples; |
730 EXPECT_EQ(NetEq::kOK, | 730 EXPECT_EQ(NetEq::kOK, |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
847 Return(static_cast<int>( | 847 Return(static_cast<int>( |
848 kPayloadLengthSamples * kChannels)))); | 848 kPayloadLengthSamples * kChannels)))); |
849 | 849 |
850 EXPECT_CALL(decoder_, PacketDuration(Pointee(kSecondPayloadValue), | 850 EXPECT_CALL(decoder_, PacketDuration(Pointee(kSecondPayloadValue), |
851 kPayloadLengthBytes)) | 851 kPayloadLengthBytes)) |
852 .Times(AtLeast(1)) | 852 .Times(AtLeast(1)) |
853 .WillRepeatedly(Return(kNetEqMaxFrameSize)); | 853 .WillRepeatedly(Return(kNetEqMaxFrameSize)); |
854 | 854 |
855 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( | 855 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
856 &decoder_, NetEqDecoder::kDecoderPCM16B, | 856 &decoder_, NetEqDecoder::kDecoderPCM16B, |
857 kPayloadType, kSampleRateHz)); | 857 "dummy name", kPayloadType, kSampleRateHz)); |
858 | 858 |
859 // Insert one packet. | 859 // Insert one packet. |
860 payload[0] = kFirstPayloadValue; // This will make Decode() fail. | 860 payload[0] = kFirstPayloadValue; // This will make Decode() fail. |
861 EXPECT_EQ(NetEq::kOK, | 861 EXPECT_EQ(NetEq::kOK, |
862 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 862 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
863 | 863 |
864 // Insert another packet. | 864 // Insert another packet. |
865 payload[0] = kSecondPayloadValue; // This will make Decode() successful. | 865 payload[0] = kSecondPayloadValue; // This will make Decode() successful. |
866 rtp_header.header.sequenceNumber++; | 866 rtp_header.header.sequenceNumber++; |
867 // The second timestamp needs to be at least 30 ms after the first to make | 867 // The second timestamp needs to be at least 30 ms after the first to make |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
961 // speech. That is, the decoded length is 5 samples shorter than the expected. | 961 // speech. That is, the decoded length is 5 samples shorter than the expected. |
962 EXPECT_CALL(mock_decoder, | 962 EXPECT_CALL(mock_decoder, |
963 Decode(_, kPayloadLengthBytes, kSampleRateHz, _, _, _)) | 963 Decode(_, kPayloadLengthBytes, kSampleRateHz, _, _, _)) |
964 .WillOnce( | 964 .WillOnce( |
965 DoAll(SetArrayArgument<4>(dummy_output, | 965 DoAll(SetArrayArgument<4>(dummy_output, |
966 dummy_output + kPayloadLengthSamples - 5), | 966 dummy_output + kPayloadLengthSamples - 5), |
967 SetArgPointee<5>(AudioDecoder::kSpeech), | 967 SetArgPointee<5>(AudioDecoder::kSpeech), |
968 Return(kPayloadLengthSamples - 5))); | 968 Return(kPayloadLengthSamples - 5))); |
969 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( | 969 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
970 &mock_decoder, NetEqDecoder::kDecoderPCM16B, | 970 &mock_decoder, NetEqDecoder::kDecoderPCM16B, |
971 kPayloadType, kSampleRateHz)); | 971 "dummy name", kPayloadType, kSampleRateHz)); |
972 | 972 |
973 // Insert one packet. | 973 // Insert one packet. |
974 EXPECT_EQ(NetEq::kOK, | 974 EXPECT_EQ(NetEq::kOK, |
975 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 975 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
976 | 976 |
977 EXPECT_EQ(5u, neteq_->sync_buffer_for_test()->FutureLength()); | 977 EXPECT_EQ(5u, neteq_->sync_buffer_for_test()->FutureLength()); |
978 | 978 |
979 // Pull audio once. | 979 // Pull audio once. |
980 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); | 980 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); |
981 int16_t output[kMaxOutputSize]; | 981 int16_t output[kMaxOutputSize]; |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1056 .Times(2) | 1056 .Times(2) |
1057 .WillRepeatedly( | 1057 .WillRepeatedly( |
1058 DoAll(SetArrayArgument<4>(dummy_output, | 1058 DoAll(SetArrayArgument<4>(dummy_output, |
1059 dummy_output + kFrameLengthSamples), | 1059 dummy_output + kFrameLengthSamples), |
1060 SetArgPointee<5>(AudioDecoder::kSpeech), | 1060 SetArgPointee<5>(AudioDecoder::kSpeech), |
1061 Return(kFrameLengthSamples))); | 1061 Return(kFrameLengthSamples))); |
1062 } | 1062 } |
1063 | 1063 |
1064 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( | 1064 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
1065 &mock_decoder, NetEqDecoder::kDecoderPCM16B, | 1065 &mock_decoder, NetEqDecoder::kDecoderPCM16B, |
1066 kPayloadType, kSampleRateHz)); | 1066 "dummy name", kPayloadType, kSampleRateHz)); |
1067 | 1067 |
1068 // Insert packets. | 1068 // Insert packets. |
1069 for (int i = 0; i < 6; ++i) { | 1069 for (int i = 0; i < 6; ++i) { |
1070 rtp_header.header.sequenceNumber += 1; | 1070 rtp_header.header.sequenceNumber += 1; |
1071 rtp_header.header.timestamp += kFrameLengthSamples; | 1071 rtp_header.header.timestamp += kFrameLengthSamples; |
1072 EXPECT_EQ(NetEq::kOK, | 1072 EXPECT_EQ(NetEq::kOK, |
1073 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 1073 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
1074 } | 1074 } |
1075 | 1075 |
1076 // Pull audio. | 1076 // Pull audio. |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1177 .Times(2) | 1177 .Times(2) |
1178 .WillRepeatedly( | 1178 .WillRepeatedly( |
1179 DoAll(SetArrayArgument<4>(dummy_output, | 1179 DoAll(SetArrayArgument<4>(dummy_output, |
1180 dummy_output + kFrameLengthSamples), | 1180 dummy_output + kFrameLengthSamples), |
1181 SetArgPointee<5>(AudioDecoder::kComfortNoise), | 1181 SetArgPointee<5>(AudioDecoder::kComfortNoise), |
1182 Return(kFrameLengthSamples))); | 1182 Return(kFrameLengthSamples))); |
1183 } | 1183 } |
1184 | 1184 |
1185 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( | 1185 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
1186 &mock_decoder, NetEqDecoder::kDecoderPCM16B, | 1186 &mock_decoder, NetEqDecoder::kDecoderPCM16B, |
1187 kPayloadType, kSampleRateHz)); | 1187 "dummy name", kPayloadType, kSampleRateHz)); |
1188 | 1188 |
1189 // Insert 2 packets. This will make netEq into codec internal CNG mode. | 1189 // Insert 2 packets. This will make netEq into codec internal CNG mode. |
1190 for (int i = 0; i < 2; ++i) { | 1190 for (int i = 0; i < 2; ++i) { |
1191 rtp_header.header.sequenceNumber += 1; | 1191 rtp_header.header.sequenceNumber += 1; |
1192 rtp_header.header.timestamp += kFrameLengthSamples; | 1192 rtp_header.header.timestamp += kFrameLengthSamples; |
1193 EXPECT_EQ(NetEq::kOK, | 1193 EXPECT_EQ(NetEq::kOK, |
1194 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 1194 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
1195 } | 1195 } |
1196 | 1196 |
1197 // Pull audio. | 1197 // Pull audio. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1233 // Tests that the return value from last_output_sample_rate_hz() is equal to the | 1233 // Tests that the return value from last_output_sample_rate_hz() is equal to the |
1234 // configured inital sample rate. | 1234 // configured inital sample rate. |
1235 TEST_F(NetEqImplTest, InitialLastOutputSampleRate) { | 1235 TEST_F(NetEqImplTest, InitialLastOutputSampleRate) { |
1236 UseNoMocks(); | 1236 UseNoMocks(); |
1237 config_.sample_rate_hz = 48000; | 1237 config_.sample_rate_hz = 48000; |
1238 CreateInstance(); | 1238 CreateInstance(); |
1239 EXPECT_EQ(48000, neteq_->last_output_sample_rate_hz()); | 1239 EXPECT_EQ(48000, neteq_->last_output_sample_rate_hz()); |
1240 } | 1240 } |
1241 | 1241 |
1242 }// namespace webrtc | 1242 }// namespace webrtc |
OLD | NEW |