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
|
/*
This file is part of jellything (https://codeberg.org/metamuffin/jellything)
which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
Copyright (C) 2023 metamuffin <metamuffin.org>
*/
use crate::{AssetRole, SourceTrack, SourceTrackKind};
impl SourceTrackKind {
pub fn letter(&self) -> char {
match self {
SourceTrackKind::Video { .. } => 'v',
SourceTrackKind::Audio { .. } => 'a',
SourceTrackKind::Subtitles => 's',
}
}
}
impl AssetRole {
pub fn as_str(&self) -> &'static str {
match self {
AssetRole::Poster => "poster",
AssetRole::Backdrop => "backdrop",
}
}
}
impl std::fmt::Display for SourceTrack {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let kspec = match &self.kind {
SourceTrackKind::Video { width, height, fps } => {
format!("Video: {width}x{height} {fps}fps ")
}
SourceTrackKind::Audio {
channels,
sample_rate,
bit_depth,
} => format!("Audio: {channels}ch {sample_rate}Hz {bit_depth}bits "),
SourceTrackKind::Subtitles => "Subtitles: ".to_string(),
};
f.write_fmt(format_args!(
"{} {:?} {} ({})",
kspec, self.name, self.language, self.codec
))
}
}
|