[Home]

Summary:ASTERISK-14228: [patch] mp3 playback not working via AGI "STREAM FILE", but "EXEC PLAYBACK" works
Reporter:Robby D (rbd)Labels:
Date Opened:2009-05-29 12:49:55Date Closed:2010-01-06 09:38:33.000-0600
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Addons/format_mp3
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) 20091230_addons_1.4_issue15224.diff
( 1) fastagi-test.py
Description:-Ubuntu 8.10 x64
-Using Asterisk 1.4.24 (compiled from source), Addons 1.4.7

Trying to play an MP3 file via FastAGI "STREAM FILE" and/or "GET DATA" commands fails, with the command returning immediately (log attached). We have tried two different types of mp3 files:
-16-bit, 44.100kHz, CBR, 128kbit (http://asterisk.gnuinter.net/files/digium/asterisk-ng/sounds/fpm-calm-river.mp3, from the standard asterisk-addons distribution)
-16-bit, 11.025kHZ, CBR, 32kbit

Playing either mp3 with the Playback() callflow command (from extensions.conf) works fine. It just seems that things are broken with AGI.

This is a problem for us because EXEC PLAYBACK can't take DTMF. We need to process DTMF like STREAM DATA allows for.

The AGI server script we are using is attached.

Note that in the log snippets you will see mention of voiceglue/phoneglue. This is because we are working the voiceglue folks to get mp3 playback working with it, and saw this bug. Note that in this testing here, we have totally removed voiceglue out of the picture. This is just plain old asterisk playing a plain old MP3 file.

****** ADDITIONAL INFORMATION ******

Relevant snippet of asterisk -vvvcr (with 'agi debug') output is as follows for EXEC PLAYBACK (which works -- we may have terminated the playback about halfway through in the snippet below on purpose because it was working):

AGI Rx << EXEC PLAYBACK "voiceglue/link/fpm-calm-river"
   -- AGI Script Executing Application: (PLAYBACK) Options: (voiceglue/link/fpm-calm-river)
   -- <SIP/5080-0226e9d0> Playing 'voiceglue/link/fpm-calm-river' (language 'en')
AGI Tx >> 200 result=-1LI>
 == Spawn extension (phoneglue, 1, 2) exited non-zero on 'SIP/5080-0226e9d0'
chl-lab-dev2-castdot2*CLI>

----------------------------
The relevant part of the starpy script run looks like:

DEBUG:FastAGI:action (<bound method FastAGIProtocol.execute of <starpy.fastagi.FastAGIProtocol instance at 0xff7bd8>>, ('PLAYBACK', 'voiceglue/link/fpm-calm-river'), {})
INFO:FastAGI:Send Command: 'EXEC PLAYBACK "voiceglue/link/fpm-calm-river"'
DEBUG:FastAGI:Line In: '200 result=-1'
DEBUG:FastAGI:onActionSuccess: -1
DEBUG:FastAGI:action (<bound method FastAGIProtocol.streamFile of <starpy.fastagi.FastAGIProtocol instance at 0xff7bd8>>, ('voiceglue/link/fpm-calm-river',), {})


-----------------------------------
On the NOT working "STREAM DATA" method, we see:

AGI Rx << STREAM FILE voiceglue/link/fpm-calm-river '' 0
   -- Playing 'voiceglue/link/fpm-calm-river' (escape_digits='') (sample_offset 0)
AGI Tx >> 200 result=0 endpos=0
   -- AGI Script agi://localhost completed, returning 0
   -- Executing [1@phoneglue:3] Hangup("SIP/5080-0226e9d0", "") in new stack

----------------------------
And the relevant part of the starpy script run looks like:

INFO:FastAGI:Send Command: "STREAM FILE voiceglue/link/fpm-calm-river '' 0"
DEBUG:FastAGI:Line In: '200 result=0 endpos=0'
DEBUG:FastAGI:onActionFailure
ERROR:hellofastagi:Failure: Traceback (most recent call last):
 File "/usr/lib/python2.5/site-packages/Twisted-8.2.0-py2.5-linux-x86_64.egg/twisted/protocols/basic.py", line 148, in dataReceived
   
 File "/usr/lib/python2.5/site-packages/starpy/fastagi.py", line 120, in lineReceived
   df.callback( line )
 File "/usr/lib/python2.5/site-packages/Twisted-8.2.0-py2.5-linux-x86_64.egg/twisted/internet/defer.py", line 243, in callback
   
 File "/usr/lib/python2.5/site-packages/Twisted-8.2.0-py2.5-linux-x86_64.egg/twisted/internet/defer.py", line 312, in _startRunCallbacks
   
--- <exception caught here> ---
 File "/usr/lib/python2.5/site-packages/Twisted-8.2.0-py2.5-linux-x86_64.egg/twisted/internet/defer.py", line 328, in _runCallbacks
   
 File "/usr/lib/python2.5/site-packages/starpy/fastagi.py", line 185, in onStreamingComplete
   endpos, digit
starpy.error.AGICommandFailure: (-1, 'End position 0 == original position, result code 0')

INFO:FastAGI:Connection terminated
Comments:By: Robby D (rbd) 2009-05-29 12:55:38

Just to clear up some possible confusion, with the text:

"Playing either mp3 with the Playback() callflow command (from extensions.conf) works fine. It just seems that things are broken with AGI."

I mean that things work with Playback either with it being called directly from extensions.conf, for via EXEC PLAYBACK with AGI. What seems to be broken here is not AGI per se, but the STREAM DATA/GET DATA AGI command integration with format_mp3 at some level.

By: Matt Florell (mflorell) 2009-07-19 22:48:30

I've noticed the same issue on 1.4.21.2 on some systems, but for us it doesn't involve MP3 at all, in fact the format of the audio file doesn't seem to matter at all(ULAW, PCM, GSM, ...).

One other interesting thing is that SAY NUMBER does work, for instance:
    -- <IAX2/ASTloop-14264> Playing 'digits/15' (language 'en')
    -- Playing 'queue-seconds' (escape_digits=) (sample_offset 0)

the caller hears "fifteen" and nothing else.

This looks much more like an AGI issue within Asterisk from what I've seen.

Any movement on this in the last two months?

By: Matt Florell (mflorell) 2009-07-20 02:24:09

Update on my problem. It seems that something didn't like the formatting of the first file I was trying to play during the call through AGI on some systems(but it didn't display any errors), and it seems if STREAM FILE encounters any problems it won't actually stream any more files during that call through the STREAM FILE command(even if it says it is playing them), but other commands will work just fine. I have not been able to isolate what causes the problem on only some systems, but reformatting all audio files to 16bit 8k PCM mono has fixed the issue on those affected systems for me.

By: Robby D (rbd) 2009-07-27 18:58:02

tilghman: I saw you picked this item up about 2 months ago. Any progress with it?

By: Robby D (rbd) 2009-12-29 17:03:38.000-0600

this issue seems small but is becoming a problem for us (I reported it about 7 months ago). I'd like to offer a bounty of $100 to $150 to have this fixed. if interested please get in touch with me at robbyd@u20.org

By: Sean Bright (seanbright) 2009-12-30 12:48:51.000-0600

Hard for me to properly test this patch from where I currently am, but it does appear to work.  Could you test and provide feedback?

By: Robby D (rbd) 2009-12-30 13:47:21.000-0600

Tested. seanbright's patch fixes this issue for me with both GET DATA and STREAM FILE

By: Sean Bright (seanbright) 2010-01-05 16:56:29.000-0600

https://reviewboard.asterisk.org/r/453

By: Digium Subversion (svnbot) 2010-01-06 09:27:20.000-0600

Repository: asterisk-addons
Revision: 1083

U   branches/1.4/formats/format_mp3.c

------------------------------------------------------------------------
r1083 | seanbright | 2010-01-06 09:27:19 -0600 (Wed, 06 Jan 2010) | 16 lines

Fix reading samples from format_mp3 after ast_seekstream/ast_tellstream.

There is a bug when using ast_seekstream/ast_tellstream with format_mp3 in that
the file read position is not reset before attempting to read samples.  So when
we seek to determine the maximum size of the file (as in res_agi's STREAM FILE)
we weren't then resetting the file pointer so that we could properly read
samples.  This patch addresses that (in a similar manner to format_wav.c).

(closes issue ASTERISK-14228)
Reported by: rbd
Patches:
     20091230_addons_1.4_issue15224.diff uploaded by seanbright (license 71)
Tested by: rbd, seanbright

Review: https://reviewboard.asterisk.org/r/453

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk-addons?view=rev&revision=1083

By: Digium Subversion (svnbot) 2010-01-06 09:35:44.000-0600

Repository: asterisk
Revision: 238014

U   trunk/addons/format_mp3.c

------------------------------------------------------------------------
r238014 | seanbright | 2010-01-06 09:35:43 -0600 (Wed, 06 Jan 2010) | 16 lines

Fix reading samples from format_mp3 after ast_seekstream/ast_tellstream.

There is a bug when using ast_seekstream/ast_tellstream with format_mp3 in that
the file read position is not reset before attempting to read samples.  So when
we seek to determine the maximum size of the file (as in res_agi's STREAM FILE)
we weren't then resetting the file pointer so that we could properly read
samples.  This patch addresses that (in a similar manner to format_wav.c).

(closes issue ASTERISK-14228)
Reported by: rbd
Patches:
     20091230_addons_1.4_issue15224.diff uploaded by seanbright (license 71)
Tested by: rbd, seanbright

Review: https://reviewboard.asterisk.org/r/453

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=238014

By: Digium Subversion (svnbot) 2010-01-06 09:38:25.000-0600

Repository: asterisk-addons
Revision: 1084

U   branches/1.6.0/formats/format_mp3.c

------------------------------------------------------------------------
r1084 | seanbright | 2010-01-06 09:38:24 -0600 (Wed, 06 Jan 2010) | 16 lines

Fix reading samples from format_mp3 after ast_seekstream/ast_tellstream.

There is a bug when using ast_seekstream/ast_tellstream with format_mp3 in that
the file read position is not reset before attempting to read samples.  So when
we seek to determine the maximum size of the file (as in res_agi's STREAM FILE)
we weren't then resetting the file pointer so that we could properly read
samples.  This patch addresses that (in a similar manner to format_wav.c).

(closes issue ASTERISK-14228)
Reported by: rbd
Patches:
     20091230_addons_1.4_issue15224.diff uploaded by seanbright (license 71)
Tested by: rbd, seanbright

Review: https://reviewboard.asterisk.org/r/453

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk-addons?view=rev&revision=1084

By: Digium Subversion (svnbot) 2010-01-06 09:38:29.000-0600

Repository: asterisk-addons
Revision: 1085

U   branches/1.6.1/formats/format_mp3.c

------------------------------------------------------------------------
r1085 | seanbright | 2010-01-06 09:38:28 -0600 (Wed, 06 Jan 2010) | 16 lines

Fix reading samples from format_mp3 after ast_seekstream/ast_tellstream.

There is a bug when using ast_seekstream/ast_tellstream with format_mp3 in that
the file read position is not reset before attempting to read samples.  So when
we seek to determine the maximum size of the file (as in res_agi's STREAM FILE)
we weren't then resetting the file pointer so that we could properly read
samples.  This patch addresses that (in a similar manner to format_wav.c).

(closes issue ASTERISK-14228)
Reported by: rbd
Patches:
     20091230_addons_1.4_issue15224.diff uploaded by seanbright (license 71)
Tested by: rbd, seanbright

Review: https://reviewboard.asterisk.org/r/453

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk-addons?view=rev&revision=1085

By: Digium Subversion (svnbot) 2010-01-06 09:38:32.000-0600

Repository: asterisk-addons
Revision: 1086

U   branches/1.6.2/formats/format_mp3.c

------------------------------------------------------------------------
r1086 | seanbright | 2010-01-06 09:38:32 -0600 (Wed, 06 Jan 2010) | 16 lines

Fix reading samples from format_mp3 after ast_seekstream/ast_tellstream.

There is a bug when using ast_seekstream/ast_tellstream with format_mp3 in that
the file read position is not reset before attempting to read samples.  So when
we seek to determine the maximum size of the file (as in res_agi's STREAM FILE)
we weren't then resetting the file pointer so that we could properly read
samples.  This patch addresses that (in a similar manner to format_wav.c).

(closes issue ASTERISK-14228)
Reported by: rbd
Patches:
     20091230_addons_1.4_issue15224.diff uploaded by seanbright (license 71)
Tested by: rbd, seanbright

Review: https://reviewboard.asterisk.org/r/453

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk-addons?view=rev&revision=1086