aboutsummaryrefslogtreecommitdiff
path: root/common/src/lib.rs
blob: 28ce5a8c973ad7783943b49fd258aee39d3f217c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
pub mod r#impl;

use bincode::{Decode, Encode};
use serde::{Deserialize, Serialize};
use std::{collections::BTreeMap, path::PathBuf};

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct DirectoryInfo {
    pub name: String,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct ItemInfo {
    pub title: String,
    pub duration: f64, // in seconds
    pub description_head: String,
    pub description: String,
    pub banner: Option<PathBuf>,
    pub tracks: BTreeMap<usize, SourceTrack>,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct SourceTrack {
    pub path: PathBuf,
    pub track_number: u64,
    pub kind: SourceTrackKind,
    pub name: String,
    pub codec: String,
    pub language: String,
    pub default_duration: Option<u64>,
    pub codec_private: Option<Vec<u8>>,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "snake_case")]
pub enum SourceTrackKind {
    Video {
        width: u64,
        height: u64,
        fps: f64,
    },
    Audio {
        channels: usize,
        sample_rate: f64,
        bit_depth: usize,
    },
    Subtitles,
}

#[derive(Debug, Clone, Decode, Encode)]
pub struct SeekIndex {
    pub blocks: Vec<BlockIndex>,
}

#[derive(Debug, Clone, Decode, Encode)]
pub struct BlockIndex {
    pub pts: u64,
    pub source_off: usize,
    pub size: usize,
}