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());
43 scoped_ptr
<webrtc::MouseCursorMonitor
>
44 BasicDesktopEnvironment::CreateMouseCursorMonitor() {
45 return make_scoped_ptr(webrtc::MouseCursorMonitor::CreateForScreen(
46 *desktop_capture_options_
, webrtc::kFullDesktopScreenId
));
49 std::string
BasicDesktopEnvironment::GetCapabilities() const {
53 void BasicDesktopEnvironment::SetCapabilities(const std::string
& capabilities
) {
56 scoped_ptr
<GnubbyAuthHandler
> BasicDesktopEnvironment::CreateGnubbyAuthHandler(
57 protocol::ClientStub
* client_stub
) {
61 scoped_ptr
<webrtc::DesktopCapturer
>
62 BasicDesktopEnvironment::CreateVideoCapturer() {
63 DCHECK(caller_task_runner_
->BelongsToCurrentThread());
65 // The basic desktop environment does not use X DAMAGE, since it is
66 // broken on many systems - see http://crbug.com/73423.
67 return make_scoped_ptr(
68 webrtc::ScreenCapturer::Create(*desktop_capture_options_
));
71 BasicDesktopEnvironment::BasicDesktopEnvironment(
72 scoped_refptr
<base::SingleThreadTaskRunner
> caller_task_runner
,
73 scoped_refptr
<base::SingleThreadTaskRunner
> input_task_runner
,
74 scoped_refptr
<base::SingleThreadTaskRunner
> ui_task_runner
)
75 : caller_task_runner_(caller_task_runner
),
76 input_task_runner_(input_task_runner
),
77 ui_task_runner_(ui_task_runner
),
78 desktop_capture_options_(
79 new webrtc::DesktopCaptureOptions(
80 webrtc::DesktopCaptureOptions::CreateDefault())) {
81 DCHECK(caller_task_runner_
->BelongsToCurrentThread());
84 BasicDesktopEnvironmentFactory::BasicDesktopEnvironmentFactory(
85 scoped_refptr
<base::SingleThreadTaskRunner
> caller_task_runner
,
86 scoped_refptr
<base::SingleThreadTaskRunner
> input_task_runner
,
87 scoped_refptr
<base::SingleThreadTaskRunner
> ui_task_runner
)
88 : caller_task_runner_(caller_task_runner
),
89 input_task_runner_(input_task_runner
),
90 ui_task_runner_(ui_task_runner
) {
93 BasicDesktopEnvironmentFactory::~BasicDesktopEnvironmentFactory() {
96 bool BasicDesktopEnvironmentFactory::SupportsAudioCapture() const {
97 DCHECK(caller_task_runner_
->BelongsToCurrentThread());
99 return AudioCapturer::IsSupported();
102 } // namespace remoting