Implement initial structure and core functionality for Duck Preview application
This commit is contained in:
0
duck_preview/dispatcher/__init__.py
Normal file
0
duck_preview/dispatcher/__init__.py
Normal file
22
duck_preview/dispatcher/frame_dispatcher.py
Normal file
22
duck_preview/dispatcher/frame_dispatcher.py
Normal file
@@ -0,0 +1,22 @@
|
||||
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)
|
||||
Reference in New Issue
Block a user