MT#56465 sdp_create(), set the origin attr including name

Always ensure to set the origin name properly when
creating SDP using `sdp_create()`.

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

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

Change-Id: I671f7b54f8bed9c4b78d6532c0072836d77173e6
pull/1826/head
Donat Zenichev 2 years ago
parent 2f24609a7b
commit 282b4490e8

@ -3368,6 +3368,41 @@ error:
return -1; return -1;
} }
static void sdp_out_add_origin(GString *out, struct call_monologue *monologue,
struct packet_stream *first_ps, sdp_ng_flags *flags)
{
const char * origin_address;
const char * origin_address_type;
/* init session params */
if (!monologue->sdp_session_id)
monologue->sdp_session_id = (unsigned long long) rtpe_now.tv_sec << 32 | rtpe_now.tv_usec;
if (!monologue->sdp_version)
monologue->sdp_version = monologue->sdp_session_id;
origin_address = sockaddr_print_buf(&first_ps->selected_sfd->local_intf->advertised_address.addr);
origin_address_type = first_ps->selected_sfd->local_intf->advertised_address.addr.family->rfc_name;
/* replace origin */
if (flags->media_address.s && is_addr_unspecified(&flags->parsed_media_address))
__parse_address(&flags->parsed_media_address, NULL, NULL, &flags->media_address);
if (flags->session_sdp_orig.parsed &&
flags->replace_origin &&
flags->ice_option != ICE_FORCE_RELAY &&
!is_addr_unspecified(&flags->parsed_media_address))
{
origin_address = sockaddr_print_buf(&flags->parsed_media_address);
}
g_string_append_printf(out,
"o=%s %llu %llu IN %s %s\r\n",
(monologue->sdp_username ? : "-"), /* just set a dash if still absent */
monologue->sdp_session_id,
monologue->sdp_version,
origin_address_type,
origin_address);
}
int sdp_create(str *out, struct call_monologue *monologue, sdp_ng_flags *flags) { int sdp_create(str *out, struct call_monologue *monologue, sdp_ng_flags *flags) {
const char *err = NULL; const char *err = NULL;
GString *s = NULL; GString *s = NULL;
@ -3386,17 +3421,11 @@ int sdp_create(str *out, struct call_monologue *monologue, sdp_ng_flags *flags)
if (!first_ps->selected_sfd) if (!first_ps->selected_sfd)
goto err; goto err;
s = g_string_new("v=0\r\no=- "); /* init new sdp */
s = g_string_new("v=0\r\n");
// init session params
if (!monologue->sdp_session_id)
monologue->sdp_session_id = (unsigned long long) rtpe_now.tv_sec << 32 | rtpe_now.tv_usec;
if (!monologue->sdp_version)
monologue->sdp_version = monologue->sdp_session_id;
g_string_append_printf(s, "%llu %llu IN %s %s\r\n", monologue->sdp_session_id, monologue->sdp_version, /* add origin including name and version */
first_ps->selected_sfd->local_intf->advertised_address.addr.family->rfc_name, sdp_out_add_origin(s, monologue, first_ps, flags);
sockaddr_print_buf(&first_ps->selected_sfd->local_intf->advertised_address.addr));
g_string_append_printf(s, "s=%s\r\n", rtpe_config.software_id); g_string_append_printf(s, "s=%s\r\n", rtpe_config.software_id);
g_string_append(s, "t=0 0\r\n"); g_string_append(s, "t=0 0\r\n");

@ -537,7 +537,7 @@ class TestVideoroom(unittest.TestCase):
sdp, sdp,
re.compile( re.compile(
"^v=0\r\n" "^v=0\r\n"
"o=- \d+ \d+ IN IP4 203.0.113.1\r\n" "o=x \d+ \d+ IN IP4 203.0.113.1\r\n"
"s=rtpengine.*?\r\n" "s=rtpengine.*?\r\n"
"t=0 0\r\n" "t=0 0\r\n"
"m=audio \d+ RTP/AVP 8\r\n" "m=audio \d+ RTP/AVP 8\r\n"
@ -822,7 +822,7 @@ class TestVideoroom(unittest.TestCase):
sdp, sdp,
re.compile( re.compile(
"^v=0\r\n" "^v=0\r\n"
"o=- \d+ \d+ IN IP4 203.0.113.1\r\n" "o=x \d+ \d+ IN IP4 203.0.113.1\r\n"
"s=rtpengine.*?\r\n" "s=rtpengine.*?\r\n"
"t=0 0\r\n" "t=0 0\r\n"
"m=audio \d+ RTP/AVP 8\r\n" "m=audio \d+ RTP/AVP 8\r\n"
@ -1088,7 +1088,7 @@ class TestVideoroom(unittest.TestCase):
sdp, sdp,
re.compile( re.compile(
"^v=0\r\n" "^v=0\r\n"
"o=- \d+ \d+ IN IP4 203.0.113.1\r\n" "o=x \d+ \d+ IN IP4 203.0.113.1\r\n"
"s=rtpengine.*?\r\n" "s=rtpengine.*?\r\n"
"t=0 0\r\n" "t=0 0\r\n"
"m=audio \d+ RTP/SAVP 8\r\n" "m=audio \d+ RTP/SAVP 8\r\n"
@ -1187,7 +1187,7 @@ class TestVideoroom(unittest.TestCase):
sdp, sdp,
re.compile( re.compile(
"^v=0\r\n" "^v=0\r\n"
"o=- \d+ \d+ IN IP4 203.0.113.1\r\n" "o=x \d+ \d+ IN IP4 203.0.113.1\r\n"
"s=rtpengine.*?\r\n" "s=rtpengine.*?\r\n"
"t=0 0\r\n" "t=0 0\r\n"
"m=audio \d+ RTP/SAVP 8\r\n" "m=audio \d+ RTP/SAVP 8\r\n"
@ -1283,7 +1283,7 @@ class TestVideoroom(unittest.TestCase):
sdp, sdp,
re.compile( re.compile(
"^v=0\r\n" "^v=0\r\n"
"o=- \d+ \d+ IN IP4 203.0.113.1\r\n" "o=x \d+ \d+ IN IP4 203.0.113.1\r\n"
"s=rtpengine.*?\r\n" "s=rtpengine.*?\r\n"
"t=0 0\r\n" "t=0 0\r\n"
"m=audio \d+ UDP/TLS/RTP/SAVPF 8\r\n" "m=audio \d+ UDP/TLS/RTP/SAVPF 8\r\n"
@ -1378,7 +1378,7 @@ class TestVideoroom(unittest.TestCase):
self.assertIsInstance(sdp, str) self.assertIsInstance(sdp, str)
match_re = re.compile( match_re = re.compile(
"^v=0\r\n" "^v=0\r\n"
"o=- \d+ \d+ IN IP4 203.0.113.1\r\n" "o=x \d+ \d+ IN IP4 203.0.113.1\r\n"
"s=rtpengine.*?\r\n" "s=rtpengine.*?\r\n"
"t=0 0\r\n" "t=0 0\r\n"
"m=audio (\d+) RTP/AVP 8\r\n" "m=audio (\d+) RTP/AVP 8\r\n"
@ -1905,7 +1905,7 @@ class TestVideoroom(unittest.TestCase):
sdp, sdp,
re.compile( re.compile(
"^v=0\r\n" "^v=0\r\n"
"o=- \d+ \d+ IN IP4 203.0.113.1\r\n" "o=x \d+ \d+ IN IP4 203.0.113.1\r\n"
"s=rtpengine.*?\r\n" "s=rtpengine.*?\r\n"
"t=0 0\r\n" "t=0 0\r\n"
"m=audio \d+ RTP/AVP 8\r\n" "m=audio \d+ RTP/AVP 8\r\n"
@ -2630,7 +2630,7 @@ class TestVideoroom(unittest.TestCase):
match_re = re.compile( match_re = re.compile(
"^v=0\r\n" "^v=0\r\n"
"o=- \d+ \d+ IN IP4 203.0.113.1\r\n" "o=x \d+ \d+ IN IP4 203.0.113.1\r\n"
"s=rtpengine.*?\r\n" "s=rtpengine.*?\r\n"
"t=0 0\r\n" "t=0 0\r\n"
"m=audio (\d+) RTP/AVP 96\r\n" "m=audio (\d+) RTP/AVP 96\r\n"
@ -2754,7 +2754,7 @@ class TestVideoroom(unittest.TestCase):
match_re = re.compile( match_re = re.compile(
"^v=0\r\n" "^v=0\r\n"
"o=- \d+ \d+ IN IP4 203.0.113.1\r\n" "o=x \d+ \d+ IN IP4 203.0.113.1\r\n"
"s=rtpengine.*?\r\n" "s=rtpengine.*?\r\n"
"t=0 0\r\n" "t=0 0\r\n"
"m=audio (\d+) RTP/AVP 96\r\n" "m=audio (\d+) RTP/AVP 96\r\n"
@ -3003,7 +3003,7 @@ class TestVideoroom(unittest.TestCase):
match_re = re.compile( match_re = re.compile(
"^v=0\r\n" "^v=0\r\n"
"o=- \d+ \d+ IN IP4 203.0.113.1\r\n" "o=x \d+ \d+ IN IP4 203.0.113.1\r\n"
"s=rtpengine.*?\r\n" "s=rtpengine.*?\r\n"
"t=0 0\r\n" "t=0 0\r\n"
"m=audio (\d+) RTP/AVP 96\r\n" "m=audio (\d+) RTP/AVP 96\r\n"

Loading…
Cancel
Save