From 944a3d4e94c7e8213bbd6ce868732f2e7f8705b3 Mon Sep 17 00:00:00 2001 From: florianschmeding <81837461+florianschmeding@users.noreply.github.com> Date: Tue, 30 May 2023 23:33:50 +0200 Subject: [PATCH 1/2] Enable clients to implement new codecs without breaking old clients by sending a list of supported codecs --- Source/OptionsView.cpp | 2 +- Source/PeersContainerView.cpp | 66 ++++++---- Source/PeersContainerView.h | 1 + Source/SonobusPluginEditor.cpp | 10 ++ Source/SonobusPluginEditor.h | 2 + Source/SonobusPluginProcessor.cpp | 202 ++++++++++++++++++++++++------ Source/SonobusPluginProcessor.h | 19 ++- 7 files changed, 232 insertions(+), 70 deletions(-) diff --git a/Source/OptionsView.cpp b/Source/OptionsView.cpp index acb82f4eb..cdd1aace5 100644 --- a/Source/OptionsView.cpp +++ b/Source/OptionsView.cpp @@ -117,7 +117,7 @@ OptionsView::OptionsView(SonobusAudioProcessor& proc, std::functionchangeAllFormatButton->addListener(this); pvf->changeAllFormatButton->setLookAndFeel(&pvf->smallLnf); - + // initially don't add any choices to the send format choice buttons here + // the choices will later be added as soon as a peer sends us their supported codecs pvf->formatChoiceButton = std::make_unique(); pvf->formatChoiceButton->setTitle(TRANS("Send Quality")); pvf->formatChoiceButton->addChoiceListener(this); - int numformats = processor.getNumberAudioCodecFormats(); - for (int i=0; i < numformats; ++i) { - SonobusAudioProcessor::AudioCodecFormatInfo finfo; - processor.getAudioCodeFormatInfo(i, finfo); - auto name = finfo.name; - if (finfo.codec == SonobusAudioProcessor::AudioCodecFormatCodec::CodecOpus && finfo.bitrate < 96000) { - name += String(" (*)"); - } - pvf->formatChoiceButton->addItem(name, i); - } - pvf->formatChoiceButton->addItem("(*) " + TRANS("not recommended"), -2, true, true); + pvf->remoteSendFormatChoiceButton = std::make_unique(); + pvf->remoteSendFormatChoiceButton->addChoiceListener(this); + pvf->remoteSendFormatChoiceButton->setTitle(TRANS("Preferred Receive Quality")); pvf->staticFormatChoiceLabel = std::make_unique