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
This commit is contained in:
Wim Taymans 2009-12-22 20:15:28 +01:00 committed by Wim Taymans
parent 681d23ccb7
commit f7070b6bc6
3 changed files with 96 additions and 0 deletions

View file

@ -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
<SUBSECTION Standard>
</SECTION>

View file

@ -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;
}

View file

@ -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__ */