[Freeswitch-users] Need help detecting when phone call is answered in lua script (it is starting before the call is picked up)

Michael Collins msc at freeswitch.org
Wed Jun 22 20:51:17 MSD 2011


Wes,

The "originate" API is very similar to the "bridge" dp command - when the
far end sends *any* media then the originate (or bridge) is considered
"successful" and processing continues. You have a few choices, but I would
start by trying this on your originate:

originate {ignore_early_media=true}sofia/gateway/mcw/914145551212 &lua(
hello.lua)

This will tell the originate not to be "successful" until the far end
actually answers, as opposed to when the far end simply sends media. The
drawback here, of course, is that if call progress is sent in band, e.g. a
busy signal, you are explicitly ignoring that information. An alternative is
found in the "execute_on_xxx" family of channel variables. Check it out:
http://wiki.freeswitch.org/wiki/Channel_Variables#The_execute_on_family

It requires a little more thought, but you end up with more fine-tuned
control over everything. Look in particular at the originate & dialplan
example under "execute_on_answer" which I believe contains the most complete
solution to your problem.

-MC

On Wed, Jun 22, 2011 at 7:47 AM, Wes <wes-fs at 499x.com> wrote:

> Hello,
>
> I'm having trouble detecting when a phone call (originated from
> freeswitch) is answered by the called party using a lua script.  I have
> freeswitch connected to a corporate phone system at my office via SIP.
> When I call my deskphone at work (914145551212), the script waits until
> I answer to start playing the welcome message, and other actions.  But
> when I call my cellphone (912625551212), the script starts before I pick
> up the cellphone, as can be seen in the logs I've pasted below.
>
> Even though the lua script isn't properly detecting when the cell phone
> has been answered, freeswitch *does* seem to know, as shown by the line:
> 2011-06-22 09:21:28.334618 [NOTICE] sofia.c:5594 Channel
> [sofia/external/912625551212] has been answered
> which gets logged when I answer the cell, even though the script is
> already running.
>
> This fact gives me hope that there will be a way to fix this script.
>
> Any suggestions are appreciated!
> thanks.
>
> using:
> FreeSWITCH Version 1.0.head (git-8decee3 2011-06-20 13-21-20 -0500)
>
> Script
> http://pastebin.freeswitch.org/16564
>
> logs:
> http://pastebin.freeswitch.org/16563
>
>
> _______________________________________________
> Join us at ClueCon 2011, Aug 9-11, Chicago
> http://www.cluecon.com 877-7-4ACLUE
>
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20110622/facabd64/attachment-0001.html 


More information about the FreeSWITCH-users mailing list