| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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.h" | 5 #include "content/browser/renderer_host/media/desktop_capture_device.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/sequenced_task_runner.h" | 10 #include "base/sequenced_task_runner.h" |
| 11 #include "base/strings/string_number_conversions.h" | 11 #include "base/strings/string_number_conversions.h" |
| 12 #include "base/synchronization/lock.h" | 12 #include "base/synchronization/lock.h" |
| 13 #include "base/threading/sequenced_worker_pool.h" | 13 #include "base/threading/sequenced_worker_pool.h" |
| 14 #include "content/public/browser/browser_thread.h" | 14 #include "content/public/browser/browser_thread.h" |
| 15 #include "content/public/common/desktop_media_id.h" | 15 #include "content/public/common/desktop_media_id.h" |
| 16 #include "media/base/video_util.h" | 16 #include "media/base/video_util.h" |
| 17 #include "third_party/libyuv/include/libyuv/scale_argb.h" | 17 #include "third_party/libyuv/include/libyuv/scale_argb.h" |
| 18 #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h" | 18 #include "third_party/webrtc/modules/desktop_capture/desktop_capturer.h" |
| 19 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" | 19 #include "third_party/webrtc/modules/desktop_capture/desktop_frame.h" |
| 20 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" | 20 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" |
| 21 #include "third_party/webrtc/modules/desktop_capture/window_capturer.h" | 21 #include "third_party/webrtc/modules/desktop_capture/window_capturer.h" |
| 22 | 22 |
| 23 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
| 24 #include "content/browser/renderer_host/media/desktop_capture_device_aura.h" |
| 25 #endif |
| 26 |
| 23 namespace content { | 27 namespace content { |
| 24 | 28 |
| 25 namespace { | 29 namespace { |
| 26 | 30 |
| 27 const int kBytesPerPixel = 4; | 31 const int kBytesPerPixel = 4; |
| 28 | 32 |
| 29 webrtc::DesktopRect ComputeLetterboxRect( | 33 webrtc::DesktopRect ComputeLetterboxRect( |
| 30 const webrtc::DesktopSize& max_size, | 34 const webrtc::DesktopSize& max_size, |
| 31 const webrtc::DesktopSize& source_size) { | 35 const webrtc::DesktopSize& source_size) { |
| 32 gfx::Rect result = media::ComputeLetterboxRegion( | 36 gfx::Rect result = media::ComputeLetterboxRegion( |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 380 scoped_ptr<media::VideoCaptureDevice> DesktopCaptureDevice::Create( | 384 scoped_ptr<media::VideoCaptureDevice> DesktopCaptureDevice::Create( |
| 381 const DesktopMediaID& source) { | 385 const DesktopMediaID& source) { |
| 382 scoped_refptr<base::SequencedWorkerPool> blocking_pool = | 386 scoped_refptr<base::SequencedWorkerPool> blocking_pool = |
| 383 BrowserThread::GetBlockingPool(); | 387 BrowserThread::GetBlockingPool(); |
| 384 scoped_refptr<base::SequencedTaskRunner> task_runner = | 388 scoped_refptr<base::SequencedTaskRunner> task_runner = |
| 385 blocking_pool->GetSequencedTaskRunner( | 389 blocking_pool->GetSequencedTaskRunner( |
| 386 blocking_pool->GetSequenceToken()); | 390 blocking_pool->GetSequenceToken()); |
| 387 | 391 |
| 388 switch (source.type) { | 392 switch (source.type) { |
| 389 case DesktopMediaID::TYPE_SCREEN: { | 393 case DesktopMediaID::TYPE_SCREEN: { |
| 394 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL) |
| 395 return scoped_ptr<media::VideoCaptureDevice>( |
| 396 DesktopCaptureDeviceAura::Create(source)); |
| 397 #else |
| 390 scoped_ptr<webrtc::DesktopCapturer> capturer; | 398 scoped_ptr<webrtc::DesktopCapturer> capturer; |
| 391 | 399 |
| 392 #if defined(OS_CHROMEOS) && !defined(ARCH_CPU_ARMEL) && defined(USE_X11) | 400 #if defined(OS_CHROMEOS) && defined(USE_X11) |
| 393 // ScreenCapturerX11 polls by default, due to poor driver support for | 401 // ScreenCapturerX11 polls by default, due to poor driver support for |
| 394 // DAMAGE. ChromeOS' drivers [can be patched to] support DAMAGE properly, | 402 // DAMAGE. ChromeOS' drivers [can be patched to] support DAMAGE properly, |
| 395 // so use it. However ARM driver seems to not support this properly, so | 403 // so use it. |
| 396 // disable it for ARM. See http://crbug.com/230105 . | |
| 397 capturer.reset(webrtc::ScreenCapturer::CreateWithXDamage(true)); | 404 capturer.reset(webrtc::ScreenCapturer::CreateWithXDamage(true)); |
| 398 #elif defined(OS_WIN) | 405 #elif defined(OS_WIN) |
| 399 // ScreenCapturerWin disables Aero by default. We don't want it disabled | 406 // ScreenCapturerWin disables Aero by default. We don't want it disabled |
| 400 // for WebRTC screen capture, though. | 407 // for WebRTC screen capture, though. |
| 401 capturer.reset( | 408 capturer.reset( |
| 402 webrtc::ScreenCapturer::CreateWithDisableAero(false)); | 409 webrtc::ScreenCapturer::CreateWithDisableAero(false)); |
| 403 #else | 410 #else |
| 404 capturer.reset(webrtc::ScreenCapturer::Create()); | 411 capturer.reset(webrtc::ScreenCapturer::Create()); |
| 405 #endif | 412 #endif |
| 406 | 413 |
| 407 return scoped_ptr<media::VideoCaptureDevice>(new DesktopCaptureDevice( | 414 return scoped_ptr<media::VideoCaptureDevice>(new DesktopCaptureDevice( |
| 408 task_runner, capturer.Pass())); | 415 task_runner, capturer.Pass())); |
| 416 #endif |
| 409 } | 417 } |
| 410 | 418 |
| 411 case DesktopMediaID::TYPE_WINDOW: { | 419 case DesktopMediaID::TYPE_WINDOW: { |
| 412 scoped_ptr<webrtc::WindowCapturer> capturer( | 420 scoped_ptr<webrtc::WindowCapturer> capturer( |
| 413 webrtc::WindowCapturer::Create()); | 421 webrtc::WindowCapturer::Create()); |
| 414 | 422 |
| 415 if (!capturer || !capturer->SelectWindow(source.id)) { | 423 if (!capturer || !capturer->SelectWindow(source.id)) { |
| 416 return scoped_ptr<media::VideoCaptureDevice>(); | 424 return scoped_ptr<media::VideoCaptureDevice>(); |
| 417 } | 425 } |
| 418 | 426 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 | 462 |
| 455 void DesktopCaptureDevice::DeAllocate() { | 463 void DesktopCaptureDevice::DeAllocate() { |
| 456 core_->DeAllocate(); | 464 core_->DeAllocate(); |
| 457 } | 465 } |
| 458 | 466 |
| 459 const media::VideoCaptureDevice::Name& DesktopCaptureDevice::device_name() { | 467 const media::VideoCaptureDevice::Name& DesktopCaptureDevice::device_name() { |
| 460 return name_; | 468 return name_; |
| 461 } | 469 } |
| 462 | 470 |
| 463 } // namespace content | 471 } // namespace content |
| OLD | NEW |