Merge branch 'master' into 0.11
[platform/upstream/gst-plugins-base.git] / sys / xvimage / xvimagepool.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_XVIMAGEPOOL_H__
21 #define __GST_XVIMAGEPOOL_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 _GstMetaXvImage GstMetaXvImage;
43
44 typedef struct _GstXvImageBufferPool GstXvImageBufferPool;
45 typedef struct _GstXvImageBufferPoolClass GstXvImageBufferPoolClass;
46 typedef struct _GstXvImageBufferPoolPrivate GstXvImageBufferPoolPrivate;
47
48 #include "xvimagesink.h"
49
50 const GstMetaInfo * gst_meta_xvimage_get_info (void);
51 #define GST_META_INFO_XVIMAGE  (gst_meta_xvimage_get_info())
52
53 #define gst_buffer_get_meta_xvimage(b) ((GstMetaXvImage*)gst_buffer_get_meta((b),GST_META_INFO_XVIMAGE))
54
55 /**
56  * GstMetaXvImage:
57  * @sink: a reference to the our #GstXvImageSink
58  * @xvimage: the XvImage of this buffer
59  * @width: the width in pixels of XvImage @xvimage
60  * @height: the height in pixels of XvImage @xvimage
61  * @im_format: the format of XvImage @xvimage
62  * @size: the size in bytes of XvImage @xvimage
63  *
64  * Subclass of #GstMeta containing additional information about an XvImage.
65  */
66 struct _GstMetaXvImage
67 {
68   GstMeta meta;
69
70   /* Reference to the xvimagesink we belong to */
71   GstXvImageSink *sink;
72
73   XvImage *xvimage;
74
75 #ifdef HAVE_XSHM
76   XShmSegmentInfo SHMInfo;
77 #endif                          /* HAVE_XSHM */
78
79   gint x, y;
80   gint width, height;
81   gint im_format;
82   size_t size;
83 };
84
85 /* buffer pool functions */
86 #define GST_TYPE_XVIMAGE_BUFFER_POOL      (gst_xvimage_buffer_pool_get_type())
87 #define GST_IS_XVIMAGE_BUFFER_POOL(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_XVIMAGE_BUFFER_POOL))
88 #define GST_XVIMAGE_BUFFER_POOL(obj)      (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_XVIMAGE_BUFFER_POOL, GstXvImageBufferPool))
89 #define GST_XVIMAGE_BUFFER_POOL_CAST(obj) ((GstXvImageBufferPool*)(obj))
90
91 struct _GstXvImageBufferPool
92 {
93   GstBufferPool bufferpool;
94
95   GstXvImageSink *sink;
96
97   GstXvImageBufferPoolPrivate *priv;
98 };
99
100 struct _GstXvImageBufferPoolClass
101 {
102   GstBufferPoolClass parent_class;
103 };
104
105 GType gst_xvimage_buffer_pool_get_type (void);
106
107 GstBufferPool *gst_xvimage_buffer_pool_new (GstXvImageSink * xvimagesink);
108
109 gboolean gst_xvimagesink_check_xshm_calls (GstXvImageSink * xvimagesink,
110       GstXContext * xcontext);
111
112 gint gst_xvimagesink_get_format_from_info (GstXvImageSink * xvimagesink,
113     GstVideoInfo * info);
114
115 G_END_DECLS
116
117 #endif /*__GST_XVIMAGEPOOL_H__*/