[{"id":1303,"web_url":"https://patchwork.libcamera.org/comment/1303/","msgid":"<20190406171340.GF4817@pendragon.ideasonboard.com>","date":"2019-04-06T17:13:40","subject":"Re: [libcamera-devel] [PATCH v3 2/5] cam: Extend BufferWriter to\n\tinclude a stream name in file path","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Niklas,\n\nThank you for the patch.\n\nOn Sat, Apr 06, 2019 at 01:59:26AM +0200, Niklas Söderlund wrote:\n> To be able to write multiple buffers captured in the same request  and\n> hence have the same sequence number the buffer writer needs to name each\n\n\"To be able to write multiple buffers captured in the same request (and\nhence having the same sequence number) the buffer writer needs to name\neach file uniquely.\"\n\n> file uniquely. Add a stream name to the writer function which the buffer\n> writer can add to the part of the pattern it already expands to the\n> sequence number. As cam only supports one streams, hard code the name to\n\ns/streams/stream/\n\n> stream0.\n> \n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  src/cam/buffer_writer.cpp | 6 ++++--\n>  src/cam/buffer_writer.h   | 2 +-\n>  src/cam/main.cpp          | 4 ++--\n>  3 files changed, 7 insertions(+), 5 deletions(-)\n> \n> diff --git a/src/cam/buffer_writer.cpp b/src/cam/buffer_writer.cpp\n> index 2d2258b4cd1cbbc2..e0374ffcb3199d30 100644\n> --- a/src/cam/buffer_writer.cpp\n> +++ b/src/cam/buffer_writer.cpp\n> @@ -19,7 +19,8 @@ BufferWriter::BufferWriter(const std::string &pattern)\n>  {\n>  }\n>  \n> -int BufferWriter::write(libcamera::Buffer *buffer)\n> +int BufferWriter::write(libcamera::Buffer *buffer,\n> +\t\t\tconst std::string &streamName)\n>  {\n>  \tstd::string filename;\n>  \tsize_t pos;\n> @@ -29,7 +30,8 @@ int BufferWriter::write(libcamera::Buffer *buffer)\n>  \tpos = filename.find_first_of('#');\n>  \tif (pos != std::string::npos) {\n>  \t\tstd::stringstream ss;\n> -\t\tss << std::setw(6) << std::setfill('0') << buffer->sequence();\n> +\t\tss << streamName << \"-\" << std::setw(6)\n> +\t\t   << std::setfill('0') << buffer->sequence();\n>  \t\tfilename.replace(pos, 1, ss.str());\n>  \t}\n>  \n> diff --git a/src/cam/buffer_writer.h b/src/cam/buffer_writer.h\n> index 9705773e0e397d45..7bf785d1e83235ff 100644\n> --- a/src/cam/buffer_writer.h\n> +++ b/src/cam/buffer_writer.h\n> @@ -16,7 +16,7 @@ class BufferWriter\n>  public:\n>  \tBufferWriter(const std::string &pattern = \"frame-#.bin\");\n>  \n> -\tint write(libcamera::Buffer *buffer);\n> +\tint write(libcamera::Buffer *buffer, const std::string &streamName);\n>  \n>  private:\n>  \tstd::string pattern_;\n> diff --git a/src/cam/main.cpp b/src/cam/main.cpp\n> index 41a4d9c6b7afa684..3dd4b24d2401162c 100644\n> --- a/src/cam/main.cpp\n> +++ b/src/cam/main.cpp\n> @@ -57,7 +57,7 @@ static int parseOptions(int argc, char *argv[])\n>  \t\t\t \"Capture until interrupted by user\", \"capture\");\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 frame sequence number.\\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 \"The default file name is 'frame-#.bin'.\",\n>  \t\t\t \"file\", ArgumentOptional, \"filename\");\n>  \tparser.addOption(OptStream, &streamKeyValue,\n> @@ -121,7 +121,7 @@ static void requestComplete(Request *request, const std::map<Stream *, Buffer *>\n>  \t\t  << std::endl;\n>  \n>  \tif (writer)\n> -\t\twriter->write(buffer);\n> +\t\twriter->write(buffer, \"stream0\");\n>  \n>  \trequest = camera->createRequest();\n>  \tif (!request) {","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["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 DF69960B1B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat,  6 Apr 2019 19:13:56 +0200 (CEST)","from pendragon.ideasonboard.com (unknown [91.183.39.81])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E7BE599F;\n\tSat,  6 Apr 2019 19:13:55 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1554570836;\n\tbh=+onNzxsl2nQCFKeC9LPThQWJLNxArxMQQK48HjKKajw=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Hfhje5R+915c/BbDksTFwJ8hY/oH4tImZU+hjJ/PJAX2Yf01cj//3lRdxkWkfTi4E\n\tl04N9ktXUrDKlOObkW8GUIguETgmjV+5QztfNJVbIRiC6GhfHic0OPfE1+JGWGp8Vx\n\tCaqGJCjgZewOvAre8q23Dlefsjfi7yLtr4IJ1KoA=","Date":"Sat, 6 Apr 2019 20:13:40 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190406171340.GF4817@pendragon.ideasonboard.com>","References":"<20190405235929.27987-1-niklas.soderlund@ragnatech.se>\n\t<20190405235929.27987-3-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20190405235929.27987-3-niklas.soderlund@ragnatech.se>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v3 2/5] cam: Extend BufferWriter to\n\tinclude a stream name in file path","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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>","X-List-Received-Date":"Sat, 06 Apr 2019 17:13:57 -0000"}}]