From d767c84022559e55708f24a3a264853c0142135e Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Sun, 8 Nov 2020 01:14:38 +0200 Subject: libcamera: Move EventDispatcher to internal API MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There's no user of the EventDispatcher (and the related EventNotifier and Timer classes) outside of libcamera. Move those classes to the internal API. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham Reviewed-by: Niklas Söderlund --- include/libcamera/camera_manager.h | 4 -- include/libcamera/event_dispatcher.h | 35 ---------------- include/libcamera/event_notifier.h | 48 --------------------- include/libcamera/internal/event_dispatcher.h | 35 ++++++++++++++++ include/libcamera/internal/event_dispatcher_poll.h | 2 +- include/libcamera/internal/event_notifier.h | 48 +++++++++++++++++++++ include/libcamera/internal/meson.build | 3 ++ include/libcamera/internal/timer.h | 49 ++++++++++++++++++++++ include/libcamera/meson.build | 3 -- include/libcamera/timer.h | 49 ---------------------- 10 files changed, 136 insertions(+), 140 deletions(-) delete mode 100644 include/libcamera/event_dispatcher.h delete mode 100644 include/libcamera/event_notifier.h create mode 100644 include/libcamera/internal/event_dispatcher.h create mode 100644 include/libcamera/internal/event_notifier.h create mode 100644 include/libcamera/internal/timer.h delete mode 100644 include/libcamera/timer.h (limited to 'include') diff --git a/include/libcamera/camera_manager.h b/include/libcamera/camera_manager.h index 6d5341c7..8c8830e7 100644 --- a/include/libcamera/camera_manager.h +++ b/include/libcamera/camera_manager.h @@ -19,7 +19,6 @@ namespace libcamera { class Camera; -class EventDispatcher; class CameraManager : public Object, public Extensible { @@ -43,9 +42,6 @@ public: static const std::string &version() { return version_; } - void setEventDispatcher(std::unique_ptr dispatcher); - EventDispatcher *eventDispatcher(); - Signal> cameraAdded; Signal> cameraRemoved; diff --git a/include/libcamera/event_dispatcher.h b/include/libcamera/event_dispatcher.h deleted file mode 100644 index cb06bf20..00000000 --- a/include/libcamera/event_dispatcher.h +++ /dev/null @@ -1,35 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2019, Google Inc. - * - * event_dispatcher.h - Event dispatcher - */ -#ifndef __LIBCAMERA_EVENT_DISPATCHER_H__ -#define __LIBCAMERA_EVENT_DISPATCHER_H__ - -#include - -namespace libcamera { - -class EventNotifier; -class Timer; - -class EventDispatcher -{ -public: - virtual ~EventDispatcher(); - - virtual void registerEventNotifier(EventNotifier *notifier) = 0; - virtual void unregisterEventNotifier(EventNotifier *notifier) = 0; - - virtual void registerTimer(Timer *timer) = 0; - virtual void unregisterTimer(Timer *timer) = 0; - - virtual void processEvents() = 0; - - virtual void interrupt() = 0; -}; - -} /* namespace libcamera */ - -#endif /* __LIBCAMERA_EVENT_DISPATCHER_H__ */ diff --git a/include/libcamera/event_notifier.h b/include/libcamera/event_notifier.h deleted file mode 100644 index a37b02ee..00000000 --- a/include/libcamera/event_notifier.h +++ /dev/null @@ -1,48 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2019, Google Inc. - * - * event_notifier.h - File descriptor event notifier - */ -#ifndef __LIBCAMERA_EVENT_NOTIFIER_H__ -#define __LIBCAMERA_EVENT_NOTIFIER_H__ - -#include -#include - -namespace libcamera { - -class Message; - -class EventNotifier : public Object -{ -public: - enum Type { - Read, - Write, - Exception, - }; - - EventNotifier(int fd, Type type, Object *parent = nullptr); - virtual ~EventNotifier(); - - Type type() const { return type_; } - int fd() const { return fd_; } - - bool enabled() const { return enabled_; } - void setEnabled(bool enable); - - Signal activated; - -protected: - void message(Message *msg) override; - -private: - int fd_; - Type type_; - bool enabled_; -}; - -} /* namespace libcamera */ - -#endif /* __LIBCAMERA_EVENT_NOTIFIER_H__ */ diff --git a/include/libcamera/internal/event_dispatcher.h b/include/libcamera/internal/event_dispatcher.h new file mode 100644 index 00000000..cb06bf20 --- /dev/null +++ b/include/libcamera/internal/event_dispatcher.h @@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * event_dispatcher.h - Event dispatcher + */ +#ifndef __LIBCAMERA_EVENT_DISPATCHER_H__ +#define __LIBCAMERA_EVENT_DISPATCHER_H__ + +#include + +namespace libcamera { + +class EventNotifier; +class Timer; + +class EventDispatcher +{ +public: + virtual ~EventDispatcher(); + + virtual void registerEventNotifier(EventNotifier *notifier) = 0; + virtual void unregisterEventNotifier(EventNotifier *notifier) = 0; + + virtual void registerTimer(Timer *timer) = 0; + virtual void unregisterTimer(Timer *timer) = 0; + + virtual void processEvents() = 0; + + virtual void interrupt() = 0; +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_EVENT_DISPATCHER_H__ */ diff --git a/include/libcamera/internal/event_dispatcher_poll.h b/include/libcamera/internal/event_dispatcher_poll.h index 39d9be52..33de051d 100644 --- a/include/libcamera/internal/event_dispatcher_poll.h +++ b/include/libcamera/internal/event_dispatcher_poll.h @@ -11,7 +11,7 @@ #include #include -#include +#include "libcamera/internal/event_dispatcher.h" struct pollfd; diff --git a/include/libcamera/internal/event_notifier.h b/include/libcamera/internal/event_notifier.h new file mode 100644 index 00000000..a37b02ee --- /dev/null +++ b/include/libcamera/internal/event_notifier.h @@ -0,0 +1,48 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * event_notifier.h - File descriptor event notifier + */ +#ifndef __LIBCAMERA_EVENT_NOTIFIER_H__ +#define __LIBCAMERA_EVENT_NOTIFIER_H__ + +#include +#include + +namespace libcamera { + +class Message; + +class EventNotifier : public Object +{ +public: + enum Type { + Read, + Write, + Exception, + }; + + EventNotifier(int fd, Type type, Object *parent = nullptr); + virtual ~EventNotifier(); + + Type type() const { return type_; } + int fd() const { return fd_; } + + bool enabled() const { return enabled_; } + void setEnabled(bool enable); + + Signal activated; + +protected: + void message(Message *msg) override; + +private: + int fd_; + Type type_; + bool enabled_; +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_EVENT_NOTIFIER_H__ */ diff --git a/include/libcamera/internal/meson.build b/include/libcamera/internal/meson.build index 6500fe2a..7cde023f 100644 --- a/include/libcamera/internal/meson.build +++ b/include/libcamera/internal/meson.build @@ -18,7 +18,9 @@ libcamera_internal_headers = files([ 'device_enumerator.h', 'device_enumerator_sysfs.h', 'device_enumerator_udev.h', + 'event_dispatcher.h', 'event_dispatcher_poll.h', + 'event_notifier.h', 'file.h', 'formats.h', 'ipa_context_wrapper.h', @@ -36,6 +38,7 @@ libcamera_internal_headers = files([ 'semaphore.h', 'sysfs.h', 'thread.h', + 'timer.h', 'utils.h', 'v4l2_controls.h', 'v4l2_device.h', diff --git a/include/libcamera/internal/timer.h b/include/libcamera/internal/timer.h new file mode 100644 index 00000000..f55fe3c0 --- /dev/null +++ b/include/libcamera/internal/timer.h @@ -0,0 +1,49 @@ +/* SPDX-License-Identifier: LGPL-2.1-or-later */ +/* + * Copyright (C) 2019, Google Inc. + * + * timer.h - Generic timer + */ +#ifndef __LIBCAMERA_TIMER_H__ +#define __LIBCAMERA_TIMER_H__ + +#include +#include + +#include +#include + +namespace libcamera { + +class Message; + +class Timer : public Object +{ +public: + Timer(Object *parent = nullptr); + ~Timer(); + + void start(unsigned int msec) { start(std::chrono::milliseconds(msec)); } + void start(std::chrono::milliseconds duration); + void start(std::chrono::steady_clock::time_point deadline); + void stop(); + bool isRunning() const; + + std::chrono::steady_clock::time_point deadline() const { return deadline_; } + + Signal timeout; + +protected: + void message(Message *msg) override; + +private: + void registerTimer(); + void unregisterTimer(); + + bool running_; + std::chrono::steady_clock::time_point deadline_; +}; + +} /* namespace libcamera */ + +#endif /* __LIBCAMERA_TIMER_H__ */ diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build index 0b891a8f..cf2935f1 100644 --- a/include/libcamera/meson.build +++ b/include/libcamera/meson.build @@ -6,8 +6,6 @@ libcamera_public_headers = files([ 'camera.h', 'camera_manager.h', 'controls.h', - 'event_dispatcher.h', - 'event_notifier.h', 'extensible.h', 'file_descriptor.h', 'framebuffer_allocator.h', @@ -19,7 +17,6 @@ libcamera_public_headers = files([ 'signal.h', 'span.h', 'stream.h', - 'timer.h', 'transform.h', ]) diff --git a/include/libcamera/timer.h b/include/libcamera/timer.h deleted file mode 100644 index f55fe3c0..00000000 --- a/include/libcamera/timer.h +++ /dev/null @@ -1,49 +0,0 @@ -/* SPDX-License-Identifier: LGPL-2.1-or-later */ -/* - * Copyright (C) 2019, Google Inc. - * - * timer.h - Generic timer - */ -#ifndef __LIBCAMERA_TIMER_H__ -#define __LIBCAMERA_TIMER_H__ - -#include -#include - -#include -#include - -namespace libcamera { - -class Message; - -class Timer : public Object -{ -public: - Timer(Object *parent = nullptr); - ~Timer(); - - void start(unsigned int msec) { start(std::chrono::milliseconds(msec)); } - void start(std::chrono::milliseconds duration); - void start(std::chrono::steady_clock::time_point deadline); - void stop(); - bool isRunning() const; - - std::chrono::steady_clock::time_point deadline() const { return deadline_; } - - Signal timeout; - -protected: - void message(Message *msg) override; - -private: - void registerTimer(); - void unregisterTimer(); - - bool running_; - std::chrono::steady_clock::time_point deadline_; -}; - -} /* namespace libcamera */ - -#endif /* __LIBCAMERA_TIMER_H__ */ -- cgit v1.2.1