there are similar functions that are built into wowza server that behave this way when using a source/edge setup. the edge server will sit idle until a request is made (tune in), then it will pull from the source server. when there are no more listeners connected to that particular stream, it will disconnect.
the problem you might run into here is with icecast (from what i can remember) if there are no sources connected, you cant connect to the stream, thus there is no way your stats will ever read more than 0 until a source stream is provided. generally if your on a home ISP, the bandwidth used is very low… if this is all over local LAN the network usage is also negligible... and reading a single file for playback wont be thrashing a hard drive (unless the drive is going bad or the file is huge and you have lots of other processes that are heavy on disk i/o). the correct process would be to load the track into memory and serve from there. since you are sourcing a stream out on the internet, why not simply tune in directly to that stream from the node? when you are not listening, its not using any bandwidth. if you are concerned about multiple nodes being tuned in at the same time, you can set up a local relay (as it looks like thats what you’ve done with liquidsoap. basically you would only need to tell liquidsoap ‘i want to start listening now’, in one way or another so it will start pulling from the remote stream. its easy enough to write a script (or use one of the many out on the internets) to check the listener stats of an icecast server and have liquidsoap disconnect if there are 0 listeners. but off the top of my head the best way to accomplish starting the stream when there are 0 listeners and you want to listen is to manually tell liquidsoap to start or switch to a live stream. such as a http GET request or a telnet command or whatever… hope this helps a little… let us know what you come up with =] cheers > On May 29, 2015, at 12:08 PM, Detrick Merz <[email protected]> wrote: > > Ah yes, it makes sense but is different from what I'm trying to do. I > have an input stream or playlist that is (effectively) always > available. That gets output out to a different icecast2 server. > Ideally I'd like to temporarily stop the input stream or playlist and > switch to something generated (maybe using the noise() or say() > function) whenever the number of listeners connected to my icecast2 > server drops to 0. No sense in wasting bandwidth by staying connected > to an input.http() stream, or in thrashing a disk playing a local > file, when there isn't actually anyone listening to it. > > Newer versions of icecast2 provide some nice status data in json > format. My current thought is to use something like > of_json(http.get("http://127.0.0.1:8000/status-json.xsl")), parse out > the "listeners":1, field, then make a decision in liquidsoap based on > the value of that field. Of course I've oversimplified the > of_json(http.get()) use, it doesn't exactly work like that ... > http.get returns headers and such besides the json data, so that > result would need to be filtered a bit before being sent to of_json(). > I haven't quite wrapped my head around parsing the result from the > http.get() yet, but it'll come. > > On Fri, May 29, 2015 at 2:50 PM, Sarah k Alawami <[email protected]> wrote: >> Yeah. I modified the code in the cook book, section on harbor mount, to suit >> my needs. So for me I have it branching in to 3, one day 4, streams when I >> go live, then fall back to my playlist which is on a constant loop. That >> playlist also branches out to the 3 streams. >> >> I hope that makes sence. >>> On May 29, 2015, at 11:42 AM, Detrick Merz <[email protected]> wrote: >>> >>> If I understand right, your example will default to playing the live >>> stream, but fallback to the playlist if the live stream stops coming >>> in. Does that seem right? >>> >>> tnx de detrick >>> >>> On Tue, May 26, 2015 at 6:29 PM, Sarah k Alawami <[email protected]> wrote: >>>> Ok, what I did was set up a harbor stream. here's my code with passwords >>>> changed of corse. >>>> >>>> pasted.co/d63e0c67. >>>> >>>> On May 26, 2015, at 3:22 PM, Detrick Merz <[email protected]> wrote: >>>> >>>> In my case, I have a liquidsoap+icecast2 server. Liquidsoap presently >>>> uses an Internet stream as an input, and outputs to icecast. Nodes >>>> within my house connect to my local icecast server. When no nodes are >>>> connected it seems like it would be polite to also have Liquidsoap >>>> stop using the Internet stream as an input (since no humans are >>>> actually listening to the stream). >>>> >>>> My thought would be something like switching to noise() or say(), or >>>> something else that doesn't access the disk repeatedly, whenever the >>>> number of listeners drops to 0. When at least one listener is >>>> connected, switch back to re-streaming the Internet stream. >>>> >>>> On Tue, May 26, 2015 at 6:00 PM, Sarah k Alawami <[email protected]> >>>> wrote: >>>> >>>> do you mean switch to an automation stream? or what. Can you maybe give us >>>> an example of what you want to do? Iv'e never heard of this but that does >>>> not mean it's not out there. >>>> >>>> Take care. >>>> >>>> On May 26, 2015, at 2:06 PM, Detrick Merz <[email protected]> wrote: >>>> >>>> Before I go trying to reinvent the wheel, does anyone have a code >>>> snippet that will default to noise() or something when the number of >>>> active listeners drops to 0? It seems like the json status that newer >>>> versions of icecast2 have should make this possible if I'm thinking >>>> about it right. >>>> >>>> Thanks, >>>> >>>> -detrick >>>> >>>> ------------------------------------------------------------------------------ >>>> _______________________________________________ >>>> Savonet-users mailing list >>>> [email protected] >>>> https://lists.sourceforge.net/lists/listinfo/savonet-users >>>> >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> _______________________________________________ >>>> Savonet-users mailing list >>>> [email protected] >>>> https://lists.sourceforge.net/lists/listinfo/savonet-users >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> _______________________________________________ >>>> Savonet-users mailing list >>>> [email protected] >>>> https://lists.sourceforge.net/lists/listinfo/savonet-users >>>> >>>> >>>> >>>> ------------------------------------------------------------------------------ >>>> >>>> _______________________________________________ >>>> Savonet-users mailing list >>>> [email protected] >>>> https://lists.sourceforge.net/lists/listinfo/savonet-users >>>> >>> >>> ------------------------------------------------------------------------------ >>> _______________________________________________ >>> Savonet-users mailing list >>> [email protected] >>> https://lists.sourceforge.net/lists/listinfo/savonet-users >> >> >> ------------------------------------------------------------------------------ >> _______________________________________________ >> Savonet-users mailing list >> [email protected] >> https://lists.sourceforge.net/lists/listinfo/savonet-users > > ------------------------------------------------------------------------------ > _______________________________________________ > Savonet-users mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/savonet-users ------------------------------------------------------------------------------ _______________________________________________ Savonet-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/savonet-users
