Chromium Code Reviews| Index: media/blink/webmediaplayer_impl.cc |
| diff --git a/media/blink/webmediaplayer_impl.cc b/media/blink/webmediaplayer_impl.cc |
| index 7c10f9fe3981b98b65561a2e49d7f3a4fe8f9ca8..e00329fe559b72e8f62108aa888259e7cbb377d3 100644 |
| --- a/media/blink/webmediaplayer_impl.cc |
| +++ b/media/blink/webmediaplayer_impl.cc |
| @@ -1398,28 +1398,29 @@ void WebMediaPlayerImpl::OnVideoNaturalSizeChange(const gfx::Size& size) { |
| DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| DCHECK_NE(ready_state_, WebMediaPlayer::kReadyStateHaveNothing); |
| + TRACE_EVENT0("media", "WebMediaPlayerImpl::OnNaturalSizeChanged"); |
| + |
| // The input |size| is from the decoded video frame, which is the original |
| // natural size and need to be rotated accordingly. |
| gfx::Size rotated_size = |
| GetRotatedVideoSize(pipeline_metadata_.video_rotation, size); |
| - if (rotated_size == pipeline_metadata_.natural_size) |
| + RecordVideoNaturalSize(rotated_size); |
| + |
| + gfx::Size old_size = pipeline_metadata_.natural_size; |
| + if (rotated_size == old_size) |
| return; |
| - TRACE_EVENT0("media", "WebMediaPlayerImpl::OnNaturalSizeChanged"); |
| - media_log_->AddEvent(media_log_->CreateVideoSizeSetEvent( |
| - rotated_size.width(), rotated_size.height())); |
| + pipeline_metadata_.natural_size = rotated_size; |
| + |
| + // WatchTimeReporter doesn't report metrics for empty videos. Re-create |
|
DaleCurtis
2017/04/17 19:05:58
Needs rebase.
|
| + // |watch_time_reporter_| if we didn't originally know the video size. |
| + if (old_size.IsEmpty()) |
| + CreateWatchTimeReporter(); |
| if (overlay_enabled_ && surface_manager_) |
| surface_manager_->NaturalSizeChanged(rotated_size); |
| - gfx::Size old_size = pipeline_metadata_.natural_size; |
| - pipeline_metadata_.natural_size = rotated_size; |
| - if (old_size.IsEmpty()) { |
| - // WatchTimeReporter doesn't report metrics for empty videos. Re-create |
| - // |watch_time_reporter_| if we didn't originally know the video size. |
| - CreateWatchTimeReporter(); |
| - } |
| client_->SizeChanged(); |
| if (observer_) |
| @@ -2348,4 +2349,42 @@ void WebMediaPlayerImpl::RecordUnderflowDuration(base::TimeDelta duration) { |
| UMA_HISTOGRAM_TIMES("Media.UnderflowDuration.MSE", duration); |
| } |
| +#define UMA_HISTOGRAM_VIDEO_HEIGHT(name, sample) \ |
| + UMA_HISTOGRAM_CUSTOM_COUNTS(name, sample, 64, 10000, 120) |
| + |
| +void WebMediaPlayerImpl::RecordVideoNaturalSize(const gfx::Size& natural_size) { |
| + // Always report video natural size to MediaLog. |
| + media_log_->AddEvent(media_log_->CreateVideoSizeSetEvent( |
| + natural_size.width(), natural_size.height())); |
| + |
| + int height = natural_size.height(); |
| + |
| + if (load_type_ == kLoadTypeURL) |
| + UMA_HISTOGRAM_VIDEO_HEIGHT("Media.VideoHeight.Average.SRC", height); |
| + else if (load_type_ == kLoadTypeMediaSource) |
| + UMA_HISTOGRAM_VIDEO_HEIGHT("Media.VideoHeight.Average.MSE", height); |
| + |
| + if (is_encrypted_) |
| + UMA_HISTOGRAM_VIDEO_HEIGHT("Media.VideoHeight.Average.EME", height); |
| + |
| + UMA_HISTOGRAM_VIDEO_HEIGHT("Media.VideoHeight.Average.All", height); |
| + |
| + if (initial_video_height_recorded_) |
| + return; |
| + |
| + initial_video_height_recorded_ = true; |
| + |
| + if (load_type_ == kLoadTypeURL) |
| + UMA_HISTOGRAM_VIDEO_HEIGHT("Media.VideoHeight.Initial.SRC", height); |
| + else if (load_type_ == kLoadTypeMediaSource) |
| + UMA_HISTOGRAM_VIDEO_HEIGHT("Media.VideoHeight.Initial.MSE", height); |
| + |
| + if (is_encrypted_) |
| + UMA_HISTOGRAM_VIDEO_HEIGHT("Media.VideoHeight.Initial.EME", height); |
| + |
| + UMA_HISTOGRAM_VIDEO_HEIGHT("Media.VideoHeight.Initial.All", height); |
| +} |
| + |
| +#undef UMA_HISTOGRAM_VIDEO_HEIGHT |
| + |
| } // namespace media |