diff options
author | metamuffin <metamuffin@disroot.org> | 2025-04-06 15:40:58 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2025-04-06 15:40:58 +0200 |
commit | 7acb520f552bd1edde5c29fbf5baf6643ec4b14e (patch) | |
tree | 222fa1d582d039b00da50735b62573db8bdc1f9d /common | |
parent | 80343d02e9e29e4bc55d790b491ce0d0c7bff201 (diff) | |
download | jellything-7acb520f552bd1edde5c29fbf5baf6643ec4b14e.tar jellything-7acb520f552bd1edde5c29fbf5baf6643ec4b14e.tar.bz2 jellything-7acb520f552bd1edde5c29fbf5baf6643ec4b14e.tar.zst |
a bit more progress on new streaming api
Diffstat (limited to 'common')
-rw-r--r-- | common/src/stream.rs | 47 |
1 files changed, 46 insertions, 1 deletions
diff --git a/common/src/stream.rs b/common/src/stream.rs index 9a00ce0..a06dad5 100644 --- a/common/src/stream.rs +++ b/common/src/stream.rs @@ -51,6 +51,47 @@ pub enum StreamSpec { }, } +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct StreamInfo { + pub name: Option<String>, + pub segments: Vec<StreamSegmentInfo>, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct StreamSegmentInfo { + pub name: Option<String>, + pub duration: u64, + pub tracks: Vec<StreamTrackInfo>, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +pub struct StreamTrackInfo { + pub name: Option<String>, + pub kind: TrackKind, + pub formats: Vec<StreamFormatInfo>, +} + +#[derive(Debug, Clone, Deserialize, Serialize)] +#[serde(rename_all = "snake_case")] +pub enum TrackKind { + Video, + Audio, + Subtitle, +} + +#[derive(Debug, Clone, Deserialize, Serialize, Default)] +pub struct StreamFormatInfo { + pub codec: String, + pub byterate: f64, + pub remux: bool, + pub containers: Vec<StreamContainer>, + + pub pixel_count: Option<u64>, + pub samplerate: Option<f64>, + pub channels: Option<usize>, + pub bit_depth: Option<u8>, +} + #[derive(Debug, Clone, Copy, Deserialize, Serialize)] #[serde(rename_all = "lowercase")] pub enum StreamContainer { @@ -119,7 +160,11 @@ impl StreamSpec { .ok_or("container") .and_then(|s| s.parse().map_err(|()| "unknown container")) }; - if query.contains_key("fragment") { + if query.contains_key("info") { + Ok(Self::Info { + segment: get_num("segment").ok(), + }) + } else if query.contains_key("fragment") { Ok(Self::Fragment { segment: get_num("segment")?, track: get_num("track")? as usize, |