Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Side by Side Diff: remoting/host/desktop_session_agent.h

Issue 11413022: DesktopSessionAgent now hosts the video capturer and provides necessary plumbing to drive it via an… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 <list>
9
8 #include "base/basictypes.h" 10 #include "base/basictypes.h"
9 #include "base/callback.h" 11 #include "base/callback.h"
10 #include "base/compiler_specific.h" 12 #include "base/compiler_specific.h"
11 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
12 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
13 #include "ipc/ipc_listener.h" 15 #include "ipc/ipc_listener.h"
14 #include "ipc/ipc_platform_file.h" 16 #include "ipc/ipc_platform_file.h"
17 #include "remoting/base/shared_buffer.h"
18 #include "remoting/base/shared_buffer_factory.h"
19 #include "remoting/host/video_frame_capturer.h"
20 #include "third_party/skia/include/core/SkRect.h"
21 #include "third_party/skia/include/core/SkRegion.h"
15 22
16 namespace IPC { 23 namespace IPC {
17 class ChannelProxy; 24 class ChannelProxy;
18 class Message; 25 class Message;
19 } // namespace IPC 26 } // namespace IPC
20 27
21 namespace remoting { 28 namespace remoting {
22 29
23 class AutoThreadTaskRunner; 30 class AutoThreadTaskRunner;
24 31
25 // Provides screen/audio capturing and input injection services for 32 // Provides screen/audio capturing and input injection services for
26 // the network process. 33 // the network process.
27 class DesktopSessionAgent : public IPC::Listener { 34 class DesktopSessionAgent
35 : public base::RefCountedThreadSafe<DesktopSessionAgent>,
36 public IPC::Listener,
37 public SharedBufferFactory,
38 public VideoFrameCapturer::Delegate {
28 public: 39 public:
29 static scoped_ptr<DesktopSessionAgent> Create( 40 static scoped_refptr<DesktopSessionAgent> Create(
30 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, 41 scoped_refptr<AutoThreadTaskRunner> caller_task_runner,
31 scoped_refptr<AutoThreadTaskRunner> io_task_runner); 42 scoped_refptr<AutoThreadTaskRunner> io_task_runner,
32 43 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner);
33 virtual ~DesktopSessionAgent();
34 44
35 // IPC::Listener implementation. 45 // IPC::Listener implementation.
36 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 46 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
37 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE; 47 virtual void OnChannelConnected(int32 peer_pid) OVERRIDE;
38 virtual void OnChannelError() OVERRIDE; 48 virtual void OnChannelError() OVERRIDE;
39 49
40 // Creates the screen/audio recorders, input stubs and the IPC channel to be 50 // SharedBufferFactory implementation.
41 // used to access them. Returns a handle of the client end of the IPC channel 51 virtual scoped_refptr<SharedBuffer> CreateSharedBuffer(uint32 size) OVERRIDE;
42 // pipe to be forwarder to the corresponding desktop environment. 52 virtual void ReleaseSharedBuffer(scoped_refptr<SharedBuffer> buffer) OVERRIDE;
43 bool Start(const base::Closure& done_task, 53
54 // VideoFrameCapturer::Delegate implementation.
55 virtual void OnCaptureCompleted(
56 scoped_refptr<CaptureData> capture_data) OVERRIDE;
57 virtual void OnCursorShapeChanged(
58 scoped_ptr<protocol::CursorShapeInfo> cursor_shape) OVERRIDE;
59
60 // Creates desktop integration components and a connected IPC channel to be
61 // used to access them. The client end of the channel is returned in
62 // the variable pointed by |desktop_pipe_out|.
63 //
64 // |disconnected_task| is invoked on |caller_task_runner_| to notify
65 // the caller that the network-to-desktop channel has been disconnected.
66 bool Start(const base::Closure& disconnected_task,
44 IPC::PlatformFileForTransit* desktop_pipe_out); 67 IPC::PlatformFileForTransit* desktop_pipe_out);
45 68
69 // Stops the agent asynchronously.
70 void Stop();
71
46 protected: 72 protected:
47 DesktopSessionAgent( 73 DesktopSessionAgent(
48 scoped_refptr<AutoThreadTaskRunner> caller_task_runner, 74 scoped_refptr<AutoThreadTaskRunner> caller_task_runner,
49 scoped_refptr<AutoThreadTaskRunner> io_task_runner); 75 scoped_refptr<AutoThreadTaskRunner> io_task_runner,
76 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner);
50 77
51 // Creates a pre-connected IPC channel to be used to access the screen/audio 78 friend class base::RefCountedThreadSafe<DesktopSessionAgent>;
79 virtual ~DesktopSessionAgent();
80
81 // Creates a connected IPC channel to be used to access the screen/audio
52 // recorders and input stubs. 82 // recorders and input stubs.
53 virtual bool DoCreateNetworkChannel( 83 virtual bool CreateChannelForNetworkProcess(
54 IPC::PlatformFileForTransit* client_out, 84 IPC::PlatformFileForTransit* client_out,
55 scoped_ptr<IPC::ChannelProxy>* server_out) = 0; 85 scoped_ptr<IPC::ChannelProxy>* server_out) = 0;
56 86
87 void InvalidateRegion(scoped_ptr<SkRegion> invalid_region);
88
89 // Handles CaptureFrame requests from the client.
90 void OnCaptureFrame();
91
92 // Handles InvalidateRegion requests from the client.
93 void OnInvalidateRegion(const std::vector<SkIRect>& invalid_rects);
94
95 // Handles SharedBufferCreated notification from the client.
96 void OnSharedBufferCreated(intptr_t id);
97
98 // Sends a message to the network process.
99 void SendToNetwork(IPC::Message* message);
100
101 // Posted to |video_capture_task_runner_| task runner to start the video
102 // capturer.
103 void StartVideoCapturer();
104
105 // Posted to |video_capture_task_runner_| task runner to stop the video
106 // capturer.
107 void StopVideoCapturer();
108
109 // Getters providing access to the task runners for platform-specific derived
110 // classes.
57 scoped_refptr<AutoThreadTaskRunner> caller_task_runner() const { 111 scoped_refptr<AutoThreadTaskRunner> caller_task_runner() const {
58 return caller_task_runner_; 112 return caller_task_runner_;
59 } 113 }
60 114
61 scoped_refptr<AutoThreadTaskRunner> io_task_runner() const { 115 scoped_refptr<AutoThreadTaskRunner> io_task_runner() const {
62 return io_task_runner_; 116 return io_task_runner_;
63 } 117 }
64 118
119 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner() const {
120 return video_capture_task_runner_;
121 }
122
65 private: 123 private:
66 // Task runner on which public methods of this class should be called. 124 // Task runner on which public methods of this class should be called.
67 scoped_refptr<AutoThreadTaskRunner> caller_task_runner_; 125 scoped_refptr<AutoThreadTaskRunner> caller_task_runner_;
68 126
69 // Message loop used by the IPC channel. 127 // Message loop used by the IPC channel.
70 scoped_refptr<AutoThreadTaskRunner> io_task_runner_; 128 scoped_refptr<AutoThreadTaskRunner> io_task_runner_;
71 129
72 // Run on |caller_task_runner_| to notify the caller that |this| has been 130 // Task runner dedicated to running themethods of the video capturer.
73 // stopped. 131 scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner_;
74 base::Closure done_task_; 132
133 // Runs on |caller_task_runner_| to notify the caller that the network-to-
134 // desktop channel has been disconnected.
135 base::Closure disconnected_task_;
75 136
76 // IPC channel connecting the desktop process with the network process. 137 // IPC channel connecting the desktop process with the network process.
77 scoped_ptr<IPC::ChannelProxy> network_channel_; 138 scoped_ptr<IPC::ChannelProxy> network_channel_;
78 139
140 // List of the shared buffers registered via |SharedBufferFactory| interface.
141 typedef std::list<scoped_refptr<SharedBuffer> > SharedBuffers;
142 SharedBuffers shared_buffers_;
143
144 scoped_ptr<VideoFrameCapturer> video_capturer_;
145
79 DISALLOW_COPY_AND_ASSIGN(DesktopSessionAgent); 146 DISALLOW_COPY_AND_ASSIGN(DesktopSessionAgent);
80 }; 147 };
81 148
82 } // namespace remoting 149 } // namespace remoting
83 150
84 #endif // REMOTING_HOST_DESKTOP_SESSION_AGENT_H_ 151 #endif // REMOTING_HOST_DESKTOP_SESSION_AGENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698