aboutsummaryrefslogtreecommitdiff
path: root/matroska/src
diff options
context:
space:
mode:
Diffstat (limited to 'matroska/src')
-rw-r--r--matroska/src/block.rs19
1 files changed, 18 insertions, 1 deletions
diff --git a/matroska/src/block.rs b/matroska/src/block.rs
index b0d6f6b..dd5b340 100644
--- a/matroska/src/block.rs
+++ b/matroska/src/block.rs
@@ -1,4 +1,4 @@
-use crate::read::ReadExt;
+use crate::{read::ReadExt, write::write_vint};
use anyhow::Result;
use std::io::Cursor;
@@ -40,4 +40,21 @@ impl Block {
timestamp_off,
})
}
+ pub fn dump(&self) -> Vec<u8> {
+ let mut out = vec![];
+ write_vint(&mut out, self.track).unwrap();
+ out.extend(self.timestamp_off.to_be_bytes().into_iter());
+ out.push(
+ match self.invisible {
+ true => 0b10000,
+ false => 0b00000,
+ } | match self.lacing {
+ Some(LacingType::Xiph) => 0b0100,
+ Some(LacingType::Ebml) => 0b1000,
+ Some(LacingType::FixedSize) => 0b1100,
+ None => 0b0000,
+ },
+ );
+ out
+ }
}