@@ -9,10 +9,13 @@
#include <memory>
#include <string>
+#include <vector>
namespace libcamera {
class PipelineHandler;
+class Stream;
+class StreamConfiguration;
class Camera final
{
@@ -30,6 +33,10 @@ public:
int acquire();
void release();
+ std::vector<Stream> streams() const;
+
+ int configure(std::vector<StreamConfiguration *> &config);
+
private:
explicit Camera(const std::string &name, class PipelineHandler *pipe);
~Camera();
@@ -6,6 +6,9 @@
*/
#include <libcamera/camera.h>
+#include <libcamera/stream.h>
+
+#include "pipeline_handler.h"
#include "log.h"
@@ -144,4 +147,49 @@ void Camera::release()
acquired_ = false;
}
+/**
+ * \brief Retrieve the supported streams of the camera
+ *
+ * \return An array of streams supported by the camera device
+ */
+std::vector<Stream> Camera::streams() const
+{
+ std::vector<Stream> streams;
+
+ if (pipe_)
+ streams = pipe_->streams(this);
+
+ return streams;
+}
+
+/**
+ * \brief Configure the camera device prior to capture
+ *
+ * Prior to starting capture, the camera device must be configured to select a
+ * set of streams.
+ *
+ * The requested configuration \a config shall contain at least one stream and
+ * may contain multiple streams. For each stream an associated StreamFormat
+ * shall be supplied. Streams supported by the camera device not part of the
+ * \a config will be disabled.
+ *
+ * Exclusive access to the camera device shall be ensured by a call to
+ * Camera::acquire() before calling this function, otherwise an -EACCES error
+ * will be returned.
+ *
+ * \param[in] config Array of stream configurations to setup
+ *
+ * \return 0 on success or a negative error code on error.
+ */
+int Camera::configure(std::vector<StreamConfiguration *> &config)
+{
+ if (!pipe_)
+ return -ENODEV;
+
+ if (!acquired_)
+ return -EACCES;
+
+ return pipe_->configure(this, config);
+}
+
} /* namespace libcamera */
Add retrieval and configuration of streams information and configuration. The implementation in the Camera are minimalistic as the heavily lifting are done by the pipeline handler implementations. The single most important thing for the helpers in the Camera object is to perform access control and making sure no request is forwarded to a pipeline handler if the camera have been disconnected. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> --- include/libcamera/camera.h | 7 ++++++ src/libcamera/camera.cpp | 48 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+)