1 /* GStreamer
2 * Copyright (C) 2007 Haakon Sporsheim <hakon.sporsheim@tandberg.com>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18 */
19
20 #ifdef HAVE_CONFIG_H
21 #include "config.h"
22 #endif
23 #include "gstwinscreencap.h"
24 #include "gstgdiscreencapsrc.h"
25 #include "gstdx9screencapsrc.h"
26
27 #ifdef HAVE_DXGI_CAP
28 #include "gstdxgiscreencapsrc.h"
29
30 GST_DEBUG_CATEGORY (gst_dxgi_screen_cap_src_debug);
31 #endif
32
33 static BOOL CALLBACK
_diplay_monitor_enum(HMONITOR hMon,HDC hdc,LPRECT rect,LPARAM param)34 _diplay_monitor_enum (HMONITOR hMon, HDC hdc, LPRECT rect, LPARAM param)
35 {
36 LPRECT *pp_rect = (LPRECT *) param;
37 CopyRect (*pp_rect, rect);
38 (*pp_rect)++;
39 return TRUE;
40 }
41
42 RECT
gst_win32_get_monitor_rect(UINT index)43 gst_win32_get_monitor_rect (UINT index)
44 {
45 RECT ret_rect;
46 LPRECT data;
47
48 data = (LPRECT) malloc (sizeof (RECT) * GetSystemMetrics (SM_CMONITORS));
49 if (data) {
50 LPRECT tmp = data;
51 EnumDisplayMonitors (NULL, NULL, _diplay_monitor_enum, (LPARAM) & tmp);
52
53 ret_rect = data[index];
54 free (data);
55 } else {
56 ZeroMemory (&ret_rect, sizeof (RECT));
57 }
58
59 return ret_rect;
60 }
61
62 static gboolean
plugin_init(GstPlugin * plugin)63 plugin_init (GstPlugin * plugin)
64 {
65 if (!gst_element_register (plugin, "gdiscreencapsrc",
66 GST_RANK_NONE, GST_TYPE_GDISCREENCAPSRC)) {
67 return FALSE;
68 }
69
70 if (!gst_element_register (plugin, "dx9screencapsrc",
71 GST_RANK_NONE, GST_TYPE_DX9SCREENCAPSRC)) {
72 return FALSE;
73 }
74 #ifdef HAVE_DXGI_CAP
75 GST_DEBUG_CATEGORY_INIT (gst_dxgi_screen_cap_src_debug,
76 "dxgiscreencapsrc", 0, "DirectX DXGI screen capture source");
77 gst_dxgi_screen_cap_src_register (plugin, GST_RANK_NONE);
78 #endif
79
80 return TRUE;
81 }
82
83 GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
84 GST_VERSION_MINOR,
85 winscreencap,
86 "Screen capture plugin for Windows",
87 plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN)
88