Index: content/renderer/media/video_track_adapter.cc |
diff --git a/content/renderer/media/video_track_adapter.cc b/content/renderer/media/video_track_adapter.cc |
index ebb47ba9f86b3f0fd4c3d70329706f435ddeff80..3f61a429c46968697e095d9d91b227ac2cdb25ea 100644 |
--- a/content/renderer/media/video_track_adapter.cc |
+++ b/content/renderer/media/video_track_adapter.cc |
@@ -24,6 +24,10 @@ namespace { |
const float kFirstFrameTimeoutInFrameIntervals = 100.0f; |
const float kNormalFrameTimeoutInFrameIntervals = 25.0f; |
+// Min delta time between two frames allowed without being dropped if a max |
+// frame rate is specified. |
+const int kMinTimeInMsBetweenFrames = 5; |
+ |
// Empty method used for keeping a reference to the original media::VideoFrame |
// in VideoFrameResolutionAdapter::DeliverFrame if cropping is needed. |
// The reference to |frame| is kept in the closure that calls this method. |
@@ -225,11 +229,24 @@ bool VideoTrackAdapter::VideoFrameResolutionAdapter::MaybeDropFrame( |
return false; |
base::TimeDelta delta = frame->timestamp() - last_time_stamp_; |
+ if (delta.InMilliseconds() < kMinTimeInMsBetweenFrames) { |
+ // We have seen video frames being delivered from camera devices back to |
+ // back. The simple AR filter for frame rate calculation is too short to |
+ // handle that. http://crbug/394315 |
+ // TODO(perkj): Can we come up with a way to fix the times stamps and the |
+ // timing when frames are delivered so all frames can be used? |
+ // The time stamps are generated by Chrome and not the actual device. |
+ // Most likely the back to back problem is caused by software and not the |
+ // actual camera. |
+ DVLOG(3) << "Drop frame since delta time since previous frame is " |
+ << delta.InMilliseconds() << "ms."; |
+ return true; |
+ } |
last_time_stamp_ = frame->timestamp(); |
- if (delta.ToInternalValue() == 0 || delta == last_time_stamp_) |
+ if (delta == last_time_stamp_) // First received frame. |
return false; |
- // Calculate the moving average frame rate. Use a simple filter with 0.1 |
- // weight of the current sample. |
+ // Calculate the frame rate using a simple AR filter. |
+ // Use a simple filter with 0.1 weight of the current sample. |
frame_rate_ = 100 / delta.InMillisecondsF() + 0.9 * frame_rate_; |
// Prefer to not drop frames. |