diff options
author | Ciro Nishiguchi <ciro.nishiguchi@ni.com> | 2019-03-25 12:41:34 -0500 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2019-11-26 11:49:18 -0800 |
commit | 9c2d90292b9a613fb290c5a04e99014d1a9118ab (patch) | |
tree | e240e14d30e0d40e0a1b4f8aff12542d1efb4ba8 /host/include | |
parent | 6ec8cf3eeac70d4458ad7a4f7f1eea4f082c140d (diff) | |
download | uhd-9c2d90292b9a613fb290c5a04e99014d1a9118ab.tar.gz uhd-9c2d90292b9a613fb290c5a04e99014d1a9118ab.tar.bz2 uhd-9c2d90292b9a613fb290c5a04e99014d1a9118ab.zip |
uhd: add new transport interface and base class implementation
New interface aimed to replace zero_copy_if for new code, including new
RFNoC development and redesign of streamer objects.
Generic implementation of send and receive transport interfaces to allow
reuse by various transport types. Derived classes implement
transport-specific functions that are invoked by the base classes
through CRTP.
Diffstat (limited to 'host/include')
-rw-r--r-- | host/include/uhd/transport/CMakeLists.txt | 1 | ||||
-rw-r--r-- | host/include/uhd/transport/frame_buff.hpp | 69 |
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 */ |