| 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 scoped_ptr<PowerSaveBlocker> power_save_blocker_; |
| 179 |
| 177 DISALLOW_COPY_AND_ASSIGN(DesktopVideoCaptureMachine); | 180 DISALLOW_COPY_AND_ASSIGN(DesktopVideoCaptureMachine); |
| 178 }; | 181 }; |
| 179 | 182 |
| 180 DesktopVideoCaptureMachine::DesktopVideoCaptureMachine( | 183 DesktopVideoCaptureMachine::DesktopVideoCaptureMachine( |
| 181 const DesktopMediaID& source) | 184 const DesktopMediaID& source) |
| 182 : desktop_window_(NULL), | 185 : desktop_window_(NULL), |
| 183 timer_(true, true), | 186 timer_(true, true), |
| 184 window_id_(source) {} | 187 window_id_(source) {} |
| 185 | 188 |
| 186 DesktopVideoCaptureMachine::~DesktopVideoCaptureMachine() {} | 189 DesktopVideoCaptureMachine::~DesktopVideoCaptureMachine() {} |
| (...skipping 19 matching lines...) Expand all Loading... |
| 206 // Update capture size. | 209 // Update capture size. |
| 207 UpdateCaptureSize(); | 210 UpdateCaptureSize(); |
| 208 | 211 |
| 209 // Start observing window events. | 212 // Start observing window events. |
| 210 desktop_window_->AddObserver(this); | 213 desktop_window_->AddObserver(this); |
| 211 | 214 |
| 212 // Start observing compositor updates. | 215 // Start observing compositor updates. |
| 213 if (desktop_window_->GetHost()) | 216 if (desktop_window_->GetHost()) |
| 214 desktop_window_->GetHost()->compositor()->AddObserver(this); | 217 desktop_window_->GetHost()->compositor()->AddObserver(this); |
| 215 | 218 |
| 219 power_save_blocker_.reset(PowerSaveBlocker::Create( |
| 220 PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, |
| 221 "DesktopCatureDevice is running").release()); |
| 222 |
| 216 // Starts timer. | 223 // Starts timer. |
| 217 timer_.Start(FROM_HERE, oracle_proxy_->min_capture_period(), | 224 timer_.Start(FROM_HERE, oracle_proxy_->min_capture_period(), |
| 218 base::Bind(&DesktopVideoCaptureMachine::Capture, AsWeakPtr(), | 225 base::Bind(&DesktopVideoCaptureMachine::Capture, AsWeakPtr(), |
| 219 false)); | 226 false)); |
| 220 | 227 |
| 221 started_ = true; | 228 started_ = true; |
| 222 return true; | 229 return true; |
| 223 } | 230 } |
| 224 | 231 |
| 225 void DesktopVideoCaptureMachine::Stop(const base::Closure& callback) { | 232 void DesktopVideoCaptureMachine::Stop(const base::Closure& callback) { |
| 226 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 233 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 234 power_save_blocker_.reset(); |
| 227 | 235 |
| 228 // Stop observing compositor and window events. | 236 // Stop observing compositor and window events. |
| 229 if (desktop_window_) { | 237 if (desktop_window_) { |
| 230 if (desktop_window_->GetHost()) | 238 if (desktop_window_->GetHost()) |
| 231 desktop_window_->GetHost()->compositor()->RemoveObserver(this); | 239 desktop_window_->GetHost()->compositor()->RemoveObserver(this); |
| 232 desktop_window_->RemoveObserver(this); | 240 desktop_window_->RemoveObserver(this); |
| 233 desktop_window_ = NULL; | 241 desktop_window_ = NULL; |
| 234 } | 242 } |
| 235 | 243 |
| 236 // Stop timer. | 244 // Stop timer. |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 scoped_ptr<Client> client) { | 537 scoped_ptr<Client> client) { |
| 530 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); | 538 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); |
| 531 core_->AllocateAndStart(params, client.Pass()); | 539 core_->AllocateAndStart(params, client.Pass()); |
| 532 } | 540 } |
| 533 | 541 |
| 534 void DesktopCaptureDeviceAura::StopAndDeAllocate() { | 542 void DesktopCaptureDeviceAura::StopAndDeAllocate() { |
| 535 core_->StopAndDeAllocate(); | 543 core_->StopAndDeAllocate(); |
| 536 } | 544 } |
| 537 | 545 |
| 538 } // namespace content | 546 } // namespace content |
| OLD | NEW |