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.
5 #ifndef REMOTING_HOST_IPC_VIDEO_FRAME_CAPTURER_H_
6 #define REMOTING_HOST_IPC_VIDEO_FRAME_CAPTURER_H_
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"
18 struct MouseCursorShape;
23 class DesktopSessionProxy;
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 {
29 explicit IpcVideoFrameCapturer(
30 scoped_refptr<DesktopSessionProxy> desktop_session_proxy);
31 virtual ~IpcVideoFrameCapturer();
33 // webrtc::DesktopCapturer interface.
34 virtual void Start(Callback* callback) OVERRIDE;
35 virtual void Capture(const webrtc::DesktopRegion& region) OVERRIDE;
37 // webrtc::ScreenCapturer interface.
38 virtual void SetMouseShapeObserver(
39 MouseShapeObserver* mouse_shape_observer) OVERRIDE;
41 // Called when a video |frame| has been captured.
42 void OnCaptureCompleted(scoped_ptr<webrtc::DesktopFrame> frame);
44 // Called when the cursor shape has changed.
45 void OnCursorShapeChanged(scoped_ptr<webrtc::MouseCursorShape> cursor_shape);
48 // Points to the callback passed to webrtc::ScreenCapturer::Start().
49 webrtc::ScreenCapturer::Callback* callback_;
51 MouseShapeObserver* mouse_shape_observer_;
53 // Wraps the IPC channel to the desktop session agent.
54 scoped_refptr<DesktopSessionProxy> desktop_session_proxy_;
56 // Set to true when a frame is being captured.
57 bool capture_pending_;
59 // Used to cancel tasks pending on the capturer when it is stopped.
60 base::WeakPtrFactory<IpcVideoFrameCapturer> weak_factory_;
62 DISALLOW_COPY_AND_ASSIGN(IpcVideoFrameCapturer);
65 } // namespace remoting
67 #endif // REMOTING_HOST_IPC_VIDEO_FRAME_CAPTURER_H_