Newer
Older
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Copyright (C) 2020 Sebastian Dröge <sebastian@centricular.com>
//
// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
use anyhow::{bail, Error};
use structopt::StructOpt;
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum ChannelConfiguration {
Mono,
Stereo,
}
impl std::str::FromStr for ChannelConfiguration {
type Err = Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"mono" => Ok(ChannelConfiguration::Mono),
"stereo" => Ok(ChannelConfiguration::Stereo),
_ => bail!(
"Invalid channel configuration '{}', valid values: 'mono', 'stereo'",
s
),
}
}
}
#[derive(Debug, StructOpt)]
#[structopt(
name = "webrtc-audio-publisher",
about = "Publish an audio stream via WebRTC."
)]
pub struct Config {
/// Input stream to record, e.g. pulseaudio:default or jack:default.
#[structopt(short, long)]
pub input_stream: String,
/// Server to publish the stream on, e.g. https://localhost:8080
#[structopt(short, long)]
pub server: String,
/// Room to create on the server. If it is published to already then this is an error.
#[structopt(short = "r", long)]
pub server_room: String,
/// Description to use for the room.
#[structopt(long)]
pub server_room_description: Option<String>,
/// TURN server to use, e.g. turn://user:password@foo.bar.com:3478.
#[structopt(long)]
pub turn_server: Option<String>,
/// TURN server to use, e.g. stun://stun.l.google.com:19302.
#[structopt(long)]
pub stun_server: Option<String>,
/// Bitrate to encode the stream to.
#[structopt(short, long, default_value = "96000")]
pub bitrate: u32,
/// Volume to use, 1.0 means no change.
#[structopt(short, long, default_value = "1.0")]
pub volume: f64,
/// Sample rate to convert to.
#[structopt(long, default_value = "48000")]
pub sample_rate: u32,
/// Channel configuration to use, can be mono or stereo.
#[structopt(long, default_value = "mono")]
pub channel_configuration: ChannelConfiguration,
}