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>
impl<'a> SimpleBlock<'a>
Sourcepub fn raw_frame_data(&self) -> &[u8] ⓘ
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).
Sourcepub fn read_frame_data(&self) -> Result<Vec<Frame<'_>>, WebmCoercionError>
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.
Sourcepub fn set_frame_data(&mut self, frames: &Vec<Frame<'_>>)
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.
Sourcepub fn new_uncheked(
frame_data: &'a [u8],
track: u64,
timestamp: i16,
invisible: bool,
lacing: Option<BlockLacing>,
discardable: bool,
keyframe: bool,
) -> Self
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>
impl<'a> Clone for SimpleBlock<'a>
Source§fn clone(&self) -> SimpleBlock<'a>
fn clone(&self) -> SimpleBlock<'a>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<'a> Debug for SimpleBlock<'a>
impl<'a> Debug for SimpleBlock<'a>
Source§impl<'a> From<SimpleBlock<'a>> for MatroskaSpec
impl<'a> From<SimpleBlock<'a>> for MatroskaSpec
Source§fn from(simple_block: SimpleBlock<'_>) -> Self
fn from(simple_block: SimpleBlock<'_>) -> Self
Source§impl<'a> TryFrom<&'a [u8]> for SimpleBlock<'a>
impl<'a> TryFrom<&'a [u8]> for SimpleBlock<'a>
Source§impl<'a> TryFrom<&'a MatroskaSpec> for SimpleBlock<'a>
impl<'a> TryFrom<&'a MatroskaSpec> for SimpleBlock<'a>
Source§type Error = WebmCoercionError
type Error = WebmCoercionError
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)