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>
|
2003-04-17 09:19:34 +00:00
|
|
|
* 2003 Colin Walters <cwalters@gnome.org>
|
2005-05-29 13:57:00 +00:00
|
|
|
* 2004 Benjamin Otte <otte@gnome.org>
|
2000-12-29 05:38:06 +00:00
|
|
|
*
|
2001-01-20 17:59:25 +00:00
|
|
|
* gstqueue.c:
|
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.
|
|
|
|
*/
|
|
|
|
|
2002-07-08 19:22:02 +00:00
|
|
|
|
2001-01-19 00:02:53 +00:00
|
|
|
#include "gst_private.h"
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-01-19 00:02:53 +00:00
|
|
|
#include "gstqueue.h"
|
2001-05-25 21:00:07 +00:00
|
|
|
#include "gstscheduler.h"
|
2001-12-18 19:03:07 +00:00
|
|
|
#include "gstevent.h"
|
2003-06-29 14:05:49 +00:00
|
|
|
#include "gstinfo.h"
|
2004-01-18 21:36:20 +00:00
|
|
|
#include "gsterror.h"
|
2005-05-29 13:57:00 +00:00
|
|
|
#include "gstaction.h"
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2005-05-29 13:57:00 +00:00
|
|
|
/*
|
|
|
|
GST_DEBUG_CATEGORY_STATIC (queue_dataflow, "queue_dataflow", 0,
|
|
|
|
"dataflow inside the queue element");
|
|
|
|
#define GST_CAT_DEFAULT queue_dataflow
|
|
|
|
*/
|
2004-03-13 15:27:01 +00:00
|
|
|
static GstElementDetails gst_queue_details = GST_ELEMENT_DETAILS ("Queue",
|
|
|
|
"Generic",
|
|
|
|
"Simple data queue",
|
2005-05-29 13:57:00 +00:00
|
|
|
"Erik Walthinsen <omega@cse.ogi.edu>, " "Benjamin Otte <otte@gnome.org>");
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* Queue signals and args */
|
2004-03-13 15:27:01 +00:00
|
|
|
enum
|
|
|
|
{
|
2003-12-13 17:12:46 +00:00
|
|
|
SIGNAL_UNDERRUN,
|
|
|
|
SIGNAL_RUNNING,
|
|
|
|
SIGNAL_OVERRUN,
|
2000-01-30 09:03:00 +00:00
|
|
|
LAST_SIGNAL
|
|
|
|
};
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
enum
|
|
|
|
{
|
2000-01-30 09:03:00 +00:00
|
|
|
ARG_0,
|
2003-12-13 17:12:46 +00:00
|
|
|
/* FIXME: don't we have another way of doing this
|
|
|
|
* "Gstreamer format" (frame/byte/time) queries? */
|
|
|
|
ARG_CUR_LEVEL_BUFFERS,
|
|
|
|
ARG_CUR_LEVEL_BYTES,
|
|
|
|
ARG_CUR_LEVEL_TIME,
|
|
|
|
ARG_MAX_SIZE_BUFFERS,
|
|
|
|
ARG_MAX_SIZE_BYTES,
|
|
|
|
ARG_MAX_SIZE_TIME,
|
2004-01-15 20:37:07 +00:00
|
|
|
ARG_MIN_THRESHOLD_BUFFERS,
|
|
|
|
ARG_MIN_THRESHOLD_BYTES,
|
|
|
|
ARG_MIN_THRESHOLD_TIME,
|
2005-05-29 13:57:00 +00:00
|
|
|
ARG_MAX_THRESHOLD_BUFFERS,
|
|
|
|
ARG_MAX_THRESHOLD_BYTES,
|
|
|
|
ARG_MAX_THRESHOLD_TIME,
|
2001-05-25 21:00:07 +00:00
|
|
|
ARG_LEAKY,
|
2005-05-29 13:57:00 +00:00
|
|
|
/* FILL ME */
|
2000-01-30 09:03:00 +00:00
|
|
|
};
|
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
typedef struct _GstQueueEventResponse
|
|
|
|
{
|
2003-12-13 17:12:46 +00:00
|
|
|
GstEvent *event;
|
|
|
|
gboolean ret, handled;
|
2004-03-15 19:27:17 +00:00
|
|
|
}
|
|
|
|
GstQueueEventResponse;
|
2003-12-13 17:12:46 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static void gst_queue_base_init (GstQueueClass * klass);
|
|
|
|
static void gst_queue_class_init (GstQueueClass * klass);
|
|
|
|
static void gst_queue_init (GstQueue * queue);
|
2004-07-09 11:23:55 +00:00
|
|
|
static void gst_queue_finalize (GObject * object);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
|
|
|
static void gst_queue_set_property (GObject * object,
|
|
|
|
guint prop_id, const GValue * value, GParamSpec * pspec);
|
|
|
|
static void gst_queue_get_property (GObject * object,
|
|
|
|
guint prop_id, GValue * value, GParamSpec * pspec);
|
|
|
|
|
2005-05-29 13:57:00 +00:00
|
|
|
static GstData *gst_queue_release_srcpad (GstAction * action, GstRealPad * pad);
|
|
|
|
static void gst_queue_release_sinkpad (GstAction * action, GstRealPad * pad,
|
|
|
|
GstData * data);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
|
|
|
static gboolean gst_queue_handle_src_event (GstPad * pad, GstEvent * event);
|
|
|
|
|
|
|
|
static GstCaps *gst_queue_getcaps (GstPad * pad);
|
2005-05-29 13:57:00 +00:00
|
|
|
static GstPadLinkReturn gst_queue_link (GstPad * pad, const GstCaps * caps);
|
2004-03-13 15:27:01 +00:00
|
|
|
static void gst_queue_locked_flush (GstQueue * queue);
|
|
|
|
|
|
|
|
static GstElementStateReturn gst_queue_change_state (GstElement * element);
|
2000-11-25 14:18:47 +00:00
|
|
|
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2003-12-13 17:12:46 +00:00
|
|
|
#define GST_TYPE_QUEUE_LEAKY (queue_leaky_get_type ())
|
|
|
|
|
2001-06-25 01:20:11 +00:00
|
|
|
static GType
|
2003-12-13 17:12:46 +00:00
|
|
|
queue_leaky_get_type (void)
|
|
|
|
{
|
2001-06-25 01:20:11 +00:00
|
|
|
static GType queue_leaky_type = 0;
|
|
|
|
static GEnumValue queue_leaky[] = {
|
2004-03-13 15:27:01 +00:00
|
|
|
{GST_QUEUE_NO_LEAK, "0", "Not Leaky"},
|
|
|
|
{GST_QUEUE_LEAK_UPSTREAM, "1", "Leaky on Upstream"},
|
|
|
|
{GST_QUEUE_LEAK_DOWNSTREAM, "2", "Leaky on Downstream"},
|
|
|
|
{0, NULL, NULL},
|
2001-05-25 21:00:07 +00:00
|
|
|
};
|
2004-03-15 19:27:17 +00:00
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
if (!queue_leaky_type) {
|
2004-03-13 15:27:01 +00:00
|
|
|
queue_leaky_type = g_enum_register_static ("GstQueueLeaky", queue_leaky);
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
|
|
|
return queue_leaky_type;
|
|
|
|
}
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2000-12-29 02:28:04 +00:00
|
|
|
static GstElementClass *parent_class = NULL;
|
2003-04-17 09:19:34 +00:00
|
|
|
static guint gst_queue_signals[LAST_SIGNAL] = { 0 };
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-06-25 01:20:11 +00:00
|
|
|
GType
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_queue_get_type (void)
|
2001-08-21 20:16:48 +00:00
|
|
|
{
|
2001-06-25 01:20:11 +00:00
|
|
|
static GType queue_type = 0;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
|
|
|
if (!queue_type) {
|
2001-06-25 01:20:11 +00:00
|
|
|
static const GTypeInfo queue_info = {
|
2003-12-13 17:12:46 +00:00
|
|
|
sizeof (GstQueueClass),
|
|
|
|
(GBaseInitFunc) gst_queue_base_init,
|
2001-06-25 01:20:11 +00:00
|
|
|
NULL,
|
2003-12-13 17:12:46 +00:00
|
|
|
(GClassInitFunc) gst_queue_class_init,
|
2001-06-25 01:20:11 +00:00
|
|
|
NULL,
|
|
|
|
NULL,
|
2003-12-13 17:12:46 +00:00
|
|
|
sizeof (GstQueue),
|
2004-04-09 19:05:03 +00:00
|
|
|
0,
|
2003-12-13 17:12:46 +00:00
|
|
|
(GInstanceInitFunc) gst_queue_init,
|
2001-09-14 22:16:47 +00:00
|
|
|
NULL
|
2000-01-30 09:03:00 +00:00
|
|
|
};
|
2003-12-13 17:12:46 +00:00
|
|
|
|
|
|
|
queue_type = g_type_register_static (GST_TYPE_ELEMENT,
|
2004-03-15 19:27:17 +00:00
|
|
|
"GstQueue", &queue_info, 0);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
2003-12-13 17:12:46 +00:00
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
return queue_type;
|
|
|
|
}
|
|
|
|
|
2001-01-20 17:59:25 +00:00
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_queue_base_init (GstQueueClass * klass)
|
2000-11-25 14:18:47 +00:00
|
|
|
{
|
2003-12-13 17:12:46 +00:00
|
|
|
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
|
2003-10-31 19:32:47 +00:00
|
|
|
|
|
|
|
gst_element_class_set_details (gstelement_class, &gst_queue_details);
|
|
|
|
}
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2003-10-31 19:32:47 +00:00
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_queue_class_init (GstQueueClass * klass)
|
2003-10-31 19:32:47 +00:00
|
|
|
{
|
2003-12-13 17:12:46 +00:00
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2003-12-13 17:12:46 +00:00
|
|
|
parent_class = g_type_class_peek_parent (klass);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2003-12-13 17:12:46 +00:00
|
|
|
/* signals */
|
|
|
|
gst_queue_signals[SIGNAL_UNDERRUN] =
|
2004-03-13 15:27:01 +00:00
|
|
|
g_signal_new ("underrun", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GstQueueClass, underrun), NULL, NULL,
|
|
|
|
g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
|
2003-12-13 17:12:46 +00:00
|
|
|
gst_queue_signals[SIGNAL_RUNNING] =
|
2004-03-13 15:27:01 +00:00
|
|
|
g_signal_new ("running", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GstQueueClass, running), NULL, NULL,
|
|
|
|
g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
|
2003-12-13 17:12:46 +00:00
|
|
|
gst_queue_signals[SIGNAL_OVERRUN] =
|
2004-03-13 15:27:01 +00:00
|
|
|
g_signal_new ("overrun", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST,
|
|
|
|
G_STRUCT_OFFSET (GstQueueClass, overrun), NULL, NULL,
|
|
|
|
g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
|
2002-01-13 22:22:42 +00:00
|
|
|
|
2005-05-29 13:57:00 +00:00
|
|
|
/* set several parent class virtual functions */
|
|
|
|
gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_queue_finalize);
|
|
|
|
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_queue_set_property);
|
|
|
|
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_queue_get_property);
|
|
|
|
|
2003-12-13 17:12:46 +00:00
|
|
|
/* properties */
|
|
|
|
g_object_class_install_property (gobject_class, ARG_CUR_LEVEL_BYTES,
|
2004-03-13 15:27:01 +00:00
|
|
|
g_param_spec_uint ("current-level-bytes", "Current level (kB)",
|
2004-03-15 19:27:17 +00:00
|
|
|
"Current amount of data in the queue (bytes)",
|
|
|
|
0, G_MAXUINT, 0, G_PARAM_READABLE));
|
2003-12-13 17:12:46 +00:00
|
|
|
g_object_class_install_property (gobject_class, ARG_CUR_LEVEL_BUFFERS,
|
2004-03-13 15:27:01 +00:00
|
|
|
g_param_spec_uint ("current-level-buffers", "Current level (buffers)",
|
2004-03-15 19:27:17 +00:00
|
|
|
"Current number of buffers in the queue",
|
|
|
|
0, G_MAXUINT, 0, G_PARAM_READABLE));
|
2003-12-13 17:12:46 +00:00
|
|
|
g_object_class_install_property (gobject_class, ARG_CUR_LEVEL_TIME,
|
2004-03-13 15:27:01 +00:00
|
|
|
g_param_spec_uint64 ("current-level-time", "Current level (ns)",
|
2004-03-15 19:27:17 +00:00
|
|
|
"Current amount of data in the queue (in ns)",
|
|
|
|
0, G_MAXUINT64, 0, G_PARAM_READABLE));
|
2003-12-13 17:12:46 +00:00
|
|
|
|
|
|
|
g_object_class_install_property (gobject_class, ARG_MAX_SIZE_BYTES,
|
2004-03-13 15:27:01 +00:00
|
|
|
g_param_spec_uint ("max-size-bytes", "Max. size (kB)",
|
2004-03-15 19:27:17 +00:00
|
|
|
"Max. amount of data in the queue (bytes, 0=disable)",
|
|
|
|
0, G_MAXUINT, 0, G_PARAM_READWRITE));
|
2003-12-13 17:12:46 +00:00
|
|
|
g_object_class_install_property (gobject_class, ARG_MAX_SIZE_BUFFERS,
|
2004-03-13 15:27:01 +00:00
|
|
|
g_param_spec_uint ("max-size-buffers", "Max. size (buffers)",
|
2004-03-15 19:27:17 +00:00
|
|
|
"Max. number of buffers in the queue (0=disable)",
|
|
|
|
0, G_MAXUINT, 0, G_PARAM_READWRITE));
|
2003-12-13 17:12:46 +00:00
|
|
|
g_object_class_install_property (gobject_class, ARG_MAX_SIZE_TIME,
|
2004-03-13 15:27:01 +00:00
|
|
|
g_param_spec_uint64 ("max-size-time", "Max. size (ns)",
|
2004-03-15 19:27:17 +00:00
|
|
|
"Max. amount of data in the queue (in ns, 0=disable)",
|
|
|
|
0, G_MAXUINT64, 0, G_PARAM_READWRITE));
|
2003-12-13 17:12:46 +00:00
|
|
|
|
2004-01-15 20:37:07 +00:00
|
|
|
g_object_class_install_property (gobject_class, ARG_MIN_THRESHOLD_BYTES,
|
2004-03-13 15:27:01 +00:00
|
|
|
g_param_spec_uint ("min-threshold-bytes", "Min. threshold (kB)",
|
2004-03-15 19:27:17 +00:00
|
|
|
"Min. amount of data in the queue to allow reading (bytes, 0=disable)",
|
|
|
|
0, G_MAXUINT, 0, G_PARAM_READWRITE));
|
2004-01-15 20:37:07 +00:00
|
|
|
g_object_class_install_property (gobject_class, ARG_MIN_THRESHOLD_BUFFERS,
|
2004-03-13 15:27:01 +00:00
|
|
|
g_param_spec_uint ("min-threshold-buffers", "Min. threshold (buffers)",
|
2004-03-15 19:27:17 +00:00
|
|
|
"Min. number of buffers in the queue to allow reading (0=disable)",
|
|
|
|
0, G_MAXUINT, 0, G_PARAM_READWRITE));
|
2004-01-15 20:37:07 +00:00
|
|
|
g_object_class_install_property (gobject_class, ARG_MIN_THRESHOLD_TIME,
|
2004-03-13 15:27:01 +00:00
|
|
|
g_param_spec_uint64 ("min-threshold-time", "Min. threshold (ns)",
|
2004-03-15 19:27:17 +00:00
|
|
|
"Min. amount of data in the queue to allow reading (in ns, 0=disable)",
|
|
|
|
0, G_MAXUINT64, 0, G_PARAM_READWRITE));
|
2003-12-13 17:12:46 +00:00
|
|
|
|
2005-05-29 13:57:00 +00:00
|
|
|
g_object_class_install_property (gobject_class, ARG_MAX_THRESHOLD_BYTES,
|
|
|
|
g_param_spec_uint ("max-threshold-bytes", "Max. threshold (kB)",
|
|
|
|
"Max. amount of data in the queue to allow writing (bytes, 0=disable)",
|
|
|
|
0, G_MAXUINT, 0, G_PARAM_READWRITE));
|
|
|
|
g_object_class_install_property (gobject_class, ARG_MAX_THRESHOLD_BUFFERS,
|
|
|
|
g_param_spec_uint ("max-threshold-buffers", "Max. threshold (buffers)",
|
|
|
|
"Max. number of buffers in the queue to allow writing (0=disable)",
|
|
|
|
0, G_MAXUINT, 0, G_PARAM_READWRITE));
|
|
|
|
g_object_class_install_property (gobject_class, ARG_MAX_THRESHOLD_TIME,
|
|
|
|
g_param_spec_uint64 ("max-threshold-time", "Max. threshold (ns)",
|
|
|
|
"Max. amount of data in the queue to allow writing (in ns, 0=disable)",
|
|
|
|
0, G_MAXUINT64, 0, G_PARAM_READWRITE));
|
|
|
|
|
2003-12-13 17:12:46 +00:00
|
|
|
g_object_class_install_property (gobject_class, ARG_LEAKY,
|
2004-03-13 15:27:01 +00:00
|
|
|
g_param_spec_enum ("leaky", "Leaky",
|
2004-03-15 19:27:17 +00:00
|
|
|
"Where the queue leaks, if at all",
|
|
|
|
GST_TYPE_QUEUE_LEAKY, GST_QUEUE_NO_LEAK, G_PARAM_READWRITE));
|
2003-12-13 17:12:46 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_queue_change_state);
|
2002-01-13 22:22:42 +00:00
|
|
|
}
|
|
|
|
|
2001-01-20 17:59:25 +00:00
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_queue_init (GstQueue * queue)
|
2000-11-25 14:18:47 +00:00
|
|
|
{
|
2001-11-14 21:09:44 +00:00
|
|
|
GST_FLAG_SET (queue, GST_ELEMENT_EVENT_AWARE);
|
2000-12-20 09:39:43 +00:00
|
|
|
|
2005-05-29 13:57:00 +00:00
|
|
|
queue->sinkpad = gst_pad_new ("sink", GST_PAD_SINK);
|
|
|
|
gst_sink_pad_set_action_handler (queue->sinkpad, gst_queue_release_sinkpad);
|
2000-12-11 00:24:32 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (queue), queue->sinkpad);
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_pad_set_link_function (queue->sinkpad,
|
2005-05-29 13:57:00 +00:00
|
|
|
GST_DEBUG_FUNCPTR (gst_queue_link));
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_pad_set_getcaps_function (queue->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_queue_getcaps));
|
2000-09-24 14:29:49 +00:00
|
|
|
|
2005-05-29 13:57:00 +00:00
|
|
|
queue->srcpad = gst_pad_new ("src", GST_PAD_SRC);
|
|
|
|
gst_src_pad_set_action_handler (queue->srcpad, gst_queue_release_srcpad);
|
2000-11-25 14:18:47 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (queue), queue->srcpad);
|
2005-05-29 13:57:00 +00:00
|
|
|
gst_pad_set_link_function (queue->srcpad, GST_DEBUG_FUNCPTR (gst_queue_link));
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_pad_set_getcaps_function (queue->srcpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_queue_getcaps));
|
|
|
|
gst_pad_set_event_function (queue->srcpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_queue_handle_src_event));
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2004-03-15 19:27:17 +00:00
|
|
|
queue->cur_level.buffers = 0; /* no content */
|
|
|
|
queue->cur_level.bytes = 0; /* no content */
|
|
|
|
queue->cur_level.time = 0; /* no content */
|
|
|
|
queue->max_size.buffers = 100; /* 100 buffers */
|
|
|
|
queue->max_size.bytes = 10 * 1024 * 1024; /* 10 MB */
|
|
|
|
queue->max_size.time = GST_SECOND; /* 1 s. */
|
|
|
|
queue->min_threshold.buffers = 0; /* no threshold */
|
|
|
|
queue->min_threshold.bytes = 0; /* no threshold */
|
|
|
|
queue->min_threshold.time = 0; /* no threshold */
|
2005-05-29 13:57:00 +00:00
|
|
|
queue->max_threshold.buffers = 0; /* no threshold */
|
|
|
|
queue->max_threshold.bytes = 0; /* no threshold */
|
|
|
|
queue->max_threshold.time = 0; /* no threshold */
|
2003-12-13 17:12:46 +00:00
|
|
|
|
2001-12-29 03:02:14 +00:00
|
|
|
queue->leaky = GST_QUEUE_NO_LEAK;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-10-27 20:28:31 +00:00
|
|
|
queue->qlock = g_mutex_new ();
|
2002-07-08 19:22:02 +00:00
|
|
|
queue->queue = g_queue_new ();
|
2003-12-13 17:12:46 +00:00
|
|
|
|
|
|
|
GST_CAT_DEBUG_OBJECT (GST_CAT_THREAD, queue,
|
2004-03-13 15:27:01 +00:00
|
|
|
"initialized queue's not_empty & not_full conditions");
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2004-07-09 11:23:55 +00:00
|
|
|
/* called only once, as opposed to dispose */
|
2001-12-22 21:18:17 +00:00
|
|
|
static void
|
2004-07-09 11:23:55 +00:00
|
|
|
gst_queue_finalize (GObject * object)
|
2001-12-22 21:18:17 +00:00
|
|
|
{
|
|
|
|
GstQueue *queue = GST_QUEUE (object);
|
|
|
|
|
2004-07-09 11:23:55 +00:00
|
|
|
GST_DEBUG_OBJECT (queue, "finalizing queue");
|
2003-03-27 03:16:08 +00:00
|
|
|
|
2003-12-13 17:12:46 +00:00
|
|
|
while (!g_queue_is_empty (queue->queue)) {
|
|
|
|
GstData *data = g_queue_pop_head (queue->queue);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-12-13 17:12:46 +00:00
|
|
|
gst_data_unref (data);
|
|
|
|
}
|
2002-07-08 19:22:02 +00:00
|
|
|
g_queue_free (queue->queue);
|
2003-12-13 17:12:46 +00:00
|
|
|
g_mutex_free (queue->qlock);
|
2001-12-22 21:18:17 +00:00
|
|
|
|
2004-07-09 11:23:55 +00:00
|
|
|
if (G_OBJECT_CLASS (parent_class)->finalize)
|
|
|
|
G_OBJECT_CLASS (parent_class)->finalize (object);
|
2001-12-22 21:18:17 +00:00
|
|
|
}
|
|
|
|
|
2004-01-11 22:11:35 +00:00
|
|
|
static GstCaps *
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_queue_getcaps (GstPad * pad)
|
2004-01-11 22:11:35 +00:00
|
|
|
{
|
|
|
|
GstQueue *queue;
|
|
|
|
|
|
|
|
queue = GST_QUEUE (gst_pad_get_parent (pad));
|
|
|
|
|
2005-05-29 13:57:00 +00:00
|
|
|
if (queue->cur_level.bytes > 0) {
|
2004-01-11 22:11:35 +00:00
|
|
|
return gst_caps_copy (queue->negotiated_caps);
|
|
|
|
}
|
|
|
|
|
|
|
|
return gst_pad_proxy_getcaps (pad);
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstPadLinkReturn
|
2005-05-29 13:57:00 +00:00
|
|
|
gst_queue_link (GstPad * pad, const GstCaps * caps)
|
2004-01-11 22:11:35 +00:00
|
|
|
{
|
|
|
|
GstQueue *queue;
|
2005-05-29 13:57:00 +00:00
|
|
|
GstPadLinkReturn ret;
|
|
|
|
GstPad *otherpad;
|
2004-01-11 22:11:35 +00:00
|
|
|
|
|
|
|
queue = GST_QUEUE (gst_pad_get_parent (pad));
|
|
|
|
|
2004-01-14 01:50:31 +00:00
|
|
|
if (queue->cur_level.bytes > 0) {
|
gst/gstcaps.c: check for ANY caps before appending/unioning
Original commit message from CVS:
* gst/gstcaps.c: (gst_caps_append), (gst_caps_union):
check for ANY caps before appending/unioning
* gst/gstcaps.c: (gst_caps_is_subset),
(gst_caps_is_equal), (gst_caps_structure_subtract_field),
(gst_caps_structure_subtract), (gst_caps_subtract):
* gst/gstcaps.h:
add gst_caps_is_equal, gst_caps_is_subset and gst_caps_subtract to
the API. deprecate gst_caps_is_equal_fixed
* gst/gstpad.c: (gst_pad_try_set_caps):
* gst/gstqueue.c: (gst_queue_link):
s/gst_caps_is_equal_fixed/gst_caps_is_equal/
* gst/gststructure.c: (gst_structure_get_name_id):
* gst/gststructure.h:
add function gst_structure_get_name_id
* gst/gstvalue.c: (gst_value_subtract_int_int_range),
(gst_value_create_new_range), (gst_value_subtract_int_range_int),
(gst_value_subtract_int_range_int_range),
(gst_value_subtract_double_double_range),
(gst_value_subtract_double_range_double),
(gst_value_subtract_double_range_double_range),
(gst_value_subtract_from_list), (gst_value_subtract_list),
(gst_value_can_intersect), (gst_value_subtract),
(gst_value_can_subtract), (gst_value_register_subtract_func),
(_gst_value_initialize):
* gst/gstvalue.h:
add support for subtracting values from each other. Note that
subtracting means subtracting as in set theory. Required for caps
stuff above.
* testsuite/caps/.cvsignore:
* testsuite/caps/Makefile.am:
* testsuite/caps/erathostenes.c: (erathostenes), (main):
* testsuite/caps/sets.c: (check_caps), (main):
* testsuite/caps/subtract.c: (check_caps), (main):
add tests for subtraction and equality code.
2004-04-21 03:25:13 +00:00
|
|
|
if (gst_caps_is_equal (caps, queue->negotiated_caps)) {
|
2004-01-11 22:11:35 +00:00
|
|
|
return GST_PAD_LINK_OK;
|
|
|
|
}
|
|
|
|
return GST_PAD_LINK_REFUSED;
|
|
|
|
}
|
|
|
|
|
2005-05-29 13:57:00 +00:00
|
|
|
otherpad = (pad == queue->srcpad) ? queue->sinkpad : queue->srcpad;
|
|
|
|
ret = gst_pad_try_set_caps (otherpad, caps);
|
2004-01-11 22:11:35 +00:00
|
|
|
|
2005-05-29 13:57:00 +00:00
|
|
|
if (GST_PAD_LINK_SUCCESSFUL (ret)) {
|
2004-01-11 22:11:35 +00:00
|
|
|
/* we store an extra copy of the negotiated caps, just in case
|
|
|
|
* the pads become unnegotiated while we have buffers */
|
|
|
|
gst_caps_replace (&queue->negotiated_caps, gst_caps_copy (caps));
|
|
|
|
}
|
|
|
|
|
2005-05-29 13:57:00 +00:00
|
|
|
return ret;
|
2004-01-11 22:11:35 +00:00
|
|
|
}
|
|
|
|
|
2001-01-20 17:59:25 +00:00
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_queue_locked_flush (GstQueue * queue)
|
2000-11-25 14:18:47 +00:00
|
|
|
{
|
2005-05-29 13:57:00 +00:00
|
|
|
GstData *data;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2005-05-29 13:57:00 +00:00
|
|
|
while ((data = g_queue_pop_head (queue->queue))) {
|
2003-12-13 17:12:46 +00:00
|
|
|
gst_data_unref (data);
|
2002-07-08 19:22:02 +00:00
|
|
|
}
|
2005-05-29 13:57:00 +00:00
|
|
|
g_assert (g_queue_is_empty (queue->queue));
|
2003-12-13 17:12:46 +00:00
|
|
|
queue->cur_level.buffers = 0;
|
|
|
|
queue->cur_level.bytes = 0;
|
|
|
|
queue->cur_level.time = 0;
|
2005-05-29 13:57:00 +00:00
|
|
|
GST_DEBUG_OBJECT (queue, "flushed");
|
|
|
|
/* FIXME: wakeup sinkpad here? */
|
|
|
|
}
|
2003-12-13 17:12:46 +00:00
|
|
|
|
2005-05-29 13:57:00 +00:00
|
|
|
/* holds lock */
|
|
|
|
static void
|
|
|
|
gst_queue_add_data (GstQueue * queue, GstData * data)
|
|
|
|
{
|
|
|
|
g_queue_push_tail (queue->queue, data);
|
2003-12-13 17:12:46 +00:00
|
|
|
|
2005-05-29 13:57:00 +00:00
|
|
|
queue->cur_level.items++;
|
|
|
|
if (GST_IS_BUFFER (data)) {
|
|
|
|
queue->cur_level.buffers++;
|
|
|
|
queue->cur_level.bytes += GST_BUFFER_SIZE (data);
|
|
|
|
if (GST_BUFFER_DURATION (data) != GST_CLOCK_TIME_NONE)
|
|
|
|
queue->cur_level.time += GST_BUFFER_DURATION (data);
|
|
|
|
}
|
2000-10-30 21:02:08 +00:00
|
|
|
}
|
|
|
|
|
2005-05-29 13:57:00 +00:00
|
|
|
/* holds lock */
|
|
|
|
static GstData *
|
|
|
|
gst_queue_remove_data (GstQueue * queue, GstData * data)
|
2003-12-14 13:14:35 +00:00
|
|
|
{
|
2005-05-29 13:57:00 +00:00
|
|
|
if (data == NULL) {
|
|
|
|
data = g_queue_pop_head (queue->queue);
|
|
|
|
} else {
|
|
|
|
g_queue_remove (queue->queue, data);
|
|
|
|
}
|
|
|
|
if (!data) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
queue->cur_level.items--;
|
|
|
|
if (GST_IS_BUFFER (data)) {
|
|
|
|
queue->cur_level.buffers--;
|
|
|
|
queue->cur_level.bytes -= GST_BUFFER_SIZE (data);
|
|
|
|
if (GST_BUFFER_DURATION (data) != GST_CLOCK_TIME_NONE)
|
|
|
|
queue->cur_level.time -= GST_BUFFER_DURATION (data);
|
2003-12-14 13:14:35 +00:00
|
|
|
}
|
2005-05-29 13:57:00 +00:00
|
|
|
return data;
|
2003-12-14 13:14:35 +00:00
|
|
|
}
|
|
|
|
|
2005-05-29 13:57:00 +00:00
|
|
|
/* check if one of the sizes is smaller than the current size */
|
|
|
|
static gboolean
|
|
|
|
gst_queue_is_smaller (GstQueue * queue, GstQueueSize * size)
|
2000-11-25 14:18:47 +00:00
|
|
|
{
|
2005-05-29 13:57:00 +00:00
|
|
|
if (size->items > 0 && size->items < queue->cur_level.items)
|
|
|
|
return TRUE;
|
|
|
|
if (size->buffers > 0 && size->buffers < queue->cur_level.buffers)
|
|
|
|
return TRUE;
|
|
|
|
if (size->bytes > 0 && size->bytes < queue->cur_level.bytes)
|
|
|
|
return TRUE;
|
|
|
|
if (size->time > 0 && size->time < queue->cur_level.time)
|
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2005-05-29 13:57:00 +00:00
|
|
|
/* check if one of the sizes is bigger than the current size */
|
|
|
|
static gboolean
|
|
|
|
gst_queue_is_bigger (GstQueue * queue, GstQueueSize * size)
|
|
|
|
{
|
|
|
|
if (size->items > 0 && size->items >= queue->cur_level.items)
|
|
|
|
return TRUE;
|
|
|
|
if (size->buffers > 0 && size->buffers >= queue->cur_level.buffers)
|
|
|
|
return TRUE;
|
|
|
|
if (size->bytes > 0 && size->bytes >= queue->cur_level.bytes)
|
|
|
|
return TRUE;
|
|
|
|
if (size->time > 0 && size->time >= queue->cur_level.time)
|
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2005-05-29 13:57:00 +00:00
|
|
|
#define STATUS(queue, msg) \
|
|
|
|
GST_LOG_OBJECT (queue, \
|
|
|
|
msg ": %u of %u-%u buffers, %u of %u-%u " \
|
|
|
|
"bytes, %" G_GUINT64_FORMAT " of %" G_GUINT64_FORMAT \
|
|
|
|
"-%" G_GUINT64_FORMAT " ns, %u elements", \
|
|
|
|
queue->cur_level.buffers, \
|
|
|
|
queue->min_threshold.buffers, \
|
|
|
|
queue->max_size.buffers, \
|
|
|
|
queue->cur_level.bytes, \
|
|
|
|
queue->min_threshold.bytes, \
|
|
|
|
queue->max_size.bytes, \
|
|
|
|
queue->cur_level.time, \
|
|
|
|
queue->min_threshold.time, \
|
|
|
|
queue->max_size.time, \
|
|
|
|
queue->queue->length)
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2005-05-29 13:57:00 +00:00
|
|
|
static gint
|
|
|
|
is_buffer (gconstpointer buf, gconstpointer unused)
|
|
|
|
{
|
|
|
|
if (GST_IS_BUFFER (buf));
|
|
|
|
return 0;
|
|
|
|
return 1;
|
|
|
|
}
|
2003-12-13 17:12:46 +00:00
|
|
|
|
2005-05-29 13:57:00 +00:00
|
|
|
static gint
|
|
|
|
is_buffer_last (gconstpointer buf, gconstpointer datap)
|
|
|
|
{
|
|
|
|
GstData **data = (GstData **) datap;
|
2003-12-13 17:12:46 +00:00
|
|
|
|
2005-05-29 13:57:00 +00:00
|
|
|
if (GST_IS_BUFFER (buf));
|
|
|
|
*data = (GstData *) buf;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_queue_release_sinkpad (GstAction * action, GstRealPad * pad, GstData * data)
|
|
|
|
{
|
|
|
|
gboolean ret = TRUE;
|
|
|
|
GstQueue *queue = GST_QUEUE (gst_pad_get_parent (GST_PAD (pad)));
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-10-08 16:06:02 +00:00
|
|
|
if (GST_IS_EVENT (data)) {
|
|
|
|
switch (GST_EVENT_TYPE (data)) {
|
2001-10-27 20:28:31 +00:00
|
|
|
case GST_EVENT_FLUSH:
|
2004-03-15 19:27:17 +00:00
|
|
|
STATUS (queue, "received flush event");
|
|
|
|
gst_queue_locked_flush (queue);
|
|
|
|
STATUS (queue, "after flush");
|
|
|
|
break;
|
2001-11-14 21:09:44 +00:00
|
|
|
case GST_EVENT_EOS:
|
2004-03-15 19:27:17 +00:00
|
|
|
STATUS (queue, "received EOS");
|
2005-05-29 13:57:00 +00:00
|
|
|
queue->got_eos = TRUE;
|
|
|
|
ret = FALSE;
|
2004-03-15 19:27:17 +00:00
|
|
|
break;
|
2001-10-27 20:28:31 +00:00
|
|
|
default:
|
2004-03-15 19:27:17 +00:00
|
|
|
/* we put the event in the queue, we don't have to act ourselves */
|
2005-05-29 13:57:00 +00:00
|
|
|
GST_LOG_OBJECT (queue,
|
2004-03-15 19:27:17 +00:00
|
|
|
"adding event %p of type %d", data, GST_EVENT_TYPE (data));
|
|
|
|
break;
|
2001-10-27 20:28:31 +00:00
|
|
|
}
|
2000-07-12 22:52:42 +00:00
|
|
|
}
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2005-05-29 13:57:00 +00:00
|
|
|
gst_queue_add_data (queue, data);
|
|
|
|
|
|
|
|
if (GST_IS_BUFFER (data)) {
|
|
|
|
GST_LOG_OBJECT (queue,
|
|
|
|
"adding buffer %p of size %d", data, GST_BUFFER_SIZE (data));
|
|
|
|
} else {
|
|
|
|
GST_LOG_OBJECT (queue,
|
|
|
|
"adding event %p of type %d", data, GST_EVENT_TYPE (data));
|
|
|
|
}
|
|
|
|
STATUS (queue, "+ level");
|
2003-12-13 17:12:46 +00:00
|
|
|
|
|
|
|
/* We make space available if we're "full" according to whatever
|
|
|
|
* the user defined as "full". Note that this only applies to buffers.
|
2005-05-29 13:57:00 +00:00
|
|
|
* We always handle events and they don't count in our statistics.
|
|
|
|
* We still check, it could be someone changed properties */
|
|
|
|
if (gst_queue_is_smaller (queue, &queue->max_size)) {
|
2003-12-13 17:12:46 +00:00
|
|
|
g_signal_emit (G_OBJECT (queue), gst_queue_signals[SIGNAL_OVERRUN], 0);
|
2005-05-29 13:57:00 +00:00
|
|
|
/* FIXME: need to recheck no buffers got processed? */
|
2003-04-17 09:19:34 +00:00
|
|
|
|
2003-12-13 17:12:46 +00:00
|
|
|
/* how are we going to make space for this buffer? */
|
|
|
|
switch (queue->leaky) {
|
2005-05-29 13:57:00 +00:00
|
|
|
/* leak buffers from end of queue */
|
2003-12-13 17:12:46 +00:00
|
|
|
case GST_QUEUE_LEAK_UPSTREAM:
|
2005-05-29 13:57:00 +00:00
|
|
|
do {
|
|
|
|
GstData *leak;
|
|
|
|
|
|
|
|
g_queue_find_custom (queue->queue, &leak, is_buffer_last);
|
|
|
|
g_assert (leak);
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (queue,
|
|
|
|
"queue is full, leaking buffer %p on upstream end", leak);
|
|
|
|
gst_queue_remove_data (queue, leak);
|
|
|
|
gst_data_unref (leak);
|
|
|
|
} while (gst_queue_is_smaller (queue, &queue->max_size));
|
|
|
|
|
|
|
|
case GST_QUEUE_LEAK_DOWNSTREAM:
|
|
|
|
/* leak buffers from front of the queue */
|
|
|
|
do {
|
|
|
|
GList *item = g_queue_find_custom (queue->queue, NULL, is_buffer);
|
|
|
|
GstData *leak;
|
|
|
|
|
|
|
|
g_assert (item);
|
|
|
|
leak = item->data;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (queue,
|
|
|
|
"queue is full, leaking buffer %p on downstream end", leak);
|
|
|
|
gst_queue_remove_data (queue, leak);
|
|
|
|
gst_data_unref (leak);
|
|
|
|
} while (gst_queue_is_smaller (queue, &queue->max_size));
|
|
|
|
|
2004-03-15 19:27:17 +00:00
|
|
|
break;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2003-12-13 17:12:46 +00:00
|
|
|
default:
|
2004-03-15 19:27:17 +00:00
|
|
|
g_warning ("Unknown leaky type, using default");
|
|
|
|
/* fall-through */
|
2003-12-13 17:12:46 +00:00
|
|
|
|
|
|
|
case GST_QUEUE_NO_LEAK:
|
2005-05-29 13:57:00 +00:00
|
|
|
/* don't leak. Instead, wait for space to be available */
|
|
|
|
/* wake up other pad in any case */
|
|
|
|
gst_real_pad_set_active (GST_REAL_PAD (queue->srcpad), TRUE);
|
|
|
|
gst_real_pad_set_active (GST_REAL_PAD (queue->sinkpad), FALSE);
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
2000-02-13 13:43:32 +00:00
|
|
|
}
|
|
|
|
|
2005-05-29 13:57:00 +00:00
|
|
|
if (gst_queue_is_smaller (queue, &queue->max_threshold) ||
|
|
|
|
queue->max_threshold.items + queue->max_threshold.buffers +
|
|
|
|
queue->max_threshold.bytes + queue->max_threshold.time == 0) {
|
|
|
|
gst_real_pad_set_active (GST_REAL_PAD (queue->srcpad), TRUE);
|
2003-12-13 17:12:46 +00:00
|
|
|
}
|
2002-07-08 19:22:02 +00:00
|
|
|
|
2005-05-29 13:57:00 +00:00
|
|
|
if (!ret)
|
|
|
|
gst_real_pad_set_active (GST_REAL_PAD (queue->sinkpad), FALSE);
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2003-10-08 16:06:02 +00:00
|
|
|
static GstData *
|
2005-05-29 13:57:00 +00:00
|
|
|
gst_queue_release_srcpad (GstAction * action, GstRealPad * pad)
|
2000-11-25 14:18:47 +00:00
|
|
|
{
|
2003-12-13 17:12:46 +00:00
|
|
|
GstData *data;
|
2005-05-29 13:57:00 +00:00
|
|
|
GstQueue *queue = GST_QUEUE (gst_pad_get_parent (GST_PAD (pad)));
|
2000-12-21 01:27:27 +00:00
|
|
|
|
2003-12-13 17:12:46 +00:00
|
|
|
/* There's something in the list now, whatever it is */
|
2005-05-29 13:57:00 +00:00
|
|
|
GST_DEBUG_OBJECT (queue, "calling get function with %u elements in queue",
|
|
|
|
queue->cur_level.items);
|
|
|
|
data = gst_queue_remove_data (queue, NULL);
|
|
|
|
GST_LOG_OBJECT (queue, "retrieved data %p from queue", *data);
|
|
|
|
|
|
|
|
if (data == NULL) {
|
|
|
|
/* queue is empty and we pulled? */
|
|
|
|
GST_WARNING_OBJECT (queue, "queue is empty and we pulled?");
|
|
|
|
gst_real_pad_set_active (GST_REAL_PAD (queue->sinkpad), TRUE);
|
|
|
|
gst_real_pad_set_active (GST_REAL_PAD (queue->srcpad), FALSE);
|
|
|
|
g_signal_emit (G_OBJECT (queue), gst_queue_signals[SIGNAL_UNDERRUN], 0);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2004-02-15 19:05:59 +00:00
|
|
|
return NULL;
|
2003-12-13 17:12:46 +00:00
|
|
|
}
|
2001-12-29 03:02:14 +00:00
|
|
|
|
2005-05-29 13:57:00 +00:00
|
|
|
if ((gst_queue_is_bigger (queue, &queue->min_threshold) ||
|
|
|
|
queue->min_threshold.items + queue->min_threshold.buffers +
|
|
|
|
queue->min_threshold.bytes + queue->min_threshold.time == 0) &&
|
|
|
|
!queue->got_eos) {
|
|
|
|
gst_real_pad_set_active (GST_REAL_PAD (queue->sinkpad), TRUE);
|
|
|
|
}
|
2001-10-27 20:28:31 +00:00
|
|
|
|
2003-10-08 16:06:02 +00:00
|
|
|
if (GST_IS_EVENT (data)) {
|
|
|
|
GstEvent *event = GST_EVENT (data);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2003-12-13 17:12:46 +00:00
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
2001-10-27 20:28:31 +00:00
|
|
|
case GST_EVENT_EOS:
|
2005-05-29 13:57:00 +00:00
|
|
|
GST_DEBUG_OBJECT (queue, "eos", GST_ELEMENT_NAME (queue));
|
2004-03-15 19:27:17 +00:00
|
|
|
gst_element_set_eos (GST_ELEMENT (queue));
|
2005-05-29 13:57:00 +00:00
|
|
|
queue->got_eos = FALSE;
|
|
|
|
gst_real_pad_set_active (GST_REAL_PAD (queue->sinkpad), TRUE);
|
2004-03-15 19:27:17 +00:00
|
|
|
break;
|
2001-10-27 20:28:31 +00:00
|
|
|
default:
|
2004-03-15 19:27:17 +00:00
|
|
|
break;
|
2001-10-27 20:28:31 +00:00
|
|
|
}
|
|
|
|
}
|
2000-02-13 13:43:32 +00:00
|
|
|
|
2005-05-29 13:57:00 +00:00
|
|
|
if (g_queue_is_empty (queue->queue)) {
|
|
|
|
g_signal_emit (G_OBJECT (queue), gst_queue_signals[SIGNAL_UNDERRUN], 0);
|
|
|
|
gst_real_pad_set_active (GST_REAL_PAD (queue->sinkpad), TRUE);
|
|
|
|
gst_real_pad_set_active (GST_REAL_PAD (queue->srcpad), FALSE);
|
|
|
|
}
|
|
|
|
|
2003-10-08 16:06:02 +00:00
|
|
|
return data;
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2002-05-26 21:54:27 +00:00
|
|
|
static gboolean
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_queue_handle_src_event (GstPad * pad, GstEvent * event)
|
2002-05-26 21:54:27 +00:00
|
|
|
{
|
2003-12-13 17:12:46 +00:00
|
|
|
GstQueue *queue = GST_QUEUE (gst_pad_get_parent (pad));
|
2005-05-29 13:57:00 +00:00
|
|
|
gboolean ret;
|
2005-03-09 11:45:03 +00:00
|
|
|
|
2005-05-29 13:57:00 +00:00
|
|
|
GST_DEBUG_OBJECT (queue, "got event %p (%d)", event, GST_EVENT_TYPE (event));
|
2004-10-11 13:14:03 +00:00
|
|
|
|
2005-05-29 13:57:00 +00:00
|
|
|
ret =
|
|
|
|
gst_pad_send_event ((pad ==
|
|
|
|
queue->srcpad) ? queue->sinkpad : queue->srcpad, event);
|
|
|
|
if (!ret)
|
2004-10-11 13:14:03 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2005-05-29 13:57:00 +00:00
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
case GST_EVENT_FLUSH:
|
|
|
|
GST_DEBUG_OBJECT (queue, "FLUSH event, flushing queue\n");
|
|
|
|
gst_queue_locked_flush (queue);
|
|
|
|
break;
|
|
|
|
case GST_EVENT_SEEK:
|
|
|
|
if (GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH) {
|
|
|
|
gst_queue_locked_flush (queue);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2004-10-11 13:14:03 +00:00
|
|
|
}
|
2002-05-26 21:54:27 +00:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2001-01-20 17:59:25 +00:00
|
|
|
static GstElementStateReturn
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_queue_change_state (GstElement * element)
|
2000-11-25 14:18:47 +00:00
|
|
|
{
|
2000-10-30 21:02:08 +00:00
|
|
|
GstQueue *queue;
|
2003-12-13 17:12:46 +00:00
|
|
|
GstElementStateReturn ret = GST_STATE_SUCCESS;
|
2005-05-29 13:57:00 +00:00
|
|
|
guint transition = GST_STATE_TRANSITION (element);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2000-11-25 14:18:47 +00:00
|
|
|
queue = GST_QUEUE (element);
|
2001-05-25 21:00:07 +00:00
|
|
|
|
2005-05-29 13:57:00 +00:00
|
|
|
GST_CAT_LOG_OBJECT (GST_CAT_STATES, element, "starting state change");
|
2001-12-04 22:12:50 +00:00
|
|
|
|
2005-05-29 13:57:00 +00:00
|
|
|
if (GST_ELEMENT_CLASS (parent_class)->change_state)
|
|
|
|
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element);
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2005-05-29 13:57:00 +00:00
|
|
|
switch (transition) {
|
2003-01-15 21:01:58 +00:00
|
|
|
case GST_STATE_PAUSED_TO_READY:
|
|
|
|
gst_queue_locked_flush (queue);
|
2004-06-06 19:44:19 +00:00
|
|
|
gst_caps_replace (&queue->negotiated_caps, NULL);
|
2003-01-15 21:01:58 +00:00
|
|
|
break;
|
2003-12-13 17:12:46 +00:00
|
|
|
default:
|
2003-01-15 21:01:58 +00:00
|
|
|
break;
|
2001-12-04 22:12:50 +00:00
|
|
|
}
|
|
|
|
|
2003-06-29 14:05:49 +00:00
|
|
|
GST_CAT_LOG_OBJECT (GST_CAT_STATES, element, "done with state change");
|
2003-12-13 17:12:46 +00:00
|
|
|
|
2001-05-25 21:00:07 +00:00
|
|
|
return ret;
|
2000-10-30 21:02:08 +00:00
|
|
|
}
|
|
|
|
|
2001-01-20 17:59:25 +00:00
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_queue_set_property (GObject * object,
|
|
|
|
guint prop_id, const GValue * value, GParamSpec * pspec)
|
2000-11-25 14:18:47 +00:00
|
|
|
{
|
2003-12-13 17:12:46 +00:00
|
|
|
GstQueue *queue = GST_QUEUE (object);
|
2001-01-20 17:59:25 +00:00
|
|
|
|
2001-06-25 01:20:11 +00:00
|
|
|
switch (prop_id) {
|
2003-12-13 17:12:46 +00:00
|
|
|
case ARG_MAX_SIZE_BYTES:
|
|
|
|
queue->max_size.bytes = g_value_get_uint (value);
|
|
|
|
break;
|
|
|
|
case ARG_MAX_SIZE_BUFFERS:
|
|
|
|
queue->max_size.buffers = g_value_get_uint (value);
|
|
|
|
break;
|
|
|
|
case ARG_MAX_SIZE_TIME:
|
|
|
|
queue->max_size.time = g_value_get_uint64 (value);
|
2000-02-13 15:20:49 +00:00
|
|
|
break;
|
2004-01-15 20:37:07 +00:00
|
|
|
case ARG_MIN_THRESHOLD_BYTES:
|
|
|
|
queue->min_threshold.bytes = g_value_get_uint (value);
|
2001-12-22 21:18:17 +00:00
|
|
|
break;
|
2004-01-15 20:37:07 +00:00
|
|
|
case ARG_MIN_THRESHOLD_BUFFERS:
|
|
|
|
queue->min_threshold.buffers = g_value_get_uint (value);
|
2003-12-13 17:12:46 +00:00
|
|
|
break;
|
2004-01-15 20:37:07 +00:00
|
|
|
case ARG_MIN_THRESHOLD_TIME:
|
|
|
|
queue->min_threshold.time = g_value_get_uint64 (value);
|
2003-12-13 17:12:46 +00:00
|
|
|
break;
|
2005-05-29 13:57:00 +00:00
|
|
|
case ARG_MAX_THRESHOLD_BYTES:
|
|
|
|
queue->max_threshold.bytes = g_value_get_uint (value);
|
2003-05-30 23:20:02 +00:00
|
|
|
break;
|
2005-05-29 13:57:00 +00:00
|
|
|
case ARG_MAX_THRESHOLD_BUFFERS:
|
|
|
|
queue->max_threshold.buffers = g_value_get_uint (value);
|
2000-12-26 23:51:04 +00:00
|
|
|
break;
|
2005-05-29 13:57:00 +00:00
|
|
|
case ARG_MAX_THRESHOLD_TIME:
|
|
|
|
queue->max_threshold.time = g_value_get_uint64 (value);
|
|
|
|
break;
|
|
|
|
case ARG_LEAKY:
|
|
|
|
queue->leaky = g_value_get_enum (value);
|
2002-06-03 15:44:28 +00:00
|
|
|
break;
|
2000-01-30 09:03:00 +00:00
|
|
|
default:
|
2001-06-25 01:20:11 +00:00
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
2000-01-30 09:03:00 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-01-20 17:59:25 +00:00
|
|
|
static void
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_queue_get_property (GObject * object,
|
|
|
|
guint prop_id, GValue * value, GParamSpec * pspec)
|
2000-11-25 14:18:47 +00:00
|
|
|
{
|
2003-12-13 17:12:46 +00:00
|
|
|
GstQueue *queue = GST_QUEUE (object);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-06-25 01:20:11 +00:00
|
|
|
switch (prop_id) {
|
2003-12-13 17:12:46 +00:00
|
|
|
case ARG_CUR_LEVEL_BYTES:
|
|
|
|
g_value_set_uint (value, queue->cur_level.bytes);
|
|
|
|
break;
|
|
|
|
case ARG_CUR_LEVEL_BUFFERS:
|
|
|
|
g_value_set_uint (value, queue->cur_level.buffers);
|
|
|
|
break;
|
|
|
|
case ARG_CUR_LEVEL_TIME:
|
|
|
|
g_value_set_uint64 (value, queue->cur_level.time);
|
|
|
|
break;
|
|
|
|
case ARG_MAX_SIZE_BYTES:
|
|
|
|
g_value_set_uint (value, queue->max_size.bytes);
|
2001-05-25 21:00:07 +00:00
|
|
|
break;
|
2003-12-13 17:12:46 +00:00
|
|
|
case ARG_MAX_SIZE_BUFFERS:
|
|
|
|
g_value_set_uint (value, queue->max_size.buffers);
|
2000-01-30 09:03:00 +00:00
|
|
|
break;
|
2003-12-13 17:12:46 +00:00
|
|
|
case ARG_MAX_SIZE_TIME:
|
|
|
|
g_value_set_uint64 (value, queue->max_size.time);
|
2001-12-22 21:18:17 +00:00
|
|
|
break;
|
2004-01-15 20:37:07 +00:00
|
|
|
case ARG_MIN_THRESHOLD_BYTES:
|
|
|
|
g_value_set_uint (value, queue->min_threshold.bytes);
|
2003-12-13 17:12:46 +00:00
|
|
|
break;
|
2004-01-15 20:37:07 +00:00
|
|
|
case ARG_MIN_THRESHOLD_BUFFERS:
|
|
|
|
g_value_set_uint (value, queue->min_threshold.buffers);
|
2003-12-13 17:12:46 +00:00
|
|
|
break;
|
2004-01-15 20:37:07 +00:00
|
|
|
case ARG_MIN_THRESHOLD_TIME:
|
|
|
|
g_value_set_uint64 (value, queue->min_threshold.time);
|
2003-12-13 17:12:46 +00:00
|
|
|
break;
|
2005-05-29 13:57:00 +00:00
|
|
|
case ARG_MAX_THRESHOLD_BYTES:
|
|
|
|
g_value_set_uint (value, queue->max_threshold.bytes);
|
2003-05-30 23:20:02 +00:00
|
|
|
break;
|
2005-05-29 13:57:00 +00:00
|
|
|
case ARG_MAX_THRESHOLD_BUFFERS:
|
|
|
|
g_value_set_uint (value, queue->max_threshold.buffers);
|
2000-12-26 23:51:04 +00:00
|
|
|
break;
|
2005-05-29 13:57:00 +00:00
|
|
|
case ARG_MAX_THRESHOLD_TIME:
|
|
|
|
g_value_set_uint64 (value, queue->max_threshold.time);
|
|
|
|
break;
|
|
|
|
case ARG_LEAKY:
|
|
|
|
g_value_set_enum (value, queue->leaky);
|
2002-06-03 15:44:28 +00:00
|
|
|
break;
|
2000-01-30 09:03:00 +00:00
|
|
|
default:
|
2001-06-25 01:20:11 +00:00
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
2000-01-30 09:03:00 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|