<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
</head>
<body bgcolor="#ffffff" text="#000000">
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.&nbsp; You can
remove the bridging code if need be.<br>
<br>
//the str variable contains where we are calling and how to go about it.<br>
&nbsp;&nbsp;&nbsp; var str =
<a class="moz-txt-link-rfc2396E" href="mailto:{ignore_early_media=true}sofia/gateway/blahBlahProvider/15551231234@sip.blahprovider.com">"{ignore_early_media=true}sofia/gateway/blahBlahProvider/15551231234@sip.blahprovider.com"</a>;&nbsp;
<br>
&nbsp;&nbsp;&nbsp; session.setVariable("ringback", "%(2000, 4000, 440.0, 480.0)");&nbsp;
//only if necessary... may not need this line.<br>
&nbsp;&nbsp;&nbsp; var s = new Session();<br>
&nbsp;&nbsp;&nbsp; s.setCallerData("caller_id_name", "My Name Is");<br>
&nbsp;&nbsp;&nbsp; s.setCallerData("caller_id_number", "16661112222");<br>
&nbsp;&nbsp;&nbsp; if (s.originate(session, str, timeout)) {<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; s.waitForMedia();<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; s.setAutoHangup(true);<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bridge(session, s);<br>
&nbsp;&nbsp;&nbsp; }<br>
<br>
//Callback reference:&nbsp;&nbsp; <a
 href="http://wiki.freeswitch.org/wiki/Javascript_DTMF_Callback_Function">http://wiki.freeswitch.org/wiki/Javascript_DTMF_Callback_Function</a>&nbsp;
<br>
<br>
Hope this helps,<br>
-Chris<br>
<br>
<br>
Michael Collins wrote:
<blockquote
 cite="mid:251B739C905BF64FBACCF028D963A5FB021B32B8@exchange.fcnetwork.com"
 type="cite">
  <meta http-equiv="Content-Type" content="text/html; ">
  <meta name="Generator" content="Microsoft Word 11 (filtered medium)">
<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}
w\:* {behavior:url(#default#VML);}
.shape {behavior:url(#default#VML);}
</style>
<![endif]--><o:SmartTagType
 namespaceuri="urn:schemas-microsoft-com:office:smarttags"
 name="PersonName">
<!--[if !mso]>
<style>
st1\:*{behavior:url(#default#ieooui) }
</style>
<![endif]-->
  <style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman";}
a:link, span.MsoHyperlink
        {color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {color:blue;
        text-decoration:underline;}
p
        {mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman";}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:Arial;
        color:navy;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.25in 1.0in 1.25in;}
div.Section1
        {page:Section1;}
-->
  </style></o:SmartTagType>
  <div class="Section1">
  <p class="MsoNormal"><font color="navy" face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial; color: navy;">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:<o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial; color: navy;"><a
 moz-do-not-send="true"
 href="http://wiki.freeswitch.org/wiki/Category:Javascript">http://wiki.freeswitch.org/wiki/Category:Javascript</a><o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial; color: navy;"><o:p>&nbsp;</o:p></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial; color: navy;">I don&#8217;t see
any examples that explicitly
use new.Session() so possibly you could try mimicking the examples
available
and see if there&#8217;s a quirk in how your script is attempting to work&#8230;<o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial; color: navy;"><o:p>&nbsp;</o:p></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial; color: navy;">-MC<o:p></o:p></span></font></p>
  <p class="MsoNormal"><font color="navy" face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial; color: navy;"><o:p>&nbsp;</o:p></span></font></p>
  <div
 style="border-style: none none none solid; border-color: -moz-use-text-color -moz-use-text-color -moz-use-text-color blue; border-width: medium medium medium 1.5pt; padding: 0in 0in 0in 4pt;">
  <div>
  <div class="MsoNormal" style="text-align: center;" align="center"><font
 face="Times New Roman" size="3"><span style="font-size: 12pt;">
  <hr tabindex="-1" align="center" size="2" width="100%"></span></font></div>
  <p class="MsoNormal"><b><font face="Tahoma" size="2"><span
 style="font-size: 10pt; font-family: Tahoma; font-weight: bold;">From:</span></font></b><font
 face="Tahoma" size="2"><span
 style="font-size: 10pt; font-family: Tahoma;">
<a class="moz-txt-link-abbreviated" href="mailto:freeswitch-users-bounces@lists.freeswitch.org">freeswitch-users-bounces@lists.freeswitch.org</a>
[<a class="moz-txt-link-freetext" href="mailto:freeswitch-users-bounces@lists.freeswitch.org">mailto:freeswitch-users-bounces@lists.freeswitch.org</a>] <b><span
 style="font-weight: bold;">On Behalf Of </span></b>Michael Jerris<br>
  <b><span style="font-weight: bold;">Sent:</span></b> Monday, March
24, 2008 7:01
AM<br>
  <b><span style="font-weight: bold;">To:</span></b> <st1:PersonName
 w:st="on"><a class="moz-txt-link-abbreviated" href="mailto:freeswitch-users@lists.freeswitch.org">freeswitch-users@lists.freeswitch.org</a></st1:PersonName><br>
  <b><span style="font-weight: bold;">Subject:</span></b> Re:
[Freeswitch-users]
Help with ignore_early_media</span></font><o:p></o:p></p>
  </div>
  <p class="MsoNormal"><font face="Times New Roman" size="3"><span
 style="font-size: 12pt;"><o:p>&nbsp;</o:p></span></font></p>
  <div>
  <p class="MsoNormal"><span class="apple-style-span"><font face="Arial"
 size="1"><span style="font-size: 7.5pt; font-family: Arial;">2008-03-23
10:22:02 [ERR]
HelloWorld.js:7 mod_spidermonkey()&nbsp; TypeError: callBack is not a
function</span></font></span><o:p></o:p></p>
  </div>
  <div>
  <p class="MsoNormal"><font face="Times New Roman" size="3"><span
 style="font-size: 12pt;"><o:p>&nbsp;</o:p></span></font></p>
  </div>
  <div>
  <p class="MsoNormal"><span class="apple-style-span"><font face="Arial"
 size="1"><span style="font-size: 7.5pt; font-family: Arial;">You have
an error in your script, so
the call is aborting.</span></font></span><o:p></o:p></p>
  </div>
  <div>
  <p class="MsoNormal"><font face="Times New Roman" size="3"><span
 style="font-size: 12pt;"><o:p>&nbsp;</o:p></span></font></p>
  </div>
  <div>
  <p class="MsoNormal"><span class="apple-style-span"><font face="Arial"
 size="1"><span style="font-size: 7.5pt; font-family: Arial;">Mike</span></font></span><o:p></o:p></p>
  </div>
  <div>
  <p class="MsoNormal"><font face="Times New Roman" size="3"><span
 style="font-size: 12pt;"><o:p>&nbsp;</o:p></span></font></p>
  </div>
  <div>
  <p class="MsoNormal"><font face="Times New Roman" size="3"><span
 style="font-size: 12pt;"><o:p>&nbsp;</o:p></span></font></p>
  </div>
  <div>
  <div>
  <p class="MsoNormal"><font face="Times New Roman" size="3"><span
 style="font-size: 12pt;">On Mar 23, 2008, at 1:14 PM, Leonardo Alves
wrote:<o:p></o:p></span></font></p>
  </div>
  <p class="MsoNormal"><font face="Times New Roman" size="3"><span
 style="font-size: 12pt;"><br>
  <br>
  <o:p></o:p></span></font></p>
  <div bgcolor="#ffffff" leftmargin="0" topmargin="0"
 canvastabstop="true" name="Compose message area" id="MailContainerBody">
  <div>
  <p class="MsoNormal"><font face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial;">I need some help using
the ignore_early_media.</span></font><o:p></o:p></p>
  </div>
  <div>
  <p class="MsoNormal"><font face="Times New Roman" size="3"><span
 style="font-size: 12pt;">&nbsp;<o:p></o:p></span></font></p>
  </div>
  <div>
  <p class="MsoNormal"><font face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial;">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.</span></font><o:p></o:p></p>
  </div>
  <div>
  <p class="MsoNormal"><font face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial;">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.</span></font><o:p></o:p></p>
  </div>
  <div>
  <p class="MsoNormal"><font face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial;">here is my .js file:</span></font><o:p></o:p></p>
  </div>
  <div>
  <p class="MsoNormal"><font face="Times New Roman" size="3"><span
 style="font-size: 12pt;">&nbsp;<o:p></o:p></span></font></p>
  </div>
  <div>
  <p><font face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial;">----------------------------------------------------------------------------------------------------------------------------------------------------</span></font><font
 size="1"><span style="font-size: 7.5pt;"><o:p></o:p></span></font></p>
  <p><font face="Times New Roman" size="1"><span
 style="font-size: 7.5pt;">var
languageCode = "en";<br>
var soundDir = "sound</span></font><font face="Courier New" size="1"><span
 style="font-size: 7.5pt; font-family: &quot;Courier New&quot;;">s</span></font><font
 size="1"><span style="font-size: 7.5pt;">/";<br>
function playFile(fileName, callBack, callBackArgs)<br>
{<br>
  </span></font><font face="Courier New" size="1"><span
 style="font-size: 7.5pt; font-family: &quot;Courier New&quot;;">new_session.</span></font><font
 size="1"><span style="font-size: 7.5pt;">streamFile(soundDir +
languageCode + "/" +
fileName, callBack, callBackArgs);<br>
}<br>
  </span></font><font face="Courier New" size="1"><span
 style="font-size: 7.5pt; font-family: &quot;Courier New&quot;;">new_session =
new Session();<br>
new_session.setCallerData("caller_id_name", "6130356060");<br>
new_session.originate(session,
"{ignore_early_media=true}sofia/gateway/asterisk/9133803764");<br>
new_session.waitForAnswer();<br>
if(new_session.ready()){<br>
playFile("HelloWorld.wav");<br>
}<br>
  </span></font><font size="1"><span style="font-size: 7.5pt;">exit();</span></font><o:p></o:p></p>
  <p><font face="Times New Roman" size="1"><span
 style="font-size: 7.5pt;">------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------</span></font><o:p></o:p></p>
  <p><font face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial;">Here
is the Freeswitch output:</span></font><o:p></o:p></p>
  <p><font face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial;">jsrun
HelloWorld.js<br>
API CALL [jsrun(HelloWorld.js)] output:<br>
OK</span></font><o:p></o:p></p>
  <p><font face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial;">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]<br>
  <a moz-do-not-send="true" href="mailto:freeswitch@debianfs01"
 title="mailto:freeswitch@debianfs01
CTRL + Clique para seguir o link">freeswitch@debianfs01</a>&gt;
2008-03-23 10:21:08 [NOTICE] switch_channel.c:1380
switch_channel_perform_mark_pre_answered() Ring-Ready
sofia/default/9133803764!<br>
2008-03-23 10:21:08 [NOTICE] sofia_glue.c:1760 sofia_glue_tech_media()
Pre-Answer sofia/default/9133803764!<br>
2008-03-23 10:21:19 [NOTICE] sofia.c:1848 sofia_handle_sip_i_state()
Channel
[sofia/default/9133803764] has been answered<br>
2008-03-23 10:22:02 [NOTICE] sofia.c:1946 sofia_handle_sip_i_state()
Hangup
sofia/default/9133803764 [CS_HOLD] [NORMAL_CLEARING]<br>
2008-03-23 10:22:02 [ERR] HelloWorld.js:7 mod_spidermonkey()&nbsp;
TypeError:
callBack is not a function<br>
2008-03-23 10:22:02 [NOTICE] switch_core_session.c:748
switch_core_session_thread() Session 24 (sofia/default/9133803764) Ended<br>
2008-03-23 10:22:02 [NOTICE] switch_core_session.c:750
switch_core_session_thread() Close Channel sofia/default/9133803764
[CS_HANGUP]</span></font><o:p></o:p></p>
  <p><font face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial;">The
problem is:</span></font><o:p></o:p></p>
  <p><font face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial;">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. </span></font><o:p></o:p></p>
  <p><font face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial;">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). </span></font><o:p></o:p></p>
  <p><font face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial;">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.</span></font><o:p></o:p></p>
  <p><font face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial;">I
would like to know if I am doing something wrong or this is a bug in
the
system.</span></font><o:p></o:p></p>
  <p><font face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial;">Thanks
for the help.</span></font><o:p></o:p></p>
  <p><font face="Arial" size="2"><span
 style="font-size: 10pt; font-family: Arial;">Leonardo
Alves</span></font><o:p></o:p></p>
  <div>
  <p class="MsoNormal"><font face="Times New Roman" size="1"><span
 style="font-size: 7.5pt;">&nbsp;</span></font><o:p></o:p></p>
  </div>
  </div>
  </div>
  <p class="MsoNormal"><font face="Times New Roman" size="3"><span
 style="font-size: 12pt;">_______________________________________________<br>
Freeswitch-users mailing list<br>
  <a moz-do-not-send="true"
 href="mailto:Freeswitch-users@lists.freeswitch.org">Freeswitch-users@lists.freeswitch.org</a><br>
<a class="moz-txt-link-freetext" href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a class="moz-txt-link-freetext" href="http://lists.freeswitch.org/mailman/options/freeswitch-users">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a class="moz-txt-link-freetext" href="http://www.freeswitch.org">http://www.freeswitch.org</a><o:p></o:p></span></font></p>
  </div>
  <p class="MsoNormal"><font face="Times New Roman" size="3"><span
 style="font-size: 12pt;"><o:p>&nbsp;</o:p></span></font></p>
  </div>
  </div>
  <pre wrap="">
<hr size="4" width="90%">
_______________________________________________
Freeswitch-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Freeswitch-users@lists.freeswitch.org">Freeswitch-users@lists.freeswitch.org</a>
<a class="moz-txt-link-freetext" href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a>
UNSUBSCRIBE:<a class="moz-txt-link-freetext" href="http://lists.freeswitch.org/mailman/options/freeswitch-users">http://lists.freeswitch.org/mailman/options/freeswitch-users</a>
<a class="moz-txt-link-freetext" href="http://www.freeswitch.org">http://www.freeswitch.org</a>
  </pre>
</blockquote>
</body>
</html>