From 577938c9bead6772f34a7f2a7f51bf98e9231985 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Tue, 26 Jul 2016 11:59:39 -0400 Subject: [PATCH] uri-sources: Make sure to set decodebin 'caps' property Fixes a regression where we decode streams twice, this was introduced when we started creating NLE object at GESTrackElement construct time. Fixes https://bugzilla.gnome.org/show_bug.cgi?id=769193 --- ges/ges-audio-uri-source.c | 28 ++++++++++++++++++++++++++-- ges/ges-video-uri-source.c | 28 ++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 4 deletions(-) diff --git a/ges/ges-audio-uri-source.c b/ges/ges-audio-uri-source.c index e75ee2d70b..945ff032e3 100644 --- a/ges/ges-audio-uri-source.c +++ b/ges/ges-audio-uri-source.c @@ -32,7 +32,7 @@ struct _GESAudioUriSourcePrivate { - void *nothing; + GstElement *decodebin; /* Reference owned by parent class */ }; enum @@ -41,6 +41,26 @@ enum PROP_URI }; +static void +ges_audio_uri_source_track_set_cb (GESAudioUriSource * self, + GParamSpec * arg G_GNUC_UNUSED, gpointer nothing) +{ + GESTrack *track; + const GstCaps *caps = NULL; + + if (!self->priv->decodebin) + return; + + track = ges_track_element_get_track (GES_TRACK_ELEMENT (self)); + if (!track) + return; + + caps = ges_track_get_caps (track); + + GST_INFO_OBJECT (self, "Setting caps to: %" GST_PTR_FORMAT, caps); + g_object_set (self->priv->decodebin, "caps", caps, NULL); +} + /* GESSource VMethod */ static GstElement * ges_audio_uri_source_create_source (GESTrackElement * trksrc) @@ -54,7 +74,8 @@ ges_audio_uri_source_create_source (GESTrackElement * trksrc) track = ges_track_element_get_track (trksrc); - decodebin = gst_element_factory_make ("uridecodebin", NULL); + self->priv->decodebin = decodebin = + gst_element_factory_make ("uridecodebin", NULL); if (track) caps = ges_track_get_caps (track); @@ -177,6 +198,9 @@ ges_audio_uri_source_init (GESAudioUriSource * self) { self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GES_TYPE_AUDIO_URI_SOURCE, GESAudioUriSourcePrivate); + + g_signal_connect (self, "notify::track", + G_CALLBACK (ges_audio_uri_source_track_set_cb), NULL); } /** diff --git a/ges/ges-video-uri-source.c b/ges/ges-video-uri-source.c index c3dc4ac63c..d52352770d 100644 --- a/ges/ges-video-uri-source.c +++ b/ges/ges-video-uri-source.c @@ -34,7 +34,7 @@ struct _GESVideoUriSourcePrivate { - void *nothing; + GstElement *decodebin; /* Reference owned by parent class */ }; enum @@ -43,6 +43,26 @@ enum PROP_URI }; +static void +ges_video_uri_source_track_set_cb (GESVideoUriSource * self, + GParamSpec * arg G_GNUC_UNUSED, gpointer nothing) +{ + GESTrack *track; + const GstCaps *caps = NULL; + + if (!self->priv->decodebin) + return; + + track = ges_track_element_get_track (GES_TRACK_ELEMENT (self)); + if (!track) + return; + + caps = ges_track_get_caps (track); + + GST_INFO_OBJECT (self, "Setting caps to: %" GST_PTR_FORMAT, caps); + g_object_set (self->priv->decodebin, "caps", caps, NULL); +} + /* GESSource VMethod */ static GstElement * ges_video_uri_source_create_source (GESTrackElement * trksrc) @@ -58,7 +78,8 @@ ges_video_uri_source_create_source (GESTrackElement * trksrc) if (track) caps = ges_track_get_caps (track); - decodebin = gst_element_factory_make ("uridecodebin", NULL); + decodebin = self->priv->decodebin = gst_element_factory_make ("uridecodebin", + NULL); g_object_set (decodebin, "caps", caps, "expose-all-streams", FALSE, "uri", self->uri, NULL); @@ -178,6 +199,9 @@ ges_video_uri_source_init (GESVideoUriSource * self) { self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self, GES_TYPE_VIDEO_URI_SOURCE, GESVideoUriSourcePrivate); + + g_signal_connect (self, "notify::track", + G_CALLBACK (ges_video_uri_source_track_set_cb), NULL); } /**