Refactor TimestampAligner for more general use.
This only changes the comments and rename variables.
Bug: chromium:1054403
Change-Id: Ie7419ca23e482361e9f90405587b8c8f839b26d2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/169101
Commit-Queue: Minyue Li <minyue@webrtc.org>
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30710}
diff --git a/rtc_base/timestamp_aligner.h b/rtc_base/timestamp_aligner.h
index 151bcdc..48023ab 100644
--- a/rtc_base/timestamp_aligner.h
+++ b/rtc_base/timestamp_aligner.h
@@ -18,14 +18,15 @@
namespace rtc {
-// The TimestampAligner class helps translating camera timestamps into
-// the same timescale as is used by rtc::TimeMicros(). Some cameras
-// have built in timestamping which is more accurate than reading the
-// system clock, but using a different epoch and unknown clock drift.
-// Frame timestamps in webrtc should use rtc::TimeMicros (system monotonic
-// time), and this class provides a filter which lets us use the
-// rtc::TimeMicros timescale, and at the same time take advantage of
-// higher accuracy of the camera clock.
+// The TimestampAligner class helps translating timestamps of a capture system
+// into the same timescale as is used by rtc::TimeMicros(). Some capture systems
+// provide timestamps, which comes from the capturing hardware (camera or sound
+// card) or stamped close to the capturing hardware. Such timestamps are more
+// accurate (less jittery) than reading the system clock, but may have a
+// different epoch and unknown clock drift. Frame timestamps in webrtc should
+// use rtc::TimeMicros (system monotonic time), and this class provides a filter
+// which lets us use the rtc::TimeMicros timescale, and at the same time take
+// advantage of higher accuracy of the capturer's clock.
// This class is not thread safe, so all calls to it must be synchronized
// externally.
@@ -35,18 +36,19 @@
~TimestampAligner();
public:
- // Translates camera timestamps to the same timescale as is used by
- // rtc::TimeMicros(). |camera_time_us| is assumed to be accurate, but
+ // Translates timestamps of a capture system to the same timescale as is used
+ // by rtc::TimeMicros(). |capturer_time_us| is assumed to be accurate, but
// with an unknown epoch and clock drift. |system_time_us| is
// time according to rtc::TimeMicros(), preferably read as soon as
// possible when the frame is captured. It may have poor accuracy
// due to poor resolution or scheduling delays. Returns the
// translated timestamp.
- int64_t TranslateTimestamp(int64_t camera_time_us, int64_t system_time_us);
+ int64_t TranslateTimestamp(int64_t capturer_time_us, int64_t system_time_us);
protected:
- // Update the estimated offset between camera time and system monotonic time.
- int64_t UpdateOffset(int64_t camera_time_us, int64_t system_time_us);
+ // Update the estimated offset between capturer's time and system monotonic
+ // time.
+ int64_t UpdateOffset(int64_t capturer_time_us, int64_t system_time_us);
// Clip timestamp, return value is always
// <= |system_time_us|, and
@@ -57,11 +59,11 @@
private:
// State for the timestamp translation.
int frames_seen_;
- // Estimated offset between camera time and system monotonic time.
+ // Estimated offset between capturer's time and system monotonic time.
int64_t offset_us_;
// State for the ClipTimestamp method, applied after the filter.
- // A large negative camera clock drift tends to push translated
+ // A large negative clock drift of the capturer tends to push translated
// timestamps into the future. |clip_bias_us_| is subtracted from the
// translated timestamps, to get them back from the future.
int64_t clip_bias_us_;