MOH streaming for wideband g722/slin16


#1

Any ideas how to stream 16 kHz audio from shoutcast ? I tried mpg123 -r 16000 with type slin16 but the results were terrible.
I would like to use the full potential of my g722 phone.


#2

The problem is 8kHz is hardcoded in res_musiconhold. Here is a little patch:

---  asterisk-1.6.2.20/res/res_musiconhold.c.old   2011-02-01 09:02:09.000000000 -0800
+++ asterisk-1.6.2.20/res/res_musiconhold.c     2011-11-26 18:10:24.000000000 -0800
@@ -634,7 +634,7 @@
        if ((strncasecmp(class->dir, "http://", 7) && strcasecmp(class->dir, "nodir")) && AST_LIST_EMPTY(&class->members))
                continue;
        /* Read mp3 audio */
-       len = ast_codec_get_len(class->format, res);
+       len = ast_codec_get_len(class->format, res * (ast_format_rate(class->format) / 8000 )); // some codecs do not use 8khZ
 
        if ((res2 = read(class->srcfd, sbuf, len)) != len) {
                if (!res2) {

Now you can stream high quality MoH using config like this:

[SmoothJazz] mode=custom application=/usr/bin/mpg123 -q -s -m -r 16000 -b 512 -@ http://tinyurl.com/7d4d6od format=slin16

Some links for reference:

lists.digium.com/pipermail/aster … 49119.html
issues.asterisk.org/jira/browse/ASTERISK-16826


#3

Patches posted here will never be included in the official code.

For them to be accepted, you must sign the electronic licence grant on issues.asterisk.org/jira/ and you must attach the patch, marking it as a code submission.

For bug fixes, it must be against a supported version or trunk.

For new features, it must be against trunk.

Posting here can poison the normal submission process, as only you are allowed to submit it formally and there could be a suspicion that your issues.asterisk.org account represents a third party who copied it from here.