MT#56129 Add a flag to force increasing the SDP version

Add a flag to force increasing the SDP version,
even if the SDP hasn't been changed.

And cover it with tests.

Flag name: 'force-increment-sdp-ver'

Additionally fix the name of the 'sdp-version' flag
in the 'rtpengine-ng-client' tool.

Change-Id: I466792668b0cd313b5e21b248dd14cd599333cbd
pull/1577/head
Donat Zenichev 2 years ago
parent 47375c5bfd
commit 50ba97b3c9

@ -970,6 +970,10 @@ Optionally included keys are:
Take control of the version field in the SDP and make sure it's increased every
time the SDP changes, and left unchanged if the SDP is the same.
- `force-increment-sdp-ver`
Force increasing the SDP version, even if the SDP hasn't been changed.
- `username`
Take control of the origin username field in the SDP. With this

@ -693,6 +693,10 @@ static void call_ng_flags_replace(struct sdp_ng_flags *out, str *s, void *dummy)
case CSH_LOOKUP("session-name"):
out->replace_sess_name = 1;
break;
case CSH_LOOKUP("force-increment-sdp-ver"):
out->force_inc_sdp_ver = 1;
out->replace_sdp_version = 1;
break;
case CSH_LOOKUP("sdp-version"):
case CSH_LOOKUP("SDP-version"):
out->replace_sdp_version = 1;

@ -2516,19 +2516,27 @@ static void sdp_version_replace(struct sdp_chopper *chop, GQueue *sessions, stru
}
}
static void sdp_version_check(struct sdp_chopper *chop, GQueue *sessions, struct call_monologue *monologue) {
// we really expect only a single session here, but we treat all the same regardless,
// and use the same version number on all of them
static void sdp_version_check(struct sdp_chopper *chop, GQueue *sessions, struct call_monologue *monologue,
unsigned int force_increase) {
/* We really expect only a single session here, but we treat all the same regardless,
* and use the same version number on all of them */
// first update all versions to match our single version
/* First update all versions to match our single version */
sdp_version_replace(chop, sessions, monologue);
// then check if we need to change
if (!monologue->last_out_sdp)
goto dup;
if (g_string_equal(monologue->last_out_sdp, chop->output))
return;
// mismatch detected. increment version, update again, and store copy
/* Now check if we need to change the version actually.
* The version change will be forced with the 'force_increase',
* and it gets incremented, regardless whether:
* - we have no previously stored SDP,
* - we have previous SDP and it's equal to the current one */
if (!force_increase) {
if (!monologue->last_out_sdp)
goto dup;
if (g_string_equal(monologue->last_out_sdp, chop->output))
return;
}
/* mismatch detected. increment version, update again, and store copy */
monologue->sdp_version++;
sdp_version_replace(chop, sessions, monologue);
g_string_free(monologue->last_out_sdp, TRUE);
@ -2835,8 +2843,13 @@ next:
copy_remainder(chop);
/* The SDP version gets increased in case:
* - if replace_sdp_version (sdp-version) flag is set and SDP information has been updated, or
* - if the force_inc_sdp_ver (force-increment-sdp-ver) flag is set additionally to replace_sdp_version,
* which forces version increase regardless changes in the SDP information.
*/
if (flags->replace_sdp_version)
sdp_version_check(chop, sessions, monologue);
sdp_version_check(chop, sessions, monologue, flags->force_inc_sdp_ver);
return 0;

@ -113,6 +113,7 @@ struct sdp_ng_flags {
replace_origin:1,
replace_sess_conn:1,
replace_sdp_version:1,
force_inc_sdp_ver:1,
replace_username:1,
replace_sess_name:1,
replace_zero_address:1,

@ -17192,7 +17192,69 @@ a=sendrecv
a=rtcp:PORT
SDP
new_call;
# there is no 'monologue->last_out_sdp', but the version still gets increased
offer('SDP version force increase', { replace => ['force-increment-sdp-ver'] }, <<SDP);
v=0
o=- 1545997027 1 IN IP4 198.51.100.1
s=tester
t=0 0
m=audio 2000 RTP/AVP 0
c=IN IP4 198.51.100.1
----------------------------
v=0
o=- 1545997027 2 IN IP4 198.51.100.1
s=tester
t=0 0
m=audio PORT RTP/AVP 0
c=IN IP4 203.0.113.1
a=rtpmap:0 PCMU/8000
a=sendrecv
a=rtcp:PORT
SDP
# there is 'monologue->last_out_sdp' and it's equal to the newly given SDP,
# but the version still gets increased
offer('SDP version force increase', { replace => ['force-increment-sdp-ver'] }, <<SDP);
v=0
o=- 1545997027 2 IN IP4 198.51.100.1
s=tester
t=0 0
m=audio 2000 RTP/AVP 0
c=IN IP4 198.51.100.1
----------------------------
v=0
o=- 1545997027 3 IN IP4 198.51.100.1
s=tester
t=0 0
m=audio PORT RTP/AVP 0
c=IN IP4 203.0.113.1
a=rtpmap:0 PCMU/8000
a=sendrecv
a=rtcp:PORT
SDP
# there is 'monologue->last_out_sdp' and it's not equal to the newly given SDP,
# and the version gets increased, as if that would be increased with 'sdp-version'.
offer('SDP version force increase', { replace => ['force-increment-sdp-ver'] }, <<SDP);
v=0
o=- 1545997027 3 IN IP4 198.51.100.1
s=tester
t=0 0
m=audio 2002 RTP/AVP 0
c=IN IP4 198.51.100.1
----------------------------
v=0
o=- 1545997027 4 IN IP4 198.51.100.1
s=tester
t=0 0
m=audio PORT RTP/AVP 0
c=IN IP4 203.0.113.1
a=rtpmap:0 PCMU/8000
a=sendrecv
a=rtcp:PORT
SDP
new_call;

@ -29,7 +29,8 @@ GetOptions(
'unidirectional' => \$options{'unidirectional'},
'replace-origin' => \$options{'replace-origin'},
'replace-session-connection' => \$options{'replace-session connection'},
'replace-sdp-version' => \$options{'replace-sdp version'},
'sdp-version' => \$options{'replace-sdp version'},
'force-increment-sdp-ver' => \$options{'force increment sdp version'},
'replace-username' => \$options{'replace-username'},
'replace-session-name' => \$options{'replace-session-name'},
'replace-zero-address' => \$options{'replace-zero-address'},

Loading…
Cancel
Save