moq-pub: Avoid namespace conflict (#66)
namespace as a command line argument or assign a unique (uuid4) value. --------- Co-authored-by: Zafer Gurel <zafer@perculus.com>
This commit is contained in:
parent
90818ac848
commit
73f450aa91
|
@ -958,6 +958,7 @@ dependencies = [
|
||||||
"rustls-pemfile",
|
"rustls-pemfile",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"tokio",
|
"tokio",
|
||||||
|
"uuid",
|
||||||
"webtransport-generic",
|
"webtransport-generic",
|
||||||
"webtransport-quinn",
|
"webtransport-quinn",
|
||||||
]
|
]
|
||||||
|
@ -1890,6 +1891,28 @@ version = "0.2.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
|
checksum = "711b9620af191e0cdc7468a8d14e709c3dcdb115b36f838e601583af800a370a"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "uuid"
|
||||||
|
version = "1.4.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "79daa5ed5740825c40b389c5e50312b9c86df53fccd33f281df655642b43869d"
|
||||||
|
dependencies = [
|
||||||
|
"getrandom",
|
||||||
|
"rand",
|
||||||
|
"uuid-macro-internal",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "uuid-macro-internal"
|
||||||
|
version = "1.4.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f7e1ba1f333bd65ce3c9f27de592fcbc256dafe3af2717f56d7c87761fbaccf4"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "value-bag"
|
name = "value-bag"
|
||||||
version = "1.4.1"
|
version = "1.4.1"
|
||||||
|
|
|
@ -46,3 +46,11 @@ rfc6381-codec = "0.1.0"
|
||||||
http = "0.2.9"
|
http = "0.2.9"
|
||||||
clap = { version = "4.0", features = ["derive"] }
|
clap = { version = "4.0", features = ["derive"] }
|
||||||
clap_mangen = "0.2.12"
|
clap_mangen = "0.2.12"
|
||||||
|
|
||||||
|
[dependencies.uuid]
|
||||||
|
version = "1.4.1"
|
||||||
|
features = [
|
||||||
|
"v4", # Lets you generate random UUIDs
|
||||||
|
"fast-rng", # Use a faster (but still sufficiently random) RNG
|
||||||
|
"macro-diagnostics", # Enable better diagnostics for compile-time UUIDs
|
||||||
|
]
|
||||||
|
|
|
@ -18,6 +18,9 @@ pub struct Config {
|
||||||
|
|
||||||
#[arg(long, hide_short_help = true, default_value = "1500000")]
|
#[arg(long, hide_short_help = true, default_value = "1500000")]
|
||||||
pub catalog_bit_rate: u32,
|
pub catalog_bit_rate: u32,
|
||||||
|
|
||||||
|
#[arg(short, long, required = false, default_value = "")]
|
||||||
|
pub namespace: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn input_parser(s: &str) -> Result<InputValues, String> {
|
fn input_parser(s: &str) -> Result<InputValues, String> {
|
||||||
|
|
|
@ -17,13 +17,19 @@ use media::*;
|
||||||
mod cli;
|
mod cli;
|
||||||
use cli::*;
|
use cli::*;
|
||||||
|
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
// TODO: clap complete
|
// TODO: clap complete
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> anyhow::Result<()> {
|
async fn main() -> anyhow::Result<()> {
|
||||||
env_logger::init();
|
env_logger::init();
|
||||||
|
|
||||||
let config = Config::parse();
|
let mut config = Config::parse();
|
||||||
|
|
||||||
|
if config.namespace.is_empty() {
|
||||||
|
config.namespace = format!("quic.video/{}", Uuid::new_v4());
|
||||||
|
}
|
||||||
|
|
||||||
let mut media = Media::new(&config).await?;
|
let mut media = Media::new(&config).await?;
|
||||||
let session_runner = SessionRunner::new(&config).await?;
|
let session_runner = SessionRunner::new(&config).await?;
|
||||||
|
@ -40,8 +46,7 @@ async fn main() -> anyhow::Result<()> {
|
||||||
join_set.spawn(async { session_runner.run().await.context("failed to run session runner") });
|
join_set.spawn(async { session_runner.run().await.context("failed to run session runner") });
|
||||||
join_set.spawn(async move { log_viewer.run().await.context("failed to run media source") });
|
join_set.spawn(async move { log_viewer.run().await.context("failed to run media source") });
|
||||||
|
|
||||||
// TODO: generate unique namespace with UUID and/or take a command line arg
|
media_runner.announce(&config.namespace, media.source()).await?;
|
||||||
media_runner.announce("quic.video/moq-pub-foo", media.source()).await?;
|
|
||||||
|
|
||||||
join_set.spawn(async move { media.run().await.context("failed to run media source") });
|
join_set.spawn(async move { media.run().await.context("failed to run media source") });
|
||||||
join_set.spawn(async move { media_runner.run().await.context("failed to run client") });
|
join_set.spawn(async move { media_runner.run().await.context("failed to run client") });
|
||||||
|
|
|
@ -64,10 +64,9 @@ impl Media {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create the catalog track
|
// Create the catalog track
|
||||||
let namespace = "quic.video/moq-pub-foo";
|
|
||||||
let (_catalog, subscriber) = Self::create_catalog(
|
let (_catalog, subscriber) = Self::create_catalog(
|
||||||
config,
|
config,
|
||||||
namespace.to_string(),
|
config.namespace.to_string(),
|
||||||
init_track_name.to_string(),
|
init_track_name.to_string(),
|
||||||
&moov,
|
&moov,
|
||||||
&tracks,
|
&tracks,
|
||||||
|
|
Loading…
Reference in New Issue