• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #ifndef REMOTING_HOST_IPC_VIDEO_FRAME_CAPTURER_H_
6 #define REMOTING_HOST_IPC_VIDEO_FRAME_CAPTURER_H_
7 
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/weak_ptr.h"
10 #include "base/memory/scoped_ptr.h"
11 #include "third_party/webrtc/modules/desktop_capture/screen_capturer.h"
12 
13 namespace IPC {
14 class Message;
15 }  // namespace IPC
16 
17 namespace media {
18 struct MouseCursorShape;
19 }  // namespace media
20 
21 namespace remoting {
22 
23 class DesktopSessionProxy;
24 
25 // Routes webrtc::ScreenCapturer calls though the IPC channel to the desktop
26 // session agent running in the desktop integration process.
27 class IpcVideoFrameCapturer : public webrtc::ScreenCapturer {
28  public:
29   explicit IpcVideoFrameCapturer(
30       scoped_refptr<DesktopSessionProxy> desktop_session_proxy);
31   virtual ~IpcVideoFrameCapturer();
32 
33   // webrtc::DesktopCapturer interface.
34   virtual void Start(Callback* callback) OVERRIDE;
35   virtual void Capture(const webrtc::DesktopRegion& region) OVERRIDE;
36 
37   // webrtc::ScreenCapturer interface.
38   virtual void SetMouseShapeObserver(
39       MouseShapeObserver* mouse_shape_observer) OVERRIDE;
40 
41   virtual bool GetScreenList(ScreenList* screens) OVERRIDE;
42 
43   virtual bool SelectScreen(webrtc::ScreenId id) OVERRIDE;
44 
45   // Called when a video |frame| has been captured.
46   void OnCaptureCompleted(scoped_ptr<webrtc::DesktopFrame> frame);
47 
48   // Called when the cursor shape has changed.
49   void OnCursorShapeChanged(scoped_ptr<webrtc::MouseCursorShape> cursor_shape);
50 
51  private:
52   // Points to the callback passed to webrtc::ScreenCapturer::Start().
53   webrtc::ScreenCapturer::Callback* callback_;
54 
55   MouseShapeObserver* mouse_shape_observer_;
56 
57   // Wraps the IPC channel to the desktop session agent.
58   scoped_refptr<DesktopSessionProxy> desktop_session_proxy_;
59 
60   // Set to true when a frame is being captured.
61   bool capture_pending_;
62 
63   // Used to cancel tasks pending on the capturer when it is stopped.
64   base::WeakPtrFactory<IpcVideoFrameCapturer> weak_factory_;
65 
66   DISALLOW_COPY_AND_ASSIGN(IpcVideoFrameCapturer);
67 };
68 
69 }  // namespace remoting
70 
71 #endif  // REMOTING_HOST_IPC_VIDEO_FRAME_CAPTURER_H_
72