diff --git a/daemon/codec.c b/daemon/codec.c index c7dc119d4..71b59df26 100644 --- a/daemon/codec.c +++ b/daemon/codec.c @@ -114,9 +114,9 @@ static void __make_transcoder(struct codec_handler *handler, struct rtp_payload_ if (handler->func != handler_func_transcode) goto reset; - ilog(LOG_DEBUG, "Leaving transcode context for " STR_FORMAT "/%i -> " STR_FORMAT "/%i intact", - STR_FMT(&source->encoding_with_params), source->channels, - STR_FMT(&dest->encoding_with_params), dest->channels); + ilog(LOG_DEBUG, "Leaving transcode context for " STR_FORMAT " -> " STR_FORMAT " intact", + STR_FMT(&source->encoding_with_params), + STR_FMT(&dest->encoding_with_params)); return; @@ -130,9 +130,9 @@ reset: handler->ssrc_hash = create_ssrc_hash_full(__ssrc_handler_new, (ssrc_free_func_t) __ssrc_handler_free, handler); - ilog(LOG_DEBUG, "Created transcode context for " STR_FORMAT "/%i -> " STR_FORMAT "/%i", - STR_FMT(&source->encoding_with_params), source->channels, - STR_FMT(&dest->encoding_with_params), dest->channels); + ilog(LOG_DEBUG, "Created transcode context for " STR_FORMAT " -> " STR_FORMAT "", + STR_FMT(&source->encoding_with_params), + STR_FMT(&dest->encoding_with_params)); } static void __ensure_codec_def(struct rtp_payload_type *pt, struct call_media *media) { diff --git a/lib/resample.c b/lib/resample.c index d38795d12..342a02cbc 100644 --- a/lib/resample.c +++ b/lib/resample.c @@ -20,6 +20,12 @@ AVFrame *resample_frame(resample_t *resample, AVFrame *frame, const format_t *to int errcode = 0; uint64_t to_channel_layout = av_get_default_channel_layout(to_format->channels); +#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(54, 31, 0) + if (!frame->channel_layout) + frame->channel_layout = av_get_default_channel_layout( + av_frame_get_channels(frame)); +#endif + if (frame->format != to_format->format) goto resample; if (frame->sample_rate != to_format->clockrate) @@ -37,12 +43,6 @@ resample: if (!resample->avresample) goto err; -#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(54, 31, 0) - if (!frame->channel_layout) - frame->channel_layout = av_get_default_channel_layout( - av_frame_get_channels(frame)); -#endif - err = "failed to set resample option"; if ((errcode = av_opt_set_int(resample->avresample, "in_channel_layout", frame->channel_layout, 0))) diff --git a/recording-daemon/decoder.c b/recording-daemon/decoder.c index e3676f439..0be517d4c 100644 --- a/recording-daemon/decoder.c +++ b/recording-daemon/decoder.c @@ -62,6 +62,9 @@ decoder_t *decoder_new(const char *payload_str, output_t *outp) { out_format.clockrate = resample_audio; // mono/stereo mixing goes here: out_format.channels = ... if (outp) { + // if this output has been configured already, re-use the same format + if (outp->encoder && outp->encoder->requested_format.format != -1) + out_format = outp->encoder->requested_format; output_config(outp, &out_format, &out_format); // save the returned sample format so we don't output_config() twice outp->encoder->requested_format.format = out_format.format;