Skip to content

Commit 08cdc65

Browse files
committed
MT#60693 add accepted legacy OSRTP for sdp_create()
Add support for accepted legacy OSRTP. This must be used then in the sdp_create(). Change-Id: I627f88b844cc32e3884b3c6ae14e8a6977d0ce1c
1 parent 2ddbeda commit 08cdc65

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

daemon/sdp.c

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3651,6 +3651,19 @@ static void sdp_out_add_media_connection(GString *out, struct call_media *media,
36513651
media_conn_address);
36523652
}
36533653

3654+
static void sdp_out_add_osrtp_media(GString *out, struct call_media *media,
3655+
const struct transport_protocol *prtp, unsigned int port)
3656+
{
3657+
g_string_append_printf(out, "m=" STR_FORMAT " %d %s ",
3658+
STR_FMT(&media->type),
3659+
port,
3660+
prtp->name);
3661+
3662+
/* print codecs and add newline */
3663+
print_codec_list(out, media);
3664+
g_string_append_printf(out, "\r\n");
3665+
}
3666+
36543667
/**
36553668
* TODO: after sdp_replace() is deprecated, move the content of this func
36563669
* to `print_sdp_media_section()`.
@@ -3683,6 +3696,7 @@ int sdp_create(str *out, struct call_monologue *monologue, sdp_ng_flags *flags)
36833696
{
36843697
const char *err = NULL;
36853698
GString *s = NULL;
3699+
const struct transport_protocol *prtp = NULL;
36863700

36873701
err = "Need at least one media";
36883702
if (!monologue->medias->len)
@@ -3741,6 +3755,25 @@ int sdp_create(str *out, struct call_monologue *monologue, sdp_ng_flags *flags)
37413755
if (!rtp_ps->selected_sfd)
37423756
goto err;
37433757

3758+
prtp = NULL;
3759+
if (media->protocol && media->protocol->srtp)
3760+
prtp = &transport_protocols[media->protocol->rtp_proto];
3761+
3762+
if (prtp) {
3763+
if (MEDIA_ISSET(media, LEGACY_OSRTP) && !MEDIA_ISSET(media, LEGACY_OSRTP_REV))
3764+
/* generate rejected m= line for accepted legacy OSRTP */
3765+
sdp_out_add_osrtp_media(s, media, prtp, 0);
3766+
else if(flags->osrtp_offer_legacy && (flags->opmode == OP_OFFER || flags->opmode == OP_REQUEST)) {
3767+
const struct transport_protocol *proto = media->protocol;
3768+
media->protocol = prtp;
3769+
3770+
sdp_out_add_osrtp_media(s, media, prtp, rtp_ps->selected_sfd->socket.local.port);
3771+
handle_sdp_media_attributes(s, media, rtp_ps, rtp_ps_link, flags);
3772+
3773+
media->protocol = proto;
3774+
}
3775+
}
3776+
37443777
/* set: media type, port, protocol (e.g. RTP/SAVP) */
37453778
err = "Unknown media protocol";
37463779
if (media->protocol)
@@ -3761,6 +3794,10 @@ int sdp_create(str *out, struct call_monologue *monologue, sdp_ng_flags *flags)
37613794
g_string_append_printf(s, "\r\n");
37623795

37633796
handle_sdp_media_attributes(s, media, rtp_ps, rtp_ps_link, flags);
3797+
3798+
if (prtp && MEDIA_ISSET(media, LEGACY_OSRTP) && MEDIA_ISSET(media, LEGACY_OSRTP_REV))
3799+
/* generate rejected m= line for accepted legacy OSRTP */
3800+
sdp_out_add_osrtp_media(s, media, prtp, 0);
37643801
}
37653802

37663803
/* The SDP version gets increased in case:

0 commit comments

Comments
 (0)