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

Unified 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: Created 8 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: remoting/host/desktop_session_agent.h
diff --git a/remoting/host/desktop_session_agent.h b/remoting/host/desktop_session_agent.h
index 569dfd56bd74040e6f0e0013e7e72347efabdc8e..483c65f51fb57879690fff8437ad25ae49615a00 100644
--- a/remoting/host/desktop_session_agent.h
+++ b/remoting/host/desktop_session_agent.h
@@ -5,6 +5,8 @@
#ifndef REMOTING_HOST_DESKTOP_SESSION_AGENT_H_
#define REMOTING_HOST_DESKTOP_SESSION_AGENT_H_
+#include <list>
+
#include "base/basictypes.h"
#include "base/callback.h"
#include "base/compiler_specific.h"
@@ -12,6 +14,11 @@
#include "base/memory/scoped_ptr.h"
#include "ipc/ipc_listener.h"
#include "ipc/ipc_platform_file.h"
+#include "remoting/base/shared_buffer.h"
+#include "remoting/host/shared_buffer_sender.h"
+#include "remoting/host/video_frame_capturer.h"
+#include "third_party/skia/include/core/SkRect.h"
+#include "third_party/skia/include/core/SkRegion.h"
namespace IPC {
class ChannelProxy;
@@ -24,29 +31,50 @@ class AutoThreadTaskRunner;
// Provides screen/audio capturing and input injection services for
// the network process.
-class DesktopSessionAgent : public IPC::Listener {
+class DesktopSessionAgent
+ : public base::RefCountedThreadSafe<DesktopSessionAgent>,
+ public IPC::Listener,
+ public SharedBufferSender,
+ public VideoFrameCapturer::Delegate {
public:
- static scoped_ptr<DesktopSessionAgent> Create(
+ static scoped_refptr<DesktopSessionAgent> Create(
scoped_refptr<AutoThreadTaskRunner> caller_task_runner,
- scoped_refptr<AutoThreadTaskRunner> io_task_runner);
-
- virtual ~DesktopSessionAgent();
+ scoped_refptr<AutoThreadTaskRunner> io_task_runner,
+ scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner);
// IPC::Listener implementation.
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
virtual void OnChannelConnected(int32 peer_pid) OVERRIDE;
virtual void OnChannelError() OVERRIDE;
+ // SharedBufferSender implementation.
+ virtual void RegisterSharedBuffer(
+ scoped_refptr<SharedBuffer> buffer) OVERRIDE;
+ virtual void DropSharedBuffer(intptr_t id) OVERRIDE;
+
+ // VideoFrameCapturer::Delegate implementation.
Wez 2012/11/16 23:37:31 We should follow up to re-name VideoFrameCapturer:
alexeypa (please no reviews) 2012/11/19 21:46:25 Ack.
+ virtual void OnCaptureCompleted(
+ scoped_refptr<CaptureData> capture_data) OVERRIDE;
+ virtual void OnCursorShapeChanged(
+ scoped_ptr<protocol::CursorShapeInfo> cursor_shape) OVERRIDE;
+
// Creates the screen/audio recorders, input stubs and the IPC channel to be
// used to access them. Returns a handle of the client end of the IPC channel
// pipe to be forwarder to the corresponding desktop environment.
Wez 2012/11/16 23:37:31 typo: forwarded. I'd suggest rewording this to ma
alexeypa (please no reviews) 2012/11/19 21:46:25 Done.
bool Start(const base::Closure& done_task,
IPC::PlatformFileForTransit* desktop_pipe_out);
+ // Stops the agent asynchronously.
Wez 2012/11/16 23:37:31 How does the caller know when this object is compl
alexeypa (please no reviews) 2012/11/19 21:46:25 I renamed |done_task| so it is not getting associa
+ void Stop();
+
protected:
DesktopSessionAgent(
scoped_refptr<AutoThreadTaskRunner> caller_task_runner,
- scoped_refptr<AutoThreadTaskRunner> io_task_runner);
+ scoped_refptr<AutoThreadTaskRunner> io_task_runner,
+ scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner);
+
+ friend class base::RefCountedThreadSafe<DesktopSessionAgent>;
+ virtual ~DesktopSessionAgent();
// Creates a pre-connected IPC channel to be used to access the screen/audio
Wez 2012/11/16 23:37:31 nit: What does "pre-connected" mean? Do you just
alexeypa (please no reviews) 2012/11/19 21:46:25 Done.
// recorders and input stubs.
@@ -54,6 +82,24 @@ class DesktopSessionAgent : public IPC::Listener {
IPC::PlatformFileForTransit* client_out,
scoped_ptr<IPC::ChannelProxy>* server_out) = 0;
+ void InvalidateRegion(scoped_ptr<SkRegion> invalid_region);
Wez 2012/11/16 23:37:31 Why not fold this in to OnInvalidateRegion?
alexeypa (please no reviews) 2012/11/19 21:46:25 To avoid creating a copy of a bunch of rects. OnIn
+
+ // Implements VideoFrameCapturer::CaptureInvalidRegion.
Wez 2012/11/16 23:37:31 nit: You mean "Implements the CaptureInvalidRegion
alexeypa (please no reviews) 2012/11/19 21:46:25 Done.
+ void OnCaptureFrame();
+
+ // Implements VideoFrameCapturer::InvalidateRegion.
+ void OnInvalidateRegion(const std::vector<SkIRect>& invalid_region);
+
+ // Handles the ChromotingNetworkDesktopMsg_SharedBufferRegistered notification
+ // from the network process.
+ void OnSharedBufferRegistered(intptr_t id);
+
+ // Sends a message to the network process.
+ void SendToNetwork(IPC::Message* message);
+
+ void StartVideoCapturer();
+ void StopVideoCapturer();
Wez 2012/11/16 23:37:31 nit: Add comments to explain the function of these
alexeypa (please no reviews) 2012/11/19 21:46:25 Done. What there methods do is documented by their
Wez 2012/11/20 07:05:39 You only need these methods so you have something
alexeypa (please no reviews) 2012/11/20 20:15:17 Done.
+
scoped_refptr<AutoThreadTaskRunner> caller_task_runner() const {
Wez 2012/11/16 23:37:31 Add a comment explaining that these getters provid
alexeypa (please no reviews) 2012/11/19 21:46:25 I don't see any value in such a comment. There are
Wez 2012/11/20 07:05:39 Right; a comment should describe why we need them,
alexeypa (please no reviews) 2012/11/20 20:15:17 I added the comment but I still think it is not su
return caller_task_runner_;
}
@@ -62,6 +108,10 @@ class DesktopSessionAgent : public IPC::Listener {
return io_task_runner_;
}
+ scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner() const {
+ return video_capture_task_runner_;
+ }
+
private:
// Task runner on which public methods of this class should be called.
scoped_refptr<AutoThreadTaskRunner> caller_task_runner_;
@@ -69,6 +119,9 @@ class DesktopSessionAgent : public IPC::Listener {
// Message loop used by the IPC channel.
scoped_refptr<AutoThreadTaskRunner> io_task_runner_;
+ // Task runner on which video public methods of this class should be called.
Wez 2012/11/16 23:37:31 Is this correct? Isn't this the thread on which th
alexeypa (please no reviews) 2012/11/19 21:46:25 Done.
+ scoped_refptr<AutoThreadTaskRunner> video_capture_task_runner_;
+
// Run on |caller_task_runner_| to notify the caller that |this| has been
// stopped.
base::Closure done_task_;
@@ -76,6 +129,12 @@ class DesktopSessionAgent : public IPC::Listener {
// IPC channel connecting the desktop process with the network process.
scoped_ptr<IPC::ChannelProxy> network_channel_;
+ // List of the shared buffers registered via |SharedBufferSender| interface.
+ typedef std::list<scoped_refptr<SharedBuffer> > SharedBuffers;
+ SharedBuffers shared_buffers_;
+
+ scoped_ptr<VideoFrameCapturer> video_capturer_;
+
DISALLOW_COPY_AND_ASSIGN(DesktopSessionAgent);
};

Powered by Google App Engine
This is Rietveld 408576698