aboutsummaryrefslogtreecommitdiffstats
path: root/host/include
diff options
context:
space:
mode:
Diffstat (limited to 'host/include')
-rw-r--r--host/include/uhd/transport/CMakeLists.txt1
-rw-r--r--host/include/uhd/transport/frame_buff.hpp69
2 files changed, 70 insertions, 0 deletions
diff --git a/host/include/uhd/transport/CMakeLists.txt b/host/include/uhd/transport/CMakeLists.txt
index d0810e502..400b3db0b 100644
--- a/host/include/uhd/transport/CMakeLists.txt
+++ b/host/include/uhd/transport/CMakeLists.txt
@@ -10,6 +10,7 @@ UHD_INSTALL(FILES
bounded_buffer.ipp
buffer_pool.hpp
chdr.hpp
+ frame_buff.hpp
if_addrs.hpp
udp_constants.hpp
udp_simple.hpp
diff --git a/host/include/uhd/transport/frame_buff.hpp b/host/include/uhd/transport/frame_buff.hpp
new file mode 100644
index 000000000..c335f0c4b
--- /dev/null
+++ b/host/include/uhd/transport/frame_buff.hpp
@@ -0,0 +1,69 @@
+//
+// Copyright 2019 Ettus Research, a National Instruments Brand
+//
+// SPDX-License-Identifier: GPL-3.0-or-later
+//
+
+#ifndef INCLUDED_UHD_TRANSPORT_FRAME_BUFF_HPP
+#define INCLUDED_UHD_TRANSPORT_FRAME_BUFF_HPP
+
+#include <memory>
+
+namespace uhd { namespace transport {
+
+/*!
+ * Contains a reference to a frame buffer managed by a link.
+ */
+class frame_buff
+{
+public:
+ /*!
+ * No-op deleter to prevent unique_ptr from deleting the buffer if the
+ * pointer goes out of scope. The lifetime of the buffers is controlled
+ * by the links.
+ */
+ struct deleter
+ {
+ void operator()(frame_buff*) {}
+ };
+
+ using uptr = std::unique_ptr<frame_buff, deleter>;
+
+ /*!
+ * Get the raw data buffer contained within the frame buffer
+ * \return a pointer to the buffer memory.
+ */
+ void* data() const
+ {
+ return _data;
+ }
+
+ /*!
+ * Returns the size of the packet
+ * \return the size of the packet contained in the frame buffer, in bytes.
+ */
+ size_t packet_size() const
+ {
+ return _packet_size;
+ }
+
+ /*!
+ * Sets the size of the packet contained in the frame buffer, in bytes.
+ * \param size Number of bytes occupied in the buffer
+ */
+ void set_packet_size(size_t size)
+ {
+ _packet_size = size;
+ }
+
+protected:
+ /*! Pointer to data of current frame */
+ void* _data = nullptr;
+
+ /*! Size of packet in current frame */
+ size_t _packet_size = 0;
+};
+
+}} // namespace uhd::transport
+
+#endif /* INCLUDED_UHD_TRANSPORT_FRAME_BUFF_HPP */