diff --git a/README.md b/README.md index b3bd148d7..a8f961a1c 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/daemon/call_interfaces.c b/daemon/call_interfaces.c index 0406e5f95..366a8c88d 100644 --- a/daemon/call_interfaces.c +++ b/daemon/call_interfaces.c @@ -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; diff --git a/daemon/sdp.c b/daemon/sdp.c index 61a24dca2..25b9dbfbd 100644 --- a/daemon/sdp.c +++ b/daemon/sdp.c @@ -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; diff --git a/include/call_interfaces.h b/include/call_interfaces.h index 8750bdbd8..c8e9de543 100644 --- a/include/call_interfaces.h +++ b/include/call_interfaces.h @@ -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, diff --git a/t/auto-daemon-tests.pl b/t/auto-daemon-tests.pl index eab6038ad..7f92681e4 100755 --- a/t/auto-daemon-tests.pl +++ b/t/auto-daemon-tests.pl @@ -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'] }, <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'] }, <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'] }, < \$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'},