diff --git a/daemon/call.c b/daemon/call.c index 22d7f0729..3de141640 100644 --- a/daemon/call.c +++ b/daemon/call.c @@ -2469,10 +2469,23 @@ void codecs_offer_answer(struct call_media *media, struct call_media *other_medi ilogs(codec, LOG_DEBUG, "Updating codecs for answerer " STR_FORMAT " #%u", STR_FMT(&other_media->monologue->tag), other_media->index); + + bool codec_answer_only = true; + // don't do codec answer for a rejected media section + if (other_media->streams.length == 0) + codec_answer_only = false; + else { + struct packet_stream *ps = other_media->streams.head->data; + if (ps->endpoint.port == 0) + codec_answer_only = false; + } + if (flags->reuse_codec) - codec_store_populate_reuse(&other_media->codecs, &sp->codecs, flags->codec_set, true); + codec_store_populate_reuse(&other_media->codecs, &sp->codecs, flags->codec_set, + codec_answer_only); else - codec_store_populate(&other_media->codecs, &sp->codecs, flags->codec_set, true); + codec_store_populate(&other_media->codecs, &sp->codecs, flags->codec_set, + codec_answer_only); codec_store_strip(&other_media->codecs, &flags->codec_strip, flags->codec_except); codec_store_offer(&other_media->codecs, &flags->codec_offer, &sp->codecs); codec_store_check_empty(&other_media->codecs, &sp->codecs); diff --git a/t/test-transcode.c b/t/test-transcode.c index 1114e9f18..d43203565 100644 --- a/t/test-transcode.c +++ b/t/test-transcode.c @@ -4,6 +4,7 @@ #include "log.h" #include "main.h" #include "ssrc.h" +#include "aux.h" int _log_facility_rtcp; int _log_facility_cdr; @@ -73,6 +74,13 @@ static void __init(void) { ml_A.ssrc_hash = create_ssrc_hash_call(); ml_B.ssrc_hash = create_ssrc_hash_call(); } +static struct packet_stream *ps_new(struct call *c) { + struct packet_stream *ps = malloc(sizeof(*ps)); + assert(ps != NULL); + memset(ps, 0, sizeof(*ps)); + ps->endpoint.port = 12345; + return ps; +} static void __start(const char *file, int line) { printf("running test %s:%i\n", file, line); rtp_ts_ht = g_hash_table_new(g_direct_hash, g_direct_equal); @@ -86,6 +94,8 @@ static void __start(const char *file, int line) { bencode_buffer_init(&call.buffer); media_A = call_media_new(&call); // originator media_B = call_media_new(&call); // output destination + g_queue_push_tail(&media_A->streams, ps_new(&call)); + g_queue_push_tail(&media_B->streams, ps_new(&call)); ZERO(ml_A); ZERO(ml_B); str_init(&ml_A.tag, "tag_A"); @@ -345,6 +355,8 @@ static void __packet_seq_ts(const char *file, int line, struct call_media *media static void end(void) { g_hash_table_destroy(rtp_ts_ht); g_hash_table_destroy(rtp_seq_ht); + g_queue_clear_full(&media_A->streams, free); + g_queue_clear_full(&media_B->streams, free); call_media_free(&media_A); call_media_free(&media_B); bencode_buffer_free(&call.buffer);