From 44176d4118ffd2d3c37fa10a3978492a82200afc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= Date: Sat, 3 Jan 2026 22:34:40 +0100 Subject: [PATCH] spa: libcamera: expose libcamera version Expose the libcamera header and library versions in the device properties similarly to `api.v4l2.cap.version` used by the v4l2 plugin. The keys are not yet promoted into the public `keys.h` header file. --- spa/plugins/libcamera/libcamera-device.cpp | 4 +++- spa/plugins/libcamera/libcamera-manager.cpp | 2 ++ spa/plugins/libcamera/libcamera-source.cpp | 2 ++ spa/plugins/libcamera/libcamera.hpp | 18 ++++++++++++++++++ 4 files changed, 25 insertions(+), 1 deletion(-) diff --git a/spa/plugins/libcamera/libcamera-device.cpp b/spa/plugins/libcamera/libcamera-device.cpp index ce29671bd..c135b78b1 100644 --- a/spa/plugins/libcamera/libcamera-device.cpp +++ b/spa/plugins/libcamera/libcamera-device.cpp @@ -98,7 +98,7 @@ const char *cameraRot(const Camera& camera) int emit_info(struct impl *impl, bool full) { - struct spa_dict_item items[10]; + struct spa_dict_item items[12]; struct spa_dict dict; uint32_t n_items = 0; struct spa_device_info info; @@ -117,6 +117,8 @@ int emit_info(struct impl *impl, bool full) ADD_ITEM(SPA_KEY_DEVICE_API, "libcamera"); ADD_ITEM(SPA_KEY_MEDIA_CLASS, "Video/Device"); ADD_ITEM(SPA_KEY_API_LIBCAMERA_PATH, impl->device_id.c_str()); + ADD_ITEM(KEY_VERSION_LIBRARY, libcamera_library_version()); + ADD_ITEM(KEY_VERSION_HEADER, libcamera_header_version()); if (auto location = cameraLoc(camera)) ADD_ITEM(SPA_KEY_API_LIBCAMERA_LOCATION, location); diff --git a/spa/plugins/libcamera/libcamera-manager.cpp b/spa/plugins/libcamera/libcamera-manager.cpp index 9dc4ce49f..a2749a3c8 100644 --- a/spa/plugins/libcamera/libcamera-manager.cpp +++ b/spa/plugins/libcamera/libcamera-manager.cpp @@ -132,6 +132,8 @@ int emit_object_info(struct impl *impl, const struct device *device) { SPA_KEY_DEVICE_API, "libcamera" }, { SPA_KEY_MEDIA_CLASS, "Video/Device" }, { SPA_KEY_API_LIBCAMERA_PATH, device->camera->id().c_str() }, + { KEY_VERSION_LIBRARY, libcamera_library_version() }, + { KEY_VERSION_HEADER, libcamera_header_version() }, }; dict = SPA_DICT_INIT_ARRAY(items); diff --git a/spa/plugins/libcamera/libcamera-source.cpp b/spa/plugins/libcamera/libcamera-source.cpp index f027f661e..ff3376e4f 100644 --- a/spa/plugins/libcamera/libcamera-source.cpp +++ b/spa/plugins/libcamera/libcamera-source.cpp @@ -1608,6 +1608,8 @@ void emit_node_info(struct impl *impl, bool full) { SPA_KEY_MEDIA_CLASS, "Video/Source" }, { SPA_KEY_MEDIA_ROLE, "Camera" }, { SPA_KEY_NODE_DRIVER, "true" }, + { KEY_VERSION_LIBRARY, libcamera_library_version() }, + { KEY_VERSION_HEADER, libcamera_header_version() }, }; uint64_t old = full ? impl->info.change_mask : 0; if (full) diff --git a/spa/plugins/libcamera/libcamera.hpp b/spa/plugins/libcamera/libcamera.hpp index 9b1089182..7f21863a7 100644 --- a/spa/plugins/libcamera/libcamera.hpp +++ b/spa/plugins/libcamera/libcamera.hpp @@ -7,8 +7,13 @@ #include #include +#include #include +#include + +#define KEY_VERSION_LIBRARY "api.libcamera.version.library" +#define KEY_VERSION_HEADER "api.libcamera.version.header" extern "C" { @@ -27,4 +32,17 @@ static inline void libcamera_log_topic_init(struct spa_log *log) spa_log_topic_init(log, &libcamera_log_topic); } +static inline const char *libcamera_library_version() +{ + return libcamera::CameraManager::version().c_str(); +} + +static inline const char *libcamera_header_version() +{ + return + SPA_STRINGIFY(LIBCAMERA_VERSION_MAJOR) "." + SPA_STRINGIFY(LIBCAMERA_VERSION_MINOR) "." + SPA_STRINGIFY(LIBCAMERA_VERSION_PATCH); +} + std::shared_ptr libcamera_manager_acquire(int& res);