From 99e1e786b475f3d6f4f8d9f5cd21db6c524ba60f Mon Sep 17 00:00:00 2001 From: Jacopo Mondi Date: Fri, 28 Jun 2019 09:13:34 +0200 Subject: libcamera: stream: Add Stream memory type MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Define the memory type a Stream uses and allow application to set it through the associated StreamConfiguration. A Stream can use either internal or external memory allocation methods, depending on where the data produced by the stream is actually saved. Signed-off-by: Jacopo Mondi Reviewed-by: Niklas Söderlund Signed-off-by: Laurent Pinchart --- src/libcamera/stream.cpp | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) (limited to 'src/libcamera/stream.cpp') diff --git a/src/libcamera/stream.cpp b/src/libcamera/stream.cpp index 12067c08..37a9bc0a 100644 --- a/src/libcamera/stream.cpp +++ b/src/libcamera/stream.cpp @@ -263,6 +263,17 @@ SizeRange StreamFormats::range(unsigned int pixelformat) const return range; } +/** + * \enum MemoryType + * \brief Define the memory type used by a Stream + * \var MemoryType::InternalMemory + * The Stream uses memory allocated internally by the library and exported to + * applications. + * \var MemoryType::ExternalMemory + * The Stream uses memory allocated externally by application and imported in + * the library. + */ + /** * \struct StreamConfiguration * \brief Configuration parameters for a stream @@ -276,7 +287,7 @@ SizeRange StreamFormats::range(unsigned int pixelformat) const * handlers provied StreamFormats. */ StreamConfiguration::StreamConfiguration() - : stream_(nullptr) + : memoryType(InternalMemory), stream_(nullptr) { } @@ -284,7 +295,7 @@ StreamConfiguration::StreamConfiguration() * \brief Construct a configuration with stream formats */ StreamConfiguration::StreamConfiguration(const StreamFormats &formats) - : stream_(nullptr), formats_(formats) + : memoryType(InternalMemory), stream_(nullptr), formats_(formats) { } @@ -301,6 +312,11 @@ StreamConfiguration::StreamConfiguration(const StreamFormats &formats) * format described in V4L2 using the V4L2_PIX_FMT_* definitions. */ +/** + * \var StreamConfiguration::memoryType + * \brief The memory type the stream shall use + */ + /** * \var StreamConfiguration::bufferCount * \brief Requested number of buffers to allocate for the stream @@ -454,18 +470,26 @@ std::unique_ptr Stream::createBuffer(unsigned int index) * \return The active configuration of the stream */ +/** + * \fn Stream::memoryType() + * \brief Retrieve the stream memory type + * \return The memory type used by the stream + */ + /** * \brief Create buffers for the stream * \param[in] count The number of buffers to create + * \param[in] memory The stream memory type * * Create \a count empty buffers in the Stream's buffer pool. */ -void Stream::createBuffers(unsigned int count) +void Stream::createBuffers(MemoryType memory, unsigned int count) { destroyBuffers(); if (count == 0) return; + memoryType_ = memory; bufferPool_.createBuffers(count); } @@ -497,4 +521,9 @@ void Stream::destroyBuffers() * next call to Camera::configure() regardless of if it includes the stream. */ +/** + * \var Stream::memoryType_ + * \brief The stream memory type + */ + } /* namespace libcamera */ -- cgit v1.2.1