diff --git a/daemon/call.c b/daemon/call.c index 9616941a8..954ceaf89 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -2446,14 +2446,14 @@ static void codecs_offer(struct call_media *media, struct call_media *other_medi codec_store_synthesise(&media->codecs, &other_media->codecs); // update supp codecs based on actions so far - codec_tracker_update(&media->codecs); + codec_tracker_update(&media->codecs, &sp->codecs); // set up handlers codec_handlers_update(media, other_media, .flags = flags, .sp = sp, .allow_asymmetric = !!(flags && flags->allow_asymmetric_codecs)); // updating the handlers may have removed some codecs, so run update the supp codecs again - codec_tracker_update(&media->codecs); + codec_tracker_update(&media->codecs, &sp->codecs); // finally set up handlers again based on final results @@ -2506,8 +2506,8 @@ static void codecs_answer(struct call_media *media, struct call_media *other_med .allow_asymmetric = !!flags->allow_asymmetric_codecs); // updating the handlers may have removed some codecs, so run update the supp codecs again - codec_tracker_update(&media->codecs); - codec_tracker_update(&other_media->codecs); + codec_tracker_update(&media->codecs, NULL); + codec_tracker_update(&other_media->codecs, NULL); // finally set up handlers again based on final results diff --git a/daemon/codec.c b/daemon/codec.c index 367f5192d..34f585209 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -4678,7 +4678,7 @@ static int ptr_cmp(const void *a, const void *b) { return 1; return 0; } -void codec_tracker_update(struct codec_store *cs) { +void codec_tracker_update(struct codec_store *cs, struct codec_store *orig_cs) { if (!cs) return; struct codec_tracker *sct = cs->tracker; @@ -4732,7 +4732,23 @@ void codec_tracker_update(struct codec_store *cs) { = g_strdup_printf(STR_FORMAT "/%u", STR_FMT(supp_codec), clockrate); str pt_str = STR_INIT(pt_s); - struct rtp_payload_type *pt = codec_add_payload_type(&pt_str, cs->media, NULL, NULL); + // see if we have a matching PT from before + struct rtp_payload_type *pt = NULL; + if (orig_cs) { + GQueue *ptq = g_hash_table_lookup(orig_cs->codec_names, &pt_str); + if (ptq) { + for (GList *n = ptq->head; n; n = n->next) { + pt = g_hash_table_lookup(orig_cs->codecs, n->data); + if (!pt) + continue; + pt = rtp_payload_type_dup(pt); + break; + } + } + } + + if (!pt) + pt = codec_add_payload_type(&pt_str, cs->media, NULL, NULL); if (!pt) continue; diff --git a/include/codec.h b/include/codec.h index 0a828fb64..03f5264ca 100644 --- a/include/codec.h +++ b/include/codec.h @@ -190,7 +190,7 @@ uint64_t codec_last_dtmf_event(struct codec_ssrc_handler *ch); uint64_t codec_encoder_pts(struct codec_ssrc_handler *ch, struct ssrc_ctx *); void codec_decoder_skip_pts(struct codec_ssrc_handler *ch, uint64_t); uint64_t codec_decoder_unskip_pts(struct codec_ssrc_handler *ch); -void codec_tracker_update(struct codec_store *); +void codec_tracker_update(struct codec_store *, struct codec_store *); void codec_handlers_stop(GQueue *, struct call_media *sink); @@ -229,7 +229,7 @@ INLINE void __codec_handlers_update(struct call_media *receiver, struct call_med { } INLINE void codec_handler_free(struct codec_handler **handler) { } -INLINE void codec_tracker_update(struct codec_store *cs) { } +INLINE void codec_tracker_update(struct codec_store *cs, struct codec_store *ocs) { } INLINE void codec_handlers_stop(GQueue *q, struct call_media *sink) { } INLINE void ensure_codec_def(struct rtp_payload_type *pt, struct call_media *media) { }