2 * Copyright (C) <2005> Julien Moutte <julien@moutte.net>
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.
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.
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.
20 #ifndef __GST_XVIMAGESINK_H__
21 #define __GST_XVIMAGESINK_H__
23 #include <gst/video/gstvideosink.h>
26 #include <sys/types.h>
29 #endif /* HAVE_XSHM */
32 #include <X11/Xutil.h>
35 #include <X11/extensions/XShm.h>
36 #endif /* HAVE_XSHM */
38 #include <X11/extensions/Xv.h>
39 #include <X11/extensions/Xvlib.h>
47 #define GST_TYPE_XVIMAGESINK \
48 (gst_xvimagesink_get_type())
49 #define GST_XVIMAGESINK(obj) \
50 (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_XVIMAGESINK, GstXvImageSink))
51 #define GST_XVIMAGESINK_CLASS(klass) \
52 (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_XVIMAGESINK, GstXvImageSinkClass))
53 #define GST_IS_XVIMAGESINK(obj) \
54 (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_XVIMAGESINK))
55 #define GST_IS_XVIMAGESINK_CLASS(klass) \
56 (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_XVIMAGESINK))
58 typedef struct _GstXContext GstXContext;
59 typedef struct _GstXWindow GstXWindow;
60 typedef struct _GstXvImageFormat GstXvImageFormat;
61 typedef struct _GstXvImageBuffer GstXvImageBuffer;
62 typedef struct _GstXvImageBufferClass GstXvImageBufferClass;
64 typedef struct _GstXvImageSink GstXvImageSink;
65 typedef struct _GstXvImageSinkClass GstXvImageSinkClass;
69 * @disp: the X11 Display of this context
70 * @screen: the default Screen of Display @disp
71 * @screen_num: the Screen number of @screen
72 * @visual: the default Visual of Screen @screen
73 * @root: the root Window of Display @disp
74 * @white: the value of a white pixel on Screen @screen
75 * @black: the value of a black pixel on Screen @screen
76 * @depth: the color depth of Display @disp
77 * @bpp: the number of bits per pixel on Display @disp
78 * @endianness: the endianness of image bytes on Display @disp
79 * @width: the width in pixels of Display @disp
80 * @height: the height in pixels of Display @disp
81 * @widthmm: the width in millimeters of Display @disp
82 * @heightmm: the height in millimeters of Display @disp
83 * @par: the pixel aspect ratio calculated from @width, @widthmm and @height,
85 * @use_xshm: used to known wether of not XShm extension is usable or not even
86 * if the Extension is present
87 * @xv_port_id: the XVideo port ID
88 * @im_format: used to store at least a valid format for XShm calls checks
89 * @formats_list: list of supported image formats on @xv_port_id
90 * @channels_list: list of #GstColorBalanceChannels
91 * @caps: the #GstCaps that Display @disp can accept
93 * Structure used to store various informations collected/calculated for a
113 gint widthmm, heightmm;
114 GValue *par; /* calculated pixel aspect ratio */
124 GList *channels_list;
128 /* Optimisation storage for buffer_alloc return */
137 * @win: the Window ID of this X11 window
138 * @width: the width in pixels of Window @win
139 * @height: the height in pixels of Window @win
140 * @internal: used to remember if Window @win was created internally or passed
141 * through the #GstXOverlay interface
142 * @gc: the Graphical Context of Window @win
144 * Structure used to store informations about a Window.
155 * @format: the image format
156 * @caps: generated #GstCaps for this image format
158 * Structure storing image format to #GstCaps association.
160 struct _GstXvImageFormat {
167 * @xvimagesink: a reference to our #GstXvImageSink
168 * @xvimage: the XvImage of this buffer
169 * @width: the width in pixels of XvImage @xvimage
170 * @height: the height in pixels of XvImage @xvimage
171 * @im_format: the image format of XvImage @xvimage
172 * @size: the size in bytes of XvImage @xvimage
174 * Subclass of #GstBuffer containing additional information about an XvImage.
176 struct _GstXvImageBuffer {
179 /* Reference to the xvimagesink we belong to */
180 GstXvImageSink *xvimagesink;
185 XShmSegmentInfo SHMInfo;
186 #endif /* HAVE_XSHM */
188 gint width, height, im_format;
194 * @display_name: the name of the Display we want to render to
195 * @xcontext: our instance's #GstXContext
196 * @xwindow: the #GstXWindow we are rendering to
197 * @xvimage: internal #GstXvImage used to store incoming buffers and render when
198 * not using the buffer_alloc optimization mechanism
199 * @cur_image: a reference to the last #GstXvImage that was put to @xwindow. It
200 * is used when Expose events are received to redraw the latest video frame
201 * @event_thread: a thread listening for events on @xwindow and handling them
202 * @running: used to inform @event_thread if it should run/shutdown
203 * @fps_n: the framerate fraction numerator
204 * @fps_d: the framerate fraction denominator
205 * @x_lock: used to protect X calls as we are not using the XLib in threaded
207 * @flow_lock: used to protect data flow routines from external calls such as
208 * events from @event_thread or methods from the #GstXOverlay interface
209 * @par: used to override calculated pixel aspect ratio from @xcontext
210 * @pool_lock: used to protect the buffer pool
211 * @image_pool: a list of #GstXvImageBuffer that could be reused at next buffer
213 * @synchronous: used to store if XSynchronous should be used or not (for
214 * debugging purpose only)
215 * @keep_aspect: used to remember if reverse negotiation scaling should respect
217 * @handle_events: used to know if we should handle select XEvents or not
218 * @brightness: used to store the user settings for color balance brightness
219 * @contrast: used to store the user settings for color balance contrast
220 * @hue: used to store the user settings for color balance hue
221 * @saturation: used to store the user settings for color balance saturation
222 * @cb_changed: used to store if the color balance settings where changed
223 * @video_width: the width of incoming video frames in pixels
224 * @video_height: the height of incoming video frames in pixels
226 * The #GstXvImageSink data structure.
228 struct _GstXvImageSink {
229 /* Our element stuff */
230 GstVideoSink videosink;
235 GstXContext *xcontext;
237 GstXvImageBuffer *xvimage;
238 GstXvImageBuffer *cur_image;
240 GThread *event_thread;
249 /* object-set pixel aspect ratio */
253 gboolean pool_invalid;
256 gboolean synchronous;
257 gboolean double_buffer;
258 gboolean keep_aspect;
259 gboolean redraw_border;
260 gboolean handle_events;
261 gboolean handle_expose;
269 /* size of incoming video, used as the size for XvImage */
270 guint video_width, video_height;
272 /* display sizes, used for clipping the image */
274 gint disp_width, disp_height;
276 /* port attributes */
277 gboolean autopaint_colorkey;
280 gboolean draw_borders;
283 gboolean have_autopaint_colorkey;
284 gboolean have_colorkey;
285 gboolean have_double_buffer;
287 /* stream metadata */
290 /* target video rectangle */
291 GstVideoRectangle render_rect;
292 gboolean have_render_rect;
295 struct _GstXvImageSinkClass {
296 GstVideoSinkClass parent_class;
299 GType gst_xvimagesink_get_type(void);
303 #endif /* __GST_XVIMAGESINK_H__ */