webrtc_sdp_lex (webrtc v0.1.0)
View SourceLexical helpers shared by the SDP codec modules.
Character classes follow the ABNF of RFC 8866 §9 (token, byte-string, non-ws-string), RFC 8839 §5.1 (ice-char) and RFC 8851 (rid-id). Every parser here returns {ok, Value} or error and never raises on malformed input.
Summary
Functions
Raise {invalid_sdp, {What, Value}} unless Value is a binary that can sit on a single SDP line. Used on the encode path to prevent line injection.
Encode a non-negative integer.
ice-char string (RFC 8839): ALPHA / DIGIT / "+" / "/".
non-ws-string: one or more VCHAR or bytes 0x80-0xFF.
rid-id (RFC 8851): 1*(alpha-numeric / "-" / "_").
byte-string (any byte except NUL, CR, LF), possibly empty.
token of RFC 8866: one or more token-char.
ASCII lowercase, byte by byte.
Parse a connection or candidate address: IPv4, IPv6 or FQDN (RFC 8866 unicast-address without extn-addr). The presence of a colon selects IPv6 (RFC 8839 §5.1).
Parse 1*DIGIT (at most 20 digits).
Parse non-zero-int-or-real (RFC 8866 §9), as used by ptime, maxptime and framerate. Integers stay integers.
Split at the first occurrence of Sep.
Split on single spaces. Returns error on empty fields, so doubled, leading or trailing spaces are rejected.
Strip leading and trailing spaces and tabs. Works on bytes, so input that is not valid UTF-8 is fine.
Types
-type address() :: inet:ip_address() | binary().
Functions
Raise {invalid_sdp, {What, Value}} unless Value is a binary that can sit on a single SDP line. Used on the encode path to prevent line injection.
-spec int(non_neg_integer()) -> binary().
Encode a non-negative integer.
ice-char string (RFC 8839): ALPHA / DIGIT / "+" / "/".
non-ws-string: one or more VCHAR or bytes 0x80-0xFF.
rid-id (RFC 8851): 1*(alpha-numeric / "-" / "_").
byte-string (any byte except NUL, CR, LF), possibly empty.
token of RFC 8866: one or more token-char.
ASCII lowercase, byte by byte.
Parse a connection or candidate address: IPv4, IPv6 or FQDN (RFC 8866 unicast-address without extn-addr). The presence of a colon selects IPv6 (RFC 8839 §5.1).
-spec parse_int(binary()) -> {ok, non_neg_integer()} | error.
Parse 1*DIGIT (at most 20 digits).
-spec parse_int(binary(), integer(), integer() | infinity) -> {ok, non_neg_integer()} | error.
Parse non-zero-int-or-real (RFC 8866 §9), as used by ptime, maxptime and framerate. Integers stay integers.
Split at the first occurrence of Sep.
Split on single spaces. Returns error on empty fields, so doubled, leading or trailing spaces are rejected.
Strip leading and trailing spaces and tabs. Works on bytes, so input that is not valid UTF-8 is fine.