[Freeswitch-users] ORIGINATE_DISPOSITION

Michael Giagnocavo mgg at giagnocavo.net
Wed Aug 17 01:48:43 MSD 2011


I'm gonna jump in with some non-specific advice that might save you a lot of hassle. Go back to the drawing board and work really hard on creating a design that does not involve getting CDR information while processing any of the call legs. Set custom variables, and pick up the a_leg CDR file, and get the b-legs from there. Anthony and I spent many hours going back and forth on this (well, more like he kindly indulged my insistence on doing it my way) and after a long time and lots of obscure edge cases making things unpleasant, I rewrote it and haven't had a problem since.

The FS code might have some of the bugs fixed, but it's not a recommend nor very well tested scenario to try to get CDR info while a leg is still going, so just save yourself the pain.

-Michael

From: freeswitch-users-bounces at lists.freeswitch.org [mailto:freeswitch-users-bounces at lists.freeswitch.org] On Behalf Of Sam
Sent: Tuesday, August 16, 2011 3:22 PM
To: FreeSWITCH Users Help
Subject: Re: [Freeswitch-users] ORIGINATE_DISPOSITION

I have tried to use the xml cdr to find the call duration, etc. but in the xml cdr, freeswitch does not return any of the duration fields, here is a pastebin of my xml output when using the perl $session->getXMLCDR(); and yes I have also set "process_cdr=b_only".

http://pastebin.freeswitch.org/17058

________________________________
From: Anthony Minessale <anthony.minessale at gmail.com<mailto:anthony.minessale at gmail.com>>
To: FreeSWITCH Users Help <freeswitch-users at lists.freeswitch.org<mailto:freeswitch-users at lists.freeswitch.org>>
Sent: Tuesday, August 16, 2011 1:26 PM
Subject: Re: [Freeswitch-users] ORIGINATE_DISPOSITION

again because in FreeSWITCH the legs are separate entity, if you
listen for hangup_complete events or log B-legs in your cdrs you will
get precise info about that.  if you really want you can add a
dialplan app to capture a timestamp when the bridge ends to save the
time.  This is of-couse only useful if the A leg does not also hangup
which is why it's best to extract this kind of data from the CDRs.


On Tue, Aug 16, 2011 at 2:57 PM, Sam <lakersman2006 at yahoo.com<mailto:lakersman2006 at yahoo.com>> wrote:
> Thanks for the clarification. Another question, when the bridge call is
> answered and hung up, how would I get the call duration or the time the call
> is hung up? I saw that the channel variable "hangup_time" is 0 on an
> answered call.
>
> ________________________________
> From: Anthony Minessale <anthony.minessale at gmail.com<mailto:anthony.minessale at gmail.com>>
> To: FreeSWITCH Users Help <freeswitch-users at lists.freeswitch.org<mailto:freeswitch-users at lists.freeswitch.org>>
> Sent: Tuesday, August 16, 2011 12:24 PM
> Subject: Re: [Freeswitch-users] ORIGINATE_DISPOSITION
>
> that is what bridge_early_media=true means, so you can hear the early
> media during originate but stil not return until the channel is
> answered or hungup.
>
> On Tue, Aug 16, 2011 at 2:18 PM, Sam <lakersman2006 at yahoo.com<mailto:lakersman2006 at yahoo.com>> wrote:
>> I need to be able to play back early media to A leg, so if
>> {ignore_early_media=false} there is no way to tell from
>> originate_disposition that the bridge was answered?
>>
>> ________________________________
>> From: Anthony Minessale <anthony.minessale at gmail.com<mailto:anthony.minessale at gmail.com>>
>> To: FreeSWITCH Users Help <freeswitch-users at lists.freeswitch.org<mailto:freeswitch-users at lists.freeswitch.org>>
>> Sent: Tuesday, August 16, 2011 11:56 AM
>> Subject: Re: [Freeswitch-users] ORIGINATE_DISPOSITION
>>
>> bridge_early_media implies ignore_early_media true so you can't use
>> them together but yes since there is no cause code for answered
>> because the call has not ended that would guarantee it was answered if
>> you exited originate with either ignore_early_media=true or
>> bridge_early_media=true
>>
>> On Tue, Aug 16, 2011 at 1:48 PM, Sam <lakersman2006 at yahoo.com<mailto:lakersman2006 at yahoo.com>> wrote:
>>> "if you call somewhere that uses early media, the originate will end
>>> setting originate_disposition to SUCCESS meaning that a live channel
>>> was produced.  Now the bridge will begin between the A and B leg."
>>> Does that mean it is safe to assume when "originate_disposition" is
>>> SUCCESS,
>>> that the call has been answered if I set the following:
>>>
>>> {ignore_early_media=false}
>>> {bridge_early_media=true}
>>>
>>>
>>> ________________________________
>>> From: Anthony Minessale <anthony.minessale at gmail.com<mailto:anthony.minessale at gmail.com>>
>>> To: FreeSWITCH Users Help <freeswitch-users at lists.freeswitch.org<mailto:freeswitch-users at lists.freeswitch.org>>
>>> Sent: Tuesday, August 16, 2011 10:54 AM
>>> Subject: Re: [Freeswitch-users] ORIGINATE_DISPOSITION
>>>
>>> The originate disposition of A leg will always have the last known status
>>> from B
>>>
>>> originate, by default, returns when:
>>>
>>> 1) media is established on a specific outgoing leg, answered or not
>>> 2) all outgoing legs are terminated.
>>>
>>> if you call somewhere that uses early media, the originate will end
>>> setting originate_disposition to SUCCESS meaning that a live channel
>>> was produced.  Now the bridge will begin between the A and B leg.
>>>
>>> When the bridge ends if the B leg is hungup, its cause will be stored
>>> in "bridge_hangup_cause"
>>>
>>> if you want to keep the originate from ending when early media is
>>> established you can add {ignore_early_media=true} or
>>> {bridge_early_media=true} prepended to your dial string and the
>>> originate will never return untill all outbound legs are either hungup
>>> or one is answered.
>>>
>>>
>>> You should take some time to expand your mind to the different
>>> paradigm in FreeSWITCH where you may have as many as 10 outbound legs
>>> at once in a forked-dial situation and some of what you think is
>>> simple and obvious will quickly dissolve.
>>>
>>> Another thing you can do is set the variable "failed_xml_cdr_prefix"
>>> on the A leg.
>>> This prefix will be mixed with an incrementing variable for each
>>> outbound call leg and in the case of a failure the entire XML cdr will
>>> be set into a var on A leg.
>>>
>>> for instance if you set failed_xml_cdr_prefix=foo you would get foo_1
>>> foo_2 etc depending on the number of outbound call legs.
>>>
>>> Additionally you can set copy_xml_cdr on the A leg and when the bridge
>>> ends you will get a complete CDR for B in the "b_leg_cdr" variable on
>>> A
>>>
>>> Finally you should really go with the flow of how FreeSWITCH is
>>> engineered and try to keep your accounting logic in a separate place
>>> and monitor the XML-CDR, CDR-CSV or event_socket +
>>> CHANNEL_HANGUP_COMPLETE events to process this information.  There is
>>> much more to a call and what happens when it's transferred etc than
>>> what you can get in a single monolithic perspective of inside the
>>> channel.  Plus it's conter intuitive to put routing, application and
>>> accounting logic in the same place.
>>>
>>>
>>>
>>> On Tue, Aug 16, 2011 at 12:26 PM, Sam <lakersman2006 at yahoo.com<mailto:lakersman2006 at yahoo.com>> wrote:
>>>> Dmitry,
>>>> Yes, I agree. For an novice like me it was extremely confusing and
>>>> frustrating that I could not get the proper B leg disposition when A leg
>>>> is
>>>> answered by FS itself.
>>>> I hope there can be some methods or functions that will allow us to get
>>>> the
>>>> proper B Leg disposition.
>>>> ________________________________
>>>> From: Dmitry Sytchev <kbdfck at gmail.com<mailto:kbdfck at gmail.com>>
>>>> To: FreeSWITCH Users Help <freeswitch-users at lists.freeswitch.org<mailto:freeswitch-users at lists.freeswitch.org>>
>>>> Sent: Tuesday, August 16, 2011 2:30 AM
>>>> Subject: Re: [Freeswitch-users] ORIGINATE_DISPOSITION
>>>>
>>>> Seems we need to clear things about B-leg disposition in wiki.
>>>> AFAIK there is no method to get correct disposition from B leg without
>>>> analyzing events in case when A-leg was answered by FS itself.
>>>> If A leg was not answered, we can use A-leg disposition for call
>>>> disposition.
>>>>
>>>> 2011/8/16 Michael Collins <msc at freeswitch.org<mailto:msc at freeswitch.org>>
>>>>
>>>>
>>>> On Mon, Aug 15, 2011 at 5:05 PM, Sam <lakersman2006 at yahoo.com<mailto:lakersman2006 at yahoo.com>> wrote:
>>>>
>>>> I am using perl's $session->get_variable("originate_disposition");
>>>>
>>>> Are you looking at the b-leg's session?
>>>>
>>>>
>>>> Also, how come the "hangup_time" shows zero on answered calls?
>>>>
>>>> Because hangup_time refers to the point in time at which the call was
>>>> hung
>>>> up. Since you are in the middle of a call (using the $session object)
>>>> you
>>>> will never see the hangup_time because the object ceases to exist once
>>>> the
>>>> call leg is disconnected.
>>>> I get the impression that you may be using the wrong tool for this
>>>> particular job, but I'm not sure without seeing it. If you don't mind
>>>> dropping it on pastebin we'll have a look and give you some suggestions.
>>>> -MC
>>>>
>>>> ________________________________
>>>> From: Michael Collins <msc at freeswitch.org<mailto:msc at freeswitch.org>>
>>>> To: FreeSWITCH Users Help <freeswitch-users at lists.freeswitch.org<mailto:freeswitch-users at lists.freeswitch.org>>
>>>> Sent: Monday, August 15, 2011 4:58 PM
>>>> Subject: Re: [Freeswitch-users] ORIGINATE_DISPOSITION
>>>>
>>>> And how are you checking the variable? Do you have an event socket open
>>>> or
>>>> ... ?
>>>> -MC
>>>>
>>>> On Mon, Aug 15, 2011 at 4:57 PM, Sam <lakersman2006 at yahoo.com<mailto:lakersman2006 at yahoo.com>> wrote:
>>>>
>>>> It is being generated with a bridge.
>>>>
>>>> ________________________________
>>>> From: Michael Collins <msc at freeswitch.org<mailto:msc at freeswitch.org>>
>>>> To: FreeSWITCH Users Help <freeswitch-users at lists.freeswitch.org<mailto:freeswitch-users at lists.freeswitch.org>>
>>>> Sent: Monday, August 15, 2011 4:54 PM
>>>> Subject: Re: [Freeswitch-users] ORIGINATE_DISPOSITION
>>>>
>>>> And how is it being generated? WIth a bridge or originate or ... ?
>>>> -MC
>>>>
>>>> On Mon, Aug 15, 2011 at 4:49 PM, Sam <lakersman2006 at yahoo.com<mailto:lakersman2006 at yahoo.com>> wrote:
>>>>
>>>> I want to know the B-leg status of the call.
>>>>
>>>> ________________________________
>>>> From: Michael Collins <msc at freeswitch.org<mailto:msc at freeswitch.org>>
>>>> To: FreeSWITCH Users Help <freeswitch-users at lists.freeswitch.org<mailto:freeswitch-users at lists.freeswitch.org>>
>>>> Sent: Monday, August 15, 2011 4:31 PM
>>>> Subject: Re: [Freeswitch-users] ORIGINATE_DISPOSITION
>>>>
>>>> I think you may be wanting "endpoint_disposition" depending on exactly
>>>> what
>>>> you're looking at.
>>>> -MC
>>>>
>>>> On Mon, Aug 15, 2011 at 3:35 PM, Sam <lakersman2006 at yahoo.com<mailto:lakersman2006 at yahoo.com>> wrote:
>>>>
>>>> For the ORIGINATE_DISPOSITION channel variable, does "SUCCESS" mean the
>>>> call
>>>> was ANSWERED?
>>>>
>>>>
>>>> FreeSWITCH-users mailing list
>>>> FreeSWITCH-users at lists.freeswitch.org<mailto: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
>>>>
>>>>
>>>>
>>>>
>>>> FreeSWITCH-users mailing list
>>>> FreeSWITCH-users at lists.freeswitch.org<mailto: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
>>>>
>>>>
>>>>
>>>>
>>>> FreeSWITCH-users mailing list
>>>> FreeSWITCH-users at lists.freeswitch.org<mailto: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
>>>>
>>>>
>>>>
>>>>
>>>> FreeSWITCH-users mailing list
>>>> FreeSWITCH-users at lists.freeswitch.org<mailto: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
>>>>
>>>>
>>>>
>>>>
>>>> FreeSWITCH-users mailing list
>>>> FreeSWITCH-users at lists.freeswitch.org<mailto: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
>>>>
>>>>
>>>>
>>>>
>>>> FreeSWITCH-users mailing list
>>>> FreeSWITCH-users at lists.freeswitch.org<mailto: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
>>>>
>>>>
>>>>
>>>>
>>>> FreeSWITCH-users mailing list
>>>> FreeSWITCH-users at lists.freeswitch.org<mailto: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
>>>>
>>>>
>>>>
>>>>
>>>> FreeSWITCH-users mailing list
>>>> FreeSWITCH-users at lists.freeswitch.org<mailto: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
>>>>
>>>>
>>>>
>>>>
>>>> --
>>>> Best regards,
>>>>
>>>> Dmitry Sytchev,
>>>> IT Engineer
>>>>
>>>>
>>>> FreeSWITCH-users mailing list
>>>> FreeSWITCH-users at lists.freeswitch.org<mailto: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
>>>>
>>>>
>>>>
>>>>
>>>> FreeSWITCH-users mailing list
>>>> FreeSWITCH-users at lists.freeswitch.org<mailto: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
>>>>
>>>>
>>>
>>>
>>>
>>> --
>>> Anthony Minessale II
>>>
>>> FreeSWITCH http://www.freeswitch.org/
>>> ClueCon http://www.cluecon.com/
>>> Twitter: http://twitter.com/FreeSWITCH_wire
>>>
>>> AIM: anthm
>>> MSN:anthony_minessale at hotmail.com<mailto:anthony_minessale at hotmail.com>
>>> GTALK/JABBER/PAYPAL:anthony.minessale at gmail.com<mailto:anthony.minessale at gmail.com>
>>> IRC: irc.freenode.net #freeswitch
>>>
>>> FreeSWITCH Developer Conference
>>> sip:888 at conference.freeswitch.org<mailto:888 at conference.freeswitch.org>
>>> googletalk:conf+888 at conference.freeswitch.org<mailto:888 at conference.freeswitch.org>
>>> pstn:+19193869900
>>>
>>>
>>> FreeSWITCH-users mailing list
>>> FreeSWITCH-users at lists.freeswitch.org<mailto: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
>>>
>>>
>>>
>>>
>>> FreeSWITCH-users mailing list
>>> FreeSWITCH-users at lists.freeswitch.org<mailto: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
>>>
>>>
>>
>>
>>
>> --
>> Anthony Minessale II
>>
>> FreeSWITCH http://www.freeswitch.org/
>> ClueCon http://www.cluecon.com/
>> Twitter: http://twitter.com/FreeSWITCH_wire
>>
>> AIM: anthm
>> MSN:anthony_minessale at hotmail.com<mailto:anthony_minessale at hotmail.com>
>> GTALK/JABBER/PAYPAL:anthony.minessale at gmail.com<mailto:anthony.minessale at gmail.com>
>> IRC: irc.freenode.net #freeswitch
>>
>> FreeSWITCH Developer Conference
>> sip:888 at conference.freeswitch.org<mailto:888 at conference.freeswitch.org>
>> googletalk:conf+888 at conference.freeswitch.org<mailto:888 at conference.freeswitch.org>
>> pstn:+19193869900
>>
>>
>> FreeSWITCH-users mailing list
>> FreeSWITCH-users at lists.freeswitch.org<mailto: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
>>
>>
>>
>>
>> FreeSWITCH-users mailing list
>> FreeSWITCH-users at lists.freeswitch.org<mailto: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
>>
>>
>
>
>
> --
> Anthony Minessale II
>
> FreeSWITCH http://www.freeswitch.org/
> ClueCon http://www.cluecon.com/
> Twitter: http://twitter.com/FreeSWITCH_wire
>
> AIM: anthm
> MSN:anthony_minessale at hotmail.com<mailto:anthony_minessale at hotmail.com>
> GTALK/JABBER/PAYPAL:anthony.minessale at gmail.com<mailto:anthony.minessale at gmail.com>
> IRC: irc.freenode.net #freeswitch
>
> FreeSWITCH Developer Conference
> sip:888 at conference.freeswitch.org<mailto:888 at conference.freeswitch.org>
> googletalk:conf+888 at conference.freeswitch.org<mailto:888 at conference.freeswitch.org>
> pstn:+19193869900
>
>
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org<mailto: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
>
>
>
>
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org<mailto: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
>
>



--
Anthony Minessale II

FreeSWITCH http://www.freeswitch.org/
ClueCon http://www.cluecon.com/
Twitter: http://twitter.com/FreeSWITCH_wire

AIM: anthm
MSN:anthony_minessale at hotmail.com<mailto:anthony_minessale at hotmail.com>
GTALK/JABBER/PAYPAL:anthony.minessale at gmail.com<mailto:anthony.minessale at gmail.com>
IRC: irc.freenode.net #freeswitch

FreeSWITCH Developer Conference
sip:888 at conference.freeswitch.org<mailto:888 at conference.freeswitch.org>
googletalk:conf+888 at conference.freeswitch.org<mailto:888 at conference.freeswitch.org>
pstn:+19193869900


FreeSWITCH-users mailing list
FreeSWITCH-users at lists.freeswitch.org<mailto: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/20110816/2a3670f8/attachment-0001.html 


Join us at ClueCon 2011 Aug 9-11, 2011
More information about the FreeSWITCH-users mailing list