mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-11-18 12:42:15 -05:00
streamer movement
This commit is contained in:
+41
-66
@@ -55,13 +55,15 @@ type BatteryConfig struct {
|
||||
}
|
||||
|
||||
type AudioConfig struct {
|
||||
// AudioConfig is only for sounds generated by roverd itself. Live capture
|
||||
// and playback are media-publisher concerns, so those settings live under
|
||||
// MediaConfig where they can be written directly into media.env.
|
||||
TTSEnabled bool `json:"ttsEnabled"`
|
||||
DefaultEngine string `json:"defaultEngine"`
|
||||
DefaultVoice string `json:"defaultVoice"`
|
||||
DefaultPitch int `json:"defaultPitch"`
|
||||
InputDevice string `json:"inputDevice" jsonschema:"minLength=1"`
|
||||
OutputDevice string `json:"outputDevice" jsonschema:"minLength=1"`
|
||||
MixerCard string `json:"mixerCard" jsonschema:"minLength=1"`
|
||||
OutputSampleRate int `json:"outputSampleRate" jsonschema:"minimum=8000,maximum=192000"`
|
||||
OutputChannels int `json:"outputChannels" jsonschema:"minimum=1,maximum=8"`
|
||||
TTSEnabled bool `json:"ttsEnabled"`
|
||||
DefaultEngine string `json:"defaultEngine"`
|
||||
DefaultVoice string `json:"defaultVoice"`
|
||||
DefaultPitch int `json:"defaultPitch"`
|
||||
}
|
||||
|
||||
type HornConfig struct {
|
||||
@@ -69,7 +71,6 @@ type HornConfig struct {
|
||||
Volume float64 `json:"volume"`
|
||||
SampleRate int `json:"sampleRate"`
|
||||
Channels int `json:"channels"`
|
||||
Device string `json:"device"`
|
||||
SineGain float64 `json:"sineGain"`
|
||||
SawGain float64 `json:"sawGain"`
|
||||
MaxDuration Duration `json:"maxDuration"`
|
||||
@@ -79,22 +80,15 @@ type MediaConfig struct {
|
||||
// RTSPPort is shared by the derived video, microphone, and forwarded-audio
|
||||
// RTSP URLs. Keeping it at this level prevents each nested block from needing
|
||||
// to repeat the same server port when the common MediaMTX listener is used.
|
||||
RTSPPort int `json:"rtspPort" jsonschema:"minimum=1,maximum=65535"`
|
||||
Manage bool `json:"manage"`
|
||||
HealthURL string `json:"healthUrl"`
|
||||
HealthInterval Duration `json:"healthInterval"`
|
||||
Video VideoMediaConfig `json:"video"`
|
||||
AudioCapture AudioCaptureConfig `json:"audioCapture"`
|
||||
AudioPlayback AudioPlaybackConfig `json:"audioPlayback"`
|
||||
RTSPPort int `json:"rtspPort" jsonschema:"minimum=1,maximum=65535"`
|
||||
Video VideoMediaConfig `json:"video"`
|
||||
AudioCapture AudioCaptureConfig `json:"audioCapture"`
|
||||
AudioPlayback AudioPlaybackConfig `json:"audioPlayback"`
|
||||
}
|
||||
|
||||
type VideoMediaConfig struct {
|
||||
// Publisher selects the installed publisher script/pipeline family. The
|
||||
// first pass uses pi-libcamera for current rovers; laptop-v4l2 can be added
|
||||
// without changing the server-facing media shape again.
|
||||
Enabled bool `json:"enabled"`
|
||||
Service string `json:"service"`
|
||||
Publisher string `json:"publisher"`
|
||||
Profile string `json:"profile" jsonschema:"minLength=1"`
|
||||
Enabled bool `json:"enabled"`
|
||||
// PublishURL is derived during validation. It remains in rover metadata for server-side
|
||||
// consumers through MediaMetadata, but is never persisted in configuration.
|
||||
PublishURL string `json:"-"`
|
||||
@@ -109,29 +103,29 @@ type VideoMediaConfig struct {
|
||||
}
|
||||
|
||||
type AudioCaptureConfig struct {
|
||||
Profile string `json:"profile" jsonschema:"minLength=1"`
|
||||
// AudioCapture describes the rover microphone stream that browsers can
|
||||
// subscribe to as "<rover>-audio". A disabled capture block still has
|
||||
// normalized defaults so enabling it only requires flipping enabled: true.
|
||||
Enabled bool `json:"enabled"`
|
||||
Service string `json:"service"`
|
||||
Enabled bool `json:"enabled"`
|
||||
// PublishURL follows the same derived-only contract as the video path.
|
||||
PublishURL string `json:"-"`
|
||||
Device string `json:"device"`
|
||||
SampleRate int `json:"sampleRate"`
|
||||
Channels int `json:"channels"`
|
||||
Bitrate int `json:"bitrate"`
|
||||
|
||||
SampleRate int `json:"sampleRate"`
|
||||
Channels int `json:"channels"`
|
||||
Bitrate int `json:"bitrate"`
|
||||
}
|
||||
|
||||
type AudioPlaybackConfig struct {
|
||||
Profile string `json:"profile" jsonschema:"minLength=1"`
|
||||
// AudioPlayback describes the reverse stream that VIP users publish into
|
||||
// MediaMTX for playback on the rover speaker. The URL is a request/read URL
|
||||
// for the rover listener, while the server converts it to publish mode when
|
||||
// it needs to inject audio.
|
||||
Enabled bool `json:"enabled"`
|
||||
Service string `json:"service"`
|
||||
Enabled bool `json:"enabled"`
|
||||
// ForwardURL is derived because the server and rover must agree on the exact -fwd path.
|
||||
ForwardURL string `json:"-"`
|
||||
Device string `json:"device"`
|
||||
ForwardURL string `json:"-"`
|
||||
|
||||
Normalize bool `json:"normalize"`
|
||||
NormalizeFilter string `json:"normalizeFilter"`
|
||||
}
|
||||
@@ -267,12 +261,13 @@ func DefaultConfig() Config {
|
||||
},
|
||||
MaxWheelMMs: 500,
|
||||
Media: MediaConfig{
|
||||
RTSPPort: 8554,
|
||||
HealthInterval: Duration{Duration: 30 * time.Second},
|
||||
RTSPPort: 8554,
|
||||
|
||||
Video: VideoMediaConfig{
|
||||
Enabled: true,
|
||||
Service: "video-publisher.service",
|
||||
Publisher: "pi-libcamera",
|
||||
Profile: "v4l2",
|
||||
Enabled: false,
|
||||
Device: "/dev/video0", InputFormat: "mjpeg",
|
||||
|
||||
Width: 640,
|
||||
Height: 480,
|
||||
FPS: 30,
|
||||
@@ -281,22 +276,23 @@ func DefaultConfig() Config {
|
||||
SensorMode: "1296:972",
|
||||
},
|
||||
AudioCapture: AudioCaptureConfig{
|
||||
Enabled: false,
|
||||
Service: "audio-only-publisher.service",
|
||||
Device: "hw:0,0",
|
||||
Profile: "alsa",
|
||||
Enabled: false,
|
||||
|
||||
SampleRate: 48000,
|
||||
Channels: 2,
|
||||
Bitrate: 510000,
|
||||
},
|
||||
AudioPlayback: AudioPlaybackConfig{
|
||||
Enabled: true,
|
||||
Service: "audio-forward-listener.service",
|
||||
Device: "forward",
|
||||
Profile: "alsa",
|
||||
Enabled: false,
|
||||
|
||||
Normalize: true,
|
||||
NormalizeFilter: "dynaudnorm=f=75:g=15:m=10:p=0.9,alimiter=limit=0.85:level=disabled",
|
||||
},
|
||||
},
|
||||
Audio: AudioConfig{
|
||||
InputDevice: "hw:0,0", OutputDevice: "hw:0,0", MixerCard: "0", OutputSampleRate: 48000, OutputChannels: 2,
|
||||
TTSEnabled: false,
|
||||
DefaultEngine: "flite",
|
||||
DefaultVoice: "rms",
|
||||
@@ -410,6 +406,9 @@ func validateConfig(cfg *Config) error {
|
||||
return errors.New("piGpio.brc: nonnegative pin and positive pulse durations required")
|
||||
}
|
||||
}
|
||||
if err := validateAudioRouting(cfg.Audio); err != nil {
|
||||
return err
|
||||
}
|
||||
validateAudioConfig(&cfg.Audio)
|
||||
validateHornConfig(&cfg.Horn)
|
||||
validateAutoSideBrushConfig(&cfg.AutoSideBrush)
|
||||
@@ -481,9 +480,6 @@ func validateMediaConfig(cfg *MediaConfig, serverURL string, roverName string) e
|
||||
if cfg.RTSPPort <= 0 {
|
||||
cfg.RTSPPort = 8554
|
||||
}
|
||||
if cfg.HealthInterval.Duration <= 0 {
|
||||
cfg.HealthInterval = Duration{Duration: 30 * time.Second}
|
||||
}
|
||||
if err := validateVideoMediaConfig(&cfg.Video, serverURL, roverName, cfg.RTSPPort); err != nil {
|
||||
return fmt.Errorf("video: %w", err)
|
||||
}
|
||||
@@ -497,12 +493,6 @@ func validateMediaConfig(cfg *MediaConfig, serverURL string, roverName string) e
|
||||
}
|
||||
|
||||
func validateVideoMediaConfig(cfg *VideoMediaConfig, serverURL string, roverName string, rtspPort int) error {
|
||||
if cfg.Service == "" {
|
||||
cfg.Service = "video-publisher.service"
|
||||
}
|
||||
if cfg.Publisher == "" {
|
||||
cfg.Publisher = "pi-libcamera"
|
||||
}
|
||||
// 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.
|
||||
@@ -519,9 +509,6 @@ func validateVideoMediaConfig(cfg *VideoMediaConfig, serverURL string, roverName
|
||||
if cfg.Bitrate <= 0 {
|
||||
cfg.Bitrate = 2000000
|
||||
}
|
||||
if cfg.SensorMode == "" && cfg.Publisher == "pi-libcamera" {
|
||||
cfg.SensorMode = "1296:972"
|
||||
}
|
||||
/*
|
||||
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.
|
||||
@@ -535,12 +522,6 @@ func validateVideoMediaConfig(cfg *VideoMediaConfig, serverURL string, roverName
|
||||
}
|
||||
|
||||
func validateAudioCaptureConfig(cfg *AudioCaptureConfig, serverURL string, roverName string, rtspPort int) error {
|
||||
if cfg.Service == "" {
|
||||
cfg.Service = "audio-only-publisher.service"
|
||||
}
|
||||
if cfg.Device == "" {
|
||||
cfg.Device = "hw:0,0"
|
||||
}
|
||||
if cfg.SampleRate <= 0 {
|
||||
cfg.SampleRate = 48000
|
||||
}
|
||||
@@ -559,12 +540,6 @@ func validateAudioCaptureConfig(cfg *AudioCaptureConfig, serverURL string, rover
|
||||
}
|
||||
|
||||
func validateAudioPlaybackConfig(cfg *AudioPlaybackConfig, serverURL string, roverName string, rtspPort int) error {
|
||||
if cfg.Service == "" {
|
||||
cfg.Service = "audio-forward-listener.service"
|
||||
}
|
||||
if cfg.Device == "" {
|
||||
cfg.Device = "forward"
|
||||
}
|
||||
if cfg.NormalizeFilter == "" {
|
||||
cfg.NormalizeFilter = "dynaudnorm=f=75:g=15:m=10:p=0.9,alimiter=limit=0.85:level=disabled"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user