stream: add method to check supported transport
authorWim Taymans <wtaymans@redhat.com>
Tue, 7 Jan 2014 11:14:15 +0000 (12:14 +0100)
committerWim Taymans <wtaymans@redhat.com>
Tue, 7 Jan 2014 11:39:57 +0000 (12:39 +0100)
Add a method to check if a transport is supported

gst/rtsp-server/rtsp-stream.c
gst/rtsp-server/rtsp-stream.h

index 01ed7b7..a92b985 100644 (file)
@@ -546,6 +546,57 @@ gst_rtsp_stream_get_dscp_qos (GstRTSPStream * stream)
 }
 
 /**
+ * gst_rtsp_stream_is_transport_supported:
+ * @stream: a #GstRTSPStream
+ * @transport: a #GstRTSPTransport
+ *
+ * Check if @transport can be handled by stream
+ *
+ * Returns: %TRUE if @transport can be handled by @stream.
+ */
+gboolean
+gst_rtsp_stream_is_transport_supported (GstRTSPStream * stream,
+    GstRTSPTransport * transport)
+{
+  GstRTSPStreamPrivate *priv;
+
+  g_return_if_fail (GST_IS_RTSP_STREAM (stream));
+
+  priv = stream->priv;
+
+  g_mutex_lock (&priv->lock);
+  if (transport->trans != GST_RTSP_TRANS_RTP)
+    goto unsupported_transmode;
+
+  if (transport->profile != GST_RTSP_PROFILE_AVP)
+    goto unsupported_profile;
+
+  if (!(transport->lower_transport & priv->protocols))
+    goto unsupported_ltrans;
+
+  g_mutex_unlock (&priv->lock);
+
+  return TRUE;
+
+  /* ERRORS */
+unsupported_transmode:
+  {
+    GST_DEBUG ("unsupported transport mode %d", transport->trans);
+    return FALSE;
+  }
+unsupported_profile:
+  {
+    GST_DEBUG ("unsupported profile %d", transport->profile);
+    return FALSE;
+  }
+unsupported_ltrans:
+  {
+    GST_DEBUG ("unsupported lower transport %d", transport->lower_transport);
+    return FALSE;
+  }
+}
+
+/**
  * gst_rtsp_stream_set_protocols:
  * @stream: a #GstRTSPStream
  * @protocols: the new flags
index b665a66..60ea876 100644 (file)
@@ -82,6 +82,9 @@ guint             gst_rtsp_stream_get_mtu          (GstRTSPStream *stream);
 void              gst_rtsp_stream_set_dscp_qos     (GstRTSPStream *stream, gint dscp_qos);
 gint              gst_rtsp_stream_get_dscp_qos     (GstRTSPStream *stream);
 
+gboolean          gst_rtsp_stream_is_transport_supported  (GstRTSPStream *stream,
+                                                           GstRTSPTransport *transport);
+
 void              gst_rtsp_stream_set_protocols    (GstRTSPStream *stream, GstRTSPLowerTrans protocols);
 GstRTSPLowerTrans gst_rtsp_stream_get_protocols    (GstRTSPStream *stream);