2 * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3 * 2000 Wim Taymans <wtay@chello.be>
5 * gstbufferpool.h: Header for buffer-pool management
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
17 * You should have received a copy of the GNU Library General Public
18 * License along with this library; if not, write to the
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 * Boston, MA 02111-1307, USA.
23 #ifndef __GST_BUFFER_POOL_H__
24 #define __GST_BUFFER_POOL_H__
26 #include <gst/gstbuffer.h>
31 #endif /* __cplusplus */
34 #define GST_BUFFER_POOL(pool) \
35 ((GstBufferPool *)(pool))
36 #define GST_BUFFER_POOL_LOCK(pool) (g_mutex_lock(GST_BUFFER_POOL(pool)->lock))
37 #define GST_BUFFER_POOL_UNLOCK(pool) (g_mutex_unlock(GST_BUFFER_POOL(pool)->lock))
39 typedef struct _GstBufferPool GstBufferPool;
41 typedef GstBuffer* (*GstBufferPoolBufferNewFunction) (GstBufferPool *pool, gint64 location, gint size, gpointer user_data);
42 typedef void (*GstBufferPoolDestroyHook) (GstBufferPool *pool, gpointer user_data);
44 struct _GstBufferPool {
51 #define GST_BUFFER_POOL_REFCOUNT(pool) (atomic_read(&(GST_BUFFER_POOL((pool))->refcount)))
54 #define GST_BUFFER_POOL_REFCOUNT(pool) (GST_BUFFER_POOL(pool)->refcount)
57 GstBufferPoolBufferNewFunction buffer_new;
58 GstBufferFreeFunc buffer_free;
59 GstBufferCopyFunc buffer_copy;
60 GstBufferPoolDestroyHook destroy_hook;
65 void _gst_buffer_pool_initialize (void);
67 /* creating a new buffer pool from scratch */
68 GstBufferPool* gst_buffer_pool_new (void);
71 void gst_buffer_pool_ref (GstBufferPool *pool);
72 void gst_buffer_pool_ref_by_count (GstBufferPool *pool, int count);
73 void gst_buffer_pool_unref (GstBufferPool *buffer);
75 /* setting create and destroy functions */
76 void gst_buffer_pool_set_buffer_new_function (GstBufferPool *pool,
77 GstBufferPoolBufferNewFunction create);
78 void gst_buffer_pool_set_buffer_free_function (GstBufferPool *pool,
79 GstBufferFreeFunc destroy);
80 void gst_buffer_pool_set_buffer_copy_function (GstBufferPool *pool,
81 GstBufferCopyFunc copy);
82 void gst_buffer_pool_set_destroy_hook (GstBufferPool *pool,
83 GstBufferPoolDestroyHook destroy);
84 void gst_buffer_pool_set_user_data (GstBufferPool *pool,
86 gpointer gst_buffer_pool_get_user_data (GstBufferPool *pool,
89 /* destroying the buffer pool */
90 void gst_buffer_pool_destroy (GstBufferPool *pool);
92 /* a default buffer pool implementation */
93 GstBufferPool* gst_buffer_pool_get_default (guint buffer_size, guint pool_size);
97 #endif /* __cplusplus */
100 #endif /* __GST_BUFFER_POOL_H__ */