From e8bd8cab410192ddcd7ec5e79f512fd307bdb44e Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 28 Jan 2009 11:48:01 +0100 Subject: [PATCH] Add method to serialize RTSP options Add gst_rtsp_options_as_text() method to serialize a set of RTSP options to a string. API: GstRTSP::gst_rtsp_options_as_text() --- gst-libs/gst/rtsp/gstrtspdefs.c | 47 +++++++++++++++++++++++++++++++++ gst-libs/gst/rtsp/gstrtspdefs.h | 2 ++ 2 files changed, 49 insertions(+) diff --git a/gst-libs/gst/rtsp/gstrtspdefs.c b/gst-libs/gst/rtsp/gstrtspdefs.c index 3523814f0f..adefb4fbf9 100644 --- a/gst-libs/gst/rtsp/gstrtspdefs.c +++ b/gst-libs/gst/rtsp/gstrtspdefs.c @@ -395,3 +395,50 @@ gst_rtsp_find_method (const gchar * method) } return GST_RTSP_INVALID; } + +/** + * gst_rtsp_options_as_text: + * @options: one or more #GstRTSPMethod + * + * Convert @moptions to a string. + * + * Returns: a new string of @opions. g_free () after usage. + * + * Since: 0.10.23 + */ +gchar * +gst_rtsp_options_as_text (GstRTSPMethod options) +{ + GString *str; + + str = g_string_new (""); + + if (options & GST_RTSP_OPTIONS) + g_string_append (str, "OPTIONS, "); + if (options & GST_RTSP_DESCRIBE) + g_string_append (str, "DESCRIBE, "); + if (options & GST_RTSP_ANNOUNCE) + g_string_append (str, "ANNOUNCE, "); + if (options & GST_RTSP_GET_PARAMETER) + g_string_append (str, "GET_PARAMETER, "); + if (options & GST_RTSP_PAUSE) + g_string_append (str, "PAUSE, "); + if (options & GST_RTSP_PLAY) + g_string_append (str, "PLAY, "); + if (options & GST_RTSP_RECORD) + g_string_append (str, "RECORD, "); + if (options & GST_RTSP_REDIRECT) + g_string_append (str, "REDIRECT, "); + if (options & GST_RTSP_SETUP) + g_string_append (str, "SETUP, "); + if (options & GST_RTSP_SET_PARAMETER) + g_string_append (str, "SET_PARAMETER, "); + if (options & GST_RTSP_TEARDOWN) + g_string_append (str, "TEARDOWN, "); + + /* remove trailing ", " if there is one */ + if (str->len > 2) + str = g_string_truncate (str, str->len - 2); + + return g_string_free (str, FALSE); +} diff --git a/gst-libs/gst/rtsp/gstrtspdefs.h b/gst-libs/gst/rtsp/gstrtspdefs.h index d2691275ff..8307212547 100644 --- a/gst-libs/gst/rtsp/gstrtspdefs.h +++ b/gst-libs/gst/rtsp/gstrtspdefs.h @@ -338,6 +338,8 @@ const gchar* gst_rtsp_version_as_text (GstRTSPVersion version); const gchar* gst_rtsp_header_as_text (GstRTSPHeaderField field); const gchar* gst_rtsp_status_as_text (GstRTSPStatusCode code); +gchar* gst_rtsp_options_as_text (GstRTSPMethod options); + GstRTSPHeaderField gst_rtsp_find_header_field (const gchar *header); GstRTSPMethod gst_rtsp_find_method (const gchar *method);