rtcpbuffer: add helper functions for SDES types
authorWim Taymans <wim.taymans@collabora.co.uk>
Tue, 22 Dec 2009 19:15:28 +0000 (20:15 +0100)
committerWim Taymans <wim@metal.(none)>
Tue, 22 Dec 2009 19:15:28 +0000 (20:15 +0100)
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
gst-libs/gst/rtp/gstrtcpbuffer.c
gst-libs/gst/rtp/gstrtcpbuffer.h

index 7574a4c..2e96a0a 100644 (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>
 
index e141eb0..9177b39 100644 (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;
+}
index 75ab4bc..b051571 100644 (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__ */