Skip to content

Commit

Permalink
MT#60693 add accepted legacy OSRTP for sdp_create()
Browse files Browse the repository at this point in the history
Add support for accepted legacy OSRTP.
This must be used then in the sdp_create().

Change-Id: I627f88b844cc32e3884b3c6ae14e8a6977d0ce1c
  • Loading branch information
zenichev committed Sep 4, 2024
1 parent 2ddbeda commit 08cdc65
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions daemon/sdp.c
Original file line number Diff line number Diff line change
Expand Up @@ -3651,6 +3651,19 @@ static void sdp_out_add_media_connection(GString *out, struct call_media *media,
media_conn_address);
}

static void sdp_out_add_osrtp_media(GString *out, struct call_media *media,
const struct transport_protocol *prtp, unsigned int port)
{
g_string_append_printf(out, "m=" STR_FORMAT " %d %s ",
STR_FMT(&media->type),
port,
prtp->name);

/* print codecs and add newline */
print_codec_list(out, media);
g_string_append_printf(out, "\r\n");
}

/**
* TODO: after sdp_replace() is deprecated, move the content of this func
* to `print_sdp_media_section()`.
Expand Down Expand Up @@ -3683,6 +3696,7 @@ int sdp_create(str *out, struct call_monologue *monologue, sdp_ng_flags *flags)
{
const char *err = NULL;
GString *s = NULL;
const struct transport_protocol *prtp = NULL;

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

prtp = NULL;
if (media->protocol && media->protocol->srtp)
prtp = &transport_protocols[media->protocol->rtp_proto];

if (prtp) {
if (MEDIA_ISSET(media, LEGACY_OSRTP) && !MEDIA_ISSET(media, LEGACY_OSRTP_REV))
/* generate rejected m= line for accepted legacy OSRTP */
sdp_out_add_osrtp_media(s, media, prtp, 0);
else if(flags->osrtp_offer_legacy && (flags->opmode == OP_OFFER || flags->opmode == OP_REQUEST)) {
const struct transport_protocol *proto = media->protocol;
media->protocol = prtp;

sdp_out_add_osrtp_media(s, media, prtp, rtp_ps->selected_sfd->socket.local.port);
handle_sdp_media_attributes(s, media, rtp_ps, rtp_ps_link, flags);

media->protocol = proto;
}
}

/* set: media type, port, protocol (e.g. RTP/SAVP) */
err = "Unknown media protocol";
if (media->protocol)
Expand All @@ -3761,6 +3794,10 @@ int sdp_create(str *out, struct call_monologue *monologue, sdp_ng_flags *flags)
g_string_append_printf(s, "\r\n");

handle_sdp_media_attributes(s, media, rtp_ps, rtp_ps_link, flags);

if (prtp && MEDIA_ISSET(media, LEGACY_OSRTP) && MEDIA_ISSET(media, LEGACY_OSRTP_REV))
/* generate rejected m= line for accepted legacy OSRTP */
sdp_out_add_osrtp_media(s, media, prtp, 0);
}

/* The SDP version gets increased in case:
Expand Down

0 comments on commit 08cdc65

Please sign in to comment.