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

Unified Diff: webrtc/media/base/videocapturer.h

Issue 2017443003: Implement timestamp translation/filter in VideoCapturer. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Simplify filter reset. Drop hack to detect if camera time and system time are the same. Created 4 years, 6 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: webrtc/media/base/videocapturer.h
diff --git a/webrtc/media/base/videocapturer.h b/webrtc/media/base/videocapturer.h
index 329ba086b90dfe1139c6f83cdd41b291af38540f..2b8d989b0c8036819f872fc07e00e0aa2bda2413 100644
--- a/webrtc/media/base/videocapturer.h
+++ b/webrtc/media/base/videocapturer.h
@@ -225,15 +225,30 @@ class VideoCapturer : public sigslot::has_slots<>,
// Reports the appropriate frame size after adaptation. Returns true
// if a frame is wanted. Returns false if there are no interested
// sinks, or if the VideoAdapter decides to drop the frame.
+
+ // This function also implements timestamp translation/filtering.
+ // |camera_time_ns| is the camera's timestamp for the captured
+ // frame; it is expected to have good accuracy, but it may use an
+ // arbitrary epoch and a small possibly free-running with a frequency
+ // slightly different from the system clock. |system_time_us| is the
+ // monotonic system time (in the same scale as rtc::TimeMicros) when
+ // the frame was captured; the application is expected to read the
+ // system time as soon as possible after frame capture, but it may
+ // suffer scheduling jitter or poor system clock resolution. The
+ // output |translated_camera_time_us| is a combined timestamp,
+ // taking advantage of the supposedly higher accuracy in the camera
+ // timestamp, but using the same epoch and frequency as system time.
bool AdaptFrame(int width,
int height,
- int64_t capture_time_ns,
+ int64_t camera_time_us,
+ int64_t system_time_us,
int* out_width,
int* out_height,
int* crop_width,
int* crop_height,
int* crop_x,
- int* crop_y);
+ int* crop_y,
+ int64_t* translated_camera_time_us);
// Callback attached to SignalFrameCaptured where SignalVideoFrames is called.
void OnFrameCaptured(VideoCapturer* video_capturer,
@@ -284,6 +299,9 @@ class VideoCapturer : public sigslot::has_slots<>,
void UpdateInputSize(int width, int height);
+ // Update the estimated offset between camera time and system monotonic time.
+ void UpdateOffset(int64_t camera_time_us, int64_t system_time_us);
+
rtc::ThreadChecker thread_checker_;
std::string id_;
CaptureState capture_state_;
@@ -310,6 +328,13 @@ class VideoCapturer : public sigslot::has_slots<>,
// Whether capturer should apply rotation to the frame before signaling it.
bool apply_rotation_;
+ // State for the timestamp translation.
+ int frames_seen_;
+ // Previous camera time seen, used to detect jumps in camera time.
+ int64_t prev_camera_time_us_;
+ // Estimated offset between camera time and system monotonic time.
+ int64_t offset_us_;
+
RTC_DISALLOW_COPY_AND_ASSIGN(VideoCapturer);
};

Powered by Google App Engine
This is Rietveld 408576698