[libcamera-devel] [RFC 4/4] libcamera: camera: integrate streams and configuration
Niklas Söderlund
niklas.soderlund at ragnatech.se
Tue Jan 22 00:06:40 CET 2019
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 at ragnatech.se>
---
include/libcamera/camera.h | 9 ++++++++
src/libcamera/camera.cpp | 46 ++++++++++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+)
diff --git a/include/libcamera/camera.h b/include/libcamera/camera.h
index 03b285c840c246e1..13395d994bade85a 100644
--- a/include/libcamera/camera.h
+++ b/include/libcamera/camera.h
@@ -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();
diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
index b80bc36e410a6e0a..ad9cf948135c03bd 100644
--- a/src/libcamera/camera.cpp
+++ b/src/libcamera/camera.cpp
@@ -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)
{
--
2.20.1
More information about the libcamera-devel
mailing list