| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 } | 116 } |
| 117 | 117 |
| 118 bool IsNetworkStateError(blink::WebMediaPlayer::NetworkState state) { | 118 bool IsNetworkStateError(blink::WebMediaPlayer::NetworkState state) { |
| 119 bool result = state == blink::WebMediaPlayer::NetworkStateFormatError || | 119 bool result = state == blink::WebMediaPlayer::NetworkStateFormatError || |
| 120 state == blink::WebMediaPlayer::NetworkStateNetworkError || | 120 state == blink::WebMediaPlayer::NetworkStateNetworkError || |
| 121 state == blink::WebMediaPlayer::NetworkStateDecodeError; | 121 state == blink::WebMediaPlayer::NetworkStateDecodeError; |
| 122 DCHECK_EQ(state > blink::WebMediaPlayer::NetworkStateLoaded, result); | 122 DCHECK_EQ(state > blink::WebMediaPlayer::NetworkStateLoaded, result); |
| 123 return result; | 123 return result; |
| 124 } | 124 } |
| 125 | 125 |
| 126 gfx::Size GetRotatedVideoSize(VideoRotation rotation, gfx::Size natural_size) { |
| 127 if (rotation == VIDEO_ROTATION_90 || rotation == VIDEO_ROTATION_270) |
| 128 return gfx::Size(natural_size.height(), natural_size.width()); |
| 129 return natural_size; |
| 130 } |
| 131 |
| 126 } // namespace | 132 } // namespace |
| 127 | 133 |
| 128 class BufferedDataSourceHostImpl; | 134 class BufferedDataSourceHostImpl; |
| 129 | 135 |
| 130 STATIC_ASSERT_ENUM(WebMediaPlayer::CORSModeUnspecified, | 136 STATIC_ASSERT_ENUM(WebMediaPlayer::CORSModeUnspecified, |
| 131 UrlData::CORS_UNSPECIFIED); | 137 UrlData::CORS_UNSPECIFIED); |
| 132 STATIC_ASSERT_ENUM(WebMediaPlayer::CORSModeAnonymous, UrlData::CORS_ANONYMOUS); | 138 STATIC_ASSERT_ENUM(WebMediaPlayer::CORSModeAnonymous, UrlData::CORS_ANONYMOUS); |
| 133 STATIC_ASSERT_ENUM(WebMediaPlayer::CORSModeUseCredentials, | 139 STATIC_ASSERT_ENUM(WebMediaPlayer::CORSModeUseCredentials, |
| 134 UrlData::CORS_USE_CREDENTIALS); | 140 UrlData::CORS_USE_CREDENTIALS); |
| 135 | 141 |
| (...skipping 833 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 969 DVLOG(1) << __FUNCTION__; | 975 DVLOG(1) << __FUNCTION__; |
| 970 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 976 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 971 | 977 |
| 972 pipeline_metadata_ = metadata; | 978 pipeline_metadata_ = metadata; |
| 973 | 979 |
| 974 UMA_HISTOGRAM_ENUMERATION("Media.VideoRotation", metadata.video_rotation, | 980 UMA_HISTOGRAM_ENUMERATION("Media.VideoRotation", metadata.video_rotation, |
| 975 VIDEO_ROTATION_MAX + 1); | 981 VIDEO_ROTATION_MAX + 1); |
| 976 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); | 982 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); |
| 977 | 983 |
| 978 if (hasVideo()) { | 984 if (hasVideo()) { |
| 979 if (pipeline_metadata_.video_rotation == VIDEO_ROTATION_90 || | 985 pipeline_metadata_.natural_size = GetRotatedVideoSize( |
| 980 pipeline_metadata_.video_rotation == VIDEO_ROTATION_270) { | 986 pipeline_metadata_.video_rotation, pipeline_metadata_.natural_size); |
| 981 gfx::Size size = pipeline_metadata_.natural_size; | |
| 982 pipeline_metadata_.natural_size = gfx::Size(size.height(), size.width()); | |
| 983 } | |
| 984 | 987 |
| 985 if (fullscreen_ && surface_manager_) | 988 if (fullscreen_ && surface_manager_) |
| 986 surface_manager_->NaturalSizeChanged(pipeline_metadata_.natural_size); | 989 surface_manager_->NaturalSizeChanged(pipeline_metadata_.natural_size); |
| 987 | 990 |
| 988 DCHECK(!video_weblayer_); | 991 DCHECK(!video_weblayer_); |
| 989 video_weblayer_.reset(new cc_blink::WebLayerImpl(cc::VideoLayer::Create( | 992 video_weblayer_.reset(new cc_blink::WebLayerImpl(cc::VideoLayer::Create( |
| 990 compositor_, pipeline_metadata_.video_rotation))); | 993 compositor_, pipeline_metadata_.video_rotation))); |
| 991 video_weblayer_->layer()->SetContentsOpaque(opaque_); | 994 video_weblayer_->layer()->SetContentsOpaque(opaque_); |
| 992 video_weblayer_->SetContentsOpaqueIsFixed(true); | 995 video_weblayer_->SetContentsOpaqueIsFixed(true); |
| 993 client_->setWebLayer(video_weblayer_.get()); | 996 client_->setWebLayer(video_weblayer_.get()); |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1066 // TODO(jrummell): didResumePlaybackBlockedForKey() should only be called | 1069 // TODO(jrummell): didResumePlaybackBlockedForKey() should only be called |
| 1067 // when a key has been successfully added (e.g. OnSessionKeysChange() with | 1070 // when a key has been successfully added (e.g. OnSessionKeysChange() with |
| 1068 // |has_additional_usable_key| = true). http://crbug.com/461903 | 1071 // |has_additional_usable_key| = true). http://crbug.com/461903 |
| 1069 encrypted_client_->didResumePlaybackBlockedForKey(); | 1072 encrypted_client_->didResumePlaybackBlockedForKey(); |
| 1070 } | 1073 } |
| 1071 | 1074 |
| 1072 void WebMediaPlayerImpl::OnVideoNaturalSizeChange(const gfx::Size& size) { | 1075 void WebMediaPlayerImpl::OnVideoNaturalSizeChange(const gfx::Size& size) { |
| 1073 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1076 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 1074 DCHECK_NE(ready_state_, WebMediaPlayer::ReadyStateHaveNothing); | 1077 DCHECK_NE(ready_state_, WebMediaPlayer::ReadyStateHaveNothing); |
| 1075 | 1078 |
| 1076 if (size == pipeline_metadata_.natural_size) | 1079 gfx::Size rotated_size = |
| 1080 GetRotatedVideoSize(pipeline_metadata_.video_rotation, size); |
| 1081 |
| 1082 if (rotated_size == pipeline_metadata_.natural_size) |
| 1077 return; | 1083 return; |
| 1078 | 1084 |
| 1079 TRACE_EVENT0("media", "WebMediaPlayerImpl::OnNaturalSizeChanged"); | 1085 TRACE_EVENT0("media", "WebMediaPlayerImpl::OnNaturalSizeChanged"); |
| 1080 media_log_->AddEvent( | 1086 media_log_->AddEvent(media_log_->CreateVideoSizeSetEvent( |
| 1081 media_log_->CreateVideoSizeSetEvent(size.width(), size.height())); | 1087 rotated_size.width(), rotated_size.height())); |
| 1082 | 1088 |
| 1083 if (fullscreen_ && surface_manager_) | 1089 if (fullscreen_ && surface_manager_) |
| 1084 surface_manager_->NaturalSizeChanged(size); | 1090 surface_manager_->NaturalSizeChanged(rotated_size); |
| 1085 | 1091 |
| 1086 pipeline_metadata_.natural_size = size; | 1092 pipeline_metadata_.natural_size = rotated_size; |
| 1087 client_->sizeChanged(); | 1093 client_->sizeChanged(); |
| 1088 } | 1094 } |
| 1089 | 1095 |
| 1090 void WebMediaPlayerImpl::OnVideoOpacityChange(bool opaque) { | 1096 void WebMediaPlayerImpl::OnVideoOpacityChange(bool opaque) { |
| 1091 DCHECK(main_task_runner_->BelongsToCurrentThread()); | 1097 DCHECK(main_task_runner_->BelongsToCurrentThread()); |
| 1092 DCHECK_NE(ready_state_, WebMediaPlayer::ReadyStateHaveNothing); | 1098 DCHECK_NE(ready_state_, WebMediaPlayer::ReadyStateHaveNothing); |
| 1093 | 1099 |
| 1094 opaque_ = opaque; | 1100 opaque_ = opaque; |
| 1095 // Modify content opaqueness of cc::Layer directly so that | 1101 // Modify content opaqueness of cc::Layer directly so that |
| 1096 // SetContentsOpaqueIsFixed is ignored. | 1102 // SetContentsOpaqueIsFixed is ignored. |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1660 if (isRemote()) | 1666 if (isRemote()) |
| 1661 return; | 1667 return; |
| 1662 #endif | 1668 #endif |
| 1663 | 1669 |
| 1664 // Idle timeout chosen arbitrarily. | 1670 // Idle timeout chosen arbitrarily. |
| 1665 background_pause_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(5), | 1671 background_pause_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(5), |
| 1666 this, &WebMediaPlayerImpl::OnPause); | 1672 this, &WebMediaPlayerImpl::OnPause); |
| 1667 } | 1673 } |
| 1668 | 1674 |
| 1669 } // namespace media | 1675 } // namespace media |
| OLD | NEW |