From 9a65ab03352806aba4b4fe0097ec046f51381011 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Thu, 12 Mar 2026 14:24:54 -0400 Subject: [PATCH] MT#55283 parse a=label This is needed to correctly print media labels for SIPREC in case the input SDPs already had media labels. Change-Id: I021f44ba28a3648ceb62db12425ddf545de42a96 --- daemon/call.c | 11 +++++++++++ daemon/sdp.c | 11 ++++++++++- include/call.h | 1 + t/auto-daemon-tests.pl | 5 +++-- 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/daemon/call.c b/daemon/call.c index 1a7bb9413..fa3429a54 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -2866,6 +2866,15 @@ static void media_set_siprec_label(struct call_media *media, sdp_ng_flags *flags media->label = call_str_cpy_c(buf); } +__attribute__((nonnull(1, 2))) +static void media_update_label(struct call_media *media, sdp_ng_flags *flags, const str *label) +{ + if (flags->siprec) // we generate our own + return; + + media->label = call_str_cpy(label); +} + __attribute__((nonnull(1))) static unsigned int media_bundle_extmap_id(struct call_media *media) { __auto_type ml = media->monologue; @@ -3877,6 +3886,7 @@ int monologue_offer_answer(struct call_monologue *monologues[2], sdp_streams_q * } else media_answer_media_id(sender_media, sp); + media_update_label(receiver_media, flags, &sp->label); media_loop_protect(sp, sender_media); media_update_flags(sender_media, sp); media_update_crypto(sender_media, sp, flags); @@ -4420,6 +4430,7 @@ static int monologue_subscribe_request1(struct call_media *src_media, struct cal media_set_echo(src_media, flags); media_set_echo_reverse(dst_media, flags); media_set_siprec_label(dst_media, flags, src_media->unique_id); + media_update_label(dst_media, flags, &src_media->label); media_update_type(dst_media, sp); media_set_protocol(dst_media, src_media, sp, flags); media_gen_media_id(dst_media, flags); diff --git a/daemon/sdp.c b/daemon/sdp.c index 4e4d60de8..705d23b63 100644 --- a/daemon/sdp.c +++ b/daemon/sdp.c @@ -68,6 +68,7 @@ enum attr_id { ATTR_MOH_ATTR_NAME, ATTR_EXTMAP, ATTR_EXTMAP_ALLOW_MIXED, + ATTR_LABEL, }; // make sure g_direct_hash can be used static_assert(sizeof(void *) >= sizeof(enum attr_id), "sizeof enum attr_id wrong"); @@ -1331,6 +1332,9 @@ static bool parse_attribute(struct sdp_attribute *a) { case CSH_LOOKUP("maxptime"): a->attr = ATTR_MAXPTIME; break; + case CSH_LOOKUP("label"): + a->attr = ATTR_LABEL; + break; default: /* check moh-attr-name (can be a variable attribute value) */ if (rtpe_config.moh_attr_name && !str_cmp(&a->strs.name, rtpe_config.moh_attr_name)) @@ -2166,6 +2170,11 @@ bool sdp_streams(const sdp_sessions_q *sessions, sdp_streams_q *streams, sdp_ng_ if (attr) sp->media_id = attr->strs.value; + // a=label + attr = attr_get_by_id(&media->attributes, ATTR_LABEL); + if (attr) + sp->label = attr->strs.value; + // be ignorant about the contents if (attr_get_by_id(&media->attributes, ATTR_RTCP_FB)) SP_SET(sp, RTCP_FB); @@ -2919,7 +2928,7 @@ static void print_sdp_media_section(GString *s, struct call_media *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) + if (media->label.len) append_attr_to_gstring(s, "label", &media->label, flags, media->type_id); if (media->bundle && MEDIA_ISSET(media, BUNDLE_ONLY) && flags->opmode == OP_OFFER && media->bundle != media) diff --git a/include/call.h b/include/call.h index 2b04997eb..744441c44 100644 --- a/include/call.h +++ b/include/call.h @@ -385,6 +385,7 @@ struct stream_params { struct session_bandwidth media_session_bandiwdth; str sdp_information; extmap_q extmap; + str label; }; struct endpoint_map { diff --git a/t/auto-daemon-tests.pl b/t/auto-daemon-tests.pl index ebe746cf3..62c42b12c 100755 --- a/t/auto-daemon-tests.pl +++ b/t/auto-daemon-tests.pl @@ -5884,6 +5884,7 @@ m=video PORT RTP/AVP 99 97 126 123 c=IN IP6 2001:db8:4321::1 b=TIAS:5952000 a=mid:2 +a=label:11 a=rtpmap:99 H265/90000 a=fmtp:99 level-id=90;max-lsr=125337600;max-lps=2088960;max-tr=22;max-tc=20;max-fps=6000;x-cisco-hevc=529 a=rtpmap:97 H264/90000 @@ -5898,7 +5899,6 @@ a=rtcp-fb:* ccm pan a=rtcp-fb:* nack pli a=rtcp-fb:* ccm fir a=rtcp-fb:* ccm tmmbr -a=label:11 a=answer:full a=cisco-mari-psre:97 ltrf=3 a=cisco-mari-psre:126 ltrf=3 @@ -6355,6 +6355,7 @@ m=video 0 RTP/AVP 99 97 126 123 c=IN IP6 :: b=TIAS:5952000 a=mid:2 +a=label:11 m=application 0 RTP/SAVP 96 c=IN IP4 0.0.0.0 a=mid:5 @@ -26304,6 +26305,7 @@ t=0 0 m=audio PORT RTP/AVP 104 9 103 111 8 101 c=IN IP4 203.0.113.1 a=mid:1 +a=label:main-audio a=rtpmap:104 SILK/16000 a=rtpmap:9 G722/8000 a=rtpmap:103 SILK/8000 @@ -26312,7 +26314,6 @@ a=fmtp:111 bitrate=16000 a=rtpmap:8 PCMA/8000 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-16 -a=label:main-audio a=sendrecv a=rtcp:PORT a=ptime:20