From deafee1a0470027c149b8e4da60117c779172da4 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Sun, 5 Mar 2023 09:13:12 -0500 Subject: [PATCH] MT#56782 use stereo= fmtp for Opus channels If the remote Opus decoder prefers receiving single-channel encoded audio, honour it and send them single-channel audio. Change-Id: I4bf952b9f922099c95e19b0ab51fbdffb2cc19db --- lib/codeclib.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/codeclib.c b/lib/codeclib.c index 0a28379a9..077eb626c 100644 --- a/lib/codeclib.c +++ b/lib/codeclib.c @@ -2105,8 +2105,13 @@ static void opus_select_encoder_format(encoder_t *enc, format_t *req_format, con break; } - // switch to mono encoding if possible - if (req_format->channels == 2 && f->channels == 1) + // honour remote stereo=0/1 flag if given, + // otherwise go with the input format + if (fmtp && fmtp->parsed.opus.stereo_send == -1) + req_format->channels = 1; + else if (fmtp && fmtp->parsed.opus.stereo_send == 1) + req_format->channels = 2; + else if (req_format->channels == 2 && f->channels == 1) req_format->channels = 1; } static void opus_select_decoder_format(decoder_t *dec, const struct rtp_codec_format *fmtp) {