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

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: 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 scoped_ptr<PowerSaveBlocker> power_save_blocker_;
129
127 DISALLOW_COPY_AND_ASSIGN(Core); 130 DISALLOW_COPY_AND_ASSIGN(Core);
128 }; 131 };
129 132
130 DesktopCaptureDevice::Core::Core( 133 DesktopCaptureDevice::Core::Core(
131 scoped_refptr<base::SingleThreadTaskRunner> task_runner, 134 scoped_refptr<base::SingleThreadTaskRunner> task_runner,
132 scoped_ptr<webrtc::DesktopCapturer> capturer, 135 scoped_ptr<webrtc::DesktopCapturer> capturer,
133 DesktopMediaID::Type type) 136 DesktopMediaID::Type type)
134 : task_runner_(task_runner), 137 : task_runner_(task_runner),
135 desktop_capturer_(capturer.Pass()), 138 desktop_capturer_(capturer.Pass()),
136 capture_in_progress_(false), 139 capture_in_progress_(false),
(...skipping 20 matching lines...) Expand all
157 DCHECK(!client_.get()); 160 DCHECK(!client_.get());
158 161
159 client_ = client.Pass(); 162 client_ = client.Pass();
160 requested_params_ = params; 163 requested_params_ = params;
161 164
162 capture_format_ = requested_params_.requested_format; 165 capture_format_ = requested_params_.requested_format;
163 166
164 // This capturer always outputs ARGB, non-interlaced. 167 // This capturer always outputs ARGB, non-interlaced.
165 capture_format_.pixel_format = media::PIXEL_FORMAT_ARGB; 168 capture_format_.pixel_format = media::PIXEL_FORMAT_ARGB;
166 169
170 power_save_blocker_.reset(PowerSaveBlocker::Create(
171 PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep,
172 "DesktopCatureDevice is running").release());
juberti2 2014/08/25 19:16:24 DesktopCatureDevice -> DesktopCaptureDevice (here
jiayl 2014/08/25 19:50:01 Done.
173
167 desktop_capturer_->Start(this); 174 desktop_capturer_->Start(this);
168 175
169 CaptureFrameAndScheduleNext(); 176 CaptureFrameAndScheduleNext();
170 } 177 }
171 178
172 void DesktopCaptureDevice::Core::SetNotificationWindowId( 179 void DesktopCaptureDevice::Core::SetNotificationWindowId(
173 gfx::NativeViewId window_id) { 180 gfx::NativeViewId window_id) {
174 DCHECK(task_runner_->BelongsToCurrentThread()); 181 DCHECK(task_runner_->BelongsToCurrentThread());
175 DCHECK(window_id); 182 DCHECK(window_id);
176 desktop_capturer_->SetExcludedWindow(window_id); 183 desktop_capturer_->SetExcludedWindow(window_id);
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
464 #else 471 #else
465 base::MessageLoop::Type thread_type = base::MessageLoop::TYPE_DEFAULT; 472 base::MessageLoop::Type thread_type = base::MessageLoop::TYPE_DEFAULT;
466 #endif 473 #endif
467 474
468 thread_.StartWithOptions(base::Thread::Options(thread_type, 0)); 475 thread_.StartWithOptions(base::Thread::Options(thread_type, 0));
469 476
470 core_.reset(new Core(thread_.message_loop_proxy(), capturer.Pass(), type)); 477 core_.reset(new Core(thread_.message_loop_proxy(), capturer.Pass(), type));
471 } 478 }
472 479
473 } // namespace content 480 } // 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