summaryrefslogtreecommitdiff
path: root/src/py/libcamera/py_camera_manager.h
blob: 710163e865f7ec8eec85c50b4a066382a7c55485 (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
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
 * Copyright (C) 2022, Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
 */

#pragma once

#include <mutex>

#include <libcamera/libcamera.h>

#include <pybind11/smart_holder.h>

using namespace libcamera;

class PyCameraManager
{
public:
	PyCameraManager();
	~PyCameraManager();

	pybind11::list cameras();
	std::shared_ptr<Camera> get(const std::string &name) { return cameraManager_->get(name); }

	static const std::string &version() { return CameraManager::version(); }

	int eventFd() const { return eventFd_.get(); }

	std::vector<pybind11::object> getReadyRequests();

	void handleRequestCompleted(Request *req);

private:
	std::unique_ptr<CameraManager> cameraManager_;

	UniqueFD eventFd_;
	std::mutex completedRequestsMutex_;
	std::vector<Request *> completedRequests_;

	void writeFd();
	void readFd();
	void pushRequest(Request *req);
	std::vector<Request *> getCompletedRequests();
};