Subclass the mjpegstream descriptor

This commit is contained in:
Julian Stirling 2026-07-10 09:48:13 +01:00
parent ad7b0d8da8
commit f85361ae67

View file

@ -250,6 +250,24 @@ class MJPEGStreamWithTimestamp(lt.outputs.MJPEGStream):
self.notify_new_frame, entry.index self.notify_new_frame, entry.index
) )
class MJPEGStreamDescriptorWithTimestamp(lt.outputs.MJPEGStreamDescriptor):
"""Subclass the Labthings descriptor to return our own class."""
def __get__(
self, obj: Optional[lt.Thing], type: type[lt.Thing] | None = None # noqa: A002
) -> MJPEGStreamWithTimestamp | Self:
"""Return our own MJPEG Stream with timestamp."""
if obj is None:
return self
try:
return obj.__dict__[self.name]
except KeyError:
obj.__dict__[self.name] = MJPEGStreamWithTimestamp(
**self._kwargs,
thing_server_interface=obj._thing_server_interface,
)
return obj.__dict__[self.name]
class BaseCamera(OFMThing, ABC): class BaseCamera(OFMThing, ABC):
"""The base class for all cameras. All cameras must directly inherit from this class. """The base class for all cameras. All cameras must directly inherit from this class.
@ -262,8 +280,8 @@ class BaseCamera(OFMThing, ABC):
_all_background_detectors: Mapping[str, BackgroundDetectAlgorithm] = lt.thing_slot() _all_background_detectors: Mapping[str, BackgroundDetectAlgorithm] = lt.thing_slot()
mjpeg_stream = lt.outputs.MJPEGStreamDescriptor() mjpeg_stream = MJPEGStreamDescriptorWithTimestamp()
lores_mjpeg_stream = lt.outputs.MJPEGStreamDescriptor() lores_mjpeg_stream = MJPEGStreamDescriptorWithTimestamp()
_memory_buffer = CameraMemoryBuffer() _memory_buffer = CameraMemoryBuffer()
supports_focus_fom: bool = False supports_focus_fom: bool = False