mirror of
https://github.com/legop3/MultiRoombaRover.git
synced 2026-09-16 09:31:20 -04:00
audio stufs
This commit is contained in:
@@ -29,19 +29,35 @@ function createAudioForwardPolicy(deps) {
|
||||
function forcePublishStreamMode(rawUrl) {
|
||||
const value = String(rawUrl || '').trim();
|
||||
if (!value) return '';
|
||||
if (!/[?&]streamid=#!::/.test(value)) return 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');
|
||||
return value.replace(/([?&]streamid=#!::[^&]*)/, '$1,m=publish');
|
||||
const normalized = value
|
||||
/*
|
||||
A literal "#" inside the SRT stream ID turns the rest of the URL into a
|
||||
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) {
|
||||
const record = roverManager.rovers.get(roverId);
|
||||
const configured = record?.meta?.media?.audioForwardUrl;
|
||||
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,
|
||||
)},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) {
|
||||
|
||||
Reference in New Issue
Block a user