Index: webrtc/media/engine/webrtcvideoengine2.cc |
diff --git a/webrtc/media/engine/webrtcvideoengine2.cc b/webrtc/media/engine/webrtcvideoengine2.cc |
index ec6b033d2f7a3862be69a9c25390d646968cfd2c..521bbdb49ee3fe06acea3dd6c9c3668cc6e6c31c 100644 |
--- a/webrtc/media/engine/webrtcvideoengine2.cc |
+++ b/webrtc/media/engine/webrtcvideoengine2.cc |
@@ -1514,7 +1514,6 @@ WebRtcVideoChannel2::WebRtcVideoSendStream::WebRtcVideoSendStream( |
pending_encoder_reconfiguration_(false), |
allocated_encoder_(nullptr, webrtc::kVideoCodecUnknown, false), |
sending_(false), |
- first_frame_timestamp_ms_(0), |
last_frame_timestamp_ms_(0) { |
parameters_.config.rtp.max_packet_size = kVideoMtu; |
parameters_.conference_mode = send_params.conference_mode; |
@@ -1573,12 +1572,15 @@ void WebRtcVideoChannel2::WebRtcVideoSendStream::OnFrame( |
} |
int64_t frame_delta_ms = frame.GetTimeStamp() / rtc::kNumNanosecsPerMillisec; |
+ |
// frame->GetTimeStamp() is essentially a delta, align to webrtc time |
- if (first_frame_timestamp_ms_ == 0) { |
- first_frame_timestamp_ms_ = rtc::Time() - frame_delta_ms; |
+ if (!first_frame_timestamp_ms_) { |
+ first_frame_timestamp_ms_ = |
+ rtc::Optional<int64_t>(rtc::Time() - frame_delta_ms); |
} |
- last_frame_timestamp_ms_ = first_frame_timestamp_ms_ + frame_delta_ms; |
+ last_frame_timestamp_ms_ = *first_frame_timestamp_ms_ + frame_delta_ms; |
+ |
video_frame.set_render_time_ms(last_frame_timestamp_ms_); |
// Reconfigure codec if necessary. |
SetDimensions(video_frame.width(), video_frame.height()); |
@@ -1608,7 +1610,7 @@ void WebRtcVideoChannel2::WebRtcVideoSendStream::SetSource( |
// Reset timestamps to realign new incoming frames to a webrtc timestamp. A |
// new capturer may have a different timestamp delta than the previous one. |
- first_frame_timestamp_ms_ = 0; |
+ first_frame_timestamp_ms_ = rtc::Optional<int64_t>(); |
if (source == NULL) { |
if (stream_ != NULL) { |