uri-sources: Make sure to set decodebin 'caps' property
authorThibault Saunier <tsaunier@gnome.org>
Tue, 26 Jul 2016 15:59:39 +0000 (11:59 -0400)
committerThibault Saunier <tsaunier@gnome.org>
Tue, 26 Jul 2016 16:07:37 +0000 (12:07 -0400)
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
ges/ges-video-uri-source.c

index e75ee2d..945ff03 100644 (file)
@@ -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);
 }
 
 /**
index c3dc4ac..d523527 100644 (file)
@@ -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);
 }
 
 /**