Skip to main content

rtci_sdp/attribute/
mux.rs

1//! The RFC 8859 multiplexing category of every SDP attribute, as data.
2//!
3//! When several m= sections share one transport (a BUNDLE group, RFC 9143), RFC 8859
4//! section 4 says for each attribute how its values in those sections relate: free
5//! ([`MuxCategory::Normal`]), equal ([`MuxCategory::Identical`]), taken from the section that
6//! sets up the transport ([`MuxCategory::Transport`]), and so on. Section 5 and the IANA
7//! tables of section 15.2 classify every attribute registered when it was written; the RFCs
8//! that registered an attribute later state its category themselves.
9//!
10//! This module is those tables: [`attribute`] for an attribute name, [`bandwidth`] for a
11//! `b=` modifier, [`rtcp_fb`] for a feedback type, [`group_semantics`] and
12//! [`ssrc_group_semantics`] for grouping semantics, [`source_attribute`] for the
13//! attributes of `a=ssrc`. It holds no logic about a description: the layer that negotiates
14//! BUNDLE asks it what to compare.
15//!
16//! # Where the tables come from
17//!
18//! * Names and categories: the "attribute-name" table of RFC 8859 section 15.2.2, which is
19//!   what IANA's registry was filled from. Entries of the form `name:value` there are
20//!   values, not attributes, and are left out.
21//! * Levels: the section 5 tables. Section 15.2.2 lists a few attributes that section 5
22//!   does not; they have no level here unless the RFC that defines them leaves no doubt
23//!   (`group`, `mid`, `depend`, `loopback`, `cs-correlation`).
24//! * `ike-setup` and `psk-fingerprint` are IDENTICAL in section 15.2.2 and CAUTION in
25//!   section 5.45; the registry table is followed. `ike-esp` and `ike-esp-udpencap` are in
26//!   section 5.45 only.
27//! * Attributes registered after RFC 8859, each with the category its own RFC gives:
28//!   `msid` (RFC 8830), `rid` (RFC 8851), `simulcast` (RFC 8853), `extmap-allow-mixed`
29//!   (RFC 8285), `rtcp-mux-only` (RFC 8858), `ice-pacing` and the re-registered ICE
30//!   attributes (RFC 8839), `end-of-candidates` (RFC 8840), `tls-id` (RFC 8842),
31//!   `sctp-port` and `max-message-size` (RFC 8841), `identity` (RFC 8827), `cryptex`
32//!   (RFC 9335), `bundle-only` (RFC 9143).
33//! * `ice-options` and `tls-id` are registered for one level, and RFC 9429 section 5.8
34//!   reads them at both, as browsers write them: their level here is
35//!   [`AttributeLevel::Both`].
36//! * The RFC 8840 row (`end-of-candidates`: either level, IDENTICAL) was written without the
37//!   RFC's text at hand; it is the one row of this table not checked against its source.
38//!
39//! `msid-semantic` and `sctpmap` were never registered and are not in the table.
40
41use super::RtcpFb;
42
43/// How the values of an attribute in the m= sections of one BUNDLE group relate (RFC 8859
44/// section 4).
45#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
46pub enum MuxCategory {
47    /// Section 4.1: independent in each m= section.
48    Normal,
49    /// Section 4.2: not advised under multiplexing; the outcome is undefined.
50    Caution,
51    /// Section 4.3: present with the same value in every bundled m= section (RFC 9143
52    /// section 7.1.3: or only in the tagged one, which then speaks for all).
53    Identical,
54    /// Section 4.4: the session value is the sum over the bundled m= sections.
55    Sum,
56    /// Section 4.5: only the value of the m= section that sets up the transport counts.
57    Transport,
58    /// Section 4.6: encapsulates other attributes, whose categories apply.
59    Inherit,
60    /// Section 4.7: the same value wherever the same payload type is repeated.
61    IdenticalPerPt,
62    /// Section 4.8: the rule is in the specification that defines the attribute.
63    Special,
64    /// Section 4.9: not analysed; not to be multiplexed.
65    Tbd,
66}
67
68/// Where an attribute may appear.
69#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
70pub enum AttributeLevel {
71    /// Session level only (`S`).
72    Session,
73    /// Media level only (`M`).
74    Media,
75    /// Either level (`B`).
76    Both,
77    /// Source level: inside `a=ssrc` (`SR`).
78    Source,
79}
80
81impl AttributeLevel {
82    /// Whether an attribute of this level may be written at the session level.
83    pub fn allows_session(self) -> bool {
84        matches!(self, AttributeLevel::Session | AttributeLevel::Both)
85    }
86
87    /// Whether an attribute of this level may be written in a media description.
88    pub fn allows_media(self) -> bool {
89        matches!(self, AttributeLevel::Media | AttributeLevel::Both)
90    }
91}
92
93/// One row of the table.
94#[derive(Debug, Clone, Copy, PartialEq, Eq)]
95pub struct AttributeInfo {
96    /// The attribute name. Names are case-sensitive.
97    pub name: &'static str,
98    /// The level, when the specifications state it.
99    pub level: Option<AttributeLevel>,
100    /// The multiplexing category.
101    pub category: MuxCategory,
102    /// Where the row comes from.
103    pub reference: &'static str,
104}
105
106use MuxCategory as C;
107
108const S: Option<AttributeLevel> = Some(AttributeLevel::Session);
109const M: Option<AttributeLevel> = Some(AttributeLevel::Media);
110const B: Option<AttributeLevel> = Some(AttributeLevel::Both);
111const SR: Option<AttributeLevel> = Some(AttributeLevel::Source);
112
113const fn row(
114    name: &'static str,
115    level: Option<AttributeLevel>,
116    category: MuxCategory,
117    reference: &'static str,
118) -> AttributeInfo {
119    AttributeInfo {
120        name,
121        level,
122        category,
123        reference,
124    }
125}
126
127/// Every attribute with a multiplexing category, sorted by name (byte order).
128pub static ATTRIBUTES: &[AttributeInfo] = &[
129    row("3GPP-Adaptation-Support", M, C::Caution, "RFC 8859"),
130    row("3GPP-Adaption-Support", None, C::Caution, "RFC 8859"),
131    row(
132        "3GPP-Asset-Information",
133        B,
134        C::Caution,
135        "RFC 8859 section 5.48",
136    ),
137    row("3GPP-Integrity-Key", S, C::Caution, "RFC 8859 section 5.48"),
138    row("3GPP-QoE-Metrics", M, C::Caution, "RFC 8859 section 5.48"),
139    row("3GPP-SDP-Auth", S, C::Caution, "RFC 8859 section 5.48"),
140    row("3GPP-SRTP-Config", M, C::Caution, "RFC 8859 section 5.48"),
141    row(
142        "3gpp-videopostdecbufsize",
143        M,
144        C::Caution,
145        "RFC 8859 section 5.48",
146    ),
147    row("3gpp.iut.replication", None, C::Tbd, "RFC 8859"),
148    row("FEC", None, C::Normal, "RFC 8859"),
149    row("FEC-OTI-extension", None, C::Tbd, "RFC 8859"),
150    row("FEC-declaration", None, C::Tbd, "RFC 8859"),
151    row("PSCid", S, C::Normal, "RFC 8859 section 5.50"),
152    row("SRTPAuthentication", M, C::Tbd, "RFC 8859 section 5.44"),
153    row("SRTPROCTxRate", M, C::Tbd, "RFC 8859 section 5.44"),
154    row("T38FaxFillBitRemoval", M, C::Tbd, "RFC 8859 section 5.52"),
155    row("T38FaxMaxBuffer", M, C::Tbd, "RFC 8859 section 5.52"),
156    row("T38FaxMaxDatagram", M, C::Tbd, "RFC 8859 section 5.52"),
157    row("T38FaxMaxIFP", M, C::Tbd, "RFC 8859 section 5.52"),
158    row("T38FaxRateManagement", M, C::Tbd, "RFC 8859 section 5.52"),
159    row("T38FaxTranscodingJBIG", M, C::Tbd, "RFC 8859 section 5.52"),
160    row("T38FaxTranscodingMMR", M, C::Tbd, "RFC 8859 section 5.52"),
161    row("T38FaxUdpEC", M, C::Tbd, "RFC 8859 section 5.52"),
162    row("T38FaxUdpECDepth", M, C::Tbd, "RFC 8859 section 5.52"),
163    row("T38FaxUdpFECMaxSpan", M, C::Tbd, "RFC 8859 section 5.52"),
164    row("T38FaxVersion", M, C::Tbd, "RFC 8859 section 5.52"),
165    row("T38MaxBitRate", M, C::Tbd, "RFC 8859 section 5.52"),
166    row("T38ModemType", M, C::Tbd, "RFC 8859 section 5.52"),
167    row("T38VendorInfo", M, C::Tbd, "RFC 8859 section 5.52"),
168    row("X-decbyterate", M, C::Caution, "RFC 8859 section 5.48"),
169    row(
170        "X-initpostdecbufperiod",
171        M,
172        C::Caution,
173        "RFC 8859 section 5.48",
174    ),
175    row(
176        "X-initpredecbufperiod",
177        M,
178        C::Caution,
179        "RFC 8859 section 5.48",
180    ),
181    row("X-predecbufsize", M, C::Caution, "RFC 8859 section 5.48"),
182    row("aal2CPS", B, C::Caution, "RFC 8859 section 5.49"),
183    row("aal2CPSSDUrate", B, C::Caution, "RFC 8859 section 5.49"),
184    row(
185        "aal2sscs3661assured",
186        B,
187        C::Caution,
188        "RFC 8859 section 5.49",
189    ),
190    row(
191        "aal2sscs3661unassured",
192        B,
193        C::Caution,
194        "RFC 8859 section 5.49",
195    ),
196    row("aal2sscs3662", B, C::Caution, "RFC 8859 section 5.49"),
197    row("aal5sscop", B, C::Caution, "RFC 8859 section 5.49"),
198    row("aalApp", B, C::Caution, "RFC 8859 section 5.49"),
199    row("aalType", B, C::Caution, "RFC 8859 section 5.49"),
200    row("abrParms", B, C::Caution, "RFC 8859 section 5.49"),
201    row("abrSetup", B, C::Caution, "RFC 8859 section 5.49"),
202    row("acap", B, C::Inherit, "RFC 8859 section 5.32"),
203    row("accept-types", M, C::Tbd, "RFC 8859 section 5.55"),
204    row("accept-wrapped-types", M, C::Tbd, "RFC 8859 section 5.55"),
205    row("acfg", M, C::Special, "RFC 8859 section 5.32"),
206    row("alt", M, C::Caution, "RFC 8859 section 5.48"),
207    row("alt-default-id", M, C::Caution, "RFC 8859 section 5.48"),
208    row("alt-group", S, C::Caution, "RFC 8859 section 5.48"),
209    row("altc", M, C::Transport, "RFC 8859 section 5.41"),
210    row("anycast", B, C::Caution, "RFC 8859 section 5.49"),
211    row("atmQOSparms", B, C::Caution, "RFC 8859 section 5.49"),
212    row("atmTrfcDesc", B, C::Caution, "RFC 8859 section 5.49"),
213    row("atmmap", B, C::Caution, "RFC 8859 section 5.49"),
214    row("bc_program", S, C::Normal, "RFC 8859 section 5.50"),
215    row("bc_service", S, C::Normal, "RFC 8859 section 5.50"),
216    row("bc_service_package", S, C::Normal, "RFC 8859 section 5.50"),
217    row("bcap", B, C::Inherit, "RFC 8859 section 5.34"),
218    row("bcastversion", S, C::Normal, "RFC 8859 section 5.44"),
219    row("bcob", B, C::Caution, "RFC 8859 section 5.49"),
220    row("bearerSigIE", B, C::Caution, "RFC 8859 section 5.49"),
221    row("bearerType", B, C::Caution, "RFC 8859 section 5.49"),
222    row("bundle-only", M, C::Normal, "RFC 9143"),
223    row("cache", B, C::Caution, "RFC 8859 section 5.49"),
224    row("calgextmap", B, C::Normal, "RFC 8859 section 5.19"),
225    row("candidate", M, C::Transport, "RFC 8859 section 5.12"),
226    row("capability", B, C::Caution, "RFC 8859 section 5.49"),
227    row("cat", S, C::Normal, "RFC 8859 section 5.1"),
228    row("cbrRate", B, C::Caution, "RFC 8859 section 5.49"),
229    row("ccap", B, C::Identical, "RFC 8859 section 5.34"),
230    row("cdsc", B, C::Normal, "RFC 8859 section 5.24"),
231    row("cfw-id", M, C::Normal, "RFC 8859 section 5.21"),
232    row("chain", B, C::Caution, "RFC 8859 section 5.49"),
233    row("channel", M, C::Normal, "RFC 8859 section 5.11"),
234    row("charset", S, C::Normal, "RFC 8859 section 5.1"),
235    row("chatroom", None, C::Tbd, "RFC 8859"),
236    row("clkrec", B, C::Caution, "RFC 8859 section 5.49"),
237    row("cmid", M, C::Normal, "RFC 8859 section 5.11"),
238    row("cname", SR, C::Normal, "RFC 8859 section 5.15"),
239    row("codecconfig", B, C::Caution, "RFC 8859 section 5.49"),
240    row("conf", M, C::Caution, "RFC 8859 section 5.4"),
241    row("confid", M, C::Tbd, "RFC 8859 section 5.27"),
242    row("connection", B, C::Transport, "RFC 8859 section 5.40"),
243    row("content", M, C::Normal, "RFC 8859 section 5.23"),
244    row("content-desc", None, C::Tbd, "RFC 8859"),
245    row("control", B, C::Caution, "RFC 8859 section 5.46"),
246    row("cpar", B, C::Inherit, "RFC 8859 section 5.24"),
247    row("cparmax", B, C::Special, "RFC 8859 section 5.24"),
248    row("cparmin", B, C::Special, "RFC 8859 section 5.24"),
249    row("cpsSDUsize", B, C::Caution, "RFC 8859 section 5.49"),
250    row("creq", B, C::Normal, "RFC 8859 section 5.32"),
251    row("cryptex", B, C::Transport, "RFC 9335"),
252    row("crypto", M, C::Transport, "RFC 8859 section 5.7"),
253    row("cs-correlation", M, C::Tbd, "RFC 8859"),
254    row("csup", B, C::Normal, "RFC 8859 section 5.32"),
255    row("curr", M, C::Caution, "RFC 8859 section 5.4"),
256    row("dccp-port", M, C::Caution, "RFC 8859 section 5.9"),
257    row("dccp-service-code", M, C::Caution, "RFC 8859 section 5.8"),
258    row("depend", M, C::IdenticalPerPt, "RFC 8859"),
259    row("des", M, C::Caution, "RFC 8859 section 5.4"),
260    row("dsel", B, C::Caution, "RFC 8859 section 5.49"),
261    row("duplication-delay", B, C::Normal, "RFC 8859 section 5.18"),
262    row("ecan", B, C::Caution, "RFC 8859 section 5.49"),
263    row("ecn-capable-rtp", M, C::Identical, "RFC 8859 section 7.4"),
264    row("eecid", B, C::Caution, "RFC 8859 section 5.49"),
265    row("end-of-candidates", B, C::Identical, "RFC 8840"),
266    row("etag", B, C::Caution, "RFC 8859 section 5.46"),
267    row("extmap", B, C::Special, "RFC 8859 section 5.13"),
268    row("extmap-allow-mixed", B, C::Identical, "RFC 8285"),
269    row("fec", B, C::Caution, "RFC 8859 section 5.49"),
270    row("fec-repair-flow", M, C::Special, "RFC 8859 section 5.22"),
271    row("fec-source-flow", M, C::Special, "RFC 8859 section 5.22"),
272    row("file-date", M, C::Tbd, "RFC 8859 section 5.28"),
273    row("file-disposition", M, C::Tbd, "RFC 8859 section 5.28"),
274    row("file-icon", M, C::Tbd, "RFC 8859 section 5.28"),
275    row("file-range", M, C::Tbd, "RFC 8859 section 5.28"),
276    row("file-selector", M, C::Tbd, "RFC 8859 section 5.28"),
277    row("file-transfer-id", M, C::Tbd, "RFC 8859 section 5.28"),
278    row("fingerprint", B, C::Transport, "RFC 8859 section 5.36"),
279    row("floorctrl", M, C::Tbd, "RFC 8859 section 5.27"),
280    row("floorid", M, C::Tbd, "RFC 8859 section 5.27"),
281    row("flute-ch", None, C::Tbd, "RFC 8859"),
282    row("flute-tsi", None, C::Tbd, "RFC 8859"),
283    row("fmtp", M, C::IdenticalPerPt, "RFC 8859 section 5.1"),
284    row("framerate", M, C::IdenticalPerPt, "RFC 8859 section 5.1"),
285    row("framesize", M, C::Caution, "RFC 8859 section 5.48"),
286    row("fsel", B, C::Caution, "RFC 8859 section 5.49"),
287    row("gc", B, C::Caution, "RFC 8859 section 5.49"),
288    row("group", S, C::Normal, "RFC 8859"),
289    row("h248item", B, C::Special, "RFC 8859 section 5.54"),
290    row("icap", B, C::Normal, "RFC 8859 section 5.34"),
291    row("ice-lite", S, C::Normal, "RFC 8859 section 5.12"),
292    row("ice-mismatch", M, C::Normal, "RFC 8839"),
293    row(
294        "ice-options",
295        B,
296        C::Normal,
297        "RFC 8839; RFC 9429 section 5.8 reads it at both levels",
298    ),
299    row("ice-pacing", S, C::Normal, "RFC 8839"),
300    row("ice-pwd", B, C::Transport, "RFC 8859 section 5.12"),
301    row("ice-ufrag", B, C::Transport, "RFC 8859 section 5.12"),
302    row("identity", S, C::Normal, "RFC 8827"),
303    row("ike-esp", B, C::Caution, "RFC 8859"),
304    row("ike-esp-udpencap", B, C::Caution, "RFC 8859"),
305    row("ike-setup", B, C::Identical, "RFC 8859 section 5.45"),
306    row("imageattr", M, C::IdenticalPerPt, "RFC 8859 section 5.17"),
307    row("inactive", B, C::Normal, "RFC 8859 section 5.1"),
308    row("ipbcp", S, C::Special, "RFC 8859 section 5.53"),
309    row("isup_usi", B, C::Caution, "RFC 8859 section 5.49"),
310    row("key-mgmt", B, C::Identical, "RFC 8859 section 5.35"),
311    row("keywds", S, C::Normal, "RFC 8859 section 5.1"),
312    row("label", M, C::Normal, "RFC 8859 section 5.5"),
313    row("lang", B, C::Normal, "RFC 8859 section 5.1"),
314    row("lcfg", B, C::Special, "RFC 8859 section 5.33"),
315    row("lij", B, C::Caution, "RFC 8859 section 5.49"),
316    row("loopback", M, C::Normal, "RFC 8859"),
317    row("loopback-mirror", M, C::Normal, "RFC 8859 section 5.29"),
318    row("loopback-source", M, C::Normal, "RFC 8859 section 5.29"),
319    row("max-message-size", M, C::Caution, "RFC 8841"),
320    row("max-size", M, C::Tbd, "RFC 8859 section 5.55"),
321    row("maxprate", B, C::Special, "RFC 8859 section 6.3"),
322    row("maxptime", M, C::IdenticalPerPt, "RFC 8859 section 5.1"),
323    row("mbms-flowid", M, C::Caution, "RFC 8859 section 5.48"),
324    row("mbms-mode", B, C::Caution, "RFC 8859 section 5.48"),
325    row("mbms-repair", B, C::Caution, "RFC 8859 section 5.48"),
326    row("mediaclk", B, C::Normal, "RFC 8859 section 5.16"),
327    row("mfcap", B, C::IdenticalPerPt, "RFC 8859 section 5.33"),
328    row("mid", M, C::Normal, "RFC 8859"),
329    row("mscap", B, C::Inherit, "RFC 8859 section 5.33"),
330    row("msid", M, C::Normal, "RFC 8830"),
331    row("msrp-cema", M, C::Tbd, "RFC 8859 section 5.26"),
332    row("mtag", B, C::Caution, "RFC 8859 section 5.46"),
333    row("multicast-rtcp", B, C::Identical, "RFC 8859 section 5.38"),
334    row("omcap", B, C::Normal, "RFC 8859 section 5.33"),
335    row("omr-codecs", M, C::Normal, "RFC 8859 section 5.51"),
336    row("omr-m-att", M, C::Normal, "RFC 8859 section 5.51"),
337    row("omr-m-bw", M, C::Normal, "RFC 8859 section 5.51"),
338    row("omr-m-cksum", M, C::Normal, "RFC 8859 section 5.51"),
339    row("omr-s-att", M, C::Normal, "RFC 8859 section 5.51"),
340    row("omr-s-bw", M, C::Normal, "RFC 8859 section 5.51"),
341    row("omr-s-cksum", M, C::Normal, "RFC 8859 section 5.51"),
342    row("onewaySel", B, C::Caution, "RFC 8859 section 5.49"),
343    row("orient", M, C::Normal, "RFC 8859 section 5.1"),
344    row("path", M, C::Tbd, "RFC 8859 section 5.55"),
345    row("pcfg", M, C::Special, "RFC 8859 section 5.32"),
346    row("portmapping-req", M, C::Caution, "RFC 8859 section 5.25"),
347    row("previous-ssrc", SR, C::Normal, "RFC 8859 section 5.15"),
348    row("profileDesc", B, C::Caution, "RFC 8859 section 5.49"),
349    row("prtfl", B, C::Caution, "RFC 8859 section 5.49"),
350    row("psk-fingerprint", B, C::Identical, "RFC 8859 section 5.45"),
351    row("ptime", M, C::IdenticalPerPt, "RFC 8859 section 5.1"),
352    row("qos-mech-recv", B, C::Transport, "RFC 8859 section 5.6"),
353    row("qos-mech-send", B, C::Transport, "RFC 8859 section 5.6"),
354    row("qosClass", B, C::Caution, "RFC 8859 section 5.49"),
355    row("quality", M, C::Normal, "RFC 8859 section 5.1"),
356    row("rams-updates", M, C::Caution, "RFC 8859 section 5.20"),
357    row("range", B, C::Caution, "RFC 8859 section 5.46"),
358    row("recvonly", B, C::Normal, "RFC 8859 section 5.1"),
359    row(
360        "remote-candidates",
361        M,
362        C::Transport,
363        "RFC 8859 section 5.12",
364    ),
365    row("repair-window", M, C::Special, "RFC 8859 section 5.22"),
366    row("resource", M, C::Normal, "RFC 8859 section 5.11"),
367    row("rid", M, C::Special, "RFC 8851"),
368    row("rmcap", B, C::IdenticalPerPt, "RFC 8859 section 5.33"),
369    row("rtcp", M, C::Transport, "RFC 8859 section 5.14"),
370    row("rtcp-fb", M, C::IdenticalPerPt, "RFC 8859 section 5.2"),
371    row("rtcp-idms", M, C::Normal, "RFC 8859 section 5.43"),
372    row("rtcp-mux", M, C::Identical, "RFC 8859 section 5.3"),
373    row("rtcp-mux-only", M, C::Identical, "RFC 8858"),
374    row("rtcp-rsize", M, C::Identical, "RFC 8859 section 5.10"),
375    row("rtcp-unicast", M, C::Identical, "RFC 8859 section 5.30"),
376    row("rtcp-xr", B, C::Normal, "RFC 8859 section 5.31"),
377    row("rtpmap", M, C::IdenticalPerPt, "RFC 8859 section 5.1"),
378    row("rtpred1", M, C::Caution, "RFC 8859 section 5.56"),
379    row("rtpred2", M, C::Caution, "RFC 8859 section 5.56"),
380    row("rtsp-ice-d-m", None, C::Tbd, "RFC 8859"),
381    row("sbc", B, C::Caution, "RFC 8859 section 5.49"),
382    row("sctp-port", M, C::Caution, "RFC 8841"),
383    row("sdplang", B, C::Normal, "RFC 8859 section 5.1"),
384    row("secondary-realm", M, C::Transport, "RFC 8859 section 5.51"),
385    row("sendonly", B, C::Normal, "RFC 8859 section 5.1"),
386    row("sendrecv", B, C::Normal, "RFC 8859 section 5.1"),
387    row("sescap", S, C::Caution, "RFC 8859 section 5.33"),
388    row("setup", B, C::Transport, "RFC 8859 section 5.40"),
389    row("silenceSupp", B, C::Caution, "RFC 8859 section 5.49"),
390    row("simulcast", M, C::Normal, "RFC 8853"),
391    row("source-filter", B, C::Identical, "RFC 8859 section 5.37"),
392    row("sqn", B, C::Normal, "RFC 8859 section 5.24"),
393    row("ssrc", M, C::Normal, "RFC 8859 section 5.15"),
394    row("ssrc-group", M, C::Normal, "RFC 8859 section 5.15"),
395    row("stc", B, C::Caution, "RFC 8859 section 5.49"),
396    row("stkmstream", B, C::Normal, "RFC 8859 section 5.44"),
397    row("structure", B, C::Caution, "RFC 8859 section 5.49"),
398    row("tcap", B, C::Inherit, "RFC 8859 section 5.32"),
399    row(
400        "tls-id",
401        B,
402        C::Identical,
403        "RFC 8842; RFC 9429 section 5.8.1 reads it at both levels",
404    ),
405    row("tool", S, C::Normal, "RFC 8859 section 5.1"),
406    row("ts-refclk", B, C::Normal, "RFC 8859 section 5.16"),
407    row("type", S, C::Normal, "RFC 8859 section 5.1"),
408    row("uiLayer1_Prot", B, C::Caution, "RFC 8859 section 5.49"),
409    row("upcc", B, C::Caution, "RFC 8859 section 5.49"),
410    row("userid", M, C::Tbd, "RFC 8859 section 5.27"),
411    row("visited-realm", M, C::Transport, "RFC 8859 section 5.51"),
412    row("vsel", B, C::Caution, "RFC 8859 section 5.49"),
413    row("zrtp-hash", M, C::Transport, "RFC 8859 section 5.39"),
414];
415
416/// The row of the attribute `name`, or `None` for an attribute without a registered
417/// multiplexing category (RFC 8859 section 4.9 treats those as TBD: not to be multiplexed
418/// until analysed; a WebRTC endpoint simply ignores an attribute it does not know).
419pub fn attribute(name: &str) -> Option<&'static AttributeInfo> {
420    ATTRIBUTES
421        .binary_search_by(|row| row.name.as_bytes().cmp(name.as_bytes()))
422        .ok()
423        .map(|index| &ATTRIBUTES[index])
424}
425
426/// The multiplexing category of the attribute `name`.
427pub fn category(name: &str) -> Option<MuxCategory> {
428    attribute(name).map(|row| row.category)
429}
430
431/// The category of a source attribute, the ones written inside `a=ssrc` (RFC 8859 section
432/// 5.15): `cname` and `previous-ssrc` are NORMAL, `fmtp` is IDENTICAL-PER-PT.
433pub fn source_attribute(name: &str) -> Option<MuxCategory> {
434    match name {
435        "cname" | "previous-ssrc" => Some(C::Normal),
436        "fmtp" => Some(C::IdenticalPerPt),
437        _ => None,
438    }
439}
440
441/// The category of a `b=` modifier (RFC 8859 section 6): `CT` is NORMAL; `AS`, `RS` and
442/// `RR` are SUM; `TIAS` is SPECIAL.
443pub fn bandwidth(bwtype: &str) -> Option<MuxCategory> {
444    match bwtype {
445        "CT" => Some(C::Normal),
446        "AS" | "RS" | "RR" => Some(C::Sum),
447        "TIAS" => Some(C::Special),
448        _ => None,
449    }
450}
451
452/// The category of an `a=rtcp-fb` line (RFC 8859 section 7): IDENTICAL-PER-PT for `ack`,
453/// `nack`, `trr-int` and `ccm` with the parameters the RFC lists, SPECIAL for
454/// `ack app` and `nack app`, IDENTICAL for `nack ecn`. `None` for a feedback type RFC 8859
455/// does not classify (`goog-remb`, `transport-cc`, ...); those follow the attribute's own
456/// category, IDENTICAL-PER-PT.
457pub fn rtcp_fb(feedback: &RtcpFb) -> Option<MuxCategory> {
458    let param = feedback.param.as_deref();
459    match (feedback.id.as_str(), param) {
460        ("ack" | "nack", Some("app")) => Some(C::Special),
461        ("nack", Some("ecn")) => Some(C::Identical),
462        ("ack", None | Some("rpsi")) => Some(C::IdenticalPerPt),
463        ("nack", None | Some("pli" | "sli" | "rpsi" | "rai" | "tllei" | "pslei")) => {
464            Some(C::IdenticalPerPt)
465        }
466        ("trr-int", _) => Some(C::IdenticalPerPt),
467        ("ccm", Some("fir" | "tmmbr" | "tstr" | "vbcm")) => Some(C::IdenticalPerPt),
468        _ => None,
469    }
470}
471
472/// The category of an `a=group` semantics (RFC 8859 section 8; RFC 9143 for `BUNDLE`):
473/// `ANAT` is CAUTION, the others NORMAL.
474pub fn group_semantics(semantics: &str) -> Option<MuxCategory> {
475    match semantics {
476        "ANAT" => Some(C::Caution),
477        "LS" | "FID" | "SRF" | "FEC" | "FEC-FR" | "CS" | "DDP" | "DUP" | "BUNDLE" => {
478            Some(C::Normal)
479        }
480        _ => None,
481    }
482}
483
484/// The category of an `a=ssrc-group` semantics (RFC 8859 section 9): all NORMAL.
485pub fn ssrc_group_semantics(semantics: &str) -> Option<MuxCategory> {
486    match semantics {
487        "FID" | "FEC" | "FEC-FR" | "DUP" => Some(C::Normal),
488        _ => None,
489    }
490}
491
492/// The category of an `a=content` value (RFC 8859 section 12): all NORMAL.
493pub fn content(tag: &str) -> Option<MuxCategory> {
494    match tag {
495        "slides" | "speaker" | "sl" | "main" | "alt" | "g.3gpp.cat" | "g.3gpp.crs" => {
496            Some(C::Normal)
497        }
498        _ => None,
499    }
500}