Streaming musiconhold with mms:// as source

Our fire department is moving to 700 mhz digital radios. The move will render all of their analog channel scanners useless. The new digital scanners are upwards of $600 each, so we’re trying not to purchase many of them.

I’m testing out the possibility of capturing the digital scanner traffic via a line out feed, and presenting to the department via a mms://mediaserver/scanner url.

This was a snap with windows media encoder, and pushing this to our media server.
Getting this to desktops isn’t a problem.

They’d also like to pick this up via an extension on the phone system.

I’ve installed mplayer, and setup a streaming category in Music on Hold.
The application this category is pointed to is a bash script in /etc/asterisk/mohstream.sh
contents of this file:

#!/bin/bash
if [ -n “ls /tmp/pdmohpipe” ]; then
rm /tmp/pdmohpipe
fi
PIPE="/tmp/pdmohpipe"
mknod $PIPE p

mkfifo $PIPE

cat $PIPE &

sleep 3
mplayer -nocache mms://ratchet/cdapdscan -really-quiet -quiet -ao pcm:fast -channels 1 -af resample=8000,channels=1,format=mulaw -ao pcm:file=$PIPE | cat $PIPE
rm $PIPE

I have a custom extension that I dial from any phone and it plays this hold music.

exten => 1234,1,Answer() exten => 1234,n,Wait(1) exten => 1234,n,MusicOnHold(cdapdscan) exten => 1234,n,Wait(1) exten => 1234,n,Hangup()

This is firing off the mplayer utility whenever module_admin reload (orange button) is pressed.

After several reloads - I’m getting multiple instances of the mplayer process writing to the same pipe - and it creates echos/loops when listened to over the phone.

Killing all the mplayer processes, and running “module reload res_musiconhold.so” from the asterisk console clears up the multiple streams, but I would like to automate this so I don’t have to baby sit the mplayer process.

Does anyone have any suggestions on how to keep the mplayer process from relaunching?

Thanks

Kirk.