[Freeswitch-users] Help with ignore_early_media

Chris Danielson chris at maxpowersoft.com
Mon Mar 24 11:01:04 PDT 2008


Here is how to handle a new session, though this is used as an example 
that shows bridging after a successful originate call is made.  You can 
remove the bridging code if need be.

//the str variable contains where we are calling and how to go about it.
    var str = 
"{ignore_early_media=true}sofia/gateway/blahBlahProvider/15551231234 at sip.blahprovider.com";  

    session.setVariable("ringback", "%(2000, 4000, 440.0, 480.0)");  
//only if necessary... may not need this line.
    var s = new Session();
    s.setCallerData("caller_id_name", "My Name Is");
    s.setCallerData("caller_id_number", "16661112222");
    if (s.originate(session, str, timeout)) {
        s.waitForMedia();
        s.setAutoHangup(true);
        bridge(session, s);
    }

//Callback reference:   
http://wiki.freeswitch.org/wiki/Javascript_DTMF_Callback_Function 

Hope this helps,
-Chris


Michael Collins wrote:
>
> Interestingly, even though JavaScript is the most developed of the 
> control languages, there is a dearth of sample scripts in SVN. Try 
> here for help:
>
> http://wiki.freeswitch.org/wiki/Category:Javascript
>
>  
>
> I don't see any examples that explicitly use new.Session() so possibly 
> you could try mimicking the examples available and see if there's a 
> quirk in how your script is attempting to work...
>
>  
>
> -MC
>
>  
>
> ------------------------------------------------------------------------
>
> *From:* freeswitch-users-bounces at lists.freeswitch.org 
> [mailto:freeswitch-users-bounces at lists.freeswitch.org] *On Behalf Of 
> *Michael Jerris
> *Sent:* Monday, March 24, 2008 7:01 AM
> *To:* freeswitch-users at lists.freeswitch.org
> *Subject:* Re: [Freeswitch-users] Help with ignore_early_media
>
>  
>
> 2008-03-23 10:22:02 [ERR] HelloWorld.js:7 mod_spidermonkey()  
> TypeError: callBack is not a function
>
>  
>
> You have an error in your script, so the call is aborting.
>
>  
>
> Mike
>
>  
>
>  
>
> On Mar 23, 2008, at 1:14 PM, Leonardo Alves wrote:
>
>
>
> I need some help using the ignore_early_media.
>
>  
>
> I am using a javascript file to dial a number from a asterisk server 
> and play a file to the person who answers the phone.
>
> The problem I am having is relatated to the early_media. I think I am 
> doing something wrong. But I cannot discover what it is.
>
> here is my .js file:
>
>  
>
> ----------------------------------------------------------------------------------------------------------------------------------------------------
>
> var languageCode = "en";
> var soundDir = "sounds/";
> function playFile(fileName, callBack, callBackArgs)
> {
> new_session.streamFile(soundDir + languageCode + "/" + fileName, 
> callBack, callBackArgs);
> }
> new_session = new Session();
> new_session.setCallerData("caller_id_name", "6130356060");
> new_session.originate(session, 
> "{ignore_early_media=true}sofia/gateway/asterisk/9133803764");
> new_session.waitForAnswer();
> if(new_session.ready()){
> playFile("HelloWorld.wav");
> }
> exit();
>
> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
>
> Here is the Freeswitch output:
>
> jsrun HelloWorld.js
> API CALL [jsrun(HelloWorld.js)] output:
> OK
>
> 2008-03-23 10:21:08 [NOTICE] switch_channel.c:531 
> switch_channel_set_name() New Channel sofia/default/9133803764 
> [ff67046e-f8db-11dc-ad03-7f3820494c31]
> freeswitch at debianfs01 <mailto:freeswitch at debianfs01>> 2008-03-23 
> 10:21:08 [NOTICE] switch_channel.c:1380 
> switch_channel_perform_mark_pre_answered() Ring-Ready 
> sofia/default/9133803764!
> 2008-03-23 10:21:08 [NOTICE] sofia_glue.c:1760 sofia_glue_tech_media() 
> Pre-Answer sofia/default/9133803764!
> 2008-03-23 10:21:19 [NOTICE] sofia.c:1848 sofia_handle_sip_i_state() 
> Channel [sofia/default/9133803764] has been answered
> 2008-03-23 10:22:02 [NOTICE] sofia.c:1946 sofia_handle_sip_i_state() 
> Hangup sofia/default/9133803764 [CS_HOLD] [NORMAL_CLEARING]
> 2008-03-23 10:22:02 [ERR] HelloWorld.js:7 mod_spidermonkey()  
> TypeError: callBack is not a function
> 2008-03-23 10:22:02 [NOTICE] switch_core_session.c:748 
> switch_core_session_thread() Session 24 (sofia/default/9133803764) Ended
> 2008-03-23 10:22:02 [NOTICE] switch_core_session.c:750 
> switch_core_session_thread() Close Channel sofia/default/9133803764 
> [CS_HANGUP]
>
> The problem is:
>
> If in the originate command I use the {ignore_early_media=true} 
> option. The script to play the file is executed when the call is 
> answered. But the person who answers the phone cannot hear the .wav file.
>
> If I do not use the {ignore_early_media=true} option. The script to 
> play the file starts when the call is preAnswered. And when the person 
> in the phone answer the call, can hear the sound of the .wav file, but 
> the audio has already started (when the preanswer is executed).
>
> ps: the computer that is making the call is a asterisk server, 
> connected with the FS by sip, and the call is made by zaptel whe pri 
> isdn signalling.
>
> I would like to know if I am doing something wrong or this is a bug in 
> the system.
>
> Thanks for the help.
>
> Leonardo Alves
>
>  
>
> _______________________________________________
> 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
> 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/20080324/4cb946a4/attachment-0002.html 


More information about the FreeSWITCH-users mailing list