问题
I have one voice application in which I want to save a recorded sound file. My code is:
$record_file= $dir_path . "recordfile_".$file_count;
$this->obj_agi->exec("Record","$record_file.wav,5,$maxsecs");
Whenever I hang up during recording, the recording application can not execute and hangup the call.
Does anyone have any idea how to manage this record function while hanging up?
回答1:
The record application process the record normally even when you hangup.
However, inside AGI, the best way to trap hangup is to trap the signal sent from Asterisk to your AGI process. By trapping your SIGHUP, you can do whatever you want (billing, touch files, insert in DB, etc).
By default, a SIGHUP will be sent.
to get more infos, here's an output from the core show application AGI (from the CLI)
A locally executed AGI script will receive SIGHUP
on hangup from the channel except when using DeadAGI. A fast AGI server will
correspondingly receive a HANGUP inline with the command dialog. Both of theses
signals may be disabled by setting the ${AGISIGHUP} channel variable to 'no'
before executing the AGI application. Alternatively, if you would like the
AGI application to exit immediately after a channel hangup is detected, set
the ${AGIEXITONHANGUP} variable to 'yes'.
来源:https://stackoverflow.com/questions/13338657/recorded-files-lost-when-user-hangs-up-in-asterisk