From b2774a1a31f0a6b8d5fb158f6df48e86301b655e Mon Sep 17 00:00:00 2001 From: Donat Zenichev Date: Wed, 20 Nov 2024 15:48:04 +0100 Subject: [PATCH] MT#56465 monologue_offer_answer: manipulations refactoring Refactor media level manipulations, no funcitonal change. Just add a separate static function that does all the job to create fictitious (zeroed) media. Change-Id: Ifa39e31cdeaa093710cf8b834e7e08881056212f --- daemon/call.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/daemon/call.c b/daemon/call.c index 4ed5e023b..11208e523 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -2958,6 +2958,25 @@ static void media_update_transcoding_flag(struct call_media *media) { MEDIA_SET(media, TRANSCODING); } +/** + * For handling sdp media level manipulations (media sessions remove). + * This function just adds a fictitious media for this side, pretending it had 0 port. + */ +static struct call_media * monologue_add_zero_media(struct call_monologue *sender_ml, struct stream_params *sp, + unsigned int *num_ports_other, sdp_ng_flags *flags) +{ + struct call_media *sender_media = NULL; + sp->rtp_endpoint.port = 0; /* pretend it was a zero stream */ + sender_media = __get_media(sender_ml, sp, flags, 0); + sender_media->media_sdp_id = sp->media_sdp_id; + __media_init_from_flags(sender_media, NULL, sp, flags); + *num_ports_other = proto_num_ports(sp->num_ports, sender_media, flags, + (flags->rtcp_mux_demux || flags->rtcp_mux_accept) ? true : false); + __disable_streams(sender_media, *num_ports_other); + __init_interface(sender_media, &sp->direction[0], *num_ports_other); + return sender_media; +} + /* called with call->master_lock held in W */ int monologue_offer_answer(struct call_monologue *monologues[2], sdp_streams_q *streams, sdp_ng_flags *flags) @@ -2996,22 +3015,13 @@ int monologue_offer_answer(struct call_monologue *monologues[2], sdp_streams_q * * This affects later the sequencing of medias, e.g. for subscribe requests. */ - /* TODO: refactor this into something more good looking code */ + /* handling of media sessions level manipulations (media sessions remove) */ if (flags->sdp_media_remove[sp->type_id]) { - sp->rtp_endpoint.port = 0; /* pretend it was a zero stream */ - sender_media = __get_media(sender_ml, sp, flags, 0); - sender_media->media_sdp_id = sp->media_sdp_id; - __media_init_from_flags(sender_media, NULL, sp, flags); - num_ports_other = proto_num_ports(sp->num_ports, sender_media, flags, - (flags->rtcp_mux_demux || flags->rtcp_mux_accept) ? true : false); - __disable_streams(sender_media, num_ports_other); + sender_media = monologue_add_zero_media(sender_ml, sp, &num_ports_other, flags); medias_offset++; - __init_interface(sender_media, &sp->direction[0], num_ports_other); - - if (sender_media->logical_intf == NULL) { + if (sender_media->logical_intf == NULL) goto error_intf; - } ilog(LOG_DEBUG, "Media type '"STR_FORMAT"' is to be removed by SDP manipulations.", STR_FMT(&sp->type)); continue;