Crate rfc6381_codec

source ·
Expand description

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 structure codec=".." — this crate only supports dealing with the value of this attribute (the bit inside quotes).
  • cod-fancy (and related productions fancy-sing / fancy-list etc.) — show extended structures that can optionally specify a charset for the data like en-gb'UTF-8'%25%20xz or ''%25%20xz — this crate does not support values using these structures.

Structs§

Enums§