-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathwhepfrom.rs
52 lines (47 loc) · 1.38 KB
/
whepfrom.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
use clap::{ArgAction, Parser};
use tracing::Level;
mod log;
#[derive(Parser)]
#[command(name = "whepfrom", version)]
struct Args {
/// Verbose mode [default: "warn", -v "info", -vv "debug", -vvv "trace"]
#[arg(short = 'v', action = ArgAction::Count, default_value_t = 0)]
verbose: u8,
/// rtsp://[username]:[password]@[ip]:[port]/[stream] Or <stream.sdp>
#[arg(short, long, default_value_t = format!("{}://0.0.0.0:8555", livetwo::SCHEME_RTSP_SERVER))]
output: String,
/// Set Listener address
#[arg(long)]
host: Option<String>,
/// The WHEP server endpoint to POST SDP offer to. e.g.: https://example.com/whep/777
#[arg(short, long)]
whep: String,
/// Authentication token to use, will be sent in the HTTP Header as 'Bearer '
#[arg(short, long)]
token: Option<String>,
/// Run a command as childprocess
#[arg(long)]
command: Option<String>,
}
#[tokio::main]
async fn main() {
let args = Args::parse();
log::set(format!(
"livetwo={},webrtc=error",
match args.verbose {
0 => Level::WARN,
1 => Level::INFO,
2 => Level::DEBUG,
_ => Level::TRACE,
}
));
livetwo::whep::from(
args.output.clone(),
args.host.clone(),
args.whep.clone(),
args.token.clone(),
args.command.clone(),
)
.await
.unwrap();
}