[Asterisk-code-review] app record: Add option to prevent silence from being truncated (asterisk[13])

Anonymous Coward asteriskteam at digium.com
Tue Feb 14 14:56:00 CST 2017


Anonymous Coward #1000019 has submitted this change and it was merged. ( https://gerrit.asterisk.org/4943 )

Change subject: app_record: Add option to prevent silence from being truncated
......................................................................


app_record: Add option to prevent silence from being truncated

When using Record() with the silence detection feature, the stream is
written out to the given file. However, if only 'silence' is detected,
this file is then truncated to the first second of the recording.

This patch adds the 'u' option to Record() to override that behavior.

ASTERISK-18286 #close
Reported by: var
Patches:
	app_record-1.8.7.1.diff (license #6184) patch uploaded by var

Change-Id: Ia1cd163483235efe2db05e52f39054288553b957
---
M CHANGES
M apps/app_record.c
2 files changed, 20 insertions(+), 2 deletions(-)

Approvals:
  Mark Michelson: Looks good to me, but someone else must approve
  Anonymous Coward #1000019: Verified
  Joshua Colp: Looks good to me, approved



diff --git a/CHANGES b/CHANGES
index dc5f058..d148f6b 100644
--- a/CHANGES
+++ b/CHANGES
@@ -9,6 +9,15 @@
 ==============================================================================
 
 ------------------------------------------------------------------------------
+--- Functionality changes from Asterisk 13.14.0 to Asterisk 13.15.0 ----------
+------------------------------------------------------------------------------
+
+app_record
+------------------
+ * Added new 'u' option to Record() application which prevents Asterisk from
+   truncating silence from the end of recorded files.
+
+------------------------------------------------------------------------------
 --- Functionality changes from Asterisk 13.13.0 to Asterisk 13.14.0 ----------
 ------------------------------------------------------------------------------
 
diff --git a/apps/app_record.c b/apps/app_record.c
index 31a54e6..56dc5f4 100644
--- a/apps/app_record.c
+++ b/apps/app_record.c
@@ -81,6 +81,9 @@
 					<option name="t">
 						<para>use alternate '*' terminator key (DTMF) instead of default '#'</para>
 					</option>
+					<option name="u">
+						<para>Don't truncate recorded silence.</para>
+					</option>
 					<option name="x">
 						<para>Ignore all terminator keys (DTMF) and keep recording until hangup.</para>
 					</option>
@@ -133,6 +136,7 @@
 	FLAG_HAS_PERCENT = (1 << 7),
 	OPTION_ANY_TERMINATE = (1 << 8),
 	OPTION_OPERATOR_EXIT = (1 << 9),
+	OPTION_NO_TRUNCATE = (1 << 10),
 };
 
 AST_APP_OPTIONS(app_opts,{
@@ -143,6 +147,7 @@
 	AST_APP_OPTION('q', OPTION_QUIET),
 	AST_APP_OPTION('s', OPTION_SKIP),
 	AST_APP_OPTION('t', OPTION_STAR_TERMINATE),
+	AST_APP_OPTION('u', OPTION_NO_TRUNCATE),
 	AST_APP_OPTION('y', OPTION_ANY_TERMINATE),
 	AST_APP_OPTION('x', OPTION_IGNORE_TERMINATE),
 });
@@ -194,6 +199,7 @@
 	int dspsilence = 0;
 	int silence = 0;		/* amount of silence to allow */
 	int gotsilence = 0;		/* did we timeout for silence? */
+	int truncate_silence = 1;	/* truncate on complete silence recording */
 	int maxduration = 0;		/* max duration of recording in milliseconds */
 	int gottimeout = 0;		/* did we timeout for maxduration exceeded? */
 	int terminator = '#';
@@ -245,7 +251,10 @@
 			ast_log(LOG_WARNING, "'%s' is not a valid silence duration\n", args.silence);
 		}
 	}
-	
+
+	if (ast_test_flag(&flags, OPTION_NO_TRUNCATE))
+		truncate_silence = 0;
+
 	if (args.maxduration) {
 		if ((sscanf(args.maxduration, "%30d", &i) == 1) && (i > -1))
 			/* Convert duration to milliseconds */
@@ -445,7 +454,7 @@
 		}
 	}
 
-	if (gotsilence) {
+	if (gotsilence && truncate_silence) {
 		ast_stream_rewind(s, silence - 1000);
 		ast_truncstream(s);
 	} else if (!gottimeout && f) {

-- 
To view, visit https://gerrit.asterisk.org/4943
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: Ia1cd163483235efe2db05e52f39054288553b957
Gerrit-PatchSet: 1
Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Owner: Sean Bright <sean.bright at gmail.com>
Gerrit-Reviewer: Anonymous Coward #1000019
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Mark Michelson <mmichelson at digium.com>



More information about the asterisk-code-review mailing list