summaryrefslogtreecommitdiff
path: root/src/cam/camera_session.cpp
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-07-07 02:12:07 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-07-22 17:13:53 +0300
commit66c955648febf926ce4e4e238d7f19d171619f5f (patch)
tree38b45be270a7a8e2c75c47d2bbfbc4566ee3809e /src/cam/camera_session.cpp
parent3d5093911396558b03b7f9815b3c467afc426f82 (diff)
cam: Move printing of camera information to CameraSession class
The three CamApp functions listControls(), listProperties() and infoConfiguration() operate on a camera. They would thus be better placed in the CameraSession class. Move them there. As they now have no error to return anymore, make them void functions. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src/cam/camera_session.cpp')
-rw-r--r--src/cam/camera_session.cpp45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/cam/camera_session.cpp b/src/cam/camera_session.cpp
index 10e66446..ceb2c3ab 100644
--- a/src/cam/camera_session.cpp
+++ b/src/cam/camera_session.cpp
@@ -11,6 +11,7 @@
#include <sstream>
#include <libcamera/control_ids.h>
+#include <libcamera/property_ids.h>
#include "camera_session.h"
#include "event_loop.h"
@@ -89,6 +90,50 @@ CameraSession::~CameraSession()
camera_->release();
}
+void CameraSession::listControls() const
+{
+ for (const auto &ctrl : camera_->controls()) {
+ const ControlId *id = ctrl.first;
+ const ControlInfo &info = ctrl.second;
+
+ std::cout << "Control: " << id->name() << ": "
+ << info.toString() << std::endl;
+ }
+}
+
+void CameraSession::listProperties() const
+{
+ for (const auto &prop : camera_->properties()) {
+ const ControlId *id = properties::properties.at(prop.first);
+ const ControlValue &value = prop.second;
+
+ std::cout << "Property: " << id->name() << " = "
+ << value.toString() << std::endl;
+ }
+}
+
+void CameraSession::infoConfiguration() const
+{
+ unsigned int index = 0;
+ for (const StreamConfiguration &cfg : *config_) {
+ std::cout << index << ": " << cfg.toString() << std::endl;
+
+ const StreamFormats &formats = cfg.formats();
+ for (PixelFormat pixelformat : formats.pixelformats()) {
+ std::cout << " * Pixelformat: "
+ << pixelformat.toString() << " "
+ << formats.range(pixelformat).toString()
+ << std::endl;
+
+ for (const Size &size : formats.sizes(pixelformat))
+ std::cout << " - " << size.toString()
+ << std::endl;
+ }
+
+ index++;
+ }
+}
+
int CameraSession::start(const OptionsParser::Options &options)
{
int ret;