no config only profiles

This commit is contained in:
legop3
2026-11-17 20:51:07 -05:00
parent 14f425744a
commit 0ea99d0158
13 changed files with 99 additions and 131 deletions
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+2 -7
View File
@@ -13,22 +13,17 @@ Enabled profiles run setup serially, then stream independently. Setup failure st
## Command variables ## Command variables
Variables are supplied through the environment. Quote expansions normally, for example `"$ROVER_VIDEO_DEVICE"`. Variables are supplied through the environment. Quote expansions normally, for example `"$ROVER_AUDIO_INPUT_DEVICE"`.
| Variables | Meaning | | Variables | Meaning |
| --- | --- | | --- | --- |
| `ROVER_NAME`, `ROVER_SERVER_HOST` | Identity and server hostname | | `ROVER_NAME`, `ROVER_SERVER_HOST` | Identity and server hostname |
| `ROVER_PROFILE_DIR`, `ROVER_REPO_DIR` | Persistent working directory and checkout | | `ROVER_PROFILE_DIR`, `ROVER_REPO_DIR` | Persistent working directory and checkout |
| `ROVER_VIDEO_DEVICE`, `ROVER_VIDEO_INPUT_FORMAT` | Camera input |
| `ROVER_VIDEO_WIDTH`, `ROVER_VIDEO_HEIGHT`, `ROVER_VIDEO_FPS`, `ROVER_VIDEO_BITRATE` | Camera/encoder settings |
| `ROVER_VIDEO_INVERTED`, `ROVER_VIDEO_SENSOR_MODE` | Orientation and optional rpicam mode |
| `ROVER_VIDEO_PUBLISH_URL`, `ROVER_AUDIO_PUBLISH_URL`, `ROVER_AUDIO_PLAYBACK_URL` | Complete derived RTSP URLs | | `ROVER_VIDEO_PUBLISH_URL`, `ROVER_AUDIO_PUBLISH_URL`, `ROVER_AUDIO_PLAYBACK_URL` | Complete derived RTSP URLs |
| `ROVER_AUDIO_INPUT_DEVICE`, `ROVER_AUDIO_OUTPUT_DEVICE` | Generated logical ALSA microphone and forwarded-audio routes | | `ROVER_AUDIO_INPUT_DEVICE`, `ROVER_AUDIO_OUTPUT_DEVICE` | Generated logical ALSA microphone and forwarded-audio routes |
| `ROVER_AUDIO_SAMPLE_RATE`, `ROVER_AUDIO_CHANNELS`, `ROVER_AUDIO_BITRATE` | Microphone encoding settings |
| `ROVER_AUDIO_NORMALIZE`, `ROVER_AUDIO_NORMALIZE_FILTER` | Forwarded-audio normalization |
Fleet Management supports one custom profile per category, saved at `/etc/roverd/profiles/<category>.yaml`. Saving a custom profile restarts roverd; choose it in the streamer's configuration to use it. Fleet Management supports one custom profile per category, saved at `/etc/roverd/profiles/<category>.yaml`. The selected setup/run commands are visible. Copy to custom lets you edit them; Save and use custom saves the configuration and selects the custom command in one restart. Camera and encoder options belong in these commands, not generic config fields.
## Audio constraints ## Audio constraints
+16 -11
View File
@@ -6,7 +6,15 @@
apt-get update && apt-get install -y ffmpeg alsa-utils apt-get update && apt-get install -y ffmpeg alsa-utils
fi fi
run: | run: |
exec ffmpeg -nostdin -f alsa -ar "$ROVER_AUDIO_SAMPLE_RATE" -ac "$ROVER_AUDIO_CHANNELS" -i "$ROVER_AUDIO_INPUT_DEVICE" -c:a libopus -b:a "$ROVER_AUDIO_BITRATE" -f rtsp -rtsp_transport tcp "$ROVER_AUDIO_PUBLISH_URL" sample_rate=48000
channels=2
bitrate=510000
arecord -D "$ROVER_AUDIO_INPUT_DEVICE" -f S32_LE -c "$channels" -r "$sample_rate" -B 16384 -F 1024 -q -t raw |
ffmpeg -nostdin -hide_banner -loglevel warning -fflags nobuffer \
-rtbufsize 0 -thread_queue_size 4096 -f s32le -ar "$sample_rate" -ac "$channels" -i pipe:0 \
-af "volume=20dB" -c:a libopus -b:a "$bitrate" -ar:a "$sample_rate" -ac:a "$channels" \
-application audio -frame_duration 20 -compression_level 0 \
-flush_packets 1 -muxdelay 0 -muxpreload 0 -f rtsp -rtsp_transport tcp "$ROVER_AUDIO_PUBLISH_URL"
- id: aiy - id: aiy
name: Google AIY Voice HAT microphone name: Google AIY Voice HAT microphone
description: HAT capture with S32_LE input, 20 dB microphone boost, and low-latency Opus settings. Reboot once after first enabling its hardware. description: HAT capture with S32_LE input, 20 dB microphone boost, and low-latency Opus settings. Reboot once after first enabling its hardware.
@@ -34,15 +42,12 @@
apt-get update && apt-get install -y ffmpeg alsa-utils apt-get update && apt-get install -y ffmpeg alsa-utils
fi fi
run: | run: |
# Preserve the HAT capture format, gain, and low-cost Opus settings. sample_rate=48000
arecord -D "$ROVER_AUDIO_INPUT_DEVICE" -f S32_LE \ channels=2
-c "$ROVER_AUDIO_CHANNELS" -r "$ROVER_AUDIO_SAMPLE_RATE" \ bitrate=510000
-B "${AUDIO_ALSA_BUFFER_BYTES:-16384}" -F "${AUDIO_ALSA_PERIOD_BYTES:-1024}" -q -t raw | arecord -D "$ROVER_AUDIO_INPUT_DEVICE" -f S32_LE -c "$channels" -r "$sample_rate" -B 16384 -F 1024 -q -t raw |
ffmpeg -nostdin -hide_banner -loglevel warning -fflags nobuffer \ ffmpeg -nostdin -hide_banner -loglevel warning -fflags nobuffer \
-rtbufsize 0 -thread_queue_size 4096 -f s32le \ -rtbufsize 0 -thread_queue_size 4096 -f s32le -ar "$sample_rate" -ac "$channels" -i pipe:0 \
-ar "$ROVER_AUDIO_SAMPLE_RATE" -ac "$ROVER_AUDIO_CHANNELS" -i pipe:0 \ -af "volume=20dB" -c:a libopus -b:a "$bitrate" -ar:a "$sample_rate" -ac:a "$channels" \
-af "volume=20dB" -c:a libopus -b:a "$ROVER_AUDIO_BITRATE" \
-ar:a "$ROVER_AUDIO_SAMPLE_RATE" -ac:a "$ROVER_AUDIO_CHANNELS" \
-application audio -frame_duration 20 -compression_level 0 \ -application audio -frame_duration 20 -compression_level 0 \
-flush_packets 1 -muxdelay 0 -muxpreload 0 \ -flush_packets 1 -muxdelay 0 -muxpreload 0 -f rtsp -rtsp_transport tcp "$ROVER_AUDIO_PUBLISH_URL"
-f rtsp -rtsp_transport tcp "$ROVER_AUDIO_PUBLISH_URL"
+12 -7
View File
@@ -6,9 +6,14 @@
apt-get update && apt-get install -y ffmpeg alsa-utils apt-get update && apt-get install -y ffmpeg alsa-utils
fi fi
run: | run: |
normalize=true
normalize_filter='dynaudnorm=f=75:g=15:m=10:p=0.9,alimiter=limit=0.85:level=disabled'
filters=() filters=()
if [ "$ROVER_AUDIO_NORMALIZE" = true ]; then filters=(-af "$ROVER_AUDIO_NORMALIZE_FILTER"); fi if [ "$normalize" = true ]; then filters=(-af "$normalize_filter"); fi
exec ffmpeg -nostdin -rtsp_transport tcp -i "$ROVER_AUDIO_PLAYBACK_URL" -vn "${filters[@]}" -f alsa "$ROVER_AUDIO_OUTPUT_DEVICE" ffmpeg -nostdin -hide_banner -loglevel warning -fflags nobuffer -flags low_delay \
-analyzeduration 200k -probesize 32k -rtsp_transport tcp -i "$ROVER_AUDIO_PLAYBACK_URL" \
-vn "${filters[@]}" -ac 1 -ar 16000 -f s16le pipe:1 |
aplay -q -D "$ROVER_AUDIO_OUTPUT_DEVICE" -t raw -f S16_LE -r 16000 -c 1
- id: aiy - id: aiy
name: Google AIY Voice HAT speaker name: Google AIY Voice HAT speaker
description: HAT playback with low-latency decoding and 16 kHz mono output through the configured audio route. Reboot once after initial setup. description: HAT playback with low-latency decoding and 16 kHz mono output through the configured audio route. Reboot once after initial setup.
@@ -36,11 +41,11 @@
apt-get update && apt-get install -y ffmpeg alsa-utils apt-get update && apt-get install -y ffmpeg alsa-utils
fi fi
run: | run: |
normalize=true
normalize_filter='dynaudnorm=f=75:g=15:m=10:p=0.9,alimiter=limit=0.85:level=disabled'
filters=() filters=()
if [ "$ROVER_AUDIO_NORMALIZE" = true ]; then filters=(-af "$ROVER_AUDIO_NORMALIZE_FILTER"); fi if [ "$normalize" = true ]; then filters=(-af "$normalize_filter"); fi
# Decode to the same explicit HAT playback format as the previous listener.
ffmpeg -nostdin -hide_banner -loglevel warning -fflags nobuffer -flags low_delay \ ffmpeg -nostdin -hide_banner -loglevel warning -fflags nobuffer -flags low_delay \
-analyzeduration 200k -probesize 32k -rtsp_transport tcp \ -analyzeduration 200k -probesize 32k -rtsp_transport tcp -i "$ROVER_AUDIO_PLAYBACK_URL" \
-i "$ROVER_AUDIO_PLAYBACK_URL" -vn "${filters[@]}" \ -vn "${filters[@]}" -ac 1 -ar 16000 -f s16le pipe:1 |
-ac 1 -ar 16000 -f s16le pipe:1 |
aplay -q -D "$ROVER_AUDIO_OUTPUT_DEVICE" -t raw -f S16_LE -r 16000 -c 1 aplay -q -D "$ROVER_AUDIO_OUTPUT_DEVICE" -t raw -f S16_LE -r 16000 -c 1
+27 -6
View File
@@ -4,9 +4,24 @@
setup: | setup: |
command -v ffmpeg >/dev/null || { apt-get update && apt-get install -y ffmpeg; } command -v ffmpeg >/dev/null || { apt-get update && apt-get install -y ffmpeg; }
run: | run: |
device=/dev/video0
input_format=mjpeg
width=640
height=480
fps=30
bitrate=2000000
inverted=false
input_options=()
if [ -n "$input_format" ]; then input_options=(-input_format "$input_format"); fi
filters=() filters=()
if [ "$ROVER_VIDEO_INVERTED" = true ]; then filters=(-vf hflip,vflip); fi if [ "$inverted" = true ]; then filters=(-vf "transpose=2,transpose=2"); fi
exec ffmpeg -nostdin -f v4l2 -input_format "$ROVER_VIDEO_INPUT_FORMAT" -video_size "${ROVER_VIDEO_WIDTH}x${ROVER_VIDEO_HEIGHT}" -framerate "$ROVER_VIDEO_FPS" -i "$ROVER_VIDEO_DEVICE" "${filters[@]}" -an -c:v libx264 -preset ultrafast -tune zerolatency -pix_fmt yuv420p -b:v "$ROVER_VIDEO_BITRATE" -f rtsp -rtsp_transport tcp "$ROVER_VIDEO_PUBLISH_URL" exec ffmpeg -nostdin -hide_banner -loglevel warning -fflags nobuffer -flags low_delay \
-thread_queue_size 4096 -f v4l2 "${input_options[@]}" -framerate "$fps" \
-video_size "${width}x${height}" -i "$device" "${filters[@]}" -an \
-c:v libx264 -preset veryfast -tune zerolatency -profile:v baseline -pix_fmt yuv420p \
-b:v "$bitrate" -maxrate "$bitrate" -bufsize "$((bitrate / 2))" \
-g "$fps" -keyint_min "$fps" -sc_threshold 0 -flush_packets 1 -muxdelay 0 -muxpreload 0 \
-f rtsp -rtsp_transport tcp "$ROVER_VIDEO_PUBLISH_URL"
- id: rpicam - id: rpicam
name: Raspberry Pi CSI camera name: Raspberry Pi CSI camera
description: rpicam/libcamera H.264 output, republished through ffmpeg. description: rpicam/libcamera H.264 output, republished through ffmpeg.
@@ -17,14 +32,20 @@
apt-get install -y rpicam-apps apt-get install -y rpicam-apps
fi fi
run: | run: |
width=640
height=480
fps=30
bitrate=2000000
inverted=true
sensor_mode=1296:972
camera=$(command -v rpicam-vid || command -v libcamera-vid) camera=$(command -v rpicam-vid || command -v libcamera-vid)
options=() options=()
if [ "$ROVER_VIDEO_INVERTED" = true ]; then options+=(--rotation 180); fi if [ "$inverted" = true ]; then options+=(--rotation 180); fi
if [ -n "$ROVER_VIDEO_SENSOR_MODE" ]; then options+=(--mode "$ROVER_VIDEO_SENSOR_MODE"); fi if [ -n "$sensor_mode" ]; then options+=(--mode "$sensor_mode"); fi
# Preserve the previous Pi publisher's camera tuning and packet timing. # Preserve the previous Pi publisher's camera tuning and packet timing.
"$camera" --inline --timeout 0 "${options[@]}" \ "$camera" --inline --timeout 0 "${options[@]}" \
--width "$ROVER_VIDEO_WIDTH" --height "$ROVER_VIDEO_HEIGHT" \ --width "$width" --height "$height" \
--framerate "$ROVER_VIDEO_FPS" --bitrate "$ROVER_VIDEO_BITRATE" \ --framerate "$fps" --bitrate "$bitrate" \
--codec h264 --intra 120 --profile baseline --denoise auto --nopreview \ --codec h264 --intra 120 --profile baseline --denoise auto --nopreview \
--metering centre --ev 0.1 --awb auto --saturation 0.6 --brightness 0 --output - | --metering centre --ev 0.1 --awb auto --saturation 0.6 --brightness 0 --output - |
ffmpeg -nostdin -hide_banner -loglevel warning -fflags nobuffer \ ffmpeg -nostdin -hide_banner -loglevel warning -fflags nobuffer \
+5 -77
View File
@@ -91,15 +91,7 @@ type VideoMediaConfig struct {
Enabled bool `json:"enabled"` Enabled bool `json:"enabled"`
// PublishURL is derived during validation. It remains in rover metadata for server-side // PublishURL is derived during validation. It remains in rover metadata for server-side
// consumers through MediaMetadata, but is never persisted in configuration. // consumers through MediaMetadata, but is never persisted in configuration.
PublishURL string `json:"-"` PublishURL string `json:"-"`
Device string `json:"device"`
InputFormat string `json:"inputFormat"`
Width int `json:"width"`
Height int `json:"height"`
FPS int `json:"fps"`
Bitrate int `json:"bitrate"`
Inverted bool `json:"inverted"`
SensorMode string `json:"sensorMode"`
} }
type AudioCaptureConfig struct { type AudioCaptureConfig struct {
@@ -110,10 +102,6 @@ type AudioCaptureConfig struct {
Enabled bool `json:"enabled"` Enabled bool `json:"enabled"`
// PublishURL follows the same derived-only contract as the video path. // PublishURL follows the same derived-only contract as the video path.
PublishURL string `json:"-"` PublishURL string `json:"-"`
SampleRate int `json:"sampleRate"`
Channels int `json:"channels"`
Bitrate int `json:"bitrate"`
} }
type AudioPlaybackConfig struct { type AudioPlaybackConfig struct {
@@ -125,9 +113,6 @@ type AudioPlaybackConfig struct {
Enabled bool `json:"enabled"` Enabled bool `json:"enabled"`
// ForwardURL is derived because the server and rover must agree on the exact -fwd path. // ForwardURL is derived because the server and rover must agree on the exact -fwd path.
ForwardURL string `json:"-"` ForwardURL string `json:"-"`
Normalize bool `json:"normalize"`
NormalizeFilter string `json:"normalizeFilter"`
} }
type CameraServoConfig struct { type CameraServoConfig struct {
@@ -261,35 +246,10 @@ func DefaultConfig() Config {
}, },
MaxWheelMMs: 500, MaxWheelMMs: 500,
Media: MediaConfig{ Media: MediaConfig{
RTSPPort: 8554, RTSPPort: 8554,
Video: VideoMediaConfig{Profile: "v4l2", Enabled: true},
Video: VideoMediaConfig{ AudioCapture: AudioCaptureConfig{Profile: "alsa", Enabled: true},
Profile: "v4l2", AudioPlayback: AudioPlaybackConfig{Profile: "alsa", Enabled: true},
Enabled: true,
Device: "/dev/video0", InputFormat: "mjpeg",
Width: 640,
Height: 480,
FPS: 30,
Bitrate: 2000000,
Inverted: false,
SensorMode: "",
},
AudioCapture: AudioCaptureConfig{
Profile: "alsa",
Enabled: true,
SampleRate: 48000,
Channels: 2,
Bitrate: 510000,
},
AudioPlayback: AudioPlaybackConfig{
Profile: "alsa",
Enabled: true,
Normalize: true,
NormalizeFilter: "dynaudnorm=f=75:g=15:m=10:p=0.9,alimiter=limit=0.85:level=disabled",
},
}, },
Audio: AudioConfig{ Audio: AudioConfig{
InputDevice: "hw:0,0", OutputDevice: "hw:0,0", MixerCard: "0", OutputSampleRate: 48000, OutputChannels: 2, InputDevice: "hw:0,0", OutputDevice: "hw:0,0", MixerCard: "0", OutputSampleRate: 48000, OutputChannels: 2,
@@ -488,26 +448,6 @@ func validateMediaConfig(cfg *MediaConfig, serverURL string, roverName string) e
} }
func validateVideoMediaConfig(cfg *VideoMediaConfig, serverURL string, roverName string, rtspPort int) error { func validateVideoMediaConfig(cfg *VideoMediaConfig, serverURL string, roverName string, rtspPort int) error {
// V4L2 input formats are consumed by ffmpeg as lowercase names such as
// mjpeg or yuyv422. Normalizing here keeps the publisher script simple and
// makes hand-edited Debian laptop configs less sensitive to capitalization.
cfg.InputFormat = strings.ToLower(strings.TrimSpace(cfg.InputFormat))
if cfg.Width <= 0 {
cfg.Width = 640
}
if cfg.Height <= 0 {
cfg.Height = 480
}
if cfg.FPS <= 0 {
cfg.FPS = 30
}
if cfg.Bitrate <= 0 {
cfg.Bitrate = 2000000
}
/*
Always derive this endpoint. Older rover configs can contain an explicit SRT publishUrl;
honoring it after a binary update would silently leave that rover on the old transport.
*/
derived, err := derivePublishURL(serverURL, roverName, rtspPort) derived, err := derivePublishURL(serverURL, roverName, rtspPort)
if err != nil { if err != nil {
return fmt.Errorf("derive publishUrl: %w", err) return fmt.Errorf("derive publishUrl: %w", err)
@@ -517,15 +457,6 @@ func validateVideoMediaConfig(cfg *VideoMediaConfig, serverURL string, roverName
} }
func validateAudioCaptureConfig(cfg *AudioCaptureConfig, serverURL string, roverName string, rtspPort int) error { func validateAudioCaptureConfig(cfg *AudioCaptureConfig, serverURL string, roverName string, rtspPort int) error {
if cfg.SampleRate <= 0 {
cfg.SampleRate = 48000
}
if cfg.Channels <= 0 {
cfg.Channels = 2
}
if cfg.Bitrate <= 0 {
cfg.Bitrate = 510000
}
derived, err := derivePublishURL(serverURL, roverName+"-audio", rtspPort) derived, err := derivePublishURL(serverURL, roverName+"-audio", rtspPort)
if err != nil { if err != nil {
return fmt.Errorf("derive publishUrl: %w", err) return fmt.Errorf("derive publishUrl: %w", err)
@@ -535,9 +466,6 @@ func validateAudioCaptureConfig(cfg *AudioCaptureConfig, serverURL string, rover
} }
func validateAudioPlaybackConfig(cfg *AudioPlaybackConfig, serverURL string, roverName string, rtspPort int) error { func validateAudioPlaybackConfig(cfg *AudioPlaybackConfig, serverURL string, roverName string, rtspPort int) error {
if cfg.NormalizeFilter == "" {
cfg.NormalizeFilter = "dynaudnorm=f=75:g=15:m=10:p=0.9,alimiter=limit=0.85:level=disabled"
}
derived, err := deriveReadURL(serverURL, roverName+"-fwd", rtspPort) derived, err := deriveReadURL(serverURL, roverName+"-fwd", rtspPort)
if err != nil { if err != nil {
return fmt.Errorf("derive forwardUrl: %w", err) return fmt.Errorf("derive forwardUrl: %w", err)
+13
View File
@@ -153,9 +153,22 @@ func (m *ManagementClient) execute(ctx context.Context, command managementComman
if command.Profile == nil { if command.Profile == nil {
return nil, fmt.Errorf("profile required") return nil, fmt.Errorf("profile required")
} }
var config *Config
if len(command.Config) > 0 {
var err error
config, err = DecodeConfig(command.Config)
if err != nil {
return nil, err
}
}
if err := SaveCustomProfile(command.Category, *command.Profile); err != nil { if err := SaveCustomProfile(command.Category, *command.Profile); err != nil {
return nil, err return nil, err
} }
if config != nil {
if err := SaveConfig(m.configPath, config); err != nil {
return nil, err
}
}
m.stopping = true m.stopping = true
if m.runtime != nil { if m.runtime != nil {
_ = m.runtime.PrepareShutdown() _ = m.runtime.PrepareShutdown()
-8
View File
@@ -8,7 +8,6 @@ import (
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
"strconv"
"sync" "sync"
"syscall" "syscall"
"time" "time"
@@ -176,15 +175,8 @@ func (m *MediaSupervisor) environment(dir string) []string {
host, _ := url.Parse(cfg.ServerURL) host, _ := url.Parse(cfg.ServerURL)
values := map[string]string{ values := map[string]string{
"ROVER_NAME": cfg.Name, "ROVER_SERVER_HOST": host.Hostname(), "ROVER_PROFILE_DIR": dir, "ROVER_REPO_DIR": m.repo, "ROVER_NAME": cfg.Name, "ROVER_SERVER_HOST": host.Hostname(), "ROVER_PROFILE_DIR": dir, "ROVER_REPO_DIR": m.repo,
"ROVER_VIDEO_DEVICE": cfg.Media.Video.Device, "ROVER_VIDEO_INPUT_FORMAT": cfg.Media.Video.InputFormat,
"ROVER_VIDEO_WIDTH": strconv.Itoa(cfg.Media.Video.Width), "ROVER_VIDEO_HEIGHT": strconv.Itoa(cfg.Media.Video.Height),
"ROVER_VIDEO_FPS": strconv.Itoa(cfg.Media.Video.FPS), "ROVER_VIDEO_BITRATE": strconv.Itoa(cfg.Media.Video.Bitrate),
"ROVER_VIDEO_INVERTED": strconv.FormatBool(cfg.Media.Video.Inverted), "ROVER_VIDEO_SENSOR_MODE": cfg.Media.Video.SensorMode,
"ROVER_VIDEO_PUBLISH_URL": cfg.Media.Video.PublishURL, "ROVER_AUDIO_PUBLISH_URL": cfg.Media.AudioCapture.PublishURL, "ROVER_VIDEO_PUBLISH_URL": cfg.Media.Video.PublishURL, "ROVER_AUDIO_PUBLISH_URL": cfg.Media.AudioCapture.PublishURL,
"ROVER_AUDIO_PLAYBACK_URL": cfg.Media.AudioPlayback.ForwardURL, "ROVER_AUDIO_INPUT_DEVICE": "rover_capture", "ROVER_AUDIO_OUTPUT_DEVICE": "rover_forward", "ROVER_AUDIO_PLAYBACK_URL": cfg.Media.AudioPlayback.ForwardURL, "ROVER_AUDIO_INPUT_DEVICE": "rover_capture", "ROVER_AUDIO_OUTPUT_DEVICE": "rover_forward",
"ROVER_AUDIO_SAMPLE_RATE": strconv.Itoa(cfg.Media.AudioCapture.SampleRate), "ROVER_AUDIO_CHANNELS": strconv.Itoa(cfg.Media.AudioCapture.Channels),
"ROVER_AUDIO_BITRATE": strconv.Itoa(cfg.Media.AudioCapture.Bitrate), "ROVER_AUDIO_NORMALIZE": strconv.FormatBool(cfg.Media.AudioPlayback.Normalize),
"ROVER_AUDIO_NORMALIZE_FILTER": cfg.Media.AudioPlayback.NormalizeFilter,
} }
env := os.Environ() env := os.Environ()
for key, value := range values { for key, value := range values {
@@ -188,8 +188,8 @@ io.on('connection', (socket) => {
})); }));
return { results }; return { results };
}); });
bind('roverManagement:saveProfile', async ({ roverId, category, profile }) => { bind('roverManagement:saveProfile', async ({ roverId, category, profile, config }) => {
const { id, result } = request(roverId, { type: 'profile.set', category, profile }); const { id, result } = request(roverId, { type: 'profile.set', category, profile, config });
await result; await result;
return { id }; return { id };
}); });
@@ -51,23 +51,25 @@ function RoverForm({ socket, record, online }) {
{record.updateStatus && <p role="status">Update: {record.updateStatus.state} — {record.updateStatus.message}</p>} {record.updateStatus && <p role="status">Update: {record.updateStatus.state} — {record.updateStatus.message}</p>}
<p role="status">{message}</p> <p role="status">{message}</p>
{results.length > 0 && <ul>{results.map((result) => <li key={result.roverId}>{result.roverId}: {result.success ? 'Saved' : result.error}</li>)}</ul>} {results.length > 0 && <ul>{results.map((result) => <li key={result.roverId}>{result.roverId}: {result.success ? 'Saved' : result.error}</li>)}</ul>}
<SchemaConfigurationForm liveData={record} schema={schema} value={draft} onChange={setDraft} disabled={busy || !online} <SchemaConfigurationForm liveData={{ record, draft }} schema={schema} value={draft} onChange={setDraft} disabled={busy || !online}
renderFieldAction={(path) => <button type="button" className="button-dark text-xs" disabled={busy || !online} renderFieldAction={(path) => <button type="button" className="button-dark text-xs" disabled={busy || !online}
onClick={() => save(path)}>Apply to all</button>} onClick={() => save(path)}>Apply to all</button>}
renderObjectFooter={(path) => path.length === 2 && path[0] === 'media' && record.profiles?.[path[1]] renderObjectFooter={(path) => path.length === 2 && path[0] === 'media' && record.profiles?.[path[1]]
? <MediaProfiles socket={socket} record={record} online={online && !busy} category={path[1]} ? <MediaProfiles socket={socket} record={record} online={online && !busy} category={path[1]}
configDirty={JSON.stringify(draft) !== JSON.stringify(record.config)} /> : null} /> draft={draft} /> : null} />
<button type="button" className="button-dark text-xs" disabled={busy || !online} onClick={() => save()}>Save to this rover</button> <button type="button" className="button-dark text-xs" disabled={busy || !online} onClick={() => save()}>Save to this rover</button>
</div>; </div>;
} }
function MediaProfiles({ socket, record, online, category, configDirty }) { function MediaProfiles({ socket, record, online, category, draft }) {
const outputRef = useRef(null); const outputRef = useRef(null);
const output = record.mediaOutput?.[category] || ''; const output = record.mediaOutput?.[category] || '';
useEffect(() => { useEffect(() => {
const element = outputRef.current; const element = outputRef.current;
if (element) element.scrollTop = element.scrollHeight; if (element) element.scrollTop = element.scrollHeight;
}, [output]); }, [output]);
const selected = record.profiles?.[category]?.find((entry) => entry.id === draft.media[category].profile);
const [editing, setEditing] = useState(false);
const [profile, setProfile] = useState({ id: 'custom', name: '', description: '', setup: '', run: '' }); const [profile, setProfile] = useState({ id: 'custom', name: '', description: '', setup: '', run: '' });
const [message, setMessage] = useState(''); const [message, setMessage] = useState('');
const [busy, setBusy] = useState(false); const [busy, setBusy] = useState(false);
@@ -78,27 +80,34 @@ function MediaProfiles({ socket, record, online, category, configDirty }) {
async function save() { async function save() {
setBusy(true); setBusy(true);
try { try {
await request(socket, 'roverManagement:saveProfile', { roverId: record.roverId, category, profile }); await request(socket, 'roverManagement:saveProfile', { roverId: record.roverId, category, profile, config: { ...draft, media: { ...draft.media, [category]: { ...draft.media[category], profile: 'custom' } } } });
setMessage('Custom profile saved. Rover is restarting. Select custom in the media settings to use it.'); setMessage('Custom profile saved and selected. Rover is restarting.');
} catch (error) { setMessage(error.message); } } catch (error) { setMessage(error.message); }
finally { setBusy(false); } finally { setBusy(false); }
} }
return <div className="space-y-0.5 text-xs"> return <div className="space-y-0.5 text-xs">
{(record.profiles?.[category] || []).map((entry) => <p key={entry.id}>{entry.name}: {entry.description}</p>)} <p>{selected?.description || 'Selected profile is unavailable.'}</p>
{selected && <>
<label className="block">Setup command<textarea className="field-input w-full font-mono" readOnly rows={4} value={selected.setup || ''} /></label>
<label className="block">Run command<textarea className="field-input w-full font-mono" readOnly rows={8} value={selected.run} /></label>
<button type="button" className="button-dark" disabled={!online || busy} onClick={() => {
setProfile({ ...selected, id: 'custom', name: selected.id === 'custom' ? selected.name : `${selected.name} (custom)` });
setEditing(true);
}}>{selected.id === 'custom' ? 'Edit custom' : 'Copy to custom'}</button>
</>}
<p>Status: {record.mediaStatus?.[category] || (online ? 'Waiting for status' : 'Offline')}</p> <p>Status: {record.mediaStatus?.[category] || (online ? 'Waiting for status' : 'Offline')}</p>
<details className="space-y-0.5"> {editing && <div className="space-y-0.5">
<summary className="cursor-pointer">Create or edit custom profile</summary> <fieldset disabled={!online || busy}>
{configDirty && <p className="text-sm text-amber-300">Save configuration changes before saving a custom profile, which restarts the rover.</p>}
<fieldset disabled={!online || busy || configDirty}>
{['name', 'description', 'setup', 'run'].map((key) => <label key={key} className="block">{key} {['name', 'description', 'setup', 'run'].map((key) => <label key={key} className="block">{key}
<textarea className="field-input block w-full" rows={['setup', 'run'].includes(key) ? 4 : 1} <textarea className="field-input block w-full" rows={['setup', 'run'].includes(key) ? 4 : 1}
value={profile[key]} onChange={(event) => setProfile((previous) => ({ ...previous, [key]: event.target.value }))} /> value={profile[key]} onChange={(event) => setProfile((previous) => ({ ...previous, [key]: event.target.value }))} />
</label>)} </label>)}
<button type="button" className="button-dark" onClick={save}>Save custom profile</button> <button type="button" className="button-dark" onClick={save}>Save and use custom</button>
<button type="button" className="button-dark" onClick={() => setEditing(false)}>Cancel</button>
</fieldset> </fieldset>
<p role="status">{message}</p> <p role="status">{message}</p>
</details> </div>}
<details><summary className="cursor-pointer">Streamer output</summary> <details open><summary className="cursor-pointer">Streamer output</summary>
<pre ref={outputRef} className="max-h-80 overflow-auto whitespace-pre-wrap text-xs">{output || 'Waiting for command stdout/stderr…'}</pre></details> <pre ref={outputRef} className="max-h-80 overflow-auto whitespace-pre-wrap text-xs">{output || 'Waiting for command stdout/stderr…'}</pre></details>
</div>; </div>;
} }