[Freeswitch-users] Javascript: record ringing of session

Birgit Arkesteijn birgit at westhawk.co.uk
Tue Nov 25 06:29:45 PST 2008


Hi Anthony,

Thanks for your feedback.
I still cannot get it to work, maybe the snippet and the output will 
give you an idea?


*** I've got the following javascript:

var endpoint_url = 'sofia/gateway/westhawk/0663';
var recordfile = "/usr/local/freeswitch/recordings/dispatcher.wav";

setGlobalVariable("RECORD_ANSWER_REQ", false);
var mSession = new Session("{ignore_early_media=false}" + endpoint_url);
console_log("info", "mSession created, start recording\n");

mSession.execute("record_session", recordfile);


*** When I run it:
freeswitch at apso> jsrun record_rings.js
API CALL [jsrun(record_rings.js)] output:
OK

freeswitch at apso> 2008-11-25 14:22:10 [NOTICE] switch_channel.c:551 
switch_channel_set_name() New Channel sofia/external/0663 
[7225b30a-bafc-11dd-be4c-05a0d8dd6ae1]
2008-11-25 14:22:10 [NOTICE] sofia.c:2327 sofia_handle_sip_i_state() 
Ring-Ready sofia/external/0663!
2008-11-25 14:22:22 [NOTICE] sofia.c:2723 sofia_handle_sip_i_state() 
Channel [sofia/external/0663] has been answered
2008-11-25 14:22:22 [INFO] record_rings.js:1 console_log() mSession 
created, start recording
2008-11-25 14:22:22 [NOTICE] mod_spidermonkey.c:2959 session_destroy() 
Hangup sofia/external/0663 [CS_SOFT_EXECUTE] [NORMAL_CLEARING]
2008-11-25 14:22:22 [NOTICE] switch_core_session.c:927 
switch_core_session_thread() Session 3 (sofia/external/0663) Ended
2008-11-25 14:22:22 [NOTICE] switch_core_session.c:929 
switch_core_session_thread() Close Channel sofia/external/0663 [CS_HANGUP]



As you can see, 'new Session' does not return on the 'ring ready' and 
therefore doesn't record the rings to/on this new channel (that is 
mSession).
Having said that, I don't know if 'ring ready' qualifies as 'early media'.

Cheers, Birgit




On 25/11/08 14:13, Anthony Minessale wrote:
> The originate method does not return until either early media or answer 
> has been received.
> in other words the very instant it returns is the soonest there is even 
> any media to record.
> 
> you can execute record_session app on the A leg before you call and 
> that's the best you can do.
> 
> session.execute("record_session");
> session.execute("bridge", LIST_OF_DESTINATIONS);
> 
> if you are not doing much else in your script it may be better to set 
> the dest as a variable then
> exit your script and execute bridge from the regular dialplan to avoid 
> extra JS overhead during the call.
> 
> 
> 
> 
> 
> On Tue, Nov 25, 2008 at 8:03 AM, Birgit Arkesteijn 
> <birgit at westhawk.co.uk <mailto:birgit at westhawk.co.uk>> wrote:
> 
>     Hi Michael,
> 
>     Sorry to nag you again.
>     I'm getting close to my deadline and I would like to give our customer
>     some feedback on this issue.
> 
>     Would you be so kind to explain what the issue is with recording rings
>     when doing 'new Session(originate_url)'?
> 
>     As far as I've been able to work out, this statement will only
>     return after
>     a) the (or some) timeout has expired or
>     b) the user has picked up
> 
>     Only in case b) we've got a originated session, that can be used to
>     record. However, since the user has already answered, the rings are not
>     recorded.
> 
>     Is that right?
> 
>     Cheers, Birgit


-- 
-- Birgit Arkesteijn, birgit at westhawk.co.uk,
-- Westhawk Ltd, Albion Wharf, 19 Albion Street, Manchester M1 5LN, UK
-- Company no: 1769350
-- Registered Office:
-- 15 London Road, Stockton Heath, Warrington WA4 6SJ. UK.
-- tel.: +44 (0)161 237 0660
-- <URL: http://www.westhawk.co.uk>




More information about the FreeSWITCH-users mailing list