MT#56465 sdp_create(), set the actual sdp session name

Always ensure to set the actual sdp session name when
creating SDP using `sdp_create()`.

A new dedicated func `sdp_out_add_session_name()` introduced
for that.

Additionally: fix auto-daemon-tests-websocket and
auto-daemon-tests-pubsub accordingly.

Change-Id: Ie62573149ef9ae226dc8c955dcb2cfaaa4d3ae87
rfuchs/dataport
Donat Zenichev 1 year ago
parent 4dfd94964f
commit 138ba8c178

@ -2638,8 +2638,9 @@ static void __call_monologue_init_from_flags(struct call_monologue *ml, sdp_ng_f
ml->sdp_attributes = flags->session_attributes;
t_queue_init(&flags->session_attributes);
/* consume sdp session origin parts (name, version etc.) */
/* consume sdp session parts */
{
/* origin (name, version etc.) */
if (!ml->sdp_username && flags->session_sdp_orig.username.len)
ml->sdp_username = call_strdup_len(call, flags->session_sdp_orig.username.s,
flags->session_sdp_orig.username.len);
@ -2649,6 +2650,14 @@ static void __call_monologue_init_from_flags(struct call_monologue *ml, sdp_ng_f
ml->sdp_version = flags->session_sdp_orig.version_num;
if (ml->sdp_version == ULLONG_MAX)
ml->sdp_version = (unsigned int)ssl_random();
/* sdp session name */
if (flags->session_sdp_name.len &&
(!ml->sdp_session_name || /* if not set yet */
(ml->sdp_session_name && !flags->replace_sess_name))) /* replace_sess_name = do not replace if possible*/
{
ml->sdp_session_name = call_strdup_len(call, flags->session_sdp_name.s,
flags->session_sdp_name.len);
}
}
// reset offer ipv4/ipv6/mixed media stats

@ -1788,8 +1788,12 @@ int sdp_streams(const sdp_sessions_q *sessions, sdp_streams_q *streams, sdp_ng_f
for (auto_iter(l, sessions->head); l; l = l->next) {
session = l->data;
/* carry some of session level attributes for a later usage, using flags
* e.g. usage in `__call_monologue_init_from_flags()`
*/
sdp_attr_append_other(&flags->session_attributes, &session->attributes);
flags->session_sdp_orig = session->origin;
flags->session_sdp_name = session->session_name;
for (__auto_type k = session->media_streams.head; k; k = k->next) {
media = k->data;
@ -3403,7 +3407,34 @@ static void sdp_out_add_origin(GString *out, struct call_monologue *monologue,
origin_address);
}
int sdp_create(str *out, struct call_monologue *monologue, sdp_ng_flags *flags) {
static void sdp_out_add_session_name(GString *out, struct call_monologue *monologue,
enum call_opmode opmode)
{
/* PUBLISH exceptionally doesn't include sdp session name from SDP.
* The session name and other values should be copied only from a source SDP,
* if that is also a media source. For a publish request that's not the case. */
const char * sdp_session_name = rtpe_config.software_id;
/* for the offer/answer model or subscribe don't use the given monologues SDP,
* but try the one of the subscription, because the given monologue itself
* has likely no session attributes set yet */
struct media_subscription *ms = call_get_top_media_subscription(monologue);
if (ms && ms->monologue && ms->monologue->sdp_session_name)
sdp_session_name = ms->monologue->sdp_session_name;
g_string_append_printf(out, "s=%s\r\n", sdp_session_name);
}
/**
* For the offer/answer model, SDP create will be triggered for the B monologue,
* which likely has empty paramaters (such as sdp origin, session name etc.), hence
* such parameters have to be taken from the A monologue (so from the subscription).
*
* For the rest of cases (publish, subscribe, janus etc.) this works as usual:
* given monologue is a monologue which is being processed.
*/
int sdp_create(str *out, struct call_monologue *monologue, sdp_ng_flags *flags)
{
const char *err = NULL;
GString *s = NULL;
@ -3427,7 +3458,10 @@ int sdp_create(str *out, struct call_monologue *monologue, sdp_ng_flags *flags)
/* add origin including name and version */
sdp_out_add_origin(s, monologue, first_ps, flags);
g_string_append_printf(s, "s=%s\r\n", rtpe_config.software_id);
/* add an actual sdp session name */
sdp_out_add_session_name(s, monologue, flags->opmode);
/* set timing to always be: 0 0 */
g_string_append(s, "t=0 0\r\n");
monologue->sdp_attr_print(s, monologue, flags);

@ -72,6 +72,7 @@ struct sdp_ng_flags {
/* keep session level attributes for internal proper parsing */
sdp_attr_q session_attributes; // top-level (not part of an m= section) SDP session attributes
struct sdp_origin session_sdp_orig;
str session_sdp_name;
/* commands to manipulate attr lines in SDP */
struct sdp_manipulations * sdp_manipulations[__MT_MAX];

@ -805,7 +805,7 @@ SDP
{ flags => ['all', 'SIPREC'] }, <<SDP);
v=0
o=- SDP_VERSION IN IP4 203.0.113.1
s=RTPE_VERSION
s=tester
t=0 0
m=audio PORT RTP/AVP 0
c=IN IP4 203.0.113.1
@ -913,7 +913,7 @@ SDP
{ flags => ['all', 'SIPREC'] }, <<SDP);
v=0
o=- SDP_VERSION IN IP4 203.0.113.1
s=RTPE_VERSION
s=tester
t=0 0
m=audio PORT RTP/AVP 0
c=IN IP4 203.0.113.1
@ -1034,7 +1034,7 @@ rcv($sock_b, $port_a, rtpm(0, 4000, 7000, 0x6543, "\x00" x 160));
{ 'flags' => ['all'] }, <<SDP);
v=0
o=- SDP_VERSION IN IP4 203.0.113.1
s=RTPE_VERSION
s=tester
t=0 0
m=audio PORT RTP/AVP 0 8
c=IN IP4 203.0.113.1
@ -1167,7 +1167,7 @@ rcv($sock_b, $port_a, rtpm(0, 4000, 7000, 0x6543, "\x00" x 160));
{ 'from-tags' => [ft(), tt()] }, <<SDP);
v=0
o=- SDP_VERSION IN IP4 203.0.113.1
s=RTPE_VERSION
s=tester
t=0 0
m=audio PORT RTP/AVP 0 8
c=IN IP4 203.0.113.1
@ -1273,7 +1273,7 @@ rcv($sock_b, $port_a, rtpm(0, 4000, 7000, 0x6543, "\x00" x 160));
{ flags => ['from-tags-' . ft(), 'from-tags-' . tt()] }, <<SDP);
v=0
o=- SDP_VERSION IN IP4 203.0.113.1
s=RTPE_VERSION
s=tester
t=0 0
m=audio PORT RTP/AVP 0 8
c=IN IP4 203.0.113.1
@ -1373,7 +1373,7 @@ rcv($sock_b, $port_a, rtpm(0, 4000, 7000, 0x6543, "\x00" x 160));
{ 'from-tags' => [tt(), ft()] }, <<SDP);
v=0
o=- SDP_VERSION IN IP4 203.0.113.1
s=RTPE_VERSION
s=tester
t=0 0
m=audio PORT RTP/AVP 0 8
c=IN IP4 203.0.113.1
@ -1704,7 +1704,7 @@ rcv($sock_b, $port_a, rtpm(0, 4000, 7000, 0x6543, "\x00" x 160));
{ flags => ['all', 'SIPREC'] }, <<SDP);
v=0
o=- SDP_VERSION IN IP4 203.0.113.1
s=RTPE_VERSION
s=tester
t=0 0
m=audio PORT RTP/AVP 0
c=IN IP4 203.0.113.1
@ -1794,7 +1794,7 @@ SDP
{ flags => ['all', 'SIPREC'], 'to-tag' => $ttr }, <<SDP);
v=0
o=- SDP_VERSION IN IP4 203.0.113.1
s=RTPE_VERSION
s=tester
t=0 0
m=audio PORT RTP/AVP 0
c=IN IP4 203.0.113.1
@ -1915,7 +1915,7 @@ SDP
{ flags => ['all', 'SIPREC'], 'to-tag' => $ttr }, <<SDP);
v=0
o=- SDP_VERSION IN IP4 203.0.113.1
s=RTPE_VERSION
s=tester
t=0 0
m=audio PORT RTP/AVP 0
c=IN IP4 203.0.113.1
@ -2040,7 +2040,7 @@ SDP
{ flags => ['all', 'SIPREC'], 'to-tag' => $ttr }, <<SDP);
v=0
o=- SDP_VERSION IN IP4 203.0.113.1
s=RTPE_VERSION
s=tester
t=0 0
m=audio PORT RTP/AVP 0
c=IN IP4 203.0.113.1
@ -3591,7 +3591,7 @@ subscribe_request('multi publish/subscribe',
{ 'from-tags' => [ $ftr, $fts ] }, <<SDP);
v=0
o=- SDP_VERSION IN IP4 203.0.113.1
s=RTPE_VERSION
s=tester
t=0 0
m=audio PORT RTP/AVP 0
c=IN IP4 203.0.113.1

@ -1572,7 +1572,7 @@ my ($ftr, $ttr, $fts) = subscribe_request('sub to multiple tags',
{ 'from-tags' => [ft(), tt()] }, <<SDP);
v=0
o=- SDP_VERSION IN IP4 203.0.113.1
s=RTPE_VERSION
s=tester
t=0 0
m=audio PORT RTP/AVP 0 8
c=IN IP4 203.0.113.1

@ -614,7 +614,7 @@ class TestVideoroom(unittest.TestCase):
re.compile(
"^v=0\r\n"
"o=- \d+ \d+ IN IP4 203.0.113.1\r\n"
"s=rtpengine.*?\r\n"
"s=foobar\r\n"
"t=0 0\r\n"
"m=audio \d+ UDP/TLS/RTP/SAVPF 8\r\n"
"c=IN IP4 203.0.113.1\r\n"
@ -902,7 +902,7 @@ class TestVideoroom(unittest.TestCase):
re.compile(
"^v=0\r\n"
"o=- \d+ \d+ IN IP4 203.0.113.1\r\n"
"s=rtpengine.*?\r\n"
"s=foobar\r\n"
"t=0 0\r\n"
"m=audio \d+ UDP/TLS/RTP/SAVPF 8\r\n"
"c=IN IP4 203.0.113.1\r\n"
@ -1753,7 +1753,7 @@ class TestVideoroom(unittest.TestCase):
re.compile(
"^v=0\r\n"
"o=- \d+ \d+ IN IP4 203.0.113.1\r\n"
"s=rtpengine.*?\r\n"
"s=-\r\n"
"t=0 0\r\n"
"a=extmap-allow-mixed\r\n"
"a=msid-semantic: WMS hJifdaJwqEqHxSG0pVbs1DrLAwiHqz7fKlqC\r\n"
@ -2020,7 +2020,7 @@ class TestVideoroom(unittest.TestCase):
re.compile(
"^v=0\r\n"
"o=- \d+ \d+ IN IP4 203.0.113.1\r\n"
"s=rtpengine.*?\r\n"
"s=foobar\r\n"
"t=0 0\r\n"
"m=audio \d+ UDP/TLS/RTP/SAVPF 8\r\n"
"c=IN IP4 203.0.113.1\r\n"
@ -3153,7 +3153,7 @@ class TestVideoroom(unittest.TestCase):
match_re = re.compile(
"^v=0\r\n"
"o=- \d+ \d+ IN IP4 203.0.113.1\r\n"
"s=rtpengine.*?\r\n"
"s=foobar\r\n"
"t=0 0\r\n"
"m=audio (\d+) RTP/AVP 96\r\n"
"c=IN IP4 203.0.113.1\r\n"

@ -1555,7 +1555,7 @@ SDP
subscribe_request('AMR asymmetric', {flags => [qw/SIPREC all/]}, <<SDP);
v=0
o=- SDP_VERSION IN IP4 203.0.113.1
s=RTPE_VERSION
s=-
t=0 0
m=audio PORT RTP/AVP 96 98
c=IN IP4 203.0.113.1

Loading…
Cancel
Save