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

Side by Side Diff: chromecast/media/base/video_plane_controller.cc

Issue 1824723003: [chromecast] Pass media task runner to VideoPlaneController. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: fixed android build Created 4 years, 9 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 | « chromecast/media/base/video_plane_controller.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 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/location.h" 13 #include "base/location.h"
14 #include "base/macros.h" 14 #include "base/macros.h"
15 #include "base/single_thread_task_runner.h" 15 #include "base/single_thread_task_runner.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "chromecast/media/base/media_message_loop.h"
18 #include "chromecast/public/cast_media_shlib.h" 17 #include "chromecast/public/cast_media_shlib.h"
19 18
20 namespace chromecast { 19 namespace chromecast {
21 namespace media { 20 namespace media {
22 21
23 namespace { 22 namespace {
24 23
25 bool RectFEqual(const RectF& r1, const RectF& r2) { 24 bool RectFEqual(const RectF& r1, const RectF& r2) {
26 return r1.x == r2.x && r1.y == r2.y && r1.width == r2.width && 25 return r1.x == r2.x && r1.y == r2.y && r1.width == r2.width &&
27 r1.height == r2.height; 26 r1.height == r2.height;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
133 // Min calling interval is computed as double average of last few time samples 132 // Min calling interval is computed as double average of last few time samples
134 // (i.e. allow at least as much time between calls as the call itself takes). 133 // (i.e. allow at least as much time between calls as the call itself takes).
135 std::vector<int64_t> samples_; 134 std::vector<int64_t> samples_;
136 size_t sample_counter_; 135 size_t sample_counter_;
137 136
138 scoped_refptr<base::SingleThreadTaskRunner> task_runner_; 137 scoped_refptr<base::SingleThreadTaskRunner> task_runner_;
139 138
140 DISALLOW_COPY_AND_ASSIGN(RateLimitedSetVideoPlaneGeometry); 139 DISALLOW_COPY_AND_ASSIGN(RateLimitedSetVideoPlaneGeometry);
141 }; 140 };
142 141
143 // static 142 VideoPlaneController::VideoPlaneController(
144 VideoPlaneController* VideoPlaneController::GetInstance() { 143 scoped_refptr<base::SingleThreadTaskRunner> media_task_runner)
145 return base::Singleton<VideoPlaneController>::get(); 144 : is_paused_(false),
146 } 145 have_output_res_(false),
146 have_graphics_res_(false),
147 output_res_(0, 0),
148 graphics_res_(0, 0),
149 have_video_plane_geometry_(false),
150 video_plane_display_rect_(0, 0),
151 video_plane_transform_(VideoPlane::TRANSFORM_NONE),
152 media_task_runner_(media_task_runner),
153 video_plane_wrapper_(
154 new RateLimitedSetVideoPlaneGeometry(media_task_runner_)) {}
155
156 VideoPlaneController::~VideoPlaneController() {}
147 157
148 // TODO(esum): SetGeometry, SetDeviceResolution, and SetGraphicsPlaneResolution 158 // TODO(esum): SetGeometry, SetDeviceResolution, and SetGraphicsPlaneResolution
149 // follow the same pattern (copy/paste). Currently it's not worth modularizing 159 // follow the same pattern (copy/paste). Currently it's not worth modularizing
150 // since there are only 3 fields. If more fields are needed in the future, 160 // since there are only 3 fields. If more fields are needed in the future,
151 // consider making a generic method to implement this pattern. 161 // consider making a generic method to implement this pattern.
152 void VideoPlaneController::SetGeometry(const RectF& display_rect, 162 void VideoPlaneController::SetGeometry(const RectF& display_rect,
153 VideoPlane::Transform transform) { 163 VideoPlane::Transform transform) {
154 DCHECK(thread_checker_.CalledOnValidThread()); 164 DCHECK(thread_checker_.CalledOnValidThread());
155 DCHECK(DisplayRectFValid(display_rect)); 165 DCHECK(DisplayRectFValid(display_rect));
156 if (have_video_plane_geometry_ && 166 if (have_video_plane_geometry_ &&
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 VLOG(1) << "Resuming controller. VideoPlane SetGeometry calls are active."; 227 VLOG(1) << "Resuming controller. VideoPlane SetGeometry calls are active.";
218 is_paused_ = false; 228 is_paused_ = false;
219 MaybeRunSetGeometry(); 229 MaybeRunSetGeometry();
220 } 230 }
221 231
222 bool VideoPlaneController::is_paused() const { 232 bool VideoPlaneController::is_paused() const {
223 DCHECK(thread_checker_.CalledOnValidThread()); 233 DCHECK(thread_checker_.CalledOnValidThread());
224 return is_paused_; 234 return is_paused_;
225 } 235 }
226 236
227 VideoPlaneController::VideoPlaneController()
228 : is_paused_(false),
229 have_output_res_(false),
230 have_graphics_res_(false),
231 output_res_(0, 0),
232 graphics_res_(0, 0),
233 have_video_plane_geometry_(false),
234 video_plane_display_rect_(0, 0),
235 video_plane_transform_(VideoPlane::TRANSFORM_NONE),
236 media_task_runner_(MediaMessageLoop::GetTaskRunner()),
237 video_plane_wrapper_(
238 new RateLimitedSetVideoPlaneGeometry(media_task_runner_)) {}
239
240 VideoPlaneController::~VideoPlaneController() {}
241
242 void VideoPlaneController::MaybeRunSetGeometry() { 237 void VideoPlaneController::MaybeRunSetGeometry() {
243 DCHECK(thread_checker_.CalledOnValidThread()); 238 DCHECK(thread_checker_.CalledOnValidThread());
244 if (is_paused_) { 239 if (is_paused_) {
245 VLOG(2) << "All VideoPlane SetGeometry calls are paused. Ignoring request."; 240 VLOG(2) << "All VideoPlane SetGeometry calls are paused. Ignoring request.";
246 return; 241 return;
247 } 242 }
248 243
249 if (!HaveDataForSetGeometry()) { 244 if (!HaveDataForSetGeometry()) {
250 VLOG(2) << "Don't have all VideoPlane SetGeometry data. Ignoring request."; 245 VLOG(2) << "Don't have all VideoPlane SetGeometry data. Ignoring request.";
251 return; 246 return;
(...skipping 18 matching lines...) Expand all
270 video_plane_wrapper_, scaled_rect, video_plane_transform_)); 265 video_plane_wrapper_, scaled_rect, video_plane_transform_));
271 } 266 }
272 267
273 bool VideoPlaneController::HaveDataForSetGeometry() const { 268 bool VideoPlaneController::HaveDataForSetGeometry() const {
274 DCHECK(thread_checker_.CalledOnValidThread()); 269 DCHECK(thread_checker_.CalledOnValidThread());
275 return have_output_res_ && have_graphics_res_ && have_video_plane_geometry_; 270 return have_output_res_ && have_graphics_res_ && have_video_plane_geometry_;
276 } 271 }
277 272
278 } // namespace media 273 } // namespace media
279 } // namespace chromecast 274 } // namespace chromecast
OLDNEW
« no previous file with comments | « chromecast/media/base/video_plane_controller.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698