use crate::mpegts::{
WritableLen,
bytes::RawData,
stream_id::StreamId,
timestamp::{Clock, ESCR, PtsDts, Timestamp},
};
#[allow(missing_docs)]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Pes<B = RawData> {
pub header: PesHeader,
pub data: B,
}
impl WritableLen for Pes {
fn writable_len(&self) -> usize {
todo!()
}
}
pub const PACKET_START_CODE_PREFIX: u64 = 0x00_0001;
#[allow(missing_docs)]
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct PesHeader {
pub stream_id: StreamId,
pub priority: bool,
pub data_alignment_indicator: bool,
pub copyright: bool,
pub original_or_copy: bool,
pub pts: Option<Timestamp<PtsDts>>,
pub dts: Option<Timestamp<PtsDts>>,
pub escr: Option<Timestamp<Clock<ESCR>>>,
pub(crate) packet_len: u16,
}
impl PesHeader {
pub fn optional_header_len(&self) -> u16 {
3 + self.pts.map_or(0, |_| 5)
+ self.dts.map_or(0, |_| 5)
+ self.escr.map_or(0, |_| 6)
}
}