pub struct Block<'a> {
pub track: u64,
pub timestamp: i16,
pub invisible: bool,
pub lacing: Option<BlockLacing>,
/* private fields */
}
Expand description
A typed interpretation of the Matroska “Block” element.
This struct has fields specific to the Block element as defined by the Matroska Spec. This struct implements TryFrom<&MatroskaSpec>
and Into<MatroskaSpec>
to simplify coercion to and from regular variants.
§Example
use webm_iterable::matroska_spec::{MatroskaSpec, Block};
let variant = &MatroskaSpec::Block(vec![0x83,0x00,0x01,0x9d,0x00,0x00,0x00]);
let mut block: Block = variant.try_into().unwrap();
assert_eq!(3, block.track);
Fields§
§track: u64
§timestamp: i16
§invisible: bool
§lacing: Option<BlockLacing>
Implementations§
Source§impl<'a> Block<'a>
impl<'a> Block<'a>
Sourcepub fn raw_frame_data(&self) -> &[u8] ⓘ
pub fn raw_frame_data(&self) -> &[u8] ⓘ
Reads the raw frame data of the 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 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 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(
track: u64,
timestamp: i16,
invisible: bool,
lacing: Option<BlockLacing>,
frame_data: &'a [u8],
) -> Self
pub fn new_uncheked( track: u64, timestamp: i16, invisible: bool, lacing: Option<BlockLacing>, frame_data: &'a [u8], ) -> Self
Creates a new block with the given data.
Primarily used if you would like to write with a given frame. For example, when you want to remux a video with libvpx.
Trait Implementations§
Source§impl<'a> From<Block<'a>> for MatroskaSpec
impl<'a> From<Block<'a>> for MatroskaSpec
Source§impl<'a> TryFrom<&'a MatroskaSpec> for Block<'a>
impl<'a> TryFrom<&'a MatroskaSpec> for Block<'a>
Source§type Error = WebmCoercionError
type Error = WebmCoercionError
Auto Trait Implementations§
impl<'a> Freeze for Block<'a>
impl<'a> RefUnwindSafe for Block<'a>
impl<'a> Send for Block<'a>
impl<'a> Sync for Block<'a>
impl<'a> Unpin for Block<'a>
impl<'a> UnwindSafe for Block<'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
)