diff --git a/.gitignore b/.gitignore
index cbb1fd9..8cec756 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,6 +9,7 @@ pnpm-lock.yaml
.env.local
.env.*.local
server/.env
+server/config/config.yaml
client/.env
# Keep .env.example files (templates)
diff --git a/client/src/hooks/useLiveKit.js b/client/src/hooks/useLiveKit.js
index 3c8b003..536f13b 100644
--- a/client/src/hooks/useLiveKit.js
+++ b/client/src/hooks/useLiveKit.js
@@ -283,8 +283,17 @@ export default function useLiveKit() {
});
});
- // Participants distants (utilisateurs WebRTC)
+ // Participants distants (utilisateurs WebRTC + server audio users)
+ // Exclure les participants internes de routage (role: 'bridge')
room.remoteParticipants.forEach((participant) => {
+ let role = null;
+ try {
+ const meta = participant.metadata ? JSON.parse(participant.metadata) : {};
+ role = meta.role || null;
+ } catch (_) {}
+
+ if (role === 'bridge') return;
+
const audioTracks = participant.audioTracks ? Array.from(participant.audioTracks.values()) : [];
const audioPublication = audioTracks[0];
const isSpeaking = room.activeSpeakers.some(s => s.identity === participant.identity);
diff --git a/electron/main.js b/electron/main.js
index fb815d3..4fade6c 100644
--- a/electron/main.js
+++ b/electron/main.js
@@ -454,7 +454,7 @@ app.whenReady().then(async () => {
if (users.find(u => u.name === name)) {
return { success: false, error: `Un utilisateur "${name}" existe déjà` };
}
- const user = { name, group, input_channel: parseInt(input_channel), output_channel: parseInt(output_channel) };
+ const user = { name, group, input_channel: parseInt(input_channel), output_channel: output_channel !== null && output_channel !== '' ? parseInt(output_channel) : null };
config.server_audio_users = [...users, user];
writeConfig(config);
return { success: true, user };
@@ -469,7 +469,7 @@ app.whenReady().then(async () => {
const users = config.server_audio_users || [];
const idx = users.findIndex(u => u.name === name);
if (idx === -1) return { success: false, error: `Utilisateur "${name}" introuvable` };
- config.server_audio_users[idx] = { name, group, input_channel: parseInt(input_channel), output_channel: parseInt(output_channel) };
+ config.server_audio_users[idx] = { name, group, input_channel: parseInt(input_channel), output_channel: output_channel !== null && output_channel !== '' ? parseInt(output_channel) : null };
writeConfig(config);
return { success: true };
} catch (error) {
@@ -497,20 +497,60 @@ app.whenReady().then(async () => {
try {
const config = readConfig();
return {
- routing: config.audio?.routing || { inputToGroup: {}, groupToOutput: {}, gains: {} },
channelNames: config.audio?.channelNames || { inputs: {}, outputs: {} },
- groups: config.groups || []
+ groups: config.groups || [],
+ serverAudioUsers: config.server_audio_users || []
};
} catch (error) {
return { error: error.message };
}
});
- ipcMain.handle('routing:save', (event, { routing, channelNames }) => {
+ // ========== Devices : découverte canaux physiques ==========
+
+ ipcMain.handle('devices:getChannels', () => {
+ try {
+ const config = readConfig();
+ const inputDeviceName = config.audio?.device?.inputDeviceId;
+ const outputDeviceName = config.audio?.device?.outputDeviceId;
+
+ let inputDevice = { name: inputDeviceName || 'Non configuré', channels: 0 };
+ let outputDevice = { name: outputDeviceName || 'Non configuré', channels: 0 };
+
+ if (process.platform === 'darwin') {
+ try {
+ const { execSync } = require('child_process');
+ const raw = execSync('system_profiler SPAudioDataType -json', { encoding: 'utf8', timeout: 5000 });
+ const data = JSON.parse(raw);
+
+ if (data.SPAudioDataType) {
+ data.SPAudioDataType.forEach(item => {
+ (item._items || []).forEach(dev => {
+ const name = dev._name || '';
+ const inCh = parseInt(dev.coreaudio_device_input) || 0;
+ const outCh = parseInt(dev.coreaudio_device_output) || 0;
+ if (inputDeviceName && name === inputDeviceName && inCh > 0) {
+ inputDevice = { name, channels: inCh };
+ }
+ if (outputDeviceName && name === outputDeviceName && outCh > 0) {
+ outputDevice = { name, channels: outCh };
+ }
+ });
+ });
+ }
+ } catch (_) { /* detection failed, keep defaults */ }
+ }
+
+ return { inputDevice, outputDevice };
+ } catch (error) {
+ return { error: error.message, inputDevice: { name: 'Inconnu', channels: 0 }, outputDevice: { name: 'Inconnu', channels: 0 } };
+ }
+ });
+
+ ipcMain.handle('routing:save', (event, { channelNames }) => {
try {
const config = readConfig();
if (!config.audio) config.audio = {};
- config.audio.routing = routing;
config.audio.channelNames = channelNames;
writeConfig(config);
return { success: true };
diff --git a/electron/preload.js b/electron/preload.js
index 920b449..4900864 100644
--- a/electron/preload.js
+++ b/electron/preload.js
@@ -65,6 +65,11 @@ contextBridge.exposeInMainWorld('electronAPI', {
save: (data) => ipcRenderer.invoke('routing:save', data)
},
+ // Découverte canaux physiques de la carte son sélectionnée
+ devices: {
+ getChannels: () => ipcRenderer.invoke('devices:getChannels')
+ },
+
// Helpers
platform: process.platform,
version: process.env.npm_package_version || '0.3.0'
diff --git a/electron/ui/app.js b/electron/ui/app.js
index c0046c0..49c96a5 100644
--- a/electron/ui/app.js
+++ b/electron/ui/app.js
@@ -10,6 +10,7 @@ let statsInterval = null;
let logsBuffer = [];
let audioLevelsWS = null;
let routingData = null;
+let deviceChannels = null;
let audioLevelsData = {
inputs: {},
groups: {},
@@ -585,7 +586,6 @@ async function loadViewData(view) {
}
if (view === 'config') {
- await fetchServerAudioUsers();
if (serverRunning) {
await fetchDevices();
await fetchConfig();
@@ -790,94 +790,119 @@ document.addEventListener('DOMContentLoaded', () => {
});
}
- // Bouton ajouter utilisateur audio serveur
- const btnAddSAU = document.getElementById('btn-add-server-audio-user');
- if (btnAddSAU) {
- btnAddSAU.addEventListener('click', addServerAudioUser);
- }
-
- // Délégation modifier/supprimer utilisateur audio serveur
- const sauList = document.getElementById('server-audio-users-list');
- if (sauList) {
- sauList.addEventListener('click', async (e) => {
- const btn = e.target.closest('[data-sau-action]');
- if (!btn) return;
- const action = btn.dataset.sauAction;
- const name = btn.dataset.sauName;
- if (action === 'edit') {
- await editServerAudioUser(name, btn.dataset.sauGroup, parseInt(btn.dataset.sauInput), parseInt(btn.dataset.sauOutput));
- } else if (action === 'delete') {
- await deleteServerAudioUser(name);
- }
- });
- }
-
// Boutons routing
document.getElementById('btn-save-routing')?.addEventListener('click', saveRouting);
document.getElementById('btn-reload-routing')?.addEventListener('click', fetchRouting);
- document.getElementById('btn-add-input-channel')?.addEventListener('click', () => addChannelRow('input'));
- document.getElementById('btn-add-output-channel')?.addEventListener('click', () => addChannelRow('output'));
+ document.getElementById('btn-refresh-channels')?.addEventListener('click', fetchRouting);
+ document.getElementById('btn-add-server-audio-user')?.addEventListener('click', addServerAudioUser);
- // Délégation suppression lignes canal (boutons ✕)
- document.addEventListener('click', (e) => {
- const btn = e.target.closest('.channel-name-delete');
+ // Délégation modifier/supprimer participant serveur
+ document.getElementById('server-audio-users-list')?.addEventListener('click', async (e) => {
+ const btn = e.target.closest('[data-sau-action]');
if (!btn) return;
- deleteChannelRow(btn.dataset.dir, btn.dataset.channel);
+ const action = btn.dataset.sauAction;
+ const name = btn.dataset.sauName;
+ if (action === 'edit') {
+ await editServerAudioUser(name, btn.dataset.sauGroup, parseInt(btn.dataset.sauInput), parseInt(btn.dataset.sauOutput));
+ } else if (action === 'delete') {
+ await deleteServerAudioUser(name);
+ }
});
});
-// ========== Server Audio Users ==========
+// ========== Server Audio Users (dans la vue Routing) ==========
-async function fetchServerAudioUsers() {
+function renderServerAudioUsers() {
const container = document.getElementById('server-audio-users-list');
if (!container) return;
- const data = await window.electronAPI.serverAudioUsers.list();
+ const users = routingData?.serverAudioUsers || [];
+ const inputs = routingData?.channelNames?.inputs || {};
+ const outputs = routingData?.channelNames?.outputs || {};
- const serverNote = serverRunning ? '' :
- '
Serveur arrêté — les modifications seront appliquées au prochain démarrage.
';
+ const chLabel = (ch, dir) => {
+ if (ch === null || ch === undefined) return 'Aucune';
+ const name = dir === 'input' ? inputs[ch] : outputs[ch];
+ return name ? `Ch ${ch} · ${name}` : `Ch ${ch}`;
+ };
- if (!data.users || data.users.length === 0) {
- container.innerHTML = serverNote + 'Aucun utilisateur audio serveur configuré
';
+ if (users.length === 0) {
+ container.innerHTML = 'Aucun participant serveur configuré
';
return;
}
- container.innerHTML = serverNote + data.users.map(user => `
-
-
-
${escapeHtml(user.name)}
-
Groupe: ${escapeHtml(user.group)} · Entrée: canal ${user.input_channel} · Sortie: canal ${user.output_channel}
-
-
- Modifier
- Supprimer
-
-
- `).join('');
+ container.innerHTML = `
+
+
+ Nom Groupe Entrée Sortie
+
+
+ ${users.map(u => `
+
+ ${escapeHtml(u.name)}
+ ${escapeHtml(u.group)}
+ ${chLabel(u.input_channel, 'input')}
+ ${chLabel(u.output_channel, 'output')}
+
+ Éditer
+ ✕
+
+ `).join('')}
+
+
`;
+}
+
+function buildChannelOptions(dir) {
+ const channels = dir === 'input'
+ ? routingData?.deviceChannels?.inputDevice?.channels || 0
+ : routingData?.deviceChannels?.outputDevice?.channels || 0;
+ const names = dir === 'input'
+ ? routingData?.channelNames?.inputs || {}
+ : routingData?.channelNames?.outputs || {};
+
+ if (channels === 0) return null; // fallback to number input
+
+ const opts = Array.from({ length: channels }, (_, i) => ({
+ value: String(i),
+ label: names[i] ? `Ch ${i}: ${names[i]}` : `Ch ${i}`
+ }));
+
+ if (dir === 'output') {
+ opts.unshift({ value: '', label: 'Aucune sortie' });
+ }
+
+ return opts;
}
async function addServerAudioUser() {
const groupsData = await window.electronAPI.groups.list();
- const groupOptions = (groupsData.groups || []).map(g => ({
- value: slugify(g.name),
- label: g.name
- }));
+ const groupOptions = (groupsData.groups || []).map(g => ({ value: slugify(g.name), label: g.name }));
const defaultGroup = groupOptions[0]?.value || 'default';
+ const inOpts = buildChannelOptions('input');
+ const outOpts = buildChannelOptions('output');
+
+ const inputField = inOpts
+ ? { name: 'input_channel', label: 'Canal d\'entrée', type: 'select', options: inOpts, default: '0' }
+ : { name: 'input_channel', label: 'Canal entrée (index)', type: 'number', default: 0, min: 0, max: 63 };
+ const outputField = outOpts
+ ? { name: 'output_channel', label: 'Canal de sortie', type: 'select', options: outOpts, default: '' }
+ : { name: 'output_channel', label: 'Canal sortie (index, vide = aucune)', type: 'number', default: '', min: 0, max: 63 };
+
const result = await showModal({
- title: 'Nouvel utilisateur audio serveur',
+ title: 'Nouveau participant serveur',
fields: [
{ name: 'name', label: 'Nom (identifiant unique, ex: foh)' },
{ name: 'group', label: 'Groupe', type: 'select', options: groupOptions, default: defaultGroup },
- { name: 'input_channel', label: 'Canal entrée (index physique)', type: 'number', default: 0, min: 0, max: 63, step: 1 },
- { name: 'output_channel', label: 'Canal sortie (index physique)', type: 'number', default: 0, min: 0, max: 63, step: 1 }
+ inputField,
+ outputField
],
confirmLabel: 'Ajouter'
});
@@ -888,12 +913,12 @@ async function addServerAudioUser() {
name: result.name.trim(),
group: result.group,
input_channel: parseInt(result.input_channel),
- output_channel: parseInt(result.output_channel)
+ output_channel: result.output_channel !== '' ? parseInt(result.output_channel) : null
});
if (res.success) {
- showNotification('Utilisateur audio serveur ajouté', 'success');
- await fetchServerAudioUsers();
+ showNotification('Participant serveur ajouté', 'success');
+ await fetchRouting();
} else {
showNotification('Erreur: ' + (res.error || 'Création échouée'), 'error');
}
@@ -901,17 +926,25 @@ async function addServerAudioUser() {
async function editServerAudioUser(name, group, input_channel, output_channel) {
const groupsData = await window.electronAPI.groups.list();
- const groupOptions = (groupsData.groups || []).map(g => ({
- value: slugify(g.name),
- label: g.name
- }));
+ const groupOptions = (groupsData.groups || []).map(g => ({ value: slugify(g.name), label: g.name }));
+
+ const inOpts = buildChannelOptions('input');
+ const outOpts = buildChannelOptions('output');
+
+ const inputField = inOpts
+ ? { name: 'input_channel', label: 'Canal d\'entrée', type: 'select', options: inOpts, default: String(input_channel) }
+ : { name: 'input_channel', label: 'Canal entrée (index)', type: 'number', default: input_channel, min: 0, max: 63 };
+ const outputDefault = output_channel !== null && output_channel !== undefined ? String(output_channel) : '';
+ const outputField = outOpts
+ ? { name: 'output_channel', label: 'Canal de sortie', type: 'select', options: outOpts, default: outputDefault }
+ : { name: 'output_channel', label: 'Canal sortie (index, vide = aucune)', type: 'number', default: outputDefault, min: 0, max: 63 };
const result = await showModal({
title: `Modifier "${name}"`,
fields: [
{ name: 'group', label: 'Groupe', type: 'select', options: groupOptions, default: group },
- { name: 'input_channel', label: 'Canal entrée (index physique)', type: 'number', default: input_channel, min: 0, max: 63, step: 1 },
- { name: 'output_channel', label: 'Canal sortie (index physique)', type: 'number', default: output_channel, min: 0, max: 63, step: 1 }
+ inputField,
+ outputField
],
confirmLabel: 'Modifier'
});
@@ -922,12 +955,12 @@ async function editServerAudioUser(name, group, input_channel, output_channel) {
name,
group: result.group,
input_channel: parseInt(result.input_channel),
- output_channel: parseInt(result.output_channel)
+ output_channel: result.output_channel !== '' ? parseInt(result.output_channel) : null
});
if (res.success) {
- showNotification('Utilisateur audio serveur modifié', 'success');
- await fetchServerAudioUsers();
+ showNotification('Participant serveur modifié', 'success');
+ await fetchRouting();
} else {
showNotification('Erreur: ' + (res.error || 'Modification échouée'), 'error');
}
@@ -935,7 +968,7 @@ async function editServerAudioUser(name, group, input_channel, output_channel) {
async function deleteServerAudioUser(name) {
const confirmed = await showModal({
- title: 'Supprimer l\'utilisateur audio serveur',
+ title: 'Supprimer le participant serveur',
message: `Supprimer "${name}" ? Cette action est irréversible.`,
confirmLabel: 'Supprimer',
confirmClass: 'btn-danger'
@@ -946,8 +979,8 @@ async function deleteServerAudioUser(name) {
const res = await window.electronAPI.serverAudioUsers.delete({ name });
if (res.success) {
- showNotification('Utilisateur audio serveur supprimé', 'success');
- await fetchServerAudioUsers();
+ showNotification('Participant serveur supprimé', 'success');
+ await fetchRouting();
} else {
showNotification('Erreur: ' + (res.error || 'Suppression échouée'), 'error');
}
@@ -956,161 +989,83 @@ async function deleteServerAudioUser(name) {
// ========== Routing ==========
async function fetchRouting() {
- const data = await window.electronAPI.routing.get();
- if (data.error) {
- showNotification('Erreur chargement routing: ' + data.error, 'error');
+ const [routingResult, devResult] = await Promise.all([
+ window.electronAPI.routing.get(),
+ window.electronAPI.devices.getChannels()
+ ]);
+
+ if (routingResult.error) {
+ showNotification('Erreur chargement routing: ' + routingResult.error, 'error');
return;
}
- routingData = data;
+
+ deviceChannels = devResult;
+ routingData = { ...routingResult, deviceChannels: devResult };
renderRoutingView();
}
function renderRoutingView() {
if (!routingData) return;
- renderChannelNamesEditor();
- renderRoutingMatrices();
+ renderDeviceBanner();
+ renderChannelLabels();
+ renderServerAudioUsers();
}
-function renderChannelNamesEditor() {
- const { channelNames } = routingData;
+function renderDeviceBanner() {
+ const el = document.getElementById('routing-device-info');
+ if (!el) return;
+
+ const dc = routingData.deviceChannels;
+ if (!dc || dc.error || (dc.inputDevice?.channels === 0 && dc.outputDevice?.channels === 0)) {
+ el.innerHTML = `Aucun device configuré — sélectionnez une carte son dans Configuration `;
+ return;
+ }
+
+ const { inputDevice, outputDevice } = dc;
+ el.innerHTML = `
+ Entrée : ${escapeHtml(inputDevice.name)}
+ ${inputDevice.channels} ch
+ ·
+ Sortie : ${escapeHtml(outputDevice.name)}
+ ${outputDevice.channels} ch `;
+}
+
+function renderChannelLabels() {
+ const { channelNames, deviceChannels: dc } = routingData;
const inputs = channelNames?.inputs || {};
const outputs = channelNames?.outputs || {};
+ const inputCount = dc?.inputDevice?.channels || 0;
+ const outputCount = dc?.outputDevice?.channels || 0;
- const inputChannels = Object.keys(inputs).sort((a, b) => parseInt(a) - parseInt(b));
- const outputChannels = Object.keys(outputs).sort((a, b) => parseInt(a) - parseInt(b));
+ const inputsEl = document.getElementById('channel-names-inputs');
+ const outputsEl = document.getElementById('channel-names-outputs');
- const inputsContainer = document.getElementById('channel-names-inputs');
- const outputsContainer = document.getElementById('channel-names-outputs');
-
- if (inputsContainer) {
- inputsContainer.innerHTML = inputChannels.length > 0
- ? inputChannels.map(ch => channelNameRow('input', ch, inputs[ch] || '')).join('')
- : 'Aucun canal d\'entrée défini.
';
+ if (inputsEl) {
+ inputsEl.innerHTML = inputCount > 0
+ ? Array.from({ length: inputCount }, (_, i) => channelLabelRow('input', i, inputs[i] || '')).join('')
+ : 'Aucun device d\'entrée détecté.
';
}
- if (outputsContainer) {
- outputsContainer.innerHTML = outputChannels.length > 0
- ? outputChannels.map(ch => channelNameRow('output', ch, outputs[ch] || '')).join('')
- : 'Aucun canal de sortie défini.
';
+ if (outputsEl) {
+ outputsEl.innerHTML = outputCount > 0
+ ? Array.from({ length: outputCount }, (_, i) => channelLabelRow('output', i, outputs[i] || '')).join('')
+ : 'Aucun device de sortie détecté.
';
}
}
-function channelNameRow(dir, ch, name) {
+function channelLabelRow(dir, ch, name) {
return `
- Canal ${ch}
+ Ch ${ch}
- ✕
+ value="${escapeHtml(name)}" placeholder="Label canal ${ch}">
`;
}
-function addChannelRow(dir) {
- const containerId = dir === 'input' ? 'channel-names-inputs' : 'channel-names-outputs';
- const container = document.getElementById(containerId);
- if (!container) return;
-
- // Retirer le message "Aucun canal" si présent
- const emptyMsg = container.querySelector('.config-note');
- if (emptyMsg) emptyMsg.remove();
-
- const existing = Array.from(container.querySelectorAll('.channel-name-row'))
- .map(r => parseInt(r.dataset.channel))
- .filter(n => !isNaN(n));
- const nextCh = existing.length > 0 ? Math.max(...existing) + 1 : 0;
-
- const row = document.createElement('div');
- row.innerHTML = channelNameRow(dir, nextCh, '');
- const newRow = row.firstElementChild;
- container.appendChild(newRow);
- newRow.querySelector('input')?.focus();
-}
-
-function deleteChannelRow(dir, channel) {
- const containerId = dir === 'input' ? 'channel-names-inputs' : 'channel-names-outputs';
- const container = document.getElementById(containerId);
- const row = container?.querySelector(`.channel-name-row[data-channel="${channel}"][data-dir="${dir}"]`);
- if (!row) return;
- row.remove();
- if (!container.querySelector('.channel-name-row')) {
- container.innerHTML = `Aucun canal de ${dir === 'input' ? 'entrée' : 'sortie'} défini.
`;
- }
-}
-
-function renderRoutingMatrices() {
- const { routing, channelNames, groups } = routingData;
- const inputs = channelNames?.inputs || {};
- const outputs = channelNames?.outputs || {};
- const inputToGroup = routing?.inputToGroup || {};
- const groupToOutput = routing?.groupToOutput || {};
-
- const inputChannels = Object.keys(inputs).sort((a, b) => parseInt(a) - parseInt(b));
- const outputChannels = Object.keys(outputs).sort((a, b) => parseInt(a) - parseInt(b));
-
- // Matrice Entrées → Groupes
- const inputMatrixEl = document.getElementById('routing-input-matrix');
- if (inputMatrixEl) {
- if (inputChannels.length === 0 || groups.length === 0) {
- inputMatrixEl.innerHTML = 'Définissez des canaux d\'entrée et des groupes pour configurer le routing.
';
- } else {
- let html = '';
- inputMatrixEl.innerHTML = html;
- }
- }
-
- // Matrice Groupes → Sorties
- const outputMatrixEl = document.getElementById('routing-output-matrix');
- if (outputMatrixEl) {
- if (groups.length === 0 || outputChannels.length === 0) {
- outputMatrixEl.innerHTML = 'Définissez des canaux de sortie et des groupes pour configurer le routing.
';
- } else {
- let html = '';
- outputMatrixEl.innerHTML = html;
- }
- }
-}
-
async function saveRouting() {
if (!routingData) return;
- // Collecter les noms de canaux depuis le DOM
const newChannelNames = { inputs: {}, outputs: {} };
document.querySelectorAll('.channel-name-input[data-dir="input"]').forEach(el => {
newChannelNames.inputs[el.dataset.channel] = el.value;
@@ -1119,37 +1074,12 @@ async function saveRouting() {
newChannelNames.outputs[el.dataset.channel] = el.value;
});
- // Collecter le routing depuis les checkboxes
- const newInputToGroup = {};
- const newGroupToOutput = {};
-
- document.querySelectorAll('.routing-check[data-direction="input"]:checked').forEach(cb => {
- const ch = cb.dataset.channel;
- if (!newInputToGroup[ch]) newInputToGroup[ch] = [];
- if (!newInputToGroup[ch].includes(cb.dataset.group)) newInputToGroup[ch].push(cb.dataset.group);
- });
-
- document.querySelectorAll('.routing-check[data-direction="output"]:checked').forEach(cb => {
- const g = cb.dataset.group;
- if (!newGroupToOutput[g]) newGroupToOutput[g] = [];
- if (!newGroupToOutput[g].includes(cb.dataset.channel)) newGroupToOutput[g].push(cb.dataset.channel);
- });
-
- const newRouting = {
- ...(routingData.routing || {}),
- inputToGroup: newInputToGroup,
- groupToOutput: newGroupToOutput
- };
-
- const result = await window.electronAPI.routing.save({ routing: newRouting, channelNames: newChannelNames });
+ const result = await window.electronAPI.routing.save({ channelNames: newChannelNames });
if (result.success) {
- routingData.routing = newRouting;
routingData.channelNames = newChannelNames;
renderRoutingView();
- showNotification('Routing sauvegardé', 'success');
- const note = document.getElementById('routing-server-note');
- if (note) note.classList.remove('hidden');
+ showNotification('Noms de canaux sauvegardés', 'success');
} else {
showNotification('Erreur: ' + (result.error || 'Sauvegarde échouée'), 'error');
}
diff --git a/electron/ui/index.html b/electron/ui/index.html
index ad8ee0a..c1c5326 100644
--- a/electron/ui/index.html
+++ b/electron/ui/index.html
@@ -126,15 +126,6 @@
Appliquer
-
-
🔗 Utilisateurs Audio Serveur
-
Participants LiveKit côté serveur avec canaux physiques d'entrée et de sortie dédiés (mix-minus natif). Voir aussi la page Routing pour le câblage entre canaux et groupes.
-
➕ Ajouter
-
-
-
💾 Sauvegarde de configuration
@@ -179,25 +170,27 @@
Routing Audio
-
+
-
🏷️ Noms des Canaux
-
Définissez les canaux physiques disponibles. Les matrices de routing se mettent à jour après la sauvegarde.
+
+
Chargement...
+
🔄 Actualiser
+
+
+
+
+
+
🏷️ Canaux Physiques
+
Labels des canaux de votre carte son. La liste est déterminée par le device sélectionné en Configuration .
-
+
Sorties
@@ -205,29 +198,18 @@
-
+
-
🎙️ Entrées → Groupes
-
Quels canaux physiques d'entrée alimentent quels groupes LiveKit.
-
-
-
-
-
-
🔊 Groupes → Sorties
-
Vers quels canaux physiques de sortie chaque groupe est routé.
-
+
🎙️ Participants Serveur
+
Participants LiveKit côté serveur — chaque ligne branche des canaux physiques d'E/S sur un groupe.
+
➕ Ajouter
+
- Sauvegarder
+ Sauvegarder noms de canaux
Recharger
- ⚠️ Redémarrez le serveur pour appliquer les changements.
diff --git a/electron/ui/styles.css b/electron/ui/styles.css
index a9889d5..066949a 100644
--- a/electron/ui/styles.css
+++ b/electron/ui/styles.css
@@ -893,7 +893,54 @@ body {
background: rgba(74, 158, 255, 0.05);
}
-/* Channel Names Editor */
+/* Device banner */
+
+.routing-device-banner {
+ display: flex;
+ align-items: center;
+ justify-content: space-between;
+ gap: 1rem;
+ padding: 0.75rem 1rem;
+ background: var(--bg-tertiary);
+ border: 1px solid var(--border-color);
+ border-radius: 6px;
+}
+
+.routing-device-info {
+ display: flex;
+ align-items: center;
+ gap: 1rem;
+ flex-wrap: wrap;
+ font-size: 0.875rem;
+}
+
+.device-entry {
+ display: flex;
+ align-items: center;
+ gap: 0.4rem;
+}
+
+.device-sep {
+ color: var(--text-secondary);
+}
+
+.device-ch-badge {
+ display: inline-block;
+ background: var(--accent-primary);
+ color: #fff;
+ font-size: 0.7rem;
+ font-weight: 600;
+ padding: 0.1rem 0.4rem;
+ border-radius: 10px;
+ letter-spacing: 0.02em;
+}
+
+.device-unset {
+ color: var(--text-secondary);
+ font-size: 0.875rem;
+}
+
+/* Channel labels */
.channel-names-grid {
display: grid;
@@ -901,21 +948,14 @@ body {
gap: 2rem;
}
-.channel-names-col-header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- margin-bottom: 0.75rem;
- padding-bottom: 0.5rem;
- border-bottom: 1px solid var(--border-color);
-}
-
-.channel-names-col-header h4 {
- font-size: 0.875rem;
+.channel-names-col h4 {
+ font-size: 0.8125rem;
color: var(--text-secondary);
text-transform: uppercase;
letter-spacing: 0.06em;
- margin: 0;
+ margin: 0 0 0.75rem;
+ padding-bottom: 0.5rem;
+ border-bottom: 1px solid var(--border-color);
}
.channel-names-list {
@@ -931,13 +971,79 @@ body {
}
.channel-index {
- min-width: 58px;
- font-size: 0.8125rem;
- color: var(--text-secondary);
+ min-width: 40px;
+ font-size: 0.8rem;
+ color: var(--accent-primary);
font-family: 'Courier New', monospace;
+ font-weight: 600;
flex-shrink: 0;
}
+/* Server Audio Users table */
+
+.sau-list {
+ margin-top: 1rem;
+}
+
+.sau-table {
+ width: 100%;
+ border-collapse: collapse;
+ font-size: 0.875rem;
+ margin-top: 0.75rem;
+}
+
+.sau-table th {
+ background: var(--bg-tertiary);
+ padding: 0.5rem 0.75rem;
+ text-align: left;
+ font-size: 0.8rem;
+ color: var(--text-secondary);
+ text-transform: uppercase;
+ letter-spacing: 0.05em;
+ border-bottom: 1px solid var(--border-color);
+}
+
+.sau-table td {
+ padding: 0.5rem 0.75rem;
+ border-bottom: 1px solid var(--border-color);
+ vertical-align: middle;
+}
+
+.sau-table tbody tr:hover td {
+ background: rgba(74, 158, 255, 0.04);
+}
+
+.sau-name {
+ font-weight: 600;
+ color: var(--text-primary);
+}
+
+.sau-actions {
+ text-align: right;
+ white-space: nowrap;
+ display: flex;
+ gap: 0.4rem;
+ justify-content: flex-end;
+}
+
+.ch-badge {
+ display: inline-block;
+ background: var(--bg-tertiary);
+ border: 1px solid var(--border-color);
+ color: var(--text-secondary);
+ font-size: 0.78rem;
+ padding: 0.1rem 0.5rem;
+ border-radius: 4px;
+ font-family: 'Courier New', monospace;
+}
+
+.ch-badge-group {
+ background: rgba(74, 158, 255, 0.12);
+ border-color: rgba(74, 158, 255, 0.3);
+ color: var(--accent-primary);
+ font-family: inherit;
+}
+
/* Routing actions bar */
.routing-actions {
diff --git a/server/bridge/AudioBridge.js b/server/bridge/AudioBridge.js
index b2c1856..a32eb50 100644
--- a/server/bridge/AudioBridge.js
+++ b/server/bridge/AudioBridge.js
@@ -17,8 +17,6 @@ import JACKBackend from './backends/JACKBackend.js';
import PipeWireBackend from './backends/PipeWireBackend.js';
import OpusCodec, { OpusPresets } from './OpusCodec.js';
import JitterBuffer, { JitterBufferPresets } from './JitterBuffer.js';
-import LiveKitClient from './LiveKitClient.js';
-import GroupAudioRouter from './GroupAudioRouter.js';
import ServerAudioUser from './ServerAudioUser.js';
export class AudioBridge extends EventEmitter {
@@ -55,8 +53,6 @@ export class AudioBridge extends EventEmitter {
this.opusEncoder = null;
this.opusDecoder = null;
this.jitterBuffer = null;
- this.liveKitClients = new Map(); // Map
- un client par groupe
- this.groupAudioRouter = null;
// État
this.isRunning = false;
@@ -64,10 +60,6 @@ export class AudioBridge extends EventEmitter {
// Buffers pour routing multi-canaux
this.inputChannelBuffers = new Map(); // Map
- this.groupBuffersFromLiveKit = new Map(); // Map
-
- // Frame accumulators pour LiveKit (240 samples → 960 samples)
- this.liveKitFrameAccumulators = new Map(); // Map
// Utilisateurs audio gérés côté serveur (participants LiveKit avec I/O physique dédiés)
this.serverAudioUsers = new Map(); // Map
@@ -118,16 +110,10 @@ export class AudioBridge extends EventEmitter {
// 3. Initialisation du jitter buffer
this._initJitterBuffer();
- // 4. Initialisation du GroupAudioRouter
- this._initGroupAudioRouter();
-
- // 5. Connexion à LiveKit
- await this._initLiveKit();
-
- // 6. Initialisation des server audio users
+ // 4. Initialisation des server audio users
await this._initServerAudioUsers();
- // 7. Démarrage du routing audio
+ // 5. Démarrage du routing audio
await this._startAudioRouting();
this.isRunning = true;
@@ -307,92 +293,6 @@ export class AudioBridge extends EventEmitter {
console.log(`✓ Jitter buffer : cible ${bufferConfig.targetSize} frames`);
}
- /**
- * Initialise le GroupAudioRouter pour le routing multi-canaux
- * @private
- */
- _initGroupAudioRouter() {
- this.groupAudioRouter = new GroupAudioRouter({
- sampleRate: this.options.sampleRate,
- frameSize: this.options.frameSize,
- maxInputChannels: this.options.maxInputChannels || 32,
- maxOutputChannels: this.options.maxOutputChannels || 32,
- groups: this.options.groups || []
- });
-
- // Charger la configuration de routing depuis les options
- if (this.options.routing) {
- this.groupAudioRouter.configure(this.options.routing);
- }
-
- // Events du router
- this.groupAudioRouter.on('configured', (stats) => {
- console.log(`✓ GroupAudioRouter configuré : ${stats.routesActive} routes`);
- });
-
- console.log('✓ GroupAudioRouter initialisé');
- }
-
- /**
- * Initialise les connexions LiveKit (une par groupe)
- * @private
- */
- async _initLiveKit() {
- if (!this.options.liveKitTokens || !Array.isArray(this.options.liveKitTokens)) {
- throw new Error('liveKitTokens requis (tableau d\'objets { groupName, groupId, token })');
- }
-
- console.log(`🔌 Initialisation ${this.options.liveKitTokens.length} connexions LiveKit (une par groupe)...`);
-
- // Créer un LiveKitClient pour chaque groupe
- for (const { groupName, groupId, token } of this.options.liveKitTokens) {
- const roomName = groupId; // La room porte le nom du groupId (slugifié)
-
- const client = new LiveKitClient({
- url: this.options.liveKitUrl,
- token,
- roomName,
- participantName: `AudioBridge-${groupId}`,
- sampleRate: this.options.sampleRate,
- channels: this.options.channels,
- audioBitrate: this.opusEncoder.options.bitrate
- });
-
- // Events LiveKit pour ce groupe
- client.on('connected', () => {
- console.log(`✓ LiveKit connecté pour groupe "${groupName}" (room: ${roomName})`);
- });
-
- client.on('disconnected', (data) => {
- const reason = data?.reason || 'unknown';
- console.warn(`⚠️ LiveKit déconnecté pour groupe "${groupName}":`, reason);
- this.stats.errors.network++;
- });
-
- client.on('reconnecting', () => {
- console.log(`🔄 LiveKit reconnexion pour groupe "${groupName}"...`);
- });
-
- client.on('audioTrackSubscribed', ({ track, participant }) => {
- console.log(`🎵 Nouveau track audio dans groupe "${groupName}": ${participant.identity}`);
- });
-
- // Réception audio depuis les clients LiveKit de ce groupe
- client.on('audioData', ({ participantName, pcmData, sampleRate, channels }) => {
- // Router vers le bon groupe
- this.emit('groupAudioIn', { groupName: groupId, pcmBuffer: pcmData });
- });
-
- // Connexion
- await client.connect();
-
- // Stocker le client par groupId
- this.liveKitClients.set(groupId, client);
- }
-
- console.log(`✓ ${this.liveKitClients.size} connexions LiveKit établies`);
- }
-
/**
* Initialise les utilisateurs audio serveur (participants LiveKit avec I/O physique)
* @private
@@ -445,44 +345,31 @@ export class AudioBridge extends EventEmitter {
}
/**
- * Démarre le routing audio bidirectionnel complet
+ * Démarre le routing audio : capture physique → server audio users
* @private
*/
async _startAudioRouting() {
- console.log('🔄 Démarrage routing audio bidirectionnel...');
+ console.log('🔄 Démarrage routing audio...');
- // ===== FLUX 1 : CAPTURE (Carte Son → Groupes → LiveKit → Clients) =====
this.audioBackend.on('audioData', (pcmData) => {
try {
- // Convertir PCM Buffer → Float32Array (pour GroupAudioRouter)
const float32Data = this._bufferToFloat32(pcmData);
-
- // Séparer les canaux si audio multi-canaux (entrelacé)
const numChannels = this.options.channels || 1;
if (numChannels === 1) {
- // Mono : un seul canal
- const channelId = this.options.inputDeviceChannel || 0;
- this.inputChannelBuffers.set(channelId, float32Data);
+ this.inputChannelBuffers.set(0, float32Data);
} else {
- // Multi-canaux : dé-entrelacer les samples
- // Format entrelacé : [L0, R0, L1, R1, ...] → [L0, L1, ...] et [R0, R1, ...]
const samplesPerChannel = float32Data.length / numChannels;
-
for (let ch = 0; ch < numChannels; ch++) {
const channelBuffer = new Float32Array(samplesPerChannel);
-
for (let i = 0; i < samplesPerChannel; i++) {
channelBuffer[i] = float32Data[i * numChannels + ch];
}
-
- // Mapper canal hardware → canal logique (peut être configuré)
- const logicalChannelId = this.options.channelMapping?.[ch] ?? ch;
- this.inputChannelBuffers.set(logicalChannelId, channelBuffer);
+ this.inputChannelBuffers.set(ch, channelBuffer);
}
}
- // ÉTAPE 0 : Envoyer les données de chaque canal vers les server audio users
+ // Alimenter chaque server audio user avec son canal d'entrée
for (const [, user] of this.serverAudioUsers) {
const channelData = this.inputChannelBuffers.get(user.inputChannel);
if (channelData) {
@@ -490,206 +377,18 @@ export class AudioBridge extends EventEmitter {
}
}
- // ÉTAPE 1 : Inputs physiques → Groupes (via GroupAudioRouter)
- const groupBuffers = this.groupAudioRouter.processInputsToGroups(
- this.inputChannelBuffers
- );
-
- if (this.stats.framesCapture % 100 === 0) {
- // Détecter si l'audio est du silence (toutes les samples < 0.001)
- let totalEnergy = 0;
- this.inputChannelBuffers.forEach((buffer) => {
- for (let i = 0; i < buffer.length; i++) {
- totalEnergy += Math.abs(buffer[i]);
- }
- });
- const avgEnergy = totalEnergy / (this.inputChannelBuffers.size * (this.options.frameSize || 960));
- console.log(`[AudioBridge] Frame ${this.stats.framesCapture}: ${this.inputChannelBuffers.size} inputs → ${groupBuffers.size} groupes | Énergie audio: ${avgEnergy.toFixed(6)}`);
- }
-
- // ÉTAPE 2 : Pour chaque groupe, envoyer vers le LiveKitClient correspondant
- groupBuffers.forEach((groupBuffer, groupName) => {
- // Les groupes sont MONO (Float32Array de N samples)
- // Mais la config globale peut être STÉRÉO (channels=2)
- // → Adapter selon la configuration
-
- let pcmBuffer;
- const configChannels = this.options.channels || 1;
-
- if (configChannels === 1) {
- // Config MONO : envoyer directement
- pcmBuffer = this._float32ToBuffer(groupBuffer);
- } else if (configChannels === 2) {
- // Config STÉRÉO : dupliquer le canal mono
- const samplesPerChannel = groupBuffer.length;
- const stereoBuffer = new Float32Array(samplesPerChannel * 2);
-
- // Entrelacer : [M0, M1, M2, ...] → [M0, M0, M1, M1, M2, M2, ...]
- for (let i = 0; i < samplesPerChannel; i++) {
- stereoBuffer[i * 2] = groupBuffer[i]; // Canal gauche
- stereoBuffer[i * 2 + 1] = groupBuffer[i]; // Canal droit (dupliqué)
- }
-
- pcmBuffer = this._float32ToBuffer(stereoBuffer);
- } else {
- console.error(`❌ Nombre de canaux non supporté: ${configChannels}`);
- return;
- }
-
- // Récupérer le client LiveKit pour ce groupe
- const client = this.liveKitClients.get(groupName);
-
- // Envoi vers LiveKit via sendAudioData (prend du PCM 16-bit)
- // Note: LiveKit gère lui-même l'encodage Opus en interne
- if (client && client.isConnected) {
- client.sendAudioData(pcmBuffer);
- if (this.stats.framesCapture % 100 === 0) {
- const channelLabel = configChannels === 1 ? 'mono' : `${configChannels}ch`;
- console.log(`[AudioBridge] → LiveKit groupe "${groupName}": ${pcmBuffer.length} bytes (${channelLabel})`);
- }
- } else {
- if (this.stats.framesCapture % 100 === 0) {
- console.log(`[AudioBridge] ⚠️ LiveKit non connecté pour groupe "${groupName}", audio non envoyé`);
- }
- }
-
- // Émettre aussi pour monitoring/debug
- this.emit('groupAudioOut', { groupName, pcmBuffer });
- });
-
- // ÉTAPE 3 : Loopback local - Groupes → Outputs physiques (sans passer par LiveKit)
- const outputBuffers = this.groupAudioRouter.processGroupsToOutputs(groupBuffers);
-
- if (this.stats.framesCapture % 100 === 0) {
- console.log(`[AudioBridge] Loopback local: ${groupBuffers.size} groupes → ${outputBuffers.size} outputs`);
- }
-
- // ÉTAPE 4 : Envoyer chaque output à la carte son
- const numOutputChannels = this.options.channels || 1;
-
- if (numOutputChannels === 1) {
- // Mono : un seul output
- if (outputBuffers.size > 0) {
- const [firstChannelId, outputBuffer] = outputBuffers.entries().next().value;
- const pcmBuffer = this._float32ToBuffer(outputBuffer);
- this.audioBackend.queueAudio(pcmBuffer);
-
- if (this.stats.framesCapture % 100 === 0) {
- console.log(`[AudioBridge] → Output mono (canal ${firstChannelId}): ${pcmBuffer.length} bytes`);
- }
- }
- } else {
- // Multi-canaux : entrelacer les samples
- // Récupérer les buffers dans l'ordre des canaux hardware
- const channelBuffers = [];
- const samplesPerChannel = this.options.frameSize;
-
- for (let ch = 0; ch < numOutputChannels; ch++) {
- const logicalChannelId = this.options.channelMapping?.[ch] ?? ch;
- const buffer = outputBuffers.get(logicalChannelId);
-
- if (buffer && buffer.length === samplesPerChannel) {
- channelBuffers.push(buffer);
- } else {
- // Canal absent ou taille incorrecte : silence
- channelBuffers.push(new Float32Array(samplesPerChannel));
- }
- }
-
- // Entrelacer : [L0, L1, ...] et [R0, R1, ...] → [L0, R0, L1, R1, ...]
- const interleavedBuffer = new Float32Array(samplesPerChannel * numOutputChannels);
-
- for (let i = 0; i < samplesPerChannel; i++) {
- for (let ch = 0; ch < numOutputChannels; ch++) {
- interleavedBuffer[i * numOutputChannels + ch] = channelBuffers[ch][i];
- }
- }
-
- const pcmBuffer = this._float32ToBuffer(interleavedBuffer);
- this.audioBackend.queueAudio(pcmBuffer);
-
- if (this.stats.framesCapture % 100 === 0) {
- console.log(`[AudioBridge] → Output multi-canaux (${numOutputChannels}ch): ${pcmBuffer.length} bytes`);
- }
- }
-
this.stats.framesCapture++;
- this.stats.framesPlayback++;
} catch (error) {
console.error('Erreur routing capture:', error);
this.stats.errors.capture++;
}
});
- // ===== FLUX 2 : LECTURE (Clients → LiveKit → Groupes → Carte Son) =====
-
- // Écouter l'audio entrant de LiveKit (sera connecté par LiveKitServerBridge)
- this.on('groupAudioIn', ({ groupName, pcmBuffer }) => {
- try {
- // Convertir PCM Buffer → Float32Array
- const float32Data = this._bufferToFloat32(pcmBuffer);
- const samplesReceived = float32Data.length;
-
- // Initialiser l'accumulateur pour ce groupe si nécessaire
- if (!this.liveKitFrameAccumulators.has(groupName)) {
- this.liveKitFrameAccumulators.set(groupName, {
- buffer: new Float32Array(960), // Frame size attendu par GroupRouter
- offset: 0
- });
- }
-
- const accumulator = this.liveKitFrameAccumulators.get(groupName);
-
- // Vérifier que le buffer ne débordera pas
- const availableSpace = 960 - accumulator.offset;
- const samplesToCopy = Math.min(samplesReceived, availableSpace);
-
- // Copier les samples dans l'accumulateur
- if (samplesToCopy > 0) {
- accumulator.buffer.set(float32Data.subarray(0, samplesToCopy), accumulator.offset);
- accumulator.offset += samplesToCopy;
- }
-
- // Si on a accumulé assez de samples (960), router vers les outputs
- if (accumulator.offset >= 960) {
- // Vérifier que le backend est toujours actif (évite crash pendant shutdown)
- if (!this.audioBackend) {
- return;
- }
-
- // Stocker le buffer complet pour le routing
- this.groupBuffersFromLiveKit.set(groupName, accumulator.buffer);
-
- // ÉTAPE 3 : Groupes → Outputs physiques (via GroupAudioRouter)
- const outputBuffers = this.groupAudioRouter.processGroupsToOutputs(
- this.groupBuffersFromLiveKit
- );
-
- // ÉTAPE 4 : Envoyer chaque output à la carte son
- outputBuffers.forEach((outputBuffer, channelId) => {
- const pcmBuffer = this._float32ToBuffer(outputBuffer);
- this.audioBackend.queueAudio(pcmBuffer);
- });
-
- // Réinitialiser l'accumulateur
- accumulator.offset = 0;
- accumulator.buffer.fill(0);
-
- this.stats.framesPlayback++;
- }
- } catch (error) {
- console.error('Erreur routing lecture:', error);
- this.stats.errors.playback++;
- }
- });
-
- // Démarrage des streams audio
await this.audioBackend.startCapture();
await this.audioBackend.startPlayback();
- console.log('✓ Routing audio bidirectionnel actif');
- console.log(' → Carte Son → GroupRouter → LiveKit → Clients');
- console.log(' ← Carte Son ← GroupRouter ← LiveKit ← Clients');
+ console.log('✓ Routing audio actif');
+ console.log(' → Carte Son → Server Audio Users → LiveKit → Clients');
}
/**
@@ -819,13 +518,6 @@ export class AudioBridge extends EventEmitter {
this.audioBackend = null;
}
- // Déconnecter tous les clients LiveKit
- for (const [groupName, client] of this.liveKitClients.entries()) {
- console.log(`🔌 Déconnexion LiveKit groupe "${groupName}"...`);
- await client.destroy();
- }
- this.liveKitClients.clear();
-
// Arrêter les server audio users
for (const [name, user] of this.serverAudioUsers.entries()) {
console.log(`🔌 Arrêt server audio user "${name}"...`);
@@ -833,11 +525,6 @@ export class AudioBridge extends EventEmitter {
}
this.serverAudioUsers.clear();
- if (this.groupAudioRouter) {
- this.groupAudioRouter.destroy();
- this.groupAudioRouter = null;
- }
-
if (this.jitterBuffer) {
this.jitterBuffer.destroy();
this.jitterBuffer = null;
@@ -855,7 +542,6 @@ export class AudioBridge extends EventEmitter {
// Nettoyer les buffers
this.inputChannelBuffers.clear();
- this.groupBuffersFromLiveKit.clear();
// Nettoyer le pool de buffers
this.bufferPool.float32 = [];
diff --git a/server/bridge/AudioBridgeManager.js b/server/bridge/AudioBridgeManager.js
index 112f406..e79e0af 100644
--- a/server/bridge/AudioBridgeManager.js
+++ b/server/bridge/AudioBridgeManager.js
@@ -34,15 +34,12 @@ class AudioBridgeManager extends EventEmitter {
const config = configManager.get();
console.log('🎵 Démarrage AudioBridge avec configuration:', config.audio);
- // Générer un token JWT par groupe
- const liveKitTokens = [];
-
// Fonction pour slugifier le nom (identique à admin.js)
const slugify = (text) => {
return text
.toString()
.normalize('NFD')
- .replace(/[\u0300-\u036f]/g, '')
+ .replace(/[̀-ͯ]/g, '')
.toLowerCase()
.trim()
.replace(/\s+/g, '-')
@@ -50,45 +47,6 @@ class AudioBridgeManager extends EventEmitter {
.replace(/--+/g, '-');
};
- for (const group of config.groups || []) {
- const groupId = slugify(group.name);
- const groupName = group.name;
-
- const token = new AccessToken(
- config.server?.livekit?.apiKey || 'devkey',
- config.server?.livekit?.apiSecret || 'secret',
- {
- identity: `AudioBridge-${groupId}`,
- name: `Audio Bridge - ${groupName}`,
- metadata: JSON.stringify({
- role: 'bridge',
- group: groupId,
- capabilities: ['audio-routing', 'monitoring']
- })
- }
- );
-
- // Permissions complètes pour ce groupe
- token.addGrant({
- room: groupId, // Chaque groupe a sa propre room
- roomJoin: true,
- canPublish: true,
- canSubscribe: true,
- canPublishData: true
- });
-
- const jwt = await token.toJwt();
- liveKitTokens.push({ groupName, groupId, token: jwt });
-
- console.log(`✓ Token JWT généré pour groupe "${groupName}" (room: ${groupId})`);
- }
-
- if (liveKitTokens.length === 0) {
- console.warn('⚠️ Aucun groupe configuré, AudioBridge ne pourra pas démarrer');
- this.isRunning = false;
- return;
- }
-
// Générer un token JWT par server audio user
const serverAudioUsers = [];
@@ -118,11 +76,13 @@ class AudioBridgeManager extends EventEmitter {
const jwt = await token.toJwt();
+ const outputChannel = user.output_channel ?? user.outputChannel;
+
serverAudioUsers.push({
name: user.name,
groupId,
inputChannel: user.input_channel ?? user.inputChannel ?? 0,
- outputChannel: user.output_channel ?? user.outputChannel ?? 0,
+ outputChannel: outputChannel !== null && outputChannel !== undefined ? outputChannel : null,
token: jwt
});
@@ -160,17 +120,11 @@ class AudioBridgeManager extends EventEmitter {
// Créer l'instance avec la config
this.bridge = new AudioBridge({
...audioConfig,
- // Options LiveKit (multi-rooms)
liveKitUrl,
- liveKitTokens, // Tableau de { groupName, groupId, token }
- // Server audio users
serverAudioUsers,
- // Options de routing
- routing: config.audio?.routing || {},
groups: config.groups || [],
maxInputChannels: 32,
maxOutputChannels: 32,
- // Device IDs extraits
inputDeviceId,
outputDeviceId
});
diff --git a/server/bridge/ServerAudioUser.js b/server/bridge/ServerAudioUser.js
index 7083612..231b223 100644
--- a/server/bridge/ServerAudioUser.js
+++ b/server/bridge/ServerAudioUser.js
@@ -18,7 +18,9 @@ class ServerAudioUser extends EventEmitter {
this.name = options.name;
this.inputChannel = parseInt(options.inputChannel, 10);
- this.outputChannel = parseInt(options.outputChannel, 10);
+ this.outputChannel = (options.outputChannel !== null && options.outputChannel !== undefined)
+ ? parseInt(options.outputChannel, 10)
+ : null;
this.groupId = options.groupId;
this.frameSize = options.frameSize || 960;
this.sampleRate = options.sampleRate || 48000;
@@ -43,7 +45,7 @@ class ServerAudioUser extends EventEmitter {
_setupClientEvents() {
this.client.on('connected', () => {
- console.log(`[ServerAudioUser:${this.name}] Connecté à room "${this.groupId}" (in:${this.inputChannel} → out:${this.outputChannel})`);
+ console.log(`[ServerAudioUser:${this.name}] Connecté à room "${this.groupId}" (in:${this.inputChannel} → out:${this.outputChannel ?? 'aucune'})`);
this.emit('connected');
});
@@ -139,7 +141,9 @@ class ServerAudioUser extends EventEmitter {
}
this.mixedOutput = mix;
- this.emit('outputReady', mix);
+ if (this.outputChannel !== null) {
+ this.emit('outputReady', mix);
+ }
}
/**
diff --git a/server/config/config.yaml b/server/config/config.yaml
index e9e8ac5..d562913 100644
--- a/server/config/config.yaml
+++ b/server/config/config.yaml
@@ -6,55 +6,22 @@ audio:
jitterBufferMs: 40
device:
inputDeviceId: Loopback Audio 4
- outputDeviceId: Haut-parleurs MacBook Pro
+ outputDeviceId: Périphérique agrégé
sampleRate: 48000
- routing:
- inputToGroup:
- "0":
- - default
- "1": []
- "2": []
- "4":
- - technique
- "5":
- - technique
- groupToOutput:
- technique:
- - "1"
- production:
- - "0"
- - "1"
- default:
- - "0"
- gains: {}
channelNames:
inputs:
- "0": Mac
- "1": Talkback FOH
- "2": Retour Console
- "3": Liaison Scène
- "4": Monitor Mix
- "5": Spare 1
+ "0": Loopback L
+ "1": Loopback R
outputs:
- "0": L
- "1": R
- "2": Talkback Console
-# Utilisateurs audio gérés côté serveur.
-# Chaque entrée crée un participant LiveKit indépendant avec un canal physique
-# d'entrée (microphone/ligne) et un canal physique de sortie dédié (mix-minus naturel).
-#
-# Exemple (décommenter et adapter) :
-# server_audio_users:
-# - name: foh
-# group: default # ID du groupe LiveKit (room) à rejoindre
-# input_channel: 1 # Index canal physique d'entrée (depuis inputDeviceId)
-# output_channel: 2 # Index canal physique de sortie (vers outputDeviceId)
-# - name: returns
-# group: default
-# input_channel: 2
-# output_channel: 3
-server_audio_users: []
-
+ "0": Casque L
+ "1": Casque R
+ "2": Mac L
+ "3": Mac R
+server_audio_users:
+ - name: Utilisateur Serveur
+ group: default
+ input_channel: 0
+ output_channel: 0
groups:
- name: Default
audioBitrate: 96
diff --git a/server/index.js b/server/index.js
index 63eafe2..3cfdb07 100644
--- a/server/index.js
+++ b/server/index.js
@@ -334,30 +334,12 @@ apiRouter.post('/token', async (req, res) => {
// Enregistrer l'utilisateur dans le système admin
registerUser(participantIdentity, username, groupId, roomName);
- // Générer les canaux virtuels depuis le routing (inputs uniquement)
- const virtualChannels = [];
- const inputToGroup = config.audio?.routing?.inputToGroup || {};
- const channelNames = config.audio?.channelNames?.inputs || {};
-
- // Trouver tous les canaux physiques routés vers ce groupe
- for (const [inputChannel, groups] of Object.entries(inputToGroup)) {
- if (groups.includes(groupId)) {
- const channelName = channelNames[inputChannel] || `Canal ${inputChannel}`;
- virtualChannels.push({
- id: `input-${inputChannel}`,
- name: channelName,
- isVirtual: true,
- audioInput: parseInt(inputChannel, 10)
- });
- }
- }
-
res.json({
token,
url: LIVEKIT_URL,
roomName,
participantIdentity,
- virtualChannels
+ virtualChannels: []
});
} catch (error) {