I don’t know whether the issue is with mplayer, or with asterisk. I have the following in pjsip.conf:
[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0
[siptrunk-auth]
type=auth
auth_type=userpass
username=mysipusername
password=mysippassword
[siptrunk-aor]
type=aor
contact=sip:voip.provider.com
[siptrunk]
type=endpoint
transport=transport-udp
context=from-siptrunk
disallow=all
allow=ulaw
outbound_auth=siptrunk-auth
aors=siptrunk-aor
[siptrunk-registration]
type=registration
transport=transport-udp
outbound_auth=siptrunk-auth
server_uri=sip:voip.provider.com
client_uri=sip:mysipusername@voip.provider.com
contact_user=inbound-calls
retry_interval=60
[siptrunk-identify]
type=identify
match=voip.provider.com
endpoint=siptrunk
And in extensions.conf:
[from-siptrunk]
exten => inbound-calls,1,Verbose(1,Playing some music.)
same => n,Answer
same => n,MusicOnHold(ulawstream)
same => n,Hangup()
In musiconhold.conf
[ulawstream]
mode=custom
application=/usr/sbin/moh.sh
And in /usr/sbin/moh.sh:
#!/bin/bash
if -n "`ls /tmp/asterisk-moh-pipe.*`" ; then
rm /tmp/asterisk-moh-pipe.*
fi
PIPE="/tmp/asterisk-moh-pipe.$"
mknod $PIPE p
/usr/sbin/mplayer https://my.icecastserver.com/live.mp3 -really-quiet -quiet -ao pcm:file$
rm $PIPE
I have a livestream going to an icecast server. I cannot hear audio in asterisk with any other method. But the problem is, when the livestream ends, I cannot get moh hold to play audio again unless I stop asterisk, uninstall mplayer, reinstall mplayer, then start asterisk again. Then I can start the livestream again and can hear audio. But sometimes that doesn’t work and I give up, try again, and then it will work.
In the console, it always says " Playing some music." whether or not it’s playing audio. Debug on and verbose increased doesn’t show anything wrong when it’s not playing.