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

paul.elder at ideasonboard.com paul.elder at ideasonboard.com
Tue Aug 3 08:18:06 CEST 2021


Hi Laurent,

On Fri, Jul 30, 2021 at 04:03:02AM +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>

Reviewed-by: Paul Elder <paul.elder at ideasonboard.com>

> ---
>  src/cam/camera_session.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} (89%)
>  rename src/cam/{buffer_writer.h => file_sink.h} (69%)
> 
> diff --git a/src/cam/camera_session.cpp b/src/cam/camera_session.cpp
> index 465c8e24190e..4f1f9ec8eb10 100644
> --- a/src/cam/camera_session.cpp
> +++ b/src/cam/camera_session.cpp
> @@ -13,9 +13,9 @@
>  #include <libcamera/control_ids.h>
>  #include <libcamera/property_ids.h>
>  
> -#include "buffer_writer.h"
>  #include "camera_session.h"
>  #include "event_loop.h"
> +#include "file_sink.h"
>  #include "main.h"
>  #include "stream_options.h"
>  
> @@ -163,9 +163,9 @@ int CameraSession::start()
>  
>  	if (options_.isSet(OptFile)) {
>  		if (!options_[OptFile].toString().empty())
> -			sink_ = std::make_unique<BufferWriter>(options_[OptFile]);
> +			sink_ = std::make_unique<FileSink>(options_[OptFile]);
>  		else
> -			sink_ = std::make_unique<BufferWriter>();
> +			sink_ = std::make_unique<FileSink>();
>  	}
>  
>  	if (sink_) {
> diff --git a/src/cam/buffer_writer.cpp b/src/cam/file_sink.cpp
> similarity index 89%
> rename from src/cam/buffer_writer.cpp
> rename to src/cam/file_sink.cpp
> index 2cf8644e843d..0ff8107c811b 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::consumeRequest(Request *request)
> +bool FileSink::consumeRequest(Request *request)
>  {
>  	const Stream *stream = request->buffers().begin()->first;
>  	FrameBuffer *buffer = request->buffers().begin()->second;
> diff --git a/src/cam/buffer_writer.h b/src/cam/file_sink.h
> similarity index 69%
> rename from src/cam/buffer_writer.h
> rename to src/cam/file_sink.h
> index 955bc2713f4c..545b1771189a 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 = "");
> -	~BufferWriter();
> +	FileSink(const std::string &pattern = "");
> +	~FileSink();
>  
>  	int configure(const libcamera::CameraConfiguration &config) override;
>  
> @@ -32,4 +32,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 649cc990d867..e692ea351987 100644
> --- a/src/cam/meson.build
> +++ b/src/cam/meson.build
> @@ -10,9 +10,9 @@ endif
>  cam_enabled = true
>  
>  cam_sources = files([
> -    'buffer_writer.cpp',
>      'camera_session.cpp',
>      'event_loop.cpp',
> +    'file_sink.cpp',
>      'frame_sink.cpp',
>      'main.cpp',
>      'options.cpp',
> -- 
> Regards,
> 
> Laurent Pinchart
> 


More information about the libcamera-devel mailing list