cam: Do not assume Location is available

In preparation to register the Location property only if the firware
interface provides it, do not assume it is available and build the
camera name using the camera sensor model as a fallback.

Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
This commit is contained in:
Jacopo Mondi 2021-03-19 13:48:28 +01:00
parent 1a26f79f21
commit aab49f903e

View file

@ -377,23 +377,38 @@ int CamApp::run()
std::string const CamApp::cameraName(const Camera *camera)
{
const ControlList &props = camera->properties();
bool addModel = true;
std::string name;
switch (props.get(properties::Location)) {
case properties::CameraLocationFront:
name = "Internal front camera";
break;
case properties::CameraLocationBack:
name = "Internal back camera";
break;
case properties::CameraLocationExternal:
name = "External camera";
if (props.contains(properties::Model))
name += " '" + props.get(properties::Model) + "'";
break;
/*
* Construct the name from the camera location, model and ID. The model
* is only used if the location isn't present or is set to External.
*/
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;
}
}
name += " (" + camera->id() + ")";
if (addModel && props.contains(properties::Model)) {
/*
* If the camera location is not availble use the camera model
* to build the camera name.
*/
name = "'" + props.get(properties::Model) + "' ";
}
name += "(" + camera->id() + ")";
return name;
}