Index: webrtc/modules/video_coding/frame_buffer2.cc |
diff --git a/webrtc/modules/video_coding/frame_buffer2.cc b/webrtc/modules/video_coding/frame_buffer2.cc |
index acc1bb83c5a0e448e030d42b98eab5d25315b0a1..c3701fbfa909cbee3c76bc8e87b607851bac4b3e 100644 |
--- a/webrtc/modules/video_coding/frame_buffer2.cc |
+++ b/webrtc/modules/video_coding/frame_buffer2.cc |
@@ -144,6 +144,32 @@ FrameBuffer::ReturnReason FrameBuffer::NextFrame( |
PropagateDecodability(next_frame_it_->second); |
AdvanceLastDecodedFrame(next_frame_it_); |
+ // Sanity check for RTP timestamp monotonicity. |
+ // TODO(brandtr): Consider clearing the entire buffer when we hit these |
+ // conditions. |
+ if (last_decoded_frame_it_ != frames_.end()) { |
philipel
2017/04/26 15:26:37
This should work, right?
if (last_decoded_frame_i
brandtr
2017/04/26 15:51:19
I don't think that would catch this situation:
* f
|
+ const FrameKey& last_decoded_frame_key = last_decoded_frame_it_->first; |
+ const FrameKey frame_key(frame->picture_id, frame->spatial_layer); |
+ |
+ const bool frame_is_higher_spatial_layer_of_last_decoded_frame = |
+ last_decoded_frame_timestamp_ == frame->timestamp && |
+ last_decoded_frame_key.picture_id == frame_key.picture_id && |
+ last_decoded_frame_key.spatial_layer < frame_key.spatial_layer; |
+ |
+ if (AheadOrAt(last_decoded_frame_timestamp_, frame->timestamp) && |
+ !frame_is_higher_spatial_layer_of_last_decoded_frame) { |
+ LOG(LS_WARNING) << "Frame with (timestamp:picture_id:spatial_id) (" |
+ << frame->timestamp << ":" << frame->picture_id << ":" |
+ << static_cast<int>(frame->spatial_layer) << ")" |
+ << " sent to decoder after frame with" |
+ << " (timestamp:picture_id:spatial_id) (" |
+ << last_decoded_frame_timestamp_ << ":" |
+ << last_decoded_frame_key.picture_id << ":" |
+ << static_cast<int>( |
+ last_decoded_frame_key.spatial_layer) |
+ << ")."; |
+ } |
+ } |
last_decoded_frame_timestamp_ = frame->timestamp; |
*frame_out = std::move(frame); |
return kFrameFound; |