Difference between revisions of "Misc. Dialplan Tools record session"

From FreeSWITCH Wiki
Jump to: navigation, search
(Post Processing Recordings in the Dialplan)
Line 158: Line 158:
 
==Post Processing Recordings in the Dialplan==
 
==Post Processing Recordings in the Dialplan==
 
* record_post_process_exec_api
 
* record_post_process_exec_api
* record_post_process_exec_api
+
* record_post_process_exec_app
 
These two variables allow the postprocessing of recorded audio.  The reason this is required is if the A leg hangs up first in a call, the dialplan stops being processed, and then you aren't able to take action on the file that was recorded.  These variables take the form of:
 
These two variables allow the postprocessing of recorded audio.  The reason this is required is if the A leg hangs up first in a call, the dialplan stops being processed, and then you aren't able to take action on the file that was recorded.  These variables take the form of:
 
  <action application="set" data="record_post_process_exec_api=some_api_app:api_app args" />
 
  <action application="set" data="record_post_process_exec_api=some_api_app:api_app args" />
 
+
<action application="set" data="record_post_process_exec_app=some_app:app args" />
  
 
==See Also==
 
==See Also==

Revision as of 20:27, 28 October 2010

Contents

Description

Records an entire phone call or session. The file extension will define the recorded file's format. Use the console command show file to determine possible formats.

Example: record_session /tmp/test.gsm will produce a GSM encoded voice file which is raw data and is not in any container (e.g. wav, ogg, etc.). The sampling rate can not be influenced by the filename.

You can use an external application to resample and manipulate the recorded file like sox.

Dialplan Example

record_session /tmp/test.gsm

The following example, once added to your dialplan will accept a call on extension 666, enable recording for the session, and bridge the call to the toll-free PSTN number through a VoIP provider. Under default FreeSwitch installations, recordings through the extension below will be saved to /usr/local/freeswitch/recordings/

<extension name="ext-666">
  <condition field="destination_number" expression="^666$">
    <action application="set" data="RECORD_TITLE=Recording ${destination_number} ${caller_id_number} ${strftime(%Y-%m-%d %H:%M)}"/>
    <action application="set" data="RECORD_COPYRIGHT=(c) 1980 Factory Records, Inc."/>
    <action application="set" data="RECORD_SOFTWARE=FreeSwitch"/>
    <action application="set" data="RECORD_ARTIST=Ian Curtis"/>
    <action application="set" data="RECORD_COMMENT=Love will tear us apart"/>
    <action application="set" data="RECORD_DATE=${strftime(%Y-%m-%d %H:%M)}"/>
    <action application="set" data="RECORD_STEREO=true"/>
    <action application="record_session" data="$${base_dir}/recordings/${strftime(%Y-%m-%d-%H-%M-%S)}_${destination_number}_${caller_id_number}.wav"/>
    <action application="set" data="ringback=${us-ring}"/>
    <action application="bridge" data="sofia/external/18007842433@sip.voip-provider.com"/>
  </condition>
</extension>

Record Calls To Extensions

To record all phone calls between extensions do the following. Make a directory under freeswitch/recordings/archive/. Then edit Local_Extension in dialplan in /usr/local/freeswitch/conf/dialplan/default.xml

   <extension name="Local_Extension">
     <condition field="destination_number" expression="^(10[01][0-8])$">

Then add the following actions.

   <action application="set" data="RECORD_TITLE=Recording ${destination_number} ${caller_id_number} ${strftime(%Y-%m-%d %H:%M)}"/>
   <action application="set" data="RECORD_COPYRIGHT=(c) 2009"/>
   <action application="set" data="RECORD_SOFTWARE=FreeSwitch"/>
   <action application="set" data="RECORD_ARTIST=FreeSwitch"/>
   <action application="set" data="RECORD_COMMENT=FreeSwitch"/>
   <action application="set" data="RECORD_DATE=${strftime(%Y-%m-%d %H:%M)}"/>
   <action application="set" data="RECORD_STEREO=true"/>
   <action application="record_session" data="$${base_dir}/recordings/archive/${strftime(%Y-%m-%d-%H-%M-%S)}_${destination_number}_${caller_id_number}.wav"/>

Record Calls From Extensions

Add the following in /usr/local/freeswitch/conf/dialplan/default/

 <extension name="flowroute.com.11.digits">
    <condition field="destination_number" expression="^(\d{11})$">
        <action application="set" data="RECORD_TITLE=Recording ${destination_number} ${caller_id_number} ${strftime(%Y-%m-%d %H:%M)}"/>
        <action application="set" data="RECORD_COPYRIGHT=(c) 2009"/>
        <action application="set" data="RECORD_SOFTWARE=FreeSwitch"/>
        <action application="set" data="RECORD_ARTIST=FreeSwitch"/>
        <action application="set" data="RECORD_COMMENT=FreeSwitch"/>
        <action application="set" data="RECORD_DATE=${strftime(%Y-%m-%d %H:%M)}"/>
        <action application="set" data="RECORD_STEREO=true"/>
        <action application="record_session" data="$${base_dir}/recordings/archive/${strftime(%Y-%m-%d-%H-%M-%S)}_${destination_number}_${caller_id_number}.wav"/>
        <action application="bridge" data="sofia/gateway/flowroute.com/$1"/>
    </condition>
 </extension>

Controlling when recording begins

Recording normally starts as soon as the bridge application is called -- oftentimes this isn't desired. You can force the recording to start after the call is actually answered by setting the channel variable media_bug_answer_req

  <action application="set" data="media_bug_answer_req=true"/>

or for releases prior to 1.0.5 or builds prior to 15235

  <action application="set" data="RECORD_ANSWER_REQ=true"/>

If you happen to be using group_confirm_key/group_confirm_file as part of your bridge, you may want to delay the start of the recording until the confirm action is completed. This can be accomplished through use of bridge_pre_execute_bleg_app/bridge_pre_execute_bleg_data:

 <action application="set" data="bridge_pre_execute_bleg_app=record_session"/>
 <action application="set" data="bridge_pre_execute_bleg_data=$${base_dir}/recordings/${strftime(%Y-%m-%d-%H-%M-%S)}_${destination_number}_${caller_id_number}.wav"/>

Recording a call on demand

If your sip client supports a record key or free function keys which allow sending DTMF you can activate server based recording during the call. Recording starts with activating the recording, so not the complete call is recorded.

There are at least two ways to do this: via DTMF or via SIP INFO.


Activating via DTMF

Recording on demand via DTMF is done via dptools' "bind_meta_app" application in dialplan as shown in default dialplan which ships with FreeSWITCH.

Here is a example dialplan:

<extension name="Local_Extension">
      <condition field="destination_number" expression="^(10[01][0-9])$">
        <!-- bind_meta_app can have these args <key> [a|b|ab] [a|b|o|s] <app> -->
        <action application="export" data="RECORD_STEREO=true"/>
        <action application="bind_meta_app" data="2 b s record_session::$${base_dir}/recordings/${caller_id_number}.${strftime(%Y-%m-%d-%H-%M-%S)}.wav"/>
        <action application="bridge" data="user/$1@${domain_name}"/>
      </condition>
</extension>

Lastly, configure your SIP client to send "*2" as DTMF within dialog. When that SIP client is called and call is established it can activate recording by pressing the configured key one time. Pressing it a second time it stops the recording. The other party doesn't hear the DTMFs but possibly its comfort noise generation (CNG) might stop momentarily. The above dialplan example is set to allow the SIP client to turn recording on and off when it is the recipient of a call (i.e. it is the B leg). Change the bind_meta_app settings if you want the originating leg (i.e. the A leg) also to be able to record the call:

<action application="bind_meta_app" data="2 ab s record_session::$${base_dir}/recordings/${caller_id_number}.${strftime(%Y-%m-%d-%H-%M-%S)}.wav"/>

(Note that bind_meta_app in this example is listening on both the a and b legs.)

Activating via SIP INFO

Recording on demand via SIP INFO messages seems to be independent from "bind_meta_app" but obey the RECORD... channel variables. So as of now there seems to be no way to restrict activating recording to one party.


Set in your sip profile the following parameter:

<param name="record-template" value="$${base_dir}/recordings/${caller_id_number}.${strftime(%Y-%m-%d-%H-%M-%S)}.wav"/>


Now your sip client can send a SIP INFO message within the call to activate the recording similar to the following:

INFO sip:mod_sofia@x.x.x.x:5060;transport=udp SIP/2.0
Via: SIP/2.0/UDP a.a.a.a:1024;branch=z9hG4bK-suzjmey8ta9k;rport
From: "AAA" <sip:AAA@x.x.x.x>;tag=8b2lmzjiwj
To: <sip:BBB@x.x.x.x;user=phone>;tag=8rN3KaBrZ0QvQ
Call-ID: 3c26a74322b8-zls28ao7ygpg
CSeq: 7 INFO
Max-Forwards: 70
Contact: <sip:AAA@a.a.a.a:1024;line=bldz828o>;reg-id=1
User-Agent: snom370/7.3.14
Record: '''on'''
Content-Length: 0


To stop recording your sip client should send a SIP INFO message within the call similar to the following:

INFO sip:mod_sofia@x.x.x.x:5060;transport=udp SIP/2.0
Via: SIP/2.0/UDP a.a.a.a:1024;branch=z9hG4bK-oiwe2puuvbuk;rport
From: "AAA" <sip:AAA@8x.x.x.x>;tag=8b2lmzjiwj
To: <sip:BBB@x.x.x.x;user=phone>;tag=8rN3KaBrZ0QvQ
Call-ID: 3c26a74322b8-zls28ao7ygpg
CSeq: 8 INFO
Max-Forwards: 70
Contact: <sip:AAA@a.a.a.a:1024;line=bldz828o>;reg-id=1
User-Agent: snom370/7.3.14
Record: '''off'''
Content-Length: 0


The way of activating this seems to be changed:

You can start or stop recording a session via SIP-INFO messages from a SIP phone. To get this working you need to set "recordings_dir" in vars.xml. In your sip-profile you have to add this:

<param name="record-path" value="$${recordings_dir}"/>
<param name="record-template" value="${caller_id_number}.${destination_number}.${strftime(%Y-%m-%d-%H-%M-%S)}.wav"/>

It seems that the bind_meta_app options are not accessible to this way of session recording...

This is tested with FreeSWITCH Version 1.0.head (17097:17188M) and Snom 370, 820 and 870 FW 8.2+

Post Processing Recordings in the Dialplan

  • record_post_process_exec_api
  • record_post_process_exec_app

These two variables allow the postprocessing of recorded audio. The reason this is required is if the A leg hangs up first in a call, the dialplan stops being processed, and then you aren't able to take action on the file that was recorded. These variables take the form of:

<action application="set" data="record_post_process_exec_api=some_api_app:api_app args" />
<action application="set" data="record_post_process_exec_app=some_app:app args" />

See Also