aggregator: Assert if the sink/src pad type that is to be used is not a GstAggregator...
[platform/upstream/gstreamer.git] / libs / gst / base / gstdataqueue.h
1 /* GStreamer
2  * Copyright (C) 2006 Edward Hervey <edward@fluendo.com>
3  *
4  * gstdataqueue.h:
5  *
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.
10  *
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.
15  *
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., 51 Franklin St, Fifth Floor,
19  * Boston, MA 02110-1301, USA.
20  */
21
22
23 #ifndef __GST_DATA_QUEUE_H__
24 #define __GST_DATA_QUEUE_H__
25
26 #include <gst/gst.h>
27 #include <gst/base/base-prelude.h>
28
29 G_BEGIN_DECLS
30 #define GST_TYPE_DATA_QUEUE \
31   (gst_data_queue_get_type())
32 #define GST_DATA_QUEUE(obj) \
33   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DATA_QUEUE,GstDataQueue))
34 #define GST_DATA_QUEUE_CLASS(klass) \
35   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DATA_QUEUE,GstDataQueueClass))
36 #define GST_IS_DATA_QUEUE(obj) \
37   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DATA_QUEUE))
38 #define GST_IS_DATA_QUEUE_CLASS(klass) \
39   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DATA_QUEUE))
40
41 typedef struct _GstDataQueue GstDataQueue;
42 typedef struct _GstDataQueueClass GstDataQueueClass;
43 typedef struct _GstDataQueueSize GstDataQueueSize;
44 typedef struct _GstDataQueueItem GstDataQueueItem;
45 typedef struct _GstDataQueuePrivate GstDataQueuePrivate;
46
47 /**
48  * GstDataQueueItem: (skip)
49  * @object: the #GstMiniObject to queue.
50  * @size: the size in bytes of the miniobject.
51  * @duration: the duration in #GstClockTime of the miniobject. Can not be
52  * %GST_CLOCK_TIME_NONE.
53  * @visible: %TRUE if @object should be considered as a visible object.
54  * @destroy: The #GDestroyNotify function to use to free the #GstDataQueueItem.
55  * This function should also drop the reference to @object the owner of the
56  * #GstDataQueueItem is assumed to hold.
57  *
58  * Structure used by #GstDataQueue. You can supply a different structure, as
59  * long as the top of the structure is identical to this structure.
60  */
61
62 struct _GstDataQueueItem
63 {
64   GstMiniObject *object;
65   guint size;
66   guint64 duration;
67   gboolean visible;
68
69   /* user supplied destroy function */
70   GDestroyNotify destroy;
71
72   /* < private > */
73   gpointer _gst_reserved[GST_PADDING];
74 };
75
76 /**
77  * GstDataQueueSize: (skip)
78  * @visible: number of buffers
79  * @bytes: number of bytes
80  * @time: amount of time
81  *
82  * Structure describing the size of a queue.
83  */
84 struct _GstDataQueueSize
85 {
86   guint visible;
87   guint bytes;
88   guint64 time;
89 };
90
91 /**
92  * GstDataQueueCheckFullFunction: (skip)
93  * @queue: a #GstDataQueue.
94  * @visible: The number of visible items currently in the queue.
95  * @bytes: The amount of bytes currently in the queue.
96  * @time: The accumulated duration of the items currently in the queue.
97  * @checkdata: The #gpointer registered when the #GstDataQueue was created.
98  *
99  * The prototype of the function used to inform the queue that it should be
100  * considered as full.
101  *
102  * Returns: %TRUE if the queue should be considered full.
103  */
104 typedef gboolean (*GstDataQueueCheckFullFunction) (GstDataQueue * queue,
105     guint visible, guint bytes, guint64 time, gpointer checkdata);
106
107 typedef void (*GstDataQueueFullCallback) (GstDataQueue * queue, gpointer checkdata);
108 typedef void (*GstDataQueueEmptyCallback) (GstDataQueue * queue, gpointer checkdata);
109
110 /**
111  * GstDataQueue:
112  * @object: the parent structure
113  *
114  * Opaque #GstDataQueue structure.
115  */
116 struct _GstDataQueue
117 {
118   GObject object;
119
120   /*< private >*/
121   GstDataQueuePrivate *priv;
122   gpointer _gst_reserved[GST_PADDING];
123 };
124
125 /**
126  * GstDataQueueClass:
127  */
128 struct _GstDataQueueClass
129 {
130   GObjectClass parent_class;
131
132   /* signals */
133   void (*empty) (GstDataQueue * queue);
134   void (*full) (GstDataQueue * queue);
135
136   gpointer _gst_reserved[GST_PADDING];
137 };
138
139 GST_BASE_API
140 GType          gst_data_queue_get_type (void);
141
142 GST_BASE_API
143 GstDataQueue * gst_data_queue_new            (GstDataQueueCheckFullFunction checkfull,
144                                               GstDataQueueFullCallback fullcallback,
145                                               GstDataQueueEmptyCallback emptycallback,
146                                               gpointer checkdata) G_GNUC_MALLOC;
147 GST_BASE_API
148 gboolean       gst_data_queue_push           (GstDataQueue * queue, GstDataQueueItem * item);
149
150 GST_BASE_API
151 gboolean       gst_data_queue_push_force     (GstDataQueue * queue, GstDataQueueItem * item);
152
153 GST_BASE_API
154 gboolean       gst_data_queue_pop            (GstDataQueue * queue, GstDataQueueItem ** item);
155
156 GST_BASE_API
157 gboolean       gst_data_queue_peek           (GstDataQueue * queue, GstDataQueueItem ** item);
158
159 GST_BASE_API
160 void           gst_data_queue_flush          (GstDataQueue * queue);
161
162 GST_BASE_API
163 void           gst_data_queue_set_flushing   (GstDataQueue * queue, gboolean flushing);
164
165 GST_BASE_API
166 gboolean       gst_data_queue_drop_head      (GstDataQueue * queue, GType type);
167
168 GST_BASE_API
169 gboolean       gst_data_queue_is_full        (GstDataQueue * queue);
170
171 GST_BASE_API
172 gboolean       gst_data_queue_is_empty       (GstDataQueue * queue);
173
174 GST_BASE_API
175 void           gst_data_queue_get_level      (GstDataQueue * queue, GstDataQueueSize *level);
176
177 GST_BASE_API
178 void           gst_data_queue_limits_changed (GstDataQueue * queue);
179
180 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
181 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstDataQueue, gst_object_unref)
182 #endif
183
184 G_END_DECLS
185
186 #endif /* __GST_DATA_QUEUE_H__ */