23 lines
702 B
Python
23 lines
702 B
Python
from __future__ import annotations
|
|
|
|
from collections.abc import Callable
|
|
|
|
from PySide6.QtCore import QObject
|
|
from PySide6.QtMultimedia import QVideoFrame
|
|
|
|
|
|
class FrameDispatcher(QObject):
|
|
def __init__(self, parent: QObject | None = None) -> None:
|
|
super().__init__(parent)
|
|
self._subscribers: list[Callable[[QVideoFrame], None]] = []
|
|
|
|
def subscribe(self, callback: Callable[[QVideoFrame], None]) -> None:
|
|
self._subscribers.append(callback)
|
|
|
|
def unsubscribe(self, callback: Callable[[QVideoFrame], None]) -> None:
|
|
self._subscribers.remove(callback)
|
|
|
|
def on_frame(self, frame: QVideoFrame) -> None:
|
|
for cb in self._subscribers:
|
|
cb(frame)
|