diff options
author | Jacopo Mondi <jacopo@jmondi.org> | 2020-01-13 13:40:46 +0100 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2020-03-06 18:10:43 +0200 |
commit | 8a1f0321dc031a34e5fd19bfeefd8e95f9a6b683 (patch) | |
tree | 7af8e75093e7261d8b6d6ff9d9a2a14bc918e55e /src/libcamera/include | |
parent | 34fc1f38bd3cfb85c9888301bcafdbca2f71b6d2 (diff) |
libcamera: byte_stream_buffer: Add Span<> support
Add support to write and read a Span<> to and from the ByteStreamBuffer
class.
Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
Diffstat (limited to 'src/libcamera/include')
-rw-r--r-- | src/libcamera/include/byte_stream_buffer.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/libcamera/include/byte_stream_buffer.h b/src/libcamera/include/byte_stream_buffer.h index b5274c62..17cb0146 100644 --- a/src/libcamera/include/byte_stream_buffer.h +++ b/src/libcamera/include/byte_stream_buffer.h @@ -10,6 +10,8 @@ #include <stddef.h> #include <stdint.h> +#include <libcamera/span.h> + namespace libcamera { class ByteStreamBuffer @@ -33,12 +35,27 @@ public: { return read(reinterpret_cast<uint8_t *>(t), sizeof(*t)); } + + template<typename T> + int read(const Span<T> &data) + { + return read(reinterpret_cast<uint8_t *>(data.data()), + data.size_bytes()); + } + template<typename T> int write(const T *t) { return write(reinterpret_cast<const uint8_t *>(t), sizeof(*t)); } + template<typename T> + int write(const Span<T> &data) + { + return write(reinterpret_cast<const uint8_t *>(data.data()), + data.size_bytes()); + } + private: ByteStreamBuffer(const ByteStreamBuffer &other) = delete; ByteStreamBuffer &operator=(const ByteStreamBuffer &other) = delete; |