multiqueue: Distinguish between buffering percentage and buffering level
[platform/upstream/gstreamer.git] / plugins / elements / gstmultiqueue.h
1 /* GStreamer
2  * Copyright (C) 2006 Edward Hervey <edward@fluendo.com>
3  *
4  * gstmultiqueue.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_MULTI_QUEUE_H__
24 #define __GST_MULTI_QUEUE_H__
25
26 #include <gst/gst.h>
27 #include <gst/base/gstdataqueue.h>
28
29 G_BEGIN_DECLS
30
31 #define GST_TYPE_MULTI_QUEUE \
32   (gst_multi_queue_get_type())
33 #define GST_MULTI_QUEUE(obj) \
34   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_MULTI_QUEUE,GstMultiQueue))
35 #define GST_MULTI_QUEUE_CLASS(klass) \
36   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_MULTI_QUEUE,GstMultiQueueClass))
37 #define GST_IS_MULTI_QUEUE(obj) \
38   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_MULTI_QUEUE))
39 #define GST_IS_MULTI_QUEUE_CLASS(obj) \
40   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_MULTI_QUEUE))
41
42 typedef struct _GstMultiQueue GstMultiQueue;
43 typedef struct _GstMultiQueueClass GstMultiQueueClass;
44
45 typedef struct _GstMultiQueuePad GstMultiQueuePad;
46 typedef struct _GstMultiQueuePadClass GstMultiQueuePadClass;
47
48 /**
49  * GstMultiQueue:
50  *
51  * Opaque #GstMultiQueue structure.
52  */
53 struct _GstMultiQueue {
54   GstElement element;
55
56   gboolean sync_by_running_time;
57   gboolean use_interleave;
58
59   /* number of queues */
60   guint nbqueues;
61
62   /* The list of individual queues */
63   GList *queues;
64   guint32 queues_cookie;
65
66   GstDataQueueSize  max_size, extra_size;
67   gboolean use_buffering;
68   gint low_watermark, high_watermark;
69   gboolean buffering;
70   gint buffering_percent;
71
72   guint    counter;     /* incoming object counter, use atomic accesses */
73   guint32  highid;      /* contains highest id of last outputted object */
74   GstClockTimeDiff high_time; /* highest start running time */
75
76   GMutex   qlock;       /* Global queue lock (vs object lock or individual */
77                         /* queues lock). Protects nbqueues, queues, global */
78                         /* GstMultiQueueSize, counter and highid */
79
80   gint numwaiting;      /* number of not-linked pads waiting */
81
82   gboolean buffering_percent_changed;
83   GMutex buffering_post_lock; /* assures only one posted at a time */
84
85   GstClockTime interleave;      /* Input interleave */
86   GstClockTimeDiff last_interleave_update;
87
88   GstClockTime unlinked_cache_time;
89 };
90
91 struct _GstMultiQueueClass {
92   GstElementClass parent_class;
93
94   /* signals emitted when ALL queues are either full or empty */
95   void (*underrun)      (GstMultiQueue *queue);
96   void (*overrun)       (GstMultiQueue *queue);
97 };
98
99 G_GNUC_INTERNAL GType gst_multi_queue_get_type (void);
100
101 G_END_DECLS
102
103
104 #endif /* __GST_MULTI_QUEUE_H__ */