1 /* GStreamer 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> 5 * 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. 10 * 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. 15 * 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. 20 */ 21 #ifndef _D3DHELPERS_H_ 22 #define _D3DHELPERS_H_ 23 24 #include <gst/gst.h> 25 #include <gst/video/video.h> 26 27 #include <windows.h> 28 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 34 # else 35 # define DECLARE_INTERFACE_IID_(i,b,d) _COM_interface i : public b 36 # endif 37 # elif !defined(DECLARE_INTERFACE_IID_) 38 # define DECLARE_INTERFACE_IID_(i,b,d) DECLARE_INTERFACE(i) 39 # endif 40 # endif 41 # if !defined(__MSABI_LONG) 42 # define __MSABI_LONG(x) x ## l 43 # endif 44 #endif 45 46 #include <d3d9.h> 47 48 typedef struct _GstD3DVideoSink GstD3DVideoSink; 49 typedef struct _GstD3DVideoSinkClass GstD3DVideoSinkClass; 50 51 typedef struct _GstD3DDisplayDevice { 52 UINT adapter; 53 D3DFORMAT format; 54 D3DTEXTUREFILTERTYPE filter_type; 55 LPDIRECT3DDEVICE9 d3d_device; 56 D3DPRESENT_PARAMETERS present_params; 57 } GstD3DDisplayDevice; 58 59 typedef struct _GstD3DDataClass { 60 guint refs; 61 LPDIRECT3D9 d3d; 62 GstD3DDisplayDevice device; 63 64 /* Track individual sink instances */ 65 GList * sink_list; 66 gboolean device_lost; 67 68 /* Window class for internal windows */ 69 WNDCLASS wnd_class; 70 71 /* Windows Message Handling */ 72 GThread * thread; 73 HWND hidden_window; 74 gboolean running; 75 gboolean error_exit; 76 } GstD3DDataClass; 77 78 typedef struct _GstD3DData { 79 /* Window Proc Stuff */ 80 HWND external_window_handle; 81 HWND window_handle; 82 gboolean window_is_internal; 83 WNDPROC orig_wnd_proc; 84 85 /* Render Constructs */ 86 LPDIRECT3DSWAPCHAIN9 swapchain; 87 LPDIRECT3DSURFACE9 surface; 88 D3DTEXTUREFILTERTYPE filtertype; 89 D3DFORMAT format; 90 GstVideoRectangle * render_rect; 91 gboolean renderable; 92 gboolean device_lost; 93 } GstD3DData; 94 95 gboolean d3d_class_init(GstD3DVideoSink * klass); 96 void d3d_class_destroy(GstD3DVideoSink * klass); 97 98 gboolean d3d_prepare_window(GstD3DVideoSink * sink); 99 gboolean d3d_stop(GstD3DVideoSink * sink); 100 void d3d_set_window_handle(GstD3DVideoSink * sink, guintptr window_id, gboolean internal); 101 void d3d_set_render_rectangle(GstD3DVideoSink * sink); 102 void d3d_expose_window(GstD3DVideoSink * sink); 103 GstFlowReturn d3d_render_buffer(GstD3DVideoSink * sink, GstBuffer * buf); 104 GstCaps * d3d_supported_caps(GstD3DVideoSink * sink); 105 gboolean d3d_set_render_format(GstD3DVideoSink * sink); 106 107 #define GST_TYPE_D3DSURFACE_BUFFER_POOL (gst_d3dsurface_buffer_pool_get_type()) 108 #define GST_IS_D3DSURFACE_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_D3DSURFACE_BUFFER_POOL)) 109 #define GST_D3DSURFACE_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_D3DSURFACE_BUFFER_POOL, GstD3DSurfaceBufferPool)) 110 #define GST_D3DSURFACE_BUFFER_POOL_CAST(obj) ((GstD3DSurfaceBufferPool*)(obj)) 111 112 typedef struct _GstD3DSurfaceBufferPool { 113 GstVideoBufferPool parent; 114 115 GstD3DVideoSink *sink; 116 GstVideoInfo info; 117 gboolean add_metavideo; 118 119 GstAllocator *allocator; 120 } GstD3DSurfaceBufferPool; 121 122 typedef struct _GstD3DSurfaceBufferPoolClass { 123 GstVideoBufferPoolClass parent_class; 124 } GstD3DSurfaceBufferPoolClass; 125 126 GType gst_d3dsurface_meta_api_get_type (void); 127 #define GST_D3DSURFACE_META_API_TYPE (gst_d3dsurface_meta_api_get_type()) 128 const GstMetaInfo * gst_d3dsurface_meta_get_info (void); 129 #define GST_D3DSURFACE_META_INFO (gst_d3dsurface_meta_get_info()) 130 131 #define gst_buffer_get_d3dsurface_meta(b) ((GstD3DSurfaceMeta*)gst_buffer_get_meta((b),GST_D3DSURFACE_META_API_TYPE)) 132 133 GType gst_d3dsurface_buffer_pool_get_type (void); 134 GstBufferPool * gst_d3dsurface_buffer_pool_new (GstD3DVideoSink * sink); 135 136 #endif /* _D3DHELPERS_H_ */ 137