aboutsummaryrefslogtreecommitdiff
path: root/stream
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2025-04-27 20:00:44 +0200
committermetamuffin <metamuffin@disroot.org>2025-04-27 20:00:44 +0200
commit335ba978dbaf203f3603a815147fd75dbf205723 (patch)
tree57f7959b6f81ad469ddd3062f2e43f88670a08e4 /stream
parent11a585b3dbe620dcc8772e713b22f1d9ba80d598 (diff)
downloadjellything-335ba978dbaf203f3603a815147fd75dbf205723.tar
jellything-335ba978dbaf203f3603a815147fd75dbf205723.tar.bz2
jellything-335ba978dbaf203f3603a815147fd75dbf205723.tar.zst
move cache to own crate
Diffstat (limited to 'stream')
-rw-r--r--stream/Cargo.toml4
-rw-r--r--stream/src/fragment.rs2
-rw-r--r--stream/src/fragment_index.rs2
-rw-r--r--stream/src/hls.rs4
-rw-r--r--stream/src/lib.rs30
-rw-r--r--stream/src/stream_info.rs20
-rw-r--r--stream/src/webvtt.rs2
7 files changed, 43 insertions, 21 deletions
diff --git a/stream/Cargo.toml b/stream/Cargo.toml
index 21d1650..ad6f098 100644
--- a/stream/Cargo.toml
+++ b/stream/Cargo.toml
@@ -4,7 +4,8 @@ version = "0.1.0"
edition = "2021"
[dependencies]
-jellybase = { path = "../base", features = ["rocket"] }
+jellycommon = { path = "../common" }
+jellycache = { path = "../cache" }
jellytranscoder = { path = "../transcoder" }
jellyremuxer = { path = "../remuxer" }
jellymatroska = { path = "../matroska" }
@@ -15,3 +16,4 @@ anyhow = { workspace = true }
tokio = { version = "1.43.0", features = ["io-util"] }
tokio-util = { version = "0.7.13", features = ["io", "io-util"] }
serde_json = "1.0.138"
+serde = { version = "1.0.217", features = ["derive"] }
diff --git a/stream/src/fragment.rs b/stream/src/fragment.rs
index 9e8c3bd..205c302 100644
--- a/stream/src/fragment.rs
+++ b/stream/src/fragment.rs
@@ -5,7 +5,7 @@
*/
use crate::{stream_info, SMediaInfo};
use anyhow::{anyhow, bail, Result};
-use jellybase::common::stream::StreamContainer;
+use jellycommon::stream::StreamContainer;
use jellyremuxer::{matroska_to_mpeg4, matroska_to_webm::matroska_to_webm};
use jellytranscoder::fragment::transcode;
use log::warn;
diff --git a/stream/src/fragment_index.rs b/stream/src/fragment_index.rs
index 6fbddc6..0632f0a 100644
--- a/stream/src/fragment_index.rs
+++ b/stream/src/fragment_index.rs
@@ -5,7 +5,7 @@
*/
use crate::{stream_info, SMediaInfo};
use anyhow::{anyhow, Result};
-use jellybase::common::stream::{SegmentNum, TrackNum};
+use jellycommon::stream::{SegmentNum, TrackNum};
use std::sync::Arc;
use tokio::io::{AsyncWriteExt, DuplexStream};
diff --git a/stream/src/hls.rs b/stream/src/hls.rs
index 3dfbf01..0ca7545 100644
--- a/stream/src/hls.rs
+++ b/stream/src/hls.rs
@@ -6,9 +6,7 @@
use crate::{stream_info, SMediaInfo};
use anyhow::{anyhow, Result};
-use jellybase::common::stream::{
- FormatNum, SegmentNum, StreamContainer, StreamSpec, TrackKind, TrackNum,
-};
+use jellycommon::stream::{FormatNum, SegmentNum, StreamContainer, StreamSpec, TrackKind, TrackNum};
use std::{fmt::Write, ops::Range, sync::Arc};
use tokio::{
io::{AsyncWriteExt, DuplexStream},
diff --git a/stream/src/lib.rs b/stream/src/lib.rs
index 4df87ae..ccc5cb9 100644
--- a/stream/src/lib.rs
+++ b/stream/src/lib.rs
@@ -14,17 +14,43 @@ use anyhow::{anyhow, bail, Context, Result};
use fragment::fragment_stream;
use fragment_index::fragment_index_stream;
use hls::{hls_multivariant_stream, hls_supermultivariant_stream, hls_variant_stream};
-use jellybase::common::{
+use jellycommon::{
stream::{StreamContainer, StreamSpec},
Node,
};
-use std::{collections::BTreeSet, io::SeekFrom, ops::Range, path::PathBuf, sync::Arc};
+use serde::{Deserialize, Serialize};
+use std::{
+ collections::BTreeSet,
+ io::SeekFrom,
+ ops::Range,
+ path::PathBuf,
+ sync::{Arc, LazyLock},
+};
use stream_info::{stream_info, write_stream_info};
use tokio::{
fs::File,
io::{duplex, AsyncReadExt, AsyncSeekExt, AsyncWriteExt, DuplexStream},
+ sync::Mutex,
};
+#[rustfmt::skip]
+#[derive(Debug, Deserialize, Serialize, Default)]
+pub struct Config {
+ #[serde(default)] pub offer_avc: bool,
+ #[serde(default)] pub offer_hevc: bool,
+ #[serde(default)] pub offer_vp8: bool,
+ #[serde(default)] pub offer_vp9: bool,
+ #[serde(default)] pub offer_av1: bool,
+}
+
+static CONF: LazyLock<Config> = LazyLock::new(|| {
+ CONF_PRELOAD
+ .blocking_lock()
+ .take()
+ .expect("cache config not preloaded. logic error")
+});
+static CONF_PRELOAD: Mutex<Option<Config>> = Mutex::const_new(None);
+
#[derive(Debug)]
pub struct SMediaInfo {
pub info: Arc<Node>,
diff --git a/stream/src/stream_info.rs b/stream/src/stream_info.rs
index ba6cc98..6f7824e 100644
--- a/stream/src/stream_info.rs
+++ b/stream/src/stream_info.rs
@@ -3,15 +3,11 @@
which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
Copyright (C) 2025 metamuffin <metamuffin.org>
*/
-use crate::SMediaInfo;
+use crate::{SMediaInfo, CONF};
use anyhow::Result;
use ebml_struct::matroska::TrackEntry;
-use jellybase::{
- common::stream::{
- StreamContainer, StreamFormatInfo, StreamInfo, StreamSegmentInfo, StreamTrackInfo,
- TrackKind,
- },
- CONF,
+use jellycommon::stream::{
+ StreamContainer, StreamFormatInfo, StreamInfo, StreamSegmentInfo, StreamTrackInfo, TrackKind,
};
use jellyremuxer::{
metadata::{matroska_metadata, MatroskaMetadata},
@@ -119,11 +115,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.transcoder.offer_av1),
- ("V_VP8", CONF.transcoder.offer_vp8),
- ("V_VP9", CONF.transcoder.offer_vp9),
- ("V_MPEG4/ISO/AVC", CONF.transcoder.offer_avc),
- ("V_MPEGH/ISO/HEVC", CONF.transcoder.offer_hevc),
+ ("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),
] {
if enable {
formats.push(StreamFormatInfo {
diff --git a/stream/src/webvtt.rs b/stream/src/webvtt.rs
index e9f0181..c0bc466 100644
--- a/stream/src/webvtt.rs
+++ b/stream/src/webvtt.rs
@@ -4,7 +4,7 @@
Copyright (C) 2025 metamuffin <metamuffin.org>
*/
use anyhow::Result;
-use jellybase::common::{stream::StreamSpec, Node};
+use jellycommon::{stream::StreamSpec, Node};
use std::sync::Arc;
use tokio::io::DuplexStream;