| 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/capture/video/file_video_capture_device.h" | 5 #include "media/capture/video/file_video_capture_device.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 359 DCHECK_EQ(capture_thread_.message_loop(), base::MessageLoop::current()); | 359 DCHECK_EQ(capture_thread_.message_loop(), base::MessageLoop::current()); |
| 360 if (!client_) | 360 if (!client_) |
| 361 return; | 361 return; |
| 362 | 362 |
| 363 // Give the captured frame to the client. | 363 // Give the captured frame to the client. |
| 364 int frame_size = 0; | 364 int frame_size = 0; |
| 365 const uint8_t* frame_ptr = file_parser_->GetNextFrame(&frame_size); | 365 const uint8_t* frame_ptr = file_parser_->GetNextFrame(&frame_size); |
| 366 DCHECK(frame_size); | 366 DCHECK(frame_size); |
| 367 CHECK(frame_ptr); | 367 CHECK(frame_ptr); |
| 368 const base::TimeTicks current_time = base::TimeTicks::Now(); | 368 const base::TimeTicks current_time = base::TimeTicks::Now(); |
| 369 if (first_ref_time_.is_null()) |
| 370 first_ref_time_ = current_time; |
| 369 client_->OnIncomingCapturedData(frame_ptr, frame_size, capture_format_, 0, | 371 client_->OnIncomingCapturedData(frame_ptr, frame_size, capture_format_, 0, |
| 370 current_time); | 372 current_time, current_time - first_ref_time_); |
| 371 // Reschedule next CaptureTask. | 373 // Reschedule next CaptureTask. |
| 372 const base::TimeDelta frame_interval = | 374 const base::TimeDelta frame_interval = |
| 373 base::TimeDelta::FromMicroseconds(1E6 / capture_format_.frame_rate); | 375 base::TimeDelta::FromMicroseconds(1E6 / capture_format_.frame_rate); |
| 374 if (next_frame_time_.is_null()) { | 376 if (next_frame_time_.is_null()) { |
| 375 next_frame_time_ = current_time + frame_interval; | 377 next_frame_time_ = current_time + frame_interval; |
| 376 } else { | 378 } else { |
| 377 next_frame_time_ += frame_interval; | 379 next_frame_time_ += frame_interval; |
| 378 // Don't accumulate any debt if we are lagging behind - just post next frame | 380 // Don't accumulate any debt if we are lagging behind - just post next frame |
| 379 // immediately and continue as normal. | 381 // immediately and continue as normal. |
| 380 if (next_frame_time_ < current_time) | 382 if (next_frame_time_ < current_time) |
| 381 next_frame_time_ = current_time; | 383 next_frame_time_ = current_time; |
| 382 } | 384 } |
| 383 base::MessageLoop::current()->PostDelayedTask( | 385 base::MessageLoop::current()->PostDelayedTask( |
| 384 FROM_HERE, base::Bind(&FileVideoCaptureDevice::OnCaptureTask, | 386 FROM_HERE, base::Bind(&FileVideoCaptureDevice::OnCaptureTask, |
| 385 base::Unretained(this)), | 387 base::Unretained(this)), |
| 386 next_frame_time_ - current_time); | 388 next_frame_time_ - current_time); |
| 387 } | 389 } |
| 388 | 390 |
| 389 } // namespace media | 391 } // namespace media |
| OLD | NEW |