Fix PacketBuffer::LastReceivedKeyframePacketMs

to return time of the last receieved packet of a key frame rather than
last received first packet of a key frame.

To match VideoReceiveStream expectation and prevent requesting
a new key frame if a large key frame is currently on the way.

Bug: None
Change-Id: I443a60872a3580d324f050080a9868f7b90d71a2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/161730
Reviewed-by: Philip Eliasson <philipel@webrtc.org>
Reviewed-by: Ilya Nikolaevskiy <ilnik@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30084}
This commit is contained in:
Danil Chapovalov
2019-12-10 17:03:00 +01:00
committed by Commit Bot
parent 5e9cac984f
commit c9e532a7eb
3 changed files with 35 additions and 4 deletions

View File

@ -755,7 +755,7 @@ TEST_F(PacketBufferTest, PacketTimestamps) {
EXPECT_FALSE(packet_keyframe_ms);
int64_t keyframe_ms = clock_.TimeInMilliseconds();
Insert(100, kKeyFrame, kFirst, kLast);
Insert(100, kKeyFrame, kFirst, kLast, {}, /*timestamp=*/1000);
packet_ms = packet_buffer_.LastReceivedPacketMs();
packet_keyframe_ms = packet_buffer_.LastReceivedKeyframePacketMs();
EXPECT_TRUE(packet_ms);
@ -765,7 +765,7 @@ TEST_F(PacketBufferTest, PacketTimestamps) {
clock_.AdvanceTimeMilliseconds(100);
int64_t delta_ms = clock_.TimeInMilliseconds();
Insert(101, kDeltaFrame, kFirst, kLast);
Insert(101, kDeltaFrame, kFirst, kLast, {}, /*timestamp=*/2000);
packet_ms = packet_buffer_.LastReceivedPacketMs();
packet_keyframe_ms = packet_buffer_.LastReceivedKeyframePacketMs();
EXPECT_TRUE(packet_ms);
@ -780,6 +780,32 @@ TEST_F(PacketBufferTest, PacketTimestamps) {
EXPECT_FALSE(packet_keyframe_ms);
}
TEST_F(PacketBufferTest,
LastReceivedKeyFrameReturnsReceiveTimeOfALastReceivedPacketOfAKeyFrame) {
clock_.AdvanceTimeMilliseconds(100);
Insert(/*seq_num=*/100, kKeyFrame, kFirst, kNotLast, {}, /*timestamp=*/1000);
EXPECT_EQ(packet_buffer_.LastReceivedKeyframePacketMs(),
clock_.TimeInMilliseconds());
clock_.AdvanceTimeMilliseconds(100);
Insert(/*seq_num=*/102, kDeltaFrame, kNotFirst, kLast, {},
/*timestamp=*/1000);
EXPECT_EQ(packet_buffer_.LastReceivedKeyframePacketMs(),
clock_.TimeInMilliseconds());
clock_.AdvanceTimeMilliseconds(100);
Insert(/*seq_num=*/101, kDeltaFrame, kNotFirst, kNotLast, {},
/*timestamp=*/1000);
EXPECT_EQ(packet_buffer_.LastReceivedKeyframePacketMs(),
clock_.TimeInMilliseconds());
clock_.AdvanceTimeMilliseconds(100);
Insert(/*seq_num=*/103, kDeltaFrame, kFirst, kNotLast, {},
/*timestamp=*/2000);
EXPECT_EQ(packet_buffer_.LastReceivedKeyframePacketMs(),
clock_.TimeInMilliseconds() - 100);
}
TEST_F(PacketBufferTest, IncomingCodecChange) {
PacketBuffer::Packet packet;
packet.video_header.is_first_packet_in_frame = true;