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-03-21 17:34:02 +00:00
|
|
|
* 2005 Wim Taymans <wim@fluendo.com>
|
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"
|
2005-03-21 17:34:02 +00:00
|
|
|
#include "gstpipeline.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"
|
2000-01-30 09:03:00 +00:00
|
|
|
|
gst/: s/gst_pad_new/&_from_template/ register pad templates in the base_init function add static pad template definit...
Original commit message from CVS:
* gst/autoplug/gstspideridentity.c:
(gst_spider_identity_request_new_pad):
* gst/elements/gstaggregator.c: (gst_aggregator_base_init),
(gst_aggregator_init):
* gst/elements/gstfakesink.c: (gst_fakesink_base_init),
(gst_fakesink_init):
* gst/elements/gstfakesrc.c: (gst_fakesrc_base_init),
(gst_fakesrc_init):
* gst/elements/gstfdsink.c: (gst_fdsink_base_init),
(gst_fdsink_init):
* gst/elements/gstfdsrc.c: (gst_fdsrc_base_init), (gst_fdsrc_init):
* gst/elements/gstfilesink.c: (gst_filesink_base_init),
(gst_filesink_init):
* gst/elements/gstfilesrc.c: (gst_filesrc_base_init),
(gst_filesrc_init):
* gst/elements/gstidentity.c: (gst_identity_base_init),
(gst_identity_init):
* gst/elements/gstmultifilesrc.c: (gst_multifilesrc_base_init),
(gst_multifilesrc_init):
* gst/elements/gstpipefilter.c: (gst_pipefilter_base_init),
(gst_pipefilter_init):
* gst/elements/gststatistics.c: (gst_statistics_base_init),
(gst_statistics_init):
* gst/elements/gsttee.c: (gst_tee_base_init), (gst_tee_init):
* gst/gstqueue.c: (gst_queue_base_init), (gst_queue_init):
s/gst_pad_new/&_from_template/
register pad templates in the base_init function
add static pad template definitions
2004-08-17 14:11:23 +00:00
|
|
|
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
|
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS_ANY);
|
|
|
|
|
|
|
|
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
|
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS_ANY);
|
|
|
|
|
gst/elements/gstfilesrc.c: compute mapsize correctly
Original commit message from CVS:
* gst/elements/gstfilesrc.c: (gst_filesrc_get_mmap):
compute mapsize correctly
* gst/elements/gstfilesrc.c: (gst_filesrc_get_mmap):
use correct datatypes when calling a varargs function
* gst/elements/gsttypefindelement.c: (stop_typefinding):
push a DISCONT event as first thing
* gst/gst_private.h:
* gst/gstinfo.c: (_gst_debug_init):
remove GST_DATAFLOW debugging category
* gst/gstbin.c: (gst_bin_iterate):
use GST_SCHEDULING category
* gst/gstpad.c: (gst_pad_get_type), (_invent_event),
(gst_pad_push), (gst_pad_pull), (gst_pad_call_chain_function),
(gst_pad_call_get_function):
add GST_DATAFLOW to easily track flow of buffers or events.
* gst/gstqueue.c: (gst_queue_get_type),
(gst_queue_handle_pending_events), (gst_queue_chain),
(gst_queue_get), (gst_queue_handle_src_event):
use own static debugging category GST_DATAFLOW for dataflow,
use DEBUG category for showing which path events go, use LOG
category for buffers.
2004-05-11 16:20:41 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (queue_dataflow);
|
2005-01-08 18:10:50 +00:00
|
|
|
#define GST_CAT_DEFAULT (queue_dataflow)
|
|
|
|
|
|
|
|
#define STATUS(queue, msg) \
|
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue, \
|
|
|
|
"(%s:%s) " msg ": %u of %u-%u buffers, %u of %u-%u " \
|
|
|
|
"bytes, %" G_GUINT64_FORMAT " of %" G_GUINT64_FORMAT \
|
|
|
|
"-%" G_GUINT64_FORMAT " ns, %u elements", \
|
|
|
|
GST_DEBUG_PAD_NAME (pad), \
|
|
|
|
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)
|
gst/elements/gstfilesrc.c: compute mapsize correctly
Original commit message from CVS:
* gst/elements/gstfilesrc.c: (gst_filesrc_get_mmap):
compute mapsize correctly
* gst/elements/gstfilesrc.c: (gst_filesrc_get_mmap):
use correct datatypes when calling a varargs function
* gst/elements/gsttypefindelement.c: (stop_typefinding):
push a DISCONT event as first thing
* gst/gst_private.h:
* gst/gstinfo.c: (_gst_debug_init):
remove GST_DATAFLOW debugging category
* gst/gstbin.c: (gst_bin_iterate):
use GST_SCHEDULING category
* gst/gstpad.c: (gst_pad_get_type), (_invent_event),
(gst_pad_push), (gst_pad_pull), (gst_pad_call_chain_function),
(gst_pad_call_get_function):
add GST_DATAFLOW to easily track flow of buffers or events.
* gst/gstqueue.c: (gst_queue_get_type),
(gst_queue_handle_pending_events), (gst_queue_chain),
(gst_queue_get), (gst_queue_handle_src_event):
use own static debugging category GST_DATAFLOW for dataflow,
use DEBUG category for showing which path events go, use LOG
category for buffers.
2004-05-11 16:20:41 +00:00
|
|
|
|
2004-03-13 15:27:01 +00:00
|
|
|
static GstElementDetails gst_queue_details = GST_ELEMENT_DETAILS ("Queue",
|
|
|
|
"Generic",
|
|
|
|
"Simple data queue",
|
|
|
|
"Erik Walthinsen <omega@cse.ogi.edu>");
|
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,
|
2001-05-25 21:00:07 +00:00
|
|
|
ARG_LEAKY,
|
2001-12-22 21:18:17 +00:00
|
|
|
ARG_MAY_DEADLOCK,
|
2003-12-13 17:12:46 +00:00
|
|
|
ARG_BLOCK_TIMEOUT
|
2004-03-13 15:27:01 +00:00
|
|
|
/* FILL ME */
|
2000-01-30 09:03:00 +00:00
|
|
|
};
|
|
|
|
|
2004-07-09 11:23:55 +00:00
|
|
|
#define GST_QUEUE_MUTEX_LOCK G_STMT_START { \
|
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue, \
|
|
|
|
"locking qlock from thread %p", \
|
|
|
|
g_thread_self ()); \
|
|
|
|
g_mutex_lock (queue->qlock); \
|
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue, \
|
|
|
|
"locked qlock from thread %p", \
|
|
|
|
g_thread_self ()); \
|
|
|
|
} G_STMT_END
|
|
|
|
|
|
|
|
#define GST_QUEUE_MUTEX_UNLOCK G_STMT_START { \
|
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue, \
|
|
|
|
"unlocking qlock from thread %p", \
|
|
|
|
g_thread_self ()); \
|
|
|
|
g_mutex_unlock (queue->qlock); \
|
|
|
|
} G_STMT_END
|
|
|
|
|
|
|
|
|
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-03-21 17:34:02 +00:00
|
|
|
static GstFlowReturn gst_queue_chain (GstPad * pad, GstBuffer * buffer);
|
|
|
|
static GstBuffer *gst_queue_bufferalloc (GstPad * pad, guint64 offset,
|
|
|
|
guint size, GstCaps * caps);
|
|
|
|
static void gst_queue_loop (GstPad * pad);
|
|
|
|
|
|
|
|
static gboolean gst_queue_handle_sink_event (GstPad * pad, GstEvent * event);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
|
|
|
static gboolean gst_queue_handle_src_event (GstPad * pad, GstEvent * event);
|
2005-05-09 10:53:13 +00:00
|
|
|
static gboolean gst_queue_handle_src_query (GstPad * pad, GstQuery * query);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
|
|
|
static GstCaps *gst_queue_getcaps (GstPad * pad);
|
2005-03-21 17:34:02 +00:00
|
|
|
static GstPadLinkReturn gst_queue_link_sink (GstPad * pad, GstPad * peer);
|
|
|
|
static GstPadLinkReturn gst_queue_link_src (GstPad * pad, GstPad * peer);
|
2004-03-13 15:27:01 +00:00
|
|
|
static void gst_queue_locked_flush (GstQueue * queue);
|
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
static gboolean gst_queue_src_activate (GstPad * pad, GstActivateMode mode);
|
2004-03-13 15:27:01 +00:00
|
|
|
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);
|
gst/elements/gstfilesrc.c: compute mapsize correctly
Original commit message from CVS:
* gst/elements/gstfilesrc.c: (gst_filesrc_get_mmap):
compute mapsize correctly
* gst/elements/gstfilesrc.c: (gst_filesrc_get_mmap):
use correct datatypes when calling a varargs function
* gst/elements/gsttypefindelement.c: (stop_typefinding):
push a DISCONT event as first thing
* gst/gst_private.h:
* gst/gstinfo.c: (_gst_debug_init):
remove GST_DATAFLOW debugging category
* gst/gstbin.c: (gst_bin_iterate):
use GST_SCHEDULING category
* gst/gstpad.c: (gst_pad_get_type), (_invent_event),
(gst_pad_push), (gst_pad_pull), (gst_pad_call_chain_function),
(gst_pad_call_get_function):
add GST_DATAFLOW to easily track flow of buffers or events.
* gst/gstqueue.c: (gst_queue_get_type),
(gst_queue_handle_pending_events), (gst_queue_chain),
(gst_queue_get), (gst_queue_handle_src_event):
use own static debugging category GST_DATAFLOW for dataflow,
use DEBUG category for showing which path events go, use LOG
category for buffers.
2004-05-11 16:20:41 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (queue_dataflow, "queue_dataflow", 0,
|
|
|
|
"dataflow inside the queue element");
|
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/: s/gst_pad_new/&_from_template/ register pad templates in the base_init function add static pad template definit...
Original commit message from CVS:
* gst/autoplug/gstspideridentity.c:
(gst_spider_identity_request_new_pad):
* gst/elements/gstaggregator.c: (gst_aggregator_base_init),
(gst_aggregator_init):
* gst/elements/gstfakesink.c: (gst_fakesink_base_init),
(gst_fakesink_init):
* gst/elements/gstfakesrc.c: (gst_fakesrc_base_init),
(gst_fakesrc_init):
* gst/elements/gstfdsink.c: (gst_fdsink_base_init),
(gst_fdsink_init):
* gst/elements/gstfdsrc.c: (gst_fdsrc_base_init), (gst_fdsrc_init):
* gst/elements/gstfilesink.c: (gst_filesink_base_init),
(gst_filesink_init):
* gst/elements/gstfilesrc.c: (gst_filesrc_base_init),
(gst_filesrc_init):
* gst/elements/gstidentity.c: (gst_identity_base_init),
(gst_identity_init):
* gst/elements/gstmultifilesrc.c: (gst_multifilesrc_base_init),
(gst_multifilesrc_init):
* gst/elements/gstpipefilter.c: (gst_pipefilter_base_init),
(gst_pipefilter_init):
* gst/elements/gststatistics.c: (gst_statistics_base_init),
(gst_statistics_init):
* gst/elements/gsttee.c: (gst_tee_base_init), (gst_tee_init):
* gst/gstqueue.c: (gst_queue_base_init), (gst_queue_init):
s/gst_pad_new/&_from_template/
register pad templates in the base_init function
add static pad template definitions
2004-08-17 14:11:23 +00:00
|
|
|
gst_element_class_add_pad_template (gstelement_class,
|
|
|
|
gst_static_pad_template_get (&srctemplate));
|
|
|
|
gst_element_class_add_pad_template (gstelement_class,
|
|
|
|
gst_static_pad_template_get (&sinktemplate));
|
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
|
|
|
|
2005-03-08 17:42:29 +00:00
|
|
|
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
|
|
|
/* 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
|
|
|
|
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
|
|
|
|
|
|
|
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
|
|
|
g_object_class_install_property (gobject_class, ARG_MAY_DEADLOCK,
|
2004-03-13 15:27:01 +00:00
|
|
|
g_param_spec_boolean ("may_deadlock", "May Deadlock",
|
2004-03-15 19:27:17 +00:00
|
|
|
"The queue may deadlock if it's full and not PLAYING",
|
|
|
|
TRUE, G_PARAM_READWRITE));
|
2003-12-13 17:12:46 +00:00
|
|
|
g_object_class_install_property (gobject_class, ARG_BLOCK_TIMEOUT,
|
2004-03-13 15:27:01 +00:00
|
|
|
g_param_spec_uint64 ("block_timeout", "Timeout for Block",
|
2004-03-15 19:27:17 +00:00
|
|
|
"Nanoseconds until blocked queue times out and returns filler event. "
|
|
|
|
"Value of -1 disables timeout",
|
|
|
|
0, G_MAXUINT64, -1, G_PARAM_READWRITE));
|
2003-12-13 17:12:46 +00:00
|
|
|
|
|
|
|
/* set several parent class virtual functions */
|
2004-07-09 11:23:55 +00:00
|
|
|
gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_queue_finalize);
|
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
|
|
|
{
|
gst/: s/gst_pad_new/&_from_template/ register pad templates in the base_init function add static pad template definit...
Original commit message from CVS:
* gst/autoplug/gstspideridentity.c:
(gst_spider_identity_request_new_pad):
* gst/elements/gstaggregator.c: (gst_aggregator_base_init),
(gst_aggregator_init):
* gst/elements/gstfakesink.c: (gst_fakesink_base_init),
(gst_fakesink_init):
* gst/elements/gstfakesrc.c: (gst_fakesrc_base_init),
(gst_fakesrc_init):
* gst/elements/gstfdsink.c: (gst_fdsink_base_init),
(gst_fdsink_init):
* gst/elements/gstfdsrc.c: (gst_fdsrc_base_init), (gst_fdsrc_init):
* gst/elements/gstfilesink.c: (gst_filesink_base_init),
(gst_filesink_init):
* gst/elements/gstfilesrc.c: (gst_filesrc_base_init),
(gst_filesrc_init):
* gst/elements/gstidentity.c: (gst_identity_base_init),
(gst_identity_init):
* gst/elements/gstmultifilesrc.c: (gst_multifilesrc_base_init),
(gst_multifilesrc_init):
* gst/elements/gstpipefilter.c: (gst_pipefilter_base_init),
(gst_pipefilter_init):
* gst/elements/gststatistics.c: (gst_statistics_base_init),
(gst_statistics_init):
* gst/elements/gsttee.c: (gst_tee_base_init), (gst_tee_init):
* gst/gstqueue.c: (gst_queue_base_init), (gst_queue_init):
s/gst_pad_new/&_from_template/
register pad templates in the base_init function
add static pad template definitions
2004-08-17 14:11:23 +00:00
|
|
|
queue->sinkpad =
|
|
|
|
gst_pad_new_from_template (gst_static_pad_template_get (&sinktemplate),
|
|
|
|
"sink");
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_pad_set_chain_function (queue->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_queue_chain));
|
2005-03-21 17:34:02 +00:00
|
|
|
gst_pad_set_event_function (queue->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_queue_handle_sink_event));
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_pad_set_link_function (queue->sinkpad,
|
2005-01-08 18:10:50 +00:00
|
|
|
GST_DEBUG_FUNCPTR (gst_queue_link_sink));
|
2004-03-13 15:27:01 +00:00
|
|
|
gst_pad_set_getcaps_function (queue->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_queue_getcaps));
|
2005-03-21 17:34:02 +00:00
|
|
|
gst_pad_set_bufferalloc_function (queue->sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_queue_bufferalloc));
|
|
|
|
gst_element_add_pad (GST_ELEMENT (queue), queue->sinkpad);
|
2000-09-24 14:29:49 +00:00
|
|
|
|
gst/: s/gst_pad_new/&_from_template/ register pad templates in the base_init function add static pad template definit...
Original commit message from CVS:
* gst/autoplug/gstspideridentity.c:
(gst_spider_identity_request_new_pad):
* gst/elements/gstaggregator.c: (gst_aggregator_base_init),
(gst_aggregator_init):
* gst/elements/gstfakesink.c: (gst_fakesink_base_init),
(gst_fakesink_init):
* gst/elements/gstfakesrc.c: (gst_fakesrc_base_init),
(gst_fakesrc_init):
* gst/elements/gstfdsink.c: (gst_fdsink_base_init),
(gst_fdsink_init):
* gst/elements/gstfdsrc.c: (gst_fdsrc_base_init), (gst_fdsrc_init):
* gst/elements/gstfilesink.c: (gst_filesink_base_init),
(gst_filesink_init):
* gst/elements/gstfilesrc.c: (gst_filesrc_base_init),
(gst_filesrc_init):
* gst/elements/gstidentity.c: (gst_identity_base_init),
(gst_identity_init):
* gst/elements/gstmultifilesrc.c: (gst_multifilesrc_base_init),
(gst_multifilesrc_init):
* gst/elements/gstpipefilter.c: (gst_pipefilter_base_init),
(gst_pipefilter_init):
* gst/elements/gststatistics.c: (gst_statistics_base_init),
(gst_statistics_init):
* gst/elements/gsttee.c: (gst_tee_base_init), (gst_tee_init):
* gst/gstqueue.c: (gst_queue_base_init), (gst_queue_init):
s/gst_pad_new/&_from_template/
register pad templates in the base_init function
add static pad template definitions
2004-08-17 14:11:23 +00:00
|
|
|
queue->srcpad =
|
|
|
|
gst_pad_new_from_template (gst_static_pad_template_get (&srctemplate),
|
|
|
|
"src");
|
2005-03-21 17:34:02 +00:00
|
|
|
gst_pad_set_loop_function (queue->srcpad, GST_DEBUG_FUNCPTR (gst_queue_loop));
|
|
|
|
gst_pad_set_activate_function (queue->srcpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_queue_src_activate));
|
2005-01-08 18:10:50 +00:00
|
|
|
gst_pad_set_link_function (queue->srcpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_queue_link_src));
|
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));
|
2004-10-11 13:14:03 +00:00
|
|
|
gst_pad_set_query_function (queue->srcpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_queue_handle_src_query));
|
2005-03-21 17:34:02 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (queue), queue->srcpad);
|
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 */
|
2005-03-21 17:34:02 +00:00
|
|
|
queue->max_size.buffers = 200; /* 200 buffers */
|
2004-03-15 19:27:17 +00:00
|
|
|
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 */
|
2003-12-13 17:12:46 +00:00
|
|
|
|
2001-12-29 03:02:14 +00:00
|
|
|
queue->leaky = GST_QUEUE_NO_LEAK;
|
2001-12-22 21:18:17 +00:00
|
|
|
queue->may_deadlock = TRUE;
|
2003-12-13 17:12:46 +00:00
|
|
|
queue->block_timeout = GST_CLOCK_TIME_NONE;
|
2002-06-09 12:13:30 +00:00
|
|
|
queue->flush = FALSE;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-10-27 20:28:31 +00:00
|
|
|
queue->qlock = g_mutex_new ();
|
2003-12-13 17:12:46 +00:00
|
|
|
queue->item_add = g_cond_new ();
|
|
|
|
queue->item_del = g_cond_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)) {
|
check/Makefile.am: remove GstData checks
Original commit message from CVS:
* check/Makefile.am: remove GstData checks
* check/gst-libs/gdp.c: (START_TEST): fix for API changes
* gst/Makefile.am: add miniobject, remove data
* gst/gst.h: add miniobject, remove data
* gst/gstdata.c: remove
* gst/gstdata.h: remove
* gst/gstdata_private.h: remove
* gst/gsttypes.h: remove GstEvent and GstMessage
* gst/gstelement.c: (gst_element_post_message): fix for API changes
* gst/gstmarshal.list: change BOXED -> OBJECT
Implement GstMiniObject.
* gst/gstminiobject.c:
* gst/gstminiobject.h:
Modify to be subclasses of GstMiniObject.
* gst/gstbuffer.c: (_gst_buffer_initialize), (gst_buffer_get_type),
(gst_buffer_class_init), (gst_buffer_finalize), (_gst_buffer_copy),
(gst_buffer_init), (gst_buffer_new), (gst_buffer_new_and_alloc),
(gst_subbuffer_get_type), (gst_subbuffer_init),
(gst_buffer_create_sub), (gst_buffer_is_span_fast),
(gst_buffer_span):
* gst/gstbuffer.h:
* gst/gstevent.c: (_gst_event_initialize), (gst_event_get_type),
(gst_event_class_init), (gst_event_init), (gst_event_finalize),
(_gst_event_copy), (gst_event_new):
* gst/gstevent.h:
* gst/gstmessage.c: (_gst_message_initialize),
(gst_message_get_type), (gst_message_class_init),
(gst_message_init), (gst_message_finalize), (_gst_message_copy),
(gst_message_new), (gst_message_new_error),
(gst_message_new_warning), (gst_message_new_tag),
(gst_message_new_state_changed), (gst_message_new_application):
* gst/gstmessage.h:
* gst/gstprobe.c: (gst_probe_perform),
(gst_probe_dispatcher_dispatch):
* gst/gstprobe.h:
* gst/gstquery.c: (_gst_query_initialize), (gst_query_get_type),
(gst_query_class_init), (gst_query_finalize), (gst_query_init),
(_gst_query_copy), (gst_query_new):
Update elements for GstData -> GstMiniObject changes
* gst/gstquery.h:
* gst/gstqueue.c: (gst_queue_finalize), (gst_queue_locked_flush),
(gst_queue_chain), (gst_queue_loop):
* gst/elements/gstbufferstore.c:
(gst_buffer_store_add_buffer_func),
(gst_buffer_store_cleared_func), (gst_buffer_store_get_buffer):
* gst/elements/gstfakesink.c: (gst_fakesink_class_init),
(gst_fakesink_render):
* gst/elements/gstfakesrc.c: (gst_fakesrc_class_init):
* gst/elements/gstfilesrc.c: (gst_mmap_buffer_get_type),
(gst_mmap_buffer_class_init), (gst_mmap_buffer_init),
(gst_mmap_buffer_finalize), (gst_filesrc_map_region),
(gst_filesrc_create_read):
* gst/elements/gstidentity.c: (gst_identity_class_init):
* gst/elements/gsttypefindelement.c:
(gst_type_find_element_src_event), (free_entry_buffers),
(gst_type_find_element_handle_event):
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer):
* libs/gst/dataprotocol/dataprotocol.h:
* libs/gst/dataprotocol/dp-private.h:
2005-05-16 20:21:55 +00:00
|
|
|
GstMiniObject *data = g_queue_pop_head (queue->queue);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
check/Makefile.am: remove GstData checks
Original commit message from CVS:
* check/Makefile.am: remove GstData checks
* check/gst-libs/gdp.c: (START_TEST): fix for API changes
* gst/Makefile.am: add miniobject, remove data
* gst/gst.h: add miniobject, remove data
* gst/gstdata.c: remove
* gst/gstdata.h: remove
* gst/gstdata_private.h: remove
* gst/gsttypes.h: remove GstEvent and GstMessage
* gst/gstelement.c: (gst_element_post_message): fix for API changes
* gst/gstmarshal.list: change BOXED -> OBJECT
Implement GstMiniObject.
* gst/gstminiobject.c:
* gst/gstminiobject.h:
Modify to be subclasses of GstMiniObject.
* gst/gstbuffer.c: (_gst_buffer_initialize), (gst_buffer_get_type),
(gst_buffer_class_init), (gst_buffer_finalize), (_gst_buffer_copy),
(gst_buffer_init), (gst_buffer_new), (gst_buffer_new_and_alloc),
(gst_subbuffer_get_type), (gst_subbuffer_init),
(gst_buffer_create_sub), (gst_buffer_is_span_fast),
(gst_buffer_span):
* gst/gstbuffer.h:
* gst/gstevent.c: (_gst_event_initialize), (gst_event_get_type),
(gst_event_class_init), (gst_event_init), (gst_event_finalize),
(_gst_event_copy), (gst_event_new):
* gst/gstevent.h:
* gst/gstmessage.c: (_gst_message_initialize),
(gst_message_get_type), (gst_message_class_init),
(gst_message_init), (gst_message_finalize), (_gst_message_copy),
(gst_message_new), (gst_message_new_error),
(gst_message_new_warning), (gst_message_new_tag),
(gst_message_new_state_changed), (gst_message_new_application):
* gst/gstmessage.h:
* gst/gstprobe.c: (gst_probe_perform),
(gst_probe_dispatcher_dispatch):
* gst/gstprobe.h:
* gst/gstquery.c: (_gst_query_initialize), (gst_query_get_type),
(gst_query_class_init), (gst_query_finalize), (gst_query_init),
(_gst_query_copy), (gst_query_new):
Update elements for GstData -> GstMiniObject changes
* gst/gstquery.h:
* gst/gstqueue.c: (gst_queue_finalize), (gst_queue_locked_flush),
(gst_queue_chain), (gst_queue_loop):
* gst/elements/gstbufferstore.c:
(gst_buffer_store_add_buffer_func),
(gst_buffer_store_cleared_func), (gst_buffer_store_get_buffer):
* gst/elements/gstfakesink.c: (gst_fakesink_class_init),
(gst_fakesink_render):
* gst/elements/gstfakesrc.c: (gst_fakesrc_class_init):
* gst/elements/gstfilesrc.c: (gst_mmap_buffer_get_type),
(gst_mmap_buffer_class_init), (gst_mmap_buffer_init),
(gst_mmap_buffer_finalize), (gst_filesrc_map_region),
(gst_filesrc_create_read):
* gst/elements/gstidentity.c: (gst_identity_class_init):
* gst/elements/gsttypefindelement.c:
(gst_type_find_element_src_event), (free_entry_buffers),
(gst_type_find_element_handle_event):
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer):
* libs/gst/dataprotocol/dataprotocol.h:
* libs/gst/dataprotocol/dp-private.h:
2005-05-16 20:21:55 +00:00
|
|
|
gst_mini_object_unref (data);
|
2003-12-13 17:12:46 +00:00
|
|
|
}
|
2002-07-08 19:22:02 +00:00
|
|
|
g_queue_free (queue->queue);
|
2005-03-21 17:34:02 +00:00
|
|
|
GST_CAT_DEBUG_OBJECT (GST_CAT_THREAD, queue, "free mutex");
|
2003-12-13 17:12:46 +00:00
|
|
|
g_mutex_free (queue->qlock);
|
2005-03-21 17:34:02 +00:00
|
|
|
GST_CAT_DEBUG_OBJECT (GST_CAT_THREAD, queue, "done free mutex");
|
2003-12-13 17:12:46 +00:00
|
|
|
g_cond_free (queue->item_add);
|
|
|
|
g_cond_free (queue->item_del);
|
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;
|
2005-03-21 17:34:02 +00:00
|
|
|
GstPad *otherpad;
|
|
|
|
GstCaps *result;
|
2004-01-11 22:11:35 +00:00
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
queue = GST_QUEUE (GST_PAD_PARENT (pad));
|
2004-01-11 22:11:35 +00:00
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
otherpad = (pad == queue->srcpad ? queue->sinkpad : queue->srcpad);
|
|
|
|
result = gst_pad_peer_get_caps (otherpad);
|
2005-05-06 17:10:49 +00:00
|
|
|
if (result == NULL)
|
|
|
|
result = gst_caps_new_any ();
|
2004-01-11 22:11:35 +00:00
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
return result;
|
2004-01-11 22:11:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GstPadLinkReturn
|
2005-03-21 17:34:02 +00:00
|
|
|
gst_queue_link_sink (GstPad * pad, GstPad * peer)
|
2005-01-08 18:10:50 +00:00
|
|
|
{
|
2005-03-21 17:34:02 +00:00
|
|
|
return GST_PAD_LINK_OK;
|
|
|
|
}
|
2005-01-08 18:10:50 +00:00
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
static GstPadLinkReturn
|
|
|
|
gst_queue_link_src (GstPad * pad, GstPad * peer)
|
|
|
|
{
|
|
|
|
GstPadLinkReturn result = GST_PAD_LINK_OK;
|
2005-01-08 18:10:50 +00:00
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
/* FIXME, see if we need to push or get pulled */
|
|
|
|
if (GST_RPAD_LINKFUNC (peer))
|
|
|
|
result = GST_RPAD_LINKFUNC (peer) (peer, pad);
|
2005-01-08 18:10:50 +00:00
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
return result;
|
2005-01-08 18:10:50 +00:00
|
|
|
}
|
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
static GstBuffer *
|
|
|
|
gst_queue_bufferalloc (GstPad * pad, guint64 offset, guint size, GstCaps * caps)
|
2004-01-11 22:11:35 +00:00
|
|
|
{
|
|
|
|
GstQueue *queue;
|
2005-03-21 17:34:02 +00:00
|
|
|
GstPad *otherpeer;
|
|
|
|
GstBuffer *result = NULL;
|
2004-01-11 22:11:35 +00:00
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
queue = GST_QUEUE (GST_PAD_PARENT (pad));
|
2004-01-11 22:11:35 +00:00
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
otherpeer = gst_pad_get_peer (queue->srcpad);
|
|
|
|
if (otherpeer == NULL || GST_RPAD_BUFFERALLOCFUNC (otherpeer) == NULL) {
|
|
|
|
/* let the default aloc function do the work */
|
|
|
|
result = NULL;
|
|
|
|
} else {
|
|
|
|
result =
|
|
|
|
GST_RPAD_BUFFERALLOCFUNC (otherpeer) (otherpeer, offset, size, caps);
|
2004-01-11 22:11:35 +00:00
|
|
|
}
|
2005-03-21 17:34:02 +00:00
|
|
|
if (otherpeer)
|
|
|
|
gst_object_unref (GST_OBJECT (otherpeer));
|
2004-01-11 22:11:35 +00:00
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
return result;
|
2004-01-11 22:11:35 +00:00
|
|
|
}
|
|
|
|
|
2005-03-21 17:34:02 +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
|
|
|
{
|
2003-12-13 17:12:46 +00:00
|
|
|
while (!g_queue_is_empty (queue->queue)) {
|
check/Makefile.am: remove GstData checks
Original commit message from CVS:
* check/Makefile.am: remove GstData checks
* check/gst-libs/gdp.c: (START_TEST): fix for API changes
* gst/Makefile.am: add miniobject, remove data
* gst/gst.h: add miniobject, remove data
* gst/gstdata.c: remove
* gst/gstdata.h: remove
* gst/gstdata_private.h: remove
* gst/gsttypes.h: remove GstEvent and GstMessage
* gst/gstelement.c: (gst_element_post_message): fix for API changes
* gst/gstmarshal.list: change BOXED -> OBJECT
Implement GstMiniObject.
* gst/gstminiobject.c:
* gst/gstminiobject.h:
Modify to be subclasses of GstMiniObject.
* gst/gstbuffer.c: (_gst_buffer_initialize), (gst_buffer_get_type),
(gst_buffer_class_init), (gst_buffer_finalize), (_gst_buffer_copy),
(gst_buffer_init), (gst_buffer_new), (gst_buffer_new_and_alloc),
(gst_subbuffer_get_type), (gst_subbuffer_init),
(gst_buffer_create_sub), (gst_buffer_is_span_fast),
(gst_buffer_span):
* gst/gstbuffer.h:
* gst/gstevent.c: (_gst_event_initialize), (gst_event_get_type),
(gst_event_class_init), (gst_event_init), (gst_event_finalize),
(_gst_event_copy), (gst_event_new):
* gst/gstevent.h:
* gst/gstmessage.c: (_gst_message_initialize),
(gst_message_get_type), (gst_message_class_init),
(gst_message_init), (gst_message_finalize), (_gst_message_copy),
(gst_message_new), (gst_message_new_error),
(gst_message_new_warning), (gst_message_new_tag),
(gst_message_new_state_changed), (gst_message_new_application):
* gst/gstmessage.h:
* gst/gstprobe.c: (gst_probe_perform),
(gst_probe_dispatcher_dispatch):
* gst/gstprobe.h:
* gst/gstquery.c: (_gst_query_initialize), (gst_query_get_type),
(gst_query_class_init), (gst_query_finalize), (gst_query_init),
(_gst_query_copy), (gst_query_new):
Update elements for GstData -> GstMiniObject changes
* gst/gstquery.h:
* gst/gstqueue.c: (gst_queue_finalize), (gst_queue_locked_flush),
(gst_queue_chain), (gst_queue_loop):
* gst/elements/gstbufferstore.c:
(gst_buffer_store_add_buffer_func),
(gst_buffer_store_cleared_func), (gst_buffer_store_get_buffer):
* gst/elements/gstfakesink.c: (gst_fakesink_class_init),
(gst_fakesink_render):
* gst/elements/gstfakesrc.c: (gst_fakesrc_class_init):
* gst/elements/gstfilesrc.c: (gst_mmap_buffer_get_type),
(gst_mmap_buffer_class_init), (gst_mmap_buffer_init),
(gst_mmap_buffer_finalize), (gst_filesrc_map_region),
(gst_filesrc_create_read):
* gst/elements/gstidentity.c: (gst_identity_class_init):
* gst/elements/gsttypefindelement.c:
(gst_type_find_element_src_event), (free_entry_buffers),
(gst_type_find_element_handle_event):
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer):
* libs/gst/dataprotocol/dataprotocol.h:
* libs/gst/dataprotocol/dp-private.h:
2005-05-16 20:21:55 +00:00
|
|
|
GstMiniObject *data = g_queue_pop_head (queue->queue);
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2004-02-09 09:11:50 +00:00
|
|
|
/* Then loose another reference because we are supposed to destroy that
|
|
|
|
data when flushing */
|
check/Makefile.am: remove GstData checks
Original commit message from CVS:
* check/Makefile.am: remove GstData checks
* check/gst-libs/gdp.c: (START_TEST): fix for API changes
* gst/Makefile.am: add miniobject, remove data
* gst/gst.h: add miniobject, remove data
* gst/gstdata.c: remove
* gst/gstdata.h: remove
* gst/gstdata_private.h: remove
* gst/gsttypes.h: remove GstEvent and GstMessage
* gst/gstelement.c: (gst_element_post_message): fix for API changes
* gst/gstmarshal.list: change BOXED -> OBJECT
Implement GstMiniObject.
* gst/gstminiobject.c:
* gst/gstminiobject.h:
Modify to be subclasses of GstMiniObject.
* gst/gstbuffer.c: (_gst_buffer_initialize), (gst_buffer_get_type),
(gst_buffer_class_init), (gst_buffer_finalize), (_gst_buffer_copy),
(gst_buffer_init), (gst_buffer_new), (gst_buffer_new_and_alloc),
(gst_subbuffer_get_type), (gst_subbuffer_init),
(gst_buffer_create_sub), (gst_buffer_is_span_fast),
(gst_buffer_span):
* gst/gstbuffer.h:
* gst/gstevent.c: (_gst_event_initialize), (gst_event_get_type),
(gst_event_class_init), (gst_event_init), (gst_event_finalize),
(_gst_event_copy), (gst_event_new):
* gst/gstevent.h:
* gst/gstmessage.c: (_gst_message_initialize),
(gst_message_get_type), (gst_message_class_init),
(gst_message_init), (gst_message_finalize), (_gst_message_copy),
(gst_message_new), (gst_message_new_error),
(gst_message_new_warning), (gst_message_new_tag),
(gst_message_new_state_changed), (gst_message_new_application):
* gst/gstmessage.h:
* gst/gstprobe.c: (gst_probe_perform),
(gst_probe_dispatcher_dispatch):
* gst/gstprobe.h:
* gst/gstquery.c: (_gst_query_initialize), (gst_query_get_type),
(gst_query_class_init), (gst_query_finalize), (gst_query_init),
(_gst_query_copy), (gst_query_new):
Update elements for GstData -> GstMiniObject changes
* gst/gstquery.h:
* gst/gstqueue.c: (gst_queue_finalize), (gst_queue_locked_flush),
(gst_queue_chain), (gst_queue_loop):
* gst/elements/gstbufferstore.c:
(gst_buffer_store_add_buffer_func),
(gst_buffer_store_cleared_func), (gst_buffer_store_get_buffer):
* gst/elements/gstfakesink.c: (gst_fakesink_class_init),
(gst_fakesink_render):
* gst/elements/gstfakesrc.c: (gst_fakesrc_class_init):
* gst/elements/gstfilesrc.c: (gst_mmap_buffer_get_type),
(gst_mmap_buffer_class_init), (gst_mmap_buffer_init),
(gst_mmap_buffer_finalize), (gst_filesrc_map_region),
(gst_filesrc_create_read):
* gst/elements/gstidentity.c: (gst_identity_class_init):
* gst/elements/gsttypefindelement.c:
(gst_type_find_element_src_event), (free_entry_buffers),
(gst_type_find_element_handle_event):
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer):
* libs/gst/dataprotocol/dataprotocol.h:
* libs/gst/dataprotocol/dp-private.h:
2005-05-16 20:21:55 +00:00
|
|
|
gst_mini_object_unref (data);
|
2002-07-08 19:22:02 +00:00
|
|
|
}
|
2003-12-13 17:12:46 +00:00
|
|
|
queue->cur_level.buffers = 0;
|
|
|
|
queue->cur_level.bytes = 0;
|
|
|
|
queue->cur_level.time = 0;
|
|
|
|
|
2002-06-09 12:13:30 +00:00
|
|
|
/* make sure any pending buffers to be added are flushed too */
|
|
|
|
queue->flush = TRUE;
|
2003-12-13 17:12:46 +00:00
|
|
|
|
|
|
|
/* we deleted something... */
|
|
|
|
g_cond_signal (queue->item_del);
|
2000-10-30 21:02:08 +00:00
|
|
|
}
|
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
#define STATUS(queue, msg) \
|
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue, \
|
|
|
|
"(%s:%s) " msg ": %u of %u-%u buffers, %u of %u-%u " \
|
|
|
|
"bytes, %" G_GUINT64_FORMAT " of %" G_GUINT64_FORMAT \
|
|
|
|
"-%" G_GUINT64_FORMAT " ns, %u elements", \
|
|
|
|
GST_DEBUG_PAD_NAME (pad), \
|
|
|
|
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)
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_queue_handle_sink_event (GstPad * pad, GstEvent * event)
|
2003-12-14 13:14:35 +00:00
|
|
|
{
|
2005-03-21 17:34:02 +00:00
|
|
|
GstQueue *queue;
|
|
|
|
|
|
|
|
queue = GST_QUEUE (GST_OBJECT_PARENT (pad));
|
|
|
|
|
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
case GST_EVENT_FLUSH:
|
|
|
|
STATUS (queue, "received flush event");
|
|
|
|
/* forward event */
|
|
|
|
gst_pad_event_default (pad, event);
|
|
|
|
if (GST_EVENT_FLUSH_DONE (event)) {
|
|
|
|
GST_STREAM_LOCK (queue->srcpad);
|
|
|
|
gst_task_start (GST_RPAD_TASK (queue->srcpad));
|
|
|
|
GST_STREAM_UNLOCK (queue->srcpad);
|
|
|
|
} else {
|
|
|
|
/* now unblock the chain function */
|
|
|
|
GST_QUEUE_MUTEX_LOCK;
|
|
|
|
gst_queue_locked_flush (queue);
|
|
|
|
GST_QUEUE_MUTEX_UNLOCK;
|
|
|
|
|
|
|
|
STATUS (queue, "after flush");
|
|
|
|
|
|
|
|
/* unblock the loop function */
|
|
|
|
g_cond_signal (queue->item_add);
|
|
|
|
|
|
|
|
/* make sure it stops */
|
|
|
|
GST_STREAM_LOCK (queue->srcpad);
|
|
|
|
gst_task_pause (GST_RPAD_TASK (queue->srcpad));
|
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue, "loop stopped");
|
|
|
|
GST_STREAM_UNLOCK (queue->srcpad);
|
|
|
|
}
|
|
|
|
goto done;
|
|
|
|
case GST_EVENT_EOS:
|
|
|
|
STATUS (queue, "received EOS");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* we put the event in the queue, we don't have to act ourselves */
|
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue,
|
|
|
|
"adding event %p of type %d", event, GST_EVENT_TYPE (event));
|
2004-06-11 15:18:58 +00:00
|
|
|
break;
|
2003-12-14 13:14:35 +00:00
|
|
|
}
|
2005-03-21 17:34:02 +00:00
|
|
|
|
|
|
|
GST_QUEUE_MUTEX_LOCK;
|
|
|
|
g_queue_push_tail (queue->queue, event);
|
|
|
|
g_cond_signal (queue->item_add);
|
|
|
|
|
|
|
|
GST_QUEUE_MUTEX_UNLOCK;
|
|
|
|
done:
|
|
|
|
|
|
|
|
return TRUE;
|
2003-12-14 13:14:35 +00:00
|
|
|
}
|
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
static gboolean
|
|
|
|
gst_queue_is_empty (GstQueue * queue)
|
2000-11-25 14:18:47 +00:00
|
|
|
{
|
2005-03-21 17:34:02 +00:00
|
|
|
return (queue->queue->length == 0 ||
|
|
|
|
(queue->min_threshold.buffers > 0 &&
|
|
|
|
queue->cur_level.buffers < queue->min_threshold.buffers) ||
|
|
|
|
(queue->min_threshold.bytes > 0 &&
|
|
|
|
queue->cur_level.bytes < queue->min_threshold.bytes) ||
|
|
|
|
(queue->min_threshold.time > 0 &&
|
|
|
|
queue->cur_level.time < queue->min_threshold.time));
|
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
gst_queue_is_filled (GstQueue * queue)
|
|
|
|
{
|
|
|
|
return (((queue->max_size.buffers > 0 &&
|
|
|
|
queue->cur_level.buffers >= queue->max_size.buffers) ||
|
|
|
|
(queue->max_size.bytes > 0 &&
|
|
|
|
queue->cur_level.bytes >= queue->max_size.bytes) ||
|
|
|
|
(queue->max_size.time > 0 &&
|
|
|
|
queue->cur_level.time >= queue->max_size.time)));
|
|
|
|
}
|
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
static GstFlowReturn
|
|
|
|
gst_queue_chain (GstPad * pad, GstBuffer * buffer)
|
|
|
|
{
|
|
|
|
GstQueue *queue;
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2001-01-29 00:06:02 +00:00
|
|
|
queue = GST_QUEUE (GST_OBJECT_PARENT (pad));
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
GST_STREAM_LOCK (pad);
|
|
|
|
|
2001-10-27 20:28:31 +00:00
|
|
|
/* we have to lock the queue since we span threads */
|
2004-07-09 11:23:55 +00:00
|
|
|
GST_QUEUE_MUTEX_LOCK;
|
2003-12-13 17:12:46 +00:00
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue,
|
|
|
|
"adding buffer %p of size %d", buffer, GST_BUFFER_SIZE (buffer));
|
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.
|
|
|
|
* We always handle events and they don't count in our statistics. */
|
2005-03-21 17:34:02 +00:00
|
|
|
while (gst_queue_is_filled (queue)) {
|
2004-07-09 11:23:55 +00:00
|
|
|
GST_QUEUE_MUTEX_UNLOCK;
|
2003-12-13 17:12:46 +00:00
|
|
|
g_signal_emit (G_OBJECT (queue), gst_queue_signals[SIGNAL_OVERRUN], 0);
|
2004-07-09 11:23:55 +00:00
|
|
|
GST_QUEUE_MUTEX_LOCK;
|
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) {
|
2004-03-15 19:27:17 +00:00
|
|
|
/* leak current buffer */
|
2003-12-13 17:12:46 +00:00
|
|
|
case GST_QUEUE_LEAK_UPSTREAM:
|
gst/elements/gstfilesrc.c: compute mapsize correctly
Original commit message from CVS:
* gst/elements/gstfilesrc.c: (gst_filesrc_get_mmap):
compute mapsize correctly
* gst/elements/gstfilesrc.c: (gst_filesrc_get_mmap):
use correct datatypes when calling a varargs function
* gst/elements/gsttypefindelement.c: (stop_typefinding):
push a DISCONT event as first thing
* gst/gst_private.h:
* gst/gstinfo.c: (_gst_debug_init):
remove GST_DATAFLOW debugging category
* gst/gstbin.c: (gst_bin_iterate):
use GST_SCHEDULING category
* gst/gstpad.c: (gst_pad_get_type), (_invent_event),
(gst_pad_push), (gst_pad_pull), (gst_pad_call_chain_function),
(gst_pad_call_get_function):
add GST_DATAFLOW to easily track flow of buffers or events.
* gst/gstqueue.c: (gst_queue_get_type),
(gst_queue_handle_pending_events), (gst_queue_chain),
(gst_queue_get), (gst_queue_handle_src_event):
use own static debugging category GST_DATAFLOW for dataflow,
use DEBUG category for showing which path events go, use LOG
category for buffers.
2004-05-11 16:20:41 +00:00
|
|
|
GST_CAT_DEBUG_OBJECT (queue_dataflow, queue,
|
2004-03-15 19:27:17 +00:00
|
|
|
"queue is full, leaking buffer on upstream end");
|
|
|
|
/* now we can clean up and exit right away */
|
|
|
|
goto out_unref;
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2004-03-15 19:27:17 +00:00
|
|
|
/* leak first buffer in the queue */
|
2004-03-13 15:27:01 +00:00
|
|
|
case GST_QUEUE_LEAK_DOWNSTREAM:{
|
2004-03-15 19:27:17 +00:00
|
|
|
/* this is a bit hacky. We'll manually iterate the list
|
|
|
|
* and find the first buffer from the head on. We'll
|
|
|
|
* unref that and "fix up" the GQueue object... */
|
|
|
|
GList *item;
|
check/Makefile.am: remove GstData checks
Original commit message from CVS:
* check/Makefile.am: remove GstData checks
* check/gst-libs/gdp.c: (START_TEST): fix for API changes
* gst/Makefile.am: add miniobject, remove data
* gst/gst.h: add miniobject, remove data
* gst/gstdata.c: remove
* gst/gstdata.h: remove
* gst/gstdata_private.h: remove
* gst/gsttypes.h: remove GstEvent and GstMessage
* gst/gstelement.c: (gst_element_post_message): fix for API changes
* gst/gstmarshal.list: change BOXED -> OBJECT
Implement GstMiniObject.
* gst/gstminiobject.c:
* gst/gstminiobject.h:
Modify to be subclasses of GstMiniObject.
* gst/gstbuffer.c: (_gst_buffer_initialize), (gst_buffer_get_type),
(gst_buffer_class_init), (gst_buffer_finalize), (_gst_buffer_copy),
(gst_buffer_init), (gst_buffer_new), (gst_buffer_new_and_alloc),
(gst_subbuffer_get_type), (gst_subbuffer_init),
(gst_buffer_create_sub), (gst_buffer_is_span_fast),
(gst_buffer_span):
* gst/gstbuffer.h:
* gst/gstevent.c: (_gst_event_initialize), (gst_event_get_type),
(gst_event_class_init), (gst_event_init), (gst_event_finalize),
(_gst_event_copy), (gst_event_new):
* gst/gstevent.h:
* gst/gstmessage.c: (_gst_message_initialize),
(gst_message_get_type), (gst_message_class_init),
(gst_message_init), (gst_message_finalize), (_gst_message_copy),
(gst_message_new), (gst_message_new_error),
(gst_message_new_warning), (gst_message_new_tag),
(gst_message_new_state_changed), (gst_message_new_application):
* gst/gstmessage.h:
* gst/gstprobe.c: (gst_probe_perform),
(gst_probe_dispatcher_dispatch):
* gst/gstprobe.h:
* gst/gstquery.c: (_gst_query_initialize), (gst_query_get_type),
(gst_query_class_init), (gst_query_finalize), (gst_query_init),
(_gst_query_copy), (gst_query_new):
Update elements for GstData -> GstMiniObject changes
* gst/gstquery.h:
* gst/gstqueue.c: (gst_queue_finalize), (gst_queue_locked_flush),
(gst_queue_chain), (gst_queue_loop):
* gst/elements/gstbufferstore.c:
(gst_buffer_store_add_buffer_func),
(gst_buffer_store_cleared_func), (gst_buffer_store_get_buffer):
* gst/elements/gstfakesink.c: (gst_fakesink_class_init),
(gst_fakesink_render):
* gst/elements/gstfakesrc.c: (gst_fakesrc_class_init):
* gst/elements/gstfilesrc.c: (gst_mmap_buffer_get_type),
(gst_mmap_buffer_class_init), (gst_mmap_buffer_init),
(gst_mmap_buffer_finalize), (gst_filesrc_map_region),
(gst_filesrc_create_read):
* gst/elements/gstidentity.c: (gst_identity_class_init):
* gst/elements/gsttypefindelement.c:
(gst_type_find_element_src_event), (free_entry_buffers),
(gst_type_find_element_handle_event):
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer):
* libs/gst/dataprotocol/dataprotocol.h:
* libs/gst/dataprotocol/dp-private.h:
2005-05-16 20:21:55 +00:00
|
|
|
GstMiniObject *leak = NULL;
|
2004-03-15 19:27:17 +00:00
|
|
|
|
gst/elements/gstfilesrc.c: compute mapsize correctly
Original commit message from CVS:
* gst/elements/gstfilesrc.c: (gst_filesrc_get_mmap):
compute mapsize correctly
* gst/elements/gstfilesrc.c: (gst_filesrc_get_mmap):
use correct datatypes when calling a varargs function
* gst/elements/gsttypefindelement.c: (stop_typefinding):
push a DISCONT event as first thing
* gst/gst_private.h:
* gst/gstinfo.c: (_gst_debug_init):
remove GST_DATAFLOW debugging category
* gst/gstbin.c: (gst_bin_iterate):
use GST_SCHEDULING category
* gst/gstpad.c: (gst_pad_get_type), (_invent_event),
(gst_pad_push), (gst_pad_pull), (gst_pad_call_chain_function),
(gst_pad_call_get_function):
add GST_DATAFLOW to easily track flow of buffers or events.
* gst/gstqueue.c: (gst_queue_get_type),
(gst_queue_handle_pending_events), (gst_queue_chain),
(gst_queue_get), (gst_queue_handle_src_event):
use own static debugging category GST_DATAFLOW for dataflow,
use DEBUG category for showing which path events go, use LOG
category for buffers.
2004-05-11 16:20:41 +00:00
|
|
|
GST_CAT_DEBUG_OBJECT (queue_dataflow, queue,
|
2004-03-15 19:27:17 +00:00
|
|
|
"queue is full, leaking buffer on downstream end");
|
|
|
|
|
|
|
|
for (item = queue->queue->head; item != NULL; item = item->next) {
|
|
|
|
if (GST_IS_BUFFER (item->data)) {
|
|
|
|
leak = item->data;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* if we didn't find anything, it means we have no buffers
|
|
|
|
* in here. That cannot happen, since we had >= 1 bufs */
|
|
|
|
g_assert (leak);
|
|
|
|
|
|
|
|
/* Now remove it from the list, fixing up the GQueue
|
|
|
|
* CHECKME: is a queue->head the first or the last item? */
|
|
|
|
item = g_list_delete_link (queue->queue->head, item);
|
|
|
|
queue->queue->head = g_list_first (item);
|
|
|
|
queue->queue->tail = g_list_last (item);
|
|
|
|
queue->queue->length--;
|
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
/* and unref the buffer at the end. Twice, because we keep a ref
|
2004-03-15 19:27:17 +00:00
|
|
|
* to make things read-only. Also keep our list uptodate. */
|
2005-03-21 17:34:02 +00:00
|
|
|
queue->cur_level.bytes -= GST_BUFFER_SIZE (buffer);
|
2004-03-15 19:27:17 +00:00
|
|
|
queue->cur_level.buffers--;
|
2005-03-21 17:34:02 +00:00
|
|
|
if (GST_BUFFER_DURATION (buffer) != GST_CLOCK_TIME_NONE)
|
|
|
|
queue->cur_level.time -= GST_BUFFER_DURATION (buffer);
|
2004-03-15 19:27:17 +00:00
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
gst_buffer_unref (buffer);
|
|
|
|
gst_buffer_unref (buffer);
|
2004-03-15 19:27:17 +00:00
|
|
|
break;
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
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
|
|
|
|
2004-03-15 19:27:17 +00:00
|
|
|
/* don't leak. Instead, wait for space to be available */
|
2003-12-13 17:12:46 +00:00
|
|
|
case GST_QUEUE_NO_LEAK:
|
2004-03-15 19:27:17 +00:00
|
|
|
STATUS (queue, "pre-full wait");
|
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
while (gst_queue_is_filled (queue)) {
|
|
|
|
STATUS (queue, "waiting for item_del signal from thread using qlock");
|
|
|
|
g_cond_wait (queue->item_del, queue->qlock);
|
|
|
|
|
2004-03-15 19:27:17 +00:00
|
|
|
/* if there's a pending state change for this queue
|
|
|
|
* or its manager, switch back to iterator so bottom
|
|
|
|
* half of state change executes */
|
2004-07-09 11:23:55 +00:00
|
|
|
STATUS (queue, "received item_del signal from thread using qlock");
|
2004-03-15 19:27:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
STATUS (queue, "post-full wait");
|
2004-07-09 11:23:55 +00:00
|
|
|
GST_QUEUE_MUTEX_UNLOCK;
|
2004-03-15 19:27:17 +00:00
|
|
|
g_signal_emit (G_OBJECT (queue), gst_queue_signals[SIGNAL_RUNNING], 0);
|
2004-07-09 11:23:55 +00:00
|
|
|
GST_QUEUE_MUTEX_LOCK;
|
2004-03-15 19:27:17 +00:00
|
|
|
break;
|
2001-05-25 21:00:07 +00:00
|
|
|
}
|
2000-02-13 13:43:32 +00:00
|
|
|
}
|
2005-03-21 17:34:02 +00:00
|
|
|
/* we are flushing */
|
|
|
|
if (GST_RPAD_IS_FLUSHING (pad))
|
|
|
|
goto out_flushing;
|
2000-02-13 13:43:32 +00:00
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
g_queue_push_tail (queue->queue, buffer);
|
2002-07-08 19:22:02 +00:00
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
/* add buffer to the statistics */
|
|
|
|
queue->cur_level.buffers++;
|
|
|
|
queue->cur_level.bytes += GST_BUFFER_SIZE (buffer);
|
|
|
|
if (GST_BUFFER_DURATION (buffer) != GST_CLOCK_TIME_NONE)
|
|
|
|
queue->cur_level.time += GST_BUFFER_DURATION (buffer);
|
2002-07-08 19:22:02 +00:00
|
|
|
|
2003-12-13 17:12:46 +00:00
|
|
|
STATUS (queue, "+ level");
|
2001-10-27 20:28:31 +00:00
|
|
|
|
gst/elements/gstfilesrc.c: compute mapsize correctly
Original commit message from CVS:
* gst/elements/gstfilesrc.c: (gst_filesrc_get_mmap):
compute mapsize correctly
* gst/elements/gstfilesrc.c: (gst_filesrc_get_mmap):
use correct datatypes when calling a varargs function
* gst/elements/gsttypefindelement.c: (stop_typefinding):
push a DISCONT event as first thing
* gst/gst_private.h:
* gst/gstinfo.c: (_gst_debug_init):
remove GST_DATAFLOW debugging category
* gst/gstbin.c: (gst_bin_iterate):
use GST_SCHEDULING category
* gst/gstpad.c: (gst_pad_get_type), (_invent_event),
(gst_pad_push), (gst_pad_pull), (gst_pad_call_chain_function),
(gst_pad_call_get_function):
add GST_DATAFLOW to easily track flow of buffers or events.
* gst/gstqueue.c: (gst_queue_get_type),
(gst_queue_handle_pending_events), (gst_queue_chain),
(gst_queue_get), (gst_queue_handle_src_event):
use own static debugging category GST_DATAFLOW for dataflow,
use DEBUG category for showing which path events go, use LOG
category for buffers.
2004-05-11 16:20:41 +00:00
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue, "signalling item_add");
|
2003-12-13 17:12:46 +00:00
|
|
|
g_cond_signal (queue->item_add);
|
2004-07-09 11:23:55 +00:00
|
|
|
GST_QUEUE_MUTEX_UNLOCK;
|
2005-03-21 17:34:02 +00:00
|
|
|
GST_STREAM_UNLOCK (pad);
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
return GST_FLOW_OK;
|
2003-03-21 20:53:26 +00:00
|
|
|
|
|
|
|
out_unref:
|
2005-03-21 17:34:02 +00:00
|
|
|
GST_QUEUE_MUTEX_UNLOCK;
|
|
|
|
GST_STREAM_UNLOCK (pad);
|
|
|
|
|
|
|
|
gst_buffer_unref (buffer);
|
|
|
|
|
|
|
|
return GST_FLOW_OK;
|
|
|
|
|
|
|
|
out_flushing:
|
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue, "exit because of flush");
|
|
|
|
GST_QUEUE_MUTEX_UNLOCK;
|
|
|
|
gst_task_pause (GST_RPAD_TASK (queue->srcpad));
|
|
|
|
GST_STREAM_UNLOCK (pad);
|
|
|
|
|
|
|
|
gst_buffer_unref (buffer);
|
|
|
|
|
|
|
|
return GST_FLOW_UNEXPECTED;
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
static void
|
|
|
|
gst_queue_loop (GstPad * pad)
|
2000-11-25 14:18:47 +00:00
|
|
|
{
|
2001-02-21 20:27:54 +00:00
|
|
|
GstQueue *queue;
|
check/Makefile.am: remove GstData checks
Original commit message from CVS:
* check/Makefile.am: remove GstData checks
* check/gst-libs/gdp.c: (START_TEST): fix for API changes
* gst/Makefile.am: add miniobject, remove data
* gst/gst.h: add miniobject, remove data
* gst/gstdata.c: remove
* gst/gstdata.h: remove
* gst/gstdata_private.h: remove
* gst/gsttypes.h: remove GstEvent and GstMessage
* gst/gstelement.c: (gst_element_post_message): fix for API changes
* gst/gstmarshal.list: change BOXED -> OBJECT
Implement GstMiniObject.
* gst/gstminiobject.c:
* gst/gstminiobject.h:
Modify to be subclasses of GstMiniObject.
* gst/gstbuffer.c: (_gst_buffer_initialize), (gst_buffer_get_type),
(gst_buffer_class_init), (gst_buffer_finalize), (_gst_buffer_copy),
(gst_buffer_init), (gst_buffer_new), (gst_buffer_new_and_alloc),
(gst_subbuffer_get_type), (gst_subbuffer_init),
(gst_buffer_create_sub), (gst_buffer_is_span_fast),
(gst_buffer_span):
* gst/gstbuffer.h:
* gst/gstevent.c: (_gst_event_initialize), (gst_event_get_type),
(gst_event_class_init), (gst_event_init), (gst_event_finalize),
(_gst_event_copy), (gst_event_new):
* gst/gstevent.h:
* gst/gstmessage.c: (_gst_message_initialize),
(gst_message_get_type), (gst_message_class_init),
(gst_message_init), (gst_message_finalize), (_gst_message_copy),
(gst_message_new), (gst_message_new_error),
(gst_message_new_warning), (gst_message_new_tag),
(gst_message_new_state_changed), (gst_message_new_application):
* gst/gstmessage.h:
* gst/gstprobe.c: (gst_probe_perform),
(gst_probe_dispatcher_dispatch):
* gst/gstprobe.h:
* gst/gstquery.c: (_gst_query_initialize), (gst_query_get_type),
(gst_query_class_init), (gst_query_finalize), (gst_query_init),
(_gst_query_copy), (gst_query_new):
Update elements for GstData -> GstMiniObject changes
* gst/gstquery.h:
* gst/gstqueue.c: (gst_queue_finalize), (gst_queue_locked_flush),
(gst_queue_chain), (gst_queue_loop):
* gst/elements/gstbufferstore.c:
(gst_buffer_store_add_buffer_func),
(gst_buffer_store_cleared_func), (gst_buffer_store_get_buffer):
* gst/elements/gstfakesink.c: (gst_fakesink_class_init),
(gst_fakesink_render):
* gst/elements/gstfakesrc.c: (gst_fakesrc_class_init):
* gst/elements/gstfilesrc.c: (gst_mmap_buffer_get_type),
(gst_mmap_buffer_class_init), (gst_mmap_buffer_init),
(gst_mmap_buffer_finalize), (gst_filesrc_map_region),
(gst_filesrc_create_read):
* gst/elements/gstidentity.c: (gst_identity_class_init):
* gst/elements/gsttypefindelement.c:
(gst_type_find_element_src_event), (free_entry_buffers),
(gst_type_find_element_handle_event):
* libs/gst/dataprotocol/dataprotocol.c:
(gst_dp_header_from_buffer):
* libs/gst/dataprotocol/dataprotocol.h:
* libs/gst/dataprotocol/dp-private.h:
2005-05-16 20:21:55 +00:00
|
|
|
GstMiniObject *data;
|
2005-03-21 17:34:02 +00:00
|
|
|
gboolean restart = TRUE;
|
Another big set of changes. Connections are now also pullfunc based. gstqueue has been updated, I don't know of any ...
Original commit message from CVS:
Another big set of changes. Connections are now also pullfunc based.
gstqueue has been updated, I don't know of any other connections offhand.
There are still a few things that need doing, specifically the concept
of a source or connection with connections to multiple thread contexts is
not dealt with. This may force us to move the threadstate from the
element to the pad, maybe keeping the element's copy for simple cases.
Then the Bin would create a structure to pass to the cothreaded _wrappers
of any such elements, which would detail the pads that are to be dealt with
by this particular cothread context.
That will speed things up to, since we don't have to look through the list
of all pads for every Src or Connection element for every iteration, we can
simply step through the list provided by the plan. Special case might even
have a single pad pointer sitting there to trump the list, if there's only
one (the common case anyway).
Task 23098 is tracking these changes. The main task 22588 depends on that
subtask, as well as 22240, which is a consistency check on PAD_DISABLED.
2000-12-08 10:33:01 +00:00
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
queue = GST_QUEUE (GST_PAD_PARENT (pad));
|
2001-02-21 20:27:54 +00:00
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
GST_STREAM_LOCK (pad);
|
2001-10-27 20:28:31 +00:00
|
|
|
|
2000-01-30 09:03:00 +00:00
|
|
|
/* have to lock for thread-safety */
|
2004-07-09 11:23:55 +00:00
|
|
|
GST_QUEUE_MUTEX_LOCK;
|
2003-12-13 17:12:46 +00:00
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
restart:
|
|
|
|
while (gst_queue_is_empty (queue)) {
|
2004-07-09 11:23:55 +00:00
|
|
|
GST_QUEUE_MUTEX_UNLOCK;
|
2003-12-13 17:12:46 +00:00
|
|
|
g_signal_emit (G_OBJECT (queue), gst_queue_signals[SIGNAL_UNDERRUN], 0);
|
2004-07-09 11:23:55 +00:00
|
|
|
GST_QUEUE_MUTEX_LOCK;
|
2003-12-13 17:12:46 +00:00
|
|
|
|
|
|
|
STATUS (queue, "pre-empty wait");
|
2005-03-21 17:34:02 +00:00
|
|
|
while (gst_queue_is_empty (queue)) {
|
2003-12-13 17:12:46 +00:00
|
|
|
STATUS (queue, "waiting for item_add");
|
2004-03-13 15:27:01 +00:00
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
/* we are flushing */
|
|
|
|
if (GST_RPAD_IS_FLUSHING (queue->sinkpad))
|
|
|
|
goto out_flushing;
|
|
|
|
|
|
|
|
GST_LOG_OBJECT (queue, "doing g_cond_wait using qlock from thread %p",
|
|
|
|
g_thread_self ());
|
|
|
|
g_cond_wait (queue->item_add, queue->qlock);
|
|
|
|
|
|
|
|
/* we got unlocked because we are flushing */
|
|
|
|
if (GST_RPAD_IS_FLUSHING (queue->sinkpad))
|
|
|
|
goto out_flushing;
|
|
|
|
|
|
|
|
GST_LOG_OBJECT (queue, "done g_cond_wait using qlock from thread %p",
|
|
|
|
g_thread_self ());
|
2003-12-13 17:12:46 +00:00
|
|
|
STATUS (queue, "got item_add signal");
|
2002-06-03 15:44:28 +00:00
|
|
|
}
|
2000-01-30 09:03:00 +00:00
|
|
|
|
2003-12-13 17:12:46 +00:00
|
|
|
STATUS (queue, "post-empty wait");
|
2004-07-09 11:23:55 +00:00
|
|
|
GST_QUEUE_MUTEX_UNLOCK;
|
2003-12-13 17:12:46 +00:00
|
|
|
g_signal_emit (G_OBJECT (queue), gst_queue_signals[SIGNAL_RUNNING], 0);
|
2004-07-09 11:23:55 +00:00
|
|
|
GST_QUEUE_MUTEX_LOCK;
|
2003-12-13 17:12:46 +00:00
|
|
|
}
|
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 */
|
|
|
|
data = g_queue_pop_head (queue->queue);
|
gst/elements/gstfilesrc.c: compute mapsize correctly
Original commit message from CVS:
* gst/elements/gstfilesrc.c: (gst_filesrc_get_mmap):
compute mapsize correctly
* gst/elements/gstfilesrc.c: (gst_filesrc_get_mmap):
use correct datatypes when calling a varargs function
* gst/elements/gsttypefindelement.c: (stop_typefinding):
push a DISCONT event as first thing
* gst/gst_private.h:
* gst/gstinfo.c: (_gst_debug_init):
remove GST_DATAFLOW debugging category
* gst/gstbin.c: (gst_bin_iterate):
use GST_SCHEDULING category
* gst/gstpad.c: (gst_pad_get_type), (_invent_event),
(gst_pad_push), (gst_pad_pull), (gst_pad_call_chain_function),
(gst_pad_call_get_function):
add GST_DATAFLOW to easily track flow of buffers or events.
* gst/gstqueue.c: (gst_queue_get_type),
(gst_queue_handle_pending_events), (gst_queue_chain),
(gst_queue_get), (gst_queue_handle_src_event):
use own static debugging category GST_DATAFLOW for dataflow,
use DEBUG category for showing which path events go, use LOG
category for buffers.
2004-05-11 16:20:41 +00:00
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue,
|
2004-03-13 15:27:01 +00:00
|
|
|
"retrieved data %p from queue", data);
|
|
|
|
|
2003-12-13 17:12:46 +00:00
|
|
|
if (GST_IS_BUFFER (data)) {
|
2005-03-21 17:34:02 +00:00
|
|
|
GstFlowReturn result;
|
|
|
|
|
2003-12-13 17:12:46 +00:00
|
|
|
/* Update statistics */
|
|
|
|
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);
|
2001-12-29 03:02:14 +00:00
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
GST_QUEUE_MUTEX_UNLOCK;
|
|
|
|
result = gst_pad_push (pad, GST_BUFFER (data));
|
|
|
|
GST_QUEUE_MUTEX_LOCK;
|
|
|
|
if (result != GST_FLOW_OK) {
|
|
|
|
gst_task_pause (GST_RPAD_TASK (queue->srcpad));
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (GST_EVENT_TYPE (data) == GST_EVENT_EOS) {
|
|
|
|
gst_task_pause (GST_RPAD_TASK (queue->srcpad));
|
|
|
|
restart = FALSE;
|
|
|
|
}
|
|
|
|
GST_QUEUE_MUTEX_UNLOCK;
|
|
|
|
gst_pad_push_event (queue->srcpad, GST_EVENT (data));
|
|
|
|
GST_QUEUE_MUTEX_LOCK;
|
|
|
|
if (restart == TRUE)
|
|
|
|
goto restart;
|
|
|
|
}
|
2001-10-27 20:28:31 +00:00
|
|
|
|
2003-12-13 17:12:46 +00:00
|
|
|
STATUS (queue, "after _get()");
|
2001-12-29 03:02:14 +00:00
|
|
|
|
gst/elements/gstfilesrc.c: compute mapsize correctly
Original commit message from CVS:
* gst/elements/gstfilesrc.c: (gst_filesrc_get_mmap):
compute mapsize correctly
* gst/elements/gstfilesrc.c: (gst_filesrc_get_mmap):
use correct datatypes when calling a varargs function
* gst/elements/gsttypefindelement.c: (stop_typefinding):
push a DISCONT event as first thing
* gst/gst_private.h:
* gst/gstinfo.c: (_gst_debug_init):
remove GST_DATAFLOW debugging category
* gst/gstbin.c: (gst_bin_iterate):
use GST_SCHEDULING category
* gst/gstpad.c: (gst_pad_get_type), (_invent_event),
(gst_pad_push), (gst_pad_pull), (gst_pad_call_chain_function),
(gst_pad_call_get_function):
add GST_DATAFLOW to easily track flow of buffers or events.
* gst/gstqueue.c: (gst_queue_get_type),
(gst_queue_handle_pending_events), (gst_queue_chain),
(gst_queue_get), (gst_queue_handle_src_event):
use own static debugging category GST_DATAFLOW for dataflow,
use DEBUG category for showing which path events go, use LOG
category for buffers.
2004-05-11 16:20:41 +00:00
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue, "signalling item_del");
|
2003-12-13 17:12:46 +00:00
|
|
|
g_cond_signal (queue->item_del);
|
2004-07-09 11:23:55 +00:00
|
|
|
GST_QUEUE_MUTEX_UNLOCK;
|
2005-03-21 17:34:02 +00:00
|
|
|
GST_STREAM_UNLOCK (pad);
|
|
|
|
return;
|
2001-10-27 20:28:31 +00:00
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
out_flushing:
|
|
|
|
GST_CAT_LOG_OBJECT (queue_dataflow, queue, "exit because of flush");
|
|
|
|
gst_task_pause (GST_RPAD_TASK (pad));
|
|
|
|
GST_QUEUE_MUTEX_UNLOCK;
|
|
|
|
GST_STREAM_UNLOCK (pad);
|
|
|
|
return;
|
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
|
|
|
{
|
2005-03-21 17:34:02 +00:00
|
|
|
GstQueue *queue = GST_QUEUE (GST_PAD_PARENT (pad));
|
|
|
|
gboolean res = TRUE;
|
2002-05-26 21:54:27 +00:00
|
|
|
|
2004-06-11 15:18:58 +00:00
|
|
|
GST_CAT_DEBUG_OBJECT (queue_dataflow, queue, "got event %p (%d)",
|
|
|
|
event, GST_EVENT_TYPE (event));
|
2002-06-08 16:30:43 +00:00
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
gst_event_ref (event);
|
|
|
|
res = gst_pad_event_default (pad, event);
|
|
|
|
GST_QUEUE_MUTEX_LOCK;
|
2003-01-12 13:06:44 +00:00
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
switch (GST_EVENT_TYPE (event)) {
|
|
|
|
case GST_EVENT_SEEK:
|
|
|
|
if (GST_EVENT_SEEK_FLAGS (event) & GST_SEEK_FLAG_FLUSH) {
|
2004-03-15 19:27:17 +00:00
|
|
|
gst_queue_locked_flush (queue);
|
2005-03-21 17:34:02 +00:00
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
2002-05-26 21:54:27 +00:00
|
|
|
}
|
2004-07-09 11:23:55 +00:00
|
|
|
GST_QUEUE_MUTEX_UNLOCK;
|
2005-03-21 17:34:02 +00:00
|
|
|
gst_event_unref (event);
|
2002-06-02 15:34:34 +00:00
|
|
|
|
2003-01-15 21:01:58 +00:00
|
|
|
return res;
|
2002-05-26 21:54:27 +00:00
|
|
|
}
|
|
|
|
|
2004-10-11 13:14:03 +00:00
|
|
|
static gboolean
|
2005-05-09 10:53:13 +00:00
|
|
|
gst_queue_handle_src_query (GstPad * pad, GstQuery * query)
|
2004-10-11 13:14:03 +00:00
|
|
|
{
|
2005-03-21 17:34:02 +00:00
|
|
|
GstQueue *queue = GST_QUEUE (GST_PAD_PARENT (pad));
|
2004-10-11 13:14:03 +00:00
|
|
|
|
2004-12-09 16:13:18 +00:00
|
|
|
if (!GST_PAD_PEER (queue->sinkpad))
|
|
|
|
return FALSE;
|
2005-05-09 10:53:13 +00:00
|
|
|
if (!gst_pad_query (GST_PAD_PEER (queue->sinkpad), query))
|
2004-10-11 13:14:03 +00:00
|
|
|
return FALSE;
|
|
|
|
|
2005-05-09 10:53:13 +00:00
|
|
|
switch (GST_QUERY_TYPE (query)) {
|
|
|
|
case GST_QUERY_POSITION:
|
|
|
|
{
|
|
|
|
gint64 peer_pos, peer_total;
|
|
|
|
GstFormat format;
|
|
|
|
|
|
|
|
/* get peer position */
|
|
|
|
gst_query_parse_position (query, &format, &peer_pos, &peer_total);
|
|
|
|
|
|
|
|
/* FIXME: this code assumes that there's no discont in the queue */
|
|
|
|
switch (format) {
|
|
|
|
case GST_FORMAT_BYTES:
|
|
|
|
peer_pos -= queue->cur_level.bytes;
|
|
|
|
break;
|
|
|
|
case GST_FORMAT_TIME:
|
|
|
|
peer_pos -= queue->cur_level.time;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
/* FIXME */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
/* set updated positions */
|
|
|
|
gst_query_set_position (query, format, peer_pos, peer_total);
|
|
|
|
break;
|
2004-10-11 13:14:03 +00:00
|
|
|
}
|
2005-05-09 10:53:13 +00:00
|
|
|
default:
|
|
|
|
break;
|
2004-10-11 13:14:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2002-05-26 21:54:27 +00:00
|
|
|
static gboolean
|
2005-03-21 17:34:02 +00:00
|
|
|
gst_queue_src_activate (GstPad * pad, GstActivateMode mode)
|
2002-05-26 21:54:27 +00:00
|
|
|
{
|
2005-03-21 17:34:02 +00:00
|
|
|
gboolean result = FALSE;
|
2002-05-26 21:54:27 +00:00
|
|
|
GstQueue *queue;
|
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
queue = GST_QUEUE (GST_OBJECT_PARENT (pad));
|
2002-05-26 21:54:27 +00:00
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
if (mode == GST_ACTIVATE_PUSH) {
|
|
|
|
/* if we have a scheduler we can start the task */
|
|
|
|
if (GST_ELEMENT_SCHEDULER (queue)) {
|
|
|
|
GST_STREAM_LOCK (pad);
|
|
|
|
GST_RPAD_TASK (pad) =
|
|
|
|
gst_scheduler_create_task (GST_ELEMENT_SCHEDULER (queue),
|
|
|
|
(GstTaskFunction) gst_queue_loop, pad);
|
|
|
|
|
|
|
|
gst_task_start (GST_RPAD_TASK (pad));
|
|
|
|
GST_STREAM_UNLOCK (pad);
|
|
|
|
result = TRUE;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
/* step 1, unblock chain and loop functions */
|
2005-05-06 17:10:49 +00:00
|
|
|
GST_QUEUE_MUTEX_LOCK;
|
2005-03-21 17:34:02 +00:00
|
|
|
g_cond_signal (queue->item_add);
|
|
|
|
g_cond_signal (queue->item_del);
|
2005-05-06 17:10:49 +00:00
|
|
|
GST_QUEUE_MUTEX_UNLOCK;
|
2002-05-26 21:54:27 +00:00
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
/* step 2, make sure streaming finishes */
|
|
|
|
GST_STREAM_LOCK (pad);
|
|
|
|
/* step 3, stop the task */
|
|
|
|
gst_task_stop (GST_RPAD_TASK (pad));
|
|
|
|
gst_object_unref (GST_OBJECT (GST_RPAD_TASK (pad)));
|
|
|
|
GST_STREAM_UNLOCK (pad);
|
|
|
|
|
|
|
|
result = TRUE;
|
|
|
|
}
|
|
|
|
return result;
|
2002-05-26 21:54:27 +00:00
|
|
|
}
|
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
|
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;
|
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-03-21 17:34:02 +00:00
|
|
|
GST_CAT_LOG_OBJECT (GST_CAT_STATES, element, "starting state change");
|
2001-12-04 22:12:50 +00:00
|
|
|
|
2001-12-14 22:59:21 +00:00
|
|
|
/* lock the queue so another thread (not in sync with this thread's state)
|
2005-03-21 17:34:02 +00:00
|
|
|
* can't call this queue's _loop (or whatever) */
|
2000-10-30 21:02:08 +00:00
|
|
|
|
2003-01-15 21:01:58 +00:00
|
|
|
switch (GST_STATE_TRANSITION (element)) {
|
|
|
|
case GST_STATE_NULL_TO_READY:
|
2005-05-17 17:37:43 +00:00
|
|
|
break;
|
|
|
|
case GST_STATE_READY_TO_PAUSED:
|
2005-05-06 17:10:49 +00:00
|
|
|
GST_QUEUE_MUTEX_LOCK;
|
2003-01-15 21:01:58 +00:00
|
|
|
gst_queue_locked_flush (queue);
|
2005-05-06 17:10:49 +00:00
|
|
|
GST_QUEUE_MUTEX_UNLOCK;
|
2003-01-15 21:01:58 +00:00
|
|
|
break;
|
|
|
|
case GST_STATE_PAUSED_TO_PLAYING:
|
2005-03-21 17:34:02 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2001-12-04 22:12:50 +00:00
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element);
|
2003-01-15 21:01:58 +00:00
|
|
|
|
2005-03-21 17:34:02 +00:00
|
|
|
switch (GST_STATE_TRANSITION (element)) {
|
|
|
|
case GST_STATE_PLAYING_TO_PAUSED:
|
2003-01-15 21:01:58 +00:00
|
|
|
break;
|
|
|
|
case GST_STATE_PAUSED_TO_READY:
|
2005-05-06 17:10:49 +00:00
|
|
|
GST_QUEUE_MUTEX_LOCK;
|
2003-01-15 21:01:58 +00:00
|
|
|
gst_queue_locked_flush (queue);
|
2005-05-06 17:10:49 +00:00
|
|
|
GST_QUEUE_MUTEX_UNLOCK;
|
2005-03-21 17:34:02 +00:00
|
|
|
break;
|
|
|
|
case GST_STATE_READY_TO_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
|
|
|
}
|
2000-10-30 21:02:08 +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
|
|
|
|
2003-12-13 17:12:46 +00:00
|
|
|
/* someone could change levels here, and since this
|
|
|
|
* affects the get/put funcs, we need to lock for safety. */
|
2004-07-09 11:23:55 +00:00
|
|
|
GST_QUEUE_MUTEX_LOCK;
|
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_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;
|
|
|
|
case ARG_LEAKY:
|
|
|
|
queue->leaky = g_value_get_enum (value);
|
2003-05-30 23:20:02 +00:00
|
|
|
break;
|
2001-12-22 21:18:17 +00:00
|
|
|
case ARG_MAY_DEADLOCK:
|
|
|
|
queue->may_deadlock = g_value_get_boolean (value);
|
2000-12-26 23:51:04 +00:00
|
|
|
break;
|
2002-06-03 15:44:28 +00:00
|
|
|
case ARG_BLOCK_TIMEOUT:
|
2003-12-13 17:12:46 +00:00
|
|
|
queue->block_timeout = g_value_get_uint64 (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;
|
|
|
|
}
|
2003-12-13 17:12:46 +00:00
|
|
|
|
2004-07-09 11:23:55 +00:00
|
|
|
GST_QUEUE_MUTEX_UNLOCK;
|
2000-01-30 09:03:00 +00:00
|
|
|
}
|
|
|
|
|
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;
|
|
|
|
case ARG_LEAKY:
|
|
|
|
g_value_set_enum (value, queue->leaky);
|
2003-05-30 23:20:02 +00:00
|
|
|
break;
|
2001-12-22 21:18:17 +00:00
|
|
|
case ARG_MAY_DEADLOCK:
|
|
|
|
g_value_set_boolean (value, queue->may_deadlock);
|
2000-12-26 23:51:04 +00:00
|
|
|
break;
|
2002-06-03 15:44:28 +00:00
|
|
|
case ARG_BLOCK_TIMEOUT:
|
2003-12-13 17:12:46 +00:00
|
|
|
g_value_set_uint64 (value, queue->block_timeout);
|
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;
|
|
|
|
}
|
|
|
|
}
|