From ddd071e54cd338e1f2fa89e8d26ac3dd29891185 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 25 Jul 2013 16:24:04 +0200 Subject: [PATCH] session: configure sdes with structure only Remove code to configure the SDES with methods and types, only allow configuration with GstStructure --- gst/rtpmanager/rtpsession.c | 61 ++++++--------------------------------- gst/rtpmanager/rtpsession.h | 4 --- gst/rtpmanager/rtpsource.c | 69 --------------------------------------------- gst/rtpmanager/rtpsource.h | 3 -- 4 files changed, 9 insertions(+), 128 deletions(-) diff --git a/gst/rtpmanager/rtpsession.c b/gst/rtpmanager/rtpsession.c index 415ea3f..dc126c5 100644 --- a/gst/rtpmanager/rtpsession.c +++ b/gst/rtpmanager/rtpsession.c @@ -460,6 +460,7 @@ rtp_session_init (RTPSession * sess) { gint i; gchar *str; + GstStructure *sdes; g_mutex_init (&sess->lock); sess->key = g_random_int (); @@ -499,20 +500,24 @@ rtp_session_init (RTPSession * sess) sess->probation = DEFAULT_PROBATION; /* some default SDES entries */ + sdes = gst_structure_new_empty ("application/x-rtp-source-sdes"); /* we do not want to leak details like the username or hostname here */ str = g_strdup_printf ("user%u@host-%x", g_random_int (), g_random_int ()); - rtp_source_set_sdes_string (sess->source, GST_RTCP_SDES_CNAME, str); + gst_structure_set (sdes, "cname", G_TYPE_STRING, str, NULL); g_free (str); #if 0 /* we do not want to leak the user's real name here */ str = g_strdup_printf ("Anon%u", g_random_int ()); - rtp_source_set_sdes_string (sess->source, GST_RTCP_SDES_NAME, str); + gst_structure_set (sdes, "name", G_TYPE_STRING, str, NULL); g_free (str); #endif - rtp_source_set_sdes_string (sess->source, GST_RTCP_SDES_TOOL, "GStreamer"); + gst_structure_set (sdes, "tool", G_TYPE_STRING, "GStreamer", NULL); + + /* and configure in the source */ + rtp_source_set_sdes_struct (sess->source, sdes); sess->first_rtcp = TRUE; sess->next_rtcp_check_time = GST_CLOCK_TIME_NONE; @@ -537,6 +542,7 @@ rtp_session_finalize (GObject * object) sess = RTP_SESSION_CAST (object); g_mutex_clear (&sess->lock); + for (i = 0; i < 32; i++) g_hash_table_destroy (sess->ssrcs[i]); @@ -1071,55 +1077,6 @@ rtp_session_get_rtcp_fraction (RTPSession * sess) } /** - * rtp_session_set_sdes_string: - * @sess: an #RTPSession - * @type: the type of the SDES item - * @item: a null-terminated string to set. - * - * Store an SDES item of @type in @sess. - * - * Returns: %FALSE if the data was unchanged @type is invalid. - */ -gboolean -rtp_session_set_sdes_string (RTPSession * sess, GstRTCPSDESType type, - const gchar * item) -{ - gboolean result; - - g_return_val_if_fail (RTP_IS_SESSION (sess), FALSE); - - RTP_SESSION_LOCK (sess); - result = rtp_source_set_sdes_string (sess->source, type, item); - RTP_SESSION_UNLOCK (sess); - - return result; -} - -/** - * rtp_session_get_sdes_string: - * @sess: an #RTPSession - * @type: the type of the SDES item - * - * Get the SDES item of @type from @sess. - * - * Returns: a null-terminated copy of the SDES item or NULL when @type was not - * valid. g_free() after usage. - */ -gchar * -rtp_session_get_sdes_string (RTPSession * sess, GstRTCPSDESType type) -{ - gchar *result; - - g_return_val_if_fail (RTP_IS_SESSION (sess), NULL); - - RTP_SESSION_LOCK (sess); - result = rtp_source_get_sdes_string (sess->source, type); - RTP_SESSION_UNLOCK (sess); - - return result; -} - -/** * rtp_session_get_sdes_struct: * @sess: an #RTSPSession * diff --git a/gst/rtpmanager/rtpsession.h b/gst/rtpmanager/rtpsession.h index 6e64e77..41c5758 100644 --- a/gst/rtpmanager/rtpsession.h +++ b/gst/rtpmanager/rtpsession.h @@ -301,10 +301,6 @@ gdouble rtp_session_get_bandwidth (RTPSession *sess); void rtp_session_set_rtcp_fraction (RTPSession *sess, gdouble fraction); gdouble rtp_session_get_rtcp_fraction (RTPSession *sess); -gboolean rtp_session_set_sdes_string (RTPSession *sess, GstRTCPSDESType type, - const gchar *cname); -gchar* rtp_session_get_sdes_string (RTPSession *sess, GstRTCPSDESType type); - GstStructure * rtp_session_get_sdes_struct (RTPSession *sess); void rtp_session_set_sdes_struct (RTPSession *sess, const GstStructure *sdes); diff --git a/gst/rtpmanager/rtpsource.c b/gst/rtpmanager/rtpsource.c index 4253992..9fd12e1 100644 --- a/gst/rtpmanager/rtpsource.c +++ b/gst/rtpmanager/rtpsource.c @@ -756,75 +756,6 @@ rtp_source_update_caps (RTPSource * src, GstCaps * caps) } /** - * rtp_source_set_sdes_string: - * @src: an #RTPSource - * @type: the type of the SDES item - * @data: the SDES data - * - * Store an SDES item of @type in @src. - * - * Returns: %FALSE if the SDES item was unchanged or @type is unknown. - */ -gboolean -rtp_source_set_sdes_string (RTPSource * src, GstRTCPSDESType type, - const gchar * data) -{ - const gchar *old; - const gchar *field; - - field = gst_rtcp_sdes_type_to_name (type); - - if (gst_structure_has_field (src->sdes, field)) - old = gst_structure_get_string (src->sdes, field); - else - old = NULL; - - if (old == NULL && data == NULL) - return FALSE; - - if (old != NULL && data != NULL && strcmp (old, data) == 0) - return FALSE; - - if (data == NULL) - gst_structure_remove_field (src->sdes, field); - else - gst_structure_set (src->sdes, field, G_TYPE_STRING, data, NULL); - - return TRUE; -} - -/** - * rtp_source_get_sdes_string: - * @src: an #RTPSource - * @type: the type of the SDES item - * - * Get the SDES item of @type from @src. - * - * Returns: a null-terminated copy of the SDES item or NULL when @type was not - * valid or the SDES item was unset. g_free() after usage. - */ -gchar * -rtp_source_get_sdes_string (RTPSource * src, GstRTCPSDESType type) -{ - gchar *result; - const gchar *type_name; - - g_return_val_if_fail (RTP_IS_SOURCE (src), NULL); - - if (type < 0 || type > GST_RTCP_SDES_PRIV - 1) - return NULL; - - type_name = gst_rtcp_sdes_type_to_name (type); - - if (!gst_structure_has_field (src->sdes, type_name)) - return NULL; - - result = g_strdup (gst_structure_get_string (src->sdes, type_name)); - - return result; -} - -/** * rtp_source_set_rtp_from: * @src: an #RTPSource * @address: the RTP address to set diff --git a/gst/rtpmanager/rtpsource.h b/gst/rtpmanager/rtpsource.h index 7f1210f..153d423 100644 --- a/gst/rtpmanager/rtpsource.h +++ b/gst/rtpmanager/rtpsource.h @@ -205,9 +205,6 @@ gchar * rtp_source_get_bye_reason (RTPSource *src); void rtp_source_update_caps (RTPSource *src, GstCaps *caps); /* SDES info */ -gboolean rtp_source_set_sdes_string (RTPSource *src, GstRTCPSDESType type, - const gchar *data); -gchar* rtp_source_get_sdes_string (RTPSource *src, GstRTCPSDESType type); const GstStructure * rtp_source_get_sdes_struct (RTPSource * src); gboolean rtp_source_set_sdes_struct (RTPSource * src, GstStructure *sdes); -- 2.7.4