[{"id":18141,"web_url":"https://patchwork.libcamera.org/comment/18141/","msgid":"<41cad79e-95a2-e455-762e-a1df16c7e36c@ideasonboard.com>","date":"2021-07-12T16:12:51","subject":"Re: [libcamera-devel] [PATCH 29/30] cam: Add camera index to file\n\tname of capture frames","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"On 07/07/2021 03:19, Laurent Pinchart wrote:\n> To prepare for multi-camera support, extend the file naming scheme for\n> captured frames to include the camera index in additiona to the stream\n\ns/additiona/additional/\n\n\n> name and frame number.\n> \n\nOh look - another one of my earlier requests come true already.\n\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  src/cam/camera_session.cpp | 9 ++++++---\n>  src/cam/camera_session.h   | 4 +++-\n>  src/cam/main.cpp           | 4 ++--\n>  3 files changed, 11 insertions(+), 6 deletions(-)\n> \n> diff --git a/src/cam/camera_session.cpp b/src/cam/camera_session.cpp\n> index f2383567af3b..90261a8cde2e 100644\n> --- a/src/cam/camera_session.cpp\n> +++ b/src/cam/camera_session.cpp\n> @@ -22,9 +22,11 @@ using namespace libcamera;\n>  \n>  CameraSession::CameraSession(CameraManager *cm,\n>  \t\t\t     const std::string &cameraId,\n> +\t\t\t     unsigned int cameraIndex,\n>  \t\t\t     const OptionsParser::Options &options)\n> -\t: options_(options), last_(0), queueCount_(0), captureCount_(0),\n> -\t  captureLimit_(0), printMetadata_(false)\n> +\t: options_(options), cameraIndex_(cameraIndex), last_(0),\n> +\t  queueCount_(0), captureCount_(0), captureLimit_(0),\n> +\t  printMetadata_(false)\n>  {\n>  \tchar *endptr;\n>  \tunsigned long index = strtoul(cameraId.c_str(), &endptr, 10);\n> @@ -152,7 +154,8 @@ int CameraSession::start()\n>  \tstreamName_.clear();\n>  \tfor (unsigned int index = 0; index < config_->size(); ++index) {\n>  \t\tStreamConfiguration &cfg = config_->at(index);\n> -\t\tstreamName_[cfg.stream()] = \"stream\" + std::to_string(index);\n> +\t\tstreamName_[cfg.stream()] = \"cam\" + std::to_string(cameraIndex_)\n> +\t\t\t\t\t  + \"-stream\" + std::to_string(index);\n>  \t}\n>  \n>  \tcamera_->requestCompleted.connect(this, &CameraSession::requestComplete);\n> diff --git a/src/cam/camera_session.h b/src/cam/camera_session.h\n> index f137279ab421..12449c98e582 100644\n> --- a/src/cam/camera_session.h\n> +++ b/src/cam/camera_session.h\n> @@ -28,7 +28,7 @@ class CameraSession\n>  {\n>  public:\n>  \tCameraSession(libcamera::CameraManager *cm,\n> -\t\t      const std::string &cameraId,\n> +\t\t      const std::string &cameraId, unsigned int cameraIndex,\n>  \t\t      const OptionsParser::Options &options);\n>  \t~CameraSession();\n>  \n> @@ -60,6 +60,8 @@ private:\n>  \n>  \tstd::map<const libcamera::Stream *, std::string> streamName_;\n>  \tstd::unique_ptr<BufferWriter> writer_;\n> +\tunsigned int cameraIndex_;\n> +\n>  \tuint64_t last_;\n>  \n>  \tunsigned int queueCount_;\n> diff --git a/src/cam/main.cpp b/src/cam/main.cpp\n> index 7688fa5540ea..96f55831ca69 100644\n> --- a/src/cam/main.cpp\n> +++ b/src/cam/main.cpp\n> @@ -136,7 +136,7 @@ int CamApp::parseOptions(int argc, char *argv[])\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 \"is expanded to the camera index, 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\", false,\n>  \t\t\t OptCamera);\n> @@ -201,7 +201,7 @@ int CamApp::run()\n>  \tif (options_.isSet(OptCamera)) {\n>  \t\tconst OptionValue &camera = options_[OptCamera];\n>  \t\tsession = std::make_unique<CameraSession>(cm_.get(),\n> -\t\t\t\t\t\t\t  camera.toString(),\n> +\t\t\t\t\t\t\t  camera.toString(), 0,\n>  \t\t\t\t\t\t\t  camera.children());\n>  \t\tif (!session->isValid()) {\n>  \t\t\tstd::cout << \"Failed to create camera session\" << std::endl;\n>","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 35D30C3226\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 12 Jul 2021 16:12:56 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id DB94568524;\n\tMon, 12 Jul 2021 18:12:55 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id EA64568513\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 12 Jul 2021 18:12:53 +0200 (CEST)","from [192.168.0.20]\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9405D3F1;\n\tMon, 12 Jul 2021 18:12:53 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"bn91Ckw+\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1626106373;\n\tbh=eOOb9t851IkxJYLRlS1IeRnNNJwUOBscPfK8MYOxv2E=;\n\th=Subject:To:References:From:Date:In-Reply-To:From;\n\tb=bn91Ckw+HpU+YlgmmHrPAECVThm1BNJSLeY8tUV0iWDVIwAX4Tw+yaqiRlxy0aQ+R\n\tvLDhiQ+wXUPUgp5mEa2UgoqCAIWO+6OXmGWUwTporRpJa4mBqLjbGhqeeB6zB+mIGQ\n\tyBmQO3PJdXQ+RAQ1cgcUvLUbiqKmx2M6ZxYfF6T0=","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","References":"<20210707021941.20804-1-laurent.pinchart@ideasonboard.com>\n\t<20210707021941.20804-30-laurent.pinchart@ideasonboard.com>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Message-ID":"<41cad79e-95a2-e455-762e-a1df16c7e36c@ideasonboard.com>","Date":"Mon, 12 Jul 2021 17:12:51 +0100","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101\n\tThunderbird/78.11.0","MIME-Version":"1.0","In-Reply-To":"<20210707021941.20804-30-laurent.pinchart@ideasonboard.com>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH 29/30] cam: Add camera index to file\n\tname of capture frames","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>"}}]