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 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1399 // TODO(jrummell): didResumePlaybackBlockedForKey() should only be called | 1399 // TODO(jrummell): didResumePlaybackBlockedForKey() should only be called |
| 1400 // when a key has been successfully added (e.g. OnSessionKeysChange() with | 1400 // when a key has been successfully added (e.g. OnSessionKeysChange() with |
| 1401 // |has_additional_usable_key| = true). http://crbug.com/461903 | 1401 // |has_additional_usable_key| = true). http://crbug.com/461903 |
| 1402 encrypted_client_->DidResumePlaybackBlockedForKey(); | 1402 encrypted_client_->DidResumePlaybackBlockedForKey(); |
| 1403 } | 1403 } |
| 1404 | 1404 |
| 1405 void WebMediaPlayerImpl::OnVideoNaturalSizeChange(const gfx::Size& size) { | 1405 void WebMediaPlayerImpl::OnVideoNaturalSizeChange(const gfx::Size& size) { |
| 1406 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1406 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 1407 DCHECK_NE(ready_state_, WebMediaPlayer::kReadyStateHaveNothing); | 1407 DCHECK_NE(ready_state_, WebMediaPlayer::kReadyStateHaveNothing); |
| 1408 | 1408 |
| 1409 TRACE_EVENT0("media", "WebMediaPlayerImpl::OnNaturalSizeChanged"); | |
| 1410 | |
| 1409 // The input |size| is from the decoded video frame, which is the original | 1411 // The input |size| is from the decoded video frame, which is the original |
| 1410 // natural size and need to be rotated accordingly. | 1412 // natural size and need to be rotated accordingly. |
| 1411 gfx::Size rotated_size = | 1413 gfx::Size rotated_size = |
| 1412 GetRotatedVideoSize(pipeline_metadata_.video_rotation, size); | 1414 GetRotatedVideoSize(pipeline_metadata_.video_rotation, size); |
| 1413 | 1415 |
| 1414 if (rotated_size == pipeline_metadata_.natural_size) | 1416 RecordVideoNaturalSize(rotated_size); |
| 1417 | |
| 1418 gfx::Size old_size = pipeline_metadata_.natural_size; | |
| 1419 if (rotated_size == old_size) | |
| 1415 return; | 1420 return; |
| 1416 | 1421 |
| 1417 TRACE_EVENT0("media", "WebMediaPlayerImpl::OnNaturalSizeChanged"); | |
| 1418 media_log_->AddEvent(media_log_->CreateVideoSizeSetEvent( | |
| 1419 rotated_size.width(), rotated_size.height())); | |
| 1420 | |
| 1421 if (overlay_enabled_ && surface_manager_) | |
| 1422 surface_manager_->NaturalSizeChanged(rotated_size); | |
| 1423 | |
| 1424 pipeline_metadata_.natural_size = rotated_size; | 1422 pipeline_metadata_.natural_size = rotated_size; |
| 1425 | 1423 |
| 1426 // Re-create |watch_time_reporter_| if we didn't originally know the video | 1424 // Re-create |watch_time_reporter_| if we didn't originally know the video |
| 1427 // size or the previous size was too small for reporting. | 1425 // size or the previous size was too small for reporting. |
| 1428 if (!watch_time_reporter_->IsSizeLargeEnoughToReportWatchTime()) | 1426 if (!watch_time_reporter_->IsSizeLargeEnoughToReportWatchTime()) |
| 1429 CreateWatchTimeReporter(); | 1427 CreateWatchTimeReporter(); |
| 1430 | 1428 |
| 1429 if (overlay_enabled_ && surface_manager_) | |
| 1430 surface_manager_->NaturalSizeChanged(rotated_size); | |
| 1431 | |
| 1431 client_->SizeChanged(); | 1432 client_->SizeChanged(); |
| 1432 | 1433 |
| 1433 if (observer_) | 1434 if (observer_) |
| 1434 observer_->OnMetadataChanged(pipeline_metadata_); | 1435 observer_->OnMetadataChanged(pipeline_metadata_); |
| 1435 } | 1436 } |
| 1436 | 1437 |
| 1437 void WebMediaPlayerImpl::OnVideoOpacityChange(bool opaque) { | 1438 void WebMediaPlayerImpl::OnVideoOpacityChange(bool opaque) { |
| 1438 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1439 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 1439 DCHECK_NE(ready_state_, WebMediaPlayer::kReadyStateHaveNothing); | 1440 DCHECK_NE(ready_state_, WebMediaPlayer::kReadyStateHaveNothing); |
| 1440 | 1441 |
| (...skipping 917 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2358 } | 2359 } |
| 2359 | 2360 |
| 2360 void WebMediaPlayerImpl::RecordUnderflowDuration(base::TimeDelta duration) { | 2361 void WebMediaPlayerImpl::RecordUnderflowDuration(base::TimeDelta duration) { |
| 2361 DCHECK(data_source_ || chunk_demuxer_); | 2362 DCHECK(data_source_ || chunk_demuxer_); |
| 2362 if (data_source_) | 2363 if (data_source_) |
| 2363 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration", duration); | 2364 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration", duration); |
| 2364 else | 2365 else |
| 2365 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration.MSE", duration); | 2366 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration.MSE", duration); |
| 2366 } | 2367 } |
| 2367 | 2368 |
| 2369 #define UMA_HISTOGRAM_VIDEO_HEIGHT(name, sample) \ | |
| 2370 UMA_HISTOGRAM_CUSTOM_COUNTS(name, sample, 100, 10000, 50) | |
| 2371 | |
| 2372 void WebMediaPlayerImpl::RecordVideoNaturalSize(const gfx::Size& natural_size) { | |
| 2373 // Always report video natural size to MediaLog. | |
| 2374 media_log_->AddEvent(media_log_->CreateVideoSizeSetEvent( | |
| 2375 natural_size.width(), natural_size.height())); | |
| 2376 | |
| 2377 if (initial_video_height_recorded_) | |
| 2378 return; | |
| 2379 | |
| 2380 initial_video_height_recorded_ = true; | |
| 2381 | |
| 2382 int height = natural_size.height(); | |
| 2383 | |
| 2384 if (load_type_ == kLoadTypeURL) | |
| 2385 UMA_HISTOGRAM_VIDEO_HEIGHT("Media.VideoHeight.Initial.SRC", height); | |
| 2386 else if (load_type_ == kLoadTypeMediaSource) | |
| 2387 UMA_HISTOGRAM_VIDEO_HEIGHT("Media.VideoHeight.Initial.MSE", height); | |
| 2388 | |
| 2389 if (is_encrypted_) | |
| 2390 UMA_HISTOGRAM_VIDEO_HEIGHT("Media.VideoHeight.Initial.EME", height); | |
| 2391 | |
| 2392 UMA_HISTOGRAM_VIDEO_HEIGHT("Media.VideoHeight.Initial.All", height); | |
| 2393 } | |
| 2394 | |
| 2395 #undef UMA_HISTOGRAM_VIDEO_HEIGHT | |
|
Ilya Sherman
2017/04/19 05:52:45
Optional nit: It seems a bit weird to #undef in an
xhwang
2017/04/19 06:03:50
Thanks for catching the weirdness. I am okay eithe
| |
| 2396 | |
| 2368 } // namespace media | 2397 } // namespace media |
| OLD | NEW |