diff options
author | Jacopo Mondi <jacopo@jmondi.org> | 2021-03-19 13:48:28 +0100 |
---|---|---|
committer | Jacopo Mondi <jacopo@jmondi.org> | 2021-03-22 08:58:52 +0100 |
commit | aab49f903e858a2ea9765514bcc26bbd18edd13c (patch) | |
tree | 658a5e3c07e40c2facbfe1970ad536e0864669e0 | |
parent | 1a26f79f213f294f16f169d2e3dd9d37517d486d (diff) |
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>
-rw-r--r-- | src/cam/main.cpp | 41 |
1 files changed, 28 insertions, 13 deletions
diff --git a/src/cam/main.cpp b/src/cam/main.cpp index e01be63a..994fbb34 100644 --- a/src/cam/main.cpp +++ b/src/cam/main.cpp @@ -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; + } + } + + 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() + ")"; + name += "(" + camera->id() + ")"; return name; } |