Internet stream download callback function.
void CALLBACK DownloadProc( const void *buffer, DWORD length, void *user );
buffer | Pointer to the downloaded data... NULL = finished downloading. |
length | The number of bytes in the buffer... 0 = HTTP or ICY tags. |
user | The user instance data given when BASS_StreamCreateURL was called. |
When the BASS_STREAM_STATUS flag is specified in the BASS_StreamCreateURL call, HTTP and ICY tags may be passed to the callback during connection, before any stream data is received. The tags are given exactly as would be returned by BASS_ChannelGetTags. You can distinguish between HTTP and ICY tags by checking what the first string starts with: "HTTP" or "ICY".
A download callback function could be used in conjunction with a BASS_SYNC_META sync set via BASS_ChannelSetSync to save individual tracks to disk from a Shoutcast stream.
FILE *file = NULL; ... void CALLBACK MyDownloadProc(const void *buffer, DWORD length, void *user) { if (!file) file = fopen("afile.mp3", "wb"); // create the file if (!buffer) fclose(file); // finished downloading else fwrite(buffer, 1, length, file); } ... HSTREAM stream = BASS_StreamCreateURL("http://www.asite.com/afile.mp3", 0, 0, MyDownloadProc, 0);