diff --git a/gst/encoding/gststreamsplitter.c b/gst/encoding/gststreamsplitter.c index 72237775ec..d634c2bae1 100644 --- a/gst/encoding/gststreamsplitter.c +++ b/gst/encoding/gststreamsplitter.c @@ -297,6 +297,53 @@ beach: return res; } +static gboolean +gst_stream_splitter_sink_acceptcaps (GstPad * pad, GstCaps * caps) +{ + GstStreamSplitter *stream_splitter = + (GstStreamSplitter *) GST_PAD_PARENT (pad); + guint32 cookie; + GList *tmp; + gboolean res = FALSE; + + /* check if one of the downstream elements accepts the caps */ + STREAMS_LOCK (stream_splitter); + +resync: + res = FALSE; + + if (G_UNLIKELY (stream_splitter->srcpads == NULL)) + goto beach; + + cookie = stream_splitter->cookie; + tmp = stream_splitter->srcpads; + + while (tmp) { + GstPad *srcpad = (GstPad *) tmp->data; + + /* Ensure srcpad doesn't get destroyed while we query peer */ + gst_object_ref (srcpad); + STREAMS_UNLOCK (stream_splitter); + + res = gst_pad_peer_query_accept_caps (srcpad, caps); + + STREAMS_LOCK (stream_splitter); + gst_object_unref (srcpad); + + if (G_UNLIKELY (cookie != stream_splitter->cookie)) + goto resync; + + if (res) + break; + + tmp = tmp->next; + } + +beach: + STREAMS_UNLOCK (stream_splitter); + return res; +} + static gboolean gst_stream_splitter_sink_query (GstPad * pad, GstObject * parent, GstQuery * query) @@ -315,6 +362,17 @@ gst_stream_splitter_sink_query (GstPad * pad, GstObject * parent, res = TRUE; break; } + case GST_QUERY_ACCEPT_CAPS: + { + GstCaps *caps; + gboolean result; + + gst_query_parse_accept_caps (query, &caps); + result = gst_stream_splitter_sink_acceptcaps (pad, caps); + gst_query_set_accept_caps_result (query, result); + res = TRUE; + break; + } default: res = gst_pad_query_default (pad, parent, query); break;