| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/video/capture/file_video_capture_device.h" | 5 #include "media/video/capture/file_video_capture_device.h" |
| 6 | 6 |
| 7 | 7 |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
| (...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 capture_format_, | 242 capture_format_, |
| 243 0, | 243 0, |
| 244 current_time); | 244 current_time); |
| 245 // Reschedule next CaptureTask. | 245 // Reschedule next CaptureTask. |
| 246 const base::TimeDelta frame_interval = | 246 const base::TimeDelta frame_interval = |
| 247 base::TimeDelta::FromMicroseconds(1E6 / capture_format_.frame_rate); | 247 base::TimeDelta::FromMicroseconds(1E6 / capture_format_.frame_rate); |
| 248 if (next_frame_time_.is_null()) { | 248 if (next_frame_time_.is_null()) { |
| 249 next_frame_time_ = current_time + frame_interval; | 249 next_frame_time_ = current_time + frame_interval; |
| 250 } else { | 250 } else { |
| 251 next_frame_time_ += frame_interval; | 251 next_frame_time_ += frame_interval; |
| 252 // Don't accumulate any debt if we are lagging behind - just post next frame |
| 253 // immediately and continue as normal. |
| 254 if (next_frame_time_ < current_time) |
| 255 next_frame_time_ = current_time; |
| 252 } | 256 } |
| 253 base::MessageLoop::current()->PostDelayedTask( | 257 base::MessageLoop::current()->PostDelayedTask( |
| 254 FROM_HERE, | 258 FROM_HERE, |
| 255 base::Bind(&FileVideoCaptureDevice::OnCaptureTask, | 259 base::Bind(&FileVideoCaptureDevice::OnCaptureTask, |
| 256 base::Unretained(this)), | 260 base::Unretained(this)), |
| 257 next_frame_time_ - current_time); | 261 next_frame_time_ - current_time); |
| 258 } | 262 } |
| 259 | 263 |
| 260 } // namespace media | 264 } // namespace media |
| OLD | NEW |