Merge branch 'master' into 0.11
[platform/upstream/gstreamer.git] / sys / ximage / ximagepool.h
1 /* GStreamer
2  * Copyright (C) <2005> Julien Moutte <julien@moutte.net>
3  *
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.
8  *
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.
13  *
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.
18  */
19
20 #ifndef __GST_XIMAGEPOOL_H__
21 #define __GST_XIMAGEPOOL_H__
22
23 #ifdef HAVE_XSHM
24 #include <sys/types.h>
25 #include <sys/ipc.h>
26 #include <sys/shm.h>
27 #endif /* HAVE_XSHM */
28
29 #include <X11/Xlib.h>
30 #include <X11/Xutil.h>
31
32 #ifdef HAVE_XSHM
33 #include <X11/extensions/XShm.h>
34 #endif /* HAVE_XSHM */
35
36 #include <string.h>
37 #include <math.h>
38
39
40 G_BEGIN_DECLS
41
42 typedef struct _GstXImageMeta GstXImageMeta;
43
44 typedef struct _GstXImageBufferPool GstXImageBufferPool;
45 typedef struct _GstXImageBufferPoolClass GstXImageBufferPoolClass;
46 typedef struct _GstXImageBufferPoolPrivate GstXImageBufferPoolPrivate;
47
48 #include "ximagesink.h"
49
50 const GstMetaInfo * gst_ximage_meta_get_info (void);
51 #define GST_XIMAGE_META_INFO  (gst_ximage_meta_get_info())
52
53 #define gst_buffer_get_ximage_meta(b) ((GstXImageMeta*)gst_buffer_get_meta((b),GST_XIMAGE_META_INFO))
54
55 /**
56  * GstXImageMeta:
57  * @simagesink: a reference to the our #GstXImageSink
58  * @ximage: the XImage of this buffer
59  * @width: the width in pixels of XImage @ximage
60  * @height: the height in pixels of XImage @ximage
61  * @size: the size in bytes of XImage @ximage
62  *
63  * Subclass of #GstMeta containing additional information about an XImage.
64  */
65 struct _GstXImageMeta
66 {
67   GstMeta meta;
68
69   /* Reference to the ximagesink we belong to */
70   GstXImageSink *sink;
71
72   XImage *ximage;
73
74 #ifdef HAVE_XSHM
75   XShmSegmentInfo SHMInfo;
76 #endif                          /* HAVE_XSHM */
77
78   gint x, y;
79   gint width, height;
80   size_t size;
81 };
82
83 /* buffer pool functions */
84 #define GST_TYPE_XIMAGE_BUFFER_POOL      (gst_ximage_buffer_pool_get_type())
85 #define GST_IS_XIMAGE_BUFFER_POOL(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_XIMAGE_BUFFER_POOL))
86 #define GST_XIMAGE_BUFFER_POOL(obj)      (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_XIMAGE_BUFFER_POOL, GstXImageBufferPool))
87 #define GST_XIMAGE_BUFFER_POOL_CAST(obj) ((GstXImageBufferPool*)(obj))
88
89 struct _GstXImageBufferPool
90 {
91   GstBufferPool bufferpool;
92
93   GstXImageSink *sink;
94
95   GstXImageBufferPoolPrivate *priv;
96 };
97
98 struct _GstXImageBufferPoolClass
99 {
100   GstBufferPoolClass parent_class;
101 };
102
103 GType gst_ximage_buffer_pool_get_type (void);
104
105 GstBufferPool * gst_ximage_buffer_pool_new     (GstXImageSink * ximagesink);
106
107 gboolean gst_ximagesink_check_xshm_calls (GstXImageSink * ximagesink,
108         GstXContext * xcontext);
109
110 G_END_DECLS
111
112 #endif /* __GST_XIMAGEPOOL_H__ */