summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/libcamera/buffer.h8
-rw-r--r--src/libcamera/buffer.cpp26
-rw-r--r--src/libcamera/v4l2_device.cpp10
3 files changed, 43 insertions, 1 deletions
diff --git a/include/libcamera/buffer.h b/include/libcamera/buffer.h
index 21a1ec4c..dc9aaad1 100644
--- a/include/libcamera/buffer.h
+++ b/include/libcamera/buffer.h
@@ -7,6 +7,7 @@
#ifndef __LIBCAMERA_BUFFER_H__
#define __LIBCAMERA_BUFFER_H__
+#include <stdint.h>
#include <vector>
#include <libcamera/signal.h>
@@ -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<Plane> &planes() { return planes_; }
Signal<Buffer *> completed;
private:
friend class BufferPool;
+ friend class V4L2Device;
unsigned int index_;
+ unsigned int bytesused_;
+ uint64_t timestamp_;
+ unsigned int sequence_;
std::vector<Plane> planes_;
};
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
@@ -204,6 +204,32 @@ Buffer::Buffer()
*/
/**
+ * \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 <string.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
+#include <sys/time.h>
#include <unistd.h>
#include <vector>
@@ -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;
}
/**