Commit c9dc66ad authored by Emircan Uysaler's avatar Emircan Uysaler Committed by Commit Bot

Handle zero timestamp case for incoming remote video

When WebRTC sets timestamp to zero for the remote video, it indicates that we
want to skip render smoothness algorithm and render asap. This CL covers this
case by skipping setting REFERENCE_TIME when timestamp is zero.

Bug: webrtc:9135
Change-Id: Ie6cf7a3a7c07cae400541f222611a6efb2ecd943
Reviewed-on: https://chromium-review.googlesource.com/1066915Reviewed-by: default avatarQiang Chen <qiangchen@chromium.org>
Commit-Queue: Emircan Uysaler <emircan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#560312}
parent 2da79f8c
......@@ -94,21 +94,22 @@ RemoteVideoSourceDelegate::~RemoteVideoSourceDelegate() {
namespace {
void DoNothing(const scoped_refptr<rtc::RefCountInterface>& ref) {}
} // anonymous
} // namespace
void MediaStreamRemoteVideoSource::RemoteVideoSourceDelegate::OnFrame(
const webrtc::VideoFrame& incoming_frame) {
const base::TimeDelta incoming_timestamp = base::TimeDelta::FromMicroseconds(
incoming_frame.timestamp_us());
const bool render_immediately = incoming_frame.timestamp_us() == 0;
const base::TimeDelta incoming_timestamp =
render_immediately
? base::TimeTicks::Now() - base::TimeTicks()
: base::TimeDelta::FromMicroseconds(incoming_frame.timestamp_us());
const base::TimeTicks render_time =
base::TimeTicks() + incoming_timestamp + time_diff_;
CHECK_NE(media::kNoTimestamp, incoming_timestamp);
render_immediately ? base::TimeTicks() + incoming_timestamp
: base::TimeTicks() + incoming_timestamp + time_diff_;
if (start_timestamp_ == media::kNoTimestamp)
start_timestamp_ = incoming_timestamp;
const base::TimeDelta elapsed_timestamp =
incoming_timestamp - start_timestamp_;
TRACE_EVENT2("webrtc", "RemoteVideoSourceDelegate::RenderFrame",
"Ideal Render Instant", render_time.ToInternalValue(),
"Timestamp", elapsed_timestamp.InMicroseconds());
......@@ -165,8 +166,12 @@ void MediaStreamRemoteVideoSource::RemoteVideoSourceDelegate::OnFrame(
media::VideoFrameMetadata::ROTATION,
WebRTCToMediaVideoRotation(incoming_frame.rotation()));
}
// Run render smoothness algorithm only when we don't have to render
// immediately.
if (!render_immediately) {
video_frame->metadata()->SetTimeTicks(
media::VideoFrameMetadata::REFERENCE_TIME, render_time);
}
io_task_runner_->PostTask(
FROM_HERE,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment