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

Side by Side Diff: content/browser/media/capture/web_contents_video_capture_device.cc

Issue 1199593005: Automatic resolution throttling for screen capture pipeline. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@resolution_chooser_ITEM13
Patch Set: Move all end_t assignments out of for-loop init. Created 5 years, 5 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 | « no previous file | media/capture/screen_capture_device_core.h » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Implementation notes: This needs to work on a variety of hardware 5 // Implementation notes: This needs to work on a variety of hardware
6 // configurations where the speed of the CPU and GPU greatly affect overall 6 // configurations where the speed of the CPU and GPU greatly affect overall
7 // performance. Spanning several threads, the process of capturing has been 7 // performance. Spanning several threads, the process of capturing has been
8 // split up into four conceptual stages: 8 // split up into four conceptual stages:
9 // 9 //
10 // 1. Reserve Buffer: Before a frame can be captured, a slot in the client's 10 // 1. Reserve Buffer: Before a frame can be captured, a slot in the client's
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 WebContentsCaptureMachine(int render_process_id, 204 WebContentsCaptureMachine(int render_process_id,
205 int main_render_frame_id, 205 int main_render_frame_id,
206 bool enable_auto_throttling); 206 bool enable_auto_throttling);
207 ~WebContentsCaptureMachine() override; 207 ~WebContentsCaptureMachine() override;
208 208
209 // VideoCaptureMachine overrides. 209 // VideoCaptureMachine overrides.
210 void Start(const scoped_refptr<media::ThreadSafeCaptureOracle>& oracle_proxy, 210 void Start(const scoped_refptr<media::ThreadSafeCaptureOracle>& oracle_proxy,
211 const media::VideoCaptureParams& params, 211 const media::VideoCaptureParams& params,
212 const base::Callback<void(bool)> callback) override; 212 const base::Callback<void(bool)> callback) override;
213 void Stop(const base::Closure& callback) override; 213 void Stop(const base::Closure& callback) override;
214 bool IsAutoThrottlingEnabled() const override {
215 return auto_throttling_enabled_;
216 }
214 217
215 // Starts a copy from the backing store or the composited surface. Must be run 218 // Starts a copy from the backing store or the composited surface. Must be run
216 // on the UI BrowserThread. |deliver_frame_cb| will be run when the operation 219 // on the UI BrowserThread. |deliver_frame_cb| will be run when the operation
217 // completes. The copy will occur to |target|. 220 // completes. The copy will occur to |target|.
218 // 221 //
219 // This may be used as a ContentCaptureSubscription::CaptureCallback. 222 // This may be used as a ContentCaptureSubscription::CaptureCallback.
220 void Capture(const base::TimeTicks& start_time, 223 void Capture(const base::TimeTicks& start_time,
221 const scoped_refptr<media::VideoFrame>& target, 224 const scoped_refptr<media::VideoFrame>& target,
222 const RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback& 225 const RenderWidgetHostViewFrameSubscriber::DeliverFrameCallback&
223 deliver_frame_cb); 226 deliver_frame_cb);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 void UpdateCaptureSize(); 259 void UpdateCaptureSize();
257 260
258 // Parameters saved in constructor. 261 // Parameters saved in constructor.
259 const int initial_render_process_id_; 262 const int initial_render_process_id_;
260 const int initial_main_render_frame_id_; 263 const int initial_main_render_frame_id_;
261 264
262 // Tracks events and calls back to RenewFrameSubscription() to maintain 265 // Tracks events and calls back to RenewFrameSubscription() to maintain
263 // capture on the correct RenderWidgetHost. 266 // capture on the correct RenderWidgetHost.
264 const scoped_refptr<WebContentsTracker> tracker_; 267 const scoped_refptr<WebContentsTracker> tracker_;
265 268
269 // Set to false to prevent the capture size from automatically adjusting in
270 // response to end-to-end utilization. This is enabled via the throttling
271 // option in the WebContentsVideoCaptureDevice device ID.
272 const bool auto_throttling_enabled_;
273
266 // A dedicated worker thread on which SkBitmap->VideoFrame conversion will 274 // A dedicated worker thread on which SkBitmap->VideoFrame conversion will
267 // occur. Only used when this activity cannot be done on the GPU. 275 // occur. Only used when this activity cannot be done on the GPU.
268 scoped_ptr<base::Thread> render_thread_; 276 scoped_ptr<base::Thread> render_thread_;
269 277
270 // Makes all the decisions about which frames to copy, and how. 278 // Makes all the decisions about which frames to copy, and how.
271 scoped_refptr<media::ThreadSafeCaptureOracle> oracle_proxy_; 279 scoped_refptr<media::ThreadSafeCaptureOracle> oracle_proxy_;
272 280
273 // Video capture parameters that this machine is started with. 281 // Video capture parameters that this machine is started with.
274 media::VideoCaptureParams capture_params_; 282 media::VideoCaptureParams capture_params_;
275 283
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 } 485 }
478 } 486 }
479 487
480 WebContentsCaptureMachine::WebContentsCaptureMachine( 488 WebContentsCaptureMachine::WebContentsCaptureMachine(
481 int render_process_id, 489 int render_process_id,
482 int main_render_frame_id, 490 int main_render_frame_id,
483 bool enable_auto_throttling) 491 bool enable_auto_throttling)
484 : initial_render_process_id_(render_process_id), 492 : initial_render_process_id_(render_process_id),
485 initial_main_render_frame_id_(main_render_frame_id), 493 initial_main_render_frame_id_(main_render_frame_id),
486 tracker_(new WebContentsTracker(true)), 494 tracker_(new WebContentsTracker(true)),
495 auto_throttling_enabled_(enable_auto_throttling),
487 weak_ptr_factory_(this) { 496 weak_ptr_factory_(this) {
488 // TODO(miu): Use |enable_auto_throttling| to enable/disable the automatic
489 // video resolution changes based on resource utilization.
490 // http://crbug.com/156767.
491 DVLOG(1) << "Created WebContentsCaptureMachine for " 497 DVLOG(1) << "Created WebContentsCaptureMachine for "
492 << render_process_id << ':' << main_render_frame_id 498 << render_process_id << ':' << main_render_frame_id
493 << (enable_auto_throttling ? " with auto-throttling enabled" : ""); 499 << (auto_throttling_enabled_ ? " with auto-throttling enabled" : "");
494 } 500 }
495 501
496 WebContentsCaptureMachine::~WebContentsCaptureMachine() {} 502 WebContentsCaptureMachine::~WebContentsCaptureMachine() {}
497 503
498 bool WebContentsCaptureMachine::IsStarted() const { 504 bool WebContentsCaptureMachine::IsStarted() const {
499 DCHECK_CURRENTLY_ON(BrowserThread::UI); 505 DCHECK_CURRENTLY_ON(BrowserThread::UI);
500 return weak_ptr_factory_.HasWeakPtrs(); 506 return weak_ptr_factory_.HasWeakPtrs();
501 } 507 }
502 508
503 void WebContentsCaptureMachine::Start( 509 void WebContentsCaptureMachine::Start(
(...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after
793 scoped_ptr<Client> client) { 799 scoped_ptr<Client> client) {
794 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); 800 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString();
795 core_->AllocateAndStart(params, client.Pass()); 801 core_->AllocateAndStart(params, client.Pass());
796 } 802 }
797 803
798 void WebContentsVideoCaptureDevice::StopAndDeAllocate() { 804 void WebContentsVideoCaptureDevice::StopAndDeAllocate() {
799 core_->StopAndDeAllocate(); 805 core_->StopAndDeAllocate();
800 } 806 }
801 807
802 } // namespace content 808 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | media/capture/screen_capture_device_core.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698