[email protected] | ce404ca | 2013-01-16 17:23:53 | [diff] [blame] | 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. | ||||
4 | |||||
5 | #ifndef REMOTING_HOST_BASIC_DESKTOP_ENVIRONMENT_H_ | ||||
6 | #define REMOTING_HOST_BASIC_DESKTOP_ENVIRONMENT_H_ | ||||
7 | |||||
joedow | 90b28f8 | 2016-06-24 04:46:45 | [diff] [blame] | 8 | #include <cstdint> |
dcheng | 0765c49 | 2016-04-06 22:41:53 | [diff] [blame] | 9 | #include <memory> |
[email protected] | a5d181f | 2013-04-19 14:55:37 | [diff] [blame] | 10 | #include <string> |
11 | |||||
[email protected] | ce404ca | 2013-01-16 17:23:53 | [diff] [blame] | 12 | #include "base/compiler_specific.h" |
[email protected] | ce404ca | 2013-01-16 17:23:53 | [diff] [blame] | 13 | #include "base/memory/ref_counted.h" |
[email protected] | ce404ca | 2013-01-16 17:23:53 | [diff] [blame] | 14 | #include "remoting/host/desktop_environment.h" |
15 | |||||
jbriance | e9b2ece | 2016-12-01 07:29:52 | [diff] [blame] | 16 | namespace base { |
17 | class SingleThreadTaskRunner; | ||||
18 | } | ||||
19 | |||||
[email protected] | 2001320 | 2014-08-08 06:33:50 | [diff] [blame] | 20 | namespace webrtc { |
21 | |||||
22 | class DesktopCaptureOptions; | ||||
23 | |||||
24 | } // namespace webrtc | ||||
25 | |||||
[email protected] | ce404ca | 2013-01-16 17:23:53 | [diff] [blame] | 26 | namespace remoting { |
27 | |||||
28 | // Used to create audio/video capturers and event executor that work with | ||||
29 | // the local console. | ||||
[email protected] | 231316a | 2013-03-25 06:01:12 | [diff] [blame] | 30 | class BasicDesktopEnvironment : public DesktopEnvironment { |
[email protected] | ce404ca | 2013-01-16 17:23:53 | [diff] [blame] | 31 | public: |
Peter Boström | e9178e4 | 2021-09-22 18:11:49 | [diff] [blame] | 32 | BasicDesktopEnvironment(const BasicDesktopEnvironment&) = delete; |
33 | BasicDesktopEnvironment& operator=(const BasicDesktopEnvironment&) = delete; | ||||
34 | |||||
dcheng | 562aba5 | 2014-10-21 12:30:14 | [diff] [blame] | 35 | ~BasicDesktopEnvironment() override; |
[email protected] | ce404ca | 2013-01-16 17:23:53 | [diff] [blame] | 36 | |
37 | // DesktopEnvironment implementation. | ||||
Joe Downing | 505ae0d0 | 2018-10-17 17:47:30 | [diff] [blame] | 38 | std::unique_ptr<ActionExecutor> CreateActionExecutor() override; |
dcheng | 0765c49 | 2016-04-06 22:41:53 | [diff] [blame] | 39 | std::unique_ptr<AudioCapturer> CreateAudioCapturer() override; |
40 | std::unique_ptr<InputInjector> CreateInputInjector() override; | ||||
41 | std::unique_ptr<ScreenControls> CreateScreenControls() override; | ||||
42 | std::unique_ptr<webrtc::DesktopCapturer> CreateVideoCapturer() override; | ||||
43 | std::unique_ptr<webrtc::MouseCursorMonitor> CreateMouseCursorMonitor() | ||||
44 | override; | ||||
Erik Jensen | c08ecf11 | 2019-12-19 00:29:49 | [diff] [blame] | 45 | std::unique_ptr<KeyboardLayoutMonitor> CreateKeyboardLayoutMonitor( |
46 | base::RepeatingCallback<void(const protocol::KeyboardLayout&)> callback) | ||||
47 | override; | ||||
Erik Jensen | 5d500dd | 2018-12-10 23:27:53 | [diff] [blame] | 48 | std::unique_ptr<FileOperations> CreateFileOperations() override; |
Yuwei Huang | 84af8d2 | 2021-08-03 00:36:58 | [diff] [blame] | 49 | std::unique_ptr<UrlForwarderConfigurator> CreateUrlForwarderConfigurator() |
50 | override; | ||||
dcheng | 562aba5 | 2014-10-21 12:30:14 | [diff] [blame] | 51 | std::string GetCapabilities() const override; |
52 | void SetCapabilities(const std::string& capabilities) override; | ||||
joedow | 90b28f8 | 2016-06-24 04:46:45 | [diff] [blame] | 53 | uint32_t GetDesktopSessionId() const override; |
Jamie Walch | 044a8cd38 | 2020-02-04 00:27:40 | [diff] [blame] | 54 | std::unique_ptr<DesktopAndCursorConditionalComposer> |
55 | CreateComposingVideoCapturer() override; | ||||
[email protected] | ce404ca | 2013-01-16 17:23:53 | [diff] [blame] | 56 | |
[email protected] | da457fc | 2013-03-14 16:32:12 | [diff] [blame] | 57 | protected: |
58 | friend class BasicDesktopEnvironmentFactory; | ||||
[email protected] | c308f512 | 2013-04-05 03:32:06 | [diff] [blame] | 59 | |
[email protected] | 231316a | 2013-03-25 06:01:12 | [diff] [blame] | 60 | BasicDesktopEnvironment( |
61 | scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | ||||
sergeyu | 85df3c48 | 2016-02-15 05:59:08 | [diff] [blame] | 62 | scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner, |
[email protected] | 231316a | 2013-03-25 06:01:12 | [diff] [blame] | 63 | scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, |
zijiehe | 4aa6ea4 | 2016-11-12 01:28:16 | [diff] [blame] | 64 | scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
Gary Kacmarcik | a7e33e4 | 2019-02-22 19:23:28 | [diff] [blame] | 65 | base::WeakPtr<ClientSessionControl> client_session_control, |
zijiehe | 4aa6ea4 | 2016-11-12 01:28:16 | [diff] [blame] | 66 | const DesktopEnvironmentOptions& options); |
[email protected] | 0c2dc37 | 2013-04-23 18:58:16 | [diff] [blame] | 67 | |
[email protected] | 231316a | 2013-03-25 06:01:12 | [diff] [blame] | 68 | scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner() const { |
69 | return caller_task_runner_; | ||||
70 | } | ||||
71 | |||||
sergeyu | 85df3c48 | 2016-02-15 05:59:08 | [diff] [blame] | 72 | scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner() |
73 | const { | ||||
74 | return video_capture_task_runner_; | ||||
75 | } | ||||
76 | |||||
[email protected] | 231316a | 2013-03-25 06:01:12 | [diff] [blame] | 77 | scoped_refptr<base::SingleThreadTaskRunner> input_task_runner() const { |
78 | return input_task_runner_; | ||||
79 | } | ||||
80 | |||||
81 | scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner() const { | ||||
82 | return ui_task_runner_; | ||||
83 | } | ||||
[email protected] | 74b08f8c | 2013-01-30 09:48:59 | [diff] [blame] | 84 | |
zijiehe | 4aa6ea4 | 2016-11-12 01:28:16 | [diff] [blame] | 85 | webrtc::DesktopCaptureOptions* mutable_desktop_capture_options() { |
86 | return options_.desktop_capture_options(); | ||||
87 | } | ||||
88 | |||||
89 | const webrtc::DesktopCaptureOptions& desktop_capture_options() const { | ||||
90 | return *options_.desktop_capture_options(); | ||||
91 | } | ||||
92 | |||||
93 | const DesktopEnvironmentOptions& desktop_environment_options() const { | ||||
94 | return options_; | ||||
[email protected] | 2001320 | 2014-08-08 06:33:50 | [diff] [blame] | 95 | } |
96 | |||||
[email protected] | da457fc | 2013-03-14 16:32:12 | [diff] [blame] | 97 | private: |
[email protected] | 231316a | 2013-03-25 06:01:12 | [diff] [blame] | 98 | // Task runner on which methods of DesktopEnvironment interface should be |
99 | // called. | ||||
100 | scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; | ||||
101 | |||||
sergeyu | 85df3c48 | 2016-02-15 05:59:08 | [diff] [blame] | 102 | // Used to run video capturer. |
103 | scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner_; | ||||
104 | |||||
[email protected] | 231316a | 2013-03-25 06:01:12 | [diff] [blame] | 105 | // Used to run input-related tasks. |
106 | scoped_refptr<base::SingleThreadTaskRunner> input_task_runner_; | ||||
107 | |||||
108 | // Used to run UI code. | ||||
109 | scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; | ||||
110 | |||||
Gary Kacmarcik | a7e33e4 | 2019-02-22 19:23:28 | [diff] [blame] | 111 | // Used to send messages directly to the client session. |
112 | base::WeakPtr<ClientSessionControl> client_session_control_; | ||||
113 | |||||
zijiehe | 4aa6ea4 | 2016-11-12 01:28:16 | [diff] [blame] | 114 | DesktopEnvironmentOptions options_; |
[email protected] | ce404ca | 2013-01-16 17:23:53 | [diff] [blame] | 115 | }; |
116 | |||||
117 | // Used to create |BasicDesktopEnvironment| instances. | ||||
118 | class BasicDesktopEnvironmentFactory : public DesktopEnvironmentFactory { | ||||
119 | public: | ||||
[email protected] | 231316a | 2013-03-25 06:01:12 | [diff] [blame] | 120 | BasicDesktopEnvironmentFactory( |
121 | scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | ||||
sergeyu | 85df3c48 | 2016-02-15 05:59:08 | [diff] [blame] | 122 | scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner, |
[email protected] | 231316a | 2013-03-25 06:01:12 | [diff] [blame] | 123 | scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, |
Scott Violet | 9778dcd | 2019-06-20 21:59:37 | [diff] [blame] | 124 | scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); |
Peter Boström | e9178e4 | 2021-09-22 18:11:49 | [diff] [blame] | 125 | |
126 | BasicDesktopEnvironmentFactory(const BasicDesktopEnvironmentFactory&) = | ||||
127 | delete; | ||||
128 | BasicDesktopEnvironmentFactory& operator=( | ||||
129 | const BasicDesktopEnvironmentFactory&) = delete; | ||||
130 | |||||
dcheng | 562aba5 | 2014-10-21 12:30:14 | [diff] [blame] | 131 | ~BasicDesktopEnvironmentFactory() override; |
[email protected] | ce404ca | 2013-01-16 17:23:53 | [diff] [blame] | 132 | |
133 | // DesktopEnvironmentFactory implementation. | ||||
dcheng | 562aba5 | 2014-10-21 12:30:14 | [diff] [blame] | 134 | bool SupportsAudioCapture() const override; |
[email protected] | ce404ca | 2013-01-16 17:23:53 | [diff] [blame] | 135 | |
[email protected] | 231316a | 2013-03-25 06:01:12 | [diff] [blame] | 136 | protected: |
137 | scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner() const { | ||||
138 | return caller_task_runner_; | ||||
139 | } | ||||
140 | |||||
sergeyu | 85df3c48 | 2016-02-15 05:59:08 | [diff] [blame] | 141 | scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner() |
142 | const { | ||||
143 | return video_capture_task_runner_; | ||||
144 | } | ||||
145 | |||||
[email protected] | 231316a | 2013-03-25 06:01:12 | [diff] [blame] | 146 | scoped_refptr<base::SingleThreadTaskRunner> input_task_runner() const { |
147 | return input_task_runner_; | ||||
148 | } | ||||
149 | |||||
150 | scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner() const { | ||||
151 | return ui_task_runner_; | ||||
152 | } | ||||
153 | |||||
[email protected] | ce404ca | 2013-01-16 17:23:53 | [diff] [blame] | 154 | private: |
[email protected] | 231316a | 2013-03-25 06:01:12 | [diff] [blame] | 155 | // Task runner on which methods of DesktopEnvironmentFactory interface should |
156 | // be called. | ||||
157 | scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; | ||||
158 | |||||
sergeyu | 85df3c48 | 2016-02-15 05:59:08 | [diff] [blame] | 159 | // Used to run video capture tasks. |
160 | scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner_; | ||||
161 | |||||
[email protected] | 231316a | 2013-03-25 06:01:12 | [diff] [blame] | 162 | // Used to run input-related tasks. |
163 | scoped_refptr<base::SingleThreadTaskRunner> input_task_runner_; | ||||
164 | |||||
165 | // Used to run UI code. | ||||
166 | scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; | ||||
[email protected] | ce404ca | 2013-01-16 17:23:53 | [diff] [blame] | 167 | }; |
168 | |||||
169 | } // namespace remoting | ||||
170 | |||||
171 | #endif // REMOTING_HOST_BASIC_DESKTOP_ENVIRONMENT_H_ |