diff options
author | metamuffin <metamuffin@disroot.org> | 2023-09-29 20:56:36 +0200 |
---|---|---|
committer | metamuffin <metamuffin@disroot.org> | 2023-09-29 20:56:36 +0200 |
commit | c62eb3a2fdaa80f472be6ecbfc2cbf2479d8d914 (patch) | |
tree | 7a32678b59c123ea6fbe6c01237aec5e3b143e87 /common/src | |
parent | 29b12a48bcfa3aa0f814f7b39a64868b6313c13d (diff) | |
download | jellything-c62eb3a2fdaa80f472be6ecbfc2cbf2479d8d914.tar jellything-c62eb3a2fdaa80f472be6ecbfc2cbf2479d8d914.tar.bz2 jellything-c62eb3a2fdaa80f472be6ecbfc2cbf2479d8d914.tar.zst |
move stream generation to new crate
Diffstat (limited to 'common/src')
-rw-r--r-- | common/src/lib.rs | 5 | ||||
-rw-r--r-- | common/src/stream.rs | 38 |
2 files changed, 42 insertions, 1 deletions
diff --git a/common/src/lib.rs b/common/src/lib.rs index 6c76903..b7f975a 100644 --- a/common/src/lib.rs +++ b/common/src/lib.rs @@ -6,6 +6,7 @@ pub mod config; pub mod helpers; pub mod r#impl; +pub mod stream; use bincode::{Decode, Encode}; #[cfg(feature = "rocket")] @@ -88,10 +89,12 @@ pub enum PublicMediaSource { Remote(String), } +pub type TrackID = usize; + #[derive(Debug, Clone, Deserialize, Serialize)] pub struct LocalTrack { pub path: PathBuf, - pub track: usize, + pub track: TrackID, pub codec_private: Option<Vec<u8>>, } diff --git a/common/src/stream.rs b/common/src/stream.rs new file mode 100644 index 0000000..59166b8 --- /dev/null +++ b/common/src/stream.rs @@ -0,0 +1,38 @@ +#[cfg(feature = "rocket")] +use rocket::{FromForm, FromFormField, UriDisplayQuery}; +use serde::{Deserialize, Serialize}; + +#[derive(Debug, Clone, Deserialize, Serialize)] +#[cfg_attr(feature = "rocket", derive(FromForm, UriDisplayQuery))] +pub struct StreamSpec { + pub tracks: Vec<usize>, + pub format: StreamFormat, + pub abr: Option<usize>, + pub vbr: Option<usize>, + pub index: Option<usize>, +} + +#[rustfmt::skip] +#[derive(Debug, Clone, Deserialize, Serialize)] +#[serde(rename_all = "snake_case")] +#[cfg_attr(feature = "rocket", derive(FromFormField, UriDisplayQuery))] +pub enum StreamFormat { + #[cfg_attr(feature = "rocket", field(value = "original"))] Original, + #[cfg_attr(feature = "rocket", field(value = "matroska"))] Matroska, + #[cfg_attr(feature = "rocket", field(value = "webm"))] Webm, + #[cfg_attr(feature = "rocket", field(value = "hls"))] Hls, + #[cfg_attr(feature = "rocket", field(value = "jhls"))] Jhls, + #[cfg_attr(feature = "rocket", field(value = "hlsseg"))] Segment, +} + +impl Default for StreamSpec { + fn default() -> Self { + Self { + tracks: Default::default(), + format: StreamFormat::Webm, + abr: Default::default(), + vbr: Default::default(), + index: Default::default(), + } + } +} |