From fc49671d7f2d173abe63d141b7ca2a93aed4499b 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 (cherry picked from commit 9a65ab03352806aba4b4fe0097ec046f51381011) (cherry picked from commit fbc54a8d3a1f7b34da3888fa0b05eed18f1d5d76) --- daemon/call.c | 13 ++++++++++++- daemon/sdp.c | 11 ++++++++++- include/call.h | 1 + t/auto-daemon-tests.pl | 5 +++-- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/daemon/call.c b/daemon/call.c index 0802cf77f..09cfac182 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -2861,6 +2861,15 @@ static void __update_media_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); +} + // `media` can be NULL __attribute__((nonnull(1, 3, 4))) static void __media_init_from_flags(struct call_media *other_media, struct call_media *media, @@ -2923,8 +2932,10 @@ static void __media_init_from_flags(struct call_media *other_media, struct call_ break; } - if (media) + if (media) { __update_media_label(media, flags, other_media->unique_id); + media_update_label(media, flags, &sp->label); + } __update_media_protocol(media, other_media, sp, flags); __update_media_id(media, other_media, sp, flags); __endpoint_loop_protect(sp, other_media); diff --git a/daemon/sdp.c b/daemon/sdp.c index 44c9a32ac..6b2e156e0 100644 --- a/daemon/sdp.c +++ b/daemon/sdp.c @@ -66,6 +66,7 @@ enum attr_id { ATTR_TLS_ID, ATTR_END_OF_CANDIDATES, ATTR_MOH_ATTR_NAME, + ATTR_LABEL, }; // make sure g_direct_hash can be used static_assert(sizeof(void *) >= sizeof(enum attr_id), "sizeof enum attr_id wrong"); @@ -1219,6 +1220,9 @@ static int 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)) @@ -2002,6 +2006,11 @@ int sdp_streams(const sdp_sessions_q *sessions, sdp_streams_q *streams, sdp_ng_f 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); @@ -2717,7 +2726,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); /* nothing more to be printed for inactive stream (non-accepted media session) */ diff --git a/include/call.h b/include/call.h index 7711123cf..8aba1f338 100644 --- a/include/call.h +++ b/include/call.h @@ -378,6 +378,7 @@ struct stream_params { int media_sdp_id; struct session_bandwidth media_session_bandiwdth; str sdp_information; + str label; }; struct endpoint_map { diff --git a/t/auto-daemon-tests.pl b/t/auto-daemon-tests.pl index ae12f8a59..9b20df508 100755 --- a/t/auto-daemon-tests.pl +++ b/t/auto-daemon-tests.pl @@ -4455,6 +4455,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 @@ -4467,7 +4468,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=extmap:4 http://protocols.cisco.com/timestamp#100us a=cisco-mari-psre:97 ltrf=3 @@ -4926,6 +4926,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 @@ -24810,6 +24811,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 @@ -24818,7 +24820,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