From 84ad104499d9efc0253dae1a60ee070ed375ad95 Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 20 Oct 2022 00:44:55 +0300 Subject: Move test applications to src/apps/ The cam and qcam test application share code, currently through a crude hack that references the cam source files directly from the qcam meson.build file. To prepare for the introduction of hosting that code in a static library, move all applications to src/apps/. Signed-off-by: Laurent Pinchart Reviewed-by: Paul Elder Reviewed-by: Kieran Bingham --- src/apps/cam/capture_script.h | 68 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 src/apps/cam/capture_script.h (limited to 'src/apps/cam/capture_script.h') diff --git a/src/apps/cam/capture_script.h b/src/apps/cam/capture_script.h new file mode 100644 index 00000000..7a0ddebb --- /dev/null +++ b/src/apps/cam/capture_script.h @@ -0,0 +1,68 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2022, Ideas on Board Oy + * + * capture_script.h - Capture session configuration script + */ + +#pragma once + +#include +#include +#include + +#include +#include + +#include + +class CaptureScript +{ +public: + CaptureScript(std::shared_ptr camera, + const std::string &fileName); + + bool valid() const { return valid_; } + + const libcamera::ControlList &frameControls(unsigned int frame); + +private: + struct EventDeleter { + void operator()(yaml_event_t *event) const + { + yaml_event_delete(event); + delete event; + } + }; + using EventPtr = std::unique_ptr; + + std::map controls_; + std::map frameControls_; + std::shared_ptr camera_; + yaml_parser_t parser_; + unsigned int loop_; + bool valid_; + + EventPtr nextEvent(yaml_event_type_t expectedType = YAML_NO_EVENT); + bool checkEvent(const EventPtr &event, yaml_event_type_t expectedType) const; + static std::string eventScalarValue(const EventPtr &event); + static std::string eventTypeName(yaml_event_type_t type); + + int parseScript(FILE *script); + + int parseProperties(); + int parseProperty(); + int parseFrames(); + int parseFrame(EventPtr event); + int parseControl(EventPtr event, libcamera::ControlList &controls); + + std::string parseScalar(); + libcamera::ControlValue parseRectangles(); + std::vector> parseArrays(); + std::vector parseSingleArray(); + + void unpackFailure(const libcamera::ControlId *id, + const std::string &repr); + libcamera::ControlValue unpackControl(const libcamera::ControlId *id); + libcamera::Rectangle unpackRectangle(const std::vector &strVec); +}; -- cgit v1.2.1