ximagesink: use memory to store XImage info
[platform/upstream/gst-plugins-base.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., 51 Franklin St, Fifth Floor,
17  * Boston, MA 02110-1301, 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 _GstXImageMemory GstXImageMemory;
43
44 typedef struct _GstXImageBufferPool GstXImageBufferPool;
45 typedef struct _GstXImageBufferPoolClass GstXImageBufferPoolClass;
46 typedef struct _GstXImageBufferPoolPrivate GstXImageBufferPoolPrivate;
47
48 #include "ximagesink.h"
49
50 /**
51  * GstXImageMemory:
52  * @sink: a reference to the our #GstXImageSink
53  * @ximage: the XImage of this buffer
54  * @width: the width in pixels of XImage @ximage
55  * @height: the height in pixels of XImage @ximage
56  * @size: the size in bytes of XImage @ximage
57  *
58  * Subclass of #GstMemory containing additional information about an XImage.
59  */
60 struct _GstXImageMemory
61 {
62   GstMemory parent;
63
64   /* Reference to the ximagesink we belong to */
65   GstXImageSink *sink;
66
67   XImage *ximage;
68
69 #ifdef HAVE_XSHM
70   XShmSegmentInfo SHMInfo;
71 #endif                          /* HAVE_XSHM */
72
73   gint x, y;
74   gint width, height;
75   size_t size;
76 };
77
78 /* buffer pool functions */
79 #define GST_TYPE_XIMAGE_BUFFER_POOL      (gst_ximage_buffer_pool_get_type())
80 #define GST_IS_XIMAGE_BUFFER_POOL(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_XIMAGE_BUFFER_POOL))
81 #define GST_XIMAGE_BUFFER_POOL(obj)      (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_XIMAGE_BUFFER_POOL, GstXImageBufferPool))
82 #define GST_XIMAGE_BUFFER_POOL_CAST(obj) ((GstXImageBufferPool*)(obj))
83
84 struct _GstXImageBufferPool
85 {
86   GstBufferPool bufferpool;
87
88   GstXImageSink *sink;
89   GstAllocator *allocator;
90
91   GstXImageBufferPoolPrivate *priv;
92 };
93
94 struct _GstXImageBufferPoolClass
95 {
96   GstBufferPoolClass parent_class;
97 };
98
99 GType gst_ximage_buffer_pool_get_type (void);
100
101 GstBufferPool * gst_ximage_buffer_pool_new     (GstXImageSink * ximagesink);
102
103 gboolean gst_ximagesink_check_xshm_calls (GstXImageSink * ximagesink,
104         GstXContext * xcontext);
105
106 G_END_DECLS
107
108 #endif /* __GST_XIMAGEPOOL_H__ */