From 86b893e54cadde01e025e5876fa666f5d889f9ea Mon Sep 17 00:00:00 2001 From: Mathieu Duponchelle Date: Thu, 16 May 2013 03:27:20 +0200 Subject: [PATCH] ges-uri-source: don't use gnlurisource but a custom bin. + This bin is a uridecodebin when GES_TRACK_TYPE_VIDEO + This bin contains a uridecodebin and a volume when GES_TRACK_TYPE_AUDIO --- ges/ges-uri-source.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 48 insertions(+), 6 deletions(-) diff --git a/ges/ges-uri-source.c b/ges/ges-uri-source.c index e6accf9..dae238f 100644 --- a/ges/ges-uri-source.c +++ b/ges/ges-uri-source.c @@ -117,15 +117,56 @@ ges_track_filesource_dispose (GObject * object) G_OBJECT_CLASS (ges_track_filesource_parent_class)->dispose (object); } +static void +_pad_added_cb (GstElement * element, GstPad * srcpad, GstPad * sinkpad) +{ + gst_pad_link (srcpad, sinkpad); +} + static GstElement * -ges_track_filesource_create_gnl_object (GESTrackElement * track_element) +ges_uri_source_create_element (GESTrackElement * trksrc) { - GstElement *gnlobject; + GESUriSource *self; + GstElement *ret; + GESTrack *track; + GstElement *decodebin; + GstElement *topbin, *volume; + GstPad *volume_srcpad, *volume_sinkpad; + GstPad *ghost; + + self = (GESUriSource *) trksrc; + track = ges_track_element_get_track (trksrc); + + switch (track->type) { + case GES_TRACK_TYPE_AUDIO: + topbin = gst_bin_new ("audio-src-bin"); + + volume = gst_element_factory_make ("volume", NULL); + gst_bin_add (GST_BIN (topbin), volume); + volume_srcpad = gst_element_get_static_pad (volume, "src"); + ghost = gst_ghost_pad_new ("src", volume_srcpad); + gst_pad_set_active (ghost, TRUE); + gst_element_add_pad (topbin, ghost); + + decodebin = gst_element_factory_make ("uridecodebin", NULL); + volume_sinkpad = gst_element_get_static_pad (volume, "sink"); + g_signal_connect (decodebin, "pad-added", G_CALLBACK (_pad_added_cb), + volume_sinkpad); + gst_element_no_more_pads (decodebin); + gst_bin_add (GST_BIN (topbin), decodebin); + + ret = topbin; + break; + default: + ret = gst_element_factory_make ("uridecodebin", NULL); + decodebin = ret; + break; + } - gnlobject = gst_element_factory_make ("gnlurisource", NULL); - g_object_set (gnlobject, "uri", ((GESUriSource *) track_element)->uri, NULL); + g_object_set (decodebin, "caps", ges_track_get_caps (track), + "expose-all-streams", FALSE, "uri", self->uri, NULL); - return gnlobject; + return ret; } static void @@ -148,7 +189,8 @@ ges_track_filesource_class_init (GESUriSourceClass * klass) g_object_class_install_property (object_class, PROP_URI, g_param_spec_string ("uri", "URI", "uri of the resource", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY)); - track_class->create_gnl_object = ges_track_filesource_create_gnl_object; + + track_class->create_element = ges_uri_source_create_element; } static void -- 2.7.4