use crate::rational::Rational;
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq)]
pub struct PacketFlags {
pub keyframe: bool,
pub end_of_stream: bool,
}
#[derive(Debug, Clone, Default)]
pub struct Packet {
pub stream_index: usize,
pub pts: Option<i64>,
pub dts: Option<i64>,
pub duration: i64,
pub end_position: Option<i64>,
pub time_base: Rational,
pub data: Vec<u8>,
pub flags: PacketFlags,
}
impl Packet {
pub fn new(stream_index: usize) -> Packet {
Packet {
stream_index,
time_base: Rational::new(1, 1000),
..Default::default()
}
}
pub fn from_data(stream_index: usize, data: Vec<u8>) -> Packet {
Packet {
data,
..Packet::new(stream_index)
}
}
pub fn is_keyframe(&self) -> bool {
self.flags.keyframe
}
}