![]() |
TSDuck v3.44-4659
MPEG Transport Stream Toolkit
|
Secure Reliable Transport (SRT) Socket. More...
#include <tsSRTSocket.h>


Public Member Functions | |
| SRTSocket (Report *report) | |
| Constructor. | |
| virtual | ~SRTSocket () override |
| Destructor. | |
| bool | close (bool silent=false) |
| Close the socket. | |
| void | defineArgs (Args &args) |
| Add command line option definitions in an Args. | |
| bool | getMessageApi () const |
| Check if the SRT socket uses the Message API. | |
| bool | getPeers (IPSocketAddress &local, IPSocketAddress &remote) |
| Get the socket peers, local and remote. | |
| int | getSocket () const |
| Get the underlying SRT socket handle (use with care). | |
| bool | getSockOpt (int optName, const char *optNameStr, void *optval, int &optlen) const |
| Get SRT option. | |
| bool | loadArgs (DuckContext &duck, Args &args) |
| Load arguments from command line. | |
| bool | muteReport (bool mute) |
| Temporarily mute the associated report. | |
| bool | open (size_t max_payload=NPOS) |
| Open the socket using parameters from the command line. | |
| bool | open (SRTSocketMode mode, const IPSocketAddress &local, const IPSocketAddress &remote, size_t max_payload=NPOS) |
| Open the socket. | |
| bool | peerDisconnected () const |
| Check if the connection was disconnected by the peer. | |
| bool | receive (void *data, size_t max_size, size_t &ret_size) |
| Receive a message. | |
| bool | receive (void *data, size_t max_size, size_t &ret_size, cn::microseconds ×tamp) |
| Receive a message with timestamp. | |
| Report & | report () const |
| Access the Report which is associated with this object. | |
| bool | reportStatistics (SRTStatMode mode=SRTStatMode::ALL) |
| Get statistics about the socket and report them. | |
| bool | send (const void *data, size_t size) |
| Send a message to the default destination address and port. | |
| bool | setAddresses (const IPSocketAddress &listener, const IPSocketAddress &caller, const IPAddress &local=IPAddress()) |
| Preset local and remote socket addresses in string form. | |
| Report * | setReport (Report *report) |
| Associate this object with another Report to log errors. | |
| ReporterBase * | setReport (ReporterBase *delegate) |
| Associate this object with another ReporterBase to log errors. | |
| size_t | totalReceivedBytes () const |
| Get the total number of received bytes since the socket was opened. | |
| size_t | totalSentBytes () const |
| Get the total number of sent bytes since the socket was opened. | |
Static Public Member Functions | |
| static UString | GetLibraryVersion () |
| Get the version of the SRT library. | |
| static int | SilentLevel (bool silent) |
| Compute a log severity level from a "silent" parameter. | |
Secure Reliable Transport (SRT) Socket.
If the libsrt is not available during compilation of this class, all methods will fail with an error status.
|
explicit |
Constructor.
| [in] | report | Where to report errors. The report object must remain valid as long as this object exists or setReport() is used with another Report object. If report is null, log messages are discarded. |
|
inline |
Open the socket using parameters from the command line.
| [in] | max_payload | Maximum payload size in bytes. Unset if NPOS. |
| bool ts::SRTSocket::open | ( | SRTSocketMode | mode, |
| const IPSocketAddress & | local, | ||
| const IPSocketAddress & | remote, | ||
| size_t | max_payload = NPOS |
||
| ) |
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 | Local socket address. Ignored in DEFAULT mode. Optional local IP address used in CALLER mode. |
| [in] | remote | Remote socket address. Ignored in DEFAULT and LISTENER modes. |
| [in] | max_payload | Maximum payload size in bytes. Unset if NPOS. |
| bool ts::SRTSocket::close | ( | bool | silent = false | ) |
Close the socket.
| [in] | silent | If true, do not report errors through the logger. This is typically useful when the socket is in some error condition and closing it is necessary although it may generate additional meaningless errors. |
| void ts::SRTSocket::defineArgs | ( | Args & | args | ) |
Add command line option definitions in an Args.
| [in,out] | args | Command line arguments to update. |
| bool ts::SRTSocket::loadArgs | ( | DuckContext & | duck, |
| Args & | args | ||
| ) |
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. |
|
inline |
Preset local and remote socket addresses in string form.
| [in] | listener | Local "[address:]port". |
| [in] | caller | Remote "address:port". |
| [in] | local | Optional, can be empty. In caller mode, specify the local outgoing IP address. |
| bool ts::SRTSocket::getPeers | ( | IPSocketAddress & | local, |
| IPSocketAddress & | remote | ||
| ) |
Get the socket peers, local and remote.
| [out] | local | Local socket address. |
| [out] | remote | Remote socket address. |
| bool ts::SRTSocket::send | ( | const void * | data, |
| size_t | size | ||
| ) |
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. |
| bool ts::SRTSocket::receive | ( | void * | data, |
| size_t | max_size, | ||
| size_t & | ret_size | ||
| ) |
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. |
| bool ts::SRTSocket::receive | ( | void * | data, |
| size_t | max_size, | ||
| size_t & | ret_size, | ||
| cn::microseconds & | timestamp | ||
| ) |
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. |
| 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 | ) |
Get statistics about the socket and report them.
| [in] | mode | Type of statistics to report (or'ing bitmask values is allowed). |
| bool ts::SRTSocket::getSockOpt | ( | int | optName, |
| const char * | optNameStr, | ||
| void * | optval, | ||
| int & | optlen | ||
| ) | 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. |
| 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.
|
inherited |
Associate this object with another Report to log errors.
| [in] | report | Where to report errors. The report object must remain valid as long as this object exists or setReport() is used with another Report object. If report is null, log messages are discarded. |
|
inherited |
Associate this object with another ReporterBase to log errors.
| [in] | delegate | Use the report of another ReporterBase. If delegate is null, the previous explicit Report is used.. |
|
inherited |
Temporarily mute the associated report.
| [in] | mute | It true, report() will return a null report (log messages are discarded), until muteReport() is invoked again with mute set to false. |
|
inlinestaticinherited |
Compute a log severity level from a "silent" parameter.
Some subclass methods have a "silent" parameter to avoid reporting errors which may be insignificant, typically when closing a device after an error, in which case the close operation may produce other errors if the previous error left the device in an inconsistent state. While those errors should not be displayed as errors, we still display them at debug level.
| [in] | silent | If true, do not report errors, report debug messages instead. |