/* 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 #include #include #include #include #include #include namespace libcamera { class Buffer; class PipelineHandler; class Request; class CameraConfiguration { public: using iterator = std::vector::iterator; using const_iterator = std::vector::const_iterator; CameraConfiguration(); void addConfiguration(const StreamConfiguration &cfg); bool isValid() const; StreamConfiguration &at(unsigned int index); const StreamConfiguration &at(unsigned int index) const; StreamConfiguration &operator[](unsigned int index) { return at(index); } const StreamConfiguration &operator[](unsigned int index) const { return at(index); } iterator begin(); const_iterator begin() const; iterator end(); const_iterator end() const; bool empty() const; std::size_t size() const; private: std::vector config_; }; class Camera final { public: static std::shared_ptr create(PipelineHandler *pipe, const std::string &name, const std::set &streams); Camera(const Camera &) = delete; Camera &operator=(const Camera &) = delete; const std::string &name() const; Signal bufferCompleted; Signal &> requestCompleted; Signal disconnected; int acquire(); int release(); const std::set &streams() const; CameraConfiguration generateConfiguration(const StreamRoles &roles); int configure(CameraConfiguration &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 pipe_; std::string name_; std::set streams_; std::set activeStreams_; bool disconnected_; State state_; }; } /* namespace libcamera */ #endif /* __LIBCAMERA_CAMERA_H__ */