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

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

Issue 502103003: Prevent the screen from sleeping when the desktop is being captured. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add TODO Created 6 years, 4 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 | content/browser/media/capture/desktop_capture_device_aura.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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "content/browser/media/capture/desktop_capture_device.h" 5 #include "content/browser/media/capture/desktop_capture_device.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "base/strings/string_number_conversions.h" 11 #include "base/strings/string_number_conversions.h"
12 #include "base/synchronization/lock.h" 12 #include "base/synchronization/lock.h"
13 #include "base/threading/thread.h" 13 #include "base/threading/thread.h"
14 #include "base/timer/timer.h" 14 #include "base/timer/timer.h"
15 #include "content/browser/media/capture/desktop_capture_device_uma_types.h" 15 #include "content/browser/media/capture/desktop_capture_device_uma_types.h"
16 #include "content/public/browser/browser_thread.h" 16 #include "content/public/browser/browser_thread.h"
17 #include "content/public/browser/desktop_media_id.h" 17 #include "content/public/browser/desktop_media_id.h"
18 #include "content/public/browser/power_save_blocker.h"
18 #include "media/base/video_util.h" 19 #include "media/base/video_util.h"
19 #include "third_party/libyuv/include/libyuv/scale_argb.h" 20 #include "third_party/libyuv/include/libyuv/scale_argb.h"
20 #include "third_party/webrtc/modules/desktop_capture/desktop_and_cursor_composer .h" 21 #include "third_party/webrtc/modules/desktop_capture/desktop_and_cursor_composer .h"
21 #include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h" 22 #include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h"
22 #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h" 23 #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h"
23 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" 24 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h"
24 #include "third_party/webrtc/modules/desktop_capture/mouse_cursor_monitor.h" 25 #include "third_party/webrtc/modules/desktop_capture/mouse_cursor_monitor.h"
25 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" 26 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h"
26 #include "third_party/webrtc/modules/desktop_capture/window_capturer.h" 27 #include "third_party/webrtc/modules/desktop_capture/window_capturer.h"
27 28
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 118
118 // True if the first capture call has returned. Used to log the first capture 119 // True if the first capture call has returned. Used to log the first capture
119 // result. 120 // result.
120 bool first_capture_returned_; 121 bool first_capture_returned_;
121 122
122 // The type of the capturer. 123 // The type of the capturer.
123 DesktopMediaID::Type capturer_type_; 124 DesktopMediaID::Type capturer_type_;
124 125
125 scoped_ptr<webrtc::BasicDesktopFrame> black_frame_; 126 scoped_ptr<webrtc::BasicDesktopFrame> black_frame_;
126 127
128 // TODO(jiayl): Remove power_save_blocker_ when there is an API to keep the
129 // screen from sleeping for the drive-by web.
130 scoped_ptr<PowerSaveBlocker> power_save_blocker_;
131
127 DISALLOW_COPY_AND_ASSIGN(Core); 132 DISALLOW_COPY_AND_ASSIGN(Core);
128 }; 133 };
129 134
130 DesktopCaptureDevice::Core::Core( 135 DesktopCaptureDevice::Core::Core(
131 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 136 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
132 scoped_ptr<webrtc::DesktopCapturer> capturer, 137 scoped_ptr<webrtc::DesktopCapturer> capturer,
133 DesktopMediaID::Type type) 138 DesktopMediaID::Type type)
134 : task_runner_(task_runner), 139 : task_runner_(task_runner),
135 desktop_capturer_(capturer.Pass()), 140 desktop_capturer_(capturer.Pass()),
136 capture_in_progress_(false), 141 capture_in_progress_(false),
(...skipping 20 matching lines...) Expand all
157 DCHECK(!client_.get()); 162 DCHECK(!client_.get());
158 163
159 client_ = client.Pass(); 164 client_ = client.Pass();
160 requested_params_ = params; 165 requested_params_ = params;
161 166
162 capture_format_ = requested_params_.requested_format; 167 capture_format_ = requested_params_.requested_format;
163 168
164 // This capturer always outputs ARGB, non-interlaced. 169 // This capturer always outputs ARGB, non-interlaced.
165 capture_format_.pixel_format = media::PIXEL_FORMAT_ARGB; 170 capture_format_.pixel_format = media::PIXEL_FORMAT_ARGB;
166 171
172 power_save_blocker_.reset(PowerSaveBlocker::Create(
173 PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep,
174 "DesktopCaptureDevice is running").release());
175
167 desktop_capturer_->Start(this); 176 desktop_capturer_->Start(this);
168 177
169 CaptureFrameAndScheduleNext(); 178 CaptureFrameAndScheduleNext();
170 } 179 }
171 180
172 void DesktopCaptureDevice::Core::SetNotificationWindowId( 181 void DesktopCaptureDevice::Core::SetNotificationWindowId(
173 gfx::NativeViewId window_id) { 182 gfx::NativeViewId window_id) {
174 DCHECK(task_runner_->BelongsToCurrentThread()); 183 DCHECK(task_runner_->BelongsToCurrentThread());
175 DCHECK(window_id); 184 DCHECK(window_id);
176 desktop_capturer_->SetExcludedWindow(window_id); 185 desktop_capturer_->SetExcludedWindow(window_id);
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 #else 473 #else
465 base::MessageLoop::Type thread_type = base::MessageLoop::TYPE_DEFAULT; 474 base::MessageLoop::Type thread_type = base::MessageLoop::TYPE_DEFAULT;
466 #endif 475 #endif
467 476
468 thread_.StartWithOptions(base::Thread::Options(thread_type, 0)); 477 thread_.StartWithOptions(base::Thread::Options(thread_type, 0));
469 478
470 core_.reset(new Core(thread_.message_loop_proxy(), capturer.Pass(), type)); 479 core_.reset(new Core(thread_.message_loop_proxy(), capturer.Pass(), type));
471 } 480 }
472 481
473 } // namespace content 482 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | content/browser/media/capture/desktop_capture_device_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698