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

Unified Diff: media/blink/webmediaplayer_impl.cc

Issue 2205173002: Merge to M53: Account for video rotation in OnVideoNaturalSizeChange() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | media/blink/webmediaplayer_impl_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/blink/webmediaplayer_impl.cc
diff --git a/media/blink/webmediaplayer_impl.cc b/media/blink/webmediaplayer_impl.cc
index 16a43350dd6e9ea8dc7ad41c112182fc85006269..d02166a0fe7a33a24d497eabfa01c0c7ee4ee10e 100644
--- a/media/blink/webmediaplayer_impl.cc
+++ b/media/blink/webmediaplayer_impl.cc
@@ -123,6 +123,12 @@ bool IsNetworkStateError(blink::WebMediaPlayer::NetworkState state) {
return result;
}
+gfx::Size GetRotatedVideoSize(VideoRotation rotation, gfx::Size natural_size) {
+ if (rotation == VIDEO_ROTATION_90 || rotation == VIDEO_ROTATION_270)
+ return gfx::Size(natural_size.height(), natural_size.width());
+ return natural_size;
+}
+
} // namespace
class BufferedDataSourceHostImpl;
@@ -976,11 +982,8 @@ void WebMediaPlayerImpl::OnMetadata(PipelineMetadata metadata) {
SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata);
if (hasVideo()) {
- if (pipeline_metadata_.video_rotation == VIDEO_ROTATION_90 ||
- pipeline_metadata_.video_rotation == VIDEO_ROTATION_270) {
- gfx::Size size = pipeline_metadata_.natural_size;
- pipeline_metadata_.natural_size = gfx::Size(size.height(), size.width());
- }
+ pipeline_metadata_.natural_size = GetRotatedVideoSize(
+ pipeline_metadata_.video_rotation, pipeline_metadata_.natural_size);
if (fullscreen_ && surface_manager_)
surface_manager_->NaturalSizeChanged(pipeline_metadata_.natural_size);
@@ -1073,17 +1076,20 @@ void WebMediaPlayerImpl::OnVideoNaturalSizeChange(const gfx::Size& size) {
DCHECK(main_task_runner_->BelongsToCurrentThread());
DCHECK_NE(ready_state_, WebMediaPlayer::ReadyStateHaveNothing);
- if (size == pipeline_metadata_.natural_size)
+ gfx::Size rotated_size =
+ GetRotatedVideoSize(pipeline_metadata_.video_rotation, size);
+
+ if (rotated_size == pipeline_metadata_.natural_size)
return;
TRACE_EVENT0("media", "WebMediaPlayerImpl::OnNaturalSizeChanged");
- media_log_->AddEvent(
- media_log_->CreateVideoSizeSetEvent(size.width(), size.height()));
+ media_log_->AddEvent(media_log_->CreateVideoSizeSetEvent(
+ rotated_size.width(), rotated_size.height()));
if (fullscreen_ && surface_manager_)
- surface_manager_->NaturalSizeChanged(size);
+ surface_manager_->NaturalSizeChanged(rotated_size);
- pipeline_metadata_.natural_size = size;
+ pipeline_metadata_.natural_size = rotated_size;
client_->sizeChanged();
}
« 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