From patchwork Wed Feb 6 06:08:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 524 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8034661023 for ; Wed, 6 Feb 2019 07:08:25 +0100 (CET) Received: from pendragon.ideasonboard.com (d51A4137F.access.telenet.be [81.164.19.127]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 2633841 for ; Wed, 6 Feb 2019 07:08:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1549433305; bh=B5M/twrOBtrd2Nb3EXgK8rTXGGs1GTb6g6u429P8jIg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=MIWAPcrFAoAbkz5uiUIeXkfmAlZhOJ1zgAJLmIhGlBAO6HOJAlIaXiKsnkZobH6Aw btCtK13tN9it+jxtXXy2NFh+PZEuMKyNNU90m08DguT3GwY6c1dWTa4IIp1A4C0Md7 ityqAH7Pwo7/2wI0bKZ1dOHYvecExoaNmkMNt3/c= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Wed, 6 Feb 2019 08:08:00 +0200 Message-Id: <20190206060818.13907-10-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.19.2 In-Reply-To: <20190206060818.13907-1-laurent.pinchart@ideasonboard.com> References: <20190206060818.13907-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 09/27] libcamera: v4l2_device: Update dequeued buffer information X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Feb 2019 06:08:26 -0000 From: Niklas Söderlund 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 --- include/libcamera/buffer.h | 8 ++++++++ src/libcamera/buffer.cpp | 26 ++++++++++++++++++++++++++ src/libcamera/v4l2_device.cpp | 10 +++++++++- 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/include/libcamera/buffer.h b/include/libcamera/buffer.h index 21a1ec4c574e..dc9aaad12a81 100644 --- a/include/libcamera/buffer.h +++ b/include/libcamera/buffer.h @@ -7,6 +7,7 @@ #ifndef __LIBCAMERA_BUFFER_H__ #define __LIBCAMERA_BUFFER_H__ +#include #include #include @@ -42,14 +43,21 @@ public: 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_; } std::vector &planes() { return planes_; } Signal completed; private: friend class BufferPool; + friend class V4L2Device; unsigned int index_; + unsigned int bytesused_; + uint64_t timestamp_; + unsigned int sequence_; std::vector planes_; }; diff --git a/src/libcamera/buffer.cpp b/src/libcamera/buffer.cpp index 5f6114cf3bc5..9ec372c2981b 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 f9839fc715f4..e8755be1f63f 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; } /**