From 9712078a73a6e23f78d2e9c5c0a238c5ca26756a Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Tue, 8 Sep 2026 11:20:20 -0400 Subject: [PATCH] MT#55283 typed rtcp_fb queue Change-Id: Ia31a6e0327a34cb934215aa14407d734d78c2507 --- daemon/codec.c | 8 ++++---- daemon/sdp.c | 20 +++++++++++++------- lib/rtplib.h | 2 +- t/test-transcode.c | 2 +- 4 files changed, 19 insertions(+), 13 deletions(-) diff --git a/daemon/codec.c b/daemon/codec.c index 4c46bfa4a..9c3a38f4e 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -3041,7 +3041,7 @@ void codec_init_payload_type(rtp_payload_type *pt, enum media_type type) { pt->codec_opts = call_str_cpy(&pt->codec_opts); // allocate everything from the rtcp-fb list - for (GList *l = pt->rtcp_fb.head; l; l = l->next) { + for (__auto_type l = pt->rtcp_fb.head; l; l = l->next) { str *fb = l->data; l->data = call_str_dup(fb); } @@ -5245,7 +5245,7 @@ static rtp_payload_type *codec_add_payload_type(const str *codec, struct call_me void payload_type_clear(rtp_payload_type *p) { - g_queue_clear(&p->rtcp_fb); + t_queue_clear(&p->rtcp_fb); ZERO(*p); p->payload_type = -1; } @@ -5266,8 +5266,8 @@ static void rtp_payload_type_copy(rtp_payload_type *dst, const rtp_payload_type *dst = *src; // make shallow copy of lists - g_queue_init(&dst->rtcp_fb); - g_queue_append(&dst->rtcp_fb, &src->rtcp_fb); + t_queue_init(&dst->rtcp_fb); + t_queue_append(&dst->rtcp_fb, &src->rtcp_fb); // duplicate contents codec_init_payload_type(dst, MT_UNKNOWN); diff --git a/daemon/sdp.c b/daemon/sdp.c index 35670fef9..23552c65e 100644 --- a/daemon/sdp.c +++ b/daemon/sdp.c @@ -1594,6 +1594,8 @@ static int fill_endpoint(struct endpoint *ep, const struct sdp_media *media, sdp } +TYPED_GHASHTABLE(rtcp_fb_ht, void, str_q, g_direct_hash, g_direct_equal, NULL, str_q_free); + static bool __rtp_payload_types(struct stream_params *sp, struct sdp_media *media) { @@ -1622,7 +1624,7 @@ static bool __rtp_payload_types(struct stream_params *sp, struct sdp_media *medi &attr->fmtp.format_parms_str); } // do the same for a=rtcp-fb - g_autoptr(GHashTable) ht_rtcp_fb = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, (GDestroyNotify) g_queue_free); + g_auto(rtcp_fb_ht) ht_rtcp_fb = rtcp_fb_ht_new(); q = attr_list_get_by_id(&media->attributes, ATTR_RTCP_FB); for (__auto_type ql = q ? q->head : NULL; ql; ql = ql->next) { attr = ql->data; @@ -1631,8 +1633,12 @@ static bool __rtp_payload_types(struct stream_params *sp, struct sdp_media *medi struct sdp_attr *ac = sdp_attr_dup(attr); t_queue_push_tail(&sp->generic_attributes, ac); } - GQueue *rq = g_hash_table_lookup_queue_new(ht_rtcp_fb, GINT_TO_POINTER(attr->rtcp_fb.payload_type), NULL); - g_queue_push_tail(rq, &attr->rtcp_fb.value); + str_q *rq = t_hash_table_lookup(ht_rtcp_fb, GINT_TO_POINTER(attr->rtcp_fb.payload_type)); + if (!rq) { + rq = str_q_new(); + t_hash_table_insert(ht_rtcp_fb, GINT_TO_POINTER(attr->rtcp_fb.payload_type), rq); + } + t_queue_push_tail(rq, &attr->rtcp_fb.value); } /* then go through the format list and associate */ @@ -1666,12 +1672,12 @@ static bool __rtp_payload_types(struct stream_params *sp, struct sdp_media *medi pt->format_parameters = *s; else pt->format_parameters = STR_EMPTY; - GQueue *rq = g_hash_table_lookup(ht_rtcp_fb, GINT_TO_POINTER(i)); + str_q *rq = t_hash_table_lookup(ht_rtcp_fb, GINT_TO_POINTER(i)); if (rq) { // steal the list contents and free the list pt->rtcp_fb = *rq; - g_queue_init(rq); - g_hash_table_remove(ht_rtcp_fb, GINT_TO_POINTER(i)); // frees `rq` + t_queue_init(rq); + t_hash_table_remove(ht_rtcp_fb, GINT_TO_POINTER(i)); // frees `rq` } // fill in ptime @@ -2292,7 +2298,7 @@ static void insert_codec_parameters(GString *s, struct call_media *cm, &pt->format_parameters, flags, cm->type_id); /* rtcp-fb */ - for (GList *k = pt->rtcp_fb.head; k; k = k->next) { + for (__auto_type k = pt->rtcp_fb.head; k; k = k->next) { str *fb = k->data; append_int_tagged_attr_to_gstring(s, "rtcp-fb", pt->payload_type, fb, flags, cm->type_id); diff --git a/lib/rtplib.h b/lib/rtplib.h index c45216066..fb18da290 100644 --- a/lib/rtplib.h +++ b/lib/rtplib.h @@ -120,7 +120,7 @@ struct rtp_payload_type { unsigned int time_base; // 48000 or 30 str format_parameters; // value of a=fmtp str codec_opts; // extra codec-specific options - GQueue rtcp_fb; // a=rtcp-fb:... + str_q rtcp_fb; // a=rtcp-fb:... int ptime; // default from RFC int bitrate; diff --git a/t/test-transcode.c b/t/test-transcode.c index bcb119c91..11bba0db6 100644 --- a/t/test-transcode.c +++ b/t/test-transcode.c @@ -167,7 +167,7 @@ static void __sdp_pt_fmt(int num, str codec, int clockrate, int channels, str fu .channels = channels, .format_parameters = *fmtdup, .codec_opts = STR_NULL, - .rtcp_fb = G_QUEUE_INIT, + .rtcp_fb = TYPED_GQUEUE_INIT, .ptime = 0, .bitrate = 0, .codec_def = NULL,