Index: webrtc/video/vie_encoder.cc |
diff --git a/webrtc/video/vie_encoder.cc b/webrtc/video/vie_encoder.cc |
index 203d1c405a8813d05b627cd464803bb9df39f645..57d8c2ff1b02f6b9c8433e877fcce5155c5bea35 100644 |
--- a/webrtc/video/vie_encoder.cc |
+++ b/webrtc/video/vie_encoder.cc |
@@ -581,7 +581,13 @@ void ViEEncoder::OnFrame(const VideoFrame& video_frame) { |
VideoFrame incoming_frame = video_frame; |
// Local time in webrtc time base. |
- int64_t current_time_ms = clock_->TimeInMilliseconds(); |
+ int64_t current_time_us = clock_->TimeInMicroseconds(); |
+ int64_t current_time_ms = current_time_us / rtc::kNumMicrosecsPerMillisec; |
+ // If the frame is not from the capturer but from decoder, render time may |
+ // be set to the future. To avoid irregularities in statistics, where frame |
+ // is captured after being encoded, we should reset capture time here. |
+ if (incoming_frame.timestamp_us() > current_time_us) |
+ incoming_frame.set_timestamp_us(current_time_us); |
// Capture time may come from clock with an offset and drift from clock_. |
int64_t capture_ntp_time_ms; |