Browse Source

MT#55283 extend codec_tracker_update

Allow codec_tracker_update to reference an existing codec_store. Then
when a supplemental codec type needs to be generated, make it look up
the type in the existing codec_store and re-use the existing payload
type if present instead of creating a new one. This allows payload type
numbers to remain unchanged during a re-invite.

Change-Id: I9e5edd897515a5e3eb5033aa6bbf21c8667d6133
pull/1772/head
Richard Fuchs 2 years ago
parent
commit
4a1fe2b779
3 changed files with 24 additions and 8 deletions
  1. +4
    -4
      daemon/call.c
  2. +18
    -2
      daemon/codec.c
  3. +2
    -2
      include/codec.h

+ 4
- 4
daemon/call.c View File

@ -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


+ 18
- 2
daemon/codec.c View File

@ -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;


+ 2
- 2
include/codec.h View File

@ -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) { }


Loading…
Cancel
Save