#[non_exhaustive]pub struct AudioTagHeader<'a> {
pub sound_format: SoundFormat,
pub sound_rate: SoundRate,
pub sound_size: SoundSize,
pub sound_type: SoundType,
pub aac_packet_type: Option<AacPacketType>,
pub data: &'a [u8],
}Expand description
The AudioTagHeader (§E.4.2) and, for AAC, the packet header of its
AACAUDIODATA body (§E.4.2.2).
AACAUDIODATA is the only audio packet layout this crate decodes; any
other SoundFormat keeps all the bytes after the first byte as
data, because no packet header of that codec is modelled
here.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.sound_format: SoundFormatSoundFormat (§E.4.2).
sound_rate: SoundRateSoundRate (§E.4.2).
sound_size: SoundSizeSoundSize (§E.4.2).
sound_type: SoundTypeSoundType (§E.4.2).
aac_packet_type: Option<AacPacketType>AACPacketType: set only for SoundFormat::Aac (§E.4.2.2).
data: &'a [u8]The coded bytes after the packet header.
Implementations§
Source§impl<'a> AudioTagHeader<'a>
impl<'a> AudioTagHeader<'a>
Sourcepub fn new(
sound_format: SoundFormat,
sound_rate: SoundRate,
sound_size: SoundSize,
sound_type: SoundType,
aac_packet_type: Option<AacPacketType>,
) -> Self
pub fn new( sound_format: SoundFormat, sound_rate: SoundRate, sound_size: SoundSize, sound_type: SoundType, aac_packet_type: Option<AacPacketType>, ) -> Self
A header with no packet header and no coded data.
Sourcepub fn sound_type_for_channels(channel_count: u16) -> SoundType
pub fn sound_type_for_channels(channel_count: u16) -> SoundType
The SoundType an audio channel_count states: one channel or fewer
is mono, anything above is stereo (§E.5’s stereo rule).
Sourcepub fn to_bytes(&self) -> Result<Vec<u8>, RtmpError>
pub fn to_bytes(&self) -> Result<Vec<u8>, RtmpError>
The header’s own bytes plus data, the whole AUDIODATA body.
§Errors
RtmpError::Malformed when an AACPacketType is stated for a
SoundFormat that carries none, or when an AAC body states none.
Sourcepub fn first_byte(&self) -> Result<u8, RtmpError>
pub fn first_byte(&self) -> Result<u8, RtmpError>
The AudioTagHeader first byte these sound fields make up (§E.4.2).
§Errors
RtmpError::FieldOverflow when a field’s code does not fit its bits
(a reserved or unknown code carries any byte).
Trait Implementations§
Source§impl<'a> Clone for AudioTagHeader<'a>
impl<'a> Clone for AudioTagHeader<'a>
impl<'a> Copy for AudioTagHeader<'a>
Source§impl Debug for AudioTagHeader<'_>
impl Debug for AudioTagHeader<'_>
Source§impl<'de: 'a, 'a> Deserialize<'de> for AudioTagHeader<'a>
Available on crate feature serde only.
impl<'de: 'a, 'a> Deserialize<'de> for AudioTagHeader<'a>
serde only.Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl<'a> Eq for AudioTagHeader<'a>
Source§impl<'a> Parse<'a> for AudioTagHeader<'a>
impl<'a> Parse<'a> for AudioTagHeader<'a>
Source§impl<'a> PartialEq for AudioTagHeader<'a>
impl<'a> PartialEq for AudioTagHeader<'a>
Source§impl<'a> Serialize for AudioTagHeader<'a>
Available on crate feature serde only.
impl<'a> Serialize for AudioTagHeader<'a>
serde only.Source§impl Serialize for AudioTagHeader<'_>
impl Serialize for AudioTagHeader<'_>
Source§type Error = RtmpError
type Error = RtmpError
Parse impl, but need not be).Source§fn serialized_len(&self) -> usize
fn serialized_len(&self) -> usize
serialize_into will write.Source§fn serialize_into(&self, buf: &mut [u8]) -> Result<usize, Self::Error>
fn serialize_into(&self, buf: &mut [u8]) -> Result<usize, Self::Error>
buf. Returns the number of bytes
written (always equal to serialized_len()).Source§fn try_to_bytes(&self) -> Result<Vec<u8>, Self::Error>
fn try_to_bytes(&self) -> Result<Vec<u8>, Self::Error>
Vec and serialize into it, returning the serializer’s error instead of
panicking. This is the only
allocate-and-serialize entry point: there is deliberately no panicking
to_bytes (hand-built values, or values assembled from damaged wire data,
can violate a wire constraint, so the error must reach the caller).