Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(748)

Unified Diff: media/capture/video/mac/video_capture_device_mac.mm

Issue 1421583007: Mac Video Capture: Sending the timestamps provided by the driver to the capture pipeline (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Alignment Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: media/capture/video/mac/video_capture_device_mac.mm
diff --git a/media/capture/video/mac/video_capture_device_mac.mm b/media/capture/video/mac/video_capture_device_mac.mm
index 5fc083e4d68169482e2c329d43ebbebcce1a7d83..e74a6c2b2a87858f3ac5b8eeba9421234311edb9 100644
--- a/media/capture/video/mac/video_capture_device_mac.mm
+++ b/media/capture/video/mac/video_capture_device_mac.mm
@@ -18,6 +18,7 @@
#include "base/thread_task_runner_handle.h"
#include "base/time/time.h"
#import "media/base/mac/avfoundation_glue.h"
+#include "media/base/timestamp_constants.h"
#import "media/capture/video/mac/platform_video_capturing_mac.h"
#import "media/capture/video/mac/video_capture_device_avfoundation_mac.h"
#import "media/capture/video/mac/video_capture_device_qtkit_mac.h"
@@ -344,6 +345,7 @@ VideoCaptureDeviceMac::VideoCaptureDeviceMac(const Name& device_name)
task_runner_(base::ThreadTaskRunnerHandle::Get()),
state_(kNotInitialized),
capture_device_(nil),
+ first_timestamp_(media::kNoTimestamp()),
weak_factory_(this) {
// Avoid reconfiguring AVFoundation or blacklisted devices.
final_resolution_selected_ = AVFoundationGlue::IsAVFoundationSupported() ||
@@ -464,7 +466,8 @@ void VideoCaptureDeviceMac::ReceiveFrame(const uint8* video_frame,
int video_frame_length,
const VideoCaptureFormat& frame_format,
int aspect_numerator,
- int aspect_denominator) {
+ int aspect_denominator,
+ base::TimeDelta timestamp) {
// This method is safe to call from a device capture thread, i.e. any thread
// controlled by QTKit/AVFoundation.
if (!final_resolution_selected_) {
@@ -535,8 +538,18 @@ void VideoCaptureDeviceMac::ReceiveFrame(const uint8* video_frame,
return;
}
+ base::TimeTicks aligned_timestamp;
+ if (timestamp == media::kNoTimestamp()) {
+ aligned_timestamp = base::TimeTicks::Now();
+ } else {
+ if (first_timestamp_ == media::kNoTimestamp()) {
+ first_timestamp_ = timestamp;
+ first_aligned_timestamp_ = base::TimeTicks::Now();
+ }
+ aligned_timestamp = first_aligned_timestamp_ + timestamp - first_timestamp_;
+ }
client_->OnIncomingCapturedData(video_frame, video_frame_length, frame_format,
- 0, base::TimeTicks::Now());
+ 0, aligned_timestamp);
}
void VideoCaptureDeviceMac::ReceiveError(const std::string& reason) {
« no previous file with comments | « media/capture/video/mac/video_capture_device_mac.h ('k') | media/capture/video/mac/video_capture_device_qtkit_mac.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698