From patchwork Wed Jul 7 02:19:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 12814 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 9FB46BD794 for ; Wed, 7 Jul 2021 02:20:37 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B21336850A; Wed, 7 Jul 2021 04:20:35 +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="NGxtDaky"; 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 AAB1960283 for ; Wed, 7 Jul 2021 04:20:31 +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 1999B2E4 for ; Wed, 7 Jul 2021 04:20:31 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1625624431; bh=a3bmGJJmzFM6lVjv9nVgmIjGp2uVHYq1YEtQ4bheUiE=; h=From:To:Subject:Date:From; b=NGxtDakyR+7Sz0zOtJgXVCmoWCb2RcVoA1+JSqWMsQ3IV77yTz0r2k2seBlpdhepl lZlKCIaC2OdP8jFKK1BgP/PZxPOUYWfxKZsaz6GMGTTOlHgQyooizWv4Kx6cUFZOnl JR9bo/V9Iixu8B3GIleSSWb9OxwLEYpSkqgZMrF8= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Wed, 7 Jul 2021 05:19:11 +0300 Message-Id: <20210707021941.20804-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 00/30] 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. Laurent Pinchart (30): 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: Avoid copies of OptionvValue and KeyValueParser::Options 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 manager 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 | 707 +++++++++++++++++++++++++++++++++---- src/cam/options.h | 97 ++--- src/cam/stream_options.cpp | 3 +- 11 files changed, 1227 insertions(+), 620 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