| 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_PROXY_H_ | 5 #ifndef REMOTING_HOST_DESKTOP_SESSION_PROXY_H_ |
| 6 #define REMOTING_HOST_DESKTOP_SESSION_PROXY_H_ | 6 #define REMOTING_HOST_DESKTOP_SESSION_PROXY_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/weak_ptr.h" | 13 #include "base/memory/weak_ptr.h" |
| 14 #include "base/process.h" | 14 #include "base/process.h" |
| 15 #include "base/sequenced_task_runner_helpers.h" | 15 #include "base/sequenced_task_runner_helpers.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 "media/video/capture/screen/screen_capturer.h" | 18 #include "media/video/capture/screen/screen_capturer.h" |
| 19 #include "media/video/capture/screen/shared_buffer.h" | |
| 20 #include "remoting/host/audio_capturer.h" | 19 #include "remoting/host/audio_capturer.h" |
| 21 #include "remoting/host/desktop_environment.h" | 20 #include "remoting/host/desktop_environment.h" |
| 22 #include "remoting/host/screen_resolution.h" | 21 #include "remoting/host/screen_resolution.h" |
| 23 #include "remoting/proto/event.pb.h" | 22 #include "remoting/proto/event.pb.h" |
| 24 #include "remoting/protocol/clipboard_stub.h" | 23 #include "remoting/protocol/clipboard_stub.h" |
| 25 #include "third_party/skia/include/core/SkRegion.h" | 24 #include "third_party/skia/include/core/SkRegion.h" |
| 26 | 25 |
| 27 namespace base { | 26 namespace base { |
| 28 class SingleThreadTaskRunner; | 27 class SingleThreadTaskRunner; |
| 29 } // namespace base | 28 } // namespace base |
| 30 | 29 |
| 31 namespace IPC { | 30 namespace IPC { |
| 32 class ChannelProxy; | 31 class ChannelProxy; |
| 33 class Message; | 32 class Message; |
| 34 } // namespace IPC | 33 } // namespace IPC |
| 35 | 34 |
| 36 struct SerializedCapturedData; | 35 struct SerializedDesktopFrame; |
| 37 | 36 |
| 38 namespace remoting { | 37 namespace remoting { |
| 39 | 38 |
| 40 class AudioPacket; | 39 class AudioPacket; |
| 41 class ClientSession; | 40 class ClientSession; |
| 42 class ClientSessionControl; | 41 class ClientSessionControl; |
| 43 class DesktopSessionConnector; | 42 class DesktopSessionConnector; |
| 44 struct DesktopSessionProxyTraits; | 43 struct DesktopSessionProxyTraits; |
| 45 class IpcAudioCapturer; | 44 class IpcAudioCapturer; |
| 46 class IpcVideoFrameCapturer; | 45 class IpcVideoFrameCapturer; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 void InjectKeyEvent(const protocol::KeyEvent& event); | 116 void InjectKeyEvent(const protocol::KeyEvent& event); |
| 118 void InjectMouseEvent(const protocol::MouseEvent& event); | 117 void InjectMouseEvent(const protocol::MouseEvent& event); |
| 119 void StartInputInjector(scoped_ptr<protocol::ClipboardStub> client_clipboard); | 118 void StartInputInjector(scoped_ptr<protocol::ClipboardStub> client_clipboard); |
| 120 | 119 |
| 121 // API used to implement the SessionController interface. | 120 // API used to implement the SessionController interface. |
| 122 void SetScreenResolution(const ScreenResolution& resolution); | 121 void SetScreenResolution(const ScreenResolution& resolution); |
| 123 | 122 |
| 124 private: | 123 private: |
| 125 friend class base::DeleteHelper<DesktopSessionProxy>; | 124 friend class base::DeleteHelper<DesktopSessionProxy>; |
| 126 friend struct DesktopSessionProxyTraits; | 125 friend struct DesktopSessionProxyTraits; |
| 126 |
| 127 class IpcSharedBufferCore; |
| 128 class IpcSharedBuffer; |
| 129 typedef std::map<int, scoped_refptr<IpcSharedBufferCore> > SharedBuffers; |
| 130 |
| 127 virtual ~DesktopSessionProxy(); | 131 virtual ~DesktopSessionProxy(); |
| 128 | 132 |
| 129 // Returns a shared buffer from the list of known buffers. | 133 // Returns a shared buffer from the list of known buffers. |
| 130 scoped_refptr<media::SharedBuffer> GetSharedBuffer(int id); | 134 scoped_refptr<IpcSharedBufferCore> GetSharedBufferCore(int id); |
| 131 | 135 |
| 132 // Handles AudioPacket notification from the desktop session agent. | 136 // Handles AudioPacket notification from the desktop session agent. |
| 133 void OnAudioPacket(const std::string& serialized_packet); | 137 void OnAudioPacket(const std::string& serialized_packet); |
| 134 | 138 |
| 135 // Registers a new shared buffer created by the desktop process. | 139 // Registers a new shared buffer created by the desktop process. |
| 136 void OnCreateSharedBuffer(int id, | 140 void OnCreateSharedBuffer(int id, |
| 137 IPC::PlatformFileForTransit handle, | 141 IPC::PlatformFileForTransit handle, |
| 138 uint32 size); | 142 uint32 size); |
| 139 | 143 |
| 140 // Drops a cached reference to the shared buffer. | 144 // Drops a cached reference to the shared buffer. |
| 141 void OnReleaseSharedBuffer(int id); | 145 void OnReleaseSharedBuffer(int id); |
| 142 | 146 |
| 143 // Handles CaptureCompleted notification from the desktop session agent. | 147 // Handles CaptureCompleted notification from the desktop session agent. |
| 144 void OnCaptureCompleted(const SerializedCapturedData& serialized_data); | 148 void OnCaptureCompleted(const SerializedDesktopFrame& serialized_frame); |
| 145 | 149 |
| 146 // Handles CursorShapeChanged notification from the desktop session agent. | 150 // Handles CursorShapeChanged notification from the desktop session agent. |
| 147 void OnCursorShapeChanged(const media::MouseCursorShape& cursor_shape); | 151 void OnCursorShapeChanged(const media::MouseCursorShape& cursor_shape); |
| 148 | 152 |
| 149 // Handles InjectClipboardEvent request from the desktop integration process. | 153 // Handles InjectClipboardEvent request from the desktop integration process. |
| 150 void OnInjectClipboardEvent(const std::string& serialized_event); | 154 void OnInjectClipboardEvent(const std::string& serialized_event); |
| 151 | 155 |
| 152 // Posts OnCaptureCompleted() to |video_capturer_| on the video thread, | 156 // Posts OnCaptureCompleted() to |video_capturer_| on the video thread, |
| 153 // passing |capture_data|. | 157 // passing |frame|. |
| 154 void PostCaptureCompleted( | 158 void PostCaptureCompleted(scoped_ptr<webrtc::DesktopFrame> frame); |
| 155 scoped_refptr<media::ScreenCaptureData> capture_data); | |
| 156 | 159 |
| 157 // Posts OnCursorShapeChanged() to |video_capturer_| on the video thread, | 160 // Posts OnCursorShapeChanged() to |video_capturer_| on the video thread, |
| 158 // passing |cursor_shape|. | 161 // passing |cursor_shape|. |
| 159 void PostCursorShape(scoped_ptr<media::MouseCursorShape> cursor_shape); | 162 void PostCursorShape(scoped_ptr<media::MouseCursorShape> cursor_shape); |
| 160 | 163 |
| 161 // Sends a message to the desktop session agent. The message is silently | 164 // Sends a message to the desktop session agent. The message is silently |
| 162 // deleted if the channel is broken. | 165 // deleted if the channel is broken. |
| 163 void SendToDesktop(IPC::Message* message); | 166 void SendToDesktop(IPC::Message* message); |
| 164 | 167 |
| 165 // Task runners: | 168 // Task runners: |
| (...skipping 24 matching lines...) Expand all Loading... |
| 190 base::WeakPtr<IpcVideoFrameCapturer> video_capturer_; | 193 base::WeakPtr<IpcVideoFrameCapturer> video_capturer_; |
| 191 | 194 |
| 192 // IPC channel to the desktop session agent. | 195 // IPC channel to the desktop session agent. |
| 193 scoped_ptr<IPC::ChannelProxy> desktop_channel_; | 196 scoped_ptr<IPC::ChannelProxy> desktop_channel_; |
| 194 | 197 |
| 195 // Handle of the desktop process. | 198 // Handle of the desktop process. |
| 196 base::ProcessHandle desktop_process_; | 199 base::ProcessHandle desktop_process_; |
| 197 | 200 |
| 198 int pending_capture_frame_requests_; | 201 int pending_capture_frame_requests_; |
| 199 | 202 |
| 200 typedef std::map<int, scoped_refptr<media::SharedBuffer> > SharedBuffers; | 203 // Shared memory buffers by Id. Each buffer is owned by the corresponding |
| 204 // frame. |
| 201 SharedBuffers shared_buffers_; | 205 SharedBuffers shared_buffers_; |
| 202 | 206 |
| 203 // Keeps the desired screen resolution so it can be passed to a newly attached | 207 // Keeps the desired screen resolution so it can be passed to a newly attached |
| 204 // desktop session agent. | 208 // desktop session agent. |
| 205 ScreenResolution screen_resolution_; | 209 ScreenResolution screen_resolution_; |
| 206 | 210 |
| 207 // True if |this| has been connected to the desktop session. | 211 // True if |this| has been connected to the desktop session. |
| 208 bool is_desktop_session_connected_; | 212 bool is_desktop_session_connected_; |
| 209 | 213 |
| 210 bool virtual_terminal_; | 214 bool virtual_terminal_; |
| 211 | 215 |
| 212 DISALLOW_COPY_AND_ASSIGN(DesktopSessionProxy); | 216 DISALLOW_COPY_AND_ASSIGN(DesktopSessionProxy); |
| 213 }; | 217 }; |
| 214 | 218 |
| 215 // Destroys |DesktopSessionProxy| instances on the caller's thread. | 219 // Destroys |DesktopSessionProxy| instances on the caller's thread. |
| 216 struct DesktopSessionProxyTraits { | 220 struct DesktopSessionProxyTraits { |
| 217 static void Destruct(const DesktopSessionProxy* desktop_session_proxy); | 221 static void Destruct(const DesktopSessionProxy* desktop_session_proxy); |
| 218 }; | 222 }; |
| 219 | 223 |
| 220 } // namespace remoting | 224 } // namespace remoting |
| 221 | 225 |
| 222 #endif // REMOTING_HOST_DESKTOP_SESSION_PROXY_H_ | 226 #endif // REMOTING_HOST_DESKTOP_SESSION_PROXY_H_ |
| OLD | NEW |