mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-04 10:24:02 +00:00
29 lines
836 B
JavaScript
29 lines
836 B
JavaScript
/**
|
|
* Canonicalize a CCTV feed type string to one of:
|
|
* 'image', 'mjpeg', 'mp4', 'webm', 'hls', or pass-through.
|
|
*
|
|
* @param {string} value - Raw feed type (e.g. 'jpeg', 'mjpg', 'video', 'stream').
|
|
* @returns {string} Normalized feed type.
|
|
*/
|
|
export function normalizeFeedType(value) {
|
|
const raw = String(value || '')
|
|
.trim()
|
|
.toLowerCase();
|
|
if (!raw) return 'image';
|
|
if (raw === 'jpeg' || raw === 'jpg' || raw === 'png') return 'image';
|
|
if (raw === 'mjpg') return 'mjpeg';
|
|
if (raw === 'video') return 'mp4';
|
|
if (raw === 'stream') return 'hls';
|
|
return raw;
|
|
}
|
|
|
|
/**
|
|
* Check whether a normalized feed type represents streaming video.
|
|
*
|
|
* @param {string} feedType
|
|
* @returns {boolean}
|
|
*/
|
|
export function isVideoFeedType(feedType) {
|
|
return feedType === 'mp4' || feedType === 'webm' || feedType === 'hls';
|
|
}
|