[Home]

Summary:ASTERISK-02449: App Sox (new app -anthm)
Reporter:Anthony Minessale (anthm)Labels:
Date Opened:2004-09-22 15:31:20Date Closed:2011-06-07 14:04:53
Priority:MajorRegression?No
Status:Closed/CompleteComponents:Applications/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) app_sox.c
Description:This app lets you play a file with sox so you can support
any format sox does.  I did it to see if it would work
in like an hour so if you find any issues you can have a FULL REFUND!

Sox(/var/lib/asterisk/sounds/demo-congrats.gsm)


Comments:By: Clod Patry (junky) 2004-09-22 22:48:01

this isnt just a small thing.
i loaded it.
when i did a show applications
it loooks like:
[...]
          SoftHangup: Soft Hangup Application
                  Sox: Usage: Sox(<filename>)

          StopMonitor: Stop monitoring a channel
[...]

to fix this, just remove the \n at the line 21 which looks like:
static char *synopsis = "Usage: Sox(<filename>)\n";

it will take off the \n in the show applications.

great job anthm.

Just tried it, there's no output in the CLI, which could be really useful and to be standard with any others apps (like Playback,sayNumber,sayDigits).
but i've not so much time today to check the src, cause it's already 12:13AM.
will check it tomorrow.

and that would be great, if like, Playback, if the default dir would be /var/lib/asterisk/sounds/ (astvarlibdir + /sounds/ set in asterisk.conf)

edited on: 09-22-04 22:53

edited on: 09-22-04 23:15

By: Anthony Minessale (anthm) 2004-09-23 09:40:26

DoH! ok here.. I'll made it emulate Playback exactly. (except you can use n and s instead of the whole words noanswer and skip if you want)

Use Sox to stream a file to a channel

[Description]:

Usage: Sox(<filename>[|options])

Options:

n[oanswer]   -- Do not auto-answer the channel.
s[kip]       -- Skip if the channel is not up.

By: Anthony Minessale (anthm) 2004-09-23 11:45:11

added auto detect /var/lib/asterisk/sounds stiff too
to install from outside ast tree...
astxs -append="CFLAGS:-I/usr/src/asterisk/include" -autoload -install app_sox.c

By: Clod Patry (junky) 2004-09-23 19:29:26

humm, i've tried the new version.
i think it has a problem now, cause when im dialing my exten, im getting just a brief part of the voice (like a beep or something) and after, there's nothing.
this is what i've in my CLI:
   -- Executing Sox("SIP/10-8aba", "/var/lib/asterisk/sounds/demo-congrats.gsm") in new stack
   -- Sox Playing '/var/lib/asterisk/sounds/demo-congrats.gsm'
debian*CLI> show channels
       Channel  (Context    Extension    Pri )   State Appl.         Data
   SIP/10-8aba  (test_sip   91           1   )    Ring Sox           /var/lib/asterisk/sounds/demo-congrats.gsm
1 active channel(s)
debian*CLI>

and this is how i've called it from my dialplan:
Sox(/var/lib/asterisk/sounds/demo-congrats.gsm);

any idea why ?
Thanks.

suggestions, Sox playing, why not just Soxing filename? that could be a great verb :)

By: Clod Patry (junky) 2004-09-26 23:28:59

i've remake the tests, and it works now, dunno what happens exactly.

i've tried the options: and i think there's a problem.
Im not hearing the demo-congrats in this way:
this is my dialplan:
exten => 92,1,answer;
exten => 92,2,Sox(/var/lib/asterisk/sounds/demo-congrats.gsm|n);
exten => 92,3,Playback(vm-review);

and this is the output in my CLI:
   -- Executing Answer("SIP/10-584c", "") in new stack
   -- Executing Sox("SIP/10-584c", "/var/lib/asterisk/sounds/demo-congrats.gsm|n") in new stack
Sep 26 23:58:14 WARNING[442387]: pbx.c:1933 ast_pbx_run: Timeout, but no rule 't' in context 'test_sip'
debian*CLI>

and the channel hangups at the timeout, it should play demo-congrats, cause the channel is up, no?

but if im taking off the n option, im hearing my demo-congrats + vm-review


And suggestion: maybe when using the s option, you should display other things then:
-- Executing Sox("SIP/10-caba", "/var/lib/asterisk/sounds/demo-congrats.gsm|s") in new stack
dialplan:
exten => 92,1,Sox(/var/lib/asterisk/sounds/demo-congrats.gsm|s);
exten => 92,2,Playback(vm-review);

cause it could be a bit confusing, cause we think sox is playing the demo-congrats, and in fact isnt playing, cause the channel isnt up.

By: Anthony Minessale (anthm) 2004-09-27 11:17:15

I had it hangup if you specified n and it was already answered
I changed it to just skip answer like playback does.

By: Clod Patry (junky) 2004-10-06 19:23:37

i just played around modules, and i've remark some trouble with ur app.
asterisk*CLI> load app_sox.so
Loaded /usr/lib/asterisk/modules/app_sox.so => (
Usage: Sox(<filename>[|options])

Options:

n[oanswer]   -- Do not auto-answer the channel.
s[kip]       -- Skip if the channel is not up.

)
 == Registered application 'Sox'
asterisk*CLI>

So when i was loading app_sox.so, i was getting all ur tdesc.


and when i was doing a show modules, i was getting this:
[...]
app_db.so                 Database access functions for Asterisk e 0
chan_sip.so               Session Initiation Protocol (SIP)        0
app_sox.so
Usage: Sox(<filename>[|options])

Optio 0
111 modules loaded
asterisk*CLI>


So i just fixed ur app for a better "display"
and i've changed the last argument passed to the function ast_register_application.



So now, it's:
asterisk*CLI> load app_sox.so
Loaded /usr/lib/asterisk/modules/app_sox.so => (Use Sox to stream a file to a channel)
 == Registered application 'Sox'
asterisk*CLI>

and when im doing show modules:
app_mp3.so                Silly MP3 Application - YEAH             0
app_dial.so               Dialing Application                      0
app_sox.so                Use Sox to stream a file to a channel    0
asterisk*CLI>



And, there's someone else who tested it ? give feedbacks please.

By: Clod Patry (junky) 2004-10-07 00:22:03

Sorry, just see my tabs was spaces.
Take the last patch.

By: Anthony Minessale (anthm) 2004-10-07 08:40:24

thx , patched version is uploaded

By: twisted (twisted) 2004-10-27 16:39:11

Hmm... Where do we go from here?  markster? anthm?  I kinda like the idea of supporting any format sox does, but how about if we just patch app_playback to try to use sox if we can't find the file in any format that we support, or would that prove too difficult?

By: Clod Patry (junky) 2004-11-01 14:08:02.000-0600

the problem with the Playback, we must to not specify the extensions. Which is harder to deal with. app_sox has the possibility to play any files we want. But that would be really cool to integrate app_sox in app_playback.

is there any bug until now related with app_sox?

i had trouble last week with it, but i don't know if it were with app_sox or sox itself.

I'll try to repeat this bug again.

By: oliver (oliver) 2004-11-02 17:39:55.000-0600

Hey,

It would be nice if this app would provide "SoxPlayback" and "SoxBackground", behaving just like the existing "Playback" and "Background".


  Grtz,

    Oliver

By: Clod Patry (junky) 2004-11-02 18:30:12.000-0600

why SoxPlayback? sox by default has the same effect.
and for app_sox listen, true, it could be really cool, but i've no idea if we can do that, cause sox its an external program.
anthm should be able to answer that question.

But like twisted already mentionned it, it should be better if we could incorporate it in app_playback/app_background (if possible).

By: oliver (oliver) 2004-11-02 18:44:25.000-0600

Hey junky,

My suggestions for the names are just to keep it consistent with the existing audio playback-apps.  I suspect making it "Background"-like won't be a problem.  Although sox is spawned to convert the audio, it's still Asterisk that plays the output on the channel, so we should be able to make it interruptable as well.


  Grtz,

     Oliver

By: Tilghman Lesher (tilghman) 2004-11-09 09:02:28.000-0600

Interesting, but as it's executing a fork(), it's not any more efficient than an AGI script.  Would it be possible to possibly compile this with the source to sox, such that a fork() is not necessary?

By: Brian West (bkw918) 2004-11-14 22:07:46.000-0600

Proof of concept.  I'll talk with tony and see if he really wants to see this in cvs or not.. Last I talked to him it was more or less just a "lets see if we can do this" type things.