From bd37d78a8c9b6ce534f96c7106d62c6c68e2eb75 Mon Sep 17 00:00:00 2001 From: George Kiagiadakis Date: Thu, 26 May 2022 19:18:35 +0300 Subject: [PATCH] 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 --- spa/plugins/libcamera/libcamera-device.cpp | 36 ++++++---------------- 1 file changed, 9 insertions(+), 27 deletions(-) diff --git a/spa/plugins/libcamera/libcamera-device.cpp b/spa/plugins/libcamera/libcamera-device.cpp index 0c7e95fd8..7f006a0cc 100644 --- a/spa/plugins/libcamera/libcamera-device.cpp +++ b/spa/plugins/libcamera/libcamera-device.cpp @@ -78,33 +78,14 @@ struct impl { std::shared_ptr 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