MT#60476 sdp_replace: generalize usage of `->session_last_sdp_orig`

Use the `->session_last_sdp_orig` for the version as well as
username type of replacements.

Remove superfluous code.

It's possible to handle it like that, because the last user
of the sdp_replace func, which is the offer/answer model, sets
the `->session_sdp_orig` actually in `__call_monologue_init_from_flags`.

Additionally: add tests for the user type of the origin replacement.
Change-Id: Idd60e628c676840c2e844077303035c0edec67e2
rfuchs/gh1842
Donat Zenichev 9 months ago
parent 92d172b524
commit 7f90fed7ad

@ -2923,28 +2923,9 @@ static void sdp_version_check(struct sdp_chopper *chop, sdp_sessions_q *sessions
/* 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 */
sdp_origin * origin = NULL;
/* re-use previous version origin if possible. 'SDP version' */
if (monologue->session_last_sdp_orig && !force_increase) {
origin = monologue->session_last_sdp_orig;
}
else if (monologue->session_sdp_orig) {
origin = monologue->session_sdp_orig;
if (monologue->session_last_sdp_orig)
sdp_orig_free(monologue->session_last_sdp_orig);
monologue->session_last_sdp_orig = sdp_orig_dup(origin);
}
else if (session) {
/* initial */
origin = &session->origin;
if (monologue->session_last_sdp_orig)
sdp_orig_free(monologue->session_last_sdp_orig);
monologue->session_last_sdp_orig = sdp_orig_dup(origin);
}
if (!origin)
if (!monologue->session_last_sdp_orig)
return;
sdp_origin *origin = monologue->session_last_sdp_orig;
/* First update all versions to match our single version */
sdp_version_replace(chop, sessions, origin);
@ -3319,18 +3300,16 @@ int sdp_replace(struct sdp_chopper *chop, sdp_sessions_q *sessions,
goto error;
}
else {
/* don't set `->session_sdp_orig` for non-tagged monologues (answerer side)
* answerer has to fill this structure with his own origin.
*/
if (!monologue->session_sdp_orig && monologue->tag.len) {
monologue->session_sdp_orig = sdp_orig_dup(&session->origin);
}
else if (monologue->session_sdp_orig && flags->replace_username) {
/* for cases with origin replacements, keep the very first used origin */
if (!monologue->session_last_sdp_orig)
monologue->session_last_sdp_orig = sdp_orig_dup(&session->origin);
if (flags->replace_username) {
/* make sure the username field in the o= line always remains the same
* in all SDPs going to a particular endpoint */
if (copy_up_to(chop, &session->origin.username))
goto error;
chopper_append_str(chop, &monologue->session_sdp_orig->username);
chopper_append_str(chop, &monologue->session_last_sdp_orig->username);
if (skip_over(chop, &session->origin.username))
goto error;
}

@ -22201,6 +22201,131 @@ SDP
new_call;
offer('SDP origin replace username only', { replace => ['username'] }, <<SDP);
v=0
o=test 1545997027 1 IN IP4 198.51.100.1
s=tester
c=IN IP4 198.51.100.1
t=0 0
m=audio 2000 RTP/AVP 0
c=IN IP4 198.51.100.1
----------------------------
v=0
o=test 1545997027 1 IN IP4 198.51.100.1
s=tester
c=IN IP4 198.51.100.1
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
answer('SDP origin replace username only', { ICE => 'remove' }, <<SDP);
v=0
o=- 1545997027 1 IN IP4 198.51.100.3
s=tester
t=0 0
m=audio 2002 RTP/AVP 0
c=IN IP4 198.51.100.3
a=sendrecv
--------------------------------------
v=0
o=- 1545997027 1 IN IP4 198.51.100.3
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
offer('SDP origin replace username only', { replace => ['username'] }, <<SDP);
v=0
o=test2 1545997027 1 IN IP4 198.51.100.1
s=tester
c=IN IP4 198.51.100.1
t=0 0
m=audio 2000 RTP/AVP 0
c=IN IP4 198.51.100.1
----------------------------
v=0
o=test 1545997027 1 IN IP4 198.51.100.1
s=tester
c=IN IP4 198.51.100.1
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
answer('SDP origin replace username only', { ICE => 'remove' }, <<SDP);
v=0
o=- 1545997027 1 IN IP4 198.51.100.3
s=tester
t=0 0
m=audio 2002 RTP/AVP 0
c=IN IP4 198.51.100.3
a=sendrecv
--------------------------------------
v=0
o=- 1545997027 1 IN IP4 198.51.100.3
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
offer('SDP origin replace username only', { replace => ['username'] }, <<SDP);
v=0
o=test3 1545997027 1 IN IP4 198.51.100.1
s=tester
c=IN IP4 198.51.100.1
t=0 0
m=audio 2000 RTP/AVP 0
c=IN IP4 198.51.100.1
----------------------------
v=0
o=test 1545997027 1 IN IP4 198.51.100.1
s=tester
c=IN IP4 198.51.100.1
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
answer('SDP origin replace username only', { ICE => 'remove' }, <<SDP);
v=0
o=- 1545997027 1 IN IP4 198.51.100.3
s=tester
t=0 0
m=audio 2002 RTP/AVP 0
c=IN IP4 198.51.100.3
a=sendrecv
--------------------------------------
v=0
o=- 1545997027 1 IN IP4 198.51.100.3
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;
offer('SDP replace everything', { replace => ['SDP version', 'origin', 'username', 'session-name'] }, <<SDP);
v=0
o=- 1545997027 1 IN IP4 198.51.100.1

Loading…
Cancel
Save