From 323f5fba7d89b03c79041fb3b01392ea5d323bf9 Mon Sep 17 00:00:00 2001 From: Jakub Adam Date: Fri, 4 Sep 2015 14:48:48 +0200 Subject: [PATCH] media: add sipe_media_stream_add_extra_attribute() Allows adding application-specific SDP attributes to media streams. --- src/core/sipe-media.c | 24 ++++++++++++++++++++++-- src/core/sipe-media.h | 14 ++++++++++++++ 2 files changed, 36 insertions(+), 2 deletions(-) diff --git a/src/core/sipe-media.c b/src/core/sipe-media.c index 2dcc9d78..a712e8a8 100644 --- a/src/core/sipe-media.c +++ b/src/core/sipe-media.c @@ -74,6 +74,8 @@ struct sipe_media_stream_private { int encryption_key_id; gboolean remote_candidates_and_codecs_set; + GSList *extra_sdp; + /* User data associated with the stream. */ gpointer data; GDestroyNotify data_free_func; @@ -106,6 +108,7 @@ remove_stream(struct sipe_media_call* call, sipe_backend_media_stream_free(SIPE_MEDIA_STREAM->backend_private); g_free(SIPE_MEDIA_STREAM->id); g_free(stream_private->encryption_key); + sipe_utils_nameval_free(stream_private->extra_sdp); g_free(stream_private); } @@ -368,6 +371,7 @@ media_stream_to_sdpmedia(struct sipe_media_call_private *call_private, GSList *all_sdpcandidates; GList *candidates; GList *i; + GSList *j; sdpmedia->name = g_strdup(SIPE_MEDIA_STREAM->id); @@ -478,8 +482,6 @@ media_stream_to_sdpmedia(struct sipe_media_call_private *call_private, attributes = sipe_utils_nameval_add(attributes, "encryption", encryption); } - sdpmedia->attributes = attributes; - // Process remote candidates candidates = sipe_backend_media_get_active_remote_candidates(SIPE_MEDIA_CALL, SIPE_MEDIA_STREAM); @@ -499,6 +501,15 @@ media_stream_to_sdpmedia(struct sipe_media_call_private *call_private, sdpmedia->encryption_key_id = stream_private->encryption_key_id; } + // Append extra attributes assigned to the stream. + for (j = stream_private->extra_sdp; j; j = g_slist_next(j)) { + struct sipnameval *attr = j->data; + attributes = sipe_utils_nameval_add(attributes, + attr->name, attr->value); + } + + sdpmedia->attributes = attributes; + return sdpmedia; } @@ -1758,6 +1769,15 @@ sipe_media_get_av_edge_credentials(struct sipe_core_private *sipe_private) } void +sipe_media_stream_add_extra_attribute(struct sipe_media_stream *stream, + const gchar *name, const gchar *value) +{ + SIPE_MEDIA_STREAM_PRIVATE->extra_sdp = + sipe_utils_nameval_add(SIPE_MEDIA_STREAM_PRIVATE->extra_sdp, + name, value); +} + +void sipe_media_stream_set_data(struct sipe_media_stream *stream, gpointer data, GDestroyNotify free_func) { diff --git a/src/core/sipe-media.h b/src/core/sipe-media.h index f1a5d70f..73026fc3 100644 --- a/src/core/sipe-media.h +++ b/src/core/sipe-media.h @@ -91,6 +91,20 @@ gboolean is_media_session_msg(struct sipe_media_call_private *call_private, void sipe_media_get_av_edge_credentials(struct sipe_core_private *sipe_private); /** + * Adds application-specific SDP attribute to the stream. This will be sent as + * a part of our SIP INVITE alongside standard media description, formatted as: + * + * a=name[:value] + * + * @param stream (in) media stream data + * @param name (in) attribute name + * @param value (in) optional value of the attribute + */ +void +sipe_media_stream_add_extra_attribute(struct sipe_media_stream *stream, + const gchar *name, const gchar *value); + +/** * Associates user data with the media stream. * * @param stream (in) media stream data -- 2.11.4.GIT