2 unstable releases
0.2.0 | Mar 17, 2024 |
---|---|
0.1.0 | May 12, 2021 |
#153 in Video
3,002 downloads per month
Used in 12 crates
(2 directly)
14KB
257 lines
rfc6381-codec
Rust library for parsing and generating codec string values, as specified in RFC 6381, section 3.
Supported RFC 6381 features
-
avc1
-
mp4a
only object-type-identifier0x40
(MPEG 4 Audio) supported - other four-character-code values not supported
- generic syntax including 'charset' and 'percent-encoding' not supported
lib.rs
:
Support for codec parameter values
See also,
Basic usage
Parse a codec string,
let codec = Codec::from_str("avc1.4D401E");
if let Ok(Codec::Avc1(avc1)) = codec {
assert_eq!(avc1.profile(), 0x4d);
} else {
panic!("unexpected codec type");
}
Generate a codec string,
let codec = Codec::avc1(0x4d, 0x40, 0x1e);
assert_eq!(codec.to_string(), "avc1.4D401E")
No support for 'fancy' syntax
RFC 6381 specifies the following BNF grammar for general syntax, which this crate does not yet fully support:
codecs := cod-simple / cod-fancy
cod-simple := "codecs" "=" unencodedv
unencodedv := id-simple / simp-list
simp-list := DQUOTE id-simple *( "," id-simple ) DQUOTE
id-simple := element
; "." reserved as hierarchy delimiter
element := 1*octet-sim
octet-sim := <any TOKEN character>
; Within a 'codecs' parameter value, "." is reserved
; as a hierarchy delimiter
cod-fancy := "codecs*" "=" encodedv
encodedv := fancy-sing / fancy-list
fancy-sing := [charset] "'" [language] "'" id-encoded
; Parsers MAY ignore <language>
; Parsers MAY support only US-ASCII and UTF-8
fancy-list := DQUOTE [charset] "'" [language] "'" id-list DQUOTE
; Parsers MAY ignore <language>
; Parsers MAY support only US-ASCII and UTF-8
id-list := id-encoded *( "," id-encoded )
id-encoded := encoded-elm *( "." encoded-elm )
; "." reserved as hierarchy delimiter
encoded-elm := 1*octet-fancy
octet-fancy := ext-octet / attribute-char
DQUOTE := %x22 ; " (double quote)
In particular note the following productions:
cod-simple
- specifies the attribute name+value structurecodec=".."
— this crate only supports dealing with the value of this attribute (the bit inside quotes).cod-fancy
(and related productionsfancy-sing
/fancy-list
etc.) — show extended structures that can optionally specify a charset for the data likeen-gb'UTF-8'%25%20xz
or''%25%20xz
— this crate does not support values using these structures.
Dependencies
~195KB