aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormetamuffin <metamuffin@disroot.org>2024-01-29 15:03:18 +0100
committermetamuffin <metamuffin@disroot.org>2024-01-29 15:03:18 +0100
commitc0ba30314a06de10c9b98ac130676dcbc9f287fa (patch)
treee35631ed3181f89ae962e9125cc5073f12967924
parent4ad7aa6042c64a6e7cfbe2693a4bbeda0514357b (diff)
downloadjellything-c0ba30314a06de10c9b98ac130676dcbc9f287fa.tar
jellything-c0ba30314a06de10c9b98ac130676dcbc9f287fa.tar.bz2
jellything-c0ba30314a06de10c9b98ac130676dcbc9f287fa.tar.zst
rename stream spec param
-rw-r--r--common/src/stream.rs18
-rw-r--r--server/src/routes/stream.rs6
-rw-r--r--server/src/routes/ui/player.rs4
-rw-r--r--stream/src/fragment.rs4
-rw-r--r--stream/src/hls.rs4
-rw-r--r--stream/src/jhls.rs2
-rw-r--r--stream/src/lib.rs8
-rw-r--r--stream/src/webvtt.rs2
-rw-r--r--web/script/player/track/mse.ts4
-rw-r--r--web/script/player/track/vtt.ts2
10 files changed, 22 insertions, 32 deletions
diff --git a/common/src/stream.rs b/common/src/stream.rs
index d0b1373..3314cb0 100644
--- a/common/src/stream.rs
+++ b/common/src/stream.rs
@@ -11,7 +11,7 @@ use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Deserialize, Serialize)]
#[cfg_attr(feature = "rocket", derive(FromForm, UriDisplayQuery))]
pub struct StreamSpec {
- pub tracks: Vec<usize>,
+ pub track: Vec<usize>,
pub format: StreamFormat,
pub webm: Option<bool>,
pub profile: Option<usize>,
@@ -36,7 +36,7 @@ pub enum StreamFormat {
impl Default for StreamSpec {
fn default() -> Self {
Self {
- tracks: Vec::new(),
+ track: Vec::new(),
format: StreamFormat::Matroska,
webm: Some(true),
profile: None,
@@ -50,18 +50,8 @@ impl StreamSpec {
use std::fmt::Write;
let mut u = String::new();
write!(u, "format={}", self.format.ident()).unwrap();
-
- if !self.tracks.is_empty() {
- write!(
- u,
- "&tracks={}",
- self.tracks
- .iter()
- .map(|s| s.to_string())
- .collect::<Vec<_>>()
- .join(",")
- )
- .unwrap();
+ for t in &self.track {
+ write!(u, "&track={}", t).unwrap();
}
if let Some(profile) = self.profile {
write!(u, "&profile={profile}").unwrap();
diff --git a/server/src/routes/stream.rs b/server/src/routes/stream.rs
index 4c9906d..ecfa3e7 100644
--- a/server/src/routes/stream.rs
+++ b/server/src/routes/stream.rs
@@ -64,8 +64,8 @@ pub async fn r_stream(
.ok_or(anyhow!("item does not contain media"))?;
// TODO its unclear how requests with multiple tracks should be handled.
- if spec.tracks.len() == 1 {
- let ti = spec.tracks[0];
+ if spec.track.len() == 1 {
+ let ti = spec.track[0];
if let TrackSource::Remote(remote_index) = source[ti] {
session
.user
@@ -102,7 +102,7 @@ pub async fn r_stream(
let uri = session.stream_url(
node.public.id.as_ref().unwrap(),
&StreamSpec {
- tracks: vec![remote_index],
+ track: vec![remote_index],
..spec
},
);
diff --git a/server/src/routes/ui/player.rs b/server/src/routes/ui/player.rs
index 7e67709..233547e 100644
--- a/server/src/routes/ui/player.rs
+++ b/server/src/routes/ui/player.rs
@@ -52,7 +52,7 @@ pub fn r_player<'a>(
let item = T_NODE.get(db, id)?.ok_or(anyhow!("node does not exist"))?;
let spec = StreamSpec {
- tracks: None
+ track: None
.into_iter()
.chain(conf.v.into_iter())
.chain(conf.a.into_iter())
@@ -63,7 +63,7 @@ pub fn r_player<'a>(
..Default::default()
};
- let playing = !spec.tracks.is_empty();
+ let playing = !spec.track.is_empty();
let conf = player_conf(item.clone(), playing)?;
Ok(LayoutPage {
diff --git a/stream/src/fragment.rs b/stream/src/fragment.rs
index f08114c..16bb703 100644
--- a/stream/src/fragment.rs
+++ b/stream/src/fragment.rs
@@ -22,10 +22,10 @@ pub async fn fragment_stream(
mut b: DuplexStream,
perms: &PermissionSet,
) -> Result<()> {
- if spec.tracks.len() != 1 {
+ if spec.track.len() != 1 {
bail!("unsupported number of tracks for segment, must be exactly one");
}
- let track = spec.tracks[0];
+ let track = spec.track[0];
let n = spec.index.ok_or(anyhow!("segment index missing"))?;
let local_track = local_tracks
diff --git a/stream/src/hls.rs b/stream/src/hls.rs
index 74f554b..b0e2e31 100644
--- a/stream/src/hls.rs
+++ b/stream/src/hls.rs
@@ -31,7 +31,7 @@ pub async fn hls_master_stream(
let uri = format!(
"stream?{}",
StreamSpec {
- tracks: vec![i],
+ track: vec![i],
format: StreamFormat::HlsVariant,
..Default::default()
}
@@ -56,7 +56,7 @@ pub async fn hls_variant_stream(
mut b: DuplexStream,
) -> Result<()> {
let local_track = local_tracks.get(0).ok_or(anyhow!("no track"))?.to_owned();
- let track_index = spec.tracks[0];
+ let track_index = spec.track[0];
let media_info = node.public.media.to_owned().ok_or(anyhow!("no media?"))?;
let frags = spawn_blocking(move || {
jellyremuxer::fragment::fragment_index(
diff --git a/stream/src/jhls.rs b/stream/src/jhls.rs
index 1313c7a..ac1a3e5 100644
--- a/stream/src/jhls.rs
+++ b/stream/src/jhls.rs
@@ -30,7 +30,7 @@ pub async fn jhls_index(
&CONF.media_path,
&node.public,
&local_track,
- spec.tracks[0],
+ spec.track[0],
)
})
.await??;
diff --git a/stream/src/lib.rs b/stream/src/lib.rs
index 4d96f8c..b62bf1c 100644
--- a/stream/src/lib.rs
+++ b/stream/src/lib.rs
@@ -64,7 +64,7 @@ pub async fn stream(
.ok_or(anyhow!("node has no media"))?;
let local_tracks = spec
- .tracks
+ .track
.iter()
.map(|i| {
anyhow::Ok(
@@ -111,7 +111,7 @@ async fn remux_stream(
CONF.media_path.to_owned(),
node.public,
local_tracks,
- spec.tracks,
+ spec.track,
spec.webm.unwrap_or(false),
)
});
@@ -125,11 +125,11 @@ async fn original_stream(
range: Range<usize>,
b: DuplexStream,
) -> Result<()> {
- if spec.tracks.len() != 1 {
+ if spec.track.len() != 1 {
bail!("invalid amout of source \"tracks\". original only allows for exactly one.")
}
- let source = local_tracks[spec.tracks[0]].clone();
+ let source = local_tracks[spec.track[0]].clone();
let mut file = File::open(CONF.media_path.join(source.path))
.await
.context("opening source")?;
diff --git a/stream/src/webvtt.rs b/stream/src/webvtt.rs
index ec26398..e9d03bf 100644
--- a/stream/src/webvtt.rs
+++ b/stream/src/webvtt.rs
@@ -21,7 +21,7 @@ pub async fn vtt_stream(
// TODO should use fragments too? big films take too long...
- let tracki = *spec.tracks.get(0).ok_or(anyhow!("no track selected"))?;
+ let tracki = *spec.track.get(0).ok_or(anyhow!("no track selected"))?;
let local_track = local_tracks.get(0).ok_or(anyhow!("no tracks"))?.clone();
let track = &node.public.media.unwrap().tracks[tracki];
let cp = local_track.codec_private.clone();
diff --git a/web/script/player/track/mse.ts b/web/script/player/track/mse.ts
index 2949890..01836b7 100644
--- a/web/script/player/track/mse.ts
+++ b/web/script/player/track/mse.ts
@@ -28,7 +28,7 @@ export class MSEPlayerTrack extends PlayerTrack {
async init() {
this.buffered.value = [{ start: 0, end: this.player.duration.value, status: "loading" }]
try {
- const res = await fetch(`/n/${encodeURIComponent(this.node_id)}/stream?format=jhlsi&tracks=${this.track_index}`, { headers: { "Accept": "application/json" } });
+ const res = await fetch(`/n/${encodeURIComponent(this.node_id)}/stream?format=jhlsi&track=${this.track_index}`, { headers: { "Accept": "application/json" } });
if (!res.ok) return this.player.error.value = "Cannot download index.", undefined;
let index!: JhlsTrackIndex & { error: string; };
try { index = await res.json(); }
@@ -122,7 +122,7 @@ export class MSEPlayerTrack extends PlayerTrack {
async load(index: number) {
this.loading.add(index);
await this.profile_selector.select_optimal_profile(this.track_index, this.profile);
- const url = `/n/${encodeURIComponent(this.node_id)}/stream?format=frag&webm=true&tracks=${this.track_index}&index=${index}${this.profile.value ? `&profile=${this.profile.value.id}` : ""}`;
+ const url = `/n/${encodeURIComponent(this.node_id)}/stream?format=frag&webm=true&track=${this.track_index}&index=${index}${this.profile.value ? `&profile=${this.profile.value.id}` : ""}`;
const buf = await this.player.downloader.download(url);
await new Promise<void>(cb => {
if (!this.index) return;
diff --git a/web/script/player/track/vtt.ts b/web/script/player/track/vtt.ts
index 4dddbc7..02a7792 100644
--- a/web/script/player/track/vtt.ts
+++ b/web/script/player/track/vtt.ts
@@ -33,7 +33,7 @@ export class VttPlayerTrack extends PlayerTrack {
async init() {
try {
- const res = await fetch(`/n/${encodeURIComponent(this.node_id)}/stream?format=jvtt&tracks=${this.track_index}`, { headers: { "Accept": "application/json" } });
+ const res = await fetch(`/n/${encodeURIComponent(this.node_id)}/stream?format=jvtt&track=${this.track_index}`, { headers: { "Accept": "application/json" } });
if (!res.ok) return this.player.error.value = "Cannot download index.", undefined;
let ai!: JvttCue[] & { error: string; };
try { ai = await res.json(); }