diff options
author | metamuffin <metamuffin@disroot.org> | 2025-04-16 14:53:58 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-04-16 14:53:58 +0200 |
commit | edfd710c055621d7ef0c8d0e9c6668b4aa2283d7 (patch) | |
tree | 1efec517324f8bda72a2b365e82c23081b4f5898 /remuxer | |
parent | a9c897c7d7df5509a195055e95dfa821fe7aa274 (diff) | |
download | jellything-edfd710c055621d7ef0c8d0e9c6668b4aa2283d7.tar jellything-edfd710c055621d7ef0c8d0e9c6668b4aa2283d7.tar.bz2 jellything-edfd710c055621d7ef0c8d0e9c6668b4aa2283d7.tar.zst |
move seek index types to remuxer
Diffstat (limited to 'remuxer')
-rw-r--r-- | remuxer/src/seek_index.rs | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/remuxer/src/seek_index.rs b/remuxer/src/seek_index.rs index bd351d9..7296d93 100644 --- a/remuxer/src/seek_index.rs +++ b/remuxer/src/seek_index.rs @@ -4,10 +4,8 @@ Copyright (C) 2025 metamuffin <metamuffin.org> */ use anyhow::{Context, Result}; -use jellybase::{ - cache::cache_memory, - common::seek_index::{BlockIndex, SeekIndex}, -}; +use bincode::{Decode, Encode}; +use jellybase::cache::cache_memory; use jellymatroska::{ block::Block, read::EbmlReader, @@ -17,6 +15,33 @@ 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>, +} + +#[derive(Debug, Clone, Decode, Encode)] +pub struct BlockIndex { + pub pts: u64, + // pub duration: Option<u64>, + pub source_off: u64, // points to start of SimpleBlock or BlockGroup (not the Block inside it) + pub size: usize, +} + +impl Default for SeekIndex { + fn default() -> Self { + Self { + version: SEEK_INDEX_VERSION, + blocks: Vec::new(), + keyframes: Vec::new(), + } + } +} + pub fn get_seek_index(path: &Path) -> anyhow::Result<Arc<BTreeMap<u64, Arc<SeekIndex>>>> { cache_memory(&["seekindex", path.to_str().unwrap()], move || { info!("generating seek index for {path:?}"); |