mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-06-21 11:51:53 +03:00
Some checks are pending
CI / AMD64 Build (push) Waiting to run
CI / ARM Build (push) Waiting to run
CI / Jetson Jetpack 6 (push) Waiting to run
CI / AMD64 Extra Build (push) Blocked by required conditions
CI / ARM Extra Build (push) Blocked by required conditions
CI / Synaptics Build (push) Blocked by required conditions
CI / Assemble and push default build (push) Blocked by required conditions
* add go2rtc stream selection to camera ffmpeg config * i18n * add config-schema.json to generated e2e mock data * e2e test * docs * fix test
34 lines
1.1 KiB
TypeScript
34 lines
1.1 KiB
TypeScript
export type StreamSourceMode = "restream" | "manual";
|
|
|
|
// The literal go2rtc restream prefix matches what the camera wizard inlines
|
|
// when it builds a restreamed input path. Only this exact host:port is treated
|
|
// as a restream so manually typed URLs (including localhost) stay manual.
|
|
export const RESTREAM_PREFIX = "rtsp://127.0.0.1:8554/";
|
|
export const RESTREAM_PRESET = "preset-rtsp-restream";
|
|
|
|
/** Build the restream input path for a given go2rtc stream name. */
|
|
export function buildRestreamPath(streamName: string): string {
|
|
return `${RESTREAM_PREFIX}${streamName}`;
|
|
}
|
|
|
|
/**
|
|
* Extract the go2rtc stream name from a restream input path.
|
|
*
|
|
* Returns the stream name when the path is a well-formed restream URL with no
|
|
* extra path segments or query, otherwise undefined.
|
|
*/
|
|
export function parseRestreamStreamName(
|
|
path: string | undefined,
|
|
): string | undefined {
|
|
if (typeof path !== "string" || !path.startsWith(RESTREAM_PREFIX)) {
|
|
return undefined;
|
|
}
|
|
|
|
const name = path.slice(RESTREAM_PREFIX.length);
|
|
if (name.length === 0 || /[/?#]/.test(name)) {
|
|
return undefined;
|
|
}
|
|
|
|
return name;
|
|
}
|