[libcamera-devel,24/30] libcamera: stream: Make FrameBuffer support mandatory

Message ID 20191126233620.1695316-25-niklas.soderlund@ragnatech.se
State Superseded
Headers show
Series
  • libcamera: Rework buffer API
Related show

Commit Message

Niklas Söderlund Nov. 26, 2019, 11:36 p.m. UTC
All pipelines now uses V4L2Streams, make using a sub-class of Stream
which implements the FrameBuffer interface helpers mandatory. Remove the
fallback implementations in the Stream base class to prevent the base
class to be instantiated directly.

Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
---
 include/libcamera/stream.h | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

Comments

Jacopo Mondi Dec. 2, 2019, 12:20 p.m. UTC | #1
Hi Niklas,

On Wed, Nov 27, 2019 at 12:36:14AM +0100, Niklas Söderlund wrote:
> All pipelines now uses V4L2Streams, make using a sub-class of Stream
> which implements the FrameBuffer interface helpers mandatory. Remove the
> fallback implementations in the Stream base class to prevent the base
> class to be instantiated directly.
>
> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>

Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

> ---
>  include/libcamera/stream.h | 12 ++++--------
>  1 file changed, 4 insertions(+), 8 deletions(-)
>
> diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h
> index 395148e45d342d92..a3c692c347340382 100644
> --- a/include/libcamera/stream.h
> +++ b/include/libcamera/stream.h
> @@ -7,7 +7,6 @@
>  #ifndef __LIBCAMERA_STREAM_H__
>  #define __LIBCAMERA_STREAM_H__
>
> -#include <errno.h>
>  #include <map>
>  #include <memory>
>  #include <string>
> @@ -89,13 +88,10 @@ protected:
>  	friend class Camera;
>
>  	virtual int allocateBuffers(const StreamConfiguration &config,
> -				    std::vector<FrameBuffer *> *buffers)
> -	{
> -		return -EINVAL;
> -	}
> -	virtual void releaseBuffers() { return; }
> -	virtual int start() { return -EINVAL; }
> -	virtual void stop() { return; }
> +				    std::vector<FrameBuffer *> *buffers) = 0;
> +	virtual void releaseBuffers() = 0;
> +	virtual int start() = 0;
> +	virtual void stop() = 0;
>
>  	int mapBuffer(const Buffer *buffer);
>  	void unmapBuffer(const Buffer *buffer);
> --
> 2.24.0
>
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel@lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel
Laurent Pinchart Dec. 15, 2019, 1:53 a.m. UTC | #2
Hi Niklas,

Thank you for the patch.

On Mon, Dec 02, 2019 at 01:20:57PM +0100, Jacopo Mondi wrote:
> On Wed, Nov 27, 2019 at 12:36:14AM +0100, Niklas Söderlund wrote:
> > All pipelines now uses V4L2Streams, make using a sub-class of Stream

s/V4L2Streams/V4L2Stream/

> > which implements the FrameBuffer interface helpers mandatory. Remove the

"make the implementation of the FrameBuffer-related interface of the
Stream class mandatory."

> > fallback implementations in the Stream base class to prevent the base
> > class to be instantiated directly.

You could drop the second sentence.

> > Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
> 
> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>

And

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

> > ---
> >  include/libcamera/stream.h | 12 ++++--------
> >  1 file changed, 4 insertions(+), 8 deletions(-)
> >
> > diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h
> > index 395148e45d342d92..a3c692c347340382 100644
> > --- a/include/libcamera/stream.h
> > +++ b/include/libcamera/stream.h
> > @@ -7,7 +7,6 @@
> >  #ifndef __LIBCAMERA_STREAM_H__
> >  #define __LIBCAMERA_STREAM_H__
> >
> > -#include <errno.h>
> >  #include <map>
> >  #include <memory>
> >  #include <string>
> > @@ -89,13 +88,10 @@ protected:
> >  	friend class Camera;
> >
> >  	virtual int allocateBuffers(const StreamConfiguration &config,
> > -				    std::vector<FrameBuffer *> *buffers)
> > -	{
> > -		return -EINVAL;
> > -	}
> > -	virtual void releaseBuffers() { return; }
> > -	virtual int start() { return -EINVAL; }
> > -	virtual void stop() { return; }
> > +				    std::vector<FrameBuffer *> *buffers) = 0;
> > +	virtual void releaseBuffers() = 0;
> > +	virtual int start() = 0;
> > +	virtual void stop() = 0;
> >
> >  	int mapBuffer(const Buffer *buffer);
> >  	void unmapBuffer(const Buffer *buffer);

Patch

diff --git a/include/libcamera/stream.h b/include/libcamera/stream.h
index 395148e45d342d92..a3c692c347340382 100644
--- a/include/libcamera/stream.h
+++ b/include/libcamera/stream.h
@@ -7,7 +7,6 @@ 
 #ifndef __LIBCAMERA_STREAM_H__
 #define __LIBCAMERA_STREAM_H__
 
-#include <errno.h>
 #include <map>
 #include <memory>
 #include <string>
@@ -89,13 +88,10 @@  protected:
 	friend class Camera;
 
 	virtual int allocateBuffers(const StreamConfiguration &config,
-				    std::vector<FrameBuffer *> *buffers)
-	{
-		return -EINVAL;
-	}
-	virtual void releaseBuffers() { return; }
-	virtual int start() { return -EINVAL; }
-	virtual void stop() { return; }
+				    std::vector<FrameBuffer *> *buffers) = 0;
+	virtual void releaseBuffers() = 0;
+	virtual int start() = 0;
+	virtual void stop() = 0;
 
 	int mapBuffer(const Buffer *buffer);
 	void unmapBuffer(const Buffer *buffer);