From b2538c80b96df937ff6fa823a489bf4710cee0e2 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Wed, 25 Sep 2024 13:52:58 +0300 Subject: apps: cam: Print an error when outputting DNG and DNG support is missing When DNG support is missing, the cam application ignores the .dng suffix of the file pattern and writes raw binary data instead, without notifying the user. This leads to confusion. Fix it by printing an error message. Signed-off-by: Laurent Pinchart Reviewed-by: Milan Zamazal Reviewed-by: Jacopo Mondi --- src/apps/cam/file_sink.h | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) (limited to 'src/apps/cam/file_sink.h') diff --git a/src/apps/cam/file_sink.h b/src/apps/cam/file_sink.h index 9d560783..71b7fe0f 100644 --- a/src/apps/cam/file_sink.h +++ b/src/apps/cam/file_sink.h @@ -21,10 +21,11 @@ class FileSink : public FrameSink { public: FileSink(const libcamera::Camera *camera, - const std::map &streamNames, - const std::string &pattern = ""); + const std::map &streamNames); ~FileSink(); + int setFilePattern(const std::string &pattern); + int configure(const libcamera::CameraConfiguration &config) override; void mapBuffer(libcamera::FrameBuffer *buffer) override; @@ -32,6 +33,14 @@ public: bool processRequest(libcamera::Request *request) override; private: + static constexpr const char *kDefaultFilePattern = "frame-#.bin"; + + enum class FileType { + Binary, + Dng, + Ppm, + }; + void writeBuffer(const libcamera::Stream *stream, libcamera::FrameBuffer *buffer, const libcamera::ControlList &metadata); @@ -39,7 +48,10 @@ private: #ifdef HAVE_TIFF const libcamera::Camera *camera_; #endif - std::map streamNames_; + std::string pattern_; + FileType fileType_; + + std::map streamNames_; std::map> mappedBuffers_; }; -- cgit v1.2.1