MT#55283 extend "answer only" logic

Provide an extra codec-store for the lookup of the answer codec. This is
needed for codec switches during an extra answer, as the original codecs
are kept in a different codec-store.

Closes #2073

Change-Id: I7e2efc434789ecc8d3b5fcf97240e5c3f7c84652
(cherry picked from commit cfe9a588fa)
mr13.5
Richard Fuchs 2 months ago
parent 33ede92d37
commit 73ba29d683

@ -2563,21 +2563,21 @@ static void codecs_answer(struct call_media *media, struct call_media *other_med
STR_FMT(&other_media->monologue->tag),
other_media->index);
bool codec_answer_only = true;
const struct codec_store *answer_cs = &media->offered_codecs;
// don't do codec answer for a rejected media section
if (other_media->streams.length == 0)
codec_answer_only = false;
answer_cs = NULL;
else if (sp->rtp_endpoint.port == 0)
codec_answer_only = false;
answer_cs = NULL;
if (flags->reuse_codec)
codec_store_populate_reuse(&other_media->codecs, &sp->codecs,
.codec_set = flags->codec_set,
.answer_only = codec_answer_only);
.answer_cs = answer_cs);
else
codec_store_populate(&other_media->codecs, &sp->codecs,
.codec_set = flags->codec_set,
.answer_only = codec_answer_only,
.answer_cs = answer_cs,
.allow_asymmetric = !!flags->allow_asymmetric_codecs);
codec_store_strip(&other_media->codecs, &flags->codec_strip, flags->codec_except);
codec_store_offer(&other_media->codecs, &flags->codec_offer, &sp->codecs);
@ -3811,12 +3811,13 @@ int monologue_subscribe_answer(struct call_monologue *dst_ml, sdp_ng_flags *flag
if (flags->allow_transcoding) {
codec_store_populate(&dst_media->codecs, &sp->codecs,
.codec_set = flags->codec_set,
.answer_only = true,
.answer_cs = &src_media->codecs,
.allow_asymmetric = !!flags->allow_asymmetric_codecs);
codec_store_strip(&dst_media->codecs, &flags->codec_strip, flags->codec_except);
codec_store_offer(&dst_media->codecs, &flags->codec_offer, &sp->codecs);
} else {
codec_store_populate(&dst_media->codecs, &sp->codecs, .answer_only = true,
codec_store_populate(&dst_media->codecs, &sp->codecs,
.answer_cs = &src_media->codecs,
.allow_asymmetric = !!flags->allow_asymmetric_codecs);
if (!codec_store_is_full_answer(&src_media->codecs, &dst_media->codecs))
return -1;

@ -5652,7 +5652,7 @@ void __codec_store_populate_reuse(struct codec_store *dst, struct codec_store *s
codec_store_add_raw_link(dst, dup, pos);
}
else {
if (!a.answer_only) {
if (!a.answer_cs) {
ilogs(codec, LOG_DEBUG, "Adding codec " STR_FORMAT "/" STR_FORMAT
" (%i) to end of list",
STR_FMT(&pt->encoding_with_params),
@ -5732,8 +5732,11 @@ void __codec_store_populate(struct codec_store *dst, struct codec_store *src, st
GINT_TO_POINTER(pt->payload_type));
if (orig_pt && !rtp_payload_type_eq_compat(orig_pt, pt))
orig_pt = NULL;
if (a.answer_only && !orig_pt) {
if (a.allow_asymmetric)
if (a.answer_cs && !orig_pt) {
orig_pt = t_hash_table_lookup(a.answer_cs->codecs, GINT_TO_POINTER(pt->payload_type));
if (orig_pt && !rtp_payload_type_eq_compat(orig_pt, pt))
orig_pt = NULL;
if (a.allow_asymmetric && !orig_pt)
orig_pt = codec_store_find_compatible(&orig_dst, pt);
if (!orig_pt) {
ilogs(codec, LOG_DEBUG, "Not adding stray answer codec "

@ -160,9 +160,9 @@ void codec_update_all_source_handlers(struct call_monologue *ml, const sdp_ng_fl
struct codec_store_args {
str_case_value_ht codec_set;
bool answer_only;
bool allow_asymmetric;
const struct codec_store *answer_cs;
struct codec_store *merge_cs;
bool allow_asymmetric;
};
__attribute__((nonnull(1)))

Loading…
Cancel
Save