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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
/* GStreamer
* Copyright (C) 2012 Roland Krikava <info@bluedigits.com>
* Copyright (C) 2010-2011 David Hoyt <dhoyt@hoytsoft.org>
* Copyright (C) 2010 Andoni Morales <ylatuya@gmail.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., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef _D3DHELPERS_H_
#define _D3DHELPERS_H_
#include <gst/gst.h>
#include <gst/video/video.h>
#include <windows.h>
#if defined(__MINGW32__)
# ifndef _OBJC_NO_COM_
# if defined(__cplusplus) && !defined(CINTERFACE)
# if defined(__GNUC__) && __GNUC__ < 3 && !defined(NOCOMATTRIBUTE)
# define DECLARE_INTERFACE_IID_(i,b,d) _COM_interface __attribute__((com_interface)) i : public b
# else
# define DECLARE_INTERFACE_IID_(i,b,d) _COM_interface i : public b
# endif
# elif !defined(DECLARE_INTERFACE_IID_)
# define DECLARE_INTERFACE_IID_(i,b,d) DECLARE_INTERFACE(i)
# endif
# endif
# if !defined(__MSABI_LONG)
# define __MSABI_LONG(x) x ## l
# endif
#endif
#include <d3d9.h>
#include <d3dx9tex.h>
typedef struct _GstD3DVideoSink GstD3DVideoSink;
typedef struct _GstD3DVideoSinkClass GstD3DVideoSinkClass;
typedef struct _GstD3DDisplayDevice {
UINT adapter;
D3DFORMAT format;
D3DTEXTUREFILTERTYPE filter_type;
LPDIRECT3DDEVICE9 d3d_device;
D3DPRESENT_PARAMETERS present_params;
} GstD3DDisplayDevice;
typedef struct _GstD3DDataClass {
guint refs;
LPDIRECT3D9 d3d;
GstD3DDisplayDevice device;
/* Track individual sink instances */
GList * sink_list;
gboolean device_lost;
/* Window class for internal windows */
WNDCLASS wnd_class;
/* Windows Message Handling */
GThread * thread;
HWND hidden_window;
gboolean running;
gboolean error_exit;
} GstD3DDataClass;
typedef struct _GstD3DData {
/* Window Proc Stuff */
HWND external_window_handle;
HWND window_handle;
gboolean window_is_internal;
WNDPROC orig_wnd_proc;
/* Render Constructs */
LPDIRECT3DSWAPCHAIN9 swapchain;
LPDIRECT3DSURFACE9 surface;
D3DTEXTUREFILTERTYPE filtertype;
D3DFORMAT format;
GstVideoRectangle * render_rect;
gboolean renderable;
gboolean device_lost;
} GstD3DData;
gboolean d3d_class_init(GstD3DVideoSink * klass);
void d3d_class_destroy(GstD3DVideoSink * klass);
gboolean d3d_prepare_window(GstD3DVideoSink * sink);
gboolean d3d_stop(GstD3DVideoSink * sink);
void d3d_set_window_handle(GstD3DVideoSink * sink, guintptr window_id, gboolean internal);
void d3d_set_render_rectangle(GstD3DVideoSink * sink);
void d3d_expose_window(GstD3DVideoSink * sink);
GstFlowReturn d3d_render_buffer(GstD3DVideoSink * sink, GstBuffer * buf);
GstCaps * d3d_supported_caps(GstD3DVideoSink * sink);
gboolean d3d_set_render_format(GstD3DVideoSink * sink);
#define GST_TYPE_D3DSURFACE_BUFFER_POOL (gst_d3dsurface_buffer_pool_get_type())
#define GST_IS_D3DSURFACE_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_D3DSURFACE_BUFFER_POOL))
#define GST_D3DSURFACE_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_D3DSURFACE_BUFFER_POOL, GstD3DSurfaceBufferPool))
#define GST_D3DSURFACE_BUFFER_POOL_CAST(obj) ((GstD3DSurfaceBufferPool*)(obj))
typedef struct _GstD3DSurfaceBufferPool {
GstVideoBufferPool parent;
GstD3DVideoSink *sink;
GstVideoInfo info;
gboolean add_metavideo;
GstAllocator *allocator;
} GstD3DSurfaceBufferPool;
typedef struct _GstD3DSurfaceBufferPoolClass {
GstVideoBufferPoolClass parent_class;
} GstD3DSurfaceBufferPoolClass;
GType gst_d3dsurface_meta_api_get_type (void);
#define GST_D3DSURFACE_META_API_TYPE (gst_d3dsurface_meta_api_get_type())
const GstMetaInfo * gst_d3dsurface_meta_get_info (void);
#define GST_D3DSURFACE_META_INFO (gst_d3dsurface_meta_get_info())
#define gst_buffer_get_d3dsurface_meta(b) ((GstD3DSurfaceMeta*)gst_buffer_get_meta((b),GST_D3DSURFACE_META_API_TYPE))
GType gst_d3dsurface_buffer_pool_get_type (void);
GstBufferPool * gst_d3dsurface_buffer_pool_new (GstD3DVideoSink * sink);
#endif /* _D3DHELPERS_H_ */
|