MT#58441 Add attr subst support to append functions

Add media attributes substitution support to
the following functions:
- `append_attr_to_gstring()`
- `append_attr_int_to_gstring()`

First functions check, if the attribute has to be
removed (by the manipulations profile), if not
then it checks out whether we have to substitute it.
If neither of manipulations have to be applied,
then the given attribute gets attached to the chopper.

This gives support of substitution for
such media level attributes like:
- `mid`
- `label`
- `ptime`
- `ice-ufrag`
- `ice-pwd`
- `ice-options`
etc.

Change-Id: I35a1ad71f1031d986a79446522da2a557c09ddcc
pull/1747/head
Donat Zenichev 2 years ago
parent 5f84bc735e
commit b9d24897a7

@ -2848,25 +2848,29 @@ static void append_attr_to_gstring(GString *s, char * name, const str * value,
if (name[0] == 'a' && name[1] == '=')
name += 2;
str attr = STR_INIT(name);
struct sdp_manipulations *sdp_manipulations = sdp_manipulations_get_by_id(flags, media_type);
/* take into account SDP arbitrary manipulations */
if (sdp_manipulate_remove(sdp_manipulations, &attr) ||
sdp_manipulations_subst(sdp_manipulations, &attr))
str attr = STR_INIT(name);
str * attr_subst = sdp_manipulations_subst(sdp_manipulations, &attr);
/* first check if the originally present attribute is to be removed */
if (sdp_manipulate_remove(sdp_manipulations, &attr))
{
ilog(LOG_DEBUG, "Cannot insert: '%s' because prevented by SDP manipulations (remove or subst)", name);
ilog(LOG_DEBUG, "Cannot insert: '%s' because prevented by SDP manipulations (remove)", name);
return;
}
/* then, if there remains something to be substituted, do that */
if (attr_subst)
attr = *attr_subst;
/* attr name */
g_string_append(s, "a=");
g_string_append(s, attr.s);
g_string_append_printf(s, "a=" STR_FORMAT, STR_FMT(&attr));
/* attr value */
if (value) {
/* attr value, don't add if substituion presented */
if (value && !attr_subst)
g_string_append_printf(s, STR_FORMAT, STR_FMT(value));
}
g_string_append(s, "\r\n");
}
@ -2878,24 +2882,29 @@ static void append_attr_int_to_gstring(GString *s, char * name, const int * valu
if (name[0] == 'a' && name[1] == '=')
name += 2;
str attr = STR_INIT(name);
struct sdp_manipulations *sdp_manipulations = sdp_manipulations_get_by_id(flags, media_type);
/* take into account SDP arbitrary manipulations */
if (sdp_manipulate_remove(sdp_manipulations, &attr) ||
sdp_manipulations_subst(sdp_manipulations, &attr))
str attr = STR_INIT(name);
str * attr_subst = sdp_manipulations_subst(sdp_manipulations, &attr);
/* first check if the originally present attribute is to be removed */
if (sdp_manipulate_remove(sdp_manipulations, &attr))
{
ilog(LOG_DEBUG, "Cannot insert: '%s' because prevented by SDP manipulations (remove or subst)", name);
ilog(LOG_DEBUG, "Cannot insert: '%s' because prevented by SDP manipulations (remove)", name);
return;
}
/* then, if there remains something to be substituted, do that */
if (attr_subst)
attr = *attr_subst;
/* attr name */
g_string_append(s, "a=");
g_string_append(s, attr.s);
g_string_append_printf(s, "a=" STR_FORMAT, STR_FMT(&attr));
/* attr value */
if (value) {
/* attr value, don't add if substituion presented */
if (value && !attr_subst)
g_string_append_printf(s, "%i", *value);
}
g_string_append(s, "\r\n");
}

Loading…
Cancel
Save