From patchwork Wed Mar 20 16:30:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 777 Return-Path: Received: from relay12.mail.gandi.net (relay12.mail.gandi.net [217.70.178.232]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 95AC4611A2 for ; Wed, 20 Mar 2019 17:30:47 +0100 (CET) Received: from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101]) (Authenticated sender: jacopo@jmondi.org) by relay12.mail.gandi.net (Postfix) with ESMTPSA id 2E3A9200003; Wed, 20 Mar 2019 16:30:47 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Wed, 20 Mar 2019 17:30:55 +0100 Message-Id: <20190320163055.22056-32-jacopo@jmondi.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190320163055.22056-1-jacopo@jmondi.org> References: <20190320163055.22056-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 31/31] HACK: cam: Add options to select the stream to use X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Mar 2019 16:30:47 -0000 Add -o and -v options switches to the cam application to select which streams to capture from. Signed-off-by: Jacopo Mondi --- src/cam/main.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/cam/main.cpp b/src/cam/main.cpp index 28ea0b7d76b2..8c5d55d11bbe 100644 --- a/src/cam/main.cpp +++ b/src/cam/main.cpp @@ -31,6 +31,8 @@ enum { OptFormat = 'f', OptHelp = 'h', OptList = 'l', + OptOutput = 'o', + OptViefinder = 'v', }; void signalHandler(int signal) @@ -65,6 +67,12 @@ static int parseOptions(int argc, char *argv[]) parser.addOption(OptHelp, OptionNone, "Display this help message", "help"); parser.addOption(OptList, OptionNone, "List all cameras", "list"); + parser.addOption(OptOutput, OptionNone, "Use output stream\n" + "If no '-o' or '-v' options are specified, use viewfinder stream only", + "list"); + parser.addOption(OptViefinder, OptionNone, "Use viewfinder stream\n" + "If no '-o' or '-v' options are specified, use viewfinder stream only", + "list"); options = parser.parse(argc, argv); if (!options.valid() || options.isSet(OptHelp)) { @@ -103,11 +111,15 @@ static int configureStreams(Camera *camera, std::set &streams, defaultConfig[viewfinder].height = 480; /* - * HACK: add output/viewfinder to 'config' - * to play with stream combinations. + * HACK: Select which stream to capture: use output if required, + * use viewfinder if required or if no option has been specified + * from the command line. */ - config[output] = defaultConfig[output]; - config[viewfinder] = defaultConfig[viewfinder]; + if (options.isSet(OptOutput)) + config[output] = defaultConfig[output]; + if (options.isSet(OptViefinder) || + (!options.isSet(OptViefinder) && !options.isSet(OptOutput))) + config[viewfinder] = defaultConfig[viewfinder]; return camera->configureStreams(config); }