Struct webm_iterable::matroska_spec::Block
source · 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.