Tizen 2.0 Release
[framework/multimedia/gst-plugins-bad0.10.git] / sys / d3dvideosink / d3dvideosink.h
1 /* GStreamer
2  * Copyright (C) 2010 David Hoyt <dhoyt@hoytsoft.org>
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., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */
19
20 #ifndef __D3DVIDEOSINK_H__
21 #define __D3DVIDEOSINK_H__
22
23 #include <gst/gst.h>
24 #include <gst/video/video.h>
25 #include <gst/video/gstvideosink.h>
26 #include <gst/interfaces/xoverlay.h>
27 #include <gst/interfaces/navigation.h>
28
29 #include <windows.h>
30 #include <d3d9.h>
31 #include <d3dx9tex.h>
32
33 #include "directx/directx.h"
34
35 #ifdef _MSC_VER
36 #pragma warning( disable : 4090 4024)
37 #endif
38
39 G_BEGIN_DECLS
40 #define GST_TYPE_D3DVIDEOSINK                     (gst_d3dvideosink_get_type())
41 #define GST_D3DVIDEOSINK(obj)                     (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_D3DVIDEOSINK,GstD3DVideoSink))
42 #define GST_D3DVIDEOSINK_CLASS(klass)             (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_D3DVIDEOSINK,GstD3DVideoSinkClass))
43 #define GST_D3DVIDEOSINK_GET_CLASS(obj)           (GST_D3DVIDEOSINK_CLASS(G_OBJECT_GET_CLASS(obj)))
44 #define GST_IS_D3DVIDEOSINK(obj)                  (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_D3DVIDEOSINK))
45 #define GST_IS_D3DVIDEOSINK_CLASS(klass)          (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_D3DVIDEOSINK))
46
47 typedef struct _GstD3DVideoSink GstD3DVideoSink;
48 typedef struct _GstD3DVideoSinkClass GstD3DVideoSinkClass;
49
50 #define GST_D3DVIDEOSINK_SWAP_CHAIN_LOCK(sink)    g_mutex_lock (GST_D3DVIDEOSINK (sink)->d3d_swap_chain_lock);
51 #define GST_D3DVIDEOSINK_SWAP_CHAIN_UNLOCK(sink)  g_mutex_unlock (GST_D3DVIDEOSINK (sink)->d3d_swap_chain_lock);
52
53 struct _GstD3DVideoSink
54 {
55   GstVideoSink sink;
56
57   /* source rectangle */
58   gint width;
59   gint height;
60
61   GstVideoFormat format;
62
63   gboolean enable_navigation_events;
64  
65   gboolean keep_aspect_ratio;
66   GValue *par; 
67
68   /* If the window is closed, we set this and error out */
69   gboolean window_closed;
70
71   /* The video window set through GstXOverlay */
72   HWND window_handle;
73   
74   /* If we created the window, it needs to be closed in ::stop() */
75   gboolean is_new_window;
76
77   /* If we create our own window, we run it from another thread */
78   GThread *window_thread;
79   HANDLE window_created_signal;
80
81   /* If we use an app-supplied window, we need to hook its WNDPROC */
82   WNDPROC prevWndProc;
83   gboolean is_hooked;
84
85   GMutex *d3d_swap_chain_lock;
86   LPDIRECT3DSWAPCHAIN9 d3d_swap_chain;
87   LPDIRECT3DSURFACE9 d3d_offscreen_surface;
88
89   D3DFORMAT d3dformat;
90   D3DFORMAT d3dfourcc;
91   D3DTEXTUREFILTERTYPE d3dfiltertype;
92 };
93
94 struct _GstD3DVideoSinkClass
95 {
96   GstVideoSinkClass parent_class;
97
98   gboolean is_directx_supported;
99   gint directx_version;
100   DirectXAPI *directx_api;
101 };
102
103 GType gst_d3dvideosink_get_type (void);
104
105 G_END_DECLS
106 #endif /* __D3DVIDEOSINK_H__ */