| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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_aura.h" | 5 #include "content/browser/media/capture/desktop_capture_device_aura.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/timer/timer.h" | 9 #include "base/timer/timer.h" |
| 10 #include "cc/output/copy_output_request.h" | 10 #include "cc/output/copy_output_request.h" |
| 11 #include "cc/output/copy_output_result.h" | 11 #include "cc/output/copy_output_result.h" |
| 12 #include "content/browser/compositor/image_transport_factory.h" | 12 #include "content/browser/compositor/image_transport_factory.h" |
| 13 #include "content/browser/media/capture/content_video_capture_device_core.h" | 13 #include "content/browser/media/capture/content_video_capture_device_core.h" |
| 14 #include "content/browser/media/capture/desktop_capture_device_uma_types.h" | 14 #include "content/browser/media/capture/desktop_capture_device_uma_types.h" |
| 15 #include "content/common/gpu/client/gl_helper.h" | 15 #include "content/common/gpu/client/gl_helper.h" |
| 16 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
| 17 #include "content/public/browser/power_save_blocker.h" |
| 17 #include "media/base/video_util.h" | 18 #include "media/base/video_util.h" |
| 18 #include "media/video/capture/video_capture_types.h" | 19 #include "media/video/capture/video_capture_types.h" |
| 19 #include "skia/ext/image_operations.h" | 20 #include "skia/ext/image_operations.h" |
| 20 #include "third_party/skia/include/core/SkBitmap.h" | 21 #include "third_party/skia/include/core/SkBitmap.h" |
| 21 #include "ui/aura/client/screen_position_client.h" | 22 #include "ui/aura/client/screen_position_client.h" |
| 22 #include "ui/aura/env.h" | 23 #include "ui/aura/env.h" |
| 23 #include "ui/aura/window.h" | 24 #include "ui/aura/window.h" |
| 24 #include "ui/aura/window_observer.h" | 25 #include "ui/aura/window_observer.h" |
| 25 #include "ui/aura/window_tree_host.h" | 26 #include "ui/aura/window_tree_host.h" |
| 26 #include "ui/base/cursor/cursors_aura.h" | 27 #include "ui/base/cursor/cursors_aura.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 media::VideoCaptureParams capture_params_; | 168 media::VideoCaptureParams capture_params_; |
| 168 | 169 |
| 169 // YUV readback pipeline. | 170 // YUV readback pipeline. |
| 170 scoped_ptr<content::ReadbackYUVInterface> yuv_readback_pipeline_; | 171 scoped_ptr<content::ReadbackYUVInterface> yuv_readback_pipeline_; |
| 171 | 172 |
| 172 // Cursor state. | 173 // Cursor state. |
| 173 ui::Cursor last_cursor_; | 174 ui::Cursor last_cursor_; |
| 174 gfx::Point cursor_hot_point_; | 175 gfx::Point cursor_hot_point_; |
| 175 SkBitmap scaled_cursor_bitmap_; | 176 SkBitmap scaled_cursor_bitmap_; |
| 176 | 177 |
| 178 // TODO(jiayl): Remove power_save_blocker_ when there is an API to keep the |
| 179 // screen from sleeping for the drive-by web. |
| 180 scoped_ptr<PowerSaveBlocker> power_save_blocker_; |
| 181 |
| 177 DISALLOW_COPY_AND_ASSIGN(DesktopVideoCaptureMachine); | 182 DISALLOW_COPY_AND_ASSIGN(DesktopVideoCaptureMachine); |
| 178 }; | 183 }; |
| 179 | 184 |
| 180 DesktopVideoCaptureMachine::DesktopVideoCaptureMachine( | 185 DesktopVideoCaptureMachine::DesktopVideoCaptureMachine( |
| 181 const DesktopMediaID& source) | 186 const DesktopMediaID& source) |
| 182 : desktop_window_(NULL), | 187 : desktop_window_(NULL), |
| 183 timer_(true, true), | 188 timer_(true, true), |
| 184 window_id_(source) {} | 189 window_id_(source) {} |
| 185 | 190 |
| 186 DesktopVideoCaptureMachine::~DesktopVideoCaptureMachine() {} | 191 DesktopVideoCaptureMachine::~DesktopVideoCaptureMachine() {} |
| (...skipping 19 matching lines...) Expand all Loading... |
| 206 // Update capture size. | 211 // Update capture size. |
| 207 UpdateCaptureSize(); | 212 UpdateCaptureSize(); |
| 208 | 213 |
| 209 // Start observing window events. | 214 // Start observing window events. |
| 210 desktop_window_->AddObserver(this); | 215 desktop_window_->AddObserver(this); |
| 211 | 216 |
| 212 // Start observing compositor updates. | 217 // Start observing compositor updates. |
| 213 if (desktop_window_->GetHost()) | 218 if (desktop_window_->GetHost()) |
| 214 desktop_window_->GetHost()->compositor()->AddObserver(this); | 219 desktop_window_->GetHost()->compositor()->AddObserver(this); |
| 215 | 220 |
| 221 power_save_blocker_.reset(PowerSaveBlocker::Create( |
| 222 PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, |
| 223 "DesktopCaptureDevice is running").release()); |
| 224 |
| 216 // Starts timer. | 225 // Starts timer. |
| 217 timer_.Start(FROM_HERE, oracle_proxy_->min_capture_period(), | 226 timer_.Start(FROM_HERE, oracle_proxy_->min_capture_period(), |
| 218 base::Bind(&DesktopVideoCaptureMachine::Capture, AsWeakPtr(), | 227 base::Bind(&DesktopVideoCaptureMachine::Capture, AsWeakPtr(), |
| 219 false)); | 228 false)); |
| 220 | 229 |
| 221 started_ = true; | 230 started_ = true; |
| 222 return true; | 231 return true; |
| 223 } | 232 } |
| 224 | 233 |
| 225 void DesktopVideoCaptureMachine::Stop(const base::Closure& callback) { | 234 void DesktopVideoCaptureMachine::Stop(const base::Closure& callback) { |
| 226 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 235 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 236 power_save_blocker_.reset(); |
| 227 | 237 |
| 228 // Stop observing compositor and window events. | 238 // Stop observing compositor and window events. |
| 229 if (desktop_window_) { | 239 if (desktop_window_) { |
| 230 if (desktop_window_->GetHost()) | 240 if (desktop_window_->GetHost()) |
| 231 desktop_window_->GetHost()->compositor()->RemoveObserver(this); | 241 desktop_window_->GetHost()->compositor()->RemoveObserver(this); |
| 232 desktop_window_->RemoveObserver(this); | 242 desktop_window_->RemoveObserver(this); |
| 233 desktop_window_ = NULL; | 243 desktop_window_ = NULL; |
| 234 } | 244 } |
| 235 | 245 |
| 236 // Stop timer. | 246 // Stop timer. |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 scoped_ptr<Client> client) { | 539 scoped_ptr<Client> client) { |
| 530 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); | 540 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); |
| 531 core_->AllocateAndStart(params, client.Pass()); | 541 core_->AllocateAndStart(params, client.Pass()); |
| 532 } | 542 } |
| 533 | 543 |
| 534 void DesktopCaptureDeviceAura::StopAndDeAllocate() { | 544 void DesktopCaptureDeviceAura::StopAndDeAllocate() { |
| 535 core_->StopAndDeAllocate(); | 545 core_->StopAndDeAllocate(); |
| 536 } | 546 } |
| 537 | 547 |
| 538 } // namespace content | 548 } // namespace content |
| OLD | NEW |