| 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 | 135 |
| 133 // Sends a message to the network process. | 136 // Sends a message to the network process. |
| 134 void SendToNetwork(IPC::Message* message); | 137 void SendToNetwork(IPC::Message* message); |
| 135 | 138 |
| 136 // Posted to |audio_capture_task_runner_| to start the audio capturer. | 139 // Posted to |audio_capture_task_runner_| to start the audio capturer. |
| 137 void StartAudioCapturer(); | 140 void StartAudioCapturer(); |
| 138 | 141 |
| 139 // Posted to |audio_capture_task_runner_| to stop the audio capturer. | 142 // Posted to |audio_capture_task_runner_| to stop the audio capturer. |
| 140 void StopAudioCapturer(); | 143 void StopAudioCapturer(); |
| 141 | 144 |
| 142 // Posted to |video_capture_task_runner_| to start the video capturer. | 145 // Posted to |video_capture_task_runner_| to start the video capturer and the |
| 143 void StartVideoCapturer(); | 146 // mouse cursor monitor. |
| 147 void StartVideoCapturerAndMouseMonitor(); |
| 144 | 148 |
| 145 // Posted to |video_capture_task_runner_| to stop the video capturer. | 149 // Posted to |video_capture_task_runner_| to stop the video capturer and the |
| 146 void StopVideoCapturer(); | 150 // mouse cursor monitor. |
| 151 void StopVideoCapturerAndMouseMonitor(); |
| 147 | 152 |
| 148 private: | 153 private: |
| 149 class SharedBuffer; | 154 class SharedBuffer; |
| 150 friend class SharedBuffer; | 155 friend class SharedBuffer; |
| 151 | 156 |
| 152 // Called by SharedBuffer when it's destroyed. | 157 // Called by SharedBuffer when it's destroyed. |
| 153 void OnSharedBufferDeleted(int id); | 158 void OnSharedBufferDeleted(int id); |
| 154 | 159 |
| 155 // Closes |desktop_pipe_| if it is open. | 160 // Closes |desktop_pipe_| if it is open. |
| 156 void CloseDesktopPipeHandle(); | 161 void CloseDesktopPipeHandle(); |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 210 | 215 |
| 211 // The number of currently allocated shared buffers. | 216 // The number of currently allocated shared buffers. |
| 212 int shared_buffers_; | 217 int shared_buffers_; |
| 213 | 218 |
| 214 // True if the desktop session agent has been started. | 219 // True if the desktop session agent has been started. |
| 215 bool started_; | 220 bool started_; |
| 216 | 221 |
| 217 // Captures the screen. | 222 // Captures the screen. |
| 218 scoped_ptr<webrtc::ScreenCapturer> video_capturer_; | 223 scoped_ptr<webrtc::ScreenCapturer> video_capturer_; |
| 219 | 224 |
| 225 // Captures mouse shapes. |
| 226 scoped_ptr<webrtc::MouseCursorMonitor> mouse_cursor_monitor_; |
| 227 |
| 220 // Keep reference to the last frame sent to make sure shared buffer is alive | 228 // Keep reference to the last frame sent to make sure shared buffer is alive |
| 221 // before it's received. | 229 // before it's received. |
| 222 scoped_ptr<webrtc::DesktopFrame> last_frame_; | 230 scoped_ptr<webrtc::DesktopFrame> last_frame_; |
| 223 | 231 |
| 224 DISALLOW_COPY_AND_ASSIGN(DesktopSessionAgent); | 232 DISALLOW_COPY_AND_ASSIGN(DesktopSessionAgent); |
| 225 }; | 233 }; |
| 226 | 234 |
| 227 } // namespace remoting | 235 } // namespace remoting |
| 228 | 236 |
| 229 #endif // REMOTING_HOST_DESKTOP_SESSION_AGENT_H_ | 237 #endif // REMOTING_HOST_DESKTOP_SESSION_AGENT_H_ |
| OLD | NEW |