You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Returns array with all audio sources (without detailed listeners information). Please see Monitor.XmlStreamParser source event for data provided about every source.
Returns array with all listeners, connected to icecast server. Please see Monitor.XmlStreamParser listener event data for details. Can produce huge amounts of data, use wisely.
Performs HTTP request to given icecast url path and returns stream for further processing. Can be useful to process large icecast XML output using Monitor.XmlStreamParser.
We use following icecast url paths:
/admin/stats
icecast server information
sources detailed information
no detailed listeners information
/admin/stats?mount=/$mount
icecast server information
specified source information
detailed information about connected listeners
/admin/listmounts?with_listeners
no information about icecast server
minimal information about sources
and detailed information about all icecast listeners
// Collect sources without storing them in a memorymonitor.createStatsXmlStream('/admin/stats',function(err,xmlStream){if(err)throwerr;varxmlParser=newMonitor.XmlStreamParser();xmlParser.on('error',function(err){console.log('error',err);});xmlParser.on('source',function(source){// Do work with received sourceconsole.log('source',source);});// Finish event is being piped from xmlStreamxmlParser.on('finish',function(){console.log('all sources are processed');});xmlStream.pipe(xmlParser);});
Feed
Establishes persistent connection with icecast using STATS HTTP method & processes events feed in realtime. Best way to create is to use monitor.createFeed method, which injects all necessary parameters.
Events
For mount.* and server.* events user-callback is provided with following parameters:
Parameter
Type
Description
event
String
Event name (present only for wildcard events)
data
Mixed
Parsed parameter(s), is described for each event below
raw
String
Raw message received from icecast
Internal events
connect: connection with icecast is established
disconnect: connection with icecast is closed
Wildcard events
*: groups absolutely all supported events, produces lots of calls
EVENT /test.mp3 title Werkdiscs - Helena Hauff - 'Sworn To Secrecy Part II'
Parameter
Type
Description
mount
String
Mountpoint name
data
String
Track name
mount.totalBytesRead
EVENT /test.mp3 total_bytes_read 1443575627
Parameter
Type
Description
mount
String
Mountpoint name
data
Integer
Source (incoming) traffic in bytes
mount.totalBytesSent
EVENT /test.mp3 total_bytes_sent 256000
Parameter
Type
Description
mount
String
Mountpoint name
data
Integer
Source (outgoing) traffic in bytes
mount.totalMBytesSent
EVENT /test.mp3 total_mbytes_sent 0
Parameter
Type
Description
mount
String
Mountpoint name
data
Integer
Source (outgoing) traffic in bytes
mount.ypCurrentlyPlaying
EVENT /test.mp3 yp_currently_playing Nickelback - How You Remind Me
Parameter
Type
Description
mount
String
Mountpoint name
data
String
Track, that is displayed in YP
server.admin
Displays administrator's email.
EVENT global admin email@example.com
Parameter
Type
Description
data
String
Administrator email
server.bannedIPs
EVENT global banned_IPs 0
Parameter
Type
Description
data
Integer
Banned ip addresses number
server.build
EVENT global build 20150616004931
Parameter
Type
Description
data
Integer
Build number
server.clientConnections
EVENT global client_connections 1029675
Parameter
Type
Description
data
Integer
Client connections number
server.clients
EVENT global clients 62
Parameter
Type
Description
data
Integer
Connected clients
server.connections
EVENT global connections 1178553
Parameter
Type
Description
data
Integer
Connections number
server.fileConnections
EVENT global file_connections 3534
Parameter
Type
Description
data
Integer
File connections number
server.host
Configuration icecast.hostname setting value. Is used for the stream directory lookups or playlist generation possibily if a Host header is not provided.
EVENT global host icecast.dev
Parameter
Type
Description
data
String
Server DNS name or IP address
server.info
Identifies the end of the big list at the beginning. When initially connected, you get a snapshot (a blast of content), and this just marks the end of it. After this then the stats are generated since the snapshot.
INFO full list end
server.listenerConnections
EVENT global listener_connections 220589
Parameter
Type
Description
data
Integer
Listener connections number
server.listeners
EVENT global listeners 16
Parameter
Type
Description
data
Integer
Current listeners number
server.location
Configuration icecast.location setting value, is also displayed in web interface.
EVENT global location RU
Parameter
Type
Description
data
String
Server location
server.outgoingKBitrate
EVENT global outgoing_kbitrate 4411
Parameter
Type
Description
data
Integer
Outgoing bitrate (kbps)
server.serverId
Icecast server identifier. Can be overrided in config file.
EVENT global server_id Icecast 2.4.0-kh1
Parameter
Type
Description
data
String
Server identifier (icecast followed by a version number or user-defined value)
server.serverStart
EVENT global server_start 06/Jul/2015:00:19:34 +0300
Parameter
Type
Description
data
String
Server start date
server.sourceClientConnections
EVENT global source_client_connections 0
Parameter
Type
Description
data
Integer
Source client connections number
server.sourceRelayConnections
EVENT global source_relay_connections 1317
Parameter
Type
Description
data
Integer
Source relay connections number
server.sources
EVENT global sources 45
Parameter
Type
Description
data
Integer
Sources number
server.sourceTotalConnections
EVENT global source_total_connections 1318
Parameter
Type
Description
data
Integer
Source total connections number
server.stats
EVENT global stats 0
Parameter
Type
Description
data
Integer
?
server.statsConnections
EVENT global stats_connections 2
Parameter
Type
Description
data
Integer
?
server.streamKBytesRead
EVENT global stream_kbytes_read 2414225600
Parameter
Type
Description
data
Integer
Stream incoming traffic (kbytes)
server.streamKBytesSent
EVENT global stream_kbytes_sent 1102687068
Parameter
Type
Description
data
Integer
Stream outgoing traffic (kbytes)
Methods
feed.connect
Establishes connection, once connected emits connect event. If you use createFeed method, it will call feed.connect automatically, so this method can be used to handle disconnects like shown below:
Closes icecast connection, once disconnected emits disconnect event.
monitor.createFeed(function(err,feed){if(err)throwerr;feed.on('connect',function(){// Disconnect with 5 seconds delaysetTimeout(feed.disconnect,5000);});});
XmlStreamParser
Writeable stream, that allows to retrieve sources, listeners & server information from icecast xml stream. Icecast xml stream can be retrieved using monitor.createStatsXmlStream method.
// Collect sources without storing them in a memorymonitor.createStatsXmlStream('/admin/stats',function(err,xmlStream){if(err)throwerr;varxmlParser=newMonitor.XmlStreamParser();// Handle errorsxmlParser.on('error',function(err){console.log('error',err);});// Handle server infoxmlParser.on('server',function(server){console.log('server',server);});// Handle sourcesxmlParser.on('source',function(source){console.log('source',source);});// Handle listenersxmlParser.on('listener',function(listener){console.log('listener',listener);});// Xml stream finishedxmlParser.on('finish',function(){console.log('data is finished');});xmlStream.pipe(xmlParser);});