Roc Toolkit internal modules
Roc Toolkit: real-time audio streaming
|
URIs and addresses. More...
Classes | |
class | EndpointUri |
Network endpoint URI. More... | |
class | endpoint_uri_to_str |
Convert EndpointUri to string. More... | |
class | IoUri |
Audio file or device URI. More... | |
class | io_uri_to_str |
Convert IoUri to string. More... | |
struct | ProtocolAttrs |
Protocol attributes. More... | |
class | ProtocolMap |
Protocol attributes map. More... | |
class | socket_addr_to_str |
Convert network address to string. More... | |
class | SocketAddr |
Socket address. More... | |
Enumerations | |
enum | AddrFamily { Family_Unknown = 0 , Family_IPv4 , Family_IPv6 } |
Address family. More... | |
enum | Interface { Iface_Invalid , Iface_Consolidated , Iface_AudioSource , Iface_AudioRepair , Iface_AudioControl , Iface_Max } |
Interface ID. More... | |
enum | PctMode { PctNonUnreserved , PctNonHost , PctNonPath } |
Percent-encoding mode. More... | |
enum | Protocol { Proto_None , Proto_RTSP , Proto_RTP , Proto_RTP_RS8M_Source , Proto_RS8M_Repair , Proto_RTP_LDPC_Source , Proto_LDPC_Repair , Proto_RTCP } |
Protocol ID. More... | |
Functions | |
const char * | addr_family_to_str (AddrFamily family) |
Convert address family to string. More... | |
ROC_ATTR_NODISCARD bool | parse_endpoint_uri (const char *str, EndpointUri::Subset subset, EndpointUri &result) |
Parse EndpointUri from string. More... | |
ROC_ATTR_NODISCARD bool | format_endpoint_uri (const EndpointUri &uri, EndpointUri::Subset subset, core::StringBuilder &dst) |
Format EndpointUri to string. More... | |
const char * | interface_to_str (Interface) |
Get string name of the interface. More... | |
bool | parse_io_uri (const char *str, IoUri &result) |
Parse IoUri from string. More... | |
bool | format_io_uri (const IoUri &uri, core::StringBuilder &dst) |
Format IoUri to string. More... | |
ROC_ATTR_NODISCARD bool | parse_socket_addr (const char *host, int port, SocketAddr &addr) |
Parse socket address (host and port). More... | |
ROC_ATTR_NODISCARD bool | pct_encode (core::StringBuilder &dst, const char *src, size_t src_sz, PctMode mode) |
Percent-encode an UTF-8 string. More... | |
ROC_ATTR_NODISCARD bool | pct_decode (core::StringBuilder &dst, const char *src, size_t src_sz) |
Percent-decode an UTF-8 string. More... | |
ROC_ATTR_NODISCARD bool | print_supported (core::IArena &) |
Print supported interfaces and protocols. More... | |
const char * | proto_to_str (Protocol proto) |
Get string name of the protocol. More... | |
URIs and addresses.
Address family.
Enumerator | |
---|---|
Family_Unknown | Invalid. |
Family_IPv4 | IPv4. |
Family_IPv6 | IPv6. |
Definition at line 19 of file addr_family.h.
Interface ID.
Definition at line 19 of file interface.h.
Protocol ID.
Definition at line 19 of file protocol.h.
const char* roc::address::addr_family_to_str | ( | AddrFamily | family | ) |
Convert address family to string.
ROC_ATTR_NODISCARD bool roc::address::format_endpoint_uri | ( | const EndpointUri & | uri, |
EndpointUri::Subset | subset, | ||
core::StringBuilder & | dst | ||
) |
Format EndpointUri to string.
Formats a normalized form of the URI.
The path and host parts of the URI are percent-encoded if necessary. The query field is stored in the encoded form, so it is just copied as is.
bool roc::address::format_io_uri | ( | const IoUri & | uri, |
core::StringBuilder & | dst | ||
) |
Format IoUri to string.
Formats a normalized form of the URI.
The path part of the URI is percent-encoded if necessary.
This function always uses the "file:" form (without "//") for files because this is the only form that supports both absolute and relative paths.
const char* roc::address::interface_to_str | ( | Interface | ) |
Get string name of the interface.
ROC_ATTR_NODISCARD bool roc::address::parse_endpoint_uri | ( | const char * | str, |
EndpointUri::Subset | subset, | ||
EndpointUri & | result | ||
) |
Parse EndpointUri from string.
The URI should be in the following form:
Examples:
The URI syntax is defined by RFC 3986.
The path and query fields are allowed only for some protocols.
The port field can be omitted if the protocol have standard port. Otherwise, the port can not be omitted.
The path and host fields of the URI are percent-decoded. (But the set of allowed unencoded characters is different for path and host).
The query fields of the URI is kept as is. The user is responsible to percent-decode it when necessary.
This parser does not try to perform full URI validation. For example, it does not check that path contains only allowed symbols. If it can be parsed, it will be.
bool roc::address::parse_io_uri | ( | const char * | str, |
IoUri & | result | ||
) |
Parse IoUri from string.
The URI should be in one of the following forms:
Where:
Examples:
The URI syntax is defined by RFC 8089 and RFC 3986.
The path part of the URI is percent-decoded.
The RFC allows usages of file:// URIs both for local and remote files. Local files should use either empty or special "localhost" hostname. This parser only recognizes these two variants; other hostnames will be considered as a parsing error.
The RFC allows only absolute paths in file:// URIs. This parser additionally allows relative paths, but only in the "file:" form (without "//"). Relative paths are not allowed in the "file://" form (with "//") because it would lead to an ambiguity.
This parser also allows a non-standard "-" path for stdin/stdout.
This parser does not try to perform full URI validation. For example, it does not check that path contains only allowed symbols. If it can be parsed, it will be.
ROC_ATTR_NODISCARD bool roc::address::parse_socket_addr | ( | const char * | host, |
int | port, | ||
SocketAddr & | addr | ||
) |
Parse socket address (host and port).
host
string should be in one of the following forms:host
can't be parsed. ROC_ATTR_NODISCARD bool roc::address::pct_decode | ( | core::StringBuilder & | dst, |
const char * | src, | ||
size_t | src_sz | ||
) |
Percent-decode an UTF-8 string.
Parameters
dst
- destination buffersrc
- source string in UTF-8src_sz
- source string sizeROC_ATTR_NODISCARD bool roc::address::pct_encode | ( | core::StringBuilder & | dst, |
const char * | src, | ||
size_t | src_sz, | ||
PctMode | mode | ||
) |
Percent-encode an UTF-8 string.
Parameters
dst
- destination buffersrc
- source string in UTF-8src_sz
- source string sizemode
- encoding modeROC_ATTR_NODISCARD bool roc::address::print_supported | ( | core::IArena & | ) |
Print supported interfaces and protocols.
const char* roc::address::proto_to_str | ( | Protocol | proto | ) |
Get string name of the protocol.