Index: webrtc/media/base/videocapturer.cc |
diff --git a/webrtc/media/base/videocapturer.cc b/webrtc/media/base/videocapturer.cc |
index 94f65143531479ab5c9344034a030c8f7edcb501..f9712edd4cb369647695154fe11859b818611952 100644 |
--- a/webrtc/media/base/videocapturer.cc |
+++ b/webrtc/media/base/videocapturer.cc |
@@ -224,6 +224,18 @@ void VideoCapturer::OnFrameCaptured(VideoCapturer*, |
return; |
} |
+ int64_t timestamp_us = |
perkj_webrtc
2016/04/08 08:22:48
do this in the frame factory instead.
nisse-webrtc
2016/04/08 09:15:43
Moving the logic there makes sense, I'll give it a
|
+ captured_frame->time_stamp / rtc::kNumNanosecsPerMicrosec; |
+ |
+ if (!timestamp_offset_valid_) { |
+ timestamp_offset_ = rtc::TimeMicros() - timestamp_us; |
+ timestamp_offset_valid_ = true; |
+ } |
+ |
+ // Add offset, to get time stamps with the same epoch as the |
+ // system monotonic clock, rtc::TimeMicros(). |
+ timestamp_us += timestamp_offset_; |
+ |
// Use a temporary buffer to scale |
std::unique_ptr<uint8_t[]> scale_buffer; |
if (IsScreencast()) { |
@@ -396,6 +408,11 @@ void VideoCapturer::OnFrameCaptured(VideoCapturer*, |
return; |
} |
+ // Overrides the timestamp set by the FrameFactory. |
+ // TODO(nisse): Arrange to either get the FrameFactory to set the |
+ // timestamp with correct offset, or not set the timestamp at all. |
+ adapted_frame->set_timestamp_us(timestamp_us); |
+ |
OnFrame(this, adapted_frame.get()); |
UpdateInputSize(captured_frame); |
} |