Skip to content

Commit

Permalink
Add WALLCLOCK_FRAME_DURATION frame metadata field
Browse files Browse the repository at this point in the history
This field is intended to be used in following CLs to
annalyze video playback smoothness.

Bug: 1042111
Change-Id: I577916538ca029e437b591ef9d03f04f78e29f8b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2097950
Commit-Queue: Eugene Zemtsov <eugene@chromium.org>
Reviewed-by: Frank Liberato <liberato@chromium.org>
Cr-Commit-Position: refs/heads/master@{#750821}
  • Loading branch information
Djuffin authored and Commit Bot committed Mar 17, 2020
1 parent f7ff81a commit b5ec2f4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
6 changes: 6 additions & 0 deletions media/base/video_frame_metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,12 @@ class MEDIA_EXPORT VideoFrameMetadata {
// network.
RECEIVE_TIME,

// If present, this field represents the duration this frame is ideally
// expected to spend on the screen during playback. Unlike FRAME_DURATION
// this field takes into account current playback rate.
// Use Get/SetTimeDelta() for this key.
WALLCLOCK_FRAME_DURATION,

NUM_KEYS
};

Expand Down
11 changes: 9 additions & 2 deletions media/filters/video_renderer_algorithm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -394,12 +394,19 @@ void VideoRendererAlgorithm::EnqueueFrame(scoped_refptr<VideoFrame> frame) {
}

std::vector<base::TimeTicks> wall_clock_times;
base::TimeDelta wallclock_duration;
wall_clock_time_cb_.Run(media_timestamps, &wall_clock_times);
ready_frame.start_time = wall_clock_times[0];
if (frame_duration_calculator_.count())
if (frame_duration_calculator_.count()) {
ready_frame.end_time = ready_frame.start_time + average_frame_duration_;
else if (wall_clock_times.size() > 1u)
wallclock_duration = average_frame_duration_;
} else if (wall_clock_times.size() > 1u) {
ready_frame.end_time = wall_clock_times[1];
wallclock_duration = ready_frame.end_time - ready_frame.start_time;
}

ready_frame.frame->metadata()->SetTimeDelta(
VideoFrameMetadata::WALLCLOCK_FRAME_DURATION, wallclock_duration);

// The vast majority of cases should always append to the back, but in rare
// circumstance we get out of order timestamps, http://crbug.com/386551.
Expand Down

0 comments on commit b5ec2f4

Please sign in to comment.