From bf4fc2d881f066bd0b0a3711126eff236a16edd1 Mon Sep 17 00:00:00 2001 From: Allen Porter Date: Fri, 31 Dec 2021 13:58:56 -0800 Subject: [PATCH] Add an example of calling the camera registry for rtsp to webrtc --- docs/core/entity/camera.md | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/docs/core/entity/camera.md b/docs/core/entity/camera.md index 6f8705f1..afbd8604 100644 --- a/docs/core/entity/camera.md +++ b/docs/core/entity/camera.md @@ -95,6 +95,21 @@ class MyCamera(Camera): An integration may provide a WebRTC stream for any RTSP camera using `async_register_rtsp_to_web_rtc_provider`. The current best practice is for an integration to provide the actual stream manipulation with an Add-on or external service. + +```python +async def handle_offer(stream_source: str, offer_sdp: str) -> str: + """Handle the signal path for a WebRTC stream and return an answer""" + try: + return await client.offer(offer_sdp, stream_source) + except ClientError as err: + raise HomeAssistantError from err + +# Call unsub when integration unloads +unsub = camera.async_register_rtsp_to_web_rtc_provider( + hass, DOMAIN, handle_offer +) +``` + ### Turn on ```python