media: Only add fakesink once per pipeline
authorNicolas Dufresne <nicolas.dufresne@collabora.co.uk>
Sat, 8 Aug 2015 13:40:09 +0000 (09:40 -0400)
committerNicolas Dufresne <nicolas.dufresne@collabora.co.uk>
Sat, 8 Aug 2015 13:46:40 +0000 (09:46 -0400)
The intention is to prevent going PLAYING state before pads are created.
If there was mutilple dynamic payload, it would leak few fakesink and
actually prevent from ever reaching playing state.

https://bugzilla.gnome.org/show_bug.cgi?id=753385

gst/rtsp-server/rtsp-media.c

index 011dae3..e623f00 100644 (file)
@@ -2517,10 +2517,12 @@ start_prepare (GstRTSPMedia * media)
 
     g_object_set_data (G_OBJECT (elem), "gst-rtsp-dynpay-handlers", handlers);
 
-    /* we add a fakesink here in order to make the state change async. We remove
-     * the fakesink again in the no-more-pads callback. */
-    priv->fakesink = gst_element_factory_make ("fakesink", "fakesink");
-    gst_bin_add (GST_BIN (priv->pipeline), priv->fakesink);
+    if (!priv->fakesink) {
+      /* we add a fakesink here in order to make the state change async. We remove
+       * the fakesink again in the no-more-pads callback. */
+      priv->fakesink = gst_element_factory_make ("fakesink", "fakesink");
+      gst_bin_add (GST_BIN (priv->pipeline), priv->fakesink);
+    }
   }
 
   if (!start_preroll (media))