use crate::time::TimeBase;
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
pub struct PacketFlags {
pub keyframe: bool,
pub header: bool,
pub corrupt: bool,
pub discard: bool,
pub unit_boundary: bool,
}
#[derive(Clone, Debug)]
pub struct Packet {
pub stream_index: u32,
pub time_base: TimeBase,
pub pts: Option<i64>,
pub dts: Option<i64>,
pub duration: Option<i64>,
pub flags: PacketFlags,
pub data: Vec<u8>,
}
impl Packet {
pub fn new(stream_index: u32, time_base: TimeBase, data: Vec<u8>) -> Self {
Self {
stream_index,
time_base,
pts: None,
dts: None,
duration: None,
flags: PacketFlags::default(),
data,
}
}
pub fn with_pts(mut self, pts: i64) -> Self {
self.pts = Some(pts);
self
}
pub fn with_dts(mut self, dts: i64) -> Self {
self.dts = Some(dts);
self
}
pub fn with_duration(mut self, d: i64) -> Self {
self.duration = Some(d);
self
}
pub fn with_keyframe(mut self, kf: bool) -> Self {
self.flags.keyframe = kf;
self
}
}