From 54afebf426e6a1aca1023176eb3d9ff75009d552 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 20 May 2009 13:47:52 +0200 Subject: multipartdemux: add flow aggregation --- gst/multipart/multipartdemux.c | 32 ++++++++++++++++++++++++++++++++ gst/multipart/multipartdemux.h | 2 ++ 2 files changed, 34 insertions(+) diff --git a/gst/multipart/multipartdemux.c b/gst/multipart/multipartdemux.c index a4f0f9c65..8669b974a 100644 --- a/gst/multipart/multipartdemux.c +++ b/gst/multipart/multipartdemux.c @@ -231,6 +231,36 @@ gst_multipart_demux_get_gstname (GstMultipartDemux * demux, gchar * mimetype) return gstname; } +static GstFlowReturn +gst_multipart_combine_flows (GstMultipartDemux * demux, GstMultipartPad * pad, + GstFlowReturn ret) +{ + GSList *walk; + + /* store the value */ + pad->last_ret = ret; + + /* any other error that is not-linked can be returned right + * away */ + if (ret != GST_FLOW_NOT_LINKED) + goto done; + + /* only return NOT_LINKED if all other pads returned NOT_LINKED */ + for (walk = demux->srcpads; walk; walk = g_slist_next (walk)) { + GstMultipartPad *opad = (GstMultipartPad *) walk->data; + + ret = opad->last_ret; + /* some other return value (must be SUCCESS but we can return + * other values as well) */ + if (ret != GST_FLOW_NOT_LINKED) + goto done; + } + /* if we get here, all other pads were unlinked and we return + * NOT_LINKED then */ +done: + return ret; +} + static GstMultipartPad * gst_multipart_find_pad_by_mime (GstMultipartDemux * demux, gchar * mime, gboolean * created) @@ -278,6 +308,7 @@ gst_multipart_find_pad_by_mime (GstMultipartDemux * demux, gchar * mime, mppad->pad = pad; mppad->mime = g_strdup (mime); + mppad->last_ret = GST_FLOW_OK; demux->srcpads = g_slist_prepend (demux->srcpads, mppad); demux->numpads++; @@ -535,6 +566,7 @@ gst_multipart_demux_chain (GstPad * pad, GstBuffer * buf) GST_DEBUG_OBJECT (multipart, "buffer has caps %" GST_PTR_FORMAT, GST_BUFFER_CAPS (outbuf)); res = gst_pad_push (srcpad->pad, outbuf); + res = gst_multipart_combine_flows (multipart, srcpad, res); if (res != GST_FLOW_OK) break; } diff --git a/gst/multipart/multipartdemux.h b/gst/multipart/multipartdemux.h index af51d5ba7..930f49ff5 100644 --- a/gst/multipart/multipartdemux.h +++ b/gst/multipart/multipartdemux.h @@ -50,6 +50,8 @@ typedef struct GstPad *pad; /* reference for this pad is held by element we belong to */ gchar *mime; + + GstFlowReturn last_ret; } GstMultipartPad; -- cgit v1.2.3