update script

master
Jay 2 years ago
parent 14636cc398
commit d5a620cf8d

@ -22,7 +22,7 @@ If you have multiple musiconhold streams; you can configure them so the caller c
digit=
```
Add this option to your musiconhold class configuration, and select a single DTMF digit (I've not tested * or # but should work). When the caller is on hold; pressing the appropiate digit will instantly switch the channel.
Add this option to your musiconhold class configuration, and select a single DTMF digit (I've not tested * or # but should work). When the caller is on hold; pressing the appropiate digit will switch the channel.
### Icecast/Shoutcast Source Streams
@ -31,28 +31,39 @@ This would be a lot easier if mplayer supported stdout; **but it doesn't**. So i
```
#!/bin/bash
PIPE="/tmp/asterisk-pipe.$$"
if [ `ps -aux | grep -c "/path/to/ices/conf.xml"` -lt 2 ]; then
/usr/bin/ices2 /path/to/ices/conf.xml
fi
PIPE="/tmp/asterisk-cmoh-pipe.$$"
mknod $PIPE p
mplayer -playlist http://host:port/playlist.m3u -really-quiet -quiet -ao pcm:file=$PIPE -af resample=8000,pan=1:0.5:0.5,channels=1,format=mulaw 2>/dev/null | cat $PIPE 2>/dev/null
rm $PIPE
mplayer http://server:port/mountpoint.ogg -softvol -really-quiet -quiet -ao pcm:file=$PIPE -af resample=8000,channels=1,format=mulaw,volume=-6:0 2>/dev/null | cat $PIPE 2>/dev/null
```
#### Translating it in to a step-by-step list:
- Check if our stream is running and start if not
- Define the path and name of our pipe using a pre-determined prefix and random number suffix.
- Create this named pipe with mknod.
- Play back the stream using mplayer; outputting PCM to the named pipe, resampled to 8khz, and downmixed.
- CAT this pipe to stdout.
- Delete the named pipe.
Originally this script had things to find existing pipes and delete them. Storing them in /tmp means they'll disappear on reboot. *If things go right* you won't need to constantly start and stop anything. You can however always look at running processes and see which pipes are being used.
The previous version borrowed heavily from the "it works" method. A couple things are different now:
- removed mplayer -playlist option since that was never a problem
- changed to -softvol for no apparent reason
- added if statement to handle checking of ices2
- removed the statement to delete the pipe as it wasn't needed
The addition of the if statement solved a problem of making sure ices2 is feeding my icecast. I attempted to do this in systemd and it just failed. I may have figured out why, but doing it inside the script doesn't hurt and is easier than mucking around with systemd.
The original version of my Classic Hold used this, in combination with icecast2 and ices2.
But surely we can do this without getting icecast ivolved....directly with applications.
But if you're just feeding a bunch ogg files to icecast, can't you do it with without icecast and using a playlist?
Oh...sure...we can...***but holy cow***.
Oh...sure...you can...***but holy cow***.
## Classic Hold Version 2: Less Complex, ***More Headache***

Loading…
Cancel
Save