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 virtual bool GetScreenList(ScreenList
* screens
) OVERRIDE
;
43 virtual bool SelectScreen(webrtc::ScreenId id
) OVERRIDE
;
45 // Called when a video |frame| has been captured.
46 void OnCaptureCompleted(scoped_ptr
<webrtc::DesktopFrame
> frame
);
48 // Called when the cursor shape has changed.
49 void OnCursorShapeChanged(scoped_ptr
<webrtc::MouseCursorShape
> cursor_shape
);
52 // Points to the callback passed to webrtc::ScreenCapturer::Start().
53 webrtc::ScreenCapturer::Callback
* callback_
;
55 MouseShapeObserver
* mouse_shape_observer_
;
57 // Wraps the IPC channel to the desktop session agent.
58 scoped_refptr
<DesktopSessionProxy
> desktop_session_proxy_
;
60 // Set to true when a frame is being captured.
61 bool capture_pending_
;
63 // Used to cancel tasks pending on the capturer when it is stopped.
64 base::WeakPtrFactory
<IpcVideoFrameCapturer
> weak_factory_
;
66 DISALLOW_COPY_AND_ASSIGN(IpcVideoFrameCapturer
);
69 } // namespace remoting
71 #endif // REMOTING_HOST_IPC_VIDEO_FRAME_CAPTURER_H_