diff options
author | Wim Taymans <wim.taymans@collabora.co.uk> | 2009-12-22 20:15:28 +0100 |
---|---|---|
committer | Wim Taymans <wim@metal.(none)> | 2009-12-22 20:15:28 +0100 |
commit | f7070b6bc6cbade5b60a2c6ad3441de4010dad43 (patch) | |
tree | 6ad82151d952966303e09c71b3778118a943b415 /gst-libs | |
parent | 681d23ccb7e2c78b0b582dd548dc0eecbac38813 (diff) |
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
Diffstat (limited to 'gst-libs')
-rw-r--r-- | gst-libs/gst/rtp/gstrtcpbuffer.c | 90 | ||||
-rw-r--r-- | gst-libs/gst/rtp/gstrtcpbuffer.h | 3 |
2 files changed, 93 insertions, 0 deletions
diff --git a/gst-libs/gst/rtp/gstrtcpbuffer.c b/gst-libs/gst/rtp/gstrtcpbuffer.c index e141eb0d6..9177b398a 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 75ab4bc72..b051571ff 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__ */ |