From patchwork Thu Jul 15 21:14:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 12971 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 9AD1DC3226 for ; Thu, 15 Jul 2021 21:15:08 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 3B76A68545; Thu, 15 Jul 2021 23:15:07 +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="JxW5hQwf"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 976586059F for ; Thu, 15 Jul 2021 23:15:04 +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 19F4E340 for ; Thu, 15 Jul 2021 23:15:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1626383704; bh=pIQwkHCg9y9CgPhhUiWS/4d6KEzuH0Pyani01ReZ9ug=; h=From:To:Subject:Date:From; b=JxW5hQwf9CQdb/9Mf7DFJzJNz6V00WiMxTgrgCzQ4BoobA6JZNzrAhsyPNp1tH6TP pqvNX0QGDZU4dol1FTX0uFvai/Zuy9h8v3zXPU/yxZ9rzCW5R6iYsbBhTZMbO6i9+J OUala/oasFsymvTeLr6BKsQkPNBwd40+RZPvcpkw= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Fri, 16 Jul 2021 00:14:26 +0300 Message-Id: <20210715211459.19373-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 00/33] Multi-camera support in the cam application 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" Hello, This patch series adds multi-camera support to the cam application, allowing it to capture streams from different cameras at the same time. While this can be used with any cameras, it is most useful to test concurrent usage of different cameras belonging to the same pipeline handler, as multiple cam instances can be run in parallel to capture from cameras belonging to different pipeline handlers. The patch series starts with a rework of the options parser to support parent-child relationships in options, allowing for syntaxes such as cam -c1 -C20 -c2 -C30 to capture 20 and 30 frames from cameras 1 and 2 respectively. The second part of the series reworks the cam application to slowly move towards multi-camera support, with the last patch flipping the switch. I've tested this successfully with cameras belonging to different pipeline handler instances. The PipelineHandler::lock() function currently prevents concurrent usage of cameras belonging to the same pipeline handler. While this will need to be addressed in order to get the full potential from multi-camera support in cam, the cam application is expected to work the same way regardless of whether the cameras belong to the same or different pipeline handlers. Compared to v2, this version fixes an embarassing bug caused by an assert added at the last minute. The fix is in patch 12/33, with 11/33 adding a small new API extension to support it. Patch 13/33 is also new, and catches a common user error. Compared to v1, this version incorporates small fixes to address review comments. Thanks Kieran for the review of v1, only "[PATCH v2 11/30] cam: options: Avoid copies of OptionvValue and KeyValueParser::Options" is missing your tag. A test branch with all the patches applied is available from https://git.libcamera.org/libcamera/pinchartl/libcamera.git/log/?h=cam/multi-cam Laurent Pinchart (33): cam: options: Make KeyValueParser::usage() private cam: options: Move Option struct to options.cpp cam: options: Document the options parser API cam: options: Move OptionValue class after OptionsParser cam: options: Add optionName() function to Option structure cam: options: Slit OptionsParser::usage() in two functions cam: options: Disable copy for parsers cam: options: Move key string left in usage() for key-value parser cam: options: Support parent-child relationship between options cam: options: Drop some OptionValue cast operators cam: options: Add empty() function to OptionValue class cam: stream_options: Use OptionValue::empty() to test if option is set cam: options: Avoid copies of OptionvValue and KeyValueParser::Options cam: options: Fail parsing when non-option arguments are found cam: Rename Capture to CameraSession cam: camera_session: Access event loop through global instance cam: Move event loop exit from CameraSession to CamApp cam: Move event loop execution from CameraSession to CamApp cam: camera_session: Use std::unique_ptr<> to manage class members cam: Store camera session pointer in CamApp class cam: Move CameraConfiguration creation to CameraSession class cam: Move camera acquire to the CameraSession class cam: Use std::unique_ptr<> to manage CameraManager cam: Drop unneeded error check and message cam: Make CamApp::cameraName() static cam: Move camera session creation and monitoring setup to run() cam: Move printing of camera information to CameraSession class cam: Move session_ member variable to a local variable in run() function cam: Reorganize run() function and merge the two event loops cam: Allow specifying directories in the --file option cam: Make camera-related options sub-options of OptCamera cam: Add camera index to file name of capture frames cam: Support using multiple cameras concurrently src/cam/buffer_writer.cpp | 7 +- src/cam/buffer_writer.h | 2 +- src/cam/camera_session.cpp | 345 ++++++++++++++++++ src/cam/camera_session.h | 76 ++++ src/cam/capture.cpp | 241 ------------- src/cam/capture.h | 55 --- src/cam/main.cpp | 312 ++++++---------- src/cam/meson.build | 2 +- src/cam/options.cpp | 722 +++++++++++++++++++++++++++++++++---- src/cam/options.h | 98 ++--- src/cam/stream_options.cpp | 15 +- 11 files changed, 1249 insertions(+), 626 deletions(-) create mode 100644 src/cam/camera_session.cpp create mode 100644 src/cam/camera_session.h delete mode 100644 src/cam/capture.cpp delete mode 100644 src/cam/capture.h