use srt_runtime::SrtUrl;
fn main() -> Result<(), Box<dyn std::error::Error>> {
let url = SrtUrl::parse(
"srt://ingest.example:9000?streamid=%23!::r=live/camera-1,m=publish&latency=200&mode=caller&passphrase=correct-horse-battery",
)
.map_err(|rejection| format!("refused: {rejection:?}"))?;
println!("{url:?}");
println!(
"connect to {}:{} as {:?}, stream id {:?}, latency {:?}, encrypted: {}",
url.host,
url.port,
url.mode,
url.stream_id,
url.latency,
url.passphrase.is_some()
);
match SrtUrl::parse("srt://ingest.example:9000?latency=fast") {
Ok(_) => return Err("a non-numeric latency must be refused".into()),
Err(rejection) => println!("srt://ingest.example:9000?latency=fast refused: {rejection:?}"),
}
Ok(())
}