Commit 7ef5d0fe authored by Dan Sanders's avatar Dan Sanders Committed by Commit Bot

[media] Report MediaPlayerRenderer WatchTime.

MediaPlayerRenderer does not report tracks or natural size in its
metadata. Due to the kMinimumVideoSize condition, MediaPlayerRenderer
WatchTime has not been reported starting in M69.

This CL reinitializes the WatchTimeReporter when MediaPlayerRenderer
emits its first natural size change event, and treats playback without
such an event as audio-only.

Bug: 959037
Change-Id: I4765e0a4d8044f084c313682092abedc205cc9cf
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1592617
Commit-Queue: Dan Sanders <sandersd@chromium.org>
Reviewed-by: default avatarDale Curtis <dalecurtis@chromium.org>
Cr-Commit-Position: refs/heads/master@{#656472}
parent 547979cf
......@@ -2124,7 +2124,18 @@ void WebMediaPlayerImpl::OnVideoNaturalSizeChange(const gfx::Size& size) {
return;
pipeline_metadata_.natural_size = rotated_size;
if (using_media_player_renderer_ && old_size.IsEmpty()) {
// If we are using MediaPlayerRenderer and this is the first size change, we
// now know that there is a video track. This condition is paired with code
// in CreateWatchTimeReporter() that guesses the existence of a video track.
CreateWatchTimeReporter();
} else {
// TODO(sandersd): If the size changed such that ShouldReportWatchTime()
// changes, |watch_time_reporter_| should be reinitialized. This should be
// internal to WatchTimeReporter.
UpdateSecondaryProperties();
}
if (video_decode_stats_reporter_ &&
!video_decode_stats_reporter_->MatchesBucketedNaturalSize(
......@@ -3053,12 +3064,18 @@ void WebMediaPlayerImpl::CreateWatchTimeReporter() {
if (!HasVideo() && !HasAudio())
return;
// MediaPlayerRenderer does not know about tracks until playback starts.
// Assume audio-only unless the natural size has been detected.
bool has_video = pipeline_metadata_.has_video;
if (using_media_player_renderer_) {
has_video = !pipeline_metadata_.natural_size.IsEmpty();
}
// Create the watch time reporter and synchronize its initial state.
watch_time_reporter_.reset(new WatchTimeReporter(
mojom::PlaybackProperties::New(pipeline_metadata_.has_audio,
pipeline_metadata_.has_video, false, false,
!!chunk_demuxer_, is_encrypted_,
embedded_media_experience_enabled_),
mojom::PlaybackProperties::New(
pipeline_metadata_.has_audio, has_video, false, false,
!!chunk_demuxer_, is_encrypted_, embedded_media_experience_enabled_),
pipeline_metadata_.natural_size,
base::BindRepeating(&WebMediaPlayerImpl::GetCurrentTimeInternal,
base::Unretained(this)),
......
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