Streaming an Asterisk conference room on an Icecast server
Saturday, March 1st, 2008Ohhhhh snap! Really cool discovery today. In preperation for a workshop me and Ryan are doing at the Grassroots Media Conference, we sat down and did some hacking with Asterisk and Icecast. In the end I figured out how to take a conference room, define an administrative user in the form of a source client to Icecast and then broadcast all the following participants conversations via Icecast. Here’s details:
Three components are essential
- Asterisk 1.4 and a Zaptel timer for conference support
- Ices2, an ogg/vorbis source client for Icecast
- Icecast2, an internet radio server
I compiled Asterisk from source, as I always do. I’m using the 1.4 branch. I installed Icecast2 from Debian. I also installed Ices2 from Debian, though debian installed the binary as /usr/bin/ices2. Asterisk expects a binary named /usr/bin/ices. I made a symlink to fix this.
I configured Ices2 according to the example config in the Asterisk source code. It’s located in contrib/asterisk-ices.xml. Most of the defaults are acceptable. You’ll have to change the Icecast login info to match that of your own server. When you do this, su to the same user that Asterisk runs as and test connectivity. I did this via this command:
$ cat /dev/random | ices /etc/asterisk/asterisk-ices.xml
If that works, word up!
Now go into the Asterisk dialplan. I’m using FreePBX 2.2.1 as a front end to Asterisk. You’ll need to make an extension context like so in extensions_custom.conf:
[custom-ices]
exten => s,1,Answer()
exten => s,n,Wait(1)
exten => s,n,SendDTMF(0000)
exten => s,n,Ices(/etc/asterisk/asterisk-ices.xml)
exten => s,n,Hangup()
This is one side of the automated call you’re going to set up. Next you have to define a conference room. This is pretty straight forward through FreePBX. Configure as needed.
Next you’ll do some of the magic. You have to automate a local call via the Asterisk Manager Interface. You can also use a .call file but I think that’s silly so I don’t do it.*
*silly = it doesn’t scale and depends on some weird system call stuff
Login to the manager on your Asterisk server. Be sure manager.conf is configured to allow access:
$ telnet (server IP) 5060
Then login using the provided documentation. I’ll leave this as an exercise to the reader. Finally, you have to originate a local call. This is all you need:
Action: Originate
Channel: Local/1000@ext-meetme
Context: custom-ices
Extension: s
Priority: 1
If you aren’t using FreePBX, you probably won’t have the ext-meetme context defined. If you are using FreePBX, the number before ext-meetme is the conference room number. When you execute this, it will trigger Asterisk to dial that number and when it answers, pick up with the context named custom-ices, which you will remember contains the information to start streaming to Icecast.
If you got this far, congratulations, you’re streaming silence from Asterisk! Next thing to do is bind some incoming numbers to the conference room. This is also an exercise to the reader. If you do this correctly, all users who call into the room will be broadcast on the mountpoint defined in Icecast.