aboutsummaryrefslogtreecommitdiff
path: root/stream/src
diff options
context:
space:
mode:
Diffstat (limited to 'stream/src')
-rw-r--r--stream/src/lib.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/stream/src/lib.rs b/stream/src/lib.rs
index be1ff32..85ff382 100644
--- a/stream/src/lib.rs
+++ b/stream/src/lib.rs
@@ -3,7 +3,9 @@
which is licensed under the GNU Affero General Public License (version 3); see /COPYING.
Copyright (C) 2023 metamuffin <metamuffin.org>
*/
+#![feature(iterator_try_collect)]
pub mod hls;
+pub mod jhls;
pub mod segment;
use anyhow::{anyhow, bail, Context, Result};
@@ -13,6 +15,7 @@ use jellycommon::{
stream::{StreamFormat, StreamSpec},
LocalTrack, MediaSource, Node,
};
+use jhls::jhls_stream;
use segment::segment_stream;
use std::{io::SeekFrom, ops::Range};
use tokio::{
@@ -56,7 +59,7 @@ pub async fn stream(node: Node, spec: StreamSpec, range: Range<usize>) -> Result
StreamFormat::Matroska => remux_stream(node, track_sources, spec, range, b).await?,
StreamFormat::HlsMaster => hls_master_stream(node, track_sources, spec, b).await?,
StreamFormat::HlsVariant => hls_variant_stream(node, track_sources, spec, b).await?,
- StreamFormat::Jhls => bail!("unsupported"),
+ StreamFormat::Jhls => jhls_stream(node, track_sources, spec, b).await?,
StreamFormat::Segment => segment_stream(node, track_sources, spec, b).await?,
}
@@ -98,7 +101,9 @@ async fn original_stream(
}
let source = track_sources[spec.tracks[0]].clone();
- let mut file = File::open(source.path).await.context("opening source")?;
+ let mut file = File::open(CONF.library_path.join(source.path))
+ .await
+ .context("opening source")?;
file.seek(SeekFrom::Start(range.start as u64))
.await
.context("seek source")?;
@@ -112,6 +117,9 @@ async fn copy_stream(mut inp: File, mut out: DuplexStream, mut amount: usize) ->
let mut buf = [0u8; 4096];
loop {
let size = inp.read(&mut buf[..amount.min(4096)]).await?;
+ if size == 0 {
+ break Ok(());
+ }
out.write_all(&buf[..size]).await?;
amount -= size;
}