can someone fix this better than me and remove FIXME's ?
[platform/upstream/gstreamer.git] / gst / gstbufferpool.h
1 /* GStreamer
2  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3  *                    2000 Wim Taymans <wtay@chello.be>
4  *
5  * gstbufferpool.h: Header for buffer-pool management
6  *
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.
11  *
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.
16  *
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.
21  */
22
23 #ifndef __GST_BUFFER_POOL_H__
24 #define __GST_BUFFER_POOL_H__
25
26 #include <gst/gstbuffer.h>
27
28
29 #ifdef __cplusplus
30 extern "C" {
31 #endif /* __cplusplus */
32
33
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))
38
39 typedef struct _GstBufferPool GstBufferPool;
40
41 typedef GstBuffer*      (*GstBufferPoolBufferNewFunction) (GstBufferPool *pool, gint64 location, gint size, gpointer user_data);
42 typedef void            (*GstBufferPoolDestroyHook)       (GstBufferPool *pool, gpointer user_data);
43
44 struct _GstBufferPool {
45   /* locking */
46   GMutex *lock;
47
48   /* refcounting */
49 #ifdef HAVE_ATOMIC_H
50   atomic_t refcount;
51 #define GST_BUFFER_POOL_REFCOUNT(pool)  (atomic_read(&(GST_BUFFER_POOL((pool))->refcount)))
52 #else
53   int refcount;
54 #define GST_BUFFER_POOL_REFCOUNT(pool)  (GST_BUFFER_POOL(pool)->refcount)
55 #endif
56
57   GstBufferPoolBufferNewFunction buffer_new;
58   GstBufferFreeFunc buffer_free;
59   GstBufferCopyFunc buffer_copy;
60   GstBufferPoolDestroyHook destroy_hook;
61     
62   gpointer user_data;
63 };
64
65 void _gst_buffer_pool_initialize (void);
66
67 /* creating a new buffer pool from scratch */
68 GstBufferPool*          gst_buffer_pool_new                     (void);
69
70 /* refcounting */
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 *pool);
74
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, 
85                                                                  gpointer user_data);
86 gpointer        gst_buffer_pool_get_user_data                   (GstBufferPool *pool);
87
88 /* destroying the buffer pool */
89 void            gst_buffer_pool_destroy                 (GstBufferPool *pool);
90
91 /* a default buffer pool implementation */
92 GstBufferPool* gst_buffer_pool_get_default (guint buffer_size, guint pool_size);
93
94 #ifdef __cplusplus
95 }
96 #endif /* __cplusplus */
97
98
99 #endif /* __GST_BUFFER_POOL_H__ */