diff --git a/ROADMAP.md b/ROADMAP.md index edf6d2b..288aa72 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -27,15 +27,9 @@ This roadmap is intentionally outcome-focused. It does not promise fixed dates. does not document, so the wire format was derived from observed behavior and may break with any TS6 update. Connection setup, picture quality, and viewer admission are not yet dependable. The "Server" connection mode (TS6's SFU) is - not implemented; only direct P2P works. The UI is gated by a build-time flag, - because the hosted client updates on every push while the gateway image is - deployed by hand, and a browser that offers streaming to a gateway too old to - answer waits forever instead of reporting an error — on since 2026-09-11 for - client.webspeak3.de now that its gateway answers setupStream/joinStream/ - sendStreamSignal (v0.11.0-beta.1+). The durable fix is a capability handshake - so the client can detect what its gateway supports rather than assuming; - until then the flag is flipped by hand whenever the frontend gains a stream - feature the deployed gateway doesn't have yet. + not implemented; only direct P2P works. Streaming needs a gateway from v0.11.0-beta.1 + on; since v0.15 the gateway announces its features when the browser connects, + so newer features stay hidden behind an older gateway instead of hanging. - Safari and Mobile Safari audio/microphone behavior - Uncommon TeamSpeak permission combinations and large permission sets - Very large servers and long-running browser sessions diff --git a/connector/src/main.rs b/connector/src/main.rs index 1d6ae5a..82bd98f 100644 --- a/connector/src/main.rs +++ b/connector/src/main.rs @@ -976,6 +976,10 @@ async fn run(args: Args) -> Result<()> { )?; let mut audio_handler = AudioHandler::::new(); let mut talking: HashSet = HashSet::new(); + // Per-speaker playback volume set by the browser (`clientvolume`). Kept + // outside the AudioHandler because its queues only live while someone + // talks; a new queue picks its volume up from here. + let mut client_volumes: HashMap = HashMap::new(); let mut audio_ticker = tokio::time::interval(tokio::time::Duration::from_millis(20)); // Commands sent via `send()` fail silently if the server rejects them (e.g. // missing permission) - no reply is sent back without a return code. Using @@ -1311,6 +1315,28 @@ async fn run(args: Args) -> Result<()> { if let Err(e) = part.send(&mut con) { emit(&Event::Error { message: e.to_string() }); } + } else if let Some(rest) = l.strip_prefix("clientvolume ") { + // `clientvolume `, 1 = unchanged, 0 = silent. + let mut parts = rest.split_whitespace(); + match ( + parts.next().and_then(|v| v.parse::().ok()), + parts.next().and_then(|v| v.parse::().ok()).filter(|v| v.is_finite()), + ) { + (Some(clid), Some(volume)) => { + let volume = volume.clamp(0.0, 2.0); + if volume == 1.0 { + client_volumes.remove(&clid); + } else { + client_volumes.insert(clid, volume); + } + if let Some(queue) = audio_handler.get_mut_queues().get_mut(&ClientId(clid)) { + queue.volume = volume; + } + } + _ => emit(&Event::Error { + message: format!("Malformed clientvolume command: {rest}"), + }), + } } else if let Some(rest) = l.strip_prefix("nickname ") { let part = con.get_state()?.client_update().set_name(rest.trim()); if let Err(e) = part.send(&mut con) { @@ -2536,6 +2562,12 @@ async fn run(args: Args) -> Result<()> { }; if let Some(from) = from { if let Ok(Some(new_talker)) = audio_handler.handle_packet(from, packet) { + if let (Some(&volume), Some(queue)) = ( + client_volumes.get(&new_talker.0), + audio_handler.get_mut_queues().get_mut(&new_talker), + ) { + queue.volume = volume; + } if talking.insert(new_talker.0) { emit(&Event::Talkers { clients: talking.iter().copied().collect() }); } diff --git a/gateway/src/index.ts b/gateway/src/index.ts index 6ff473b..9d4b448 100644 --- a/gateway/src/index.ts +++ b/gateway/src/index.ts @@ -115,6 +115,9 @@ const SERVE_STATIC = process.env.WEB_STATIC !== "0"; // issue #12): set on the container, these end up in the served index.html as // tags the client reads at startup, so changing them needs no rebuild. // Meta tags rather than an inline script, which CONTENT_SECURITY_POLICY forbids. +// Sent to every browser in the "hello" message on socket open; see there. +const GATEWAY_FEATURES = ["clientVolume"]; + const RUNTIME_CONFIG_META = Object.entries({ "webspeak3-default-server": process.env.DEFAULT_SERVER, "webspeak3-default-channel": process.env.DEFAULT_CHANNEL, @@ -628,6 +631,12 @@ wss.on("connection", (socket: WebSocket, req: IncomingMessage) => { const ip = clientIp(req); connectionsPerIp.set(ip, (connectionsPerIp.get(ip) ?? 0) + 1); + // The hosted UI updates on every push, the gateway only when its image is + // pulled, so the browser must not assume a feature exists just because it + // knows about it. A gateway without "hello" (before v0.15) supports the + // v0.14 feature set, streaming included; anything newer gets a name here. + socket.send(JSON.stringify({ type: "hello", features: GATEWAY_FEATURES })); + heartbeats.set(socket, { isAlive: true }); socket.on("pong", () => { const state = heartbeats.get(socket); @@ -809,6 +818,10 @@ wss.on("connection", (socket: WebSocket, req: IncomingMessage) => { await connection?.setOutputMuted(msg.muted); break; } + case "setClientVolume": { + connection?.setClientVolume(Number(msg.clientId), Number(msg.volume)); + break; + } case "setNickname": { await connection?.setNickname(msg.nickname); break; diff --git a/gateway/src/ts3/connection.ts b/gateway/src/ts3/connection.ts index 5c69a30..f5d3c20 100644 --- a/gateway/src/ts3/connection.ts +++ b/gateway/src/ts3/connection.ts @@ -930,6 +930,11 @@ export class Ts3Connection { this.writeLine(`muteoutput ${muted ? "1" : "0"}`); } + /** Playback volume for one speaker, mixed in the connector (1 = unchanged). */ + setClientVolume(clientId: number, volume: number): void { + if (Number.isInteger(clientId) && Number.isFinite(volume)) this.writeLine(`clientvolume ${clientId} ${volume}`); + } + async setNickname(nickname: string): Promise { const sanitized = nickname.replace(/[\r\n]+/g, " ").trim(); if (sanitized) this.writeLine(`nickname ${sanitized}`); diff --git a/web/src/App.css b/web/src/App.css index 378c628..782a9e0 100644 --- a/web/src/App.css +++ b/web/src/App.css @@ -1417,6 +1417,17 @@ flex: 1; } +.ts-menu-volume input { + flex: 1; + min-width: 6rem; +} + +.ts-menu-volume-value { + min-width: 2.6rem; + text-align: right; + color: var(--text-muted); +} + .ts-menu-item-shortcut { color: var(--text-muted); } diff --git a/web/src/App.tsx b/web/src/App.tsx index 7ba411d..b680094 100644 --- a/web/src/App.tsx +++ b/web/src/App.tsx @@ -536,6 +536,18 @@ interface Contact { } const CONTACTS_KEY = "webspeak3:contacts"; +// Per-speaker playback volume by client UID (1 = unchanged), mixed in the +// connector. Keyed by UID so it follows a person across servers and reconnects. +const CLIENT_VOLUMES_KEY = "webspeak3:client-volumes"; + +function loadClientVolumes(): Record { + try { + const raw = localStorage.getItem(CLIENT_VOLUMES_KEY); + return raw ? (JSON.parse(raw) as Record) : {}; + } catch { + return {}; + } +} function loadContacts(): Contact[] { try { @@ -1798,25 +1810,6 @@ const RESOLUTION_CHOICES = [360, 480, 720, 1080, 1440, 0]; const FPS_CHOICES = [5, 30, 60]; const AUDIO_BITRATE_CHOICES = [64, 96, 128, 192, 256, 320]; -// Kill switch for the streaming UI. -// -// The frontend and the gateway ship on different schedules: client.webspeak3.de -// is rebuilt by Cloudflare Pages on every push to main, while the gateway and -// connector are a Docker image that has to be pulled onto the host by hand. So -// right after a release the browser can already know about setupStream while -// the gateway it talks to does not - and an unsupported setupStream is not an -// error, it is silence: the publish panel waits at "starting" forever, after -// the browser has already asked the user to share a screen. -// -// Flip this to false again whenever the frontend gains a stream feature the -// deployed gateway does not have yet, and back once it has caught up. The -// durable fix is a capability handshake so the client can tell on its own; -// see ROADMAP.md. -// -// On since 2026-09-11: the gateway on client.webspeak3.de was rebuilt on the -// v0.11.0-beta.1 image and answers setupStream/joinStream/sendStreamSignal. -const STREAM_UI_ENABLED = true; - // Streaming talks to TS6 over a protocol nobody published, so it is marked // alpha everywhere the user can reach it: the settings dialog, both stream // panels, and the toolbar button's tooltip. @@ -6378,6 +6371,9 @@ function AppInner() { // Gateway-broadcast "notice" (currently: SIGTERM restart warning). Global, // not per-session - it should show no matter which tab is active. const [restartNotice, setRestartNotice] = useState(null); + // What the gateway announced in its "hello" (gateway/src/index.ts). Empty for + // a gateway older than the handshake, so a feature newer than it stays hidden. + const [gatewayFeatures, setGatewayFeatures] = useState>(new Set()); // Terms of use, own-hosted instance only (see IS_OWN_HOSTED_INSTANCE): shown // mandatorily on first visit, reopenable any time from the menu afterwards. const [tosOpen, setTosOpen] = useState(false); @@ -6395,6 +6391,7 @@ function AppInner() { const [connectError, setConnectError] = useState(null); const [channels, setChannels] = useState([]); const [clients, setClients] = useState([]); + const [clientVolumes, setClientVolumes] = useState>(loadClientVolumes); /** Stream metadata per publishing client id, keyed by clid. */ const [streamInfos, setStreamInfos] = useState>({}); const [watchedStream, setWatchedStream] = useState(null); @@ -6702,6 +6699,27 @@ function AppInner() { localStorage.setItem(CONTACTS_KEY, JSON.stringify(contacts)); }, [contacts]); + useEffect(() => { + localStorage.setItem(CLIENT_VOLUMES_KEY, JSON.stringify(clientVolumes)); + }, [clientVolumes]); + + // Push each visible client's volume to its connector. Remembered per socket, + // so a reconnect (fresh connector) resends everything, and a client id reused + // by someone else gets reset to that person's volume. + const sentClientVolumesRef = useRef(new WeakMap>()); + useEffect(() => { + const socket = socketRef.current; + if (!socket || !connected || !gatewayFeatures.has("clientVolume")) return; + let sent = sentClientVolumesRef.current.get(socket); + if (!sent) sentClientVolumesRef.current.set(socket, (sent = new Map())); + for (const c of clients) { + const volume = clientVolumes[c.uid] ?? 1; + if ((sent.get(c.id) ?? 1) === volume) continue; + socket.send(JSON.stringify({ type: "setClientVolume", clientId: c.id, volume })); + sent.set(c.id, volume); + } + }, [clients, clientVolumes, connected, gatewayFeatures]); + useEffect(() => { localStorage.setItem(WHISPER_LISTS_KEY, JSON.stringify(whisperLists)); }, [whisperLists]); @@ -7219,6 +7237,10 @@ function AppInner() { setRestartNotice(data.messageKey ? t(data.messageKey) : String(data.message || "")); return; } + if (data.type === "hello") { + setGatewayFeatures(new Set(Array.isArray(data.features) ? data.features : [])); + return; + } // Inactive tab: update parked snapshot only (no audio playback). if (sessionId !== activeSessionIdRef.current) { @@ -10112,7 +10134,6 @@ function AppInner() { onChange={(e) => setVadThreshold(Number(e.target.value))} /> - {STREAM_UI_ENABLED && ( - )} - {STREAM_UI_ENABLED && !clientContextMenu.isSelf && streamInfos[clientContextMenu.clientId] && ( + {!clientContextMenu.isSelf && + gatewayFeatures.has("clientVolume") && + (() => { + const uid = clients.find((c) => c.id === clientContextMenu.clientId)?.uid; + if (!uid) return null; + const percent = Math.round((clientVolumes[uid] ?? 1) * 100); + return ( + + ); + })()} + {!clientContextMenu.isSelf && streamInfos[clientContextMenu.clientId] && (