libcamera/base: Move extended base functionality

Move the functionality for the following components to the new
base support library:

 - BoundMethod
 - EventDispatcher
 - EventDispatcherPoll
 - Log
 - Message
 - Object
 - Signal
 - Semaphore
 - Thread
 - Timer

While it would be preferable to see these split to move one component
per commit, these components are all interdependent upon each other,
which leaves us with one big change performing the move for all of them.

Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Kieran Bingham
2021-06-15 16:15:12 +01:00
parent 6410d1d37c
commit 27aff949fb
161 changed files with 390 additions and 366 deletions

View File

@@ -4,8 +4,8 @@
*
* bound_method.h - Method bind and invocation
*/
#ifndef __LIBCAMERA_BOUND_METHOD_H__
#define __LIBCAMERA_BOUND_METHOD_H__
#ifndef __LIBCAMERA_BASE_BOUND_METHOD_H__
#define __LIBCAMERA_BASE_BOUND_METHOD_H__
#include <memory>
#include <tuple>
@@ -236,4 +236,4 @@ private:
} /* namespace libcamera */
#endif /* __LIBCAMERA_BOUND_METHOD_H__ */
#endif /* __LIBCAMERA_BASE_BOUND_METHOD_H__ */

View File

@@ -4,8 +4,8 @@
*
* event_dispatcher.h - Event dispatcher
*/
#ifndef __LIBCAMERA_INTERNAL_EVENT_DISPATCHER_H__
#define __LIBCAMERA_INTERNAL_EVENT_DISPATCHER_H__
#ifndef __LIBCAMERA_BASE_EVENT_DISPATCHER_H__
#define __LIBCAMERA_BASE_EVENT_DISPATCHER_H__
#include <vector>
@@ -32,4 +32,4 @@ public:
} /* namespace libcamera */
#endif /* __LIBCAMERA_INTERNAL_EVENT_DISPATCHER_H__ */
#endif /* __LIBCAMERA_BASE_EVENT_DISPATCHER_H__ */

View File

@@ -4,14 +4,14 @@
*
* event_dispatcher_poll.h - Poll-based event dispatcher
*/
#ifndef __LIBCAMERA_INTERNAL_EVENT_DISPATCHER_POLL_H__
#define __LIBCAMERA_INTERNAL_EVENT_DISPATCHER_POLL_H__
#ifndef __LIBCAMERA_BASE_EVENT_DISPATCHER_POLL_H__
#define __LIBCAMERA_BASE_EVENT_DISPATCHER_POLL_H__
#include <list>
#include <map>
#include <vector>
#include "libcamera/internal/event_dispatcher.h"
#include <libcamera/base/event_dispatcher.h>
struct pollfd;
@@ -55,4 +55,4 @@ private:
} /* namespace libcamera */
#endif /* __LIBCAMERA_INTERNAL_EVENT_DISPATCHER_POLL_H__ */
#endif /* __LIBCAMERA_BASE_EVENT_DISPATCHER_POLL_H__ */

View File

@@ -4,8 +4,8 @@
*
* log.h - Logging infrastructure
*/
#ifndef __LIBCAMERA_INTERNAL_LOG_H__
#define __LIBCAMERA_INTERNAL_LOG_H__
#ifndef __LIBCAMERA_BASE_LOG_H__
#define __LIBCAMERA_BASE_LOG_H__
#include <chrono>
#include <sstream>
@@ -127,4 +127,4 @@ LogMessage _log(const LogCategory *category, LogSeverity severity,
} /* namespace libcamera */
#endif /* __LIBCAMERA_INTERNAL_LOG_H__ */
#endif /* __LIBCAMERA_BASE_LOG_H__ */

View File

@@ -3,7 +3,17 @@
libcamera_base_include_dir = libcamera_include_dir / 'base'
libcamera_base_headers = files([
'bound_method.h',
'class.h',
'event_dispatcher.h',
'event_dispatcher_poll.h',
'log.h',
'message.h',
'object.h',
'semaphore.h',
'signal.h',
'thread.h',
'timer.h',
'utils.h',
])

View File

@@ -4,12 +4,12 @@
*
* message.h - Message queue support
*/
#ifndef __LIBCAMERA_INTERNAL_MESSAGE_H__
#define __LIBCAMERA_INTERNAL_MESSAGE_H__
#ifndef __LIBCAMERA_BASE_MESSAGE_H__
#define __LIBCAMERA_BASE_MESSAGE_H__
#include <atomic>
#include <libcamera/bound_method.h>
#include <libcamera/base/bound_method.h>
namespace libcamera {
@@ -68,4 +68,4 @@ private:
} /* namespace libcamera */
#endif /* __LIBCAMERA_INTERNAL_MESSAGE_H__ */
#endif /* __LIBCAMERA_BASE_MESSAGE_H__ */

View File

@@ -4,14 +4,14 @@
*
* object.h - Base object
*/
#ifndef __LIBCAMERA_OBJECT_H__
#define __LIBCAMERA_OBJECT_H__
#ifndef __LIBCAMERA_BASE_OBJECT_H__
#define __LIBCAMERA_BASE_OBJECT_H__
#include <list>
#include <memory>
#include <vector>
#include <libcamera/bound_method.h>
#include <libcamera/base/bound_method.h>
namespace libcamera {
@@ -68,4 +68,4 @@ private:
} /* namespace libcamera */
#endif /* __LIBCAMERA_OBJECT_H__ */
#endif /* __LIBCAMERA_BASE_OBJECT_H__ */

View File

@@ -4,12 +4,12 @@
*
* semaphore.h - General-purpose counting semaphore
*/
#ifndef __LIBCAMERA_INTERNAL_SEMAPHORE_H__
#define __LIBCAMERA_INTERNAL_SEMAPHORE_H__
#ifndef __LIBCAMERA_BASE_SEMAPHORE_H__
#define __LIBCAMERA_BASE_SEMAPHORE_H__
#include <condition_variable>
#include "libcamera/internal/thread.h"
#include <libcamera/base/thread.h>
namespace libcamera {
@@ -31,4 +31,4 @@ private:
} /* namespace libcamera */
#endif /* __LIBCAMERA_INTERNAL_SEMAPHORE_H__ */
#endif /* __LIBCAMERA_BASE_SEMAPHORE_H__ */

View File

@@ -4,16 +4,16 @@
*
* signal.h - Signal & slot implementation
*/
#ifndef __LIBCAMERA_SIGNAL_H__
#define __LIBCAMERA_SIGNAL_H__
#ifndef __LIBCAMERA_BASE_SIGNAL_H__
#define __LIBCAMERA_BASE_SIGNAL_H__
#include <functional>
#include <list>
#include <type_traits>
#include <vector>
#include <libcamera/bound_method.h>
#include <libcamera/object.h>
#include <libcamera/base/bound_method.h>
#include <libcamera/base/object.h>
namespace libcamera {
@@ -129,4 +129,4 @@ public:
} /* namespace libcamera */
#endif /* __LIBCAMERA_SIGNAL_H__ */
#endif /* __LIBCAMERA_BASE_SIGNAL_H__ */

View File

@@ -4,20 +4,18 @@
*
* thread.h - Thread support
*/
#ifndef __LIBCAMERA_INTERNAL_THREAD_H__
#define __LIBCAMERA_INTERNAL_THREAD_H__
#ifndef __LIBCAMERA_BASE_THREAD_H__
#define __LIBCAMERA_BASE_THREAD_H__
#include <memory>
#include <mutex>
#include <sys/types.h>
#include <thread>
#include <libcamera/signal.h>
#include <libcamera/base/message.h>
#include <libcamera/base/signal.h>
#include <libcamera/base/utils.h>
#include "libcamera/internal/message.h"
namespace libcamera {
class EventDispatcher;
@@ -75,4 +73,4 @@ private:
} /* namespace libcamera */
#endif /* __LIBCAMERA_INTERNAL_THREAD_H__ */
#endif /* __LIBCAMERA_BASE_THREAD_H__ */

View File

@@ -4,14 +4,14 @@
*
* timer.h - Generic timer
*/
#ifndef __LIBCAMERA_INTERNAL_TIMER_H__
#define __LIBCAMERA_INTERNAL_TIMER_H__
#ifndef __LIBCAMERA_BASE_TIMER_H__
#define __LIBCAMERA_BASE_TIMER_H__
#include <chrono>
#include <stdint.h>
#include <libcamera/object.h>
#include <libcamera/signal.h>
#include <libcamera/base/object.h>
#include <libcamera/base/signal.h>
namespace libcamera {
@@ -46,4 +46,4 @@ private:
} /* namespace libcamera */
#endif /* __LIBCAMERA_INTERNAL_TIMER_H__ */
#endif /* __LIBCAMERA_BASE_TIMER_H__ */

View File

@@ -13,11 +13,11 @@
#include <string>
#include <libcamera/base/class.h>
#include <libcamera/base/object.h>
#include <libcamera/base/signal.h>
#include <libcamera/controls.h>
#include <libcamera/object.h>
#include <libcamera/request.h>
#include <libcamera/signal.h>
#include <libcamera/stream.h>
#include <libcamera/transform.h>

View File

@@ -13,9 +13,8 @@
#include <vector>
#include <libcamera/base/class.h>
#include <libcamera/object.h>
#include <libcamera/signal.h>
#include <libcamera/base/object.h>
#include <libcamera/base/signal.h>
namespace libcamera {

View File

@@ -12,13 +12,13 @@
#include <vector>
#include <libcamera/base/class.h>
#include <libcamera/base/log.h>
#include <libcamera/controls.h>
#include <libcamera/geometry.h>
#include <libcamera/ipa/core_ipa_interface.h>
#include "libcamera/internal/formats.h"
#include "libcamera/internal/log.h"
#include "libcamera/internal/v4l2_subdevice.h"
namespace libcamera {

View File

@@ -13,7 +13,7 @@
#include <linux/media.h>
#include <libcamera/signal.h>
#include <libcamera/base/signal.h>
namespace libcamera {

View File

@@ -7,8 +7,8 @@
#ifndef __LIBCAMERA_INTERNAL_EVENT_NOTIFIER_H__
#define __LIBCAMERA_INTERNAL_EVENT_NOTIFIER_H__
#include <libcamera/object.h>
#include <libcamera/signal.h>
#include <libcamera/base/object.h>
#include <libcamera/base/signal.h>
namespace libcamera {

View File

@@ -14,6 +14,8 @@
#include <type_traits>
#include <vector>
#include <libcamera/base/log.h>
#include <libcamera/buffer.h>
#include <libcamera/control_ids.h>
#include <libcamera/geometry.h>
@@ -22,7 +24,6 @@
#include "libcamera/internal/byte_stream_buffer.h"
#include "libcamera/internal/camera_sensor.h"
#include "libcamera/internal/control_serializer.h"
#include "libcamera/internal/log.h"
namespace libcamera {

View File

@@ -10,11 +10,12 @@
#include <stdint.h>
#include <vector>
#include <libcamera/base/log.h>
#include <libcamera/ipa/ipa_interface.h>
#include <libcamera/ipa/ipa_module_info.h>
#include "libcamera/internal/ipa_module.h"
#include "libcamera/internal/log.h"
#include "libcamera/internal/pipeline_handler.h"
#include "libcamera/internal/pub_key.h"

View File

@@ -11,10 +11,11 @@
#include <string>
#include <vector>
#include <libcamera/base/log.h>
#include <libcamera/ipa/ipa_interface.h>
#include <libcamera/ipa/ipa_module_info.h>
#include "libcamera/internal/log.h"
#include "libcamera/internal/pipeline_handler.h"
namespace libcamera {

View File

@@ -9,9 +9,9 @@
#include <vector>
#include "libcamera/internal/ipc_unixsocket.h"
#include <libcamera/base/signal.h>
#include <libcamera/signal.h>
#include "libcamera/internal/ipc_unixsocket.h"
namespace libcamera {

View File

@@ -12,7 +12,7 @@
#include <sys/types.h>
#include <vector>
#include <libcamera/signal.h>
#include <libcamera/base/signal.h>
namespace libcamera {

View File

@@ -14,9 +14,9 @@
#include <linux/media.h>
#include <libcamera/signal.h>
#include <libcamera/base/log.h>
#include <libcamera/base/signal.h>
#include "libcamera/internal/log.h"
#include "libcamera/internal/media_object.h"
namespace libcamera {

View File

@@ -22,8 +22,6 @@ 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',
@@ -31,18 +29,13 @@ libcamera_internal_headers = files([
'ipa_module.h',
'ipa_proxy.h',
'ipc_unixsocket.h',
'log.h',
'media_device.h',
'media_object.h',
'message.h',
'pipeline_handler.h',
'process.h',
'pub_key.h',
'semaphore.h',
'source_paths.h',
'sysfs.h',
'thread.h',
'timer.h',
'v4l2_device.h',
'v4l2_pixelformat.h',
'v4l2_subdevice.h',

View File

@@ -16,9 +16,9 @@
#include <vector>
#include <libcamera/base/class.h>
#include <libcamera/base/object.h>
#include <libcamera/controls.h>
#include <libcamera/object.h>
#include <libcamera/stream.h>
#include "libcamera/internal/ipa_proxy.h"

View File

@@ -11,7 +11,7 @@
#include <string>
#include <vector>
#include <libcamera/signal.h>
#include <libcamera/base/signal.h>
namespace libcamera {

View File

@@ -13,11 +13,11 @@
#include <linux/videodev2.h>
#include <libcamera/controls.h>
#include <libcamera/signal.h>
#include <libcamera/span.h>
#include <libcamera/base/log.h>
#include <libcamera/base/signal.h>
#include "libcamera/internal/log.h"
#include <libcamera/controls.h>
#include <libcamera/span.h>
namespace libcamera {

View File

@@ -12,11 +12,11 @@
#include <vector>
#include <libcamera/base/class.h>
#include <libcamera/base/log.h>
#include <libcamera/geometry.h>
#include "libcamera/internal/formats.h"
#include "libcamera/internal/log.h"
#include "libcamera/internal/media_object.h"
#include "libcamera/internal/v4l2_device.h"

View File

@@ -17,14 +17,14 @@
#include <linux/videodev2.h>
#include <libcamera/base/class.h>
#include <libcamera/base/log.h>
#include <libcamera/base/signal.h>
#include <libcamera/buffer.h>
#include <libcamera/geometry.h>
#include <libcamera/pixel_format.h>
#include <libcamera/signal.h>
#include "libcamera/internal/formats.h"
#include "libcamera/internal/log.h"
#include "libcamera/internal/v4l2_device.h"
#include "libcamera/internal/v4l2_pixelformat.h"

View File

@@ -13,10 +13,11 @@
#include <map>
#include <vector>
#include <libcamera/base/signal.h>
#include <libcamera/buffer.h>
#include <libcamera/controls.h>
#include <libcamera/geometry.h>
#include <libcamera/signal.h>
namespace libcamera {

View File

@@ -1,7 +1,6 @@
# SPDX-License-Identifier: CC0-1.0
libcamera_public_headers = files([
'bound_method.h',
'buffer.h',
'camera.h',
'camera_manager.h',
@@ -11,10 +10,8 @@ libcamera_public_headers = files([
'framebuffer_allocator.h',
'geometry.h',
'logging.h',
'object.h',
'pixel_format.h',
'request.h',
'signal.h',
'span.h',
'stream.h',
'transform.h',

View File

@@ -14,9 +14,9 @@
#include <unordered_set>
#include <libcamera/base/class.h>
#include <libcamera/base/signal.h>
#include <libcamera/controls.h>
#include <libcamera/signal.h>
namespace libcamera {