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

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

Issue 2622803002: Clean-up: media::PipelineMetadata stores the rotated video size. (Closed)
Patch Set: Addressed comments. Created 3 years, 11 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 | « media/base/pipeline_metadata.h ('k') | 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 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1160 DVLOG(1) << __func__; 1160 DVLOG(1) << __func__;
1161 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1161 DCHECK(main_task_runner_->BelongsToCurrentThread());
1162 1162
1163 pipeline_metadata_ = metadata; 1163 pipeline_metadata_ = metadata;
1164 1164
1165 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); 1165 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata);
1166 UMA_HISTOGRAM_ENUMERATION("Media.VideoRotation", metadata.video_rotation, 1166 UMA_HISTOGRAM_ENUMERATION("Media.VideoRotation", metadata.video_rotation,
1167 VIDEO_ROTATION_MAX + 1); 1167 VIDEO_ROTATION_MAX + 1);
1168 1168
1169 if (hasVideo()) { 1169 if (hasVideo()) {
1170 pipeline_metadata_.natural_size = GetRotatedVideoSize(
1171 pipeline_metadata_.video_rotation, pipeline_metadata_.natural_size);
1172
1173 if (overlay_enabled_) { 1170 if (overlay_enabled_) {
1174 // SurfaceView doesn't support rotated video, so transition back if 1171 // SurfaceView doesn't support rotated video, so transition back if
1175 // the video is now rotated. If |force_video_overlays_|, we keep the 1172 // the video is now rotated. If |force_video_overlays_|, we keep the
1176 // overlay anyway so that the state machine keeps working. 1173 // overlay anyway so that the state machine keeps working.
1177 if (!force_video_overlays_ && !DoesOverlaySupportMetadata()) 1174 if (!force_video_overlays_ && !DoesOverlaySupportMetadata())
1178 DisableOverlay(); 1175 DisableOverlay();
1179 else if (surface_manager_) 1176 else if (surface_manager_)
1180 surface_manager_->NaturalSizeChanged(pipeline_metadata_.natural_size); 1177 surface_manager_->NaturalSizeChanged(pipeline_metadata_.natural_size);
1181 } 1178 }
1182 1179
1183 DCHECK(!video_weblayer_); 1180 DCHECK(!video_weblayer_);
1184 video_weblayer_.reset(new cc_blink::WebLayerImpl(cc::VideoLayer::Create( 1181 video_weblayer_.reset(new cc_blink::WebLayerImpl(cc::VideoLayer::Create(
1185 compositor_, pipeline_metadata_.video_rotation))); 1182 compositor_, pipeline_metadata_.video_rotation)));
1186 video_weblayer_->layer()->SetContentsOpaque(opaque_); 1183 video_weblayer_->layer()->SetContentsOpaque(opaque_);
1187 video_weblayer_->SetContentsOpaqueIsFixed(true); 1184 video_weblayer_->SetContentsOpaqueIsFixed(true);
1188 client_->setWebLayer(video_weblayer_.get()); 1185 client_->setWebLayer(video_weblayer_.get());
1189 } 1186 }
1190 1187
1191 if (observer_) 1188 if (observer_)
1192 observer_->OnMetadataChanged(metadata); 1189 observer_->OnMetadataChanged(pipeline_metadata_);
1193 1190
1194 CreateWatchTimeReporter(); 1191 CreateWatchTimeReporter();
1195 UpdatePlayState(); 1192 UpdatePlayState();
1196 } 1193 }
1197 1194
1198 void WebMediaPlayerImpl::OnBufferingStateChange(BufferingState state) { 1195 void WebMediaPlayerImpl::OnBufferingStateChange(BufferingState state) {
1199 DVLOG(1) << __func__ << "(" << state << ")"; 1196 DVLOG(1) << __func__ << "(" << state << ")";
1200 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1197 DCHECK(main_task_runner_->BelongsToCurrentThread());
1201 1198
1202 // Ignore buffering state changes until we've completed all outstanding 1199 // Ignore buffering state changes until we've completed all outstanding
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1300 // TODO(jrummell): didResumePlaybackBlockedForKey() should only be called 1297 // TODO(jrummell): didResumePlaybackBlockedForKey() should only be called
1301 // when a key has been successfully added (e.g. OnSessionKeysChange() with 1298 // when a key has been successfully added (e.g. OnSessionKeysChange() with
1302 // |has_additional_usable_key| = true). http://crbug.com/461903 1299 // |has_additional_usable_key| = true). http://crbug.com/461903
1303 encrypted_client_->didResumePlaybackBlockedForKey(); 1300 encrypted_client_->didResumePlaybackBlockedForKey();
1304 } 1301 }
1305 1302
1306 void WebMediaPlayerImpl::OnVideoNaturalSizeChange(const gfx::Size& size) { 1303 void WebMediaPlayerImpl::OnVideoNaturalSizeChange(const gfx::Size& size) {
1307 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1304 DCHECK(main_task_runner_->BelongsToCurrentThread());
1308 DCHECK_NE(ready_state_, WebMediaPlayer::ReadyStateHaveNothing); 1305 DCHECK_NE(ready_state_, WebMediaPlayer::ReadyStateHaveNothing);
1309 1306
1307 // The input |size| is from the decoded video frame, which is the original
1308 // natural size and need to be rotated accordingly.
1310 gfx::Size rotated_size = 1309 gfx::Size rotated_size =
1311 GetRotatedVideoSize(pipeline_metadata_.video_rotation, size); 1310 GetRotatedVideoSize(pipeline_metadata_.video_rotation, size);
1312 1311
1313 if (rotated_size == pipeline_metadata_.natural_size) 1312 if (rotated_size == pipeline_metadata_.natural_size)
1314 return; 1313 return;
1315 1314
1316 TRACE_EVENT0("media", "WebMediaPlayerImpl::OnNaturalSizeChanged"); 1315 TRACE_EVENT0("media", "WebMediaPlayerImpl::OnNaturalSizeChanged");
1317 media_log_->AddEvent(media_log_->CreateVideoSizeSetEvent( 1316 media_log_->AddEvent(media_log_->CreateVideoSizeSetEvent(
1318 rotated_size.width(), rotated_size.height())); 1317 rotated_size.width(), rotated_size.height()));
1319 1318
1320 if (overlay_enabled_ && surface_manager_) 1319 if (overlay_enabled_ && surface_manager_)
1321 surface_manager_->NaturalSizeChanged(rotated_size); 1320 surface_manager_->NaturalSizeChanged(rotated_size);
1322 1321
1323 gfx::Size old_size = pipeline_metadata_.natural_size; 1322 gfx::Size old_size = pipeline_metadata_.natural_size;
1324 pipeline_metadata_.natural_size = rotated_size; 1323 pipeline_metadata_.natural_size = rotated_size;
1325 if (old_size.IsEmpty()) { 1324 if (old_size.IsEmpty()) {
1326 // WatchTimeReporter doesn't report metrics for empty videos. Re-create 1325 // WatchTimeReporter doesn't report metrics for empty videos. Re-create
1327 // |watch_time_reporter_| if we didn't originally know the video size. 1326 // |watch_time_reporter_| if we didn't originally know the video size.
1328 CreateWatchTimeReporter(); 1327 CreateWatchTimeReporter();
1329 } 1328 }
1330 client_->sizeChanged(); 1329 client_->sizeChanged();
1331 1330
1332 if (observer_) { 1331 if (observer_)
1333 PipelineMetadata metadata = pipeline_metadata_; 1332 observer_->OnMetadataChanged(pipeline_metadata_);
1334 metadata.natural_size = size;
1335 observer_->OnMetadataChanged(metadata);
1336 }
1337 } 1333 }
1338 1334
1339 void WebMediaPlayerImpl::OnVideoOpacityChange(bool opaque) { 1335 void WebMediaPlayerImpl::OnVideoOpacityChange(bool opaque) {
1340 DCHECK(main_task_runner_->BelongsToCurrentThread()); 1336 DCHECK(main_task_runner_->BelongsToCurrentThread());
1341 DCHECK_NE(ready_state_, WebMediaPlayer::ReadyStateHaveNothing); 1337 DCHECK_NE(ready_state_, WebMediaPlayer::ReadyStateHaveNothing);
1342 1338
1343 opaque_ = opaque; 1339 opaque_ = opaque;
1344 // Modify content opaqueness of cc::Layer directly so that 1340 // Modify content opaqueness of cc::Layer directly so that
1345 // SetContentsOpaqueIsFixed is ignored. 1341 // SetContentsOpaqueIsFixed is ignored.
1346 if (video_weblayer_) 1342 if (video_weblayer_)
(...skipping 735 matching lines...) Expand 10 before | Expand all | Expand 10 after
2082 bool WebMediaPlayerImpl::ShouldPauseWhenHidden() const { 2078 bool WebMediaPlayerImpl::ShouldPauseWhenHidden() const {
2083 #if defined(OS_ANDROID) // WMPI_CAST 2079 #if defined(OS_ANDROID) // WMPI_CAST
2084 if (isRemote()) 2080 if (isRemote())
2085 return false; 2081 return false;
2086 #endif // defined(OS_ANDROID) // WMPI_CAST 2082 #endif // defined(OS_ANDROID) // WMPI_CAST
2087 2083
2088 return hasVideo() && !hasAudio(); 2084 return hasVideo() && !hasAudio();
2089 } 2085 }
2090 2086
2091 } // namespace media 2087 } // namespace media
OLDNEW
« no previous file with comments | « media/base/pipeline_metadata.h ('k') | media/blink/webmediaplayer_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698