From patchwork Wed Jul 7 02:19:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 12842 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 43156BD794 for ; Wed, 7 Jul 2021 02:20:57 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id E5FFA6853E; Wed, 7 Jul 2021 04:20:56 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="t99/rmRY"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 6AB9F68542 for ; Wed, 7 Jul 2021 04:20:42 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 0631BDEE for ; Wed, 7 Jul 2021 04:20:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1625624442; bh=u9IISQNiJ2dkXRR1zckrrowgaqStDINjemH06IziE4o=; h=From:To:Subject:Date:In-Reply-To:References:From; b=t99/rmRYC9ngbIxFVzPwx/xD5G+ZbqNstdUkyJOBrrz1GZtdY4yeLpcRGNWSZ2w6S wn43AyU/GVIL+Tm5mtT6tc7S6a5OV7wfBtwBy2AHEcVRjhf5JFQLQeEVCjd1SzvGaE GaAfg+9dzikC+Z/MuXRiUh9k7TMIGJhsIgGn84FE= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Wed, 7 Jul 2021 05:19:40 +0300 Message-Id: <20210707021941.20804-30-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210707021941.20804-1-laurent.pinchart@ideasonboard.com> References: <20210707021941.20804-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 29/30] cam: Add camera index to file name of capture frames X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" To prepare for multi-camera support, extend the file naming scheme for captured frames to include the camera index in additiona to the stream name and frame number. Signed-off-by: Laurent Pinchart Reviewed-by: Kieran Bingham --- src/cam/camera_session.cpp | 9 ++++++--- src/cam/camera_session.h | 4 +++- src/cam/main.cpp | 4 ++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/cam/camera_session.cpp b/src/cam/camera_session.cpp index f2383567af3b..90261a8cde2e 100644 --- a/src/cam/camera_session.cpp +++ b/src/cam/camera_session.cpp @@ -22,9 +22,11 @@ using namespace libcamera; CameraSession::CameraSession(CameraManager *cm, const std::string &cameraId, + unsigned int cameraIndex, const OptionsParser::Options &options) - : options_(options), last_(0), queueCount_(0), captureCount_(0), - captureLimit_(0), printMetadata_(false) + : options_(options), cameraIndex_(cameraIndex), last_(0), + queueCount_(0), captureCount_(0), captureLimit_(0), + printMetadata_(false) { char *endptr; unsigned long index = strtoul(cameraId.c_str(), &endptr, 10); @@ -152,7 +154,8 @@ int CameraSession::start() streamName_.clear(); for (unsigned int index = 0; index < config_->size(); ++index) { StreamConfiguration &cfg = config_->at(index); - streamName_[cfg.stream()] = "stream" + std::to_string(index); + streamName_[cfg.stream()] = "cam" + std::to_string(cameraIndex_) + + "-stream" + std::to_string(index); } camera_->requestCompleted.connect(this, &CameraSession::requestComplete); diff --git a/src/cam/camera_session.h b/src/cam/camera_session.h index f137279ab421..12449c98e582 100644 --- a/src/cam/camera_session.h +++ b/src/cam/camera_session.h @@ -28,7 +28,7 @@ class CameraSession { public: CameraSession(libcamera::CameraManager *cm, - const std::string &cameraId, + const std::string &cameraId, unsigned int cameraIndex, const OptionsParser::Options &options); ~CameraSession(); @@ -60,6 +60,8 @@ private: std::map streamName_; std::unique_ptr writer_; + unsigned int cameraIndex_; + uint64_t last_; unsigned int queueCount_; diff --git a/src/cam/main.cpp b/src/cam/main.cpp index 7688fa5540ea..96f55831ca69 100644 --- a/src/cam/main.cpp +++ b/src/cam/main.cpp @@ -136,7 +136,7 @@ int CamApp::parseOptions(int argc, char *argv[]) "If the file name ends with a '/', it sets the directory in which\n" "to write files, using the default file name. Otherwise it sets the\n" "full file path and name. The first '#' character in the file name\n" - "is expanded to the stream name and frame sequence number.\n" + "is expanded to the camera index, stream name and frame sequence number.\n" "The default file name is 'frame-#.bin'.", "file", ArgumentOptional, "filename", false, OptCamera); @@ -201,7 +201,7 @@ int CamApp::run() if (options_.isSet(OptCamera)) { const OptionValue &camera = options_[OptCamera]; session = std::make_unique(cm_.get(), - camera.toString(), + camera.toString(), 0, camera.children()); if (!session->isValid()) { std::cout << "Failed to create camera session" << std::endl;