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