summaryrefslogtreecommitdiff
path: root/Documentation/docs.rst
AgeCommit message (Expand)Author
2020-06-05docs: Markup LD_PRELOAD as codeMarvin Schmidt
2020-06-05docs: Remove trailing whitespaceMarvin Schmidt
2020-06-05docs: Remove stray HTML tagsMarvin Schmidt
2020-04-15licenses: Add SPDX headers to RST documentationLaurent Pinchart
2019-10-23Documentation: Generate local TOC on demandLaurent Pinchart
2019-10-23Documentation: Link to API section in DocsLaurent Pinchart
2019-07-10Documentation: Fix trivial spelling errorKieran Bingham
2018-12-14Documentation: Remove | on the left side of diagramsLaurent Pinchart
2018-12-14Documentation: Add architecture documentationLaurent Pinchart
href='#n56'>56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90
/* 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 <set>
#include <string>

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

namespace libcamera {

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

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

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

	const std::string &name() const;

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

	int acquire();
	int release();

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

	int allocateBuffers();
	int freeBuffers();

	Request *createRequest();
	int queueRequest(Request *request);

	int start();
	int stop();

private:
	enum State {
		CameraAvailable,
		CameraAcquired,
		CameraConfigured,
		CameraPrepared,
		CameraRunning,
	};

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

	bool stateBetween(State low, State high) const;
	bool stateIs(State state) const;

	friend class PipelineHandler;
	void disconnect();

	void requestComplete(Request *request);

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

	bool disconnected_;
	State state_;
};

} /* namespace libcamera */

#endif /* __LIBCAMERA_CAMERA_H__ */