[Asterisk-Users] Macros not working as expected with extension
"h" in some circumstances
Martin Pycko
martinp at digium.com
Mon Apr 21 07:33:39 MST 2003
> To make a question out of this: Why does it appear that I cannot use macros from within the "h" extension if the originating side hangs up first in a SIP->SIP call?
Because you call GotoIf in the unproper way.
The syntax is
GotoIf, Condition?jump_if_condition_1:jump_if_condition_0
Notice ":" not "|"
In your example you have the condition for _1_, it's s|6
jumping straight to NoOp ....
Martin
>
> JT
>
>
>
> from extensions.conf:
>
> [intern-post]
>
> ; Make sure that if we are recording the channel, we properly clean up the
> ; recorded files.
> exten => h,1,Macro(record-cleanup)
>
> ; Include operator context
> include => operator
> .
> .
> .
> (all extensions in this context are includes other than "h")
>
>
>
> [macro-record-cleanup]
> ; If we have recorded a call, it is to our advantage to change the
> ; format of the call from a two-file system (blah-in.wav blah-out.wav)
> ; into a single file that contains both legs of the call, and then
> ; compress the call into some reasonably small filesize using gsm
> ; compression. This routine should be called out of the "h" priority
> ; in a context. If the call was not recorded, this macro will
> ; not cause any harm, so calling it on each hangup isn't a problem.
> ;
> ; First, did we record this call? If ${CALLFILENAME} is zero, then
> ; we can be fairly certain that this call wasn't recorded, so just
> ; jump to the end of this macro and return out of routine.
> ;
> exten => s,1,SetVar(MONITORDIR=/var/spool/asterisk/monitor)
> exten => s,2,GotoIf($[${CALLFILENAME} = 0]?s|6)
> ;
> ; This part of the routine mixes the in and out .wav files into one .wav, and then
> ; cleans up the original files (removes them)
> ;
> exten => s,3,System(/usr/local/bin/wmix ${CALLFILENAME}-in.wav ${CALLFILENAME}-out.wav > ${CALLFILENAME})
> exten => s,4,System(/bin/rm ${MONITORDIR}/${CALLFILENAME}-in.wav ${MONITORDIR}/${CALLFILENAME}-out.wav)
> ;
> ; This part of the routine compresses the .wav files into a .gsm file for
> ; better storage (about 1/5 the size of a .wav file). Use "untoast" to restore
> ; to normal wav file format. (toast and untoast are fairly standard on Linux systems)
> ;
> exten => s,5,System(/usr/bin/toast -F ${CALLFILENAME})
> ;
> ; End of routine, return to calling point (note: NoOp required for GotoIf at priority 1)
> exten => s,6,NoOp
>
>
>
>
> Output when the originating side ends the call first (unexpectedly stops at priority 1 in macro):
>
> (normal call setup and progress not shown - I show everything after hangup)
>
> *CLI> DEBUG[30737]: File rtp.c, Line 739 (ast_rtp_raw_write): Difference is 10888, ms is 1381
> DEBUG[30737]: File channel.c, Line 2015 (ast_channel_bridge): Didn't get a frame from channel: SIP/2203-751b
> DEBUG[30737]: File channel.c, Line 2083 (ast_channel_bridge): Bridge stops bridging channels SIP/2203-751b and SIP/2205-12f1
> == Spawn extension (intern-post, 2205, 1) exited non-zero on 'SIP/2203-751b'
> -- Executing Macro("SIP/2203-751b", "record-cleanup") in new stack
> -- Executing SetVar("SIP/2203-751b", "MONITORDIR=/var/spool/asterisk/monitor") in new stack
> DEBUG[30737]: File app_macro.c, Line 166 (macro_exec): Extension s, priority 1 returned normally even though call was hung up
> DEBUG[7176]: File chan_sip.c, Line 503 (__sip_ack): Stopping retransmission on '15125295754753e9727742e77c3d1c51 at 10.0.1.10' of Request 103: Found
>
> *CLI>
>
>
>
> Output when destination side ends the call first (this works as it should):
>
> (normal call setup and progress not shown - I show everything after hangup)
>
> *CLI> DEBUG[31761]: File channel.c, Line 2015 (ast_channel_bridge): Didn't get a frame from channel: SIP/2205-75be
> DEBUG[31761]: File channel.c, Line 2083 (ast_channel_bridge): Bridge stops bridging channels SIP/2203-fcac and SIP/2205-75be
> == Spawn extension (intern-post, 2205, 1) exited non-zero on 'SIP/2203-fcac'
> -- Executing Macro("SIP/2203-fcac", "record-cleanup") in new stack
> -- Executing SetVar("SIP/2203-fcac", "MONITORDIR=/var/spool/asterisk/monitor") in new stack
> -- Executing GotoIf("SIP/2203-fcac", "0?s|6") in new stack
> WARNING[31761]: File pbx.c, Line 4190 (pbx_builtin_gotoif): Not taking any branch
> -- Executing System("SIP/2203-fcac", "/usr/local/bin/wmix 20030420-184036-2203-2205-in.wav 20030420-184036-2203-2205-out.wav > 20030420-184036-2203-2205") in new stack
> -- Executing System("SIP/2203-fcac", "/bin/rm /var/spool/asterisk/monitor/20030420-184036-2203-2205-in.wav /var/spool/asterisk/monitor/20030420-184036-2203-2205-out.wav") in new stack
> -- Executing System("SIP/2203-fcac", "/usr/bin/toast -F 20030420-184036-2203-2205") in new stack
> -- Executing NoOp("SIP/2203-fcac", "") in new stack
> DEBUG[7176]: File chan_sip.c, Line 503 (__sip_ack): Stopping retransmission on '947298470 at 10.0.1.6' of Request 102: Found
>
> *CLI>
>
>
>
>
> _______________________________________________
> Asterisk-Users mailing list
> Asterisk-Users at lists.digium.com
> http://lists.digium.com/mailman/listinfo/asterisk-users
>
More information about the asterisk-users
mailing list