libcamera: pipeline: virtual: Fill buffer's metadata
Fill the `FrameMetadata` object of the `FrameBuffer`s because it should not be left uninitialized as users expect to be able to access it and find reasonable data there. Bug: https://bugs.libcamera.org/show_bug.cgi?id=245 Signed-off-by: Barnabás Pőcze <pobrn@protonmail.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
This commit is contained in:
parent
9c29274382
commit
98cf9eb533
2 changed files with 18 additions and 1 deletions
|
@ -286,6 +286,11 @@ int PipelineHandlerVirtual::exportFrameBuffers([[maybe_unused]] Camera *camera,
|
||||||
int PipelineHandlerVirtual::start([[maybe_unused]] Camera *camera,
|
int PipelineHandlerVirtual::start([[maybe_unused]] Camera *camera,
|
||||||
[[maybe_unused]] const ControlList *controls)
|
[[maybe_unused]] const ControlList *controls)
|
||||||
{
|
{
|
||||||
|
VirtualCameraData *data = cameraData(camera);
|
||||||
|
|
||||||
|
for (auto &s : data->streamConfigs_)
|
||||||
|
s.seq = 0;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -297,13 +302,24 @@ int PipelineHandlerVirtual::queueRequestDevice([[maybe_unused]] Camera *camera,
|
||||||
Request *request)
|
Request *request)
|
||||||
{
|
{
|
||||||
VirtualCameraData *data = cameraData(camera);
|
VirtualCameraData *data = cameraData(camera);
|
||||||
|
const auto timestamp = currentTimestamp();
|
||||||
|
|
||||||
for (auto const &[stream, buffer] : request->buffers()) {
|
for (auto const &[stream, buffer] : request->buffers()) {
|
||||||
bool found = false;
|
bool found = false;
|
||||||
/* map buffer and fill test patterns */
|
/* map buffer and fill test patterns */
|
||||||
for (auto &streamConfig : data->streamConfigs_) {
|
for (auto &streamConfig : data->streamConfigs_) {
|
||||||
if (stream == &streamConfig.stream) {
|
if (stream == &streamConfig.stream) {
|
||||||
|
FrameMetadata &fmd = buffer->_d()->metadata();
|
||||||
|
|
||||||
|
fmd.status = FrameMetadata::Status::FrameSuccess;
|
||||||
|
fmd.sequence = streamConfig.seq++;
|
||||||
|
fmd.timestamp = timestamp;
|
||||||
|
|
||||||
|
for (const auto [i, p] : utils::enumerate(buffer->planes()))
|
||||||
|
fmd.planes()[i].bytesused = p.length;
|
||||||
|
|
||||||
found = true;
|
found = true;
|
||||||
|
|
||||||
if (streamConfig.frameGenerator->generateFrame(
|
if (streamConfig.frameGenerator->generateFrame(
|
||||||
stream->configuration().size, buffer))
|
stream->configuration().size, buffer))
|
||||||
buffer->_d()->cancel();
|
buffer->_d()->cancel();
|
||||||
|
@ -315,7 +331,7 @@ int PipelineHandlerVirtual::queueRequestDevice([[maybe_unused]] Camera *camera,
|
||||||
ASSERT(found);
|
ASSERT(found);
|
||||||
}
|
}
|
||||||
|
|
||||||
request->metadata().set(controls::SensorTimestamp, currentTimestamp());
|
request->metadata().set(controls::SensorTimestamp, timestamp);
|
||||||
completeRequest(request);
|
completeRequest(request);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
@ -37,6 +37,7 @@ public:
|
||||||
struct StreamConfig {
|
struct StreamConfig {
|
||||||
Stream stream;
|
Stream stream;
|
||||||
std::unique_ptr<FrameGenerator> frameGenerator;
|
std::unique_ptr<FrameGenerator> frameGenerator;
|
||||||
|
unsigned int seq = 0;
|
||||||
};
|
};
|
||||||
/* The config file is parsed to the Configuration struct */
|
/* The config file is parsed to the Configuration struct */
|
||||||
struct Configuration {
|
struct Configuration {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue