[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; |
Jamie Walch | 044a8cd38 | 2020-02-04 00:27:40 | [diff] [blame^] | 50 | std::unique_ptr<DesktopAndCursorConditionalComposer> |
51 | CreateComposingVideoCapturer() override; | ||||
[email protected] | ce404ca | 2013-01-16 17:23:53 | [diff] [blame] | 52 | |
[email protected] | da457fc | 2013-03-14 16:32:12 | [diff] [blame] | 53 | protected: |
54 | friend class BasicDesktopEnvironmentFactory; | ||||
[email protected] | c308f512 | 2013-04-05 03:32:06 | [diff] [blame] | 55 | |
[email protected] | 231316a | 2013-03-25 06:01:12 | [diff] [blame] | 56 | BasicDesktopEnvironment( |
57 | scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | ||||
sergeyu | 85df3c48 | 2016-02-15 05:59:08 | [diff] [blame] | 58 | scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner, |
[email protected] | 231316a | 2013-03-25 06:01:12 | [diff] [blame] | 59 | scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, |
zijiehe | 4aa6ea4 | 2016-11-12 01:28:16 | [diff] [blame] | 60 | scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner, |
Gary Kacmarcik | a7e33e4 | 2019-02-22 19:23:28 | [diff] [blame] | 61 | base::WeakPtr<ClientSessionControl> client_session_control, |
zijiehe | 4aa6ea4 | 2016-11-12 01:28:16 | [diff] [blame] | 62 | const DesktopEnvironmentOptions& options); |
[email protected] | 0c2dc37 | 2013-04-23 18:58:16 | [diff] [blame] | 63 | |
[email protected] | 231316a | 2013-03-25 06:01:12 | [diff] [blame] | 64 | scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner() const { |
65 | return caller_task_runner_; | ||||
66 | } | ||||
67 | |||||
sergeyu | 85df3c48 | 2016-02-15 05:59:08 | [diff] [blame] | 68 | scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner() |
69 | const { | ||||
70 | return video_capture_task_runner_; | ||||
71 | } | ||||
72 | |||||
[email protected] | 231316a | 2013-03-25 06:01:12 | [diff] [blame] | 73 | scoped_refptr<base::SingleThreadTaskRunner> input_task_runner() const { |
74 | return input_task_runner_; | ||||
75 | } | ||||
76 | |||||
77 | scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner() const { | ||||
78 | return ui_task_runner_; | ||||
79 | } | ||||
[email protected] | 74b08f8c | 2013-01-30 09:48:59 | [diff] [blame] | 80 | |
zijiehe | 4aa6ea4 | 2016-11-12 01:28:16 | [diff] [blame] | 81 | webrtc::DesktopCaptureOptions* mutable_desktop_capture_options() { |
82 | return options_.desktop_capture_options(); | ||||
83 | } | ||||
84 | |||||
85 | const webrtc::DesktopCaptureOptions& desktop_capture_options() const { | ||||
86 | return *options_.desktop_capture_options(); | ||||
87 | } | ||||
88 | |||||
89 | const DesktopEnvironmentOptions& desktop_environment_options() const { | ||||
90 | return options_; | ||||
[email protected] | 2001320 | 2014-08-08 06:33:50 | [diff] [blame] | 91 | } |
92 | |||||
[email protected] | da457fc | 2013-03-14 16:32:12 | [diff] [blame] | 93 | private: |
[email protected] | 231316a | 2013-03-25 06:01:12 | [diff] [blame] | 94 | // Task runner on which methods of DesktopEnvironment interface should be |
95 | // called. | ||||
96 | scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; | ||||
97 | |||||
sergeyu | 85df3c48 | 2016-02-15 05:59:08 | [diff] [blame] | 98 | // Used to run video capturer. |
99 | scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner_; | ||||
100 | |||||
[email protected] | 231316a | 2013-03-25 06:01:12 | [diff] [blame] | 101 | // Used to run input-related tasks. |
102 | scoped_refptr<base::SingleThreadTaskRunner> input_task_runner_; | ||||
103 | |||||
104 | // Used to run UI code. | ||||
105 | scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; | ||||
106 | |||||
Gary Kacmarcik | a7e33e4 | 2019-02-22 19:23:28 | [diff] [blame] | 107 | // Used to send messages directly to the client session. |
108 | base::WeakPtr<ClientSessionControl> client_session_control_; | ||||
109 | |||||
zijiehe | 4aa6ea4 | 2016-11-12 01:28:16 | [diff] [blame] | 110 | DesktopEnvironmentOptions options_; |
[email protected] | 2001320 | 2014-08-08 06:33:50 | [diff] [blame] | 111 | |
[email protected] | ce404ca | 2013-01-16 17:23:53 | [diff] [blame] | 112 | DISALLOW_COPY_AND_ASSIGN(BasicDesktopEnvironment); |
113 | }; | ||||
114 | |||||
115 | // Used to create |BasicDesktopEnvironment| instances. | ||||
116 | class BasicDesktopEnvironmentFactory : public DesktopEnvironmentFactory { | ||||
117 | public: | ||||
[email protected] | 231316a | 2013-03-25 06:01:12 | [diff] [blame] | 118 | BasicDesktopEnvironmentFactory( |
119 | scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner, | ||||
sergeyu | 85df3c48 | 2016-02-15 05:59:08 | [diff] [blame] | 120 | scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner, |
[email protected] | 231316a | 2013-03-25 06:01:12 | [diff] [blame] | 121 | scoped_refptr<base::SingleThreadTaskRunner> input_task_runner, |
Scott Violet | 9778dcd | 2019-06-20 21:59:37 | [diff] [blame] | 122 | scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner); |
dcheng | 562aba5 | 2014-10-21 12:30:14 | [diff] [blame] | 123 | ~BasicDesktopEnvironmentFactory() override; |
[email protected] | ce404ca | 2013-01-16 17:23:53 | [diff] [blame] | 124 | |
125 | // DesktopEnvironmentFactory implementation. | ||||
dcheng | 562aba5 | 2014-10-21 12:30:14 | [diff] [blame] | 126 | bool SupportsAudioCapture() const override; |
[email protected] | ce404ca | 2013-01-16 17:23:53 | [diff] [blame] | 127 | |
[email protected] | 231316a | 2013-03-25 06:01:12 | [diff] [blame] | 128 | protected: |
129 | scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner() const { | ||||
130 | return caller_task_runner_; | ||||
131 | } | ||||
132 | |||||
sergeyu | 85df3c48 | 2016-02-15 05:59:08 | [diff] [blame] | 133 | scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner() |
134 | const { | ||||
135 | return video_capture_task_runner_; | ||||
136 | } | ||||
137 | |||||
[email protected] | 231316a | 2013-03-25 06:01:12 | [diff] [blame] | 138 | scoped_refptr<base::SingleThreadTaskRunner> input_task_runner() const { |
139 | return input_task_runner_; | ||||
140 | } | ||||
141 | |||||
142 | scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner() const { | ||||
143 | return ui_task_runner_; | ||||
144 | } | ||||
145 | |||||
[email protected] | ce404ca | 2013-01-16 17:23:53 | [diff] [blame] | 146 | private: |
[email protected] | 231316a | 2013-03-25 06:01:12 | [diff] [blame] | 147 | // Task runner on which methods of DesktopEnvironmentFactory interface should |
148 | // be called. | ||||
149 | scoped_refptr<base::SingleThreadTaskRunner> caller_task_runner_; | ||||
150 | |||||
sergeyu | 85df3c48 | 2016-02-15 05:59:08 | [diff] [blame] | 151 | // Used to run video capture tasks. |
152 | scoped_refptr<base::SingleThreadTaskRunner> video_capture_task_runner_; | ||||
153 | |||||
[email protected] | 231316a | 2013-03-25 06:01:12 | [diff] [blame] | 154 | // Used to run input-related tasks. |
155 | scoped_refptr<base::SingleThreadTaskRunner> input_task_runner_; | ||||
156 | |||||
157 | // Used to run UI code. | ||||
158 | scoped_refptr<base::SingleThreadTaskRunner> ui_task_runner_; | ||||
159 | |||||
[email protected] | ce404ca | 2013-01-16 17:23:53 | [diff] [blame] | 160 | DISALLOW_COPY_AND_ASSIGN(BasicDesktopEnvironmentFactory); |
161 | }; | ||||
162 | |||||
163 | } // namespace remoting | ||||
164 | |||||
165 | #endif // REMOTING_HOST_BASIC_DESKTOP_ENVIRONMENT_H_ |