libcamera: advertise the device.product.name and not some random description

We can override the description with a localized one in the session
manager, instead, like it's done in alsa
This commit is contained in:
George Kiagiadakis 2022-05-26 19:18:35 +03:00
parent 96472e259f
commit bd37d78a8c

View file

@ -78,33 +78,14 @@ struct impl {
std::shared_ptr<Camera> camera;
};
std::string cameraDesc(const Camera *camera)
std::string cameraModel(const Camera *camera)
{
const ControlList &props = camera->properties();
bool addModel = true;
std::string name;
if (props.contains(properties::Location)) {
switch (props.get(properties::Location)) {
case properties::CameraLocationFront:
addModel = false;
name = "Internal front camera ";
break;
case properties::CameraLocationBack:
addModel = false;
name = "Internal back camera ";
break;
case properties::CameraLocationExternal:
name = "External camera ";
break;
}
}
if (addModel) {
if (props.contains(properties::Model))
name = "" + props.get(properties::Model);
else
name = "" + camera->id();
}
if (props.contains(properties::Model))
name = props.get(properties::Model);
else
name = camera->id();
return name;
}
@ -135,7 +116,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], location[10], desc[256], name[256];
char path[256], location[10], model[256], name[256];
info = SPA_DEVICE_INFO_INIT();
@ -149,8 +130,9 @@ static int emit_info(struct impl *impl, bool full)
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(model, sizeof(model), "%s", cameraModel(impl->camera.get()).c_str());
ADD_ITEM(SPA_KEY_DEVICE_PRODUCT_NAME, model);
ADD_ITEM(SPA_KEY_DEVICE_DESCRIPTION, model);
snprintf(name, sizeof(name), "libcamera_device.%s", impl->props.device);
ADD_ITEM(SPA_KEY_DEVICE_NAME, name);
#undef ADD_ITEM