stream: release some locks in error cases
[platform/upstream/gstreamer.git] / gst / rtsp-server / rtsp-stream.c
index 96485df..fb20090 100644 (file)
@@ -173,12 +173,10 @@ gst_rtsp_stream_class_init (GstRTSPStreamClass * klass)
           "The control string for this stream", DEFAULT_CONTROL,
           G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
 
-#ifdef GST_TYPE_RTSP_PROFILE
   g_object_class_install_property (gobject_class, PROP_PROFILES,
       g_param_spec_flags ("profiles", "Profiles",
           "Allowed transfer profiles", GST_TYPE_RTSP_PROFILE,
           DEFAULT_PROFILES, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
-#endif
 
   g_object_class_install_property (gobject_class, PROP_PROTOCOLS,
       g_param_spec_flags ("protocols", "Protocols",
@@ -599,16 +597,19 @@ gst_rtsp_stream_is_transport_supported (GstRTSPStream * stream,
 unsupported_transmode:
   {
     GST_DEBUG ("unsupported transport mode %d", transport->trans);
+    g_mutex_unlock (&priv->lock);
     return FALSE;
   }
 unsupported_profile:
   {
     GST_DEBUG ("unsupported profile %d", transport->profile);
+    g_mutex_unlock (&priv->lock);
     return FALSE;
   }
 unsupported_ltrans:
   {
     GST_DEBUG ("unsupported lower transport %d", transport->lower_transport);
+    g_mutex_unlock (&priv->lock);
     return FALSE;
   }
 }
@@ -1856,6 +1857,7 @@ gst_rtsp_stream_leave_bin (GstRTSPStream * stream, GstBin * bin,
 
 was_not_joined:
   {
+    g_mutex_unlock (&priv->lock);
     return TRUE;
   }
 }
@@ -1915,7 +1917,11 @@ gst_rtsp_stream_get_rtpinfo (GstRTSPStream * stream,
         !g_object_class_find_property (payobjclass, "timestamp"))
       goto no_stats;
 
-    g_object_get (priv->payloader, "seqnum", seq, "timestamp", rtptime, NULL);
+    if (seq)
+      g_object_get (priv->payloader, "seqnum", seq, NULL);
+
+    if (rtptime)
+      g_object_get (priv->payloader, "timestamp", rtptime, NULL);
 
     if (running_time)
       *running_time = GST_CLOCK_TIME_NONE;
@@ -2069,14 +2075,14 @@ update_transport (GstRTSPStream * stream, GstRTSPStreamTransport * trans,
       }
 
       if (add) {
-        GST_INFO ("adding %s:%d-%d", dest, min, max);
-        g_signal_emit_by_name (priv->udpsink[0], "add", dest, min, NULL);
-        g_signal_emit_by_name (priv->udpsink[1], "add", dest, max, NULL);
         if (ttl > 0) {
           GST_INFO ("setting ttl-mc %d", ttl);
           g_object_set (G_OBJECT (priv->udpsink[0]), "ttl-mc", ttl, NULL);
           g_object_set (G_OBJECT (priv->udpsink[1]), "ttl-mc", ttl, NULL);
         }
+        GST_INFO ("adding %s:%d-%d", dest, min, max);
+        g_signal_emit_by_name (priv->udpsink[0], "add", dest, min, NULL);
+        g_signal_emit_by_name (priv->udpsink[1], "add", dest, max, NULL);
         priv->transports = g_list_prepend (priv->transports, trans);
       } else {
         GST_INFO ("removing %s:%d-%d", dest, min, max);
@@ -2184,15 +2190,15 @@ gst_rtsp_stream_remove_transport (GstRTSPStream * stream,
  *
  * @stream must be joined to a bin.
  *
- * Returns: the RTP socket or %NULL if no socket could be allocated for @family.
- *     Unref after usage
+ * Returns: (transfer full): the RTP socket or %NULL if no socket could be
+ *     allocated for @family. Unref after usage
  */
 GSocket *
 gst_rtsp_stream_get_rtp_socket (GstRTSPStream * stream, GSocketFamily family)
 {
   GstRTSPStreamPrivate *priv = GST_RTSP_STREAM_GET_PRIVATE (stream);
   GSocket *socket;
-  gchar *name;
+  const gchar *name;
 
   g_return_val_if_fail (GST_IS_RTSP_STREAM (stream), NULL);
   g_return_val_if_fail (family == G_SOCKET_FAMILY_IPV4 ||
@@ -2218,15 +2224,15 @@ gst_rtsp_stream_get_rtp_socket (GstRTSPStream * stream, GSocketFamily family)
  *
  * @stream must be joined to a bin.
  *
- * Returns: the RTCP socket or %NULL if no socket could be allocated for
- *     @family. Unref after usage
+ * Returns: (transfer full): the RTCP socket or %NULL if no socket could be
+ *     allocated for @family. Unref after usage
  */
 GSocket *
 gst_rtsp_stream_get_rtcp_socket (GstRTSPStream * stream, GSocketFamily family)
 {
   GstRTSPStreamPrivate *priv = GST_RTSP_STREAM_GET_PRIVATE (stream);
   GSocket *socket;
-  gchar *name;
+  const gchar *name;
 
   g_return_val_if_fail (GST_IS_RTSP_STREAM (stream), NULL);
   g_return_val_if_fail (family == G_SOCKET_FAMILY_IPV4 ||