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 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
439 size_t Channels() const override { return 1; } | 439 size_t Channels() const override { return 1; } |
440 | 440 |
441 uint16_t next_value() const { return next_value_; } | 441 uint16_t next_value() const { return next_value_; } |
442 | 442 |
443 private: | 443 private: |
444 int16_t next_value_; | 444 int16_t next_value_; |
445 } decoder_; | 445 } decoder_; |
446 | 446 |
447 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( | 447 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
448 &decoder_, NetEqDecoder::kDecoderPCM16B, | 448 &decoder_, NetEqDecoder::kDecoderPCM16B, |
449 "dummy name", kPayloadType, kSampleRateHz)); | 449 "dummy name", kPayloadType)); |
450 | 450 |
451 // Insert one packet. | 451 // Insert one packet. |
452 EXPECT_EQ(NetEq::kOK, | 452 EXPECT_EQ(NetEq::kOK, |
453 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 453 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
454 | 454 |
455 // Pull audio once. | 455 // Pull audio once. |
456 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); | 456 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); |
457 AudioFrame output; | 457 AudioFrame output; |
458 bool muted; | 458 bool muted; |
459 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); | 459 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 uint8_t payload[kPayloadLengthBytes] = {0}; | 502 uint8_t payload[kPayloadLengthBytes] = {0}; |
503 WebRtcRTPHeader rtp_header; | 503 WebRtcRTPHeader rtp_header; |
504 rtp_header.header.payloadType = kPayloadType; | 504 rtp_header.header.payloadType = kPayloadType; |
505 rtp_header.header.sequenceNumber = 0x1234; | 505 rtp_header.header.sequenceNumber = 0x1234; |
506 rtp_header.header.timestamp = 0x12345678; | 506 rtp_header.header.timestamp = 0x12345678; |
507 rtp_header.header.ssrc = 0x87654321; | 507 rtp_header.header.ssrc = 0x87654321; |
508 | 508 |
509 // Create a mock decoder object. | 509 // Create a mock decoder object. |
510 MockAudioDecoder mock_decoder; | 510 MockAudioDecoder mock_decoder; |
511 EXPECT_CALL(mock_decoder, Reset()).WillRepeatedly(Return()); | 511 EXPECT_CALL(mock_decoder, Reset()).WillRepeatedly(Return()); |
| 512 EXPECT_CALL(mock_decoder, SampleRateHz()) |
| 513 .WillRepeatedly(Return(kSampleRateHz)); |
512 EXPECT_CALL(mock_decoder, Channels()).WillRepeatedly(Return(1)); | 514 EXPECT_CALL(mock_decoder, Channels()).WillRepeatedly(Return(1)); |
513 EXPECT_CALL(mock_decoder, IncomingPacket(_, kPayloadLengthBytes, _, _, _)) | 515 EXPECT_CALL(mock_decoder, IncomingPacket(_, kPayloadLengthBytes, _, _, _)) |
514 .WillRepeatedly(Return(0)); | 516 .WillRepeatedly(Return(0)); |
515 EXPECT_CALL(mock_decoder, PacketDuration(_, kPayloadLengthBytes)) | 517 EXPECT_CALL(mock_decoder, PacketDuration(_, kPayloadLengthBytes)) |
516 .WillRepeatedly(Return(kPayloadLengthSamples)); | 518 .WillRepeatedly(Return(kPayloadLengthSamples)); |
517 int16_t dummy_output[kPayloadLengthSamples] = {0}; | 519 int16_t dummy_output[kPayloadLengthSamples] = {0}; |
518 // The below expectation will make the mock decoder write | 520 // The below expectation will make the mock decoder write |
519 // |kPayloadLengthSamples| zeros to the output array, and mark it as speech. | 521 // |kPayloadLengthSamples| zeros to the output array, and mark it as speech. |
520 EXPECT_CALL(mock_decoder, DecodeInternal(Pointee(0), kPayloadLengthBytes, | 522 EXPECT_CALL(mock_decoder, DecodeInternal(Pointee(0), kPayloadLengthBytes, |
521 kSampleRateHz, _, _)) | 523 kSampleRateHz, _, _)) |
522 .WillOnce(DoAll(SetArrayArgument<3>(dummy_output, | 524 .WillOnce(DoAll(SetArrayArgument<3>(dummy_output, |
523 dummy_output + kPayloadLengthSamples), | 525 dummy_output + kPayloadLengthSamples), |
524 SetArgPointee<4>(AudioDecoder::kSpeech), | 526 SetArgPointee<4>(AudioDecoder::kSpeech), |
525 Return(kPayloadLengthSamples))); | 527 Return(kPayloadLengthSamples))); |
526 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( | 528 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
527 &mock_decoder, NetEqDecoder::kDecoderPCM16B, | 529 &mock_decoder, NetEqDecoder::kDecoderPCM16B, |
528 "dummy name", kPayloadType, kSampleRateHz)); | 530 "dummy name", kPayloadType)); |
529 | 531 |
530 // Insert one packet. | 532 // Insert one packet. |
531 EXPECT_EQ(NetEq::kOK, | 533 EXPECT_EQ(NetEq::kOK, |
532 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 534 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
533 | 535 |
534 // Pull audio once. | 536 // Pull audio once. |
535 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); | 537 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); |
536 AudioFrame output; | 538 AudioFrame output; |
537 bool muted; | 539 bool muted; |
538 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); | 540 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 | 653 |
652 WebRtcRTPHeader rtp_header; | 654 WebRtcRTPHeader rtp_header; |
653 rtp_header.header.payloadType = kPayloadType; | 655 rtp_header.header.payloadType = kPayloadType; |
654 rtp_header.header.sequenceNumber = 0x1234; | 656 rtp_header.header.sequenceNumber = 0x1234; |
655 rtp_header.header.timestamp = 0x12345678; | 657 rtp_header.header.timestamp = 0x12345678; |
656 rtp_header.header.ssrc = 0x87654321; | 658 rtp_header.header.ssrc = 0x87654321; |
657 | 659 |
658 // Create a mock decoder object. | 660 // Create a mock decoder object. |
659 MockAudioDecoder mock_decoder; | 661 MockAudioDecoder mock_decoder; |
660 EXPECT_CALL(mock_decoder, Reset()).WillRepeatedly(Return()); | 662 EXPECT_CALL(mock_decoder, Reset()).WillRepeatedly(Return()); |
| 663 EXPECT_CALL(mock_decoder, SampleRateHz()) |
| 664 .WillRepeatedly(Return(kSampleRateKhz * 1000)); |
661 EXPECT_CALL(mock_decoder, Channels()).WillRepeatedly(Return(1)); | 665 EXPECT_CALL(mock_decoder, Channels()).WillRepeatedly(Return(1)); |
662 EXPECT_CALL(mock_decoder, IncomingPacket(_, kPayloadLengthBytes, _, _, _)) | 666 EXPECT_CALL(mock_decoder, IncomingPacket(_, kPayloadLengthBytes, _, _, _)) |
663 .WillRepeatedly(Return(0)); | 667 .WillRepeatedly(Return(0)); |
664 EXPECT_CALL(mock_decoder, PacketDuration(_, kPayloadLengthBytes)) | 668 EXPECT_CALL(mock_decoder, PacketDuration(_, kPayloadLengthBytes)) |
665 .WillRepeatedly(Return(kPayloadLengthSamples)); | 669 .WillRepeatedly(Return(kPayloadLengthSamples)); |
666 // Packed duration when asking the decoder for more CNG data (without a new | 670 // Packed duration when asking the decoder for more CNG data (without a new |
667 // packet). | 671 // packet). |
668 EXPECT_CALL(mock_decoder, PacketDuration(nullptr, 0)) | 672 EXPECT_CALL(mock_decoder, PacketDuration(nullptr, 0)) |
669 .WillRepeatedly(Return(kPayloadLengthSamples)); | 673 .WillRepeatedly(Return(kPayloadLengthSamples)); |
670 | 674 |
(...skipping 22 matching lines...) Expand all Loading... |
693 | 697 |
694 EXPECT_CALL(mock_decoder, DecodeInternal(Pointee(2), kPayloadLengthBytes, | 698 EXPECT_CALL(mock_decoder, DecodeInternal(Pointee(2), kPayloadLengthBytes, |
695 kSampleRateKhz * 1000, _, _)) | 699 kSampleRateKhz * 1000, _, _)) |
696 .WillOnce(DoAll(SetArrayArgument<3>(dummy_output, | 700 .WillOnce(DoAll(SetArrayArgument<3>(dummy_output, |
697 dummy_output + kPayloadLengthSamples), | 701 dummy_output + kPayloadLengthSamples), |
698 SetArgPointee<4>(AudioDecoder::kSpeech), | 702 SetArgPointee<4>(AudioDecoder::kSpeech), |
699 Return(kPayloadLengthSamples))); | 703 Return(kPayloadLengthSamples))); |
700 | 704 |
701 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( | 705 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
702 &mock_decoder, NetEqDecoder::kDecoderOpus, | 706 &mock_decoder, NetEqDecoder::kDecoderOpus, |
703 "dummy name", kPayloadType, kSampleRateKhz * 1000)); | 707 "dummy name", kPayloadType)); |
704 | 708 |
705 // Insert one packet (decoder will return speech). | 709 // Insert one packet (decoder will return speech). |
706 EXPECT_EQ(NetEq::kOK, | 710 EXPECT_EQ(NetEq::kOK, |
707 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 711 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
708 | 712 |
709 // Insert second packet (decoder will return CNG). | 713 // Insert second packet (decoder will return CNG). |
710 payload[0] = 1; | 714 payload[0] = 1; |
711 rtp_header.header.sequenceNumber++; | 715 rtp_header.header.sequenceNumber++; |
712 rtp_header.header.timestamp += kPayloadLengthSamples; | 716 rtp_header.header.timestamp += kPayloadLengthSamples; |
713 EXPECT_EQ(NetEq::kOK, | 717 EXPECT_EQ(NetEq::kOK, |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
837 Return(static_cast<int>( | 841 Return(static_cast<int>( |
838 kPayloadLengthSamples * kChannels)))); | 842 kPayloadLengthSamples * kChannels)))); |
839 | 843 |
840 EXPECT_CALL(decoder_, PacketDuration(Pointee(kSecondPayloadValue), | 844 EXPECT_CALL(decoder_, PacketDuration(Pointee(kSecondPayloadValue), |
841 kPayloadLengthBytes)) | 845 kPayloadLengthBytes)) |
842 .Times(AtLeast(1)) | 846 .Times(AtLeast(1)) |
843 .WillRepeatedly(Return(kNetEqMaxFrameSize)); | 847 .WillRepeatedly(Return(kNetEqMaxFrameSize)); |
844 | 848 |
845 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( | 849 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
846 &decoder_, NetEqDecoder::kDecoderPCM16B, | 850 &decoder_, NetEqDecoder::kDecoderPCM16B, |
847 "dummy name", kPayloadType, kSampleRateHz)); | 851 "dummy name", kPayloadType)); |
848 | 852 |
849 // Insert one packet. | 853 // Insert one packet. |
850 payload[0] = kFirstPayloadValue; // This will make Decode() fail. | 854 payload[0] = kFirstPayloadValue; // This will make Decode() fail. |
851 EXPECT_EQ(NetEq::kOK, | 855 EXPECT_EQ(NetEq::kOK, |
852 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 856 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
853 | 857 |
854 // Insert another packet. | 858 // Insert another packet. |
855 payload[0] = kSecondPayloadValue; // This will make Decode() successful. | 859 payload[0] = kSecondPayloadValue; // This will make Decode() successful. |
856 rtp_header.header.sequenceNumber++; | 860 rtp_header.header.sequenceNumber++; |
857 // The second timestamp needs to be at least 30 ms after the first to make | 861 // The second timestamp needs to be at least 30 ms after the first to make |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
931 uint8_t payload[kPayloadLengthBytes] = {0}; | 935 uint8_t payload[kPayloadLengthBytes] = {0}; |
932 WebRtcRTPHeader rtp_header; | 936 WebRtcRTPHeader rtp_header; |
933 rtp_header.header.payloadType = kPayloadType; | 937 rtp_header.header.payloadType = kPayloadType; |
934 rtp_header.header.sequenceNumber = 0x1234; | 938 rtp_header.header.sequenceNumber = 0x1234; |
935 rtp_header.header.timestamp = 0x12345678; | 939 rtp_header.header.timestamp = 0x12345678; |
936 rtp_header.header.ssrc = 0x87654321; | 940 rtp_header.header.ssrc = 0x87654321; |
937 | 941 |
938 // Create a mock decoder object. | 942 // Create a mock decoder object. |
939 MockAudioDecoder mock_decoder; | 943 MockAudioDecoder mock_decoder; |
940 EXPECT_CALL(mock_decoder, Reset()).WillRepeatedly(Return()); | 944 EXPECT_CALL(mock_decoder, Reset()).WillRepeatedly(Return()); |
| 945 EXPECT_CALL(mock_decoder, SampleRateHz()) |
| 946 .WillRepeatedly(Return(kSampleRateHz)); |
941 EXPECT_CALL(mock_decoder, Channels()).WillRepeatedly(Return(1)); | 947 EXPECT_CALL(mock_decoder, Channels()).WillRepeatedly(Return(1)); |
942 EXPECT_CALL(mock_decoder, IncomingPacket(_, kPayloadLengthBytes, _, _, _)) | 948 EXPECT_CALL(mock_decoder, IncomingPacket(_, kPayloadLengthBytes, _, _, _)) |
943 .WillRepeatedly(Return(0)); | 949 .WillRepeatedly(Return(0)); |
944 EXPECT_CALL(mock_decoder, PacketDuration(_, _)) | 950 EXPECT_CALL(mock_decoder, PacketDuration(_, _)) |
945 .WillRepeatedly(Return(kPayloadLengthSamples)); | 951 .WillRepeatedly(Return(kPayloadLengthSamples)); |
946 int16_t dummy_output[kPayloadLengthSamples] = {0}; | 952 int16_t dummy_output[kPayloadLengthSamples] = {0}; |
947 // The below expectation will make the mock decoder write | 953 // The below expectation will make the mock decoder write |
948 // |kPayloadLengthSamples| - 5 zeros to the output array, and mark it as | 954 // |kPayloadLengthSamples| - 5 zeros to the output array, and mark it as |
949 // speech. That is, the decoded length is 5 samples shorter than the expected. | 955 // speech. That is, the decoded length is 5 samples shorter than the expected. |
950 EXPECT_CALL(mock_decoder, | 956 EXPECT_CALL(mock_decoder, |
951 DecodeInternal(_, kPayloadLengthBytes, kSampleRateHz, _, _)) | 957 DecodeInternal(_, kPayloadLengthBytes, kSampleRateHz, _, _)) |
952 .WillOnce( | 958 .WillOnce( |
953 DoAll(SetArrayArgument<3>(dummy_output, | 959 DoAll(SetArrayArgument<3>(dummy_output, |
954 dummy_output + kPayloadLengthSamples - 5), | 960 dummy_output + kPayloadLengthSamples - 5), |
955 SetArgPointee<4>(AudioDecoder::kSpeech), | 961 SetArgPointee<4>(AudioDecoder::kSpeech), |
956 Return(kPayloadLengthSamples - 5))); | 962 Return(kPayloadLengthSamples - 5))); |
957 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( | 963 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
958 &mock_decoder, NetEqDecoder::kDecoderPCM16B, | 964 &mock_decoder, NetEqDecoder::kDecoderPCM16B, |
959 "dummy name", kPayloadType, kSampleRateHz)); | 965 "dummy name", kPayloadType)); |
960 | 966 |
961 // Insert one packet. | 967 // Insert one packet. |
962 EXPECT_EQ(NetEq::kOK, | 968 EXPECT_EQ(NetEq::kOK, |
963 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 969 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
964 | 970 |
965 EXPECT_EQ(5u, neteq_->sync_buffer_for_test()->FutureLength()); | 971 EXPECT_EQ(5u, neteq_->sync_buffer_for_test()->FutureLength()); |
966 | 972 |
967 // Pull audio once. | 973 // Pull audio once. |
968 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); | 974 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); |
969 AudioFrame output; | 975 AudioFrame output; |
(...skipping 26 matching lines...) Expand all Loading... |
996 | 1002 |
997 WebRtcRTPHeader rtp_header; | 1003 WebRtcRTPHeader rtp_header; |
998 rtp_header.header.payloadType = kPayloadType; | 1004 rtp_header.header.payloadType = kPayloadType; |
999 rtp_header.header.sequenceNumber = 0x1234; | 1005 rtp_header.header.sequenceNumber = 0x1234; |
1000 rtp_header.header.timestamp = 0x12345678; | 1006 rtp_header.header.timestamp = 0x12345678; |
1001 rtp_header.header.ssrc = 0x87654321; | 1007 rtp_header.header.ssrc = 0x87654321; |
1002 | 1008 |
1003 // Create a mock decoder object. | 1009 // Create a mock decoder object. |
1004 MockAudioDecoder mock_decoder; | 1010 MockAudioDecoder mock_decoder; |
1005 EXPECT_CALL(mock_decoder, Reset()).WillRepeatedly(Return()); | 1011 EXPECT_CALL(mock_decoder, Reset()).WillRepeatedly(Return()); |
| 1012 EXPECT_CALL(mock_decoder, SampleRateHz()) |
| 1013 .WillRepeatedly(Return(kSampleRateHz)); |
1006 EXPECT_CALL(mock_decoder, Channels()).WillRepeatedly(Return(1)); | 1014 EXPECT_CALL(mock_decoder, Channels()).WillRepeatedly(Return(1)); |
1007 EXPECT_CALL(mock_decoder, IncomingPacket(_, kPayloadLengthBytes, _, _, _)) | 1015 EXPECT_CALL(mock_decoder, IncomingPacket(_, kPayloadLengthBytes, _, _, _)) |
1008 .WillRepeatedly(Return(0)); | 1016 .WillRepeatedly(Return(0)); |
1009 EXPECT_CALL(mock_decoder, PacketDuration(_, _)) | 1017 EXPECT_CALL(mock_decoder, PacketDuration(_, _)) |
1010 .WillRepeatedly(Return(kFrameLengthSamples)); | 1018 .WillRepeatedly(Return(kFrameLengthSamples)); |
1011 EXPECT_CALL(mock_decoder, ErrorCode()) | 1019 EXPECT_CALL(mock_decoder, ErrorCode()) |
1012 .WillOnce(Return(kDecoderErrorCode)); | 1020 .WillOnce(Return(kDecoderErrorCode)); |
1013 EXPECT_CALL(mock_decoder, HasDecodePlc()) | 1021 EXPECT_CALL(mock_decoder, HasDecodePlc()) |
1014 .WillOnce(Return(false)); | 1022 .WillOnce(Return(false)); |
1015 int16_t dummy_output[kFrameLengthSamples] = {0}; | 1023 int16_t dummy_output[kFrameLengthSamples] = {0}; |
(...skipping 24 matching lines...) Expand all Loading... |
1040 .Times(2) | 1048 .Times(2) |
1041 .WillRepeatedly( | 1049 .WillRepeatedly( |
1042 DoAll(SetArrayArgument<3>(dummy_output, | 1050 DoAll(SetArrayArgument<3>(dummy_output, |
1043 dummy_output + kFrameLengthSamples), | 1051 dummy_output + kFrameLengthSamples), |
1044 SetArgPointee<4>(AudioDecoder::kSpeech), | 1052 SetArgPointee<4>(AudioDecoder::kSpeech), |
1045 Return(kFrameLengthSamples))); | 1053 Return(kFrameLengthSamples))); |
1046 } | 1054 } |
1047 | 1055 |
1048 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( | 1056 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
1049 &mock_decoder, NetEqDecoder::kDecoderPCM16B, | 1057 &mock_decoder, NetEqDecoder::kDecoderPCM16B, |
1050 "dummy name", kPayloadType, kSampleRateHz)); | 1058 "dummy name", kPayloadType)); |
1051 | 1059 |
1052 // Insert packets. | 1060 // Insert packets. |
1053 for (int i = 0; i < 6; ++i) { | 1061 for (int i = 0; i < 6; ++i) { |
1054 rtp_header.header.sequenceNumber += 1; | 1062 rtp_header.header.sequenceNumber += 1; |
1055 rtp_header.header.timestamp += kFrameLengthSamples; | 1063 rtp_header.header.timestamp += kFrameLengthSamples; |
1056 EXPECT_EQ(NetEq::kOK, | 1064 EXPECT_EQ(NetEq::kOK, |
1057 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 1065 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
1058 } | 1066 } |
1059 | 1067 |
1060 // Pull audio. | 1068 // Pull audio. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1110 | 1118 |
1111 WebRtcRTPHeader rtp_header; | 1119 WebRtcRTPHeader rtp_header; |
1112 rtp_header.header.payloadType = kPayloadType; | 1120 rtp_header.header.payloadType = kPayloadType; |
1113 rtp_header.header.sequenceNumber = 0x1234; | 1121 rtp_header.header.sequenceNumber = 0x1234; |
1114 rtp_header.header.timestamp = 0x12345678; | 1122 rtp_header.header.timestamp = 0x12345678; |
1115 rtp_header.header.ssrc = 0x87654321; | 1123 rtp_header.header.ssrc = 0x87654321; |
1116 | 1124 |
1117 // Create a mock decoder object. | 1125 // Create a mock decoder object. |
1118 MockAudioDecoder mock_decoder; | 1126 MockAudioDecoder mock_decoder; |
1119 EXPECT_CALL(mock_decoder, Reset()).WillRepeatedly(Return()); | 1127 EXPECT_CALL(mock_decoder, Reset()).WillRepeatedly(Return()); |
| 1128 EXPECT_CALL(mock_decoder, SampleRateHz()) |
| 1129 .WillRepeatedly(Return(kSampleRateHz)); |
1120 EXPECT_CALL(mock_decoder, Channels()).WillRepeatedly(Return(1)); | 1130 EXPECT_CALL(mock_decoder, Channels()).WillRepeatedly(Return(1)); |
1121 EXPECT_CALL(mock_decoder, IncomingPacket(_, kPayloadLengthBytes, _, _, _)) | 1131 EXPECT_CALL(mock_decoder, IncomingPacket(_, kPayloadLengthBytes, _, _, _)) |
1122 .WillRepeatedly(Return(0)); | 1132 .WillRepeatedly(Return(0)); |
1123 EXPECT_CALL(mock_decoder, PacketDuration(_, _)) | 1133 EXPECT_CALL(mock_decoder, PacketDuration(_, _)) |
1124 .WillRepeatedly(Return(kFrameLengthSamples)); | 1134 .WillRepeatedly(Return(kFrameLengthSamples)); |
1125 EXPECT_CALL(mock_decoder, ErrorCode()) | 1135 EXPECT_CALL(mock_decoder, ErrorCode()) |
1126 .WillOnce(Return(kDecoderErrorCode)); | 1136 .WillOnce(Return(kDecoderErrorCode)); |
1127 int16_t dummy_output[kFrameLengthSamples] = {0}; | 1137 int16_t dummy_output[kFrameLengthSamples] = {0}; |
1128 | 1138 |
1129 { | 1139 { |
(...skipping 20 matching lines...) Expand all Loading... |
1150 .Times(2) | 1160 .Times(2) |
1151 .WillRepeatedly( | 1161 .WillRepeatedly( |
1152 DoAll(SetArrayArgument<3>(dummy_output, | 1162 DoAll(SetArrayArgument<3>(dummy_output, |
1153 dummy_output + kFrameLengthSamples), | 1163 dummy_output + kFrameLengthSamples), |
1154 SetArgPointee<4>(AudioDecoder::kComfortNoise), | 1164 SetArgPointee<4>(AudioDecoder::kComfortNoise), |
1155 Return(kFrameLengthSamples))); | 1165 Return(kFrameLengthSamples))); |
1156 } | 1166 } |
1157 | 1167 |
1158 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( | 1168 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
1159 &mock_decoder, NetEqDecoder::kDecoderPCM16B, | 1169 &mock_decoder, NetEqDecoder::kDecoderPCM16B, |
1160 "dummy name", kPayloadType, kSampleRateHz)); | 1170 "dummy name", kPayloadType)); |
1161 | 1171 |
1162 // Insert 2 packets. This will make netEq into codec internal CNG mode. | 1172 // Insert 2 packets. This will make netEq into codec internal CNG mode. |
1163 for (int i = 0; i < 2; ++i) { | 1173 for (int i = 0; i < 2; ++i) { |
1164 rtp_header.header.sequenceNumber += 1; | 1174 rtp_header.header.sequenceNumber += 1; |
1165 rtp_header.header.timestamp += kFrameLengthSamples; | 1175 rtp_header.header.timestamp += kFrameLengthSamples; |
1166 EXPECT_EQ(NetEq::kOK, | 1176 EXPECT_EQ(NetEq::kOK, |
1167 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 1177 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
1168 } | 1178 } |
1169 | 1179 |
1170 // Pull audio. | 1180 // Pull audio. |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1286 uint8_t payload[kPayloadLengthBytes] = {0}; | 1296 uint8_t payload[kPayloadLengthBytes] = {0}; |
1287 EXPECT_EQ(NetEq::kOK, neteq_->InsertPacket(rtp_header, payload, 10)); | 1297 EXPECT_EQ(NetEq::kOK, neteq_->InsertPacket(rtp_header, payload, 10)); |
1288 sequence_number_++; | 1298 sequence_number_++; |
1289 } | 1299 } |
1290 | 1300 |
1291 void Register120msCodec(AudioDecoder::SpeechType speech_type) { | 1301 void Register120msCodec(AudioDecoder::SpeechType speech_type) { |
1292 decoder_.reset(new Decoder120ms(kSamplingFreq_, speech_type)); | 1302 decoder_.reset(new Decoder120ms(kSamplingFreq_, speech_type)); |
1293 ASSERT_EQ(2u, decoder_->Channels()); | 1303 ASSERT_EQ(2u, decoder_->Channels()); |
1294 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( | 1304 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
1295 decoder_.get(), NetEqDecoder::kDecoderOpus_2ch, | 1305 decoder_.get(), NetEqDecoder::kDecoderOpus_2ch, |
1296 "120ms codec", kPayloadType, kSamplingFreq_)); | 1306 "120ms codec", kPayloadType)); |
1297 } | 1307 } |
1298 | 1308 |
1299 std::unique_ptr<Decoder120ms> decoder_; | 1309 std::unique_ptr<Decoder120ms> decoder_; |
1300 AudioFrame output_; | 1310 AudioFrame output_; |
1301 const uint32_t kPayloadType = 17; | 1311 const uint32_t kPayloadType = 17; |
1302 const uint32_t kSamplingFreq_ = 48000; | 1312 const uint32_t kSamplingFreq_ = 48000; |
1303 uint16_t sequence_number_ = 1; | 1313 uint16_t sequence_number_ = 1; |
1304 }; | 1314 }; |
1305 | 1315 |
1306 TEST_F(NetEqImplTest120ms, AudioRepetition) { | 1316 TEST_F(NetEqImplTest120ms, AudioRepetition) { |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1432 EXPECT_CALL(*mock_delay_manager_, BufferLimits(_, _)) | 1442 EXPECT_CALL(*mock_delay_manager_, BufferLimits(_, _)) |
1433 .Times(1) | 1443 .Times(1) |
1434 .WillOnce(DoAll(SetArgPointee<0>(1), SetArgPointee<1>(2))); | 1444 .WillOnce(DoAll(SetArgPointee<0>(1), SetArgPointee<1>(2))); |
1435 | 1445 |
1436 bool muted; | 1446 bool muted; |
1437 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_, &muted)); | 1447 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_, &muted)); |
1438 EXPECT_EQ(kAccelerate, neteq_->last_operation_for_test()); | 1448 EXPECT_EQ(kAccelerate, neteq_->last_operation_for_test()); |
1439 } | 1449 } |
1440 | 1450 |
1441 }// namespace webrtc | 1451 }// namespace webrtc |
OLD | NEW |