2011-03-29 08:39:42 +00:00
|
|
|
/*
|
2011-03-29 08:42:31 +00:00
|
|
|
* GStreamer Funnel element
|
2011-03-29 08:39:42 +00:00
|
|
|
*
|
|
|
|
* Copyright 2007 Collabora Ltd.
|
|
|
|
* @author: Olivier Crete <olivier.crete@collabora.co.uk>
|
|
|
|
* Copyright 2007 Nokia Corp.
|
|
|
|
*
|
2011-03-29 08:42:31 +00:00
|
|
|
* gstfunnel.c: Simple Funnel element
|
2011-03-29 08:39:42 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 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
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2011-03-29 08:42:31 +00:00
|
|
|
* SECTION:element-funnel
|
2011-03-29 08:39:42 +00:00
|
|
|
*
|
2011-03-29 09:18:36 +00:00
|
|
|
* Takes packets from various input sinks into one output source.
|
|
|
|
*
|
|
|
|
* funnel always outputs a single, open ended segment from
|
|
|
|
* 0 with in %GST_FORMAT_TIME and outputs the buffers of the
|
|
|
|
* different sinkpads with timestamps that are set to the
|
|
|
|
* running time for that stream. funnel does not synchronize
|
|
|
|
* the different input streams but simply forwards all buffers
|
|
|
|
* immediately when they arrive.
|
|
|
|
*
|
2011-03-29 08:39:42 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
2011-03-29 08:42:31 +00:00
|
|
|
#include "config.h"
|
2011-03-29 08:39:42 +00:00
|
|
|
#endif
|
|
|
|
|
2011-03-29 08:42:31 +00:00
|
|
|
#include "gstfunnel.h"
|
2011-03-29 08:39:42 +00:00
|
|
|
|
2011-03-29 08:42:31 +00:00
|
|
|
GST_DEBUG_CATEGORY_STATIC (gst_funnel_debug);
|
|
|
|
#define GST_CAT_DEFAULT gst_funnel_debug
|
2011-03-29 08:39:42 +00:00
|
|
|
|
2014-07-09 13:48:10 +00:00
|
|
|
GType gst_funnel_pad_get_type (void);
|
|
|
|
#define GST_TYPE_FUNNEL_PAD \
|
|
|
|
(gst_funnel_pad_get_type())
|
|
|
|
#define GST_FUNNEL_PAD(obj) \
|
|
|
|
(G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_FUNNEL_PAD, GstFunnelPad))
|
|
|
|
#define GST_FUNNEL_PAD_CLASS(klass) \
|
|
|
|
(G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_FUNNEL_PAD, GstFunnelPadClass))
|
|
|
|
#define GST_IS_FUNNEL_PAD(obj) \
|
|
|
|
(G_TYPE_CHECK_INSTANCE_TYPE ((obj), GST_TYPE_FUNNEL_PAD))
|
|
|
|
#define GST_IS_FUNNEL_PAD_CLASS(klass) \
|
|
|
|
(G_TYPE_CHECK_CLASS_TYPE ((klass), GST_TYPE_FUNNEL_PAD))
|
|
|
|
#define GST_FUNNEL_PAD_CAST(obj) \
|
|
|
|
((GstFunnelPad *)(obj))
|
|
|
|
|
|
|
|
typedef struct _GstFunnelPad GstFunnelPad;
|
|
|
|
typedef struct _GstFunnelPadClass GstFunnelPadClass;
|
|
|
|
|
|
|
|
struct _GstFunnelPad
|
|
|
|
{
|
|
|
|
GstPad parent;
|
|
|
|
|
|
|
|
gboolean got_eos;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct _GstFunnelPadClass
|
|
|
|
{
|
|
|
|
GstPadClass parent;
|
|
|
|
};
|
|
|
|
|
|
|
|
G_DEFINE_TYPE (GstFunnelPad, gst_funnel_pad, GST_TYPE_PAD);
|
|
|
|
|
2015-05-14 09:48:45 +00:00
|
|
|
#define DEFAULT_FORWARD_STICKY_EVENTS TRUE
|
|
|
|
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
PROP_0,
|
|
|
|
PROP_FORWARD_STICKY_EVENTS
|
|
|
|
};
|
|
|
|
|
2014-07-09 13:48:10 +00:00
|
|
|
static void
|
|
|
|
gst_funnel_pad_class_init (GstFunnelPadClass * klass)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_funnel_pad_init (GstFunnelPad * pad)
|
|
|
|
{
|
|
|
|
pad->got_eos = FALSE;
|
|
|
|
}
|
|
|
|
|
2016-02-27 15:36:28 +00:00
|
|
|
static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink_%u",
|
2011-03-29 08:39:42 +00:00
|
|
|
GST_PAD_SINK,
|
|
|
|
GST_PAD_REQUEST,
|
|
|
|
GST_STATIC_CAPS_ANY);
|
|
|
|
|
2016-02-27 15:36:28 +00:00
|
|
|
static GstStaticPadTemplate src_template = GST_STATIC_PAD_TEMPLATE ("src",
|
2011-03-29 08:39:42 +00:00
|
|
|
GST_PAD_SRC,
|
|
|
|
GST_PAD_ALWAYS,
|
|
|
|
GST_STATIC_CAPS_ANY);
|
|
|
|
|
2011-04-18 16:07:06 +00:00
|
|
|
#define _do_init \
|
2011-03-29 08:42:31 +00:00
|
|
|
GST_DEBUG_CATEGORY_INIT (gst_funnel_debug, "funnel", 0, "funnel element");
|
2011-04-18 16:07:06 +00:00
|
|
|
#define gst_funnel_parent_class parent_class
|
|
|
|
G_DEFINE_TYPE_WITH_CODE (GstFunnel, gst_funnel, GST_TYPE_ELEMENT, _do_init);
|
2011-03-29 08:39:42 +00:00
|
|
|
|
2014-07-09 13:48:10 +00:00
|
|
|
static GstStateChangeReturn gst_funnel_change_state (GstElement * element,
|
|
|
|
GstStateChange transition);
|
2011-03-29 08:42:31 +00:00
|
|
|
static GstPad *gst_funnel_request_new_pad (GstElement * element,
|
2011-05-10 14:41:36 +00:00
|
|
|
GstPadTemplate * templ, const gchar * name, const GstCaps * caps);
|
2011-03-29 08:42:31 +00:00
|
|
|
static void gst_funnel_release_pad (GstElement * element, GstPad * pad);
|
2011-03-29 08:39:42 +00:00
|
|
|
|
2011-11-17 11:40:45 +00:00
|
|
|
static GstFlowReturn gst_funnel_sink_chain (GstPad * pad, GstObject * parent,
|
|
|
|
GstBuffer * buffer);
|
2015-03-18 08:36:35 +00:00
|
|
|
static GstFlowReturn gst_funnel_sink_chain_list (GstPad * pad,
|
|
|
|
GstObject * parent, GstBufferList * list);
|
2011-11-17 11:40:45 +00:00
|
|
|
static gboolean gst_funnel_sink_event (GstPad * pad, GstObject * parent,
|
|
|
|
GstEvent * event);
|
2011-03-29 08:39:42 +00:00
|
|
|
|
2015-05-14 09:48:45 +00:00
|
|
|
static void
|
|
|
|
gst_funnel_set_property (GObject * object, guint prop_id,
|
|
|
|
const GValue * value, GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
GstFunnel *funnel = GST_FUNNEL (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_FORWARD_STICKY_EVENTS:
|
|
|
|
funnel->forward_sticky_events = g_value_get_boolean (value);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
gst_funnel_get_property (GObject * object, guint prop_id, GValue * value,
|
|
|
|
GParamSpec * pspec)
|
|
|
|
{
|
|
|
|
GstFunnel *funnel = GST_FUNNEL (object);
|
|
|
|
|
|
|
|
switch (prop_id) {
|
|
|
|
case PROP_FORWARD_STICKY_EVENTS:
|
|
|
|
g_value_set_boolean (value, funnel->forward_sticky_events);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-29 08:39:42 +00:00
|
|
|
static void
|
2011-03-29 08:42:31 +00:00
|
|
|
gst_funnel_dispose (GObject * object)
|
2011-03-29 08:39:42 +00:00
|
|
|
{
|
2013-07-02 00:35:21 +00:00
|
|
|
GstFunnel *funnel = GST_FUNNEL (object);
|
2011-03-29 08:39:42 +00:00
|
|
|
GList *item;
|
|
|
|
|
2013-07-02 00:35:21 +00:00
|
|
|
gst_object_replace ((GstObject **) & funnel->last_sinkpad, NULL);
|
|
|
|
|
2011-03-29 08:39:42 +00:00
|
|
|
restart:
|
|
|
|
for (item = GST_ELEMENT_PADS (object); item; item = g_list_next (item)) {
|
|
|
|
GstPad *pad = GST_PAD (item->data);
|
|
|
|
|
|
|
|
if (GST_PAD_IS_SINK (pad)) {
|
|
|
|
gst_element_release_request_pad (GST_ELEMENT (object), pad);
|
|
|
|
goto restart;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
G_OBJECT_CLASS (parent_class)->dispose (object);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-03-29 08:42:31 +00:00
|
|
|
gst_funnel_class_init (GstFunnelClass * klass)
|
2011-03-29 08:39:42 +00:00
|
|
|
{
|
|
|
|
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
|
|
GstElementClass *gstelement_class = GST_ELEMENT_CLASS (klass);
|
|
|
|
|
2015-05-14 09:48:45 +00:00
|
|
|
gobject_class->set_property = gst_funnel_set_property;
|
|
|
|
gobject_class->get_property = gst_funnel_get_property;
|
2011-03-29 08:42:31 +00:00
|
|
|
gobject_class->dispose = GST_DEBUG_FUNCPTR (gst_funnel_dispose);
|
2011-03-29 08:39:42 +00:00
|
|
|
|
2015-05-14 09:48:45 +00:00
|
|
|
g_object_class_install_property (gobject_class, PROP_FORWARD_STICKY_EVENTS,
|
|
|
|
g_param_spec_boolean ("forward-sticky-events", "Forward sticky events",
|
|
|
|
"Forward sticky events on stream changes",
|
|
|
|
DEFAULT_FORWARD_STICKY_EVENTS,
|
|
|
|
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS |
|
|
|
|
GST_PARAM_MUTABLE_READY));
|
|
|
|
|
2012-04-09 12:05:07 +00:00
|
|
|
gst_element_class_set_static_metadata (gstelement_class,
|
2011-04-18 16:07:06 +00:00
|
|
|
"Funnel pipe fitting", "Generic", "N-to-1 pipe fitting",
|
|
|
|
"Olivier Crete <olivier.crete@collabora.co.uk>");
|
|
|
|
|
2016-02-27 15:36:28 +00:00
|
|
|
gst_element_class_add_static_pad_template (gstelement_class, &sink_template);
|
|
|
|
gst_element_class_add_static_pad_template (gstelement_class, &src_template);
|
2011-04-18 16:07:06 +00:00
|
|
|
|
2011-03-29 08:39:42 +00:00
|
|
|
gstelement_class->request_new_pad =
|
2011-03-29 08:42:31 +00:00
|
|
|
GST_DEBUG_FUNCPTR (gst_funnel_request_new_pad);
|
|
|
|
gstelement_class->release_pad = GST_DEBUG_FUNCPTR (gst_funnel_release_pad);
|
2014-07-09 13:48:10 +00:00
|
|
|
gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_funnel_change_state);
|
2011-03-29 08:39:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2011-04-18 16:07:06 +00:00
|
|
|
gst_funnel_init (GstFunnel * funnel)
|
2011-03-29 08:39:42 +00:00
|
|
|
{
|
2016-02-27 15:36:28 +00:00
|
|
|
funnel->srcpad = gst_pad_new_from_static_template (&src_template, "src");
|
2011-03-29 08:39:42 +00:00
|
|
|
gst_pad_use_fixed_caps (funnel->srcpad);
|
2013-12-20 10:37:53 +00:00
|
|
|
|
2011-03-29 08:39:42 +00:00
|
|
|
gst_element_add_pad (GST_ELEMENT (funnel), funnel->srcpad);
|
2015-05-14 09:48:45 +00:00
|
|
|
|
|
|
|
funnel->forward_sticky_events = DEFAULT_FORWARD_STICKY_EVENTS;
|
2011-03-29 08:39:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GstPad *
|
2011-03-29 08:42:31 +00:00
|
|
|
gst_funnel_request_new_pad (GstElement * element, GstPadTemplate * templ,
|
2011-05-10 14:41:36 +00:00
|
|
|
const gchar * name, const GstCaps * caps)
|
2011-03-29 08:39:42 +00:00
|
|
|
{
|
|
|
|
GstPad *sinkpad;
|
|
|
|
|
|
|
|
GST_DEBUG_OBJECT (element, "requesting pad");
|
|
|
|
|
2014-07-09 13:48:10 +00:00
|
|
|
sinkpad = GST_PAD_CAST (g_object_new (GST_TYPE_FUNNEL_PAD,
|
|
|
|
"name", name, "direction", templ->direction, "template", templ,
|
|
|
|
NULL));
|
2011-03-29 08:39:42 +00:00
|
|
|
|
2011-03-29 09:07:48 +00:00
|
|
|
gst_pad_set_chain_function (sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_funnel_sink_chain));
|
2015-03-18 08:36:35 +00:00
|
|
|
gst_pad_set_chain_list_function (sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_funnel_sink_chain_list));
|
2011-03-29 09:07:48 +00:00
|
|
|
gst_pad_set_event_function (sinkpad,
|
|
|
|
GST_DEBUG_FUNCPTR (gst_funnel_sink_event));
|
2011-03-29 08:39:42 +00:00
|
|
|
|
2013-12-20 10:37:53 +00:00
|
|
|
GST_OBJECT_FLAG_SET (sinkpad, GST_PAD_FLAG_PROXY_CAPS);
|
|
|
|
GST_OBJECT_FLAG_SET (sinkpad, GST_PAD_FLAG_PROXY_ALLOCATION);
|
|
|
|
|
2011-03-29 08:39:42 +00:00
|
|
|
gst_pad_set_active (sinkpad, TRUE);
|
|
|
|
|
|
|
|
gst_element_add_pad (element, sinkpad);
|
|
|
|
|
2015-05-27 11:54:25 +00:00
|
|
|
GST_DEBUG_OBJECT (element, "requested pad %s:%s",
|
|
|
|
GST_DEBUG_PAD_NAME (sinkpad));
|
|
|
|
|
2011-03-29 08:39:42 +00:00
|
|
|
return sinkpad;
|
|
|
|
}
|
|
|
|
|
2012-05-26 03:52:33 +00:00
|
|
|
static gboolean
|
2014-04-11 17:52:02 +00:00
|
|
|
gst_funnel_all_sinkpads_eos_unlocked (GstFunnel * funnel, GstPad * pad)
|
2012-05-26 03:52:33 +00:00
|
|
|
{
|
|
|
|
GstElement *element = GST_ELEMENT_CAST (funnel);
|
|
|
|
GList *item;
|
2014-04-11 17:52:02 +00:00
|
|
|
gboolean all_eos = FALSE;
|
|
|
|
|
2012-05-26 03:52:33 +00:00
|
|
|
|
|
|
|
if (element->numsinkpads == 0)
|
2014-04-11 17:52:02 +00:00
|
|
|
goto done;
|
2012-05-26 03:52:33 +00:00
|
|
|
|
|
|
|
for (item = element->sinkpads; item != NULL; item = g_list_next (item)) {
|
2014-07-09 13:48:10 +00:00
|
|
|
GstFunnelPad *sinkpad = GST_FUNNEL_PAD_CAST (item->data);
|
2013-07-02 00:35:21 +00:00
|
|
|
|
2014-11-28 13:17:54 +00:00
|
|
|
if (!sinkpad->got_eos) {
|
2014-07-09 13:48:10 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2012-05-26 03:52:33 +00:00
|
|
|
}
|
|
|
|
|
2014-04-11 17:52:02 +00:00
|
|
|
all_eos = TRUE;
|
|
|
|
|
|
|
|
done:
|
|
|
|
return all_eos;
|
2012-05-26 03:52:33 +00:00
|
|
|
}
|
|
|
|
|
2011-03-29 08:39:42 +00:00
|
|
|
static void
|
2011-03-29 08:42:31 +00:00
|
|
|
gst_funnel_release_pad (GstElement * element, GstPad * pad)
|
2011-03-29 08:39:42 +00:00
|
|
|
{
|
2011-03-29 08:42:31 +00:00
|
|
|
GstFunnel *funnel = GST_FUNNEL (element);
|
2014-07-09 13:48:10 +00:00
|
|
|
GstFunnelPad *fpad = GST_FUNNEL_PAD_CAST (pad);
|
|
|
|
gboolean got_eos;
|
2012-05-26 03:52:33 +00:00
|
|
|
gboolean send_eos = FALSE;
|
2011-03-29 08:39:42 +00:00
|
|
|
|
2015-05-27 11:54:25 +00:00
|
|
|
GST_DEBUG_OBJECT (funnel, "releasing pad %s:%s", GST_DEBUG_PAD_NAME (pad));
|
2011-03-29 08:39:42 +00:00
|
|
|
|
|
|
|
gst_pad_set_active (pad, FALSE);
|
|
|
|
|
2014-07-09 13:48:10 +00:00
|
|
|
got_eos = fpad->got_eos;
|
2012-06-12 11:26:35 +00:00
|
|
|
|
2011-03-29 08:39:42 +00:00
|
|
|
gst_element_remove_pad (GST_ELEMENT_CAST (funnel), pad);
|
2012-05-26 03:52:33 +00:00
|
|
|
|
2014-07-09 13:48:10 +00:00
|
|
|
GST_OBJECT_LOCK (funnel);
|
|
|
|
if (!got_eos && gst_funnel_all_sinkpads_eos_unlocked (funnel, NULL)) {
|
2012-05-26 03:52:33 +00:00
|
|
|
GST_DEBUG_OBJECT (funnel, "Pad removed. All others are EOS. Sending EOS");
|
|
|
|
send_eos = TRUE;
|
|
|
|
}
|
2014-07-09 13:48:10 +00:00
|
|
|
GST_OBJECT_UNLOCK (funnel);
|
2012-05-26 03:52:33 +00:00
|
|
|
|
|
|
|
if (send_eos)
|
|
|
|
if (!gst_pad_push_event (funnel->srcpad, gst_event_new_eos ()))
|
|
|
|
GST_WARNING_OBJECT (funnel, "Failure pushing EOS");
|
2011-03-29 08:39:42 +00:00
|
|
|
}
|
|
|
|
|
2013-07-02 00:35:21 +00:00
|
|
|
static gboolean
|
|
|
|
forward_events (GstPad * pad, GstEvent ** event, gpointer user_data)
|
|
|
|
{
|
|
|
|
GstPad *srcpad = user_data;
|
|
|
|
|
|
|
|
if (GST_EVENT_TYPE (*event) != GST_EVENT_EOS)
|
|
|
|
gst_pad_push_event (srcpad, gst_event_ref (*event));
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2011-03-29 08:39:42 +00:00
|
|
|
static GstFlowReturn
|
2015-03-18 08:36:35 +00:00
|
|
|
gst_funnel_sink_chain_object (GstPad * pad, GstFunnel * funnel,
|
|
|
|
gboolean is_list, GstMiniObject * obj)
|
2011-03-29 08:39:42 +00:00
|
|
|
{
|
|
|
|
GstFlowReturn res;
|
|
|
|
|
2015-03-10 04:07:18 +00:00
|
|
|
GST_DEBUG_OBJECT (pad, "received %" GST_PTR_FORMAT, obj);
|
2011-03-29 08:39:42 +00:00
|
|
|
|
2013-07-02 00:35:21 +00:00
|
|
|
GST_PAD_STREAM_LOCK (funnel->srcpad);
|
2012-05-26 03:52:33 +00:00
|
|
|
|
2015-05-14 09:48:45 +00:00
|
|
|
if ((funnel->last_sinkpad == NULL) || (funnel->forward_sticky_events
|
|
|
|
&& (funnel->last_sinkpad != pad))) {
|
2013-07-02 00:35:21 +00:00
|
|
|
gst_object_replace ((GstObject **) & funnel->last_sinkpad,
|
|
|
|
GST_OBJECT (pad));
|
2012-05-26 03:52:33 +00:00
|
|
|
|
2015-05-14 09:48:45 +00:00
|
|
|
GST_DEBUG_OBJECT (pad, "Forwarding sticky events");
|
2013-07-02 00:35:21 +00:00
|
|
|
gst_pad_sticky_events_foreach (pad, forward_events, funnel->srcpad);
|
2011-03-29 08:39:42 +00:00
|
|
|
}
|
|
|
|
|
2015-03-18 08:36:35 +00:00
|
|
|
if (is_list)
|
|
|
|
res = gst_pad_push_list (funnel->srcpad, GST_BUFFER_LIST_CAST (obj));
|
|
|
|
else
|
|
|
|
res = gst_pad_push (funnel->srcpad, GST_BUFFER_CAST (obj));
|
2011-03-29 08:39:42 +00:00
|
|
|
|
2013-07-02 00:35:21 +00:00
|
|
|
GST_PAD_STREAM_UNLOCK (funnel->srcpad);
|
2011-03-29 08:39:42 +00:00
|
|
|
|
2015-05-27 11:54:25 +00:00
|
|
|
GST_LOG_OBJECT (pad, "handled buffer%s %s", (is_list ? "list" : ""),
|
2015-03-18 08:36:35 +00:00
|
|
|
gst_flow_get_name (res));
|
2011-03-29 08:39:42 +00:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2015-03-18 08:36:35 +00:00
|
|
|
static GstFlowReturn
|
|
|
|
gst_funnel_sink_chain_list (GstPad * pad, GstObject * parent,
|
|
|
|
GstBufferList * list)
|
|
|
|
{
|
|
|
|
GstFunnel *funnel = GST_FUNNEL (parent);
|
|
|
|
|
|
|
|
return gst_funnel_sink_chain_object (pad, funnel, TRUE,
|
|
|
|
GST_MINI_OBJECT_CAST (list));
|
|
|
|
}
|
|
|
|
|
|
|
|
static GstFlowReturn
|
|
|
|
gst_funnel_sink_chain (GstPad * pad, GstObject * parent, GstBuffer * buffer)
|
|
|
|
{
|
|
|
|
GstFunnel *funnel = GST_FUNNEL (parent);
|
|
|
|
|
|
|
|
return gst_funnel_sink_chain_object (pad, funnel, FALSE,
|
|
|
|
GST_MINI_OBJECT_CAST (buffer));
|
|
|
|
}
|
|
|
|
|
2011-03-29 08:39:42 +00:00
|
|
|
static gboolean
|
2011-11-17 11:40:45 +00:00
|
|
|
gst_funnel_sink_event (GstPad * pad, GstObject * parent, GstEvent * event)
|
2011-03-29 08:39:42 +00:00
|
|
|
{
|
2011-11-17 11:40:45 +00:00
|
|
|
GstFunnel *funnel = GST_FUNNEL (parent);
|
2014-07-09 13:48:10 +00:00
|
|
|
GstFunnelPad *fpad = GST_FUNNEL_PAD_CAST (pad);
|
2011-03-29 08:39:42 +00:00
|
|
|
gboolean forward = TRUE;
|
|
|
|
gboolean res = TRUE;
|
2013-07-02 00:35:21 +00:00
|
|
|
gboolean unlock = FALSE;
|
2011-03-29 08:39:42 +00:00
|
|
|
|
2015-05-27 11:54:25 +00:00
|
|
|
GST_DEBUG_OBJECT (pad, "received event %" GST_PTR_FORMAT, event);
|
|
|
|
|
2013-07-02 00:35:21 +00:00
|
|
|
if (GST_EVENT_IS_STICKY (event)) {
|
|
|
|
unlock = TRUE;
|
|
|
|
GST_PAD_STREAM_LOCK (funnel->srcpad);
|
2011-03-29 08:39:42 +00:00
|
|
|
|
2014-06-16 11:47:55 +00:00
|
|
|
if (GST_EVENT_TYPE (event) == GST_EVENT_EOS) {
|
2014-07-09 13:48:10 +00:00
|
|
|
GST_OBJECT_LOCK (funnel);
|
|
|
|
fpad->got_eos = TRUE;
|
2014-06-16 11:47:55 +00:00
|
|
|
if (!gst_funnel_all_sinkpads_eos_unlocked (funnel, pad)) {
|
|
|
|
forward = FALSE;
|
|
|
|
} else {
|
|
|
|
forward = TRUE;
|
|
|
|
}
|
2014-07-09 13:48:10 +00:00
|
|
|
GST_OBJECT_UNLOCK (funnel);
|
2014-06-16 11:47:55 +00:00
|
|
|
} else if (pad != funnel->last_sinkpad) {
|
2014-04-11 17:52:02 +00:00
|
|
|
forward = FALSE;
|
|
|
|
}
|
2014-07-09 13:48:10 +00:00
|
|
|
} else if (GST_EVENT_TYPE (event) == GST_EVENT_FLUSH_STOP) {
|
|
|
|
unlock = TRUE;
|
|
|
|
GST_PAD_STREAM_LOCK (funnel->srcpad);
|
|
|
|
GST_OBJECT_LOCK (funnel);
|
|
|
|
fpad->got_eos = FALSE;
|
|
|
|
GST_OBJECT_UNLOCK (funnel);
|
2014-12-05 05:16:52 +00:00
|
|
|
} else if (GST_EVENT_TYPE (event) == GST_EVENT_GAP) {
|
|
|
|
/* If no data is coming and we receive GAP event, need to forward sticky events. */
|
|
|
|
unlock = TRUE;
|
|
|
|
GST_PAD_STREAM_LOCK (funnel->srcpad);
|
|
|
|
GST_OBJECT_LOCK (funnel);
|
|
|
|
gst_object_replace ((GstObject **) & funnel->last_sinkpad,
|
|
|
|
GST_OBJECT (pad));
|
|
|
|
GST_OBJECT_UNLOCK (funnel);
|
|
|
|
gst_pad_sticky_events_foreach (pad, forward_events, funnel->srcpad);
|
2011-03-29 08:39:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (forward)
|
|
|
|
res = gst_pad_push_event (funnel->srcpad, event);
|
2011-01-06 17:11:31 +00:00
|
|
|
else
|
|
|
|
gst_event_unref (event);
|
2011-03-29 08:39:42 +00:00
|
|
|
|
2013-07-02 00:21:10 +00:00
|
|
|
if (unlock)
|
|
|
|
GST_PAD_STREAM_UNLOCK (funnel->srcpad);
|
2011-11-15 10:20:48 +00:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
2014-07-09 13:48:10 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
reset_pad (const GValue * data, gpointer user_data)
|
|
|
|
{
|
|
|
|
GstPad *pad = g_value_get_object (data);
|
|
|
|
GstFunnelPad *fpad = GST_FUNNEL_PAD_CAST (pad);
|
2015-09-21 11:58:51 +00:00
|
|
|
GstFunnel *funnel = user_data;
|
2014-07-09 13:48:10 +00:00
|
|
|
|
2015-09-21 11:58:51 +00:00
|
|
|
GST_OBJECT_LOCK (funnel);
|
2014-07-09 13:48:10 +00:00
|
|
|
fpad->got_eos = FALSE;
|
2015-09-21 11:58:51 +00:00
|
|
|
GST_OBJECT_UNLOCK (funnel);
|
2014-07-09 13:48:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static GstStateChangeReturn
|
|
|
|
gst_funnel_change_state (GstElement * element, GstStateChange transition)
|
|
|
|
{
|
|
|
|
GstStateChangeReturn ret;
|
|
|
|
|
|
|
|
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition);
|
|
|
|
if (ret == GST_STATE_CHANGE_FAILURE)
|
|
|
|
return ret;
|
|
|
|
|
|
|
|
switch (transition) {
|
|
|
|
case GST_STATE_CHANGE_PAUSED_TO_READY:
|
|
|
|
{
|
|
|
|
GstIterator *iter = gst_element_iterate_sink_pads (element);
|
|
|
|
GstIteratorResult res;
|
|
|
|
|
|
|
|
do {
|
2015-09-21 11:58:51 +00:00
|
|
|
res = gst_iterator_foreach (iter, reset_pad, element);
|
|
|
|
if (res == GST_ITERATOR_RESYNC)
|
|
|
|
gst_iterator_resync (iter);
|
2014-07-09 13:48:10 +00:00
|
|
|
} while (res == GST_ITERATOR_RESYNC);
|
|
|
|
gst_iterator_free (iter);
|
|
|
|
|
|
|
|
if (res == GST_ITERATOR_ERROR)
|
|
|
|
return GST_STATE_CHANGE_FAILURE;
|
|
|
|
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|