directdrwasink: call previous WndProc if any
[platform/upstream/gstreamer.git] / sys / directdraw / gstdirectdrawsink.h
1 /* GStreamer
2  * Copyright (C) 2005 Sebastien Moutte <sebastien@moutte.net>
3  * Copyright (C) 2007 Pioneers of the Inevitable <songbird@songbirdnest.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Library General Public
7  * License as published by the Free Software Foundation; either
8  * version 2 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13  * Library General Public License for more details.
14  *
15  * You should have received a copy of the GNU Library General Public
16  * License along with this library; if not, write to the
17  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
18  * Boston, MA 02110-1301, USA.
19  *
20  * The development of this code was made possible due to the involvement
21  * of Pioneers of the Inevitable, the creators of the Songbird Music player
22  *
23  */
24
25 #ifndef __GST_DIRECTDRAWSINK_H__
26 #define __GST_DIRECTDRAWSINK_H__
27
28 #define DIRECTDRAW_VERSION 0x0700
29
30 #include <gst/gst.h>
31 #include <gst/video/gstvideosink.h>
32 #include <gst/interfaces/xoverlay.h>
33 #include <gst/interfaces/navigation.h>
34
35 #include <windows.h>
36 #include <ddraw.h>
37
38 G_BEGIN_DECLS
39
40 #define GST_TYPE_DIRECTDRAW_SINK            (gst_directdraw_sink_get_type())
41 #define GST_DIRECTDRAW_SINK(obj)            (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DIRECTDRAW_SINK,GstDirectDrawSink))
42 #define GST_DIRECTDRAW_SINK_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DIRECTDRAW_SINK,GstDirectDrawSinkClass))
43 #define GST_IS_DIRECTDRAW_SINK(obj)         (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DIRECTDRAW_SINK))
44 #define GST_IS_DIRECTDRAW_SINK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DIRECTDRAW_SINK))
45 typedef struct _GstDirectDrawSink GstDirectDrawSink;
46 typedef struct _GstDirectDrawSinkClass GstDirectDrawSinkClass;
47
48 #define GST_TYPE_DDRAWSURFACE (gst_ddrawsurface_get_type())
49 #define GST_IS_DDRAWSURFACE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_DDRAWSURFACE))
50 #define GST_DDRAWSURFACE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_DDRAWSURFACE, GstDDrawSurface))
51
52 typedef struct _GstDDrawSurface GstDDrawSurface;
53
54 struct _GstDDrawSurface
55 {
56   /* Extension of GstBuffer to store directdraw surfaces */
57   GstBuffer buffer;
58
59   /* directdraw surface */
60   LPDIRECTDRAWSURFACE surface;
61
62   /* surface dimensions */
63   gint width;
64   gint height;
65
66   /*TRUE when surface is locked*/
67   gboolean locked;
68
69   /*TRUE when surface is using a system memory buffer 
70   (i'm using system memory when directdraw optimized pitch is not the same as the GStreamer one)*/
71   gboolean system_memory;
72
73   /* pixel format of the encapsulated surface */
74   DDPIXELFORMAT dd_pixel_format;
75
76   /* pointer to parent */
77   GstDirectDrawSink *ddrawsink;
78 };
79
80 struct _GstDirectDrawSink
81 {
82   GstVideoSink videosink;
83
84   /* directdraw offscreen surfaces pool */
85   GSList *buffer_pool;
86   GMutex *pool_lock;
87
88   /* directdraw objects */
89   LPDIRECTDRAW ddraw_object;
90   LPDIRECTDRAWSURFACE primary_surface;
91   LPDIRECTDRAWSURFACE offscreen_surface;
92   LPDIRECTDRAWCLIPPER clipper; 
93
94   /* last buffer displayed (used for XOverlay interface expose method) */
95   GstBuffer * last_buffer;
96
97   /* directdraw caps */
98   GstCaps *caps;
99
100   /* video window management */
101   HWND video_window;
102   gboolean our_video_window;
103   HANDLE window_created_signal;
104   WNDPROC previous_wndproc;
105   LONG_PTR previous_user_data;
106   
107   /* video properties */
108   gint video_width, video_height;
109   gint out_width, out_height;
110   gint fps_n;
111   gint fps_d;
112
113   /* properties */
114   gboolean keep_aspect_ratio;
115
116   /*pixel format */
117   DDPIXELFORMAT dd_pixel_format;
118
119   /* thread processing our default window messages */
120   GThread *window_thread;
121
122   /* TRUE when directdraw object is set up */
123   gboolean setup;
124
125   /* TRUE if the hardware supports blitting from one colorspace to another */
126   gboolean can_blit_between_colorspace;
127
128   /* This flag is used to force re-creation of our offscreen surface.
129    * It's needed when hardware doesn't support fourcc blit and the bit depth
130    * of the current display mode changes.
131    */
132   gboolean must_recreate_offscreen;
133 };
134
135 struct _GstDirectDrawSinkClass
136 {
137   GstVideoSinkClass parent_class;
138 };
139
140 GType gst_directdraw_sink_get_type (void);
141
142 G_END_DECLS
143
144 #endif /* __GST_DIRECTDRAWSINK_H__ */