|
libflute
|
FLUTE transmitter class. More...
#include <Transmitter.h>
Classes | |
| class | FileDescription |
| File Description object. More... | |
Public Types | |
| using | FdtNamespace = FileDeliveryTable::FdtNamespace |
| FDT namespace enumeration. More... | |
| typedef std::function< void(uint32_t)> | completion_callback_t |
| Definition of a file transmission completion callback function that can be registered through ::register_completion_callback. More... | |
Public Member Functions | |
| 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. More... | |
| virtual | ~Transmitter () |
| Default destructor. More... | |
| const std::optional< boost::asio::ip::udp::endpoint > & | udp_tunnel_address () const |
| Get UDP Tunnel Address. More... | |
| Transmitter & | udp_tunnel_address (const boost::asio::ip::udp::endpoint &new_tunnel_endpoint) |
| Set UDP Tunnel Address. More... | |
| Transmitter & | udp_tunnel_address (boost::asio::ip::udp::endpoint &&new_tunnel_endpoint) |
| Set UDP Tunnel Address. More... | |
| Transmitter & | udp_tunnel_address (const std::optional< boost::asio::ip::udp::endpoint > &new_tunnel_endpoint) |
| Set UDP Tunnel Address. More... | |
| Transmitter & | udp_tunnel_address (std::optional< boost::asio::ip::udp::endpoint > &&new_tunnel_endpoint) |
| Set UDP Tunnel Address. More... | |
| Transmitter & | udp_tunnel_address (const std::nullopt_t &) |
| Unset UDP Tunnel Address. More... | |
| uint32_t | rate_limit () const |
| Get Maximum Bit Rate. More... | |
| Transmitter & | rate_limit (uint32_t limit) |
| Set Maximum Bit Rate. More... | |
| const boost::asio::ip::udp::endpoint & | endpoint () const |
| Get UDP Address for FLUTE session. More... | |
| Transmitter & | endpoint (const std::string &address, uint32_t port) |
| Set UDP Address for FLUTE session. More... | |
| const std::optional< boost::asio::ip::address > & | source_address () const |
| Get the optional source address for the FLUTE session. More... | |
| void | enable_ipsec (uint32_t spi, const std::string &aes_key) |
| Enable IPSEC ESP encryption of FLUTE payloads. More... | |
| 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). More... | |
| uint16_t | send (const std::shared_ptr< FileDescription > &file_description) |
| Transmit a file. More... | |
| uint64_t | seconds_since_epoch () |
| Convenience function to get the current timestamp for expiry calculation. More... | |
| void | register_completion_callback (completion_callback_t cb) |
| Register a callback for file transmission completion notifications. More... | |
| void | activate () |
| Activate the FLUTE session. More... | |
| void | deactivate () |
| Deactivate the FLUTE session. More... | |
| size_t | number_of_files () |
| Get number of files currently in queue for sending. More... | |
| Transmitter & | endpoint (const boost::asio::ip::udp::endpoint &destination) |
| Set UDP Address for FLUTE session. More... | |
| Transmitter & | endpoint (boost::asio::ip::udp::endpoint &&destination) |
| Transmitter & | source_address (const std::optional< boost::asio::ip::address > &source) |
| Set the source address for FLUTE session. More... | |
| Transmitter & | source_address (std::optional< boost::asio::ip::address > &&source) |
FLUTE transmitter class.
Construct an instance of this to send data through a FLUTE/ALC session.
The session can be active (sending packets) or inactive (sending of packets paused). This allows the FLUTE session to be suspended using the deactivate() method and later resumed using activate().
Definition at line 40 of file Transmitter.h.
| typedef std::function<void(uint32_t)> LibFlute::Transmitter::completion_callback_t |
Definition of a file transmission completion callback function that can be registered through ::register_completion_callback.
| toi | TOI of the file that has completed transmission |
Definition at line 365 of file Transmitter.h.
FDT namespace enumeration.
Definition at line 45 of file Transmitter.h.
| LibFlute::Transmitter::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, |
||
| Transmitter::FdtNamespace | fdt_namespace = FileDeliveryTable::FDT_NS_NONE, |
||
| bool | active = true, |
||
| const std::optional< std::string > & | source_address = std::nullopt |
||
| ) |
Constructor.
Creates a Transmitter object.
If tunnel_endpoint is given a value then:
destination_address is the encapsulated destination IP addresses.source_address has a value then this is used as the encapsulated source IP address, if not then the source address of the connection to tunnel_endpoint is used.If tunnel_endpoint is not given a value then:
destination_address is the destination address for the connection.source_address has a value then an attempt will be made to bind the local end of the connection to this address. If the attempt is unsuccessful then a std::runtime_error exception will be thrown.| destination_address | Target (multicast) address, if tunnel_endpoint is given then this is the encapsulated destination IP address |
| port | Target port |
| tsi | TSI value for the session |
| mtu | Path MTU to size FLUTE packets for |
| rate_limit | Transmit rate limit (in kbps) |
| io_context | Boost io_context to run the socket operations in (must be provided by the caller) |
| tunnel_endpoint | Tunnelling endpoint address (default: no tunnelling) |
| fdt_namespace | Which XML namespace to use for the FDT (default: none) |
| active | Start as active/inactive FLUTE session (default: active) |
| source_address | Source address (default: automatically assign source address) |
| boost::system::system_error | When source_address is given a value and tunnel_endpoint has no value and the address in source_address could not be bound as the local end of the connection. |
Definition at line 459 of file Transmitter.cpp.
|
virtualdefault |
Default destructor.
| auto LibFlute::Transmitter::activate | ( | ) |
Activate the FLUTE session.
If the Transmitter is currently deactivated then the state is set to active and the FLUTE stream will start transmitting. Sending of packets will start or resume until the deactivate() method is called or this Transmitter is destroyed.
Definition at line 807 of file Transmitter.cpp.
| auto LibFlute::Transmitter::deactivate | ( | ) |
Deactivate the FLUTE session.
If the Transmitter is currently active then the FLUTE stream is halted and the state is changed to deactivated. Sending of packets will be halted until the activate() method is called. Note that this will pause File transmission part way through if a File is currently being transmitted. If the application wishes for deactivation once Files have finished sending then it should only deactivate() when the completion callback is called and number_of_files() equals 0 to ensure all Files have been completely transmitted.
Definition at line 816 of file Transmitter.cpp.
| auto LibFlute::Transmitter::enable_ipsec | ( | uint32_t | spi, |
| const std::string & | aes_key | ||
| ) |
Enable IPSEC ESP encryption of FLUTE payloads.
| spi | Security Parameter Index value to use |
| aes_key | AES key as a hex string (without leading 0x). Must be an even number of characters long. |
Definition at line 600 of file Transmitter.cpp.
|
inline |
Get UDP Address for FLUTE session.
Gets the destination address for the FLUTE session packets. If the UDP tunnel address is set then the packets will be tunnelled to the UDP tunnel address, otherwise packets are sent directly to the destination address.
Definition at line 494 of file Transmitter.h.
| auto LibFlute::Transmitter::endpoint | ( | boost::asio::ip::udp::endpoint && | destination | ) |
Definition at line 576 of file Transmitter.cpp.
| auto LibFlute::Transmitter::endpoint | ( | const boost::asio::ip::udp::endpoint & | destination | ) |
Set UDP Address for FLUTE session.
Sets the destination address for FLUTE session packets. If the UDP Tunnel Address is not set then FLUTE packets will be sent directly to this UDP endpoint. When a UDP Tunnel Address is set then FLUTE packets with this destination will be tunnelled to the UDP Tunnel Address.
| destination | The UDP endpoint to set as the FLUTE packet destination address and port. |
Definition at line 570 of file Transmitter.cpp.
| auto LibFlute::Transmitter::endpoint | ( | const std::string & | address, |
| uint32_t | port | ||
| ) |
Set UDP Address for FLUTE session.
Sets the destination address for FLUTE session packets. If the UDP Tunnel Address is not set then FLUTE packets will be sent directly to this UDP endpoint. When a UDP Tunnel Address is set then FLUTE packets with this destination will be tunnelled to the UDP Tunnel Address.
| address | The IP address or hostname to set as the FLUTE packet destination address. |
| port | The UDP port number to set as the FLUTE packet destination UDP port. |
Definition at line 565 of file Transmitter.cpp.
|
inline |
Get number of files currently in queue for sending.
Definition at line 635 of file Transmitter.h.
|
inline |
Get Maximum Bit Rate.
Returns the maximum bit rate (MBR) value that the Transmitter is using. A 0 MBR means no limit.
Definition at line 474 of file Transmitter.h.
|
inline |
Set Maximum Bit Rate.
Sets the MBR for transmission. A value of 0 indicates no rate limit.
| limit | The new MBR to set. |
Definition at line 484 of file Transmitter.h.
|
inline |
Register a callback for file transmission completion notifications.
| cb | Function to call on file completion |
Definition at line 609 of file Transmitter.h.
| auto LibFlute::Transmitter::seconds_since_epoch | ( | ) |
Convenience function to get the current timestamp for expiry calculation.
Definition at line 611 of file Transmitter.cpp.
| uint16_t LibFlute::Transmitter::send | ( | const std::shared_ptr< FileDescription > & | file_description | ) |
Transmit a file.
The caller must ensure the file description passed here remains valid until the completion callback for this file description is called.
The file description object passed in file_description may be updated by the Transmitter until the completion callback for this file description is called.
If a file description is reused then the TOI of the previous use is reused. This allows resends or updates to existing files to be transmitted.
| file_description | The file description object for the file to send |
| auto LibFlute::Transmitter::send | ( | const std::string & | content_location, |
| const std::string & | content_type, | ||
| uint32_t | expires, | ||
| char * | data, | ||
| size_t | length | ||
| ) |
Transmit a file (deprecated).
The caller must ensure the data buffer passed here remains valid until the completion callback for this file is called.
| content_location | URI to set in the content location field of the generated FDT entry |
| content_type | MIME type to set in the content type field of the generated FDT entry |
| expires | Expiry timestamp (based on NTP epoch) |
| data | Pointer to the data buffer (managed by caller) |
| length | Length of the data buffer (in bytes) |
Definition at line 643 of file Transmitter.cpp.
|
inline |
Get the optional source address for the FLUTE session.
Definition at line 531 of file Transmitter.h.
| auto LibFlute::Transmitter::source_address | ( | const std::optional< boost::asio::ip::address > & | source | ) |
Set the source address for FLUTE session.
Sets the optional source address to use for FLUTE session packets. If the UDP Tunnel Address is not set then the outgoing socket will be bound to this address, if set. When a UDP Tunnel Address is set then this provides the source address for encapsulated packets. If the source address is not set then a local address will be selected automatically.
| source | The IP source address to use for FLUTE packets. |
| boost::system::system_error | If UDP tunnel is not used and the UDP socket cannot be bound to source. |
Definition at line 582 of file Transmitter.cpp.
| auto LibFlute::Transmitter::source_address | ( | std::optional< boost::asio::ip::address > && | source | ) |
Definition at line 591 of file Transmitter.cpp.
|
inline |
Get UDP Tunnel Address.
Definition at line 416 of file Transmitter.h.
| auto LibFlute::Transmitter::udp_tunnel_address | ( | boost::asio::ip::udp::endpoint && | new_tunnel_endpoint | ) |
Set UDP Tunnel Address.
Sets the UDP tunnel endpoint to be new_tunnel_endpoint. This moves the value from new_tunnel_endpoint.
| new_tunnel_endpoint | The new UDP tunnel endpoint to set. |
Definition at line 525 of file Transmitter.cpp.
| auto LibFlute::Transmitter::udp_tunnel_address | ( | const boost::asio::ip::udp::endpoint & | new_tunnel_endpoint | ) |
Set UDP Tunnel Address.
Sets the UDP tunnel endpoint to be a copy of new_tunnel_endpoint.
| new_tunnel_endpoint | The new UDP tunnel endpoint to set. |
Definition at line 520 of file Transmitter.cpp.
| auto LibFlute::Transmitter::udp_tunnel_address | ( | const std::nullopt_t & | ) |
Unset UDP Tunnel Address.
Removes the UDP tunnel endpoint. If the stream is active then it will switch back to multicast transmission.
Definition at line 560 of file Transmitter.cpp.
| auto LibFlute::Transmitter::udp_tunnel_address | ( | const std::optional< boost::asio::ip::udp::endpoint > & | new_tunnel_endpoint | ) |
Set UDP Tunnel Address.
Sets the UDP tunnel endpoint to be a copy of the optional new_tunnel_endpoint.
| new_tunnel_endpoint | The optional UDP tunnel endpoint to set. |
Definition at line 530 of file Transmitter.cpp.
| auto LibFlute::Transmitter::udp_tunnel_address | ( | std::optional< boost::asio::ip::udp::endpoint > && | new_tunnel_endpoint | ) |
Set UDP Tunnel Address.
Sets the UDP tunnel endpoint to be the optional new_tunnel_endpoint. This moves the value from new_tunnel_endpoint.
| new_tunnel_endpoint | The optional UDP tunnel endpoint to set. |
Definition at line 535 of file Transmitter.cpp.