pub struct ParseOptions {
pub blank_lines: bool,
pub unordered_media_lines: bool,
pub loose_fields: bool,
}Expand description
What SessionDescription::unmarshal_with_options accepts beyond the RFC 8866 grammar.
SessionDescription::unmarshal parses with ParseOptions::strict: RFC 9429 section
5.8 has a description that is not well formed rejected, so the engine’s own parsing is
the grammar and nothing else. An application that has to read what other software calls
SDP can ask for each leniency by name, or for all of them with
ParseOptions::lenient.
§What is accepted in every mode
These are the places where the parser is deliberately wider than the grammar, each for a reason:
- A line may end in a bare LF instead of CRLF. RFC 8866 section 5: “parsers SHOULD be tolerant and also accept lines terminated with a single newline character”.
- The last line may have no line ending, and empty lines may follow it. Descriptions
that went through a text field or a
trim()look like this. z=may follow at=line that has nor=line. RFC 4566 allowed it, and RFC 8866 movedz=into the repeat description; a description written to RFC 4566 still parses.k=lines are checked for syntax and dropped (RFC 8866 section 5.12: “MUST be discarded if received”).a=name:with an empty value is kept as an attribute whose value is the empty string. RFC 3611 defines one (a=rtcp-xr:), although the RFC 8866byte-stringis never empty.- An attribute this crate does not know is kept as it is, at either level (RFC 8866 section 5.13: “an attribute that is not understood MUST be ignored”). The typed accessors are where the value of a known attribute is checked.
- Several
c=lines in one media description are accepted; the last one is kept.
§What is always refused
A type letter RFC 8866 does not define (section 5: such a description is ignored or
rejected whole), a line that is not <type>=<value>, NUL, a bare CR, text that is not
UTF-8 when the description names no other set with a=charset (unmarshal, from bytes),
session-level lines out of order, and a
description without v=, o=, s= or t=.
Fields§
§blank_lines: boolSkip empty lines before and between lines, as some media players accept.
unordered_media_lines: boolAccept i=, c=, b= and k= after a= lines inside a media description. Some
gateways write them so; RFC 8866 section 5 has them “in exactly the order given”.
loose_fields: boolDo not check what the fields of a line contain beyond what the parser needs:
fields may be separated and surrounded by any run of spaces and tabs; t= times may
be any number; addresses in o= and c= need only be free of white space (and c=
may lack one); i=, e= and p= text is kept unchecked; s= may be empty; extra
fields after the stop time of t= are ignored.