forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
/
basic_desktop_environment.h
180 lines (136 loc) · 5.7 KB
/
basic_desktop_environment.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef REMOTING_HOST_BASIC_DESKTOP_ENVIRONMENT_H_
#define REMOTING_HOST_BASIC_DESKTOP_ENVIRONMENT_H_
#include <cstdint>
#include <memory>
#include <string>
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "remoting/host/desktop_environment.h"
namespace base {
class SingleThreadTaskRunner;
}
namespace ui {
class SystemInputInjectorFactory;
}
namespace webrtc {
class DesktopCaptureOptions;
} // namespace webrtc
namespace remoting {
// Used to create audio/video capturers and event executor that work with
// the local console.
class BasicDesktopEnvironment : public DesktopEnvironment {
public:
~BasicDesktopEnvironment() override;
// DesktopEnvironment implementation.
std::unique_ptr<ActionExecutor> CreateActionExecutor() override;
std::unique_ptr<AudioCapturer> CreateAudioCapturer() override;
std::unique_ptr<InputInjector> CreateInputInjector() override;
std::unique_ptr<ScreenControls> CreateScreenControls() override;
std::unique_ptr<webrtc::DesktopCapturer> CreateVideoCapturer() override;
std::unique_ptr<webrtc::MouseCursorMonitor> CreateMouseCursorMonitor()
override;
std::unique_ptr<FileOperations> CreateFileOperations() override;
std::string GetCapabilities() const override;
void SetCapabilities(const std::string& capabilities) override;
uint32_t GetDesktopSessionId() const override;
protected:
friend class BasicDesktopEnvironmentFactory;
BasicDesktopEnvironment(
scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
ui::SystemInputInjectorFactory* system_input_injector_factory,
base::WeakPtr<ClientSessionControl> client_session_control,
const DesktopEnvironmentOptions& options);
scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner() const {
return caller_task_runner_;
}
scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner()
const {
return video_capture_task_runner_;
}
scoped_refptr<base::SingleThreadTaskRunner> input_task_runner() const {
return input_task_runner_;
}
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner() const {
return ui_task_runner_;
}
webrtc::DesktopCaptureOptions* mutable_desktop_capture_options() {
return options_.desktop_capture_options();
}
const webrtc::DesktopCaptureOptions& desktop_capture_options() const {
return *options_.desktop_capture_options();
}
ui::SystemInputInjectorFactory* system_input_injector_factory() const {
return system_input_injector_factory_;
}
const DesktopEnvironmentOptions& desktop_environment_options() const {
return options_;
}
private:
// Task runner on which methods of DesktopEnvironment interface should be
// called.
scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_;
// Used to run video capturer.
scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner_;
// Used to run input-related tasks.
scoped_refptr<base::SingleThreadTaskRunner> input_task_runner_;
// Used to run UI code.
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
// Passed to InputInjector.
ui::SystemInputInjectorFactory* system_input_injector_factory_;
// Used to send messages directly to the client session.
base::WeakPtr<ClientSessionControl> client_session_control_;
DesktopEnvironmentOptions options_;
DISALLOW_COPY_AND_ASSIGN(BasicDesktopEnvironment);
};
// Used to create |BasicDesktopEnvironment| instances.
class BasicDesktopEnvironmentFactory : public DesktopEnvironmentFactory {
public:
BasicDesktopEnvironmentFactory(
scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> input_task_runner,
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner,
ui::SystemInputInjectorFactory* system_input_injector_factory);
~BasicDesktopEnvironmentFactory() override;
// DesktopEnvironmentFactory implementation.
bool SupportsAudioCapture() const override;
protected:
scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner() const {
return caller_task_runner_;
}
scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner()
const {
return video_capture_task_runner_;
}
scoped_refptr<base::SingleThreadTaskRunner> input_task_runner() const {
return input_task_runner_;
}
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner() const {
return ui_task_runner_;
}
ui::SystemInputInjectorFactory* system_input_injector_factory() const {
return system_input_injector_factory_;
}
private:
// Task runner on which methods of DesktopEnvironmentFactory interface should
// be called.
scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_;
// Used to run video capture tasks.
scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner_;
// Used to run input-related tasks.
scoped_refptr<base::SingleThreadTaskRunner> input_task_runner_;
// Used to run UI code.
scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_;
// Passed to the environments built.
ui::SystemInputInjectorFactory* system_input_injector_factory_;
DISALLOW_COPY_AND_ASSIGN(BasicDesktopEnvironmentFactory);
};
} // namespace remoting
#endif // REMOTING_HOST_BASIC_DESKTOP_ENVIRONMENT_H_