Home Forum Developers IP0x streaming (or non-streaming) MP3 audio... mpg123

JRPassphrase Registration Control

In order to register on this site, you must first submit the passphrase below.

TODO list for each hardware target can be found as sticky topic in the corresponding forum


luckman212
useravatar
User Info

streaming (or non-streaming) MP3 audio... mpg123

hello again.
yes a lot of posts today big_smile, well I had a day to toy around with my asterisk box.  So I was thinking it would be great if it would be possible to use a low-bitrate MP3 audio stream instead of the boring Music on Hold (MOH) that comes with asterisk. 

not to mention that every time you place someone one hold, and then pick up the call, and then put them back on hold, the music starts over from the beginning! ouch.

I found some documentation about how to do it here
http://www.voip-info.org/wiki/view/Aste … nhold.conf

and here
http://www.mpg123.de/asterisk.shtml

There are other quite useful applications for this as well (think about baby monitor/room monitor -- all you need is a microphone & a shoutcast/icecast server at the home or office, you can define an extension and dial into your asterisk box to listen to the room audio!)

but I guess the switchfin trunk has no mpg123 in it.  Could it be added?  (I mean, not sure if mpg123 can run on Blackfin cpu or if anyone tested it yet).  I would be happy to try to work on this if someone can just point me in the right direction.  Is there any idea on this?


Administrator has disabled public posting
luckman212
useravatar
User Info

Re: streaming (or non-streaming) MP3 audio... mpg123

I want to add another thing:
http://network.allfaq.org/forums/t/13176.aspx

according to this, one instance of mpg123 running "serves" audio to all people who are attached to that MOH stream.  This seems to scale better, so even though cpu usage may be high for decoding the mp3, it still may be more efficient when there are 2-3 people on hold, instead of the standard MOH decoder serving separate streams to each person.   Not sure if this is accurate but it seems logical.


Administrator has disabled public posting
Albi90
useravatar
User Info

Re: streaming (or non-streaming) MP3 audio... mpg123

if you want to give it a go you can follow my guide in http://switchfin.org/index.php?option=c … id=54#p378

let us know how you go!!


Administrator has disabled public posting
luckman212
useravatar
User Info

Re: streaming (or non-streaming) MP3 audio... mpg123

whew, ouch!! sad
I tried and failed miserably with this.  I am guessing the problem is mainly I have no idea what I am doing when it comes to compiling. 

I did try to follow the steps from your guide Jason, making adjustments where necessary, and I basically got as far as this:

1) the 'mpg123' entry now appears as an option in make menuconfig
2) the source file is successfully downloaded during compilation
3) the source is extracted and the 'make' command is executed and tries to compile

but I get this error:

Code:

make[1]: *** No targets specified and no makefile found.  Stop.

Hmmm.. ok so I guess it needs to be configured.  So I enter into the '/switchfin/build_ip04/mpg123-1.12.3' directory and type './configure'

It goes thru the process and completes successfully.
Now, I go back to /switchfin and type "make mpg123" -- it starts to compile and gets pretty far actually, but finally fails, and I now get this output:

Code:

libtool: link:  gcc -shared  .libs/compat.o .libs/parse.o .libs/frame.o .libs/format.o .libs/dct64.o .libs/equalizer.o .libs/id3.o .libs/optimize.o .libs/readers.o .libs/tabinit.o .libs/libmpg123.o .libs/index.o .libs/stringbuf.o .libs/icy.o .libs/icy2utf8.o .libs/ntom.o .libs/synth.o .libs/synth_8bit.o .libs/layer1.o .libs/layer2.o .libs/layer3.o .libs/synth_s32.o .libs/synth_real.o .libs/dct64_i386.o .libs/synth_i586.o .libs/synth_i586_dither.o .libs/dct64_mmx.o .libs/tabinit_mmx.o .libs/synth_mmx.o .libs/synth_3dnow.o .libs/dct64_3dnow.o .libs/equalizer_3dnow.o .libs/dct36_3dnow.o .libs/dct64_3dnowext.o .libs/synth_3dnowext.o .libs/dct36_3dnowext.o .libs/dct64_sse.o .libs/dct64_sse_float.o .libs/synth_sse_float.o .libs/synth_stereo_sse_float.o .libs/synth_sse_s32.o .libs/synth_stereo_sse_s32.o .libs/synth_sse.o .libs/getcpuflags.o .libs/dither.o .libs/feature.o .libs/lfs_wrap.o .libs/lfs_alias.o   -lm    -Wl,-soname -Wl,libmpg123.so.0 -Wl,-version-script -Wl,.libs/libmpg123.ver -o .libs/libmpg123.so.0.25.5

/usr/bin/ld:.libs/libmpg123.ver:2: syntax error in VERSION script
collect2: ld returned 1 exit status
make[4]: *** [libmpg123.la] Error 1
make[4]: Leaving directory `/home/luke/Desktop/switchfin/build_ip04/mpg123-1.12.3/src/libmpg123'
make[3]: *** [all-recursive] Error 1
make[3]: Leaving directory `/home/luke/Desktop/switchfin/build_ip04/mpg123-1.12.3/src'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/home/luke/Desktop/switchfin/build_ip04/mpg123-1.12.3/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/luke/Desktop/switchfin/build_ip04/mpg123-1.12.3'
make: *** [mpg123] Error 2
[luke@fedora switchfin]$

here is where of course I am failing.
I know I probably need to make an 'mpg123.patch' file so that the source will compile for Blackfin.  But I really have no idea what I am doing there.  I looked at the patch that you made for uw-imap but I don't even really know how to "read" those patch files, much less to be able to create the patch needed to get it compiled.   Or maybe I am just missing some libs.

I somehow think that If I was a lot smarter I could get it to compile but I really just don't know where to begin here.  If you can find time to give me any more guidance in this I really do want to learn & help. 

I am attaching my modifications here:
mpg123 mod

(extract into switchfin directory) so you can see what I have done so far (not much I know!!)  Please Help!  neutral

final note:  I was digging around in the uClinux-dist folder and I found that the following other players are already included as part of uClinux dist:

Code:

switchfin/build_ip04/uClinux-dist/user/madplay

switchfin/build_ip04/uClinux-dist/user/mp3play
switchfin/build_ip04/uClinux-dist/user/asterisk-addons/format_mp3
switchfin/build_ip04/uClinux-dist/user/blkfin-apps/mplayer

Is it trivial to add these in to the build structure?  I mean, is this easier than trying to compile mpg123?  I am just asking, I do not know the exact capabilities of each of these apps.


Administrator has disabled public posting
Albi90
useravatar
User Info

Re: streaming (or non-streaming) MP3 audio... mpg123

you will need to configure using --host=bfin-linux-uclibc

have a look at the sqlite3.mk file as an example


Administrator has disabled public posting
luckman212
useravatar
User Info

Re: streaming (or non-streaming) MP3 audio... mpg123

thanks Jason, I will take a look.
I just edited my previous post, what about those other built in players?
madplay
mp3play
format_mp3
mplayer

any chance those would be easier to integrate?


Administrator has disabled public posting
Albi90
useravatar
User Info

Re: streaming (or non-streaming) MP3 audio... mpg123

if any of them will do the job just select custom kernel options in make menuconfig
then run make
then in the next menu select "kernel/libary/Defaults selection" and select "Customize Application/Libary Settings"


Administrator has disabled public posting
luckman212
useravatar
User Info

Re: streaming (or non-streaming) MP3 audio... mpg123

ok, so i tried to add in modules: 
madplay
mp3play
tone
Mplayer

I successfully comlpeted "make" but "make image" fails, with this error.

Code:

/home/luke/Desktop/switchfin/build_ip04/uClinux-dist/user/genext2fs/build-host/genext2fs: couldn't allocate a block (no free space)

make[4]: *** [image.rootfs.ext2.force] Error 1
make[4]: Leaving directory `/home/luke/Desktop/switchfin/build_ip04/uClinux-dist/vendors/Rowetel/IP04'
make[3]: *** [image] Error 2
make[3]: Leaving directory `/home/luke/Desktop/switchfin/build_ip04/uClinux-dist/vendors/Rowetel/IP04'
make[2]: *** [image] Error 2
make[2]: Leaving directory `/home/luke/Desktop/switchfin/build_ip04/uClinux-dist/vendors'
make[1]: *** [image] Error 2
make[1]: Leaving directory `/home/luke/Desktop/switchfin/build_ip04/uClinux-dist'
make: [image] Error 2 (ignored)
gcc /home/luke/Desktop/switchfin/package/sources/zeropad.c -o /home/luke/Desktop/switchfin/build_ip04/image_ip04/zeropad -Wall
/home/luke/Desktop/switchfin/build_ip04/image_ip04/zeropad /home/luke/Desktop/switchfin/build_ip04/image_ip04/uImage /home/luke/Desktop/switchfin/build_ip04/image_ip04/fix_image.astfin 0x20000
Error opening /home/luke/Desktop/switchfin/build_ip04/image_ip04/uImage
make: *** [image] Error 1

does it mean that the uImage was too big for the IP02 to hold? I mean is it a fixed maximum size or something?  I don't know how to interpret this error.  The hard drive in my build environment has 23GB free space...


Administrator has disabled public posting
Albi90
useravatar
User Info

Re: streaming (or non-streaming) MP3 audio... mpg123

Hi Luke

It means your uImage is now to big, you need to cut out some packages.


Administrator has disabled public posting
luckman212
useravatar
User Info

Re: streaming (or non-streaming) MP3 audio... mpg123

sad  ok thats what I thought.   is there any way to tell the size of the various packages so I can see which ones are "meaningful" to remove?   do you know of any that are not essential?


Administrator has disabled public posting
Albi90
useravatar
User Info

Re: streaming (or non-streaming) MP3 audio... mpg123

Mmmm did u add all of those players I would think mplayer would be sizable not sure about the others.
If you have tiff2pdf enabled in the main menu this also takes up abit of space.


Administrator has disabled public posting
luckman212
useravatar
User Info

Re: streaming (or non-streaming) MP3 audio... mpg123

nope I dont have Tiff2PDF, in fact I disabled fax detection too, not using any fax related stuff.   I will try to build without mplayer.  too bad we dont have an extra meg or 2 of space for "stuff".   I dont know of any "neater" package than the ip0x (fanless, tiny, low power) but i guess it would be great if Rowetel would refresh the design and maybe beef up the cpu & add some more ram to the mix.  double the ram would really give this some more room to breathe.


Administrator has disabled public posting
Albi90
useravatar
User Info

Re: streaming (or non-streaming) MP3 audio... mpg123

That’s something i would like to see as well but David will never change the IP04 as its the only atcom model that is approved (A tick) for use in Australia. And its an expensive exercise to get approval.


Administrator has disabled public posting
luckman212
useravatar
User Info

Re: streaming (or non-streaming) MP3 audio... mpg123

do you have any thoughts on Running switchfin on an x86 embedded platform, such as the new Norco 6620-III (PDF datasheet) or Atom D510 Silent Dual-Core Multi LAN M350 Kit.  The D510 (2nd link) has a hardware watchdog-timer which may be useful, as well as 3 gigabit LAN ports... so many possibilities.... 

Both of those are in rugged steel/aluminum cases with no fans (silent) and nice hardware spec.  Yes no FXO/FXS but these can be added fairly easy & cheap via gateways (cheap one for example Grandstream HandyTone HT502 gives you 2 FXS for ~ US$45.

I love switchfin gui and I love that its being actively developed but I am always in the back of my mind worried about aging hardware.


Administrator has disabled public posting
Albi90
useravatar
User Info

Re: streaming (or non-streaming) MP3 audio... mpg123

The only issue i can see with using the GUI 4.0 on another platform would be the links to /persistent these can all be changed in js/astman.js and scripts/*

you may also have to change some of the syntax in the scripts as they are for busybox apps and full systems have slightly varied syntax.


Administrator has disabled public posting
luckman212
useravatar
User Info

Re: streaming (or non-streaming) MP3 audio... mpg123

hmm that "sounds easy" hehe.   so to build an asterisk box using one of those Atom systems would I install linux first, then asterisk & then try to load switchfin GUI on top of it ... I mean since they are not flash-based units, you dont build uImage but instead install directly to CF-card, SSD drive etc.  So how would you get GUI 4.0 on there?


Administrator has disabled public posting
Albi90
useravatar
User Info

Re: streaming (or non-streaming) MP3 audio... mpg123

yup thats correct you would have to build the system install asterisk then load the gui ontop you can get the GUI 4.0 from "svn co https://switchfin.svn.sourceforge.net/s … gui/trunk/ gui"


Administrator has disabled public posting
luckman212
useravatar
User Info

Re: streaming (or non-streaming) MP3 audio... mpg123

ah... ok good to know, I will tuck this away for a later date.  Sticking with the ipXX for now.  smile


Administrator has disabled public posting
Albi90
useravatar
User Info

Re: streaming (or non-streaming) MP3 audio... mpg123

Had a quick look into madplay, has no streaming support so you would have to create a script called "stream.sh" (as you cant use pipe from asterisk).

Code:


#!/bin/sh
wget -O - $1 | madplay -

don’t forget to make it executable "chmod +x stream.sh"
Then call the script from asterisk like "stream.sh http://mystream.com" not sure if it will work but worth a try :-)


Administrator has disabled public posting
Albi90
useravatar
User Info

Re: streaming (or non-streaming) MP3 audio... mpg123

heheh i was abit wrong heres a link to what you want
http://www.ctunion.com/node/228


Administrator has disabled public posting
luckman212
useravatar
User Info

Re: streaming (or non-streaming) MP3 audio... mpg123

cool thats awesome jason thanks.  trying now big_smile


Administrator has disabled public posting
luckman212
useravatar
User Info

Re: streaming (or non-streaming) MP3 audio... mpg123

no luck so far... its very weird I can get madplay to run no problem, and I made a shell script to use 'wget' to pipe the stream to madplay and that seems to work too (no way to test it because there is no console/dsp output on ip0x).   But when I add this config to my musiconhold.conf, it causes my asterisk to die immediately upon startup.

here's what I've got so far:

Code:

1) vi /etc/asterisk/mohstream.sh:


#!/bin/sh
/usr/bin/wget -q -O - http://216.155.137.148:8004 | /usr/bin/madplay -Q -z -o raw:- --mono -R 8000 -a -12 -

2) chmod +x mohstream.sh

3) edit /etc/asterisk/musiconhold.conf, change default context:

[default]
mode=custom
application=/etc/asterisk/mohstream.sh

4) reboot

when I try running asterisk -vvvvv from console, it dies immediately after the 'parsing musiconhold.conf' .. so it definitely doesn't like something about that file or the streaming.    Not sure where to go next.   I am sure this is possible.... because when I run madplay/wget manually, cpu usage is like 1-2% which is great


Administrator has disabled public posting
Albi90
useravatar
User Info

Re: streaming (or non-streaming) MP3 audio... mpg123

sounds like you ran out of memory, may be its trying to cache the stream in ram and chewed it all up :-(

do u have procwatch installed?


Administrator has disabled public posting
luckman212
useravatar
User Info

Re: streaming (or non-streaming) MP3 audio... mpg123

yes I do have procwatch installed.... how can I determine if I am really running out of memory?  shouldnt use too much memory, I mean these are 32kbit streams... not sure how much data wget buffers... but is there some way to see free memory on the unit?  or monitor it?


Administrator has disabled public posting
luckman212
useravatar
User Info

Re: streaming (or non-streaming) MP3 audio... mpg123

i just found cat /proc/meminfo

heres what It looks like without the MOH streaming...  looks like about 12MB free... should be enough no?

Code:

root@ip0x:~> cat /proc/meminfo 

MemTotal:          41728 kB
MemFree:           12220 kB
Buffers:             648 kB
Cached:             8120 kB
SwapCached:            0 kB
Active:             3520 kB
Inactive:           5248 kB
Active(anon):          0 kB
Inactive(anon):        0 kB
Active(file):       3520 kB
Inactive(file):     5248 kB
SwapTotal:             0 kB
SwapFree:              0 kB
Dirty:                12 kB
Writeback:             0 kB
AnonPages:             0 kB
Mapped:                0 kB
Slab:               1256 kB
SReclaimable:        412 kB
SUnreclaim:          844 kB
PageTables:            0 kB
NFS_Unstable:          0 kB
Bounce:                0 kB
WritebackTmp:          0 kB
CommitLimit:       20864 kB
Committed_AS:          0 kB
VmallocTotal:          0 kB
VmallocUsed:           0 kB
VmallocChunk:          0 kB


Administrator has disabled public posting
Albi90
useravatar
User Info

Re: streaming (or non-streaming) MP3 audio... mpg123

yup that should be heaps


Administrator has disabled public posting
luckman212
useravatar
User Info

Re: streaming (or non-streaming) MP3 audio... mpg123

yeah I just fired up 2 shells, side by side, one side was running 'top'
it showed ~11.6mb free

on the other shell, I ran this command:
wget -q -O - http://216.155.137.148:8004 | /usr/bin/madplay -Q -z -o raw:- --mono -R 8000 -a -12 -


which just starts printing garbage to the console (the audio stream I guess) and I let this run for about 3 minutes.  I watched the free mem... it dropped to about 10.7mb but not lower than that.  So I don't think its a memory problem...

<scratching head>  what else could it be??


Administrator has disabled public posting
Albi90
useravatar
User Info

Re: streaming (or non-streaming) MP3 audio... mpg123

after a bit of testing it seems that madplay is fine and the way it has been implemented is fine but res_musiconhold has an issue with mode=custom


Administrator has disabled public posting
luckman212
useravatar
User Info

Re: streaming (or non-streaming) MP3 audio... mpg123

arrg.  is that a non-fixable problem?   what If I use asterisk 1.6?

edit: in the meantime  I am trying to build a uImage w/ madplay + asterisk 1.6 to see if its any different


Administrator has disabled public posting
luckman212
useravatar
User Info

Re: streaming (or non-streaming) MP3 audio... mpg123

ok I failed with the asterisk 1.6

asterisk 1.6 seems to not play with G729 codec (which I need)
upon reboot after flashing, GUI is dead and asterisk is not running.

I ssh in, and try to start asterisk manually:

Code:

root@ip0x:~> asterisk -vvvvv

   |
   | (lines removed)
   |
  == Parsing '/etc/asterisk/phoneprov.conf':   == Found
res_phoneprov.so => (HTTP Phone Provisioning)
asterisk: can't resolve symbol '_G729AB_DEC_RESET'
root@ip0x:~> cat /etc/asterisk/phoneprov.conf
[general]
root@ip0x:~>

http://i.imgur.com/MATmb.png
ok so, any idea on this one?


Administrator has disabled public posting

Board Info

Board Stats:   Total Users: 2587  Total Topics: 299  Total Polls: 1  Total Posts: 1727  Dormant
User Info:   Newest User :  user2553   Members Online: 0   Guests Online: 372
Online  There are no members online
Topic
New
Locked
Topic
New
Locked
Sticky
Active
New/Active
Sticky
Active
New/Active
New/Closed
New Sticky
Closed/Active
New/Locked
New Sticky
Locked/Active
Active/Sticky
Sticky/Locked
Sticky Active Locked
Active/Sticky
Sticky/Locked
Sticky/Active/Locked