/* SPDX-License-Identifier: LGPL-2.1-or-later */ /* * Copyright (C) 2018, Google Inc. * * camera.h - Camera object interface */ #pragma once #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include namespace libcamera { class FrameBuffer; class FrameBufferAllocator; class PipelineHandler; class Request; class SensorConfiguration { public: unsigned int bitDepth = 0; Rectangle analogCrop; struct { unsigned int binX = 1; unsigned int binY = 1; } binning; struct { unsigned int xOddInc = 1; unsigned int xEvenInc = 1; unsigned int yOddInc = 1; unsigned int yEvenInc = 1; } skipping; Size outputSize; bool isValid() const; }; class CameraConfiguration { public: enum Status { Valid, Adjusted, Invalid, }; using iterator = std::vector::iterator; using const_iterator = std::vector::const_iterator; virtual ~CameraConfiguration(); void addConfiguration(const StreamConfiguration &cfg); virtual Status validate() = 0; 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; std::optional sensorConfig; Transform transform; protected: CameraConfiguration(); enum class ColorSpaceFlag { None, StreamsShareColorSpace, }; using ColorSpaceFlags = Flags; Status validateColorSpaces(ColorSpaceFlags flags = ColorSpaceFlag::None); std::vector config_; }; class Camera final : public Object, public std::enable_shared_from_this, public Extensible { LIBCAMERA_DECLARE_PRIVATE() public: static std::shared_ptr create(std::unique_ptr d, const std::string &id, const std::set &streams); const std::string &id() const; Signal bufferCompleted; Signal requestCompleted; Signal<> disconnected; int acquire(); int release(); const ControlInfoMap &controls() const; const ControlList &properties() const; const std::set &streams() const; std::unique_ptr generateConfiguration(Span roles = {}); std::unique_ptr generateConfiguration(std::initializer_list roles) { return generateConfiguration(Span(roles.begin(), roles.end())); } int configure(CameraConfiguration *config); std::unique_ptr createRequest(uint64_t cookie = 0); int queueRequest(Request *request); int start(const ControlList *controls = nullptr); int stop(); private: LIBCAMERA_DISABLE_COPY(Camera) Camera(std::unique_ptr d, const std::string &id, const std::set &streams); ~Camera(); friend class PipelineHandler; void disconnect(); void requestComplete(Request *request); friend class FrameBufferAllocator; int exportFrameBuffers(Stream *stream, std::vector> *buffers); }; } /* namespace libcamera */