BASS_Encode_CastGetStats
Retrieves stats from the Shoutcast or Icecast server.
const char *BASS_Encode_CastGetStats(
HENCODE handle
DWORD type,
char *pass
);
Parameters
handle | The encoder handle.
|
type | The type of stats to retrieve. One of the following.
BASS_ENCODE_STATS_SHOUT | Shoutcast stats, including listener information and additional server information.
| BASS_ENCODE_STATS_ICE | Icecast mount-point listener information.
| BASS_ENCODE_STATS_ICESERV | Icecast server stats, including information on all mount points on the server.
|
|
pass | The server admin password... NULL = use the password provided in the BASS_Encode_CastInit call. A username can also be included in the form of "username:password".
|
Return value
If successful, the stats are returned, else NULL is returned. Use BASS_ErrorGetCode to get the error code.
Error codes
BASS_ERROR_HANDLE | handle is not valid.
|
BASS_ERROR_ILLTYPE | type is invalid.
|
BASS_ERROR_NOTAVAIL | There isn't a cast of the requested type set on the encoder.
|
BASS_ERROR_TIMEOUT | The server did not respond to the request within the timeout period, as set with the BASS_CONFIG_NET_TIMEOUT config option.
|
BASS_ERROR_MEM | There is insufficient memory.
|
BASS_ERROR_UNKNOWN | Some other mystery problem!
|
Remarks
The stats are returned in XML format.
Each encoder has a single stats buffer, which is reused by each call of this function for the encoder. So if the data needs to be retained across multiple calls, it should be copied to another buffer.
Example
Display the number of listeners.
int listeners = 0;
const char *stats;
if (stats = BASS_Encode_CastGetStats(encoder, BASS_ENCODE_STATS_SHOUT, NULL)) {
const char *t = strstr(stats, "<CURRENTLISTENERS>"); // Shoutcast listener count
if (t) listeners = atoi(t + 18);
} else if (stats = BASS_Encode_CastGetStats(encoder, BASS_ENCODE_STATS_ICE, NULL)) {
const char *t = strstr(stats, "<Listeners>"); // Icecast listener count
if (t) listeners = atoi(t + 11);
}
printf("listeners = %d\n", listeners);
See also
BASS_Encode_CastInit, BASS_Encode_GetCount