rtspdefs: add RFC 4567 headers and status code
[platform/upstream/gstreamer.git] / gst-libs / gst / rtsp / gstrtspdefs.c
index e39059c..667538f 100644 (file)
@@ -13,8 +13,8 @@
  *
  * You should have received a copy of the GNU Library General Public
  * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
  */
 /*
  * Unless otherwise indicated, Source Code is licensed under MIT license.
@@ -174,6 +174,9 @@ static struct rtsp_header rtsp_headers[] = {
   /* Since 0.10.36 */
   {"RTCP-Interval", FALSE},
 
+  /* Since 1.4 */
+  {"KeyMgmt", FALSE},
+
   {NULL, FALSE}
 };
 
@@ -229,6 +232,7 @@ rtsp_init_status (void)
       "Only aggregate operation allowed");
   DEF_STATUS (GST_RTSP_STS_UNSUPPORTED_TRANSPORT, "Unsupported transport");
   DEF_STATUS (GST_RTSP_STS_DESTINATION_UNREACHABLE, "Destination unreachable");
+  DEF_STATUS (GST_RTSP_STS_KEY_MANAGEMENT_FAILURE, "Key management failure");
   DEF_STATUS (GST_RTSP_STS_INTERNAL_SERVER_ERROR, "Internal Server Error");
   DEF_STATUS (GST_RTSP_STS_NOT_IMPLEMENTED, "Not Implemented");
   DEF_STATUS (GST_RTSP_STS_BAD_GATEWAY, "Bad Gateway");
@@ -427,8 +431,6 @@ gst_rtsp_find_method (const gchar * method)
  * Convert @options to a string.
  *
  * Returns: a new string of @options. g_free() after usage.
- *
- * Since: 0.10.23
  */
 gchar *
 gst_rtsp_options_as_text (GstRTSPMethod options)
@@ -468,14 +470,52 @@ gst_rtsp_options_as_text (GstRTSPMethod options)
 }
 
 /**
+ * gst_rtsp_options_from_text:
+ * @options: a comma separated list of options
+ *
+ * Convert the comma separated list @options to a #GstRTSPMethod bitwise or
+ * of methods. This functions is the reverse of gst_rtsp_options_as_text().
+ *
+ * Returns: a #GstRTSPMethod
+ *
+ * Since: 1.2
+ */
+GstRTSPMethod
+gst_rtsp_options_from_text (const gchar * options)
+{
+  GstRTSPMethod methods;
+  gchar **ostr;
+  gint i;
+
+  /* The string is like:
+   * OPTIONS, DESCRIBE, ANNOUNCE, PLAY, SETUP, ...
+   */
+  ostr = g_strsplit (options, ",", 0);
+
+  methods = 0;
+  for (i = 0; ostr[i]; i++) {
+    gchar *stripped;
+    GstRTSPMethod method;
+
+    stripped = g_strstrip (ostr[i]);
+    method = gst_rtsp_find_method (stripped);
+
+    /* keep bitfield of supported methods */
+    if (method != GST_RTSP_INVALID)
+      methods |= method;
+  }
+  g_strfreev (ostr);
+
+  return methods;
+}
+
+/**
  * gst_rtsp_header_allow_multiple:
  * @field: a #GstRTSPHeaderField
  *
  * Check whether @field may appear multiple times in a message.
  *
  * Returns: %TRUE if multiple headers are allowed.
- *
- * Since: 0.10.25
  */
 gboolean
 gst_rtsp_header_allow_multiple (GstRTSPHeaderField field)