From f7070b6bc6cbade5b60a2c6ad3441de4010dad43 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Tue, 22 Dec 2009 20:15:28 +0100 Subject: [PATCH] rtcpbuffer: add helper functions for SDES types Add functions to convert SDES names to their types and back. Will be used later to set SDES items using a GstStructure. See #595265 --- docs/libs/gst-plugins-base-libs-sections.txt | 3 + gst-libs/gst/rtp/gstrtcpbuffer.c | 90 ++++++++++++++++++++++++++++ gst-libs/gst/rtp/gstrtcpbuffer.h | 3 + 3 files changed, 96 insertions(+) diff --git a/docs/libs/gst-plugins-base-libs-sections.txt b/docs/libs/gst-plugins-base-libs-sections.txt index 7574a4c..2e96a0a 100644 --- a/docs/libs/gst-plugins-base-libs-sections.txt +++ b/docs/libs/gst-plugins-base-libs-sections.txt @@ -1119,6 +1119,9 @@ gst_rtcp_packet_fb_set_media_ssrc gst_rtcp_ntp_to_unix gst_rtcp_unix_to_ntp +gst_rtcp_sdes_name_to_type +gst_rtcp_sdes_type_to_name + diff --git a/gst-libs/gst/rtp/gstrtcpbuffer.c b/gst-libs/gst/rtp/gstrtcpbuffer.c index e141eb0..9177b39 100644 --- a/gst-libs/gst/rtp/gstrtcpbuffer.c +++ b/gst-libs/gst/rtp/gstrtcpbuffer.c @@ -1853,3 +1853,93 @@ gst_rtcp_unix_to_ntp (guint64 unixtime) return ntptime; } + +/** + * gst_rtcp_sdes_type_to_name: + * @type: a #GstRTCPSDESType + * + * Converts @type to the string equivalent. The string is typically used as a + * key in a #GstStructure containing SDES items. + * + * Returns: the string equivalent of @type + * + * Since: 0.10.26 + */ +const gchar * +gst_rtcp_sdes_type_to_name (GstRTCPSDESType type) +{ + const gchar *result; + + switch (type) { + case GST_RTCP_SDES_CNAME: + result = "cname"; + break; + case GST_RTCP_SDES_NAME: + result = "name"; + break; + case GST_RTCP_SDES_EMAIL: + result = "email"; + break; + case GST_RTCP_SDES_PHONE: + result = "phone"; + break; + case GST_RTCP_SDES_LOC: + result = "location"; + break; + case GST_RTCP_SDES_TOOL: + result = "tool"; + break; + case GST_RTCP_SDES_NOTE: + result = "note"; + break; + case GST_RTCP_SDES_PRIV: + result = "priv"; + break; + default: + result = NULL; + break; + } + return result; +} + +/** + * gst_rtcp_sdes_name_to_type: + * @name: a SDES name + * + * Convert @name into a @GstRTCPSDESType. @name is typically a key in a + * #GstStructure containing SDES items. + * + * Returns: the #GstRTCPSDESType for @name or #GST_RTCP_SDES_PRIV when @name + * is a private sdes item. + * + * Since: 0.10.26 + */ +GstRTCPSDESType +gst_rtcp_sdes_name_to_type (const gchar * name) +{ + if (name == NULL || strlen (name) == 0) + return GST_RTCP_SDES_INVALID; + + if (strcmp ("cname", name) == 0) + return GST_RTCP_SDES_CNAME; + + if (strcmp ("name", name) == 0) + return GST_RTCP_SDES_NAME; + + if (strcmp ("email", name) == 0) + return GST_RTCP_SDES_EMAIL; + + if (strcmp ("phone", name) == 0) + return GST_RTCP_SDES_PHONE; + + if (strcmp ("location", name) == 0) + return GST_RTCP_SDES_LOC; + + if (strcmp ("tool", name) == 0) + return GST_RTCP_SDES_TOOL; + + if (strcmp ("note", name) == 0) + return GST_RTCP_SDES_NOTE; + + return GST_RTCP_SDES_PRIV; +} diff --git a/gst-libs/gst/rtp/gstrtcpbuffer.h b/gst-libs/gst/rtp/gstrtcpbuffer.h index 75ab4bc..b051571 100644 --- a/gst-libs/gst/rtp/gstrtcpbuffer.h +++ b/gst-libs/gst/rtp/gstrtcpbuffer.h @@ -274,6 +274,9 @@ void gst_rtcp_packet_fb_set_type (GstRTCPPacket *packet, Gs guint64 gst_rtcp_ntp_to_unix (guint64 ntptime); guint64 gst_rtcp_unix_to_ntp (guint64 unixtime); +const gchar * gst_rtcp_sdes_type_to_name (GstRTCPSDESType type); +GstRTCPSDESType gst_rtcp_sdes_name_to_type (const gchar *name); + G_END_DECLS #endif /* __GST_RTCPBUFFER_H__ */ -- 2.7.4