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

Unified Diff: content/browser/media/capture/content_video_capture_device_core.cc

Issue 955253002: Add metadata to media::VideoFrame and plumb it through IPC/MediaStream. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Windows compile errors. Created 5 years, 10 months 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: content/browser/media/capture/content_video_capture_device_core.cc
diff --git a/content/browser/media/capture/content_video_capture_device_core.cc b/content/browser/media/capture/content_video_capture_device_core.cc
index e2a51c4594be3d97bc1e36bde2868998cd5f1742..dcaa3535a023051f4d770dbe5ebd6bfeaaad3a7d 100644
--- a/content/browser/media/capture/content_video_capture_device_core.cc
+++ b/content/browser/media/capture/content_video_capture_device_core.cc
@@ -70,6 +70,9 @@ bool ThreadSafeCaptureOracle::ObserveEventAndDecideCapture(
base::TimeTicks event_time,
scoped_refptr<media::VideoFrame>* storage,
CaptureFrameCallback* callback) {
+ // Grab the current time before waiting to acquire the |lock_|.
+ const base::TimeTicks capture_begin_time = base::TimeTicks::Now();
+
base::AutoLock guard(lock_);
if (!client_)
@@ -141,7 +144,8 @@ bool ThreadSafeCaptureOracle::ObserveEventAndDecideCapture(
*callback = base::Bind(&ThreadSafeCaptureOracle::DidCaptureFrame,
this,
frame_number,
- output_buffer);
+ output_buffer,
+ capture_begin_time);
return true;
}
@@ -188,6 +192,7 @@ void ThreadSafeCaptureOracle::ReportError(const std::string& reason) {
void ThreadSafeCaptureOracle::DidCaptureFrame(
int frame_number,
const scoped_refptr<media::VideoCaptureDevice::Client::Buffer>& buffer,
+ base::TimeTicks capture_begin_time,
const scoped_refptr<media::VideoFrame>& frame,
base::TimeTicks timestamp,
bool success) {
@@ -201,13 +206,22 @@ void ThreadSafeCaptureOracle::DidCaptureFrame(
if (success) {
if (oracle_->CompleteCapture(frame_number, &timestamp)) {
- media::VideoCaptureFormat format = params_.requested_format;
- // TODO(miu): Passing VideoCaptureFormat here introduces ambiguities. The
- // following is a hack where frame_size takes on a different meaning than
- // everywhere else (i.e., coded size, not visible size). Will fix in
- // soon-upcoming code change.
- format.frame_size = frame->coded_size();
- client_->OnIncomingCapturedVideoFrame(buffer, format, frame, timestamp);
+ // TODO(miu): Use the locked-in frame rate from AnimatedContentSampler.
+ frame->metadata().SetDouble(media::VideoFrame::kFrameRateMetadataKey,
+ params_.requested_format.frame_rate);
+ // Provide capture begin/end timestamps in the VideoFrame metadata.
+ // Casting the int64 internal value of the start and end TimeTickses to
+ // double is reasonable here. This will guarantee 1us resolution for
+ // values up to 2^53 (e.g., ~285 years since kernel boot). Alternative
+ // approaches are much more heavyweight (e.g., storing the low and high 32
+ // bits as separate fields, storing as formatted ASCII strings, etc.).
+ frame->metadata().SetDouble(
+ "captureBeginTimeTicks",
Alpha Left Google 2015/02/26 21:17:23 Can these names be defined in video_frame.h as wel
miu 2015/02/26 23:25:18 I'm uncomfortable with starting the practice of pu
+ static_cast<double>(capture_begin_time.ToInternalValue()));
+ frame->metadata().SetDouble(
+ "captureEndTimeTicks",
+ static_cast<double>(base::TimeTicks::Now().ToInternalValue()));
+ client_->OnIncomingCapturedVideoFrame(buffer, frame, timestamp);
}
}
}

Powered by Google App Engine
This is Rietveld 408576698