summaryrefslogtreecommitdiff
path: root/src/qcam/assets
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-07-24 01:09:58 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-07-24 14:23:03 +0300
commit7145d15e043a9066a7e0a6a53ba95b1b1af851d5 (patch)
treeef70cb295a1afcd2c40d2e031e95a899b7412a4f /src/qcam/assets
parenta8a2048ab0541d7a9743bc7f0db91229cc34f320 (diff)
libcamera: formats: Remove unnecessary explicit constructor calls
When initializing the PixelFormatInfo::format field with a PixelFormat, there's no need to call the PixelFormat (copy) constructor explicitly. Remove the unnecessary calls. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src/qcam/assets')
0 files changed, 0 insertions, 0 deletions
5 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
 * Copyright (C) 2020, Raspberry Pi (Trading) Ltd.
 *
 * stream_options.cpp - Helper to parse options for streams
 */
#include "stream_options.h"

#include <iostream>

using namespace libcamera;

StreamKeyValueParser::StreamKeyValueParser()
{
	addOption("role", OptionString,
		  "Role for the stream (viewfinder, video, still, raw)",
		  ArgumentRequired);
	addOption("width", OptionInteger, "Width in pixels",
		  ArgumentRequired);
	addOption("height", OptionInteger, "Height in pixels",
		  ArgumentRequired);
	addOption("pixelformat", OptionString, "Pixel format name",
		  ArgumentRequired);
}

KeyValueParser::Options StreamKeyValueParser::parse(const char *arguments)
{
	KeyValueParser::Options options = KeyValueParser::parse(arguments);
	StreamRole role;

	if (options.valid() && options.isSet("role") &&
	    !parseRole(&role, options)) {
		std::cerr << "Unknown stream role "
			  << options["role"].toString() << std::endl;
		options.invalidate();
	}

	return options;
}

StreamRoles StreamKeyValueParser::roles(const OptionValue &values)
{
	/* If no configuration values to examine default to viewfinder. */
	if (values.empty())
		return { StreamRole::Viewfinder };

	const std::vector<OptionValue> &streamParameters = values.toArray();

	StreamRoles roles;
	for (auto const &value : streamParameters) {
		StreamRole role;

		/* If role is invalid or not set default to viewfinder. */
		if (!parseRole(&role, value.toKeyValues()))
			role = StreamRole::Viewfinder;

		roles.push_back(role);
	}

	return roles;
}

int StreamKeyValueParser::updateConfiguration(CameraConfiguration *config,
					      const OptionValue &values)
{
	if (!config) {
		std::cerr << "No configuration provided" << std::endl;
		return -EINVAL;
	}

	/* If no configuration values nothing to do. */
	if (values.empty())
		return 0;

	const std::vector<OptionValue> &streamParameters = values.toArray();

	if (config->size() != streamParameters.size()) {
		std::cerr
			<< "Number of streams in configuration "
			<< config->size()
			<< " does not match number of streams parsed "
			<< streamParameters.size()
			<< std::endl;
		return -EINVAL;
	}

	unsigned int i = 0;
	for (auto const &value : streamParameters) {
		KeyValueParser::Options opts = value.toKeyValues();
		StreamConfiguration &cfg = config->at(i++);