Skip to content

Commit

Permalink
Revert some questionable changes. (#281)
Browse files Browse the repository at this point in the history
  • Loading branch information
kixelated authored Jan 13, 2025
1 parent e493860 commit c53b5ad
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/npm.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Build/Publish NPM Package
env:
NPM_CONFIG_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
run: |
npm install
npm run pack
Expand Down
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion dev/pub
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ ffmpeg -hide_banner -v quiet \
-i "$INPUT" \
-c copy \
-f mp4 -movflags cmaf+separate_moof+delay_moov+skip_trailer+frag_every_frame \
- | cargo run --bin moq-karp -- --tls-disable-verify "$@" "${URL}" publish
- | cargo run --bin moq-karp -- --tls-disable-verify "$@" publish "${URL}"
2 changes: 1 addition & 1 deletion moq-karp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ tracing = "0.1"
lazy_static = "1"
regex = "1"

tokio = { version = "1.41", features = ["macros"] }
tokio = { version = "1.43", features = ["macros"] }

# CLI only dependencies
moq-native = { path = "../moq-native", version = "0.6", optional = true }
Expand Down
56 changes: 31 additions & 25 deletions moq-karp/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use moq_karp::{cmaf, BroadcastProducer};
use moq_native::quic;

#[derive(Parser, Clone)]
struct Cli {
struct Config {
/// Listen for UDP packets on the given address.
#[arg(long, default_value = "[::]:0")]
pub bind: net::SocketAddr,
Expand All @@ -25,46 +25,52 @@ struct Cli {
/// If we're publishing or subscribing.
#[command(subcommand)]
pub command: Command,

/// The URL must start with https://
pub url: String,
}

#[derive(Subcommand, Clone)]
pub enum Command {
/// Connect to the server, do nothing else.
Connect,

// Publish a video stream.
Publish,
//Subscribe,
/// Publish a video stream to the provided URL.
Publish {
/// The URL must start with `https://` or `http://`.
///
/// - If `http` is used, a HTTP fetch to "/fingerprint" is first made to get the TLS certificiate fingerprint (insecure).
/// The URL is then upgraded to `https`.
///
/// - If `https` is used, then A WebTransport connection is made via QUIC to the provided host/port.
/// The path is used to identify the broadcast, with the rest of the URL (ex. query/fragment) currently ignored.
url: String,
},
}

#[tokio::main]
async fn main() -> anyhow::Result<()> {
let cli = Cli::parse();
cli.log.init();
let config = Config::parse();
config.log.init();

let tls = cli.tls.load()?;
let quic = quic::Endpoint::new(quic::Config { bind: cli.bind, tls })?;
match config.command.clone() {
Command::Publish { url } => publish(config, url).await,
//Command::Subscribe => subscribe(session, broadcast).await,
}
}

tracing::info!(url = ?cli.url, "connecting");
async fn connect(config: &Config, url: &str) -> anyhow::Result<(Session, Path)> {
let tls = config.tls.load()?;
let quic = quic::Endpoint::new(quic::Config { bind: config.bind, tls })?;

let url = Url::parse(&cli.url).context("invalid URL")?;
let session = quic.client.connect(&url).await?;
let session = Session::connect(session).await?;
tracing::info!(?url, "connecting");

let url = Url::parse(url).context("invalid URL")?;
let path = url.path_segments().context("missing path")?.collect::<Path>();

match cli.command {
Command::Connect => return Ok(()),
Command::Publish => publish(session, path).await,
//Command::Subscribe => subscribe(session, broadcast).await,
}
let session = quic.client.connect(&url).await?;
let session = Session::connect(session).await?;

Ok((session, path))
}

#[tracing::instrument(skip_all, fields(?path))]
async fn publish(session: Session, path: Path) -> anyhow::Result<()> {
#[tracing::instrument(skip_all, fields(?url))]
async fn publish(config: Config, url: String) -> anyhow::Result<()> {
let (session, path) = connect(&config, &url).await?;
let broadcast = BroadcastProducer::new(session.clone(), path)?;
let mut input = tokio::io::stdin();

Expand Down
7 changes: 1 addition & 6 deletions moq-relay/src/origins.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,6 @@ impl Origins {
let routes = self.routes.lock().unwrap();

let available = routes.get(path)?;
available
.iter()
.filter(|route| route.is_some())
.next()
.cloned()
.unwrap()
available.iter().find(|route| route.is_some()).cloned().unwrap()
}
}
2 changes: 1 addition & 1 deletion moq-transfork/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ bytes = "1"
thiserror = "2"
tracing = "0.1"

tokio = { version = "1.41", features = [
tokio = { version = "1.43", features = [
"macros",
"io-util",
"sync",
Expand Down
4 changes: 2 additions & 2 deletions moq-web/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ moq-karp = { version = "0.11", path = "../moq-karp", default-features = false }
web-codecs = "0.3.2"
tokio = { version = "1", features = ["sync"] }

js-sys = "0.3.72"
js-sys = "0.3.77"
url = "2"
thiserror = "2"
hex = "0.4"

[dependencies.web-sys]
version = "0.3.72"
version = "0.3.77"
features = [
"Window",
"Document",
Expand Down

0 comments on commit c53b5ad

Please sign in to comment.