diff --git a/src/components/live/live-go2rtc.ts b/src/components/live/live-go2rtc.ts index 20509c73..00fd0c34 100644 --- a/src/components/live/live-go2rtc.ts +++ b/src/components/live/live-go2rtc.ts @@ -115,7 +115,9 @@ export class FrigateCardGo2RTC extends LitElement { this._player.src = address; this._player.visibilityCheck = false; this._player.background = true; - this._player.mode = 'webrtc'; + if (this.cameraConfig?.go2rtc?.modes) { + this._player.mode = this.cameraConfig.go2rtc.modes.join(','); + } this.requestUpdate(); } diff --git a/src/const.ts b/src/const.ts index 0e49a7a4..0194dc92 100644 --- a/src/const.ts +++ b/src/const.ts @@ -12,6 +12,7 @@ export const CONF_CAMERAS_ARRAY_FRIGATE_LABEL = `${CONF_CAMERAS}.#.frigate.label` as const; export const CONF_CAMERAS_ARRAY_FRIGATE_URL = `${CONF_CAMERAS}.#.frigate.url` as const; export const CONF_CAMERAS_ARRAY_FRIGATE_ZONE = `${CONF_CAMERAS}.#.frigate.zone` as const; +export const CONF_CAMERAS_ARRAY_GO2RTC_MODES = `${CONF_CAMERAS}.#.go2rtc.modes` as const; export const CONF_CAMERAS_ARRAY_ID = `${CONF_CAMERAS}.#.id` as const; export const CONF_CAMERAS_ARRAY_TITLE = `${CONF_CAMERAS}.#.title` as const; export const CONF_CAMERAS_ARRAY_ICON = `${CONF_CAMERAS}.#.icon` as const; diff --git a/src/editor.ts b/src/editor.ts index 3f4283dc..a5e68f65 100644 --- a/src/editor.ts +++ b/src/editor.ts @@ -129,6 +129,7 @@ import { CONF_VIEW_UPDATE_SECONDS, CONF_PERFORMANCE_FEATURES_MEDIA_CHUNK_SIZE, MEDIA_CHUNK_SIZE_MAX, + CONF_CAMERAS_ARRAY_GO2RTC_MODES, } from './const.js'; import { localize } from './localize/localize.js'; import frigate_card_editor_style from './scss/editor.scss'; @@ -156,6 +157,7 @@ const MENU_BUTTONS = 'buttons'; const MENU_CAMERAS = 'cameras'; const MENU_CAMERAS_DEPENDENCIES = 'cameras.dependencies'; const MENU_CAMERAS_FRIGATE = 'cameras.frigate'; +const MENU_CAMERAS_GO2RTC = 'cameras.go2rtc'; const MENU_CAMERAS_TRIGGERS = 'cameras.triggers'; const MENU_CAMERAS_WEBRTC = 'cameras.webrtc'; const MENU_IMAGE_LAYOUT = 'image.layout'; @@ -491,6 +493,14 @@ export class FrigateCardEditor extends LitElement implements LovelaceCardEditor { value: 'high', label: localize('config.performance.profiles.high') }, ]; + protected _go2rtcModes: EditorSelectOption[] = [ + { value: '', label: '' }, + { value: 'mse', label: localize('config.cameras.go2rtc.modes.mse') }, + { value: 'webrtc', label: localize('config.cameras.go2rtc.modes.webrtc') }, + { value: 'mp4', label: localize('config.cameras.go2rtc.modes.mp4') }, + { value: 'mjpeg', label: localize('config.cameras.go2rtc.modes.mjpeg') }, + ]; + public setConfig(config: RawFrigateCardConfig): void { // Note: This does not use Zod to parse the configuration, so it may be // partially or completely invalid. It's more useful to have a partially @@ -1404,6 +1414,23 @@ export class FrigateCardEditor extends LitElement implements LovelaceCardEditor }, )}`, )} + ${this._putInSubmenu( + MENU_CAMERAS_GO2RTC, + cameraIndex, + 'config.cameras.go2rtc.editor_label', + { name: 'mdi:alpha-g-circle' }, + html`${this._renderOptionSelector( + getArrayConfigPath(CONF_CAMERAS_ARRAY_GO2RTC_MODES, cameraIndex), + this._go2rtcModes, + { + multiple: true, + label: localize('config.cameras.go2rtc.modes.editor_label') + } + )} + ${this._renderStringInput( + getArrayConfigPath(CONF_CAMERAS_ARRAY_WEBRTC_CARD_URL, cameraIndex), + )}`, + )} ${this._putInSubmenu( MENU_CAMERAS_WEBRTC, cameraIndex, diff --git a/src/localize/languages/en.json b/src/localize/languages/en.json index 0cf1b12e..42fd0051 100644 --- a/src/localize/languages/en.json +++ b/src/localize/languages/en.json @@ -23,6 +23,16 @@ "url": "Frigate server URL", "zone": "Frigate zone" }, + "go2rtc": { + "editor_label": "go2rtc Options", + "modes": { + "editor_label": "go2rtc Modes", + "mse": "Media Source Extensions (MSE)", + "webrtc": "Web Real-Time Communication (WebRTC)", + "mp4": "MPEG-4 (MP4)", + "mjpeg": "Motion JPEG (MJPEG)" + } + }, "icon": "Icon for this camera (Autodetected from entity)", "id": "Unique id for this camera in this card", "live_provider": "Live view provider for this camera", diff --git a/src/types.ts b/src/types.ts index 133d09e3..5270a820 100644 --- a/src/types.ts +++ b/src/types.ts @@ -435,6 +435,12 @@ const cameraConfigSchema = z }) .default(cameraConfigDefault.frigate), + go2rtc: z + .object({ + modes: z.enum(['webrtc', 'mse', 'mp4', 'mjpeg']).array(), + }) + .optional(), + // Camera identifiers for WebRTC. webrtc_card: webrtcCardCameraConfigSchema.optional(),