Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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) \ | |
|
DaleCurtis
2017/04/14 22:03:38
Define near where used and then use #undef afterwa
xhwang
2017/04/14 22:18:06
Done.
| |
| 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 Loading... | |
| 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); |
| 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 Loading... | |
| 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 22:03:38
Want to go ahead and just add this now?
xhwang
2017/04/14 22:18:06
I want to merge this back to M59 to collect data e
xhwang
2017/04/14 23:07:41
Done.
| |
| 2361 // See http://crbug.com/709354 | |
| 2362 | |
| 2363 if (initial_video_height_recorded_) | |
|
tguilbert
2017/04/14 22:00:49
Drive-by: For HLS, our original video size is alwa
xhwang
2017/04/14 22:04:53
Good point.
Will OnVideoNaturalSizeChange() be c
| |
| 2364 return; | |
| 2365 | |
| 2366 initial_video_height_recorded_ = true; | |
| 2367 int height = natural_size.height(); | |
| 2368 | |
| 2369 if (load_type_ == kLoadTypeURL) | |
| 2370 UMA_HISTOGRAM_VIDEO_HEIGHT("Media.VideoHeight.Initial.SRC", height); | |
| 2371 else if (load_type_ == kLoadTypeMediaSource) | |
| 2372 UMA_HISTOGRAM_VIDEO_HEIGHT("Media.VideoHeight.Initial.MSE", height); | |
| 2373 | |
| 2374 if (is_encrypted_) | |
| 2375 UMA_HISTOGRAM_VIDEO_HEIGHT("Media.VideoHeight.Initial.EME", height); | |
| 2376 | |
| 2377 UMA_HISTOGRAM_VIDEO_HEIGHT("Media.VideoHeight.Initial.All", height); | |
| 2378 } | |
| 2379 | |
| 2351 } // namespace media | 2380 } // namespace media |
| OLD | NEW |