Skip to content

Commit aab49f9

Browse files
committed
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>
1 parent 1a26f79 commit aab49f9

File tree

1 file changed

+28
-13
lines changed

1 file changed

+28
-13
lines changed

src/cam/main.cpp

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -377,23 +377,38 @@ int CamApp::run()
377377
std::string const CamApp::cameraName(const Camera *camera)
378378
{
379379
const ControlList &props = camera->properties();
380+
bool addModel = true;
380381
std::string name;
381382

382-
switch (props.get(properties::Location)) {
383-
case properties::CameraLocationFront:
384-
name = "Internal front camera";
385-
break;
386-
case properties::CameraLocationBack:
387-
name = "Internal back camera";
388-
break;
389-
case properties::CameraLocationExternal:
390-
name = "External camera";
391-
if (props.contains(properties::Model))
392-
name += " '" + props.get(properties::Model) + "'";
393-
break;
383+
/*
384+
* Construct the name from the camera location, model and ID. The model
385+
* is only used if the location isn't present or is set to External.
386+
*/
387+
if (props.contains(properties::Location)) {
388+
switch (props.get(properties::Location)) {
389+
case properties::CameraLocationFront:
390+
addModel = false;
391+
name = "Internal front camera ";
392+
break;
393+
case properties::CameraLocationBack:
394+
addModel = false;
395+
name = "Internal back camera ";
396+
break;
397+
case properties::CameraLocationExternal:
398+
name = "External camera ";
399+
break;
400+
}
401+
}
402+
403+
if (addModel && props.contains(properties::Model)) {
404+
/*
405+
* If the camera location is not availble use the camera model
406+
* to build the camera name.
407+
*/
408+
name = "'" + props.get(properties::Model) + "' ";
394409
}
395410

396-
name += " (" + camera->id() + ")";
411+
name += "(" + camera->id() + ")";
397412

398413
return name;
399414
}

0 commit comments

Comments
 (0)