From dbe4e5d53415f1c47232ebe1709ba5e51c39ecb1 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Fri, 12 Jan 2024 13:17:10 -0500 Subject: [PATCH] MT#55283 add sdp_manipulate_remove_attr Convenience function to check multiple parts of an attributes against the removal list. Change-Id: Ifdc5c8d659b7792e1ac415f4a4a456fba52aa6d6 --- daemon/sdp.c | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/daemon/sdp.c b/daemon/sdp.c index c78fd97f1..846714f7a 100644 --- a/daemon/sdp.c +++ b/daemon/sdp.c @@ -347,6 +347,22 @@ static bool sdp_manipulate_remove_c(const char *attr_name, sdp_ng_flags *flags, return sdp_manipulate_remove(sdp_manipulations, &STR_INIT(attr_name)); } +/** + * Checks whether an attribute removal request exists for a given session level. + * `attr_name` must be without `a=`. + */ +static bool sdp_manipulate_remove_attr(struct sdp_manipulations *sdp_manipulations, + const struct sdp_attribute *attr) +{ + if (sdp_manipulate_remove(sdp_manipulations, &attr->key)) + return true; + if (sdp_manipulate_remove(sdp_manipulations, &attr->name)) + return true; + if (sdp_manipulate_remove(sdp_manipulations, &attr->line_value)) + return true; + return false; +} + /** * Adds values into a requested session level (global, audio, video) */ @@ -2380,7 +2396,7 @@ static int process_session_attributes(struct sdp_chopper *chop, struct sdp_attri } /* if attr is supposed to be removed don't add to the chop->output */ - if (sdp_manipulate_remove(sdp_manipulations, &attr->line_value)) + if (sdp_manipulate_remove_attr(sdp_manipulations, attr)) goto strip; /* if attr is supposed to be substituted don't add to the chop->output, but add another value */ @@ -2530,7 +2546,7 @@ static int process_media_attributes(struct sdp_chopper *chop, struct sdp_media * } /* if attr is supposed to be removed don't add to the chop->output */ - if (sdp_manipulate_remove(sdp_manipulations, &attr->line_value)) + if (sdp_manipulate_remove_attr(sdp_manipulations, attr)) goto strip; /* if attr is supposed to be substituted don't add to the chop->output, but add another value */