From ae07dd83054bfa209fd0eb9426bc604a2df5bb22 Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Sat, 5 Apr 2025 06:13:42 -0600 Subject: [PATCH] Remove duplicate enabled checkers --- frigate/output/birdseye.py | 14 +------------- frigate/output/output.py | 32 ++++++++++++++++---------------- 2 files changed, 17 insertions(+), 29 deletions(-) diff --git a/frigate/output/birdseye.py b/frigate/output/birdseye.py index 919aa3054..f10998076 100644 --- a/frigate/output/birdseye.py +++ b/frigate/output/birdseye.py @@ -754,7 +754,6 @@ class Birdseye: "birdseye", self.converter, websocket_server, stop_event ) self.birdseye_manager = BirdsEyeFrameManager(config, stop_event) - self.config_enabled_subscriber = ConfigSubscriber("config/enabled/") self.birdseye_subscriber = ConfigSubscriber("config/birdseye/") self.frame_manager = SharedMemoryFrameManager() self.stop_event = stop_event @@ -799,24 +798,13 @@ class Birdseye: updated_birdseye_config, ) = self.birdseye_subscriber.check_for_update() - ( - updated_enabled_topic, - updated_enabled_config, - ) = self.config_enabled_subscriber.check_for_update() - - if not updated_birdseye_topic and not updated_enabled_topic: + if not updated_birdseye_topic: break if updated_birdseye_config: camera_name = updated_birdseye_topic.rpartition("/")[-1] self.config.cameras[camera_name].birdseye = updated_birdseye_config - if updated_enabled_config: - camera_name = updated_enabled_topic.rpartition("/")[-1] - self.config.cameras[ - camera_name - ].enabled = updated_enabled_config.enabled - if self.birdseye_manager.update( camera, len([o for o in current_tracked_objects if not o["stationary"]]), diff --git a/frigate/output/output.py b/frigate/output/output.py index 30900a5ab..885fffd8d 100644 --- a/frigate/output/output.py +++ b/frigate/output/output.py @@ -99,12 +99,7 @@ def output_frames( websocket_thread = threading.Thread(target=websocket_server.serve_forever) detection_subscriber = DetectionSubscriber(DetectionTypeEnum.video) - - enabled_subscribers = { - camera: ConfigSubscriber(f"config/enabled/{camera}", True) - for camera in config.cameras.keys() - if config.cameras[camera].enabled_in_config - } + config_enabled_subscriber = ConfigSubscriber("config/enabled/") jsmpeg_cameras: dict[str, JsmpegCamera] = {} birdseye: Birdseye | None = None @@ -128,16 +123,21 @@ def output_frames( websocket_thread.start() - def get_enabled_state(camera: str) -> bool: - _, config_data = enabled_subscribers[camera].check_for_update() - - if config_data: - config.cameras[camera].enabled = config_data.enabled - return config_data.enabled - - return config.cameras[camera].enabled - while not stop_event.is_set(): + # check if there is an updated config + while True: + ( + updated_enabled_topic, + updated_enabled_config, + ) = config_enabled_subscriber.check_for_update() + + if not updated_enabled_topic: + break + + if updated_enabled_config: + camera_name = updated_enabled_topic.rpartition("/")[-1] + config.cameras[camera_name].enabled = updated_enabled_config.enabled + (topic, data) = detection_subscriber.check_for_update(timeout=1) now = datetime.datetime.now().timestamp() @@ -160,7 +160,7 @@ def output_frames( _, ) = data - if not get_enabled_state(camera): + if not config.cameras[camera].enabled: continue frame = frame_manager.get(frame_name, config.cameras[camera].frame_shape_yuv)