mirror of
https://gitlab.freedesktop.org/pipewire/pipewire
synced 2024-09-20 00:11:31 +00:00
v4l2: propagate vendor and device id to the node object
When pipewire is accessed through the portal camera API then only the camera node objects are visible for the client. However, chromium wants to know the vendor and device ids to identify cameras. And those properties are currently only added to the device object. Fix this by propagating the ids to the node object. Fixes #1879
This commit is contained in:
parent
22d668a8a0
commit
f5ec830cc2
|
@ -49,6 +49,8 @@ static const char default_device[] = "/dev/video0";
|
||||||
|
|
||||||
struct props {
|
struct props {
|
||||||
char device[64];
|
char device[64];
|
||||||
|
char product_id[6];
|
||||||
|
char vendor_id[6];
|
||||||
int device_fd;
|
int device_fd;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -73,7 +75,7 @@ struct impl {
|
||||||
static int emit_info(struct impl *this, bool full)
|
static int emit_info(struct impl *this, bool full)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
struct spa_dict_item items[10];
|
struct spa_dict_item items[12];
|
||||||
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];
|
||||||
|
@ -91,6 +93,10 @@ static int emit_info(struct impl *this, bool full)
|
||||||
ADD_ITEM(SPA_KEY_OBJECT_PATH, path);
|
ADD_ITEM(SPA_KEY_OBJECT_PATH, path);
|
||||||
ADD_ITEM(SPA_KEY_DEVICE_API, "v4l2");
|
ADD_ITEM(SPA_KEY_DEVICE_API, "v4l2");
|
||||||
ADD_ITEM(SPA_KEY_MEDIA_CLASS, "Video/Device");
|
ADD_ITEM(SPA_KEY_MEDIA_CLASS, "Video/Device");
|
||||||
|
if (this->props.product_id[0])
|
||||||
|
ADD_ITEM(SPA_KEY_DEVICE_PRODUCT_ID, this->props.product_id);
|
||||||
|
if (this->props.vendor_id[0])
|
||||||
|
ADD_ITEM(SPA_KEY_DEVICE_VENDOR_ID, this->props.vendor_id);
|
||||||
ADD_ITEM(SPA_KEY_API_V4L2_PATH, (char *)this->props.device);
|
ADD_ITEM(SPA_KEY_API_V4L2_PATH, (char *)this->props.device);
|
||||||
ADD_ITEM(SPA_KEY_API_V4L2_CAP_DRIVER, (char *)this->dev.cap.driver);
|
ADD_ITEM(SPA_KEY_API_V4L2_CAP_DRIVER, (char *)this->dev.cap.driver);
|
||||||
ADD_ITEM(SPA_KEY_API_V4L2_CAP_CARD, (char *)this->dev.cap.card);
|
ADD_ITEM(SPA_KEY_API_V4L2_CAP_CARD, (char *)this->dev.cap.card);
|
||||||
|
@ -247,6 +253,10 @@ impl_init(const struct spa_handle_factory *factory,
|
||||||
|
|
||||||
if (info && (str = spa_dict_lookup(info, SPA_KEY_API_V4L2_PATH)))
|
if (info && (str = spa_dict_lookup(info, SPA_KEY_API_V4L2_PATH)))
|
||||||
strncpy(this->props.device, str, 63);
|
strncpy(this->props.device, str, 63);
|
||||||
|
if (info && (str = spa_dict_lookup(info, SPA_KEY_DEVICE_PRODUCT_ID)))
|
||||||
|
strncpy(this->props.product_id, str, 5);
|
||||||
|
if (info && (str = spa_dict_lookup(info, SPA_KEY_DEVICE_VENDOR_ID)))
|
||||||
|
strncpy(this->props.vendor_id, str, 5);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue