2000-12-29 05:38:06 +00:00
|
|
|
/* GStreamer
|
|
|
|
* Copyright (C) 1999,2000 Erik Walthinsen <omega@cse.ogi.edu>
|
|
|
|
* 2000 Wim Taymans <wtay@chello.be>
|
|
|
|
*
|
2005-10-15 15:30:24 +00:00
|
|
|
* gstqueue.h:
|
2000-01-30 09:03:00 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public
|
|
|
|
* License along with this library; if not, write to the
|
|
|
|
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
|
|
* Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __GST_QUEUE_H__
|
|
|
|
#define __GST_QUEUE_H__
|
|
|
|
|
2006-01-04 12:41:35 +00:00
|
|
|
#include <gst/gst.h>
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2002-07-08 19:22:02 +00:00
|
|
|
G_BEGIN_DECLS
|
2004-03-15 14:43:35 +00:00
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
#define GST_TYPE_QUEUE \
|
|
|
|
(gst_queue_get_type())
|
|
|
|
#define GST_QUEUE(obj) \
|
2001-06-25 01:20:11 +00:00
|
|
|
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_QUEUE,GstQueue))
|
2000-01-30 09:03:00 +00:00
|
|
|
#define GST_QUEUE_CLASS(klass) \
|
2001-06-25 01:20:11 +00:00
|
|
|
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_QUEUE,GstQueueClass))
|
2000-01-30 09:03:00 +00:00
|
|
|
#define GST_IS_QUEUE(obj) \
|
2001-06-25 01:20:11 +00:00
|
|
|
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_QUEUE))
|
2006-06-01 18:22:14 +00:00
|
|
|
#define GST_IS_QUEUE_CLASS(klass) \
|
2001-06-25 01:20:11 +00:00
|
|
|
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_QUEUE))
|
2011-11-17 11:40:45 +00:00
|
|
|
#define GST_QUEUE_CAST(obj) \
|
|
|
|
((GstQueue *)(obj))
|
2004-03-15 14:43:35 +00:00
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
typedef struct _GstQueue GstQueue;
|
2004-04-07 15:31:25 +00:00
|
|
|
typedef struct _GstQueueSize GstQueueSize;
|
2011-03-24 16:27:09 +00:00
|
|
|
typedef enum _GstQueueLeaky GstQueueLeaky;
|
2000-01-30 09:03:00 +00:00
|
|
|
typedef struct _GstQueueClass GstQueueClass;
|
|
|
|
|
2005-11-24 09:44:07 +00:00
|
|
|
/**
|
2011-03-24 16:27:09 +00:00
|
|
|
* GstQueueLeaky:
|
|
|
|
* @GST_QUEUE_NO_LEAK: Not Leaky
|
|
|
|
* @GST_QUEUE_LEAK_UPSTREAM: Leaky on upstream (new buffers)
|
|
|
|
* @GST_QUEUE_LEAK_DOWNSTREAM: Leaky on downstream (old buffers)
|
|
|
|
*
|
|
|
|
* Buffer dropping scheme to avoid the queue to block when full.
|
|
|
|
*/
|
|
|
|
enum _GstQueueLeaky {
|
|
|
|
GST_QUEUE_NO_LEAK = 0,
|
|
|
|
GST_QUEUE_LEAK_UPSTREAM = 1,
|
|
|
|
GST_QUEUE_LEAK_DOWNSTREAM = 2
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
2005-11-24 09:44:07 +00:00
|
|
|
* GstQueueSize:
|
|
|
|
* @buffers: number of buffers
|
|
|
|
* @bytes: number of bytes
|
|
|
|
* @time: amount of time
|
|
|
|
*
|
|
|
|
* Structure describing the size of a queue.
|
|
|
|
*/
|
2004-04-07 15:31:25 +00:00
|
|
|
struct _GstQueueSize {
|
2005-11-24 09:44:07 +00:00
|
|
|
guint buffers;
|
|
|
|
guint bytes;
|
|
|
|
guint64 time;
|
2004-04-07 15:31:25 +00:00
|
|
|
};
|
|
|
|
|
plugins/elements/gstqueue.*: Refactor an cleanup queue a bit.
Original commit message from CVS:
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_finalize), (update_time_level), (apply_segment),
(apply_buffer), (gst_queue_locked_flush),
(gst_queue_locked_enqueue), (gst_queue_locked_dequeue),
(gst_queue_handle_sink_event), (gst_queue_chain),
(gst_queue_push_one), (gst_queue_loop):
* plugins/elements/gstqueue.h:
Refactor an cleanup queue a bit.
Do better time level calculations that also work when the srcpad is not
yet running.
Remove some unneeded debug lines.
* tests/check/elements/queue.c: (GST_START_TEST), (queue_suite):
Added testcase for time level measurement.
Try to make some stuff more racefree.
2007-05-12 15:35:40 +00:00
|
|
|
#define GST_QUEUE_CLEAR_LEVEL(l) G_STMT_START { \
|
|
|
|
l.buffers = 0; \
|
|
|
|
l.bytes = 0; \
|
|
|
|
l.time = 0; \
|
|
|
|
} G_STMT_END
|
|
|
|
|
2005-11-24 09:44:07 +00:00
|
|
|
/**
|
|
|
|
* GstQueue:
|
|
|
|
*
|
|
|
|
* Opaque #GstQueue structure.
|
|
|
|
*/
|
2004-03-15 14:43:35 +00:00
|
|
|
struct _GstQueue {
|
2000-12-29 02:28:04 +00:00
|
|
|
GstElement element;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2005-11-24 09:44:07 +00:00
|
|
|
/*< private >*/
|
2000-01-30 09:03:00 +00:00
|
|
|
GstPad *sinkpad;
|
|
|
|
GstPad *srcpad;
|
|
|
|
|
2007-05-10 15:21:20 +00:00
|
|
|
/* segments to keep track of timestamps */
|
|
|
|
GstSegment sink_segment;
|
|
|
|
GstSegment src_segment;
|
|
|
|
|
2009-09-28 13:20:06 +00:00
|
|
|
/* position of src/sink */
|
|
|
|
GstClockTime sinktime, srctime;
|
|
|
|
/* TRUE if either position needs to be recalculated */
|
|
|
|
gboolean sink_tainted, src_tainted;
|
|
|
|
|
2005-07-19 17:46:37 +00:00
|
|
|
/* flowreturn when srcpad is paused */
|
|
|
|
GstFlowReturn srcresult;
|
2007-09-14 20:24:22 +00:00
|
|
|
gboolean unexpected;
|
|
|
|
gboolean eos;
|
2005-07-19 17:46:37 +00:00
|
|
|
|
2003-12-13 17:12:46 +00:00
|
|
|
/* the queue of data we're keeping our grubby hands on */
|
2011-11-03 23:08:52 +00:00
|
|
|
GQueue queue;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2004-04-07 15:31:25 +00:00
|
|
|
GstQueueSize
|
2009-08-28 15:49:11 +00:00
|
|
|
cur_level, /* currently in the queue */
|
|
|
|
max_size, /* max. amount of data allowed in the queue */
|
|
|
|
min_threshold, /* min. amount of data required to wake reader */
|
plugins/elements/gstqueue.*: In queue, when EOS is received, if minimum threshold > max_size - current_level, there i...
Original commit message from CVS:
Patch by Tommi Myöhänen <ext-tommi dot myohanen at nokia dot com>
* plugins/elements/gstqueue.c: (gst_queue_init),
(gst_queue_locked_flush), (gst_queue_handle_sink_event),
(gst_queue_set_property):
* plugins/elements/gstqueue.h:
In queue, when EOS is received, if minimum threshold > max_size -
current_level, there is chance that queue blocks forever in conditional item
del wait. This is because the queue is not emptied completely due to minimum
threshold.
Here is another approach. Instead of setting cur_levels to max in EOS, just
zero all minimum threshold levels. This should make sure that queue gives out
all data. When going to READY (stop) state, just reset the original minimum
threshold levels.
Fixes #336336.
2006-03-29 11:02:33 +00:00
|
|
|
orig_min_threshold; /* Original min.threshold, for reset in EOS */
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2003-12-13 17:12:46 +00:00
|
|
|
/* whether we leak data, and at which end */
|
|
|
|
gint leaky;
|
|
|
|
|
2012-01-19 08:27:04 +00:00
|
|
|
GMutex qlock; /* lock for queue (vs object lock) */
|
2010-10-12 16:48:10 +00:00
|
|
|
gboolean waiting_add;
|
2012-01-19 08:27:04 +00:00
|
|
|
GCond item_add; /* signals buffers now available for reading */
|
2010-10-12 16:48:10 +00:00
|
|
|
gboolean waiting_del;
|
2012-01-19 08:27:04 +00:00
|
|
|
GCond item_del; /* signals space now available for writing */
|
2009-08-28 15:49:11 +00:00
|
|
|
|
2008-02-20 15:44:33 +00:00
|
|
|
gboolean head_needs_discont, tail_needs_discont;
|
2010-03-05 16:18:23 +00:00
|
|
|
gboolean push_newsegment;
|
2011-03-24 16:27:09 +00:00
|
|
|
|
|
|
|
gboolean silent; /* don't emit signals */
|
2010-10-11 08:27:52 +00:00
|
|
|
|
|
|
|
/* whether the first new segment has been applied to src */
|
|
|
|
gboolean newseg_applied_to_src;
|
2012-03-14 14:42:33 +00:00
|
|
|
|
|
|
|
gboolean last_query;
|
2000-01-30 09:03:00 +00:00
|
|
|
};
|
|
|
|
|
2004-03-15 14:43:35 +00:00
|
|
|
struct _GstQueueClass {
|
2000-12-29 02:28:04 +00:00
|
|
|
GstElementClass parent_class;
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2003-12-13 17:12:46 +00:00
|
|
|
/* signals - 'running' is called from both sides
|
|
|
|
* which might make it sort of non-useful... */
|
2009-08-28 15:49:11 +00:00
|
|
|
void (*underrun) (GstQueue *queue);
|
|
|
|
void (*running) (GstQueue *queue);
|
|
|
|
void (*overrun) (GstQueue *queue);
|
2003-10-07 21:58:42 +00:00
|
|
|
|
2009-08-28 15:49:11 +00:00
|
|
|
void (*pushing) (GstQueue *queue);
|
2000-01-30 09:03:00 +00:00
|
|
|
};
|
|
|
|
|
2001-06-25 01:20:11 +00:00
|
|
|
GType gst_queue_get_type (void);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2002-07-08 19:22:02 +00:00
|
|
|
G_END_DECLS
|
2004-03-15 14:43:35 +00:00
|
|
|
|
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
#endif /* __GST_QUEUE_H__ */
|