[svn-commits] sgriepentrog: trunk r423193 - in /trunk: ./ apps/ include/asterisk/ main/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Tue Sep 16 11:33:56 CDT 2014


Author: sgriepentrog
Date: Tue Sep 16 11:33:53 2014
New Revision: 423193

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=423193
Log:
Voicemail: get correct duration when copying file to vm

Changes made during format improvements resulted in the
recording to voicemail option 'm' of the MixMonitor app
writing a zero length duration in the msgXXXX.txt file.

This change introduces a new function ast_ratestream(),
which provides the sample rate of the format associated
with the stream, and updates the app_voicemail function
for ast_app_copy_recording_to_vm to calculate the right
duration.

Review: https://reviewboard.asterisk.org/r/3996/
ASTERISK-24328 #close
........

Merged revisions 423192 from http://svn.asterisk.org/svn/asterisk/branches/13

Modified:
    trunk/   (props changed)
    trunk/apps/app_voicemail.c
    trunk/include/asterisk/file.h
    trunk/main/file.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-13-merged' - no diff available.

Modified: trunk/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_voicemail.c?view=diff&rev=423193&r1=423192&r2=423193
==============================================================================
--- trunk/apps/app_voicemail.c (original)
+++ trunk/apps/app_voicemail.c Tue Sep 16 11:33:53 2014
@@ -6130,15 +6130,11 @@
 	if ((recording_fs = ast_readfile(recdata->recording_file, recdata->recording_ext, NULL, 0, 0, VOICEMAIL_DIR_MODE))) {
 		if (!ast_seekstream(recording_fs, 0, SEEK_END)) {
 			long framelength = ast_tellstream(recording_fs);
-			struct ast_format *result;
-			/* XXX This use of ast_getformatbyname seems incorrect here. The file extension does not necessarily correspond
-			 * to the name of the format. For instance, if "raw" were passed in, I don't think ast_getformatbyname would
-			 * find the slinear format
-			 */
-			result = ast_format_cache_get(recdata->recording_ext);
-			if (result) {
-				duration = (int) (framelength / ast_format_get_sample_rate(result));
-				ao2_ref(result, -1);
+			int sample_rate = ast_ratestream(recording_fs);
+			if (sample_rate) {
+				duration = (int) (framelength / sample_rate);
+			} else {
+				ast_log(LOG_ERROR,"Unable to determine sample rate of recording %s\n", recdata->recording_file);
 			}
 		}
 	}

Modified: trunk/include/asterisk/file.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/file.h?view=diff&rev=423193&r1=423192&r2=423193
==============================================================================
--- trunk/include/asterisk/file.h (original)
+++ trunk/include/asterisk/file.h Tue Sep 16 11:33:53 2014
@@ -350,6 +350,13 @@
  */
 off_t ast_tellstream(struct ast_filestream *fs);
 
+/*!
+ * \brief Return the sample rate of the stream's format
+ * \param fs fs to act on
+ * \return sample rate in Hz
+ */
+int ast_ratestream(struct ast_filestream *fs);
+
 /*! 
  * \brief Read a frame from a filestream 
  * \param s ast_filestream to act on

Modified: trunk/main/file.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/file.c?view=diff&rev=423193&r1=423192&r2=423193
==============================================================================
--- trunk/main/file.c (original)
+++ trunk/main/file.c Tue Sep 16 11:33:53 2014
@@ -1024,6 +1024,11 @@
 off_t ast_tellstream(struct ast_filestream *fs)
 {
 	return fs->fmt->tell(fs);
+}
+
+int ast_ratestream(struct ast_filestream *fs)
+{
+	return ast_format_get_sample_rate(fs->fmt->format);
 }
 
 int ast_stream_fastforward(struct ast_filestream *fs, off_t ms)




More information about the svn-commits mailing list