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/renderer_host/media/desktop_capture_device_aura.h" | 5 #include "content/browser/renderer_host/media/desktop_capture_device_aura.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" |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 false)); | 210 false)); |
211 | 211 |
212 started_ = true; | 212 started_ = true; |
213 return true; | 213 return true; |
214 } | 214 } |
215 | 215 |
216 void DesktopVideoCaptureMachine::Stop() { | 216 void DesktopVideoCaptureMachine::Stop() { |
217 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 217 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
218 | 218 |
219 // Stop observing window events. | 219 // Stop observing window events. |
220 if (desktop_window_) | 220 if (desktop_window_) { |
221 desktop_window_->RemoveObserver(this); | 221 desktop_window_->RemoveObserver(this); |
| 222 desktop_window_ = NULL; |
| 223 } |
222 | 224 |
223 // Stop observing compositor updates. | 225 // Stop observing compositor updates. |
224 if (desktop_layer_) { | 226 if (desktop_layer_) { |
225 ui::Compositor* compositor = desktop_layer_->GetCompositor(); | 227 ui::Compositor* compositor = desktop_layer_->GetCompositor(); |
226 if (compositor) | 228 if (compositor) |
227 compositor->RemoveObserver(this); | 229 compositor->RemoveObserver(this); |
| 230 desktop_layer_ = NULL; |
228 } | 231 } |
229 | 232 |
230 // Stop timer. | 233 // Stop timer. |
231 timer_.Stop(); | 234 timer_.Stop(); |
232 | 235 |
233 started_ = false; | 236 started_ = false; |
234 } | 237 } |
235 | 238 |
236 void DesktopVideoCaptureMachine::UpdateCaptureSize() { | 239 void DesktopVideoCaptureMachine::UpdateCaptureSize() { |
237 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 240 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 RenderCursorOnVideoFrame(target, cursor_bitmap, cursor_position); | 286 RenderCursorOnVideoFrame(target, cursor_bitmap, cursor_position); |
284 release_callback->Run(0, false); | 287 release_callback->Run(0, false); |
285 capture_frame_cb.Run(start_time, result); | 288 capture_frame_cb.Run(start_time, result); |
286 } | 289 } |
287 | 290 |
288 void DesktopVideoCaptureMachine::DidCopyOutput( | 291 void DesktopVideoCaptureMachine::DidCopyOutput( |
289 scoped_refptr<media::VideoFrame> video_frame, | 292 scoped_refptr<media::VideoFrame> video_frame, |
290 base::Time start_time, | 293 base::Time start_time, |
291 const ThreadSafeCaptureOracle::CaptureFrameCallback& capture_frame_cb, | 294 const ThreadSafeCaptureOracle::CaptureFrameCallback& capture_frame_cb, |
292 scoped_ptr<cc::CopyOutputResult> result) { | 295 scoped_ptr<cc::CopyOutputResult> result) { |
293 if (result->IsEmpty() || result->size().IsEmpty()) | 296 if (result->IsEmpty() || result->size().IsEmpty() || !desktop_layer_) |
294 return; | 297 return; |
295 | 298 |
296 // Compute the dest size we want after the letterboxing resize. Make the | 299 // Compute the dest size we want after the letterboxing resize. Make the |
297 // coordinates and sizes even because we letterbox in YUV space | 300 // coordinates and sizes even because we letterbox in YUV space |
298 // (see CopyRGBToVideoFrame). They need to be even for the UV samples to | 301 // (see CopyRGBToVideoFrame). They need to be even for the UV samples to |
299 // line up correctly. | 302 // line up correctly. |
300 // The video frame's coded_size() and the result's size() are both physical | 303 // The video frame's coded_size() and the result's size() are both physical |
301 // pixels. | 304 // pixels. |
302 gfx::Rect region_in_frame = | 305 gfx::Rect region_in_frame = |
303 media::ComputeLetterboxRegion(gfx::Rect(video_frame->coded_size()), | 306 media::ComputeLetterboxRegion(gfx::Rect(video_frame->coded_size()), |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
389 const gfx::Rect& old_bounds, | 392 const gfx::Rect& old_bounds, |
390 const gfx::Rect& new_bounds) { | 393 const gfx::Rect& new_bounds) { |
391 DCHECK(desktop_window_ && window == desktop_window_); | 394 DCHECK(desktop_window_ && window == desktop_window_); |
392 | 395 |
393 // Post task to update capture size on UI thread. | 396 // Post task to update capture size on UI thread. |
394 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( | 397 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( |
395 &DesktopVideoCaptureMachine::UpdateCaptureSize, AsWeakPtr())); | 398 &DesktopVideoCaptureMachine::UpdateCaptureSize, AsWeakPtr())); |
396 } | 399 } |
397 | 400 |
398 void DesktopVideoCaptureMachine::OnWindowDestroyed(aura::Window* window) { | 401 void DesktopVideoCaptureMachine::OnWindowDestroyed(aura::Window* window) { |
399 DCHECK(desktop_window_ && window == desktop_window_); | 402 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
400 desktop_window_ = NULL; | |
401 desktop_layer_ = NULL; | |
402 | 403 |
403 // Post task to stop capture on UI thread. | 404 Stop(); |
404 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( | 405 |
405 &DesktopVideoCaptureMachine::Stop, AsWeakPtr())); | 406 oracle_proxy_->ReportError(); |
406 } | 407 } |
407 | 408 |
408 void DesktopVideoCaptureMachine::OnCompositingEnded( | 409 void DesktopVideoCaptureMachine::OnCompositingEnded( |
409 ui::Compositor* compositor) { | 410 ui::Compositor* compositor) { |
410 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( | 411 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, base::Bind( |
411 &DesktopVideoCaptureMachine::Capture, AsWeakPtr(), true)); | 412 &DesktopVideoCaptureMachine::Capture, AsWeakPtr(), true)); |
412 } | 413 } |
413 | 414 |
414 } // namespace | 415 } // namespace |
415 | 416 |
(...skipping 17 matching lines...) Expand all Loading... |
433 scoped_ptr<Client> client) { | 434 scoped_ptr<Client> client) { |
434 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); | 435 DVLOG(1) << "Allocating " << params.requested_format.frame_size.ToString(); |
435 impl_->AllocateAndStart(params, client.Pass()); | 436 impl_->AllocateAndStart(params, client.Pass()); |
436 } | 437 } |
437 | 438 |
438 void DesktopCaptureDeviceAura::StopAndDeAllocate() { | 439 void DesktopCaptureDeviceAura::StopAndDeAllocate() { |
439 impl_->StopAndDeAllocate(); | 440 impl_->StopAndDeAllocate(); |
440 } | 441 } |
441 | 442 |
442 } // namespace content | 443 } // namespace content |
OLD | NEW |