session: improve RTP-Info
authorWim Taymans <wtaymans@redhat.com>
Fri, 7 Feb 2014 15:39:49 +0000 (16:39 +0100)
committerWim Taymans <wtaymans@redhat.com>
Fri, 7 Feb 2014 15:39:49 +0000 (16:39 +0100)
Ignore streams that can't generate RTP-Info instead of failing.
Don't return the empty string when all streams are unconfigured but
return NULL so that we don't generate and empty RTP-Info header.
Improve docs a little.

gst/rtsp-server/rtsp-session-media.c
gst/rtsp-server/rtsp-stream-transport.c

index 9cee477..eea6c75 100644 (file)
@@ -239,8 +239,8 @@ gst_rtsp_session_media_get_base_time (GstRTSPSessionMedia * media)
  * Retrieve the RTP-Info header string for all streams in @media
  * with configured transports.
  *
- * Returns: (transfer full): The RTP-Info as a string, g_free()
- *   after usage.
+ * Returns: (transfer full): The RTP-Info as a string or %NULL when
+ *   no RTP-Info could be generated, g_free() after usage.
  */
 gchar *
 gst_rtsp_session_media_get_rtpinfo (GstRTSPSessionMedia * media)
@@ -306,8 +306,10 @@ gst_rtsp_session_media_get_rtpinfo (GstRTSPSessionMedia * media)
 
     stream_rtpinfo =
         gst_rtsp_stream_transport_get_rtpinfo (transport, earliest);
-    if (stream_rtpinfo == NULL)
-      goto stream_rtpinfo_missing;
+    if (stream_rtpinfo == NULL) {
+      GST_DEBUG_OBJECT (media, "ignoring unknown RTPInfo %d", i);
+      continue;
+    }
 
     if (rtpinfo == NULL)
       rtpinfo = g_string_new ("");
@@ -317,14 +319,12 @@ gst_rtsp_session_media_get_rtpinfo (GstRTSPSessionMedia * media)
     g_string_append (rtpinfo, stream_rtpinfo);
     g_free (stream_rtpinfo);
   }
+  g_mutex_unlock (&priv->lock);
 
   if (rtpinfo == NULL) {
-    GST_INFO_OBJECT (media, "no transports configured, RTP info is empty");
-    rtpinfo = g_string_new ("");
+    GST_WARNING_OBJECT (media, "RTP info is empty");
+    return NULL;
   }
-
-  g_mutex_unlock (&priv->lock);
-
   return g_string_free (rtpinfo, FALSE);
 
   /* ERRORS */
@@ -334,14 +334,6 @@ not_prepared:
     GST_ERROR_OBJECT (media, "media was not prepared");
     return NULL;
   }
-stream_rtpinfo_missing:
-  {
-    g_mutex_unlock (&priv->lock);
-    if (rtpinfo)
-      g_string_free (rtpinfo, TRUE);
-    GST_ERROR_OBJECT (media, "could not get stream %d rtpinfo", i);
-    return NULL;
-  }
 }
 
 /**
index ea0a04f..4020ee4 100644 (file)
@@ -315,10 +315,10 @@ gst_rtsp_stream_transport_get_url (GstRTSPStreamTransport * trans)
  * @trans: a #GstRTSPStreamTransport
  * @start_time: a star time
  *
- * Get the RTPInfo string for @trans and @start_time.
+ * Get the RTP-Info string for @trans and @start_time.
  *
- * Returns: the RTPInfo string for @trans and @start_time. g_free() after
- * usage.
+ * Returns: the RTPInfo string for @trans and @start_time or %NULL when
+ * the RTP-Info could not be determined. g_free() after usage.
  */
 gchar *
 gst_rtsp_stream_transport_get_rtpinfo (GstRTSPStreamTransport * trans,