blob: 4f7c85bde3e5359e507014fe311f517427ea266b [file] [log] [blame]
sergeyu@chromium.orgba6d56c2013-10-16 02:48:41 +00001/*
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/modules/desktop_capture/desktop_capturer.h"
15#include "webrtc/modules/desktop_capture/mouse_cursor_monitor.h"
16#include "webrtc/system_wrappers/interface/scoped_ptr.h"
17
18namespace webrtc {
19
20// A wrapper for DesktopCapturer that also captures mouse using specified
21// MouseCursorMonitor and renders it on the generated streams.
22class 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 virtual void Start(DesktopCapturer::Callback* callback) OVERRIDE;
36 virtual void Capture(const DesktopRegion& region) OVERRIDE;
37
38 private:
39 // DesktopCapturer::Callback interface.
40 virtual SharedMemory* CreateSharedMemory(size_t size) OVERRIDE;
41 virtual void OnCaptureCompleted(DesktopFrame* frame) OVERRIDE;
42
43 // MouseCursorMonitor::Callback interface.
44 virtual void OnMouseCursor(MouseCursor* cursor) OVERRIDE;
45 virtual void OnMouseCursorPosition(MouseCursorMonitor::CursorState state,
46 const DesktopVector& position) OVERRIDE;
47
48 scoped_ptr<DesktopCapturer> desktop_capturer_;
49 scoped_ptr<MouseCursorMonitor> mouse_monitor_;
50
51 DesktopCapturer::Callback* callback_;
52
53 scoped_ptr<MouseCursor> cursor_;
54 MouseCursorMonitor::CursorState cursor_state_;
55 DesktopVector cursor_position_;
56
57 DISALLOW_COPY_AND_ASSIGN(DesktopAndCursorComposer);
58};
59
60} // namespace webrtc
61
62#endif // WEBRTC_MODULES_DESKTOP_CAPTURE_DESKTOP_AND_CURSOR_COMPOSER_H_