This commit is contained in:
legop3
2025-11-14 22:39:51 -05:00
parent 835850e686
commit 6cfdde30ea
3 changed files with 24 additions and 5 deletions
+1 -1
View File
@@ -79,7 +79,7 @@ The script must be executed via `sudo` from the user that owns the repo. It will
Publishing rovers lives on a trusted network, so the shipped config (tracked at `server/mediamtx/mediamtx.yml`) skips HTTP auth for SRT ingest and whitelists any path that matches `rover-*`. The installer overwrites `/etc/mediamtx/mediamtx.yml` every time you run it—if you need to tweak ports or add TURN servers, edit the template in the repo and rerun `install_server.sh` so every box stays in sync automatically. Publishing rovers lives on a trusted network, so the shipped config (tracked at `server/mediamtx/mediamtx.yml`) skips HTTP auth for SRT ingest and whitelists any path that matches `rover-*`. The installer overwrites `/etc/mediamtx/mediamtx.yml` every time you run it—if you need to tweak ports or add TURN servers, edit the template in the repo and rerun `install_server.sh` so every box stays in sync automatically.
Once finished, update `server/config.yaml` with your admin passwords and `media.whepBaseUrl` (`http://192.168.0.86:8889/whep`). Restart `multirover.service` whenever you edit the config. To pull updates later, just `git pull`, re-run `npm install --production` inside `server/`, and restart the service—no need to rerun the installer. Once finished, update `server/config.yaml` with your admin passwords and `media.whepBaseUrl` (`http://192.168.0.86:8889/whep`). The UI appends the rover ID to whatever you provide; if you prefer a different layout, include `{roverId}` or `{id}` in the URL (for example `http://192.168.0.86:8889/{id}/whep`). Restart `multirover.service` whenever you edit the config. To pull updates later, just `git pull`, re-run `npm install --production` inside `server/`, and restart the service—no need to rerun the installer.
### Video handshake + diagnostics ### Video handshake + diagnostics
+4
View File
@@ -8,4 +8,8 @@ admins:
discord_id: "0987654321" discord_id: "0987654321"
lockdown: true lockdown: true
media: media:
# Base URL for mediaMTX WHEP publishes. Append the rover ID automatically, or embed {roverId}/{id}.
# Examples:
# http://192.168.0.86:8889/whep -> becomes http://192.168.0.86:8889/whep/<roverId>
# http://192.168.0.86:8889/{id}/whep -> becomes http://192.168.0.86:8889/Freaky/whep
whepBaseUrl: "http://192.168.0.86:8889/whep" whepBaseUrl: "http://192.168.0.86:8889/whep"
+19 -4
View File
@@ -9,6 +9,21 @@ const { loadConfig } = require('../helpers/configLoader');
const config = loadConfig(); const config = loadConfig();
const mediaConfig = config.media || {}; const mediaConfig = config.media || {};
function buildWhepUrl(roverId) {
const base = mediaConfig.whepBaseUrl;
if (!base) {
return '';
}
const encodedId = encodeURIComponent(roverId);
if (base.includes('{roverId}')) {
return base.replace(/\{roverId\}/g, encodedId);
}
if (base.includes('{id}')) {
return base.replace(/\{id\}/g, encodedId);
}
return `${base.replace(/\/$/, '')}/${encodedId}`;
}
function canView(socket, roverId) { function canView(socket, roverId) {
const mode = getMode(); const mode = getMode();
if (mode === MODES.LOCKDOWN && !isLockdownAdmin(socket)) { if (mode === MODES.LOCKDOWN && !isLockdownAdmin(socket)) {
@@ -27,9 +42,6 @@ function canView(socket, roverId) {
io.on('connection', (socket) => { io.on('connection', (socket) => {
socket.on('video:request', ({ roverId } = {}, cb = () => {}) => { socket.on('video:request', ({ roverId } = {}, cb = () => {}) => {
try { try {
if (!mediaConfig.whepBaseUrl) {
throw new Error('Server video base URL missing');
}
if (!roverId) { if (!roverId) {
throw new Error('roverId required'); throw new Error('roverId required');
} }
@@ -39,8 +51,11 @@ io.on('connection', (socket) => {
if (!canView(socket, roverId)) { if (!canView(socket, roverId)) {
throw new Error('Not authorized for video'); throw new Error('Not authorized for video');
} }
const url = buildWhepUrl(roverId);
if (!url) {
throw new Error('Server video base URL missing');
}
const sessionId = videoSessions.createSession(socket, roverId); const sessionId = videoSessions.createSession(socket, roverId);
const url = `${mediaConfig.whepBaseUrl.replace(/\/$/, '')}/${roverId}`;
cb({ url, token: sessionId }); cb({ url, token: sessionId });
} catch (err) { } catch (err) {
logger.warn('video request failed: %s', err.message); logger.warn('video request failed: %s', err.message);