Skip to main content

OwnedTsPacket

Struct OwnedTsPacket 

Source
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: u16

13-bit PID extracted from bytes 1–2.

§pusi: bool

Payload Unit Start Indicator (byte 1 bit 6).

§has_adaptation: bool

Adaptation field present flag (byte 3 bit 5).

§has_payload: bool

Payload present flag (byte 3 bit 4).

§tei: bool

Transport Error Indicator (byte 1 bit 7).

§scrambling: u8

2-bit transport_scrambling_control (byte 3 bits 7–6).

§continuity_counter: u8

4-bit continuity_counter (byte 3 bits 3–0).

§discontinuity: bool

Discontinuity 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

Source

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.

Source

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).

Source

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).

Source

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.

Source

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.

Source

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

Source§

fn clone(&self) -> OwnedTsPacket

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for OwnedTsPacket

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Serialize for OwnedTsPacket

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.