Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions Source/OptionsView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,10 @@ OptionsView::OptionsView(SonobusAudioProcessor& proc, std::function<AudioDeviceM
int numformats = processor.getNumberAudioCodecFormats();
for (int i=0; i < numformats; ++i) {
SonobusAudioProcessor::AudioCodecFormatInfo finfo;
processor.getAudioCodeFormatInfo(i, finfo);
processor.getAudioCodecFormatInfo(i, finfo);
auto name = finfo.name;
if (finfo.codec == SonobusAudioProcessor::AudioCodecFormatCodec::CodecOpus && finfo.bitrate < 96000) {
if (finfo.codec == SonobusAudioProcessor::AudioCodecFormatCodec::CodecOpus && finfo.bitrate < 96000 ||
finfo.codec == SonobusAudioProcessor::AudioCodecFormatCodec::CodecPCM && finfo.bitdepth == 1) {
name += String(" (*)");
}
mOptionsFormatChoiceDefaultChoice->addItem(name, i+1);
Expand Down
67 changes: 44 additions & 23 deletions Source/PeersContainerView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,35 +526,19 @@ PeerViewInfo * PeersContainerView::createPeerViewInfo()
pvf->changeAllFormatButton->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<SonoChoiceButton>();
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<SonoChoiceButton>();
pvf->remoteSendFormatChoiceButton->addChoiceListener(this);
pvf->remoteSendFormatChoiceButton->setTitle(TRANS("Preferred Receive Quality"));

pvf->staticFormatChoiceLabel = std::make_unique<Label>("sendfmtst", TRANS("Send Quality"));
pvf->staticFormatChoiceLabel->setAccessible(false);
configLabel(pvf->staticFormatChoiceLabel.get(), LabelTypeRegular);


pvf->remoteSendFormatChoiceButton = std::make_unique<SonoChoiceButton>();
pvf->remoteSendFormatChoiceButton->addChoiceListener(this);
pvf->remoteSendFormatChoiceButton->setTitle(TRANS("Preferred Receive Quality"));
pvf->remoteSendFormatChoiceButton->addItem(TRANS("No Preference"), -1);
for (int i=0; i < numformats; ++i) {
pvf->remoteSendFormatChoiceButton->addItem(processor.getAudioCodeFormatName(i), i);
}

pvf->staticRemoteSendFormatChoiceLabel = std::make_unique<Label>("recvfmtst", TRANS("Preferred Recv Quality"));
configLabel(pvf->staticRemoteSendFormatChoiceLabel.get(), LabelTypeRegular);
pvf->staticRemoteSendFormatChoiceLabel->setAccessible(false);
Expand Down Expand Up @@ -1578,6 +1562,8 @@ void PeersContainerView::updatePeerViews(int specific)
// for (int i=0; i < mPeerViews.size(); ++i) {
for (int di=0; di < mPeerUpdateOrdering.size(); ++di) {
int i = mPeerUpdateOrdering[di];
// update the send format choice buttons dropdown choices, because a reordering of the peer views could have happened
updateAvailableCodecOptions(processor.getRemotePeerUserName(i));

if (specific >= 0 && specific != i) continue;
if (di >= mPeerViews.size()) {
Expand Down Expand Up @@ -1752,9 +1738,11 @@ void PeersContainerView::updatePeerViews(int specific)


int formatindex = processor.getRemotePeerAudioCodecFormat(i);
pvf->formatChoiceButton->setSelectedItemIndex(formatindex >= 0 ? formatindex : processor.getDefaultAudioCodecFormat(), dontSendNotification);
// the formatIndex can differ from the choice buttons index
// thus set the selected value by using the SonoChoiceButtons "ident" and not the "index"
pvf->formatChoiceButton->setSelectedId(formatindex >= 0 ? formatindex : processor.getDefaultAudioCodecFormat(), dontSendNotification);
String sendqual;
sendqual << processor.getRemotePeerActualSendChannelCount(i) << "ch " << processor.getAudioCodeFormatName(formatindex);
sendqual << processor.getRemotePeerActualSendChannelCount(i) << "ch " << processor.getAudioCodecFormatName(formatindex);
pvf->sendQualityLabel->setText(sendqual, dontSendNotification);

// pvf->recvMeter->setMeterSource (processor.getRemotePeerRecvMeterSource(i));
Expand Down Expand Up @@ -1825,6 +1813,39 @@ void PeersContainerView::updatePeerViews(int specific)
lastUpdateTimestampMs = nowstampms;
}

// updates the send format choice buttons choices
void PeersContainerView::updateAvailableCodecOptions(const String & username) {
// resolve view of peer
for (int di=0; di < mPeerViews.size(); ++di) {
int i = mPeerUpdateOrdering[di];
if (username == processor.getRemotePeerUserName(i)) {
PeerViewInfo * pvf = mPeerViews.getUnchecked(di);
pvf->formatChoiceButton->clearItems();
pvf->remoteSendFormatChoiceButton->clearItems();
// show codecs in the send and receive choices that are supported by the peer
std::vector<int> formats = processor.getRemotePeerSupportedAudioFormatIndexes(i);

for (auto & format : formats) {
SonobusAudioProcessor::AudioCodecFormatInfo finfo;
processor.getAudioCodecFormatInfo(format, finfo);
auto name = finfo.name;
if (finfo.codec == SonobusAudioProcessor::AudioCodecFormatCodec::CodecOpus && finfo.bitrate < 96000 ||
finfo.codec == SonobusAudioProcessor::AudioCodecFormatCodec::CodecPCM && finfo.bitdepth == 1) {
name += String(" (*)");
}
pvf->formatChoiceButton->addItem(name, format);
}
pvf->formatChoiceButton->addItem("(*) " + TRANS("not recommended"), -2, true, true);

pvf->remoteSendFormatChoiceButton->addItem(TRANS("No Preference"), -1);
for (auto & format : formats) {
pvf->remoteSendFormatChoiceButton->addItem(processor.getAudioCodecFormatName(format), format);
}
return;
}
}
}

void PeersContainerView::startLatencyTest(int di)
{
if (di >= mPeerViews.size()) return;
Expand Down
1 change: 1 addition & 0 deletions Source/PeersContainerView.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ public MultiTimer

void setPeerDisplayMode(SonobusAudioProcessor::PeerDisplayMode mode);

void updateAvailableCodecOptions(const String & username);

protected:

Expand Down
10 changes: 10 additions & 0 deletions Source/SonobusPluginEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1708,6 +1708,14 @@ void SonobusAudioProcessorEditor::peerBlockedInfoChanged(SonobusAudioProcessor *

}

void SonobusAudioProcessorEditor::peerCodecInfoReceived(SonobusAudioProcessor *comp, const String & username)
{
{
const ScopedLock sl (clientStateLock);
clientEvents.add(ClientEvent(ClientEvent::PeerCodecInfoReceivedEvent, username));
}
triggerAsyncUpdate();
}

//////////////////////////

Expand Down Expand Up @@ -3938,6 +3946,8 @@ void SonobusAudioProcessorEditor::handleAsyncUpdate()
}
else if (ev.type == ClientEvent::PeerBlockedInfoChangedEvent) {
updatePeerState(true);
} else if (ev.type == ClientEvent::PeerCodecInfoReceivedEvent) {
mPeerContainer->updateAvailableCodecOptions(ev.message);
}
}

Expand Down
2 changes: 2 additions & 0 deletions Source/SonobusPluginEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@ public PeersContainerView::Listener
void sbChatEventReceived(SonobusAudioProcessor *comp, const SBChatEvent & mesg) override;
void peerRequestedLatencyMatch(SonobusAudioProcessor *comp, const String & username, float latency) override;
void peerBlockedInfoChanged(SonobusAudioProcessor *comp, const String & username, bool blocked) override;
void peerCodecInfoReceived(SonobusAudioProcessor *comp, const String & userName) override;

std::function<AudioDeviceManager*()> getAudioDeviceManager; // = []() { return 0; };
std::function<bool()> isInterAppAudioConnected; // = []() { return 0; };
Expand Down Expand Up @@ -454,6 +455,7 @@ public PeersContainerView::Listener
PublicGroupDeletedEvent,
PeerRequestedLatencyMatchEvent,
PeerBlockedInfoChangedEvent,
PeerCodecInfoReceivedEvent,
Error
};

Expand Down
Loading