| 1 | |
| 2 | |
| 3 | use crate::units::{Duration, Timestamp}; |
| 4 | |
| 5 | |
| 6 | #[derive(Debug, Clone, PartialEq, Eq)] |
| 7 | pub struct Packet { |
| 8 | |
| 9 | pub track_id: u32, |
| 10 | |
| 11 | pub pts: Timestamp, |
| 12 | |
| 13 | pub dur: Duration, |
| 14 | |
| 15 | pub data: Box<[u8]>, |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | pub granule: Option<i64>, |
| 21 | } |
| 22 | |
| 23 | impl Packet { |
| 24 | |
| 25 | pub fn new(track_id: u32, pts: Timestamp, dur: Duration, data: &[u8]) -> Packet { |
| 26 | Packet { |
| 27 | track_id, |
| 28 | pts, |
| 29 | dur, |
| 30 | data: data.to_vec().into_boxed_slice(), |
| 31 | granule: None, |
| 32 | } |
| 33 | } |
| 34 | |
| 35 | |
| 36 | pub fn pts(&self) -> Timestamp { |
| 37 | self.pts |
| 38 | } |
| 39 | |
| 40 | |
| 41 | pub fn buf(&self) -> &[u8] { |
| 42 | &self.data |
| 43 | } |
| 44 | } |