Merge pull request #969 from dermotduffy/share-entity
Use Frigate camera name as webrtc_card default URL
This commit is contained in:
@@ -187,8 +187,8 @@ cameras:
|
|||||||
|
|
||||||
| Option | Default | Overridable | Description |
|
| Option | Default | Overridable | Description |
|
||||||
| - | - | - | - |
|
| - | - | - | - |
|
||||||
| `entity` | | :heavy_multiplication_x: | The RTSP entity to pass to the WebRTC Card for this camera. Specify this OR `url`. |
|
| `entity` | | :heavy_multiplication_x: | The RTSP entity to pass to the WebRTC Card for this camera. |
|
||||||
| `url` | | :heavy_multiplication_x: | The RTSP url to pass to the WebRTC Card. Specify this OR `entity`. |
|
| `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. |
|
| `*`| | :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
|
#### 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
|
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
|
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:
|
provide. There are two ways to specify the WebRTC Card source camera:
|
||||||
@@ -899,12 +905,12 @@ cameras:
|
|||||||
url: 'rtsp://USERNAME:PASSWORD@CAMERA:554/RTSP_PATH'
|
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
|
```yaml
|
||||||
live:
|
cameras:
|
||||||
webrtc_card:
|
- webrtc_card:
|
||||||
ui: true
|
ui: true
|
||||||
```
|
```
|
||||||
|
|
||||||
See [the WebRTC Card live configuration](#webrtc-live-configuration) above, and the
|
See [the WebRTC Card live configuration](#webrtc-live-configuration) above, and the
|
||||||
|
|||||||
@@ -1093,7 +1093,9 @@ export class FrigateCameraManagerEngine
|
|||||||
// go2rtc is exposed by the integration under the (slightly
|
// go2rtc is exposed by the integration under the (slightly
|
||||||
// misleading) 'mse' path, even though that path can serve all go2rtc
|
// misleading) 'mse' path, even though that path can serve all go2rtc
|
||||||
// modes.
|
// 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,
|
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 ui = getUIEndpoint();
|
||||||
const go2rtc = getGo2RTC();
|
const go2rtc = getGo2RTC();
|
||||||
const jsmpeg = getJSMPEG();
|
const jsmpeg = getJSMPEG();
|
||||||
|
const webrtcCard = getWebRTCCard();
|
||||||
|
|
||||||
return ui || go2rtc || jsmpeg
|
return ui || go2rtc || jsmpeg
|
||||||
? {
|
? {
|
||||||
...(ui && { ui: ui }),
|
...(ui && { ui: ui }),
|
||||||
...(go2rtc && { go2rtc: go2rtc }),
|
...(go2rtc && { go2rtc: go2rtc }),
|
||||||
...(jsmpeg && { jsmpeg: jsmpeg }),
|
...(jsmpeg && { jsmpeg: jsmpeg }),
|
||||||
|
...(jsmpeg && { jsmpeg: jsmpeg }),
|
||||||
|
...(webrtcCard && { webrtcCard: webrtcCard }),
|
||||||
}
|
}
|
||||||
: null;
|
: null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -124,6 +124,7 @@ export interface CameraEndpoints {
|
|||||||
ui?: CameraEndpoint;
|
ui?: CameraEndpoint;
|
||||||
go2rtc?: CameraEndpoint;
|
go2rtc?: CameraEndpoint;
|
||||||
jsmpeg?: CameraEndpoint;
|
jsmpeg?: CameraEndpoint;
|
||||||
|
webrtcCard?: CameraEndpoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type CameraConfigs = Map<string, CameraConfig>;
|
export type CameraConfigs = Map<string, CameraConfig>;
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ import {
|
|||||||
hideMediaControlsTemporarily,
|
hideMediaControlsTemporarily,
|
||||||
MEDIA_LOAD_CONTROLS_HIDE_SECONDS,
|
MEDIA_LOAD_CONTROLS_HIDE_SECONDS,
|
||||||
} from '../../utils/media.js';
|
} from '../../utils/media.js';
|
||||||
|
import { CameraEndpoints } from '../../camera-manager/types.js';
|
||||||
|
|
||||||
// Create a wrapper for AlexxIT's WebRTC card
|
// Create a wrapper for AlexxIT's WebRTC card
|
||||||
// - https://github.com/AlexxIT/WebRTC
|
// - https://github.com/AlexxIT/WebRTC
|
||||||
@@ -28,6 +29,9 @@ export class FrigateCardLiveWebRTCCard
|
|||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
public cameraConfig?: CameraConfig;
|
public cameraConfig?: CameraConfig;
|
||||||
|
|
||||||
|
@property({ attribute: false })
|
||||||
|
public cameraEndpoints?: CameraEndpoints;
|
||||||
|
|
||||||
@property({ attribute: false })
|
@property({ attribute: false })
|
||||||
public cardWideConfig?: CardWideConfig;
|
public cardWideConfig?: CardWideConfig;
|
||||||
|
|
||||||
@@ -90,12 +94,18 @@ export class FrigateCardLiveWebRTCCard
|
|||||||
protected _createWebRTC(): HTMLElement | null {
|
protected _createWebRTC(): HTMLElement | null {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||||
const webrtcElement = this._webrtcTask.value;
|
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 & {
|
const webrtc = new webrtcElement() as HTMLElement & {
|
||||||
hass: HomeAssistant;
|
hass: HomeAssistant;
|
||||||
setConfig: (config: Record<string, unknown>) => void;
|
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;
|
webrtc.hass = this.hass;
|
||||||
return webrtc;
|
return webrtc;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -899,6 +899,7 @@ export class FrigateCardLiveProvider
|
|||||||
class=${classMap(providerClasses)}
|
class=${classMap(providerClasses)}
|
||||||
.hass=${this.hass}
|
.hass=${this.hass}
|
||||||
.cameraConfig=${this.cameraConfig}
|
.cameraConfig=${this.cameraConfig}
|
||||||
|
.cameraEndpoints=${this.cameraEndpoints}
|
||||||
.cardWideConfig=${this.cardWideConfig}
|
.cardWideConfig=${this.cardWideConfig}
|
||||||
@frigate-card:media:loaded=${this._videoMediaShowHandler.bind(this)}
|
@frigate-card:media:loaded=${this._videoMediaShowHandler.bind(this)}
|
||||||
>
|
>
|
||||||
|
|||||||
Reference in New Issue
Block a user