rtci_sdp/attribute/informational.rs
1//! The informational attributes of RFC 8866 section 6: `tool`, `type`, `orient` and
2//! `quality`. WebRTC gives them no meaning; they are read and written with their grammar so
3//! an application that uses them gets them checked.
4
5use crate::attribute::string_attribute;
6use crate::grammar;
7
8string_attribute!(
9 /// `a=tool:<name and version>` (RFC 8866 section 6.3, session level): the tool that
10 /// created the description. `text`, any `byte-string`.
11 Tool,
12 "tool",
13 "a=tool",
14 |v| grammar::is_byte_string(v)
15);
16
17string_attribute!(
18 /// `a=type:<conference type>` (RFC 8866 section 6.9, session level): `broadcast`,
19 /// `meeting`, `moderated`, `test` or `H332`, case-sensitive.
20 ConferenceType,
21 "type",
22 "a=type",
23 |v| matches!(v, "broadcast" | "meeting" | "moderated" | "test" | "H332")
24);
25
26string_attribute!(
27 /// `a=orient:<orientation>` (RFC 8866 section 6.8, media level): the orientation of a
28 /// whiteboard or presentation workspace, `portrait`, `landscape` or `seascape`,
29 /// case-sensitive.
30 Orient,
31 "orient",
32 "a=orient",
33 |v| matches!(v, "portrait" | "landscape" | "seascape")
34);
35
36string_attribute!(
37 /// `a=quality:<quality>` (RFC 8866 section 6.14, media level): a suggested encoding
38 /// quality, `zero-based-integer` (0 to 10 for video, 5 being the default behaviour).
39 Quality,
40 "quality",
41 "a=quality",
42 |v| v == "0" || (grammar::is_integer(v) && v.parse::<u32>().is_ok())
43);
44
45impl Quality {
46 /// The value as a number.
47 pub fn value(&self) -> u32 {
48 // Checked by `parse`: `0` or an integer that fits.
49 self.as_str().parse().unwrap_or(0)
50 }
51}