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