[libcamera-devel] [PATCH 4/8] cam: Rename BufferWriter to FileSink

Niklas Söderlund niklas.soderlund at ragnatech.se
Tue May 19 16:38:50 CEST 2020


Hi Laurent,

Thanks for your work.

On 2020-05-19 06:25:01 +0300, Laurent Pinchart wrote:
> Rename the BufferWriter class to FileSink to establish a common naming
> scheme for all sinks.
> 
> Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>

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

> ---
>  src/cam/capture.cpp                          |  6 +++---
>  src/cam/{buffer_writer.cpp => file_sink.cpp} | 14 +++++++-------
>  src/cam/{buffer_writer.h => file_sink.h}     | 14 +++++++-------
>  src/cam/meson.build                          |  2 +-
>  4 files changed, 18 insertions(+), 18 deletions(-)
>  rename src/cam/{buffer_writer.cpp => file_sink.cpp} (85%)
>  rename src/cam/{buffer_writer.h => file_sink.h} (70%)
> 
> diff --git a/src/cam/capture.cpp b/src/cam/capture.cpp
> index 7fc9cba48892..6982d89fabe7 100644
> --- a/src/cam/capture.cpp
> +++ b/src/cam/capture.cpp
> @@ -11,8 +11,8 @@
>  #include <limits.h>
>  #include <sstream>
>  
> -#include "buffer_writer.h"
>  #include "capture.h"
> +#include "file_sink.h"
>  #include "main.h"
>  
>  using namespace libcamera;
> @@ -48,9 +48,9 @@ int Capture::run(EventLoop *loop, const OptionsParser::Options &options)
>  
>  	if (options.isSet(OptFile)) {
>  		if (!options[OptFile].toString().empty())
> -			sink_ = new BufferWriter(options[OptFile]);
> +			sink_ = new FileSink(options[OptFile]);
>  		else
> -			sink_ = new BufferWriter();
> +			sink_ = new FileSink();
>  	}
>  
>  	if (sink_) {
> diff --git a/src/cam/buffer_writer.cpp b/src/cam/file_sink.cpp
> similarity index 85%
> rename from src/cam/buffer_writer.cpp
> rename to src/cam/file_sink.cpp
> index 2bec4b132155..225f3d2200c1 100644
> --- a/src/cam/buffer_writer.cpp
> +++ b/src/cam/file_sink.cpp
> @@ -2,7 +2,7 @@
>  /*
>   * Copyright (C) 2019, Google Inc.
>   *
> - * buffer_writer.cpp - Buffer writer
> + * file_sink.cpp - File Sink
>   */
>  
>  #include <fcntl.h>
> @@ -15,16 +15,16 @@
>  
>  #include <libcamera/camera.h>
>  
> -#include "buffer_writer.h"
> +#include "file_sink.h"
>  
>  using namespace libcamera;
>  
> -BufferWriter::BufferWriter(const std::string &pattern)
> +FileSink::FileSink(const std::string &pattern)
>  	: pattern_(pattern)
>  {
>  }
>  
> -BufferWriter::~BufferWriter()
> +FileSink::~FileSink()
>  {
>  	for (auto &iter : mappedBuffers_) {
>  		void *memory = iter.second.first;
> @@ -34,7 +34,7 @@ BufferWriter::~BufferWriter()
>  	mappedBuffers_.clear();
>  }
>  
> -int BufferWriter::configure(const libcamera::CameraConfiguration &config)
> +int FileSink::configure(const libcamera::CameraConfiguration &config)
>  {
>  	int ret = FrameSink::configure(config);
>  	if (ret < 0)
> @@ -49,7 +49,7 @@ int BufferWriter::configure(const libcamera::CameraConfiguration &config)
>  	return 0;
>  }
>  
> -void BufferWriter::mapBuffer(FrameBuffer *buffer)
> +void FileSink::mapBuffer(FrameBuffer *buffer)
>  {
>  	for (const FrameBuffer::Plane &plane : buffer->planes()) {
>  		void *memory = mmap(NULL, plane.length, PROT_READ, MAP_SHARED,
> @@ -60,7 +60,7 @@ void BufferWriter::mapBuffer(FrameBuffer *buffer)
>  	}
>  }
>  
> -bool BufferWriter::consumeBuffer(const Stream *stream, FrameBuffer *buffer)
> +bool FileSink::consumeBuffer(const Stream *stream, FrameBuffer *buffer)
>  {
>  	std::string filename;
>  	size_t pos;
> diff --git a/src/cam/buffer_writer.h b/src/cam/file_sink.h
> similarity index 70%
> rename from src/cam/buffer_writer.h
> rename to src/cam/file_sink.h
> index 5a5b176f73d8..9d427918a785 100644
> --- a/src/cam/buffer_writer.h
> +++ b/src/cam/file_sink.h
> @@ -2,10 +2,10 @@
>  /*
>   * Copyright (C) 2019, Google Inc.
>   *
> - * buffer_writer.h - Buffer writer
> + * file_sink.h - File Sink
>   */
> -#ifndef __CAM_BUFFER_WRITER_H__
> -#define __CAM_BUFFER_WRITER_H__
> +#ifndef __CAM_FILE_SINK_H__
> +#define __CAM_FILE_SINK_H__
>  
>  #include <map>
>  #include <string>
> @@ -14,11 +14,11 @@
>  
>  #include "frame_sink.h"
>  
> -class BufferWriter : public FrameSink
> +class FileSink : public FrameSink
>  {
>  public:
> -	BufferWriter(const std::string &pattern = "frame-#.bin");
> -	~BufferWriter();
> +	FileSink(const std::string &pattern = "frame-#.bin");
> +	~FileSink();
>  
>  	int configure(const libcamera::CameraConfiguration &config) override;
>  
> @@ -33,4 +33,4 @@ private:
>  	std::map<int, std::pair<void *, unsigned int>> mappedBuffers_;
>  };
>  
> -#endif /* __CAM_BUFFER_WRITER_H__ */
> +#endif /* __CAM_FILE_SINK_H__ */
> diff --git a/src/cam/meson.build b/src/cam/meson.build
> index d7b72ec02f8c..6ba49e82fbd1 100644
> --- a/src/cam/meson.build
> +++ b/src/cam/meson.build
> @@ -1,9 +1,9 @@
>  # SPDX-License-Identifier: CC0-1.0
>  
>  cam_sources = files([
> -    'buffer_writer.cpp',
>      'capture.cpp',
>      'event_loop.cpp',
> +    'file_sink.cpp',
>      'frame_sink.cpp',
>      'main.cpp',
>      'options.cpp',
> -- 
> Regards,
> 
> Laurent Pinchart
> 
> _______________________________________________
> libcamera-devel mailing list
> libcamera-devel at lists.libcamera.org
> https://lists.libcamera.org/listinfo/libcamera-devel

-- 
Regards,
Niklas Söderlund


More information about the libcamera-devel mailing list