18 #include <boost/asio.hpp>
19 #include <boost/bind/bind.hpp>
68 FileDescription(
const std::string &content_location,
const std::string &filename);
82 FileDescription(
const std::string &content_location,
const std::vector<unsigned char> &
data);
168 bool has_tsi()
const {
return _tsi.has_value(); };
176 uint64_t
tsi()
const {
return _tsi?_tsi.value():0; };
185 uint32_t
toi()
const {
return _file_entry.
toi; };
317 const std::string &
get_etag()
const;
346 void _attach_file(
const std::string &filename);
347 void _free_file_data();
348 void _calculate_file_entry();
350 std::optional<uint64_t> _tsi;
353 std::string _filename;
397 Transmitter(
const std::string& destination_address,
398 short port, uint64_t tsi,
unsigned short mtu,
400 boost::asio::io_context& io_context,
401 const std::optional<boost::asio::ip::udp::endpoint>& tunnel_endpoint = std::nullopt,
416 const std::optional<boost::asio::ip::udp::endpoint> &
udp_tunnel_address()
const {
return _tunnel_endpoint; };
494 const boost::asio::ip::udp::endpoint &
endpoint()
const {
return _endpoint; };
531 const std::optional<boost::asio::ip::address> &
source_address()
const {
return _source_address; };
557 void enable_ipsec( uint32_t spi,
const std::string& aes_key);
575 uint16_t
send(
const std::string& content_location,
576 const std::string& content_type,
595 uint16_t
send(
const std::shared_ptr<FileDescription> &file_description);
635 size_t number_of_files() { std::lock_guard<std::mutex> guard(_files_mutex);
return _files.size(); };
639 void send_next_packet();
640 void fdt_send_tick(
const boost::system::error_code& error);
641 void start_fdt_repeat_timer();
643 void file_transmitted(uint32_t toi);
645 void handle_send_to(
const boost::system::error_code& error);
646 boost::asio::ip::udp::endpoint _endpoint;
647 std::optional<boost::asio::ip::address> _source_address;
648 boost::asio::ip::udp::socket _socket;
649 boost::asio::io_context& _io_context;
650 boost::asio::deadline_timer _send_timer;
651 boost::asio::deadline_timer _fdt_timer;
656 std::unique_ptr<FileDeliveryTable> _fdt;
657 std::map<uint32_t, std::shared_ptr<File>> _files;
658 std::mutex _files_mutex;
660 unsigned _fdt_repeat_interval = 5;
663 uint32_t _max_payload;
667 std::string _mcast_address;
669 uint32_t _rate_limit = 0;
670 std::optional<boost::asio::ip::udp::endpoint> _tunnel_endpoint = std::nullopt;
671 boost::asio::ip::address _tunnel_local_address;
FdtNamespace
FDT namespace enumeration.
FileDescription & set_content_location(const std::string &location)
Set Content-Location.
uint64_t tsi() const
Get the associated TSI value.
size_t data_length()
Get the length in bytes of the data to be transmitted.
FileDescription & set_expiry_time(const date_time_type &expiry_time)
Change the file expiry time.
const char * data()
Get the data to be transmitted.
FileDescription & set_etag(const std::string &etag)
Set the ETag value for the file.
std::chrono::system_clock::time_point date_time_type
FileDescription & toi(uint32_t val)
Set the TOI (used by the Transmitter class)
FileDescription & operator=(const FileDescription &other)
Copy operator.
FileDescription & set_content_type(const std::string &content_type)
Change the file content type.
uint32_t toi() const
Get the TOI associated with this file description.
virtual ~FileDescription()
Destructor.
FileDescription & set_content(const std::string &filename)
Change the file contents using a local file.
FileDescription & tsi(uint64_t val)
Set the TSI (used by the Transmitter class)
bool has_tsi() const
Has a Transmitter associated a TSI with this file?
const FileDeliveryTable::FileEntry & file_entry() const
Get the FDT file entry.
FileDescription & merge_fec_oti(const FecOti &fec_oti)
Merge the FecOti values.
FileDescription & set_compression(CompressionAlgorithm compression)
Set the compression algorithm.
bool operator==(const FileDescription &other) const
Equality operator.
date_time_type get_expiry_time() const
Get the currently set expiry time.
const std::string & get_etag() const
Get the current ETag value.
uint64_t seconds_since_epoch()
Convenience function to get the current timestamp for expiry calculation.
virtual ~Transmitter()
Default destructor.
size_t number_of_files()
Get number of files currently in queue for sending.
const std::optional< boost::asio::ip::udp::endpoint > & udp_tunnel_address() const
Get UDP Tunnel Address.
void deactivate()
Deactivate the FLUTE session.
Transmitter & rate_limit(uint32_t limit)
Set Maximum Bit Rate.
const std::optional< boost::asio::ip::address > & source_address() const
Get the optional source address for the FLUTE session.
std::function< void(uint32_t)> completion_callback_t
Definition of a file transmission completion callback function that can be registered through ::regis...
const boost::asio::ip::udp::endpoint & endpoint() const
Get UDP Address for FLUTE session.
uint16_t send(const std::string &content_location, const std::string &content_type, uint32_t expires, char *data, size_t length)
Transmit a file (deprecated).
void enable_ipsec(uint32_t spi, const std::string &aes_key)
Enable IPSEC ESP encryption of FLUTE payloads.
uint16_t send(const std::shared_ptr< FileDescription > &file_description)
Transmit a file.
Transmitter(const std::string &destination_address, short port, uint64_t tsi, unsigned short mtu, uint32_t rate_limit, boost::asio::io_context &io_context, const std::optional< boost::asio::ip::udp::endpoint > &tunnel_endpoint=std::nullopt, FdtNamespace fdt_namespace=FileDeliveryTable::FDT_NS_NONE, bool active=true, const std::optional< std::string > &source_address=std::nullopt)
Constructor.
void register_completion_callback(completion_callback_t cb)
Register a callback for file transmission completion notifications.
uint32_t rate_limit() const
Get Maximum Bit Rate.
void activate()
Activate the FLUTE session.
An entry for a file in the FDT.