summaryrefslogtreecommitdiff
path: root/src/libcamera/pipeline/virtual/virtual.h
blob: 92ad7d4a9f17b9bb2b1e51ae5d9e0f43bf5d7371 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
 * Copyright (C) 2024, Google Inc.
 *
 * Pipeline handler for virtual cameras
 */

#pragma once

#include <string>
#include <variant>
#include <vector>

#include <libcamera/geometry.h>
#include <libcamera/stream.h>

#include "libcamera/internal/camera.h"
#include "libcamera/internal/pipeline_handler.h"

#include "frame_generator.h"
#include "image_frame_generator.h"
#include "test_pattern_generator.h"

namespace libcamera {

using VirtualFrame = std::variant<TestPattern, ImageFrames>;

class VirtualCameraData : public Camera::Private
{
public:
	const static unsigned int kMaxStream = 3;

	struct Resolution {
		Size size;
		std::vector<int64_t> frameRates;
	};
	struct StreamConfig {
		Stream stream;
		std::unique_ptr<FrameGenerator> frameGenerator;
	};
	/* The config file is parsed to the Configuration struct */
	struct Configuration {
		std::string id;
		std::vector<Resolution> resolutions;
		VirtualFrame frame;

		Size maxResolutionSize;
		Size minResolutionSize;
	};

	VirtualCameraData(PipelineHandler *pipe,
			  const std::vector<Resolution> &supportedResolutions);

	~VirtualCameraData() = default;

	Configuration config_;

	std::vector<StreamConfig> streamConfigs_;
};

} /* namespace libcamera */