{"id":13002,"url":"https://patchwork.libcamera.org/api/1.1/patches/13002/?format=json","web_url":"https://patchwork.libcamera.org/patch/13002/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20210715211459.19373-31-laurent.pinchart@ideasonboard.com>","date":"2021-07-15T21:14:56","name":"[libcamera-devel,v3,30/33] cam: Allow specifying directories in the --file option","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"d7c7bb02a3c8a7347d040d800c6d77dee8f9449c","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/13002/mbox/","series":[{"id":2242,"url":"https://patchwork.libcamera.org/api/1.1/series/2242/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=2242","date":"2021-07-15T21:14:26","name":"Multi-camera support in the cam application","version":3,"mbox":"https://patchwork.libcamera.org/series/2242/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/13002/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/13002/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id C9961C3228\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 15 Jul 2021 21:15:33 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7AC6868566;\n\tThu, 15 Jul 2021 23:15:33 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id BF2AF68544\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 15 Jul 2021 23:15:14 +0200 (CEST)","from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5BED6340\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 15 Jul 2021 23:15:14 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"psYBQ2Hl\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1626383714;\n\tbh=deM3YgFU680f/nPIKkYwSskrp3IL9MmrKvZ1pCr8jPQ=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=psYBQ2HliEb+mWOOIpJs7YwfYAnE3x9oeAdHMSiHq/2K+Yz9hSnRTPsqxebDWCaa+\n\tfCbnFJYMYkJWZz0sCuU2D68eDgnTtBCzuGa4E8j7xQCBemrOA9KhsD/DRnnA6h+zyR\n\tMtIFk+Xwf9L+sNkwHWcRyv/r33uu6tSC7gnl/FV4=","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 16 Jul 2021 00:14:56 +0300","Message-Id":"<20210715211459.19373-31-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.31.1","In-Reply-To":"<20210715211459.19373-1-laurent.pinchart@ideasonboard.com>","References":"<20210715211459.19373-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v3 30/33] cam: Allow specifying\n\tdirectories in the --file option","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"The value of the --file option is the full name of the file to which\ncaptured frames are written. To write files to a specific directory with\nthe default naming scheme, the \"frame-#.bin\" name has to appear at the\nend of the file name. Simplify usage of the option by allowing --file to\nspecify a directory only. If the file name ends with a '/', the default\n\"frame-#.bin\" file name is automatically appended.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n src/cam/buffer_writer.cpp | 7 ++++++-\n src/cam/buffer_writer.h   | 2 +-\n src/cam/main.cpp          | 5 ++++-\n 3 files changed, 11 insertions(+), 3 deletions(-)","diff":"diff --git a/src/cam/buffer_writer.cpp b/src/cam/buffer_writer.cpp\nindex f2b21aef3362..a7648a92fc92 100644\n--- a/src/cam/buffer_writer.cpp\n+++ b/src/cam/buffer_writer.cpp\n@@ -49,7 +49,12 @@ int BufferWriter::write(FrameBuffer *buffer, const std::string &streamName)\n \tsize_t pos;\n \tint fd, ret = 0;\n \n-\tfilename = pattern_;\n+\tif (!pattern_.empty())\n+\t\tfilename = pattern_;\n+\n+\tif (filename.empty() || filename.back() == '/')\n+\t\tfilename += \"frame-#.bin\";\n+\n \tpos = filename.find_first_of('#');\n \tif (pos != std::string::npos) {\n \t\tstd::stringstream ss;\ndiff --git a/src/cam/buffer_writer.h b/src/cam/buffer_writer.h\nindex 604ce8702ec7..7626de42d369 100644\n--- a/src/cam/buffer_writer.h\n+++ b/src/cam/buffer_writer.h\n@@ -15,7 +15,7 @@\n class BufferWriter\n {\n public:\n-\tBufferWriter(const std::string &pattern = \"frame-#.bin\");\n+\tBufferWriter(const std::string &pattern = \"\");\n \t~BufferWriter();\n \n \tvoid mapBuffer(libcamera::FrameBuffer *buffer);\ndiff --git a/src/cam/main.cpp b/src/cam/main.cpp\nindex a3f19d0fa61b..6d7d45e11499 100644\n--- a/src/cam/main.cpp\n+++ b/src/cam/main.cpp\n@@ -118,7 +118,10 @@ int CamApp::parseOptions(int argc, char *argv[])\n \t\t\t \"capture\", ArgumentOptional, \"count\");\n \tparser.addOption(OptFile, OptionString,\n \t\t\t \"Write captured frames to disk\\n\"\n-\t\t\t \"The first '#' character in the file name is expanded to the stream name and frame sequence number.\\n\"\n+\t\t\t \"If the file name ends with a '/', it sets the directory in which\\n\"\n+\t\t\t \"to write files, using the default file name. Otherwise it sets the\\n\"\n+\t\t\t \"full file path and name. The first '#' character in the file name\\n\"\n+\t\t\t \"is expanded to the stream name and frame sequence number.\\n\"\n \t\t\t \"The default file name is 'frame-#.bin'.\",\n \t\t\t \"file\", ArgumentOptional, \"filename\");\n \tparser.addOption(OptStream, &streamKeyValue,\n","prefixes":["libcamera-devel","v3","30/33"]}