mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-15 17:12:59 -04:00
audio stufs
This commit is contained in:
@@ -314,9 +314,9 @@ log "Installed audio-forward listener helper + systemd unit"
|
|||||||
install -d -o roverd -g roverd /var/lib/roverd
|
install -d -o roverd -g roverd /var/lib/roverd
|
||||||
cat > /var/lib/roverd/video.env <<'ENV'
|
cat > /var/lib/roverd/video.env <<'ENV'
|
||||||
# Managed by roverd; placeholder values will be overwritten at runtime.
|
# Managed by roverd; placeholder values will be overwritten at runtime.
|
||||||
PUBLISH_URL=srt://192.168.0.86:9000?streamid=#!::r=CHANGE_ME,m=publish&latency=10&mode=caller&transtype=live&pkt_size=1316
|
PUBLISH_URL=srt://192.168.0.86:9000?streamid=%23%21::r=CHANGE_ME,m=publish&latency=20000&mode=caller&transtype=live&pkt_size=1316
|
||||||
AUDIO_PUBLISH_URL=srt://192.168.0.86:9000?streamid=#!::r=CHANGE_ME-audio,m=publish&latency=10&mode=caller&transtype=live&pkt_size=1316
|
AUDIO_PUBLISH_URL=srt://192.168.0.86:9000?streamid=%23%21::r=CHANGE_ME-audio,m=publish&latency=20000&mode=caller&transtype=live&pkt_size=1316
|
||||||
AUDIO_FORWARD_URL=srt://192.168.0.86:9000?streamid=#!::r=CHANGE_ME-fwd,m=request&latency=10&mode=caller&transtype=live&pkt_size=1316
|
AUDIO_FORWARD_URL=srt://192.168.0.86:9000?streamid=%23%21::r=CHANGE_ME-fwd,m=request&latency=20000&mode=caller&transtype=live&pkt_size=1316
|
||||||
VIDEO_BITRATE=2000000
|
VIDEO_BITRATE=2000000
|
||||||
AUDIO_ENABLE=0
|
AUDIO_ENABLE=0
|
||||||
AUDIO_DEVICE=hw:0,0
|
AUDIO_DEVICE=hw:0,0
|
||||||
|
|||||||
+35
-1
@@ -296,6 +296,9 @@ func LoadConfig(path string) (*Config, error) {
|
|||||||
}
|
}
|
||||||
cfg.Media.AudioForwardURL = derived
|
cfg.Media.AudioForwardURL = derived
|
||||||
}
|
}
|
||||||
|
cfg.Media.PublishURL = normalizeSRTURLForLowLatency(cfg.Media.PublishURL)
|
||||||
|
cfg.Media.AudioPublishURL = normalizeSRTURLForLowLatency(cfg.Media.AudioPublishURL)
|
||||||
|
cfg.Media.AudioForwardURL = normalizeSRTURLForLowLatency(cfg.Media.AudioForwardURL)
|
||||||
if err := validateServoConfig(&cfg.CameraServo); err != nil {
|
if err := validateServoConfig(&cfg.CameraServo); err != nil {
|
||||||
return nil, fmt.Errorf("cameraServo: %w", err)
|
return nil, fmt.Errorf("cameraServo: %w", err)
|
||||||
}
|
}
|
||||||
@@ -440,9 +443,40 @@ func deriveSRTURL(serverURL, streamName string, port int, mode string) (string,
|
|||||||
port = 9000
|
port = 9000
|
||||||
}
|
}
|
||||||
escaped := url.PathEscape(streamName)
|
escaped := url.PathEscape(streamName)
|
||||||
return fmt.Sprintf("srt://%s:%d?streamid=#!::r=%s,m=%s&latency=10&mode=caller&transtype=live&pkt_size=1316", host, port, escaped, mode), nil
|
return fmt.Sprintf("srt://%s:%d?streamid=%%23%%21::r=%s,m=%s&latency=20000&mode=caller&transtype=live&pkt_size=1316", host, port, escaped, mode), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func normalizeSRTURLForLowLatency(raw string) string {
|
||||||
|
trimmed := strings.TrimSpace(raw)
|
||||||
|
if trimmed == "" || !strings.HasPrefix(trimmed, "srt://") {
|
||||||
|
return raw
|
||||||
|
}
|
||||||
|
|
||||||
|
// SRT stream IDs commonly start with "#!::". In a URL, a literal "#"
|
||||||
|
// begins the fragment section, so ffmpeg/libsrt can ignore query options
|
||||||
|
// placed after it. MediaMTX then falls back to the SRT default latency,
|
||||||
|
// which showed up in diagnostics as a 120 ms receive delay even though the
|
||||||
|
// URL text contained latency=10. Percent-encoding only the "#!" prefix keeps
|
||||||
|
// MediaMTX's stream ID parser behavior while allowing latency/mode/transtype
|
||||||
|
// to remain real SRT query parameters.
|
||||||
|
normalized := strings.ReplaceAll(trimmed, "streamid=#!::", "streamid=%23%21::")
|
||||||
|
|
||||||
|
// ffmpeg's SRT latency URL option is expressed in microseconds. Use 20 ms as
|
||||||
|
// the default interactive rover target: much lower than the 120 ms fallback,
|
||||||
|
// but not so aggressive that tiny LAN jitter immediately causes drops.
|
||||||
|
if srtLegacyLatencyRe.MatchString(normalized) {
|
||||||
|
normalized = srtLegacyLatencyRe.ReplaceAllString(normalized, "${1}20000${2}")
|
||||||
|
} else if !strings.Contains(normalized, "latency=") {
|
||||||
|
separator := "&"
|
||||||
|
if !strings.Contains(normalized, "?") {
|
||||||
|
separator = "?"
|
||||||
|
}
|
||||||
|
normalized += separator + "latency=20000"
|
||||||
|
}
|
||||||
|
return normalized
|
||||||
|
}
|
||||||
|
|
||||||
|
var srtLegacyLatencyRe = regexp.MustCompile(`([?&]latency=)10($|&)`)
|
||||||
var hexColorRe = regexp.MustCompile(`^#[0-9A-Fa-f]{6}$`)
|
var hexColorRe = regexp.MustCompile(`^#[0-9A-Fa-f]{6}$`)
|
||||||
|
|
||||||
func normalizeHexColor(raw string) (string, error) {
|
func normalizeHexColor(raw string) (string, error) {
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ battery:
|
|||||||
urgent: 1650
|
urgent: 1650
|
||||||
maxWheelSpeed: 350
|
maxWheelSpeed: 350
|
||||||
media:
|
media:
|
||||||
publishUrl: srt://192.168.0.86:9000?streamid=#!::r=roomba-alpha,m=publish&latency=10&mode=caller&transtype=live&pkt_size=1316
|
publishUrl: srt://192.168.0.86:9000?streamid=%23%21::r=roomba-alpha,m=publish&latency=20000&mode=caller&transtype=live&pkt_size=1316
|
||||||
audioForwardUrl: srt://192.168.0.86:9000?streamid=#!::r=roomba-alpha-fwd,m=request&latency=10&mode=caller&transtype=live&pkt_size=1316
|
audioForwardUrl: srt://192.168.0.86:9000?streamid=%23%21::r=roomba-alpha-fwd,m=request&latency=20000&mode=caller&transtype=live&pkt_size=1316
|
||||||
publishPort: 9000
|
publishPort: 9000
|
||||||
# Default assumes camera is mounted upside down; set false for upright mounts.
|
# Default assumes camera is mounted upside down; set false for upright mounts.
|
||||||
cameraInverted: true
|
cameraInverted: true
|
||||||
|
|||||||
@@ -29,19 +29,35 @@ function createAudioForwardPolicy(deps) {
|
|||||||
function forcePublishStreamMode(rawUrl) {
|
function forcePublishStreamMode(rawUrl) {
|
||||||
const value = String(rawUrl || '').trim();
|
const value = String(rawUrl || '').trim();
|
||||||
if (!value) return '';
|
if (!value) return '';
|
||||||
if (!/[?&]streamid=#!::/.test(value)) return value;
|
const normalized = value
|
||||||
if (/,m=publish\b/.test(value)) return value;
|
/*
|
||||||
if (/,m=[a-zA-Z]+\b/.test(value)) return value.replace(/,m=[a-zA-Z]+\b/, ',m=publish');
|
A literal "#" inside the SRT stream ID turns the rest of the URL into a
|
||||||
return value.replace(/([?&]streamid=#!::[^&]*)/, '$1,m=publish');
|
fragment for normal URL parsers. Encoding the "#!" prefix keeps MediaMTX
|
||||||
|
receiving the same stream ID while allowing latency/mode/transtype to be
|
||||||
|
parsed as real SRT options instead of being accidentally hidden inside
|
||||||
|
the stream ID text.
|
||||||
|
*/
|
||||||
|
.replace(/([?&]streamid=)#!::/, '$1%23%21::')
|
||||||
|
/*
|
||||||
|
SRT latency is expressed in microseconds by ffmpeg/libsrt. The previous
|
||||||
|
latency=10 value was both too small to be a sane target and, because of
|
||||||
|
the unescaped stream ID, was not being applied in practice. Use the same
|
||||||
|
20 ms target as rover publishing.
|
||||||
|
*/
|
||||||
|
.replace(/([?&]latency=)10\b/, (_, prefix) => `${prefix}20000`);
|
||||||
|
if (!/[?&]streamid=(?:#!::|%23%21::)/.test(normalized)) return normalized;
|
||||||
|
if (/,m=publish\b/.test(normalized)) return normalized;
|
||||||
|
if (/,m=[a-zA-Z]+\b/.test(normalized)) return normalized.replace(/,m=[a-zA-Z]+\b/, ',m=publish');
|
||||||
|
return normalized.replace(/([?&]streamid=(?:#!::|%23%21::)[^&]*)/, '$1,m=publish');
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolveForwardUrl(roverId) {
|
function resolveForwardUrl(roverId) {
|
||||||
const record = roverManager.rovers.get(roverId);
|
const record = roverManager.rovers.get(roverId);
|
||||||
const configured = record?.meta?.media?.audioForwardUrl;
|
const configured = record?.meta?.media?.audioForwardUrl;
|
||||||
if (configured) return forcePublishStreamMode(configured);
|
if (configured) return forcePublishStreamMode(configured);
|
||||||
return `srt://127.0.0.1:9000?streamid=#!::r=${encodeURIComponent(
|
return `srt://127.0.0.1:9000?streamid=%23%21::r=${encodeURIComponent(
|
||||||
roverId + streamSuffix,
|
roverId + streamSuffix,
|
||||||
)},m=publish&latency=10&mode=caller&transtype=live&pkt_size=1316`;
|
)},m=publish&latency=20000&mode=caller&transtype=live&pkt_size=1316`;
|
||||||
}
|
}
|
||||||
|
|
||||||
function resolveForwardPathId(roverId) {
|
function resolveForwardPathId(roverId) {
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
1. add camera filter indicator for when youre changing it
|
1. fix rover request spam queue cheat
|
||||||
2. make alert feed better with fadeout and stuff and it stays when you hover over one
|
2. fix this:
|
||||||
3. fix rover request spam queue cheat
|
|
||||||
4. fix this:
|
|
||||||
`Jun 18 15:14:18 roombaserver.local node[216731]: /home/daniel/MultiRoombaRover/server/src/services/roverManager/socketHandlers.js:92
|
`Jun 18 15:14:18 roombaserver.local node[216731]: /home/daniel/MultiRoombaRover/server/src/services/roverManager/socketHandlers.js:92
|
||||||
Jun 18 15:14:18 roombaserver.local node[216731]: cb({ error: err.message });
|
Jun 18 15:14:18 roombaserver.local node[216731]: cb({ error: err.message });
|
||||||
Jun 18 15:14:18 roombaserver.local node[216731]: ^
|
Jun 18 15:14:18 roombaserver.local node[216731]: ^
|
||||||
|
|||||||
Reference in New Issue
Block a user