Author Topic: How to figure out file type of live streams  (Read 163 times)

kafffee

  • Posts: 146
Hello there everyone :-)

I am adding some multiple file type functionality to my player, and I am wondering about this question:

When I want to play a live stream, for instance with:

BASS_FLAC_StreamCreateURL()

How will I know whether its a FLAC-Stream for instance, so I can use this method BASS_FLAC_StreamCreateURL, and not something like BASS_OPUS_StreamCreateURL?

I might not have a URL like this:

https://liveradio.de/play.flac

but like this:

https://liveradio.de/

Ian @ un4seen

  • Administrator
  • Posts: 24730
Re: How to figure out file type of live streams
« Reply #1 on: 2 Sep '22 - 13:13 »
I would recommend using the plugin system and have it automatically detect the format. That means loading the add-ons (eg. BASSFLAC and BASSOPUS) via BASS_PluginLoad, and using BASS_StreamCreateURL for all formats. You can check a stream's "ctype" value with BASS_ChannelGetInfo afterwards to find out what its format is.

kafffee

  • Posts: 146
Re: How to figure out file type of live streams
« Reply #2 on: 2 Sep '22 - 15:15 »
OK it works. Is there something like a table for the different types, because ctype only returns a number...

Ian @ un4seen

  • Administrator
  • Posts: 24730
Re: How to figure out file type of live streams
« Reply #3 on: 2 Sep '22 - 16:11 »
The "ctype" value definitions can be found in the BASS and add-on header files. If you would like to map them to strings, you could hardcode that for BASS's built-in formats and use BASS_PluginGetInfo for add-on formats. An example of doing that can be found in the GetCTypeString function in the PLUGINS.C example included in the BASS package (C\PLUGINS folder). If you are using a known set of add-ons, you could hardcode their format strings too (instead of using BASS_PluginGetInfo) if you prefer, eg. for full control over what the strings are.