• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
47 #include "ximagesink.h"
48 
49 /**
50  * GstXImageMemory:
51  * @sink: a reference to the our #GstXImageSink
52  * @ximage: the XImage of this buffer
53  * @width: the width in pixels of XImage @ximage
54  * @height: the height in pixels of XImage @ximage
55  * @size: the size in bytes of XImage @ximage
56  *
57  * Subclass of #GstMemory containing additional information about an XImage.
58  */
59 struct _GstXImageMemory
60 {
61   GstMemory parent;
62 
63   /* Reference to the ximagesink we belong to */
64   GstXImageSink *sink;
65 
66   XImage *ximage;
67 
68 #ifdef HAVE_XSHM
69   XShmSegmentInfo SHMInfo;
70 #endif                          /* HAVE_XSHM */
71 
72   gint x, y;
73   gint width, height;
74   size_t size;
75 };
76 
77 /* buffer pool functions */
78 #define GST_TYPE_XIMAGE_BUFFER_POOL      (gst_ximage_buffer_pool_get_type())
79 #define GST_IS_XIMAGE_BUFFER_POOL(obj)   (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_XIMAGE_BUFFER_POOL))
80 #define GST_XIMAGE_BUFFER_POOL(obj)      (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_XIMAGE_BUFFER_POOL, GstXImageBufferPool))
81 #define GST_XIMAGE_BUFFER_POOL_CAST(obj) ((GstXImageBufferPool*)(obj))
82 
83 struct _GstXImageBufferPool
84 {
85   GstBufferPool bufferpool;
86 
87   GstXImageSink *sink;
88   GstAllocator *allocator;
89 
90   GstCaps *caps;
91   GstVideoInfo info;
92   GstVideoAlignment align;
93   guint    padded_width;
94   guint    padded_height;
95   gboolean add_metavideo;
96   gboolean need_alignment;
97 };
98 
99 struct _GstXImageBufferPoolClass
100 {
101   GstBufferPoolClass parent_class;
102 };
103 
104 GType gst_ximage_buffer_pool_get_type (void);
105 
106 GstBufferPool * gst_ximage_buffer_pool_new     (GstXImageSink * ximagesink);
107 
108 gboolean gst_x_image_sink_check_xshm_calls (GstXImageSink * ximagesink,
109         GstXContext * xcontext);
110 
111 G_END_DECLS
112 
113 #endif /* __GST_XIMAGEPOOL_H__ */
114