[libcamera-devel,2/8] cam: Add FrameSink base class

Message ID 20200519032505.17307-3-laurent.pinchart@ideasonboard.com
State Changes Requested
Delegated to: Laurent Pinchart
Headers show
Series
  • libcamera: Add DRM/KMS viewfinder display to cam
Related show

Commit Message

Laurent Pinchart May 19, 2020, 3:24 a.m. UTC
The FrameSink class serves as a base to implement components that
consume frames. This allows handling frame sinks in a generic way,
independent of their nature. The BufferWrite class will be ported to
FrameSink in a second step.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
---
 src/cam/frame_sink.cpp | 31 +++++++++++++++++++++++++++++++
 src/cam/frame_sink.h   | 35 +++++++++++++++++++++++++++++++++++
 src/cam/meson.build    |  1 +
 3 files changed, 67 insertions(+)
 create mode 100644 src/cam/frame_sink.cpp
 create mode 100644 src/cam/frame_sink.h

Comments

Niklas Söderlund May 19, 2020, 2:29 p.m. UTC | #1
Hi Laurent,

Thanks for your work.

On 2020-05-19 06:24:59 +0300, Laurent Pinchart wrote:
> The FrameSink class serves as a base to implement components that
> consume frames. This allows handling frame sinks in a generic way,
> independent of their nature. The BufferWrite class will be ported to
> FrameSink in a second step.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

> ---
>  src/cam/frame_sink.cpp | 31 +++++++++++++++++++++++++++++++
>  src/cam/frame_sink.h   | 35 +++++++++++++++++++++++++++++++++++
>  src/cam/meson.build    |  1 +
>  3 files changed, 67 insertions(+)
>  create mode 100644 src/cam/frame_sink.cpp
>  create mode 100644 src/cam/frame_sink.h
> 
> diff --git a/src/cam/frame_sink.cpp b/src/cam/frame_sink.cpp
> new file mode 100644
> index 000000000000..fbe16e2f5081
> --- /dev/null
> +++ b/src/cam/frame_sink.cpp
> @@ -0,0 +1,31 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +/*
> + * Copyright (C) 2020, Ideas on Board Oy
> + *
> + * frame_sink.cpp - Base Frame Sink Class
> + */
> +
> +#include "frame_sink.h"
> +
> +FrameSink::~FrameSink()
> +{
> +}
> +
> +int FrameSink::configure(const libcamera::CameraConfiguration &config)
> +{
> +	return 0;
> +}
> +
> +void FrameSink::mapBuffer(libcamera::FrameBuffer *buffer)
> +{
> +}
> +
> +int FrameSink::start()
> +{
> +	return 0;
> +}
> +
> +int FrameSink::stop()
> +{
> +	return 0;
> +}
> diff --git a/src/cam/frame_sink.h b/src/cam/frame_sink.h
> new file mode 100644
> index 000000000000..39604a07eb70
> --- /dev/null
> +++ b/src/cam/frame_sink.h
> @@ -0,0 +1,35 @@
> +/* SPDX-License-Identifier: GPL-2.0-or-later */
> +/*
> + * Copyright (C) 2020, Ideas on Board Oy
> + *
> + * frame_sink.h - Base Frame Sink Class
> + */
> +#ifndef __CAM_FRAME_SINK_H__
> +#define __CAM_FRAME_SINK_H__
> +
> +#include <libcamera/signal.h>
> +
> +namespace libcamera {
> +class CameraConfiguration;
> +class FrameBuffer;
> +class Stream;
> +} /* namespace libcamera */
> +
> +class FrameSink
> +{
> +public:
> +	virtual ~FrameSink();
> +
> +	virtual int configure(const libcamera::CameraConfiguration &config);
> +
> +	virtual void mapBuffer(libcamera::FrameBuffer *buffer);
> +
> +	virtual int start();
> +	virtual int stop();
> +
> +	virtual bool consumeBuffer(const libcamera::Stream *stream,
> +				   libcamera::FrameBuffer *buffer) = 0;
> +	libcamera::Signal<libcamera::FrameBuffer *> bufferReleased;
> +};
> +
> +#endif /* __CAM_FRAME_SINK_H__ */
> diff --git a/src/cam/meson.build b/src/cam/meson.build
> index 89e124fbae2a..d7b72ec02f8c 100644
> --- a/src/cam/meson.build
> +++ b/src/cam/meson.build
> @@ -4,6 +4,7 @@ cam_sources = files([
>      'buffer_writer.cpp',
>      'capture.cpp',
>      'event_loop.cpp',
> +    'frame_sink.cpp',
>      'main.cpp',
>      'options.cpp',
>      'stream_options.cpp',
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

Patch

diff --git a/src/cam/frame_sink.cpp b/src/cam/frame_sink.cpp
new file mode 100644
index 000000000000..fbe16e2f5081
--- /dev/null
+++ b/src/cam/frame_sink.cpp
@@ -0,0 +1,31 @@ 
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2020, Ideas on Board Oy
+ *
+ * frame_sink.cpp - Base Frame Sink Class
+ */
+
+#include "frame_sink.h"
+
+FrameSink::~FrameSink()
+{
+}
+
+int FrameSink::configure(const libcamera::CameraConfiguration &config)
+{
+	return 0;
+}
+
+void FrameSink::mapBuffer(libcamera::FrameBuffer *buffer)
+{
+}
+
+int FrameSink::start()
+{
+	return 0;
+}
+
+int FrameSink::stop()
+{
+	return 0;
+}
diff --git a/src/cam/frame_sink.h b/src/cam/frame_sink.h
new file mode 100644
index 000000000000..39604a07eb70
--- /dev/null
+++ b/src/cam/frame_sink.h
@@ -0,0 +1,35 @@ 
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2020, Ideas on Board Oy
+ *
+ * frame_sink.h - Base Frame Sink Class
+ */
+#ifndef __CAM_FRAME_SINK_H__
+#define __CAM_FRAME_SINK_H__
+
+#include <libcamera/signal.h>
+
+namespace libcamera {
+class CameraConfiguration;
+class FrameBuffer;
+class Stream;
+} /* namespace libcamera */
+
+class FrameSink
+{
+public:
+	virtual ~FrameSink();
+
+	virtual int configure(const libcamera::CameraConfiguration &config);
+
+	virtual void mapBuffer(libcamera::FrameBuffer *buffer);
+
+	virtual int start();
+	virtual int stop();
+
+	virtual bool consumeBuffer(const libcamera::Stream *stream,
+				   libcamera::FrameBuffer *buffer) = 0;
+	libcamera::Signal<libcamera::FrameBuffer *> bufferReleased;
+};
+
+#endif /* __CAM_FRAME_SINK_H__ */
diff --git a/src/cam/meson.build b/src/cam/meson.build
index 89e124fbae2a..d7b72ec02f8c 100644
--- a/src/cam/meson.build
+++ b/src/cam/meson.build
@@ -4,6 +4,7 @@  cam_sources = files([
     'buffer_writer.cpp',
     'capture.cpp',
     'event_loop.cpp',
+    'frame_sink.cpp',
     'main.cpp',
     'options.cpp',
     'stream_options.cpp',