pub struct OwnedTsPacket {
pub raw: [u8; 188],
pub pid: u16,
pub pusi: bool,
pub has_adaptation: bool,
pub has_payload: bool,
pub tei: bool,
pub scrambling: u8,
pub continuity_counter: u8,
pub discontinuity: bool,
}Expand description
Owned 188-byte TS packet with pre-parsed header fields.
The raw bytes are stored in raw; the parsed flags (pid, pusi, etc.) are
pre-extracted at construction time so hot paths avoid repeated byte masking.
§Payload access
Use payload / payload_mut to obtain
a slice that correctly skips the 4-byte header and any adaptation field.
§Building packets
serialize_with_payload constructs a plain
payload-only packet (no adaptation field) filled with 0xFF stuffing.
Fields§
§raw: [u8; 188]The raw 188 bytes (serialized as a byte sequence).
pid: u1613-bit PID extracted from bytes 1–2.
pusi: boolPayload Unit Start Indicator (byte 1 bit 6).
has_adaptation: boolAdaptation field present flag (byte 3 bit 5).
has_payload: boolPayload present flag (byte 3 bit 4).
tei: boolTransport Error Indicator (byte 1 bit 7).
scrambling: u82-bit transport_scrambling_control (byte 3 bits 7–6).
continuity_counter: u84-bit continuity_counter (byte 3 bits 3–0).
discontinuity: boolDiscontinuity flag: true if the adaptation-field discontinuity_indicator
was set in the source packet, or if the caller marks this as a
continuity-counter discontinuity boundary. Defaults to false on parse.
Implementations§
Source§impl OwnedTsPacket
impl OwnedTsPacket
Sourcepub fn parse(raw: [u8; 188]) -> Result<Self>
pub fn parse(raw: [u8; 188]) -> Result<Self>
Parse a 188-byte owned TS packet.
Returns Error::InvalidSyncByte if raw[0] != 0x47.
Header bit-parsing is delegated to TsHeader::parse.
The discontinuity field defaults to false; set it manually if needed.
Sourcepub fn scrambling_control(&self) -> ScramblingControl
pub fn scrambling_control(&self) -> ScramblingControl
Typed view of the 2-bit transport_scrambling_control field.
See ScramblingControl for the spec citation (H.222.0 Table 2-4 +
ETSI TS 100 289 §5.1 Table 1).
Sourcepub fn adaptation_field_control(&self) -> AdaptationFieldControl
pub fn adaptation_field_control(&self) -> AdaptationFieldControl
Typed view of the adaptation_field_control 2-bit field, derived from the
stored has_adaptation/has_payload booleans.
See AdaptationFieldControl for the spec citation (H.222.0 Table 2-5).
Sourcepub fn payload(&self) -> Option<&[u8]>
pub fn payload(&self) -> Option<&[u8]>
Return the payload bytes (after the 4-byte header and any adaptation field).
Returns None when has_payload is false or the
adaptation field consumed all remaining bytes.
Sourcepub fn payload_mut(&mut self) -> Option<&mut [u8]>
pub fn payload_mut(&mut self) -> Option<&mut [u8]>
Return a mutable slice of the payload bytes.
Returns None when has_payload is false or the
adaptation field consumed all remaining bytes.
Sourcepub fn serialize_with_payload(
pid: u16,
pusi: bool,
cc: u8,
payload: &[u8],
) -> [u8; 188]
pub fn serialize_with_payload( pid: u16, pusi: bool, cc: u8, payload: &[u8], ) -> [u8; 188]
Build a 188-byte payload-only TS packet (no adaptation field).
The packet is initialised to 0xFF (MPEG-TS stuffing), the 4-byte header
is written via TsHeader::serialize_into, then up to 184 bytes of
payload are copied starting at byte 4. Any unfilled bytes remain 0xFF.
§Panics
Never panics — serializing a 4-byte header into a 188-byte buffer cannot fail.
Trait Implementations§
Source§impl Clone for OwnedTsPacket
impl Clone for OwnedTsPacket
Source§fn clone(&self) -> OwnedTsPacket
fn clone(&self) -> OwnedTsPacket
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more