summaryrefslogtreecommitdiff
path: root/sys/winscreencap/gstwinscreencap.c
blob: f24939699df0874000faaeee507c7043a2e353f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/* GStreamer
 * Copyright (C) 2007 Haakon Sporsheim <hakon.sporsheim@tandberg.com>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
 * Boston, MA 02110-1301, USA.
 */

#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstwinscreencap.h"
#include "gstgdiscreencapsrc.h"
#include "gstdx9screencapsrc.h"

#ifdef HAVE_DXGI_CAP
#include <versionhelpers.h>
#include "gstdxgiscreencapsrc.h"

GST_DEBUG_CATEGORY (gst_dxgi_screen_cap_src_debug);
#endif

static BOOL CALLBACK
_diplay_monitor_enum (HMONITOR hMon, HDC hdc, LPRECT rect, LPARAM param)
{
  LPRECT *pp_rect = (LPRECT *) param;
  CopyRect (*pp_rect, rect);
  (*pp_rect)++;
  return TRUE;
}

RECT
gst_win32_get_monitor_rect (UINT index)
{
  RECT ret_rect;
  LPRECT data;

  data = (LPRECT) malloc (sizeof (RECT) * GetSystemMetrics (SM_CMONITORS));
  if (data) {
    LPRECT tmp = data;
    EnumDisplayMonitors (NULL, NULL, _diplay_monitor_enum, (LPARAM) & tmp);

    ret_rect = data[index];
    free (data);
  } else {
    ZeroMemory (&ret_rect, sizeof (RECT));
  }

  return ret_rect;
}

static gboolean
plugin_init (GstPlugin * plugin)
{
  if (!gst_element_register (plugin, "gdiscreencapsrc",
          GST_RANK_NONE, GST_TYPE_GDISCREENCAPSRC)) {
    return FALSE;
  }

  if (!gst_element_register (plugin, "dx9screencapsrc",
          GST_RANK_NONE, GST_TYPE_DX9SCREENCAPSRC)) {
    return FALSE;
  }
#ifdef HAVE_DXGI_CAP
  if (IsWindows8OrGreater ()) {
    GST_DEBUG_CATEGORY_INIT (gst_dxgi_screen_cap_src_debug,
        "dxgiscreencapsrc", 0, "DirectX DXGI screen capture source");

    /* dxgiscreencapsrc is needs Windows8 or later. */
    if (!gst_element_register (plugin, "dxgiscreencapsrc",
            GST_RANK_NONE, GST_TYPE_DXGI_SCREEN_CAP_SRC)) {
      return FALSE;
    }
  }
#endif

  return TRUE;
}

GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
    GST_VERSION_MINOR,
    winscreencap,
    "Screen capture plugin for Windows",
    plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)