From 5c58bcfd155b7aa6d101b32a77da35d4284cbcad Mon Sep 17 00:00:00 2001 From: Mart Raudsepp Date: Thu, 3 Nov 2011 14:10:31 +0200 Subject: [PATCH] decodebin2: Post all source pads in stream-topology messages as "element-srcpad" values This allows us to easily get ahold of all pads on a stream-topology message, including pre-decoder ones, while "pad" only gives us access to the raw pads (as used by discoverer). --- gst/playback/gstdecodebin2.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/gst/playback/gstdecodebin2.c b/gst/playback/gstdecodebin2.c index 22f6cc5..520416b 100644 --- a/gst/playback/gstdecodebin2.c +++ b/gst/playback/gstdecodebin2.c @@ -3352,7 +3352,8 @@ sort_end_pads (GstDecodePad * da, GstDecodePad * db) } static GstCaps * -_gst_element_get_linked_caps (GstElement * src, GstElement * sink) +_gst_element_get_linked_caps (GstElement * src, GstElement * sink, + GstPad ** srcpad) { GstIterator *it; GstElement *parent; @@ -3369,6 +3370,10 @@ _gst_element_get_linked_caps (GstElement * src, GstElement * sink) parent = gst_pad_get_parent_element (peer); if (parent == sink) { caps = gst_pad_get_negotiated_caps (pad); + if (srcpad) { + gst_object_ref (pad); + *srcpad = pad; + } done = TRUE; } @@ -3397,6 +3402,7 @@ static GQuark topology_structure_name = 0; static GQuark topology_caps = 0; static GQuark topology_next = 0; static GQuark topology_pad = 0; +static GQuark topology_element_srcpad = 0; /* FIXME: Invent gst_structure_take_structure() to prevent all the * structure copying for nothing @@ -3422,8 +3428,11 @@ gst_decode_chain_get_topology (GstDecodeChain * chain) gst_structure_id_set (u, topology_caps, GST_TYPE_CAPS, chain->endcaps, NULL); - if (chain->endpad) + if (chain->endpad) { gst_structure_id_set (u, topology_pad, GST_TYPE_PAD, chain->endpad, NULL); + gst_structure_id_set (u, topology_element_srcpad, GST_TYPE_PAD, + chain->endpad, NULL); + } gst_structure_id_set (s, topology_next, GST_TYPE_STRUCTURE, u, NULL); gst_structure_free (u); u = s; @@ -3453,13 +3462,15 @@ gst_decode_chain_get_topology (GstDecodeChain * chain) GstDecodeElement *delem, *delem_next; GstElement *elem, *elem_next; GstCaps *caps; + GstPad *srcpad; delem = l->data; elem = delem->element; delem_next = l->next->data; elem_next = delem_next->element; + srcpad = NULL; - caps = _gst_element_get_linked_caps (elem_next, elem); + caps = _gst_element_get_linked_caps (elem_next, elem, &srcpad); if (caps) { s = gst_structure_id_empty_new (topology_structure_name); @@ -3470,6 +3481,12 @@ gst_decode_chain_get_topology (GstDecodeChain * chain) gst_structure_free (u); u = s; } + + if (srcpad) { + gst_structure_id_set (u, topology_element_srcpad, GST_TYPE_PAD, srcpad, + NULL); + gst_object_unref (srcpad); + } } /* Caps that resulted in this chain */ @@ -3484,6 +3501,8 @@ gst_decode_chain_get_topology (GstDecodeChain * chain) } } gst_structure_id_set (u, topology_caps, GST_TYPE_CAPS, caps, NULL); + gst_structure_id_set (u, topology_element_srcpad, GST_TYPE_PAD, chain->pad, + NULL); gst_caps_unref (caps); return u; @@ -4059,6 +4078,7 @@ gst_decode_bin_plugin_init (GstPlugin * plugin) topology_caps = g_quark_from_static_string ("caps"); topology_next = g_quark_from_static_string ("next"); topology_pad = g_quark_from_static_string ("pad"); + topology_element_srcpad = g_quark_from_static_string ("element-srcpad"); return gst_element_register (plugin, "decodebin2", GST_RANK_NONE, GST_TYPE_DECODE_BIN); -- 2.7.4