[libcamera-devel,v4,31/31] HACK: cam: Add options to select the stream to use

Message ID 20190320163055.22056-32-jacopo@jmondi.org
State Superseded
Headers show
Series
  • libcamera: ipu3: Add ImgU support + multiple streams
Related show

Commit Message

Jacopo Mondi March 20, 2019, 4:30 p.m. UTC
Add -o and -v options switches to the cam application to select which
streams to capture from.

Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
---
 src/cam/main.cpp | 20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

Patch

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<Stream *> &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);
 }