diff options
-rw-r--r-- | plugins/elements/gsttee.c | 27 | ||||
-rw-r--r-- | plugins/elements/gsttee.h | 2 |
2 files changed, 20 insertions, 9 deletions
diff --git a/plugins/elements/gsttee.c b/plugins/elements/gsttee.c index a6d4b9dac..15423c096 100644 --- a/plugins/elements/gsttee.c +++ b/plugins/elements/gsttee.c @@ -208,6 +208,8 @@ restart: } } + gst_flow_combiner_free (GST_TEE_CAST (object)->flowcombiner); + G_OBJECT_CLASS (parent_class)->dispose (object); } @@ -282,6 +284,12 @@ gst_tee_class_init (GstTeeClass * klass) gstelement_class->release_pad = GST_DEBUG_FUNCPTR (gst_tee_release_pad); } +static GstFlowReturn +gst_tee_pad_get_result (gpointer data) +{ + return GST_TEE_PAD_CAST (data)->result; +} + static void gst_tee_init (GstTee * tee) { @@ -289,6 +297,7 @@ gst_tee_init (GstTee * tee) tee->sinkpad = gst_pad_new_from_static_template (&sinktemplate, "sink"); tee->sink_mode = GST_PAD_MODE_NONE; + tee->flowcombiner = gst_flow_combiner_new (gst_tee_pad_get_result); gst_pad_set_event_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_tee_sink_event)); @@ -370,7 +379,9 @@ gst_tee_request_new_pad (GstElement * element, GstPadTemplate * templ, /* Forward sticky events to the new srcpad */ gst_pad_sticky_events_foreach (tee->sinkpad, forward_sticky_events, srcpad); GST_OBJECT_FLAG_SET (srcpad, GST_PAD_FLAG_PROXY_CAPS); + gst_element_add_pad (GST_ELEMENT_CAST (tee), srcpad); + gst_flow_combiner_add_stream (tee->flowcombiner, srcpad); return srcpad; @@ -417,6 +428,7 @@ gst_tee_release_pad (GstElement * element, GstPad * pad) gst_object_ref (pad); gst_element_remove_pad (GST_ELEMENT_CAST (tee), pad); + gst_flow_combiner_remove_stream (tee->flowcombiner, pad); gst_pad_set_active (pad, FALSE); GST_TEE_DYN_UNLOCK (tee); @@ -652,15 +664,12 @@ restart: goto restart; } + cret = gst_flow_combiner_update_flow (tee->flowcombiner, pad, ret); + /* stop pushing more buffers when we have a fatal error */ - if (G_UNLIKELY (ret != GST_FLOW_OK && ret != GST_FLOW_NOT_LINKED)) + if (G_UNLIKELY (cret != GST_FLOW_OK && cret != GST_FLOW_NOT_LINKED)) goto error; - /* keep all other return values, overwriting the previous one. */ - if (G_LIKELY (ret != GST_FLOW_NOT_LINKED)) { - GST_LOG_OBJECT (tee, "Replacing ret val %d with %d", cret, ret); - cret = ret; - } pads = g_list_next (pads); } GST_OBJECT_UNLOCK (tee); @@ -674,15 +683,15 @@ restart: no_pads: { GST_DEBUG_OBJECT (tee, "there are no pads, return not-linked"); - ret = GST_FLOW_NOT_LINKED; + cret = GST_FLOW_NOT_LINKED; goto error; } error: { - GST_DEBUG_OBJECT (tee, "received error %s", gst_flow_get_name (ret)); + GST_DEBUG_OBJECT (tee, "received error %s", gst_flow_get_name (cret)); GST_OBJECT_UNLOCK (tee); gst_mini_object_unref (GST_MINI_OBJECT_CAST (data)); - return ret; + return cret; } } diff --git a/plugins/elements/gsttee.h b/plugins/elements/gsttee.h index c092b8fac..23d9edc37 100644 --- a/plugins/elements/gsttee.h +++ b/plugins/elements/gsttee.h @@ -73,6 +73,8 @@ struct _GstTee { GstPad *allocpad; guint pad_counter; + GstFlowCombiner *flowcombiner; + gboolean has_chain; gboolean silent; gchar *last_message; |