Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(91)

Side by Side Diff: media/blink/webmediaplayer_impl.cc

Issue 2814043005: media: Report initial video height to UMA (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « media/blink/webmediaplayer_impl.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "media/blink/webmediaplayer_impl.h" 5 #include "media/blink/webmediaplayer_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <limits> 9 #include <limits>
10 #include <string> 10 #include <string>
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 using blink::WebMediaPlayer; 74 using blink::WebMediaPlayer;
75 using blink::WebRect; 75 using blink::WebRect;
76 using blink::WebSize; 76 using blink::WebSize;
77 using blink::WebString; 77 using blink::WebString;
78 using gpu::gles2::GLES2Interface; 78 using gpu::gles2::GLES2Interface;
79 79
80 #define STATIC_ASSERT_ENUM(a, b) \ 80 #define STATIC_ASSERT_ENUM(a, b) \
81 static_assert(static_cast<int>(a) == static_cast<int>(b), \ 81 static_assert(static_cast<int>(a) == static_cast<int>(b), \
82 "mismatching enums: " #a) 82 "mismatching enums: " #a)
83 83
84 #define UMA_HISTOGRAM_VIDEO_HEIGHT(name, sample) \
85 UMA_HISTOGRAM_CUSTOM_COUNTS(name, sample, 64, 10000, 120)
86
84 namespace media { 87 namespace media {
85 88
86 namespace { 89 namespace {
87 90
88 // Limits the range of playback rate. 91 // Limits the range of playback rate.
89 // 92 //
90 // TODO(kylep): Revisit these. 93 // TODO(kylep): Revisit these.
91 // 94 //
92 // Vista has substantially lower performance than XP or Windows7. If you speed 95 // Vista has substantially lower performance than XP or Windows7. If you speed
93 // up a video too much, it can't keep up, and rendering stops updating except on 96 // up a video too much, it can't keep up, and rendering stops updating except on
(...skipping 1297 matching lines...) Expand 10 before | Expand all | Expand 10 after
1391 // TODO(jrummell): didResumePlaybackBlockedForKey() should only be called 1394 // TODO(jrummell): didResumePlaybackBlockedForKey() should only be called
1392 // when a key has been successfully added (e.g. OnSessionKeysChange() with 1395 // when a key has been successfully added (e.g. OnSessionKeysChange() with
1393 // |has_additional_usable_key| = true). http://crbug.com/461903 1396 // |has_additional_usable_key| = true). http://crbug.com/461903
1394 encrypted_client_->DidResumePlaybackBlockedForKey(); 1397 encrypted_client_->DidResumePlaybackBlockedForKey();
1395 } 1398 }
1396 1399
1397 void WebMediaPlayerImpl::OnVideoNaturalSizeChange(const gfx::Size& size) { 1400 void WebMediaPlayerImpl::OnVideoNaturalSizeChange(const gfx::Size& size) {
1398 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1401 DCHECK(main_task_runner_->BelongsToCurrentThread());
1399 DCHECK_NE(ready_state_, WebMediaPlayer::kReadyStateHaveNothing); 1402 DCHECK_NE(ready_state_, WebMediaPlayer::kReadyStateHaveNothing);
1400 1403
1404 TRACE_EVENT0("media", "WebMediaPlayerImpl::OnNaturalSizeChanged");
1405
1401 // The input |size| is from the decoded video frame, which is the original 1406 // The input |size| is from the decoded video frame, which is the original
1402 // natural size and need to be rotated accordingly. 1407 // natural size and need to be rotated accordingly.
1403 gfx::Size rotated_size = 1408 gfx::Size rotated_size =
1404 GetRotatedVideoSize(pipeline_metadata_.video_rotation, size); 1409 GetRotatedVideoSize(pipeline_metadata_.video_rotation, size);
1405 1410
1406 if (rotated_size == pipeline_metadata_.natural_size) 1411 RecordVideoNaturalSize(rotated_size);
DaleCurtis 2017/04/14 18:30:19 Put below l.1415 to avoid duplicate size events?
xhwang 2017/04/14 20:30:35 OnVideoNaturalSizeChange() should only be called o
1412
1413 gfx::Size old_size = pipeline_metadata_.natural_size;
1414 if (rotated_size == old_size)
1407 return; 1415 return;
1408 1416
1409 TRACE_EVENT0("media", "WebMediaPlayerImpl::OnNaturalSizeChanged"); 1417 pipeline_metadata_.natural_size = rotated_size;
1410 media_log_->AddEvent(media_log_->CreateVideoSizeSetEvent( 1418
1411 rotated_size.width(), rotated_size.height())); 1419 // WatchTimeReporter doesn't report metrics for empty videos. Re-create
1420 // |watch_time_reporter_| if we didn't originally know the video size.
1421 if (old_size.IsEmpty())
1422 CreateWatchTimeReporter();
1412 1423
1413 if (overlay_enabled_ && surface_manager_) 1424 if (overlay_enabled_ && surface_manager_)
1414 surface_manager_->NaturalSizeChanged(rotated_size); 1425 surface_manager_->NaturalSizeChanged(rotated_size);
1415 1426
1416 gfx::Size old_size = pipeline_metadata_.natural_size;
1417 pipeline_metadata_.natural_size = rotated_size;
1418 if (old_size.IsEmpty()) {
1419 // WatchTimeReporter doesn't report metrics for empty videos. Re-create
1420 // |watch_time_reporter_| if we didn't originally know the video size.
1421 CreateWatchTimeReporter();
1422 }
1423 client_->SizeChanged(); 1427 client_->SizeChanged();
1424 1428
1425 if (observer_) 1429 if (observer_)
1426 observer_->OnMetadataChanged(pipeline_metadata_); 1430 observer_->OnMetadataChanged(pipeline_metadata_);
1427 } 1431 }
1428 1432
1429 void WebMediaPlayerImpl::OnVideoOpacityChange(bool opaque) { 1433 void WebMediaPlayerImpl::OnVideoOpacityChange(bool opaque) {
1430 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1434 DCHECK(main_task_runner_->BelongsToCurrentThread());
1431 DCHECK_NE(ready_state_, WebMediaPlayer::kReadyStateHaveNothing); 1435 DCHECK_NE(ready_state_, WebMediaPlayer::kReadyStateHaveNothing);
1432 1436
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after
2341 } 2345 }
2342 2346
2343 void WebMediaPlayerImpl::RecordUnderflowDuration(base::TimeDelta duration) { 2347 void WebMediaPlayerImpl::RecordUnderflowDuration(base::TimeDelta duration) {
2344 DCHECK(data_source_ || chunk_demuxer_); 2348 DCHECK(data_source_ || chunk_demuxer_);
2345 if (data_source_) 2349 if (data_source_)
2346 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration", duration); 2350 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration", duration);
2347 else 2351 else
2348 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration.MSE", duration); 2352 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration.MSE", duration);
2349 } 2353 }
2350 2354
2355 void WebMediaPlayerImpl::RecordVideoNaturalSize(const gfx::Size& natural_size) {
2356 // Always report video natural size to MediaLog.
2357 media_log_->AddEvent(media_log_->CreateVideoSizeSetEvent(
2358 natural_size.width(), natural_size.height()));
2359
2360 // TODO(xhwang): Also report "average" video height for this playback session.
DaleCurtis 2017/04/14 18:30:19 Why not just record every size change? Why the foc
xhwang 2017/04/14 20:30:35 As discussed offline, this is useful to measure th
2361 // See http://crbug.com/709354
2362
2363 if (initial_video_height_recorded_)
2364 return;
2365
2366 initial_video_height_recorded_ = true;
2367
2368 int height = natural_size.height();
2369 // For vertical videos, use it's width instead of height for UMA reporting.
DaleCurtis 2017/04/14 18:48:57 Hmmm, why? Seems like this might muddy the metrics
xhwang 2017/04/14 20:30:35 I was debating on this myself. Unless we report th
2370 if (height > natural_size.width())
2371 height = natural_size.width();
2372
2373 if (load_type_ == kLoadTypeURL)
2374 UMA_HISTOGRAM_VIDEO_HEIGHT("Media.VideoHeight.Initial.SRC", height);
2375 else if (load_type_ == kLoadTypeMediaSource)
2376 UMA_HISTOGRAM_VIDEO_HEIGHT("Media.VideoHeight.Initial.MSE", height);
2377
2378 if (is_encrypted_)
2379 UMA_HISTOGRAM_VIDEO_HEIGHT("Media.VideoHeight.Initial.EME", height);
2380
2381 UMA_HISTOGRAM_VIDEO_HEIGHT("Media.VideoHeight.Initial.ALL", height);
DaleCurtis 2017/04/14 18:48:57 All
xhwang 2017/04/14 20:30:35 Done. Thanks for catching this!
2382 }
2383
2351 } // namespace media 2384 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/webmediaplayer_impl.h ('k') | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698