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 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 rtp_header.header.ssrc = 0x87654321; | 424 rtp_header.header.ssrc = 0x87654321; |
425 | 425 |
426 // This is a dummy decoder that produces as many output samples as the input | 426 // This is a dummy decoder that produces as many output samples as the input |
427 // has bytes. The output is an increasing series, starting at 1 for the first | 427 // has bytes. The output is an increasing series, starting at 1 for the first |
428 // sample, and then increasing by 1 for each sample. | 428 // sample, and then increasing by 1 for each sample. |
429 class CountingSamplesDecoder : public AudioDecoder { | 429 class CountingSamplesDecoder : public AudioDecoder { |
430 public: | 430 public: |
431 CountingSamplesDecoder() : next_value_(1) {} | 431 CountingSamplesDecoder() : next_value_(1) {} |
432 | 432 |
433 // Produce as many samples as input bytes (|encoded_len|). | 433 // Produce as many samples as input bytes (|encoded_len|). |
434 int Decode(const uint8_t* encoded, | 434 int DecodeInternal(const uint8_t* encoded, |
435 size_t encoded_len, | 435 size_t encoded_len, |
436 int /* sample_rate_hz */, | 436 int /* sample_rate_hz */, |
437 size_t /* max_decoded_bytes */, | 437 int16_t* decoded, |
438 int16_t* decoded, | 438 SpeechType* speech_type) override { |
439 SpeechType* speech_type) override { | |
440 for (size_t i = 0; i < encoded_len; ++i) { | 439 for (size_t i = 0; i < encoded_len; ++i) { |
441 decoded[i] = next_value_++; | 440 decoded[i] = next_value_++; |
442 } | 441 } |
443 *speech_type = kSpeech; | 442 *speech_type = kSpeech; |
444 return encoded_len; | 443 return encoded_len; |
445 } | 444 } |
446 | 445 |
447 void Reset() override { next_value_ = 1; } | 446 void Reset() override { next_value_ = 1; } |
448 | 447 |
449 size_t Channels() const override { return 1; } | 448 size_t Channels() const override { return 1; } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
520 | 519 |
521 // Create a mock decoder object. | 520 // Create a mock decoder object. |
522 MockAudioDecoder mock_decoder; | 521 MockAudioDecoder mock_decoder; |
523 EXPECT_CALL(mock_decoder, Reset()).WillRepeatedly(Return()); | 522 EXPECT_CALL(mock_decoder, Reset()).WillRepeatedly(Return()); |
524 EXPECT_CALL(mock_decoder, Channels()).WillRepeatedly(Return(1)); | 523 EXPECT_CALL(mock_decoder, Channels()).WillRepeatedly(Return(1)); |
525 EXPECT_CALL(mock_decoder, IncomingPacket(_, kPayloadLengthBytes, _, _, _)) | 524 EXPECT_CALL(mock_decoder, IncomingPacket(_, kPayloadLengthBytes, _, _, _)) |
526 .WillRepeatedly(Return(0)); | 525 .WillRepeatedly(Return(0)); |
527 int16_t dummy_output[kPayloadLengthSamples] = {0}; | 526 int16_t dummy_output[kPayloadLengthSamples] = {0}; |
528 // The below expectation will make the mock decoder write | 527 // The below expectation will make the mock decoder write |
529 // |kPayloadLengthSamples| zeros to the output array, and mark it as speech. | 528 // |kPayloadLengthSamples| zeros to the output array, and mark it as speech. |
530 EXPECT_CALL(mock_decoder, | 529 EXPECT_CALL(mock_decoder, DecodeInternal(Pointee(0), kPayloadLengthBytes, |
531 Decode(Pointee(0), kPayloadLengthBytes, kSampleRateHz, _, _, _)) | 530 kSampleRateHz, _, _)) |
532 .WillOnce(DoAll(SetArrayArgument<4>(dummy_output, | 531 .WillOnce(DoAll(SetArrayArgument<3>(dummy_output, |
533 dummy_output + kPayloadLengthSamples), | 532 dummy_output + kPayloadLengthSamples), |
534 SetArgPointee<5>(AudioDecoder::kSpeech), | 533 SetArgPointee<4>(AudioDecoder::kSpeech), |
535 Return(kPayloadLengthSamples))); | 534 Return(kPayloadLengthSamples))); |
536 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( | 535 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
537 &mock_decoder, NetEqDecoder::kDecoderPCM16B, | 536 &mock_decoder, NetEqDecoder::kDecoderPCM16B, |
538 kPayloadType, kSampleRateHz)); | 537 kPayloadType, kSampleRateHz)); |
539 | 538 |
540 // Insert one packet. | 539 // Insert one packet. |
541 EXPECT_EQ(NetEq::kOK, | 540 EXPECT_EQ(NetEq::kOK, |
542 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 541 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
543 | 542 |
544 // Pull audio once. | 543 // Pull audio once. |
(...skipping 18 matching lines...) Expand all Loading... |
563 EXPECT_EQ(NetEq::kOK, | 562 EXPECT_EQ(NetEq::kOK, |
564 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 563 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
565 rtp_header.header.sequenceNumber += 2; | 564 rtp_header.header.sequenceNumber += 2; |
566 rtp_header.header.timestamp += 2 * kPayloadLengthSamples; | 565 rtp_header.header.timestamp += 2 * kPayloadLengthSamples; |
567 payload[0] = 2; | 566 payload[0] = 2; |
568 EXPECT_EQ(NetEq::kOK, | 567 EXPECT_EQ(NetEq::kOK, |
569 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 568 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
570 | 569 |
571 // Expect only the second packet to be decoded (the one with "2" as the first | 570 // Expect only the second packet to be decoded (the one with "2" as the first |
572 // payload byte). | 571 // payload byte). |
573 EXPECT_CALL(mock_decoder, | 572 EXPECT_CALL(mock_decoder, DecodeInternal(Pointee(2), kPayloadLengthBytes, |
574 Decode(Pointee(2), kPayloadLengthBytes, kSampleRateHz, _, _, _)) | 573 kSampleRateHz, _, _)) |
575 .WillOnce(DoAll(SetArrayArgument<4>(dummy_output, | 574 .WillOnce(DoAll(SetArrayArgument<3>(dummy_output, |
576 dummy_output + kPayloadLengthSamples), | 575 dummy_output + kPayloadLengthSamples), |
577 SetArgPointee<5>(AudioDecoder::kSpeech), | 576 SetArgPointee<4>(AudioDecoder::kSpeech), |
578 Return(kPayloadLengthSamples))); | 577 Return(kPayloadLengthSamples))); |
579 | 578 |
580 // Pull audio once. | 579 // Pull audio once. |
581 EXPECT_EQ( | 580 EXPECT_EQ( |
582 NetEq::kOK, | 581 NetEq::kOK, |
583 neteq_->GetAudio( | 582 neteq_->GetAudio( |
584 kMaxOutputSize, output, &samples_per_channel, &num_channels, &type)); | 583 kMaxOutputSize, output, &samples_per_channel, &num_channels, &type)); |
585 ASSERT_EQ(kMaxOutputSize, samples_per_channel); | 584 ASSERT_EQ(kMaxOutputSize, samples_per_channel); |
586 EXPECT_EQ(1, num_channels); | 585 EXPECT_EQ(1, num_channels); |
587 EXPECT_EQ(kOutputNormal, type); | 586 EXPECT_EQ(kOutputNormal, type); |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 | 680 |
682 // Create a mock decoder object. | 681 // Create a mock decoder object. |
683 MockAudioDecoder mock_decoder; | 682 MockAudioDecoder mock_decoder; |
684 EXPECT_CALL(mock_decoder, Reset()).WillRepeatedly(Return()); | 683 EXPECT_CALL(mock_decoder, Reset()).WillRepeatedly(Return()); |
685 EXPECT_CALL(mock_decoder, Channels()).WillRepeatedly(Return(1)); | 684 EXPECT_CALL(mock_decoder, Channels()).WillRepeatedly(Return(1)); |
686 EXPECT_CALL(mock_decoder, IncomingPacket(_, kPayloadLengthBytes, _, _, _)) | 685 EXPECT_CALL(mock_decoder, IncomingPacket(_, kPayloadLengthBytes, _, _, _)) |
687 .WillRepeatedly(Return(0)); | 686 .WillRepeatedly(Return(0)); |
688 | 687 |
689 // Pointee(x) verifies that first byte of the payload equals x, this makes it | 688 // Pointee(x) verifies that first byte of the payload equals x, this makes it |
690 // possible to verify that the correct payload is fed to Decode(). | 689 // possible to verify that the correct payload is fed to Decode(). |
691 EXPECT_CALL(mock_decoder, Decode(Pointee(0), kPayloadLengthBytes, | 690 EXPECT_CALL(mock_decoder, DecodeInternal(Pointee(0), kPayloadLengthBytes, |
692 kSampleRateKhz * 1000, _, _, _)) | 691 kSampleRateKhz * 1000, _, _)) |
693 .WillOnce(DoAll(SetArrayArgument<4>(dummy_output, | 692 .WillOnce(DoAll(SetArrayArgument<3>(dummy_output, |
694 dummy_output + kPayloadLengthSamples), | 693 dummy_output + kPayloadLengthSamples), |
695 SetArgPointee<5>(AudioDecoder::kSpeech), | 694 SetArgPointee<4>(AudioDecoder::kSpeech), |
696 Return(kPayloadLengthSamples))); | 695 Return(kPayloadLengthSamples))); |
697 | 696 |
698 EXPECT_CALL(mock_decoder, Decode(Pointee(1), kPayloadLengthBytes, | 697 EXPECT_CALL(mock_decoder, DecodeInternal(Pointee(1), kPayloadLengthBytes, |
699 kSampleRateKhz * 1000, _, _, _)) | 698 kSampleRateKhz * 1000, _, _)) |
700 .WillOnce(DoAll(SetArrayArgument<4>(dummy_output, | 699 .WillOnce(DoAll(SetArrayArgument<3>(dummy_output, |
701 dummy_output + kPayloadLengthSamples), | 700 dummy_output + kPayloadLengthSamples), |
702 SetArgPointee<5>(AudioDecoder::kComfortNoise), | 701 SetArgPointee<4>(AudioDecoder::kComfortNoise), |
703 Return(kPayloadLengthSamples))); | 702 Return(kPayloadLengthSamples))); |
704 | 703 |
705 EXPECT_CALL(mock_decoder, Decode(IsNull(), 0, kSampleRateKhz * 1000, _, _, _)) | 704 EXPECT_CALL(mock_decoder, |
706 .WillOnce(DoAll(SetArrayArgument<4>(dummy_output, | 705 DecodeInternal(IsNull(), 0, kSampleRateKhz * 1000, _, _)) |
| 706 .WillOnce(DoAll(SetArrayArgument<3>(dummy_output, |
707 dummy_output + kPayloadLengthSamples), | 707 dummy_output + kPayloadLengthSamples), |
708 SetArgPointee<5>(AudioDecoder::kComfortNoise), | 708 SetArgPointee<4>(AudioDecoder::kComfortNoise), |
709 Return(kPayloadLengthSamples))); | 709 Return(kPayloadLengthSamples))); |
710 | 710 |
711 EXPECT_CALL(mock_decoder, Decode(Pointee(2), kPayloadLengthBytes, | 711 EXPECT_CALL(mock_decoder, DecodeInternal(Pointee(2), kPayloadLengthBytes, |
712 kSampleRateKhz * 1000, _, _, _)) | 712 kSampleRateKhz * 1000, _, _)) |
713 .WillOnce(DoAll(SetArrayArgument<4>(dummy_output, | 713 .WillOnce(DoAll(SetArrayArgument<3>(dummy_output, |
714 dummy_output + kPayloadLengthSamples), | 714 dummy_output + kPayloadLengthSamples), |
715 SetArgPointee<5>(AudioDecoder::kSpeech), | 715 SetArgPointee<4>(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 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 |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
953 EXPECT_CALL(mock_decoder, Channels()).WillRepeatedly(Return(1)); | 953 EXPECT_CALL(mock_decoder, Channels()).WillRepeatedly(Return(1)); |
954 EXPECT_CALL(mock_decoder, IncomingPacket(_, kPayloadLengthBytes, _, _, _)) | 954 EXPECT_CALL(mock_decoder, IncomingPacket(_, kPayloadLengthBytes, _, _, _)) |
955 .WillRepeatedly(Return(0)); | 955 .WillRepeatedly(Return(0)); |
956 EXPECT_CALL(mock_decoder, PacketDuration(_, _)) | 956 EXPECT_CALL(mock_decoder, PacketDuration(_, _)) |
957 .WillRepeatedly(Return(kPayloadLengthSamples)); | 957 .WillRepeatedly(Return(kPayloadLengthSamples)); |
958 int16_t dummy_output[kPayloadLengthSamples] = {0}; | 958 int16_t dummy_output[kPayloadLengthSamples] = {0}; |
959 // The below expectation will make the mock decoder write | 959 // The below expectation will make the mock decoder write |
960 // |kPayloadLengthSamples| - 5 zeros to the output array, and mark it as | 960 // |kPayloadLengthSamples| - 5 zeros to the output array, and mark it as |
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 DecodeInternal(_, kPayloadLengthBytes, kSampleRateHz, _, _)) |
964 .WillOnce( | 964 .WillOnce( |
965 DoAll(SetArrayArgument<4>(dummy_output, | 965 DoAll(SetArrayArgument<3>(dummy_output, |
966 dummy_output + kPayloadLengthSamples - 5), | 966 dummy_output + kPayloadLengthSamples - 5), |
967 SetArgPointee<5>(AudioDecoder::kSpeech), | 967 SetArgPointee<4>(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 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()); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1027 EXPECT_CALL(mock_decoder, ErrorCode()) | 1027 EXPECT_CALL(mock_decoder, ErrorCode()) |
1028 .WillOnce(Return(kDecoderErrorCode)); | 1028 .WillOnce(Return(kDecoderErrorCode)); |
1029 EXPECT_CALL(mock_decoder, HasDecodePlc()) | 1029 EXPECT_CALL(mock_decoder, HasDecodePlc()) |
1030 .WillOnce(Return(false)); | 1030 .WillOnce(Return(false)); |
1031 int16_t dummy_output[kFrameLengthSamples] = {0}; | 1031 int16_t dummy_output[kFrameLengthSamples] = {0}; |
1032 | 1032 |
1033 { | 1033 { |
1034 InSequence sequence; // Dummy variable. | 1034 InSequence sequence; // Dummy variable. |
1035 // Mock decoder works normally the first time. | 1035 // Mock decoder works normally the first time. |
1036 EXPECT_CALL(mock_decoder, | 1036 EXPECT_CALL(mock_decoder, |
1037 Decode(_, kPayloadLengthBytes, kSampleRateHz, _, _, _)) | 1037 DecodeInternal(_, kPayloadLengthBytes, kSampleRateHz, _, _)) |
1038 .Times(3) | 1038 .Times(3) |
1039 .WillRepeatedly( | 1039 .WillRepeatedly( |
1040 DoAll(SetArrayArgument<4>(dummy_output, | 1040 DoAll(SetArrayArgument<3>(dummy_output, |
1041 dummy_output + kFrameLengthSamples), | 1041 dummy_output + kFrameLengthSamples), |
1042 SetArgPointee<5>(AudioDecoder::kSpeech), | 1042 SetArgPointee<4>(AudioDecoder::kSpeech), |
1043 Return(kFrameLengthSamples))) | 1043 Return(kFrameLengthSamples))) |
1044 .RetiresOnSaturation(); | 1044 .RetiresOnSaturation(); |
1045 | 1045 |
1046 // Then mock decoder fails. A common reason for failure can be buffer being | 1046 // Then mock decoder fails. A common reason for failure can be buffer being |
1047 // too short | 1047 // too short |
1048 EXPECT_CALL(mock_decoder, | 1048 EXPECT_CALL(mock_decoder, |
1049 Decode(_, kPayloadLengthBytes, kSampleRateHz, _, _, _)) | 1049 DecodeInternal(_, kPayloadLengthBytes, kSampleRateHz, _, _)) |
1050 .WillOnce(Return(-1)) | 1050 .WillOnce(Return(-1)) |
1051 .RetiresOnSaturation(); | 1051 .RetiresOnSaturation(); |
1052 | 1052 |
1053 // Mock decoder finally returns to normal. | 1053 // Mock decoder finally returns to normal. |
1054 EXPECT_CALL(mock_decoder, | 1054 EXPECT_CALL(mock_decoder, |
1055 Decode(_, kPayloadLengthBytes, kSampleRateHz, _, _, _)) | 1055 DecodeInternal(_, kPayloadLengthBytes, kSampleRateHz, _, _)) |
1056 .Times(2) | 1056 .Times(2) |
1057 .WillRepeatedly( | 1057 .WillRepeatedly( |
1058 DoAll(SetArrayArgument<4>(dummy_output, | 1058 DoAll(SetArrayArgument<3>(dummy_output, |
1059 dummy_output + kFrameLengthSamples), | 1059 dummy_output + kFrameLengthSamples), |
1060 SetArgPointee<5>(AudioDecoder::kSpeech), | 1060 SetArgPointee<4>(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 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; |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1150 EXPECT_CALL(mock_decoder, PacketDuration(_, _)) | 1150 EXPECT_CALL(mock_decoder, PacketDuration(_, _)) |
1151 .WillRepeatedly(Return(kFrameLengthSamples)); | 1151 .WillRepeatedly(Return(kFrameLengthSamples)); |
1152 EXPECT_CALL(mock_decoder, ErrorCode()) | 1152 EXPECT_CALL(mock_decoder, ErrorCode()) |
1153 .WillOnce(Return(kDecoderErrorCode)); | 1153 .WillOnce(Return(kDecoderErrorCode)); |
1154 int16_t dummy_output[kFrameLengthSamples] = {0}; | 1154 int16_t dummy_output[kFrameLengthSamples] = {0}; |
1155 | 1155 |
1156 { | 1156 { |
1157 InSequence sequence; // Dummy variable. | 1157 InSequence sequence; // Dummy variable. |
1158 // Mock decoder works normally the first 2 times. | 1158 // Mock decoder works normally the first 2 times. |
1159 EXPECT_CALL(mock_decoder, | 1159 EXPECT_CALL(mock_decoder, |
1160 Decode(_, kPayloadLengthBytes, kSampleRateHz, _, _, _)) | 1160 DecodeInternal(_, kPayloadLengthBytes, kSampleRateHz, _, _)) |
1161 .Times(2) | 1161 .Times(2) |
1162 .WillRepeatedly( | 1162 .WillRepeatedly( |
1163 DoAll(SetArrayArgument<4>(dummy_output, | 1163 DoAll(SetArrayArgument<3>(dummy_output, |
1164 dummy_output + kFrameLengthSamples), | 1164 dummy_output + kFrameLengthSamples), |
1165 SetArgPointee<5>(AudioDecoder::kComfortNoise), | 1165 SetArgPointee<4>(AudioDecoder::kComfortNoise), |
1166 Return(kFrameLengthSamples))) | 1166 Return(kFrameLengthSamples))) |
1167 .RetiresOnSaturation(); | 1167 .RetiresOnSaturation(); |
1168 | 1168 |
1169 // Then mock decoder fails. A common reason for failure can be buffer being | 1169 // Then mock decoder fails. A common reason for failure can be buffer being |
1170 // too short | 1170 // too short |
1171 EXPECT_CALL(mock_decoder, Decode(nullptr, 0, kSampleRateHz, _, _, _)) | 1171 EXPECT_CALL(mock_decoder, DecodeInternal(nullptr, 0, kSampleRateHz, _, _)) |
1172 .WillOnce(Return(-1)) | 1172 .WillOnce(Return(-1)) |
1173 .RetiresOnSaturation(); | 1173 .RetiresOnSaturation(); |
1174 | 1174 |
1175 // Mock decoder finally returns to normal. | 1175 // Mock decoder finally returns to normal. |
1176 EXPECT_CALL(mock_decoder, Decode(nullptr, 0, kSampleRateHz, _, _, _)) | 1176 EXPECT_CALL(mock_decoder, DecodeInternal(nullptr, 0, kSampleRateHz, _, _)) |
1177 .Times(2) | 1177 .Times(2) |
1178 .WillRepeatedly( | 1178 .WillRepeatedly( |
1179 DoAll(SetArrayArgument<4>(dummy_output, | 1179 DoAll(SetArrayArgument<3>(dummy_output, |
1180 dummy_output + kFrameLengthSamples), | 1180 dummy_output + kFrameLengthSamples), |
1181 SetArgPointee<5>(AudioDecoder::kComfortNoise), | 1181 SetArgPointee<4>(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 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; |
(...skipping 41 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 |