What is the best way to get the call duration of B-leg in Asterisk?
A num--------(a-leg)------->Asterisk PBX--------(b-leg)-----------> B num
The simple dialplan is:
[bleg_duration]
exten => _X.,1,Answer()
same => n,Wait(10)
same => n,Dial(dahdi/G1/${B_NUM},30,gS(60))
same => n,Noop(${CDR(billsec)})
same => n,Noop(${DIALEDTIME}) ;Time for the call (seconds)
same => n,Noop(${ANSWEREDTIME}) ;Time from dial to answer (seconds)
same => n,Hangup()
so if A number call to that dialplan, it wait for 10 seconds before connect to B number. I would like to get the duration from when the B num is answered to when B num hangup. I think it's common need and but can't find the easy way to get it.
1) You can use forkCDR record.
2) You can dial via Local/ channel, second cdr record will have correct billsec.
3) You can save EPOCH(current time) and user it.
and yes, you still can use
${ANSWEREDTIME}: This is the amount of time for actual call.