use alloc::string::String;
use alloc::vec::Vec;
use mpeg_ts::pid::Pid;
use super::{DegradationRecord, InputDegradation, Track, TrackId};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
#[non_exhaustive]
pub struct PcrSample {
pub pcr_27mhz: u64,
pub pid: Pid,
pub packet_index: u64,
pub discontinuity: bool,
}
impl PcrSample {
pub fn new(pcr_27mhz: u64, pid: Pid, packet_index: u64, discontinuity: bool) -> Self {
Self {
pcr_27mhz,
pid,
packet_index,
discontinuity,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[non_exhaustive]
pub struct SkippedTrack {
pub fourcc: String,
pub reason: String,
pub track_id: Option<TrackId>,
}
impl SkippedTrack {
pub fn new(fourcc: String, reason: String) -> Self {
Self {
fourcc,
reason,
track_id: None,
}
}
}
#[derive(Debug, Clone)]
#[non_exhaustive]
pub struct Media {
pub tracks: Vec<Track>,
pub movie_timescale: u32,
pub pcr: Vec<PcrSample>,
pub skipped: Vec<SkippedTrack>,
pub degraded: Vec<InputDegradation>,
pub degraded_at: Vec<DegradationRecord>,
}
impl Media {
pub fn new(tracks: Vec<Track>, movie_timescale: u32) -> Self {
Self {
tracks,
movie_timescale,
pcr: Vec::new(),
skipped: Vec::new(),
degraded: Vec::new(),
degraded_at: Vec::new(),
}
}
pub fn with_pcr(mut self, pcr: Vec<PcrSample>) -> Self {
self.pcr = pcr;
self
}
}