From 97e8b3a2eb321884fe1e15fb584f41a38cc33d51 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sat, 23 Mar 2019 03:24:25 +0200 Subject: qcam: Add Qt-based GUI application qcam is a sample camera GUI application based on Qt. It demonstrates integration of the Qt event loop with libcamera. The application lets the user select a camera through the GUI, and then captures a single stream from the camera and displays it in a window. Only streams in YUYV formats are supported for now. Signed-off-by: Laurent Pinchart Acked-by: Kieran Bingham Tested-by: Kieran Bingham --- src/qcam/qt_event_dispatcher.h | 62 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 src/qcam/qt_event_dispatcher.h (limited to 'src/qcam/qt_event_dispatcher.h') diff --git a/src/qcam/qt_event_dispatcher.h b/src/qcam/qt_event_dispatcher.h new file mode 100644 index 00000000..b0f123e5 --- /dev/null +++ b/src/qcam/qt_event_dispatcher.h @@ -0,0 +1,62 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * qt_event_dispatcher.h - qcam - Qt-based event dispatcher + */ +#ifndef __QCAM_QT_EVENT_DISPATCHER_H__ +#define __QCAM_QT_EVENT_DISPATCHER_H__ + +#include + +#include + +using namespace libcamera; + +class QSocketNotifier; + +class QtEventDispatcher final : public EventDispatcher, public QObject +{ +public: + QtEventDispatcher(); + ~QtEventDispatcher(); + + void registerEventNotifier(EventNotifier *notifier); + void unregisterEventNotifier(EventNotifier *notifier); + + void registerTimer(Timer *timer); + void unregisterTimer(Timer *timer); + + void processEvents(); + + void interrupt(); + +protected: + void timerEvent(QTimerEvent *event); + +private: + void readNotifierActivated(int socket); + void writeNotifierActivated(int socket); + void exceptionNotifierActivated(int socket); + + struct NotifierPair { + NotifierPair() + : notifier(nullptr), qnotifier(nullptr) + { + } + EventNotifier *notifier; + QSocketNotifier *qnotifier; + }; + + struct NotifierSet { + NotifierPair read; + NotifierPair write; + NotifierPair exception; + }; + + std::map notifiers_; + std::map timers_; + std::map timerIds_; +}; + +#endif /* __QCAM_QT_EVENT_DISPATCHER_H__ */ -- cgit v1.2.1