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., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, 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 _GstXImageSrcBuffer GstXImageSrcBuffer;
48 /* Global X Context stuff */
51 * @disp: the X11 Display of this context
52 * @screen: the default Screen of Display @disp
53 * @screen_num: the Screen number of @screen
54 * @visual: the default Visual of Screen @screen
55 * @root: the root Window of Display @disp
56 * @white: the value of a white pixel on Screen @screen
57 * @black: the value of a black pixel on Screen @screen
58 * @depth: the color depth of Display @disp
59 * @bpp: the number of bits per pixel on Display @disp
60 * @endianness: the endianness of image bytes on Display @disp
61 * @width: the width in pixels of Display @disp
62 * @height: the height in pixels of Display @disp
63 * @widthmm: the width in millimeters of Display @disp
64 * @heightmm: the height in millimeters of Display @disp
65 * @par: the pixel aspect ratio calculated from @width, @widthmm and @height,
67 * @use_xshm: used to known wether of not XShm extension is usable or not even
68 * if the Extension is present
69 * @caps: the #GstCaps that Display @disp can accept
71 * Structure used to store various informations collected/calculated for a
91 gint widthmm, heightmm;
93 /* these are the output masks
94 * for buffers from ximagesrc
95 * and are in big endian */
96 guint32 r_mask_output, g_mask_output, b_mask_output;
98 GValue *par; /* calculated pixel aspect ratio */
107 * @win: the Window ID of this X11 window
108 * @width: the width in pixels of Window @win
109 * @height: the height in pixels of Window @win
110 * @internal: used to remember if Window @win was created internally or passed
111 * through the #GstXOverlay interface
112 * @gc: the Graphical Context of Window @win
114 * Structure used to store informations about a Window.
123 gboolean ximageutil_check_xshm_calls (GstXContext * xcontext);
125 GstXContext *ximageutil_xcontext_get (GstElement *parent,
126 const gchar *display_name);
127 void ximageutil_xcontext_clear (GstXContext *xcontext);
128 void ximageutil_calculate_pixel_aspect_ratio (GstXContext * xcontext);
130 /* custom ximagesrc buffer, copied from ximagesink */
132 /* BufferReturnFunc is called when a buffer is finalised */
133 typedef void (*BufferReturnFunc) (GstElement *parent, GstXImageSrcBuffer *buf);
136 * GstXImageSrcBuffer:
137 * @parent: a reference to the element we belong to
138 * @ximage: the XImage of this buffer
139 * @width: the width in pixels of XImage @ximage
140 * @height: the height in pixels of XImage @ximage
141 * @size: the size in bytes of XImage @ximage
143 * Subclass of #GstBuffer containing additional information about an XImage.
145 struct _GstXImageSrcBuffer {
148 /* Reference to the ximagesrc we belong to */
154 XShmSegmentInfo SHMInfo;
155 #endif /* HAVE_XSHM */
160 BufferReturnFunc return_func;
164 GstXImageSrcBuffer *gst_ximageutil_ximage_new (GstXContext *xcontext,
165 GstElement *parent, int width, int height, BufferReturnFunc return_func);
167 void gst_ximageutil_ximage_destroy (GstXContext *xcontext,
168 GstXImageSrcBuffer * ximage);
170 /* Call to manually release a buffer */
171 void gst_ximage_buffer_free (GstXImageSrcBuffer *ximage);
173 #define GST_TYPE_XIMAGESRC_BUFFER (gst_ximagesrc_buffer_get_type())
174 #define GST_IS_XIMAGESRC_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_XIMAGESRC_BUFFER))
175 #define GST_IS_XIMAGESRC_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_XIMAGESRC_BUFFER))
176 #define GST_XIMAGESRC_BUFFER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_XIMAGESRC_BUFFER, GstXImageSrcBuffer))
177 #define GST_XIMAGESRC_BUFFER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_XIMAGESRC_BUFFER, GstXImageSrcBufferClass))
178 #define GST_XIMAGESRC_BUFFER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_XIMAGESRC_BUFFER, GstXImageSrcBufferClass))
182 #endif /* __GST_XIMAGEUTIL_H__ */