 Chromium Code Reviews
 Chromium Code Reviews Issue 1531543002:
  [Chromecast] Adding pause/resume operations to VideoPlaneController.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master
    
  
    Issue 1531543002:
  [Chromecast] Adding pause/resume operations to VideoPlaneController.  (Closed) 
  Base URL: https://chromium.googlesource.com/chromium/src.git@master| OLD | NEW | 
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "chromecast/media/base/video_plane_controller.h" | 5 #include "chromecast/media/base/video_plane_controller.h" | 
| 6 | 6 | 
| 7 #include <vector> | 7 #include <vector> | 
| 8 | 8 | 
| 9 #include "base/bind.h" | 9 #include "base/bind.h" | 
| 10 #include "base/location.h" | 10 #include "base/location.h" | 
| (...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 195 | 195 | 
| 196 VLOG(1) << "New graphics resolution " << resolution.width << "x" | 196 VLOG(1) << "New graphics resolution " << resolution.width << "x" | 
| 197 << resolution.height; | 197 << resolution.height; | 
| 198 | 198 | 
| 199 have_graphics_res_ = true; | 199 have_graphics_res_ = true; | 
| 200 graphics_res_ = resolution; | 200 graphics_res_ = resolution; | 
| 201 | 201 | 
| 202 MaybeRunSetGeometry(); | 202 MaybeRunSetGeometry(); | 
| 203 } | 203 } | 
| 204 | 204 | 
| 205 void VideoPlaneController::Pause() { | |
| 
derekjchow1
2015/12/15 22:40:35
Since this is a public function, you should thread
 
esum
2015/12/17 08:28:12
Done.
 | |
| 206 VLOG(1) << "Pausing controller. No more VideoPlane SetGeometry calls."; | |
| 207 is_paused_ = true; | |
| 208 } | |
| 209 | |
| 210 void VideoPlaneController::Resume() { | |
| 
derekjchow1
2015/12/15 22:40:35
ditto.
 
esum
2015/12/17 08:28:12
Done.
 | |
| 211 VLOG(1) << "Resuming controller. VideoPlane SetGeometry calls are active."; | |
| 212 is_paused_ = false; | |
| 213 } | |
| 214 | |
| 215 void VideoPlaneController::ClearGeometryState() { | |
| 
derekjchow1
2015/12/15 22:40:35
ditto.
 
esum
2015/12/17 08:28:12
Done.
 | |
| 216 have_video_plane_geometry_ = false; | |
| 217 video_plane_display_rect_ = RectF(0, 0, 0, 0); | |
| 218 video_plane_transform_ = VideoPlane::TRANSFORM_NONE; | |
| 219 } | |
| 220 | |
| 205 VideoPlaneController::VideoPlaneController() | 221 VideoPlaneController::VideoPlaneController() | 
| 206 : have_output_res_(false), | 222 : is_paused_(false), | 
| 223 have_output_res_(false), | |
| 207 have_graphics_res_(false), | 224 have_graphics_res_(false), | 
| 208 output_res_(0, 0), | 225 output_res_(0, 0), | 
| 209 graphics_res_(0, 0), | 226 graphics_res_(0, 0), | 
| 210 have_video_plane_geometry_(false), | 227 have_video_plane_geometry_(false), | 
| 211 video_plane_display_rect_(0, 0), | 228 video_plane_display_rect_(0, 0), | 
| 212 video_plane_transform_(VideoPlane::TRANSFORM_NONE), | 229 video_plane_transform_(VideoPlane::TRANSFORM_NONE), | 
| 213 media_task_runner_(MediaMessageLoop::GetTaskRunner()), | 230 media_task_runner_(MediaMessageLoop::GetTaskRunner()), | 
| 214 video_plane_wrapper_( | 231 video_plane_wrapper_( | 
| 215 new RateLimitedSetVideoPlaneGeometry(media_task_runner_)) {} | 232 new RateLimitedSetVideoPlaneGeometry(media_task_runner_)) {} | 
| 216 | 233 | 
| 217 VideoPlaneController::~VideoPlaneController() {} | 234 VideoPlaneController::~VideoPlaneController() {} | 
| 218 | 235 | 
| 219 void VideoPlaneController::MaybeRunSetGeometry() { | 236 void VideoPlaneController::MaybeRunSetGeometry() { | 
| 220 DCHECK(thread_checker_.CalledOnValidThread()); | 237 DCHECK(thread_checker_.CalledOnValidThread()); | 
| 221 if (!HaveDataForSetGeometry()) | 238 if (is_paused_) { | 
| 239 VLOG(2) << "All VideoPlane SetGeometry calls are paused. Ignoring request."; | |
| 222 return; | 240 return; | 
| 241 } | |
| 242 | |
| 243 if (!HaveDataForSetGeometry()) { | |
| 244 VLOG(2) << "Don't have all VideoPlane SetGeometry data. Ignoring request."; | |
| 245 return; | |
| 246 } | |
| 223 | 247 | 
| 224 DCHECK(graphics_res_.width != 0 && graphics_res_.height != 0); | 248 DCHECK(graphics_res_.width != 0 && graphics_res_.height != 0); | 
| 225 | 249 | 
| 226 RectF scaled_rect = video_plane_display_rect_; | 250 RectF scaled_rect = video_plane_display_rect_; | 
| 227 if (graphics_res_.width != output_res_.width || | 251 if (graphics_res_.width != output_res_.width || | 
| 228 graphics_res_.height != output_res_.height) { | 252 graphics_res_.height != output_res_.height) { | 
| 229 float sx = static_cast<float>(output_res_.width) / graphics_res_.width; | 253 float sx = static_cast<float>(output_res_.width) / graphics_res_.width; | 
| 230 float sy = static_cast<float>(output_res_.height) / graphics_res_.height; | 254 float sy = static_cast<float>(output_res_.height) / graphics_res_.height; | 
| 231 scaled_rect.x *= sx; | 255 scaled_rect.x *= sx; | 
| 232 scaled_rect.y *= sy; | 256 scaled_rect.y *= sy; | 
| 233 scaled_rect.width *= sx; | 257 scaled_rect.width *= sx; | 
| 234 scaled_rect.height *= sy; | 258 scaled_rect.height *= sy; | 
| 235 } | 259 } | 
| 236 | 260 | 
| 237 media_task_runner_->PostTask( | 261 media_task_runner_->PostTask( | 
| 238 FROM_HERE, | 262 FROM_HERE, | 
| 239 base::Bind(&RateLimitedSetVideoPlaneGeometry::SetGeometry, | 263 base::Bind(&RateLimitedSetVideoPlaneGeometry::SetGeometry, | 
| 240 video_plane_wrapper_, scaled_rect, video_plane_transform_)); | 264 video_plane_wrapper_, scaled_rect, video_plane_transform_)); | 
| 241 } | 265 } | 
| 242 | 266 | 
| 243 bool VideoPlaneController::HaveDataForSetGeometry() const { | 267 bool VideoPlaneController::HaveDataForSetGeometry() const { | 
| 244 DCHECK(thread_checker_.CalledOnValidThread()); | 268 DCHECK(thread_checker_.CalledOnValidThread()); | 
| 245 return have_output_res_ && have_graphics_res_ && have_video_plane_geometry_; | 269 return have_output_res_ && have_graphics_res_ && have_video_plane_geometry_; | 
| 246 } | 270 } | 
| 247 | 271 | 
| 248 } // namespace media | 272 } // namespace media | 
| 249 } // namespace chromecast | 273 } // namespace chromecast | 
| OLD | NEW |