| 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/media/capture/desktop_capture_device.h" | 5 #include "content/browser/media/capture/desktop_capture_device.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <string.h> | 9 #include <string.h> |
| 10 #include <utility> | 10 #include <utility> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/feature_list.h" | |
| 14 #include "base/location.h" | 13 #include "base/location.h" |
| 15 #include "base/logging.h" | 14 #include "base/logging.h" |
| 16 #include "base/macros.h" | 15 #include "base/macros.h" |
| 17 #include "base/message_loop/message_loop.h" | 16 #include "base/message_loop/message_loop.h" |
| 18 #include "base/metrics/histogram_macros.h" | 17 #include "base/metrics/histogram_macros.h" |
| 19 #include "base/single_thread_task_runner.h" | 18 #include "base/single_thread_task_runner.h" |
| 20 #include "base/strings/string_number_conversions.h" | 19 #include "base/strings/string_number_conversions.h" |
| 21 #include "base/synchronization/lock.h" | 20 #include "base/synchronization/lock.h" |
| 22 #include "base/threading/thread.h" | 21 #include "base/threading/thread.h" |
| 23 #include "base/threading/thread_restrictions.h" | 22 #include "base/threading/thread_restrictions.h" |
| 24 #include "base/timer/timer.h" | 23 #include "base/timer/timer.h" |
| 25 #include "build/build_config.h" | 24 #include "build/build_config.h" |
| 26 #include "content/browser/media/capture/desktop_capture_device_uma_types.h" | 25 #include "content/browser/media/capture/desktop_capture_device_uma_types.h" |
| 27 #include "content/public/browser/browser_thread.h" | 26 #include "content/public/browser/browser_thread.h" |
| 27 #include "content/public/browser/desktop_capture.h" |
| 28 #include "content/public/browser/desktop_media_id.h" | 28 #include "content/public/browser/desktop_media_id.h" |
| 29 #include "content/public/common/content_switches.h" | 29 #include "content/public/common/content_switches.h" |
| 30 #include "content/public/common/service_manager_connection.h" | 30 #include "content/public/common/service_manager_connection.h" |
| 31 #include "device/wake_lock/public/interfaces/wake_lock_provider.mojom.h" | 31 #include "device/wake_lock/public/interfaces/wake_lock_provider.mojom.h" |
| 32 #include "device/wake_lock/public/interfaces/wake_lock_service.mojom.h" | 32 #include "device/wake_lock/public/interfaces/wake_lock_service.mojom.h" |
| 33 #include "media/base/video_util.h" | 33 #include "media/base/video_util.h" |
| 34 #include "media/capture/content/capture_resolution_chooser.h" | 34 #include "media/capture/content/capture_resolution_chooser.h" |
| 35 #include "services/device/public/interfaces/constants.mojom.h" | 35 #include "services/device/public/interfaces/constants.mojom.h" |
| 36 #include "services/service_manager/public/cpp/connector.h" | 36 #include "services/service_manager/public/cpp/connector.h" |
| 37 #include "third_party/libyuv/include/libyuv/scale_argb.h" | 37 #include "third_party/libyuv/include/libyuv/scale_argb.h" |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 | 72 |
| 73 service_manager::Connector* connector = | 73 service_manager::Connector* connector = |
| 74 ServiceManagerConnection::GetForProcess()->GetConnector(); | 74 ServiceManagerConnection::GetForProcess()->GetConnector(); |
| 75 | 75 |
| 76 DCHECK(connector); | 76 DCHECK(connector); |
| 77 return connector->Clone(); | 77 return connector->Clone(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 } // namespace | 80 } // namespace |
| 81 | 81 |
| 82 #if defined(OS_WIN) | |
| 83 const base::Feature kDirectXCapturer{"DirectXCapturer", | |
| 84 base::FEATURE_ENABLED_BY_DEFAULT}; | |
| 85 #endif | |
| 86 | |
| 87 class DesktopCaptureDevice::Core : public webrtc::DesktopCapturer::Callback { | 82 class DesktopCaptureDevice::Core : public webrtc::DesktopCapturer::Callback { |
| 88 public: | 83 public: |
| 89 Core(scoped_refptr<base::SingleThreadTaskRunner> task_runner, | 84 Core(scoped_refptr<base::SingleThreadTaskRunner> task_runner, |
| 90 std::unique_ptr<webrtc::DesktopCapturer> capturer, | 85 std::unique_ptr<webrtc::DesktopCapturer> capturer, |
| 91 DesktopMediaID::Type type); | 86 DesktopMediaID::Type type); |
| 92 ~Core() override; | 87 ~Core() override; |
| 93 | 88 |
| 94 // Implementation of VideoCaptureDevice methods. | 89 // Implementation of VideoCaptureDevice methods. |
| 95 void AllocateAndStart(const media::VideoCaptureParams& params, | 90 void AllocateAndStart(const media::VideoCaptureParams& params, |
| 96 std::unique_ptr<Client> client); | 91 std::unique_ptr<Client> client); |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 device::mojom::WakeLockType::PreventDisplaySleep, | 389 device::mojom::WakeLockType::PreventDisplaySleep, |
| 395 device::mojom::WakeLockReason::ReasonOther, "Desktop capture is running", | 390 device::mojom::WakeLockReason::ReasonOther, "Desktop capture is running", |
| 396 mojo::MakeRequest(&wake_lock_)); | 391 mojo::MakeRequest(&wake_lock_)); |
| 397 | 392 |
| 398 wake_lock_->RequestWakeLock(); | 393 wake_lock_->RequestWakeLock(); |
| 399 } | 394 } |
| 400 | 395 |
| 401 // static | 396 // static |
| 402 std::unique_ptr<media::VideoCaptureDevice> DesktopCaptureDevice::Create( | 397 std::unique_ptr<media::VideoCaptureDevice> DesktopCaptureDevice::Create( |
| 403 const DesktopMediaID& source) { | 398 const DesktopMediaID& source) { |
| 404 webrtc::DesktopCaptureOptions options = | 399 auto options = CreateDesktopCaptureOptions(); |
| 405 webrtc::DesktopCaptureOptions::CreateDefault(); | |
| 406 // Leave desktop effects enabled during WebRTC captures. | |
| 407 options.set_disable_effects(false); | |
| 408 | |
| 409 #if defined(OS_WIN) | |
| 410 if (!base::FeatureList::IsEnabled(kDirectXCapturer)) { | |
| 411 options.set_allow_use_magnification_api(true); | |
| 412 } else { | |
| 413 options.set_allow_directx_capturer(true); | |
| 414 options.set_allow_use_magnification_api(false); | |
| 415 } | |
| 416 #endif | |
| 417 | |
| 418 std::unique_ptr<webrtc::DesktopCapturer> capturer; | 400 std::unique_ptr<webrtc::DesktopCapturer> capturer; |
| 419 | 401 |
| 420 switch (source.type) { | 402 switch (source.type) { |
| 421 case DesktopMediaID::TYPE_SCREEN: { | 403 case DesktopMediaID::TYPE_SCREEN: { |
| 422 std::unique_ptr<webrtc::DesktopCapturer> screen_capturer( | 404 std::unique_ptr<webrtc::DesktopCapturer> screen_capturer( |
| 423 webrtc::DesktopCapturer::CreateScreenCapturer(options)); | 405 webrtc::DesktopCapturer::CreateScreenCapturer(options)); |
| 424 if (screen_capturer && screen_capturer->SelectSource(source.id)) { | 406 if (screen_capturer && screen_capturer->SelectSource(source.id)) { |
| 425 capturer.reset(new webrtc::DesktopAndCursorComposer( | 407 capturer.reset(new webrtc::DesktopAndCursorComposer( |
| 426 screen_capturer.release(), | 408 screen_capturer.release(), |
| 427 webrtc::MouseCursorMonitor::CreateForScreen(options, source.id))); | 409 webrtc::MouseCursorMonitor::CreateForScreen(options, source.id))); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 #else | 479 #else |
| 498 base::MessageLoop::Type thread_type = base::MessageLoop::TYPE_DEFAULT; | 480 base::MessageLoop::Type thread_type = base::MessageLoop::TYPE_DEFAULT; |
| 499 #endif | 481 #endif |
| 500 | 482 |
| 501 thread_.StartWithOptions(base::Thread::Options(thread_type, 0)); | 483 thread_.StartWithOptions(base::Thread::Options(thread_type, 0)); |
| 502 | 484 |
| 503 core_.reset(new Core(thread_.task_runner(), std::move(capturer), type)); | 485 core_.reset(new Core(thread_.task_runner(), std::move(capturer), type)); |
| 504 } | 486 } |
| 505 | 487 |
| 506 } // namespace content | 488 } // namespace content |
| OLD | NEW |