libcamera: Add event notification infrastructure
Add three new classes, EventDispatcher, EventNotifier and Timer, that define APIs for file descriptor event notification and timers. The implementation of the EventDispatcher is meant to be provided to libcamera by the application. The event dispatcher is integrated twith the camera manager to implement automatic registration of timers and events. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
@@ -6,8 +6,10 @@
|
||||
*/
|
||||
|
||||
#include <libcamera/camera_manager.h>
|
||||
#include <libcamera/event_dispatcher.h>
|
||||
|
||||
#include "device_enumerator.h"
|
||||
#include "log.h"
|
||||
#include "pipeline_handler.h"
|
||||
|
||||
/**
|
||||
@@ -37,10 +39,15 @@
|
||||
namespace libcamera {
|
||||
|
||||
CameraManager::CameraManager()
|
||||
: enumerator_(nullptr)
|
||||
: enumerator_(nullptr), dispatcher_(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
CameraManager::~CameraManager()
|
||||
{
|
||||
delete dispatcher_;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Start the camera manager
|
||||
*
|
||||
@@ -176,4 +183,36 @@ CameraManager *CameraManager::instance()
|
||||
return &manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Set the event dispatcher
|
||||
* \param dispatcher Pointer to the event dispatcher
|
||||
*
|
||||
* libcamera requires an event dispatcher to integrate event notification and
|
||||
* timers with the application event loop. Applications shall call this function
|
||||
* once and only once before the camera manager is started with start() to set
|
||||
* the event dispatcher.
|
||||
*
|
||||
* The CameraManager takes ownership of the event dispatcher and will delete it
|
||||
* when the application terminates.
|
||||
*/
|
||||
void CameraManager::setEventDispatcher(EventDispatcher *dispatcher)
|
||||
{
|
||||
if (dispatcher_) {
|
||||
LOG(Warning) << "Event dispatcher is already set";
|
||||
return;
|
||||
}
|
||||
|
||||
dispatcher_ = dispatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Retrieve the event dispatcher
|
||||
* \return Pointer to the event dispatcher, or nullptr if no event dispatcher
|
||||
* has been set
|
||||
*/
|
||||
EventDispatcher *CameraManager::eventDispatcher()
|
||||
{
|
||||
return dispatcher_;
|
||||
}
|
||||
|
||||
} /* namespace libcamera */
|
||||
|
||||
Reference in New Issue
Block a user