Secure Reliable Transport (SRT) Socket.
More...
#include <tsSRTSocket.h>
|
| | SRTSocket (Report *report) |
| | Constructor.
|
| |
|
virtual | ~SRTSocket () override |
| | Destructor.
|
| |
| SRTArgs & | args () |
| | Access the SRT options to modify them.
|
| |
| const SRTArgs & | args () const |
| | Access the SRT options to read them.
|
| |
| bool | close (bool silent=false) |
| | Close the socket.
|
| |
| 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 opt_name, const char *opt_name_str, void *optval, int &optlen) const |
| | Get SRT option.
|
| |
| bool | isOpen () const |
| | Check if the SRT socket is open.
|
| |
| bool | muteReport (bool mute) |
| | Temporarily mute the associated report.
|
| |
| bool | open () |
| | Open the socket using parameters from the command line.
|
| |
| bool | open (SRTSocketMode mode, const IPSocketAddress &local, const IPSocketAddress &remote) |
| | 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.
|
| |
| virtual Report & | report () const override |
| | 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.
|
| |
| 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.
|
| |
Secure Reliable Transport (SRT) Socket.
If the libsrt is not available during compilation of this class, all methods will fail with an error status.
- See also
- https://github.com/Haivision/srt
-
https://github.com/Robotweax/srt
-
https://www.srtalliance.org/
◆ SRTSocket()
| ts::SRTSocket::SRTSocket |
( |
Report * |
report | ) |
|
|
explicit |
Constructor.
- Parameters
-
| [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. |
◆ args() [1/2]
Access the SRT options to modify them.
All options must be set before opening the socket.
- Returns
- A reference to the SRT options.
◆ args() [2/2]
| const SRTArgs & ts::SRTSocket::args |
( |
| ) |
const |
|
inline |
Access the SRT options to read them.
- Returns
- A constant reference to the SRT options.
◆ isOpen()
| bool ts::SRTSocket::isOpen |
( |
| ) |
const |
Check if the SRT socket is open.
- Returns
- True if the socket is open, false otherwise.
◆ open() [1/2]
| bool ts::SRTSocket::open |
( |
| ) |
|
|
inline |
Open the socket using parameters from the command line.
- Returns
- True on success, false on error.
◆ open() [2/2]
Open the socket.
- Parameters
-
| [in] | mode | SRT socket mode. If set to DEFAULT, the mode must have been specified in the SRT 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. |
- Returns
- True on success, false on error.
◆ close()
| bool ts::SRTSocket::close |
( |
bool |
silent = false | ) |
|
Close the socket.
- Parameters
-
| [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. |
- Returns
- True on success, false on error.
◆ getPeers()
Get the socket peers, local and remote.
- Parameters
-
| [out] | local | Local socket address. |
| [out] | remote | Remote socket address. |
- Returns
- True on success, false on error.
◆ send()
| bool ts::SRTSocket::send |
( |
const void * |
data, |
|
|
size_t |
size |
|
) |
| |
Send a message to the default destination address and port.
- Parameters
-
| [in] | data | Address of the message to send. |
| [in] | size | Size in bytes of the message to send. |
- Returns
- True on success, false on error.
◆ receive() [1/2]
| bool ts::SRTSocket::receive |
( |
void * |
data, |
|
|
size_t |
max_size, |
|
|
size_t & |
ret_size |
|
) |
| |
Receive a message.
- Parameters
-
| [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. |
- Returns
- True on success, false on error.
◆ receive() [2/2]
| bool ts::SRTSocket::receive |
( |
void * |
data, |
|
|
size_t |
max_size, |
|
|
size_t & |
ret_size, |
|
|
cn::microseconds & |
timestamp |
|
) |
| |
Receive a message with timestamp.
- Parameters
-
| [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. |
- Returns
- True on success, false on error.
◆ totalSentBytes()
| size_t ts::SRTSocket::totalSentBytes |
( |
| ) |
const |
Get the total number of sent bytes since the socket was opened.
- Returns
- The total number of sent bytes since the socket was opened.
◆ totalReceivedBytes()
| size_t ts::SRTSocket::totalReceivedBytes |
( |
| ) |
const |
Get the total number of received bytes since the socket was opened.
- Returns
- The total number of received bytes since the socket was opened.
◆ peerDisconnected()
| 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.
- Returns
- True if the connection was closed by the peer.
◆ reportStatistics()
Get statistics about the socket and report them.
- Parameters
-
| [in] | mode | Type of statistics to report (or'ing bitmask values is allowed). |
- Returns
- True on success, false on error.
◆ getSockOpt()
| bool ts::SRTSocket::getSockOpt |
( |
int |
opt_name, |
|
|
const char * |
opt_name_str, |
|
|
void * |
optval, |
|
|
int & |
optlen |
|
) |
| const |
Get SRT option.
- Parameters
-
| [in] | opt_name | Option name as enumeration. The possible values for opt_name 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] | opt_name_str | 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. |
- Returns
- True on success, false on error.
◆ getSocket()
| 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.
- Returns
- The underlying SRT socket handle.
◆ GetLibraryVersion()
| static UString ts::SRTSocket::GetLibraryVersion |
( |
| ) |
|
|
static |
Get the version of the SRT library.
- Returns
- A string describing the SRT library version (or the lack of SRT support).
◆ report()
| virtual Report & ts::ReporterBase::report |
( |
| ) |
const |
|
overridevirtualinherited |
Access the Report which is associated with this object.
Can be called from another thread only if the Report object is thread-safe.
- Returns
- A reference to the associated report.
Implements ts::ReporterInterface.
◆ setReport() [1/2]
Associate this object with another Report to log errors.
- Parameters
-
| [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. |
- Returns
- The address of the previous Report object or a null pointer if there was none.
◆ setReport() [2/2]
Associate this object with another ReporterBase to log errors.
- Parameters
-
| [in] | delegate | Use the report of another ReporterBase. If delegate is null, the previous explicit Report is used.. |
- Returns
- The address of the previous ReporterBase object or a null pointer if there was none.
◆ muteReport()
| bool ts::ReporterBase::muteReport |
( |
bool |
mute | ) |
|
|
inherited |
Temporarily mute the associated report.
- Parameters
-
| [in] | mute | It true, report() will return a null report (log messages are discarded), until muteReport() is invoked again with mute set to false. |
- Returns
- Previous state of the mute field.
◆ SilentLevel()
| static int ts::ReporterBase::SilentLevel |
( |
bool |
silent, |
|
|
int |
default_severity = Severity::Error |
|
) |
| |
|
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.
- Parameters
-
| [in] | silent | If true, do not report errors, report debug messages instead. |
| [in] | default_severity | Default severity, in non-silent mode (error by default). |
- Returns
- Error when silent is false, Debug otherwise.
The documentation for this class was generated from the following file: