Add support for custom go2rtc URLs.

This commit is contained in:
Dermot Duffy
2023-10-07 18:29:31 -07:00
parent cf8935da73
commit db50e36c76
5 changed files with 306 additions and 16 deletions
+14 -8
View File
@@ -1148,16 +1148,22 @@ export class FrigateCameraManagerEngine
};
const getGo2RTC = (): CameraEndpoint | null => {
return {
endpoint:
`/api/frigate/${cameraConfig.frigate.client_id}` +
// go2rtc is exposed by the integration under the (slightly
const stream = cameraConfig.go2rtc?.stream ?? cameraConfig.frigate.camera_name;
const url = cameraConfig.go2rtc?.url
? cameraConfig.go2rtc.url.replace(/\/+$/, '')
: null;
const endpoint = url
? `${url}/api/ws?src=${stream}`
: // go2rtc is exposed by the integration under the (slightly
// misleading) 'mse' path, even though that path can serve all go2rtc
// modes.
`/mse/api/ws?src=${
cameraConfig.go2rtc?.stream ?? cameraConfig.frigate.camera_name
}`,
sign: true,
`/api/frigate/${cameraConfig.frigate.client_id}/mse/api/ws?src=${stream}`;
return {
endpoint: endpoint,
// Only sign the endpoint if it's local to HA.
sign: endpoint.startsWith('/'),
};
};
+2 -2
View File
@@ -10,7 +10,7 @@ import { customElement, property } from 'lit/decorators.js';
import { CameraEndpoints } from '../../camera-manager/types.js';
import { CameraConfig, MicrophoneConfig } from '../../config/types.js';
import { localize } from '../../localize/localize';
import liveMSEStyle from '../../scss/live-go2rtc.scss';
import liveGo2RTCStyle from '../../scss/live-go2rtc.scss';
import { ExtendedHomeAssistant, FrigateCardMediaPlayer } from '../../types.js';
import { getEndpointAddressOrDispatchError } from '../../utils/endpoint';
import { setControlsOnVideo } from '../../utils/media.js';
@@ -167,7 +167,7 @@ export class FrigateCardGo2RTC extends LitElement implements FrigateCardMediaPla
}
static get styles(): CSSResultGroup {
return unsafeCSS(liveMSEStyle);
return unsafeCSS(liveGo2RTCStyle);
}
}
+1
View File
@@ -774,6 +774,7 @@ const microphoneConfigSchema = z
export type MicrophoneConfig = z.infer<typeof microphoneConfigSchema>;
const go2rtcConfigSchema = z.object({
url: z.string().optional(),
modes: z.enum(['webrtc', 'mse', 'mp4', 'mjpeg']).array().optional(),
stream: z.string().optional(),
});