Skip to main content

AudioTagHeader

Struct AudioTagHeader 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§sound_format: SoundFormat

SoundFormat (§E.4.2).

§sound_rate: SoundRate

SoundRate (§E.4.2).

§sound_size: SoundSize

SoundSize (§E.4.2).

§sound_type: SoundType

SoundType (§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>

Source

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.

Source

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

Source

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.

Source

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>

Source§

fn clone(&self) -> Self

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<'a> Copy for AudioTagHeader<'a>

Source§

impl Debug for AudioTagHeader<'_>

Source§

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

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

impl<'de: 'a, 'a> Deserialize<'de> for AudioTagHeader<'a>

Available on crate feature serde only.
Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<'a> Eq for AudioTagHeader<'a>

Source§

impl<'a> Parse<'a> for AudioTagHeader<'a>

Source§

type Error = RtmpError

The error type this implementer returns. Typically the enclosing crate’s Error enum.
Source§

fn parse(bytes: &'a [u8]) -> Result<Self, RtmpError>

Parse bytes as Self. Returns Err(Self::Error) on any protocol violation or buffer underrun. Read more
Source§

impl<'a> PartialEq for AudioTagHeader<'a>

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl<'a> Serialize for AudioTagHeader<'a>

Available on crate feature serde only.
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
Source§

impl Serialize for AudioTagHeader<'_>

Source§

type Error = RtmpError

The error type this implementer returns (usually the same as the corresponding Parse impl, but need not be).
Source§

fn serialized_len(&self) -> usize

Number of bytes serialize_into will write.
Source§

fn serialize_into(&self, buf: &mut [u8]) -> Result<usize, Self::Error>

Write the serialised form into buf. Returns the number of bytes written (always equal to serialized_len()).
Source§

fn try_to_bytes(&self) -> Result<Vec<u8>, Self::Error>

Allocate a 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).
Source§

fn serialize_append(&self, out: &mut Vec<u8>) -> Result<usize, Self::Error>

Append the serialised form to out, returning the number of bytes appended. out is left unchanged when the serializer fails.
Source§

impl<'a> StructuralPartialEq for AudioTagHeader<'a>

Auto Trait Implementations§

§

impl<'a> Forget for AudioTagHeader<'a>

§

impl<'a> Freeze for AudioTagHeader<'a>
where &'a [u8]: Freeze,

§

impl<'a> Move for AudioTagHeader<'a>

§

impl<'a> RefUnwindSafe for AudioTagHeader<'a>

§

impl<'a> Send for AudioTagHeader<'a>
where &'a [u8]: Send,

§

impl<'a> Sync for AudioTagHeader<'a>

§

impl<'a> Unpin for AudioTagHeader<'a>
where &'a [u8]: Unpin,

§

impl<'a> UnsafeUnpin for AudioTagHeader<'a>
where &'a [u8]: UnsafeUnpin,

§

impl<'a> UnwindSafe for AudioTagHeader<'a>
where &'a [u8]: UnwindSafe,

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.