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

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

Issue 2853503002: Dont request keyframes if the stream is inactive or if we are currently receiving a keyframe. (Closed)
Patch Set: Rebase Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « webrtc/modules/video_coding/packet_buffer.cc ('k') | webrtc/video/end_to_end_tests.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 bool Insert(uint16_t seq_num, // packet sequence number 52 bool Insert(uint16_t seq_num, // packet sequence number
53 IsKeyFrame keyframe, // is keyframe 53 IsKeyFrame keyframe, // is keyframe
54 IsFirst first, // is first packet of frame 54 IsFirst first, // is first packet of frame
55 IsLast last, // is last packet of frame 55 IsLast last, // is last packet of frame
56 int data_size = 0, // size of data 56 int data_size = 0, // size of data
57 uint8_t* data = nullptr) { // data pointer 57 uint8_t* data = nullptr) { // data pointer
58 VCMPacket packet; 58 VCMPacket packet;
59 packet.codec = kVideoCodecGeneric; 59 packet.codec = kVideoCodecGeneric;
60 packet.seqNum = seq_num; 60 packet.seqNum = seq_num;
61 packet.frameType = keyframe ? kVideoFrameKey : kVideoFrameDelta; 61 packet.frameType =
62 keyframe == kKeyFrame ? kVideoFrameKey : kVideoFrameDelta;
62 packet.is_first_packet_in_frame = first == kFirst; 63 packet.is_first_packet_in_frame = first == kFirst;
63 packet.markerBit = last == kLast; 64 packet.markerBit = last == kLast;
64 packet.sizeBytes = data_size; 65 packet.sizeBytes = data_size;
65 packet.dataPtr = data; 66 packet.dataPtr = data;
66 67
67 return packet_buffer_->InsertPacket(&packet); 68 return packet_buffer_->InsertPacket(&packet);
68 } 69 }
69 70
70 void CheckFrame(uint16_t first_seq_num) { 71 void CheckFrame(uint16_t first_seq_num) {
71 auto frame_it = frames_from_callback_.find(first_seq_num); 72 auto frame_it = frames_from_callback_.find(first_seq_num);
72 ASSERT_FALSE(frame_it == frames_from_callback_.end()) 73 ASSERT_FALSE(frame_it == frames_from_callback_.end())
73 << "Could not find frame with first sequence number " << first_seq_num 74 << "Could not find frame with first sequence number " << first_seq_num
74 << "."; 75 << ".";
75 } 76 }
76 77
77 const int kStartSize = 16; 78 const int kStartSize = 16;
78 const int kMaxSize = 64; 79 const int kMaxSize = 64;
79 80
80 Random rand_; 81 Random rand_;
81 std::unique_ptr<Clock> clock_; 82 std::unique_ptr<SimulatedClock> clock_;
82 rtc::scoped_refptr<PacketBuffer> packet_buffer_; 83 rtc::scoped_refptr<PacketBuffer> packet_buffer_;
83 std::map<uint16_t, std::unique_ptr<RtpFrameObject>> frames_from_callback_; 84 std::map<uint16_t, std::unique_ptr<RtpFrameObject>> frames_from_callback_;
84 }; 85 };
85 86
86 TEST_F(TestPacketBuffer, InsertOnePacket) { 87 TEST_F(TestPacketBuffer, InsertOnePacket) {
87 const uint16_t seq_num = Rand(); 88 const uint16_t seq_num = Rand();
88 EXPECT_TRUE(Insert(seq_num, kKeyFrame, kFirst, kLast)); 89 EXPECT_TRUE(Insert(seq_num, kKeyFrame, kFirst, kLast));
89 } 90 }
90 91
91 TEST_F(TestPacketBuffer, InsertMultiplePackets) { 92 TEST_F(TestPacketBuffer, InsertMultiplePackets) {
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 } 495 }
495 496
496 packet.seqNum = kStartSize - 1; 497 packet.seqNum = kStartSize - 1;
497 packet.markerBit = true; 498 packet.markerBit = true;
498 packet_buffer_->InsertPacket(&packet); 499 packet_buffer_->InsertPacket(&packet);
499 500
500 EXPECT_EQ(1UL, frames_from_callback_.size()); 501 EXPECT_EQ(1UL, frames_from_callback_.size());
501 CheckFrame(0); 502 CheckFrame(0);
502 } 503 }
503 504
505 TEST_F(TestPacketBuffer, PacketTimestamps) {
506 rtc::Optional<int64_t> packet_ms;
507 rtc::Optional<int64_t> packet_keyframe_ms;
508
509 packet_ms = packet_buffer_->LastReceivedPacketMs();
510 packet_keyframe_ms = packet_buffer_->LastReceivedKeyframePacketMs();
511 EXPECT_FALSE(packet_ms);
512 EXPECT_FALSE(packet_keyframe_ms);
513
514 int64_t keyframe_ms = clock_->TimeInMilliseconds();
515 EXPECT_TRUE(Insert(100, kKeyFrame, kFirst, kLast));
516 packet_ms = packet_buffer_->LastReceivedPacketMs();
517 packet_keyframe_ms = packet_buffer_->LastReceivedKeyframePacketMs();
518 EXPECT_TRUE(packet_ms);
519 EXPECT_TRUE(packet_keyframe_ms);
520 EXPECT_EQ(keyframe_ms, *packet_ms);
521 EXPECT_EQ(keyframe_ms, *packet_keyframe_ms);
522
523 clock_->AdvanceTimeMilliseconds(100);
524 int64_t delta_ms = clock_->TimeInMilliseconds();
525 EXPECT_TRUE(Insert(101, kDeltaFrame, kFirst, kLast));
526 packet_ms = packet_buffer_->LastReceivedPacketMs();
527 packet_keyframe_ms = packet_buffer_->LastReceivedKeyframePacketMs();
528 EXPECT_TRUE(packet_ms);
529 EXPECT_TRUE(packet_keyframe_ms);
530 EXPECT_EQ(delta_ms, *packet_ms);
531 EXPECT_EQ(keyframe_ms, *packet_keyframe_ms);
532
533 packet_buffer_->Clear();
534 packet_ms = packet_buffer_->LastReceivedPacketMs();
535 packet_keyframe_ms = packet_buffer_->LastReceivedKeyframePacketMs();
536 EXPECT_FALSE(packet_ms);
537 EXPECT_FALSE(packet_keyframe_ms);
538 }
539
504 } // namespace video_coding 540 } // namespace video_coding
505 } // namespace webrtc 541 } // namespace webrtc
OLDNEW
« no previous file with comments | « webrtc/modules/video_coding/packet_buffer.cc ('k') | webrtc/video/end_to_end_tests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698