@@ -865,7 +865,7 @@ void CameraDevice::abortRequest(Camera3RequestDescriptor *descriptor) const
notifyError(descriptor->frameNumber_, nullptr, CAMERA3_MSG_ERROR_REQUEST);
for (auto &buffer : descriptor->buffers_)
- buffer.status = Camera3RequestDescriptor::Status::Error;
+ buffer.status = StreamBuffer::Status::Error;
descriptor->status_ = Camera3RequestDescriptor::Status::Error;
}
@@ -1163,7 +1163,7 @@ void CameraDevice::requestComplete(Request *request)
if (fence)
buffer.fence = fence->release();
}
- buffer.status = Camera3RequestDescriptor::Status::Success;
+ buffer.status = StreamBuffer::Status::Success;
}
/*
@@ -1226,12 +1226,12 @@ void CameraDevice::requestComplete(Request *request)
auto iter = descriptor->pendingStreamsToProcess_.begin();
while (iter != descriptor->pendingStreamsToProcess_.end()) {
CameraStream *stream = iter->first;
- Camera3RequestDescriptor::StreamBuffer *buffer = iter->second;
+ StreamBuffer *buffer = iter->second;
FrameBuffer *src = request->findBuffer(stream->stream());
if (!src) {
LOG(HAL, Error) << "Failed to find a source stream buffer";
- setBufferStatus(*buffer, Camera3RequestDescriptor::Status::Error);
+ setBufferStatus(*buffer, StreamBuffer::Status::Error);
iter = descriptor->pendingStreamsToProcess_.erase(iter);
continue;
}
@@ -1241,7 +1241,7 @@ void CameraDevice::requestComplete(Request *request)
++iter;
int ret = stream->process(buffer);
if (ret) {
- setBufferStatus(*buffer, Camera3RequestDescriptor::Status::Error);
+ setBufferStatus(*buffer, StreamBuffer::Status::Error);
descriptor->pendingStreamsToProcess_.erase(stream);
/*
@@ -1311,7 +1311,7 @@ void CameraDevice::sendCaptureResults()
for (auto &buffer : descriptor->buffers_) {
camera3_buffer_status status = CAMERA3_BUFFER_STATUS_ERROR;
- if (buffer.status == Camera3RequestDescriptor::Status::Success)
+ if (buffer.status == StreamBuffer::Status::Success)
status = CAMERA3_BUFFER_STATUS_OK;
/*
@@ -1335,11 +1335,11 @@ void CameraDevice::sendCaptureResults()
}
}
-void CameraDevice::setBufferStatus(Camera3RequestDescriptor::StreamBuffer &streamBuffer,
- Camera3RequestDescriptor::Status status)
+void CameraDevice::setBufferStatus(StreamBuffer &streamBuffer,
+ StreamBuffer::Status status)
{
streamBuffer.status = status;
- if (status != Camera3RequestDescriptor::Status::Success) {
+ if (status != StreamBuffer::Status::Success) {
notifyError(streamBuffer.request->frameNumber_,
streamBuffer.stream->camera3Stream(),
CAMERA3_MSG_ERROR_BUFFER);
@@ -1363,8 +1363,8 @@ void CameraDevice::setBufferStatus(Camera3RequestDescriptor::StreamBuffer &strea
* be generated from post-processing have been completed. Mark the descriptor as
* complete using completeDescriptor() in that case.
*/
-void CameraDevice::streamProcessingComplete(Camera3RequestDescriptor::StreamBuffer *streamBuffer,
- Camera3RequestDescriptor::Status status)
+void CameraDevice::streamProcessingComplete(StreamBuffer *streamBuffer,
+ StreamBuffer::Status status)
{
setBufferStatus(*streamBuffer, status);
@@ -65,8 +65,8 @@ public:
int configureStreams(camera3_stream_configuration_t *stream_list);
int processCaptureRequest(camera3_capture_request_t *request);
void requestComplete(libcamera::Request *request);
- void streamProcessingComplete(Camera3RequestDescriptor::StreamBuffer *bufferStream,
- Camera3RequestDescriptor::Status status);
+ void streamProcessingComplete(StreamBuffer *bufferStream,
+ StreamBuffer::Status status);
protected:
std::string logPrefix() const override;
@@ -97,8 +97,8 @@ private:
void completeDescriptor(Camera3RequestDescriptor *descriptor)
LIBCAMERA_TSA_EXCLUDES(descriptorsMutex_);
void sendCaptureResults() LIBCAMERA_TSA_REQUIRES(descriptorsMutex_);
- void setBufferStatus(Camera3RequestDescriptor::StreamBuffer &buffer,
- Camera3RequestDescriptor::Status status);
+ void setBufferStatus(StreamBuffer &buffer,
+ StreamBuffer::Status status);
std::unique_ptr<CameraMetadata> getResultMetadata(
const Camera3RequestDescriptor &descriptor) const;
@@ -141,7 +141,7 @@ Camera3RequestDescriptor::Camera3RequestDescriptor(
Camera3RequestDescriptor::~Camera3RequestDescriptor() = default;
/**
- * \struct Camera3RequestDescriptor::StreamBuffer
+ * \class StreamBuffer
* \brief Group information for per-stream buffer of Camera3RequestDescriptor
*
* A capture request placed to the libcamera HAL can contain multiple streams.
@@ -150,35 +150,35 @@ Camera3RequestDescriptor::~Camera3RequestDescriptor() = default;
* generation. The generation of the stream will depend on its type (refer to
* the CameraStream::Type documentation).
*
- * \var Camera3RequestDescriptor::StreamBuffer::stream
+ * \var StreamBuffer::stream
* \brief Pointer to the corresponding CameraStream
*
- * \var Camera3RequestDescriptor::StreamBuffer::camera3Buffer
+ * \var StreamBuffer::camera3Buffer
* \brief Native handle to the buffer
*
- * \var Camera3RequestDescriptor::StreamBuffer::frameBuffer
+ * \var StreamBuffer::frameBuffer
* \brief Encapsulate the dmabuf handle inside a libcamera::FrameBuffer for
* direct streams
*
- * \var Camera3RequestDescriptor::StreamBuffer::fence
+ * \var StreamBuffer::fence
* \brief Acquire fence of the buffer
*
- * \var Camera3RequestDescriptor::StreamBuffer::status
+ * \var StreamBuffer::status
* \brief Track the status of the buffer
*
- * \var Camera3RequestDescriptor::StreamBuffer::internalBuffer
+ * \var StreamBuffer::internalBuffer
* \brief Pointer to a buffer internally handled by CameraStream (if any)
*
- * \var Camera3RequestDescriptor::StreamBuffer::srcBuffer
+ * \var StreamBuffer::srcBuffer
* \brief Pointer to the source frame buffer used for post-processing
*
- * \var Camera3RequestDescriptor::StreamBuffer::dstBuffer
+ * \var StreamBuffer::dstBuffer
* \brief Pointer to the destination frame buffer used for post-processing
*
- * \var Camera3RequestDescriptor::StreamBuffer::request
+ * \var StreamBuffer::request
* \brief Back pointer to the Camera3RequestDescriptor to which the StreamBuffer belongs
*/
-Camera3RequestDescriptor::StreamBuffer::StreamBuffer(
+StreamBuffer::StreamBuffer(
CameraStream *cameraStream, const camera3_stream_buffer_t &buffer,
Camera3RequestDescriptor *requestDescriptor)
: stream(cameraStream), camera3Buffer(buffer.buffer),
@@ -186,9 +186,8 @@ Camera3RequestDescriptor::StreamBuffer::StreamBuffer(
{
}
-Camera3RequestDescriptor::StreamBuffer::~StreamBuffer() = default;
+StreamBuffer::~StreamBuffer() = default;
-Camera3RequestDescriptor::StreamBuffer::StreamBuffer(StreamBuffer &&) = default;
+StreamBuffer::StreamBuffer(StreamBuffer &&) = default;
-Camera3RequestDescriptor::StreamBuffer &
-Camera3RequestDescriptor::StreamBuffer::operator=(Camera3RequestDescriptor::StreamBuffer &&) = default;
+StreamBuffer &StreamBuffer::operator=(StreamBuffer &&) = default;
@@ -26,7 +26,9 @@
class CameraBuffer;
class CameraStream;
-class Camera3RequestDescriptor
+class Camera3RequestDescriptor;
+
+class StreamBuffer
{
public:
enum class Status {
@@ -34,27 +36,34 @@ public:
Error,
};
- struct StreamBuffer {
- StreamBuffer(CameraStream *stream,
- const camera3_stream_buffer_t &buffer,
- Camera3RequestDescriptor *request);
- ~StreamBuffer();
-
- StreamBuffer(StreamBuffer &&);
- StreamBuffer &operator=(StreamBuffer &&);
-
- CameraStream *stream;
- buffer_handle_t *camera3Buffer;
- std::unique_ptr<HALFrameBuffer> frameBuffer;
- libcamera::UniqueFD fence;
- Status status = Status::Success;
- libcamera::FrameBuffer *internalBuffer = nullptr;
- const libcamera::FrameBuffer *srcBuffer = nullptr;
- std::unique_ptr<CameraBuffer> dstBuffer;
- Camera3RequestDescriptor *request;
-
- private:
- LIBCAMERA_DISABLE_COPY(StreamBuffer)
+ StreamBuffer(CameraStream *stream,
+ const camera3_stream_buffer_t &buffer,
+ Camera3RequestDescriptor *request);
+ ~StreamBuffer();
+
+ StreamBuffer(StreamBuffer &&);
+ StreamBuffer &operator=(StreamBuffer &&);
+
+ CameraStream *stream;
+ buffer_handle_t *camera3Buffer;
+ std::unique_ptr<HALFrameBuffer> frameBuffer;
+ libcamera::UniqueFD fence;
+ Status status = Status::Success;
+ libcamera::FrameBuffer *internalBuffer = nullptr;
+ const libcamera::FrameBuffer *srcBuffer = nullptr;
+ std::unique_ptr<CameraBuffer> dstBuffer;
+ Camera3RequestDescriptor *request;
+
+private:
+ LIBCAMERA_DISABLE_COPY(StreamBuffer)
+};
+
+class Camera3RequestDescriptor
+{
+public:
+ enum class Status {
+ Success,
+ Error,
};
/* Keeps track of streams requiring post-processing. */
@@ -112,14 +112,14 @@ int CameraStream::configure()
worker_ = std::make_unique<PostProcessorWorker>(postProcessor_.get());
postProcessor_->processComplete.connect(
- this, [&](Camera3RequestDescriptor::StreamBuffer *streamBuffer,
+ this, [&](StreamBuffer *streamBuffer,
PostProcessor::Status status) {
- Camera3RequestDescriptor::Status bufferStatus;
+ StreamBuffer::Status bufferStatus;
if (status == PostProcessor::Status::Success)
- bufferStatus = Camera3RequestDescriptor::Status::Success;
+ bufferStatus = StreamBuffer::Status::Success;
else
- bufferStatus = Camera3RequestDescriptor::Status::Error;
+ bufferStatus = StreamBuffer::Status::Error;
cameraDevice_->streamProcessingComplete(streamBuffer,
bufferStatus);
@@ -165,7 +165,7 @@ int CameraStream::waitFence(int fence)
return -errno;
}
-int CameraStream::process(Camera3RequestDescriptor::StreamBuffer *streamBuffer)
+int CameraStream::process(StreamBuffer *streamBuffer)
{
ASSERT(type_ != Type::Direct);
@@ -283,7 +283,7 @@ void CameraStream::PostProcessorWorker::start()
Thread::start();
}
-void CameraStream::PostProcessorWorker::queueRequest(Camera3RequestDescriptor::StreamBuffer *dest)
+void CameraStream::PostProcessorWorker::queueRequest(StreamBuffer *dest)
{
{
MutexLocker lock(mutex_);
@@ -306,7 +306,7 @@ void CameraStream::PostProcessorWorker::run()
if (state_ != State::Running)
break;
- Camera3RequestDescriptor::StreamBuffer *streamBuffer = requests_.front();
+ StreamBuffer *streamBuffer = requests_.front();
requests_.pop();
locker.unlock();
@@ -316,7 +316,7 @@ void CameraStream::PostProcessorWorker::run()
}
if (state_ == State::Flushing) {
- std::queue<Camera3RequestDescriptor::StreamBuffer *> requests =
+ std::queue<StreamBuffer *> requests =
std::move(requests_);
locker.unlock();
@@ -127,7 +127,7 @@ public:
CameraStream *sourceStream() const { return sourceStream_; }
int configure();
- int process(Camera3RequestDescriptor::StreamBuffer *streamBuffer);
+ int process(StreamBuffer *streamBuffer);
libcamera::FrameBuffer *getBuffer();
void putBuffer(libcamera::FrameBuffer *buffer);
void flush();
@@ -146,7 +146,7 @@ private:
~PostProcessorWorker();
void start();
- void queueRequest(Camera3RequestDescriptor::StreamBuffer *request);
+ void queueRequest(StreamBuffer *request);
void flush();
protected:
@@ -158,7 +158,7 @@ private:
libcamera::Mutex mutex_;
libcamera::ConditionVariable cv_;
- std::queue<Camera3RequestDescriptor::StreamBuffer *> requests_
+ std::queue<StreamBuffer *> requests_
LIBCAMERA_TSA_GUARDED_BY(mutex_);
State state_ LIBCAMERA_TSA_GUARDED_BY(mutex_) = State::Stopped;
@@ -20,7 +20,7 @@ public:
virtual ~Encoder() = default;
virtual int configure(const libcamera::StreamConfiguration &cfg) = 0;
- virtual int encode(Camera3RequestDescriptor::StreamBuffer *buffer,
+ virtual int encode(StreamBuffer *buffer,
libcamera::Span<const uint8_t> exifData,
unsigned int quality) = 0;
};
@@ -33,7 +33,7 @@ int EncoderJea::configure(const libcamera::StreamConfiguration &cfg)
return 0;
}
-int EncoderJea::encode(Camera3RequestDescriptor::StreamBuffer *buffer,
+int EncoderJea::encode(StreamBuffer *buffer,
libcamera::Span<const uint8_t> exifData,
unsigned int quality)
{
@@ -20,7 +20,7 @@ public:
~EncoderJea();
int configure(const libcamera::StreamConfiguration &cfg) override;
- int encode(Camera3RequestDescriptor::StreamBuffer *buffer,
+ int encode(StreamBuffer *buffer,
libcamera::Span<const uint8_t> exifData,
unsigned int quality) override;
@@ -180,7 +180,7 @@ void EncoderLibJpeg::compressNV(const std::vector<Span<uint8_t>> &planes)
}
}
-int EncoderLibJpeg::encode(Camera3RequestDescriptor::StreamBuffer *buffer,
+int EncoderLibJpeg::encode(StreamBuffer *buffer,
libcamera::Span<const uint8_t> exifData,
unsigned int quality)
{
@@ -22,7 +22,7 @@ public:
~EncoderLibJpeg();
int configure(const libcamera::StreamConfiguration &cfg) override;
- int encode(Camera3RequestDescriptor::StreamBuffer *buffer,
+ int encode(StreamBuffer *buffer,
libcamera::Span<const uint8_t> exifData,
unsigned int quality) override;
int encode(const std::vector<libcamera::Span<uint8_t>> &planes,
@@ -106,7 +106,7 @@ void PostProcessorJpeg::generateThumbnail(const FrameBuffer &source,
}
}
-void PostProcessorJpeg::process(Camera3RequestDescriptor::StreamBuffer *streamBuffer)
+void PostProcessorJpeg::process(StreamBuffer *streamBuffer)
{
ASSERT(encoder_);
@@ -22,7 +22,7 @@ public:
int configure(const libcamera::StreamConfiguration &incfg,
const libcamera::StreamConfiguration &outcfg) override;
- void process(Camera3RequestDescriptor::StreamBuffer *streamBuffer) override;
+ void process(StreamBuffer *streamBuffer) override;
private:
void generateThumbnail(const libcamera::FrameBuffer &source,
@@ -27,7 +27,7 @@ public:
virtual int configure(const libcamera::StreamConfiguration &inCfg,
const libcamera::StreamConfiguration &outCfg) = 0;
- virtual void process(Camera3RequestDescriptor::StreamBuffer *streamBuffer) = 0;
+ virtual void process(StreamBuffer *streamBuffer) = 0;
- libcamera::Signal<Camera3RequestDescriptor::StreamBuffer *, Status> processComplete;
+ libcamera::Signal<StreamBuffer *, Status> processComplete;
};
@@ -49,7 +49,7 @@ int PostProcessorYuv::configure(const StreamConfiguration &inCfg,
return 0;
}
-void PostProcessorYuv::process(Camera3RequestDescriptor::StreamBuffer *streamBuffer)
+void PostProcessorYuv::process(StreamBuffer *streamBuffer)
{
const FrameBuffer &source = *streamBuffer->srcBuffer;
CameraBuffer *destination = streamBuffer->dstBuffer.get();
@@ -18,7 +18,7 @@ public:
int configure(const libcamera::StreamConfiguration &incfg,
const libcamera::StreamConfiguration &outcfg) override;
- void process(Camera3RequestDescriptor::StreamBuffer *streamBuffer) override;
+ void process(StreamBuffer *streamBuffer) override;
private:
bool isValidBuffers(const libcamera::FrameBuffer &source,