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

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

Issue 2198403002: Account for video rotation in OnVideoNaturalSizeChange() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Account for video rotation in OnVideoNaturalSizeChange() Created 4 years, 4 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 | « no previous file | media/blink/webmediaplayer_impl_unittest.cc » ('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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 879 matching lines...) Expand 10 before | Expand all | Expand 10 after
1015 DVLOG(1) << __func__; 1021 DVLOG(1) << __func__;
1016 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1022 DCHECK(main_task_runner_->BelongsToCurrentThread());
1017 1023
1018 pipeline_metadata_ = metadata; 1024 pipeline_metadata_ = metadata;
1019 1025
1020 UMA_HISTOGRAM_ENUMERATION("Media.VideoRotation", metadata.video_rotation, 1026 UMA_HISTOGRAM_ENUMERATION("Media.VideoRotation", metadata.video_rotation,
1021 VIDEO_ROTATION_MAX + 1); 1027 VIDEO_ROTATION_MAX + 1);
1022 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); 1028 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata);
1023 1029
1024 if (hasVideo()) { 1030 if (hasVideo()) {
1025 if (pipeline_metadata_.video_rotation == VIDEO_ROTATION_90 || 1031 pipeline_metadata_.natural_size = GetRotatedVideoSize(
1026 pipeline_metadata_.video_rotation == VIDEO_ROTATION_270) { 1032 pipeline_metadata_.video_rotation, pipeline_metadata_.natural_size);
1027 gfx::Size size = pipeline_metadata_.natural_size;
1028 pipeline_metadata_.natural_size = gfx::Size(size.height(), size.width());
1029 }
1030 1033
1031 if (overlay_enabled_ && surface_manager_) 1034 if (overlay_enabled_ && surface_manager_)
1032 surface_manager_->NaturalSizeChanged(pipeline_metadata_.natural_size); 1035 surface_manager_->NaturalSizeChanged(pipeline_metadata_.natural_size);
1033 1036
1034 DCHECK(!video_weblayer_); 1037 DCHECK(!video_weblayer_);
1035 video_weblayer_.reset(new cc_blink::WebLayerImpl(cc::VideoLayer::Create( 1038 video_weblayer_.reset(new cc_blink::WebLayerImpl(cc::VideoLayer::Create(
1036 compositor_, pipeline_metadata_.video_rotation))); 1039 compositor_, pipeline_metadata_.video_rotation)));
1037 video_weblayer_->layer()->SetContentsOpaque(opaque_); 1040 video_weblayer_->layer()->SetContentsOpaque(opaque_);
1038 video_weblayer_->SetContentsOpaqueIsFixed(true); 1041 video_weblayer_->SetContentsOpaqueIsFixed(true);
1039 client_->setWebLayer(video_weblayer_.get()); 1042 client_->setWebLayer(video_weblayer_.get());
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 // TODO(jrummell): didResumePlaybackBlockedForKey() should only be called 1123 // TODO(jrummell): didResumePlaybackBlockedForKey() should only be called
1121 // when a key has been successfully added (e.g. OnSessionKeysChange() with 1124 // when a key has been successfully added (e.g. OnSessionKeysChange() with
1122 // |has_additional_usable_key| = true). http://crbug.com/461903 1125 // |has_additional_usable_key| = true). http://crbug.com/461903
1123 encrypted_client_->didResumePlaybackBlockedForKey(); 1126 encrypted_client_->didResumePlaybackBlockedForKey();
1124 } 1127 }
1125 1128
1126 void WebMediaPlayerImpl::OnVideoNaturalSizeChange(const gfx::Size& size) { 1129 void WebMediaPlayerImpl::OnVideoNaturalSizeChange(const gfx::Size& size) {
1127 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1130 DCHECK(main_task_runner_->BelongsToCurrentThread());
1128 DCHECK_NE(ready_state_, WebMediaPlayer::ReadyStateHaveNothing); 1131 DCHECK_NE(ready_state_, WebMediaPlayer::ReadyStateHaveNothing);
1129 1132
1130 if (size == pipeline_metadata_.natural_size) 1133 gfx::Size rotated_size =
1134 GetRotatedVideoSize(pipeline_metadata_.video_rotation, size);
1135
1136 if (rotated_size == pipeline_metadata_.natural_size)
1131 return; 1137 return;
1132 1138
1133 TRACE_EVENT0("media", "WebMediaPlayerImpl::OnNaturalSizeChanged"); 1139 TRACE_EVENT0("media", "WebMediaPlayerImpl::OnNaturalSizeChanged");
1134 media_log_->AddEvent( 1140 media_log_->AddEvent(media_log_->CreateVideoSizeSetEvent(
1135 media_log_->CreateVideoSizeSetEvent(size.width(), size.height())); 1141 rotated_size.width(), rotated_size.height()));
1136 1142
1137 if (overlay_enabled_ && surface_manager_) 1143 if (overlay_enabled_ && surface_manager_)
1138 surface_manager_->NaturalSizeChanged(size); 1144 surface_manager_->NaturalSizeChanged(rotated_size);
1139 1145
1140 pipeline_metadata_.natural_size = size; 1146 pipeline_metadata_.natural_size = rotated_size;
1141 client_->sizeChanged(); 1147 client_->sizeChanged();
1142 } 1148 }
1143 1149
1144 void WebMediaPlayerImpl::OnVideoOpacityChange(bool opaque) { 1150 void WebMediaPlayerImpl::OnVideoOpacityChange(bool opaque) {
1145 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1151 DCHECK(main_task_runner_->BelongsToCurrentThread());
1146 DCHECK_NE(ready_state_, WebMediaPlayer::ReadyStateHaveNothing); 1152 DCHECK_NE(ready_state_, WebMediaPlayer::ReadyStateHaveNothing);
1147 1153
1148 opaque_ = opaque; 1154 opaque_ = opaque;
1149 // Modify content opaqueness of cc::Layer directly so that 1155 // Modify content opaqueness of cc::Layer directly so that
1150 // SetContentsOpaqueIsFixed is ignored. 1156 // SetContentsOpaqueIsFixed is ignored.
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
1720 if (isRemote()) 1726 if (isRemote())
1721 return; 1727 return;
1722 #endif 1728 #endif
1723 1729
1724 // Idle timeout chosen arbitrarily. 1730 // Idle timeout chosen arbitrarily.
1725 background_pause_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(5), 1731 background_pause_timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(5),
1726 this, &WebMediaPlayerImpl::OnPause); 1732 this, &WebMediaPlayerImpl::OnPause);
1727 } 1733 }
1728 1734
1729 } // namespace media 1735 } // namespace media
OLDNEW
« no previous file with comments | « no previous file | media/blink/webmediaplayer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698