|
|
@ -38,6 +38,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
|
|
|
#include "asterisk/translate.h"
|
|
|
|
#include "asterisk/translate.h"
|
|
|
|
#include "asterisk/dsp.h"
|
|
|
|
#include "asterisk/dsp.h"
|
|
|
|
#include "asterisk/utils.h"
|
|
|
|
#include "asterisk/utils.h"
|
|
|
|
|
|
|
|
#include "asterisk/options.h"
|
|
|
|
|
|
|
|
|
|
|
|
static char *tdesc = "Trivial Record Application";
|
|
|
|
static char *tdesc = "Trivial Record Application";
|
|
|
|
|
|
|
|
|
|
|
@ -98,6 +99,8 @@ static int record_exec(struct ast_channel *chan, void *data)
|
|
|
|
int option_quiet = 0;
|
|
|
|
int option_quiet = 0;
|
|
|
|
int rfmt = 0;
|
|
|
|
int rfmt = 0;
|
|
|
|
int flags;
|
|
|
|
int flags;
|
|
|
|
|
|
|
|
int waitres;
|
|
|
|
|
|
|
|
struct ast_silence_generator *silgen = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
/* The next few lines of code parse out the filename and header from the input string */
|
|
|
|
/* The next few lines of code parse out the filename and header from the input string */
|
|
|
|
if (ast_strlen_zero(data)) { /* no data implies no filename or anything is present */
|
|
|
|
if (ast_strlen_zero(data)) { /* no data implies no filename or anything is present */
|
|
|
@ -199,7 +202,10 @@ static int record_exec(struct ast_channel *chan, void *data)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!res) {
|
|
|
|
if (res) {
|
|
|
|
|
|
|
|
ast_log(LOG_WARNING, "Could not answer channel '%s'\n", chan->name);
|
|
|
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!option_quiet) {
|
|
|
|
if (!option_quiet) {
|
|
|
|
/* Some code to play a nice little beep to signify the start of the record operation */
|
|
|
|
/* Some code to play a nice little beep to signify the start of the record operation */
|
|
|
@ -235,8 +241,13 @@ static int record_exec(struct ast_channel *chan, void *data)
|
|
|
|
flags = option_append ? O_CREAT|O_APPEND|O_WRONLY : O_CREAT|O_TRUNC|O_WRONLY;
|
|
|
|
flags = option_append ? O_CREAT|O_APPEND|O_WRONLY : O_CREAT|O_TRUNC|O_WRONLY;
|
|
|
|
s = ast_writefile( tmp, ext, NULL, flags , 0, 0644);
|
|
|
|
s = ast_writefile( tmp, ext, NULL, flags , 0, 0644);
|
|
|
|
|
|
|
|
|
|
|
|
if (s) {
|
|
|
|
if (!s) {
|
|
|
|
int waitres;
|
|
|
|
ast_log(LOG_WARNING, "Could not create file %s\n", filename);
|
|
|
|
|
|
|
|
goto out;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (option_transmit_silence_during_record)
|
|
|
|
|
|
|
|
silgen = ast_channel_start_silence_generator(chan);
|
|
|
|
|
|
|
|
|
|
|
|
/* Request a video update */
|
|
|
|
/* Request a video update */
|
|
|
|
ast_indicate(chan, AST_CONTROL_VIDUPDATE);
|
|
|
|
ast_indicate(chan, AST_CONTROL_VIDUPDATE);
|
|
|
@ -311,11 +322,11 @@ static int record_exec(struct ast_channel *chan, void *data)
|
|
|
|
ast_truncstream(s);
|
|
|
|
ast_truncstream(s);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ast_closestream(s);
|
|
|
|
ast_closestream(s);
|
|
|
|
} else
|
|
|
|
|
|
|
|
ast_log(LOG_WARNING, "Could not create file %s\n", filename);
|
|
|
|
|
|
|
|
} else
|
|
|
|
|
|
|
|
ast_log(LOG_WARNING, "Could not answer channel '%s'\n", chan->name);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (silgen)
|
|
|
|
|
|
|
|
ast_channel_stop_silence_generator(chan, silgen);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
out:
|
|
|
|
if ((silence > 0) && rfmt) {
|
|
|
|
if ((silence > 0) && rfmt) {
|
|
|
|
res = ast_set_read_format(chan, rfmt);
|
|
|
|
res = ast_set_read_format(chan, rfmt);
|
|
|
|
if (res)
|
|
|
|
if (res)
|
|
|
|