mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
libcamera: add camera location property on nodes
This commit is contained in:
parent
d4efdb44e3
commit
cd8ac5c1a6
2 changed files with 24 additions and 1 deletions
|
|
@ -93,6 +93,8 @@ extern "C" {
|
|||
#define SPA_KEY_API_LIBCAMERA "api.libcamera" /**< key for the libcamera api */
|
||||
#define SPA_KEY_API_LIBCAMERA_PATH "api.libcamera.path" /**< libcamera device path as can be
|
||||
* used in open() */
|
||||
#define SPA_KEY_API_LIBCAMERA_LOCATION "api.libcamera.location" /**< location of the camera:
|
||||
* "front", "back" or "external" */
|
||||
|
||||
/** info from libcamera_capability */
|
||||
#define SPA_KEY_API_LIBCAMERA_CAP_DRIVER "api.libcamera.cap.driver" /**< driver from capbility */
|
||||
|
|
|
|||
|
|
@ -108,6 +108,25 @@ std::string cameraDesc(const Camera *camera)
|
|||
return name;
|
||||
}
|
||||
|
||||
std::string cameraLoc(const Camera *camera)
|
||||
{
|
||||
const ControlList &props = camera->properties();
|
||||
std::string location;
|
||||
if (props.contains(properties::Location)) {
|
||||
switch (props.get(properties::Location)) {
|
||||
case properties::CameraLocationFront:
|
||||
location = "front";
|
||||
break;
|
||||
case properties::CameraLocationBack:
|
||||
location = "back";
|
||||
break;
|
||||
case properties::CameraLocationExternal:
|
||||
location = "external";
|
||||
break;
|
||||
}
|
||||
}
|
||||
return location;
|
||||
}
|
||||
|
||||
static int emit_info(struct impl *impl, bool full)
|
||||
{
|
||||
|
|
@ -116,7 +135,7 @@ static int emit_info(struct impl *impl, bool full)
|
|||
uint32_t n_items = 0;
|
||||
struct spa_device_info info;
|
||||
struct spa_param_info params[2];
|
||||
char path[256], desc[256], name[256];
|
||||
char path[256], location[10], desc[256], name[256];
|
||||
|
||||
info = SPA_DEVICE_INFO_INIT();
|
||||
|
||||
|
|
@ -128,6 +147,8 @@ static 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, (char *)impl->props.device);
|
||||
snprintf(location, sizeof(location), "%s", cameraLoc(impl->camera.get()).c_str());
|
||||
ADD_ITEM(SPA_KEY_API_LIBCAMERA_LOCATION, location);
|
||||
snprintf(desc, sizeof(desc), "%s", cameraDesc(impl->camera.get()).c_str());
|
||||
ADD_ITEM(SPA_KEY_DEVICE_DESCRIPTION, desc);
|
||||
snprintf(name, sizeof(name), "libcamera_device.%s", impl->props.device);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue