mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
spa: libcamera: consume the device numbers libcamera property
Pass on the device numbers property of libcamera to session managers, with they are better equipped to filter the camera/video devices across v4l2 and libcamera.
This commit is contained in:
parent
983d34f344
commit
79518d13ae
2 changed files with 29 additions and 2 deletions
|
|
@ -275,7 +275,8 @@ struct spa_device_methods {
|
||||||
#define SPA_KEY_DEVICE_PROFILE_SET "device.profile-set" /**< profile set for the device */
|
#define SPA_KEY_DEVICE_PROFILE_SET "device.profile-set" /**< profile set for the device */
|
||||||
#define SPA_KEY_DEVICE_STRING "device.string" /**< device string in the underlying
|
#define SPA_KEY_DEVICE_STRING "device.string" /**< device string in the underlying
|
||||||
* layer's format. E.g. "surround51:0" */
|
* layer's format. E.g. "surround51:0" */
|
||||||
|
#define SPA_KEY_DEVICE_DEVIDS "device.devids" /**< space separated list of device ids (dev_t) of the
|
||||||
|
* underlying device(s) if applicable */
|
||||||
/**
|
/**
|
||||||
* \}
|
* \}
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
#include <libcamera/camera.h>
|
#include <libcamera/camera.h>
|
||||||
#include <libcamera/property_ids.h>
|
#include <libcamera/property_ids.h>
|
||||||
|
#include <libcamera/base/span.h>
|
||||||
|
|
||||||
using namespace libcamera;
|
using namespace libcamera;
|
||||||
|
|
||||||
|
|
@ -55,6 +56,17 @@ struct impl {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const libcamera::Span<const int64_t> cameraDevice(
|
||||||
|
const Camera *camera)
|
||||||
|
{
|
||||||
|
const ControlList &props = camera->properties();
|
||||||
|
|
||||||
|
if (auto devices = props.get(properties::SystemDevices))
|
||||||
|
return devices.value();
|
||||||
|
|
||||||
|
return {};
|
||||||
|
}
|
||||||
|
|
||||||
static std::string cameraModel(const Camera *camera)
|
static std::string cameraModel(const Camera *camera)
|
||||||
{
|
{
|
||||||
const ControlList &props = camera->properties();
|
const ControlList &props = camera->properties();
|
||||||
|
|
@ -90,7 +102,8 @@ static int emit_info(struct impl *impl, bool full)
|
||||||
uint32_t n_items = 0;
|
uint32_t n_items = 0;
|
||||||
struct spa_device_info info;
|
struct spa_device_info info;
|
||||||
struct spa_param_info params[2];
|
struct spa_param_info params[2];
|
||||||
char path[256], model[256], name[256];
|
char path[256], model[256], name[256], devices_str[128];
|
||||||
|
struct spa_strbuf buf;
|
||||||
|
|
||||||
info = SPA_DEVICE_INFO_INIT();
|
info = SPA_DEVICE_INFO_INIT();
|
||||||
|
|
||||||
|
|
@ -111,6 +124,19 @@ static int emit_info(struct impl *impl, bool full)
|
||||||
ADD_ITEM(SPA_KEY_DEVICE_DESCRIPTION, model);
|
ADD_ITEM(SPA_KEY_DEVICE_DESCRIPTION, model);
|
||||||
snprintf(name, sizeof(name), "libcamera_device.%s", impl->device_id.c_str());
|
snprintf(name, sizeof(name), "libcamera_device.%s", impl->device_id.c_str());
|
||||||
ADD_ITEM(SPA_KEY_DEVICE_NAME, name);
|
ADD_ITEM(SPA_KEY_DEVICE_NAME, name);
|
||||||
|
|
||||||
|
auto device_numbers = cameraDevice(impl->camera.get());
|
||||||
|
|
||||||
|
if (!device_numbers.empty()) {
|
||||||
|
spa_strbuf_init(&buf, devices_str, sizeof(devices_str));
|
||||||
|
|
||||||
|
/* created a space separated string of all the device numbers */
|
||||||
|
for (int64_t device_number : device_numbers)
|
||||||
|
spa_strbuf_append(&buf, "%" PRId64 " ", device_number);
|
||||||
|
|
||||||
|
ADD_ITEM(SPA_KEY_DEVICE_DEVIDS, devices_str);
|
||||||
|
}
|
||||||
|
|
||||||
#undef ADD_ITEM
|
#undef ADD_ITEM
|
||||||
|
|
||||||
dict = SPA_DICT_INIT(items, n_items);
|
dict = SPA_DICT_INIT(items, n_items);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue