libcamera: framebuffer: Move remaining private data to Private class

Private members of the FrameBuffer class are split between FrameBuffer
and FrameBuffer::Private. There was no real justification for this
split, and keeping some members private in the FrameBuffer class causes
multiple issues:

- Future modifications of the FrameBuffer class without breaking the ABI
  may be more difficult.
- Mutable access to members that should not be modified by applications
  require a friend statement, or going through the Private class.

Move all remaining private members to the Private class to address the
first issue, and add a Private::metadata() function to address the
second problem.

Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>
Tested-by: Naushir Patuck <naush@raspberrypi.com>
This commit is contained in:
Laurent Pinchart
2022-10-02 02:21:16 +03:00
parent e0e54965df
commit c20d3f5575
6 changed files with 71 additions and 53 deletions

View File

@@ -1791,12 +1791,14 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer()
watchdog_.start(std::chrono::duration_cast<std::chrono::milliseconds>(watchdogDuration_));
}
buffer->metadata_.status = buf.flags & V4L2_BUF_FLAG_ERROR
? FrameMetadata::FrameError
: FrameMetadata::FrameSuccess;
buffer->metadata_.sequence = buf.sequence;
buffer->metadata_.timestamp = buf.timestamp.tv_sec * 1000000000ULL
+ buf.timestamp.tv_usec * 1000ULL;
FrameMetadata &metadata = buffer->_d()->metadata();
metadata.status = buf.flags & V4L2_BUF_FLAG_ERROR
? FrameMetadata::FrameError
: FrameMetadata::FrameSuccess;
metadata.sequence = buf.sequence;
metadata.timestamp = buf.timestamp.tv_sec * 1000000000ULL
+ buf.timestamp.tv_usec * 1000ULL;
if (V4L2_TYPE_IS_OUTPUT(buf.type))
return buffer;
@@ -1812,10 +1814,9 @@ FrameBuffer *V4L2VideoDevice::dequeueBuffer()
<< buf.sequence << ")";
firstFrame_ = buf.sequence;
}
buffer->metadata_.sequence -= firstFrame_.value();
metadata.sequence -= firstFrame_.value();
unsigned int numV4l2Planes = multiPlanar ? buf.length : 1;
FrameMetadata &metadata = buffer->metadata_;
if (numV4l2Planes != buffer->planes().size()) {
/*
@@ -1941,9 +1942,10 @@ int V4L2VideoDevice::streamOff()
/* Send back all queued buffers. */
for (auto it : queuedBuffers_) {
FrameBuffer *buffer = it.second;
FrameMetadata &metadata = buffer->_d()->metadata();
cache_->put(it.first);
buffer->metadata_.status = FrameMetadata::FrameCancelled;
metadata.status = FrameMetadata::FrameCancelled;
bufferReady.emit(buffer);
}