Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(430)

Side by Side Diff: webrtc/modules/video_coding/jitter_buffer_unittest.cc

Issue 2123913002: Remove old WebRTC-NewVideoJitterBuffer used for testing the NackModule. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/modules/video_coding/jitter_buffer.cc ('k') | webrtc/modules/video_coding/receiver.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2011 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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 sequence_numbers.end()); 211 sequence_numbers.end());
212 } 212 }
213 213
214 void RequestKeyFrame() override { ++keyframe_requests_; } 214 void RequestKeyFrame() override { ++keyframe_requests_; }
215 215
216 ::testing::NiceMock<ProcessThreadMock> process_thread_mock_; 216 ::testing::NiceMock<ProcessThreadMock> process_thread_mock_;
217 std::vector<uint16_t> nack_sent_; 217 std::vector<uint16_t> nack_sent_;
218 int keyframe_requests_; 218 int keyframe_requests_;
219 219
220 protected: 220 protected:
221 TestBasicJitterBuffer() : scoped_field_trial_(GetParam()) {} 221 TestBasicJitterBuffer() {}
222 void SetUp() override { 222 void SetUp() override {
223 clock_.reset(new SimulatedClock(0)); 223 clock_.reset(new SimulatedClock(0));
224 jitter_buffer_.reset(new VCMJitterBuffer( 224 jitter_buffer_.reset(new VCMJitterBuffer(
225 clock_.get(), 225 clock_.get(),
226 std::unique_ptr<EventWrapper>(event_factory_.CreateEvent()), 226 std::unique_ptr<EventWrapper>(event_factory_.CreateEvent()),
227 this, 227 this,
228 this)); 228 this));
229 jitter_buffer_->Start(); 229 jitter_buffer_->Start();
230 seq_num_ = 1234; 230 seq_num_ = 1234;
231 timestamp_ = 0; 231 timestamp_ = 0;
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 } 309 }
310 310
311 uint16_t seq_num_; 311 uint16_t seq_num_;
312 uint32_t timestamp_; 312 uint32_t timestamp_;
313 int size_; 313 int size_;
314 uint8_t data_[1500]; 314 uint8_t data_[1500];
315 std::unique_ptr<VCMPacket> packet_; 315 std::unique_ptr<VCMPacket> packet_;
316 std::unique_ptr<SimulatedClock> clock_; 316 std::unique_ptr<SimulatedClock> clock_;
317 NullEventFactory event_factory_; 317 NullEventFactory event_factory_;
318 std::unique_ptr<VCMJitterBuffer> jitter_buffer_; 318 std::unique_ptr<VCMJitterBuffer> jitter_buffer_;
319 test::ScopedFieldTrials scoped_field_trial_;
320 }; 319 };
321 320
322 INSTANTIATE_TEST_CASE_P(
323 TestWithNackModule,
324 TestBasicJitterBuffer,
325 ::testing::Values("WebRTC-NewVideoJitterBuffer/Enabled/",
326 "WebRTC-NewVideoJitterBuffer/Disabled/"));
327
328 class TestRunningJitterBuffer : public ::testing::TestWithParam<std::string>, 321 class TestRunningJitterBuffer : public ::testing::TestWithParam<std::string>,
329 public NackSender, 322 public NackSender,
330 public KeyFrameRequestSender { 323 public KeyFrameRequestSender {
331 public: 324 public:
332 void SendNack(const std::vector<uint16_t>& sequence_numbers) { 325 void SendNack(const std::vector<uint16_t>& sequence_numbers) {
333 nack_sent_.insert(nack_sent_.end(), sequence_numbers.begin(), 326 nack_sent_.insert(nack_sent_.end(), sequence_numbers.begin(),
334 sequence_numbers.end()); 327 sequence_numbers.end());
335 } 328 }
336 329
337 void RequestKeyFrame() { ++keyframe_requests_; } 330 void RequestKeyFrame() { ++keyframe_requests_; }
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 StreamGenerator* stream_generator_; 436 StreamGenerator* stream_generator_;
444 std::unique_ptr<SimulatedClock> clock_; 437 std::unique_ptr<SimulatedClock> clock_;
445 NullEventFactory event_factory_; 438 NullEventFactory event_factory_;
446 size_t max_nack_list_size_; 439 size_t max_nack_list_size_;
447 int oldest_packet_to_nack_; 440 int oldest_packet_to_nack_;
448 uint8_t data_buffer_[kDataBufferSize]; 441 uint8_t data_buffer_[kDataBufferSize];
449 }; 442 };
450 443
451 class TestJitterBufferNack : public TestRunningJitterBuffer { 444 class TestJitterBufferNack : public TestRunningJitterBuffer {
452 protected: 445 protected:
453 TestJitterBufferNack() : scoped_field_trial_(GetParam()) {} 446 TestJitterBufferNack() {}
454 virtual void SetUp() { 447 virtual void SetUp() {
455 TestRunningJitterBuffer::SetUp(); 448 TestRunningJitterBuffer::SetUp();
456 jitter_buffer_->SetNackMode(kNack, -1, -1); 449 jitter_buffer_->SetNackMode(kNack, -1, -1);
457 } 450 }
458 451
459 virtual void TearDown() { TestRunningJitterBuffer::TearDown(); } 452 virtual void TearDown() { TestRunningJitterBuffer::TearDown(); }
460
461 test::ScopedFieldTrials scoped_field_trial_;
462 }; 453 };
463 454
464 INSTANTIATE_TEST_CASE_P( 455 TEST_F(TestBasicJitterBuffer, StopRunning) {
465 TestWithNackModule,
466 TestJitterBufferNack,
467 ::testing::Values("WebRTC-NewVideoJitterBuffer/Enabled/",
468 "WebRTC-NewVideoJitterBuffer/Disabled/"));
469
470 TEST_P(TestBasicJitterBuffer, StopRunning) {
471 jitter_buffer_->Stop(); 456 jitter_buffer_->Stop();
472 EXPECT_TRUE(NULL == DecodeCompleteFrame()); 457 EXPECT_TRUE(NULL == DecodeCompleteFrame());
473 EXPECT_TRUE(NULL == DecodeIncompleteFrame()); 458 EXPECT_TRUE(NULL == DecodeIncompleteFrame());
474 jitter_buffer_->Start(); 459 jitter_buffer_->Start();
475 // Allow selective errors. 460 // Allow selective errors.
476 jitter_buffer_->SetDecodeErrorMode(kSelectiveErrors); 461 jitter_buffer_->SetDecodeErrorMode(kSelectiveErrors);
477 462
478 // No packets inserted. 463 // No packets inserted.
479 EXPECT_TRUE(NULL == DecodeCompleteFrame()); 464 EXPECT_TRUE(NULL == DecodeCompleteFrame());
480 EXPECT_TRUE(NULL == DecodeIncompleteFrame()); 465 EXPECT_TRUE(NULL == DecodeIncompleteFrame());
481 466
482 // Allow decoding with errors. 467 // Allow decoding with errors.
483 jitter_buffer_->SetDecodeErrorMode(kWithErrors); 468 jitter_buffer_->SetDecodeErrorMode(kWithErrors);
484 469
485 // No packets inserted. 470 // No packets inserted.
486 EXPECT_TRUE(NULL == DecodeCompleteFrame()); 471 EXPECT_TRUE(NULL == DecodeCompleteFrame());
487 EXPECT_TRUE(NULL == DecodeIncompleteFrame()); 472 EXPECT_TRUE(NULL == DecodeIncompleteFrame());
488 } 473 }
489 474
490 TEST_P(TestBasicJitterBuffer, SinglePacketFrame) { 475 TEST_F(TestBasicJitterBuffer, SinglePacketFrame) {
491 // Always start with a complete key frame when not allowing errors. 476 // Always start with a complete key frame when not allowing errors.
492 jitter_buffer_->SetDecodeErrorMode(kNoErrors); 477 jitter_buffer_->SetDecodeErrorMode(kNoErrors);
493 packet_->frameType = kVideoFrameKey; 478 packet_->frameType = kVideoFrameKey;
494 packet_->isFirstPacket = true; 479 packet_->isFirstPacket = true;
495 packet_->markerBit = true; 480 packet_->markerBit = true;
496 packet_->timestamp += 123 * 90; 481 packet_->timestamp += 123 * 90;
497 482
498 // Insert the packet to the jitter buffer and get a frame. 483 // Insert the packet to the jitter buffer and get a frame.
499 bool retransmitted = false; 484 bool retransmitted = false;
500 EXPECT_EQ(kCompleteSession, 485 EXPECT_EQ(kCompleteSession,
501 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 486 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
502 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); 487 VCMEncodedFrame* frame_out = DecodeCompleteFrame();
503 CheckOutFrame(frame_out, size_, false); 488 CheckOutFrame(frame_out, size_, false);
504 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); 489 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType());
505 jitter_buffer_->ReleaseFrame(frame_out); 490 jitter_buffer_->ReleaseFrame(frame_out);
506 } 491 }
507 492
508 TEST_P(TestBasicJitterBuffer, VerifyHistogramStats) { 493 TEST_F(TestBasicJitterBuffer, VerifyHistogramStats) {
509 metrics::Reset(); 494 metrics::Reset();
510 // Always start with a complete key frame when not allowing errors. 495 // Always start with a complete key frame when not allowing errors.
511 jitter_buffer_->SetDecodeErrorMode(kNoErrors); 496 jitter_buffer_->SetDecodeErrorMode(kNoErrors);
512 packet_->frameType = kVideoFrameKey; 497 packet_->frameType = kVideoFrameKey;
513 packet_->isFirstPacket = true; 498 packet_->isFirstPacket = true;
514 packet_->markerBit = true; 499 packet_->markerBit = true;
515 packet_->timestamp += 123 * 90; 500 packet_->timestamp += 123 * 90;
516 501
517 // Insert single packet frame to the jitter buffer and get a frame. 502 // Insert single packet frame to the jitter buffer and get a frame.
518 bool retransmitted = false; 503 bool retransmitted = false;
(...skipping 17 matching lines...) Expand all
536 521
537 // Verify that histograms are not updated if stop is called again. 522 // Verify that histograms are not updated if stop is called again.
538 jitter_buffer_->Stop(); 523 jitter_buffer_->Stop();
539 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.DiscardedPacketsInPercent")); 524 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.DiscardedPacketsInPercent"));
540 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.DuplicatedPacketsInPercent")); 525 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.DuplicatedPacketsInPercent"));
541 EXPECT_EQ( 526 EXPECT_EQ(
542 1, metrics::NumSamples("WebRTC.Video.CompleteFramesReceivedPerSecond")); 527 1, metrics::NumSamples("WebRTC.Video.CompleteFramesReceivedPerSecond"));
543 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.KeyFramesReceivedInPermille")); 528 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.KeyFramesReceivedInPermille"));
544 } 529 }
545 530
546 TEST_P(TestBasicJitterBuffer, DualPacketFrame) { 531 TEST_F(TestBasicJitterBuffer, DualPacketFrame) {
547 packet_->frameType = kVideoFrameKey; 532 packet_->frameType = kVideoFrameKey;
548 packet_->isFirstPacket = true; 533 packet_->isFirstPacket = true;
549 packet_->markerBit = false; 534 packet_->markerBit = false;
550 535
551 bool retransmitted = false; 536 bool retransmitted = false;
552 EXPECT_EQ(kIncomplete, 537 EXPECT_EQ(kIncomplete,
553 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 538 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
554 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); 539 VCMEncodedFrame* frame_out = DecodeCompleteFrame();
555 // Should not be complete. 540 // Should not be complete.
556 EXPECT_TRUE(frame_out == NULL); 541 EXPECT_TRUE(frame_out == NULL);
557 542
558 ++seq_num_; 543 ++seq_num_;
559 packet_->isFirstPacket = false; 544 packet_->isFirstPacket = false;
560 packet_->markerBit = true; 545 packet_->markerBit = true;
561 packet_->seqNum = seq_num_; 546 packet_->seqNum = seq_num_;
562 547
563 EXPECT_EQ(kCompleteSession, 548 EXPECT_EQ(kCompleteSession,
564 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 549 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
565 550
566 frame_out = DecodeCompleteFrame(); 551 frame_out = DecodeCompleteFrame();
567 CheckOutFrame(frame_out, 2 * size_, false); 552 CheckOutFrame(frame_out, 2 * size_, false);
568 553
569 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); 554 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType());
570 jitter_buffer_->ReleaseFrame(frame_out); 555 jitter_buffer_->ReleaseFrame(frame_out);
571 } 556 }
572 557
573 TEST_P(TestBasicJitterBuffer, 100PacketKeyFrame) { 558 TEST_F(TestBasicJitterBuffer, 100PacketKeyFrame) {
574 packet_->frameType = kVideoFrameKey; 559 packet_->frameType = kVideoFrameKey;
575 packet_->isFirstPacket = true; 560 packet_->isFirstPacket = true;
576 packet_->markerBit = false; 561 packet_->markerBit = false;
577 562
578 bool retransmitted = false; 563 bool retransmitted = false;
579 EXPECT_EQ(kIncomplete, 564 EXPECT_EQ(kIncomplete,
580 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 565 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
581 566
582 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); 567 VCMEncodedFrame* frame_out = DecodeCompleteFrame();
583 568
(...skipping 22 matching lines...) Expand all
606 EXPECT_EQ(kCompleteSession, 591 EXPECT_EQ(kCompleteSession,
607 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 592 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
608 593
609 frame_out = DecodeCompleteFrame(); 594 frame_out = DecodeCompleteFrame();
610 595
611 CheckOutFrame(frame_out, 100 * size_, false); 596 CheckOutFrame(frame_out, 100 * size_, false);
612 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); 597 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType());
613 jitter_buffer_->ReleaseFrame(frame_out); 598 jitter_buffer_->ReleaseFrame(frame_out);
614 } 599 }
615 600
616 TEST_P(TestBasicJitterBuffer, 100PacketDeltaFrame) { 601 TEST_F(TestBasicJitterBuffer, 100PacketDeltaFrame) {
617 // Always start with a complete key frame. 602 // Always start with a complete key frame.
618 packet_->frameType = kVideoFrameKey; 603 packet_->frameType = kVideoFrameKey;
619 packet_->isFirstPacket = true; 604 packet_->isFirstPacket = true;
620 packet_->markerBit = true; 605 packet_->markerBit = true;
621 606
622 bool retransmitted = false; 607 bool retransmitted = false;
623 EXPECT_EQ(kCompleteSession, 608 EXPECT_EQ(kCompleteSession,
624 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 609 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
625 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); 610 VCMEncodedFrame* frame_out = DecodeCompleteFrame();
626 EXPECT_FALSE(frame_out == NULL); 611 EXPECT_FALSE(frame_out == NULL);
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 EXPECT_EQ(kCompleteSession, 647 EXPECT_EQ(kCompleteSession,
663 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 648 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
664 649
665 frame_out = DecodeCompleteFrame(); 650 frame_out = DecodeCompleteFrame();
666 651
667 CheckOutFrame(frame_out, 100 * size_, false); 652 CheckOutFrame(frame_out, 100 * size_, false);
668 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); 653 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType());
669 jitter_buffer_->ReleaseFrame(frame_out); 654 jitter_buffer_->ReleaseFrame(frame_out);
670 } 655 }
671 656
672 TEST_P(TestBasicJitterBuffer, PacketReorderingReverseOrder) { 657 TEST_F(TestBasicJitterBuffer, PacketReorderingReverseOrder) {
673 // Insert the "first" packet last. 658 // Insert the "first" packet last.
674 seq_num_ += 100; 659 seq_num_ += 100;
675 packet_->frameType = kVideoFrameKey; 660 packet_->frameType = kVideoFrameKey;
676 packet_->isFirstPacket = false; 661 packet_->isFirstPacket = false;
677 packet_->markerBit = true; 662 packet_->markerBit = true;
678 packet_->seqNum = seq_num_; 663 packet_->seqNum = seq_num_;
679 packet_->timestamp = timestamp_; 664 packet_->timestamp = timestamp_;
680 665
681 bool retransmitted = false; 666 bool retransmitted = false;
682 EXPECT_EQ(kIncomplete, 667 EXPECT_EQ(kIncomplete,
(...skipping 26 matching lines...) Expand all
709 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 694 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
710 695
711 frame_out = DecodeCompleteFrame(); 696 frame_out = DecodeCompleteFrame();
712 697
713 CheckOutFrame(frame_out, 100 * size_, false); 698 CheckOutFrame(frame_out, 100 * size_, false);
714 699
715 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); 700 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType());
716 jitter_buffer_->ReleaseFrame(frame_out); 701 jitter_buffer_->ReleaseFrame(frame_out);
717 } 702 }
718 703
719 TEST_P(TestBasicJitterBuffer, FrameReordering2Frames2PacketsEach) { 704 TEST_F(TestBasicJitterBuffer, FrameReordering2Frames2PacketsEach) {
720 packet_->frameType = kVideoFrameDelta; 705 packet_->frameType = kVideoFrameDelta;
721 packet_->isFirstPacket = true; 706 packet_->isFirstPacket = true;
722 packet_->markerBit = false; 707 packet_->markerBit = false;
723 708
724 bool retransmitted = false; 709 bool retransmitted = false;
725 EXPECT_EQ(kIncomplete, 710 EXPECT_EQ(kIncomplete,
726 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 711 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
727 712
728 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); 713 VCMEncodedFrame* frame_out = DecodeCompleteFrame();
729 714
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 CheckOutFrame(frame_out, 2 * size_, false); 754 CheckOutFrame(frame_out, 2 * size_, false);
770 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); 755 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType());
771 jitter_buffer_->ReleaseFrame(frame_out); 756 jitter_buffer_->ReleaseFrame(frame_out);
772 757
773 frame_out = DecodeCompleteFrame(); 758 frame_out = DecodeCompleteFrame();
774 CheckOutFrame(frame_out, 2 * size_, false); 759 CheckOutFrame(frame_out, 2 * size_, false);
775 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); 760 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType());
776 jitter_buffer_->ReleaseFrame(frame_out); 761 jitter_buffer_->ReleaseFrame(frame_out);
777 } 762 }
778 763
779 TEST_P(TestBasicJitterBuffer, TestReorderingWithPadding) { 764 TEST_F(TestBasicJitterBuffer, TestReorderingWithPadding) {
780 packet_->frameType = kVideoFrameKey; 765 packet_->frameType = kVideoFrameKey;
781 packet_->isFirstPacket = true; 766 packet_->isFirstPacket = true;
782 packet_->markerBit = true; 767 packet_->markerBit = true;
783 768
784 // Send in an initial good packet/frame (Frame A) to start things off. 769 // Send in an initial good packet/frame (Frame A) to start things off.
785 bool retransmitted = false; 770 bool retransmitted = false;
786 EXPECT_EQ(kCompleteSession, 771 EXPECT_EQ(kCompleteSession,
787 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 772 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
788 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); 773 VCMEncodedFrame* frame_out = DecodeCompleteFrame();
789 EXPECT_TRUE(frame_out != NULL); 774 EXPECT_TRUE(frame_out != NULL);
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
831 empty_packet.seqNum += 1; 816 empty_packet.seqNum += 1;
832 EXPECT_EQ(kOldPacket, 817 EXPECT_EQ(kOldPacket,
833 jitter_buffer_->InsertPacket(empty_packet, &retransmitted)); 818 jitter_buffer_->InsertPacket(empty_packet, &retransmitted));
834 819
835 // But now Frame C should be ready! 820 // But now Frame C should be ready!
836 frame_out = DecodeCompleteFrame(); 821 frame_out = DecodeCompleteFrame();
837 EXPECT_TRUE(frame_out != NULL); 822 EXPECT_TRUE(frame_out != NULL);
838 jitter_buffer_->ReleaseFrame(frame_out); 823 jitter_buffer_->ReleaseFrame(frame_out);
839 } 824 }
840 825
841 TEST_P(TestBasicJitterBuffer, DuplicatePackets) { 826 TEST_F(TestBasicJitterBuffer, DuplicatePackets) {
842 packet_->frameType = kVideoFrameKey; 827 packet_->frameType = kVideoFrameKey;
843 packet_->isFirstPacket = true; 828 packet_->isFirstPacket = true;
844 packet_->markerBit = false; 829 packet_->markerBit = false;
845 packet_->seqNum = seq_num_; 830 packet_->seqNum = seq_num_;
846 packet_->timestamp = timestamp_; 831 packet_->timestamp = timestamp_;
847 EXPECT_EQ(0, jitter_buffer_->num_packets()); 832 EXPECT_EQ(0, jitter_buffer_->num_packets());
848 EXPECT_EQ(0, jitter_buffer_->num_duplicated_packets()); 833 EXPECT_EQ(0, jitter_buffer_->num_duplicated_packets());
849 834
850 bool retransmitted = false; 835 bool retransmitted = false;
851 EXPECT_EQ(kIncomplete, 836 EXPECT_EQ(kIncomplete,
(...skipping 22 matching lines...) Expand all
874 frame_out = DecodeCompleteFrame(); 859 frame_out = DecodeCompleteFrame();
875 ASSERT_TRUE(frame_out != NULL); 860 ASSERT_TRUE(frame_out != NULL);
876 CheckOutFrame(frame_out, 2 * size_, false); 861 CheckOutFrame(frame_out, 2 * size_, false);
877 862
878 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); 863 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType());
879 EXPECT_EQ(3, jitter_buffer_->num_packets()); 864 EXPECT_EQ(3, jitter_buffer_->num_packets());
880 EXPECT_EQ(1, jitter_buffer_->num_duplicated_packets()); 865 EXPECT_EQ(1, jitter_buffer_->num_duplicated_packets());
881 jitter_buffer_->ReleaseFrame(frame_out); 866 jitter_buffer_->ReleaseFrame(frame_out);
882 } 867 }
883 868
884 TEST_P(TestBasicJitterBuffer, DuplicatePreviousDeltaFramePacket) { 869 TEST_F(TestBasicJitterBuffer, DuplicatePreviousDeltaFramePacket) {
885 packet_->frameType = kVideoFrameKey; 870 packet_->frameType = kVideoFrameKey;
886 packet_->isFirstPacket = true; 871 packet_->isFirstPacket = true;
887 packet_->markerBit = true; 872 packet_->markerBit = true;
888 packet_->seqNum = seq_num_; 873 packet_->seqNum = seq_num_;
889 packet_->timestamp = timestamp_; 874 packet_->timestamp = timestamp_;
890 jitter_buffer_->SetDecodeErrorMode(kNoErrors); 875 jitter_buffer_->SetDecodeErrorMode(kNoErrors);
891 EXPECT_EQ(0, jitter_buffer_->num_packets()); 876 EXPECT_EQ(0, jitter_buffer_->num_packets());
892 EXPECT_EQ(0, jitter_buffer_->num_duplicated_packets()); 877 EXPECT_EQ(0, jitter_buffer_->num_duplicated_packets());
893 878
894 bool retransmitted = false; 879 bool retransmitted = false;
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 // Should be able to decode 3 delta frames, key frame already decoded. 911 // Should be able to decode 3 delta frames, key frame already decoded.
927 for (size_t i = 0; i < 3; ++i) { 912 for (size_t i = 0; i < 3; ++i) {
928 frame_out = DecodeCompleteFrame(); 913 frame_out = DecodeCompleteFrame();
929 ASSERT_TRUE(frame_out != NULL); 914 ASSERT_TRUE(frame_out != NULL);
930 CheckOutFrame(frame_out, size_, false); 915 CheckOutFrame(frame_out, size_, false);
931 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); 916 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType());
932 jitter_buffer_->ReleaseFrame(frame_out); 917 jitter_buffer_->ReleaseFrame(frame_out);
933 } 918 }
934 } 919 }
935 920
936 TEST_P(TestBasicJitterBuffer, TestSkipForwardVp9) { 921 TEST_F(TestBasicJitterBuffer, TestSkipForwardVp9) {
937 // Verify that JB skips forward to next base layer frame. 922 // Verify that JB skips forward to next base layer frame.
938 // ------------------------------------------------- 923 // -------------------------------------------------
939 // | 65485 | 65486 | 65487 | 65488 | 65489 | ... 924 // | 65485 | 65486 | 65487 | 65488 | 65489 | ...
940 // | pid:5 | pid:6 | pid:7 | pid:8 | pid:9 | ... 925 // | pid:5 | pid:6 | pid:7 | pid:8 | pid:9 | ...
941 // | tid:0 | tid:2 | tid:1 | tid:2 | tid:0 | ... 926 // | tid:0 | tid:2 | tid:1 | tid:2 | tid:0 | ...
942 // | ss | x | x | x | | 927 // | ss | x | x | x | |
943 // ------------------------------------------------- 928 // -------------------------------------------------
944 // |<----------tl0idx:200--------->|<---tl0idx:201--- 929 // |<----------tl0idx:200--------->|<---tl0idx:201---
945 930
946 bool re = false; 931 bool re = false;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 EXPECT_EQ(1000U, frame_out->TimeStamp()); 964 EXPECT_EQ(1000U, frame_out->TimeStamp());
980 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); 965 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType());
981 jitter_buffer_->ReleaseFrame(frame_out); 966 jitter_buffer_->ReleaseFrame(frame_out);
982 967
983 frame_out = DecodeCompleteFrame(); 968 frame_out = DecodeCompleteFrame();
984 EXPECT_EQ(13000U, frame_out->TimeStamp()); 969 EXPECT_EQ(13000U, frame_out->TimeStamp());
985 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); 970 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType());
986 jitter_buffer_->ReleaseFrame(frame_out); 971 jitter_buffer_->ReleaseFrame(frame_out);
987 } 972 }
988 973
989 TEST_P(TestBasicJitterBuffer, ReorderedVp9SsData_3TlLayers) { 974 TEST_F(TestBasicJitterBuffer, ReorderedVp9SsData_3TlLayers) {
990 // Verify that frames are updated with SS data when SS packet is reordered. 975 // Verify that frames are updated with SS data when SS packet is reordered.
991 // -------------------------------- 976 // --------------------------------
992 // | 65486 | 65487 | 65485 |... 977 // | 65486 | 65487 | 65485 |...
993 // | pid:6 | pid:7 | pid:5 |... 978 // | pid:6 | pid:7 | pid:5 |...
994 // | tid:2 | tid:1 | tid:0 |... 979 // | tid:2 | tid:1 | tid:0 |...
995 // | | | ss | 980 // | | | ss |
996 // -------------------------------- 981 // --------------------------------
997 // |<--------tl0idx:200--------->| 982 // |<--------tl0idx:200--------->|
998 983
999 bool re = false; 984 bool re = false;
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 jitter_buffer_->ReleaseFrame(frame_out); 1038 jitter_buffer_->ReleaseFrame(frame_out);
1054 1039
1055 frame_out = DecodeCompleteFrame(); 1040 frame_out = DecodeCompleteFrame();
1056 EXPECT_EQ(9000U, frame_out->TimeStamp()); 1041 EXPECT_EQ(9000U, frame_out->TimeStamp());
1057 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); 1042 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType());
1058 EXPECT_EQ(1, frame_out->CodecSpecific()->codecSpecific.VP9.temporal_idx); 1043 EXPECT_EQ(1, frame_out->CodecSpecific()->codecSpecific.VP9.temporal_idx);
1059 EXPECT_TRUE(frame_out->CodecSpecific()->codecSpecific.VP9.temporal_up_switch); 1044 EXPECT_TRUE(frame_out->CodecSpecific()->codecSpecific.VP9.temporal_up_switch);
1060 jitter_buffer_->ReleaseFrame(frame_out); 1045 jitter_buffer_->ReleaseFrame(frame_out);
1061 } 1046 }
1062 1047
1063 TEST_P(TestBasicJitterBuffer, ReorderedVp9SsData_2Tl2SLayers) { 1048 TEST_F(TestBasicJitterBuffer, ReorderedVp9SsData_2Tl2SLayers) {
1064 // Verify that frames are updated with SS data when SS packet is reordered. 1049 // Verify that frames are updated with SS data when SS packet is reordered.
1065 // ----------------------------------------- 1050 // -----------------------------------------
1066 // | 65486 | 65487 | 65485 | 65484 |... 1051 // | 65486 | 65487 | 65485 | 65484 |...
1067 // | pid:6 | pid:6 | pid:5 | pid:5 |... 1052 // | pid:6 | pid:6 | pid:5 | pid:5 |...
1068 // | tid:1 | tid:1 | tid:0 | tid:0 |... 1053 // | tid:1 | tid:1 | tid:0 | tid:0 |...
1069 // | sid:0 | sid:1 | sid:1 | sid:0 |... 1054 // | sid:0 | sid:1 | sid:1 | sid:0 |...
1070 // | t:6000 | t:6000 | t:3000 | t:3000 | 1055 // | t:6000 | t:6000 | t:3000 | t:3000 |
1071 // | | | | ss | 1056 // | | | | ss |
1072 // ----------------------------------------- 1057 // -----------------------------------------
1073 // |<-----------tl0idx:200------------>| 1058 // |<-----------tl0idx:200------------>|
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1137 jitter_buffer_->ReleaseFrame(frame_out); 1122 jitter_buffer_->ReleaseFrame(frame_out);
1138 1123
1139 frame_out = DecodeCompleteFrame(); 1124 frame_out = DecodeCompleteFrame();
1140 EXPECT_EQ(6000U, frame_out->TimeStamp()); 1125 EXPECT_EQ(6000U, frame_out->TimeStamp());
1141 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); 1126 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType());
1142 EXPECT_EQ(1, frame_out->CodecSpecific()->codecSpecific.VP9.temporal_idx); 1127 EXPECT_EQ(1, frame_out->CodecSpecific()->codecSpecific.VP9.temporal_idx);
1143 EXPECT_TRUE(frame_out->CodecSpecific()->codecSpecific.VP9.temporal_up_switch); 1128 EXPECT_TRUE(frame_out->CodecSpecific()->codecSpecific.VP9.temporal_up_switch);
1144 jitter_buffer_->ReleaseFrame(frame_out); 1129 jitter_buffer_->ReleaseFrame(frame_out);
1145 } 1130 }
1146 1131
1147 TEST_P(TestBasicJitterBuffer, H264InsertStartCode) { 1132 TEST_F(TestBasicJitterBuffer, H264InsertStartCode) {
1148 packet_->frameType = kVideoFrameKey; 1133 packet_->frameType = kVideoFrameKey;
1149 packet_->isFirstPacket = true; 1134 packet_->isFirstPacket = true;
1150 packet_->markerBit = false; 1135 packet_->markerBit = false;
1151 packet_->seqNum = seq_num_; 1136 packet_->seqNum = seq_num_;
1152 packet_->timestamp = timestamp_; 1137 packet_->timestamp = timestamp_;
1153 packet_->insertStartCode = true; 1138 packet_->insertStartCode = true;
1154 1139
1155 bool retransmitted = false; 1140 bool retransmitted = false;
1156 EXPECT_EQ(kIncomplete, 1141 EXPECT_EQ(kIncomplete,
1157 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 1142 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
(...skipping 11 matching lines...) Expand all
1169 EXPECT_EQ(kCompleteSession, 1154 EXPECT_EQ(kCompleteSession,
1170 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 1155 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
1171 1156
1172 frame_out = DecodeCompleteFrame(); 1157 frame_out = DecodeCompleteFrame();
1173 CheckOutFrame(frame_out, size_ * 2 + 4 * 2, true); 1158 CheckOutFrame(frame_out, size_ * 2 + 4 * 2, true);
1174 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); 1159 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType());
1175 jitter_buffer_->ReleaseFrame(frame_out); 1160 jitter_buffer_->ReleaseFrame(frame_out);
1176 } 1161 }
1177 1162
1178 // Test threshold conditions of decodable state. 1163 // Test threshold conditions of decodable state.
1179 TEST_P(TestBasicJitterBuffer, PacketLossWithSelectiveErrorsThresholdCheck) { 1164 TEST_F(TestBasicJitterBuffer, PacketLossWithSelectiveErrorsThresholdCheck) {
1180 jitter_buffer_->SetDecodeErrorMode(kSelectiveErrors); 1165 jitter_buffer_->SetDecodeErrorMode(kSelectiveErrors);
1181 // Always start with a key frame. Use 10 packets to test Decodable State 1166 // Always start with a key frame. Use 10 packets to test Decodable State
1182 // boundaries. 1167 // boundaries.
1183 packet_->frameType = kVideoFrameKey; 1168 packet_->frameType = kVideoFrameKey;
1184 packet_->isFirstPacket = true; 1169 packet_->isFirstPacket = true;
1185 packet_->markerBit = false; 1170 packet_->markerBit = false;
1186 packet_->seqNum = seq_num_; 1171 packet_->seqNum = seq_num_;
1187 packet_->timestamp = timestamp_; 1172 packet_->timestamp = timestamp_;
1188 1173
1189 bool retransmitted = false; 1174 bool retransmitted = false;
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1255 CheckOutFrame(frame_out, 9 * size_, false); 1240 CheckOutFrame(frame_out, 9 * size_, false);
1256 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); 1241 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType());
1257 jitter_buffer_->ReleaseFrame(frame_out); 1242 jitter_buffer_->ReleaseFrame(frame_out);
1258 1243
1259 packet_->markerBit = true; 1244 packet_->markerBit = true;
1260 packet_->seqNum++; 1245 packet_->seqNum++;
1261 EXPECT_EQ(kOldPacket, jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 1246 EXPECT_EQ(kOldPacket, jitter_buffer_->InsertPacket(*packet_, &retransmitted));
1262 } 1247 }
1263 1248
1264 // Make sure first packet is present before a frame can be decoded. 1249 // Make sure first packet is present before a frame can be decoded.
1265 TEST_P(TestBasicJitterBuffer, PacketLossWithSelectiveErrorsIncompleteKey) { 1250 TEST_F(TestBasicJitterBuffer, PacketLossWithSelectiveErrorsIncompleteKey) {
1266 jitter_buffer_->SetDecodeErrorMode(kSelectiveErrors); 1251 jitter_buffer_->SetDecodeErrorMode(kSelectiveErrors);
1267 // Always start with a key frame. 1252 // Always start with a key frame.
1268 packet_->frameType = kVideoFrameKey; 1253 packet_->frameType = kVideoFrameKey;
1269 packet_->isFirstPacket = true; 1254 packet_->isFirstPacket = true;
1270 packet_->markerBit = true; 1255 packet_->markerBit = true;
1271 packet_->seqNum = seq_num_; 1256 packet_->seqNum = seq_num_;
1272 packet_->timestamp = timestamp_; 1257 packet_->timestamp = timestamp_;
1273 1258
1274 bool retransmitted = false; 1259 bool retransmitted = false;
1275 EXPECT_EQ(kCompleteSession, 1260 EXPECT_EQ(kCompleteSession,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1319 packet_->seqNum++; 1304 packet_->seqNum++;
1320 EXPECT_EQ(kCompleteSession, 1305 EXPECT_EQ(kCompleteSession,
1321 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 1306 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
1322 frame_out = DecodeCompleteFrame(); 1307 frame_out = DecodeCompleteFrame();
1323 CheckOutFrame(frame_out, 6 * size_, false); 1308 CheckOutFrame(frame_out, 6 * size_, false);
1324 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); 1309 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType());
1325 jitter_buffer_->ReleaseFrame(frame_out); 1310 jitter_buffer_->ReleaseFrame(frame_out);
1326 } 1311 }
1327 1312
1328 // Make sure first packet is present before a frame can be decoded. 1313 // Make sure first packet is present before a frame can be decoded.
1329 TEST_P(TestBasicJitterBuffer, PacketLossWithSelectiveErrorsMissingFirstPacket) { 1314 TEST_F(TestBasicJitterBuffer, PacketLossWithSelectiveErrorsMissingFirstPacket) {
1330 jitter_buffer_->SetDecodeErrorMode(kSelectiveErrors); 1315 jitter_buffer_->SetDecodeErrorMode(kSelectiveErrors);
1331 // Always start with a key frame. 1316 // Always start with a key frame.
1332 packet_->frameType = kVideoFrameKey; 1317 packet_->frameType = kVideoFrameKey;
1333 packet_->isFirstPacket = true; 1318 packet_->isFirstPacket = true;
1334 packet_->markerBit = true; 1319 packet_->markerBit = true;
1335 packet_->seqNum = seq_num_; 1320 packet_->seqNum = seq_num_;
1336 packet_->timestamp = timestamp_; 1321 packet_->timestamp = timestamp_;
1337 1322
1338 bool retransmitted = false; 1323 bool retransmitted = false;
1339 EXPECT_EQ(kCompleteSession, 1324 EXPECT_EQ(kCompleteSession,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1381 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 1366 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
1382 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr); 1367 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr);
1383 EXPECT_TRUE(jitter_buffer_->NextMaybeIncompleteTimestamp(&timestamp)); 1368 EXPECT_TRUE(jitter_buffer_->NextMaybeIncompleteTimestamp(&timestamp));
1384 1369
1385 frame_out = DecodeIncompleteFrame(); 1370 frame_out = DecodeIncompleteFrame();
1386 CheckOutFrame(frame_out, 7 * size_, false); 1371 CheckOutFrame(frame_out, 7 * size_, false);
1387 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); 1372 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType());
1388 jitter_buffer_->ReleaseFrame(frame_out); 1373 jitter_buffer_->ReleaseFrame(frame_out);
1389 } 1374 }
1390 1375
1391 TEST_P(TestBasicJitterBuffer, DiscontinuousStreamWhenDecodingWithErrors) { 1376 TEST_F(TestBasicJitterBuffer, DiscontinuousStreamWhenDecodingWithErrors) {
1392 // Will use one packet per frame. 1377 // Will use one packet per frame.
1393 jitter_buffer_->SetDecodeErrorMode(kWithErrors); 1378 jitter_buffer_->SetDecodeErrorMode(kWithErrors);
1394 packet_->frameType = kVideoFrameKey; 1379 packet_->frameType = kVideoFrameKey;
1395 packet_->isFirstPacket = true; 1380 packet_->isFirstPacket = true;
1396 packet_->markerBit = true; 1381 packet_->markerBit = true;
1397 packet_->seqNum = seq_num_; 1382 packet_->seqNum = seq_num_;
1398 packet_->timestamp = timestamp_; 1383 packet_->timestamp = timestamp_;
1399 bool retransmitted = false; 1384 bool retransmitted = false;
1400 EXPECT_EQ(kCompleteSession, 1385 EXPECT_EQ(kCompleteSession,
1401 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 1386 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
(...skipping 23 matching lines...) Expand all
1425 packet_->markerBit = false; 1410 packet_->markerBit = false;
1426 packet_->seqNum = seq_num_; 1411 packet_->seqNum = seq_num_;
1427 packet_->timestamp = timestamp_; 1412 packet_->timestamp = timestamp_;
1428 EXPECT_EQ(kDecodableSession, 1413 EXPECT_EQ(kDecodableSession,
1429 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 1414 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
1430 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr); 1415 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr);
1431 EXPECT_TRUE(jitter_buffer_->NextMaybeIncompleteTimestamp(&next_timestamp)); 1416 EXPECT_TRUE(jitter_buffer_->NextMaybeIncompleteTimestamp(&next_timestamp));
1432 EXPECT_EQ(packet_->timestamp - 33 * 90, next_timestamp); 1417 EXPECT_EQ(packet_->timestamp - 33 * 90, next_timestamp);
1433 } 1418 }
1434 1419
1435 TEST_P(TestBasicJitterBuffer, PacketLoss) { 1420 TEST_F(TestBasicJitterBuffer, PacketLoss) {
1436 // Verify missing packets statistics and not decodable packets statistics. 1421 // Verify missing packets statistics and not decodable packets statistics.
1437 // Insert 10 frames consisting of 4 packets and remove one from all of them. 1422 // Insert 10 frames consisting of 4 packets and remove one from all of them.
1438 // The last packet is an empty (non-media) packet. 1423 // The last packet is an empty (non-media) packet.
1439 1424
1440 // Select a start seqNum which triggers a difficult wrap situation 1425 // Select a start seqNum which triggers a difficult wrap situation
1441 // The JB will only output (incomplete)frames if the next one has started 1426 // The JB will only output (incomplete)frames if the next one has started
1442 // to arrive. Start by inserting one frame (key). 1427 // to arrive. Start by inserting one frame (key).
1443 jitter_buffer_->SetDecodeErrorMode(kWithErrors); 1428 jitter_buffer_->SetDecodeErrorMode(kWithErrors);
1444 seq_num_ = 0xffff - 4; 1429 seq_num_ = 0xffff - 4;
1445 seq_num_++; 1430 seq_num_++;
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1526 EXPECT_EQ(kOldPacket, jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 1511 EXPECT_EQ(kOldPacket, jitter_buffer_->InsertPacket(*packet_, &retransmitted));
1527 1512
1528 EXPECT_EQ(3, jitter_buffer_->num_discarded_packets()); 1513 EXPECT_EQ(3, jitter_buffer_->num_discarded_packets());
1529 1514
1530 jitter_buffer_->Flush(); 1515 jitter_buffer_->Flush();
1531 1516
1532 // This statistic shouldn't be reset by a flush. 1517 // This statistic shouldn't be reset by a flush.
1533 EXPECT_EQ(3, jitter_buffer_->num_discarded_packets()); 1518 EXPECT_EQ(3, jitter_buffer_->num_discarded_packets());
1534 } 1519 }
1535 1520
1536 TEST_P(TestBasicJitterBuffer, DeltaFrame100PacketsWithSeqNumWrap) { 1521 TEST_F(TestBasicJitterBuffer, DeltaFrame100PacketsWithSeqNumWrap) {
1537 seq_num_ = 0xfff0; 1522 seq_num_ = 0xfff0;
1538 packet_->frameType = kVideoFrameKey; 1523 packet_->frameType = kVideoFrameKey;
1539 packet_->isFirstPacket = true; 1524 packet_->isFirstPacket = true;
1540 packet_->markerBit = false; 1525 packet_->markerBit = false;
1541 packet_->seqNum = seq_num_; 1526 packet_->seqNum = seq_num_;
1542 packet_->timestamp = timestamp_; 1527 packet_->timestamp = timestamp_;
1543 1528
1544 bool retransmitted = false; 1529 bool retransmitted = false;
1545 EXPECT_EQ(kIncomplete, 1530 EXPECT_EQ(kIncomplete,
1546 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 1531 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
(...skipping 28 matching lines...) Expand all
1575 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 1560 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
1576 1561
1577 frame_out = DecodeCompleteFrame(); 1562 frame_out = DecodeCompleteFrame();
1578 1563
1579 CheckOutFrame(frame_out, 100 * size_, false); 1564 CheckOutFrame(frame_out, 100 * size_, false);
1580 1565
1581 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); 1566 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType());
1582 jitter_buffer_->ReleaseFrame(frame_out); 1567 jitter_buffer_->ReleaseFrame(frame_out);
1583 } 1568 }
1584 1569
1585 TEST_P(TestBasicJitterBuffer, PacketReorderingReverseWithNegSeqNumWrap) { 1570 TEST_F(TestBasicJitterBuffer, PacketReorderingReverseWithNegSeqNumWrap) {
1586 // Insert "first" packet last seqnum. 1571 // Insert "first" packet last seqnum.
1587 seq_num_ = 10; 1572 seq_num_ = 10;
1588 packet_->frameType = kVideoFrameKey; 1573 packet_->frameType = kVideoFrameKey;
1589 packet_->isFirstPacket = false; 1574 packet_->isFirstPacket = false;
1590 packet_->markerBit = true; 1575 packet_->markerBit = true;
1591 packet_->seqNum = seq_num_; 1576 packet_->seqNum = seq_num_;
1592 1577
1593 bool retransmitted = false; 1578 bool retransmitted = false;
1594 EXPECT_EQ(kIncomplete, 1579 EXPECT_EQ(kIncomplete,
1595 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 1580 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
(...skipping 28 matching lines...) Expand all
1624 1609
1625 EXPECT_EQ(kCompleteSession, 1610 EXPECT_EQ(kCompleteSession,
1626 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 1611 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
1627 1612
1628 frame_out = DecodeCompleteFrame(); 1613 frame_out = DecodeCompleteFrame();
1629 CheckOutFrame(frame_out, 100 * size_, false); 1614 CheckOutFrame(frame_out, 100 * size_, false);
1630 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); 1615 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType());
1631 jitter_buffer_->ReleaseFrame(frame_out); 1616 jitter_buffer_->ReleaseFrame(frame_out);
1632 } 1617 }
1633 1618
1634 TEST_P(TestBasicJitterBuffer, TestInsertOldFrame) { 1619 TEST_F(TestBasicJitterBuffer, TestInsertOldFrame) {
1635 // ------- ------- 1620 // ------- -------
1636 // | 2 | | 1 | 1621 // | 2 | | 1 |
1637 // ------- ------- 1622 // ------- -------
1638 // t = 3000 t = 2000 1623 // t = 3000 t = 2000
1639 seq_num_ = 2; 1624 seq_num_ = 2;
1640 timestamp_ = 3000; 1625 timestamp_ = 3000;
1641 packet_->frameType = kVideoFrameKey; 1626 packet_->frameType = kVideoFrameKey;
1642 packet_->isFirstPacket = true; 1627 packet_->isFirstPacket = true;
1643 packet_->markerBit = true; 1628 packet_->markerBit = true;
1644 packet_->timestamp = timestamp_; 1629 packet_->timestamp = timestamp_;
(...skipping 13 matching lines...) Expand all
1658 timestamp_ = 2000; 1643 timestamp_ = 2000;
1659 packet_->frameType = kVideoFrameDelta; 1644 packet_->frameType = kVideoFrameDelta;
1660 packet_->isFirstPacket = true; 1645 packet_->isFirstPacket = true;
1661 packet_->markerBit = true; 1646 packet_->markerBit = true;
1662 packet_->seqNum = seq_num_; 1647 packet_->seqNum = seq_num_;
1663 packet_->timestamp = timestamp_; 1648 packet_->timestamp = timestamp_;
1664 1649
1665 EXPECT_EQ(kOldPacket, jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 1650 EXPECT_EQ(kOldPacket, jitter_buffer_->InsertPacket(*packet_, &retransmitted));
1666 } 1651 }
1667 1652
1668 TEST_P(TestBasicJitterBuffer, TestInsertOldFrameWithSeqNumWrap) { 1653 TEST_F(TestBasicJitterBuffer, TestInsertOldFrameWithSeqNumWrap) {
1669 // ------- ------- 1654 // ------- -------
1670 // | 2 | | 1 | 1655 // | 2 | | 1 |
1671 // ------- ------- 1656 // ------- -------
1672 // t = 3000 t = 0xffffff00 1657 // t = 3000 t = 0xffffff00
1673 1658
1674 seq_num_ = 2; 1659 seq_num_ = 2;
1675 timestamp_ = 3000; 1660 timestamp_ = 3000;
1676 packet_->frameType = kVideoFrameKey; 1661 packet_->frameType = kVideoFrameKey;
1677 packet_->isFirstPacket = true; 1662 packet_->isFirstPacket = true;
1678 packet_->markerBit = true; 1663 packet_->markerBit = true;
(...skipping 18 matching lines...) Expand all
1697 packet_->frameType = kVideoFrameDelta; 1682 packet_->frameType = kVideoFrameDelta;
1698 packet_->isFirstPacket = true; 1683 packet_->isFirstPacket = true;
1699 packet_->markerBit = true; 1684 packet_->markerBit = true;
1700 packet_->seqNum = seq_num_; 1685 packet_->seqNum = seq_num_;
1701 packet_->timestamp = timestamp_; 1686 packet_->timestamp = timestamp_;
1702 1687
1703 // This timestamp is old. 1688 // This timestamp is old.
1704 EXPECT_EQ(kOldPacket, jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 1689 EXPECT_EQ(kOldPacket, jitter_buffer_->InsertPacket(*packet_, &retransmitted));
1705 } 1690 }
1706 1691
1707 TEST_P(TestBasicJitterBuffer, TimestampWrap) { 1692 TEST_F(TestBasicJitterBuffer, TimestampWrap) {
1708 // --------------- --------------- 1693 // --------------- ---------------
1709 // | 1 | 2 | | 3 | 4 | 1694 // | 1 | 2 | | 3 | 4 |
1710 // --------------- --------------- 1695 // --------------- ---------------
1711 // t = 0xffffff00 t = 33*90 1696 // t = 0xffffff00 t = 33*90
1712 1697
1713 timestamp_ = 0xffffff00; 1698 timestamp_ = 0xffffff00;
1714 packet_->frameType = kVideoFrameKey; 1699 packet_->frameType = kVideoFrameKey;
1715 packet_->isFirstPacket = true; 1700 packet_->isFirstPacket = true;
1716 packet_->markerBit = false; 1701 packet_->markerBit = false;
1717 packet_->seqNum = seq_num_; 1702 packet_->seqNum = seq_num_;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1757 1742
1758 EXPECT_EQ(kCompleteSession, 1743 EXPECT_EQ(kCompleteSession,
1759 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 1744 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
1760 1745
1761 frame_out = DecodeCompleteFrame(); 1746 frame_out = DecodeCompleteFrame();
1762 CheckOutFrame(frame_out, 2 * size_, false); 1747 CheckOutFrame(frame_out, 2 * size_, false);
1763 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); 1748 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType());
1764 jitter_buffer_->ReleaseFrame(frame_out); 1749 jitter_buffer_->ReleaseFrame(frame_out);
1765 } 1750 }
1766 1751
1767 TEST_P(TestBasicJitterBuffer, 2FrameWithTimestampWrap) { 1752 TEST_F(TestBasicJitterBuffer, 2FrameWithTimestampWrap) {
1768 // ------- ------- 1753 // ------- -------
1769 // | 1 | | 2 | 1754 // | 1 | | 2 |
1770 // ------- ------- 1755 // ------- -------
1771 // t = 0xffffff00 t = 2700 1756 // t = 0xffffff00 t = 2700
1772 1757
1773 timestamp_ = 0xffffff00; 1758 timestamp_ = 0xffffff00;
1774 packet_->frameType = kVideoFrameKey; 1759 packet_->frameType = kVideoFrameKey;
1775 packet_->isFirstPacket = true; 1760 packet_->isFirstPacket = true;
1776 packet_->markerBit = true; 1761 packet_->markerBit = true;
1777 packet_->timestamp = timestamp_; 1762 packet_->timestamp = timestamp_;
(...skipping 21 matching lines...) Expand all
1799 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); 1784 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType());
1800 jitter_buffer_->ReleaseFrame(frame_out); 1785 jitter_buffer_->ReleaseFrame(frame_out);
1801 1786
1802 VCMEncodedFrame* frame_out2 = DecodeCompleteFrame(); 1787 VCMEncodedFrame* frame_out2 = DecodeCompleteFrame();
1803 EXPECT_EQ(2700u, frame_out2->TimeStamp()); 1788 EXPECT_EQ(2700u, frame_out2->TimeStamp());
1804 CheckOutFrame(frame_out2, size_, false); 1789 CheckOutFrame(frame_out2, size_, false);
1805 EXPECT_EQ(kVideoFrameDelta, frame_out2->FrameType()); 1790 EXPECT_EQ(kVideoFrameDelta, frame_out2->FrameType());
1806 jitter_buffer_->ReleaseFrame(frame_out2); 1791 jitter_buffer_->ReleaseFrame(frame_out2);
1807 } 1792 }
1808 1793
1809 TEST_P(TestBasicJitterBuffer, Insert2FramesReOrderedWithTimestampWrap) { 1794 TEST_F(TestBasicJitterBuffer, Insert2FramesReOrderedWithTimestampWrap) {
1810 // ------- ------- 1795 // ------- -------
1811 // | 2 | | 1 | 1796 // | 2 | | 1 |
1812 // ------- ------- 1797 // ------- -------
1813 // t = 2700 t = 0xffffff00 1798 // t = 2700 t = 0xffffff00
1814 1799
1815 seq_num_ = 2; 1800 seq_num_ = 2;
1816 timestamp_ = 2700; 1801 timestamp_ = 2700;
1817 packet_->frameType = kVideoFrameDelta; 1802 packet_->frameType = kVideoFrameDelta;
1818 packet_->isFirstPacket = true; 1803 packet_->isFirstPacket = true;
1819 packet_->markerBit = true; 1804 packet_->markerBit = true;
(...skipping 22 matching lines...) Expand all
1842 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); 1827 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType());
1843 jitter_buffer_->ReleaseFrame(frame_out); 1828 jitter_buffer_->ReleaseFrame(frame_out);
1844 1829
1845 VCMEncodedFrame* frame_out2 = DecodeCompleteFrame(); 1830 VCMEncodedFrame* frame_out2 = DecodeCompleteFrame();
1846 EXPECT_EQ(2700u, frame_out2->TimeStamp()); 1831 EXPECT_EQ(2700u, frame_out2->TimeStamp());
1847 CheckOutFrame(frame_out2, size_, false); 1832 CheckOutFrame(frame_out2, size_, false);
1848 EXPECT_EQ(kVideoFrameDelta, frame_out2->FrameType()); 1833 EXPECT_EQ(kVideoFrameDelta, frame_out2->FrameType());
1849 jitter_buffer_->ReleaseFrame(frame_out2); 1834 jitter_buffer_->ReleaseFrame(frame_out2);
1850 } 1835 }
1851 1836
1852 TEST_P(TestBasicJitterBuffer, DeltaFrameWithMoreThanMaxNumberOfPackets) { 1837 TEST_F(TestBasicJitterBuffer, DeltaFrameWithMoreThanMaxNumberOfPackets) {
1853 int loop = 0; 1838 int loop = 0;
1854 bool firstPacket = true; 1839 bool firstPacket = true;
1855 bool retransmitted = false; 1840 bool retransmitted = false;
1856 // Insert kMaxPacketsInJitterBuffer into frame. 1841 // Insert kMaxPacketsInJitterBuffer into frame.
1857 do { 1842 do {
1858 seq_num_++; 1843 seq_num_++;
1859 packet_->isFirstPacket = false; 1844 packet_->isFirstPacket = false;
1860 packet_->markerBit = false; 1845 packet_->markerBit = false;
1861 packet_->seqNum = seq_num_; 1846 packet_->seqNum = seq_num_;
1862 1847
(...skipping 14 matching lines...) Expand all
1877 seq_num_++; 1862 seq_num_++;
1878 packet_->isFirstPacket = false; 1863 packet_->isFirstPacket = false;
1879 packet_->markerBit = true; 1864 packet_->markerBit = true;
1880 packet_->seqNum = seq_num_; 1865 packet_->seqNum = seq_num_;
1881 1866
1882 // Insert the packet -> frame recycled. 1867 // Insert the packet -> frame recycled.
1883 EXPECT_EQ(kSizeError, jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 1868 EXPECT_EQ(kSizeError, jitter_buffer_->InsertPacket(*packet_, &retransmitted));
1884 EXPECT_TRUE(NULL == DecodeCompleteFrame()); 1869 EXPECT_TRUE(NULL == DecodeCompleteFrame());
1885 } 1870 }
1886 1871
1887 TEST_P(TestBasicJitterBuffer, ExceedNumOfFrameWithSeqNumWrap) { 1872 TEST_F(TestBasicJitterBuffer, ExceedNumOfFrameWithSeqNumWrap) {
1888 // TEST fill JB with more than max number of frame (50 delta frames + 1873 // TEST fill JB with more than max number of frame (50 delta frames +
1889 // 51 key frames) with wrap in seq_num_ 1874 // 51 key frames) with wrap in seq_num_
1890 // 1875 //
1891 // -------------------------------------------------------------- 1876 // --------------------------------------------------------------
1892 // | 65485 | 65486 | 65487 | .... | 65535 | 0 | 1 | 2 | .....| 50 | 1877 // | 65485 | 65486 | 65487 | .... | 65535 | 0 | 1 | 2 | .....| 50 |
1893 // -------------------------------------------------------------- 1878 // --------------------------------------------------------------
1894 // |<-----------delta frames------------->|<------key frames----->| 1879 // |<-----------delta frames------------->|<------key frames----->|
1895 1880
1896 // Make sure the jitter doesn't request a keyframe after too much non- 1881 // Make sure the jitter doesn't request a keyframe after too much non-
1897 // decodable frames. 1882 // decodable frames.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1937 EXPECT_EQ(kFlushIndicator, 1922 EXPECT_EQ(kFlushIndicator,
1938 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 1923 jitter_buffer_->InsertPacket(*packet_, &retransmitted));
1939 1924
1940 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); 1925 VCMEncodedFrame* frame_out = DecodeCompleteFrame();
1941 EXPECT_EQ(first_key_frame_timestamp, frame_out->TimeStamp()); 1926 EXPECT_EQ(first_key_frame_timestamp, frame_out->TimeStamp());
1942 CheckOutFrame(frame_out, size_, false); 1927 CheckOutFrame(frame_out, size_, false);
1943 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); 1928 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType());
1944 jitter_buffer_->ReleaseFrame(frame_out); 1929 jitter_buffer_->ReleaseFrame(frame_out);
1945 } 1930 }
1946 1931
1947 TEST_P(TestBasicJitterBuffer, EmptyLastFrame) { 1932 TEST_F(TestBasicJitterBuffer, EmptyLastFrame) {
1948 jitter_buffer_->SetDecodeErrorMode(kWithErrors); 1933 jitter_buffer_->SetDecodeErrorMode(kWithErrors);
1949 seq_num_ = 3; 1934 seq_num_ = 3;
1950 // Insert one empty packet per frame, should never return the last timestamp 1935 // Insert one empty packet per frame, should never return the last timestamp
1951 // inserted. Only return empty frames in the presence of subsequent frames. 1936 // inserted. Only return empty frames in the presence of subsequent frames.
1952 int maxSize = 1000; 1937 int maxSize = 1000;
1953 bool retransmitted = false; 1938 bool retransmitted = false;
1954 for (int i = 0; i < maxSize + 10; i++) { 1939 for (int i = 0; i < maxSize + 10; i++) {
1955 timestamp_ += 33 * 90; 1940 timestamp_ += 33 * 90;
1956 seq_num_++; 1941 seq_num_++;
1957 packet_->isFirstPacket = false; 1942 packet_->isFirstPacket = false;
1958 packet_->markerBit = false; 1943 packet_->markerBit = false;
1959 packet_->seqNum = seq_num_; 1944 packet_->seqNum = seq_num_;
1960 packet_->timestamp = timestamp_; 1945 packet_->timestamp = timestamp_;
1961 packet_->frameType = kEmptyFrame; 1946 packet_->frameType = kEmptyFrame;
1962 1947
1963 EXPECT_EQ(kNoError, jitter_buffer_->InsertPacket(*packet_, &retransmitted)); 1948 EXPECT_EQ(kNoError, jitter_buffer_->InsertPacket(*packet_, &retransmitted));
1964 VCMEncodedFrame* testFrame = DecodeIncompleteFrame(); 1949 VCMEncodedFrame* testFrame = DecodeIncompleteFrame();
1965 // Timestamp should never be the last TS inserted. 1950 // Timestamp should never be the last TS inserted.
1966 if (testFrame != NULL) { 1951 if (testFrame != NULL) {
1967 EXPECT_TRUE(testFrame->TimeStamp() < timestamp_); 1952 EXPECT_TRUE(testFrame->TimeStamp() < timestamp_);
1968 jitter_buffer_->ReleaseFrame(testFrame); 1953 jitter_buffer_->ReleaseFrame(testFrame);
1969 } 1954 }
1970 } 1955 }
1971 } 1956 }
1972 1957
1973 TEST_P(TestBasicJitterBuffer, H264IncompleteNalu) { 1958 TEST_F(TestBasicJitterBuffer, H264IncompleteNalu) {
1974 jitter_buffer_->SetNackMode(kNoNack, -1, -1); 1959 jitter_buffer_->SetNackMode(kNoNack, -1, -1);
1975 jitter_buffer_->SetDecodeErrorMode(kWithErrors); 1960 jitter_buffer_->SetDecodeErrorMode(kWithErrors);
1976 ++seq_num_; 1961 ++seq_num_;
1977 timestamp_ += 33 * 90; 1962 timestamp_ += 33 * 90;
1978 int insertedLength = 0; 1963 int insertedLength = 0;
1979 packet_->seqNum = seq_num_; 1964 packet_->seqNum = seq_num_;
1980 packet_->timestamp = timestamp_; 1965 packet_->timestamp = timestamp_;
1981 packet_->frameType = kVideoFrameKey; 1966 packet_->frameType = kVideoFrameKey;
1982 packet_->isFirstPacket = true; 1967 packet_->isFirstPacket = true;
1983 packet_->completeNALU = kNaluStart; 1968 packet_->completeNALU = kNaluStart;
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
2146 emptypacket.markerBit = true; 2131 emptypacket.markerBit = true;
2147 EXPECT_EQ(kCompleteSession, 2132 EXPECT_EQ(kCompleteSession,
2148 jitter_buffer_->InsertPacket(emptypacket, &retransmitted)); 2133 jitter_buffer_->InsertPacket(emptypacket, &retransmitted));
2149 2134
2150 frame_out = DecodeCompleteFrame(); 2135 frame_out = DecodeCompleteFrame();
2151 // Only last NALU is complete 2136 // Only last NALU is complete
2152 CheckOutFrame(frame_out, packet_->sizeBytes, false); 2137 CheckOutFrame(frame_out, packet_->sizeBytes, false);
2153 jitter_buffer_->ReleaseFrame(frame_out); 2138 jitter_buffer_->ReleaseFrame(frame_out);
2154 } 2139 }
2155 2140
2156 TEST_P(TestBasicJitterBuffer, NextFrameWhenIncomplete) { 2141 TEST_F(TestBasicJitterBuffer, NextFrameWhenIncomplete) {
2157 // Test that a we cannot get incomplete frames from the JB if we haven't 2142 // Test that a we cannot get incomplete frames from the JB if we haven't
2158 // received the marker bit, unless we have received a packet from a later 2143 // received the marker bit, unless we have received a packet from a later
2159 // timestamp. 2144 // timestamp.
2160 jitter_buffer_->SetDecodeErrorMode(kWithErrors); 2145 jitter_buffer_->SetDecodeErrorMode(kWithErrors);
2161 // Start with a complete key frame - insert and decode. 2146 // Start with a complete key frame - insert and decode.
2162 packet_->frameType = kVideoFrameKey; 2147 packet_->frameType = kVideoFrameKey;
2163 packet_->isFirstPacket = true; 2148 packet_->isFirstPacket = true;
2164 packet_->markerBit = true; 2149 packet_->markerBit = true;
2165 bool retransmitted = false; 2150 bool retransmitted = false;
2166 2151
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
2323 stream_generator_->GenerateFrame(kVideoFrameDelta, 2, 0, 2308 stream_generator_->GenerateFrame(kVideoFrameDelta, 2, 0,
2324 clock_->TimeInMilliseconds()); 2309 clock_->TimeInMilliseconds());
2325 EXPECT_EQ(kIncomplete, InsertPacketAndPop(1)); 2310 EXPECT_EQ(kIncomplete, InsertPacketAndPop(1));
2326 EXPECT_EQ(kCompleteSession, InsertPacketAndPop(1)); 2311 EXPECT_EQ(kCompleteSession, InsertPacketAndPop(1));
2327 EXPECT_FALSE(DecodeCompleteFrame()); 2312 EXPECT_FALSE(DecodeCompleteFrame());
2328 EXPECT_EQ(kCompleteSession, InsertPacketAndPop(0)); 2313 EXPECT_EQ(kCompleteSession, InsertPacketAndPop(0));
2329 EXPECT_TRUE(DecodeCompleteFrame()); 2314 EXPECT_TRUE(DecodeCompleteFrame());
2330 EXPECT_TRUE(DecodeCompleteFrame()); 2315 EXPECT_TRUE(DecodeCompleteFrame());
2331 } 2316 }
2332 2317
2333 TEST_P(TestJitterBufferNack, EmptyPackets) { 2318 TEST_F(TestJitterBufferNack, EmptyPackets) {
2334 // Make sure empty packets doesn't clog the jitter buffer. 2319 // Make sure empty packets doesn't clog the jitter buffer.
2335 jitter_buffer_->SetNackMode(kNack, media_optimization::kLowRttNackMs, -1); 2320 jitter_buffer_->SetNackMode(kNack, media_optimization::kLowRttNackMs, -1);
2336 EXPECT_GE(InsertFrames(kMaxNumberOfFrames, kEmptyFrame), kNoError); 2321 EXPECT_GE(InsertFrames(kMaxNumberOfFrames, kEmptyFrame), kNoError);
2337 InsertFrame(kVideoFrameKey); 2322 InsertFrame(kVideoFrameKey);
2338 EXPECT_TRUE(DecodeCompleteFrame()); 2323 EXPECT_TRUE(DecodeCompleteFrame());
2339 } 2324 }
2340 2325
2341 TEST_P(TestJitterBufferNack, NackTooOldPackets) { 2326 TEST_F(TestJitterBufferNack, NackTooOldPackets) {
2342 // Insert a key frame and decode it. 2327 // Insert a key frame and decode it.
2343 EXPECT_GE(InsertFrame(kVideoFrameKey), kNoError); 2328 EXPECT_GE(InsertFrame(kVideoFrameKey), kNoError);
2344 EXPECT_TRUE(DecodeCompleteFrame()); 2329 EXPECT_TRUE(DecodeCompleteFrame());
2345 2330
2346 // Drop one frame and insert |kNackHistoryLength| to trigger NACKing a too 2331 // Drop one frame and insert |kNackHistoryLength| to trigger NACKing a too
2347 // old packet. 2332 // old packet.
2348 DropFrame(1); 2333 DropFrame(1);
2349 // Insert a frame which should trigger a recycle until the next key frame. 2334 // Insert a frame which should trigger a recycle until the next key frame.
2350 EXPECT_EQ(kFlushIndicator, 2335 EXPECT_EQ(kFlushIndicator,
2351 InsertFrames(oldest_packet_to_nack_ + 1, kVideoFrameDelta)); 2336 InsertFrames(oldest_packet_to_nack_ + 1, kVideoFrameDelta));
(...skipping 12 matching lines...) Expand all
2364 EXPECT_FALSE(DecodeIncompleteFrame()); 2349 EXPECT_FALSE(DecodeIncompleteFrame());
2365 2350
2366 // The next complete continuous frame isn't a key frame, but we're waiting 2351 // The next complete continuous frame isn't a key frame, but we're waiting
2367 // for one. 2352 // for one.
2368 EXPECT_FALSE(DecodeCompleteFrame()); 2353 EXPECT_FALSE(DecodeCompleteFrame());
2369 EXPECT_GE(InsertFrame(kVideoFrameKey), kNoError); 2354 EXPECT_GE(InsertFrame(kVideoFrameKey), kNoError);
2370 // Skipping ahead to the key frame. 2355 // Skipping ahead to the key frame.
2371 EXPECT_TRUE(DecodeCompleteFrame()); 2356 EXPECT_TRUE(DecodeCompleteFrame());
2372 } 2357 }
2373 2358
2374 TEST_P(TestJitterBufferNack, NackLargeJitterBuffer) { 2359 TEST_F(TestJitterBufferNack, NackLargeJitterBuffer) {
2375 // Insert a key frame and decode it. 2360 // Insert a key frame and decode it.
2376 EXPECT_GE(InsertFrame(kVideoFrameKey), kNoError); 2361 EXPECT_GE(InsertFrame(kVideoFrameKey), kNoError);
2377 EXPECT_TRUE(DecodeCompleteFrame()); 2362 EXPECT_TRUE(DecodeCompleteFrame());
2378 2363
2379 // Insert a frame which should trigger a recycle until the next key frame. 2364 // Insert a frame which should trigger a recycle until the next key frame.
2380 EXPECT_GE(InsertFrames(oldest_packet_to_nack_, kVideoFrameDelta), kNoError); 2365 EXPECT_GE(InsertFrames(oldest_packet_to_nack_, kVideoFrameDelta), kNoError);
2381 2366
2382 bool request_key_frame = false; 2367 bool request_key_frame = false;
2383 std::vector<uint16_t> nack_list = 2368 std::vector<uint16_t> nack_list =
2384 jitter_buffer_->GetNackList(&request_key_frame); 2369 jitter_buffer_->GetNackList(&request_key_frame);
2385 // Verify that the jitter buffer does not request a key frame. 2370 // Verify that the jitter buffer does not request a key frame.
2386 EXPECT_FALSE(request_key_frame); 2371 EXPECT_FALSE(request_key_frame);
2387 // Verify that no packets are NACKed. 2372 // Verify that no packets are NACKed.
2388 EXPECT_EQ(0u, nack_list.size()); 2373 EXPECT_EQ(0u, nack_list.size());
2389 // Verify that we can decode the next frame. 2374 // Verify that we can decode the next frame.
2390 EXPECT_TRUE(DecodeCompleteFrame()); 2375 EXPECT_TRUE(DecodeCompleteFrame());
2391 } 2376 }
2392 2377
2393 TEST_P(TestJitterBufferNack, NackListFull) { 2378 TEST_F(TestJitterBufferNack, NackListFull) {
2394 // Insert a key frame and decode it. 2379 // Insert a key frame and decode it.
2395 EXPECT_GE(InsertFrame(kVideoFrameKey), kNoError); 2380 EXPECT_GE(InsertFrame(kVideoFrameKey), kNoError);
2396 EXPECT_TRUE(DecodeCompleteFrame()); 2381 EXPECT_TRUE(DecodeCompleteFrame());
2397 2382
2398 // Generate and drop |kNackHistoryLength| packets to fill the NACK list. 2383 // Generate and drop |kNackHistoryLength| packets to fill the NACK list.
2399 DropFrame(max_nack_list_size_ + 1); 2384 DropFrame(max_nack_list_size_ + 1);
2400 // Insert a frame which should trigger a recycle until the next key frame. 2385 // Insert a frame which should trigger a recycle until the next key frame.
2401 EXPECT_EQ(kFlushIndicator, InsertFrame(kVideoFrameDelta)); 2386 EXPECT_EQ(kFlushIndicator, InsertFrame(kVideoFrameDelta));
2402 EXPECT_FALSE(DecodeCompleteFrame()); 2387 EXPECT_FALSE(DecodeCompleteFrame());
2403 2388
(...skipping 12 matching lines...) Expand all
2416 EXPECT_TRUE(request_key_frame); 2401 EXPECT_TRUE(request_key_frame);
2417 // The next complete continuous frame isn't a key frame, but we're waiting 2402 // The next complete continuous frame isn't a key frame, but we're waiting
2418 // for one. 2403 // for one.
2419 EXPECT_FALSE(DecodeCompleteFrame()); 2404 EXPECT_FALSE(DecodeCompleteFrame());
2420 EXPECT_FALSE(DecodeIncompleteFrame()); 2405 EXPECT_FALSE(DecodeIncompleteFrame());
2421 EXPECT_GE(InsertFrame(kVideoFrameKey), kNoError); 2406 EXPECT_GE(InsertFrame(kVideoFrameKey), kNoError);
2422 // Skipping ahead to the key frame. 2407 // Skipping ahead to the key frame.
2423 EXPECT_TRUE(DecodeCompleteFrame()); 2408 EXPECT_TRUE(DecodeCompleteFrame());
2424 } 2409 }
2425 2410
2426 TEST_P(TestJitterBufferNack, NoNackListReturnedBeforeFirstDecode) { 2411 TEST_F(TestJitterBufferNack, NoNackListReturnedBeforeFirstDecode) {
2427 DropFrame(10); 2412 DropFrame(10);
2428 // Insert a frame and try to generate a NACK list. Shouldn't get one. 2413 // Insert a frame and try to generate a NACK list. Shouldn't get one.
2429 EXPECT_GE(InsertFrame(kVideoFrameDelta), kNoError); 2414 EXPECT_GE(InsertFrame(kVideoFrameDelta), kNoError);
2430 bool request_key_frame = false; 2415 bool request_key_frame = false;
2431 std::vector<uint16_t> nack_list = 2416 std::vector<uint16_t> nack_list =
2432 jitter_buffer_->GetNackList(&request_key_frame); 2417 jitter_buffer_->GetNackList(&request_key_frame);
2433 // No list generated, and a key frame request is signaled. 2418 // No list generated, and a key frame request is signaled.
2434 EXPECT_EQ(0u, nack_list.size()); 2419 EXPECT_EQ(0u, nack_list.size());
2435 EXPECT_TRUE(request_key_frame); 2420 EXPECT_TRUE(request_key_frame);
2436 } 2421 }
2437 2422
2438 TEST_P(TestJitterBufferNack, NackListBuiltBeforeFirstDecode) { 2423 TEST_F(TestJitterBufferNack, NackListBuiltBeforeFirstDecode) {
2439 stream_generator_->Init(0, clock_->TimeInMilliseconds()); 2424 stream_generator_->Init(0, clock_->TimeInMilliseconds());
2440 InsertFrame(kVideoFrameKey); 2425 InsertFrame(kVideoFrameKey);
2441 stream_generator_->GenerateFrame(kVideoFrameDelta, 2, 0, 2426 stream_generator_->GenerateFrame(kVideoFrameDelta, 2, 0,
2442 clock_->TimeInMilliseconds()); 2427 clock_->TimeInMilliseconds());
2443 stream_generator_->NextPacket(NULL); // Drop packet. 2428 stream_generator_->NextPacket(NULL); // Drop packet.
2444 EXPECT_EQ(kIncomplete, InsertPacketAndPop(0)); 2429 EXPECT_EQ(kIncomplete, InsertPacketAndPop(0));
2445 EXPECT_TRUE(DecodeCompleteFrame()); 2430 EXPECT_TRUE(DecodeCompleteFrame());
2446 bool extended = false; 2431 bool extended = false;
2447 std::vector<uint16_t> nack_list = jitter_buffer_->GetNackList(&extended); 2432 std::vector<uint16_t> nack_list = jitter_buffer_->GetNackList(&extended);
2448 if (field_trial::FindFullName("WebRTC-NewVideoJitterBuffer") == "Enabled") 2433 EXPECT_EQ(1u, nack_list.size());
2449 EXPECT_EQ(1u, nack_sent_.size());
2450 else
2451 EXPECT_EQ(1u, nack_list.size());
2452 } 2434 }
2453 2435
2454 TEST_P(TestJitterBufferNack, VerifyRetransmittedFlag) { 2436 TEST_F(TestJitterBufferNack, VerifyRetransmittedFlag) {
2455 stream_generator_->Init(0, clock_->TimeInMilliseconds()); 2437 stream_generator_->Init(0, clock_->TimeInMilliseconds());
2456 stream_generator_->GenerateFrame(kVideoFrameKey, 3, 0, 2438 stream_generator_->GenerateFrame(kVideoFrameKey, 3, 0,
2457 clock_->TimeInMilliseconds()); 2439 clock_->TimeInMilliseconds());
2458 VCMPacket packet; 2440 VCMPacket packet;
2459 stream_generator_->PopPacket(&packet, 0); 2441 stream_generator_->PopPacket(&packet, 0);
2460 bool retransmitted = false; 2442 bool retransmitted = false;
2461 EXPECT_EQ(kIncomplete, jitter_buffer_->InsertPacket(packet, &retransmitted)); 2443 EXPECT_EQ(kIncomplete, jitter_buffer_->InsertPacket(packet, &retransmitted));
2462 EXPECT_FALSE(retransmitted); 2444 EXPECT_FALSE(retransmitted);
2463 // Drop second packet. 2445 // Drop second packet.
2464 stream_generator_->PopPacket(&packet, 1); 2446 stream_generator_->PopPacket(&packet, 1);
2465 EXPECT_EQ(kIncomplete, jitter_buffer_->InsertPacket(packet, &retransmitted)); 2447 EXPECT_EQ(kIncomplete, jitter_buffer_->InsertPacket(packet, &retransmitted));
2466 EXPECT_FALSE(retransmitted); 2448 EXPECT_FALSE(retransmitted);
2467 EXPECT_FALSE(DecodeCompleteFrame()); 2449 EXPECT_FALSE(DecodeCompleteFrame());
2468 bool extended = false; 2450 bool extended = false;
2469 std::vector<uint16_t> nack_list = jitter_buffer_->GetNackList(&extended); 2451 std::vector<uint16_t> nack_list = jitter_buffer_->GetNackList(&extended);
2470 uint16_t seq_num; 2452 uint16_t seq_num;
2471 if (field_trial::FindFullName("WebRTC-NewVideoJitterBuffer") == "Enabled") { 2453 EXPECT_EQ(1u, nack_list.size());
2472 EXPECT_EQ(1u, nack_sent_.size()); 2454 seq_num = nack_list[0];
2473 seq_num = nack_sent_[0];
2474 } else {
2475 EXPECT_EQ(1u, nack_list.size());
2476 seq_num = nack_list[0];
2477 }
2478 stream_generator_->PopPacket(&packet, 0); 2455 stream_generator_->PopPacket(&packet, 0);
2479 EXPECT_EQ(packet.seqNum, seq_num); 2456 EXPECT_EQ(packet.seqNum, seq_num);
2480 EXPECT_EQ(kCompleteSession, 2457 EXPECT_EQ(kCompleteSession,
2481 jitter_buffer_->InsertPacket(packet, &retransmitted)); 2458 jitter_buffer_->InsertPacket(packet, &retransmitted));
2482 EXPECT_TRUE(retransmitted); 2459 EXPECT_TRUE(retransmitted);
2483 EXPECT_TRUE(DecodeCompleteFrame()); 2460 EXPECT_TRUE(DecodeCompleteFrame());
2484 } 2461 }
2485 2462
2486 TEST_P(TestJitterBufferNack, UseNackToRecoverFirstKeyFrame) { 2463 TEST_F(TestJitterBufferNack, UseNackToRecoverFirstKeyFrame) {
2487 stream_generator_->Init(0, clock_->TimeInMilliseconds()); 2464 stream_generator_->Init(0, clock_->TimeInMilliseconds());
2488 stream_generator_->GenerateFrame(kVideoFrameKey, 3, 0, 2465 stream_generator_->GenerateFrame(kVideoFrameKey, 3, 0,
2489 clock_->TimeInMilliseconds()); 2466 clock_->TimeInMilliseconds());
2490 EXPECT_EQ(kIncomplete, InsertPacketAndPop(0)); 2467 EXPECT_EQ(kIncomplete, InsertPacketAndPop(0));
2491 // Drop second packet. 2468 // Drop second packet.
2492 EXPECT_EQ(kIncomplete, InsertPacketAndPop(1)); 2469 EXPECT_EQ(kIncomplete, InsertPacketAndPop(1));
2493 EXPECT_FALSE(DecodeCompleteFrame()); 2470 EXPECT_FALSE(DecodeCompleteFrame());
2494 bool extended = false; 2471 bool extended = false;
2495 std::vector<uint16_t> nack_list = jitter_buffer_->GetNackList(&extended); 2472 std::vector<uint16_t> nack_list = jitter_buffer_->GetNackList(&extended);
2496 uint16_t seq_num; 2473 uint16_t seq_num;
2497 if (field_trial::FindFullName("WebRTC-NewVideoJitterBuffer") == "Enabled") { 2474 ASSERT_EQ(1u, nack_list.size());
2498 ASSERT_EQ(1u, nack_sent_.size()); 2475 seq_num = nack_list[0];
2499 seq_num = nack_sent_[0];
2500 } else {
2501 ASSERT_EQ(1u, nack_list.size());
2502 seq_num = nack_list[0];
2503 }
2504 VCMPacket packet; 2476 VCMPacket packet;
2505 stream_generator_->GetPacket(&packet, 0); 2477 stream_generator_->GetPacket(&packet, 0);
2506 EXPECT_EQ(packet.seqNum, seq_num); 2478 EXPECT_EQ(packet.seqNum, seq_num);
2507 } 2479 }
2508 2480
2509 TEST_P(TestJitterBufferNack, UseNackToRecoverFirstKeyFrameSecondInQueue) { 2481 TEST_F(TestJitterBufferNack, UseNackToRecoverFirstKeyFrameSecondInQueue) {
2510 VCMPacket packet; 2482 VCMPacket packet;
2511 stream_generator_->Init(0, clock_->TimeInMilliseconds()); 2483 stream_generator_->Init(0, clock_->TimeInMilliseconds());
2512 // First frame is delta. 2484 // First frame is delta.
2513 stream_generator_->GenerateFrame(kVideoFrameDelta, 3, 0, 2485 stream_generator_->GenerateFrame(kVideoFrameDelta, 3, 0,
2514 clock_->TimeInMilliseconds()); 2486 clock_->TimeInMilliseconds());
2515 EXPECT_EQ(kIncomplete, InsertPacketAndPop(0)); 2487 EXPECT_EQ(kIncomplete, InsertPacketAndPop(0));
2516 // Drop second packet in frame. 2488 // Drop second packet in frame.
2517 ASSERT_TRUE(stream_generator_->PopPacket(&packet, 0)); 2489 ASSERT_TRUE(stream_generator_->PopPacket(&packet, 0));
2518 EXPECT_EQ(kIncomplete, InsertPacketAndPop(0)); 2490 EXPECT_EQ(kIncomplete, InsertPacketAndPop(0));
2519 // Second frame is key. 2491 // Second frame is key.
2520 stream_generator_->GenerateFrame(kVideoFrameKey, 3, 0, 2492 stream_generator_->GenerateFrame(kVideoFrameKey, 3, 0,
2521 clock_->TimeInMilliseconds() + 10); 2493 clock_->TimeInMilliseconds() + 10);
2522 EXPECT_EQ(kIncomplete, InsertPacketAndPop(0)); 2494 EXPECT_EQ(kIncomplete, InsertPacketAndPop(0));
2523 // Drop second packet in frame. 2495 // Drop second packet in frame.
2524 EXPECT_EQ(kIncomplete, InsertPacketAndPop(1)); 2496 EXPECT_EQ(kIncomplete, InsertPacketAndPop(1));
2525 EXPECT_FALSE(DecodeCompleteFrame()); 2497 EXPECT_FALSE(DecodeCompleteFrame());
2526 bool extended = false; 2498 bool extended = false;
2527 std::vector<uint16_t> nack_list = jitter_buffer_->GetNackList(&extended); 2499 std::vector<uint16_t> nack_list = jitter_buffer_->GetNackList(&extended);
2528 uint16_t seq_num; 2500 uint16_t seq_num;
2529 if (field_trial::FindFullName("WebRTC-NewVideoJitterBuffer") == "Enabled") { 2501 ASSERT_EQ(1u, nack_list.size());
2530 ASSERT_EQ(2u, nack_sent_.size()); 2502 seq_num = nack_list[0];
2531 seq_num = nack_sent_[1];
2532 } else {
2533 ASSERT_EQ(1u, nack_list.size());
2534 seq_num = nack_list[0];
2535 }
2536 stream_generator_->GetPacket(&packet, 0); 2503 stream_generator_->GetPacket(&packet, 0);
2537 EXPECT_EQ(packet.seqNum, seq_num); 2504 EXPECT_EQ(packet.seqNum, seq_num);
2538 } 2505 }
2539 2506
2540 TEST_P(TestJitterBufferNack, NormalOperation) { 2507 TEST_F(TestJitterBufferNack, NormalOperation) {
2541 EXPECT_EQ(kNack, jitter_buffer_->nack_mode()); 2508 EXPECT_EQ(kNack, jitter_buffer_->nack_mode());
2542 jitter_buffer_->SetDecodeErrorMode(kWithErrors); 2509 jitter_buffer_->SetDecodeErrorMode(kWithErrors);
2543 2510
2544 EXPECT_GE(InsertFrame(kVideoFrameKey), kNoError); 2511 EXPECT_GE(InsertFrame(kVideoFrameKey), kNoError);
2545 EXPECT_TRUE(DecodeIncompleteFrame()); 2512 EXPECT_TRUE(DecodeIncompleteFrame());
2546 2513
2547 // ---------------------------------------------------------------- 2514 // ----------------------------------------------------------------
2548 // | 1 | 2 | .. | 8 | 9 | x | 11 | 12 | .. | 19 | x | 21 | .. | 100 | 2515 // | 1 | 2 | .. | 8 | 9 | x | 11 | 12 | .. | 19 | x | 21 | .. | 100 |
2549 // ---------------------------------------------------------------- 2516 // ----------------------------------------------------------------
2550 stream_generator_->GenerateFrame(kVideoFrameKey, 100, 0, 2517 stream_generator_->GenerateFrame(kVideoFrameKey, 100, 0,
(...skipping 12 matching lines...) Expand all
2563 EXPECT_EQ(kDecodableSession, InsertPacketAndPop(0)); 2530 EXPECT_EQ(kDecodableSession, InsertPacketAndPop(0));
2564 EXPECT_EQ(0, stream_generator_->PacketsRemaining()); 2531 EXPECT_EQ(0, stream_generator_->PacketsRemaining());
2565 EXPECT_FALSE(DecodeCompleteFrame()); 2532 EXPECT_FALSE(DecodeCompleteFrame());
2566 EXPECT_FALSE(DecodeIncompleteFrame()); 2533 EXPECT_FALSE(DecodeIncompleteFrame());
2567 bool request_key_frame = false; 2534 bool request_key_frame = false;
2568 2535
2569 // Verify the NACK list. 2536 // Verify the NACK list.
2570 std::vector<uint16_t> nack_list = 2537 std::vector<uint16_t> nack_list =
2571 jitter_buffer_->GetNackList(&request_key_frame); 2538 jitter_buffer_->GetNackList(&request_key_frame);
2572 const size_t kExpectedNackSize = 9; 2539 const size_t kExpectedNackSize = 9;
2573 if (field_trial::FindFullName("WebRTC-NewVideoJitterBuffer") == "Enabled") 2540 ASSERT_EQ(kExpectedNackSize, nack_list.size());
2574 ASSERT_EQ(kExpectedNackSize, nack_sent_.size());
2575 else
2576 ASSERT_EQ(kExpectedNackSize, nack_list.size());
2577 for (size_t i = 0; i < nack_list.size(); ++i) 2541 for (size_t i = 0; i < nack_list.size(); ++i)
2578 EXPECT_EQ((1 + i) * 10, nack_list[i]); 2542 EXPECT_EQ((1 + i) * 10, nack_list[i]);
2579 } 2543 }
2580 2544
2581 TEST_P(TestJitterBufferNack, NormalOperationWrap) { 2545 TEST_F(TestJitterBufferNack, NormalOperationWrap) {
2582 bool request_key_frame = false; 2546 bool request_key_frame = false;
2583 // ------- ------------------------------------------------------------ 2547 // ------- ------------------------------------------------------------
2584 // | 65532 | | 65533 | 65534 | 65535 | x | 1 | .. | 9 | x | 11 |.....| 96 | 2548 // | 65532 | | 65533 | 65534 | 65535 | x | 1 | .. | 9 | x | 11 |.....| 96 |
2585 // ------- ------------------------------------------------------------ 2549 // ------- ------------------------------------------------------------
2586 stream_generator_->Init(65532, clock_->TimeInMilliseconds()); 2550 stream_generator_->Init(65532, clock_->TimeInMilliseconds());
2587 InsertFrame(kVideoFrameKey); 2551 InsertFrame(kVideoFrameKey);
2588 EXPECT_FALSE(request_key_frame); 2552 EXPECT_FALSE(request_key_frame);
2589 EXPECT_TRUE(DecodeCompleteFrame()); 2553 EXPECT_TRUE(DecodeCompleteFrame());
2590 stream_generator_->GenerateFrame(kVideoFrameDelta, 100, 0, 2554 stream_generator_->GenerateFrame(kVideoFrameDelta, 100, 0,
2591 clock_->TimeInMilliseconds()); 2555 clock_->TimeInMilliseconds());
2592 EXPECT_EQ(kIncomplete, InsertPacketAndPop(0)); 2556 EXPECT_EQ(kIncomplete, InsertPacketAndPop(0));
2593 while (stream_generator_->PacketsRemaining() > 1) { 2557 while (stream_generator_->PacketsRemaining() > 1) {
2594 if (stream_generator_->NextSequenceNumber() % 10 != 0) { 2558 if (stream_generator_->NextSequenceNumber() % 10 != 0) {
2595 EXPECT_EQ(kIncomplete, InsertPacketAndPop(0)); 2559 EXPECT_EQ(kIncomplete, InsertPacketAndPop(0));
2596 EXPECT_FALSE(request_key_frame); 2560 EXPECT_FALSE(request_key_frame);
2597 } else { 2561 } else {
2598 stream_generator_->NextPacket(NULL); // Drop packet 2562 stream_generator_->NextPacket(NULL); // Drop packet
2599 } 2563 }
2600 } 2564 }
2601 EXPECT_EQ(kIncomplete, InsertPacketAndPop(0)); 2565 EXPECT_EQ(kIncomplete, InsertPacketAndPop(0));
2602 EXPECT_FALSE(request_key_frame); 2566 EXPECT_FALSE(request_key_frame);
2603 EXPECT_EQ(0, stream_generator_->PacketsRemaining()); 2567 EXPECT_EQ(0, stream_generator_->PacketsRemaining());
2604 EXPECT_FALSE(DecodeCompleteFrame()); 2568 EXPECT_FALSE(DecodeCompleteFrame());
2605 EXPECT_FALSE(DecodeCompleteFrame()); 2569 EXPECT_FALSE(DecodeCompleteFrame());
2606 bool extended = false; 2570 bool extended = false;
2607 std::vector<uint16_t> nack_list = jitter_buffer_->GetNackList(&extended); 2571 std::vector<uint16_t> nack_list = jitter_buffer_->GetNackList(&extended);
2608 // Verify the NACK list. 2572 // Verify the NACK list.
2609 const size_t kExpectedNackSize = 10; 2573 const size_t kExpectedNackSize = 10;
2610 if (field_trial::FindFullName("WebRTC-NewVideoJitterBuffer") == "Enabled") { 2574 ASSERT_EQ(kExpectedNackSize, nack_list.size());
2611 ASSERT_EQ(kExpectedNackSize, nack_sent_.size()); 2575 for (size_t i = 0; i < nack_list.size(); ++i)
2612 for (size_t i = 0; i < nack_sent_.size(); ++i) 2576 EXPECT_EQ(i * 10, nack_list[i]);
2613 EXPECT_EQ(i * 10, nack_sent_[i]);
2614 } else {
2615 ASSERT_EQ(kExpectedNackSize, nack_list.size());
2616 for (size_t i = 0; i < nack_list.size(); ++i)
2617 EXPECT_EQ(i * 10, nack_list[i]);
2618 }
2619 } 2577 }
2620 2578
2621 TEST_P(TestJitterBufferNack, NormalOperationWrap2) { 2579 TEST_F(TestJitterBufferNack, NormalOperationWrap2) {
2622 bool request_key_frame = false; 2580 bool request_key_frame = false;
2623 // ----------------------------------- 2581 // -----------------------------------
2624 // | 65532 | 65533 | 65534 | x | 0 | 1 | 2582 // | 65532 | 65533 | 65534 | x | 0 | 1 |
2625 // ----------------------------------- 2583 // -----------------------------------
2626 stream_generator_->Init(65532, clock_->TimeInMilliseconds()); 2584 stream_generator_->Init(65532, clock_->TimeInMilliseconds());
2627 InsertFrame(kVideoFrameKey); 2585 InsertFrame(kVideoFrameKey);
2628 EXPECT_FALSE(request_key_frame); 2586 EXPECT_FALSE(request_key_frame);
2629 EXPECT_TRUE(DecodeCompleteFrame()); 2587 EXPECT_TRUE(DecodeCompleteFrame());
2630 stream_generator_->GenerateFrame(kVideoFrameDelta, 1, 0, 2588 stream_generator_->GenerateFrame(kVideoFrameDelta, 1, 0,
2631 clock_->TimeInMilliseconds()); 2589 clock_->TimeInMilliseconds());
2632 clock_->AdvanceTimeMilliseconds(kDefaultFramePeriodMs); 2590 clock_->AdvanceTimeMilliseconds(kDefaultFramePeriodMs);
2633 for (int i = 0; i < 5; ++i) { 2591 for (int i = 0; i < 5; ++i) {
2634 if (stream_generator_->NextSequenceNumber() != 65535) { 2592 if (stream_generator_->NextSequenceNumber() != 65535) {
2635 EXPECT_EQ(kCompleteSession, InsertPacketAndPop(0)); 2593 EXPECT_EQ(kCompleteSession, InsertPacketAndPop(0));
2636 EXPECT_FALSE(request_key_frame); 2594 EXPECT_FALSE(request_key_frame);
2637 } else { 2595 } else {
2638 stream_generator_->NextPacket(NULL); // Drop packet 2596 stream_generator_->NextPacket(NULL); // Drop packet
2639 } 2597 }
2640 stream_generator_->GenerateFrame(kVideoFrameDelta, 1, 0, 2598 stream_generator_->GenerateFrame(kVideoFrameDelta, 1, 0,
2641 clock_->TimeInMilliseconds()); 2599 clock_->TimeInMilliseconds());
2642 clock_->AdvanceTimeMilliseconds(kDefaultFramePeriodMs); 2600 clock_->AdvanceTimeMilliseconds(kDefaultFramePeriodMs);
2643 } 2601 }
2644 EXPECT_EQ(kCompleteSession, InsertPacketAndPop(0)); 2602 EXPECT_EQ(kCompleteSession, InsertPacketAndPop(0));
2645 EXPECT_FALSE(request_key_frame); 2603 EXPECT_FALSE(request_key_frame);
2646 bool extended = false; 2604 bool extended = false;
2647 std::vector<uint16_t> nack_list = jitter_buffer_->GetNackList(&extended); 2605 std::vector<uint16_t> nack_list = jitter_buffer_->GetNackList(&extended);
2648 // Verify the NACK list. 2606 // Verify the NACK list.
2649 if (field_trial::FindFullName("WebRTC-NewVideoJitterBuffer") == "Enabled") { 2607 ASSERT_EQ(1u, nack_list.size());
2650 ASSERT_EQ(1u, nack_sent_.size()); 2608 EXPECT_EQ(65535, nack_list[0]);
2651 EXPECT_EQ(65535, nack_sent_[0]);
2652 } else {
2653 ASSERT_EQ(1u, nack_list.size());
2654 EXPECT_EQ(65535, nack_list[0]);
2655 }
2656 } 2609 }
2657 2610
2658 TEST_P(TestJitterBufferNack, ResetByFutureKeyFrameDoesntError) { 2611 TEST_F(TestJitterBufferNack, ResetByFutureKeyFrameDoesntError) {
2659 stream_generator_->Init(0, clock_->TimeInMilliseconds()); 2612 stream_generator_->Init(0, clock_->TimeInMilliseconds());
2660 InsertFrame(kVideoFrameKey); 2613 InsertFrame(kVideoFrameKey);
2661 EXPECT_TRUE(DecodeCompleteFrame()); 2614 EXPECT_TRUE(DecodeCompleteFrame());
2662 bool extended = false; 2615 bool extended = false;
2663 std::vector<uint16_t> nack_list = jitter_buffer_->GetNackList(&extended); 2616 std::vector<uint16_t> nack_list = jitter_buffer_->GetNackList(&extended);
2664 EXPECT_EQ(0u, nack_list.size()); 2617 EXPECT_EQ(0u, nack_list.size());
2665 2618
2666 // Far-into-the-future video frame, could be caused by resetting the encoder 2619 // Far-into-the-future video frame, could be caused by resetting the encoder
2667 // or otherwise restarting. This should not fail when error when the packet is 2620 // or otherwise restarting. This should not fail when error when the packet is
2668 // a keyframe, even if all of the nack list needs to be flushed. 2621 // a keyframe, even if all of the nack list needs to be flushed.
2669 stream_generator_->Init(10000, clock_->TimeInMilliseconds()); 2622 stream_generator_->Init(10000, clock_->TimeInMilliseconds());
2670 clock_->AdvanceTimeMilliseconds(kDefaultFramePeriodMs); 2623 clock_->AdvanceTimeMilliseconds(kDefaultFramePeriodMs);
2671 InsertFrame(kVideoFrameKey); 2624 InsertFrame(kVideoFrameKey);
2672 EXPECT_TRUE(DecodeCompleteFrame()); 2625 EXPECT_TRUE(DecodeCompleteFrame());
2673 nack_list = jitter_buffer_->GetNackList(&extended); 2626 nack_list = jitter_buffer_->GetNackList(&extended);
2674 EXPECT_EQ(0u, nack_list.size()); 2627 EXPECT_EQ(0u, nack_list.size());
2675 2628
2676 // Stream should be decodable from this point. 2629 // Stream should be decodable from this point.
2677 clock_->AdvanceTimeMilliseconds(kDefaultFramePeriodMs); 2630 clock_->AdvanceTimeMilliseconds(kDefaultFramePeriodMs);
2678 InsertFrame(kVideoFrameDelta); 2631 InsertFrame(kVideoFrameDelta);
2679 EXPECT_TRUE(DecodeCompleteFrame()); 2632 EXPECT_TRUE(DecodeCompleteFrame());
2680 nack_list = jitter_buffer_->GetNackList(&extended); 2633 nack_list = jitter_buffer_->GetNackList(&extended);
2681 EXPECT_EQ(0u, nack_list.size()); 2634 EXPECT_EQ(0u, nack_list.size());
2682 } 2635 }
2683 2636
2684 } // namespace webrtc 2637 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/jitter_buffer.cc ('k') | webrtc/modules/video_coding/receiver.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698