ToolX 1.11.1 [e3f477f]
A GUI debug tool chain for diagnosing GVA systems
Loading...
Searching...
No Matches
srt_utils.h File Reference

Helpers shared by the SRT transmit and receive tabs: connection settings, srt:// URL building, validation and the transmit to receive mapping. More...

#include <cstddef>
#include <string>
#include <QJsonObject>
Include dependency graph for srt_utils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  toolx::streams::SrtLinkConfig
 The settings of one end of an SRT link. More...
struct  toolx::streams::SrtStreamEntry
 A named SRT link, one row of the transmit or receive table. More...

Enumerations

enum class  toolx::streams::SrtConnectionMode { kCaller , kListener , kRendezvous }
 How an SRT connection is established. More...

Functions

const char * toolx::streams::srtModeName (SrtConnectionMode mode)
 The name of a connection mode as shown in the tables.
bool toolx::streams::srtModeFromName (const std::string &name, SrtConnectionMode &mode)
 Parse a connection mode name (case insensitive).
bool toolx::streams::validateSrtLink (const SrtLinkConfig &link, std::string &error)
 Check the settings of a link.
std::string toolx::streams::buildSrtUrl (const SrtLinkConfig &link)
 Build the srt:// URL for a link, with the passphrase percent encoded.
SrtLinkConfig toolx::streams::receiverFor (const SrtLinkConfig &transmit, const std::string &local_address)
 The settings of the receiving end of a link.
QJsonObject toolx::streams::srtLinkToJson (const SrtLinkConfig &link)
 The settings of a link as a JSON object for the configuration file.
SrtLinkConfig toolx::streams::srtLinkFromJson (const QJsonObject &object)
 Read the settings of a link from a JSON object.

Variables

constexpr int toolx::streams::kSrtMinPort = 1
 Lowest accepted UDP port.
constexpr int toolx::streams::kSrtMaxPort = 65535
 Highest accepted UDP port.
constexpr int toolx::streams::kSrtMaxLatencyMs = 65535
 Highest accepted latency in milliseconds.
constexpr size_t toolx::streams::kSrtMinPassphrase = 10
 Shortest accepted passphrase.
constexpr size_t toolx::streams::kSrtMaxPassphrase = 79
 Longest accepted passphrase.

Detailed Description

Helpers shared by the SRT transmit and receive tabs: connection settings, srt:// URL building, validation and the transmit to receive mapping.

Enumeration Type Documentation

◆ SrtConnectionMode

How an SRT connection is established.

Enumerator
kCaller 

Connect to a listening peer.

kListener 

Wait for a caller.

kRendezvous 

Both peers connect to each other at the same time.

Function Documentation

◆ buildSrtUrl()

std::string toolx::streams::buildSrtUrl ( const SrtLinkConfig & link)

Build the srt:// URL for a link, with the passphrase percent encoded.

Parameters
linkthe settings, validated with validateSrtLink()
Returns
std::string the URL accepted by mediax::srt::ParseSrtUrl()

◆ receiverFor()

SrtLinkConfig toolx::streams::receiverFor ( const SrtLinkConfig & transmit,
const std::string & local_address )

The settings of the receiving end of a link.

There is no discovery, so a transmit row is turned into the row that connects to it: a caller transmitter gets a listening receiver, a listening transmitter gets a calling receiver that connects to local_address, and a rendezvous pair swap addresses.

Parameters
transmitthe transmitting end
local_addressthe address of this machine, used when the transmitter listens
Returns
SrtLinkConfig the receiving end with the same port, latency and passphrase

◆ srtLinkFromJson()

SrtLinkConfig toolx::streams::srtLinkFromJson ( const QJsonObject & object)

Read the settings of a link from a JSON object.

Missing values keep the defaults of SrtLinkConfig, an unknown mode is a caller. The port and the latency are limited to the accepted range.

Parameters
objectthe object made by srtLinkToJson()
Returns
SrtLinkConfig the settings

◆ srtLinkToJson()

QJsonObject toolx::streams::srtLinkToJson ( const SrtLinkConfig & link)

The settings of a link as a JSON object for the configuration file.

The passphrase is stored as it is, so a file holding one must be kept private.

Parameters
linkthe settings
Returns
QJsonObject with mode, host, port, latency and passphrase

◆ srtModeFromName()

bool toolx::streams::srtModeFromName ( const std::string & name,
SrtConnectionMode & mode )

Parse a connection mode name (case insensitive).

Parameters
namethe name
modereceives the mode
Returns
true if the name was recognised

◆ srtModeName()

const char * toolx::streams::srtModeName ( SrtConnectionMode mode)

The name of a connection mode as shown in the tables.

Parameters
modethe mode
Returns
const char* "Caller", "Listener" or "Rendezvous"

◆ validateSrtLink()

bool toolx::streams::validateSrtLink ( const SrtLinkConfig & link,
std::string & error )

Check the settings of a link.

Parameters
linkthe settings
errorreceives the reason when false is returned
Returns
true if the settings can be used to open a link