1use super::RtcpFb;
42
43#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
46pub enum MuxCategory {
47 Normal,
49 Caution,
51 Identical,
54 Sum,
56 Transport,
58 Inherit,
60 IdenticalPerPt,
62 Special,
64 Tbd,
66}
67
68#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
70pub enum AttributeLevel {
71 Session,
73 Media,
75 Both,
77 Source,
79}
80
81impl AttributeLevel {
82 pub fn allows_session(self) -> bool {
84 matches!(self, AttributeLevel::Session | AttributeLevel::Both)
85 }
86
87 pub fn allows_media(self) -> bool {
89 matches!(self, AttributeLevel::Media | AttributeLevel::Both)
90 }
91}
92
93#[derive(Debug, Clone, Copy, PartialEq, Eq)]
95pub struct AttributeInfo {
96 pub name: &'static str,
98 pub level: Option<AttributeLevel>,
100 pub category: MuxCategory,
102 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
127pub 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
416pub 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
426pub fn category(name: &str) -> Option<MuxCategory> {
428 attribute(name).map(|row| row.category)
429}
430
431pub 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
441pub 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
452pub 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
472pub 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
484pub 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
492pub 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}