Friday, January 4, 2013

Asternic (2.0 earlier/later) and latest FreePBX 2.10 (or even 2.11) recording/playback via the GUI doesn’t show anymore after upgrading FBX or a new updated installation of FBX

Hi guys, had encountered an issue with Asternic and FreePBX’s latest Queue module which I noticed was version 2.10.07. Since I updated, the guide and .diff file provided by Asternic doesn’t work. So I had to do some hacks to get it sorted. I guess until Asternic team fixes the .diff file, here’s what you can quickly do to fix it.

IMPORTANT:

  • This only applies for queue module version 2.10.0.7 or newer, you can still use the .diff file provided by Asternic for older versions. If you follow the INSTALL file in the asternic tar.gz package, and when you patch, you don’t get errors, you are then still using the old version. If you do get errors, then you’ve installed the new version of the queue module.
  • If you upgraded/updated your FreePBX then suddenly recordings don’t work, well, then this updated new queues module is the issue.
  • If you ever upgrade the core/queues module after doing these steps below, you must redo step 1, every time you upgrade/update core/queues module in FBX
  • If you are installing Asternic for the first time on a FreePBX queue version 2.10.0.7 or higher, follow the steps detailed in Asternic’s “INSTALL” file up until the patch fpbxmixmon.diff, skip that part and do the parts below instead, to get straight to the fix, once done, continue the “INSTALL” file instructions per usual
  • The recordings after doing this hack below, will still show up in both Asternic and also in ARI

NOTICE

  • I believe in the new recordings formatting, the FreePBX team has probably done some cleanup in their codes to streamline recordings.
  • USE THIS AT YOUR OWN RISK! While I take precautions to use FBX standards and not to invoke changes to any other dialplans, things can go wrong, so test test test
  • NOTE: Improvise if needed, e.g. directory location etc.

 

Step 1 – Modify the FreePBX coding

# nano /var/www/html/admin/modules/queues/functions.inc/dialplan.php

Locate anywhere that says sub-record-check and replace it with sub-record-check-asternic

This is because, we will need to override this context to fit to Asternic’s fancy.

 

Step 2 – Create a MODIFIED sub-record-check macro to support Asternic recording format and post recording script.

# nano /etc/asterisk/extensions_override_freepbx.conf

Paste this below into that file. Please be aware of the location of MONITOR_EXEC script to match the location of yours. All single lines below, so ensure that when copying/pasting.

[sub-record-check-asternic]
exten => s,1,GotoIf($["${BLINDTRANSFER}" = ""]?check)
exten => s,n,ResetCDR()
exten => s,n,GotoIf($["${REC_STATUS}" != "RECORDING"]?check)
exten => s,n,Set(AUDIOHOOK_INHERIT(MixMonitor)=yes)
exten => s,n,MixMonitor(${MIXMON_DIR}${YEAR}/${MONTH}/${DAY}/${CALLFILENAME}.${MIXMON_FORMAT},a,${MIXMON_POST})
exten => s,n(check),Set(__MON_FMT=${IF($["${MIXMON_FORMAT}"="wav49"]?WAV:${MIXMON_FORMAT})})
exten => s,n,GotoIf($["${REC_STATUS}"!="RECORDING"]?next)
exten => s,n,Set(CDR(recordingfile)=${CALLFILENAME}.${MON_FMT})
exten => s,n,Return()
exten => s,n(next),ExecIf($[!${LEN(${ARG1})}]?Return())
exten => s,n,GotoIf($["${REC_STATUS}"!=""]?${ARG1},1)
exten => s,n,Set(__REC_STATUS=INITIALIZED)
exten => s,n,ExecIf($["${REC_POLICY_MODE}"="" & "${ARG3}"!=""]?Set(__REC_POLICY_MODE=${ARG3}))
exten => s,n,Set(NOW=${EPOCH})
exten => s,n,Set(__DAY=${STRFTIME(${NOW},,%d)})
exten => s,n,Set(__MONTH=${STRFTIME(${NOW},,%m)})
exten => s,n,Set(__YEAR=${STRFTIME(${NOW},,%Y)})
exten => s,n,Set(__TIMESTR=${YEAR}${MONTH}${DAY}-${STRFTIME(${NOW},,%H%M%S)})
exten => s,n,Set(__FROMEXTEN=${IF($[${LEN(${AMPUSER})}]?${AMPUSER}:${IF($[${LEN(${REALCALLERIDNUM})}]?${REALCALLERIDNUM}:unknown)})})
;exten => s,n,Set(__CALLFILENAME=${ARG1}-${ARG2}-${FROMEXTEN}-${TIMESTR}-${UNIQUEID})  ;;;MODIFIED LINE 1 -- THIS WAS THE ORIGINAL VERSION, ITS COMMENTED SO IT WONT EXECUTE
exten => s,n,Set(__CALLFILENAME=q${ARG2}-${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}-${UNIQUEID}) ;;; MODIFIED LINE 2 -- THIS IS MY VERSION, COMPATIBLE WITH ASTERNIC
exten => s,n,Set(__MONITOR_EXEC=/usr/local/parselog/update_mix_mixmonitor.pl ^{UNIQUEID} ${MIXMON_DIR}${YEAR}/${MONTH}/${DAY}/${CALLFILENAME}.${MIXMON_FORMAT}) ;;; MODIFIED LINE 3 --THIS I ADDED

exten => s,n,Goto(${ARG1},1)

exten => recq,1,Set(AUDIOHOOK_INHERIT(MixMonitor)=yes)
exten => recq,n,Set(MONITOR_FILENAME=${MIXMON_DIR}${YEAR}/${MONTH}/${DAY}/${CALLFILENAME})
exten => recq,n,Set(__REC_STATUS=RECORDING)
exten => recq,n,Set(CDR(recordingfile)=${CALLFILENAME}.${MON_FMT})
exten => recq,n,Return()

exten => q,1,GosubIf($["${REC_POLICY_MODE}"="always"]?recq,1(${EXTEN},${ARG2},${FROMEXTEN}))
exten => q,n,Return()

Step 3 – Make any change in FreePBX and it should all work again Smile

- Click submit to anything and click Apply Conf

- Try to make calls and see ..

 

Additional stuff

Below is the parselog file I used that worked, be sure to find out AND CHANGE where your LAME app is in. In this case (Debian) lame was in /usr/local/bin/lame

A working parselog file. Click here. IT SHOULD BE THE SAME AS THE Original but yea…Please follow the configuration guide from Asternic for the parselog file.

Outbound call recording should work without any issues if you follow Asternic’s guide as it doesn’t interfere with FreePBX core coding through php, it uses the [macro-dialout-trunk-predial-hook] that doesn’t get directly modified in FreePBX gui.

 

Here’s my screenie of the before and after, notice before I hadn’t had recording, now with the above steps 1-3, it works again, yay

image

 

Bonus

If you got files that were not converted due to this issue above, here’s a dirty way how to get it working again on Asternic

1) Go to each directory containing the .wav file and run this code (For Debian 6 only, use on other OSes at your own risk)

# cd /var/spool/asterisk/monitor/2013/01/01/

# for i in `ls -l | awk {'print $9'}`; do uniqwav=`echo $i | cut -d - -f6 `;  uniqueid=`echo ${uniqwav//.wav/}`; /usr/local/parselog/update_mix_mixmonitor.pl $uniqueid `pwd`/$i; done

1 comment:

dndinfotainment p said...

Hi,
I am from Virat Bharat I Saw This Blog. This Is very Informative to our Youth. Really Good If you Want to see our Site You can easily Visit

http://www.viratbharat.com/Technology/Technology_News.aspx

Thanking You
Puneet Kardam