aboutsummaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authoranthm <anthm@f38db490-d61c-443f-a65b-d21fe96a405b>2005-01-05 19:11:26 +0000
committeranthm <anthm@f38db490-d61c-443f-a65b-d21fe96a405b>2005-01-05 19:11:26 +0000
commitffcef3b142ddb66219c2087f3e5e3b49fcb7ee21 (patch)
tree7025bb838afebf8e38571c156efde7eb4f25ea41 /contrib
parentdbe6ddeb43ade81974f82f1cecac1637a547d6dc (diff)
add rawplayer applet to contrib/utils
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@4675 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'contrib')
-rwxr-xr-xcontrib/utils/README.rawplayer37
-rwxr-xr-xcontrib/utils/rawplayer.c38
2 files changed, 75 insertions, 0 deletions
diff --git a/contrib/utils/README.rawplayer b/contrib/utils/README.rawplayer
new file mode 100755
index 000000000..146898a5c
--- /dev/null
+++ b/contrib/utils/README.rawplayer
@@ -0,0 +1,37 @@
+rawplayer is a simple C applet to stream raw music files in place of mpg123
+
+INSTALL
+
+compile the .c file and install:
+gcc -O2 rawplayer.c -o /usr/bin/rawplayer
+
+
+
+Converting MP3 to RAW
+
+Make track01.mp3 into track01.raw with sox (if compiled with mp3 support).
+sox -c 1 track01.mp3 -t raw -r 8000 -c 1 -s -w track01.raw
+
+Otherwise, use whatever app to turn track01.mp3 into track01.wav then use sox on the wav.
+sox -c 1 track01.wav -t raw -r 8000 -c 1 -s -w track01.raw
+
+
+Once you have the raw files put them in any dir on your system (eg /var/lib/asterisk/holdmusic_raw).
+and set up a class in musiconhold.conf like so:
+
+[classes]
+default => custom:/var/lib/asterisk/holdmusic_raw,/usr/bin/rawplayer
+
+
+This is the most efficient way to implement moh because no cpu usage is required to
+explode the very compressed mp3 data then downsample the music to the 8khz mono on the fly
+instead the data is already stored on the disk in the format that asterisk needs it to be
+and the player does little more than pick up frames from the file and hand them to right
+to the asterisk pipe where the audio is shared into all the channels who require it.
+
+
+If you have cpu to spare and want a simple mp3 solution consider the format_mp3 from
+asterisk-addons and the files based moh.
+
+
+
diff --git a/contrib/utils/rawplayer.c b/contrib/utils/rawplayer.c
new file mode 100755
index 000000000..61944a885
--- /dev/null
+++ b/contrib/utils/rawplayer.c
@@ -0,0 +1,38 @@
+/*
+ Rawplayer.c simple raw file stdout player
+ (c) Anthony C Minessale II <anthmct@yahoo.com>
+*/
+
+#define BUFLEN 320
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+static int deliver_file(char *path, int fdout) {
+ int fd = 0, bytes = 0;
+ short buf[BUFLEN];
+
+ if ((fd = open(path,O_RDONLY))) {
+ while ((bytes=read(fd, buf, BUFLEN))) {
+ write(fdout, buf, bytes);
+ }
+ if(fd)
+ close(fd);
+ } else
+ return -1;
+
+ return 0;
+}
+
+
+int main(int argc, char *argv[]) {
+ int x = 0, fdout = 0;
+ fdout = fileno(stdout);
+ for (;;)
+ for (x = 1; x < argc ; x++) {
+ if(deliver_file(argv[x], fdout))
+ exit(1);
+ }
+}
+