aboutsummaryrefslogtreecommitdiff
path: root/common/src
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-04-14 13:41:42 +0200
committermetamuffin <metamuffin@disroot.org>2025-04-14 13:41:42 +0200
commita3afc2756a52f7d6fedc928b97c8ff3eb1ade338 (patch)
tree9bb043975a6b92e45bbc2f09e19641f1109950b1 /common/src
parent48a57a52d85d387efe122fb4d9fb113f577a0a98 (diff)
downloadjellything-a3afc2756a52f7d6fedc928b97c8ff3eb1ade338.tar
jellything-a3afc2756a52f7d6fedc928b97c8ff3eb1ade338.tar.bz2
jellything-a3afc2756a52f7d6fedc928b97c8ff3eb1ade338.tar.zst
lots of rewriting and removing dumb code
Diffstat (limited to 'common/src')
-rw-r--r--common/src/lib.rs1
-rw-r--r--common/src/stream.rs53
2 files changed, 35 insertions, 19 deletions
diff --git a/common/src/lib.rs b/common/src/lib.rs
index ce333eb..00f07b6 100644
--- a/common/src/lib.rs
+++ b/common/src/lib.rs
@@ -171,7 +171,6 @@ pub type TrackID = usize;
pub struct LocalTrack {
pub path: PathBuf,
pub track: TrackID,
- pub codec_private: Option<Vec<u8>>,
}
#[derive(Debug, Clone, Deserialize, Serialize, Encode, Decode)]
diff --git a/common/src/stream.rs b/common/src/stream.rs
index a06dad5..75349cc 100644
--- a/common/src/stream.rs
+++ b/common/src/stream.rs
@@ -6,10 +6,15 @@
use serde::{Deserialize, Serialize};
use std::{collections::BTreeMap, fmt::Display, str::FromStr};
+pub type SegmentNum = usize;
+pub type TrackNum = usize;
+pub type FormatNum = usize;
+pub type IndexNum = usize;
+
#[derive(Debug, Clone, Deserialize, Serialize)]
pub enum StreamSpec {
Whep {
- track: usize,
+ track: TrackNum,
seek: u64,
},
WhepControl {
@@ -20,34 +25,34 @@ pub enum StreamSpec {
container: StreamContainer,
},
Original {
- track: usize,
+ track: TrackNum,
},
HlsSuperMultiVariant {
container: StreamContainer,
},
HlsMultiVariant {
- segment: u64,
+ segment: SegmentNum,
container: StreamContainer,
},
HlsVariant {
- segment: u64,
- track: usize,
+ segment: SegmentNum,
+ track: TrackNum,
container: StreamContainer,
- format: usize,
+ format: FormatNum,
},
Info {
segment: Option<u64>,
},
FragmentIndex {
- segment: u64,
- track: usize,
+ segment: SegmentNum,
+ track: TrackNum,
},
Fragment {
- segment: u64,
- track: usize,
- index: u64,
+ segment: SegmentNum,
+ track: TrackNum,
+ index: IndexNum,
container: StreamContainer,
- format: usize,
+ format: FormatNum,
},
}
@@ -60,7 +65,7 @@ pub struct StreamInfo {
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct StreamSegmentInfo {
pub name: Option<String>,
- pub duration: u64,
+ pub duration: f64,
pub tracks: Vec<StreamTrackInfo>,
}
@@ -92,7 +97,7 @@ pub struct StreamFormatInfo {
pub bit_depth: Option<u8>,
}
-#[derive(Debug, Clone, Copy, Deserialize, Serialize)]
+#[derive(Debug, Clone, Copy, PartialEq, Eq, Deserialize, Serialize)]
#[serde(rename_all = "lowercase")]
pub enum StreamContainer {
WebM,
@@ -164,13 +169,25 @@ impl StreamSpec {
Ok(Self::Info {
segment: get_num("segment").ok(),
})
+ } else if query.contains_key("hlsmultivariant") {
+ Ok(Self::HlsMultiVariant {
+ segment: get_num("segment")? as SegmentNum,
+ container: get_container()?,
+ })
+ } else if query.contains_key("hlsvariant") {
+ Ok(Self::HlsVariant {
+ segment: get_num("segment")? as SegmentNum,
+ track: get_num("track")? as TrackNum,
+ format: get_num("format")? as FormatNum,
+ container: get_container()?,
+ })
} else if query.contains_key("fragment") {
Ok(Self::Fragment {
- segment: get_num("segment")?,
- track: get_num("track")? as usize,
- index: get_num("index")?,
+ segment: get_num("segment")? as SegmentNum,
+ track: get_num("track")? as TrackNum,
+ format: get_num("format")? as FormatNum,
+ index: get_num("index")? as IndexNum,
container: get_container()?,
- format: get_num("format")? as usize,
})
} else {
Err("invalid stream spec")