diff --git a/api/video/video_frame.cc b/api/video/video_frame.cc index 35dedce1b2..fd975dfd87 100644 --- a/api/video/video_frame.cc +++ b/api/video/video_frame.cc @@ -164,9 +164,9 @@ VideoFrame::Builder::~Builder() = default; VideoFrame VideoFrame::Builder::build() { RTC_CHECK(video_frame_buffer_ != nullptr); return VideoFrame(id_, video_frame_buffer_, timestamp_us_, - capture_time_identifier_, timestamp_rtp_, ntp_time_ms_, - rotation_, color_space_, render_parameters_, update_rect_, - packet_infos_); + capture_time_identifier_, reference_time_, timestamp_rtp_, + ntp_time_ms_, rotation_, color_space_, render_parameters_, + update_rect_, packet_infos_); } VideoFrame::Builder& VideoFrame::Builder::set_video_frame_buffer( @@ -193,6 +193,12 @@ VideoFrame::Builder& VideoFrame::Builder::set_capture_time_identifier( return *this; } +VideoFrame::Builder& VideoFrame::Builder::set_reference_time( + const absl::optional& reference_time) { + reference_time_ = reference_time; + return *this; +} + VideoFrame::Builder& VideoFrame::Builder::set_timestamp_rtp( uint32_t timestamp_rtp) { timestamp_rtp_ = timestamp_rtp; @@ -264,6 +270,7 @@ VideoFrame::VideoFrame(uint16_t id, const rtc::scoped_refptr& buffer, int64_t timestamp_us, const absl::optional& capture_time_identifier, + const absl::optional& reference_time, uint32_t timestamp_rtp, int64_t ntp_time_ms, VideoRotation rotation, @@ -277,6 +284,7 @@ VideoFrame::VideoFrame(uint16_t id, ntp_time_ms_(ntp_time_ms), timestamp_us_(timestamp_us), capture_time_identifier_(capture_time_identifier), + reference_time_(reference_time), rotation_(rotation), color_space_(color_space), render_parameters_(render_parameters), diff --git a/api/video/video_frame.h b/api/video/video_frame.h index a257a3209e..2608f9aa42 100644 --- a/api/video/video_frame.h +++ b/api/video/video_frame.h @@ -109,6 +109,8 @@ class RTC_EXPORT VideoFrame { Builder& set_timestamp_us(int64_t timestamp_us); Builder& set_capture_time_identifier( const absl::optional& capture_time_identifier); + Builder& set_reference_time( + const absl::optional& reference_time); Builder& set_timestamp_rtp(uint32_t timestamp_rtp); Builder& set_ntp_time_ms(int64_t ntp_time_ms); Builder& set_rotation(VideoRotation rotation); @@ -123,6 +125,7 @@ class RTC_EXPORT VideoFrame { rtc::scoped_refptr video_frame_buffer_; int64_t timestamp_us_ = 0; absl::optional capture_time_identifier_; + absl::optional reference_time_; uint32_t timestamp_rtp_ = 0; int64_t ntp_time_ms_ = 0; VideoRotation rotation_ = kVideoRotation_0; @@ -177,6 +180,13 @@ class RTC_EXPORT VideoFrame { capture_time_identifier_ = capture_time_identifier; } + const absl::optional& reference_time() const { + return reference_time_; + } + void set_reference_time(const absl::optional& reference_time) { + reference_time_ = reference_time; + } + // Set frame timestamp (90kHz). void set_timestamp(uint32_t timestamp) { timestamp_rtp_ = timestamp; } @@ -274,6 +284,7 @@ class RTC_EXPORT VideoFrame { const rtc::scoped_refptr& buffer, int64_t timestamp_us, const absl::optional& capture_time_identifier, + const absl::optional& reference_time, uint32_t timestamp_rtp, int64_t ntp_time_ms, VideoRotation rotation, @@ -289,6 +300,11 @@ class RTC_EXPORT VideoFrame { int64_t ntp_time_ms_; int64_t timestamp_us_; absl::optional capture_time_identifier_; + // Contains a monotonically increasing clock time and represents the time + // when the frame was captured. Not all platforms provide the "true" sample + // capture time in |reference_time| but might instead use a somewhat delayed + // (by the time it took to capture the frame) version of it. + absl::optional reference_time_; VideoRotation rotation_; absl::optional color_space_; // Contains parameters that affect have the frame should be rendered.