Secure Reliable Transport (SRT) Socket. More...
Public Member Functions | |
SRTSocket () | |
Constructor. | |
virtual | ~SRTSocket () override |
Destructor. | |
bool | close (Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance())))) |
Close the socket. More... | |
virtual void | defineArgs (Args &args) override |
Add command line option definitions in an Args. More... | |
bool | getMessageApi () const |
Check if the SRT socket uses the Message API. More... | |
int | getSocket () const |
Get the underlying SRT socket handle (use with care). More... | |
bool | getSockOpt (int optName, const char *optNameStr, void *optval, int &optlen, Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance())))) const |
Get SRT option. More... | |
virtual bool | loadArgs (DuckContext &duck, Args &args) override |
Load arguments from command line. More... | |
bool | open (Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance())))) |
Open the socket using parameters from the command line. More... | |
bool | open (SRTSocketMode mode, const IPv4SocketAddress &local_address, const IPv4SocketAddress &remote_address, Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance())))) |
Open the socket. More... | |
bool | peerDisconnected () const |
Check if the connection was disconnected by the peer. More... | |
bool | receive (void *data, size_t max_size, size_t &ret_size, MicroSecond ×tamp, Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance())))) |
Receive a message with timestamp. More... | |
bool | receive (void *data, size_t max_size, size_t &ret_size, Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance())))) |
Receive a message. More... | |
bool | reportStatistics (SRTStatMode mode=SRTStatMode::ALL, Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance())))) |
Get statistics about the socket and report them. More... | |
bool | send (const void *data, size_t size, Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance())))) |
Send a message to the default destination address and port. More... | |
bool | setAddresses (const UString &listener_address, const UString &caller_address, const UString &local_interface=UString(), Report &report=(*(static_cast< ts::Report * >(ts::CerrReport::Instance())))) |
Preset local and remote socket addresses in string form. More... | |
size_t | totalReceivedBytes () const |
Get the total number of received bytes since the socket was opened. More... | |
size_t | totalSentBytes () const |
Get the total number of sent bytes since the socket was opened. More... | |
Static Public Member Functions | |
static UString | GetLibraryVersion () |
Get the version of the SRT library. More... | |
Secure Reliable Transport (SRT) Socket.
If the libsrt is not available during compilation of this class, all methods will fail with an error status.
|
inline |
Open the socket using parameters from the command line.
[in,out] | report | Where to report error. |
bool ts::SRTSocket::open | ( | SRTSocketMode | mode, |
const IPv4SocketAddress & | local_address, | ||
const IPv4SocketAddress & | remote_address, | ||
Report & | report = (*(static_cast< ts::Report * >(ts::CerrReport::Instance()))) |
||
) |
Open the socket.
[in] | mode | SRT socket mode. If set to DEFAULT, the mode must have been specified in the command line options. |
[in] | local_address | Local socket address. Ignored in DEFAULT mode. Optional local IP address used in CALLER mode. |
[in] | remote_address | Remote socket address. Ignored in DEFAULT and LISTENER modes. |
[in,out] | report | Where to report error. |
bool ts::SRTSocket::close | ( | Report & | report = (*(static_cast< ts::Report * >(ts::CerrReport::Instance()))) | ) |
Close the socket.
[in,out] | report | Where to report error. |
|
overridevirtual |
Add command line option definitions in an Args.
[in,out] | args | Command line arguments to update. |
Implements ts::ArgsSupplierInterface.
|
overridevirtual |
Load arguments from command line.
Args error indicator is set in case of incorrect arguments.
[in,out] | duck | TSDuck execution context. |
[in,out] | args | Command line arguments. |
Implements ts::ArgsSupplierInterface.
|
inline |
Preset local and remote socket addresses in string form.
[in] | listener_address | Local "[address:]port". |
[in] | caller_address | Remote "address:port". |
[in] | local_interface | Optional, can be empty. In caller mode, specify the local outgoing IP address. |
[in,out] | report | Where to report error. |
bool ts::SRTSocket::send | ( | const void * | data, |
size_t | size, | ||
Report & | report = (*(static_cast< ts::Report * >(ts::CerrReport::Instance()))) |
||
) |
Send a message to the default destination address and port.
[in] | data | Address of the message to send. |
[in] | size | Size in bytes of the message to send. |
[in,out] | report | Where to report error. |
bool ts::SRTSocket::receive | ( | void * | data, |
size_t | max_size, | ||
size_t & | ret_size, | ||
Report & | report = (*(static_cast< ts::Report * >(ts::CerrReport::Instance()))) |
||
) |
Receive a message.
[out] | data | Address of the buffer for the received message. |
[in] | max_size | Size in bytes of the reception buffer. |
[out] | ret_size | Size in bytes of the received message. Will never be larger than max_size. |
[in,out] | report | Where to report error. |
bool ts::SRTSocket::receive | ( | void * | data, |
size_t | max_size, | ||
size_t & | ret_size, | ||
MicroSecond & | timestamp, | ||
Report & | report = (*(static_cast< ts::Report * >(ts::CerrReport::Instance()))) |
||
) |
Receive a message with timestamp.
[out] | data | Address of the buffer for the received message. |
[in] | max_size | Size in bytes of the reception buffer. |
[out] | ret_size | Size in bytes of the received message. Will never be larger than max_size. |
[out] | timestamp | Source timestamp in micro-seconds, negative if not available. |
[in,out] | report | Where to report error. |
size_t ts::SRTSocket::totalSentBytes | ( | ) | const |
Get the total number of sent bytes since the socket was opened.
size_t ts::SRTSocket::totalReceivedBytes | ( | ) | const |
Get the total number of received bytes since the socket was opened.
bool ts::SRTSocket::peerDisconnected | ( | ) | const |
Check if the connection was disconnected by the peer.
This can be used after a send/receive error to differentiate between "end of session" and actual error.
bool ts::SRTSocket::reportStatistics | ( | SRTStatMode | mode = SRTStatMode::ALL , |
Report & | report = (*(static_cast< ts::Report * >(ts::CerrReport::Instance()))) |
||
) |
Get statistics about the socket and report them.
[in] | mode | Type of statistics to report (or'ing bitmask values is allowed). |
[in,out] | report | Where to report statistics and errors. |
bool ts::SRTSocket::getSockOpt | ( | int | optName, |
const char * | optNameStr, | ||
void * | optval, | ||
int & | optlen, | ||
Report & | report = (*(static_cast< ts::Report * >(ts::CerrReport::Instance()))) |
||
) | const |
Get SRT option.
[in] | optName | Option name as enumeration. The possible values for optName are given by the enumeration type SRT_SOCKOPT in libsrt. The profile of this method uses "int" to remain portable in the absence of libsrt, but the actual values come from SRT_SOCKOPT in libsrt. |
[in] | optNameStr | Option name as ASCII string. |
[out] | optval | Address of returned value. |
[in,out] | optlen | Size of returned buffer (input), updated to size of returned value. |
[in,out] | report | Where to report error. |
int ts::SRTSocket::getSocket | ( | ) | const |
Get the underlying SRT socket handle (use with care).
This method is reserved for low-level operations and should not be used by normal applications.
bool ts::SRTSocket::getMessageApi | ( | ) | const |
Check if the SRT socket uses the Message API.
|
static |
Get the version of the SRT library.