Detect type of streaming server

Started by GTHvidsten,

GTHvidsten

I'm writing a .NET application (using BASS.NET) that supports both Icecast and Shoutcast, so I'm using the generic BassEnc.BASS_Encode_CastInit() to start casting.

Now I'd like to use BassEnc.BASS_Encode_CastGetStats() to get the current listener count, but to use this you must send in a BASSEncodeStats type that says if the server is a Shoutcast or an Icecast server. Seeing as I'm using the generic BassEnc.BASS_Encode_CastInit() I don't know what the server actually is.

Is there a way to detect the server type (without having to manually send HTTP requests)?

radio42

I guess you logically know to which type of server you connect?!

I.e. logically in code you must per server differentiate between the two types of servers. BASS in their API don't need that differentiation for the BASS_Encode_CastInit() call, but for others, like the BASS_Encode_CastGetStats() call.



Also take a look to the Un4seen.Bass.Misc.BroadCast class - which wraps a lot of the streaming stuff.

GTHvidsten

I don't have any logic in my code to differentiate between the two types of servers, and I wouldn't want to either (for ease of use).

Looks like the BroadCast class also needs to know what type of server to stream to, based on the example:
SHOUTcast shoutcast = new SHOUTcast(lame);
_broadCast = new BroadCast(shoutcast);

GTHvidsten

And now I see what you mean by "logically know to which type of server you connect". The server parameter to BASS_Encode_CastInit() is different for Shoutcast and Icecast... and I've only been testing with Icecast so never ran into an issue :D
I guess I'll have to add a switch to be able to use both, and this switch will also make me able to use BASS_Encode_CastGetStats()... unless you have some other good ideas I haven't thought of yet :)

Ian @ un4seen

Yes, the server type is determined in the BASS_Encode_CastInit "server" parameter (Icecast if a mount point is included and Shoutcast otherwise). BASS_Encode_CastGetStats checks that first and fails (with BASS_ERROR_NOTAVAIL) if the wrong stats are requested, so you can simply try both (like in the CAST.C example included in BASSenc package).

GTHvidsten

QuoteIcecast if a mount point

Isn't a mount point also used for Shoutcast? It is just called "Stream ID" and appended to the server URL with a comma instead of as a path? Or maybe you check for both?

Chris

#6
address:port (Shoutcast 1)
address:port,streamid (Shoutcast 2)
address:port/mount (Icecast).

The ",streamID". Is for Shoutcast2 only.