pipeline: Handle rendering with disabled tracks
authorThibault Saunier <tsaunier@gnome.org>
Wed, 10 Jun 2015 15:54:20 +0000 (17:54 +0200)
committerThibault Saunier <tsaunier@gnome.org>
Wed, 10 Jun 2015 16:00:58 +0000 (18:00 +0200)
Summary:
The user might want to render only some media type of the timeline,
for example he wants to only render the audio part of the timeline.

It was failing as we were not connecting the track but were still trying
to 'render' it.

Depends on D153

Reviewers: Mathieu_Du

Reviewed By: Mathieu_Du

Differential Revision: http://phabricator.freedesktop.org/D154

ges/ges-pipeline.c

index 3f081b6..9feefa0 100644 (file)
@@ -69,6 +69,7 @@ struct _GESPipelinePrivate
 
   GMutex dyn_mutex;
   GList *chains;
+  GList *not_rendered_tracks;
 
   GstEncodingProfile *profile;
 };
@@ -560,6 +561,14 @@ ges_pipeline_change_state (GstElement * element, GstStateChange transition)
       }
       _link_tracks (self);
       break;
+    case GST_STATE_CHANGE_PAUSED_TO_READY:
+    {
+      GList *tmp;
+
+      for (tmp = self->priv->not_rendered_tracks; tmp; tmp = tmp->next)
+        gst_element_set_locked_state (tmp->data, FALSE);
+    }
+      break;
     default:
       break;
   }
@@ -816,7 +825,13 @@ _link_track (GESPipeline * self, GESTrack * track)
         gst_caps_unref (caps);
 
         if (G_UNLIKELY (sinkpad == NULL)) {
-          GST_ERROR_OBJECT (self, "Couldn't get a pad from encodebin !");
+          GST_INFO_OBJECT (self, "Couldn't get a pad from encodebin !");
+          gst_element_set_locked_state (GST_ELEMENT (track), TRUE);
+
+          self->priv->not_rendered_tracks =
+              g_list_append (self->priv->not_rendered_tracks, track);
+
+
           goto error;
         }
       }
@@ -843,10 +858,12 @@ _link_track (GESPipeline * self, GESTrack * track)
 error:
   {
     if (chain->tee) {
+      gst_element_set_state (chain->tee, GST_STATE_NULL);
       gst_bin_remove (GST_BIN_CAST (self), chain->tee);
     }
     if (sinkpad)
       gst_object_unref (sinkpad);
+
     g_free (chain);
   }
 }