#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
pub struct SampleFlags(u8);
impl SampleFlags {
pub const KEYFRAME: SampleFlags = SampleFlags(0b0000_0001);
pub const DISPOSABLE: SampleFlags = SampleFlags(0b0000_0010);
pub const fn empty() -> Self {
SampleFlags(0)
}
pub const fn contains(self, other: Self) -> bool {
(self.0 & other.0) == other.0
}
pub fn insert(&mut self, other: Self) {
self.0 |= other.0;
}
}
impl core::ops::BitOr for SampleFlags {
type Output = Self;
fn bitor(self, rhs: Self) -> Self {
SampleFlags(self.0 | rhs.0)
}
}
#[derive(Debug, Clone)]
pub struct Sample {
pub dts: u64,
pub pts: u64,
pub duration: u32,
pub flags: SampleFlags,
pub data: Vec<u8>,
}
impl Sample {
pub fn is_segment_boundary(&self) -> bool {
self.flags.contains(SampleFlags::KEYFRAME)
}
}