Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
|
hshi1
2013/12/13 01:28:51
This file has already been renamed to desktop_capt
Sergey Ulanov
2013/12/13 02:54:29
Done.
| |
| 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/renderer_host/media/desktop_capture_device_ash.h" | 5 #include "content/browser/renderer_host/media/desktop_capture_device_ash.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/timer/timer.h" | 8 #include "base/timer/timer.h" |
| 9 #include "cc/output/copy_output_request.h" | 9 #include "cc/output/copy_output_request.h" |
| 10 #include "cc/output/copy_output_result.h" | 10 #include "cc/output/copy_output_result.h" |
| 11 #include "content/browser/aura/image_transport_factory.h" | 11 #include "content/browser/aura/image_transport_factory.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 76 // The window associated with the desktop. | 76 // The window associated with the desktop. |
| 77 aura::Window* desktop_window_; | 77 aura::Window* desktop_window_; |
| 78 | 78 |
| 79 // The layer associated with the desktop. | 79 // The layer associated with the desktop. |
| 80 ui::Layer* desktop_layer_; | 80 ui::Layer* desktop_layer_; |
| 81 | 81 |
| 82 // The timer that kicks off period captures. | 82 // The timer that kicks off period captures. |
| 83 base::Timer timer_; | 83 base::Timer timer_; |
| 84 | 84 |
| 85 // The id of the window being captured. | 85 // The id of the window being captured. |
| 86 const DesktopMediaID& window_id_; | 86 DesktopMediaID window_id_; |
| 87 | 87 |
| 88 // Makes all the decisions about which frames to copy, and how. | 88 // Makes all the decisions about which frames to copy, and how. |
| 89 scoped_refptr<ThreadSafeCaptureOracle> oracle_proxy_; | 89 scoped_refptr<ThreadSafeCaptureOracle> oracle_proxy_; |
| 90 | 90 |
| 91 // YUV readback pipeline. | 91 // YUV readback pipeline. |
| 92 scoped_ptr<content::ReadbackYUVInterface> yuv_readback_pipeline_; | 92 scoped_ptr<content::ReadbackYUVInterface> yuv_readback_pipeline_; |
| 93 | 93 |
| 94 DISALLOW_COPY_AND_ASSIGN(DesktopVideoCaptureMachine); | 94 DISALLOW_COPY_AND_ASSIGN(DesktopVideoCaptureMachine); |
| 95 }; | 95 }; |
| 96 | 96 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 138 false)); | 138 false)); |
| 139 | 139 |
| 140 started_ = true; | 140 started_ = true; |
| 141 return true; | 141 return true; |
| 142 } | 142 } |
| 143 | 143 |
| 144 void DesktopVideoCaptureMachine::Stop() { | 144 void DesktopVideoCaptureMachine::Stop() { |
| 145 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 145 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 146 | 146 |
| 147 // Stop observing window events. | 147 // Stop observing window events. |
| 148 if (desktop_window_) | 148 if (desktop_window_) { |
| 149 desktop_window_->RemoveObserver(this); | 149 desktop_window_->RemoveObserver(this); |
| 150 desktop_window_ = NULL; | |
| 151 } | |
| 150 | 152 |
| 151 // Stop observing compositor updates. | 153 // Stop observing compositor updates. |
| 152 if (desktop_layer_) { | 154 if (desktop_layer_) { |
| 153 ui::Compositor* compositor = desktop_layer_->GetCompositor(); | 155 ui::Compositor* compositor = desktop_layer_->GetCompositor(); |
| 154 if (compositor) | 156 if (compositor) |
| 155 compositor->RemoveObserver(this); | 157 compositor->RemoveObserver(this); |
| 158 desktop_layer_ = NULL; | |
| 156 } | 159 } |
| 157 | 160 |
| 158 // Stop timer. | 161 // Stop timer. |
| 159 timer_.Stop(); | 162 timer_.Stop(); |
| 160 | 163 |
| 161 started_ = false; | 164 started_ = false; |
| 162 } | 165 } |
| 163 | 166 |
| 164 void DesktopVideoCaptureMachine::UpdateCaptureSize() { | 167 void DesktopVideoCaptureMachine::UpdateCaptureSize() { |
| 165 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 168 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 268 const gfx::Rect& old_bounds, | 271 const gfx::Rect& old_bounds, |
| 269 const gfx::Rect& new_bounds) { | 272 const gfx::Rect& new_bounds) { |
| 270 DCHECK(desktop_window_ && window == desktop_window_); | 273 DCHECK(desktop_window_ && window == desktop_window_); |
| 271 | 274 |
| 272 // Post task to update capture size on UI thread. | 275 // Post task to update capture size on UI thread. |
| 273 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( | 276 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( |
| 274 &DesktopVideoCaptureMachine::UpdateCaptureSize, AsWeakPtr())); | 277 &DesktopVideoCaptureMachine::UpdateCaptureSize, AsWeakPtr())); |
| 275 } | 278 } |
| 276 | 279 |
| 277 void DesktopVideoCaptureMachine::OnWindowDestroyed(aura::Window* window) { | 280 void DesktopVideoCaptureMachine::OnWindowDestroyed(aura::Window* window) { |
| 278 DCHECK(desktop_window_ && window == desktop_window_); | 281 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 279 desktop_window_ = NULL; | |
| 280 desktop_layer_ = NULL; | |
| 281 | 282 |
| 282 // Post task to stop capture on UI thread. | 283 Stop(); |
| 283 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( | 284 |
| 284 &DesktopVideoCaptureMachine::Stop, AsWeakPtr())); | 285 oracle_proxy_->ReportError(); |
| 285 } | 286 } |
| 286 | 287 |
| 287 void DesktopVideoCaptureMachine::OnCompositingEnded( | 288 void DesktopVideoCaptureMachine::OnCompositingEnded( |
| 288 ui::Compositor* compositor) { | 289 ui::Compositor* compositor) { |
| 289 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( | 290 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( |
| 290 &DesktopVideoCaptureMachine::Capture, AsWeakPtr(), true)); | 291 &DesktopVideoCaptureMachine::Capture, AsWeakPtr(), true)); |
| 291 } | 292 } |
| 292 | 293 |
| 293 } // namespace | 294 } // namespace |
| 294 | 295 |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 312 scoped_ptr<Client> client) { | 313 scoped_ptr<Client> client) { |
| 313 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); | 314 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); |
| 314 impl_->AllocateAndStart(params, client.Pass()); | 315 impl_->AllocateAndStart(params, client.Pass()); |
| 315 } | 316 } |
| 316 | 317 |
| 317 void DesktopCaptureDeviceAsh::StopAndDeAllocate() { | 318 void DesktopCaptureDeviceAsh::StopAndDeAllocate() { |
| 318 impl_->StopAndDeAllocate(); | 319 impl_->StopAndDeAllocate(); |
| 319 } | 320 } |
| 320 | 321 |
| 321 } // namespace content | 322 } // namespace content |
| OLD | NEW |