diff --git a/daemon/call.c b/daemon/call.c index 4277d028d..5ff820381 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -668,6 +668,14 @@ static struct rtp_extension *call_media_ext_lookup_ht(struct call_media *m, unsi } +static const struct extmap_ops extmap_ops_short = { + .lookup = call_media_ext_lookup_array, +}; +static const struct extmap_ops extmap_ops_long = { + .lookup = call_media_ext_lookup_ht, +}; + + struct call_media *call_media_new(call_t *call) { struct call_media *med; med = uid_alloc(&call->medias); @@ -683,7 +691,7 @@ struct call_media *call_media_new(call_t *call) { ssrc_hash_call_init(&med->ssrc_hash_out); med->extmap_ht = extmap_ht_new(); med->ext_name_ht = ext_name_ht_new(); - med->extmap_lookup = call_media_ext_lookup_array; + med->extmap_ops = &extmap_ops_short; return med; } @@ -2867,7 +2875,7 @@ static void media_reset_extmap(struct call_media *media, { // reset basic table memset(media->extmap_a, 0, sizeof(media->extmap_a)); - media->extmap_lookup = call_media_ext_lookup_array; + media->extmap_ops = &extmap_ops_short; if (!exclude) { // shortcut, reset everything @@ -2889,7 +2897,7 @@ static void media_reset_extmap(struct call_media *media, if (ext->id > 0 && ext->id <= 14) media->extmap_a[ext->id - 1] = ext; else - media->extmap_lookup = call_media_ext_lookup_ht; + media->extmap_ops = &extmap_ops_long; ele = ele->next; continue; @@ -2921,7 +2929,7 @@ static void media_init_extmap(struct call_media *media, struct rtp_extension *ex if (ext->id > 0 && ext->id <= 14) media->extmap_a[ext->id - 1] = ext; else - media->extmap_lookup = call_media_ext_lookup_ht; + media->extmap_ops = &extmap_ops_long; } __attribute__((nonnull(1, 2))) diff --git a/daemon/media_socket.c b/daemon/media_socket.c index d4dffee46..3d1ea3d6f 100644 --- a/daemon/media_socket.c +++ b/daemon/media_socket.c @@ -2395,7 +2395,7 @@ static void media_packet_rtcp_mux(struct packet_handler_ctx *phc, struct sink_ha static void media_packet_rtp_extension(struct packet_handler_ctx *phc, unsigned int id, const str *data) { - __auto_type ext = phc->mp.media->extmap_lookup(phc->mp.media, id); + __auto_type ext = phc->mp.media->extmap_ops->lookup(phc->mp.media, id); if (!ext) return; diff --git a/include/call.h b/include/call.h index 67bb0a129..316ec91b5 100644 --- a/include/call.h +++ b/include/call.h @@ -463,6 +463,12 @@ INLINE int64_t packet_stream_last_packet(const struct packet_stream *ps) { return MAX(lp1, lp2); } + +struct extmap_ops { + struct rtp_extension *(*lookup)(struct call_media *, unsigned int); +}; + + /** * Protected by call->master_lock, except the RO elements. * @@ -488,7 +494,7 @@ struct call_media { extmap_q extmap; // container struct rtp_extension *extmap_a[14]; // 1-14 -> [0..13] extmap_ht extmap_ht; - struct rtp_extension *(*extmap_lookup)(struct call_media *, unsigned int); + const struct extmap_ops *extmap_ops; ext_name_ht ext_name_ht; str media_id; @@ -498,7 +504,7 @@ struct call_media { const struct dtls_hash_func *fp_hash_func; /* outgoing */ str tls_id; candidate_q ice_candidates; /* slice-alloc'd, as received */ - unsigned int media_rec_slot; + unsigned int media_rec_slot; packet_stream_q streams; /* normally RTP + RTCP */ endpoint_map_q endpoint_maps;