• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2013 The WebRTC project authors. All Rights Reserved.
3  *
4  *  Use of this source code is governed by a BSD-style license
5  *  that can be found in the LICENSE file in the root of the source
6  *  tree. An additional intellectual property rights grant can be found
7  *  in the file PATENTS.  All contributing project authors may
8  *  be found in the AUTHORS file in the root of the source tree.
9  */
10 
11 #ifndef WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_AND_CURSOR_COMPOSER_H_
12 #define WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_AND_CURSOR_COMPOSER_H_
13 
14 #include "webrtc/base/scoped_ptr.h"
15 #include "webrtc/modules/desktop_capture/desktop_capturer.h"
16 #include "webrtc/modules/desktop_capture/mouse_cursor_monitor.h"
17 
18 namespace webrtc {
19 
20 // A wrapper for DesktopCapturer that also captures mouse using specified
21 // MouseCursorMonitor and renders it on the generated streams.
22 class DesktopAndCursorComposer : public DesktopCapturer,
23                             public DesktopCapturer::Callback,
24                             public MouseCursorMonitor::Callback {
25  public:
26   // Creates a new blender that captures mouse cursor using |mouse_monitor| and
27   // renders it into the frames generated by |desktop_capturer|. If
28   // |mouse_monitor| is NULL the frames are passed unmodified. Takes ownership
29   // of both arguments.
30   DesktopAndCursorComposer(DesktopCapturer* desktop_capturer,
31                       MouseCursorMonitor* mouse_monitor);
32   virtual ~DesktopAndCursorComposer();
33 
34   // DesktopCapturer interface.
35   void Start(DesktopCapturer::Callback* callback) override;
36   void Capture(const DesktopRegion& region) override;
37   void SetExcludedWindow(WindowId window) override;
38 
39  private:
40   // DesktopCapturer::Callback interface.
41   SharedMemory* CreateSharedMemory(size_t size) override;
42   void OnCaptureCompleted(DesktopFrame* frame) override;
43 
44   // MouseCursorMonitor::Callback interface.
45   void OnMouseCursor(MouseCursor* cursor) override;
46   void OnMouseCursorPosition(MouseCursorMonitor::CursorState state,
47                              const DesktopVector& position) override;
48 
49   rtc::scoped_ptr<DesktopCapturer> desktop_capturer_;
50   rtc::scoped_ptr<MouseCursorMonitor> mouse_monitor_;
51 
52   DesktopCapturer::Callback* callback_;
53 
54   rtc::scoped_ptr<MouseCursor> cursor_;
55   MouseCursorMonitor::CursorState cursor_state_;
56   DesktopVector cursor_position_;
57 
58   RTC_DISALLOW_COPY_AND_ASSIGN(DesktopAndCursorComposer);
59 };
60 
61 }  // namespace webrtc
62 
63 #endif  // WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_AND_CURSOR_COMPOSER_H_
64