use crate::descriptors::DescriptorLoop;
use crate::error::{Error, Result};
use dvb_common::{Parse, Serialize};
pub const TABLE_ID: u8 = 0x02;
pub const PID: u16 = 0x0000;
const MIN_HEADER_LEN: usize = 3;
const EXTENSION_HEADER_LEN: usize = 5;
const PCR_PID_LEN: usize = 2;
const PROG_INFO_LEN_BYTES: usize = 2;
const CRC_LEN: usize = 4;
const MIN_SECTION_LEN: usize =
MIN_HEADER_LEN + EXTENSION_HEADER_LEN + PCR_PID_LEN + PROG_INFO_LEN_BYTES + CRC_LEN;
const STREAM_HEADER_LEN: usize = 5;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[non_exhaustive]
pub enum StreamType {
Reserved,
Mpeg1Video,
Mpeg2Video,
Mpeg1Audio,
Mpeg2Audio,
PrivateSections,
PesPrivateData,
Mheg,
DsmCc,
H222_1,
Iso13818_6TypeA,
Iso13818_6TypeB,
Iso13818_6TypeC,
Iso13818_6TypeD,
Auxiliary,
AacAdts,
Mpeg4Video,
AacLatm,
SlFlexMuxPes,
SlFlexMuxSections,
SyncDownload,
MetadataPes,
MetadataSections,
MetadataDataCarousel,
MetadataObjectCarousel,
MetadataSyncDownload,
Ipmp,
H264,
Iso14496_3Audio,
Iso14496_17Text,
AuxiliaryVideo,
Svc,
Mvc,
Jpeg2000,
AdditionalViewH262,
AdditionalViewH264,
Hevc,
HevcTemporalSubset,
Mvcd,
Temi,
HevcAnnexG,
HevcAnnexGTemporal,
HevcAnnexH,
HevcAnnexHTemporal,
GreenAccessUnits,
MhasAudioMain,
MhasAudioAux,
QualityAccessUnits,
MediaOrchestration,
MctsHevc,
JpegXs,
Vvc,
VvcTemporalSubset,
Evc,
Ac3,
Scte35,
EAc3,
IpmpHigh,
ReservedRange(u8),
UserPrivate(u8),
}
impl StreamType {
#[must_use]
pub fn from_u8(v: u8) -> Self {
match v {
0x00 => Self::Reserved,
0x01 => Self::Mpeg1Video,
0x02 => Self::Mpeg2Video,
0x03 => Self::Mpeg1Audio,
0x04 => Self::Mpeg2Audio,
0x05 => Self::PrivateSections,
0x06 => Self::PesPrivateData,
0x07 => Self::Mheg,
0x08 => Self::DsmCc,
0x09 => Self::H222_1,
0x0A => Self::Iso13818_6TypeA,
0x0B => Self::Iso13818_6TypeB,
0x0C => Self::Iso13818_6TypeC,
0x0D => Self::Iso13818_6TypeD,
0x0E => Self::Auxiliary,
0x0F => Self::AacAdts,
0x10 => Self::Mpeg4Video,
0x11 => Self::AacLatm,
0x12 => Self::SlFlexMuxPes,
0x13 => Self::SlFlexMuxSections,
0x14 => Self::SyncDownload,
0x15 => Self::MetadataPes,
0x16 => Self::MetadataSections,
0x17 => Self::MetadataDataCarousel,
0x18 => Self::MetadataObjectCarousel,
0x19 => Self::MetadataSyncDownload,
0x1A => Self::Ipmp,
0x1B => Self::H264,
0x1C => Self::Iso14496_3Audio,
0x1D => Self::Iso14496_17Text,
0x1E => Self::AuxiliaryVideo,
0x1F => Self::Svc,
0x20 => Self::Mvc,
0x21 => Self::Jpeg2000,
0x22 => Self::AdditionalViewH262,
0x23 => Self::AdditionalViewH264,
0x24 => Self::Hevc,
0x25 => Self::HevcTemporalSubset,
0x26 => Self::Mvcd,
0x27 => Self::Temi,
0x28 => Self::HevcAnnexG,
0x29 => Self::HevcAnnexGTemporal,
0x2A => Self::HevcAnnexH,
0x2B => Self::HevcAnnexHTemporal,
0x2C => Self::GreenAccessUnits,
0x2D => Self::MhasAudioMain,
0x2E => Self::MhasAudioAux,
0x2F => Self::QualityAccessUnits,
0x30 => Self::MediaOrchestration,
0x31 => Self::MctsHevc,
0x32 => Self::JpegXs,
0x33 => Self::Vvc,
0x34 => Self::VvcTemporalSubset,
0x35 => Self::Evc,
0x36..=0x7E => Self::ReservedRange(v),
0x7F => Self::IpmpHigh,
0x81 => Self::Ac3,
0x86 => Self::Scte35,
0x87 => Self::EAc3,
_ => Self::UserPrivate(v),
}
}
#[must_use]
pub fn to_u8(self) -> u8 {
match self {
Self::Reserved => 0x00,
Self::Mpeg1Video => 0x01,
Self::Mpeg2Video => 0x02,
Self::Mpeg1Audio => 0x03,
Self::Mpeg2Audio => 0x04,
Self::PrivateSections => 0x05,
Self::PesPrivateData => 0x06,
Self::Mheg => 0x07,
Self::DsmCc => 0x08,
Self::H222_1 => 0x09,
Self::Iso13818_6TypeA => 0x0A,
Self::Iso13818_6TypeB => 0x0B,
Self::Iso13818_6TypeC => 0x0C,
Self::Iso13818_6TypeD => 0x0D,
Self::Auxiliary => 0x0E,
Self::AacAdts => 0x0F,
Self::Mpeg4Video => 0x10,
Self::AacLatm => 0x11,
Self::SlFlexMuxPes => 0x12,
Self::SlFlexMuxSections => 0x13,
Self::SyncDownload => 0x14,
Self::MetadataPes => 0x15,
Self::MetadataSections => 0x16,
Self::MetadataDataCarousel => 0x17,
Self::MetadataObjectCarousel => 0x18,
Self::MetadataSyncDownload => 0x19,
Self::Ipmp => 0x1A,
Self::H264 => 0x1B,
Self::Iso14496_3Audio => 0x1C,
Self::Iso14496_17Text => 0x1D,
Self::AuxiliaryVideo => 0x1E,
Self::Svc => 0x1F,
Self::Mvc => 0x20,
Self::Jpeg2000 => 0x21,
Self::AdditionalViewH262 => 0x22,
Self::AdditionalViewH264 => 0x23,
Self::Hevc => 0x24,
Self::HevcTemporalSubset => 0x25,
Self::Mvcd => 0x26,
Self::Temi => 0x27,
Self::HevcAnnexG => 0x28,
Self::HevcAnnexGTemporal => 0x29,
Self::HevcAnnexH => 0x2A,
Self::HevcAnnexHTemporal => 0x2B,
Self::GreenAccessUnits => 0x2C,
Self::MhasAudioMain => 0x2D,
Self::MhasAudioAux => 0x2E,
Self::QualityAccessUnits => 0x2F,
Self::MediaOrchestration => 0x30,
Self::MctsHevc => 0x31,
Self::JpegXs => 0x32,
Self::Vvc => 0x33,
Self::VvcTemporalSubset => 0x34,
Self::Evc => 0x35,
Self::IpmpHigh => 0x7F,
Self::Ac3 => 0x81,
Self::Scte35 => 0x86,
Self::EAc3 => 0x87,
Self::ReservedRange(v) | Self::UserPrivate(v) => v,
}
}
#[must_use]
pub fn name(self) -> &'static str {
match self {
Self::Reserved => "Reserved",
Self::Mpeg1Video => "MPEG-1 Video",
Self::Mpeg2Video => "MPEG-2 Video",
Self::Mpeg1Audio => "MPEG-1 Audio",
Self::Mpeg2Audio => "MPEG-2 Audio",
Self::PrivateSections => "Private Sections",
Self::PesPrivateData => "PES Private Data",
Self::Mheg => "MHEG",
Self::DsmCc => "DSM-CC",
Self::H222_1 => "H.222.1",
Self::Iso13818_6TypeA => "ISO/IEC 13818-6 Type A",
Self::Iso13818_6TypeB => "ISO/IEC 13818-6 Type B",
Self::Iso13818_6TypeC => "ISO/IEC 13818-6 Type C",
Self::Iso13818_6TypeD => "ISO/IEC 13818-6 Type D",
Self::Auxiliary => "Auxiliary",
Self::AacAdts => "AAC ADTS",
Self::Mpeg4Video => "MPEG-4 Video",
Self::AacLatm => "AAC LATM",
Self::SlFlexMuxPes => "SL/FlexMux in PES",
Self::SlFlexMuxSections => "SL/FlexMux in Sections",
Self::SyncDownload => "Sync Download Protocol",
Self::MetadataPes => "Metadata in PES",
Self::MetadataSections => "Metadata in Sections",
Self::MetadataDataCarousel => "Metadata Data Carousel",
Self::MetadataObjectCarousel => "Metadata Object Carousel",
Self::MetadataSyncDownload => "Metadata Sync Download",
Self::Ipmp => "IPMP",
Self::H264 => "H.264/AVC",
Self::Iso14496_3Audio => "ISO/IEC 14496-3 Audio",
Self::Iso14496_17Text => "ISO/IEC 14496-17 Text",
Self::AuxiliaryVideo => "Auxiliary Video",
Self::Svc => "SVC",
Self::Mvc => "MVC",
Self::Jpeg2000 => "JPEG 2000",
Self::AdditionalViewH262 => "Additional View H.262 (3D)",
Self::AdditionalViewH264 => "Additional View H.264 (3D)",
Self::Hevc => "HEVC/H.265",
Self::HevcTemporalSubset => "HEVC Temporal Subset",
Self::Mvcd => "MVCD (H.264 Annex I)",
Self::Temi => "TEMI",
Self::HevcAnnexG => "HEVC Annex G",
Self::HevcAnnexGTemporal => "HEVC Annex G Temporal",
Self::HevcAnnexH => "HEVC Annex H",
Self::HevcAnnexHTemporal => "HEVC Annex H Temporal",
Self::GreenAccessUnits => "Green Access Units",
Self::MhasAudioMain => "MHAS Audio Main",
Self::MhasAudioAux => "MHAS Audio Aux",
Self::QualityAccessUnits => "Quality Access Units",
Self::MediaOrchestration => "Media Orchestration",
Self::MctsHevc => "MCTS HEVC",
Self::JpegXs => "JPEG XS",
Self::Vvc => "VVC/H.266",
Self::VvcTemporalSubset => "VVC Temporal Subset",
Self::Evc => "EVC",
Self::IpmpHigh => "IPMP (0x7F)",
Self::Ac3 => "AC-3",
Self::Scte35 => "SCTE-35",
Self::EAc3 => "E-AC-3",
Self::ReservedRange(_) => "Reserved",
Self::UserPrivate(_) => "User Private",
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[cfg_attr(feature = "yoke", derive(yoke::Yokeable))]
pub struct PmtStream<'a> {
pub stream_type: StreamType,
pub elementary_pid: u16,
pub es_info: DescriptorLoop<'a>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize))]
#[cfg_attr(feature = "yoke", derive(yoke::Yokeable))]
pub struct PmtSection<'a> {
pub program_number: u16,
pub version_number: u8,
pub current_next_indicator: bool,
pub pcr_pid: u16,
pub program_info: DescriptorLoop<'a>,
pub streams: Vec<PmtStream<'a>>,
}
impl<'a> Parse<'a> for PmtSection<'a> {
type Error = crate::error::Error;
fn parse(bytes: &'a [u8]) -> Result<Self> {
let min_len =
MIN_HEADER_LEN + EXTENSION_HEADER_LEN + PCR_PID_LEN + PROG_INFO_LEN_BYTES + CRC_LEN;
if bytes.len() < min_len {
return Err(Error::BufferTooShort {
need: min_len,
have: bytes.len(),
what: "PmtSection",
});
}
if bytes[0] != TABLE_ID {
return Err(Error::UnexpectedTableId {
table_id: bytes[0],
what: "PmtSection",
expected: &[TABLE_ID],
});
}
let section_length = ((bytes[1] & 0x0F) as u16) << 8 | bytes[2] as u16;
let total = super::check_section_length(
bytes.len(),
MIN_HEADER_LEN,
section_length as usize,
MIN_SECTION_LEN,
)?;
let program_number = u16::from_be_bytes([bytes[3], bytes[4]]);
let version_number = (bytes[5] >> 1) & 0x1F;
let current_next_indicator = (bytes[5] & 0x01) != 0;
let pcr_pid = (((bytes[8] & 0x1F) as u16) << 8) | bytes[9] as u16;
let program_info_length = (((bytes[10] & 0x0F) as usize) << 8) | bytes[11] as usize;
let prog_info_start =
MIN_HEADER_LEN + EXTENSION_HEADER_LEN + PCR_PID_LEN + PROG_INFO_LEN_BYTES;
let prog_info_end = prog_info_start + program_info_length;
let stream_loop_end = total - CRC_LEN;
if prog_info_end > stream_loop_end {
return Err(Error::SectionLengthOverflow {
declared: program_info_length,
available: stream_loop_end.saturating_sub(prog_info_start),
});
}
let program_info = DescriptorLoop::new(&bytes[prog_info_start..prog_info_end]);
let mut streams = Vec::new();
let mut pos = prog_info_end;
while pos + STREAM_HEADER_LEN <= stream_loop_end {
let stream_type = StreamType::from_u8(bytes[pos]);
let elementary_pid = (((bytes[pos + 1] & 0x1F) as u16) << 8) | bytes[pos + 2] as u16;
let es_info_length =
(((bytes[pos + 3] & 0x0F) as usize) << 8) | bytes[pos + 4] as usize;
let es_start = pos + STREAM_HEADER_LEN;
let es_end = es_start + es_info_length;
if es_end > stream_loop_end {
return Err(Error::SectionLengthOverflow {
declared: es_info_length,
available: stream_loop_end.saturating_sub(es_start),
});
}
streams.push(PmtStream {
stream_type,
elementary_pid,
es_info: DescriptorLoop::new(&bytes[es_start..es_end]),
});
pos = es_end;
}
Ok(PmtSection {
program_number,
version_number,
current_next_indicator,
pcr_pid,
program_info,
streams,
})
}
}
impl Serialize for PmtSection<'_> {
type Error = crate::error::Error;
fn serialized_len(&self) -> usize {
let streams_bytes: usize = self
.streams
.iter()
.map(|s| STREAM_HEADER_LEN + s.es_info.len())
.sum();
MIN_HEADER_LEN
+ EXTENSION_HEADER_LEN
+ PCR_PID_LEN
+ PROG_INFO_LEN_BYTES
+ self.program_info.len()
+ streams_bytes
+ CRC_LEN
}
fn serialize_into(&self, buf: &mut [u8]) -> Result<usize> {
let len = self.serialized_len();
if buf.len() < len {
return Err(Error::OutputBufferTooSmall {
need: len,
have: buf.len(),
});
}
let section_length: u16 = (len - MIN_HEADER_LEN) as u16;
buf[0] = TABLE_ID;
buf[1] = super::SECTION_B1_FLAGS_PSI | ((section_length >> 8) as u8 & 0x0F);
buf[2] = (section_length & 0xFF) as u8;
buf[3..5].copy_from_slice(&self.program_number.to_be_bytes());
buf[5] = 0xC0 | ((self.version_number & 0x1F) << 1) | u8::from(self.current_next_indicator);
buf[6] = 0;
buf[7] = 0;
buf[8] = 0xE0 | ((self.pcr_pid >> 8) as u8 & 0x1F);
buf[9] = (self.pcr_pid & 0xFF) as u8;
let pil = self.program_info.len() as u16;
buf[10] = 0xF0 | ((pil >> 8) as u8 & 0x0F);
buf[11] = (pil & 0xFF) as u8;
let prog_info_start =
MIN_HEADER_LEN + EXTENSION_HEADER_LEN + PCR_PID_LEN + PROG_INFO_LEN_BYTES;
buf[prog_info_start..prog_info_start + self.program_info.len()]
.copy_from_slice(self.program_info.raw());
let mut pos = prog_info_start + self.program_info.len();
for stream in &self.streams {
buf[pos] = stream.stream_type.to_u8();
buf[pos + 1] = 0xE0 | ((stream.elementary_pid >> 8) as u8 & 0x1F);
buf[pos + 2] = (stream.elementary_pid & 0xFF) as u8;
let esl = stream.es_info.len() as u16;
buf[pos + 3] = 0xF0 | ((esl >> 8) as u8 & 0x0F);
buf[pos + 4] = (esl & 0xFF) as u8;
let es_start = pos + STREAM_HEADER_LEN;
buf[es_start..es_start + stream.es_info.len()].copy_from_slice(stream.es_info.raw());
pos = es_start + stream.es_info.len();
}
let crc_pos = len - CRC_LEN;
let crc = dvb_common::crc32_mpeg2::compute(&buf[..crc_pos]);
buf[crc_pos..len].copy_from_slice(&crc.to_be_bytes());
Ok(len)
}
}
impl<'a> crate::traits::TableDef<'a> for PmtSection<'a> {
const TABLE_ID_RANGES: &'static [(u8, u8)] = &[(TABLE_ID, TABLE_ID)];
const NAME: &'static str = "PROGRAM_MAP";
}
#[cfg(test)]
mod tests {
use super::*;
fn build_pmt(
program_number: u16,
version: u8,
pcr_pid: u16,
program_info: &[u8],
streams: &[(u8, u16, Vec<u8>)],
) -> Vec<u8> {
let streams_bytes: usize = streams
.iter()
.map(|(_, _, es)| STREAM_HEADER_LEN + es.len())
.sum();
let section_length: u16 = (EXTENSION_HEADER_LEN
+ PCR_PID_LEN
+ PROG_INFO_LEN_BYTES
+ program_info.len()
+ streams_bytes
+ CRC_LEN) as u16;
let mut v = Vec::new();
v.push(TABLE_ID);
v.push(super::super::SECTION_B1_FLAGS_PSI | ((section_length >> 8) as u8 & 0x0F));
v.push((section_length & 0xFF) as u8);
v.extend_from_slice(&program_number.to_be_bytes());
v.push(0xC0 | ((version & 0x1F) << 1) | 0x01);
v.push(0);
v.push(0);
v.push(0xE0 | ((pcr_pid >> 8) as u8 & 0x1F));
v.push((pcr_pid & 0xFF) as u8);
v.push(0xF0 | ((program_info.len() >> 8) as u8 & 0x0F));
v.push((program_info.len() & 0xFF) as u8);
v.extend_from_slice(program_info);
for (stype, pid, es) in streams {
v.push(*stype);
v.push(0xE0 | ((pid >> 8) as u8 & 0x1F));
v.push((pid & 0xFF) as u8);
v.push(0xF0 | ((es.len() >> 8) as u8 & 0x0F));
v.push((es.len() & 0xFF) as u8);
v.extend_from_slice(es);
}
v.extend_from_slice(&[0, 0, 0, 0]);
v
}
#[test]
fn parse_extracts_pcr_pid_and_program_info() {
let bytes = build_pmt(42, 5, 0x0100, &[0xAA, 0xBB], &[]);
let pmt = PmtSection::parse(&bytes).unwrap();
assert_eq!(pmt.program_number, 42);
assert_eq!(pmt.version_number, 5);
assert!(pmt.current_next_indicator);
assert_eq!(pmt.pcr_pid, 0x0100);
assert_eq!(pmt.program_info.raw(), &[0xAA, 0xBB]);
assert_eq!(pmt.streams.len(), 0);
}
#[test]
fn parse_elementary_streams_and_es_info_slices() {
let bytes = build_pmt(
1,
0,
0x101,
&[],
&[(0x02, 0x102, vec![0x11, 0x22]), (0x1B, 0x103, vec![0x33])],
);
let pmt = PmtSection::parse(&bytes).unwrap();
assert_eq!(pmt.streams.len(), 2);
assert_eq!(pmt.streams[0].stream_type, StreamType::Mpeg2Video);
assert_eq!(pmt.streams[0].elementary_pid, 0x102);
assert_eq!(pmt.streams[0].es_info.raw(), &[0x11, 0x22]);
assert_eq!(pmt.streams[1].stream_type, StreamType::H264);
assert_eq!(pmt.streams[1].elementary_pid, 0x103);
assert_eq!(pmt.streams[1].es_info.raw(), &[0x33]);
}
#[test]
fn parse_rejects_wrong_table_id() {
let mut bytes = build_pmt(1, 0, 0x100, &[], &[]);
bytes[0] = 0x00;
let err = PmtSection::parse(&bytes).unwrap_err();
assert!(matches!(
err,
Error::UnexpectedTableId { table_id: 0x00, .. }
));
}
#[test]
fn parse_rejects_short_buffer() {
let err = PmtSection::parse(&[0x02, 0x00]).unwrap_err();
assert!(matches!(err, Error::BufferTooShort { .. }));
}
#[test]
fn serialize_round_trip_empty_program() {
let pmt = PmtSection {
program_number: 1,
version_number: 0,
current_next_indicator: true,
pcr_pid: 0x100,
program_info: DescriptorLoop::new(&[]),
streams: vec![],
};
let mut buf = vec![0u8; pmt.serialized_len()];
pmt.serialize_into(&mut buf).unwrap();
let re = PmtSection::parse(&buf).unwrap();
assert_eq!(pmt, re);
}
#[test]
fn serialize_round_trip_with_streams_and_descriptors() {
let prog_info: [u8; 3] = [0x09, 0x01, 0xFF];
let es1: [u8; 4] = [0x52, 0x02, 0xAA, 0xBB];
let es2: [u8; 2] = [0x0A, 0x00];
let pmt = PmtSection {
program_number: 0xABCD,
version_number: 7,
current_next_indicator: true,
pcr_pid: 0x1F0,
program_info: DescriptorLoop::new(&prog_info),
streams: vec![
PmtStream {
stream_type: StreamType::Mpeg2Video,
elementary_pid: 0x100,
es_info: DescriptorLoop::new(&es1),
},
PmtStream {
stream_type: StreamType::Mpeg1Audio,
elementary_pid: 0x101,
es_info: DescriptorLoop::new(&es2),
},
PmtStream {
stream_type: StreamType::H264,
elementary_pid: 0x102,
es_info: DescriptorLoop::new(&[]),
},
],
};
let mut buf = vec![0u8; pmt.serialized_len()];
pmt.serialize_into(&mut buf).unwrap();
let re = PmtSection::parse(&buf).unwrap();
assert_eq!(pmt, re);
}
#[test]
fn zero_elementary_streams_is_valid() {
let bytes = build_pmt(99, 0, 0x0100, &[], &[]);
let pmt = PmtSection::parse(&bytes).unwrap();
assert_eq!(pmt.streams.len(), 0);
}
#[test]
fn parse_preserves_raw_program_info_bytes() {
let pi = vec![0x09, 0x04, 0x01, 0x02, 0x03, 0x04];
let bytes = build_pmt(1, 0, 0x100, &pi, &[]);
let pmt = PmtSection::parse(&bytes).unwrap();
assert_eq!(pmt.program_info.raw(), &pi[..]);
}
#[test]
fn parse_rejects_zero_section_length() {
let mut buf = vec![0u8; 64];
buf[0] = TABLE_ID;
buf[1] = 0xF0;
buf[2] = 0x00;
for b in &mut buf[3..] {
*b = 0xFF;
}
assert!(matches!(
PmtSection::parse(&buf).unwrap_err(),
Error::SectionLengthOverflow { .. }
));
}
#[test]
fn stream_type_full_range_round_trip() {
for byte in 0u8..=0xFF {
let st = StreamType::from_u8(byte);
assert_eq!(
st.to_u8(),
byte,
"StreamType round-trip failed for {byte:#04x}"
);
}
}
#[test]
fn stream_type_named_values() {
assert_eq!(StreamType::Mpeg2Video.to_u8(), 0x02);
assert_eq!(StreamType::H264.to_u8(), 0x1B);
assert_eq!(StreamType::Hevc.to_u8(), 0x24);
assert_eq!(StreamType::Vvc.to_u8(), 0x33);
assert_eq!(StreamType::MediaOrchestration.to_u8(), 0x30);
assert_eq!(StreamType::Mvcd.to_u8(), 0x26);
assert_eq!(StreamType::Temi.to_u8(), 0x27);
assert_eq!(StreamType::Ac3.to_u8(), 0x81);
assert_eq!(StreamType::Scte35.to_u8(), 0x86);
assert_eq!(StreamType::EAc3.to_u8(), 0x87);
assert_eq!(StreamType::AacAdts.to_u8(), 0x0F);
assert_eq!(StreamType::IpmpHigh.to_u8(), 0x7F);
}
#[test]
fn stream_type_names() {
assert_eq!(StreamType::Mpeg2Video.name(), "MPEG-2 Video");
assert_eq!(StreamType::H264.name(), "H.264/AVC");
assert_eq!(StreamType::Hevc.name(), "HEVC/H.265");
assert_eq!(StreamType::Vvc.name(), "VVC/H.266");
assert_eq!(StreamType::MediaOrchestration.name(), "Media Orchestration");
assert_eq!(StreamType::Mvcd.name(), "MVCD (H.264 Annex I)");
assert_eq!(StreamType::Temi.name(), "TEMI");
assert_eq!(StreamType::DsmCc.name(), "DSM-CC");
assert_eq!(StreamType::Ac3.name(), "AC-3");
assert_eq!(StreamType::Scte35.name(), "SCTE-35");
}
}