1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "remoting/host/basic_desktop_environment.h"
8 #include "base/logging.h"
9 #include "base/single_thread_task_runner.h"
10 #include "remoting/host/audio_capturer.h"
11 #include "remoting/host/client_session_control.h"
12 #include "remoting/host/gnubby_auth_handler.h"
13 #include "remoting/host/input_injector.h"
14 #include "remoting/host/screen_controls.h"
15 #include "third_party/webrtc/modules/desktop_capture/desktop_capture_options.h"
16 #include "third_party/webrtc/modules/desktop_capture/mouse_cursor_monitor.h"
17 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h"
21 BasicDesktopEnvironment::~BasicDesktopEnvironment() {
22 DCHECK(caller_task_runner_
->BelongsToCurrentThread());
25 scoped_ptr
<AudioCapturer
> BasicDesktopEnvironment::CreateAudioCapturer() {
26 DCHECK(caller_task_runner_
->BelongsToCurrentThread());
28 return AudioCapturer::Create();
31 scoped_ptr
<InputInjector
> BasicDesktopEnvironment::CreateInputInjector() {
32 DCHECK(caller_task_runner_
->BelongsToCurrentThread());
34 return InputInjector::Create(input_task_runner(), ui_task_runner());
37 scoped_ptr
<ScreenControls
> BasicDesktopEnvironment::CreateScreenControls() {
38 DCHECK(caller_task_runner_
->BelongsToCurrentThread());
40 return scoped_ptr
<ScreenControls
>();
43 scoped_ptr
<webrtc::MouseCursorMonitor
>
44 BasicDesktopEnvironment::CreateMouseCursorMonitor() {
45 return scoped_ptr
<webrtc::MouseCursorMonitor
>(
46 webrtc::MouseCursorMonitor::CreateForScreen(
47 *desktop_capture_options_
,
48 webrtc::kFullDesktopScreenId
));
51 std::string
BasicDesktopEnvironment::GetCapabilities() const {
55 void BasicDesktopEnvironment::SetCapabilities(const std::string
& capabilities
) {
58 scoped_ptr
<GnubbyAuthHandler
> BasicDesktopEnvironment::CreateGnubbyAuthHandler(
59 protocol::ClientStub
* client_stub
) {
60 return scoped_ptr
<GnubbyAuthHandler
>();
63 scoped_ptr
<webrtc::DesktopCapturer
>
64 BasicDesktopEnvironment::CreateVideoCapturer() {
65 DCHECK(caller_task_runner_
->BelongsToCurrentThread());
67 // The basic desktop environment does not use X DAMAGE, since it is
68 // broken on many systems - see http://crbug.com/73423.
69 return scoped_ptr
<webrtc::DesktopCapturer
>(
70 webrtc::ScreenCapturer::Create(*desktop_capture_options_
));
73 BasicDesktopEnvironment::BasicDesktopEnvironment(
74 scoped_refptr
<base::SingleThreadTaskRunner
> caller_task_runner
,
75 scoped_refptr
<base::SingleThreadTaskRunner
> input_task_runner
,
76 scoped_refptr
<base::SingleThreadTaskRunner
> ui_task_runner
)
77 : caller_task_runner_(caller_task_runner
),
78 input_task_runner_(input_task_runner
),
79 ui_task_runner_(ui_task_runner
),
80 desktop_capture_options_(
81 new webrtc::DesktopCaptureOptions(
82 webrtc::DesktopCaptureOptions::CreateDefault())) {
83 DCHECK(caller_task_runner_
->BelongsToCurrentThread());
86 BasicDesktopEnvironmentFactory::BasicDesktopEnvironmentFactory(
87 scoped_refptr
<base::SingleThreadTaskRunner
> caller_task_runner
,
88 scoped_refptr
<base::SingleThreadTaskRunner
> input_task_runner
,
89 scoped_refptr
<base::SingleThreadTaskRunner
> ui_task_runner
)
90 : caller_task_runner_(caller_task_runner
),
91 input_task_runner_(input_task_runner
),
92 ui_task_runner_(ui_task_runner
) {
95 BasicDesktopEnvironmentFactory::~BasicDesktopEnvironmentFactory() {
98 bool BasicDesktopEnvironmentFactory::SupportsAudioCapture() const {
99 DCHECK(caller_task_runner_
->BelongsToCurrentThread());
101 return AudioCapturer::IsSupported();
104 } // namespace remoting