pub struct IcecastStatsSource { /* private fields */ }
Expand description
A streaming source
Implementations§
Source§impl IcecastStatsSource
impl IcecastStatsSource
Sourcepub fn artist(&self) -> Option<&String>
pub fn artist(&self) -> Option<&String>
Artist of the current song Metadata set by source client
Sourcepub fn audio_bitrate(&self) -> &Option<u32>
pub fn audio_bitrate(&self) -> &Option<u32>
Audio bitrate in bits/s Can be set by source client Example: 128000
Sourcepub fn audio_channels(&self) -> &Option<u8>
pub fn audio_channels(&self) -> &Option<u8>
Audio bitrate in bits/s Can be set by source client Example: 1
Sourcepub fn audio_samplerate(&self) -> &Option<u32>
pub fn audio_samplerate(&self) -> &Option<u32>
Information about the samplerate of the stream. Can be set by source client Example: 48000
Sourcepub fn audio_bitrate_source(&self) -> &Option<u32>
pub fn audio_bitrate_source(&self) -> &Option<u32>
Audio bitrate of the source in bits/s Can be set by source client Example: 128000
Sourcepub fn audio_channels_source(&self) -> &Option<u8>
pub fn audio_channels_source(&self) -> &Option<u8>
Audio bitrate of the source in bits/s Can be set by source client Example: 1
Sourcepub fn audio_samplerate_source(&self) -> &Option<u32>
pub fn audio_samplerate_source(&self) -> &Option<u32>
Information about the samplerate of the stream source. Can be set by source client Example: 48000
Sourcepub fn frame_rate(&self) -> &Option<f32>
pub fn frame_rate(&self) -> &Option<f32>
Example: 25.00
Sourcepub fn frame_size(&self) -> Option<&String>
pub fn frame_size(&self) -> Option<&String>
Example: 720 x 576
Sourcepub fn ice_bitrate(&self) -> &Option<u32>
pub fn ice_bitrate(&self) -> &Option<u32>
Example: 128
Sourcepub fn listener_peak(&self) -> &Option<u32>
pub fn listener_peak(&self) -> &Option<u32>
Example: 234
Sourcepub fn listenurl(&self) -> Option<&String>
pub fn listenurl(&self) -> Option<&String>
Example: http://localhost:8000/test2
Examples found in repository?
10fn main() -> Result<(), Box<dyn Error>> {
11 let args: Vec<String> = env::args().collect();
12 if args.len() != 2 {
13 println!("url parameter expected");
14 std::process::exit(1);
15 } else {
16 println!("* Parsing arg as url '{}'", args[1]);
17 let base_url = Url::parse(&args[1])?;
18 println!("* Create icecast status url from '{}'", base_url);
19 let url = generate_icecast_stats_url(base_url);
20 println!("* Fetching from '{}'", url);
21 let resp = get(url.to_string())?;
22 println!("* Decode json from response");
23 let j: IcecastStatsRoot = resp.json()?;
24 println!(
25 "* Result: ServerID='{}' written to 'output.m3u'",
26 j.icestats.server_id()
27 );
28
29 let mut file = File::create("output.m3u")?;
30 writeln!(file, "#EXTM3U")?;
31
32 // Write each line to the file
33 for stream in j.icestats.sources_vec() {
34 match stream.listenurl() {
35 Some(listenurl) => {
36 let line = stream.generate_name();
37 writeln!(file, "#EXTINF:0, {}", line)?;
38 writeln!(file, "{}\n", listenurl)?;
39 }
40 None => println!("Ignoring station because empty listenurl"),
41 }
42 }
43 }
44 Ok(())
45}
Sourcepub fn server_description(&self) -> Option<&String>
pub fn server_description(&self) -> Option<&String>
Example: Unspecified description
Sourcepub fn server_name(&self) -> Option<&String>
pub fn server_name(&self) -> Option<&String>
Example: Unspecified name
Sourcepub fn server_type(&self) -> Option<&String>
pub fn server_type(&self) -> Option<&String>
MIME-type for the stream currently active on this mountpoint.
Example: application/ogg
Sourcepub fn subtype(&self) -> Option<&String>
pub fn subtype(&self) -> Option<&String>
MIME-subtype, can be e.g. codecs like Opus, Vorbis, Theora. Separated with /.
Example: application/ogg
Sourcepub fn stream_start(&self) -> Option<&String>
pub fn stream_start(&self) -> Option<&String>
Example: 2021-04-09T21:49:52+0200
Sourcepub fn user_agent(&self) -> Option<&String>
pub fn user_agent(&self) -> Option<&String>
HTTP user agent string as sent by the source client.
Sourcepub fn video_bitrate(&self) -> Option<u32>
pub fn video_bitrate(&self) -> Option<u32>
Example: 200000
Sourcepub fn video_quality(&self) -> &Option<u32>
pub fn video_quality(&self) -> &Option<u32>
Example: 0
Sourcepub fn generate_name(&self) -> String
pub fn generate_name(&self) -> String
Generate simple name
Examples found in repository?
10fn main() -> Result<(), Box<dyn Error>> {
11 let args: Vec<String> = env::args().collect();
12 if args.len() != 2 {
13 println!("url parameter expected");
14 std::process::exit(1);
15 } else {
16 println!("* Parsing arg as url '{}'", args[1]);
17 let base_url = Url::parse(&args[1])?;
18 println!("* Create icecast status url from '{}'", base_url);
19 let url = generate_icecast_stats_url(base_url);
20 println!("* Fetching from '{}'", url);
21 let resp = get(url.to_string())?;
22 println!("* Decode json from response");
23 let j: IcecastStatsRoot = resp.json()?;
24 println!(
25 "* Result: ServerID='{}' written to 'output.m3u'",
26 j.icestats.server_id()
27 );
28
29 let mut file = File::create("output.m3u")?;
30 writeln!(file, "#EXTM3U")?;
31
32 // Write each line to the file
33 for stream in j.icestats.sources_vec() {
34 match stream.listenurl() {
35 Some(listenurl) => {
36 let line = stream.generate_name();
37 writeln!(file, "#EXTINF:0, {}", line)?;
38 writeln!(file, "{}\n", listenurl)?;
39 }
40 None => println!("Ignoring station because empty listenurl"),
41 }
42 }
43 }
44 Ok(())
45}
Trait Implementations§
Source§impl Clone for IcecastStatsSource
impl Clone for IcecastStatsSource
Source§fn clone(&self) -> IcecastStatsSource
fn clone(&self) -> IcecastStatsSource
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more