Init commit
This commit is contained in:
19
server/core/lib/live-videos/rtsp-url.ts
Normal file
19
server/core/lib/live-videos/rtsp-url.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { CONFIG } from '@server/initializers/config.js'
|
||||
|
||||
function buildRtspUrl (endpoint: string | undefined, urlPattern: string | undefined, targetCamera: string) {
|
||||
const normalizedEndpoint = (endpoint || 'rtsp://localhost:8554').trim().replace(/\/+$/, '')
|
||||
const normalizedPattern = (urlPattern || '/{targetCamera}/live')
|
||||
.replace('{targetCamera}', encodeURIComponent(targetCamera))
|
||||
|
||||
if (normalizedPattern.startsWith('/')) return normalizedEndpoint + normalizedPattern
|
||||
|
||||
return normalizedEndpoint + '/' + normalizedPattern
|
||||
}
|
||||
|
||||
export function buildRtspSourceUrlForTargetCamera (targetCamera: string) {
|
||||
return buildRtspUrl(CONFIG.LIVE.RTSP_SOURCE.ENDPOINT, CONFIG.LIVE.RTSP_SOURCE.URL_PATTERN, targetCamera)
|
||||
}
|
||||
|
||||
export function buildRtspSinkUrlForTargetCamera (targetCamera: string) {
|
||||
return buildRtspUrl(CONFIG.LIVE.RTSP_SINK.ENDPOINT, CONFIG.LIVE.RTSP_SINK.URL_PATTERN, targetCamera)
|
||||
}
|
||||
Reference in New Issue
Block a user