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

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

Issue 2625513002: [M56] Turn off video overlay on android for rotated video. (Closed)
Patch Set: 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/blink/webmediaplayer_impl.h ('k') | no next file » | 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 323 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 surface_created_cb_.Cancel(); 334 surface_created_cb_.Cancel();
335 overlay_surface_id_ = SurfaceManager::kNoSurfaceID; 335 overlay_surface_id_ = SurfaceManager::kNoSurfaceID;
336 336
337 if (decoder_requires_restart_for_overlay_) 337 if (decoder_requires_restart_for_overlay_)
338 ScheduleRestart(); 338 ScheduleRestart();
339 else if (!set_surface_cb_.is_null()) 339 else if (!set_surface_cb_.is_null())
340 set_surface_cb_.Run(overlay_surface_id_); 340 set_surface_cb_.Run(overlay_surface_id_);
341 } 341 }
342 342
343 void WebMediaPlayerImpl::enteredFullscreen() { 343 void WebMediaPlayerImpl::enteredFullscreen() {
344 if (!force_video_overlays_ && !disable_fullscreen_video_overlays_) 344 // |force_video_overlays_| implies that we're already in overlay mode, so take
345 // no action here. Otherwise, switch to an overlay if it's allowed and if
346 // it will display properly.
347 if (!force_video_overlays_ && !disable_fullscreen_video_overlays_ &&
348 DoesOverlaySupportMetadata()) {
345 EnableOverlay(); 349 EnableOverlay();
350 }
346 if (observer_) 351 if (observer_)
347 observer_->OnEnteredFullscreen(); 352 observer_->OnEnteredFullscreen();
348 } 353 }
349 354
350 void WebMediaPlayerImpl::exitedFullscreen() { 355 void WebMediaPlayerImpl::exitedFullscreen() {
351 if (!force_video_overlays_ && !disable_fullscreen_video_overlays_) 356 // If we're in overlay mode, then exit it unless we're supposed to be in
357 // overlay mode all the time.
358 if (!force_video_overlays_ && overlay_enabled_)
352 DisableOverlay(); 359 DisableOverlay();
353 if (observer_) 360 if (observer_)
354 observer_->OnExitedFullscreen(); 361 observer_->OnExitedFullscreen();
355 } 362 }
356 363
357 void WebMediaPlayerImpl::DoLoad(LoadType load_type, 364 void WebMediaPlayerImpl::DoLoad(LoadType load_type,
358 const blink::WebURL& url, 365 const blink::WebURL& url,
359 CORSMode cors_mode) { 366 CORSMode cors_mode) {
360 DVLOG(1) << __func__; 367 DVLOG(1) << __func__;
361 DCHECK(main_task_runner_->BelongsToCurrentThread()); 368 DCHECK(main_task_runner_->BelongsToCurrentThread());
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after
1129 pipeline_metadata_ = metadata; 1136 pipeline_metadata_ = metadata;
1130 1137
1131 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata); 1138 SetReadyState(WebMediaPlayer::ReadyStateHaveMetadata);
1132 UMA_HISTOGRAM_ENUMERATION("Media.VideoRotation", metadata.video_rotation, 1139 UMA_HISTOGRAM_ENUMERATION("Media.VideoRotation", metadata.video_rotation,
1133 VIDEO_ROTATION_MAX + 1); 1140 VIDEO_ROTATION_MAX + 1);
1134 1141
1135 if (hasVideo()) { 1142 if (hasVideo()) {
1136 pipeline_metadata_.natural_size = GetRotatedVideoSize( 1143 pipeline_metadata_.natural_size = GetRotatedVideoSize(
1137 pipeline_metadata_.video_rotation, pipeline_metadata_.natural_size); 1144 pipeline_metadata_.video_rotation, pipeline_metadata_.natural_size);
1138 1145
1139 if (overlay_enabled_ && surface_manager_) 1146 if (overlay_enabled_) {
1140 surface_manager_->NaturalSizeChanged(pipeline_metadata_.natural_size); 1147 // SurfaceView doesn't support rotated video, so transition back if
1148 // the video is now rotated. If |force_video_overlays_|, we keep the
1149 // overlay anyway so that the state machine keeps working.
1150 if (!force_video_overlays_ && !DoesOverlaySupportMetadata())
1151 DisableOverlay();
1152 else if (surface_manager_)
1153 surface_manager_->NaturalSizeChanged(pipeline_metadata_.natural_size);
1154 }
1141 1155
1142 DCHECK(!video_weblayer_); 1156 DCHECK(!video_weblayer_);
1143 video_weblayer_.reset(new cc_blink::WebLayerImpl(cc::VideoLayer::Create( 1157 video_weblayer_.reset(new cc_blink::WebLayerImpl(cc::VideoLayer::Create(
1144 compositor_, pipeline_metadata_.video_rotation))); 1158 compositor_, pipeline_metadata_.video_rotation)));
1145 video_weblayer_->layer()->SetContentsOpaque(opaque_); 1159 video_weblayer_->layer()->SetContentsOpaque(opaque_);
1146 video_weblayer_->SetContentsOpaqueIsFixed(true); 1160 video_weblayer_->SetContentsOpaqueIsFixed(true);
1147 client_->setWebLayer(video_weblayer_.get()); 1161 client_->setWebLayer(video_weblayer_.get());
1148 } 1162 }
1149 1163
1150 if (observer_) 1164 if (observer_)
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after
1947 hasAudio(), hasVideo(), !!chunk_demuxer_, is_encrypted_, media_log_, 1961 hasAudio(), hasVideo(), !!chunk_demuxer_, is_encrypted_, media_log_,
1948 pipeline_metadata_.natural_size, 1962 pipeline_metadata_.natural_size,
1949 base::Bind(&GetCurrentTimeInternal, this))); 1963 base::Bind(&GetCurrentTimeInternal, this)));
1950 watch_time_reporter_->OnVolumeChange(volume_); 1964 watch_time_reporter_->OnVolumeChange(volume_);
1951 if (delegate_ && delegate_->IsHidden()) 1965 if (delegate_ && delegate_->IsHidden())
1952 watch_time_reporter_->OnHidden(); 1966 watch_time_reporter_->OnHidden();
1953 else 1967 else
1954 watch_time_reporter_->OnShown(); 1968 watch_time_reporter_->OnShown();
1955 } 1969 }
1956 1970
1971 bool WebMediaPlayerImpl::DoesOverlaySupportMetadata() const {
1972 return pipeline_metadata_.video_rotation == VIDEO_ROTATION_0;
1973 }
1974
1957 } // namespace media 1975 } // namespace media
OLDNEW
« no previous file with comments | « media/blink/webmediaplayer_impl.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698