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