Skip to content
Closed
Show file tree
Hide file tree
Changes from 17 commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
7d6ecf1
feat: add ingest module (hls)
sebastianpiq Dec 8, 2025
8cc31ff
feat: implement hls importer
sebastianpiq Dec 9, 2025
ea83ea0
Merge branch 'main' into feat/hls-ingest-module
sebastianpiq Dec 9, 2025
c1d9c3f
chore: update dependencies
sebastianpiq Dec 9, 2025
4027289
refactor: rename `InputFormat` to `ImportType` and use `hang::import:…
sebastianpiq Dec 9, 2025
ab19cdf
refactor: Rename `Media` and `Manifest` structs to `ImportMedia` and …
sebastianpiq Dec 9, 2025
d03f54d
refactor: extract run_loop helper and improve code quality
sebastianpiq Dec 10, 2025
8891ee3
Merge branch 'main' into feat/hls-ingest-module
sebastianpiq Dec 10, 2025
d00ad22
Recover removed comments
sebastianpiq Dec 11, 2025
5606b97
Recover removed comments
sebastianpiq Dec 11, 2025
bec9bfe
rename HLS ingestion from `ingest-hls` to `pub-hls`
sebastianpiq Dec 11, 2025
a9b87d1
Improve code style
sebastianpiq Dec 11, 2025
af60a6e
Code optimization
sebastianpiq Dec 11, 2025
bcf48bd
Merge remote-tracking branch 'origin/main' into feat/hls-ingest-module
kixelated Dec 12, 2025
6206ba3
Reshuffle the import stuff a bit.
kixelated Dec 12, 2025
bf9e958
Resolve merge conflicts and revamp publish CLI
sebastianpiq Dec 15, 2025
37ae6d0
refactor: Simplify Fmp4 catalog management to always use the broadcas…
sebastianpiq Dec 15, 2025
bd98a40
refactor: remove redundant MediaType enum from HLS importer and use b…
sebastianpiq Dec 16, 2025
0bab310
refactor: Fmp4 importer now uses the broadcast's existing catalog ins…
sebastianpiq Dec 16, 2025
060af17
Merge branch 'main' into feat/hls-ingest-module
sebastianpiq Dec 17, 2025
8307f3c
feat: directly define `pub-hls` recipe and explicitly pass `fmp4` for…
sebastianpiq Dec 17, 2025
401e840
feat: Add a justfile command to serve HLS
sebastianpiq Dec 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ leaf:
pub name url='http://localhost:4443/anon' *args:
cd rs && just pub {{name}} {{url}} {{args}}

# Ingest a live HLS media playlist and publish it via hang (full ladder).
# Thin wrapper around the Rust justfile recipe.
pub-hls url name='demo' relay='http://localhost:4443/anon':
cd rs && just pub-hls {{url}} {{name}} {{relay}}

# Publish/subscribe using gstreamer - see https://github.com/moq-dev/gstreamer
pub-gst name url='http://localhost:4443/anon':
@echo "GStreamer plugin has moved to: https://github.com/moq-dev/gstreamer"
Expand Down
140 changes: 140 additions & 0 deletions rs/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions rs/hang-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ path = "src/main.rs"
[dependencies]
anyhow = { version = "1", features = ["backtrace"] }
axum = { version = "0.8", features = ["tokio"] }
bytes = "1.10"
clap = { version = "4", features = ["derive"] }
hang = { workspace = true }
hyper-serve = { version = "0.6", features = ["tls-rustls"] }
Expand Down
30 changes: 5 additions & 25 deletions rs/hang-cli/src/client.rs
Original file line number Diff line number Diff line change
@@ -1,49 +1,29 @@
use crate::import::Import;
use crate::ImportType;
use anyhow::Context;
use crate::Publish;

use hang::moq_lite;
use tokio::io::AsyncRead;
use url::Url;

pub async fn client<T: AsyncRead + Unpin>(
config: moq_native::ClientConfig,
url: Url,
name: String,
format: ImportType,
input: &mut T,
) -> anyhow::Result<()> {
let broadcast = moq_lite::Broadcast::produce();
pub async fn client(config: moq_native::ClientConfig, url: Url, name: String, publish: Publish) -> anyhow::Result<()> {
let client = config.init()?;

tracing::info!(%url, %name, "connecting");
let session = client.connect(url).await?;

// Create an origin producer to publish to the broadcast.
let origin = moq_lite::Origin::produce();
origin.producer.publish_broadcast(&name, publish.consume());

// Establish the connection, not providing a subscriber.
let session = moq_lite::Session::connect(session, origin.consumer, None).await?;

let mut import = Import::new(broadcast.producer.into(), format);
import
.init_from(input)
.await
.context("failed to initialize from media stream")?;

// Announce the broadcast as available once the catalog is ready.
origin.producer.publish_broadcast(&name, broadcast.consumer);

// Notify systemd that we're ready.
let _ = sd_notify::notify(true, &[sd_notify::NotifyState::Ready]);

tokio::select! {
res = import.read_from(input) => res,
res = publish.run() => res,
res = session.closed() => res.map_err(Into::into),

_ = tokio::signal::ctrl_c() => {
session.close(moq_lite::Error::Cancel);

// Give it a chance to close.
tokio::time::sleep(std::time::Duration::from_millis(100)).await;
Ok(())
},
Expand Down
Loading