2 * Copyright (C) <2005> Luca Ognibene <luogni@tin.it>
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., 51 Franklin St, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
20 #ifndef __GST_XIMAGEUTIL_H__
21 #define __GST_XIMAGEUTIL_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 */
43 typedef struct _GstXContext GstXContext;
44 typedef struct _GstXWindow GstXWindow;
45 typedef struct _GstXImage GstXImage;
46 typedef struct _GstMetaXImage GstMetaXImage;
48 /* Global X Context stuff */
51 * @disp: the X11 Display of this context
52 * @screen: the default Screen of Display @disp
53 * @visual: the default Visual of Screen @screen
54 * @root: the root Window of Display @disp
55 * @white: the value of a white pixel on Screen @screen
56 * @black: the value of a black pixel on Screen @screen
57 * @depth: the color depth of Display @disp
58 * @bpp: the number of bits per pixel on Display @disp
59 * @endianness: the endianness of image bytes on Display @disp
60 * @width: the width in pixels of Display @disp
61 * @height: the height in pixels of Display @disp
62 * @widthmm: the width in millimeters of Display @disp
63 * @heightmm: the height in millimeters of Display @disp
64 * @par_n: the pixel aspect ratio numerator calculated from @width, @widthmm
66 * @par_d: the pixel aspect ratio denumerator calculated from @width, @widthmm
69 * @use_xshm: used to known wether of not XShm extension is usable or not even
70 * if the Extension is present
71 * @caps: the #GstCaps that Display @disp can accept
73 * Structure used to store various informations collected/calculated for a
92 gint widthmm, heightmm;
94 /* these are the output masks
95 * for buffers from ximagesrc
96 * and are in big endian */
97 guint32 r_mask_output, g_mask_output, b_mask_output;
99 guint par_n; /* calculated pixel aspect ratio numerator */
100 guint par_d; /* calculated pixel aspect ratio denumerator */
109 * @win: the Window ID of this X11 window
110 * @width: the width in pixels of Window @win
111 * @height: the height in pixels of Window @win
112 * @internal: used to remember if Window @win was created internally or passed
113 * through the #GstXOverlay interface
114 * @gc: the Graphical Context of Window @win
116 * Structure used to store informations about a Window.
125 gboolean ximageutil_check_xshm_calls (GstXContext * xcontext);
127 GstXContext *ximageutil_xcontext_get (GstElement *parent,
128 const gchar *display_name);
129 void ximageutil_xcontext_clear (GstXContext *xcontext);
130 void ximageutil_calculate_pixel_aspect_ratio (GstXContext * xcontext);
132 /* custom ximagesrc buffer, copied from ximagesink */
134 /* BufferReturnFunc is called when a buffer is finalised */
135 typedef gboolean (*BufferReturnFunc) (GstElement *parent, GstBuffer *buf);
139 * @parent: a reference to the element we belong to
140 * @ximage: the XImage of this buffer
141 * @width: the width in pixels of XImage @ximage
142 * @height: the height in pixels of XImage @ximage
143 * @size: the size in bytes of XImage @ximage
145 * Extra data attached to buffers containing additional information about an XImage.
147 struct _GstMetaXImage {
150 /* Reference to the ximagesrc we belong to */
156 XShmSegmentInfo SHMInfo;
157 #endif /* HAVE_XSHM */
162 BufferReturnFunc return_func;
165 GType gst_meta_ximage_api_get_type (void);
166 const GstMetaInfo * gst_meta_ximage_get_info (void);
167 #define GST_META_XIMAGE_GET(buf) ((GstMetaXImage *)gst_buffer_get_meta(buf,gst_meta_ximage_api_get_type()))
168 #define GST_META_XIMAGE_ADD(buf) ((GstMetaXImage *)gst_buffer_add_meta(buf,gst_meta_ximage_get_info(),NULL))
170 GstBuffer *gst_ximageutil_ximage_new (GstXContext *xcontext,
171 GstElement *parent, int width, int height, BufferReturnFunc return_func);
173 void gst_ximageutil_ximage_destroy (GstXContext *xcontext,
176 /* Call to manually release a buffer */
177 void gst_ximage_buffer_free (GstBuffer *ximage);
181 #endif /* __GST_XIMAGEUTIL_H__ */