Wednesday 24 July 2013

How to pause and resume Asterisk call recordings

If you record your calls you may wish to enable pausing and unpausing of the recordings. This is relativly simple to do once you understand the features.conf file and the ActivateOn and ActivatedBy fields.
Firstly lets take the example where you receive an incoming call and wish to pause and unpause it. features.conf would contain the following two lines in the [applicationmap] section :-
InPauseMonitor   => #1,peer/callee,Macro,recpause,recording-disabled
InUnpauseMonitor => #3,peer/callee,Macro,recunpause,recording-enabled
It is the callee which is allowed to pause and unpause and since the Monitor() application is being run on the inbound channel the macro needs to be run on the peer.
For doing the same with outbound calls its the caller who is allowed to pause and unpause and since this is the same channel which ran the Monitor() application the macro needs to be run on the same channel :-
OutPauseMonitor   => #1,self/caller,Macro,recpause,recording-disabled
OutUnpauseMonitor => #3,self/caller,Macro,recunpause,recording-enabled
Here are the macros which are called and should be placed in extensions.conf. Rather than pausing and unapusing the recording we are actually stopping and starting the recording. That is purely because we have all the individual recordings sent to a remote server which combines and converts them to a mp3 file therefore reducing the cpu load on the asterisk server.
[macro-recpause]
exten => s,1,Playback(/var/lib/asterisk/sounds/recording/beep/beep)
exten => s,n,NoOp(Call Paused - Channel=${CHANNEL} BrigdePeer=${BRIDGEPEER})
exten => s,n,StopMonitor
[macro-recunpause]
exten => s,1,Monitor(wav,${FNAME}_${EPOCH})
exten => s,n,NoOp(Call Unpaused - Channel=${CHANNEL} BrigdePeer=${BRIDGEPEER})
exten => s,n,Playback(/var/lib/asterisk/sounds/recording/beepbeep/beepbeep)
In the features.conf file in addition to specifying the macro to be run we also specified a music on hold class to be used for playing music on hold to the other party. Shown below are the contents of musiconhold.conf and exactly the same files are played as in the ones in the macros. This ensures both parties hear the exact same audio. You can use different audio files if you wish although make sure the music on hold files are the exact same duration otherwise they will be cut short if they are longer or partially repeated if they are shorter.
[recording-disabled]
mode=files
directory=/var/lib/asterisk/sounds/recording/beep
[recording-enabled]
mode=files
directory=/var/lib/asterisk/sounds/recording/beepbeep

4 comments:

  1. I think you have a small misstake, the moh class in features.conf settings is "recording-disabled" and "recording-enabled" , but in musiconhold.conf you have classes defined as "monitor-disabled" and "monitor-enabled"

    ReplyDelete
  2. Hey Gareth! Are you still around and paying attention to what is posted on this blog of yours? :) Please let me know, I could use your assistance.

    ReplyDelete