OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef REMOTING_HOST_DESKTOP_SESSION_AGENT_H_ | 5 #ifndef REMOTING_HOST_DESKTOP_SESSION_AGENT_H_ |
6 #define REMOTING_HOST_DESKTOP_SESSION_AGENT_H_ | 6 #define REMOTING_HOST_DESKTOP_SESSION_AGENT_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/callback.h" | 11 #include "base/callback.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/memory/scoped_ptr.h" | 14 #include "base/memory/scoped_ptr.h" |
15 #include "base/memory/weak_ptr.h" | 15 #include "base/memory/weak_ptr.h" |
16 #include "ipc/ipc_listener.h" | 16 #include "ipc/ipc_listener.h" |
17 #include "ipc/ipc_platform_file.h" | 17 #include "ipc/ipc_platform_file.h" |
18 #include "remoting/host/client_session_control.h" | 18 #include "remoting/host/client_session_control.h" |
19 #include "remoting/protocol/clipboard_stub.h" | 19 #include "remoting/protocol/clipboard_stub.h" |
20 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" | 20 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h" |
| 21 #include "third_party/webrtc/modules/desktop_capture/mouse_cursor_monitor.h" |
21 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" | 22 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h" |
22 | 23 |
23 namespace IPC { | 24 namespace IPC { |
24 class ChannelProxy; | 25 class ChannelProxy; |
25 class Message; | 26 class Message; |
26 } // namespace IPC | 27 } // namespace IPC |
27 | 28 |
28 namespace remoting { | 29 namespace remoting { |
29 | 30 |
30 class AudioCapturer; | 31 class AudioCapturer; |
31 class AudioPacket; | 32 class AudioPacket; |
32 class AutoThreadTaskRunner; | 33 class AutoThreadTaskRunner; |
33 class DesktopEnvironment; | 34 class DesktopEnvironment; |
34 class DesktopEnvironmentFactory; | 35 class DesktopEnvironmentFactory; |
35 class InputInjector; | 36 class InputInjector; |
36 class RemoteInputFilter; | 37 class RemoteInputFilter; |
37 class ScreenControls; | 38 class ScreenControls; |
38 class ScreenResolution; | 39 class ScreenResolution; |
39 | 40 |
40 namespace protocol { | 41 namespace protocol { |
41 class InputEventTracker; | 42 class InputEventTracker; |
42 } // namespace protocol | 43 } // namespace protocol |
43 | 44 |
44 // Provides screen/audio capturing and input injection services for | 45 // Provides screen/audio capturing and input injection services for |
45 // the network process. | 46 // the network process. |
46 class DesktopSessionAgent | 47 class DesktopSessionAgent |
47 : public base::RefCountedThreadSafe<DesktopSessionAgent>, | 48 : public base::RefCountedThreadSafe<DesktopSessionAgent>, |
48 public IPC::Listener, | 49 public IPC::Listener, |
49 public webrtc::DesktopCapturer::Callback, | 50 public webrtc::DesktopCapturer::Callback, |
50 public webrtc::ScreenCapturer::MouseShapeObserver, | 51 public webrtc::MouseCursorMonitor::Callback, |
51 public ClientSessionControl { | 52 public ClientSessionControl { |
52 public: | 53 public: |
53 class Delegate { | 54 class Delegate { |
54 public: | 55 public: |
55 virtual ~Delegate(); | 56 virtual ~Delegate(); |
56 | 57 |
57 // Returns an instance of desktop environment factory used. | 58 // Returns an instance of desktop environment factory used. |
58 virtual DesktopEnvironmentFactory& desktop_environment_factory() = 0; | 59 virtual DesktopEnvironmentFactory& desktop_environment_factory() = 0; |
59 | 60 |
60 // Notifies the delegate that the network-to-desktop channel has been | 61 // Notifies the delegate that the network-to-desktop channel has been |
(...skipping 10 matching lines...) Expand all Loading... |
71 | 72 |
72 // IPC::Listener implementation. | 73 // IPC::Listener implementation. |
73 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 74 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
74 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; | 75 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; |
75 virtual void OnChannelError() OVERRIDE; | 76 virtual void OnChannelError() OVERRIDE; |
76 | 77 |
77 // webrtc::DesktopCapturer::Callback implementation. | 78 // webrtc::DesktopCapturer::Callback implementation. |
78 virtual webrtc::SharedMemory* CreateSharedMemory(size_t size) OVERRIDE; | 79 virtual webrtc::SharedMemory* CreateSharedMemory(size_t size) OVERRIDE; |
79 virtual void OnCaptureCompleted(webrtc::DesktopFrame* frame) OVERRIDE; | 80 virtual void OnCaptureCompleted(webrtc::DesktopFrame* frame) OVERRIDE; |
80 | 81 |
81 // webrtc::ScreenCapturer::MouseShapeObserver implementation. | 82 // webrtc::MouseCursorMonitor::Callback implementation. |
82 virtual void OnCursorShapeChanged( | 83 virtual void OnMouseCursor(webrtc::MouseCursor* cursor) OVERRIDE; |
83 webrtc::MouseCursorShape* cursor_shape) OVERRIDE; | 84 virtual void OnMouseCursorPosition( |
| 85 webrtc::MouseCursorMonitor::CursorState state, |
| 86 const webrtc::DesktopVector& position) OVERRIDE; |
84 | 87 |
85 // Forwards a local clipboard event though the IPC channel to the network | 88 // Forwards a local clipboard event though the IPC channel to the network |
86 // process. | 89 // process. |
87 void InjectClipboardEvent(const protocol::ClipboardEvent& event); | 90 void InjectClipboardEvent(const protocol::ClipboardEvent& event); |
88 | 91 |
89 // Forwards an audio packet though the IPC channel to the network process. | 92 // Forwards an audio packet though the IPC channel to the network process. |
90 void ProcessAudioPacket(scoped_ptr<AudioPacket> packet); | 93 void ProcessAudioPacket(scoped_ptr<AudioPacket> packet); |
91 | 94 |
92 // Creates desktop integration components and a connected IPC channel to be | 95 // Creates desktop integration components and a connected IPC channel to be |
93 // used to access them. The client end of the channel is returned in | 96 // used to access them. The client end of the channel is returned in |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 | 137 |
135 // Sends a message to the network process. | 138 // Sends a message to the network process. |
136 void SendToNetwork(IPC::Message* message); | 139 void SendToNetwork(IPC::Message* message); |
137 | 140 |
138 // Posted to |audio_capture_task_runner_| to start the audio capturer. | 141 // Posted to |audio_capture_task_runner_| to start the audio capturer. |
139 void StartAudioCapturer(); | 142 void StartAudioCapturer(); |
140 | 143 |
141 // Posted to |audio_capture_task_runner_| to stop the audio capturer. | 144 // Posted to |audio_capture_task_runner_| to stop the audio capturer. |
142 void StopAudioCapturer(); | 145 void StopAudioCapturer(); |
143 | 146 |
144 // Posted to |video_capture_task_runner_| to start the video capturer. | 147 // Posted to |video_capture_task_runner_| to start the video capturer and the |
145 void StartVideoCapturer(); | 148 // mouse cursor monitor. |
| 149 void StartVideoCapturerAndMouseMonitor(); |
146 | 150 |
147 // Posted to |video_capture_task_runner_| to stop the video capturer. | 151 // Posted to |video_capture_task_runner_| to stop the video capturer and the |
148 void StopVideoCapturer(); | 152 // mouse cursor monitor. |
| 153 void StopVideoCapturerAndMouseMonitor(); |
149 | 154 |
150 private: | 155 private: |
151 class SharedBuffer; | 156 class SharedBuffer; |
152 friend class SharedBuffer; | 157 friend class SharedBuffer; |
153 | 158 |
154 // Called by SharedBuffer when it's destroyed. | 159 // Called by SharedBuffer when it's destroyed. |
155 void OnSharedBufferDeleted(int id); | 160 void OnSharedBufferDeleted(int id); |
156 | 161 |
157 // Task runner dedicated to running methods of |audio_capturer_|. | 162 // Task runner dedicated to running methods of |audio_capturer_|. |
158 scoped_refptr<AutoThreadTaskRunner> audio_capture_task_runner_; | 163 scoped_refptr<AutoThreadTaskRunner> audio_capture_task_runner_; |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 | 214 |
210 // The number of currently allocated shared buffers. | 215 // The number of currently allocated shared buffers. |
211 int shared_buffers_; | 216 int shared_buffers_; |
212 | 217 |
213 // True if the desktop session agent has been started. | 218 // True if the desktop session agent has been started. |
214 bool started_; | 219 bool started_; |
215 | 220 |
216 // Captures the screen. | 221 // Captures the screen. |
217 scoped_ptr<webrtc::ScreenCapturer> video_capturer_; | 222 scoped_ptr<webrtc::ScreenCapturer> video_capturer_; |
218 | 223 |
| 224 // Captures mouse shapes. |
| 225 scoped_ptr<webrtc::MouseCursorMonitor> mouse_cursor_monitor_; |
| 226 |
219 // Keep reference to the last frame sent to make sure shared buffer is alive | 227 // Keep reference to the last frame sent to make sure shared buffer is alive |
220 // before it's received. | 228 // before it's received. |
221 scoped_ptr<webrtc::DesktopFrame> last_frame_; | 229 scoped_ptr<webrtc::DesktopFrame> last_frame_; |
222 | 230 |
223 DISALLOW_COPY_AND_ASSIGN(DesktopSessionAgent); | 231 DISALLOW_COPY_AND_ASSIGN(DesktopSessionAgent); |
224 }; | 232 }; |
225 | 233 |
226 } // namespace remoting | 234 } // namespace remoting |
227 | 235 |
228 #endif // REMOTING_HOST_DESKTOP_SESSION_AGENT_H_ | 236 #endif // REMOTING_HOST_DESKTOP_SESSION_AGENT_H_ |
OLD | NEW |