Struct AdtsHeader

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

Extract information for a single ADTS frame from the start of the given byte buffer .

Implementations§

Source§

impl<'buf> AdtsHeader<'buf>

Source

pub fn from_bytes(buf: &'buf [u8]) -> Result<AdtsHeader<'_>, AdtsHeaderError>

Construct an instance by borrowing the given byte buffer. The given buffer may be longer then the ADTS frame, in which case the rest of the buffer is ignored.

Note that this function returns Err if there is not enough data to parse the whole header, but it can return Ok even if there is not enough data in the given buffer to hold the whole of the payload that the header indicates should be present (however if there is not enough data to hold the payload, then payload() will return None).

Source

pub fn mpeg_version(&self) -> MpegVersion

Source

pub fn protection(&self) -> ProtectionIndicator

Source

pub fn audio_object_type(&self) -> AudioObjectType

Source

pub fn sampling_frequency(&self) -> SamplingFrequency

Source

pub fn private_bit(&self) -> u8

either 1 or 0

Source

pub fn channel_configuration(&self) -> ChannelConfiguration

Source

pub fn originality(&self) -> Originality

Source

pub fn home(&self) -> u8

either 1 or 0

Source

pub fn copyright_identification_bit(&self) -> u8

either 1 or 0

Source

pub fn copyright_identification_start(&self) -> CopyrightIdentificationStart

Source

pub fn frame_length(&self) -> u16

length of this frame, including the length of the header.

Source

pub fn payload_length(&self) -> Option<u16>

Calculates the length of the frame payload from the frame_length header value, and the total size of headers in this frame – returning None if the frame_length header had a value too small to even include the headers

Source

pub fn adts_buffer_fullness(&self) -> u16

Source

pub fn crc(&self) -> Option<u16>

Gives the 16-bit cyclic redundancy check value stored in this frame header, or None if the header does not supply a CRC.

NB the implementation doesn’t currently check that the CRC is correct

Source

pub fn number_of_raw_data_blocks_in_frame(&self) -> u8

The number of data blocks in the frame, a value between 1 and 4 inclusive.

(Note that in the serialised ADTS data stores the number of blocks - 1. This method returns the actual number of blocks by adding one to the serialised value.)

Most streams store a single block per ADTS frame

Source

pub fn payload(&self) -> Result<&'buf [u8], PayloadError>

The payload AAC data inside this ADTS frame

Trait Implementations§

Source§

impl<'buf> Debug for AdtsHeader<'buf>

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'buf> Freeze for AdtsHeader<'buf>

§

impl<'buf> RefUnwindSafe for AdtsHeader<'buf>

§

impl<'buf> Send for AdtsHeader<'buf>

§

impl<'buf> Sync for AdtsHeader<'buf>

§

impl<'buf> Unpin for AdtsHeader<'buf>

§

impl<'buf> UnwindSafe for AdtsHeader<'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.