From b2dbee028c10c2b031f63aaf9bd24f2984be83d5 Mon Sep 17 00:00:00 2001 From: Allen Porter Date: Fri, 31 Dec 2021 13:08:21 -0800 Subject: [PATCH 1/4] Update developer docs to mention RTSP to WebRTC --- docs/core/entity/camera.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/core/entity/camera.md b/docs/core/entity/camera.md index 5da1188d..6f8705f1 100644 --- a/docs/core/entity/camera.md +++ b/docs/core/entity/camera.md @@ -91,6 +91,10 @@ class MyCamera(Camera): """Handle the WebRTC offer and return an answer.""" ``` +### RTSP to WebRTC + +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. + ### Turn on ```python From bf4fc2d881f066bd0b0a3711126eff236a16edd1 Mon Sep 17 00:00:00 2001 From: Allen Porter Date: Fri, 31 Dec 2021 13:58:56 -0800 Subject: [PATCH 2/4] 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 From f98ef0dd14cee61b6b4e0c32d73d9b9e624c8ba2 Mon Sep 17 00:00:00 2001 From: Allen Porter Date: Fri, 31 Dec 2021 14:00:23 -0800 Subject: [PATCH 3/4] Clarify unsub call instructions --- docs/core/entity/camera.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/core/entity/camera.md b/docs/core/entity/camera.md index afbd8604..043eed6c 100644 --- a/docs/core/entity/camera.md +++ b/docs/core/entity/camera.md @@ -104,7 +104,7 @@ async def handle_offer(stream_source: str, offer_sdp: str) -> str: except ClientError as err: raise HomeAssistantError from err -# Call unsub when integration unloads +# Call unsub() when integration unloads unsub = camera.async_register_rtsp_to_web_rtc_provider( hass, DOMAIN, handle_offer ) From 277f215bebd87d5363faeb513f135f28819805b7 Mon Sep 17 00:00:00 2001 From: "J. Nick Koston" Date: Fri, 31 Dec 2021 14:37:04 -1000 Subject: [PATCH 4/4] Update docs/core/entity/camera.md --- docs/core/entity/camera.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/core/entity/camera.md b/docs/core/entity/camera.md index 043eed6c..1d709efb 100644 --- a/docs/core/entity/camera.md +++ b/docs/core/entity/camera.md @@ -98,7 +98,7 @@ An integration may provide a WebRTC stream for any RTSP camera using `async_regi ```python async def handle_offer(stream_source: str, offer_sdp: str) -> str: - """Handle the signal path for a WebRTC stream and return an answer""" + """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: