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 1380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1391 // TODO(jrummell): didResumePlaybackBlockedForKey() should only be called | 1391 // TODO(jrummell): didResumePlaybackBlockedForKey() should only be called |
1392 // when a key has been successfully added (e.g. OnSessionKeysChange() with | 1392 // when a key has been successfully added (e.g. OnSessionKeysChange() with |
1393 // |has_additional_usable_key| = true). http://crbug.com/461903 | 1393 // |has_additional_usable_key| = true). http://crbug.com/461903 |
1394 encrypted_client_->DidResumePlaybackBlockedForKey(); | 1394 encrypted_client_->DidResumePlaybackBlockedForKey(); |
1395 } | 1395 } |
1396 | 1396 |
1397 void WebMediaPlayerImpl::OnVideoNaturalSizeChange(const gfx::Size& size) { | 1397 void WebMediaPlayerImpl::OnVideoNaturalSizeChange(const gfx::Size& size) { |
1398 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1398 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
1399 DCHECK_NE(ready_state_, WebMediaPlayer::kReadyStateHaveNothing); | 1399 DCHECK_NE(ready_state_, WebMediaPlayer::kReadyStateHaveNothing); |
1400 | 1400 |
1401 TRACE_EVENT0("media", "WebMediaPlayerImpl::OnNaturalSizeChanged"); | |
1402 | |
1401 // The input |size| is from the decoded video frame, which is the original | 1403 // The input |size| is from the decoded video frame, which is the original |
1402 // natural size and need to be rotated accordingly. | 1404 // natural size and need to be rotated accordingly. |
1403 gfx::Size rotated_size = | 1405 gfx::Size rotated_size = |
1404 GetRotatedVideoSize(pipeline_metadata_.video_rotation, size); | 1406 GetRotatedVideoSize(pipeline_metadata_.video_rotation, size); |
1405 | 1407 |
1406 if (rotated_size == pipeline_metadata_.natural_size) | 1408 RecordVideoNaturalSize(rotated_size); |
1409 | |
1410 gfx::Size old_size = pipeline_metadata_.natural_size; | |
1411 if (rotated_size == old_size) | |
1407 return; | 1412 return; |
1408 | 1413 |
1409 TRACE_EVENT0("media", "WebMediaPlayerImpl::OnNaturalSizeChanged"); | 1414 pipeline_metadata_.natural_size = rotated_size; |
1410 media_log_->AddEvent(media_log_->CreateVideoSizeSetEvent( | 1415 |
1411 rotated_size.width(), rotated_size.height())); | 1416 // WatchTimeReporter doesn't report metrics for empty videos. Re-create |
DaleCurtis
2017/04/17 19:05:58
Needs rebase.
| |
1417 // |watch_time_reporter_| if we didn't originally know the video size. | |
1418 if (old_size.IsEmpty()) | |
1419 CreateWatchTimeReporter(); | |
1412 | 1420 |
1413 if (overlay_enabled_ && surface_manager_) | 1421 if (overlay_enabled_ && surface_manager_) |
1414 surface_manager_->NaturalSizeChanged(rotated_size); | 1422 surface_manager_->NaturalSizeChanged(rotated_size); |
1415 | 1423 |
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(); | 1424 client_->SizeChanged(); |
1424 | 1425 |
1425 if (observer_) | 1426 if (observer_) |
1426 observer_->OnMetadataChanged(pipeline_metadata_); | 1427 observer_->OnMetadataChanged(pipeline_metadata_); |
1427 } | 1428 } |
1428 | 1429 |
1429 void WebMediaPlayerImpl::OnVideoOpacityChange(bool opaque) { | 1430 void WebMediaPlayerImpl::OnVideoOpacityChange(bool opaque) { |
1430 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1431 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
1431 DCHECK_NE(ready_state_, WebMediaPlayer::kReadyStateHaveNothing); | 1432 DCHECK_NE(ready_state_, WebMediaPlayer::kReadyStateHaveNothing); |
1432 | 1433 |
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2341 } | 2342 } |
2342 | 2343 |
2343 void WebMediaPlayerImpl::RecordUnderflowDuration(base::TimeDelta duration) { | 2344 void WebMediaPlayerImpl::RecordUnderflowDuration(base::TimeDelta duration) { |
2344 DCHECK(data_source_ || chunk_demuxer_); | 2345 DCHECK(data_source_ || chunk_demuxer_); |
2345 if (data_source_) | 2346 if (data_source_) |
2346 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration", duration); | 2347 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration", duration); |
2347 else | 2348 else |
2348 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration.MSE", duration); | 2349 UMA_HISTOGRAM_TIMES("Media.UnderflowDuration.MSE", duration); |
2349 } | 2350 } |
2350 | 2351 |
2352 #define UMA_HISTOGRAM_VIDEO_HEIGHT(name, sample) \ | |
2353 UMA_HISTOGRAM_CUSTOM_COUNTS(name, sample, 64, 10000, 120) | |
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 int height = natural_size.height(); | |
2361 | |
2362 if (load_type_ == kLoadTypeURL) | |
2363 UMA_HISTOGRAM_VIDEO_HEIGHT("Media.VideoHeight.Average.SRC", height); | |
2364 else if (load_type_ == kLoadTypeMediaSource) | |
2365 UMA_HISTOGRAM_VIDEO_HEIGHT("Media.VideoHeight.Average.MSE", height); | |
2366 | |
2367 if (is_encrypted_) | |
2368 UMA_HISTOGRAM_VIDEO_HEIGHT("Media.VideoHeight.Average.EME", height); | |
2369 | |
2370 UMA_HISTOGRAM_VIDEO_HEIGHT("Media.VideoHeight.Average.All", height); | |
2371 | |
2372 if (initial_video_height_recorded_) | |
2373 return; | |
2374 | |
2375 initial_video_height_recorded_ = true; | |
2376 | |
2377 if (load_type_ == kLoadTypeURL) | |
2378 UMA_HISTOGRAM_VIDEO_HEIGHT("Media.VideoHeight.Initial.SRC", height); | |
2379 else if (load_type_ == kLoadTypeMediaSource) | |
2380 UMA_HISTOGRAM_VIDEO_HEIGHT("Media.VideoHeight.Initial.MSE", height); | |
2381 | |
2382 if (is_encrypted_) | |
2383 UMA_HISTOGRAM_VIDEO_HEIGHT("Media.VideoHeight.Initial.EME", height); | |
2384 | |
2385 UMA_HISTOGRAM_VIDEO_HEIGHT("Media.VideoHeight.Initial.All", height); | |
2386 } | |
2387 | |
2388 #undef UMA_HISTOGRAM_VIDEO_HEIGHT | |
2389 | |
2351 } // namespace media | 2390 } // namespace media |
OLD | NEW |