summaryrefslogtreecommitdiff
path: root/include/libcamera/camera.h
blob: 1c0ee07c2a227ac9ce72697c68bb729efb3aac6e (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
62
63
64
65
66
/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
 * Copyright (C) 2018, Google Inc.
 *
 * camera.h - Camera object interface
 */
#ifndef __LIBCAMERA_CAMERA_H__
#define __LIBCAMERA_CAMERA_H__

#include <map>
#include <memory>
#include <string>

#include <libcamera/request.h>
#include <libcamera/signal.h>

namespace libcamera {

class Buffer;
class PipelineHandler;
class Stream;
class StreamConfiguration;

class Camera final
{
public:
	static std::shared_ptr<Camera> create(PipelineHandler *pipe,
					      const std::string &name,
					      const std::vector<Stream *> &streams);

	Camera(const Camera &) = delete;
	Camera &operator=(const Camera &) = delete;

	const std::string &name() const;

	Signal<Request *, const std::map<Stream *, Buffer *> &> requestCompleted;
	Signal<Camera *> disconnected;

	int acquire();
	void release();

	const std::vector<Stream *> &streams() const;
	std::map<Stream *, StreamConfiguration>
	streamConfiguration(std::vector<Stream *> &streams);
	int configureStreams(std::map<Stream *, StreamConfiguration> &config);

private:
	Camera(PipelineHandler *pipe, const std::string &name);
	~Camera();

	friend class PipelineHandler;
	void disconnect();
	int exclusiveAccess();

	std::shared_ptr<PipelineHandler> pipe_;
	std::string name_;
	std::vector<Stream *> streams_;
	std::vector<Stream *> activeStreams_;

	bool acquired_;
	bool disconnected_;
};

} /* namespace libcamera */

#endif /* __LIBCAMERA_CAMERA_H__ */