queue2: Integrate into coreplugins
[platform/upstream/gstreamer.git] / plugins / elements / gstqueue2.h
1 /* GStreamer
2  * Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
3  *                    2003 Colin Walters <cwalters@gnome.org>
4  *                    2000,2005,2007 Wim Taymans <wim.taymans@gmail.com>
5  *                    2007 Thiago Sousa Santos <thiagoss@lcc.ufcg.edu.br>
6  *
7  * gstqueue2.h:
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Library General Public
11  * License as published by the Free Software Foundation; either
12  * version 2 of the License, or (at your option) any later version.
13  *
14  * This library is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17  * Library General Public License for more details.
18  *
19  * You should have received a copy of the GNU Library General Public
20  * License along with this library; if not, write to the
21  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
22  * Boston, MA 02111-1307, USA.
23  */
24 #ifndef __GST_QUEUE2_H__
25 #define __GST_QUEUE2_H__
26
27 #include <gst/gst.h>
28
29 G_BEGIN_DECLS
30
31 #define GST_TYPE_QUEUE2 \
32   (gst_queue2_get_type())
33 #define GST_QUEUE2(obj) \
34   (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_QUEUE2,GstQueue2))
35 #define GST_QUEUE2_CLASS(klass) \
36   (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_QUEUE2,GstQueue2Class))
37 #define GST_IS_QUEUE2(obj) \
38   (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_QUEUE2))
39 #define GST_IS_QUEUE2_CLASS(klass) \
40   (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_QUEUE2))
41 #define GST_QUEUE2_CAST(obj) \
42   ((GstQueue2 *)(obj))
43
44 typedef struct _GstQueue2 GstQueue2;
45 typedef struct _GstQueue2Size GstQueue2Size;
46 typedef struct _GstQueue2Class GstQueue2Class;
47
48 /* used to keep track of sizes (current and max) */
49 struct _GstQueue2Size
50 {
51   guint buffers;
52   guint bytes;
53   guint64 time;
54   guint64 rate_time;
55 };
56
57 struct _GstQueue2
58 {
59   GstElement element;
60
61   /*< private > */
62   GstPad *sinkpad;
63   GstPad *srcpad;
64
65   /* segments to keep track of timestamps */
66   GstSegment sink_segment;
67   GstSegment src_segment;
68
69   /* flowreturn when srcpad is paused */
70   GstFlowReturn srcresult;
71   gboolean is_eos;
72   gboolean unexpected;
73
74   /* the queue of data we're keeping our hands on */
75   GQueue *queue;
76
77   GstQueue2Size cur_level;       /* currently in the queue */
78   GstQueue2Size max_level;       /* max. amount of data allowed in the queue */
79   gboolean use_buffering;
80   gboolean use_rate_estimate;
81   GstClockTime buffering_interval;
82   gint low_percent;             /* low/high watermarks for buffering */
83   gint high_percent;
84
85   /* current buffering state */
86   gboolean is_buffering;
87   guint buffering_iteration;
88
89   /* for measuring input/output rates */
90   GTimer *in_timer;
91   gboolean in_timer_started;
92   gdouble last_in_elapsed;
93   guint64 bytes_in;
94   gdouble byte_in_rate;
95
96   GTimer *out_timer;
97   gboolean out_timer_started;
98   gdouble last_out_elapsed;
99   guint64 bytes_out;
100   gdouble byte_out_rate;
101
102   GMutex *qlock;                /* lock for queue (vs object lock) */
103   gboolean waiting_add;
104   GCond *item_add;              /* signals buffers now available for reading */
105   gboolean waiting_del;
106   GCond *item_del;              /* signals space now available for writing */
107
108   /* temp location stuff */
109   gchar *temp_template;
110   gboolean temp_location_set;
111   gchar *temp_location;
112   FILE *temp_file;
113   guint64 writing_pos;
114   guint64 reading_pos;
115   guint64 max_reading_pos;
116   /* we need this to send the first new segment event of the stream
117    * because we can't save it on the file */
118   gboolean segment_event_received;
119   GstEvent *starting_segment;
120
121 };
122
123 struct _GstQueue2Class
124 {
125   GstElementClass parent_class;
126 };
127
128 GType gst_queue2_get_type (void);
129
130 G_END_DECLS
131
132 #endif /* __GST_QUEUE2_H__ */