From 7eb354797999c2910e0c9f2bc15d952d4cb87aa2 Mon Sep 17 00:00:00 2001 From: Nick Mowen Date: Thu, 13 Oct 2022 14:43:25 -0600 Subject: [PATCH] Add relay controller for go2rtc --- frigate/relay.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 frigate/relay.py diff --git a/frigate/relay.py b/frigate/relay.py new file mode 100644 index 000000000..ae2eca37f --- /dev/null +++ b/frigate/relay.py @@ -0,0 +1,27 @@ +"""Controls go2rtc relay.""" + + +import requests +import urllib.parse + +from frigate.config import CameraConfig, FrigateConfig + + +class RelayApi: + """Control go2rtc relay API.""" + + def __init__(self, config: FrigateConfig) -> None: + self.config: FrigateConfig = config + + def add_cameras(self) -> None: + """Add cameras to go2rtc relay.""" + self.relays: dict[str, str] = {} + + for cam_name, camera in self.config.cameras.items(): + for input in camera.ffmpeg.inputs: + if "relay" in input.roles: + self.relays[cam_name] = input.path + + for name, path in self.relays.items(): + params = {"src": urllib.parse.quote_plus(path), "name": name} + requests.put("http://localhost:1984/api/streams", params=params)