Use Frigate camera name as webrtc_card default URL.
This commit is contained in:
@@ -187,8 +187,8 @@ cameras:
|
||||
|
||||
| Option | Default | Overridable | Description |
|
||||
| - | - | - | - |
|
||||
| `entity` | | :heavy_multiplication_x: | The RTSP entity to pass to the WebRTC Card for this camera. Specify this OR `url`. |
|
||||
| `url` | | :heavy_multiplication_x: | The RTSP url to pass to the WebRTC Card. Specify this OR `entity`. |
|
||||
| `entity` | | :heavy_multiplication_x: | The RTSP entity to pass to the WebRTC Card for this camera. |
|
||||
| `url` | Depends on the camera engine (e.g. Frigate will use the camera name by default since this is the [recommended setup](https://deploy-preview-4055--frigate-docs.netlify.app/guides/configuring_go2rtc/))| :heavy_multiplication_x: | The RTSP url to pass to the WebRTC Card. |
|
||||
| `*`| | :heavy_multiplication_x: | Any options specified in the `webrtc_card:` YAML dictionary are silently passed through to the AlexxIT's WebRTC Card. See [WebRTC Configuration](https://github.com/AlexxIT/WebRTC#configuration) for full details this external card provides. |
|
||||
|
||||
|
||||
@@ -873,6 +873,12 @@ events/snapshots/UI. A perfect combination!
|
||||
|
||||
#### Specifying The WebRTC Card Camera
|
||||
|
||||
##### Frigate v0.12 and onwards
|
||||
|
||||
If you have used the [recommended go2rtc setup](https://deploy-preview-4055--frigate-docs.netlify.app/guides/configuring_go2rtc/) for Frigate, no additional `webrtc_card` configuration is necessary.
|
||||
|
||||
##### Frigate v0.11 and earlier
|
||||
|
||||
The WebRTC Card live provider does **not** support use of Frigate-provided
|
||||
camera entities, as it requires an RTSP stream which Frigate does not currently
|
||||
provide. There are two ways to specify the WebRTC Card source camera:
|
||||
@@ -899,11 +905,11 @@ cameras:
|
||||
url: 'rtsp://USERNAME:PASSWORD@CAMERA:554/RTSP_PATH'
|
||||
```
|
||||
|
||||
Other WebRTC Card options may be specified under the `live` section, like so:
|
||||
Other WebRTC Card options may be specified under the `webrtc_card` section, like so:
|
||||
|
||||
```yaml
|
||||
live:
|
||||
webrtc_card:
|
||||
cameras:
|
||||
- webrtc_card:
|
||||
ui: true
|
||||
```
|
||||
|
||||
|
||||
@@ -1093,7 +1093,9 @@ export class FrigateCameraManagerEngine
|
||||
// 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}`,
|
||||
`/mse/api/ws?src=${
|
||||
cameraConfig.go2rtc?.stream ?? cameraConfig.frigate.camera_name
|
||||
}`,
|
||||
sign: true,
|
||||
};
|
||||
};
|
||||
@@ -1107,15 +1109,30 @@ export class FrigateCameraManagerEngine
|
||||
};
|
||||
};
|
||||
|
||||
const getWebRTCCard = (): CameraEndpoint | null => {
|
||||
// By defaykt use the frigate camera name which is the default recommended
|
||||
// setup as per:
|
||||
// https://deploy-preview-4055--frigate-docs.netlify.app/guides/configuring_go2rtc/
|
||||
//
|
||||
// The user may override this in their webrtc_card configuration.
|
||||
const endpoint = cameraConfig.frigate.camera_name
|
||||
? cameraConfig.frigate.camera_name
|
||||
: null;
|
||||
return endpoint ? { endpoint: endpoint } : null;
|
||||
};
|
||||
|
||||
const ui = getUIEndpoint();
|
||||
const go2rtc = getGo2RTC();
|
||||
const jsmpeg = getJSMPEG();
|
||||
const webrtcCard = getWebRTCCard();
|
||||
|
||||
return ui || go2rtc || jsmpeg
|
||||
? {
|
||||
...(ui && { ui: ui }),
|
||||
...(go2rtc && { go2rtc: go2rtc }),
|
||||
...(jsmpeg && { jsmpeg: jsmpeg }),
|
||||
...(jsmpeg && { jsmpeg: jsmpeg }),
|
||||
...(webrtcCard && { webrtcCard: webrtcCard }),
|
||||
}
|
||||
: null;
|
||||
}
|
||||
|
||||
@@ -124,6 +124,7 @@ export interface CameraEndpoints {
|
||||
ui?: CameraEndpoint;
|
||||
go2rtc?: CameraEndpoint;
|
||||
jsmpeg?: CameraEndpoint;
|
||||
webrtcCard?: CameraEndpoint;
|
||||
}
|
||||
|
||||
export type CameraConfigs = Map<string, CameraConfig>;
|
||||
|
||||
@@ -17,6 +17,7 @@ import {
|
||||
hideMediaControlsTemporarily,
|
||||
MEDIA_LOAD_CONTROLS_HIDE_SECONDS,
|
||||
} from '../../utils/media.js';
|
||||
import { CameraEndpoints } from '../../camera-manager/types.js';
|
||||
|
||||
// Create a wrapper for AlexxIT's WebRTC card
|
||||
// - https://github.com/AlexxIT/WebRTC
|
||||
@@ -28,6 +29,9 @@ export class FrigateCardLiveWebRTCCard
|
||||
@property({ attribute: false })
|
||||
public cameraConfig?: CameraConfig;
|
||||
|
||||
@property({ attribute: false })
|
||||
public cameraEndpoints?: CameraEndpoints;
|
||||
|
||||
@property({ attribute: false })
|
||||
public cardWideConfig?: CardWideConfig;
|
||||
|
||||
@@ -90,12 +94,18 @@ export class FrigateCardLiveWebRTCCard
|
||||
protected _createWebRTC(): HTMLElement | null {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
const webrtcElement = this._webrtcTask.value;
|
||||
if (webrtcElement && this.hass && this.cameraConfig?.webrtc_card) {
|
||||
if (webrtcElement && this.hass && this.cameraConfig) {
|
||||
const webrtc = new webrtcElement() as HTMLElement & {
|
||||
hass: HomeAssistant;
|
||||
setConfig: (config: Record<string, unknown>) => void;
|
||||
};
|
||||
webrtc.setConfig(this.cameraConfig.webrtc_card);
|
||||
const config = {...this.cameraConfig.webrtc_card};
|
||||
if (!config.url && !config.entity && this.cameraEndpoints?.webrtcCard) {
|
||||
// This will never need to be signed, it is just used internally by the
|
||||
// card as a stream name lookup.
|
||||
config.url = this.cameraEndpoints.webrtcCard.endpoint;
|
||||
}
|
||||
webrtc.setConfig(config);
|
||||
webrtc.hass = this.hass;
|
||||
return webrtc;
|
||||
}
|
||||
|
||||
@@ -899,6 +899,7 @@ export class FrigateCardLiveProvider
|
||||
class=${classMap(providerClasses)}
|
||||
.hass=${this.hass}
|
||||
.cameraConfig=${this.cameraConfig}
|
||||
.cameraEndpoints=${this.cameraEndpoints}
|
||||
.cardWideConfig=${this.cardWideConfig}
|
||||
@frigate-card:media:loaded=${this._videoMediaShowHandler.bind(this)}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user