diff options
author | Thiago Santos <ts.santos@partner.samsung.com> | 2013-11-01 15:51:28 -0300 |
---|---|---|
committer | Thiago Santos <ts.santos@partner.samsung.com> | 2013-11-07 21:28:03 -0300 |
commit | 558c1a83d89def7153a9a96901fc778124a7d354 (patch) | |
tree | a4d2ee788b093e2df7d5f82cd97afe8afac48cc2 | |
parent | c5cd21b64c88db402a4829f19583e45495f245b5 (diff) |
tee: use GstFlowCombinerflowcombiner-arrayiter
Use the newly added GstFlowCombiner to handle GstFlowReturn
combination
https://bugzilla.gnome.org/show_bug.cgi?id=709224
-rw-r--r-- | plugins/elements/gsttee.c | 30 | ||||
-rw-r--r-- | plugins/elements/gsttee.h | 2 |
2 files changed, 23 insertions, 9 deletions
diff --git a/plugins/elements/gsttee.c b/plugins/elements/gsttee.c index a6d4b9dac..0b142325f 100644 --- a/plugins/elements/gsttee.c +++ b/plugins/elements/gsttee.c @@ -135,6 +135,8 @@ struct _GstTeePad { GstPad parent; + GstFlowCombinerPadId flow_padid; + gboolean pushed; GstFlowReturn result; gboolean removed; @@ -208,6 +210,8 @@ restart: } } + gst_flow_combiner_free (GST_TEE_CAST (object)->flowcombiner); + G_OBJECT_CLASS (parent_class)->dispose (object); } @@ -289,6 +293,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_pad_set_event_function (tee->sinkpad, GST_DEBUG_FUNCPTR (gst_tee_sink_event)); @@ -371,6 +376,8 @@ gst_tee_request_new_pad (GstElement * element, GstPadTemplate * templ, 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_TEE_PAD_CAST (srcpad)->flow_padid = + gst_flow_combiner_add_pad (tee->flowcombiner, srcpad); return srcpad; @@ -417,6 +424,8 @@ 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_pad (tee->flowcombiner, + GST_TEE_PAD_CAST (pad)->flow_padid); gst_pad_set_active (pad, FALSE); GST_TEE_DYN_UNLOCK (tee); @@ -568,6 +577,8 @@ clear_pads (GstPad * pad, GstTee * tee) { GST_TEE_PAD_CAST (pad)->pushed = FALSE; GST_TEE_PAD_CAST (pad)->result = GST_FLOW_NOT_LINKED; + gst_flow_combiner_set_flow (tee->flowcombiner, + GST_TEE_PAD_CAST (pad)->flow_padid, GST_FLOW_NOT_LINKED); } static GstFlowReturn @@ -600,6 +611,8 @@ gst_tee_handle_data (GstTee * tee, gpointer data, gboolean is_list) } else { ret = gst_pad_push (pad, GST_BUFFER_CAST (data)); } + gst_flow_combiner_set_flow (tee->flowcombiner, + GST_TEE_PAD_CAST (pad)->flow_padid, ret); return ret; } @@ -652,15 +665,14 @@ restart: goto restart; } + cret = + gst_flow_combiner_update_flow (tee->flowcombiner, + GST_TEE_PAD_CAST (pad)->flow_padid, 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 +686,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; |