From 96cb2e8f732988a0f8b7b7caf15df5773be661af Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Mon, 15 Jan 2024 11:19:59 -0500 Subject: [PATCH] MT#55283 distinguish between lookup and creation While processing SDPs, we only need to look up manipulation instructions, which means we can just return NULL if none were given, instead of always creating the object. Change-Id: If187c1289eb385b23b86b3aa326634efaf0ce5ad --- include/call_interfaces.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/include/call_interfaces.h b/include/call_interfaces.h index eb0b8a76c..0b509b284 100644 --- a/include/call_interfaces.h +++ b/include/call_interfaces.h @@ -264,21 +264,25 @@ int call_interfaces_init(void); void call_interfaces_free(void); void call_interfaces_timer(void); -INLINE struct sdp_manipulations *sdp_manipulations_get_by_id(sdp_ng_flags *f, enum media_type id) { +INLINE struct sdp_manipulations *sdp_manipulations_get_by_id(const sdp_ng_flags *f, enum media_type id) { + if (id < 0 || id >= G_N_ELEMENTS(f->sdp_manipulations)) + return NULL; + return f->sdp_manipulations[id]; +} +INLINE struct sdp_manipulations *sdp_manipulations_get_create_by_id(sdp_ng_flags *f, enum media_type id) { if (id < 0 || id >= G_N_ELEMENTS(f->sdp_manipulations)) return NULL; if (!f->sdp_manipulations[id]) f->sdp_manipulations[id] = g_slice_alloc0(sizeof(*f->sdp_manipulations[id])); return f->sdp_manipulations[id]; } - INLINE struct sdp_manipulations *sdp_manipulations_get_by_name(sdp_ng_flags *f, const str *s) { if (!str_cmp(s, "none") || !str_cmp(s, "global")) - return sdp_manipulations_get_by_id(f, MT_UNKNOWN); + return sdp_manipulations_get_create_by_id(f, MT_UNKNOWN); enum media_type id = codec_get_type(s); if (id == MT_OTHER) return NULL; - return sdp_manipulations_get_by_id(f, id); + return sdp_manipulations_get_create_by_id(f, id); }