diff --git a/daemon/codec.c b/daemon/codec.c index a12d09fee..15567d4b4 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -739,6 +739,8 @@ static void __reset_sequencer(void *p, void *dummy) { if (s->sequencers) g_hash_table_destroy(s->sequencers); s->sequencers = NULL; + s->media_cache = NULL; + s->sequencer_cache = NULL; } static bool __make_transcoder_full(struct codec_handler *handler, rtp_payload_type *dest, GHashTable *output_transcoders, int dtmf_payload_type, bool pcm_dtmf_detect, @@ -2200,11 +2202,17 @@ static int __handler_func_sequencer(struct media_packet *mp, struct transcode_pa // get sequencer appropriate for our output if (!ssrc_in->sequencers) ssrc_in->sequencers = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, __seq_free); - packet_sequencer_t *seq = g_hash_table_lookup(ssrc_in->sequencers, mp->media_out); + packet_sequencer_t *seq; + if (mp->media_out == ssrc_in->media_cache) + seq = ssrc_in->sequencer_cache; + else + seq = g_hash_table_lookup(ssrc_in->sequencers, mp->media_out); if (!seq) { seq = g_new0(__typeof(*seq), 1); packet_sequencer_init(seq, (GDestroyNotify) __transcode_packet_free); g_hash_table_insert(ssrc_in->sequencers, mp->media_out, seq); + ssrc_in->media_cache = mp->media_out; + ssrc_in->sequencer_cache = seq; // this is a quick fix to restore sequencer values until upper layer behavior will be fixed unsigned int stats_ext_seq = atomic_get_na(&ssrc_in->stats->ext_seq); if(stats_ext_seq) { diff --git a/include/ssrc.h b/include/ssrc.h index b499f98a2..25a09e287 100644 --- a/include/ssrc.h +++ b/include/ssrc.h @@ -99,6 +99,8 @@ struct ssrc_entry_call { // for transcoding // input only GHashTable *sequencers; + packet_sequencer_t *sequencer_cache; // to skip hash lookup + struct call_media *media_cache; // to skip hash lookup uint32_t jitter, transit; // output only uint16_t seq_diff;