mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-17 17:35:06 +03:00
Request complete by themselves when all the buffers they contain have completed, connecting the buffer's completed signal to be notified of buffer completion. While this works for now, it prevents pipelines from delaying request completion until all metadata is available, and makes it impossible to ensure that requests complete in the order they are queued. To fix this, make request completion handling explicit in pipeline handlers. The base PipelineHandler class is extended with implementations of the queueRequest() and stop() methods and gets new completeBuffer() and completeRequest() methods to help pipeline handlers tracking requests and buffers. The three existing pipeline handlers connect the bufferReady signal of their capture video node to a slot of their respective camera data instance, where they use the PipelineHandler helpers to notify buffer and request completion. Request completion is handled synchronously with buffer completion as the pipeline handlers don't need to support more advanced use cases, but this paves the road for future work. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
89 lines
1.5 KiB
C++
89 lines
1.5 KiB
C++
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
|
/*
|
|
* Copyright (C) 2019, Google Inc.
|
|
*
|
|
* buffer.h - Buffer handling
|
|
*/
|
|
#ifndef __LIBCAMERA_BUFFER_H__
|
|
#define __LIBCAMERA_BUFFER_H__
|
|
|
|
#include <stdint.h>
|
|
#include <vector>
|
|
|
|
namespace libcamera {
|
|
|
|
class BufferPool;
|
|
|
|
class Plane final
|
|
{
|
|
public:
|
|
Plane();
|
|
~Plane();
|
|
|
|
int dmabuf() const { return fd_; }
|
|
int setDmabuf(int fd, unsigned int length);
|
|
|
|
void *mem();
|
|
unsigned int length() const { return length_; }
|
|
|
|
private:
|
|
int mmap();
|
|
int munmap();
|
|
|
|
int fd_;
|
|
unsigned int length_;
|
|
void *mem_;
|
|
};
|
|
|
|
class Buffer final
|
|
{
|
|
public:
|
|
enum Status {
|
|
BufferSuccess,
|
|
BufferError,
|
|
BufferCancelled,
|
|
};
|
|
|
|
Buffer();
|
|
|
|
unsigned int index() const { return index_; }
|
|
unsigned int bytesused() const { return bytesused_; }
|
|
uint64_t timestamp() const { return timestamp_; }
|
|
unsigned int sequence() const { return sequence_; }
|
|
Status status() const { return status_; }
|
|
std::vector<Plane> &planes() { return planes_; }
|
|
|
|
private:
|
|
friend class BufferPool;
|
|
friend class PipelineHandler;
|
|
friend class V4L2Device;
|
|
|
|
void cancel();
|
|
|
|
unsigned int index_;
|
|
unsigned int bytesused_;
|
|
uint64_t timestamp_;
|
|
unsigned int sequence_;
|
|
Status status_;
|
|
|
|
std::vector<Plane> planes_;
|
|
};
|
|
|
|
class BufferPool final
|
|
{
|
|
public:
|
|
~BufferPool();
|
|
|
|
void createBuffers(unsigned int count);
|
|
void destroyBuffers();
|
|
|
|
unsigned int count() const { return buffers_.size(); }
|
|
std::vector<Buffer> &buffers() { return buffers_; }
|
|
|
|
private:
|
|
std::vector<Buffer> buffers_;
|
|
};
|
|
|
|
} /* namespace libcamera */
|
|
|
|
#endif /* __LIBCAMERA_BUFFER_H__ */
|