From 16fc4e5e0ec9dd47bb0e937c39f9c8466ecf745f Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Wed, 10 Jan 2024 16:59:27 -0500 Subject: [PATCH] MT#55283 extend SDP attribute matching For tagged attributes using a `a=name:tag value` format, extend pattern matching so that just `name` matches as well as `name:tag`. Only support this for removal (not substitution) as these attributes generally can appear multiple times, and doing a static substitution on all of them is kinda pointless. Change-Id: I07c7f6e9075e862902bffe679d5de8618162eb8f --- daemon/sdp.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/daemon/sdp.c b/daemon/sdp.c index 10dfaca06..c78fd97f1 100644 --- a/daemon/sdp.c +++ b/daemon/sdp.c @@ -338,6 +338,15 @@ static bool sdp_manipulate_remove(struct sdp_manipulations * sdp_manipulations, return false; } +/** + * Checks whether an attribute removal request exists for a given session level. + * `attr_name` must be without `a=`. + */ +static bool sdp_manipulate_remove_c(const char *attr_name, sdp_ng_flags *flags, enum media_type media_type) { + struct sdp_manipulations *sdp_manipulations = sdp_manipulations_get_by_id(flags, media_type); + return sdp_manipulate_remove(sdp_manipulations, &STR_INIT(attr_name)); +} + /** * Adds values into a requested session level (global, audio, video) */ @@ -2957,6 +2966,8 @@ static void append_attr_to_gstring(GString *s, const char * name, const str * va static void append_tagged_attr_to_gstring(GString *s, const char * name, const str *tag, const str * value, sdp_ng_flags *flags, enum media_type media_type) { + if (sdp_manipulate_remove_c(name, flags, media_type)) + return; g_autoptr(GString) n = g_string_new(name); g_string_append_c(n, ':'); g_string_append_len(n, tag->s, tag->len); @@ -2967,6 +2978,8 @@ static void append_tagged_attr_to_gstring(GString *s, const char * name, const s static void append_int_tagged_attr_to_gstring(GString *s, const char * name, unsigned int tag, const str * value, sdp_ng_flags *flags, enum media_type media_type) { + if (sdp_manipulate_remove_c(name, flags, media_type)) + return; g_autoptr(GString) n = g_string_new(name); g_string_append_printf(n, ":%u", tag); generic_append_attr_to_gstring(s, n->str, ' ', value, flags, media_type);