[libcamera-devel,RFC,2/4] libcamera: stream: add basic stream class

Message ID 20190121230640.8783-3-niklas.soderlund@ragnatech.se
State Rejected
Headers show
Series
  • libcamera: add base for applications to configure cameras
Related show

Commit Message

Niklas Söderlund Jan. 21, 2019, 11:06 p.m. UTC
Add a extremely simple Stream implementation. The idea is that once
capability support is added to the library each stream would describe
it's capabilities using this class. A application would then select one
or more streams based on these capabilities and using there numerical ID
configure and capture those streams.

At this stage all the Stream class provides is a way for a Camera object
to communicate which stream IDs it's able to operate on. This basically
limits the usefulness of the object to cameras which only provides one
stream per camera.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
---
 include/libcamera/libcamera.h |  1 +
 include/libcamera/meson.build |  1 +
 include/libcamera/stream.h    | 25 +++++++++++++++
 src/libcamera/meson.build     |  1 +
 src/libcamera/stream.cpp      | 58 +++++++++++++++++++++++++++++++++++
 5 files changed, 86 insertions(+)
 create mode 100644 include/libcamera/stream.h
 create mode 100644 src/libcamera/stream.cpp

Patch

diff --git a/include/libcamera/libcamera.h b/include/libcamera/libcamera.h
index c0511cf6d662b63f..272dfd5e4a67d5de 100644
--- a/include/libcamera/libcamera.h
+++ b/include/libcamera/libcamera.h
@@ -12,6 +12,7 @@ 
 #include <libcamera/event_dispatcher.h>
 #include <libcamera/event_notifier.h>
 #include <libcamera/signal.h>
+#include <libcamera/stream.h>
 #include <libcamera/timer.h>
 
 #endif /* __LIBCAMERA_LIBCAMERA_H__ */
diff --git a/include/libcamera/meson.build b/include/libcamera/meson.build
index d7cb55ba4a49e1e8..54a680787e5c17aa 100644
--- a/include/libcamera/meson.build
+++ b/include/libcamera/meson.build
@@ -5,6 +5,7 @@  libcamera_api = files([
     'event_notifier.h',
     'libcamera.h',
     'signal.h',
+    'stream.h',
     'timer.h',
 ])
 
diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h
new file mode 100644
index 0000000000000000..8386c68e33fe57d0
--- /dev/null
+++ b/include/libcamera/stream.h
@@ -0,0 +1,25 @@ 
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2019, Google Inc.
+ *
+ * stream.h - Stream object interface
+ */
+#ifndef __LIBCAMERA_STREAM_H__
+#define __LIBCAMERA_STREAM_H__
+
+namespace libcamera {
+
+class Stream final
+{
+public:
+	Stream(unsigned int id);
+
+	unsigned int id() { return id_; };
+
+private:
+	unsigned int id_;
+};
+
+} /* namespace libcamera */
+
+#endif /* __LIBCAMERA_STREAM_H__ */
diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
index f9f25c0ecf1564cc..9f6ff99eebe2f5bc 100644
--- a/src/libcamera/meson.build
+++ b/src/libcamera/meson.build
@@ -10,6 +10,7 @@  libcamera_sources = files([
     'media_object.cpp',
     'pipeline_handler.cpp',
     'signal.cpp',
+    'stream.cpp',
     'timer.cpp',
     'v4l2_device.cpp',
 ])
diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp
new file mode 100644
index 0000000000000000..db47c24760b360b4
--- /dev/null
+++ b/src/libcamera/stream.cpp
@@ -0,0 +1,58 @@ 
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2019, Google Inc.
+ *
+ * stream.cpp - Stream information
+ */
+
+#include <libcamera/stream.h>
+
+/**
+ * \file stream.h
+ * \brief Stream information handling
+ *
+ * Each camera device is composed of one or multiple video stream connected
+ * to one image source. The Stream class holds all static information about
+ * a stream belonging to a camera device. A camera should provide a separate
+ * Stream object for every stream it can support.
+ *
+ * Camera devices expose at least one stream, and may expose additional streams
+ * based on the device capabilities. This can be used, for instance, to
+ * implement concurrent viewfinder and video capture, or concurrent viewfinder,
+ * video capture and still image capture.
+ */
+
+namespace libcamera {
+
+/**
+ * \class Stream
+ * \brief Stream information carrier
+ *
+ * The Stream class is a model of all static information which can be
+ * associated with a video stream. It provides the mapping of a stream
+ * capabilities to a numerical ID which should be used when configuring
+ * the camera which might contain a collections of streams.
+ *
+ * \todo Add capabilities to the Stream API. Without this the Stream class
+ *	 only serves to map streams of unknown capabilities to a stream ID.
+ *	 This in it self is important as it allows applications to configure
+ *	 and capture from one or more streams even if it won't be able to
+ *	 select the optimal stream for the task.
+ */
+
+/**
+ * \brief Create a new stream with a ID
+ * \param[in] id Numerical ID which should be unique for the camera device the stream belongs to.
+ */
+Stream::Stream(unsigned int id)
+	: id_(id)
+{
+}
+
+/**
+ * \fn Stream::id()
+ * \brief Retrieve the streams ID
+ * \return The stream ID
+ */
+
+} /* namespace libcamera */