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>
40 #ifdef GST_EXT_XV_ENHANCEMENT
41 #include <X11/Xatom.h>
51 #define GST_TYPE_XVIMAGESINK \
52 (gst_xvimagesink_get_type())
53 #define GST_XVIMAGESINK(obj) \
54 (G_TYPE_CHECK_INSTANCE_CAST((obj), GST_TYPE_XVIMAGESINK, GstXvImageSink))
55 #define GST_XVIMAGESINK_CLASS(klass) \
56 (G_TYPE_CHECK_CLASS_CAST((klass), GST_TYPE_XVIMAGESINK, GstXvImageSinkClass))
57 #define GST_IS_XVIMAGESINK(obj) \
58 (G_TYPE_CHECK_INSTANCE_TYPE((obj), GST_TYPE_XVIMAGESINK))
59 #define GST_IS_XVIMAGESINK_CLASS(klass) \
60 (G_TYPE_CHECK_CLASS_TYPE((klass), GST_TYPE_XVIMAGESINK))
62 #ifdef GST_EXT_XV_ENHANCEMENT
63 #define XV_SCREEN_SIZE_WIDTH 4096
64 #define XV_SCREEN_SIZE_HEIGHT 4096
65 #endif /* GST_EXT_XV_ENHANCEMENT */
67 typedef struct _GstXContext GstXContext;
68 typedef struct _GstXWindow GstXWindow;
69 typedef struct _GstXvImageFormat GstXvImageFormat;
70 typedef struct _GstXvImageBuffer GstXvImageBuffer;
71 typedef struct _GstXvImageBufferClass GstXvImageBufferClass;
73 typedef struct _GstXvImageSink GstXvImageSink;
74 typedef struct _GstXvImageSinkClass GstXvImageSinkClass;
78 * @disp: the X11 Display of this context
79 * @screen: the default Screen of Display @disp
80 * @screen_num: the Screen number of @screen
81 * @visual: the default Visual of Screen @screen
82 * @root: the root Window of Display @disp
83 * @white: the value of a white pixel on Screen @screen
84 * @black: the value of a black pixel on Screen @screen
85 * @depth: the color depth of Display @disp
86 * @bpp: the number of bits per pixel on Display @disp
87 * @endianness: the endianness of image bytes on Display @disp
88 * @width: the width in pixels of Display @disp
89 * @height: the height in pixels of Display @disp
90 * @widthmm: the width in millimeters of Display @disp
91 * @heightmm: the height in millimeters of Display @disp
92 * @par: the pixel aspect ratio calculated from @width, @widthmm and @height,
94 * @use_xshm: used to known wether of not XShm extension is usable or not even
95 * if the Extension is present
96 * @xv_port_id: the XVideo port ID
97 * @im_format: used to store at least a valid format for XShm calls checks
98 * @formats_list: list of supported image formats on @xv_port_id
99 * @channels_list: list of #GstColorBalanceChannels
100 * @caps: the #GstCaps that Display @disp can accept
102 * Structure used to store various informations collected/calculated for a
105 struct _GstXContext {
122 gint widthmm, heightmm;
123 GValue *par; /* calculated pixel aspect ratio */
133 GList *channels_list;
137 /* Optimisation storage for buffer_alloc return */
146 * @win: the Window ID of this X11 window
147 * @width: the width in pixels of Window @win
148 * @height: the height in pixels of Window @win
149 * @internal: used to remember if Window @win was created internally or passed
150 * through the #GstXOverlay interface
151 * @gc: the Graphical Context of Window @win
153 * Structure used to store informations about a Window.
157 #ifdef GST_EXT_XV_ENHANCEMENT
167 * @format: the image format
168 * @caps: generated #GstCaps for this image format
170 * Structure storing image format to #GstCaps association.
172 struct _GstXvImageFormat {
179 * @xvimagesink: a reference to our #GstXvImageSink
180 * @xvimage: the XvImage of this buffer
181 * @width: the width in pixels of XvImage @xvimage
182 * @height: the height in pixels of XvImage @xvimage
183 * @im_format: the image format of XvImage @xvimage
184 * @size: the size in bytes of XvImage @xvimage
186 * Subclass of #GstBuffer containing additional information about an XvImage.
188 struct _GstXvImageBuffer {
191 /* Reference to the xvimagesink we belong to */
192 GstXvImageSink *xvimagesink;
197 XShmSegmentInfo SHMInfo;
198 #endif /* HAVE_XSHM */
200 gint width, height, im_format;
206 * @display_name: the name of the Display we want to render to
207 * @xcontext: our instance's #GstXContext
208 * @xwindow: the #GstXWindow we are rendering to
209 * @xvimage: internal #GstXvImage used to store incoming buffers and render when
210 * not using the buffer_alloc optimization mechanism
211 * @cur_image: a reference to the last #GstXvImage that was put to @xwindow. It
212 * is used when Expose events are received to redraw the latest video frame
213 * @event_thread: a thread listening for events on @xwindow and handling them
214 * @running: used to inform @event_thread if it should run/shutdown
215 * @fps_n: the framerate fraction numerator
216 * @fps_d: the framerate fraction denominator
217 * @x_lock: used to protect X calls as we are not using the XLib in threaded
219 * @flow_lock: used to protect data flow routines from external calls such as
220 * events from @event_thread or methods from the #GstXOverlay interface
221 * @par: used to override calculated pixel aspect ratio from @xcontext
222 * @pool_lock: used to protect the buffer pool
223 * @image_pool: a list of #GstXvImageBuffer that could be reused at next buffer
225 * @synchronous: used to store if XSynchronous should be used or not (for
226 * debugging purpose only)
227 * @keep_aspect: used to remember if reverse negotiation scaling should respect
229 * @handle_events: used to know if we should handle select XEvents or not
230 * @brightness: used to store the user settings for color balance brightness
231 * @contrast: used to store the user settings for color balance contrast
232 * @hue: used to store the user settings for color balance hue
233 * @saturation: used to store the user settings for color balance saturation
234 * @cb_changed: used to store if the color balance settings where changed
235 * @video_width: the width of incoming video frames in pixels
236 * @video_height: the height of incoming video frames in pixels
238 * The #GstXvImageSink data structure.
240 struct _GstXvImageSink {
241 /* Our element stuff */
242 GstVideoSink videosink;
247 GstXContext *xcontext;
249 GstXvImageBuffer *xvimage;
250 GstXvImageBuffer *cur_image;
252 GThread *event_thread;
261 /* object-set pixel aspect ratio */
265 gboolean pool_invalid;
268 gboolean synchronous;
269 gboolean double_buffer;
270 gboolean keep_aspect;
271 gboolean redraw_border;
272 gboolean handle_events;
273 gboolean handle_expose;
281 /* size of incoming video, used as the size for XvImage */
282 guint video_width, video_height;
284 /* display sizes, used for clipping the image */
286 gint disp_width, disp_height;
288 /* port attributes */
289 gboolean autopaint_colorkey;
292 gboolean draw_borders;
295 gboolean have_autopaint_colorkey;
296 gboolean have_colorkey;
297 gboolean have_double_buffer;
299 /* stream metadata */
302 /* target video rectangle */
303 GstVideoRectangle render_rect;
304 gboolean have_render_rect;
306 #ifdef GST_EXT_XV_ENHANCEMENT
309 guint display_geometry_method;
311 gboolean rotate_changed;
316 GstVideoRectangle dst_roi;
317 XImage* xim_transparenter;
321 /* needed if fourcc is one if S series */
323 guint aligned_height;
327 #ifdef GST_EXT_XV_ENHANCEMENT
328 /* max plane count *********************************************************/
329 #define MPLANE_IMGB_MAX_COUNT (4)
331 /* image buffer definition ***************************************************
333 +------------------------------------------+ ---
335 | uaddr[], index[] | |
336 | +---------------------------+ --- | |
338 | |<-------- width[] -------->| | | |
341 | | |height[]|elevation[]
346 | +---------------------------+ --- | |
348 +------------------------------------------+ ---
350 |<----------------- stride[] ------------------>|
352 typedef struct _GstMultiPlaneImageBuffer GstMultiPlaneImageBuffer;
353 struct _GstMultiPlaneImageBuffer
357 /* width of each image plane */
358 gint width[MPLANE_IMGB_MAX_COUNT];
359 /* height of each image plane */
360 gint height[MPLANE_IMGB_MAX_COUNT];
361 /* stride of each image plane */
362 gint stride[MPLANE_IMGB_MAX_COUNT];
363 /* elevation of each image plane */
364 gint elevation[MPLANE_IMGB_MAX_COUNT];
365 /* user space address of each image plane */
366 gpointer uaddr[MPLANE_IMGB_MAX_COUNT];
367 /* Index of real address of each image plane, if needs */
368 gpointer index[MPLANE_IMGB_MAX_COUNT];
369 /* left postion, if needs */
371 /* top position, if needs */
373 /* to align memory */
378 #endif /* GST_EXT_XV_ENHANCEMENT */
380 struct _GstXvImageSinkClass {
381 GstVideoSinkClass parent_class;
384 GType gst_xvimagesink_get_type(void);
388 #endif /* __GST_XVIMAGESINK_H__ */