From patchwork Fri Apr 5 23:59:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 935 Return-Path: Received: from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net [195.74.38.228]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0013E610B3 for ; Sat, 6 Apr 2019 01:59:37 +0200 (CEST) X-Halon-ID: dd4313a8-57fe-11e9-8144-0050569116f7 Authorized-sender: niklas@soderlund.pp.se Received: from bismarck.berto.se (unknown [89.233.230.99]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id dd4313a8-57fe-11e9-8144-0050569116f7; Sat, 06 Apr 2019 01:59:35 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Sat, 6 Apr 2019 01:59:26 +0200 Message-Id: <20190405235929.27987-3-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190405235929.27987-1-niklas.soderlund@ragnatech.se> References: <20190405235929.27987-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 2/5] cam: Extend BufferWriter to include a stream name in file path X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Apr 2019 23:59:38 -0000 To be able to write multiple buffers captured in the same request and hence have the same sequence number the buffer writer needs to name each file uniquely. Add a stream name to the writer function which the buffer writer can add to the part of the pattern it already expands to the sequence number. As cam only supports one streams, hard code the name to stream0. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- src/cam/buffer_writer.cpp | 6 ++++-- src/cam/buffer_writer.h | 2 +- src/cam/main.cpp | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/cam/buffer_writer.cpp b/src/cam/buffer_writer.cpp index 2d2258b4cd1cbbc2..e0374ffcb3199d30 100644 --- a/src/cam/buffer_writer.cpp +++ b/src/cam/buffer_writer.cpp @@ -19,7 +19,8 @@ BufferWriter::BufferWriter(const std::string &pattern) { } -int BufferWriter::write(libcamera::Buffer *buffer) +int BufferWriter::write(libcamera::Buffer *buffer, + const std::string &streamName) { std::string filename; size_t pos; @@ -29,7 +30,8 @@ int BufferWriter::write(libcamera::Buffer *buffer) pos = filename.find_first_of('#'); if (pos != std::string::npos) { std::stringstream ss; - ss << std::setw(6) << std::setfill('0') << buffer->sequence(); + ss << streamName << "-" << std::setw(6) + << std::setfill('0') << buffer->sequence(); filename.replace(pos, 1, ss.str()); } diff --git a/src/cam/buffer_writer.h b/src/cam/buffer_writer.h index 9705773e0e397d45..7bf785d1e83235ff 100644 --- a/src/cam/buffer_writer.h +++ b/src/cam/buffer_writer.h @@ -16,7 +16,7 @@ class BufferWriter public: BufferWriter(const std::string &pattern = "frame-#.bin"); - int write(libcamera::Buffer *buffer); + int write(libcamera::Buffer *buffer, const std::string &streamName); private: std::string pattern_; diff --git a/src/cam/main.cpp b/src/cam/main.cpp index 41a4d9c6b7afa684..3dd4b24d2401162c 100644 --- a/src/cam/main.cpp +++ b/src/cam/main.cpp @@ -57,7 +57,7 @@ static int parseOptions(int argc, char *argv[]) "Capture until interrupted by user", "capture"); parser.addOption(OptFile, OptionString, "Write captured frames to disk\n" - "The first '#' character in the file name is expanded to the frame sequence number.\n" + "The first '#' character in the file name is expanded to the stream name and frame sequence number.\n" "The default file name is 'frame-#.bin'.", "file", ArgumentOptional, "filename"); parser.addOption(OptStream, &streamKeyValue, @@ -121,7 +121,7 @@ static void requestComplete(Request *request, const std::map << std::endl; if (writer) - writer->write(buffer); + writer->write(buffer, "stream0"); request = camera->createRequest(); if (!request) {