| 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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 352 EXPECT_CALL(*mock_delay_manager_, SetPacketAudioLength(30)) | 352 EXPECT_CALL(*mock_delay_manager_, SetPacketAudioLength(30)) |
| 353 .WillOnce(Return(0)); | 353 .WillOnce(Return(0)); |
| 354 } | 354 } |
| 355 | 355 |
| 356 // Expectations for payload splitter. | 356 // Expectations for payload splitter. |
| 357 EXPECT_CALL(*mock_payload_splitter_, SplitAudio(_, _)) | 357 EXPECT_CALL(*mock_payload_splitter_, SplitAudio(_, _)) |
| 358 .Times(2) | 358 .Times(2) |
| 359 .WillRepeatedly(Return(PayloadSplitter::kOK)); | 359 .WillRepeatedly(Return(PayloadSplitter::kOK)); |
| 360 | 360 |
| 361 // Insert first packet. | 361 // Insert first packet. |
| 362 neteq_->InsertPacket(rtp_header, payload, kPayloadLength, kFirstReceiveTime); | 362 neteq_->InsertPacket(rtp_header, payload, kFirstReceiveTime); |
| 363 | 363 |
| 364 // Insert second packet. | 364 // Insert second packet. |
| 365 rtp_header.header.timestamp += 160; | 365 rtp_header.header.timestamp += 160; |
| 366 rtp_header.header.sequenceNumber += 1; | 366 rtp_header.header.sequenceNumber += 1; |
| 367 neteq_->InsertPacket(rtp_header, payload, kPayloadLength, | 367 neteq_->InsertPacket(rtp_header, payload, kFirstReceiveTime + 155); |
| 368 kFirstReceiveTime + 155); | |
| 369 } | 368 } |
| 370 | 369 |
| 371 TEST_F(NetEqImplTest, InsertPacketsUntilBufferIsFull) { | 370 TEST_F(NetEqImplTest, InsertPacketsUntilBufferIsFull) { |
| 372 UseNoMocks(); | 371 UseNoMocks(); |
| 373 CreateInstance(); | 372 CreateInstance(); |
| 374 | 373 |
| 375 const int kPayloadLengthSamples = 80; | 374 const int kPayloadLengthSamples = 80; |
| 376 const size_t kPayloadLengthBytes = 2 * kPayloadLengthSamples; // PCM 16-bit. | 375 const size_t kPayloadLengthBytes = 2 * kPayloadLengthSamples; // PCM 16-bit. |
| 377 const uint8_t kPayloadType = 17; // Just an arbitrary number. | 376 const uint8_t kPayloadType = 17; // Just an arbitrary number. |
| 378 const uint32_t kReceiveTime = 17; // Value doesn't matter for this test. | 377 const uint32_t kReceiveTime = 17; // Value doesn't matter for this test. |
| 379 uint8_t payload[kPayloadLengthBytes] = {0}; | 378 uint8_t payload[kPayloadLengthBytes] = {0}; |
| 380 WebRtcRTPHeader rtp_header; | 379 WebRtcRTPHeader rtp_header; |
| 381 rtp_header.header.payloadType = kPayloadType; | 380 rtp_header.header.payloadType = kPayloadType; |
| 382 rtp_header.header.sequenceNumber = 0x1234; | 381 rtp_header.header.sequenceNumber = 0x1234; |
| 383 rtp_header.header.timestamp = 0x12345678; | 382 rtp_header.header.timestamp = 0x12345678; |
| 384 rtp_header.header.ssrc = 0x87654321; | 383 rtp_header.header.ssrc = 0x87654321; |
| 385 | 384 |
| 386 EXPECT_EQ(NetEq::kOK, neteq_->RegisterPayloadType( | 385 EXPECT_EQ(NetEq::kOK, neteq_->RegisterPayloadType( |
| 387 NetEqDecoder::kDecoderPCM16B, kPayloadType)); | 386 NetEqDecoder::kDecoderPCM16B, kPayloadType)); |
| 388 | 387 |
| 389 // Insert packets. The buffer should not flush. | 388 // Insert packets. The buffer should not flush. |
| 390 for (size_t i = 1; i <= config_.max_packets_in_buffer; ++i) { | 389 for (size_t i = 1; i <= config_.max_packets_in_buffer; ++i) { |
| 391 EXPECT_EQ(NetEq::kOK, | 390 EXPECT_EQ(NetEq::kOK, |
| 392 neteq_->InsertPacket( | 391 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
| 393 rtp_header, payload, kPayloadLengthBytes, kReceiveTime)); | |
| 394 rtp_header.header.timestamp += kPayloadLengthSamples; | 392 rtp_header.header.timestamp += kPayloadLengthSamples; |
| 395 rtp_header.header.sequenceNumber += 1; | 393 rtp_header.header.sequenceNumber += 1; |
| 396 EXPECT_EQ(i, packet_buffer_->NumPacketsInBuffer()); | 394 EXPECT_EQ(i, packet_buffer_->NumPacketsInBuffer()); |
| 397 } | 395 } |
| 398 | 396 |
| 399 // Insert one more packet and make sure the buffer got flushed. That is, it | 397 // Insert one more packet and make sure the buffer got flushed. That is, it |
| 400 // should only hold one single packet. | 398 // should only hold one single packet. |
| 401 EXPECT_EQ(NetEq::kOK, | 399 EXPECT_EQ(NetEq::kOK, |
| 402 neteq_->InsertPacket( | 400 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
| 403 rtp_header, payload, kPayloadLengthBytes, kReceiveTime)); | |
| 404 EXPECT_EQ(1u, packet_buffer_->NumPacketsInBuffer()); | 401 EXPECT_EQ(1u, packet_buffer_->NumPacketsInBuffer()); |
| 405 const RTPHeader* test_header = packet_buffer_->NextRtpHeader(); | 402 const RTPHeader* test_header = packet_buffer_->NextRtpHeader(); |
| 406 EXPECT_EQ(rtp_header.header.timestamp, test_header->timestamp); | 403 EXPECT_EQ(rtp_header.header.timestamp, test_header->timestamp); |
| 407 EXPECT_EQ(rtp_header.header.sequenceNumber, test_header->sequenceNumber); | 404 EXPECT_EQ(rtp_header.header.sequenceNumber, test_header->sequenceNumber); |
| 408 } | 405 } |
| 409 | 406 |
| 410 // This test verifies that timestamps propagate from the incoming packets | 407 // This test verifies that timestamps propagate from the incoming packets |
| 411 // through to the sync buffer and to the playout timestamp. | 408 // through to the sync buffer and to the playout timestamp. |
| 412 TEST_F(NetEqImplTest, VerifyTimestampPropagation) { | 409 TEST_F(NetEqImplTest, VerifyTimestampPropagation) { |
| 413 UseNoMocks(); | 410 UseNoMocks(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 456 private: | 453 private: |
| 457 int16_t next_value_; | 454 int16_t next_value_; |
| 458 } decoder_; | 455 } decoder_; |
| 459 | 456 |
| 460 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( | 457 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
| 461 &decoder_, NetEqDecoder::kDecoderPCM16B, | 458 &decoder_, NetEqDecoder::kDecoderPCM16B, |
| 462 kPayloadType, kSampleRateHz)); | 459 kPayloadType, kSampleRateHz)); |
| 463 | 460 |
| 464 // Insert one packet. | 461 // Insert one packet. |
| 465 EXPECT_EQ(NetEq::kOK, | 462 EXPECT_EQ(NetEq::kOK, |
| 466 neteq_->InsertPacket( | 463 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
| 467 rtp_header, payload, kPayloadLengthBytes, kReceiveTime)); | |
| 468 | 464 |
| 469 // Pull audio once. | 465 // Pull audio once. |
| 470 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); | 466 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); |
| 471 int16_t output[kMaxOutputSize]; | 467 int16_t output[kMaxOutputSize]; |
| 472 size_t samples_per_channel; | 468 size_t samples_per_channel; |
| 473 int num_channels; | 469 int num_channels; |
| 474 NetEqOutputType type; | 470 NetEqOutputType type; |
| 475 EXPECT_EQ( | 471 EXPECT_EQ( |
| 476 NetEq::kOK, | 472 NetEq::kOK, |
| 477 neteq_->GetAudio( | 473 neteq_->GetAudio( |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 536 .WillOnce(DoAll(SetArrayArgument<4>(dummy_output, | 532 .WillOnce(DoAll(SetArrayArgument<4>(dummy_output, |
| 537 dummy_output + kPayloadLengthSamples), | 533 dummy_output + kPayloadLengthSamples), |
| 538 SetArgPointee<5>(AudioDecoder::kSpeech), | 534 SetArgPointee<5>(AudioDecoder::kSpeech), |
| 539 Return(kPayloadLengthSamples))); | 535 Return(kPayloadLengthSamples))); |
| 540 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( | 536 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
| 541 &mock_decoder, NetEqDecoder::kDecoderPCM16B, | 537 &mock_decoder, NetEqDecoder::kDecoderPCM16B, |
| 542 kPayloadType, kSampleRateHz)); | 538 kPayloadType, kSampleRateHz)); |
| 543 | 539 |
| 544 // Insert one packet. | 540 // Insert one packet. |
| 545 EXPECT_EQ(NetEq::kOK, | 541 EXPECT_EQ(NetEq::kOK, |
| 546 neteq_->InsertPacket( | 542 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
| 547 rtp_header, payload, kPayloadLengthBytes, kReceiveTime)); | |
| 548 | 543 |
| 549 // Pull audio once. | 544 // Pull audio once. |
| 550 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); | 545 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); |
| 551 int16_t output[kMaxOutputSize]; | 546 int16_t output[kMaxOutputSize]; |
| 552 size_t samples_per_channel; | 547 size_t samples_per_channel; |
| 553 int num_channels; | 548 int num_channels; |
| 554 NetEqOutputType type; | 549 NetEqOutputType type; |
| 555 EXPECT_EQ( | 550 EXPECT_EQ( |
| 556 NetEq::kOK, | 551 NetEq::kOK, |
| 557 neteq_->GetAudio( | 552 neteq_->GetAudio( |
| 558 kMaxOutputSize, output, &samples_per_channel, &num_channels, &type)); | 553 kMaxOutputSize, output, &samples_per_channel, &num_channels, &type)); |
| 559 ASSERT_EQ(kMaxOutputSize, samples_per_channel); | 554 ASSERT_EQ(kMaxOutputSize, samples_per_channel); |
| 560 EXPECT_EQ(1, num_channels); | 555 EXPECT_EQ(1, num_channels); |
| 561 EXPECT_EQ(kOutputNormal, type); | 556 EXPECT_EQ(kOutputNormal, type); |
| 562 | 557 |
| 563 // Insert two more packets. The first one is out of order, and is already too | 558 // Insert two more packets. The first one is out of order, and is already too |
| 564 // old, the second one is the expected next packet. | 559 // old, the second one is the expected next packet. |
| 565 rtp_header.header.sequenceNumber -= 1; | 560 rtp_header.header.sequenceNumber -= 1; |
| 566 rtp_header.header.timestamp -= kPayloadLengthSamples; | 561 rtp_header.header.timestamp -= kPayloadLengthSamples; |
| 567 payload[0] = 1; | 562 payload[0] = 1; |
| 568 EXPECT_EQ(NetEq::kOK, | 563 EXPECT_EQ(NetEq::kOK, |
| 569 neteq_->InsertPacket( | 564 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
| 570 rtp_header, payload, kPayloadLengthBytes, kReceiveTime)); | |
| 571 rtp_header.header.sequenceNumber += 2; | 565 rtp_header.header.sequenceNumber += 2; |
| 572 rtp_header.header.timestamp += 2 * kPayloadLengthSamples; | 566 rtp_header.header.timestamp += 2 * kPayloadLengthSamples; |
| 573 payload[0] = 2; | 567 payload[0] = 2; |
| 574 EXPECT_EQ(NetEq::kOK, | 568 EXPECT_EQ(NetEq::kOK, |
| 575 neteq_->InsertPacket( | 569 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
| 576 rtp_header, payload, kPayloadLengthBytes, kReceiveTime)); | |
| 577 | 570 |
| 578 // Expect only the second packet to be decoded (the one with "2" as the first | 571 // Expect only the second packet to be decoded (the one with "2" as the first |
| 579 // payload byte). | 572 // payload byte). |
| 580 EXPECT_CALL(mock_decoder, | 573 EXPECT_CALL(mock_decoder, |
| 581 Decode(Pointee(2), kPayloadLengthBytes, kSampleRateHz, _, _, _)) | 574 Decode(Pointee(2), kPayloadLengthBytes, kSampleRateHz, _, _, _)) |
| 582 .WillOnce(DoAll(SetArrayArgument<4>(dummy_output, | 575 .WillOnce(DoAll(SetArrayArgument<4>(dummy_output, |
| 583 dummy_output + kPayloadLengthSamples), | 576 dummy_output + kPayloadLengthSamples), |
| 584 SetArgPointee<5>(AudioDecoder::kSpeech), | 577 SetArgPointee<5>(AudioDecoder::kSpeech), |
| 585 Return(kPayloadLengthSamples))); | 578 Return(kPayloadLengthSamples))); |
| 586 | 579 |
| (...skipping 28 matching lines...) Expand all Loading... |
| 615 uint8_t payload[kPayloadLengthBytes] = {0}; | 608 uint8_t payload[kPayloadLengthBytes] = {0}; |
| 616 WebRtcRTPHeader rtp_header; | 609 WebRtcRTPHeader rtp_header; |
| 617 rtp_header.header.payloadType = kPayloadType; | 610 rtp_header.header.payloadType = kPayloadType; |
| 618 rtp_header.header.sequenceNumber = 0x1234; | 611 rtp_header.header.sequenceNumber = 0x1234; |
| 619 rtp_header.header.timestamp = 0x12345678; | 612 rtp_header.header.timestamp = 0x12345678; |
| 620 rtp_header.header.ssrc = 0x87654321; | 613 rtp_header.header.ssrc = 0x87654321; |
| 621 | 614 |
| 622 // Insert one packet. Note that we have not registered any payload type, so | 615 // Insert one packet. Note that we have not registered any payload type, so |
| 623 // this packet will be rejected. | 616 // this packet will be rejected. |
| 624 EXPECT_EQ(NetEq::kFail, | 617 EXPECT_EQ(NetEq::kFail, |
| 625 neteq_->InsertPacket(rtp_header, payload, kPayloadLengthBytes, | 618 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
| 626 kReceiveTime)); | |
| 627 EXPECT_EQ(NetEq::kUnknownRtpPayloadType, neteq_->LastError()); | 619 EXPECT_EQ(NetEq::kUnknownRtpPayloadType, neteq_->LastError()); |
| 628 | 620 |
| 629 // Pull audio once. | 621 // Pull audio once. |
| 630 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); | 622 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); |
| 631 int16_t output[kMaxOutputSize]; | 623 int16_t output[kMaxOutputSize]; |
| 632 size_t samples_per_channel; | 624 size_t samples_per_channel; |
| 633 int num_channels; | 625 int num_channels; |
| 634 NetEqOutputType type; | 626 NetEqOutputType type; |
| 635 EXPECT_EQ(NetEq::kOK, | 627 EXPECT_EQ(NetEq::kOK, |
| 636 neteq_->GetAudio(kMaxOutputSize, output, &samples_per_channel, | 628 neteq_->GetAudio(kMaxOutputSize, output, &samples_per_channel, |
| 637 &num_channels, &type)); | 629 &num_channels, &type)); |
| 638 ASSERT_LE(samples_per_channel, kMaxOutputSize); | 630 ASSERT_LE(samples_per_channel, kMaxOutputSize); |
| 639 EXPECT_EQ(kMaxOutputSize, samples_per_channel); | 631 EXPECT_EQ(kMaxOutputSize, samples_per_channel); |
| 640 EXPECT_EQ(1, num_channels); | 632 EXPECT_EQ(1, num_channels); |
| 641 EXPECT_EQ(kOutputPLC, type); | 633 EXPECT_EQ(kOutputPLC, type); |
| 642 | 634 |
| 643 // Register the payload type. | 635 // Register the payload type. |
| 644 EXPECT_EQ(NetEq::kOK, neteq_->RegisterPayloadType( | 636 EXPECT_EQ(NetEq::kOK, neteq_->RegisterPayloadType( |
| 645 NetEqDecoder::kDecoderPCM16B, kPayloadType)); | 637 NetEqDecoder::kDecoderPCM16B, kPayloadType)); |
| 646 | 638 |
| 647 // Insert 10 packets. | 639 // Insert 10 packets. |
| 648 for (size_t i = 0; i < 10; ++i) { | 640 for (size_t i = 0; i < 10; ++i) { |
| 649 rtp_header.header.sequenceNumber++; | 641 rtp_header.header.sequenceNumber++; |
| 650 rtp_header.header.timestamp += kPayloadLengthSamples; | 642 rtp_header.header.timestamp += kPayloadLengthSamples; |
| 651 EXPECT_EQ(NetEq::kOK, | 643 EXPECT_EQ(NetEq::kOK, |
| 652 neteq_->InsertPacket(rtp_header, payload, kPayloadLengthBytes, | 644 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
| 653 kReceiveTime)); | |
| 654 EXPECT_EQ(i + 1, packet_buffer_->NumPacketsInBuffer()); | 645 EXPECT_EQ(i + 1, packet_buffer_->NumPacketsInBuffer()); |
| 655 } | 646 } |
| 656 | 647 |
| 657 // Pull audio repeatedly and make sure we get normal output, that is not PLC. | 648 // Pull audio repeatedly and make sure we get normal output, that is not PLC. |
| 658 for (size_t i = 0; i < 3; ++i) { | 649 for (size_t i = 0; i < 3; ++i) { |
| 659 EXPECT_EQ(NetEq::kOK, | 650 EXPECT_EQ(NetEq::kOK, |
| 660 neteq_->GetAudio(kMaxOutputSize, output, &samples_per_channel, | 651 neteq_->GetAudio(kMaxOutputSize, output, &samples_per_channel, |
| 661 &num_channels, &type)); | 652 &num_channels, &type)); |
| 662 ASSERT_LE(samples_per_channel, kMaxOutputSize); | 653 ASSERT_LE(samples_per_channel, kMaxOutputSize); |
| 663 EXPECT_EQ(kMaxOutputSize, samples_per_channel); | 654 EXPECT_EQ(kMaxOutputSize, samples_per_channel); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 723 dummy_output + kPayloadLengthSamples), | 714 dummy_output + kPayloadLengthSamples), |
| 724 SetArgPointee<5>(AudioDecoder::kSpeech), | 715 SetArgPointee<5>(AudioDecoder::kSpeech), |
| 725 Return(kPayloadLengthSamples))); | 716 Return(kPayloadLengthSamples))); |
| 726 | 717 |
| 727 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( | 718 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
| 728 &mock_decoder, NetEqDecoder::kDecoderOpus, | 719 &mock_decoder, NetEqDecoder::kDecoderOpus, |
| 729 kPayloadType, kSampleRateKhz * 1000)); | 720 kPayloadType, kSampleRateKhz * 1000)); |
| 730 | 721 |
| 731 // Insert one packet (decoder will return speech). | 722 // Insert one packet (decoder will return speech). |
| 732 EXPECT_EQ(NetEq::kOK, | 723 EXPECT_EQ(NetEq::kOK, |
| 733 neteq_->InsertPacket( | 724 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
| 734 rtp_header, payload, kPayloadLengthBytes, kReceiveTime)); | |
| 735 | 725 |
| 736 // Insert second packet (decoder will return CNG). | 726 // Insert second packet (decoder will return CNG). |
| 737 payload[0] = 1; | 727 payload[0] = 1; |
| 738 rtp_header.header.sequenceNumber++; | 728 rtp_header.header.sequenceNumber++; |
| 739 rtp_header.header.timestamp += kPayloadLengthSamples; | 729 rtp_header.header.timestamp += kPayloadLengthSamples; |
| 740 EXPECT_EQ(NetEq::kOK, | 730 EXPECT_EQ(NetEq::kOK, |
| 741 neteq_->InsertPacket( | 731 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
| 742 rtp_header, payload, kPayloadLengthBytes, kReceiveTime)); | |
| 743 | 732 |
| 744 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateKhz); | 733 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateKhz); |
| 745 int16_t output[kMaxOutputSize]; | 734 int16_t output[kMaxOutputSize]; |
| 746 size_t samples_per_channel; | 735 size_t samples_per_channel; |
| 747 int num_channels; | 736 int num_channels; |
| 748 uint32_t timestamp; | 737 uint32_t timestamp; |
| 749 uint32_t last_timestamp; | 738 uint32_t last_timestamp; |
| 750 NetEqOutputType type; | 739 NetEqOutputType type; |
| 751 NetEqOutputType expected_type[8] = { | 740 NetEqOutputType expected_type[8] = { |
| 752 kOutputNormal, kOutputNormal, | 741 kOutputNormal, kOutputNormal, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 778 EXPECT_TRUE(neteq_->GetPlayoutTimestamp(×tamp)); | 767 EXPECT_TRUE(neteq_->GetPlayoutTimestamp(×tamp)); |
| 779 EXPECT_EQ(timestamp, last_timestamp + expected_timestamp_increment[i]); | 768 EXPECT_EQ(timestamp, last_timestamp + expected_timestamp_increment[i]); |
| 780 last_timestamp = timestamp; | 769 last_timestamp = timestamp; |
| 781 } | 770 } |
| 782 | 771 |
| 783 // Insert third packet, which leaves a gap from last packet. | 772 // Insert third packet, which leaves a gap from last packet. |
| 784 payload[0] = 2; | 773 payload[0] = 2; |
| 785 rtp_header.header.sequenceNumber += 2; | 774 rtp_header.header.sequenceNumber += 2; |
| 786 rtp_header.header.timestamp += 2 * kPayloadLengthSamples; | 775 rtp_header.header.timestamp += 2 * kPayloadLengthSamples; |
| 787 EXPECT_EQ(NetEq::kOK, | 776 EXPECT_EQ(NetEq::kOK, |
| 788 neteq_->InsertPacket( | 777 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
| 789 rtp_header, payload, kPayloadLengthBytes, kReceiveTime)); | |
| 790 | 778 |
| 791 for (size_t i = 6; i < 8; ++i) { | 779 for (size_t i = 6; i < 8; ++i) { |
| 792 ASSERT_EQ(kMaxOutputSize, samples_per_channel); | 780 ASSERT_EQ(kMaxOutputSize, samples_per_channel); |
| 793 EXPECT_EQ(1, num_channels); | 781 EXPECT_EQ(1, num_channels); |
| 794 EXPECT_EQ(expected_type[i - 1], type); | 782 EXPECT_EQ(expected_type[i - 1], type); |
| 795 EXPECT_EQ(NetEq::kOK, | 783 EXPECT_EQ(NetEq::kOK, |
| 796 neteq_->GetAudio(kMaxOutputSize, output, &samples_per_channel, | 784 neteq_->GetAudio(kMaxOutputSize, output, &samples_per_channel, |
| 797 &num_channels, &type)); | 785 &num_channels, &type)); |
| 798 EXPECT_TRUE(neteq_->GetPlayoutTimestamp(×tamp)); | 786 EXPECT_TRUE(neteq_->GetPlayoutTimestamp(×tamp)); |
| 799 EXPECT_EQ(timestamp, last_timestamp + expected_timestamp_increment[i]); | 787 EXPECT_EQ(timestamp, last_timestamp + expected_timestamp_increment[i]); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 864 .Times(AtLeast(1)) | 852 .Times(AtLeast(1)) |
| 865 .WillRepeatedly(Return(kNetEqMaxFrameSize)); | 853 .WillRepeatedly(Return(kNetEqMaxFrameSize)); |
| 866 | 854 |
| 867 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( | 855 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
| 868 &decoder_, NetEqDecoder::kDecoderPCM16B, | 856 &decoder_, NetEqDecoder::kDecoderPCM16B, |
| 869 kPayloadType, kSampleRateHz)); | 857 kPayloadType, kSampleRateHz)); |
| 870 | 858 |
| 871 // Insert one packet. | 859 // Insert one packet. |
| 872 payload[0] = kFirstPayloadValue; // This will make Decode() fail. | 860 payload[0] = kFirstPayloadValue; // This will make Decode() fail. |
| 873 EXPECT_EQ(NetEq::kOK, | 861 EXPECT_EQ(NetEq::kOK, |
| 874 neteq_->InsertPacket( | 862 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
| 875 rtp_header, payload, kPayloadLengthBytes, kReceiveTime)); | |
| 876 | 863 |
| 877 // Insert another packet. | 864 // Insert another packet. |
| 878 payload[0] = kSecondPayloadValue; // This will make Decode() successful. | 865 payload[0] = kSecondPayloadValue; // This will make Decode() successful. |
| 879 rtp_header.header.sequenceNumber++; | 866 rtp_header.header.sequenceNumber++; |
| 880 // 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 |
| 881 // the second packet get decoded. | 868 // the second packet get decoded. |
| 882 rtp_header.header.timestamp += 3 * kPayloadLengthSamples; | 869 rtp_header.header.timestamp += 3 * kPayloadLengthSamples; |
| 883 EXPECT_EQ(NetEq::kOK, | 870 EXPECT_EQ(NetEq::kOK, |
| 884 neteq_->InsertPacket( | 871 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
| 885 rtp_header, payload, kPayloadLengthBytes, kReceiveTime)); | |
| 886 | 872 |
| 887 const size_t kMaxOutputSize = | 873 const size_t kMaxOutputSize = |
| 888 static_cast<size_t>(10 * kSampleRateHz / 1000 * kChannels); | 874 static_cast<size_t>(10 * kSampleRateHz / 1000 * kChannels); |
| 889 int16_t output[kMaxOutputSize]; | 875 int16_t output[kMaxOutputSize]; |
| 890 size_t samples_per_channel; | 876 size_t samples_per_channel; |
| 891 int num_channels; | 877 int num_channels; |
| 892 NetEqOutputType type; | 878 NetEqOutputType type; |
| 893 | 879 |
| 894 EXPECT_EQ(NetEq::kFail, neteq_->GetAudio(kMaxOutputSize, output, | 880 EXPECT_EQ(NetEq::kFail, neteq_->GetAudio(kMaxOutputSize, output, |
| 895 &samples_per_channel, &num_channels, | 881 &samples_per_channel, &num_channels, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 925 rtp_header.header.timestamp = 0x12345678; | 911 rtp_header.header.timestamp = 0x12345678; |
| 926 rtp_header.header.ssrc = 0x87654321; | 912 rtp_header.header.ssrc = 0x87654321; |
| 927 | 913 |
| 928 EXPECT_EQ(NetEq::kOK, neteq_->RegisterPayloadType( | 914 EXPECT_EQ(NetEq::kOK, neteq_->RegisterPayloadType( |
| 929 NetEqDecoder::kDecoderPCM16B, kPayloadType)); | 915 NetEqDecoder::kDecoderPCM16B, kPayloadType)); |
| 930 | 916 |
| 931 // Insert packets until the buffer flushes. | 917 // Insert packets until the buffer flushes. |
| 932 for (size_t i = 0; i <= config_.max_packets_in_buffer; ++i) { | 918 for (size_t i = 0; i <= config_.max_packets_in_buffer; ++i) { |
| 933 EXPECT_EQ(i, packet_buffer_->NumPacketsInBuffer()); | 919 EXPECT_EQ(i, packet_buffer_->NumPacketsInBuffer()); |
| 934 EXPECT_EQ(NetEq::kOK, | 920 EXPECT_EQ(NetEq::kOK, |
| 935 neteq_->InsertPacket(rtp_header, payload, kPayloadLengthBytes, | 921 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
| 936 kReceiveTime)); | |
| 937 rtp_header.header.timestamp += | 922 rtp_header.header.timestamp += |
| 938 rtc::checked_cast<uint32_t>(kPayloadLengthSamples); | 923 rtc::checked_cast<uint32_t>(kPayloadLengthSamples); |
| 939 ++rtp_header.header.sequenceNumber; | 924 ++rtp_header.header.sequenceNumber; |
| 940 } | 925 } |
| 941 EXPECT_EQ(1u, packet_buffer_->NumPacketsInBuffer()); | 926 EXPECT_EQ(1u, packet_buffer_->NumPacketsInBuffer()); |
| 942 | 927 |
| 943 // Ask for network statistics. This should not crash. | 928 // Ask for network statistics. This should not crash. |
| 944 NetEqNetworkStatistics stats; | 929 NetEqNetworkStatistics stats; |
| 945 EXPECT_EQ(NetEq::kOK, neteq_->NetworkStatistics(&stats)); | 930 EXPECT_EQ(NetEq::kOK, neteq_->NetworkStatistics(&stats)); |
| 946 } | 931 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 980 DoAll(SetArrayArgument<4>(dummy_output, | 965 DoAll(SetArrayArgument<4>(dummy_output, |
| 981 dummy_output + kPayloadLengthSamples - 5), | 966 dummy_output + kPayloadLengthSamples - 5), |
| 982 SetArgPointee<5>(AudioDecoder::kSpeech), | 967 SetArgPointee<5>(AudioDecoder::kSpeech), |
| 983 Return(kPayloadLengthSamples - 5))); | 968 Return(kPayloadLengthSamples - 5))); |
| 984 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( | 969 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
| 985 &mock_decoder, NetEqDecoder::kDecoderPCM16B, | 970 &mock_decoder, NetEqDecoder::kDecoderPCM16B, |
| 986 kPayloadType, kSampleRateHz)); | 971 kPayloadType, kSampleRateHz)); |
| 987 | 972 |
| 988 // Insert one packet. | 973 // Insert one packet. |
| 989 EXPECT_EQ(NetEq::kOK, | 974 EXPECT_EQ(NetEq::kOK, |
| 990 neteq_->InsertPacket(rtp_header, payload, kPayloadLengthBytes, | 975 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
| 991 kReceiveTime)); | |
| 992 | 976 |
| 993 EXPECT_EQ(5u, neteq_->sync_buffer_for_test()->FutureLength()); | 977 EXPECT_EQ(5u, neteq_->sync_buffer_for_test()->FutureLength()); |
| 994 | 978 |
| 995 // Pull audio once. | 979 // Pull audio once. |
| 996 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); | 980 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); |
| 997 int16_t output[kMaxOutputSize]; | 981 int16_t output[kMaxOutputSize]; |
| 998 size_t samples_per_channel; | 982 size_t samples_per_channel; |
| 999 int num_channels; | 983 int num_channels; |
| 1000 NetEqOutputType type; | 984 NetEqOutputType type; |
| 1001 EXPECT_EQ(NetEq::kOK, | 985 EXPECT_EQ(NetEq::kOK, |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1079 | 1063 |
| 1080 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( | 1064 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
| 1081 &mock_decoder, NetEqDecoder::kDecoderPCM16B, | 1065 &mock_decoder, NetEqDecoder::kDecoderPCM16B, |
| 1082 kPayloadType, kSampleRateHz)); | 1066 kPayloadType, kSampleRateHz)); |
| 1083 | 1067 |
| 1084 // Insert packets. | 1068 // Insert packets. |
| 1085 for (int i = 0; i < 6; ++i) { | 1069 for (int i = 0; i < 6; ++i) { |
| 1086 rtp_header.header.sequenceNumber += 1; | 1070 rtp_header.header.sequenceNumber += 1; |
| 1087 rtp_header.header.timestamp += kFrameLengthSamples; | 1071 rtp_header.header.timestamp += kFrameLengthSamples; |
| 1088 EXPECT_EQ(NetEq::kOK, | 1072 EXPECT_EQ(NetEq::kOK, |
| 1089 neteq_->InsertPacket(rtp_header, payload, kPayloadLengthBytes, | 1073 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
| 1090 kReceiveTime)); | |
| 1091 } | 1074 } |
| 1092 | 1075 |
| 1093 // Pull audio. | 1076 // Pull audio. |
| 1094 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); | 1077 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); |
| 1095 int16_t output[kMaxOutputSize]; | 1078 int16_t output[kMaxOutputSize]; |
| 1096 size_t samples_per_channel; | 1079 size_t samples_per_channel; |
| 1097 int num_channels; | 1080 int num_channels; |
| 1098 NetEqOutputType type; | 1081 NetEqOutputType type; |
| 1099 EXPECT_EQ(NetEq::kOK, | 1082 EXPECT_EQ(NetEq::kOK, |
| 1100 neteq_->GetAudio(kMaxOutputSize, output, &samples_per_channel, | 1083 neteq_->GetAudio(kMaxOutputSize, output, &samples_per_channel, |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1201 | 1184 |
| 1202 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( | 1185 EXPECT_EQ(NetEq::kOK, neteq_->RegisterExternalDecoder( |
| 1203 &mock_decoder, NetEqDecoder::kDecoderPCM16B, | 1186 &mock_decoder, NetEqDecoder::kDecoderPCM16B, |
| 1204 kPayloadType, kSampleRateHz)); | 1187 kPayloadType, kSampleRateHz)); |
| 1205 | 1188 |
| 1206 // 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. |
| 1207 for (int i = 0; i < 2; ++i) { | 1190 for (int i = 0; i < 2; ++i) { |
| 1208 rtp_header.header.sequenceNumber += 1; | 1191 rtp_header.header.sequenceNumber += 1; |
| 1209 rtp_header.header.timestamp += kFrameLengthSamples; | 1192 rtp_header.header.timestamp += kFrameLengthSamples; |
| 1210 EXPECT_EQ(NetEq::kOK, | 1193 EXPECT_EQ(NetEq::kOK, |
| 1211 neteq_->InsertPacket(rtp_header, payload, kPayloadLengthBytes, | 1194 neteq_->InsertPacket(rtp_header, payload, kReceiveTime)); |
| 1212 kReceiveTime)); | |
| 1213 } | 1195 } |
| 1214 | 1196 |
| 1215 // Pull audio. | 1197 // Pull audio. |
| 1216 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); | 1198 const size_t kMaxOutputSize = static_cast<size_t>(10 * kSampleRateHz / 1000); |
| 1217 int16_t output[kMaxOutputSize]; | 1199 int16_t output[kMaxOutputSize]; |
| 1218 size_t samples_per_channel; | 1200 size_t samples_per_channel; |
| 1219 int num_channels; | 1201 int num_channels; |
| 1220 NetEqOutputType type; | 1202 NetEqOutputType type; |
| 1221 EXPECT_EQ(NetEq::kOK, | 1203 EXPECT_EQ(NetEq::kOK, |
| 1222 neteq_->GetAudio(kMaxOutputSize, output, &samples_per_channel, | 1204 neteq_->GetAudio(kMaxOutputSize, output, &samples_per_channel, |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1242 neteq_->GetAudio(kMaxOutputSize, output, &samples_per_channel, | 1224 neteq_->GetAudio(kMaxOutputSize, output, &samples_per_channel, |
| 1243 &num_channels, &type)); | 1225 &num_channels, &type)); |
| 1244 EXPECT_EQ(kMaxOutputSize, samples_per_channel); | 1226 EXPECT_EQ(kMaxOutputSize, samples_per_channel); |
| 1245 EXPECT_EQ(1, num_channels); | 1227 EXPECT_EQ(1, num_channels); |
| 1246 EXPECT_EQ(kOutputCNG, type); | 1228 EXPECT_EQ(kOutputCNG, type); |
| 1247 | 1229 |
| 1248 EXPECT_CALL(mock_decoder, Die()); | 1230 EXPECT_CALL(mock_decoder, Die()); |
| 1249 } | 1231 } |
| 1250 | 1232 |
| 1251 }// namespace webrtc | 1233 }// namespace webrtc |
| OLD | NEW |