[Asterisk-Users] Sipura SPA-3000 and PSTN dtmf

Vahan Yerkanian vahan at arminco.com
Wed Mar 1 09:31:39 MST 2006


Actually,

I believe that something is wrong with the way asterisk implements the 
whole rfc2833 in rtp.c , moreover, the default value of 100ms in 
dtmf_tones[] in do_senddigit() inchannel.c is to short to be detected 
for lots of commercially available fxo gateways.

This was reported several times but as of today the issue is there.

I ended up with the following ugly hack for rtp.c & channel.c:

--- work/asterisk-1.2.4/rtp.c   Wed Mar  1 20:25:03 2006
+++ /root/cvs/rtp.c     Tue Feb 21 00:05:55 2006
@@ -1150,7 +1150,7 @@
         rtpheader[1] = htonl(rtp->lastdigitts);
         rtpheader[2] = htonl(rtp->ssrc);
         rtpheader[3] = htonl((digit << 24) | (0xa << 16) | (0));
-       for (x = 0; x < 6; x++) {
+       for (x = 0; x < 15; x++) {
                 if (rtp->them.sin_port && rtp->them.sin_addr.s_addr) {
                         res = sendto(rtp->s, (void *) rtpheader, hdrlen 
+ 4, 0, (struct sockaddr *) &rtp->them, sizeof(rtp->them));
                         if (res < 0)
@@ -1163,12 +1163,12 @@
                                             ntohs(rtp->them.sin_port), 
payload, rtp->seqno, rtp->lastdigitts, res - hdrlen);
                 }
                 /* Sequence number of last two end packets does not get 
incremented */
-               if (x < 3)
+               if (x < 12)
                         rtp->seqno++;
                 /* Clear marker bit and set seqno */
                 rtpheader[0] = htonl((2 << 30) | (payload << 16) | 
(rtp->seqno));
                 /* For the last three packets, set the duration and the 
end bit */
-               if (x == 2) {
+               if (x == 11) {
  #if 0
                         /* No, this is wrong...  Do not increment 
lastdigitts, that's not according
                            to the RFC, as best we can determine */



--- work/asterisk-1.2.4/channel.c       Wed Mar  1 20:25:01 2006
+++ /root/cvs/channel.c Tue Feb 21 00:05:50 2006
@@ -2111,22 +2111,22 @@
                  * it by doing our own generation. (PM2002)
                  */
                 static const char* dtmf_tones[] = {
-                       "!941+1336/100,!0/100", /* 0 */
-                       "!697+1209/100,!0/100", /* 1 */
-                       "!697+1336/100,!0/100", /* 2 */
-                       "!697+1477/100,!0/100", /* 3 */
-                       "!770+1209/100,!0/100", /* 4 */
-                       "!770+1336/100,!0/100", /* 5 */
-                       "!770+1477/100,!0/100", /* 6 */
-                       "!852+1209/100,!0/100", /* 7 */
-                       "!852+1336/100,!0/100", /* 8 */
-                       "!852+1477/100,!0/100", /* 9 */
-                       "!697+1633/100,!0/100", /* A */
-                       "!770+1633/100,!0/100", /* B */
-                       "!852+1633/100,!0/100", /* C */
-                       "!941+1633/100,!0/100", /* D */
-                       "!941+1209/100,!0/100", /* * */
-                       "!941+1477/100,!0/100" };       /* # */
+                       "!941+1336/250,!0/100", /* 0 */
+                       "!697+1209/250,!0/100", /* 1 */
+                       "!697+1336/250,!0/100", /* 2 */
+                       "!697+1477/250,!0/100", /* 3 */
+                       "!770+1209/250,!0/100", /* 4 */
+                       "!770+1336/250,!0/100", /* 5 */
+                       "!770+1477/250,!0/100", /* 6 */
+                       "!852+1209/250,!0/100", /* 7 */
+                       "!852+1336/250,!0/100", /* 8 */
+                       "!852+1477/250,!0/100", /* 9 */
+                       "!697+1633/250,!0/100", /* A */
+                       "!770+1633/250,!0/100", /* B */
+                       "!852+1633/250,!0/100", /* C */
+                       "!941+1633/250,!0/100", /* D */
+                       "!941+1209/250,!0/100", /* * */
+                       "!941+1477/250,!0/100" };       /* # */
                 if (digit >= '0' && digit <='9')
                         ast_playtones_start(chan, 0, 
dtmf_tones[digit-'0'], 0);
                 else if (digit >= 'A' && digit <= 'D')



Arsen Chaloyan wrote:
> Vahan,
> 
> see my comments below.
> 
[snip]
 >
> Actually SPA-3000 should receive rfc2833 DTMF events
> from IP side and put inband DTMFs instead to PSTN
> side.
> 
> SPA-3000 fails to correctly detect rfc2833 events,
> which poorly constructed by asterisk.
> 
> So asterisk isn't fully compliant to rfc2833, from the
> other hand other VoIP gateways (but not SPA-3000)
> manage to detect rfc2833 DTMFs from asterisk.
> 
> SPA-3000 serves well in this scenario if source of RTP
> stream is another VoIP device or phone (cisco, snom,
> aastra...), not asterisk itself.
> 
> Here come the solution:
> try to exclude asterisk from media path
> canreinvite=yes
> 
> [111]
> ;SPA-3000 FXO port
> type=friend
> username=111
> secret=xxx
> host=dynamic
> canreinvite=yes
> dtmfmode=rfc2833
> 
> This is the only way I manage to setup
> asterisk/SPA-3000 in described scenario.
> 
> Hope this will help,
> Arsen.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: vahan.vcf
Type: text/x-vcard
Size: 287 bytes
Desc: not available
Url : http://lists.digium.com/pipermail/asterisk-users/attachments/20060301/42e79a11/vahan.vcf


More information about the asterisk-users mailing list