@@ -7,11 +7,16 @@
#ifndef __LIBCAMERA_CAMERA_H__
#define __LIBCAMERA_CAMERA_H__
+#include <map>
#include <memory>
#include <string>
+#include <vector>
namespace libcamera {
+class Stream;
+class StreamFormat;
+
class Camera final
{
public:
@@ -22,6 +27,10 @@ public:
const std::string &name() const;
+ std::vector<Stream> streams() const;
+
+ int configure(const std::map<unsigned int, StreamFormat *> &config);
+
int acquire();
void release();
@@ -6,6 +6,7 @@
*/
#include <libcamera/camera.h>
+#include <libcamera/stream.h>
#include "log.h"
@@ -83,6 +84,51 @@ const std::string &Camera::name() const
return name_;
}
+/**
+ * \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;
+
+ /* TODO: Call into pipeline handler and get streams. */
+ /* HACK: Hard code a single stream with ID 0. */
+ streams.push_back(Stream(0));
+
+ 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(const std::map<unsigned int, StreamFormat *> &config)
+{
+ if (!acquired_)
+ return -EACCES;
+
+ /* TODO: Call into pipeline handler to configure the hardware. */
+
+ return 0;
+}
+
Camera::Camera(const std::string &name)
: name_(name)
{
Implement stubs for retrieving the streams of a camera and configuration of the same. This just add stubs and further building blocks are needed to make this useful. Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> --- include/libcamera/camera.h | 9 ++++++++ src/libcamera/camera.cpp | 46 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+)