From: Sebastian Dröge Date: Thu, 22 Sep 2016 15:25:18 +0000 (-0400) Subject: nleurisource: Always provide a srcpad X-Git-Tag: 1.19.3~493^2~943 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7aa69d0ea0a71fcf388ac71bdf243d9c8e2da7e9;p=platform%2Fupstream%2Fgstreamer.git nleurisource: Always provide a srcpad By putting uridecodebin into a bin with a ghostpad. Without this, nlesource tries to get a srcpad too early (before uridecodebin added one) and everything fails miserably. This has to be fixed properly in nlesource at some point, by properly handling dynamically added pads. Currently they can only work if they are added in states <= READY, which is not the usual case. https://bugzilla.gnome.org/show_bug.cgi?id=771843 --- diff --git a/plugins/nle/nleurisource.c b/plugins/nle/nleurisource.c index 6adbc754..eed90a5 100644 --- a/plugins/nle/nleurisource.c +++ b/plugins/nle/nleurisource.c @@ -94,24 +94,40 @@ nle_urisource_class_init (NleURISourceClass * klass) } static void +pad_added_cb (GstElement * element, GstPad * srcpad, GstPad * ghostpad) +{ + gst_ghost_pad_set_target (GST_GHOST_PAD (ghostpad), srcpad); +} + +static void nle_urisource_init (NleURISource * urisource) { - GstElement *decodebin = NULL; + GstElement *bin, *decodebin = NULL; + GstPad *ghostpad; GST_OBJECT_FLAG_SET (urisource, NLE_OBJECT_SOURCE); /* We create a bin with source and decodebin within */ - decodebin = + urisource->decodebin = decodebin = gst_element_factory_make ("uridecodebin", "internal-uridecodebin"); g_object_set (decodebin, "expose-all-streams", FALSE, NULL); - gst_bin_add (GST_BIN (urisource), decodebin); + bin = gst_bin_new ("internal-bin"); + gst_bin_add (GST_BIN (bin), decodebin); + + ghostpad = gst_ghost_pad_new_no_target ("src", GST_PAD_SRC); + gst_element_add_pad (bin, ghostpad); + + gst_bin_add (GST_BIN (urisource), bin); + + g_signal_connect (decodebin, "pad-added", G_CALLBACK (pad_added_cb), + ghostpad); } static inline void nle_urisource_set_uri (NleURISource * fs, const gchar * uri) { - g_object_set (NLE_SOURCE (fs)->element, "uri", uri, NULL); + g_object_set (fs->decodebin, "uri", uri, NULL); } static void @@ -138,8 +154,7 @@ nle_urisource_get_property (GObject * object, guint prop_id, switch (prop_id) { case ARG_URI: - g_object_get_property ((GObject *) NLE_SOURCE (fs)->element, "uri", - value); + g_object_get_property ((GObject *) fs->decodebin, "uri", value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); @@ -151,7 +166,7 @@ nle_urisource_get_property (GObject * object, guint prop_id, static gboolean nle_urisource_prepare (NleObject * object) { - NleSource *fs = (NleSource *) object; + NleURISource *fs = (NleURISource *) object; GST_DEBUG ("prepare"); @@ -159,7 +174,7 @@ nle_urisource_prepare (NleObject * object) if (!gst_caps_is_any (object->caps)) { GST_DEBUG_OBJECT (object, "Setting uridecodebin caps to %" GST_PTR_FORMAT, object->caps); - g_object_set (fs->element, "caps", object->caps, NULL); + g_object_set (fs->decodebin, "caps", object->caps, NULL); } return NLE_OBJECT_CLASS (parent_class)->prepare (object); diff --git a/plugins/nle/nleurisource.h b/plugins/nle/nleurisource.h index a2750e5..14bbe4f 100644 --- a/plugins/nle/nleurisource.h +++ b/plugins/nle/nleurisource.h @@ -44,6 +44,7 @@ struct _NleURISource NleSource parent; gchar *uri; + GstElement *decodebin; }; struct _NleURISourceClass