Add voice redundancy and the encoder settings on Android
Redundancy sends every voice packet again, one to four times, 20 to 200 ms apart. Listeners' jitter buffers grow to wait for the copies, native clients' included, so a lost packet costs nothing while a copy arrives. With a native client listening over a bursty lossy uplink, the frames lost to concealment fell from 10% to under 1%. Android gets the desktop's encoder settings: bitrate, complexity, VBR, FEC, music codec, and the new redundancy delay and copies. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -5,6 +5,7 @@ import com.ts3client.audio.VoiceInput;
|
||||
import com.ts3client.config.Settings;
|
||||
|
||||
import javax.swing.JCheckBox;
|
||||
import javax.swing.JComboBox;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.JSlider;
|
||||
@@ -24,6 +25,8 @@ final class EncoderSection {
|
||||
private final JCheckBox vbrCheck;
|
||||
private final JCheckBox fecCheck;
|
||||
private final JCheckBox musicCheck;
|
||||
private final JComboBox<String> redundancyCombo;
|
||||
private final JComboBox<Integer> copiesCombo;
|
||||
|
||||
private final JLabel bitrateLabel;
|
||||
|
||||
@@ -53,6 +56,43 @@ final class EncoderSection {
|
||||
fecCheck.addActionListener(e -> pushLive());
|
||||
musicCheck.addActionListener(e -> pushLive());
|
||||
|
||||
String[] delays = new String[Settings.REDUNDANCY_DELAYS.length];
|
||||
for (int i = 0; i < delays.length; i++) {
|
||||
int ms = Settings.REDUNDANCY_DELAYS[i];
|
||||
delays[i] = ms == 0 ? "Off" : ms + " ms";
|
||||
}
|
||||
redundancyCombo = new JComboBox<>(delays);
|
||||
redundancyCombo.setSelectedIndex(nearestDelay(settings.redundancyDelay));
|
||||
Integer[] copies = new Integer[Settings.MAX_REDUNDANCY_COPIES];
|
||||
for (int i = 0; i < copies.length; i++) copies[i] = i + 1;
|
||||
copiesCombo = new JComboBox<>(copies);
|
||||
copiesCombo.setSelectedItem(Math.max(1, Math.min(Settings.MAX_REDUNDANCY_COPIES, settings.redundancyCopies)));
|
||||
copiesCombo.setEnabled(selectedDelay() > 0);
|
||||
redundancyCombo.addActionListener(e -> {
|
||||
copiesCombo.setEnabled(selectedDelay() > 0);
|
||||
pushRedundancy();
|
||||
});
|
||||
copiesCombo.addActionListener(e -> pushRedundancy());
|
||||
}
|
||||
|
||||
private void pushRedundancy() {
|
||||
if (liveMic != null) liveMic.setRedundancy(selectedDelay(), selectedCopies());
|
||||
}
|
||||
|
||||
private int selectedCopies() {
|
||||
return (Integer) copiesCombo.getSelectedItem();
|
||||
}
|
||||
|
||||
private static int nearestDelay(int ms) {
|
||||
int best = 0;
|
||||
for (int i = 1; i < Settings.REDUNDANCY_DELAYS.length; i++) {
|
||||
if (Math.abs(Settings.REDUNDANCY_DELAYS[i] - ms) < Math.abs(Settings.REDUNDANCY_DELAYS[best] - ms)) best = i;
|
||||
}
|
||||
return best;
|
||||
}
|
||||
|
||||
private int selectedDelay() {
|
||||
return Settings.REDUNDANCY_DELAYS[redundancyCombo.getSelectedIndex()];
|
||||
}
|
||||
|
||||
/** Adds the section's rows to {@code form} from {@code row} on; returns the next free row. */
|
||||
@@ -62,6 +102,8 @@ final class EncoderSection {
|
||||
FormPanel.addWide(form, c, row++, vbrCheck);
|
||||
FormPanel.addWide(form, c, row++, fecCheck);
|
||||
FormPanel.addWide(form, c, row++, musicCheck);
|
||||
FormPanel.addRow(form, c, row++, new JLabel("Redundancy:"), redundancyCombo);
|
||||
FormPanel.addRow(form, c, row++, new JLabel("Copies:"), copiesCombo);
|
||||
return row;
|
||||
}
|
||||
|
||||
@@ -72,6 +114,8 @@ final class EncoderSection {
|
||||
target.vbr = vbrCheck.isSelected();
|
||||
target.fec = fecCheck.isSelected();
|
||||
target.music = musicCheck.isSelected();
|
||||
target.redundancyDelay = selectedDelay();
|
||||
target.redundancyCopies = selectedCopies();
|
||||
}
|
||||
|
||||
private void pushLive() {
|
||||
|
||||
Reference in New Issue
Block a user