| 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/aura_window_capture_machine.h" | 5 #include "content/browser/media/capture/aura_window_capture_machine.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 #include "ui/compositor/compositor.h" | 31 #include "ui/compositor/compositor.h" |
| 32 #include "ui/compositor/dip_util.h" | 32 #include "ui/compositor/dip_util.h" |
| 33 #include "ui/compositor/layer.h" | 33 #include "ui/compositor/layer.h" |
| 34 #include "ui/wm/public/activation_client.h" | 34 #include "ui/wm/public/activation_client.h" |
| 35 | 35 |
| 36 namespace content { | 36 namespace content { |
| 37 | 37 |
| 38 AuraWindowCaptureMachine::AuraWindowCaptureMachine() | 38 AuraWindowCaptureMachine::AuraWindowCaptureMachine() |
| 39 : desktop_window_(NULL), | 39 : desktop_window_(NULL), |
| 40 screen_capture_(false), | 40 screen_capture_(false), |
| 41 frame_capture_active_(true), |
| 41 weak_factory_(this) {} | 42 weak_factory_(this) {} |
| 42 | 43 |
| 43 AuraWindowCaptureMachine::~AuraWindowCaptureMachine() {} | 44 AuraWindowCaptureMachine::~AuraWindowCaptureMachine() {} |
| 44 | 45 |
| 45 void AuraWindowCaptureMachine::Start( | 46 void AuraWindowCaptureMachine::Start( |
| 46 const scoped_refptr<media::ThreadSafeCaptureOracle>& oracle_proxy, | 47 const scoped_refptr<media::ThreadSafeCaptureOracle>& oracle_proxy, |
| 47 const media::VideoCaptureParams& params, | 48 const media::VideoCaptureParams& params, |
| 48 const base::Callback<void(bool)> callback) { | 49 const base::Callback<void(bool)> callback) { |
| 49 // Starts the capture machine asynchronously. | 50 // Starts the capture machine asynchronously. |
| 50 BrowserThread::PostTaskAndReplyWithResult( | 51 BrowserThread::PostTaskAndReplyWithResult( |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 | 88 |
| 88 power_save_blocker_.reset(new device::PowerSaveBlocker( | 89 power_save_blocker_.reset(new device::PowerSaveBlocker( |
| 89 device::PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, | 90 device::PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, |
| 90 device::PowerSaveBlocker::kReasonOther, "DesktopCaptureDevice is running", | 91 device::PowerSaveBlocker::kReasonOther, "DesktopCaptureDevice is running", |
| 91 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI), | 92 BrowserThread::GetTaskRunnerForThread(BrowserThread::UI), |
| 92 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE))); | 93 BrowserThread::GetTaskRunnerForThread(BrowserThread::FILE))); |
| 93 | 94 |
| 94 return true; | 95 return true; |
| 95 } | 96 } |
| 96 | 97 |
| 98 void AuraWindowCaptureMachine::Suspend() { |
| 99 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 100 base::Bind(&AuraWindowCaptureMachine::InternalSuspend, |
| 101 base::Unretained(this))); |
| 102 } |
| 103 |
| 104 void AuraWindowCaptureMachine::InternalSuspend() { |
| 105 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 106 DVLOG(1) << "Suspending frame capture and delivery."; |
| 107 frame_capture_active_ = false; |
| 108 } |
| 109 |
| 110 void AuraWindowCaptureMachine::Resume() { |
| 111 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, |
| 112 base::Bind(&AuraWindowCaptureMachine::InternalResume, |
| 113 base::Unretained(this))); |
| 114 } |
| 115 |
| 116 void AuraWindowCaptureMachine::InternalResume() { |
| 117 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 118 DVLOG(1) << "Resuming frame capture and delivery."; |
| 119 frame_capture_active_ = true; |
| 120 } |
| 121 |
| 97 void AuraWindowCaptureMachine::Stop(const base::Closure& callback) { | 122 void AuraWindowCaptureMachine::Stop(const base::Closure& callback) { |
| 98 // Stops the capture machine asynchronously. | 123 // Stops the capture machine asynchronously. |
| 99 BrowserThread::PostTask( | 124 BrowserThread::PostTask( |
| 100 BrowserThread::UI, FROM_HERE, base::Bind( | 125 BrowserThread::UI, FROM_HERE, base::Bind( |
| 101 &AuraWindowCaptureMachine::InternalStop, | 126 &AuraWindowCaptureMachine::InternalStop, |
| 102 base::Unretained(this), | 127 base::Unretained(this), |
| 103 callback)); | 128 callback)); |
| 104 } | 129 } |
| 105 | 130 |
| 106 void AuraWindowCaptureMachine::InternalStop(const base::Closure& callback) { | 131 void AuraWindowCaptureMachine::InternalStop(const base::Closure& callback) { |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 401 // this is the only reliable way to ensure all screen changes are captured, as | 426 // this is the only reliable way to ensure all screen changes are captured, as |
| 402 // of this writing. | 427 // of this writing. |
| 403 // http://crbug.com/600031 | 428 // http://crbug.com/600031 |
| 404 // | 429 // |
| 405 // TODO(miu): Need a better observer callback interface from the compositor | 430 // TODO(miu): Need a better observer callback interface from the compositor |
| 406 // for this use case. The solution here will always capture frames at the | 431 // for this use case. The solution here will always capture frames at the |
| 407 // maximum framerate, which means CPU/GPU is being wasted on redundant | 432 // maximum framerate, which means CPU/GPU is being wasted on redundant |
| 408 // captures and quality/smoothness of animating content will suffer | 433 // captures and quality/smoothness of animating content will suffer |
| 409 // significantly. | 434 // significantly. |
| 410 // http://crbug.com/492839 | 435 // http://crbug.com/492839 |
| 411 Capture(timestamp); | 436 if (frame_capture_active_) |
| 437 Capture(timestamp); |
| 412 } | 438 } |
| 413 | 439 |
| 414 void AuraWindowCaptureMachine::OnCompositingShuttingDown( | 440 void AuraWindowCaptureMachine::OnCompositingShuttingDown( |
| 415 ui::Compositor* compositor) { | 441 ui::Compositor* compositor) { |
| 416 DCHECK_CURRENTLY_ON(BrowserThread::UI); | 442 DCHECK_CURRENTLY_ON(BrowserThread::UI); |
| 417 compositor->RemoveAnimationObserver(this); | 443 compositor->RemoveAnimationObserver(this); |
| 418 } | 444 } |
| 419 | 445 |
| 420 } // namespace content | 446 } // namespace content |
| OLD | NEW |