2 * Copyright (C) 2010 Wim Taymans <wim.taymans@gmail.com>
4 * gstbufferpool.h: Header for GstBufferPool object
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
23 #ifndef __GST_BUFFER_POOL_H__
24 #define __GST_BUFFER_POOL_H__
26 #include <gst/gstminiobject.h>
27 #include <gst/gstatomicqueue.h>
28 #include <gst/gstpoll.h>
29 #include <gst/gstclock.h>
30 #include <gst/gstpad.h>
31 #include <gst/gstbuffer.h>
35 typedef struct _GstBufferPool GstBufferPool;
36 typedef struct _GstBufferPoolPrivate GstBufferPoolPrivate;
37 typedef struct _GstBufferPoolClass GstBufferPoolClass;
40 * GST_BUFFER_POOL_TRACE_NAME:
42 * The name used for tracing memory allocations.
44 #define GST_BUFFER_POOL_TRACE_NAME "GstBufferPool"
46 #define GST_TYPE_BUFFER_POOL (gst_buffer_pool_get_type())
47 #define GST_IS_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_BUFFER_POOL))
48 #define GST_IS_BUFFER_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_BUFFER_POOL))
49 #define GST_BUFFER_POOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GST_TYPE_BUFFER_POOL, GstBufferPoolClass))
50 #define GST_BUFFER_POOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_BUFFER_POOL, GstBufferPool))
51 #define GST_BUFFER_POOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_BUFFER_POOL, GstBufferPoolClass))
52 #define GST_BUFFER_POOL_CAST(obj) ((GstBufferPool *)(obj))
56 * @GST_BUFFER_POOL_FLAG_NONE: no flags
57 * @GST_BUFFER_POOL_FLAG_KEY_UNIT: buffer is keyframe
58 * @GST_BUFFER_POOL_FLAG_WAIT: wait for buffer
59 * @GST_BUFFER_POOL_FLAG_DISCONT: buffer is discont
61 * Additional flags to control the allocation of a buffer
64 GST_BUFFER_POOL_FLAG_NONE = 0,
65 GST_BUFFER_POOL_FLAG_KEY_UNIT = (1 << 0),
66 GST_BUFFER_POOL_FLAG_WAIT = (1 << 1),
67 GST_BUFFER_POOL_FLAG_DISCONT = (1 << 2),
68 GST_BUFFER_POOL_FLAG_LAST = (1 << 16),
72 * GstBufferPoolParams:
73 * @format: the format of @start and @stop
74 * @start: the start position
75 * @stop: the stop position
76 * @flags: additional flags
78 * Parameters passed to the gst_buffer_pool_acquire_buffer() function to control the
79 * allocation of the buffer.
81 typedef struct _GstBufferPoolParams {
85 GstBufferPoolFlags flags;
86 } GstBufferPoolParams;
90 * @mini_object: the parent structure
92 * The structure of a #GstBufferPool. Use the associated macros to access the public
95 struct _GstBufferPool {
100 GstAtomicQueue *queue;
103 GstStructure *config;
105 GstBufferPoolPrivate *priv;
107 gpointer _gst_reserved[GST_PADDING];
110 struct _GstBufferPoolClass {
111 GstObjectClass object_class;
114 void (*set_active) (GstBufferPool *pool, gboolean active);
115 gboolean (*set_config) (GstBufferPool *pool, GstStructure *config);
117 GstFlowReturn (*acquire_buffer) (GstBufferPool *pool, GstBuffer **buffer,
118 GstBufferPoolParams *params);
119 GstFlowReturn (*alloc_buffer) (GstBufferPool *pool, GstBuffer **buffer,
120 GstBufferPoolParams *params);
121 void (*release_buffer) (GstBufferPool *pool, GstBuffer *buffer);
122 void (*free_buffer) (GstBufferPool *pool, GstBuffer *buffer);
124 gpointer _gst_reserved[GST_PADDING];
127 GType gst_buffer_pool_get_type (void);
130 GstBufferPool * gst_buffer_pool_new (void);
132 /* state management */
133 void gst_buffer_pool_set_active (GstBufferPool *pool, gboolean active);
135 gboolean gst_buffer_pool_set_config (GstBufferPool *pool, GstStructure *config);
136 const GstStructure * gst_buffer_pool_get_config (GstBufferPool *pool);
138 /* helpers for configuring the config structure */
139 void gst_buffer_pool_config_set (GstStructure *config, guint size,
140 guint min_buffers, guint max_buffers,
141 guint prefix, guint postfix, guint align);
142 gboolean gst_buffer_pool_config_get (GstStructure *config, guint *size,
143 guint *min_buffers, guint *max_buffers,
144 guint *prefix, guint *postfix, guint *align);
146 /* buffer management */
147 GstFlowReturn gst_buffer_pool_acquire_buffer (GstBufferPool *pool, GstBuffer **buffer,
148 GstBufferPoolParams *params);
149 void gst_buffer_pool_release_buffer (GstBufferPool *pool, GstBuffer *buffer);
153 #endif /* __GST_BUFFER_POOL_H__ */