[svn-commits] dlee: branch dlee/record r392753 - in /team/dlee/record: apps/ include/asteri...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Jun 24 14:53:51 CDT 2013


Author: dlee
Date: Mon Jun 24 14:53:49 2013
New Revision: 392753

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=392753
Log:
Addressed review feedback.
 * Removed redundant code
 * Fixed some spacing
 * Fixed hard-coded sound file in ast_play_sound


Modified:
    team/dlee/record/apps/app_minivm.c
    team/dlee/record/apps/app_voicemail.c
    team/dlee/record/include/asterisk/app.h
    team/dlee/record/include/asterisk/channel.h
    team/dlee/record/include/asterisk/file.h
    team/dlee/record/include/asterisk/stasis_app_recording.h
    team/dlee/record/main/app.c
    team/dlee/record/main/file.c
    team/dlee/record/res/res_stasis_recording.c

Modified: team/dlee/record/apps/app_minivm.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/record/apps/app_minivm.c?view=diff&rev=392753&r1=392752&r2=392753
==============================================================================
--- team/dlee/record/apps/app_minivm.c (original)
+++ team/dlee/record/apps/app_minivm.c Mon Jun 24 14:53:49 2013
@@ -1674,7 +1674,7 @@
 				ast_channel_setoption(chan, AST_OPTION_RXGAIN, &record_gain, sizeof(record_gain), 0);
 			if (ast_test_flag(vmu, MVM_OPERATOR))
 				canceldtmf = "0";
-			cmd = ast_play_and_record_full(chan, playfile, recordfile, maxtime, fmt, duration, sound_duration, global_silencethreshold, global_maxsilence, unlockdir, acceptdtmf, canceldtmf);
+			cmd = ast_play_and_record_full(chan, playfile, recordfile, maxtime, fmt, duration, sound_duration, global_silencethreshold, global_maxsilence, unlockdir, acceptdtmf, canceldtmf, AST_RECORD_IF_EXISTS_OVERWRITE);
 			if (record_gain)
 				ast_channel_setoption(chan, AST_OPTION_RXGAIN, &zero_gain, sizeof(zero_gain), 0);
 			if (cmd == -1) /* User has hung up, no options to give */

Modified: team/dlee/record/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/record/apps/app_voicemail.c?view=diff&rev=392753&r1=392752&r2=392753
==============================================================================
--- team/dlee/record/apps/app_voicemail.c (original)
+++ team/dlee/record/apps/app_voicemail.c Mon Jun 24 14:53:49 2013
@@ -14684,7 +14684,7 @@
 				ast_channel_setoption(chan, AST_OPTION_RXGAIN, &record_gain, sizeof(record_gain), 0);
 			if (ast_test_flag(vmu, VM_OPERATOR))
 				canceldtmf = "0";
-			cmd = ast_play_and_record_full(chan, playfile, tempfile, maxtime, fmt, duration, sound_duration, silencethreshold, maxsilence, unlockdir, acceptdtmf, canceldtmf);
+			cmd = ast_play_and_record_full(chan, playfile, tempfile, maxtime, fmt, duration, sound_duration, silencethreshold, maxsilence, unlockdir, acceptdtmf, canceldtmf, AST_RECORD_IF_EXISTS_OVERWRITE);
 			if (strchr(canceldtmf, cmd)) {
 			/* need this flag here to distinguish between pressing '0' during message recording or after */
 				canceleddtmf = 1;

Modified: team/dlee/record/include/asterisk/app.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/record/include/asterisk/app.h?view=diff&rev=392753&r1=392752&r2=392753
==============================================================================
--- team/dlee/record/include/asterisk/app.h (original)
+++ team/dlee/record/include/asterisk/app.h Mon Jun 24 14:53:49 2013
@@ -686,8 +686,31 @@
 	long *offsetms,
 	ast_waitstream_fr_cb cb);
 
+/*!
+ * \brief Plays a sound to the channel, in the channel's default language.
+ *
+ * This will stop any existing streams on the channel.
+
+ * \param chan channel to stream the file to
+ * \param filename the name of the file you wish to stream, minus the extension
+ * \retval 0 on success.
+ * \retval -1 on failure.
+ * \since 12
+ */
+int ast_play_media(struct ast_channel *chan, const char *filename);
+
 /*! \brief Play a stream and wait for a digit, returning the digit that was pressed */
 int ast_play_and_wait(struct ast_channel *chan, const char *fn);
+
+/*! Possible actions to take if a recording already exists */
+enum ast_record_if_exists {
+	/*! Fail the recording. */
+	AST_RECORD_IF_EXISTS_FAIL,
+	/*! Overwrite the existing recording. */
+	AST_RECORD_IF_EXISTS_OVERWRITE,
+	/*! Append to the existing recording. */
+	AST_RECORD_IF_EXISTS_APPEND,
+};
 
 /*!
  * \brief Record a file based on input from a channel
@@ -705,13 +728,14 @@
  * \param path Optional filesystem path to unlock
  * \param acceptdtmf Character of DTMF to end and accept the recording
  * \param canceldtmf Character of DTMF to end and cancel the recording
+ * \param ast_record_if_exists Action to take if recording already exists.
  *
  * \retval -1 failure or hangup
  * \retval 'S' Recording ended from silence timeout
  * \retval 't' Recording ended from the message exceeding the maximum duration
  * \retval dtmfchar Recording ended via the return value's DTMF character for either cancel or accept.
  */
-int ast_play_and_record_full(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime_sec, const char *fmt, int *duration, int *sound_duration, int silencethreshold, int maxsilence_ms, const char *path, const char *acceptdtmf, const char *canceldtmf);
+int ast_play_and_record_full(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime_sec, const char *fmt, int *duration, int *sound_duration, int silencethreshold, int maxsilence_ms, const char *path, const char *acceptdtmf, const char *canceldtmf, enum ast_record_if_exists if_exists);
 
 /*!
  * \brief Record a file based on input from a channel. Use default accept and cancel DTMF.

Modified: team/dlee/record/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/record/include/asterisk/channel.h?view=diff&rev=392753&r1=392752&r2=392753
==============================================================================
--- team/dlee/record/include/asterisk/channel.h (original)
+++ team/dlee/record/include/asterisk/channel.h Mon Jun 24 14:53:49 2013
@@ -1844,7 +1844,7 @@
  *
  * \code
  * RAII_VAR(struct ast_format_janitor *, janitor,
- * 	ast_format_janitor_create(chan), ast_format_janitor_dtor);
+ *	ast_format_janitor_create(chan), ast_format_janitor_dtor);
  * \endocde
  *
  * \param chan Channel to reset at destruction.

Modified: team/dlee/record/include/asterisk/file.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/record/include/asterisk/file.h?view=diff&rev=392753&r1=392752&r2=392753
==============================================================================
--- team/dlee/record/include/asterisk/file.h (original)
+++ team/dlee/record/include/asterisk/file.h Mon Jun 24 14:53:49 2013
@@ -63,18 +63,6 @@
  * a file.
  */
 typedef void (ast_waitstream_fr_cb)(struct ast_channel *chan, long ms, enum ast_waitstream_fr_cb_values val);
-
-/*!
- * \brief Plays a sound to the channel, in the channel's default language.
- *
- * This will stop any existing streams on the channel.
-
- * \param chan channel to stream the file to
- * \param filename the name of the file you wish to stream, minus the extension
- * \retval 0 on success.
- * \retval -1 on failure.
- */
-int ast_play_sound(struct ast_channel *chan, const char *filename);
 
 /*!
  * \brief Streams a file

Modified: team/dlee/record/include/asterisk/stasis_app_recording.h
URL: http://svnview.digium.com/svn/asterisk/team/dlee/record/include/asterisk/stasis_app_recording.h?view=diff&rev=392753&r1=392752&r2=392753
==============================================================================
--- team/dlee/record/include/asterisk/stasis_app_recording.h (original)
+++ team/dlee/record/include/asterisk/stasis_app_recording.h Mon Jun 24 14:53:49 2013
@@ -28,6 +28,7 @@
  * \since 12
  */
 
+#include "asterisk/app.h"
 #include "asterisk/stasis_app.h"
 
 /*! Opaque struct for handling the recording of media to a file. */
@@ -51,16 +52,6 @@
 enum stasis_app_recording_media_operation {
 	/*! Stop the recording operation. */
 	STASIS_APP_RECORDING_STOP,
-};
-
-/*! Possible actions to take if a recording already exists */
-enum stasis_app_recording_if_exists {
-	/*! Fail the recording. */
-	STASIS_APP_RECORDING_IF_EXISTS_FAIL,
-	/*! Overwrite the existing recording. */
-	STASIS_APP_RECORDING_IF_EXISTS_OVERWRITE,
-	/*! Append to the existing recording. */
-	STASIS_APP_RECORDING_IF_EXISTS_APPEND,
 };
 
 #define STASIS_APP_RECORDING_TERMINATE_INVALID 0
@@ -82,7 +73,7 @@
 	 */
 	char terminate_on;
 	/*! How to handle recording when a file already exists */
-	enum stasis_app_recording_if_exists if_exists;
+	enum ast_record_if_exists if_exists;
 	/*! If true, a beep is played at the start of recording */
 	int beep:1;
 };
@@ -118,7 +109,7 @@
  * \return How to handle an existing file.
  * \return -1 on error.
  */
-enum stasis_app_recording_if_exists stasis_app_recording_if_exists_parse(
+enum ast_record_if_exists stasis_app_recording_if_exists_parse(
 	const char *str);
 
 /*!

Modified: team/dlee/record/main/app.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/record/main/app.c?view=diff&rev=392753&r1=392752&r2=392753
==============================================================================
--- team/dlee/record/main/app.c (original)
+++ team/dlee/record/main/app.c Mon Jun 24 14:53:49 2013
@@ -343,6 +343,17 @@
 
 	res = ast_app_exec_macro(autoservice_chan, macro_chan, args_str);
 	ast_free(args_str);
+	return res;
+}
+
+int ast_play_media(struct ast_channel *chan, const char *filename)
+{
+	int res;
+	res = ast_streamfile(chan, filename, ast_channel_language(chan));
+	if (res == 0) {
+		res = ast_waitstream(chan, "");
+	}
+	ast_stopstream(chan);
 	return res;
 }
 
@@ -1169,7 +1180,7 @@
  * \retval 't' Recording ended from the message exceeding the maximum duration, or via DTMF in prepend mode
  * \retval dtmfchar Recording ended via the return value's DTMF character for either cancel or accept.
  */
-static int __ast_play_and_record(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, int *sound_duration, int beep, int silencethreshold, int maxsilence, const char *path, int prepend, const char *acceptdtmf, const char *canceldtmf, int skip_confirmation_sound)
+static int __ast_play_and_record(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, int *sound_duration, int beep, int silencethreshold, int maxsilence, const char *path, int prepend, const char *acceptdtmf, const char *canceldtmf, int skip_confirmation_sound, enum ast_record_if_exists if_exists)
 {
 	int d = 0;
 	char *fmts;
@@ -1186,6 +1197,21 @@
 	struct ast_format rfmt;
 	struct ast_silence_generator *silgen = NULL;
 	char prependfile[PATH_MAX];
+	int ioflags;	/* IO flags for writing output file */
+
+	ioflags = O_CREAT|O_WRONLY;
+
+	switch (if_exists) {
+	case AST_RECORD_IF_EXISTS_FAIL:
+		ioflags |= O_EXCL;
+		break;
+	case AST_RECORD_IF_EXISTS_OVERWRITE:
+		ioflags |= O_TRUNC;
+		break;
+	case AST_RECORD_IF_EXISTS_APPEND:
+		ioflags |= O_APPEND;
+		break;
+	}
 
 	ast_format_clear(&rfmt);
 	if (silencethreshold < 0) {
@@ -1239,7 +1265,7 @@
 
 	end = start = time(NULL);  /* pre-initialize end to be same as start in case we never get into loop */
 	for (x = 0; x < fmtcnt; x++) {
-		others[x] = ast_writefile(prepend ? prependfile : recordfile, sfmt[x], comment, O_TRUNC, 0, AST_FILE_MODE);
+		others[x] = ast_writefile(prepend ? prependfile : recordfile, sfmt[x], comment, ioflags, 0, AST_FILE_MODE);
 		ast_verb(3, "x=%d, open writing:  %s format: %s, %p\n", x, prepend ? prependfile : recordfile, sfmt[x], others[x]);
 
 		if (!others[x]) {
@@ -1477,19 +1503,19 @@
 static const char default_acceptdtmf[] = "#";
 static const char default_canceldtmf[] = "";
 
-int ast_play_and_record_full(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, int *sound_duration, int silencethreshold, int maxsilence, const char *path, const char *acceptdtmf, const char *canceldtmf)
-{
-	return __ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, sound_duration, 0, silencethreshold, maxsilence, path, 0, S_OR(acceptdtmf, default_acceptdtmf), S_OR(canceldtmf, default_canceldtmf), 0);
+int ast_play_and_record_full(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, int *sound_duration, int silencethreshold, int maxsilence, const char *path, const char *acceptdtmf, const char *canceldtmf, enum ast_record_if_exists if_exists)
+{
+	return __ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, sound_duration, 0, silencethreshold, maxsilence, path, 0, S_OR(acceptdtmf, default_acceptdtmf), S_OR(canceldtmf, default_canceldtmf), 0, if_exists);
 }
 
 int ast_play_and_record(struct ast_channel *chan, const char *playfile, const char *recordfile, int maxtime, const char *fmt, int *duration, int *sound_duration, int silencethreshold, int maxsilence, const char *path)
 {
-	return __ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, sound_duration, 0, silencethreshold, maxsilence, path, 0, default_acceptdtmf, default_canceldtmf, 0);
+	return __ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, sound_duration, 0, silencethreshold, maxsilence, path, 0, default_acceptdtmf, default_canceldtmf, 0, AST_RECORD_IF_EXISTS_OVERWRITE);
 }
 
 int ast_play_and_prepend(struct ast_channel *chan, char *playfile, char *recordfile, int maxtime, char *fmt, int *duration, int *sound_duration, int beep, int silencethreshold, int maxsilence)
 {
-	return __ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, sound_duration, beep, silencethreshold, maxsilence, NULL, 1, default_acceptdtmf, default_canceldtmf, 1);
+	return __ast_play_and_record(chan, playfile, recordfile, maxtime, fmt, duration, sound_duration, beep, silencethreshold, maxsilence, NULL, 1, default_acceptdtmf, default_canceldtmf, 1, AST_RECORD_IF_EXISTS_OVERWRITE);
 }
 
 /* Channel group core functions */

Modified: team/dlee/record/main/file.c
URL: http://svnview.digium.com/svn/asterisk/team/dlee/record/main/file.c?view=diff&rev=392753&r1=392752&r2=392753
==============================================================================
--- team/dlee/record/main/file.c (original)
+++ team/dlee/record/main/file.c Mon Jun 24 14:53:49 2013
@@ -1004,17 +1004,6 @@
 int ast_filecopy(const char *filename, const char *filename2, const char *fmt)
 {
 	return filehelper(filename, filename2, fmt, ACTION_COPY);
-}
-
-int ast_play_sound(struct ast_channel *chan, const char *filename)
-{
-	int res;
-	res = ast_streamfile(chan, "beep", ast_channel_language(chan));
-	if (res == 0) {
-		res = ast_waitstream(chan, "");
-	}
-	ast_stopstream(chan);
-	return res;
 }
 
 int ast_streamfile(struct ast_channel *chan, const char *filename, const char *preflang)

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=392753&r1=392752&r2=392753
==============================================================================
--- team/dlee/record/res/res_stasis_recording.c (original)
+++ team/dlee/record/res/res_stasis_recording.c Mon Jun 24 14:53:49 2013
@@ -154,24 +154,24 @@
 	return STASIS_APP_RECORDING_TERMINATE_INVALID;
 }
 
-enum stasis_app_recording_if_exists stasis_app_recording_if_exists_parse(
+enum ast_record_if_exists stasis_app_recording_if_exists_parse(
 	const char *str)
 {
 	if (ast_strlen_zero(str)) {
 		/* Default value */
-		return STASIS_APP_RECORDING_IF_EXISTS_FAIL;
+		return AST_RECORD_IF_EXISTS_FAIL;
 	}
 
 	if (strcasecmp(str, "fail") == 0) {
-		return STASIS_APP_RECORDING_IF_EXISTS_FAIL;
+		return AST_RECORD_IF_EXISTS_FAIL;
 	}
 
 	if (strcasecmp(str, "overwrite") == 0) {
-		return STASIS_APP_RECORDING_IF_EXISTS_OVERWRITE;
+		return AST_RECORD_IF_EXISTS_OVERWRITE;
 	}
 
 	if (strcasecmp(str, "append") == 0) {
-		return STASIS_APP_RECORDING_IF_EXISTS_APPEND;
+		return AST_RECORD_IF_EXISTS_APPEND;
 	}
 
 	return -1;
@@ -207,26 +207,6 @@
 	recording_publish(recording);
 }
 
-static int recording_should_terminate(struct stasis_app_recording *recording,
-	char dtmf)
-{
-	int res = 0;
-	switch (recording->options->terminate_on) {
-	case STASIS_APP_RECORDING_TERMINATE_NONE:
-		break;
-	case STASIS_APP_RECORDING_TERMINATE_ANY:
-		res = 1;
-		break;
-	default:
-		if (dtmf == recording->options->terminate_on) {
-			res = 1;
-		}
-		break;
-	}
-
-	return res;
-}
-
 static void recording_cleanup(struct stasis_app_recording *recording)
 {
 	ao2_unlink_flags(recordings, recording,
@@ -238,19 +218,8 @@
 {
 	RAII_VAR(struct stasis_app_recording *, recording,
 		NULL, recording_cleanup);
-	RAII_VAR(struct ast_filestream *, s, NULL, ast_closestream);
-	RAII_VAR(struct ast_format_janitor *, janitor,
-		NULL, ast_format_janitor_dtor);
-	RAII_VAR(struct ast_dsp *, sildet, NULL, ast_dsp_free);
-
-	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 */
-	int res;	/* Result variable */
-	int total_silence_ms = 0;	/* Total silence currently recorded */
-	long max_silence_ms = 0;	/* Max silence for termination */
-	long maxms;	/* Max milliseconds to record */
-	struct timeval start;	/* Start of recording */
+	char *acceptdtmf;
+	int res;
 
 	recording = data;
 	ast_assert(recording != NULL);
@@ -260,59 +229,18 @@
 	recording_publish(recording);
 	ao2_unlock(recording);
 
-	ioflags = O_CREAT|O_WRONLY;
-
-	switch (recording->options->if_exists) {
-	case STASIS_APP_RECORDING_IF_EXISTS_FAIL:
-		ioflags |= O_EXCL;
+	switch (recording->options->terminate_on) {
+	case STASIS_APP_RECORDING_TERMINATE_NONE:
+	case STASIS_APP_RECORDING_TERMINATE_INVALID:
+		acceptdtmf = "";
 		break;
-	case STASIS_APP_RECORDING_IF_EXISTS_OVERWRITE:
-		ioflags |= O_TRUNC;
+	case STASIS_APP_RECORDING_TERMINATE_ANY:
+		acceptdtmf = "#*0123456789abcd";
 		break;
-	case STASIS_APP_RECORDING_IF_EXISTS_APPEND:
-		ioflags |= O_APPEND;
-		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);
-		if (janitor == NULL) {
-			recording_fail(recording);
-			return NULL;
-		}
-
-		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;
-		}
-		ast_dsp_set_threshold(sildet,
-			ast_dsp_get_threshold_from_settings(THRESHOLD_SILENCE));
-	}
-
-	s = ast_writefile(recording->absolute_name, recording->options->format,
-		RECORDING_COMMENT, ioflags, RECORDING_CHECK, AST_FILE_MODE);
-	if (s == NULL) {
-		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;
+	default:
+		acceptdtmf = ast_alloca(2);
+		acceptdtmf[0] = recording->options->terminate_on;
+		acceptdtmf[1] = '\0';
 	}
 
 	res = ast_auto_answer(chan);
@@ -323,90 +251,19 @@
 		return NULL;
 	}
 
-	if (recording->options->beep) {
-		res = ast_play_sound(chan, "beep");
-	}
-	if (res != 0) {
-		ast_debug(3, "%s: Failed to play beep\n",
-			ast_channel_uniqueid(chan));
-		recording_fail(recording);
-		return NULL;
-	}
-
-	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);
-
-		ms = ast_waitfor(chan, ms);
-		if (ms < 0) {
-			ast_debug(3, "%s: Error waiting for channel\n",
-				ast_channel_uniqueid(chan));
-			break;
-		}
-
-		if (maxms > 0 && ms == 0) {
-			ast_debug(3, "%s: Recording timed out\n",
-				ast_channel_uniqueid(chan));
-			break;
-		}
-
-		f = ast_read(chan);
-		if (!f) {
-			ast_debug(3, "%s: Error reading frame\n",
-				ast_channel_uniqueid(chan));
-			break;
-		}
-
-		switch (f->frametype) {
-		case AST_FRAME_VOICE:
-			res = ast_writestream(s, f);
-
-			if (res == 0 && sildet) {
-				ast_dsp_silence(sildet, f, &total_silence_ms);
-			}
-			break;
-		case AST_FRAME_VIDEO:
-			res = ast_writestream(s, f);
-			break;
-		case AST_FRAME_DTMF:
-			dtmf_term = recording_should_terminate(recording,
-				f->subclass.integer);
-			break;
-		default:
-			/* Drop the frame */
-			break;
-		}
-
-		if (dtmf_term) {
-			ast_debug(3,
-				"%s: DTMF detected. Terminating recording\n",
-				ast_channel_uniqueid(chan));
-			break;
-		}
-
-		if (total_silence_ms > max_silence_ms) {
-			/* Strip off the detected silence. Leave a second of it,
-			 * for a smooth transition at the end. */
-			ast_stream_rewind(s, total_silence_ms - 1000);
-			ast_truncstream(s);
-			ast_debug(3,
-				"%s: Silence detected. Terminating recording\n",
-				ast_channel_uniqueid(chan));
-			break;
-		}
-
-		if (res != 0) {
-			ast_debug(3, "%s: Error writing recording\n",
-				ast_channel_uniqueid(chan));
-			break;
-		}
-	}
-
+	ast_play_and_record_full(chan,
+		recording->options->beep ? "beep" : NULL,
+		recording->absolute_name,
+		recording->options->max_duration_seconds,
+		recording->options->format,
+		NULL, /* duration */
+		NULL, /* sound_duration */
+		-1, /* silencethreshold */
+		recording->options->max_silence_seconds * 1000,
+		NULL, /* path */
+		acceptdtmf,
+		NULL, /* canceldtmf */
+		recording->options->if_exists);
 
 	ast_debug(3, "%s: Recording complete\n", ast_channel_uniqueid(chan));
 




More information about the svn-commits mailing list