[libcamera-devel,v5,1/6] libcamera: stream: add initial Stream class

Message ID 20190130115615.17362-2-niklas.soderlund@ragnatech.se
State Accepted
Headers show
Series
  • libcamera: add basic support for streams and format configuration
Related show

Commit Message

Niklas Söderlund Jan. 30, 2019, 11:56 a.m. UTC
Add an initial Stream implementation. The idea is that once capability
support is added to the library each stream will describe its
capabilities using this class. An application will then select one or
more streams based on these capabilities and use them to configure the
camera and capture.

At this stage the Stream class is empty as capabilities are yet to be
added. The class is still useful as it will be used to communicate how
many streams a Camera object provides.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 include/libcamera/libcamera.h |  1 +
 include/libcamera/meson.build |  1 +
 include/libcamera/stream.h    | 18 +++++++++++++
 src/libcamera/meson.build     |  1 +
 src/libcamera/stream.cpp      | 51 +++++++++++++++++++++++++++++++++++
 5 files changed, 72 insertions(+)
 create mode 100644 include/libcamera/stream.h
 create mode 100644 src/libcamera/stream.cpp

Comments

Laurent Pinchart Jan. 30, 2019, 10:58 p.m. UTC | #1
Hi Niklas,

Thank you for the patch.

On Wed, Jan 30, 2019 at 12:56:10PM +0100, Niklas Söderlund wrote:
> Add an initial Stream implementation. The idea is that once capability
> support is added to the library each stream will describe its
> capabilities using this class. An application will then select one or
> more streams based on these capabilities and use them to configure the
> camera and capture.
> 
> At this stage the Stream class is empty as capabilities are yet to be
> added. The class is still useful as it will be used to communicate how
> many streams a Camera object provides.
> 
> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
> ---
>  include/libcamera/libcamera.h |  1 +
>  include/libcamera/meson.build |  1 +
>  include/libcamera/stream.h    | 18 +++++++++++++
>  src/libcamera/meson.build     |  1 +
>  src/libcamera/stream.cpp      | 51 +++++++++++++++++++++++++++++++++++
>  5 files changed, 72 insertions(+)
>  create mode 100644 include/libcamera/stream.h
>  create mode 100644 src/libcamera/stream.cpp
> 
> diff --git a/include/libcamera/libcamera.h b/include/libcamera/libcamera.h
> index 6619e556ebbd20e4..8167e8099ac061d2 100644
> --- a/include/libcamera/libcamera.h
> +++ b/include/libcamera/libcamera.h
> @@ -13,6 +13,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 8fcbbf7892ea9280..8c14423bc444ef51 100644
> --- a/include/libcamera/meson.build
> +++ b/include/libcamera/meson.build
> @@ -6,6 +6,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..4f47d85ed6382b36
> --- /dev/null
> +++ b/include/libcamera/stream.h
> @@ -0,0 +1,18 @@
> +/* SPDX-License-Identifier: LGPL-2.1-or-later */
> +/*
> + * Copyright (C) 2019, Google Inc.
> + *
> + * stream.h - Video stream for a Camera
> + */
> +#ifndef __LIBCAMERA_STREAM_H__
> +#define __LIBCAMERA_STREAM_H__
> +
> +namespace libcamera {
> +
> +class Stream final
> +{
> +};
> +
> +} /* namespace libcamera */
> +
> +#endif /* __LIBCAMERA_STREAM_H__ */
> diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
> index b5b25965fd123350..a4e9cc8f936c47a7 100644
> --- a/src/libcamera/meson.build
> +++ b/src/libcamera/meson.build
> @@ -11,6 +11,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..f82b05a2bcfa14e9
> --- /dev/null
> +++ b/src/libcamera/stream.cpp
> @@ -0,0 +1,51 @@
> +/* SPDX-License-Identifier: LGPL-2.1-or-later */
> +/*
> + * Copyright (C) 2019, Google Inc.
> + *
> + * stream.cpp - Video stream for a Camera
> + */
> +
> +#include <libcamera/stream.h>
> +
> +/**
> + * \file stream.h
> + * \brief Video stream for a Camera
> + *
> + * A camera device can provide frames in different resolutions and formats
> + * concurrently from a single image source. The Stream class represents
> + * one of the multiple concurrent streams.
> + *
> + * All streams exposed by a camera device share the same image source and are
> + * thus not fully independent. Parameters related to the image source, such as
> + * the exposure time or flash control, are common to all streams. Other
> + * parameters, such as format or resolution, may be specified per-stream,
> + * depending on the capabilities of the camera device.
> + *
> + * 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 Video stream for a camera
> + *
> + * The Stream class models of all static information which are associated

s/models of/models/

> + * with a single video stream. Streams are exposed by the Camera object they
> + * belong to.
> + *
> + * Cameras are capable of supplying more then one stream from the same video

s/Cameras are capable of supplying/Cameras may supply/

(as not all cameras are capable of supplying multiple streams)

s/then/than/

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

> + * source. In such cases an application can inspect all available streams and
> + * select the ones that best fit its use case.
> + *
> + * \todo Add capabilities to the stream API. Without this the Stream class only
> + * serves to reveal how many streams of unknown capabilities a camera supports.
> + * This in itself is productive as it allows applications to configure and
> + * capture from one or more streams even if they won't be able to select the
> + * optimal stream for the task.
> + */
> +
> +} /* namespace libcamera */

Patch

diff --git a/include/libcamera/libcamera.h b/include/libcamera/libcamera.h
index 6619e556ebbd20e4..8167e8099ac061d2 100644
--- a/include/libcamera/libcamera.h
+++ b/include/libcamera/libcamera.h
@@ -13,6 +13,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 8fcbbf7892ea9280..8c14423bc444ef51 100644
--- a/include/libcamera/meson.build
+++ b/include/libcamera/meson.build
@@ -6,6 +6,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..4f47d85ed6382b36
--- /dev/null
+++ b/include/libcamera/stream.h
@@ -0,0 +1,18 @@ 
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2019, Google Inc.
+ *
+ * stream.h - Video stream for a Camera
+ */
+#ifndef __LIBCAMERA_STREAM_H__
+#define __LIBCAMERA_STREAM_H__
+
+namespace libcamera {
+
+class Stream final
+{
+};
+
+} /* namespace libcamera */
+
+#endif /* __LIBCAMERA_STREAM_H__ */
diff --git a/src/libcamera/meson.build b/src/libcamera/meson.build
index b5b25965fd123350..a4e9cc8f936c47a7 100644
--- a/src/libcamera/meson.build
+++ b/src/libcamera/meson.build
@@ -11,6 +11,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..f82b05a2bcfa14e9
--- /dev/null
+++ b/src/libcamera/stream.cpp
@@ -0,0 +1,51 @@ 
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ * Copyright (C) 2019, Google Inc.
+ *
+ * stream.cpp - Video stream for a Camera
+ */
+
+#include <libcamera/stream.h>
+
+/**
+ * \file stream.h
+ * \brief Video stream for a Camera
+ *
+ * A camera device can provide frames in different resolutions and formats
+ * concurrently from a single image source. The Stream class represents
+ * one of the multiple concurrent streams.
+ *
+ * All streams exposed by a camera device share the same image source and are
+ * thus not fully independent. Parameters related to the image source, such as
+ * the exposure time or flash control, are common to all streams. Other
+ * parameters, such as format or resolution, may be specified per-stream,
+ * depending on the capabilities of the camera device.
+ *
+ * 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 Video stream for a camera
+ *
+ * The Stream class models of all static information which are associated
+ * with a single video stream. Streams are exposed by the Camera object they
+ * belong to.
+ *
+ * Cameras are capable of supplying more then one stream from the same video
+ * source. In such cases an application can inspect all available streams and
+ * select the ones that best fit its use case.
+ *
+ * \todo Add capabilities to the stream API. Without this the Stream class only
+ * serves to reveal how many streams of unknown capabilities a camera supports.
+ * This in itself is productive as it allows applications to configure and
+ * capture from one or more streams even if they won't be able to select the
+ * optimal stream for the task.
+ */
+
+} /* namespace libcamera */