Files
frigate/frigate/comms/detections_updater.py
T

43 lines
1.0 KiB
Python
Raw Normal View History

"""Facilitates communication between processes."""
from enum import Enum
2025-08-08 06:08:37 -06:00
from typing import Any
2024-06-21 17:30:19 -04:00
from .zmq_proxy import Publisher, Subscriber
class DetectionTypeEnum(str, Enum):
all = ""
api = "api"
video = "video"
audio = "audio"
2025-03-23 14:30:48 -05:00
lpr = "lpr"
2024-06-21 17:30:19 -04:00
class DetectionPublisher(Publisher):
"""Simplifies receiving video and audio detections."""
2024-06-21 17:30:19 -04:00
topic_base = "detection/"
2025-08-08 06:08:37 -06:00
def __init__(self, topic: str) -> None:
2024-06-21 17:30:19 -04:00
super().__init__(topic)
2024-06-21 17:30:19 -04:00
class DetectionSubscriber(Subscriber):
"""Simplifies receiving video and audio detections."""
2024-06-21 17:30:19 -04:00
topic_base = "detection/"
2025-08-08 06:08:37 -06:00
def __init__(self, topic: str) -> None:
2024-06-21 17:30:19 -04:00
super().__init__(topic)
2024-06-21 17:30:19 -04:00
def check_for_update(
2025-08-08 06:08:37 -06:00
self, timeout: float | None = None
) -> tuple[str, Any] | tuple[None, None] | None:
2024-06-21 17:30:19 -04:00
return super().check_for_update(timeout)
2025-05-13 16:27:20 +02:00
def _return_object(self, topic: str, payload: Any) -> Any:
2024-06-21 17:30:19 -04:00
if payload is None:
return (None, None)
2025-08-08 06:08:37 -06:00
return (topic[len(self.topic_base) :], payload)