2 * Copyright (C) 2012 Roland Krikava <info@bluedigits.com>
3 * Copyright (C) 2010-2011 David Hoyt <dhoyt@hoytsoft.org>
4 * Copyright (C) 2010 Andoni Morales <ylatuya@gmail.com>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
21 #ifndef _D3DHELPERS_H_
22 #define _D3DHELPERS_H_
25 #include <gst/video/video.h>
29 #if defined(__MINGW32__)
30 # ifndef _OBJC_NO_COM_
31 # if defined(__cplusplus) && !defined(CINTERFACE)
32 # if defined(__GNUC__) && __GNUC__ < 3 && !defined(NOCOMATTRIBUTE)
33 # define DECLARE_INTERFACE_IID_(i,b,d) _COM_interface __attribute__((com_interface)) i : public b
35 # define DECLARE_INTERFACE_IID_(i,b,d) _COM_interface i : public b
37 # elif !defined(DECLARE_INTERFACE_IID_)
38 # define DECLARE_INTERFACE_IID_(i,b,d) DECLARE_INTERFACE(i)
41 # if !defined(__MSABI_LONG)
42 # define __MSABI_LONG(x) x ## l
48 typedef struct _GstD3DVideoSink GstD3DVideoSink;
49 typedef struct _GstD3DVideoSinkClass GstD3DVideoSinkClass;
51 typedef struct _GstD3DDisplayDevice {
54 D3DTEXTUREFILTERTYPE filter_type;
55 LPDIRECT3DDEVICE9 d3d_device;
56 D3DPRESENT_PARAMETERS present_params;
57 } GstD3DDisplayDevice;
59 typedef struct _GstD3DDataClass {
62 GstD3DDisplayDevice device;
63 GList *supported_formats;
65 /* Track individual sink instances */
69 /* Window class for internal windows */
72 /* Windows Message Handling */
74 GMutex thread_start_mutex;
75 GCond thread_start_cond;
77 gboolean thread_started;
78 gboolean thread_error_exit;
81 typedef struct _GstD3DData {
82 /* Window Proc Stuff */
83 HWND external_window_handle;
85 gboolean window_is_internal;
86 WNDPROC orig_wnd_proc;
88 /* Render Constructs */
89 LPDIRECT3DSWAPCHAIN9 swapchain;
90 LPDIRECT3DSURFACE9 surface;
91 D3DTEXTUREFILTERTYPE filtertype;
93 GstVideoRectangle * render_rect;
97 /* list of GstD3DVideoSinkOverlay structs */
99 gboolean overlay_needs_resize;
102 gboolean d3d_class_init(GstD3DVideoSink * klass);
103 void d3d_class_destroy(GstD3DVideoSink * klass);
105 gboolean d3d_prepare_window(GstD3DVideoSink * sink);
106 gboolean d3d_stop(GstD3DVideoSink * sink);
107 void d3d_set_window_handle(GstD3DVideoSink * sink, guintptr window_id, gboolean internal);
108 void d3d_set_render_rectangle(GstD3DVideoSink * sink);
109 void d3d_expose_window(GstD3DVideoSink * sink);
110 GstFlowReturn d3d_render_buffer(GstD3DVideoSink * sink, GstBuffer * buf);
111 GstCaps * d3d_supported_caps(GstD3DVideoSink * sink);
112 gboolean d3d_set_render_format(GstD3DVideoSink * sink);
113 gboolean d3d_get_hwnd_window_size (HWND hwnd, gint * width, gint * height);
115 #define GST_TYPE_D3DSURFACE_BUFFER_POOL (gst_d3dsurface_buffer_pool_get_type())
116 #define GST_IS_D3DSURFACE_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_D3DSURFACE_BUFFER_POOL))
117 #define GST_D3DSURFACE_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_D3DSURFACE_BUFFER_POOL, GstD3DSurfaceBufferPool))
118 #define GST_D3DSURFACE_BUFFER_POOL_CAST(obj) ((GstD3DSurfaceBufferPool*)(obj))
120 typedef struct _GstD3DSurfaceBufferPool {
121 GstVideoBufferPool parent;
123 GstD3DVideoSink *sink;
125 gboolean add_metavideo;
127 GstAllocator *allocator;
128 } GstD3DSurfaceBufferPool;
130 typedef struct _GstD3DSurfaceBufferPoolClass {
131 GstVideoBufferPoolClass parent_class;
132 } GstD3DSurfaceBufferPoolClass;
134 GType gst_d3dsurface_meta_api_get_type (void);
135 #define GST_D3DSURFACE_META_API_TYPE (gst_d3dsurface_meta_api_get_type())
136 const GstMetaInfo * gst_d3dsurface_meta_get_info (void);
137 #define GST_D3DSURFACE_META_INFO (gst_d3dsurface_meta_get_info())
139 #define gst_buffer_get_d3dsurface_meta(b) ((GstD3DSurfaceMeta*)gst_buffer_get_meta((b),GST_D3DSURFACE_META_API_TYPE))
141 GType gst_d3dsurface_buffer_pool_get_type (void);
142 GstBufferPool * gst_d3dsurface_buffer_pool_new (GstD3DVideoSink * sink);
144 #endif /* _D3DHELPERS_H_ */