From 72416e074a159c4c3756ae6ea04da999a74b67ec Mon Sep 17 00:00:00 2001 From: Donat Zenichev Date: Tue, 1 Oct 2024 17:25:47 +0200 Subject: [PATCH] MT#60476 print_sdp_media_section: refactor inactive streams Refactor inactive streams handling (non-accepted media) so, that they get also labels being printed. Change-Id: I6627aba77a5f391f797762202eb4f0977bc0fc4a --- daemon/sdp.c | 26 ++++++++++---------------- t/auto-daemon-tests.pl | 1 + 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/daemon/sdp.c b/daemon/sdp.c index 106beee56..6421bc8ea 100644 --- a/daemon/sdp.c +++ b/daemon/sdp.c @@ -2630,7 +2630,9 @@ static void print_sdp_media_section(GString *s, struct call_media *media, struct packet_stream *rtp_ps, packet_stream_list *rtp_ps_link, sdp_ng_flags *flags) { + struct call_monologue *monologue = media->monologue; struct packet_stream *ps_rtcp = NULL; + bool inactive_media = (!address || !address->port || !rtp_ps->selected_sfd); /* audio is accepted? */ if (source_media) { /* just print out all original values and attributes */ @@ -2638,31 +2640,23 @@ static void print_sdp_media_section(GString *s, struct call_media *media, return; } - /* add attributes and connection information only when audio is accepted */ - if (!address || !address->port || !rtp_ps->selected_sfd) { - /* print zeroed address for the non accepted media, see RFC 3264 */ - sdp_out_add_media_connection(s, media, rtp_ps, NULL, flags); - - /* just add the mid before finalizing (see #1361 and #1362). */ - if (media->media_id.s) - append_attr_to_gstring(s, "mid", &media->media_id, flags, media->type_id); - - return; - } - - struct call_monologue *monologue = media->monologue; - - /* add actual media connection */ - sdp_out_add_media_connection(s, media, rtp_ps, &address->address, flags); + /* add actual media connection + * print zeroed address for the non accepted media, see RFC 3264 */ + sdp_out_add_media_connection(s, media, rtp_ps, (inactive_media ? NULL : &address->address), flags); /* add per media bandwidth */ sdp_out_add_bandwidth(s, monologue, media); + /* mid and label must be added even for inactive streams (see #1361 and #1362). */ if (media->media_id.s) append_attr_to_gstring(s, "mid", &media->media_id, flags, media->type_id); if (media->label.len && flags->siprec) append_attr_to_gstring(s, "label", &media->label, flags, media->type_id); + /* nothing more to be printed for inactive stream (non-accepted media session) */ + if (inactive_media) + return; + if (proto_is_rtp(media->protocol)) insert_codec_parameters(s, media, flags); diff --git a/t/auto-daemon-tests.pl b/t/auto-daemon-tests.pl index 19b02affa..1ddd424e4 100755 --- a/t/auto-daemon-tests.pl +++ b/t/auto-daemon-tests.pl @@ -648,6 +648,7 @@ a=rtcp:PORT a=ptime:20 m=video 0 RTP/AVP 99 97 126 123 c=IN IP6 :: +b=TIAS:5952000 a=mid:2 m=application 0 RTP/SAVP 96 c=IN IP4 0.0.0.0