summaryrefslogtreecommitdiff
path: root/Documentation/contributing.rst
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-01-20 13:24:50 +0200
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-01-22 18:46:00 +0200
commitce2ea24fb46f924bda14721c7cee0d2e4ea0d74f (patch)
treee6ce88cd1a6aae47315e83bf488dec24731236e9 /Documentation/contributing.rst
parent667f53b522d6181ca3794e0d45d52bc1b069a513 (diff)
libcamera: Fix documentation of buffer allocation/export functions
The V4L2VideoDevice::exportBuffers(), PipelineHandler::exportFrameBuffers() and FrameBufferAllocator::allocate() functions all return the number of allocated buffers on success, but are documented as returning 0 in that case. Fix their documentation. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
Diffstat (limited to 'Documentation/contributing.rst')
0 files changed, 0 insertions, 0 deletions
ref='#n122'>122 123 124 125 126 127 128
/* 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, stillraw)",
		  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)
{
	const std::vector<OptionValue> &streamParameters = values.toArray();

	/* If no configuration values to examine default to viewfinder. */
	if (streamParameters.empty())
		return { StreamRole::Viewfinder };

	StreamRoles roles;
	for (auto const &value : streamParameters) {
		KeyValueParser::Options opts = value.toKeyValues();
		StreamRole role;

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

		roles.push_back(role);
	}

	return roles;
}

int StreamKeyValueParser::updateConfiguration(CameraConfiguration *config,
					      const OptionValue &values)
{
	const std::vector<OptionValue> &streamParameters = values.toArray();

	if (!config) {
		std::cerr << "No configuration provided" << std::endl;
		return -EINVAL;
	}

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

	if (config->size() != streamParameters.size()) {
		std::cerr