Commit aea4a57a authored by jiayl's avatar jiayl Committed by Commit bot

Prevent the screen from sleeping when the desktop is being captured.

BUG=405784

Review URL: https://codereview.chromium.org/502103003

Cr-Commit-Position: refs/heads/master@{#291908}
parent c9f0746c
...@@ -15,6 +15,7 @@ ...@@ -15,6 +15,7 @@
#include "content/browser/media/capture/desktop_capture_device_uma_types.h" #include "content/browser/media/capture/desktop_capture_device_uma_types.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/desktop_media_id.h" #include "content/public/browser/desktop_media_id.h"
#include "content/public/browser/power_save_blocker.h"
#include "media/base/video_util.h" #include "media/base/video_util.h"
#include "third_party/libyuv/include/libyuv/scale_argb.h" #include "third_party/libyuv/include/libyuv/scale_argb.h"
#include "third_party/webrtc/modules/desktop_capture/desktop_and_cursor_composer.h" #include "third_party/webrtc/modules/desktop_capture/desktop_and_cursor_composer.h"
...@@ -124,6 +125,10 @@ class DesktopCaptureDevice::Core : public webrtc::DesktopCapturer::Callback { ...@@ -124,6 +125,10 @@ class DesktopCaptureDevice::Core : public webrtc::DesktopCapturer::Callback {
scoped_ptr<webrtc::BasicDesktopFrame> black_frame_; scoped_ptr<webrtc::BasicDesktopFrame> black_frame_;
// TODO(jiayl): Remove power_save_blocker_ when there is an API to keep the
// screen from sleeping for the drive-by web.
scoped_ptr<PowerSaveBlocker> power_save_blocker_;
DISALLOW_COPY_AND_ASSIGN(Core); DISALLOW_COPY_AND_ASSIGN(Core);
}; };
...@@ -164,6 +169,10 @@ void DesktopCaptureDevice::Core::AllocateAndStart( ...@@ -164,6 +169,10 @@ void DesktopCaptureDevice::Core::AllocateAndStart(
// This capturer always outputs ARGB, non-interlaced. // This capturer always outputs ARGB, non-interlaced.
capture_format_.pixel_format = media::PIXEL_FORMAT_ARGB; capture_format_.pixel_format = media::PIXEL_FORMAT_ARGB;
power_save_blocker_.reset(PowerSaveBlocker::Create(
PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep,
"DesktopCaptureDevice is running").release());
desktop_capturer_->Start(this); desktop_capturer_->Start(this);
CaptureFrameAndScheduleNext(); CaptureFrameAndScheduleNext();
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "content/browser/media/capture/desktop_capture_device_uma_types.h" #include "content/browser/media/capture/desktop_capture_device_uma_types.h"
#include "content/common/gpu/client/gl_helper.h" #include "content/common/gpu/client/gl_helper.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "content/public/browser/power_save_blocker.h"
#include "media/base/video_util.h" #include "media/base/video_util.h"
#include "media/video/capture/video_capture_types.h" #include "media/video/capture/video_capture_types.h"
#include "skia/ext/image_operations.h" #include "skia/ext/image_operations.h"
...@@ -174,6 +175,10 @@ class DesktopVideoCaptureMachine ...@@ -174,6 +175,10 @@ class DesktopVideoCaptureMachine
gfx::Point cursor_hot_point_; gfx::Point cursor_hot_point_;
SkBitmap scaled_cursor_bitmap_; SkBitmap scaled_cursor_bitmap_;
// TODO(jiayl): Remove power_save_blocker_ when there is an API to keep the
// screen from sleeping for the drive-by web.
scoped_ptr<PowerSaveBlocker> power_save_blocker_;
DISALLOW_COPY_AND_ASSIGN(DesktopVideoCaptureMachine); DISALLOW_COPY_AND_ASSIGN(DesktopVideoCaptureMachine);
}; };
...@@ -213,6 +218,10 @@ bool DesktopVideoCaptureMachine::Start( ...@@ -213,6 +218,10 @@ bool DesktopVideoCaptureMachine::Start(
if (desktop_window_->GetHost()) if (desktop_window_->GetHost())
desktop_window_->GetHost()->compositor()->AddObserver(this); desktop_window_->GetHost()->compositor()->AddObserver(this);
power_save_blocker_.reset(PowerSaveBlocker::Create(
PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep,
"DesktopCaptureDevice is running").release());
// Starts timer. // Starts timer.
timer_.Start(FROM_HERE, oracle_proxy_->min_capture_period(), timer_.Start(FROM_HERE, oracle_proxy_->min_capture_period(),
base::Bind(&DesktopVideoCaptureMachine::Capture, AsWeakPtr(), base::Bind(&DesktopVideoCaptureMachine::Capture, AsWeakPtr(),
...@@ -224,6 +233,7 @@ bool DesktopVideoCaptureMachine::Start( ...@@ -224,6 +233,7 @@ bool DesktopVideoCaptureMachine::Start(
void DesktopVideoCaptureMachine::Stop(const base::Closure& callback) { void DesktopVideoCaptureMachine::Stop(const base::Closure& callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
power_save_blocker_.reset();
// Stop observing compositor and window events. // Stop observing compositor and window events.
if (desktop_window_) { if (desktop_window_) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment