From e94e52c0cb27f92c085da6e776af8b3d3172bbb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Date: Thu, 24 Jan 2019 23:34:51 +0100 Subject: libcamera: v4l2_device: Update dequeued buffer information MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Copy the information from the struct v4l2_buffer when dequeueing the buffer as applications need this information to make sense of the captured data. Signed-off-by: Niklas Söderlund Signed-off-by: Jacopo Mondi Signed-off-by: Kieran Bingham Signed-off-by: Laurent Pinchart --- src/libcamera/buffer.cpp | 26 ++++++++++++++++++++++++++ src/libcamera/v4l2_device.cpp | 10 +++++++++- 2 files changed, 35 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/libcamera/buffer.cpp b/src/libcamera/buffer.cpp index 5f6114cf..9ec372c2 100644 --- a/src/libcamera/buffer.cpp +++ b/src/libcamera/buffer.cpp @@ -203,6 +203,32 @@ Buffer::Buffer() * \brief A Signal to provide notifications that the specific Buffer is ready */ +/** + * \fn Buffer::bytesused() + * \brief Retrieve the number of bytes occupied by the data in the buffer + * \return Number of bytes occupied in the buffer + */ + +/** + * \fn Buffer::timestamp() + * \brief Retrieve the time when the buffer was processed + * + * The timestamp is expressed as a number number of nanoseconds since the epoch. + * + * \return Timestamp when the buffer was processed + */ + +/** + * \fn Buffer::sequence() + * \brief Retrieve the buffer sequence number + * + * The sequence number is a monotonically increasing number assigned to the + * buffer processed by the stream. Gaps in the sequence numbers indicate + * dropped frames. + * + * \return Sequence number of the buffer + */ + /** * \class BufferPool * \brief A pool of buffers diff --git a/src/libcamera/v4l2_device.cpp b/src/libcamera/v4l2_device.cpp index f9839fc7..e8755be1 100644 --- a/src/libcamera/v4l2_device.cpp +++ b/src/libcamera/v4l2_device.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -723,7 +724,14 @@ Buffer *V4L2Device::dequeueBuffer() if (--queuedBuffersCount_ == 0) fdEvent_->setEnabled(false); - return &bufferPool_->buffers()[buf.index]; + Buffer *buffer = &bufferPool_->buffers()[buf.index]; + + buffer->bytesused_ = buf.bytesused; + buffer->timestamp_ = buf.timestamp.tv_sec * 1000000000ULL + + buf.timestamp.tv_usec * 1000ULL; + buffer->sequence_ = buf.sequence; + + return buffer; } /** -- cgit v1.2.1