Asterisk 內建一個 *1 的 feature: on demand recording,通話中,按下*1 可以開始進行錄音,不過如果要客製錄音檔名或儲存目錄,就必須停用內建的 feature,然後用 Macro 重寫一個錄音功能。
如果有使用 FreePBX,停用此功能必須使用 Web UI 操作
FreePBX Admin > Feature Codes
In-Call Asterisk Toggle Call Recording: Disabled
沒有安裝 FreePBX 時
編輯/etc/asterisk/features.conf
... [featuremap] ;automon=*1 ;將這行註解
檢查設定
#asterisk -rx "features show" Builtin Feature Default Current --------------- ------- ------- Pickup *8 *8 Blind Transfer # ## Attended Transfer *2 One Touch Monitor <這裡必須是空白> Disconnect Call * ** Park Call One Touch MixMonitor <這裡必須是空白>
以系統有安裝 FreePBX 為例
編輯 /etc/asterisk/extensions_custom.conf
... ... [macro-myautomon] exten => s,1,Set(DYNAMIC_FEATURES=myautomon) exten => s,n,Set(MONITOR_FILENAME=${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}-${CALLERID(num)}) exten => s,n,Wait(1) exten => s,n,MixMonitor(${MONITOR_FILENAME}.wav,b,mv /var/spool/asterisk/monitor/^{MONITOR_FILENAME}.wav /var/spool/asterisk/monitor)
編輯 /etc/asterisk/features_applicationmap_custom.conf
myautomon => *1,caller,Macro,myautomon
編輯 /etc/asterisk/globals_custom.conf
DYNAMIC_FEATURES=myautomon
TIPs:
修改 globals_custom 可以讓內外線都能啟用這功能。
要限制外線或內線,才能啟用此功能時,必須在 outbound 或 inbound 的 context 內加上
Set(DYNAMIC_FEATURES=myautomon)
macro-myautomon:
[macro-myautomon] exten => s,1,Set(DYNAMIC_FEATURES=myautomon) exten => s,n,Set(MONITOR_FILENAME=${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}-${CALLERID(num)) exten => s,n,Wait(1) exten => s,n,MixMonitor(${MONITOR_FILENAME}.wav,b,mv /var/spool/asterisk/monitor/^{MONITOR_FILENAME}.wav /var/spool/asterisk/monitor/`/usr/bin/mysql -u root -p<db_pass> -N -B -D <db_name> -e "SELECT calldate,'From:',src,'To:',dst,'' FROM cdr WHERE uniqueid = ^{UNIQUEID}"|sed -s s'/\s/_/ g'`.wav
錄音檔輸出格式為:
-rw------- 1 asterisk asterisk 161644 May 17 17:54 2012-05-17_17:53:57_From:_101_To:_011800677522_.wav -rw------- 1 asterisk asterisk 118764 May 17 17:51 2012-05-17_17:51:16_From:_101_To:_011800677522_.wav