webm_iterable::matroska_spec

Struct SimpleBlock

Source
pub struct SimpleBlock<'a> {
    pub track: u64,
    pub timestamp: i16,
    pub invisible: bool,
    pub lacing: Option<BlockLacing>,
    pub discardable: bool,
    pub keyframe: bool,
    /* private fields */
}
Expand description

A typed interpretation of the Matroska “SimpleBlock” element.

This struct has fields specific to the SimpleBlock element as defined by the Matroska Spec. This struct implements TryFrom<&MatroskaSpec> and Into<MatroskaSpec> to simplify coercion to and from regular enum variants.

§Example

use webm_iterable::matroska_spec::{MatroskaSpec, SimpleBlock};
 
let variant = &MatroskaSpec::SimpleBlock(vec![0x81,0x00,0x01,0x9d,0x00,0x00,0x00]);
let mut simple_block: SimpleBlock = variant.try_into().unwrap();
assert_eq!(true, simple_block.discardable);

Fields§

§track: u64§timestamp: i16§invisible: bool§lacing: Option<BlockLacing>§discardable: bool§keyframe: bool

Implementations§

Source§

impl<'a> SimpleBlock<'a>

Source

pub fn raw_frame_data(&self) -> &[u8]

Reads the raw frame data of the simple block.

Frame data can be formatted differently depending on the block lacing. Generally, it is easier to use Self::read_frame_data() rather than this method to access the frames in the block. This method is provided in the event raw packet data needs to be handled in a special way (for example, if the data is encrypted).

Source

pub fn read_frame_data(&self) -> Result<Vec<Frame<'_>>, WebmCoercionError>

Reads the frames encoded in the simple block.

This method outputs the binary frames encoded in the block, taking into account any block lacing. Details on block lacing can be found in the Matroska spec.

§Errors

This method can return an error if the frame data is malformed.

Source

pub fn set_frame_data(&mut self, frames: &Vec<Frame<'_>>)

Updates the frame data contained in the simple block.

This method writes frame data to a newly allocated vector owned by the block. Future calls to Self::read_frame_data() and Self::raw_frame_data() will use the data set via this method.

§Panics

This method can panic if the block has its lacing set as [’BlockLacing::FixedSize`] and the input frames are not all the same length.

Source

pub fn new_uncheked( frame_data: &'a [u8], track: u64, timestamp: i16, invisible: bool, lacing: Option<BlockLacing>, discardable: bool, keyframe: bool, ) -> Self

Creates a new simple block with the given data.

Primarily used when you want to write with a given frame. For example, when you want to remux a video with libvpx.

§Safety

The frame data is not checked for validity.

Trait Implementations§

Source§

impl<'a> Clone for SimpleBlock<'a>

Source§

fn clone(&self) -> SimpleBlock<'a>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for SimpleBlock<'a>

Source§

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

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

impl<'a> From<SimpleBlock<'a>> for MatroskaSpec

Source§

fn from(simple_block: SimpleBlock<'_>) -> Self

Converts to this type from the input type.
Source§

impl<'a> TryFrom<&'a [u8]> for SimpleBlock<'a>

Source§

type Error = WebmCoercionError

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

fn try_from(data: &'a [u8]) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a MatroskaSpec> for SimpleBlock<'a>

Source§

type Error = WebmCoercionError

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

fn try_from(value: &'a MatroskaSpec) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl<'a> TryFrom<&'a Vec<u8>> for SimpleBlock<'a>

Source§

type Error = WebmCoercionError

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

fn try_from(value: &'a Vec<u8>) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

§

impl<'a> Freeze for SimpleBlock<'a>

§

impl<'a> RefUnwindSafe for SimpleBlock<'a>

§

impl<'a> Send for SimpleBlock<'a>

§

impl<'a> Sync for SimpleBlock<'a>

§

impl<'a> Unpin for SimpleBlock<'a>

§

impl<'a> UnwindSafe for SimpleBlock<'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, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. 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> 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 = 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.