Struct IcecastStatsSource

Source
pub struct IcecastStatsSource { /* private fields */ }
Expand description

A streaming source

Implementations§

Source§

impl IcecastStatsSource

Source

pub fn artist(&self) -> Option<&String>

Artist of the current song Metadata set by source client

Source

pub fn title(&self) -> Option<&String>

Title of the current song Metadata set by source client

Source

pub fn audio_bitrate(&self) -> &Option<u32>

Audio bitrate in bits/s Can be set by source client Example: 128000

Source

pub fn audio_channels(&self) -> &Option<u8>

Audio bitrate in bits/s Can be set by source client Example: 1

Source

pub fn audio_samplerate(&self) -> &Option<u32>

Information about the samplerate of the stream. Can be set by source client Example: 48000

Source

pub fn audio_bitrate_source(&self) -> &Option<u32>

Audio bitrate of the source in bits/s Can be set by source client Example: 128000

Source

pub fn audio_channels_source(&self) -> &Option<u8>

Audio bitrate of the source in bits/s Can be set by source client Example: 1

Source

pub fn audio_samplerate_source(&self) -> &Option<u32>

Information about the samplerate of the stream source. Can be set by source client Example: 48000

Source

pub fn frame_rate(&self) -> &Option<f32>

Example: 25.00

Source

pub fn frame_size(&self) -> Option<&String>

Example: 720 x 576

Source

pub fn bitrate(&self) -> &Option<u32>

Example: 128

Source

pub fn genre(&self) -> Option<&String>

Example: jazz, classical

Source

pub fn ice_bitrate(&self) -> &Option<u32>

Example: 128

Source

pub fn listener_peak(&self) -> &Option<u32>

Example: 234

Source

pub fn listeners(&self) -> &Option<u32>

Currently Active Listeners.

Example: 23

Source

pub fn listenurl(&self) -> Option<&String>

Example: http://localhost:8000/test2

Examples found in repository?
examples/m3u-gen.rs (line 34)
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}
Source

pub fn server_description(&self) -> Option<&String>

Example: Unspecified description

Source

pub fn server_name(&self) -> Option<&String>

Example: Unspecified name

Source

pub fn server_type(&self) -> Option<&String>

MIME-type for the stream currently active on this mountpoint.

Example: application/ogg

Source

pub fn subtype(&self) -> Option<&String>

MIME-subtype, can be e.g. codecs like Opus, Vorbis, Theora. Separated with /.

Example: application/ogg

Source

pub fn stream_start(&self) -> Option<&String>

Example: 2021-04-09T21:49:52+0200

Source

pub fn user_agent(&self) -> Option<&String>

HTTP user agent string as sent by the source client.

Source

pub fn video_bitrate(&self) -> Option<u32>

Example: 200000

Source

pub fn video_quality(&self) -> &Option<u32>

Example: 0

Source

pub fn generate_name(&self) -> String

Generate simple name

Examples found in repository?
examples/m3u-gen.rs (line 36)
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

Source§

fn clone(&self) -> IcecastStatsSource

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for IcecastStatsSource

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for IcecastStatsSource

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for IcecastStatsSource

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,