#include <audioreceive.h>
Inheritance diagram for AudioReceive:
Public Member Functions | |
AudioReceive (Connection *conn, string file, int timeout, int silence_timeout, bool DTMF_exit) throw (CapiExternalError) | |
Constructor. Create an object and test for audio mode. | |
void | mainLoop () throw (CapiWrongState, CapiExternalError) |
Start file reception, wait for one of the timeouts or disconnection and stop the reception. | |
void | dataIn (unsigned char *data, unsigned length) |
Test all received audio packets for silence and count silent packets. | |
long | duration () |
Return the time in seconds since start of mainLoop(). | |
Private Attributes | |
unsigned int | silence_count |
counter how many consecutive samples (bytes) have been silent | |
unsigned int | silence_timeout |
amount of silence samples after which record is finished | |
string | file |
file name to save audio data to | |
long | start_time |
time in seconds since the epoch when the recording was started | |
long | end_time |
time in seconds since the epoch when the recording was finished |
This module handles the reception of an audio wave file. It can recognize silence in the signal and timeout after a given period of silence, after a general timeout or after the reception of a DTMF signal.
If DTMF abort is enabled, the module will abort immediately if the DTMF receiving buffer (see Connection::getDTMF) isn't empty when it is created. That allows the user to abort subsequent audio receive and send commands with one DTMF signal w/o needing to check for received DTMF after each command.
The call must be in audio mode (by connecting with service VOICE), otherwise an exception will be caused.
The created file will be saved in the format given by Capi, that is bit-reversed A-Law (or u-Law), 8 kHz mono.
|
Constructor. Create an object and test for audio mode. The constructor also converts the given silence_timeout from seconds to number of samples (bytes).
|
|
Test all received audio packets for silence and count silent packets. All bytes of a received packages (i.e. 2048 bytes) are partly A-Law decoded, added and compared to a threshhold. If silence is found, silence_count is increased, otherwise the counter is reset to 0. If the silence_timeout value is reached, the mainLoop is signalled to finish. Reimplemented from CallModule.
|
|
Return the time in seconds since start of mainLoop().
|
|
Start file reception, wait for one of the timeouts or disconnection and stop the reception. If the recording was finished because of silence, the silence is truncated away from the recorded file
Reimplemented from CallModule.
|
|
time in seconds since the epoch when the recording was finished
|
|
file name to save audio data to
|
|
counter how many consecutive samples (bytes) have been silent
|
|
amount of silence samples after which record is finished
|
|
time in seconds since the epoch when the recording was started
|