Asterisk cmd Ices

ICES

Encode and stream audio using 'ices'

Description

ICES(config.xml)

Streams to an icecast server using ices (available separately).
A configuration file must be supplied for ices (see contrib/asterisk-ices.xml).

ICES() sends the audio output (pcm samples) to stdout. It expects an executable called ices or ices2 in /usr/bin/ or /usr/local/bin/.
If you want to stream mp3 instead of ogg, then you might want to replace ices with a combination of ezstream and lame (see the discussion attached to this page for details). ices2 only accepts PCM and Vorbis as input; however since PCM input can be given "live" you should be able to do some shell hackery with mpg321 to feed MP3s through ices2 (or use ices0).

How to configure ices2


From: "Barton Hodges" <barton at gcmcomputers dot com>
To: <asterisk-users at lists dot digium.com>
Subject: [Asterisk-Users] Streaming calls to the Internet - A Mini How-To
Date: Thu, 11 Mar 2004 10:19:52 -0600

I was searching for a way to stream Asterisk channels onto the Internet, but never found a source that described the steps. This is a very rough mini how-to. You cannot simply cut and paste all of the code below without modifications to suit your needs. Feel free to modify, improve, etc. :)

Install, configure, and start Icecast (http://www.icecast.org/)
Install Ices2 (http://www.icecast.org/ices.php)
Modify asterisk/contrib/asterisk-ices.xml as needed.

Modify musiconhold.conf, meetme.conf and extensions.conf

musiconhold.conf:
random => quietmp3:/var/lib/asterisk/mohmp3,-z

meetme.conf:
[rooms]
conf => 104

extensions.conf:
[stream]
; Conference Room
exten => 100,1,Answer
exten => 100,n,Wait(1)
exten => 100,n,MeetMe(104)
exten => 100,n,HangUp
; Music On Hold
exten => 101,1,Answer
exten => 101,n,Wait(1)
exten => 101,n,MusicOnHold(random)
exten => 101,n,HangUp
; Stream
exten => 102,1,Answer
exten => 102,n,Wait(1)
exten => 102,n,Ices(/some/where/asterisk-ices.xml)
exten => 102,n,HangUp

Create 2 files, moh.call and stream.call:

moh.call:
Channel: Local/101@stream
MaxRetries: 2
RetryTime: 60
WaitTime: 30
Context: stream
Extension: 100
Priority: 1

stream.call:
Channel: Local/102@stream
MaxRetries: 2
RetryTime: 60
WaitTime: 30
Context: stream
Extension: 100
Priority: 1


Now, move the 2 .call files to /var/spool/asterisk/outgoing:

mv moh.call /var/spool/asterisk/outgoing
mv stream.call /var/spool/asterisk/outgoing

Connect to your Icecast stream and you should hear your MusicOnHold music.

Other people can join the conference by dialing x100, and their voices will stream too.
-Barton

Additional thoughts and tips

  • in Asterisk 1.4 you will unfortunately not succed with "Ices" being the only MeetMe participant and having MeetMe play music-on-hold (Option m). That is why the above example manually adds a MoH call leg to the conference.
  • Ices() itself does not provide any audio feedback to the streaming caller, that's another reason why you might consider to select the MeetMe approach shown above.
  • you can extend the above example by adding the "Ices" leg to MeetMe, with the help of a triggered .call file by using TrySystem and MeetMeCount, only when a designated user calls in; close the conference when that marked user exits (option x of MeetMe)


; == Dial-in for active chat participant ==
exten => 110,1,Answer
exten => 110,n,MeetMeCount(104|MEMECO)
exten => 110,n,GotoIf($[${MEMECO} > 0]?enter)
; follow the .call file examples above and establish a bridge with extensions 111 and 112
; if you want to do it the right way then first 'cp' the .call file to /tmp and then 'mv' this copy to .../outgoing
exten => 110,n,TrySystem('cp /var/spool/asterisk/streamchat.call /var/spool/asterisk/outgoing/')
exten => 110,n,Wait(1)
exten => 110,n(enter),Playback(WelcomToChat)
exten => 110,n,MeetMe(104,AMop) ; we are now a marked conference user
exten => 110,n,HangUp
; == Ices streaming initiated by streamchat.call ==
exten => 111,1,Answer
exten => 111,n,Wait(1)
exten => 111,n,Ices(/etc/asterisk/ices-chat.xml)
exten => 111,n,HangUp
; == Conference Room entry for icecast streaming and listen-only participants ==
exten => 112,1,Answer
exten => 112,n,Wait(1)
exten => 112,n,MeetMe(104,qlMx) ; eXit if last marked user leaves the room
exten => 112,n,HangUp



Basic knowledge

  • Typically icecast will wait for 1 minute of source audio to arrive (and buffer) before letting the listening clients have it, creating a considerably delay.
  • Useful streaming source clients are edcast for Windows (stand-alone or as plugins for WinAmp or FooBar2000), MuSE for Mac OS, ezstream for Linux, or in general VLC as multi-platform solution.
  • With icecast the ports do not really play any role (except maybe for firewall and bindport considerations). A streaming source that connects to port 8001 will automatically stream to the same mountpoint on e.g. port 8000.
  • The icecast server v2.3 has support for both an intro and a fallback (music-on-hold) audio file. Therefore this must not necessarily be done on the Asterisk/MeetMe side.
  • If you elect to stream mp3 instead of ogg then you need to make sure that Intro and Fallback sources are of the same bitrate as the stream: Many media players cannot deal with bitrate changes of ongoing .mp3 streams. It appears that for .ogg this is not an issue.
  • Icecast2 can also stream the Theora video format. Question: Is there a way to integrate this with video for Asterisk?

Configuration notes

If ices is complaining about broken pipe errors from within asterisk, you may need to create a symlink from "ices" to "ices2" in your /usr/local/bin directory.

User reports

If that doesn't work for some reason (In my case, I needed to stream through a flash applet on a web page, so it needed to be an mp3 stream), you can use an eagi that pipes through an encoder and then to your streaming software. In my case, I piped the audio through ffmpeg and then to ezstream which sent it to icecast.

Here's my quick and easy eagi script:

#!/bin/sh
cat /dev/fd/3 | sox -t raw -r 8000 -w -s -c 1 - -t raw -r 44100 - vol 2|ffmpeg -f s16le -ar 44100 -ac 1 -i - -ab 32k -f mp3 - | ezstream -c /var/lib/asterisk/ices/stream.mp3.xml

It just dumps the audio through sox, to increase the volume a bit, and convert the sample rate, then ffmpeg to encode the mp3, and then ezstream to send it to an icecast server. I could probably skip the sox step, and get ffmpeg to do those adjustments on its own, but for now, I know sox's command line better, so I used that. :)

The dialplan is as simple as

exten => meetme,n,MeetMe(confname,1qd)

put all the members of the conversation in there,

exten => mp3stream,n,EAGI(mp3stream.sh)

and then put this in as well to start recording.

Streaming MOH

I use icecast, and Liquidsoap to stream MOH into Asterisk.

See also

  • Short and useful overview on icecast and ices2
  • Edcast JACK client: Hook into any jack output port and broadcast the audio to an icecast or shoutcast server. Asterisk 1.6 comes with JACK audio interface support.
  • Also LiquidSoap can be used to stream Asterisk audio input via JACK
  • Asterisk cmd jack: JACK audio interface
  • app_rtppage (bug/patch 11797): Send multicast to capable phones like Snom, Linksys, Cisco or Barix
  • Asterisk cmd MeetMe
  • Flumotion: Streaming with GStreamer and Twisted (and Python)
  • Comparison of media streaming systems
  • patch 4296 added the ogg vorbis format in SVN revision 6173 (Jan 2008) for Recording, Playback and Voicemail. Is that a way to record a g722 wideband call and then have a streaming client simultaneously access the recording?
  • MAST: Multicast Audio Streaming Toolkit
  • VLC: VideoLAN player/server including multicast & shoutcast support
  • Commercial: CyberData SIP/multicast paging speakers and SIP streaming server
  • PlaySip is a tool that can take a SIP call (gsm or uLaw), and re-broadcast it to an RTSP/RTP server (3-5sec latency)
  • mod_shout for Freeswitch


Go back to Asterisk

Created by: JustRumours, Last modification: Tue 08 of Jan, 2013 (16:08 UTC)


Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+

Page Changes | Comments

 

Featured -

Search: