#identifier #transport-stream #format #smpte #mpeg #constants #authority

smptera-format-identifiers-rust

Constants for Format Identifiers defined by the SMPTE Registration Authority

3 releases (breaking)

0.4.0 May 30, 2023
0.3.0 Apr 9, 2021
0.2.0 Jul 26, 2020

#152 in Multimedia

Download history 102/week @ 2024-01-02 247/week @ 2024-01-09 344/week @ 2024-01-16 218/week @ 2024-01-23 176/week @ 2024-01-30 359/week @ 2024-02-06 539/week @ 2024-02-13 372/week @ 2024-02-20 503/week @ 2024-02-27 313/week @ 2024-03-05 553/week @ 2024-03-12 355/week @ 2024-03-19 445/week @ 2024-03-26 468/week @ 2024-04-02 468/week @ 2024-04-09 203/week @ 2024-04-16

1,630 downloads per month
Used in 5 crates (via mpeg2ts-reader)

MIT/Apache

36KB

crates.io version Documentation Rust

Rust constants for the format Identifier values on record with the SMPTE Registration Authority for use in MPEG Transport Stream data.


lib.rs:

Format Identifier value on record with the SMPTE Registration Authority for use in MPEG Transport Stream data.

(This create is automatically generated from a mirror of the SMPTE-RA data by code in the smptera-format-identifiers-rust project.)

The simple wrapper type FormatIdentifier defines a constant for each format identifier in the SMPTE-RA data,

use std::io::stdout;
println!("{:?}", FormatIdentifier::AC_3);
// prints: FormatIdentifier(FourCC{AC-3})

Usage

Create from a slice,

let descriptor_data = b"\x05\x04CUEI";
let id = FormatIdentifier::from(&descriptor_data[2..6]);
assert_eq!(id, FormatIdentifier::CUEI);

Wrap an existing FourCC value,

let fcc = FourCC(*b"CUEI");
let id = FormatIdentifier(fcc);
assert_eq!(id, FormatIdentifier::CUEI);

Use provided constants in matches,

match FormatIdentifier::from(&descriptor_data[2..6]) {
    FormatIdentifier::CUEI => println!("SCTE-35 suspected"),
    FormatIdentifier::KLVA => println!("SMPTE RP 217-2001 KLV Packets?"),
    other_id => println!("Some other kinda stuff: {:?}", other_id),
}

Write bytes values,

let mut data = vec![];
let mut io = Cursor::new(data);

let id = &FormatIdentifier::ID3;
io.write(id.into())
    .expect("write failed");

assert_eq!(io.into_inner(), [b'I', b'D', b'3', b' ']);

Dependencies

~11KB