Chromium Code Reviews| Index: talk/media/webrtc/webrtcvideoengine2.cc |
| diff --git a/talk/media/webrtc/webrtcvideoengine2.cc b/talk/media/webrtc/webrtcvideoengine2.cc |
| index 0a2152e5e4c891494f34df4a271acb13aa3ec90f..ae3a15ebbca8aba079020737ec696944dab42868 100644 |
| --- a/talk/media/webrtc/webrtcvideoengine2.cc |
| +++ b/talk/media/webrtc/webrtcvideoengine2.cc |
| @@ -42,6 +42,7 @@ |
| #include "webrtc/base/buffer.h" |
| #include "webrtc/base/logging.h" |
| #include "webrtc/base/stringutils.h" |
| +#include "webrtc/base/timeutils.h" |
| #include "webrtc/call.h" |
| #include "webrtc/modules/video_coding/codecs/h264/include/h264.h" |
| #include "webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h" |
| @@ -1663,7 +1664,9 @@ WebRtcVideoChannel2::WebRtcVideoSendStream::WebRtcVideoSendStream( |
| capturer_(NULL), |
| sending_(false), |
| muted_(false), |
| - old_adapt_changes_(0) { |
| + old_adapt_changes_(0), |
| + base_timestamp_ms_(0), |
| + last_timestamp_ms_(0) { |
| parameters_.config.rtp.max_packet_size = kVideoMtu; |
| sp.GetPrimarySsrcs(¶meters_.config.rtp.ssrcs); |
| @@ -1727,6 +1730,15 @@ void WebRtcVideoChannel2::WebRtcVideoSendStream::InputFrame( |
| static_cast<int>(frame->GetWidth()), |
| static_cast<int>(frame->GetHeight())); |
| } |
| + |
| + int64_t frame_delta_ms = frame->GetTimeStamp() / rtc::kNumNanosecsPerMillisec; |
| + // frame->GetTimeStamp() is essentially a delta, align to webrtc time |
| + if (base_timestamp_ms_ == 0) { |
| + base_timestamp_ms_ = rtc::Time() - frame_delta_ms; |
|
pthatcher1
2015/07/15 17:53:07
This makes it more clear that this value should pr
qiangchen
2015/07/15 19:35:22
Done.
|
| + } |
| + |
| + last_timestamp_ms_ = base_timestamp_ms_ + frame_delta_ms; |
|
pthatcher1
2015/07/15 17:53:07
And this should be last_frame_timestamp_ms_.
qiangchen
2015/07/15 19:35:22
Done.
|
| + video_frame.set_render_time_ms(last_timestamp_ms_); |
| // Reconfigure codec if necessary. |
| SetDimensions( |
| video_frame.width(), video_frame.height(), capturer->IsScreencast()); |
| @@ -1755,6 +1767,14 @@ bool WebRtcVideoChannel2::WebRtcVideoSendStream::SetCapturer( |
| CreateBlackFrame(&black_frame, last_dimensions_.width, |
| last_dimensions_.height); |
| + |
| + // Force this black frame not to be dropped due to timestamp order |
| + // check. As IncomingCapturedFrame will drop the frame if this frame's |
| + // timestamp is less than or equal to last frame's timestamp, it is |
| + // necessary to give this black frame a larger timestamp than the |
| + // previous one. |
| + last_timestamp_ms_ += format_.interval / rtc::kNumNanosecsPerMillisec; |
| + black_frame.set_render_time_ms(last_timestamp_ms_); |
| stream_->Input()->IncomingCapturedFrame(black_frame); |
| } |