Clear FrameBuffer if there were no frames received for 10 minutes

This is a workaround for the case when there are no video frames in a
call for a very long time, such that RTP timestamps wraparound and
FrameBuffer can't figure out if the frame is older or newer.

Bug: webrtc:9974
Change-Id: Ie1eaa4938813dbbd637ddcbe7ff118ead2bfa4a9
Reviewed-on: https://webrtc-review.googlesource.com/c/109882
Reviewed-by: Philip Eliasson <philipel@webrtc.org>
Commit-Queue: Ilya Nikolaevskiy <ilnik@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#25548}
diff --git a/modules/video_coding/frame_buffer2.cc b/modules/video_coding/frame_buffer2.cc
index f9a4f54..04fba84 100644
--- a/modules/video_coding/frame_buffer2.cc
+++ b/modules/video_coding/frame_buffer2.cc
@@ -113,6 +113,9 @@
         if (keyframe_required && !frame->is_keyframe())
           continue;
 
+        // TODO(https://bugs.webrtc.org/9974): consider removing this check
+        // as it may make a stream undecodable after a very long delay between
+        // frames.
         if (last_decoded_frame_timestamp_ &&
             AheadOf(*last_decoded_frame_timestamp_, frame->Timestamp())) {
           continue;
@@ -244,6 +247,11 @@
   new_continuous_frame_event_.Set();
 }
 
+void FrameBuffer::Clear() {
+  rtc::CritScope lock(&crit_);
+  ClearFramesAndHistory();
+}
+
 void FrameBuffer::UpdateRtt(int64_t rtt_ms) {
   rtc::CritScope lock(&crit_);
   jitter_estimator_->UpdateRtt(rtt_ms);