[asterisk-commits] dlee: branch dlee/record r390035 - /team/dlee/record/res/res_stasis_recording.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed May 29 13:24:47 CDT 2013
Author: dlee
Date: Wed May 29 13:24:43 2013
New Revision: 390035
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=390035
Log:
Mostly working
Modified:
team/dlee/record/res/res_stasis_recording.c
Modified: team/dlee/record/res/res_stasis_recording.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/record/res/res_stasis_recording.c?view=diff&rev=390035&r1=390034&r2=390035
==============================================================================
--- team/dlee/record/res/res_stasis_recording.c (original)
+++ team/dlee/record/res/res_stasis_recording.c Wed May 29 13:24:43 2013
@@ -35,6 +35,7 @@
#include "asterisk/dsp.h"
#include "asterisk/file.h"
#include "asterisk/module.h"
+#include "asterisk/paths.h"
#include "asterisk/stasis_app_impl.h"
#include "asterisk/stasis_app_recording.h"
#include "asterisk/stasis_channels.h"
@@ -44,6 +45,9 @@
/*! Comment is ignored by most formats, so we will ignore it, too. */
#define RECORDING_COMMENT NULL
+
+/*! Recording check is unimplemented. le sigh */
+#define RECORDING_CHECK 0
STASIS_MESSAGE_TYPE_DEFN(stasis_app_recording_snapshot_type);
@@ -237,7 +241,6 @@
NULL, ast_format_janitor_dtor);
RAII_VAR(struct ast_dsp *, sildet, NULL, ast_dsp_free);
- int check; /* Whether to check file existence before writing. */
int dtmf_term = 0; /* Flag to indicate termination via DTMF */
int ioflags; /* IO flags for writing output file */
int ms; /* Time remaining/waited, in milliseconds */
@@ -255,23 +258,23 @@
recording_publish(recording);
ao2_unlock(recording);
- check = 1;
ioflags = O_CREAT|O_WRONLY;
switch (recording->options->if_exists) {
case STASIS_APP_RECORDING_IF_EXISTS_FAIL:
+ ioflags |= O_EXCL;
break;
case STASIS_APP_RECORDING_IF_EXISTS_OVERWRITE:
- check = 0;
+ ioflags |= O_TRUNC;
+ break;
+ case STASIS_APP_RECORDING_IF_EXISTS_APPEND:
ioflags |= O_APPEND;
break;
- case STASIS_APP_RECORDING_IF_EXISTS_APPEND:
- check = 0;
- ioflags |= O_TRUNC;
- break;
}
if (recording->options->max_silence_seconds > 0) {
+ ast_debug(3, "%s: Attaching silence detector",
+ ast_channel_uniqueid(chan));
max_silence_ms = recording->options->max_silence_seconds * 1000;
janitor = ast_format_janitor_create(chan);
@@ -282,12 +285,17 @@
res = ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR);
if (res != 0) {
+ ast_log(LOG_WARNING, "%s: Failed to change read format",
+ ast_channel_uniqueid(chan));
recording_fail(recording);
return NULL;
}
sildet = ast_dsp_new();
if (!sildet) {
+ ast_log(LOG_WARNING,
+ "%s: Failed to create silence detector",
+ ast_channel_uniqueid(chan));
recording_fail(recording);
return NULL;
}
@@ -295,11 +303,12 @@
ast_dsp_get_threshold_from_settings(THRESHOLD_SILENCE));
}
- s = ast_writefile(recording->options->name,recording->options->format,
- RECORDING_COMMENT, ioflags, check, AST_FILE_MODE);
+ s = ast_writefile(recording->options->name, recording->options->format,
+ RECORDING_COMMENT, ioflags, RECORDING_CHECK, AST_FILE_MODE);
if (s == NULL) {
- ast_log(LOG_WARNING, "Could not create file %s.%s\n",
- recording->options->name, recording->options->format);
+ ast_log(LOG_WARNING, "%s: Could not record to file %s.%s: %s\n",
+ ast_channel_uniqueid(chan), recording->options->name,
+ recording->options->format, strerror(errno));
recording_fail(recording);
return NULL;
}
@@ -323,6 +332,10 @@
}
maxms = recording->options->max_duration_seconds * 1000;
+ /* A zero maximum indicates forever */
+ if (maxms == 0) {
+ maxms = -1;
+ }
start = ast_tvnow();
while ((ms = ast_remaining_ms(start, maxms))) {
RAII_VAR(struct ast_frame *, f, NULL, ast_frame_dtor);
@@ -399,8 +412,6 @@
recording->state = STASIS_APP_RECORDING_STATE_COMPLETE;
recording_publish(recording);
ao2_unlock(recording);
-
- ast_play_sound(chan, "beep"); /* TEMP - indication that recording is done */
return NULL;
}
More information about the asterisk-commits
mailing list