aboutsummaryrefslogtreecommitdiff
path: root/remuxer/src
diff options
context:
space:
mode:
Diffstat (limited to 'remuxer/src')
-rw-r--r--remuxer/src/metadata.rs24
-rw-r--r--remuxer/src/seek_index.rs6
2 files changed, 12 insertions, 18 deletions
diff --git a/remuxer/src/metadata.rs b/remuxer/src/metadata.rs
index c8a5f8f..4a496fe 100644
--- a/remuxer/src/metadata.rs
+++ b/remuxer/src/metadata.rs
@@ -33,20 +33,17 @@ pub struct MatroskaMetadata {
pub infojson: Option<Vec<u8>>,
}
pub fn checked_matroska_metadata(path: &Path) -> Result<Arc<Option<MatroskaMetadata>>> {
- cache_memory(
- &["mkmeta-check-v1", path.to_string_lossy().as_ref()],
- || {
- let mut magic = [0; 4];
- File::open(path)?.read_exact(&mut magic).ok();
- if !matches!(magic, [0x1A, 0x45, 0xDF, 0xA3]) {
- return Ok(None);
- }
- Ok(Some((*matroska_metadata(path)?).clone()))
- },
- )
+ cache_memory("mkmeta-check-v1", path, || {
+ let mut magic = [0; 4];
+ File::open(path)?.read_exact(&mut magic).ok();
+ if !matches!(magic, [0x1A, 0x45, 0xDF, 0xA3]) {
+ return Ok(None);
+ }
+ Ok(Some((*matroska_metadata(path)?).clone()))
+ })
}
pub fn matroska_metadata(path: &Path) -> Result<Arc<MatroskaMetadata>> {
- cache_memory(&["mkmeta-v3", path.to_string_lossy().as_ref()], || {
+ cache_memory("mkmeta-v3", path, || {
info!("reading {path:?}");
let mut file = BufReader::new(File::open(path)?);
let mut file = file.by_ref().take(u64::MAX);
@@ -86,7 +83,8 @@ pub fn matroska_metadata(path: &Path) -> Result<Arc<MatroskaMetadata>> {
| "cover.avif" => {
cover = Some(
AssetInner::Cache(cache_file(
- &["att-cover", path.to_string_lossy().as_ref()],
+ "att-cover",
+ path,
move |mut file| {
file.write_all(&f.data)?;
Ok(())
diff --git a/remuxer/src/seek_index.rs b/remuxer/src/seek_index.rs
index 82f62fb..1e1ce02 100644
--- a/remuxer/src/seek_index.rs
+++ b/remuxer/src/seek_index.rs
@@ -15,11 +15,8 @@ use jellymatroska::{
use log::{debug, info, trace, warn};
use std::{collections::BTreeMap, fs::File, io::BufReader, path::Path, sync::Arc};
-pub const SEEK_INDEX_VERSION: u32 = 0x5eef1de4;
-
#[derive(Debug, Clone, Decode, Encode)]
pub struct SeekIndex {
- pub version: u32,
pub blocks: Vec<BlockIndex>,
pub keyframes: Vec<usize>,
}
@@ -35,7 +32,6 @@ pub struct BlockIndex {
impl Default for SeekIndex {
fn default() -> Self {
Self {
- version: SEEK_INDEX_VERSION,
blocks: Vec::new(),
keyframes: Vec::new(),
}
@@ -43,7 +39,7 @@ impl Default for SeekIndex {
}
pub fn get_seek_index(path: &Path) -> anyhow::Result<Arc<BTreeMap<u64, Arc<SeekIndex>>>> {
- cache_memory(&["seekindex", path.to_str().unwrap()], move || {
+ cache_memory("seekindex-v1", path, move || {
info!("generating seek index for {path:?}");
let input = File::open(path).context("opening source file")?;
let mut input = EbmlReader::new(BufReader::new(input));