| 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 rtp_header.header.payloadType = kPayloadType; | 186 rtp_header.header.payloadType = kPayloadType; |
| 187 rtp_header.header.sequenceNumber = 0x1234; | 187 rtp_header.header.sequenceNumber = 0x1234; |
| 188 rtp_header.header.timestamp = 0x12345678; | 188 rtp_header.header.timestamp = 0x12345678; |
| 189 rtp_header.header.ssrc = 0x87654321; | 189 rtp_header.header.ssrc = 0x87654321; |
| 190 | 190 |
| 191 EXPECT_EQ(NetEq::kOK, neteq_->RegisterPayloadType( | 191 EXPECT_EQ(NetEq::kOK, neteq_->RegisterPayloadType( |
| 192 decoder_type, "telephone-event", kPayloadType)); | 192 decoder_type, "telephone-event", kPayloadType)); |
| 193 | 193 |
| 194 // Insert first packet. | 194 // Insert first packet. |
| 195 EXPECT_EQ(NetEq::kOK, | 195 EXPECT_EQ(NetEq::kOK, |
| 196 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 196 neteq_->InsertPacket(rtp_header.header, payload, kReceiveTime)); |
| 197 | 197 |
| 198 // Pull audio once. | 198 // Pull audio once. |
| 199 const size_t kMaxOutputSize = | 199 const size_t kMaxOutputSize = |
| 200 static_cast<size_t>(10 * kSampleRateHz / 1000); | 200 static_cast<size_t>(10 * kSampleRateHz / 1000); |
| 201 AudioFrame output; | 201 AudioFrame output; |
| 202 bool muted; | 202 bool muted; |
| 203 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); | 203 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); |
| 204 ASSERT_FALSE(muted); | 204 ASSERT_FALSE(muted); |
| 205 ASSERT_EQ(kMaxOutputSize, output.samples_per_channel_); | 205 ASSERT_EQ(kMaxOutputSize, output.samples_per_channel_); |
| 206 EXPECT_EQ(1u, output.num_channels_); | 206 EXPECT_EQ(1u, output.num_channels_); |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 .Times(1); | 377 .Times(1); |
| 378 EXPECT_CALL(*mock_delay_manager_, ResetPacketIatCount()).Times(1); | 378 EXPECT_CALL(*mock_delay_manager_, ResetPacketIatCount()).Times(1); |
| 379 // Expectations when the second packet is inserted. Slightly different. | 379 // Expectations when the second packet is inserted. Slightly different. |
| 380 EXPECT_CALL(*mock_delay_manager_, last_pack_cng_or_dtmf()) | 380 EXPECT_CALL(*mock_delay_manager_, last_pack_cng_or_dtmf()) |
| 381 .WillOnce(Return(0)); | 381 .WillOnce(Return(0)); |
| 382 EXPECT_CALL(*mock_delay_manager_, SetPacketAudioLength(30)) | 382 EXPECT_CALL(*mock_delay_manager_, SetPacketAudioLength(30)) |
| 383 .WillOnce(Return(0)); | 383 .WillOnce(Return(0)); |
| 384 } | 384 } |
| 385 | 385 |
| 386 // Insert first packet. | 386 // Insert first packet. |
| 387 neteq_->InsertPacket(rtp_header, payload, kFirstReceiveTime); | 387 neteq_->InsertPacket(rtp_header.header, payload, kFirstReceiveTime); |
| 388 | 388 |
| 389 // Insert second packet. | 389 // Insert second packet. |
| 390 rtp_header.header.timestamp += 160; | 390 rtp_header.header.timestamp += 160; |
| 391 rtp_header.header.sequenceNumber += 1; | 391 rtp_header.header.sequenceNumber += 1; |
| 392 neteq_->InsertPacket(rtp_header, payload, kFirstReceiveTime + 155); | 392 neteq_->InsertPacket(rtp_header.header, payload, kFirstReceiveTime + 155); |
| 393 } | 393 } |
| 394 | 394 |
| 395 TEST_F(NetEqImplTest, InsertPacketsUntilBufferIsFull) { | 395 TEST_F(NetEqImplTest, InsertPacketsUntilBufferIsFull) { |
| 396 UseNoMocks(); | 396 UseNoMocks(); |
| 397 CreateInstance(); | 397 CreateInstance(); |
| 398 | 398 |
| 399 const int kPayloadLengthSamples = 80; | 399 const int kPayloadLengthSamples = 80; |
| 400 const size_t kPayloadLengthBytes = 2 * kPayloadLengthSamples; // PCM 16-bit. | 400 const size_t kPayloadLengthBytes = 2 * kPayloadLengthSamples; // PCM 16-bit. |
| 401 const uint8_t kPayloadType = 17; // Just an arbitrary number. | 401 const uint8_t kPayloadType = 17; // Just an arbitrary number. |
| 402 const uint32_t kReceiveTime = 17; // Value doesn't matter for this test. | 402 const uint32_t kReceiveTime = 17; // Value doesn't matter for this test. |
| 403 uint8_t payload[kPayloadLengthBytes] = {0}; | 403 uint8_t payload[kPayloadLengthBytes] = {0}; |
| 404 WebRtcRTPHeader rtp_header; | 404 WebRtcRTPHeader rtp_header; |
| 405 rtp_header.header.payloadType = kPayloadType; | 405 rtp_header.header.payloadType = kPayloadType; |
| 406 rtp_header.header.sequenceNumber = 0x1234; | 406 rtp_header.header.sequenceNumber = 0x1234; |
| 407 rtp_header.header.timestamp = 0x12345678; | 407 rtp_header.header.timestamp = 0x12345678; |
| 408 rtp_header.header.ssrc = 0x87654321; | 408 rtp_header.header.ssrc = 0x87654321; |
| 409 | 409 |
| 410 EXPECT_EQ(NetEq::kOK, neteq_->RegisterPayloadType( | 410 EXPECT_EQ(NetEq::kOK, neteq_->RegisterPayloadType( |
| 411 NetEqDecoder::kDecoderPCM16B, "", kPayloadType)); | 411 NetEqDecoder::kDecoderPCM16B, "", kPayloadType)); |
| 412 | 412 |
| 413 // Insert packets. The buffer should not flush. | 413 // Insert packets. The buffer should not flush. |
| 414 for (size_t i = 1; i <= config_.max_packets_in_buffer; ++i) { | 414 for (size_t i = 1; i <= config_.max_packets_in_buffer; ++i) { |
| 415 EXPECT_EQ(NetEq::kOK, | 415 EXPECT_EQ(NetEq::kOK, |
| 416 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 416 neteq_->InsertPacket(rtp_header.header, payload, kReceiveTime)); |
| 417 rtp_header.header.timestamp += kPayloadLengthSamples; | 417 rtp_header.header.timestamp += kPayloadLengthSamples; |
| 418 rtp_header.header.sequenceNumber += 1; | 418 rtp_header.header.sequenceNumber += 1; |
| 419 EXPECT_EQ(i, packet_buffer_->NumPacketsInBuffer()); | 419 EXPECT_EQ(i, packet_buffer_->NumPacketsInBuffer()); |
| 420 } | 420 } |
| 421 | 421 |
| 422 // Insert one more packet and make sure the buffer got flushed. That is, it | 422 // Insert one more packet and make sure the buffer got flushed. That is, it |
| 423 // should only hold one single packet. | 423 // should only hold one single packet. |
| 424 EXPECT_EQ(NetEq::kOK, | 424 EXPECT_EQ(NetEq::kOK, |
| 425 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 425 neteq_->InsertPacket(rtp_header.header, payload, kReceiveTime)); |
| 426 EXPECT_EQ(1u, packet_buffer_->NumPacketsInBuffer()); | 426 EXPECT_EQ(1u, packet_buffer_->NumPacketsInBuffer()); |
| 427 const Packet* test_packet = packet_buffer_->PeekNextPacket(); | 427 const Packet* test_packet = packet_buffer_->PeekNextPacket(); |
| 428 EXPECT_EQ(rtp_header.header.timestamp, test_packet->timestamp); | 428 EXPECT_EQ(rtp_header.header.timestamp, test_packet->timestamp); |
| 429 EXPECT_EQ(rtp_header.header.sequenceNumber, test_packet->sequence_number); | 429 EXPECT_EQ(rtp_header.header.sequenceNumber, test_packet->sequence_number); |
| 430 } | 430 } |
| 431 | 431 |
| 432 TEST_F(NetEqImplTest, TestDtmfPacketAVT) { | 432 TEST_F(NetEqImplTest, TestDtmfPacketAVT) { |
| 433 TestDtmfPacket(NetEqDecoder::kDecoderAVT); | 433 TestDtmfPacket(NetEqDecoder::kDecoderAVT); |
| 434 } | 434 } |
| 435 | 435 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 private: | 495 private: |
| 496 int16_t next_value_; | 496 int16_t next_value_; |
| 497 } decoder_; | 497 } decoder_; |
| 498 | 498 |
| 499 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( | 499 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
| 500 &decoder_, NetEqDecoder::kDecoderPCM16B, | 500 &decoder_, NetEqDecoder::kDecoderPCM16B, |
| 501 "dummy name", kPayloadType)); | 501 "dummy name", kPayloadType)); |
| 502 | 502 |
| 503 // Insert one packet. | 503 // Insert one packet. |
| 504 EXPECT_EQ(NetEq::kOK, | 504 EXPECT_EQ(NetEq::kOK, |
| 505 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 505 neteq_->InsertPacket(rtp_header.header, payload, kReceiveTime)); |
| 506 | 506 |
| 507 // Pull audio once. | 507 // Pull audio once. |
| 508 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); | 508 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); |
| 509 AudioFrame output; | 509 AudioFrame output; |
| 510 bool muted; | 510 bool muted; |
| 511 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); | 511 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); |
| 512 ASSERT_FALSE(muted); | 512 ASSERT_FALSE(muted); |
| 513 ASSERT_EQ(kMaxOutputSize, output.samples_per_channel_); | 513 ASSERT_EQ(kMaxOutputSize, output.samples_per_channel_); |
| 514 EXPECT_EQ(1u, output.num_channels_); | 514 EXPECT_EQ(1u, output.num_channels_); |
| 515 EXPECT_EQ(AudioFrame::kNormalSpeech, output.speech_type_); | 515 EXPECT_EQ(AudioFrame::kNormalSpeech, output.speech_type_); |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 576 .WillOnce(DoAll(SetArrayArgument<3>(dummy_output, | 576 .WillOnce(DoAll(SetArrayArgument<3>(dummy_output, |
| 577 dummy_output + kPayloadLengthSamples), | 577 dummy_output + kPayloadLengthSamples), |
| 578 SetArgPointee<4>(AudioDecoder::kSpeech), | 578 SetArgPointee<4>(AudioDecoder::kSpeech), |
| 579 Return(kPayloadLengthSamples))); | 579 Return(kPayloadLengthSamples))); |
| 580 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( | 580 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
| 581 &mock_decoder, NetEqDecoder::kDecoderPCM16B, | 581 &mock_decoder, NetEqDecoder::kDecoderPCM16B, |
| 582 "dummy name", kPayloadType)); | 582 "dummy name", kPayloadType)); |
| 583 | 583 |
| 584 // Insert one packet. | 584 // Insert one packet. |
| 585 EXPECT_EQ(NetEq::kOK, | 585 EXPECT_EQ(NetEq::kOK, |
| 586 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 586 neteq_->InsertPacket(rtp_header.header, payload, kReceiveTime)); |
| 587 | 587 |
| 588 // Pull audio once. | 588 // Pull audio once. |
| 589 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); | 589 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); |
| 590 AudioFrame output; | 590 AudioFrame output; |
| 591 bool muted; | 591 bool muted; |
| 592 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); | 592 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); |
| 593 ASSERT_EQ(kMaxOutputSize, output.samples_per_channel_); | 593 ASSERT_EQ(kMaxOutputSize, output.samples_per_channel_); |
| 594 EXPECT_EQ(1u, output.num_channels_); | 594 EXPECT_EQ(1u, output.num_channels_); |
| 595 EXPECT_EQ(AudioFrame::kNormalSpeech, output.speech_type_); | 595 EXPECT_EQ(AudioFrame::kNormalSpeech, output.speech_type_); |
| 596 | 596 |
| 597 // Insert two more packets. The first one is out of order, and is already too | 597 // Insert two more packets. The first one is out of order, and is already too |
| 598 // old, the second one is the expected next packet. | 598 // old, the second one is the expected next packet. |
| 599 rtp_header.header.sequenceNumber -= 1; | 599 rtp_header.header.sequenceNumber -= 1; |
| 600 rtp_header.header.timestamp -= kPayloadLengthSamples; | 600 rtp_header.header.timestamp -= kPayloadLengthSamples; |
| 601 payload[0] = 1; | 601 payload[0] = 1; |
| 602 EXPECT_EQ(NetEq::kOK, | 602 EXPECT_EQ(NetEq::kOK, |
| 603 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 603 neteq_->InsertPacket(rtp_header.header, payload, kReceiveTime)); |
| 604 rtp_header.header.sequenceNumber += 2; | 604 rtp_header.header.sequenceNumber += 2; |
| 605 rtp_header.header.timestamp += 2 * kPayloadLengthSamples; | 605 rtp_header.header.timestamp += 2 * kPayloadLengthSamples; |
| 606 payload[0] = 2; | 606 payload[0] = 2; |
| 607 EXPECT_EQ(NetEq::kOK, | 607 EXPECT_EQ(NetEq::kOK, |
| 608 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 608 neteq_->InsertPacket(rtp_header.header, payload, kReceiveTime)); |
| 609 | 609 |
| 610 // Expect only the second packet to be decoded (the one with "2" as the first | 610 // Expect only the second packet to be decoded (the one with "2" as the first |
| 611 // payload byte). | 611 // payload byte). |
| 612 EXPECT_CALL(mock_decoder, DecodeInternal(Pointee(2), kPayloadLengthBytes, | 612 EXPECT_CALL(mock_decoder, DecodeInternal(Pointee(2), kPayloadLengthBytes, |
| 613 kSampleRateHz, _, _)) | 613 kSampleRateHz, _, _)) |
| 614 .WillOnce(DoAll(SetArrayArgument<3>(dummy_output, | 614 .WillOnce(DoAll(SetArrayArgument<3>(dummy_output, |
| 615 dummy_output + kPayloadLengthSamples), | 615 dummy_output + kPayloadLengthSamples), |
| 616 SetArgPointee<4>(AudioDecoder::kSpeech), | 616 SetArgPointee<4>(AudioDecoder::kSpeech), |
| 617 Return(kPayloadLengthSamples))); | 617 Return(kPayloadLengthSamples))); |
| 618 | 618 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 644 uint8_t payload[kPayloadLengthBytes] = {0}; | 644 uint8_t payload[kPayloadLengthBytes] = {0}; |
| 645 WebRtcRTPHeader rtp_header; | 645 WebRtcRTPHeader rtp_header; |
| 646 rtp_header.header.payloadType = kPayloadType; | 646 rtp_header.header.payloadType = kPayloadType; |
| 647 rtp_header.header.sequenceNumber = 0x1234; | 647 rtp_header.header.sequenceNumber = 0x1234; |
| 648 rtp_header.header.timestamp = 0x12345678; | 648 rtp_header.header.timestamp = 0x12345678; |
| 649 rtp_header.header.ssrc = 0x87654321; | 649 rtp_header.header.ssrc = 0x87654321; |
| 650 | 650 |
| 651 // Insert one packet. Note that we have not registered any payload type, so | 651 // Insert one packet. Note that we have not registered any payload type, so |
| 652 // this packet will be rejected. | 652 // this packet will be rejected. |
| 653 EXPECT_EQ(NetEq::kFail, | 653 EXPECT_EQ(NetEq::kFail, |
| 654 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 654 neteq_->InsertPacket(rtp_header.header, payload, kReceiveTime)); |
| 655 EXPECT_EQ(NetEq::kUnknownRtpPayloadType, neteq_->LastError()); | 655 EXPECT_EQ(NetEq::kUnknownRtpPayloadType, neteq_->LastError()); |
| 656 | 656 |
| 657 // Pull audio once. | 657 // Pull audio once. |
| 658 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); | 658 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); |
| 659 AudioFrame output; | 659 AudioFrame output; |
| 660 bool muted; | 660 bool muted; |
| 661 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); | 661 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); |
| 662 ASSERT_LE(output.samples_per_channel_, kMaxOutputSize); | 662 ASSERT_LE(output.samples_per_channel_, kMaxOutputSize); |
| 663 EXPECT_EQ(kMaxOutputSize, output.samples_per_channel_); | 663 EXPECT_EQ(kMaxOutputSize, output.samples_per_channel_); |
| 664 EXPECT_EQ(1u, output.num_channels_); | 664 EXPECT_EQ(1u, output.num_channels_); |
| 665 EXPECT_EQ(AudioFrame::kPLC, output.speech_type_); | 665 EXPECT_EQ(AudioFrame::kPLC, output.speech_type_); |
| 666 | 666 |
| 667 // Register the payload type. | 667 // Register the payload type. |
| 668 EXPECT_EQ(NetEq::kOK, neteq_->RegisterPayloadType( | 668 EXPECT_EQ(NetEq::kOK, neteq_->RegisterPayloadType( |
| 669 NetEqDecoder::kDecoderPCM16B, "", kPayloadType)); | 669 NetEqDecoder::kDecoderPCM16B, "", kPayloadType)); |
| 670 | 670 |
| 671 // Insert 10 packets. | 671 // Insert 10 packets. |
| 672 for (size_t i = 0; i < 10; ++i) { | 672 for (size_t i = 0; i < 10; ++i) { |
| 673 rtp_header.header.sequenceNumber++; | 673 rtp_header.header.sequenceNumber++; |
| 674 rtp_header.header.timestamp += kPayloadLengthSamples; | 674 rtp_header.header.timestamp += kPayloadLengthSamples; |
| 675 EXPECT_EQ(NetEq::kOK, | 675 EXPECT_EQ(NetEq::kOK, |
| 676 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 676 neteq_->InsertPacket(rtp_header.header, payload, kReceiveTime)); |
| 677 EXPECT_EQ(i + 1, packet_buffer_->NumPacketsInBuffer()); | 677 EXPECT_EQ(i + 1, packet_buffer_->NumPacketsInBuffer()); |
| 678 } | 678 } |
| 679 | 679 |
| 680 // Pull audio repeatedly and make sure we get normal output, that is not PLC. | 680 // Pull audio repeatedly and make sure we get normal output, that is not PLC. |
| 681 for (size_t i = 0; i < 3; ++i) { | 681 for (size_t i = 0; i < 3; ++i) { |
| 682 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); | 682 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); |
| 683 ASSERT_LE(output.samples_per_channel_, kMaxOutputSize); | 683 ASSERT_LE(output.samples_per_channel_, kMaxOutputSize); |
| 684 EXPECT_EQ(kMaxOutputSize, output.samples_per_channel_); | 684 EXPECT_EQ(kMaxOutputSize, output.samples_per_channel_); |
| 685 EXPECT_EQ(1u, output.num_channels_); | 685 EXPECT_EQ(1u, output.num_channels_); |
| 686 EXPECT_EQ(AudioFrame::kNormalSpeech, output.speech_type_) | 686 EXPECT_EQ(AudioFrame::kNormalSpeech, output.speech_type_) |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 753 dummy_output + kPayloadLengthSamples), | 753 dummy_output + kPayloadLengthSamples), |
| 754 SetArgPointee<4>(AudioDecoder::kSpeech), | 754 SetArgPointee<4>(AudioDecoder::kSpeech), |
| 755 Return(kPayloadLengthSamples))); | 755 Return(kPayloadLengthSamples))); |
| 756 | 756 |
| 757 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( | 757 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
| 758 &mock_decoder, NetEqDecoder::kDecoderOpus, | 758 &mock_decoder, NetEqDecoder::kDecoderOpus, |
| 759 "dummy name", kPayloadType)); | 759 "dummy name", kPayloadType)); |
| 760 | 760 |
| 761 // Insert one packet (decoder will return speech). | 761 // Insert one packet (decoder will return speech). |
| 762 EXPECT_EQ(NetEq::kOK, | 762 EXPECT_EQ(NetEq::kOK, |
| 763 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 763 neteq_->InsertPacket(rtp_header.header, payload, kReceiveTime)); |
| 764 | 764 |
| 765 // Insert second packet (decoder will return CNG). | 765 // Insert second packet (decoder will return CNG). |
| 766 payload[0] = 1; | 766 payload[0] = 1; |
| 767 rtp_header.header.sequenceNumber++; | 767 rtp_header.header.sequenceNumber++; |
| 768 rtp_header.header.timestamp += kPayloadLengthSamples; | 768 rtp_header.header.timestamp += kPayloadLengthSamples; |
| 769 EXPECT_EQ(NetEq::kOK, | 769 EXPECT_EQ(NetEq::kOK, |
| 770 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 770 neteq_->InsertPacket(rtp_header.header, payload, kReceiveTime)); |
| 771 | 771 |
| 772 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateKhz); | 772 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateKhz); |
| 773 AudioFrame output; | 773 AudioFrame output; |
| 774 AudioFrame::SpeechType expected_type[8] = { | 774 AudioFrame::SpeechType expected_type[8] = { |
| 775 AudioFrame::kNormalSpeech, AudioFrame::kNormalSpeech, | 775 AudioFrame::kNormalSpeech, AudioFrame::kNormalSpeech, |
| 776 AudioFrame::kCNG, AudioFrame::kCNG, | 776 AudioFrame::kCNG, AudioFrame::kCNG, |
| 777 AudioFrame::kCNG, AudioFrame::kCNG, | 777 AudioFrame::kCNG, AudioFrame::kCNG, |
| 778 AudioFrame::kNormalSpeech, AudioFrame::kNormalSpeech | 778 AudioFrame::kNormalSpeech, AudioFrame::kNormalSpeech |
| 779 }; | 779 }; |
| 780 int expected_timestamp_increment[8] = { | 780 int expected_timestamp_increment[8] = { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 811 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); | 811 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); |
| 812 SCOPED_TRACE(""); | 812 SCOPED_TRACE(""); |
| 813 verify_timestamp(neteq_->GetPlayoutTimestamp(), i); | 813 verify_timestamp(neteq_->GetPlayoutTimestamp(), i); |
| 814 } | 814 } |
| 815 | 815 |
| 816 // Insert third packet, which leaves a gap from last packet. | 816 // Insert third packet, which leaves a gap from last packet. |
| 817 payload[0] = 2; | 817 payload[0] = 2; |
| 818 rtp_header.header.sequenceNumber += 2; | 818 rtp_header.header.sequenceNumber += 2; |
| 819 rtp_header.header.timestamp += 2 * kPayloadLengthSamples; | 819 rtp_header.header.timestamp += 2 * kPayloadLengthSamples; |
| 820 EXPECT_EQ(NetEq::kOK, | 820 EXPECT_EQ(NetEq::kOK, |
| 821 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 821 neteq_->InsertPacket(rtp_header.header, payload, kReceiveTime)); |
| 822 | 822 |
| 823 for (size_t i = 6; i < 8; ++i) { | 823 for (size_t i = 6; i < 8; ++i) { |
| 824 ASSERT_EQ(kMaxOutputSize, output.samples_per_channel_); | 824 ASSERT_EQ(kMaxOutputSize, output.samples_per_channel_); |
| 825 EXPECT_EQ(1u, output.num_channels_); | 825 EXPECT_EQ(1u, output.num_channels_); |
| 826 EXPECT_EQ(expected_type[i - 1], output.speech_type_); | 826 EXPECT_EQ(expected_type[i - 1], output.speech_type_); |
| 827 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); | 827 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); |
| 828 SCOPED_TRACE(""); | 828 SCOPED_TRACE(""); |
| 829 verify_timestamp(neteq_->GetPlayoutTimestamp(), i); | 829 verify_timestamp(neteq_->GetPlayoutTimestamp(), i); |
| 830 } | 830 } |
| 831 | 831 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 889 EXPECT_CALL(decoder, Channels()) | 889 EXPECT_CALL(decoder, Channels()) |
| 890 .WillRepeatedly(Return(kChannels)); | 890 .WillRepeatedly(Return(kChannels)); |
| 891 | 891 |
| 892 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( | 892 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
| 893 &decoder, NetEqDecoder::kDecoderPCM16B, | 893 &decoder, NetEqDecoder::kDecoderPCM16B, |
| 894 "dummy name", kPayloadType)); | 894 "dummy name", kPayloadType)); |
| 895 | 895 |
| 896 // Insert one packet. | 896 // Insert one packet. |
| 897 payload[0] = kFirstPayloadValue; // This will make Decode() fail. | 897 payload[0] = kFirstPayloadValue; // This will make Decode() fail. |
| 898 EXPECT_EQ(NetEq::kOK, | 898 EXPECT_EQ(NetEq::kOK, |
| 899 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 899 neteq_->InsertPacket(rtp_header.header, payload, kReceiveTime)); |
| 900 | 900 |
| 901 // Insert another packet. | 901 // Insert another packet. |
| 902 payload[0] = kSecondPayloadValue; // This will make Decode() successful. | 902 payload[0] = kSecondPayloadValue; // This will make Decode() successful. |
| 903 rtp_header.header.sequenceNumber++; | 903 rtp_header.header.sequenceNumber++; |
| 904 // The second timestamp needs to be at least 30 ms after the first to make | 904 // The second timestamp needs to be at least 30 ms after the first to make |
| 905 // the second packet get decoded. | 905 // the second packet get decoded. |
| 906 rtp_header.header.timestamp += 3 * kPayloadLengthSamples; | 906 rtp_header.header.timestamp += 3 * kPayloadLengthSamples; |
| 907 EXPECT_EQ(NetEq::kOK, | 907 EXPECT_EQ(NetEq::kOK, |
| 908 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 908 neteq_->InsertPacket(rtp_header.header, payload, kReceiveTime)); |
| 909 | 909 |
| 910 AudioFrame output; | 910 AudioFrame output; |
| 911 bool muted; | 911 bool muted; |
| 912 // First call to GetAudio will try to decode the "faulty" packet. | 912 // First call to GetAudio will try to decode the "faulty" packet. |
| 913 // Expect kFail return value... | 913 // Expect kFail return value... |
| 914 EXPECT_EQ(NetEq::kFail, neteq_->GetAudio(&output, &muted)); | 914 EXPECT_EQ(NetEq::kFail, neteq_->GetAudio(&output, &muted)); |
| 915 // ... and kOtherDecoderError error code. | 915 // ... and kOtherDecoderError error code. |
| 916 EXPECT_EQ(NetEq::kOtherDecoderError, neteq_->LastError()); | 916 EXPECT_EQ(NetEq::kOtherDecoderError, neteq_->LastError()); |
| 917 // Output size and number of channels should be correct. | 917 // Output size and number of channels should be correct. |
| 918 const size_t kExpectedOutputSize = 10 * (kSampleRateHz / 1000) * kChannels; | 918 const size_t kExpectedOutputSize = 10 * (kSampleRateHz / 1000) * kChannels; |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 950 rtp_header.header.timestamp = 0x12345678; | 950 rtp_header.header.timestamp = 0x12345678; |
| 951 rtp_header.header.ssrc = 0x87654321; | 951 rtp_header.header.ssrc = 0x87654321; |
| 952 | 952 |
| 953 EXPECT_EQ(NetEq::kOK, neteq_->RegisterPayloadType( | 953 EXPECT_EQ(NetEq::kOK, neteq_->RegisterPayloadType( |
| 954 NetEqDecoder::kDecoderPCM16B, "", kPayloadType)); | 954 NetEqDecoder::kDecoderPCM16B, "", kPayloadType)); |
| 955 | 955 |
| 956 // Insert packets until the buffer flushes. | 956 // Insert packets until the buffer flushes. |
| 957 for (size_t i = 0; i <= config_.max_packets_in_buffer; ++i) { | 957 for (size_t i = 0; i <= config_.max_packets_in_buffer; ++i) { |
| 958 EXPECT_EQ(i, packet_buffer_->NumPacketsInBuffer()); | 958 EXPECT_EQ(i, packet_buffer_->NumPacketsInBuffer()); |
| 959 EXPECT_EQ(NetEq::kOK, | 959 EXPECT_EQ(NetEq::kOK, |
| 960 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 960 neteq_->InsertPacket(rtp_header.header, payload, kReceiveTime)); |
| 961 rtp_header.header.timestamp += | 961 rtp_header.header.timestamp += |
| 962 rtc::checked_cast<uint32_t>(kPayloadLengthSamples); | 962 rtc::checked_cast<uint32_t>(kPayloadLengthSamples); |
| 963 ++rtp_header.header.sequenceNumber; | 963 ++rtp_header.header.sequenceNumber; |
| 964 } | 964 } |
| 965 EXPECT_EQ(1u, packet_buffer_->NumPacketsInBuffer()); | 965 EXPECT_EQ(1u, packet_buffer_->NumPacketsInBuffer()); |
| 966 | 966 |
| 967 // Ask for network statistics. This should not crash. | 967 // Ask for network statistics. This should not crash. |
| 968 NetEqNetworkStatistics stats; | 968 NetEqNetworkStatistics stats; |
| 969 EXPECT_EQ(NetEq::kOK, neteq_->NetworkStatistics(&stats)); | 969 EXPECT_EQ(NetEq::kOK, neteq_->NetworkStatistics(&stats)); |
| 970 } | 970 } |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1006 DoAll(SetArrayArgument<3>(dummy_output, | 1006 DoAll(SetArrayArgument<3>(dummy_output, |
| 1007 dummy_output + kPayloadLengthSamples - 5), | 1007 dummy_output + kPayloadLengthSamples - 5), |
| 1008 SetArgPointee<4>(AudioDecoder::kSpeech), | 1008 SetArgPointee<4>(AudioDecoder::kSpeech), |
| 1009 Return(kPayloadLengthSamples - 5))); | 1009 Return(kPayloadLengthSamples - 5))); |
| 1010 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( | 1010 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
| 1011 &mock_decoder, NetEqDecoder::kDecoderPCM16B, | 1011 &mock_decoder, NetEqDecoder::kDecoderPCM16B, |
| 1012 "dummy name", kPayloadType)); | 1012 "dummy name", kPayloadType)); |
| 1013 | 1013 |
| 1014 // Insert one packet. | 1014 // Insert one packet. |
| 1015 EXPECT_EQ(NetEq::kOK, | 1015 EXPECT_EQ(NetEq::kOK, |
| 1016 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 1016 neteq_->InsertPacket(rtp_header.header, payload, kReceiveTime)); |
| 1017 | 1017 |
| 1018 EXPECT_EQ(5u, neteq_->sync_buffer_for_test()->FutureLength()); | 1018 EXPECT_EQ(5u, neteq_->sync_buffer_for_test()->FutureLength()); |
| 1019 | 1019 |
| 1020 // Pull audio once. | 1020 // Pull audio once. |
| 1021 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); | 1021 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); |
| 1022 AudioFrame output; | 1022 AudioFrame output; |
| 1023 bool muted; | 1023 bool muted; |
| 1024 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); | 1024 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); |
| 1025 ASSERT_EQ(kMaxOutputSize, output.samples_per_channel_); | 1025 ASSERT_EQ(kMaxOutputSize, output.samples_per_channel_); |
| 1026 EXPECT_EQ(1u, output.num_channels_); | 1026 EXPECT_EQ(1u, output.num_channels_); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1102 | 1102 |
| 1103 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( | 1103 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
| 1104 &mock_decoder, NetEqDecoder::kDecoderPCM16B, | 1104 &mock_decoder, NetEqDecoder::kDecoderPCM16B, |
| 1105 "dummy name", kPayloadType)); | 1105 "dummy name", kPayloadType)); |
| 1106 | 1106 |
| 1107 // Insert packets. | 1107 // Insert packets. |
| 1108 for (int i = 0; i < 6; ++i) { | 1108 for (int i = 0; i < 6; ++i) { |
| 1109 rtp_header.header.sequenceNumber += 1; | 1109 rtp_header.header.sequenceNumber += 1; |
| 1110 rtp_header.header.timestamp += kFrameLengthSamples; | 1110 rtp_header.header.timestamp += kFrameLengthSamples; |
| 1111 EXPECT_EQ(NetEq::kOK, | 1111 EXPECT_EQ(NetEq::kOK, |
| 1112 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 1112 neteq_->InsertPacket(rtp_header.header, payload, kReceiveTime)); |
| 1113 } | 1113 } |
| 1114 | 1114 |
| 1115 // Pull audio. | 1115 // Pull audio. |
| 1116 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); | 1116 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); |
| 1117 AudioFrame output; | 1117 AudioFrame output; |
| 1118 bool muted; | 1118 bool muted; |
| 1119 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); | 1119 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); |
| 1120 EXPECT_EQ(kMaxOutputSize, output.samples_per_channel_); | 1120 EXPECT_EQ(kMaxOutputSize, output.samples_per_channel_); |
| 1121 EXPECT_EQ(1u, output.num_channels_); | 1121 EXPECT_EQ(1u, output.num_channels_); |
| 1122 EXPECT_EQ(AudioFrame::kNormalSpeech, output.speech_type_); | 1122 EXPECT_EQ(AudioFrame::kNormalSpeech, output.speech_type_); |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1214 | 1214 |
| 1215 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( | 1215 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
| 1216 &mock_decoder, NetEqDecoder::kDecoderPCM16B, | 1216 &mock_decoder, NetEqDecoder::kDecoderPCM16B, |
| 1217 "dummy name", kPayloadType)); | 1217 "dummy name", kPayloadType)); |
| 1218 | 1218 |
| 1219 // Insert 2 packets. This will make netEq into codec internal CNG mode. | 1219 // Insert 2 packets. This will make netEq into codec internal CNG mode. |
| 1220 for (int i = 0; i < 2; ++i) { | 1220 for (int i = 0; i < 2; ++i) { |
| 1221 rtp_header.header.sequenceNumber += 1; | 1221 rtp_header.header.sequenceNumber += 1; |
| 1222 rtp_header.header.timestamp += kFrameLengthSamples; | 1222 rtp_header.header.timestamp += kFrameLengthSamples; |
| 1223 EXPECT_EQ(NetEq::kOK, | 1223 EXPECT_EQ(NetEq::kOK, |
| 1224 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); | 1224 neteq_->InsertPacket(rtp_header.header, payload, kReceiveTime)); |
| 1225 } | 1225 } |
| 1226 | 1226 |
| 1227 // Pull audio. | 1227 // Pull audio. |
| 1228 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); | 1228 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); |
| 1229 AudioFrame output; | 1229 AudioFrame output; |
| 1230 bool muted; | 1230 bool muted; |
| 1231 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); | 1231 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output, &muted)); |
| 1232 EXPECT_EQ(kMaxOutputSize, output.samples_per_channel_); | 1232 EXPECT_EQ(kMaxOutputSize, output.samples_per_channel_); |
| 1233 EXPECT_EQ(1u, output.num_channels_); | 1233 EXPECT_EQ(1u, output.num_channels_); |
| 1234 EXPECT_EQ(AudioFrame::kCNG, output.speech_type_); | 1234 EXPECT_EQ(AudioFrame::kCNG, output.speech_type_); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1334 } | 1334 } |
| 1335 | 1335 |
| 1336 void InsertPacket(uint32_t timestamp) { | 1336 void InsertPacket(uint32_t timestamp) { |
| 1337 WebRtcRTPHeader rtp_header; | 1337 WebRtcRTPHeader rtp_header; |
| 1338 rtp_header.header.payloadType = kPayloadType; | 1338 rtp_header.header.payloadType = kPayloadType; |
| 1339 rtp_header.header.sequenceNumber = sequence_number_; | 1339 rtp_header.header.sequenceNumber = sequence_number_; |
| 1340 rtp_header.header.timestamp = timestamp; | 1340 rtp_header.header.timestamp = timestamp; |
| 1341 rtp_header.header.ssrc = 15; | 1341 rtp_header.header.ssrc = 15; |
| 1342 const size_t kPayloadLengthBytes = 1; // This can be arbitrary. | 1342 const size_t kPayloadLengthBytes = 1; // This can be arbitrary. |
| 1343 uint8_t payload[kPayloadLengthBytes] = {0}; | 1343 uint8_t payload[kPayloadLengthBytes] = {0}; |
| 1344 EXPECT_EQ(NetEq::kOK, neteq_->InsertPacket(rtp_header, payload, 10)); | 1344 EXPECT_EQ(NetEq::kOK, neteq_->InsertPacket(rtp_header.header, payload, 10)); |
| 1345 sequence_number_++; | 1345 sequence_number_++; |
| 1346 } | 1346 } |
| 1347 | 1347 |
| 1348 void Register120msCodec(AudioDecoder::SpeechType speech_type) { | 1348 void Register120msCodec(AudioDecoder::SpeechType speech_type) { |
| 1349 decoder_.reset(new Decoder120ms(kSamplingFreq_, speech_type)); | 1349 decoder_.reset(new Decoder120ms(kSamplingFreq_, speech_type)); |
| 1350 ASSERT_EQ(2u, decoder_->Channels()); | 1350 ASSERT_EQ(2u, decoder_->Channels()); |
| 1351 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( | 1351 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
| 1352 decoder_.get(), NetEqDecoder::kDecoderOpus_2ch, | 1352 decoder_.get(), NetEqDecoder::kDecoderOpus_2ch, |
| 1353 "120ms codec", kPayloadType)); | 1353 "120ms codec", kPayloadType)); |
| 1354 } | 1354 } |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1489 EXPECT_CALL(*mock_delay_manager_, BufferLimits(_, _)) | 1489 EXPECT_CALL(*mock_delay_manager_, BufferLimits(_, _)) |
| 1490 .Times(1) | 1490 .Times(1) |
| 1491 .WillOnce(DoAll(SetArgPointee<0>(1), SetArgPointee<1>(2))); | 1491 .WillOnce(DoAll(SetArgPointee<0>(1), SetArgPointee<1>(2))); |
| 1492 | 1492 |
| 1493 bool muted; | 1493 bool muted; |
| 1494 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_, &muted)); | 1494 EXPECT_EQ(NetEq::kOK, neteq_->GetAudio(&output_, &muted)); |
| 1495 EXPECT_EQ(kAccelerate, neteq_->last_operation_for_test()); | 1495 EXPECT_EQ(kAccelerate, neteq_->last_operation_for_test()); |
| 1496 } | 1496 } |
| 1497 | 1497 |
| 1498 }// namespace webrtc | 1498 }// namespace webrtc |
| OLD | NEW |