Skip to main content

FlvHeader

Struct FlvHeader 

Source
#[non_exhaustive]
pub struct FlvHeader<'a> { pub has_audio: bool, pub has_video: bool, pub data_offset: u32, pub extra: &'a [u8], }
Expand description

The FLV file header (§E.2), including the PreviousTagSize0 that always follows it.

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.
§has_audio: bool

TypeFlags bit 0 (§E.2): the file carries audio tags.

§has_video: bool

TypeFlags bit 2 (§E.2): the file carries video tags.

§data_offset: u32

DataOffset as it was on the wire (§E.2): the first byte after the header. FLV_DATA_OFFSET on every header this crate writes; an input may declare a larger one (extra header bytes the caller skips), and keeping it makes a parse/serialize round trip byte-exact.

§extra: &'a [u8]

The DataOffset - 9 extra header bytes between the fixed 9-byte header and the PreviousTagSize0 that the parser skipped (§E.2). Empty on every header this crate writes.

Implementations§

Source§

impl<'a> FlvHeader<'a>

Source

pub fn new(has_audio: bool, has_video: bool) -> Self

A header declaring the given track kinds, with the standard DataOffset.

Source

pub fn type_flags(&self) -> u8

The TypeFlags byte (§E.2) this header puts on the wire.

Source

pub fn first_tag_offset(&self) -> usize

Offset of the first tag’s header: past the DataOffset the header declares and its PreviousTagSize0 (§E.2). A DataOffset shorter than the header itself is clamped to FLV_HEADER_LEN, since the first tag cannot start inside the header.

Source§

impl FlvHeader<'_>

Source

pub fn declared_data_offset(bytes: &[u8]) -> Result<u32, RtmpError>

The DataOffset the fixed 9-byte header declares (FLV §E.2), after checking the signature, without requiring the bytes it points past. A streaming reader uses it to bound how much it buffers before the whole header has arrived.

Trait Implementations§

Source§

impl<'a> Clone for FlvHeader<'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 FlvHeader<'a>

Source§

impl<'a> Debug for FlvHeader<'a>

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 FlvHeader<'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 FlvHeader<'a>

Source§

impl<'a> Parse<'a> for FlvHeader<'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.
Source§

impl<'a> PartialEq for FlvHeader<'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 FlvHeader<'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<'a> Serialize for FlvHeader<'a>

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

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§

impl<'a> StructuralPartialEq for FlvHeader<'a>

Auto Trait Implementations§

§

impl<'a> Forget for FlvHeader<'a>

§

impl<'a> Freeze for FlvHeader<'a>

§

impl<'a> Move for FlvHeader<'a>

§

impl<'a> RefUnwindSafe for FlvHeader<'a>

§

impl<'a> Send for FlvHeader<'a>

§

impl<'a> Sync for FlvHeader<'a>

§

impl<'a> Unpin for FlvHeader<'a>

§

impl<'a> UnsafeUnpin for FlvHeader<'a>

§

impl<'a> UnwindSafe for FlvHeader<'a>

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.