PesHeader

Struct PesHeader 

Source
pub struct PesHeader<'buf> { /* private fields */ }
Expand description

Header at the start of every PES packet.

The header identifies,

  • The stream identifier, returned by stream_id()
  • The the size of the packet, returned by pes_packet_length(), which may well be larger than the size of the payload buffer obtained from the header (the payload is likely split across multiple Transport Stream packets)

In addition, the header may provide access to either

  • an additional set of header data followed by a payload, when contents() returns PesContents::Parsed
  • just a payload on its own, when contents() returns PesContents::Payload

Implementations§

Source§

impl<'buf> PesHeader<'buf>

Source

pub fn from_bytes(buf: &'buf [u8]) -> Option<PesHeader<'buf>>

Wraps the given slice in a PesHeader, which will then provide method to parse the header fields within the slice.

Returns None if the buffer is too small to hold the PES header, or if the PES ‘start code prefix’ is missing.

TODO: should probably return Result.

Source

pub fn stream_id(&self) -> StreamId

Indicator of the type of stream per ISO/IEC 13818-1, Table 2-18.

Source

pub fn pes_packet_length(&self) -> PesLength

The overall length of the PES packet, once all pieces from the transport stream have been collected.

Source

pub fn contents(&self) -> PesContents<'buf>

Either PesContents::Parsed, or PesContents::Payload, depending on the value of stream_id()

Auto Trait Implementations§

§

impl<'buf> Freeze for PesHeader<'buf>

§

impl<'buf> RefUnwindSafe for PesHeader<'buf>

§

impl<'buf> Send for PesHeader<'buf>

§

impl<'buf> Sync for PesHeader<'buf>

§

impl<'buf> Unpin for PesHeader<'buf>

§

impl<'buf> UnwindSafe for PesHeader<'buf>

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