diff --git a/webrtc/base/timestampaligner.cc b/webrtc/base/timestampaligner.cc index e03e4fb04e..66724399fe 100644 --- a/webrtc/base/timestampaligner.cc +++ b/webrtc/base/timestampaligner.cc @@ -13,11 +13,16 @@ namespace rtc { -TimestampAligner::TimestampAligner() : frames_seen_(0), offset_us_(0) {} +TimestampAligner::TimestampAligner() : frames_seen_(0), offset_us_(0) { + thread_checker_.DetachFromThread(); +} + TimestampAligner::~TimestampAligner() {} int64_t TimestampAligner::UpdateOffset(int64_t camera_time_us, int64_t system_time_us) { + RTC_DCHECK(thread_checker_.CalledOnValidThread()); + // Estimate the offset between system monotonic time and the capture // time from the camera. The camera is assumed to provide more // accurate timestamps than we get from the system time. But the @@ -86,6 +91,8 @@ int64_t TimestampAligner::UpdateOffset(int64_t camera_time_us, int64_t TimestampAligner::ClipTimestamp(int64_t time_us, int64_t system_time_us) { + RTC_DCHECK(thread_checker_.CalledOnValidThread()); + // Make timestamps monotonic. if (!prev_translated_time_us_) { // Initialize. diff --git a/webrtc/base/timestampaligner.h b/webrtc/base/timestampaligner.h index 35008d38c7..d59c6a4a4e 100644 --- a/webrtc/base/timestampaligner.h +++ b/webrtc/base/timestampaligner.h @@ -14,6 +14,7 @@ #include "webrtc/base/basictypes.h" #include "webrtc/base/constructormagic.h" #include "webrtc/base/optional.h" +#include "webrtc/base/thread_checker.h" namespace rtc { @@ -29,6 +30,8 @@ class TimestampAligner { int64_t ClipTimestamp(int64_t filtered_time_us, int64_t system_time_us); private: + rtc::ThreadChecker thread_checker_; + // State for the timestamp translation. int frames_seen_; // Estimated offset between camera time and system monotonic time.