OLD | NEW |
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 22 matching lines...) Expand all Loading... |
33 | 33 |
34 namespace { | 34 namespace { |
35 const uint32_t kProcessIntervalSec = 60; | 35 const uint32_t kProcessIntervalSec = 60; |
36 } // namespace | 36 } // namespace |
37 | 37 |
38 class Vp9SsMapTest : public ::testing::Test { | 38 class Vp9SsMapTest : public ::testing::Test { |
39 protected: | 39 protected: |
40 Vp9SsMapTest() : packet_() {} | 40 Vp9SsMapTest() : packet_() {} |
41 | 41 |
42 virtual void SetUp() { | 42 virtual void SetUp() { |
43 packet_.isFirstPacket = true; | 43 packet_.is_first_packet_in_frame = true; |
44 packet_.dataPtr = data_; | 44 packet_.dataPtr = data_; |
45 packet_.sizeBytes = 1400; | 45 packet_.sizeBytes = 1400; |
46 packet_.seqNum = 1234; | 46 packet_.seqNum = 1234; |
47 packet_.timestamp = 1; | 47 packet_.timestamp = 1; |
48 packet_.markerBit = true; | 48 packet_.markerBit = true; |
49 packet_.frameType = kVideoFrameKey; | 49 packet_.frameType = kVideoFrameKey; |
50 packet_.codec = kVideoCodecVP9; | 50 packet_.codec = kVideoCodecVP9; |
51 packet_.video_header.codec = kRtpVideoVp9; | 51 packet_.video_header.codec = kRtpVideoVp9; |
52 packet_.video_header.codecHeader.VP9.flexible_mode = false; | 52 packet_.video_header.codecHeader.VP9.flexible_mode = false; |
53 packet_.video_header.codecHeader.VP9.gof_idx = 0; | 53 packet_.video_header.codecHeader.VP9.gof_idx = 0; |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
471 | 471 |
472 // No packets inserted. | 472 // No packets inserted. |
473 EXPECT_TRUE(NULL == DecodeCompleteFrame()); | 473 EXPECT_TRUE(NULL == DecodeCompleteFrame()); |
474 EXPECT_TRUE(NULL == DecodeIncompleteFrame()); | 474 EXPECT_TRUE(NULL == DecodeIncompleteFrame()); |
475 } | 475 } |
476 | 476 |
477 TEST_F(TestBasicJitterBuffer, SinglePacketFrame) { | 477 TEST_F(TestBasicJitterBuffer, SinglePacketFrame) { |
478 // Always start with a complete key frame when not allowing errors. | 478 // Always start with a complete key frame when not allowing errors. |
479 jitter_buffer_->SetDecodeErrorMode(kNoErrors); | 479 jitter_buffer_->SetDecodeErrorMode(kNoErrors); |
480 packet_->frameType = kVideoFrameKey; | 480 packet_->frameType = kVideoFrameKey; |
481 packet_->isFirstPacket = true; | 481 packet_->is_first_packet_in_frame = true; |
482 packet_->markerBit = true; | 482 packet_->markerBit = true; |
483 packet_->timestamp += 123 * 90; | 483 packet_->timestamp += 123 * 90; |
484 | 484 |
485 // Insert the packet to the jitter buffer and get a frame. | 485 // Insert the packet to the jitter buffer and get a frame. |
486 bool retransmitted = false; | 486 bool retransmitted = false; |
487 EXPECT_EQ(kCompleteSession, | 487 EXPECT_EQ(kCompleteSession, |
488 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 488 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
489 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); | 489 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); |
490 CheckOutFrame(frame_out, size_, false); | 490 CheckOutFrame(frame_out, size_, false); |
491 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); | 491 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); |
492 jitter_buffer_->ReleaseFrame(frame_out); | 492 jitter_buffer_->ReleaseFrame(frame_out); |
493 } | 493 } |
494 | 494 |
495 TEST_F(TestBasicJitterBuffer, VerifyHistogramStats) { | 495 TEST_F(TestBasicJitterBuffer, VerifyHistogramStats) { |
496 metrics::Reset(); | 496 metrics::Reset(); |
497 // Always start with a complete key frame when not allowing errors. | 497 // Always start with a complete key frame when not allowing errors. |
498 jitter_buffer_->SetDecodeErrorMode(kNoErrors); | 498 jitter_buffer_->SetDecodeErrorMode(kNoErrors); |
499 packet_->frameType = kVideoFrameKey; | 499 packet_->frameType = kVideoFrameKey; |
500 packet_->isFirstPacket = true; | 500 packet_->is_first_packet_in_frame = true; |
501 packet_->markerBit = true; | 501 packet_->markerBit = true; |
502 packet_->timestamp += 123 * 90; | 502 packet_->timestamp += 123 * 90; |
503 | 503 |
504 // Insert single packet frame to the jitter buffer and get a frame. | 504 // Insert single packet frame to the jitter buffer and get a frame. |
505 bool retransmitted = false; | 505 bool retransmitted = false; |
506 EXPECT_EQ(kCompleteSession, | 506 EXPECT_EQ(kCompleteSession, |
507 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 507 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
508 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); | 508 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); |
509 CheckOutFrame(frame_out, size_, false); | 509 CheckOutFrame(frame_out, size_, false); |
510 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); | 510 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); |
(...skipping 14 matching lines...) Expand all Loading... |
525 jitter_buffer_->Stop(); | 525 jitter_buffer_->Stop(); |
526 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.DiscardedPacketsInPercent")); | 526 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.DiscardedPacketsInPercent")); |
527 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.DuplicatedPacketsInPercent")); | 527 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.DuplicatedPacketsInPercent")); |
528 EXPECT_EQ( | 528 EXPECT_EQ( |
529 1, metrics::NumSamples("WebRTC.Video.CompleteFramesReceivedPerSecond")); | 529 1, metrics::NumSamples("WebRTC.Video.CompleteFramesReceivedPerSecond")); |
530 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.KeyFramesReceivedInPermille")); | 530 EXPECT_EQ(1, metrics::NumSamples("WebRTC.Video.KeyFramesReceivedInPermille")); |
531 } | 531 } |
532 | 532 |
533 TEST_F(TestBasicJitterBuffer, DualPacketFrame) { | 533 TEST_F(TestBasicJitterBuffer, DualPacketFrame) { |
534 packet_->frameType = kVideoFrameKey; | 534 packet_->frameType = kVideoFrameKey; |
535 packet_->isFirstPacket = true; | 535 packet_->is_first_packet_in_frame = true; |
536 packet_->markerBit = false; | 536 packet_->markerBit = false; |
537 | 537 |
538 bool retransmitted = false; | 538 bool retransmitted = false; |
539 EXPECT_EQ(kIncomplete, | 539 EXPECT_EQ(kIncomplete, |
540 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 540 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
541 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); | 541 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); |
542 // Should not be complete. | 542 // Should not be complete. |
543 EXPECT_TRUE(frame_out == NULL); | 543 EXPECT_TRUE(frame_out == NULL); |
544 | 544 |
545 ++seq_num_; | 545 ++seq_num_; |
546 packet_->isFirstPacket = false; | 546 packet_->is_first_packet_in_frame = false; |
547 packet_->markerBit = true; | 547 packet_->markerBit = true; |
548 packet_->seqNum = seq_num_; | 548 packet_->seqNum = seq_num_; |
549 | 549 |
550 EXPECT_EQ(kCompleteSession, | 550 EXPECT_EQ(kCompleteSession, |
551 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 551 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
552 | 552 |
553 frame_out = DecodeCompleteFrame(); | 553 frame_out = DecodeCompleteFrame(); |
554 CheckOutFrame(frame_out, 2 * size_, false); | 554 CheckOutFrame(frame_out, 2 * size_, false); |
555 | 555 |
556 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); | 556 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); |
557 jitter_buffer_->ReleaseFrame(frame_out); | 557 jitter_buffer_->ReleaseFrame(frame_out); |
558 } | 558 } |
559 | 559 |
560 TEST_F(TestBasicJitterBuffer, 100PacketKeyFrame) { | 560 TEST_F(TestBasicJitterBuffer, 100PacketKeyFrame) { |
561 packet_->frameType = kVideoFrameKey; | 561 packet_->frameType = kVideoFrameKey; |
562 packet_->isFirstPacket = true; | 562 packet_->is_first_packet_in_frame = true; |
563 packet_->markerBit = false; | 563 packet_->markerBit = false; |
564 | 564 |
565 bool retransmitted = false; | 565 bool retransmitted = false; |
566 EXPECT_EQ(kIncomplete, | 566 EXPECT_EQ(kIncomplete, |
567 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 567 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
568 | 568 |
569 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); | 569 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); |
570 | 570 |
571 // Frame should not be complete. | 571 // Frame should not be complete. |
572 EXPECT_TRUE(frame_out == NULL); | 572 EXPECT_TRUE(frame_out == NULL); |
573 | 573 |
574 // Insert 98 frames. | 574 // Insert 98 frames. |
575 int loop = 0; | 575 int loop = 0; |
576 do { | 576 do { |
577 seq_num_++; | 577 seq_num_++; |
578 packet_->isFirstPacket = false; | 578 packet_->is_first_packet_in_frame = false; |
579 packet_->markerBit = false; | 579 packet_->markerBit = false; |
580 packet_->seqNum = seq_num_; | 580 packet_->seqNum = seq_num_; |
581 | 581 |
582 EXPECT_EQ(kIncomplete, | 582 EXPECT_EQ(kIncomplete, |
583 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 583 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
584 loop++; | 584 loop++; |
585 } while (loop < 98); | 585 } while (loop < 98); |
586 | 586 |
587 // Insert last packet. | 587 // Insert last packet. |
588 ++seq_num_; | 588 ++seq_num_; |
589 packet_->isFirstPacket = false; | 589 packet_->is_first_packet_in_frame = false; |
590 packet_->markerBit = true; | 590 packet_->markerBit = true; |
591 packet_->seqNum = seq_num_; | 591 packet_->seqNum = seq_num_; |
592 | 592 |
593 EXPECT_EQ(kCompleteSession, | 593 EXPECT_EQ(kCompleteSession, |
594 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 594 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
595 | 595 |
596 frame_out = DecodeCompleteFrame(); | 596 frame_out = DecodeCompleteFrame(); |
597 | 597 |
598 CheckOutFrame(frame_out, 100 * size_, false); | 598 CheckOutFrame(frame_out, 100 * size_, false); |
599 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); | 599 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); |
600 jitter_buffer_->ReleaseFrame(frame_out); | 600 jitter_buffer_->ReleaseFrame(frame_out); |
601 } | 601 } |
602 | 602 |
603 TEST_F(TestBasicJitterBuffer, 100PacketDeltaFrame) { | 603 TEST_F(TestBasicJitterBuffer, 100PacketDeltaFrame) { |
604 // Always start with a complete key frame. | 604 // Always start with a complete key frame. |
605 packet_->frameType = kVideoFrameKey; | 605 packet_->frameType = kVideoFrameKey; |
606 packet_->isFirstPacket = true; | 606 packet_->is_first_packet_in_frame = true; |
607 packet_->markerBit = true; | 607 packet_->markerBit = true; |
608 | 608 |
609 bool retransmitted = false; | 609 bool retransmitted = false; |
610 EXPECT_EQ(kCompleteSession, | 610 EXPECT_EQ(kCompleteSession, |
611 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 611 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
612 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); | 612 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); |
613 EXPECT_FALSE(frame_out == NULL); | 613 EXPECT_FALSE(frame_out == NULL); |
614 jitter_buffer_->ReleaseFrame(frame_out); | 614 jitter_buffer_->ReleaseFrame(frame_out); |
615 | 615 |
616 ++seq_num_; | 616 ++seq_num_; |
617 packet_->seqNum = seq_num_; | 617 packet_->seqNum = seq_num_; |
618 packet_->markerBit = false; | 618 packet_->markerBit = false; |
619 packet_->frameType = kVideoFrameDelta; | 619 packet_->frameType = kVideoFrameDelta; |
620 packet_->timestamp += 33 * 90; | 620 packet_->timestamp += 33 * 90; |
621 | 621 |
622 EXPECT_EQ(kIncomplete, | 622 EXPECT_EQ(kIncomplete, |
623 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 623 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
624 | 624 |
625 frame_out = DecodeCompleteFrame(); | 625 frame_out = DecodeCompleteFrame(); |
626 | 626 |
627 // Frame should not be complete. | 627 // Frame should not be complete. |
628 EXPECT_TRUE(frame_out == NULL); | 628 EXPECT_TRUE(frame_out == NULL); |
629 | 629 |
630 packet_->isFirstPacket = false; | 630 packet_->is_first_packet_in_frame = false; |
631 // Insert 98 frames. | 631 // Insert 98 frames. |
632 int loop = 0; | 632 int loop = 0; |
633 do { | 633 do { |
634 ++seq_num_; | 634 ++seq_num_; |
635 packet_->seqNum = seq_num_; | 635 packet_->seqNum = seq_num_; |
636 | 636 |
637 // Insert a packet into a frame. | 637 // Insert a packet into a frame. |
638 EXPECT_EQ(kIncomplete, | 638 EXPECT_EQ(kIncomplete, |
639 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 639 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
640 loop++; | 640 loop++; |
641 } while (loop < 98); | 641 } while (loop < 98); |
642 | 642 |
643 // Insert the last packet. | 643 // Insert the last packet. |
644 ++seq_num_; | 644 ++seq_num_; |
645 packet_->isFirstPacket = false; | 645 packet_->is_first_packet_in_frame = false; |
646 packet_->markerBit = true; | 646 packet_->markerBit = true; |
647 packet_->seqNum = seq_num_; | 647 packet_->seqNum = seq_num_; |
648 | 648 |
649 EXPECT_EQ(kCompleteSession, | 649 EXPECT_EQ(kCompleteSession, |
650 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 650 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
651 | 651 |
652 frame_out = DecodeCompleteFrame(); | 652 frame_out = DecodeCompleteFrame(); |
653 | 653 |
654 CheckOutFrame(frame_out, 100 * size_, false); | 654 CheckOutFrame(frame_out, 100 * size_, false); |
655 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); | 655 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); |
656 jitter_buffer_->ReleaseFrame(frame_out); | 656 jitter_buffer_->ReleaseFrame(frame_out); |
657 } | 657 } |
658 | 658 |
659 TEST_F(TestBasicJitterBuffer, PacketReorderingReverseOrder) { | 659 TEST_F(TestBasicJitterBuffer, PacketReorderingReverseOrder) { |
660 // Insert the "first" packet last. | 660 // Insert the "first" packet last. |
661 seq_num_ += 100; | 661 seq_num_ += 100; |
662 packet_->frameType = kVideoFrameKey; | 662 packet_->frameType = kVideoFrameKey; |
663 packet_->isFirstPacket = false; | 663 packet_->is_first_packet_in_frame = false; |
664 packet_->markerBit = true; | 664 packet_->markerBit = true; |
665 packet_->seqNum = seq_num_; | 665 packet_->seqNum = seq_num_; |
666 packet_->timestamp = timestamp_; | 666 packet_->timestamp = timestamp_; |
667 | 667 |
668 bool retransmitted = false; | 668 bool retransmitted = false; |
669 EXPECT_EQ(kIncomplete, | 669 EXPECT_EQ(kIncomplete, |
670 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 670 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
671 | 671 |
672 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); | 672 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); |
673 | 673 |
674 EXPECT_TRUE(frame_out == NULL); | 674 EXPECT_TRUE(frame_out == NULL); |
675 | 675 |
676 // Insert 98 packets. | 676 // Insert 98 packets. |
677 int loop = 0; | 677 int loop = 0; |
678 do { | 678 do { |
679 seq_num_--; | 679 seq_num_--; |
680 packet_->isFirstPacket = false; | 680 packet_->is_first_packet_in_frame = false; |
681 packet_->markerBit = false; | 681 packet_->markerBit = false; |
682 packet_->seqNum = seq_num_; | 682 packet_->seqNum = seq_num_; |
683 | 683 |
684 EXPECT_EQ(kIncomplete, | 684 EXPECT_EQ(kIncomplete, |
685 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 685 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
686 loop++; | 686 loop++; |
687 } while (loop < 98); | 687 } while (loop < 98); |
688 | 688 |
689 // Insert the last packet. | 689 // Insert the last packet. |
690 seq_num_--; | 690 seq_num_--; |
691 packet_->isFirstPacket = true; | 691 packet_->is_first_packet_in_frame = true; |
692 packet_->markerBit = false; | 692 packet_->markerBit = false; |
693 packet_->seqNum = seq_num_; | 693 packet_->seqNum = seq_num_; |
694 | 694 |
695 EXPECT_EQ(kCompleteSession, | 695 EXPECT_EQ(kCompleteSession, |
696 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 696 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
697 | 697 |
698 frame_out = DecodeCompleteFrame(); | 698 frame_out = DecodeCompleteFrame(); |
699 | 699 |
700 CheckOutFrame(frame_out, 100 * size_, false); | 700 CheckOutFrame(frame_out, 100 * size_, false); |
701 | 701 |
702 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); | 702 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); |
703 jitter_buffer_->ReleaseFrame(frame_out); | 703 jitter_buffer_->ReleaseFrame(frame_out); |
704 } | 704 } |
705 | 705 |
706 TEST_F(TestBasicJitterBuffer, FrameReordering2Frames2PacketsEach) { | 706 TEST_F(TestBasicJitterBuffer, FrameReordering2Frames2PacketsEach) { |
707 packet_->frameType = kVideoFrameDelta; | 707 packet_->frameType = kVideoFrameDelta; |
708 packet_->isFirstPacket = true; | 708 packet_->is_first_packet_in_frame = true; |
709 packet_->markerBit = false; | 709 packet_->markerBit = false; |
710 | 710 |
711 bool retransmitted = false; | 711 bool retransmitted = false; |
712 EXPECT_EQ(kIncomplete, | 712 EXPECT_EQ(kIncomplete, |
713 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 713 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
714 | 714 |
715 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); | 715 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); |
716 | 716 |
717 EXPECT_TRUE(frame_out == NULL); | 717 EXPECT_TRUE(frame_out == NULL); |
718 | 718 |
719 seq_num_++; | 719 seq_num_++; |
720 packet_->isFirstPacket = false; | 720 packet_->is_first_packet_in_frame = false; |
721 packet_->markerBit = true; | 721 packet_->markerBit = true; |
722 packet_->seqNum = seq_num_; | 722 packet_->seqNum = seq_num_; |
723 | 723 |
724 EXPECT_EQ(kCompleteSession, | 724 EXPECT_EQ(kCompleteSession, |
725 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 725 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
726 | 726 |
727 // check that we fail to get frame since seqnum is not continuous | 727 // check that we fail to get frame since seqnum is not continuous |
728 frame_out = DecodeCompleteFrame(); | 728 frame_out = DecodeCompleteFrame(); |
729 EXPECT_TRUE(frame_out == NULL); | 729 EXPECT_TRUE(frame_out == NULL); |
730 | 730 |
731 seq_num_ -= 3; | 731 seq_num_ -= 3; |
732 timestamp_ -= 33 * 90; | 732 timestamp_ -= 33 * 90; |
733 packet_->frameType = kVideoFrameKey; | 733 packet_->frameType = kVideoFrameKey; |
734 packet_->isFirstPacket = true; | 734 packet_->is_first_packet_in_frame = true; |
735 packet_->markerBit = false; | 735 packet_->markerBit = false; |
736 packet_->seqNum = seq_num_; | 736 packet_->seqNum = seq_num_; |
737 packet_->timestamp = timestamp_; | 737 packet_->timestamp = timestamp_; |
738 | 738 |
739 EXPECT_EQ(kIncomplete, | 739 EXPECT_EQ(kIncomplete, |
740 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 740 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
741 | 741 |
742 frame_out = DecodeCompleteFrame(); | 742 frame_out = DecodeCompleteFrame(); |
743 | 743 |
744 // It should not be complete. | 744 // It should not be complete. |
745 EXPECT_TRUE(frame_out == NULL); | 745 EXPECT_TRUE(frame_out == NULL); |
746 | 746 |
747 seq_num_++; | 747 seq_num_++; |
748 packet_->isFirstPacket = false; | 748 packet_->is_first_packet_in_frame = false; |
749 packet_->markerBit = true; | 749 packet_->markerBit = true; |
750 packet_->seqNum = seq_num_; | 750 packet_->seqNum = seq_num_; |
751 | 751 |
752 EXPECT_EQ(kCompleteSession, | 752 EXPECT_EQ(kCompleteSession, |
753 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 753 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
754 | 754 |
755 frame_out = DecodeCompleteFrame(); | 755 frame_out = DecodeCompleteFrame(); |
756 CheckOutFrame(frame_out, 2 * size_, false); | 756 CheckOutFrame(frame_out, 2 * size_, false); |
757 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); | 757 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); |
758 jitter_buffer_->ReleaseFrame(frame_out); | 758 jitter_buffer_->ReleaseFrame(frame_out); |
759 | 759 |
760 frame_out = DecodeCompleteFrame(); | 760 frame_out = DecodeCompleteFrame(); |
761 CheckOutFrame(frame_out, 2 * size_, false); | 761 CheckOutFrame(frame_out, 2 * size_, false); |
762 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); | 762 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); |
763 jitter_buffer_->ReleaseFrame(frame_out); | 763 jitter_buffer_->ReleaseFrame(frame_out); |
764 } | 764 } |
765 | 765 |
766 TEST_F(TestBasicJitterBuffer, TestReorderingWithPadding) { | 766 TEST_F(TestBasicJitterBuffer, TestReorderingWithPadding) { |
767 packet_->frameType = kVideoFrameKey; | 767 packet_->frameType = kVideoFrameKey; |
768 packet_->isFirstPacket = true; | 768 packet_->is_first_packet_in_frame = true; |
769 packet_->markerBit = true; | 769 packet_->markerBit = true; |
770 | 770 |
771 // Send in an initial good packet/frame (Frame A) to start things off. | 771 // Send in an initial good packet/frame (Frame A) to start things off. |
772 bool retransmitted = false; | 772 bool retransmitted = false; |
773 EXPECT_EQ(kCompleteSession, | 773 EXPECT_EQ(kCompleteSession, |
774 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 774 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
775 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); | 775 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); |
776 EXPECT_TRUE(frame_out != NULL); | 776 EXPECT_TRUE(frame_out != NULL); |
777 jitter_buffer_->ReleaseFrame(frame_out); | 777 jitter_buffer_->ReleaseFrame(frame_out); |
778 | 778 |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
820 jitter_buffer_->InsertPacket(empty_packet, &retransmitted)); | 820 jitter_buffer_->InsertPacket(empty_packet, &retransmitted)); |
821 | 821 |
822 // But now Frame C should be ready! | 822 // But now Frame C should be ready! |
823 frame_out = DecodeCompleteFrame(); | 823 frame_out = DecodeCompleteFrame(); |
824 EXPECT_TRUE(frame_out != NULL); | 824 EXPECT_TRUE(frame_out != NULL); |
825 jitter_buffer_->ReleaseFrame(frame_out); | 825 jitter_buffer_->ReleaseFrame(frame_out); |
826 } | 826 } |
827 | 827 |
828 TEST_F(TestBasicJitterBuffer, DuplicatePackets) { | 828 TEST_F(TestBasicJitterBuffer, DuplicatePackets) { |
829 packet_->frameType = kVideoFrameKey; | 829 packet_->frameType = kVideoFrameKey; |
830 packet_->isFirstPacket = true; | 830 packet_->is_first_packet_in_frame = true; |
831 packet_->markerBit = false; | 831 packet_->markerBit = false; |
832 packet_->seqNum = seq_num_; | 832 packet_->seqNum = seq_num_; |
833 packet_->timestamp = timestamp_; | 833 packet_->timestamp = timestamp_; |
834 EXPECT_EQ(0, jitter_buffer_->num_packets()); | 834 EXPECT_EQ(0, jitter_buffer_->num_packets()); |
835 EXPECT_EQ(0, jitter_buffer_->num_duplicated_packets()); | 835 EXPECT_EQ(0, jitter_buffer_->num_duplicated_packets()); |
836 | 836 |
837 bool retransmitted = false; | 837 bool retransmitted = false; |
838 EXPECT_EQ(kIncomplete, | 838 EXPECT_EQ(kIncomplete, |
839 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 839 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
840 | 840 |
841 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); | 841 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); |
842 | 842 |
843 EXPECT_TRUE(frame_out == NULL); | 843 EXPECT_TRUE(frame_out == NULL); |
844 EXPECT_EQ(1, jitter_buffer_->num_packets()); | 844 EXPECT_EQ(1, jitter_buffer_->num_packets()); |
845 EXPECT_EQ(0, jitter_buffer_->num_duplicated_packets()); | 845 EXPECT_EQ(0, jitter_buffer_->num_duplicated_packets()); |
846 | 846 |
847 // Insert a packet into a frame. | 847 // Insert a packet into a frame. |
848 EXPECT_EQ(kDuplicatePacket, | 848 EXPECT_EQ(kDuplicatePacket, |
849 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 849 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
850 EXPECT_EQ(2, jitter_buffer_->num_packets()); | 850 EXPECT_EQ(2, jitter_buffer_->num_packets()); |
851 EXPECT_EQ(1, jitter_buffer_->num_duplicated_packets()); | 851 EXPECT_EQ(1, jitter_buffer_->num_duplicated_packets()); |
852 | 852 |
853 seq_num_++; | 853 seq_num_++; |
854 packet_->seqNum = seq_num_; | 854 packet_->seqNum = seq_num_; |
855 packet_->markerBit = true; | 855 packet_->markerBit = true; |
856 packet_->isFirstPacket = false; | 856 packet_->is_first_packet_in_frame = false; |
857 | 857 |
858 EXPECT_EQ(kCompleteSession, | 858 EXPECT_EQ(kCompleteSession, |
859 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 859 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
860 | 860 |
861 frame_out = DecodeCompleteFrame(); | 861 frame_out = DecodeCompleteFrame(); |
862 ASSERT_TRUE(frame_out != NULL); | 862 ASSERT_TRUE(frame_out != NULL); |
863 CheckOutFrame(frame_out, 2 * size_, false); | 863 CheckOutFrame(frame_out, 2 * size_, false); |
864 | 864 |
865 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); | 865 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); |
866 EXPECT_EQ(3, jitter_buffer_->num_packets()); | 866 EXPECT_EQ(3, jitter_buffer_->num_packets()); |
867 EXPECT_EQ(1, jitter_buffer_->num_duplicated_packets()); | 867 EXPECT_EQ(1, jitter_buffer_->num_duplicated_packets()); |
868 jitter_buffer_->ReleaseFrame(frame_out); | 868 jitter_buffer_->ReleaseFrame(frame_out); |
869 } | 869 } |
870 | 870 |
871 TEST_F(TestBasicJitterBuffer, DuplicatePreviousDeltaFramePacket) { | 871 TEST_F(TestBasicJitterBuffer, DuplicatePreviousDeltaFramePacket) { |
872 packet_->frameType = kVideoFrameKey; | 872 packet_->frameType = kVideoFrameKey; |
873 packet_->isFirstPacket = true; | 873 packet_->is_first_packet_in_frame = true; |
874 packet_->markerBit = true; | 874 packet_->markerBit = true; |
875 packet_->seqNum = seq_num_; | 875 packet_->seqNum = seq_num_; |
876 packet_->timestamp = timestamp_; | 876 packet_->timestamp = timestamp_; |
877 jitter_buffer_->SetDecodeErrorMode(kNoErrors); | 877 jitter_buffer_->SetDecodeErrorMode(kNoErrors); |
878 EXPECT_EQ(0, jitter_buffer_->num_packets()); | 878 EXPECT_EQ(0, jitter_buffer_->num_packets()); |
879 EXPECT_EQ(0, jitter_buffer_->num_duplicated_packets()); | 879 EXPECT_EQ(0, jitter_buffer_->num_duplicated_packets()); |
880 | 880 |
881 bool retransmitted = false; | 881 bool retransmitted = false; |
882 // Insert first complete frame. | 882 // Insert first complete frame. |
883 EXPECT_EQ(kCompleteSession, | 883 EXPECT_EQ(kCompleteSession, |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
926 // | 65485 | 65486 | 65487 | 65488 | 65489 | ... | 926 // | 65485 | 65486 | 65487 | 65488 | 65489 | ... |
927 // | pid:5 | pid:6 | pid:7 | pid:8 | pid:9 | ... | 927 // | pid:5 | pid:6 | pid:7 | pid:8 | pid:9 | ... |
928 // | tid:0 | tid:2 | tid:1 | tid:2 | tid:0 | ... | 928 // | tid:0 | tid:2 | tid:1 | tid:2 | tid:0 | ... |
929 // | ss | x | x | x | | | 929 // | ss | x | x | x | | |
930 // ------------------------------------------------- | 930 // ------------------------------------------------- |
931 // |<----------tl0idx:200--------->|<---tl0idx:201--- | 931 // |<----------tl0idx:200--------->|<---tl0idx:201--- |
932 | 932 |
933 bool re = false; | 933 bool re = false; |
934 packet_->codec = kVideoCodecVP9; | 934 packet_->codec = kVideoCodecVP9; |
935 packet_->video_header.codec = kRtpVideoVp9; | 935 packet_->video_header.codec = kRtpVideoVp9; |
936 packet_->isFirstPacket = true; | 936 packet_->is_first_packet_in_frame = true; |
937 packet_->markerBit = true; | 937 packet_->markerBit = true; |
938 packet_->video_header.codecHeader.VP9.flexible_mode = false; | 938 packet_->video_header.codecHeader.VP9.flexible_mode = false; |
939 packet_->video_header.codecHeader.VP9.spatial_idx = 0; | 939 packet_->video_header.codecHeader.VP9.spatial_idx = 0; |
940 packet_->video_header.codecHeader.VP9.beginning_of_frame = true; | 940 packet_->video_header.codecHeader.VP9.beginning_of_frame = true; |
941 packet_->video_header.codecHeader.VP9.end_of_frame = true; | 941 packet_->video_header.codecHeader.VP9.end_of_frame = true; |
942 packet_->video_header.codecHeader.VP9.temporal_up_switch = false; | 942 packet_->video_header.codecHeader.VP9.temporal_up_switch = false; |
943 | 943 |
944 packet_->seqNum = 65485; | 944 packet_->seqNum = 65485; |
945 packet_->timestamp = 1000; | 945 packet_->timestamp = 1000; |
946 packet_->frameType = kVideoFrameKey; | 946 packet_->frameType = kVideoFrameKey; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
979 // | 65486 | 65487 | 65485 |... | 979 // | 65486 | 65487 | 65485 |... |
980 // | pid:6 | pid:7 | pid:5 |... | 980 // | pid:6 | pid:7 | pid:5 |... |
981 // | tid:2 | tid:1 | tid:0 |... | 981 // | tid:2 | tid:1 | tid:0 |... |
982 // | | | ss | | 982 // | | | ss | |
983 // -------------------------------- | 983 // -------------------------------- |
984 // |<--------tl0idx:200--------->| | 984 // |<--------tl0idx:200--------->| |
985 | 985 |
986 bool re = false; | 986 bool re = false; |
987 packet_->codec = kVideoCodecVP9; | 987 packet_->codec = kVideoCodecVP9; |
988 packet_->video_header.codec = kRtpVideoVp9; | 988 packet_->video_header.codec = kRtpVideoVp9; |
989 packet_->isFirstPacket = true; | 989 packet_->is_first_packet_in_frame = true; |
990 packet_->markerBit = true; | 990 packet_->markerBit = true; |
991 packet_->video_header.codecHeader.VP9.flexible_mode = false; | 991 packet_->video_header.codecHeader.VP9.flexible_mode = false; |
992 packet_->video_header.codecHeader.VP9.spatial_idx = 0; | 992 packet_->video_header.codecHeader.VP9.spatial_idx = 0; |
993 packet_->video_header.codecHeader.VP9.beginning_of_frame = true; | 993 packet_->video_header.codecHeader.VP9.beginning_of_frame = true; |
994 packet_->video_header.codecHeader.VP9.end_of_frame = true; | 994 packet_->video_header.codecHeader.VP9.end_of_frame = true; |
995 packet_->video_header.codecHeader.VP9.tl0_pic_idx = 200; | 995 packet_->video_header.codecHeader.VP9.tl0_pic_idx = 200; |
996 | 996 |
997 packet_->seqNum = 65486; | 997 packet_->seqNum = 65486; |
998 packet_->timestamp = 6000; | 998 packet_->timestamp = 6000; |
999 packet_->frameType = kVideoFrameDelta; | 999 packet_->frameType = kVideoFrameDelta; |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1060 // |<-----------tl0idx:200------------>| | 1060 // |<-----------tl0idx:200------------>| |
1061 | 1061 |
1062 bool re = false; | 1062 bool re = false; |
1063 packet_->codec = kVideoCodecVP9; | 1063 packet_->codec = kVideoCodecVP9; |
1064 packet_->video_header.codec = kRtpVideoVp9; | 1064 packet_->video_header.codec = kRtpVideoVp9; |
1065 packet_->video_header.codecHeader.VP9.flexible_mode = false; | 1065 packet_->video_header.codecHeader.VP9.flexible_mode = false; |
1066 packet_->video_header.codecHeader.VP9.beginning_of_frame = true; | 1066 packet_->video_header.codecHeader.VP9.beginning_of_frame = true; |
1067 packet_->video_header.codecHeader.VP9.end_of_frame = true; | 1067 packet_->video_header.codecHeader.VP9.end_of_frame = true; |
1068 packet_->video_header.codecHeader.VP9.tl0_pic_idx = 200; | 1068 packet_->video_header.codecHeader.VP9.tl0_pic_idx = 200; |
1069 | 1069 |
1070 packet_->isFirstPacket = true; | 1070 packet_->is_first_packet_in_frame = true; |
1071 packet_->markerBit = false; | 1071 packet_->markerBit = false; |
1072 packet_->seqNum = 65486; | 1072 packet_->seqNum = 65486; |
1073 packet_->timestamp = 6000; | 1073 packet_->timestamp = 6000; |
1074 packet_->frameType = kVideoFrameDelta; | 1074 packet_->frameType = kVideoFrameDelta; |
1075 packet_->video_header.codecHeader.VP9.spatial_idx = 0; | 1075 packet_->video_header.codecHeader.VP9.spatial_idx = 0; |
1076 packet_->video_header.codecHeader.VP9.picture_id = 6; | 1076 packet_->video_header.codecHeader.VP9.picture_id = 6; |
1077 packet_->video_header.codecHeader.VP9.temporal_idx = 1; | 1077 packet_->video_header.codecHeader.VP9.temporal_idx = 1; |
1078 packet_->video_header.codecHeader.VP9.temporal_up_switch = true; | 1078 packet_->video_header.codecHeader.VP9.temporal_up_switch = true; |
1079 EXPECT_EQ(kIncomplete, jitter_buffer_->InsertPacket(*packet_, &re)); | 1079 EXPECT_EQ(kIncomplete, jitter_buffer_->InsertPacket(*packet_, &re)); |
1080 | 1080 |
1081 packet_->isFirstPacket = false; | 1081 packet_->is_first_packet_in_frame = false; |
1082 packet_->markerBit = true; | 1082 packet_->markerBit = true; |
1083 packet_->seqNum = 65487; | 1083 packet_->seqNum = 65487; |
1084 packet_->frameType = kVideoFrameDelta; | 1084 packet_->frameType = kVideoFrameDelta; |
1085 packet_->video_header.codecHeader.VP9.spatial_idx = 1; | 1085 packet_->video_header.codecHeader.VP9.spatial_idx = 1; |
1086 packet_->video_header.codecHeader.VP9.picture_id = 6; | 1086 packet_->video_header.codecHeader.VP9.picture_id = 6; |
1087 packet_->video_header.codecHeader.VP9.temporal_idx = 1; | 1087 packet_->video_header.codecHeader.VP9.temporal_idx = 1; |
1088 packet_->video_header.codecHeader.VP9.temporal_up_switch = true; | 1088 packet_->video_header.codecHeader.VP9.temporal_up_switch = true; |
1089 EXPECT_EQ(kCompleteSession, jitter_buffer_->InsertPacket(*packet_, &re)); | 1089 EXPECT_EQ(kCompleteSession, jitter_buffer_->InsertPacket(*packet_, &re)); |
1090 | 1090 |
1091 packet_->isFirstPacket = false; | 1091 packet_->is_first_packet_in_frame = false; |
1092 packet_->markerBit = true; | 1092 packet_->markerBit = true; |
1093 packet_->seqNum = 65485; | 1093 packet_->seqNum = 65485; |
1094 packet_->timestamp = 3000; | 1094 packet_->timestamp = 3000; |
1095 packet_->frameType = kVideoFrameKey; | 1095 packet_->frameType = kVideoFrameKey; |
1096 packet_->video_header.codecHeader.VP9.spatial_idx = 1; | 1096 packet_->video_header.codecHeader.VP9.spatial_idx = 1; |
1097 packet_->video_header.codecHeader.VP9.picture_id = 5; | 1097 packet_->video_header.codecHeader.VP9.picture_id = 5; |
1098 packet_->video_header.codecHeader.VP9.temporal_idx = 0; | 1098 packet_->video_header.codecHeader.VP9.temporal_idx = 0; |
1099 packet_->video_header.codecHeader.VP9.temporal_up_switch = false; | 1099 packet_->video_header.codecHeader.VP9.temporal_up_switch = false; |
1100 EXPECT_EQ(kIncomplete, jitter_buffer_->InsertPacket(*packet_, &re)); | 1100 EXPECT_EQ(kIncomplete, jitter_buffer_->InsertPacket(*packet_, &re)); |
1101 | 1101 |
1102 // Insert first frame with SS data. | 1102 // Insert first frame with SS data. |
1103 packet_->isFirstPacket = true; | 1103 packet_->is_first_packet_in_frame = true; |
1104 packet_->markerBit = false; | 1104 packet_->markerBit = false; |
1105 packet_->seqNum = 65484; | 1105 packet_->seqNum = 65484; |
1106 packet_->frameType = kVideoFrameKey; | 1106 packet_->frameType = kVideoFrameKey; |
1107 packet_->width = 352; | 1107 packet_->width = 352; |
1108 packet_->height = 288; | 1108 packet_->height = 288; |
1109 packet_->video_header.codecHeader.VP9.spatial_idx = 0; | 1109 packet_->video_header.codecHeader.VP9.spatial_idx = 0; |
1110 packet_->video_header.codecHeader.VP9.picture_id = 5; | 1110 packet_->video_header.codecHeader.VP9.picture_id = 5; |
1111 packet_->video_header.codecHeader.VP9.temporal_idx = 0; | 1111 packet_->video_header.codecHeader.VP9.temporal_idx = 0; |
1112 packet_->video_header.codecHeader.VP9.temporal_up_switch = false; | 1112 packet_->video_header.codecHeader.VP9.temporal_up_switch = false; |
1113 packet_->video_header.codecHeader.VP9.ss_data_available = true; | 1113 packet_->video_header.codecHeader.VP9.ss_data_available = true; |
(...skipping 12 matching lines...) Expand all Loading... |
1126 frame_out = DecodeCompleteFrame(); | 1126 frame_out = DecodeCompleteFrame(); |
1127 EXPECT_EQ(6000U, frame_out->TimeStamp()); | 1127 EXPECT_EQ(6000U, frame_out->TimeStamp()); |
1128 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); | 1128 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); |
1129 EXPECT_EQ(1, frame_out->CodecSpecific()->codecSpecific.VP9.temporal_idx); | 1129 EXPECT_EQ(1, frame_out->CodecSpecific()->codecSpecific.VP9.temporal_idx); |
1130 EXPECT_TRUE(frame_out->CodecSpecific()->codecSpecific.VP9.temporal_up_switch); | 1130 EXPECT_TRUE(frame_out->CodecSpecific()->codecSpecific.VP9.temporal_up_switch); |
1131 jitter_buffer_->ReleaseFrame(frame_out); | 1131 jitter_buffer_->ReleaseFrame(frame_out); |
1132 } | 1132 } |
1133 | 1133 |
1134 TEST_F(TestBasicJitterBuffer, H264InsertStartCode) { | 1134 TEST_F(TestBasicJitterBuffer, H264InsertStartCode) { |
1135 packet_->frameType = kVideoFrameKey; | 1135 packet_->frameType = kVideoFrameKey; |
1136 packet_->isFirstPacket = true; | 1136 packet_->is_first_packet_in_frame = true; |
1137 packet_->markerBit = false; | 1137 packet_->markerBit = false; |
1138 packet_->seqNum = seq_num_; | 1138 packet_->seqNum = seq_num_; |
1139 packet_->timestamp = timestamp_; | 1139 packet_->timestamp = timestamp_; |
1140 packet_->insertStartCode = true; | 1140 packet_->insertStartCode = true; |
1141 | 1141 |
1142 bool retransmitted = false; | 1142 bool retransmitted = false; |
1143 EXPECT_EQ(kIncomplete, | 1143 EXPECT_EQ(kIncomplete, |
1144 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1144 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1145 | 1145 |
1146 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); | 1146 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); |
1147 | 1147 |
1148 // Frame should not be complete. | 1148 // Frame should not be complete. |
1149 EXPECT_TRUE(frame_out == NULL); | 1149 EXPECT_TRUE(frame_out == NULL); |
1150 | 1150 |
1151 seq_num_++; | 1151 seq_num_++; |
1152 packet_->isFirstPacket = false; | 1152 packet_->is_first_packet_in_frame = false; |
1153 packet_->markerBit = true; | 1153 packet_->markerBit = true; |
1154 packet_->seqNum = seq_num_; | 1154 packet_->seqNum = seq_num_; |
1155 | 1155 |
1156 EXPECT_EQ(kCompleteSession, | 1156 EXPECT_EQ(kCompleteSession, |
1157 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1157 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1158 | 1158 |
1159 frame_out = DecodeCompleteFrame(); | 1159 frame_out = DecodeCompleteFrame(); |
1160 CheckOutFrame(frame_out, size_ * 2 + 4 * 2, true); | 1160 CheckOutFrame(frame_out, size_ * 2 + 4 * 2, true); |
1161 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); | 1161 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); |
1162 jitter_buffer_->ReleaseFrame(frame_out); | 1162 jitter_buffer_->ReleaseFrame(frame_out); |
1163 } | 1163 } |
1164 | 1164 |
1165 TEST_F(TestBasicJitterBuffer, SpsAndPpsHandling) { | 1165 TEST_F(TestBasicJitterBuffer, SpsAndPpsHandling) { |
1166 jitter_buffer_->SetDecodeErrorMode(kNoErrors); | 1166 jitter_buffer_->SetDecodeErrorMode(kNoErrors); |
1167 | 1167 |
1168 packet_->timestamp = timestamp_; | 1168 packet_->timestamp = timestamp_; |
1169 packet_->frameType = kVideoFrameKey; | 1169 packet_->frameType = kVideoFrameKey; |
1170 packet_->isFirstPacket = true; | 1170 packet_->is_first_packet_in_frame = true; |
1171 packet_->markerBit = true; | 1171 packet_->markerBit = true; |
1172 packet_->codec = kVideoCodecH264; | 1172 packet_->codec = kVideoCodecH264; |
1173 packet_->video_header.codec = kRtpVideoH264; | 1173 packet_->video_header.codec = kRtpVideoH264; |
1174 packet_->video_header.codecHeader.H264.nalu_type = H264::NaluType::kIdr; | 1174 packet_->video_header.codecHeader.H264.nalu_type = H264::NaluType::kIdr; |
1175 packet_->video_header.codecHeader.H264.nalus[0].type = H264::NaluType::kIdr; | 1175 packet_->video_header.codecHeader.H264.nalus[0].type = H264::NaluType::kIdr; |
1176 packet_->video_header.codecHeader.H264.nalus[0].sps_id = -1; | 1176 packet_->video_header.codecHeader.H264.nalus[0].sps_id = -1; |
1177 packet_->video_header.codecHeader.H264.nalus[0].pps_id = 0; | 1177 packet_->video_header.codecHeader.H264.nalus[0].pps_id = 0; |
1178 packet_->video_header.codecHeader.H264.nalus_length = 1; | 1178 packet_->video_header.codecHeader.H264.nalus_length = 1; |
1179 bool retransmitted = false; | 1179 bool retransmitted = false; |
1180 EXPECT_EQ(kCompleteSession, | 1180 EXPECT_EQ(kCompleteSession, |
1181 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1181 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1182 // Not decodable since sps and pps are missing. | 1182 // Not decodable since sps and pps are missing. |
1183 EXPECT_EQ(nullptr, DecodeCompleteFrame()); | 1183 EXPECT_EQ(nullptr, DecodeCompleteFrame()); |
1184 | 1184 |
1185 timestamp_ += 3000; | 1185 timestamp_ += 3000; |
1186 packet_->timestamp = timestamp_; | 1186 packet_->timestamp = timestamp_; |
1187 ++seq_num_; | 1187 ++seq_num_; |
1188 packet_->seqNum = seq_num_; | 1188 packet_->seqNum = seq_num_; |
1189 packet_->frameType = kVideoFrameKey; | 1189 packet_->frameType = kVideoFrameKey; |
1190 packet_->isFirstPacket = true; | 1190 packet_->is_first_packet_in_frame = true; |
1191 packet_->markerBit = false; | 1191 packet_->markerBit = false; |
1192 packet_->codec = kVideoCodecH264; | 1192 packet_->codec = kVideoCodecH264; |
1193 packet_->video_header.codec = kRtpVideoH264; | 1193 packet_->video_header.codec = kRtpVideoH264; |
1194 packet_->video_header.codecHeader.H264.nalu_type = H264::NaluType::kStapA; | 1194 packet_->video_header.codecHeader.H264.nalu_type = H264::NaluType::kStapA; |
1195 packet_->video_header.codecHeader.H264.nalus[0].type = H264::NaluType::kSps; | 1195 packet_->video_header.codecHeader.H264.nalus[0].type = H264::NaluType::kSps; |
1196 packet_->video_header.codecHeader.H264.nalus[0].sps_id = 0; | 1196 packet_->video_header.codecHeader.H264.nalus[0].sps_id = 0; |
1197 packet_->video_header.codecHeader.H264.nalus[0].pps_id = -1; | 1197 packet_->video_header.codecHeader.H264.nalus[0].pps_id = -1; |
1198 packet_->video_header.codecHeader.H264.nalus[1].type = H264::NaluType::kPps; | 1198 packet_->video_header.codecHeader.H264.nalus[1].type = H264::NaluType::kPps; |
1199 packet_->video_header.codecHeader.H264.nalus[1].sps_id = 0; | 1199 packet_->video_header.codecHeader.H264.nalus[1].sps_id = 0; |
1200 packet_->video_header.codecHeader.H264.nalus[1].pps_id = 0; | 1200 packet_->video_header.codecHeader.H264.nalus[1].pps_id = 0; |
1201 packet_->video_header.codecHeader.H264.nalus_length = 2; | 1201 packet_->video_header.codecHeader.H264.nalus_length = 2; |
1202 // Not complete since the marker bit hasn't been received. | 1202 // Not complete since the marker bit hasn't been received. |
1203 EXPECT_EQ(kIncomplete, | 1203 EXPECT_EQ(kIncomplete, |
1204 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1204 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1205 | 1205 |
1206 ++seq_num_; | 1206 ++seq_num_; |
1207 packet_->seqNum = seq_num_; | 1207 packet_->seqNum = seq_num_; |
1208 packet_->frameType = kVideoFrameKey; | 1208 packet_->frameType = kVideoFrameKey; |
1209 packet_->isFirstPacket = false; | 1209 packet_->is_first_packet_in_frame = false; |
1210 packet_->markerBit = true; | 1210 packet_->markerBit = true; |
1211 packet_->codec = kVideoCodecH264; | 1211 packet_->codec = kVideoCodecH264; |
1212 packet_->video_header.codec = kRtpVideoH264; | 1212 packet_->video_header.codec = kRtpVideoH264; |
1213 packet_->video_header.codecHeader.H264.nalu_type = H264::NaluType::kIdr; | 1213 packet_->video_header.codecHeader.H264.nalu_type = H264::NaluType::kIdr; |
1214 packet_->video_header.codecHeader.H264.nalus[0].type = H264::NaluType::kIdr; | 1214 packet_->video_header.codecHeader.H264.nalus[0].type = H264::NaluType::kIdr; |
1215 packet_->video_header.codecHeader.H264.nalus[0].sps_id = -1; | 1215 packet_->video_header.codecHeader.H264.nalus[0].sps_id = -1; |
1216 packet_->video_header.codecHeader.H264.nalus[0].pps_id = 0; | 1216 packet_->video_header.codecHeader.H264.nalus[0].pps_id = 0; |
1217 packet_->video_header.codecHeader.H264.nalus_length = 1; | 1217 packet_->video_header.codecHeader.H264.nalus_length = 1; |
1218 // Complete and decodable since the pps and sps are received in the first | 1218 // Complete and decodable since the pps and sps are received in the first |
1219 // packet of this frame. | 1219 // packet of this frame. |
1220 EXPECT_EQ(kCompleteSession, | 1220 EXPECT_EQ(kCompleteSession, |
1221 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1221 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1222 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); | 1222 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); |
1223 ASSERT_NE(nullptr, frame_out); | 1223 ASSERT_NE(nullptr, frame_out); |
1224 jitter_buffer_->ReleaseFrame(frame_out); | 1224 jitter_buffer_->ReleaseFrame(frame_out); |
1225 | 1225 |
1226 timestamp_ += 3000; | 1226 timestamp_ += 3000; |
1227 packet_->timestamp = timestamp_; | 1227 packet_->timestamp = timestamp_; |
1228 ++seq_num_; | 1228 ++seq_num_; |
1229 packet_->seqNum = seq_num_; | 1229 packet_->seqNum = seq_num_; |
1230 packet_->frameType = kVideoFrameDelta; | 1230 packet_->frameType = kVideoFrameDelta; |
1231 packet_->isFirstPacket = true; | 1231 packet_->is_first_packet_in_frame = true; |
1232 packet_->markerBit = true; | 1232 packet_->markerBit = true; |
1233 packet_->codec = kVideoCodecH264; | 1233 packet_->codec = kVideoCodecH264; |
1234 packet_->video_header.codec = kRtpVideoH264; | 1234 packet_->video_header.codec = kRtpVideoH264; |
1235 packet_->video_header.codecHeader.H264.nalu_type = H264::NaluType::kSlice; | 1235 packet_->video_header.codecHeader.H264.nalu_type = H264::NaluType::kSlice; |
1236 packet_->video_header.codecHeader.H264.nalus[0].type = H264::NaluType::kSlice; | 1236 packet_->video_header.codecHeader.H264.nalus[0].type = H264::NaluType::kSlice; |
1237 packet_->video_header.codecHeader.H264.nalus[0].sps_id = -1; | 1237 packet_->video_header.codecHeader.H264.nalus[0].sps_id = -1; |
1238 packet_->video_header.codecHeader.H264.nalus[0].pps_id = 0; | 1238 packet_->video_header.codecHeader.H264.nalus[0].pps_id = 0; |
1239 packet_->video_header.codecHeader.H264.nalus_length = 1; | 1239 packet_->video_header.codecHeader.H264.nalus_length = 1; |
1240 // Complete and decodable since sps, pps and key frame has been received. | 1240 // Complete and decodable since sps, pps and key frame has been received. |
1241 EXPECT_EQ(kCompleteSession, | 1241 EXPECT_EQ(kCompleteSession, |
1242 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1242 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1243 frame_out = DecodeCompleteFrame(); | 1243 frame_out = DecodeCompleteFrame(); |
1244 ASSERT_NE(nullptr, frame_out); | 1244 ASSERT_NE(nullptr, frame_out); |
1245 jitter_buffer_->ReleaseFrame(frame_out); | 1245 jitter_buffer_->ReleaseFrame(frame_out); |
1246 } | 1246 } |
1247 | 1247 |
1248 // Test threshold conditions of decodable state. | 1248 // Test threshold conditions of decodable state. |
1249 TEST_F(TestBasicJitterBuffer, PacketLossWithSelectiveErrorsThresholdCheck) { | 1249 TEST_F(TestBasicJitterBuffer, PacketLossWithSelectiveErrorsThresholdCheck) { |
1250 jitter_buffer_->SetDecodeErrorMode(kSelectiveErrors); | 1250 jitter_buffer_->SetDecodeErrorMode(kSelectiveErrors); |
1251 // Always start with a key frame. Use 10 packets to test Decodable State | 1251 // Always start with a key frame. Use 10 packets to test Decodable State |
1252 // boundaries. | 1252 // boundaries. |
1253 packet_->frameType = kVideoFrameKey; | 1253 packet_->frameType = kVideoFrameKey; |
1254 packet_->isFirstPacket = true; | 1254 packet_->is_first_packet_in_frame = true; |
1255 packet_->markerBit = false; | 1255 packet_->markerBit = false; |
1256 packet_->seqNum = seq_num_; | 1256 packet_->seqNum = seq_num_; |
1257 packet_->timestamp = timestamp_; | 1257 packet_->timestamp = timestamp_; |
1258 | 1258 |
1259 bool retransmitted = false; | 1259 bool retransmitted = false; |
1260 EXPECT_EQ(kIncomplete, | 1260 EXPECT_EQ(kIncomplete, |
1261 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1261 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1262 uint32_t timestamp = 0; | 1262 uint32_t timestamp = 0; |
1263 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr); | 1263 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr); |
1264 EXPECT_FALSE(jitter_buffer_->NextMaybeIncompleteTimestamp(×tamp)); | 1264 EXPECT_FALSE(jitter_buffer_->NextMaybeIncompleteTimestamp(×tamp)); |
1265 | 1265 |
1266 packet_->isFirstPacket = false; | 1266 packet_->is_first_packet_in_frame = false; |
1267 for (int i = 1; i < 9; ++i) { | 1267 for (int i = 1; i < 9; ++i) { |
1268 packet_->seqNum++; | 1268 packet_->seqNum++; |
1269 EXPECT_EQ(kIncomplete, | 1269 EXPECT_EQ(kIncomplete, |
1270 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1270 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1271 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr); | 1271 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr); |
1272 EXPECT_FALSE(jitter_buffer_->NextMaybeIncompleteTimestamp(×tamp)); | 1272 EXPECT_FALSE(jitter_buffer_->NextMaybeIncompleteTimestamp(×tamp)); |
1273 } | 1273 } |
1274 | 1274 |
1275 // last packet | 1275 // last packet |
1276 packet_->markerBit = true; | 1276 packet_->markerBit = true; |
1277 packet_->seqNum++; | 1277 packet_->seqNum++; |
1278 | 1278 |
1279 EXPECT_EQ(kCompleteSession, | 1279 EXPECT_EQ(kCompleteSession, |
1280 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1280 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1281 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); | 1281 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); |
1282 CheckOutFrame(frame_out, 10 * size_, false); | 1282 CheckOutFrame(frame_out, 10 * size_, false); |
1283 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); | 1283 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); |
1284 jitter_buffer_->ReleaseFrame(frame_out); | 1284 jitter_buffer_->ReleaseFrame(frame_out); |
1285 | 1285 |
1286 // An incomplete frame can only be decoded once a subsequent frame has begun | 1286 // An incomplete frame can only be decoded once a subsequent frame has begun |
1287 // to arrive. Insert packet in distant frame for this purpose. | 1287 // to arrive. Insert packet in distant frame for this purpose. |
1288 packet_->frameType = kVideoFrameDelta; | 1288 packet_->frameType = kVideoFrameDelta; |
1289 packet_->isFirstPacket = true; | 1289 packet_->is_first_packet_in_frame = true; |
1290 packet_->markerBit = false; | 1290 packet_->markerBit = false; |
1291 packet_->seqNum += 100; | 1291 packet_->seqNum += 100; |
1292 packet_->timestamp += 33 * 90 * 8; | 1292 packet_->timestamp += 33 * 90 * 8; |
1293 | 1293 |
1294 EXPECT_EQ(kDecodableSession, | 1294 EXPECT_EQ(kDecodableSession, |
1295 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1295 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1296 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr); | 1296 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr); |
1297 EXPECT_FALSE(jitter_buffer_->NextMaybeIncompleteTimestamp(×tamp)); | 1297 EXPECT_FALSE(jitter_buffer_->NextMaybeIncompleteTimestamp(×tamp)); |
1298 | 1298 |
1299 // Insert second frame | 1299 // Insert second frame |
1300 packet_->seqNum -= 99; | 1300 packet_->seqNum -= 99; |
1301 packet_->timestamp -= 33 * 90 * 7; | 1301 packet_->timestamp -= 33 * 90 * 7; |
1302 | 1302 |
1303 EXPECT_EQ(kDecodableSession, | 1303 EXPECT_EQ(kDecodableSession, |
1304 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1304 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1305 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr); | 1305 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr); |
1306 EXPECT_TRUE(jitter_buffer_->NextMaybeIncompleteTimestamp(×tamp)); | 1306 EXPECT_TRUE(jitter_buffer_->NextMaybeIncompleteTimestamp(×tamp)); |
1307 | 1307 |
1308 packet_->isFirstPacket = false; | 1308 packet_->is_first_packet_in_frame = false; |
1309 for (int i = 1; i < 8; ++i) { | 1309 for (int i = 1; i < 8; ++i) { |
1310 packet_->seqNum++; | 1310 packet_->seqNum++; |
1311 EXPECT_EQ(kDecodableSession, | 1311 EXPECT_EQ(kDecodableSession, |
1312 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1312 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1313 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr); | 1313 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr); |
1314 EXPECT_TRUE(jitter_buffer_->NextMaybeIncompleteTimestamp(×tamp)); | 1314 EXPECT_TRUE(jitter_buffer_->NextMaybeIncompleteTimestamp(×tamp)); |
1315 } | 1315 } |
1316 | 1316 |
1317 packet_->seqNum++; | 1317 packet_->seqNum++; |
1318 EXPECT_EQ(kDecodableSession, | 1318 EXPECT_EQ(kDecodableSession, |
(...skipping 10 matching lines...) Expand all Loading... |
1329 packet_->markerBit = true; | 1329 packet_->markerBit = true; |
1330 packet_->seqNum++; | 1330 packet_->seqNum++; |
1331 EXPECT_EQ(kOldPacket, jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1331 EXPECT_EQ(kOldPacket, jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1332 } | 1332 } |
1333 | 1333 |
1334 // Make sure first packet is present before a frame can be decoded. | 1334 // Make sure first packet is present before a frame can be decoded. |
1335 TEST_F(TestBasicJitterBuffer, PacketLossWithSelectiveErrorsIncompleteKey) { | 1335 TEST_F(TestBasicJitterBuffer, PacketLossWithSelectiveErrorsIncompleteKey) { |
1336 jitter_buffer_->SetDecodeErrorMode(kSelectiveErrors); | 1336 jitter_buffer_->SetDecodeErrorMode(kSelectiveErrors); |
1337 // Always start with a key frame. | 1337 // Always start with a key frame. |
1338 packet_->frameType = kVideoFrameKey; | 1338 packet_->frameType = kVideoFrameKey; |
1339 packet_->isFirstPacket = true; | 1339 packet_->is_first_packet_in_frame = true; |
1340 packet_->markerBit = true; | 1340 packet_->markerBit = true; |
1341 packet_->seqNum = seq_num_; | 1341 packet_->seqNum = seq_num_; |
1342 packet_->timestamp = timestamp_; | 1342 packet_->timestamp = timestamp_; |
1343 | 1343 |
1344 bool retransmitted = false; | 1344 bool retransmitted = false; |
1345 EXPECT_EQ(kCompleteSession, | 1345 EXPECT_EQ(kCompleteSession, |
1346 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1346 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1347 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); | 1347 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); |
1348 CheckOutFrame(frame_out, size_, false); | 1348 CheckOutFrame(frame_out, size_, false); |
1349 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); | 1349 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); |
1350 jitter_buffer_->ReleaseFrame(frame_out); | 1350 jitter_buffer_->ReleaseFrame(frame_out); |
1351 | 1351 |
1352 // An incomplete frame can only be decoded once a subsequent frame has begun | 1352 // An incomplete frame can only be decoded once a subsequent frame has begun |
1353 // to arrive. Insert packet in distant frame for this purpose. | 1353 // to arrive. Insert packet in distant frame for this purpose. |
1354 packet_->frameType = kVideoFrameDelta; | 1354 packet_->frameType = kVideoFrameDelta; |
1355 packet_->isFirstPacket = false; | 1355 packet_->is_first_packet_in_frame = false; |
1356 packet_->markerBit = false; | 1356 packet_->markerBit = false; |
1357 packet_->seqNum += 100; | 1357 packet_->seqNum += 100; |
1358 packet_->timestamp += 33 * 90 * 8; | 1358 packet_->timestamp += 33 * 90 * 8; |
1359 EXPECT_EQ(kIncomplete, | 1359 EXPECT_EQ(kIncomplete, |
1360 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1360 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1361 uint32_t timestamp; | 1361 uint32_t timestamp; |
1362 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr); | 1362 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr); |
1363 EXPECT_FALSE(jitter_buffer_->NextMaybeIncompleteTimestamp(×tamp)); | 1363 EXPECT_FALSE(jitter_buffer_->NextMaybeIncompleteTimestamp(×tamp)); |
1364 | 1364 |
1365 // Insert second frame - an incomplete key frame. | 1365 // Insert second frame - an incomplete key frame. |
1366 packet_->frameType = kVideoFrameKey; | 1366 packet_->frameType = kVideoFrameKey; |
1367 packet_->isFirstPacket = true; | 1367 packet_->is_first_packet_in_frame = true; |
1368 packet_->seqNum -= 99; | 1368 packet_->seqNum -= 99; |
1369 packet_->timestamp -= 33 * 90 * 7; | 1369 packet_->timestamp -= 33 * 90 * 7; |
1370 | 1370 |
1371 EXPECT_EQ(kIncomplete, | 1371 EXPECT_EQ(kIncomplete, |
1372 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1372 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1373 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr); | 1373 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr); |
1374 EXPECT_FALSE(jitter_buffer_->NextMaybeIncompleteTimestamp(×tamp)); | 1374 EXPECT_FALSE(jitter_buffer_->NextMaybeIncompleteTimestamp(×tamp)); |
1375 | 1375 |
1376 // Insert a few more packets. Make sure we're waiting for the key frame to be | 1376 // Insert a few more packets. Make sure we're waiting for the key frame to be |
1377 // complete. | 1377 // complete. |
1378 packet_->isFirstPacket = false; | 1378 packet_->is_first_packet_in_frame = false; |
1379 for (int i = 1; i < 5; ++i) { | 1379 for (int i = 1; i < 5; ++i) { |
1380 packet_->seqNum++; | 1380 packet_->seqNum++; |
1381 EXPECT_EQ(kIncomplete, | 1381 EXPECT_EQ(kIncomplete, |
1382 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1382 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1383 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr); | 1383 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr); |
1384 EXPECT_FALSE(jitter_buffer_->NextMaybeIncompleteTimestamp(×tamp)); | 1384 EXPECT_FALSE(jitter_buffer_->NextMaybeIncompleteTimestamp(×tamp)); |
1385 } | 1385 } |
1386 | 1386 |
1387 // Complete key frame. | 1387 // Complete key frame. |
1388 packet_->markerBit = true; | 1388 packet_->markerBit = true; |
1389 packet_->seqNum++; | 1389 packet_->seqNum++; |
1390 EXPECT_EQ(kCompleteSession, | 1390 EXPECT_EQ(kCompleteSession, |
1391 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1391 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1392 frame_out = DecodeCompleteFrame(); | 1392 frame_out = DecodeCompleteFrame(); |
1393 CheckOutFrame(frame_out, 6 * size_, false); | 1393 CheckOutFrame(frame_out, 6 * size_, false); |
1394 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); | 1394 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); |
1395 jitter_buffer_->ReleaseFrame(frame_out); | 1395 jitter_buffer_->ReleaseFrame(frame_out); |
1396 } | 1396 } |
1397 | 1397 |
1398 // Make sure first packet is present before a frame can be decoded. | 1398 // Make sure first packet is present before a frame can be decoded. |
1399 TEST_F(TestBasicJitterBuffer, PacketLossWithSelectiveErrorsMissingFirstPacket) { | 1399 TEST_F(TestBasicJitterBuffer, PacketLossWithSelectiveErrorsMissingFirstPacket) { |
1400 jitter_buffer_->SetDecodeErrorMode(kSelectiveErrors); | 1400 jitter_buffer_->SetDecodeErrorMode(kSelectiveErrors); |
1401 // Always start with a key frame. | 1401 // Always start with a key frame. |
1402 packet_->frameType = kVideoFrameKey; | 1402 packet_->frameType = kVideoFrameKey; |
1403 packet_->isFirstPacket = true; | 1403 packet_->is_first_packet_in_frame = true; |
1404 packet_->markerBit = true; | 1404 packet_->markerBit = true; |
1405 packet_->seqNum = seq_num_; | 1405 packet_->seqNum = seq_num_; |
1406 packet_->timestamp = timestamp_; | 1406 packet_->timestamp = timestamp_; |
1407 | 1407 |
1408 bool retransmitted = false; | 1408 bool retransmitted = false; |
1409 EXPECT_EQ(kCompleteSession, | 1409 EXPECT_EQ(kCompleteSession, |
1410 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1410 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1411 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); | 1411 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); |
1412 CheckOutFrame(frame_out, size_, false); | 1412 CheckOutFrame(frame_out, size_, false); |
1413 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); | 1413 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); |
1414 jitter_buffer_->ReleaseFrame(frame_out); | 1414 jitter_buffer_->ReleaseFrame(frame_out); |
1415 | 1415 |
1416 // An incomplete frame can only be decoded once a subsequent frame has begun | 1416 // An incomplete frame can only be decoded once a subsequent frame has begun |
1417 // to arrive. Insert packet in distant frame for this purpose. | 1417 // to arrive. Insert packet in distant frame for this purpose. |
1418 packet_->frameType = kVideoFrameDelta; | 1418 packet_->frameType = kVideoFrameDelta; |
1419 packet_->isFirstPacket = false; | 1419 packet_->is_first_packet_in_frame = false; |
1420 packet_->markerBit = false; | 1420 packet_->markerBit = false; |
1421 packet_->seqNum += 100; | 1421 packet_->seqNum += 100; |
1422 packet_->timestamp += 33 * 90 * 8; | 1422 packet_->timestamp += 33 * 90 * 8; |
1423 EXPECT_EQ(kIncomplete, | 1423 EXPECT_EQ(kIncomplete, |
1424 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1424 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1425 uint32_t timestamp; | 1425 uint32_t timestamp; |
1426 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr); | 1426 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr); |
1427 EXPECT_FALSE(jitter_buffer_->NextMaybeIncompleteTimestamp(×tamp)); | 1427 EXPECT_FALSE(jitter_buffer_->NextMaybeIncompleteTimestamp(×tamp)); |
1428 | 1428 |
1429 // Insert second frame with the first packet missing. Make sure we're waiting | 1429 // Insert second frame with the first packet missing. Make sure we're waiting |
1430 // for the key frame to be complete. | 1430 // for the key frame to be complete. |
1431 packet_->seqNum -= 98; | 1431 packet_->seqNum -= 98; |
1432 packet_->timestamp -= 33 * 90 * 7; | 1432 packet_->timestamp -= 33 * 90 * 7; |
1433 | 1433 |
1434 EXPECT_EQ(kIncomplete, | 1434 EXPECT_EQ(kIncomplete, |
1435 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1435 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1436 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr); | 1436 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr); |
1437 EXPECT_FALSE(jitter_buffer_->NextMaybeIncompleteTimestamp(×tamp)); | 1437 EXPECT_FALSE(jitter_buffer_->NextMaybeIncompleteTimestamp(×tamp)); |
1438 | 1438 |
1439 for (int i = 0; i < 5; ++i) { | 1439 for (int i = 0; i < 5; ++i) { |
1440 packet_->seqNum++; | 1440 packet_->seqNum++; |
1441 EXPECT_EQ(kIncomplete, | 1441 EXPECT_EQ(kIncomplete, |
1442 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1442 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1443 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr); | 1443 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr); |
1444 EXPECT_FALSE(jitter_buffer_->NextMaybeIncompleteTimestamp(×tamp)); | 1444 EXPECT_FALSE(jitter_buffer_->NextMaybeIncompleteTimestamp(×tamp)); |
1445 } | 1445 } |
1446 | 1446 |
1447 // Add first packet. Frame should now be decodable, but incomplete. | 1447 // Add first packet. Frame should now be decodable, but incomplete. |
1448 packet_->isFirstPacket = true; | 1448 packet_->is_first_packet_in_frame = true; |
1449 packet_->seqNum -= 6; | 1449 packet_->seqNum -= 6; |
1450 EXPECT_EQ(kDecodableSession, | 1450 EXPECT_EQ(kDecodableSession, |
1451 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1451 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1452 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr); | 1452 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr); |
1453 EXPECT_TRUE(jitter_buffer_->NextMaybeIncompleteTimestamp(×tamp)); | 1453 EXPECT_TRUE(jitter_buffer_->NextMaybeIncompleteTimestamp(×tamp)); |
1454 | 1454 |
1455 frame_out = DecodeIncompleteFrame(); | 1455 frame_out = DecodeIncompleteFrame(); |
1456 CheckOutFrame(frame_out, 7 * size_, false); | 1456 CheckOutFrame(frame_out, 7 * size_, false); |
1457 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); | 1457 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); |
1458 jitter_buffer_->ReleaseFrame(frame_out); | 1458 jitter_buffer_->ReleaseFrame(frame_out); |
1459 } | 1459 } |
1460 | 1460 |
1461 TEST_F(TestBasicJitterBuffer, DiscontinuousStreamWhenDecodingWithErrors) { | 1461 TEST_F(TestBasicJitterBuffer, DiscontinuousStreamWhenDecodingWithErrors) { |
1462 // Will use one packet per frame. | 1462 // Will use one packet per frame. |
1463 jitter_buffer_->SetDecodeErrorMode(kWithErrors); | 1463 jitter_buffer_->SetDecodeErrorMode(kWithErrors); |
1464 packet_->frameType = kVideoFrameKey; | 1464 packet_->frameType = kVideoFrameKey; |
1465 packet_->isFirstPacket = true; | 1465 packet_->is_first_packet_in_frame = true; |
1466 packet_->markerBit = true; | 1466 packet_->markerBit = true; |
1467 packet_->seqNum = seq_num_; | 1467 packet_->seqNum = seq_num_; |
1468 packet_->timestamp = timestamp_; | 1468 packet_->timestamp = timestamp_; |
1469 bool retransmitted = false; | 1469 bool retransmitted = false; |
1470 EXPECT_EQ(kCompleteSession, | 1470 EXPECT_EQ(kCompleteSession, |
1471 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1471 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1472 uint32_t next_timestamp; | 1472 uint32_t next_timestamp; |
1473 VCMEncodedFrame* frame = jitter_buffer_->NextCompleteFrame(0); | 1473 VCMEncodedFrame* frame = jitter_buffer_->NextCompleteFrame(0); |
1474 EXPECT_NE(frame, nullptr); | 1474 EXPECT_NE(frame, nullptr); |
1475 EXPECT_EQ(packet_->timestamp, frame->TimeStamp()); | 1475 EXPECT_EQ(packet_->timestamp, frame->TimeStamp()); |
1476 frame = jitter_buffer_->ExtractAndSetDecode(frame->TimeStamp()); | 1476 frame = jitter_buffer_->ExtractAndSetDecode(frame->TimeStamp()); |
1477 EXPECT_TRUE(frame != NULL); | 1477 EXPECT_TRUE(frame != NULL); |
1478 jitter_buffer_->ReleaseFrame(frame); | 1478 jitter_buffer_->ReleaseFrame(frame); |
1479 | 1479 |
1480 // Drop a complete frame. | 1480 // Drop a complete frame. |
1481 timestamp_ += 2 * 33 * 90; | 1481 timestamp_ += 2 * 33 * 90; |
1482 seq_num_ += 2; | 1482 seq_num_ += 2; |
1483 packet_->frameType = kVideoFrameDelta; | 1483 packet_->frameType = kVideoFrameDelta; |
1484 packet_->isFirstPacket = true; | 1484 packet_->is_first_packet_in_frame = true; |
1485 packet_->markerBit = false; | 1485 packet_->markerBit = false; |
1486 packet_->seqNum = seq_num_; | 1486 packet_->seqNum = seq_num_; |
1487 packet_->timestamp = timestamp_; | 1487 packet_->timestamp = timestamp_; |
1488 EXPECT_EQ(kDecodableSession, | 1488 EXPECT_EQ(kDecodableSession, |
1489 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1489 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1490 // Insert a packet (so the previous one will be released). | 1490 // Insert a packet (so the previous one will be released). |
1491 timestamp_ += 33 * 90; | 1491 timestamp_ += 33 * 90; |
1492 seq_num_ += 2; | 1492 seq_num_ += 2; |
1493 packet_->frameType = kVideoFrameDelta; | 1493 packet_->frameType = kVideoFrameDelta; |
1494 packet_->isFirstPacket = true; | 1494 packet_->is_first_packet_in_frame = true; |
1495 packet_->markerBit = false; | 1495 packet_->markerBit = false; |
1496 packet_->seqNum = seq_num_; | 1496 packet_->seqNum = seq_num_; |
1497 packet_->timestamp = timestamp_; | 1497 packet_->timestamp = timestamp_; |
1498 EXPECT_EQ(kDecodableSession, | 1498 EXPECT_EQ(kDecodableSession, |
1499 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1499 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1500 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr); | 1500 EXPECT_EQ(jitter_buffer_->NextCompleteFrame(0), nullptr); |
1501 EXPECT_TRUE(jitter_buffer_->NextMaybeIncompleteTimestamp(&next_timestamp)); | 1501 EXPECT_TRUE(jitter_buffer_->NextMaybeIncompleteTimestamp(&next_timestamp)); |
1502 EXPECT_EQ(packet_->timestamp - 33 * 90, next_timestamp); | 1502 EXPECT_EQ(packet_->timestamp - 33 * 90, next_timestamp); |
1503 } | 1503 } |
1504 | 1504 |
1505 TEST_F(TestBasicJitterBuffer, PacketLoss) { | 1505 TEST_F(TestBasicJitterBuffer, PacketLoss) { |
1506 // Verify missing packets statistics and not decodable packets statistics. | 1506 // Verify missing packets statistics and not decodable packets statistics. |
1507 // Insert 10 frames consisting of 4 packets and remove one from all of them. | 1507 // Insert 10 frames consisting of 4 packets and remove one from all of them. |
1508 // The last packet is an empty (non-media) packet. | 1508 // The last packet is an empty (non-media) packet. |
1509 | 1509 |
1510 // Select a start seqNum which triggers a difficult wrap situation | 1510 // Select a start seqNum which triggers a difficult wrap situation |
1511 // The JB will only output (incomplete)frames if the next one has started | 1511 // The JB will only output (incomplete)frames if the next one has started |
1512 // to arrive. Start by inserting one frame (key). | 1512 // to arrive. Start by inserting one frame (key). |
1513 jitter_buffer_->SetDecodeErrorMode(kWithErrors); | 1513 jitter_buffer_->SetDecodeErrorMode(kWithErrors); |
1514 seq_num_ = 0xffff - 4; | 1514 seq_num_ = 0xffff - 4; |
1515 seq_num_++; | 1515 seq_num_++; |
1516 packet_->frameType = kVideoFrameKey; | 1516 packet_->frameType = kVideoFrameKey; |
1517 packet_->isFirstPacket = true; | 1517 packet_->is_first_packet_in_frame = true; |
1518 packet_->markerBit = false; | 1518 packet_->markerBit = false; |
1519 packet_->seqNum = seq_num_; | 1519 packet_->seqNum = seq_num_; |
1520 packet_->timestamp = timestamp_; | 1520 packet_->timestamp = timestamp_; |
1521 packet_->completeNALU = kNaluStart; | 1521 packet_->completeNALU = kNaluStart; |
1522 | 1522 |
1523 bool retransmitted = false; | 1523 bool retransmitted = false; |
1524 EXPECT_EQ(kDecodableSession, | 1524 EXPECT_EQ(kDecodableSession, |
1525 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1525 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1526 for (int i = 0; i < 11; ++i) { | 1526 for (int i = 0; i < 11; ++i) { |
1527 webrtc::FrameType frametype = kVideoFrameDelta; | 1527 webrtc::FrameType frametype = kVideoFrameDelta; |
1528 seq_num_++; | 1528 seq_num_++; |
1529 timestamp_ += 33 * 90; | 1529 timestamp_ += 33 * 90; |
1530 packet_->frameType = frametype; | 1530 packet_->frameType = frametype; |
1531 packet_->isFirstPacket = true; | 1531 packet_->is_first_packet_in_frame = true; |
1532 packet_->markerBit = false; | 1532 packet_->markerBit = false; |
1533 packet_->seqNum = seq_num_; | 1533 packet_->seqNum = seq_num_; |
1534 packet_->timestamp = timestamp_; | 1534 packet_->timestamp = timestamp_; |
1535 packet_->completeNALU = kNaluStart; | 1535 packet_->completeNALU = kNaluStart; |
1536 | 1536 |
1537 EXPECT_EQ(kDecodableSession, | 1537 EXPECT_EQ(kDecodableSession, |
1538 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1538 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1539 | 1539 |
1540 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); | 1540 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); |
1541 | 1541 |
1542 // Should not be complete. | 1542 // Should not be complete. |
1543 EXPECT_TRUE(frame_out == NULL); | 1543 EXPECT_TRUE(frame_out == NULL); |
1544 | 1544 |
1545 seq_num_ += 2; | 1545 seq_num_ += 2; |
1546 packet_->isFirstPacket = false; | 1546 packet_->is_first_packet_in_frame = false; |
1547 packet_->markerBit = true; | 1547 packet_->markerBit = true; |
1548 packet_->seqNum = seq_num_; | 1548 packet_->seqNum = seq_num_; |
1549 packet_->completeNALU = kNaluEnd; | 1549 packet_->completeNALU = kNaluEnd; |
1550 | 1550 |
1551 EXPECT_EQ(jitter_buffer_->InsertPacket(*packet_, &retransmitted), | 1551 EXPECT_EQ(jitter_buffer_->InsertPacket(*packet_, &retransmitted), |
1552 kDecodableSession); | 1552 kDecodableSession); |
1553 | 1553 |
1554 // Insert an empty (non-media) packet. | 1554 // Insert an empty (non-media) packet. |
1555 seq_num_++; | 1555 seq_num_++; |
1556 packet_->isFirstPacket = false; | 1556 packet_->is_first_packet_in_frame = false; |
1557 packet_->markerBit = false; | 1557 packet_->markerBit = false; |
1558 packet_->seqNum = seq_num_; | 1558 packet_->seqNum = seq_num_; |
1559 packet_->completeNALU = kNaluEnd; | 1559 packet_->completeNALU = kNaluEnd; |
1560 packet_->frameType = kEmptyFrame; | 1560 packet_->frameType = kEmptyFrame; |
1561 | 1561 |
1562 EXPECT_EQ(jitter_buffer_->InsertPacket(*packet_, &retransmitted), | 1562 EXPECT_EQ(jitter_buffer_->InsertPacket(*packet_, &retransmitted), |
1563 kDecodableSession); | 1563 kDecodableSession); |
1564 frame_out = DecodeIncompleteFrame(); | 1564 frame_out = DecodeIncompleteFrame(); |
1565 | 1565 |
1566 // One of the packets has been discarded by the jitter buffer. | 1566 // One of the packets has been discarded by the jitter buffer. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1599 | 1599 |
1600 jitter_buffer_->Flush(); | 1600 jitter_buffer_->Flush(); |
1601 | 1601 |
1602 // This statistic shouldn't be reset by a flush. | 1602 // This statistic shouldn't be reset by a flush. |
1603 EXPECT_EQ(3, jitter_buffer_->num_discarded_packets()); | 1603 EXPECT_EQ(3, jitter_buffer_->num_discarded_packets()); |
1604 } | 1604 } |
1605 | 1605 |
1606 TEST_F(TestBasicJitterBuffer, DeltaFrame100PacketsWithSeqNumWrap) { | 1606 TEST_F(TestBasicJitterBuffer, DeltaFrame100PacketsWithSeqNumWrap) { |
1607 seq_num_ = 0xfff0; | 1607 seq_num_ = 0xfff0; |
1608 packet_->frameType = kVideoFrameKey; | 1608 packet_->frameType = kVideoFrameKey; |
1609 packet_->isFirstPacket = true; | 1609 packet_->is_first_packet_in_frame = true; |
1610 packet_->markerBit = false; | 1610 packet_->markerBit = false; |
1611 packet_->seqNum = seq_num_; | 1611 packet_->seqNum = seq_num_; |
1612 packet_->timestamp = timestamp_; | 1612 packet_->timestamp = timestamp_; |
1613 | 1613 |
1614 bool retransmitted = false; | 1614 bool retransmitted = false; |
1615 EXPECT_EQ(kIncomplete, | 1615 EXPECT_EQ(kIncomplete, |
1616 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1616 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1617 | 1617 |
1618 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); | 1618 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); |
1619 | 1619 |
1620 EXPECT_TRUE(frame_out == NULL); | 1620 EXPECT_TRUE(frame_out == NULL); |
1621 | 1621 |
1622 int loop = 0; | 1622 int loop = 0; |
1623 do { | 1623 do { |
1624 seq_num_++; | 1624 seq_num_++; |
1625 packet_->isFirstPacket = false; | 1625 packet_->is_first_packet_in_frame = false; |
1626 packet_->markerBit = false; | 1626 packet_->markerBit = false; |
1627 packet_->seqNum = seq_num_; | 1627 packet_->seqNum = seq_num_; |
1628 | 1628 |
1629 EXPECT_EQ(kIncomplete, | 1629 EXPECT_EQ(kIncomplete, |
1630 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1630 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1631 | 1631 |
1632 frame_out = DecodeCompleteFrame(); | 1632 frame_out = DecodeCompleteFrame(); |
1633 | 1633 |
1634 EXPECT_TRUE(frame_out == NULL); | 1634 EXPECT_TRUE(frame_out == NULL); |
1635 | 1635 |
1636 loop++; | 1636 loop++; |
1637 } while (loop < 98); | 1637 } while (loop < 98); |
1638 | 1638 |
1639 seq_num_++; | 1639 seq_num_++; |
1640 packet_->isFirstPacket = false; | 1640 packet_->is_first_packet_in_frame = false; |
1641 packet_->markerBit = true; | 1641 packet_->markerBit = true; |
1642 packet_->seqNum = seq_num_; | 1642 packet_->seqNum = seq_num_; |
1643 | 1643 |
1644 EXPECT_EQ(kCompleteSession, | 1644 EXPECT_EQ(kCompleteSession, |
1645 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1645 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1646 | 1646 |
1647 frame_out = DecodeCompleteFrame(); | 1647 frame_out = DecodeCompleteFrame(); |
1648 | 1648 |
1649 CheckOutFrame(frame_out, 100 * size_, false); | 1649 CheckOutFrame(frame_out, 100 * size_, false); |
1650 | 1650 |
1651 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); | 1651 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); |
1652 jitter_buffer_->ReleaseFrame(frame_out); | 1652 jitter_buffer_->ReleaseFrame(frame_out); |
1653 } | 1653 } |
1654 | 1654 |
1655 TEST_F(TestBasicJitterBuffer, PacketReorderingReverseWithNegSeqNumWrap) { | 1655 TEST_F(TestBasicJitterBuffer, PacketReorderingReverseWithNegSeqNumWrap) { |
1656 // Insert "first" packet last seqnum. | 1656 // Insert "first" packet last seqnum. |
1657 seq_num_ = 10; | 1657 seq_num_ = 10; |
1658 packet_->frameType = kVideoFrameKey; | 1658 packet_->frameType = kVideoFrameKey; |
1659 packet_->isFirstPacket = false; | 1659 packet_->is_first_packet_in_frame = false; |
1660 packet_->markerBit = true; | 1660 packet_->markerBit = true; |
1661 packet_->seqNum = seq_num_; | 1661 packet_->seqNum = seq_num_; |
1662 | 1662 |
1663 bool retransmitted = false; | 1663 bool retransmitted = false; |
1664 EXPECT_EQ(kIncomplete, | 1664 EXPECT_EQ(kIncomplete, |
1665 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1665 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1666 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); | 1666 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); |
1667 | 1667 |
1668 // Should not be complete. | 1668 // Should not be complete. |
1669 EXPECT_TRUE(frame_out == NULL); | 1669 EXPECT_TRUE(frame_out == NULL); |
1670 | 1670 |
1671 // Insert 98 frames. | 1671 // Insert 98 frames. |
1672 int loop = 0; | 1672 int loop = 0; |
1673 do { | 1673 do { |
1674 seq_num_--; | 1674 seq_num_--; |
1675 packet_->isFirstPacket = false; | 1675 packet_->is_first_packet_in_frame = false; |
1676 packet_->markerBit = false; | 1676 packet_->markerBit = false; |
1677 packet_->seqNum = seq_num_; | 1677 packet_->seqNum = seq_num_; |
1678 | 1678 |
1679 EXPECT_EQ(kIncomplete, | 1679 EXPECT_EQ(kIncomplete, |
1680 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1680 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1681 | 1681 |
1682 frame_out = DecodeCompleteFrame(); | 1682 frame_out = DecodeCompleteFrame(); |
1683 | 1683 |
1684 EXPECT_TRUE(frame_out == NULL); | 1684 EXPECT_TRUE(frame_out == NULL); |
1685 | 1685 |
1686 loop++; | 1686 loop++; |
1687 } while (loop < 98); | 1687 } while (loop < 98); |
1688 | 1688 |
1689 // Insert last packet. | 1689 // Insert last packet. |
1690 seq_num_--; | 1690 seq_num_--; |
1691 packet_->isFirstPacket = true; | 1691 packet_->is_first_packet_in_frame = true; |
1692 packet_->markerBit = false; | 1692 packet_->markerBit = false; |
1693 packet_->seqNum = seq_num_; | 1693 packet_->seqNum = seq_num_; |
1694 | 1694 |
1695 EXPECT_EQ(kCompleteSession, | 1695 EXPECT_EQ(kCompleteSession, |
1696 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1696 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1697 | 1697 |
1698 frame_out = DecodeCompleteFrame(); | 1698 frame_out = DecodeCompleteFrame(); |
1699 CheckOutFrame(frame_out, 100 * size_, false); | 1699 CheckOutFrame(frame_out, 100 * size_, false); |
1700 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); | 1700 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); |
1701 jitter_buffer_->ReleaseFrame(frame_out); | 1701 jitter_buffer_->ReleaseFrame(frame_out); |
1702 } | 1702 } |
1703 | 1703 |
1704 TEST_F(TestBasicJitterBuffer, TestInsertOldFrame) { | 1704 TEST_F(TestBasicJitterBuffer, TestInsertOldFrame) { |
1705 // ------- ------- | 1705 // ------- ------- |
1706 // | 2 | | 1 | | 1706 // | 2 | | 1 | |
1707 // ------- ------- | 1707 // ------- ------- |
1708 // t = 3000 t = 2000 | 1708 // t = 3000 t = 2000 |
1709 seq_num_ = 2; | 1709 seq_num_ = 2; |
1710 timestamp_ = 3000; | 1710 timestamp_ = 3000; |
1711 packet_->frameType = kVideoFrameKey; | 1711 packet_->frameType = kVideoFrameKey; |
1712 packet_->isFirstPacket = true; | 1712 packet_->is_first_packet_in_frame = true; |
1713 packet_->markerBit = true; | 1713 packet_->markerBit = true; |
1714 packet_->timestamp = timestamp_; | 1714 packet_->timestamp = timestamp_; |
1715 packet_->seqNum = seq_num_; | 1715 packet_->seqNum = seq_num_; |
1716 | 1716 |
1717 bool retransmitted = false; | 1717 bool retransmitted = false; |
1718 EXPECT_EQ(kCompleteSession, | 1718 EXPECT_EQ(kCompleteSession, |
1719 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1719 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1720 | 1720 |
1721 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); | 1721 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); |
1722 EXPECT_EQ(3000u, frame_out->TimeStamp()); | 1722 EXPECT_EQ(3000u, frame_out->TimeStamp()); |
1723 CheckOutFrame(frame_out, size_, false); | 1723 CheckOutFrame(frame_out, size_, false); |
1724 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); | 1724 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); |
1725 jitter_buffer_->ReleaseFrame(frame_out); | 1725 jitter_buffer_->ReleaseFrame(frame_out); |
1726 | 1726 |
1727 seq_num_--; | 1727 seq_num_--; |
1728 timestamp_ = 2000; | 1728 timestamp_ = 2000; |
1729 packet_->frameType = kVideoFrameDelta; | 1729 packet_->frameType = kVideoFrameDelta; |
1730 packet_->isFirstPacket = true; | 1730 packet_->is_first_packet_in_frame = true; |
1731 packet_->markerBit = true; | 1731 packet_->markerBit = true; |
1732 packet_->seqNum = seq_num_; | 1732 packet_->seqNum = seq_num_; |
1733 packet_->timestamp = timestamp_; | 1733 packet_->timestamp = timestamp_; |
1734 | 1734 |
1735 EXPECT_EQ(kOldPacket, jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1735 EXPECT_EQ(kOldPacket, jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1736 } | 1736 } |
1737 | 1737 |
1738 TEST_F(TestBasicJitterBuffer, TestInsertOldFrameWithSeqNumWrap) { | 1738 TEST_F(TestBasicJitterBuffer, TestInsertOldFrameWithSeqNumWrap) { |
1739 // ------- ------- | 1739 // ------- ------- |
1740 // | 2 | | 1 | | 1740 // | 2 | | 1 | |
1741 // ------- ------- | 1741 // ------- ------- |
1742 // t = 3000 t = 0xffffff00 | 1742 // t = 3000 t = 0xffffff00 |
1743 | 1743 |
1744 seq_num_ = 2; | 1744 seq_num_ = 2; |
1745 timestamp_ = 3000; | 1745 timestamp_ = 3000; |
1746 packet_->frameType = kVideoFrameKey; | 1746 packet_->frameType = kVideoFrameKey; |
1747 packet_->isFirstPacket = true; | 1747 packet_->is_first_packet_in_frame = true; |
1748 packet_->markerBit = true; | 1748 packet_->markerBit = true; |
1749 packet_->seqNum = seq_num_; | 1749 packet_->seqNum = seq_num_; |
1750 packet_->timestamp = timestamp_; | 1750 packet_->timestamp = timestamp_; |
1751 | 1751 |
1752 bool retransmitted = false; | 1752 bool retransmitted = false; |
1753 EXPECT_EQ(kCompleteSession, | 1753 EXPECT_EQ(kCompleteSession, |
1754 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1754 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1755 | 1755 |
1756 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); | 1756 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); |
1757 EXPECT_EQ(timestamp_, frame_out->TimeStamp()); | 1757 EXPECT_EQ(timestamp_, frame_out->TimeStamp()); |
1758 | 1758 |
1759 CheckOutFrame(frame_out, size_, false); | 1759 CheckOutFrame(frame_out, size_, false); |
1760 | 1760 |
1761 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); | 1761 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); |
1762 | 1762 |
1763 jitter_buffer_->ReleaseFrame(frame_out); | 1763 jitter_buffer_->ReleaseFrame(frame_out); |
1764 | 1764 |
1765 seq_num_--; | 1765 seq_num_--; |
1766 timestamp_ = 0xffffff00; | 1766 timestamp_ = 0xffffff00; |
1767 packet_->frameType = kVideoFrameDelta; | 1767 packet_->frameType = kVideoFrameDelta; |
1768 packet_->isFirstPacket = true; | 1768 packet_->is_first_packet_in_frame = true; |
1769 packet_->markerBit = true; | 1769 packet_->markerBit = true; |
1770 packet_->seqNum = seq_num_; | 1770 packet_->seqNum = seq_num_; |
1771 packet_->timestamp = timestamp_; | 1771 packet_->timestamp = timestamp_; |
1772 | 1772 |
1773 // This timestamp is old. | 1773 // This timestamp is old. |
1774 EXPECT_EQ(kOldPacket, jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1774 EXPECT_EQ(kOldPacket, jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1775 } | 1775 } |
1776 | 1776 |
1777 TEST_F(TestBasicJitterBuffer, TimestampWrap) { | 1777 TEST_F(TestBasicJitterBuffer, TimestampWrap) { |
1778 // --------------- --------------- | 1778 // --------------- --------------- |
1779 // | 1 | 2 | | 3 | 4 | | 1779 // | 1 | 2 | | 3 | 4 | |
1780 // --------------- --------------- | 1780 // --------------- --------------- |
1781 // t = 0xffffff00 t = 33*90 | 1781 // t = 0xffffff00 t = 33*90 |
1782 | 1782 |
1783 timestamp_ = 0xffffff00; | 1783 timestamp_ = 0xffffff00; |
1784 packet_->frameType = kVideoFrameKey; | 1784 packet_->frameType = kVideoFrameKey; |
1785 packet_->isFirstPacket = true; | 1785 packet_->is_first_packet_in_frame = true; |
1786 packet_->markerBit = false; | 1786 packet_->markerBit = false; |
1787 packet_->seqNum = seq_num_; | 1787 packet_->seqNum = seq_num_; |
1788 packet_->timestamp = timestamp_; | 1788 packet_->timestamp = timestamp_; |
1789 | 1789 |
1790 bool retransmitted = false; | 1790 bool retransmitted = false; |
1791 EXPECT_EQ(kIncomplete, | 1791 EXPECT_EQ(kIncomplete, |
1792 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1792 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1793 | 1793 |
1794 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); | 1794 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); |
1795 EXPECT_TRUE(frame_out == NULL); | 1795 EXPECT_TRUE(frame_out == NULL); |
1796 | 1796 |
1797 seq_num_++; | 1797 seq_num_++; |
1798 packet_->isFirstPacket = false; | 1798 packet_->is_first_packet_in_frame = false; |
1799 packet_->markerBit = true; | 1799 packet_->markerBit = true; |
1800 packet_->seqNum = seq_num_; | 1800 packet_->seqNum = seq_num_; |
1801 | 1801 |
1802 EXPECT_EQ(kCompleteSession, | 1802 EXPECT_EQ(kCompleteSession, |
1803 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1803 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1804 | 1804 |
1805 frame_out = DecodeCompleteFrame(); | 1805 frame_out = DecodeCompleteFrame(); |
1806 CheckOutFrame(frame_out, 2 * size_, false); | 1806 CheckOutFrame(frame_out, 2 * size_, false); |
1807 jitter_buffer_->ReleaseFrame(frame_out); | 1807 jitter_buffer_->ReleaseFrame(frame_out); |
1808 | 1808 |
1809 seq_num_++; | 1809 seq_num_++; |
1810 timestamp_ += 33 * 90; | 1810 timestamp_ += 33 * 90; |
1811 packet_->frameType = kVideoFrameDelta; | 1811 packet_->frameType = kVideoFrameDelta; |
1812 packet_->isFirstPacket = true; | 1812 packet_->is_first_packet_in_frame = true; |
1813 packet_->markerBit = false; | 1813 packet_->markerBit = false; |
1814 packet_->seqNum = seq_num_; | 1814 packet_->seqNum = seq_num_; |
1815 packet_->timestamp = timestamp_; | 1815 packet_->timestamp = timestamp_; |
1816 | 1816 |
1817 EXPECT_EQ(kIncomplete, | 1817 EXPECT_EQ(kIncomplete, |
1818 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1818 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1819 | 1819 |
1820 frame_out = DecodeCompleteFrame(); | 1820 frame_out = DecodeCompleteFrame(); |
1821 EXPECT_TRUE(frame_out == NULL); | 1821 EXPECT_TRUE(frame_out == NULL); |
1822 | 1822 |
1823 seq_num_++; | 1823 seq_num_++; |
1824 packet_->isFirstPacket = false; | 1824 packet_->is_first_packet_in_frame = false; |
1825 packet_->markerBit = true; | 1825 packet_->markerBit = true; |
1826 packet_->seqNum = seq_num_; | 1826 packet_->seqNum = seq_num_; |
1827 | 1827 |
1828 EXPECT_EQ(kCompleteSession, | 1828 EXPECT_EQ(kCompleteSession, |
1829 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1829 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1830 | 1830 |
1831 frame_out = DecodeCompleteFrame(); | 1831 frame_out = DecodeCompleteFrame(); |
1832 CheckOutFrame(frame_out, 2 * size_, false); | 1832 CheckOutFrame(frame_out, 2 * size_, false); |
1833 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); | 1833 EXPECT_EQ(kVideoFrameDelta, frame_out->FrameType()); |
1834 jitter_buffer_->ReleaseFrame(frame_out); | 1834 jitter_buffer_->ReleaseFrame(frame_out); |
1835 } | 1835 } |
1836 | 1836 |
1837 TEST_F(TestBasicJitterBuffer, 2FrameWithTimestampWrap) { | 1837 TEST_F(TestBasicJitterBuffer, 2FrameWithTimestampWrap) { |
1838 // ------- ------- | 1838 // ------- ------- |
1839 // | 1 | | 2 | | 1839 // | 1 | | 2 | |
1840 // ------- ------- | 1840 // ------- ------- |
1841 // t = 0xffffff00 t = 2700 | 1841 // t = 0xffffff00 t = 2700 |
1842 | 1842 |
1843 timestamp_ = 0xffffff00; | 1843 timestamp_ = 0xffffff00; |
1844 packet_->frameType = kVideoFrameKey; | 1844 packet_->frameType = kVideoFrameKey; |
1845 packet_->isFirstPacket = true; | 1845 packet_->is_first_packet_in_frame = true; |
1846 packet_->markerBit = true; | 1846 packet_->markerBit = true; |
1847 packet_->timestamp = timestamp_; | 1847 packet_->timestamp = timestamp_; |
1848 | 1848 |
1849 bool retransmitted = false; | 1849 bool retransmitted = false; |
1850 // Insert first frame (session will be complete). | 1850 // Insert first frame (session will be complete). |
1851 EXPECT_EQ(kCompleteSession, | 1851 EXPECT_EQ(kCompleteSession, |
1852 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1852 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1853 | 1853 |
1854 // Insert next frame. | 1854 // Insert next frame. |
1855 seq_num_++; | 1855 seq_num_++; |
1856 timestamp_ = 2700; | 1856 timestamp_ = 2700; |
1857 packet_->frameType = kVideoFrameDelta; | 1857 packet_->frameType = kVideoFrameDelta; |
1858 packet_->isFirstPacket = true; | 1858 packet_->is_first_packet_in_frame = true; |
1859 packet_->markerBit = true; | 1859 packet_->markerBit = true; |
1860 packet_->seqNum = seq_num_; | 1860 packet_->seqNum = seq_num_; |
1861 packet_->timestamp = timestamp_; | 1861 packet_->timestamp = timestamp_; |
1862 | 1862 |
1863 EXPECT_EQ(kCompleteSession, | 1863 EXPECT_EQ(kCompleteSession, |
1864 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1864 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1865 | 1865 |
1866 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); | 1866 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); |
1867 EXPECT_EQ(0xffffff00, frame_out->TimeStamp()); | 1867 EXPECT_EQ(0xffffff00, frame_out->TimeStamp()); |
1868 CheckOutFrame(frame_out, size_, false); | 1868 CheckOutFrame(frame_out, size_, false); |
1869 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); | 1869 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); |
1870 jitter_buffer_->ReleaseFrame(frame_out); | 1870 jitter_buffer_->ReleaseFrame(frame_out); |
1871 | 1871 |
1872 VCMEncodedFrame* frame_out2 = DecodeCompleteFrame(); | 1872 VCMEncodedFrame* frame_out2 = DecodeCompleteFrame(); |
1873 EXPECT_EQ(2700u, frame_out2->TimeStamp()); | 1873 EXPECT_EQ(2700u, frame_out2->TimeStamp()); |
1874 CheckOutFrame(frame_out2, size_, false); | 1874 CheckOutFrame(frame_out2, size_, false); |
1875 EXPECT_EQ(kVideoFrameDelta, frame_out2->FrameType()); | 1875 EXPECT_EQ(kVideoFrameDelta, frame_out2->FrameType()); |
1876 jitter_buffer_->ReleaseFrame(frame_out2); | 1876 jitter_buffer_->ReleaseFrame(frame_out2); |
1877 } | 1877 } |
1878 | 1878 |
1879 TEST_F(TestBasicJitterBuffer, Insert2FramesReOrderedWithTimestampWrap) { | 1879 TEST_F(TestBasicJitterBuffer, Insert2FramesReOrderedWithTimestampWrap) { |
1880 // ------- ------- | 1880 // ------- ------- |
1881 // | 2 | | 1 | | 1881 // | 2 | | 1 | |
1882 // ------- ------- | 1882 // ------- ------- |
1883 // t = 2700 t = 0xffffff00 | 1883 // t = 2700 t = 0xffffff00 |
1884 | 1884 |
1885 seq_num_ = 2; | 1885 seq_num_ = 2; |
1886 timestamp_ = 2700; | 1886 timestamp_ = 2700; |
1887 packet_->frameType = kVideoFrameDelta; | 1887 packet_->frameType = kVideoFrameDelta; |
1888 packet_->isFirstPacket = true; | 1888 packet_->is_first_packet_in_frame = true; |
1889 packet_->markerBit = true; | 1889 packet_->markerBit = true; |
1890 packet_->seqNum = seq_num_; | 1890 packet_->seqNum = seq_num_; |
1891 packet_->timestamp = timestamp_; | 1891 packet_->timestamp = timestamp_; |
1892 | 1892 |
1893 bool retransmitted = false; | 1893 bool retransmitted = false; |
1894 EXPECT_EQ(kCompleteSession, | 1894 EXPECT_EQ(kCompleteSession, |
1895 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1895 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1896 | 1896 |
1897 // Insert second frame | 1897 // Insert second frame |
1898 seq_num_--; | 1898 seq_num_--; |
1899 timestamp_ = 0xffffff00; | 1899 timestamp_ = 0xffffff00; |
1900 packet_->frameType = kVideoFrameKey; | 1900 packet_->frameType = kVideoFrameKey; |
1901 packet_->isFirstPacket = true; | 1901 packet_->is_first_packet_in_frame = true; |
1902 packet_->markerBit = true; | 1902 packet_->markerBit = true; |
1903 packet_->seqNum = seq_num_; | 1903 packet_->seqNum = seq_num_; |
1904 packet_->timestamp = timestamp_; | 1904 packet_->timestamp = timestamp_; |
1905 | 1905 |
1906 EXPECT_EQ(kCompleteSession, | 1906 EXPECT_EQ(kCompleteSession, |
1907 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1907 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1908 | 1908 |
1909 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); | 1909 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); |
1910 EXPECT_EQ(0xffffff00, frame_out->TimeStamp()); | 1910 EXPECT_EQ(0xffffff00, frame_out->TimeStamp()); |
1911 CheckOutFrame(frame_out, size_, false); | 1911 CheckOutFrame(frame_out, size_, false); |
1912 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); | 1912 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); |
1913 jitter_buffer_->ReleaseFrame(frame_out); | 1913 jitter_buffer_->ReleaseFrame(frame_out); |
1914 | 1914 |
1915 VCMEncodedFrame* frame_out2 = DecodeCompleteFrame(); | 1915 VCMEncodedFrame* frame_out2 = DecodeCompleteFrame(); |
1916 EXPECT_EQ(2700u, frame_out2->TimeStamp()); | 1916 EXPECT_EQ(2700u, frame_out2->TimeStamp()); |
1917 CheckOutFrame(frame_out2, size_, false); | 1917 CheckOutFrame(frame_out2, size_, false); |
1918 EXPECT_EQ(kVideoFrameDelta, frame_out2->FrameType()); | 1918 EXPECT_EQ(kVideoFrameDelta, frame_out2->FrameType()); |
1919 jitter_buffer_->ReleaseFrame(frame_out2); | 1919 jitter_buffer_->ReleaseFrame(frame_out2); |
1920 } | 1920 } |
1921 | 1921 |
1922 TEST_F(TestBasicJitterBuffer, DeltaFrameWithMoreThanMaxNumberOfPackets) { | 1922 TEST_F(TestBasicJitterBuffer, DeltaFrameWithMoreThanMaxNumberOfPackets) { |
1923 int loop = 0; | 1923 int loop = 0; |
1924 bool firstPacket = true; | 1924 bool firstPacket = true; |
1925 bool retransmitted = false; | 1925 bool retransmitted = false; |
1926 // Insert kMaxPacketsInJitterBuffer into frame. | 1926 // Insert kMaxPacketsInJitterBuffer into frame. |
1927 do { | 1927 do { |
1928 seq_num_++; | 1928 seq_num_++; |
1929 packet_->isFirstPacket = false; | 1929 packet_->is_first_packet_in_frame = false; |
1930 packet_->markerBit = false; | 1930 packet_->markerBit = false; |
1931 packet_->seqNum = seq_num_; | 1931 packet_->seqNum = seq_num_; |
1932 | 1932 |
1933 if (firstPacket) { | 1933 if (firstPacket) { |
1934 EXPECT_EQ(kIncomplete, | 1934 EXPECT_EQ(kIncomplete, |
1935 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1935 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1936 firstPacket = false; | 1936 firstPacket = false; |
1937 } else { | 1937 } else { |
1938 EXPECT_EQ(kIncomplete, | 1938 EXPECT_EQ(kIncomplete, |
1939 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1939 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1940 } | 1940 } |
1941 | 1941 |
1942 loop++; | 1942 loop++; |
1943 } while (loop < kMaxPacketsInSession); | 1943 } while (loop < kMaxPacketsInSession); |
1944 | 1944 |
1945 // Max number of packets inserted. | 1945 // Max number of packets inserted. |
1946 // Insert one more packet. | 1946 // Insert one more packet. |
1947 seq_num_++; | 1947 seq_num_++; |
1948 packet_->isFirstPacket = false; | 1948 packet_->is_first_packet_in_frame = false; |
1949 packet_->markerBit = true; | 1949 packet_->markerBit = true; |
1950 packet_->seqNum = seq_num_; | 1950 packet_->seqNum = seq_num_; |
1951 | 1951 |
1952 // Insert the packet -> frame recycled. | 1952 // Insert the packet -> frame recycled. |
1953 EXPECT_EQ(kSizeError, jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1953 EXPECT_EQ(kSizeError, jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1954 EXPECT_TRUE(NULL == DecodeCompleteFrame()); | 1954 EXPECT_TRUE(NULL == DecodeCompleteFrame()); |
1955 } | 1955 } |
1956 | 1956 |
1957 TEST_F(TestBasicJitterBuffer, ExceedNumOfFrameWithSeqNumWrap) { | 1957 TEST_F(TestBasicJitterBuffer, ExceedNumOfFrameWithSeqNumWrap) { |
1958 // TEST fill JB with more than max number of frame (50 delta frames + | 1958 // TEST fill JB with more than max number of frame (50 delta frames + |
(...skipping 10 matching lines...) Expand all Loading... |
1969 jitter_buffer_->SetNackSettings(kMaxNumberOfFrames, kMaxNumberOfFrames, 0); | 1969 jitter_buffer_->SetNackSettings(kMaxNumberOfFrames, kMaxNumberOfFrames, 0); |
1970 | 1970 |
1971 int loop = 0; | 1971 int loop = 0; |
1972 seq_num_ = 65485; | 1972 seq_num_ = 65485; |
1973 uint32_t first_key_frame_timestamp = 0; | 1973 uint32_t first_key_frame_timestamp = 0; |
1974 bool retransmitted = false; | 1974 bool retransmitted = false; |
1975 // Insert MAX_NUMBER_OF_FRAMES frames. | 1975 // Insert MAX_NUMBER_OF_FRAMES frames. |
1976 do { | 1976 do { |
1977 timestamp_ += 33 * 90; | 1977 timestamp_ += 33 * 90; |
1978 seq_num_++; | 1978 seq_num_++; |
1979 packet_->isFirstPacket = true; | 1979 packet_->is_first_packet_in_frame = true; |
1980 packet_->markerBit = true; | 1980 packet_->markerBit = true; |
1981 packet_->seqNum = seq_num_; | 1981 packet_->seqNum = seq_num_; |
1982 packet_->timestamp = timestamp_; | 1982 packet_->timestamp = timestamp_; |
1983 | 1983 |
1984 if (loop == 50) { | 1984 if (loop == 50) { |
1985 first_key_frame_timestamp = packet_->timestamp; | 1985 first_key_frame_timestamp = packet_->timestamp; |
1986 packet_->frameType = kVideoFrameKey; | 1986 packet_->frameType = kVideoFrameKey; |
1987 } | 1987 } |
1988 | 1988 |
1989 // Insert frame. | 1989 // Insert frame. |
1990 EXPECT_EQ(kCompleteSession, | 1990 EXPECT_EQ(kCompleteSession, |
1991 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 1991 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
1992 | 1992 |
1993 loop++; | 1993 loop++; |
1994 } while (loop < kMaxNumberOfFrames); | 1994 } while (loop < kMaxNumberOfFrames); |
1995 | 1995 |
1996 // Max number of frames inserted. | 1996 // Max number of frames inserted. |
1997 | 1997 |
1998 // Insert one more frame. | 1998 // Insert one more frame. |
1999 timestamp_ += 33 * 90; | 1999 timestamp_ += 33 * 90; |
2000 seq_num_++; | 2000 seq_num_++; |
2001 packet_->isFirstPacket = true; | 2001 packet_->is_first_packet_in_frame = true; |
2002 packet_->markerBit = true; | 2002 packet_->markerBit = true; |
2003 packet_->seqNum = seq_num_; | 2003 packet_->seqNum = seq_num_; |
2004 packet_->timestamp = timestamp_; | 2004 packet_->timestamp = timestamp_; |
2005 | 2005 |
2006 // Now, no free frame - frames will be recycled until first key frame. | 2006 // Now, no free frame - frames will be recycled until first key frame. |
2007 EXPECT_EQ(kFlushIndicator, | 2007 EXPECT_EQ(kFlushIndicator, |
2008 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 2008 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
2009 | 2009 |
2010 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); | 2010 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); |
2011 EXPECT_EQ(first_key_frame_timestamp, frame_out->TimeStamp()); | 2011 EXPECT_EQ(first_key_frame_timestamp, frame_out->TimeStamp()); |
2012 CheckOutFrame(frame_out, size_, false); | 2012 CheckOutFrame(frame_out, size_, false); |
2013 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); | 2013 EXPECT_EQ(kVideoFrameKey, frame_out->FrameType()); |
2014 jitter_buffer_->ReleaseFrame(frame_out); | 2014 jitter_buffer_->ReleaseFrame(frame_out); |
2015 } | 2015 } |
2016 | 2016 |
2017 TEST_F(TestBasicJitterBuffer, EmptyLastFrame) { | 2017 TEST_F(TestBasicJitterBuffer, EmptyLastFrame) { |
2018 jitter_buffer_->SetDecodeErrorMode(kWithErrors); | 2018 jitter_buffer_->SetDecodeErrorMode(kWithErrors); |
2019 seq_num_ = 3; | 2019 seq_num_ = 3; |
2020 // Insert one empty packet per frame, should never return the last timestamp | 2020 // Insert one empty packet per frame, should never return the last timestamp |
2021 // inserted. Only return empty frames in the presence of subsequent frames. | 2021 // inserted. Only return empty frames in the presence of subsequent frames. |
2022 int maxSize = 1000; | 2022 int maxSize = 1000; |
2023 bool retransmitted = false; | 2023 bool retransmitted = false; |
2024 for (int i = 0; i < maxSize + 10; i++) { | 2024 for (int i = 0; i < maxSize + 10; i++) { |
2025 timestamp_ += 33 * 90; | 2025 timestamp_ += 33 * 90; |
2026 seq_num_++; | 2026 seq_num_++; |
2027 packet_->isFirstPacket = false; | 2027 packet_->is_first_packet_in_frame = false; |
2028 packet_->markerBit = false; | 2028 packet_->markerBit = false; |
2029 packet_->seqNum = seq_num_; | 2029 packet_->seqNum = seq_num_; |
2030 packet_->timestamp = timestamp_; | 2030 packet_->timestamp = timestamp_; |
2031 packet_->frameType = kEmptyFrame; | 2031 packet_->frameType = kEmptyFrame; |
2032 | 2032 |
2033 EXPECT_EQ(kNoError, jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 2033 EXPECT_EQ(kNoError, jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
2034 VCMEncodedFrame* testFrame = DecodeIncompleteFrame(); | 2034 VCMEncodedFrame* testFrame = DecodeIncompleteFrame(); |
2035 // Timestamp should never be the last TS inserted. | 2035 // Timestamp should never be the last TS inserted. |
2036 if (testFrame != NULL) { | 2036 if (testFrame != NULL) { |
2037 EXPECT_TRUE(testFrame->TimeStamp() < timestamp_); | 2037 EXPECT_TRUE(testFrame->TimeStamp() < timestamp_); |
2038 jitter_buffer_->ReleaseFrame(testFrame); | 2038 jitter_buffer_->ReleaseFrame(testFrame); |
2039 } | 2039 } |
2040 } | 2040 } |
2041 } | 2041 } |
2042 | 2042 |
2043 TEST_F(TestBasicJitterBuffer, H264IncompleteNalu) { | 2043 TEST_F(TestBasicJitterBuffer, H264IncompleteNalu) { |
2044 jitter_buffer_->SetNackMode(kNoNack, -1, -1); | 2044 jitter_buffer_->SetNackMode(kNoNack, -1, -1); |
2045 jitter_buffer_->SetDecodeErrorMode(kWithErrors); | 2045 jitter_buffer_->SetDecodeErrorMode(kWithErrors); |
2046 ++seq_num_; | 2046 ++seq_num_; |
2047 timestamp_ += 33 * 90; | 2047 timestamp_ += 33 * 90; |
2048 int insertedLength = 0; | 2048 int insertedLength = 0; |
2049 packet_->seqNum = seq_num_; | 2049 packet_->seqNum = seq_num_; |
2050 packet_->timestamp = timestamp_; | 2050 packet_->timestamp = timestamp_; |
2051 packet_->frameType = kVideoFrameKey; | 2051 packet_->frameType = kVideoFrameKey; |
2052 packet_->isFirstPacket = true; | 2052 packet_->is_first_packet_in_frame = true; |
2053 packet_->completeNALU = kNaluStart; | 2053 packet_->completeNALU = kNaluStart; |
2054 packet_->markerBit = false; | 2054 packet_->markerBit = false; |
2055 bool retransmitted = false; | 2055 bool retransmitted = false; |
2056 | 2056 |
2057 EXPECT_EQ(kDecodableSession, | 2057 EXPECT_EQ(kDecodableSession, |
2058 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 2058 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
2059 | 2059 |
2060 seq_num_ += 2; // Skip one packet. | 2060 seq_num_ += 2; // Skip one packet. |
2061 packet_->seqNum = seq_num_; | 2061 packet_->seqNum = seq_num_; |
2062 packet_->frameType = kVideoFrameKey; | 2062 packet_->frameType = kVideoFrameKey; |
2063 packet_->isFirstPacket = false; | 2063 packet_->is_first_packet_in_frame = false; |
2064 packet_->completeNALU = kNaluIncomplete; | 2064 packet_->completeNALU = kNaluIncomplete; |
2065 packet_->markerBit = false; | 2065 packet_->markerBit = false; |
2066 | 2066 |
2067 EXPECT_EQ(kDecodableSession, | 2067 EXPECT_EQ(kDecodableSession, |
2068 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 2068 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
2069 | 2069 |
2070 seq_num_++; | 2070 seq_num_++; |
2071 packet_->seqNum = seq_num_; | 2071 packet_->seqNum = seq_num_; |
2072 packet_->frameType = kVideoFrameKey; | 2072 packet_->frameType = kVideoFrameKey; |
2073 packet_->isFirstPacket = false; | 2073 packet_->is_first_packet_in_frame = false; |
2074 packet_->completeNALU = kNaluEnd; | 2074 packet_->completeNALU = kNaluEnd; |
2075 packet_->markerBit = false; | 2075 packet_->markerBit = false; |
2076 | 2076 |
2077 EXPECT_EQ(kDecodableSession, | 2077 EXPECT_EQ(kDecodableSession, |
2078 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 2078 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
2079 | 2079 |
2080 seq_num_++; | 2080 seq_num_++; |
2081 packet_->seqNum = seq_num_; | 2081 packet_->seqNum = seq_num_; |
2082 packet_->completeNALU = kNaluComplete; | 2082 packet_->completeNALU = kNaluComplete; |
2083 packet_->markerBit = true; // Last packet. | 2083 packet_->markerBit = true; // Last packet. |
2084 EXPECT_EQ(kDecodableSession, | 2084 EXPECT_EQ(kDecodableSession, |
2085 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 2085 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
2086 // The JB will only output (incomplete) frames if a packet belonging to a | 2086 // The JB will only output (incomplete) frames if a packet belonging to a |
2087 // subsequent frame was already inserted. Insert one packet of a subsequent | 2087 // subsequent frame was already inserted. Insert one packet of a subsequent |
2088 // frame. place high timestamp so the JB would always have a next frame | 2088 // frame. place high timestamp so the JB would always have a next frame |
2089 // (otherwise, for every inserted frame we need to take care of the next | 2089 // (otherwise, for every inserted frame we need to take care of the next |
2090 // frame as well). | 2090 // frame as well). |
2091 packet_->seqNum = 1; | 2091 packet_->seqNum = 1; |
2092 packet_->timestamp = timestamp_ + 33 * 90 * 10; | 2092 packet_->timestamp = timestamp_ + 33 * 90 * 10; |
2093 packet_->frameType = kVideoFrameDelta; | 2093 packet_->frameType = kVideoFrameDelta; |
2094 packet_->isFirstPacket = false; | 2094 packet_->is_first_packet_in_frame = false; |
2095 packet_->completeNALU = kNaluStart; | 2095 packet_->completeNALU = kNaluStart; |
2096 packet_->markerBit = false; | 2096 packet_->markerBit = false; |
2097 | 2097 |
2098 EXPECT_EQ(kDecodableSession, | 2098 EXPECT_EQ(kDecodableSession, |
2099 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 2099 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
2100 | 2100 |
2101 VCMEncodedFrame* frame_out = DecodeIncompleteFrame(); | 2101 VCMEncodedFrame* frame_out = DecodeIncompleteFrame(); |
2102 | 2102 |
2103 // We can decode everything from a NALU until a packet has been lost. | 2103 // We can decode everything from a NALU until a packet has been lost. |
2104 // Thus we can decode the first packet of the first NALU and the second NALU | 2104 // Thus we can decode the first packet of the first NALU and the second NALU |
2105 // which consists of one packet. | 2105 // which consists of one packet. |
2106 CheckOutFrame(frame_out, packet_->sizeBytes * 2, false); | 2106 CheckOutFrame(frame_out, packet_->sizeBytes * 2, false); |
2107 jitter_buffer_->ReleaseFrame(frame_out); | 2107 jitter_buffer_->ReleaseFrame(frame_out); |
2108 | 2108 |
2109 // Test reordered start frame + 1 lost. | 2109 // Test reordered start frame + 1 lost. |
2110 seq_num_ += 2; // Re-order 1 frame. | 2110 seq_num_ += 2; // Re-order 1 frame. |
2111 timestamp_ += 33 * 90; | 2111 timestamp_ += 33 * 90; |
2112 insertedLength = 0; | 2112 insertedLength = 0; |
2113 | 2113 |
2114 packet_->seqNum = seq_num_; | 2114 packet_->seqNum = seq_num_; |
2115 packet_->timestamp = timestamp_; | 2115 packet_->timestamp = timestamp_; |
2116 packet_->frameType = kVideoFrameKey; | 2116 packet_->frameType = kVideoFrameKey; |
2117 packet_->isFirstPacket = false; | 2117 packet_->is_first_packet_in_frame = false; |
2118 packet_->completeNALU = kNaluEnd; | 2118 packet_->completeNALU = kNaluEnd; |
2119 packet_->markerBit = false; | 2119 packet_->markerBit = false; |
2120 EXPECT_EQ(kDecodableSession, | 2120 EXPECT_EQ(kDecodableSession, |
2121 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 2121 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
2122 insertedLength += packet_->sizeBytes; // This packet should be decoded. | 2122 insertedLength += packet_->sizeBytes; // This packet should be decoded. |
2123 seq_num_--; | 2123 seq_num_--; |
2124 packet_->seqNum = seq_num_; | 2124 packet_->seqNum = seq_num_; |
2125 packet_->timestamp = timestamp_; | 2125 packet_->timestamp = timestamp_; |
2126 packet_->frameType = kVideoFrameKey; | 2126 packet_->frameType = kVideoFrameKey; |
2127 packet_->isFirstPacket = true; | 2127 packet_->is_first_packet_in_frame = true; |
2128 packet_->completeNALU = kNaluStart; | 2128 packet_->completeNALU = kNaluStart; |
2129 packet_->markerBit = false; | 2129 packet_->markerBit = false; |
2130 | 2130 |
2131 EXPECT_EQ(kDecodableSession, | 2131 EXPECT_EQ(kDecodableSession, |
2132 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 2132 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
2133 insertedLength += packet_->sizeBytes; // This packet should be decoded. | 2133 insertedLength += packet_->sizeBytes; // This packet should be decoded. |
2134 | 2134 |
2135 seq_num_ += 3; // One packet drop. | 2135 seq_num_ += 3; // One packet drop. |
2136 packet_->seqNum = seq_num_; | 2136 packet_->seqNum = seq_num_; |
2137 packet_->timestamp = timestamp_; | 2137 packet_->timestamp = timestamp_; |
2138 packet_->frameType = kVideoFrameKey; | 2138 packet_->frameType = kVideoFrameKey; |
2139 packet_->isFirstPacket = false; | 2139 packet_->is_first_packet_in_frame = false; |
2140 packet_->completeNALU = kNaluComplete; | 2140 packet_->completeNALU = kNaluComplete; |
2141 packet_->markerBit = false; | 2141 packet_->markerBit = false; |
2142 EXPECT_EQ(kDecodableSession, | 2142 EXPECT_EQ(kDecodableSession, |
2143 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 2143 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
2144 insertedLength += packet_->sizeBytes; // This packet should be decoded. | 2144 insertedLength += packet_->sizeBytes; // This packet should be decoded. |
2145 seq_num_++; | 2145 seq_num_++; |
2146 packet_->seqNum = seq_num_; | 2146 packet_->seqNum = seq_num_; |
2147 packet_->timestamp = timestamp_; | 2147 packet_->timestamp = timestamp_; |
2148 packet_->frameType = kVideoFrameKey; | 2148 packet_->frameType = kVideoFrameKey; |
2149 packet_->isFirstPacket = false; | 2149 packet_->is_first_packet_in_frame = false; |
2150 packet_->completeNALU = kNaluStart; | 2150 packet_->completeNALU = kNaluStart; |
2151 packet_->markerBit = false; | 2151 packet_->markerBit = false; |
2152 EXPECT_EQ(kDecodableSession, | 2152 EXPECT_EQ(kDecodableSession, |
2153 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 2153 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
2154 // This packet should be decoded since it's the beginning of a NAL. | 2154 // This packet should be decoded since it's the beginning of a NAL. |
2155 insertedLength += packet_->sizeBytes; | 2155 insertedLength += packet_->sizeBytes; |
2156 | 2156 |
2157 seq_num_ += 2; | 2157 seq_num_ += 2; |
2158 packet_->seqNum = seq_num_; | 2158 packet_->seqNum = seq_num_; |
2159 packet_->timestamp = timestamp_; | 2159 packet_->timestamp = timestamp_; |
2160 packet_->frameType = kVideoFrameKey; | 2160 packet_->frameType = kVideoFrameKey; |
2161 packet_->isFirstPacket = false; | 2161 packet_->is_first_packet_in_frame = false; |
2162 packet_->completeNALU = kNaluEnd; | 2162 packet_->completeNALU = kNaluEnd; |
2163 packet_->markerBit = true; | 2163 packet_->markerBit = true; |
2164 EXPECT_EQ(kDecodableSession, | 2164 EXPECT_EQ(kDecodableSession, |
2165 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 2165 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
2166 // This packet should not be decoded because it is an incomplete NAL if it | 2166 // This packet should not be decoded because it is an incomplete NAL if it |
2167 // is the last. | 2167 // is the last. |
2168 frame_out = DecodeIncompleteFrame(); | 2168 frame_out = DecodeIncompleteFrame(); |
2169 // Only last NALU is complete. | 2169 // Only last NALU is complete. |
2170 CheckOutFrame(frame_out, insertedLength, false); | 2170 CheckOutFrame(frame_out, insertedLength, false); |
2171 jitter_buffer_->ReleaseFrame(frame_out); | 2171 jitter_buffer_->ReleaseFrame(frame_out); |
2172 | 2172 |
2173 // Test to insert empty packet. | 2173 // Test to insert empty packet. |
2174 seq_num_++; | 2174 seq_num_++; |
2175 timestamp_ += 33 * 90; | 2175 timestamp_ += 33 * 90; |
2176 WebRtcRTPHeader rtpHeader; | 2176 WebRtcRTPHeader rtpHeader; |
2177 memset(&rtpHeader, 0, sizeof(rtpHeader)); | 2177 memset(&rtpHeader, 0, sizeof(rtpHeader)); |
2178 VCMPacket emptypacket(data_, 0, rtpHeader); | 2178 VCMPacket emptypacket(data_, 0, rtpHeader); |
2179 emptypacket.seqNum = seq_num_; | 2179 emptypacket.seqNum = seq_num_; |
2180 emptypacket.timestamp = timestamp_; | 2180 emptypacket.timestamp = timestamp_; |
2181 emptypacket.frameType = kVideoFrameKey; | 2181 emptypacket.frameType = kVideoFrameKey; |
2182 emptypacket.isFirstPacket = true; | 2182 emptypacket.is_first_packet_in_frame = true; |
2183 emptypacket.completeNALU = kNaluComplete; | 2183 emptypacket.completeNALU = kNaluComplete; |
2184 emptypacket.markerBit = true; | 2184 emptypacket.markerBit = true; |
2185 EXPECT_EQ(kCompleteSession, | 2185 EXPECT_EQ(kCompleteSession, |
2186 jitter_buffer_->InsertPacket(emptypacket, &retransmitted)); | 2186 jitter_buffer_->InsertPacket(emptypacket, &retransmitted)); |
2187 // This packet should not be decoded because it is an incomplete NAL if it | 2187 // This packet should not be decoded because it is an incomplete NAL if it |
2188 // is the last. | 2188 // is the last. |
2189 | 2189 |
2190 // Will be sent to the decoder, as a packet belonging to a subsequent frame | 2190 // Will be sent to the decoder, as a packet belonging to a subsequent frame |
2191 // has arrived. | 2191 // has arrived. |
2192 frame_out = DecodeIncompleteFrame(); | 2192 frame_out = DecodeIncompleteFrame(); |
2193 EXPECT_TRUE(frame_out != NULL); | 2193 EXPECT_TRUE(frame_out != NULL); |
2194 jitter_buffer_->ReleaseFrame(frame_out); | 2194 jitter_buffer_->ReleaseFrame(frame_out); |
2195 | 2195 |
2196 // Test that a frame can include an empty packet. | 2196 // Test that a frame can include an empty packet. |
2197 seq_num_++; | 2197 seq_num_++; |
2198 timestamp_ += 33 * 90; | 2198 timestamp_ += 33 * 90; |
2199 | 2199 |
2200 packet_->seqNum = seq_num_; | 2200 packet_->seqNum = seq_num_; |
2201 packet_->timestamp = timestamp_; | 2201 packet_->timestamp = timestamp_; |
2202 packet_->frameType = kVideoFrameKey; | 2202 packet_->frameType = kVideoFrameKey; |
2203 packet_->isFirstPacket = true; | 2203 packet_->is_first_packet_in_frame = true; |
2204 packet_->completeNALU = kNaluComplete; | 2204 packet_->completeNALU = kNaluComplete; |
2205 packet_->markerBit = false; | 2205 packet_->markerBit = false; |
2206 | 2206 |
2207 EXPECT_EQ(kDecodableSession, | 2207 EXPECT_EQ(kDecodableSession, |
2208 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 2208 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
2209 | 2209 |
2210 seq_num_++; | 2210 seq_num_++; |
2211 emptypacket.seqNum = seq_num_; | 2211 emptypacket.seqNum = seq_num_; |
2212 emptypacket.timestamp = timestamp_; | 2212 emptypacket.timestamp = timestamp_; |
2213 emptypacket.frameType = kVideoFrameKey; | 2213 emptypacket.frameType = kVideoFrameKey; |
2214 emptypacket.isFirstPacket = true; | 2214 emptypacket.is_first_packet_in_frame = true; |
2215 emptypacket.completeNALU = kNaluComplete; | 2215 emptypacket.completeNALU = kNaluComplete; |
2216 emptypacket.markerBit = true; | 2216 emptypacket.markerBit = true; |
2217 EXPECT_EQ(kCompleteSession, | 2217 EXPECT_EQ(kCompleteSession, |
2218 jitter_buffer_->InsertPacket(emptypacket, &retransmitted)); | 2218 jitter_buffer_->InsertPacket(emptypacket, &retransmitted)); |
2219 | 2219 |
2220 frame_out = DecodeCompleteFrame(); | 2220 frame_out = DecodeCompleteFrame(); |
2221 // Only last NALU is complete | 2221 // Only last NALU is complete |
2222 CheckOutFrame(frame_out, packet_->sizeBytes, false); | 2222 CheckOutFrame(frame_out, packet_->sizeBytes, false); |
2223 jitter_buffer_->ReleaseFrame(frame_out); | 2223 jitter_buffer_->ReleaseFrame(frame_out); |
2224 } | 2224 } |
2225 | 2225 |
2226 TEST_F(TestBasicJitterBuffer, NextFrameWhenIncomplete) { | 2226 TEST_F(TestBasicJitterBuffer, NextFrameWhenIncomplete) { |
2227 // Test that a we cannot get incomplete frames from the JB if we haven't | 2227 // Test that a we cannot get incomplete frames from the JB if we haven't |
2228 // received the marker bit, unless we have received a packet from a later | 2228 // received the marker bit, unless we have received a packet from a later |
2229 // timestamp. | 2229 // timestamp. |
2230 jitter_buffer_->SetDecodeErrorMode(kWithErrors); | 2230 jitter_buffer_->SetDecodeErrorMode(kWithErrors); |
2231 // Start with a complete key frame - insert and decode. | 2231 // Start with a complete key frame - insert and decode. |
2232 packet_->frameType = kVideoFrameKey; | 2232 packet_->frameType = kVideoFrameKey; |
2233 packet_->isFirstPacket = true; | 2233 packet_->is_first_packet_in_frame = true; |
2234 packet_->markerBit = true; | 2234 packet_->markerBit = true; |
2235 bool retransmitted = false; | 2235 bool retransmitted = false; |
2236 | 2236 |
2237 EXPECT_EQ(kCompleteSession, | 2237 EXPECT_EQ(kCompleteSession, |
2238 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 2238 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
2239 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); | 2239 VCMEncodedFrame* frame_out = DecodeCompleteFrame(); |
2240 EXPECT_TRUE(frame_out != NULL); | 2240 EXPECT_TRUE(frame_out != NULL); |
2241 jitter_buffer_->ReleaseFrame(frame_out); | 2241 jitter_buffer_->ReleaseFrame(frame_out); |
2242 | 2242 |
2243 packet_->seqNum += 2; | 2243 packet_->seqNum += 2; |
2244 packet_->timestamp += 33 * 90; | 2244 packet_->timestamp += 33 * 90; |
2245 packet_->frameType = kVideoFrameDelta; | 2245 packet_->frameType = kVideoFrameDelta; |
2246 packet_->isFirstPacket = false; | 2246 packet_->is_first_packet_in_frame = false; |
2247 packet_->markerBit = false; | 2247 packet_->markerBit = false; |
2248 | 2248 |
2249 EXPECT_EQ(kDecodableSession, | 2249 EXPECT_EQ(kDecodableSession, |
2250 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 2250 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
2251 | 2251 |
2252 frame_out = DecodeIncompleteFrame(); | 2252 frame_out = DecodeIncompleteFrame(); |
2253 EXPECT_TRUE(frame_out == NULL); | 2253 EXPECT_TRUE(frame_out == NULL); |
2254 | 2254 |
2255 packet_->seqNum += 2; | 2255 packet_->seqNum += 2; |
2256 packet_->timestamp += 33 * 90; | 2256 packet_->timestamp += 33 * 90; |
2257 packet_->isFirstPacket = true; | 2257 packet_->is_first_packet_in_frame = true; |
2258 | 2258 |
2259 EXPECT_EQ(kDecodableSession, | 2259 EXPECT_EQ(kDecodableSession, |
2260 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); | 2260 jitter_buffer_->InsertPacket(*packet_, &retransmitted)); |
2261 | 2261 |
2262 frame_out = DecodeIncompleteFrame(); | 2262 frame_out = DecodeIncompleteFrame(); |
2263 CheckOutFrame(frame_out, packet_->sizeBytes, false); | 2263 CheckOutFrame(frame_out, packet_->sizeBytes, false); |
2264 jitter_buffer_->ReleaseFrame(frame_out); | 2264 jitter_buffer_->ReleaseFrame(frame_out); |
2265 } | 2265 } |
2266 | 2266 |
2267 TEST_F(TestRunningJitterBuffer, Full) { | 2267 TEST_F(TestRunningJitterBuffer, Full) { |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2712 EXPECT_EQ(0u, nack_list.size()); | 2712 EXPECT_EQ(0u, nack_list.size()); |
2713 | 2713 |
2714 // Stream should be decodable from this point. | 2714 // Stream should be decodable from this point. |
2715 clock_->AdvanceTimeMilliseconds(kDefaultFramePeriodMs); | 2715 clock_->AdvanceTimeMilliseconds(kDefaultFramePeriodMs); |
2716 InsertFrame(kVideoFrameDelta); | 2716 InsertFrame(kVideoFrameDelta); |
2717 EXPECT_TRUE(DecodeCompleteFrame()); | 2717 EXPECT_TRUE(DecodeCompleteFrame()); |
2718 nack_list = jitter_buffer_->GetNackList(&extended); | 2718 nack_list = jitter_buffer_->GetNackList(&extended); |
2719 EXPECT_EQ(0u, nack_list.size()); | 2719 EXPECT_EQ(0u, nack_list.size()); |
2720 } | 2720 } |
2721 } // namespace webrtc | 2721 } // namespace webrtc |
OLD | NEW |