Index: webrtc/modules/video_coding/packet_buffer.cc |
diff --git a/webrtc/modules/video_coding/packet_buffer.cc b/webrtc/modules/video_coding/packet_buffer.cc |
index 3b0d09f042efc77ec7cb77a92b33877d0493237a..1dd4259d79300ea938c8e056f4cc94ed341629a8 100644 |
--- a/webrtc/modules/video_coding/packet_buffer.cc |
+++ b/webrtc/modules/video_coding/packet_buffer.cc |
@@ -59,6 +59,7 @@ bool PacketBuffer::InsertPacket(VCMPacket* packet) { |
std::vector<std::unique_ptr<RtpFrameObject>> found_frames; |
{ |
rtc::CritScope lock(&crit_); |
+ |
uint16_t seq_num = packet->seqNum; |
size_t index = seq_num % size_; |
@@ -107,6 +108,11 @@ bool PacketBuffer::InsertPacket(VCMPacket* packet) { |
data_buffer_[index] = *packet; |
packet->dataPtr = nullptr; |
+ int64_t now_ms = clock_->TimeInMilliseconds(); |
+ last_received_packet_ms_ = rtc::Optional<int64_t>(now_ms); |
+ if (packet->frameType == kVideoFrameKey) |
+ last_received_keyframe_packet_ms_ = rtc::Optional<int64_t>(now_ms); |
+ |
found_frames = FindFrames(seq_num); |
} |
@@ -143,6 +149,18 @@ void PacketBuffer::Clear() { |
first_packet_received_ = false; |
is_cleared_to_first_seq_num_ = false; |
+ last_received_packet_ms_ = rtc::Optional<int64_t>(); |
+ last_received_keyframe_packet_ms_ = rtc::Optional<int64_t>(); |
+} |
+ |
+rtc::Optional<int64_t> PacketBuffer::LastReceivedPacketMs() const { |
stefan-webrtc
2017/05/17 06:32:11
I think it would be good to add thread checks to e
philipel
2017/05/18 09:23:40
I'm not sure I understand why we should do that. W
holmer
2017/05/18 09:25:52
The main reason would be to ensure we get calls fr
|
+ rtc::CritScope lock(&crit_); |
+ return last_received_packet_ms_; |
+} |
+ |
+rtc::Optional<int64_t> PacketBuffer::LastReceivedKeyframePacketMs() const { |
+ rtc::CritScope lock(&crit_); |
+ return last_received_keyframe_packet_ms_; |
} |
bool PacketBuffer::ExpandBufferSize() { |