diff options
author | Wim Taymans <wim.taymans@collabora.co.uk> | 2012-11-27 11:02:19 +0100 |
---|---|---|
committer | Wim Taymans <wim.taymans@collabora.co.uk> | 2012-11-27 11:15:34 +0100 |
commit | b511f938d414749f0ebd577b3eaa965e5ca1f3fd (patch) | |
tree | 86cf2462a9116e20d543fc4e00da30b7363d00b5 | |
parent | 9e8e3dfef4f0909be301d17e04fbb0a3d5a80ed8 (diff) |
rtsp: add method to parse options list
-rw-r--r-- | docs/libs/gst-plugins-base-libs-sections.txt | 1 | ||||
-rw-r--r-- | gst-libs/gst/rtsp/gstrtspdefs.c | 40 | ||||
-rw-r--r-- | gst-libs/gst/rtsp/gstrtspdefs.h | 1 |
3 files changed, 42 insertions, 0 deletions
diff --git a/docs/libs/gst-plugins-base-libs-sections.txt b/docs/libs/gst-plugins-base-libs-sections.txt index 89e7cd936..c2d46328e 100644 --- a/docs/libs/gst-plugins-base-libs-sections.txt +++ b/docs/libs/gst-plugins-base-libs-sections.txt @@ -1275,6 +1275,7 @@ gst_rtsp_header_as_text gst_rtsp_header_allow_multiple gst_rtsp_status_as_text gst_rtsp_options_as_text +gst_rtsp_options_from_text gst_rtsp_find_header_field gst_rtsp_find_method <SUBSECTION Standard> diff --git a/gst-libs/gst/rtsp/gstrtspdefs.c b/gst-libs/gst/rtsp/gstrtspdefs.c index aaf15bfab..2fdc9c95d 100644 --- a/gst-libs/gst/rtsp/gstrtspdefs.c +++ b/gst-libs/gst/rtsp/gstrtspdefs.c @@ -466,6 +466,46 @@ 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.1.1 + */ +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 * diff --git a/gst-libs/gst/rtsp/gstrtspdefs.h b/gst-libs/gst/rtsp/gstrtspdefs.h index 5246fd213..6a10ec307 100644 --- a/gst-libs/gst/rtsp/gstrtspdefs.h +++ b/gst-libs/gst/rtsp/gstrtspdefs.h @@ -399,6 +399,7 @@ 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); +GstRTSPMethod gst_rtsp_options_from_text (const gchar *options); GstRTSPHeaderField gst_rtsp_find_header_field (const gchar *header); GstRTSPMethod gst_rtsp_find_method (const gchar *method); |