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>
impl<'buf> AdtsHeader<'buf>
Sourcepub fn from_bytes(buf: &'buf [u8]) -> Result<AdtsHeader<'_>, AdtsHeaderError>
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).
pub fn mpeg_version(&self) -> MpegVersion
pub fn protection(&self) -> ProtectionIndicator
pub fn audio_object_type(&self) -> AudioObjectType
pub fn sampling_frequency(&self) -> SamplingFrequency
Sourcepub fn private_bit(&self) -> u8
pub fn private_bit(&self) -> u8
either 1 or 0
pub fn channel_configuration(&self) -> ChannelConfiguration
pub fn originality(&self) -> Originality
Sourcepub fn copyright_identification_bit(&self) -> u8
pub fn copyright_identification_bit(&self) -> u8
either 1 or 0
pub fn copyright_identification_start(&self) -> CopyrightIdentificationStart
Sourcepub fn frame_length(&self) -> u16
pub fn frame_length(&self) -> u16
length of this frame, including the length of the header.
Sourcepub fn payload_length(&self) -> Option<u16>
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
pub fn adts_buffer_fullness(&self) -> u16
Sourcepub fn crc(&self) -> Option<u16>
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
Sourcepub fn number_of_raw_data_blocks_in_frame(&self) -> u8
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
Sourcepub fn payload(&self) -> Result<&'buf [u8], PayloadError>
pub fn payload(&self) -> Result<&'buf [u8], PayloadError>
The payload AAC data inside this ADTS frame