So here is what I have done so far, with the help of another use who was did something similar, and that user created a script and shared it with me. I created a new file in usr/local/bin
and named it streamurl.sh:
#!/bin/sh
# change to yes enable debugging output
DEBUG=no
VLC=/usr/bin/vlc
if [ "$DEBUG" = "yes" ] ; then
VLC="$VLC -vvv --file-logging --logfile /tmp/vlc.log"
else
su -c "cvlc "$1" --play-and-exit --network-caching=100 --no-video --sout '#transcode{acodec=s16l,channels=1,samplerate=8000,afilter=mono}:file {mux=dummy,dst=-}'" www-data
su -c "cvlc "/var/lib/asterisk/sounds/1_RLN.wav" --play-and-exit --network-caching=100 --no-video --sout '#transcode{acodec=s16l,channels=1,samplerate=8000,afilter=mono}:file {mux=dummy,dst=-}'" www-data
fi
sleep 10
Then I made it executable with chmod a+x
. Then in /var/lib/asterisk/sounds
I placed a .wav file and named it pleasecallback.wav
. In musiconhold.conf, I have (stream.mp3 is my icecast stream):
[general]
[default]
mode=files
directory=moh
[ulawstream]
mode=custom
application=/usr/local/bin/pleasecallback.sh http://0.0.0.0:8000/stream.mp3
format=ulaw
In sip.conf, I have:
[general]
context=public
allowoverlap=no
udpbindaddr=0.0.0.0
tcpenable=no
tcpbindaddr=0.0.0.0
transport=udp
srvlookup=yes
register => 15555555555:password@voip.freephoneline.ca/15555555555
[freephoneline]
context=from-trunk
host=voip.freephoneline.ca
username=15555555555
secret=password
type=friend
insecure=port,invite
dtmfmode=auto
disallow=all
allow=ulaw
fromdomain=freephoneline.ca
secret=[password]
type=user
context=from-trunk
insecure=port,invite
fromdomain=freephoneline.ca
[basic-options](!)
dtmfmode=rfc2833
context=from-office
type=friend
[natted-phone](!,basic-options)
directmedia=no
host=dynamic
[public-phone](!,basic-options)
directmedia=yes
[my-codecs](!)
disallow=all
In extensions.conf, I have:
[from-trunk]
exten => _X.,1,Set(CALLERID(num)=SIP-ID)
exten => _X.,2,Answer()
exten => _X.,3,Wait(1)
exten => _X.,4,MusicOnHold(ulawstream)
exten => _X.,5,Hangup()
exten => _X.,6,NoOp()
But when I call my sip’s phone # from outside, This is what I get:
Executing [15555555555@from-trunk:1] Set("SIP/freephoneline-00000006", "CALLERID(num)=SIP-ID") in new stack
-- Executing [15555555555@from-trunk:2] Answer("SIP/freephoneline-00000006", "") in new stack
-- Executing [15555555555@from-trunk:3] Wait("SIP/freephoneline-00000006", "1") in new stack
-- Executing [15555555555@from-trunk:4] MusicOnHold("SIP/freephoneline-00000006", "ulawstream") in new stack
-- Started music on hold, class 'ulawstream', on channel 'SIP/freephoneline-00000006'
-- Stopped music on hold on SIP/freephoneline-00000006
== Spawn extension (from-trunk, 15555555555, 4) exited non-zero on 'SIP/freephoneline-00000006'
I don’t hear anything, whether I have a mountpoint (stream) going in icecast or not. If I’m not playing a stream, I don’t hear my .wav message. If I am playing a stream, I don’t hear that. I apologize if the answer is obvious. I am just piecing this together with the help of another user and I haven’t gotten any feedback on my dialplan yet (I don’t know how to write a dialplan in extensions.conf). So a lot of this is guessing and Googling.