aboutsummaryrefslogtreecommitdiff
path: root/stream/src
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2026-02-19 00:57:18 +0100
committermetamuffin <metamuffin@disroot.org>2026-02-19 00:57:18 +0100
commit696f4e060b932c5987c4796dae560fe95754aaa1 (patch)
tree925e7b2d19f0cca51355b8bbf6fe651be815cc11 /stream/src
parent1adce5a199952eb6fd3f9ebfc7038f5e479e5271 (diff)
downloadjellything-696f4e060b932c5987c4796dae560fe95754aaa1.tar
jellything-696f4e060b932c5987c4796dae560fe95754aaa1.tar.bz2
jellything-696f4e060b932c5987c4796dae560fe95754aaa1.tar.zst
fix server-side video playback
Diffstat (limited to 'stream/src')
-rw-r--r--stream/src/lib.rs12
-rw-r--r--stream/src/stream_info.rs16
2 files changed, 10 insertions, 18 deletions
diff --git a/stream/src/lib.rs b/stream/src/lib.rs
index 424e44b..1407643 100644
--- a/stream/src/lib.rs
+++ b/stream/src/lib.rs
@@ -25,7 +25,7 @@ use std::{
io::{Read, Seek, SeekFrom},
ops::Range,
path::PathBuf,
- sync::{Arc, LazyLock, Mutex},
+ sync::Arc,
};
use stream_info::{stream_info, write_stream_info};
@@ -39,19 +39,11 @@ pub struct Config {
#[serde(default)] pub offer_av1: bool,
}
-pub static CONF_PRELOAD: Mutex<Option<Config>> = Mutex::new(None);
-static CONF: LazyLock<Config> = LazyLock::new(|| {
- CONF_PRELOAD
- .lock()
- .unwrap()
- .take()
- .expect("stream config not preloaded. logic error")
-});
-
pub struct SMediaInfo {
pub title: Option<String>,
pub files: BTreeSet<PathBuf>,
pub cache: Arc<Cache>,
+ pub config: Arc<Config>,
}
pub struct StreamHead {
diff --git a/stream/src/stream_info.rs b/stream/src/stream_info.rs
index 33dd288..694a44f 100644
--- a/stream/src/stream_info.rs
+++ b/stream/src/stream_info.rs
@@ -3,7 +3,7 @@
which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
Copyright (C) 2026 metamuffin <metamuffin.org>
*/
-use crate::{CONF, SMediaInfo, cues::generate_cues, metadata::read_metadata};
+use crate::{Config, SMediaInfo, cues::generate_cues, metadata::read_metadata};
use anyhow::Result;
use jellyremuxer::matroska::{self, Segment, TrackEntry, TrackType};
use jellystream_types::{
@@ -47,7 +47,7 @@ pub(crate) fn stream_info(info: &SMediaInfo) -> Result<(InternalStreamInfo, Stre
matroska::TrackType::Subtitle => TrackKind::Subtitle,
_ => todo!(),
},
- formats: stream_formats(t, byterate * 8.),
+ formats: stream_formats(&info.config, t, byterate * 8.),
});
track_to_file.push((i, t.track_number));
}
@@ -71,7 +71,7 @@ pub(crate) fn stream_info(info: &SMediaInfo) -> Result<(InternalStreamInfo, Stre
))
}
-fn stream_formats(t: &TrackEntry, remux_bitrate: f64) -> Vec<StreamFormatInfo> {
+fn stream_formats(config: &Config, t: &TrackEntry, remux_bitrate: f64) -> Vec<StreamFormatInfo> {
let mut formats = Vec::new();
formats.push(StreamFormatInfo {
codec: t.codec_id.to_string(),
@@ -103,11 +103,11 @@ fn stream_formats(t: &TrackEntry, remux_bitrate: f64) -> Vec<StreamFormatInfo> {
// most codecs use chroma subsampling that requires even dims
let h = ((w * sh) / sw) & !1; // clear last bit to ensure even height.
for (cid, enable) in [
- ("V_AV1", CONF.offer_av1),
- ("V_VP8", CONF.offer_vp8),
- ("V_VP9", CONF.offer_vp9),
- ("V_MPEG4/ISO/AVC", CONF.offer_avc),
- ("V_MPEGH/ISO/HEVC", CONF.offer_hevc),
+ ("V_AV1", config.offer_av1),
+ ("V_VP8", config.offer_vp8),
+ ("V_VP9", config.offer_vp9),
+ ("V_MPEG4/ISO/AVC", config.offer_avc),
+ ("V_MPEGH/ISO/HEVC", config.offer_hevc),
] {
if enable {
formats.push(StreamFormatInfo {