summaryrefslogtreecommitdiffstats
path: root/gst/rtpmanager/rtpsource.c
diff options
context:
space:
mode:
Diffstat (limited to 'gst/rtpmanager/rtpsource.c')
-rw-r--r--gst/rtpmanager/rtpsource.c99
1 files changed, 54 insertions, 45 deletions
diff --git a/gst/rtpmanager/rtpsource.c b/gst/rtpmanager/rtpsource.c
index 209c17b5..40cdd238 100644
--- a/gst/rtpmanager/rtpsource.c
+++ b/gst/rtpmanager/rtpsource.c
@@ -188,52 +188,13 @@ rtp_source_finalize (GObject * object)
G_OBJECT_CLASS (rtp_source_parent_class)->finalize (object);
}
-#define MAX_ADDRESS 64
-static void
-make_address_string (GstNetAddress * addr, gchar * dest, gulong n)
-{
- switch (gst_netaddress_get_net_type (addr)) {
- case GST_NET_TYPE_IP4:
- {
- guint32 address;
- guint16 port;
-
- gst_netaddress_get_ip4_address (addr, &address, &port);
- address = g_ntohl (address);
-
- g_snprintf (dest, n, "%d.%d.%d.%d:%d", (address >> 24) & 0xff,
- (address >> 16) & 0xff, (address >> 8) & 0xff, address & 0xff,
- g_ntohs (port));
- break;
- }
- case GST_NET_TYPE_IP6:
- {
- guint8 address[16];
- guint16 port;
-
- gst_netaddress_get_ip6_address (addr, address, &port);
-
- g_snprintf (dest, n, "[%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x]:%d",
- (address[0] << 8) | address[1], (address[2] << 8) | address[3],
- (address[4] << 8) | address[5], (address[6] << 8) | address[7],
- (address[8] << 8) | address[9], (address[10] << 8) | address[11],
- (address[12] << 8) | address[13], (address[14] << 8) | address[15],
- g_ntohs (port));
- break;
- }
- default:
- dest[0] = 0;
- break;
- }
-}
-
static GstStructure *
rtp_source_create_stats (RTPSource * src)
{
GstStructure *s;
gboolean is_sender = src->is_sender;
gboolean internal = src->internal;
- gchar address_str[MAX_ADDRESS];
+ gchar address_str[GST_NETADDRESS_MAX_LEN];
/* common data for all types of sources */
s = gst_structure_new ("application/x-rtp-source-stats",
@@ -246,11 +207,13 @@ rtp_source_create_stats (RTPSource * src)
/* add address and port */
if (src->have_rtp_from) {
- make_address_string (&src->rtp_from, address_str, sizeof (address_str));
+ gst_netaddress_to_string (&src->rtp_from, address_str,
+ sizeof (address_str));
gst_structure_set (s, "rtp-from", G_TYPE_STRING, address_str, NULL);
}
if (src->have_rtcp_from) {
- make_address_string (&src->rtcp_from, address_str, sizeof (address_str));
+ gst_netaddress_to_string (&src->rtcp_from, address_str,
+ sizeof (address_str));
gst_structure_set (s, "rtcp-from", G_TYPE_STRING, address_str, NULL);
}
@@ -316,8 +279,16 @@ rtp_source_create_stats (RTPSource * src)
return s;
}
-static GstStructure *
-rtp_source_create_sdes (RTPSource * src)
+/**
+ * rtp_source_get_sdes_struct:
+ * @src: an #RTSPSource
+ *
+ * Get the SDES data as a GstStructure
+ *
+ * Returns: a GstStructure with SDES items for @src.
+ */
+GstStructure *
+rtp_source_get_sdes_struct (RTPSource * src)
{
GstStructure *s;
gchar *str;
@@ -356,6 +327,44 @@ rtp_source_create_sdes (RTPSource * src)
return s;
}
+/**
+ * rtp_source_set_sdes_struct:
+ * @src: an #RTSPSource
+ * @sdes: a #GstStructure with SDES info
+ *
+ * Set the SDES items from @sdes.
+ */
+void
+rtp_source_set_sdes_struct (RTPSource * src, const GstStructure * sdes)
+{
+ const gchar *str;
+
+ if (!gst_structure_has_name (sdes, "application/x-rtp-source-sdes"))
+ return;
+
+ if ((str = gst_structure_get_string (sdes, "cname"))) {
+ rtp_source_set_sdes_string (src, GST_RTCP_SDES_CNAME, str);
+ }
+ if ((str = gst_structure_get_string (sdes, "name"))) {
+ rtp_source_set_sdes_string (src, GST_RTCP_SDES_NAME, str);
+ }
+ if ((str = gst_structure_get_string (sdes, "email"))) {
+ rtp_source_set_sdes_string (src, GST_RTCP_SDES_EMAIL, str);
+ }
+ if ((str = gst_structure_get_string (sdes, "phone"))) {
+ rtp_source_set_sdes_string (src, GST_RTCP_SDES_PHONE, str);
+ }
+ if ((str = gst_structure_get_string (sdes, "location"))) {
+ rtp_source_set_sdes_string (src, GST_RTCP_SDES_LOC, str);
+ }
+ if ((str = gst_structure_get_string (sdes, "tool"))) {
+ rtp_source_set_sdes_string (src, GST_RTCP_SDES_TOOL, str);
+ }
+ if ((str = gst_structure_get_string (sdes, "note"))) {
+ rtp_source_set_sdes_string (src, GST_RTCP_SDES_NOTE, str);
+ }
+}
+
static void
rtp_source_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
@@ -396,7 +405,7 @@ rtp_source_get_property (GObject * object, guint prop_id,
g_value_set_boolean (value, rtp_source_is_sender (src));
break;
case PROP_SDES:
- g_value_take_boxed (value, rtp_source_create_sdes (src));
+ g_value_take_boxed (value, rtp_source_get_sdes_struct (src));
break;
case PROP_STATS:
g_value_take_boxed (value, rtp_source_create_stats (src));