aboutsummaryrefslogtreecommitdiff
path: root/stream/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'stream/src/lib.rs')
-rw-r--r--stream/src/lib.rs23
1 files changed, 19 insertions, 4 deletions
diff --git a/stream/src/lib.rs b/stream/src/lib.rs
index ccb424a..5051b18 100644
--- a/stream/src/lib.rs
+++ b/stream/src/lib.rs
@@ -11,6 +11,23 @@ use tokio::{
};
use tokio_util::io::SyncIoBridge;
+pub struct StreamHead {
+ pub content_type: &'static str,
+ pub range_supported: bool,
+}
+
+#[rustfmt::skip]
+pub fn stream_head(spec: &StreamSpec) -> StreamHead {
+ let webm_or_mkv = if spec.webm.unwrap_or(false) { "video/webm" } else { "video/x-matroska" };
+ match spec.format {
+ StreamFormat::Original => StreamHead { content_type: "video/x-matroska", range_supported: true },
+ StreamFormat::Matroska => StreamHead { content_type: webm_or_mkv, range_supported: true },
+ StreamFormat::Hls => StreamHead { content_type: "application/vnd.apple.mpegurl", range_supported: false },
+ StreamFormat::Jhls => StreamHead { content_type: "application/jellything-jhls+json", range_supported: false },
+ StreamFormat::Segment => StreamHead { content_type: webm_or_mkv, range_supported: false },
+ }
+}
+
pub async fn stream(node: Node, spec: StreamSpec, range: Range<usize>) -> Result<DuplexStream> {
let (a, b) = duplex(4096);
@@ -26,9 +43,7 @@ pub async fn stream(node: Node, spec: StreamSpec, range: Range<usize>) -> Result
match spec.format {
StreamFormat::Original => original_stream(track_sources, spec, range, b).await?,
- StreamFormat::Matroska | StreamFormat::Webm => {
- remux_stream(node, track_sources, spec, range, b).await?
- }
+ StreamFormat::Matroska => remux_stream(node, track_sources, spec, range, b).await?,
StreamFormat::Hls => todo!(),
StreamFormat::Jhls => todo!(),
StreamFormat::Segment => todo!(),
@@ -54,7 +69,7 @@ async fn remux_stream(
node.public,
track_sources,
spec.tracks,
- spec.format == StreamFormat::Webm,
+ spec.webm.unwrap_or(false),
)
});