Files
external_libcamera/include/libcamera/request.h
Laurent Pinchart a2bcf6feee libcamera: buffer: Split memory information to BufferMemory
The Buffer class is a large beast the stores information about the
buffer memory, dynamic metadata related to the frame stored in the
buffer, and buffer reference data (in the index). In order to implement
buffer import we will need to extend this with dmabuf file descriptors,
making usage of the class even more complex.

Refactor the Buffer class by splitting the buffer memory information to
a BufferMemory class, and repurposing the Buffer class to reference a
buffer and to store dynamic metadata. The BufferMemory class becomes a
long term storage, valid and stable from the time buffer memory is
allocated to the time it is freed. The Buffer class, on the other hand,
becomes transient, is created on demand when an application requires a
buffer, is given to a request, and is deleted when the request
completes.

Buffer and BufferMemory don't need to be copied, so their copy
constructor and assignment operators are deleted.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>
2019-07-14 16:00:54 +03:00

70 lines
1.4 KiB
C++

/* SPDX-License-Identifier: LGPL-2.1-or-later */
/*
* Copyright (C) 2019, Google Inc.
*
* request.h - Capture request handling
*/
#ifndef __LIBCAMERA_REQUEST_H__
#define __LIBCAMERA_REQUEST_H__
#include <map>
#include <memory>
#include <stdint.h>
#include <unordered_set>
#include <libcamera/controls.h>
#include <libcamera/signal.h>
namespace libcamera {
class Buffer;
class Camera;
class Stream;
class Request
{
public:
enum Status {
RequestPending,
RequestComplete,
RequestCancelled,
};
Request(Camera *camera, uint64_t cookie = 0);
Request(const Request &) = delete;
Request &operator=(const Request &) = delete;
~Request();
ControlList &controls() { return controls_; }
const std::map<Stream *, Buffer *> &buffers() const { return bufferMap_; }
int addBuffer(std::unique_ptr<Buffer> buffer);
Buffer *findBuffer(Stream *stream) const;
uint64_t cookie() const { return cookie_; }
Status status() const { return status_; }
bool hasPendingBuffers() const { return !pending_.empty(); }
private:
friend class Camera;
friend class PipelineHandler;
int prepare();
void complete(Status status);
bool completeBuffer(Buffer *buffer);
Camera *camera_;
ControlList controls_;
std::map<Stream *, Buffer *> bufferMap_;
std::unordered_set<Buffer *> pending_;
const uint64_t cookie_;
Status status_;
};
} /* namespace libcamera */
#endif /* __LIBCAMERA_REQUEST_H__ */