Skip to main content

framefinery_api/
packet.rs

1/// Identifier for a logical stream within a media pipeline.
2#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3pub struct StreamId(pub u32);
4
5/// Integer timestamp used by packet and encoded-chunk metadata.
6///
7/// The time base is owned by the caller or future muxing layer.
8#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
9pub struct Timestamp(pub i64);
10
11/// Encoded packet passed between generic pipeline stages.
12#[derive(Debug, Clone, PartialEq, Eq)]
13pub struct Packet {
14    /// Stream this packet belongs to.
15    pub stream_id: StreamId,
16    /// Optional presentation timestamp.
17    pub pts: Option<Timestamp>,
18    /// Packet payload bytes.
19    pub data: Vec<u8>,
20}
21
22impl Packet {
23    /// Create a packet with stream id, optional timestamp, and payload bytes.
24    pub fn new(stream_id: StreamId, pts: Option<Timestamp>, data: Vec<u8>) -> Self {
25        Self {
26            stream_id,
27            pts,
28            data,
29        }
30    }
31}