[svn-commits] file: branch group/media_formats r407409 - /team/group/media_formats/apps/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Wed Feb 5 09:59:35 CST 2014


Author: file
Date: Wed Feb  5 09:59:29 2014
New Revision: 407409

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=407409
Log:
Move some more applications over.

Modified:
    team/group/media_formats/apps/app_dictate.c
    team/group/media_formats/apps/app_dumpchan.c
    team/group/media_formats/apps/app_festival.c
    team/group/media_formats/apps/app_ices.c
    team/group/media_formats/apps/app_milliwatt.c

Modified: team/group/media_formats/apps/app_dictate.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/apps/app_dictate.c?view=diff&rev=407409&r1=407408&r2=407409
==============================================================================
--- team/group/media_formats/apps/app_dictate.c (original)
+++ team/group/media_formats/apps/app_dictate.c Wed Feb  5 09:59:29 2014
@@ -43,6 +43,7 @@
 #include "asterisk/module.h"
 #include "asterisk/say.h"
 #include "asterisk/app.h"
+#include "asterisk/format_cache.h"
 
 /*** DOCUMENTATION
 	<application name="Dictate" language="en_US">
@@ -108,8 +109,7 @@
 		len = 0,
 		maxlen = 0,
 		mode = 0;
-	struct ast_format oldr;
-	ast_format_clear(&oldr);
+	struct ast_format *oldr;
 
 	snprintf(dftbase, sizeof(dftbase), "%s/dictate", ast_config_AST_SPOOL_DIR);
 	if (!ast_strlen_zero(data)) {
@@ -126,8 +126,8 @@
 	if (args.argc > 1 && args.filename) {
 		filename = args.filename;
 	}
-	ast_format_copy(&oldr, ast_channel_readformat(chan));
-	if ((res = ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR)) < 0) {
+	oldr = ast_format_copy(ast_channel_readformat(chan));
+	if ((res = ast_set_read_format(chan, ast_format_slin)) < 0) {
 		ast_log(LOG_WARNING, "Unable to set to linear mode.\n");
 		return -1;
 	}
@@ -335,8 +335,9 @@
 			ast_frfree(f);
 		}
 	}
-	if (oldr.id) {
-		ast_set_read_format(chan, &oldr);
+	if (oldr) {
+		ast_set_read_format(chan, oldr);
+		ao2_ref(oldr, -1);
 	}
 	return 0;
 }

Modified: team/group/media_formats/apps/app_dumpchan.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/apps/app_dumpchan.c?view=diff&rev=407409&r1=407408&r2=407409
==============================================================================
--- team/group/media_formats/apps/app_dumpchan.c (original)
+++ team/group/media_formats/apps/app_dumpchan.c Wed Feb  5 09:59:29 2014
@@ -144,10 +144,10 @@
 		ast_channel_state(c),
 		ast_channel_rings(c),
 		ast_getformatname_multiple(nf, sizeof(nf), ast_channel_nativeformats(c)),
-		ast_getformatname(ast_channel_writeformat(c)),
-		ast_getformatname(ast_channel_readformat(c)),
-		ast_getformatname(ast_channel_rawwriteformat(c)),
-		ast_getformatname(ast_channel_rawreadformat(c)),
+		ast_channel_writeformat(c)->codec->name,
+		ast_channel_readformat(c)->codec->name,
+		ast_channel_rawwriteformat(c)->codec->name,
+		ast_channel_rawreadformat(c)->codec->name,
 		ast_channel_writetrans(c) ? "Yes" : "No",
 		ast_translate_path_to_str(ast_channel_writetrans(c), &write_transpath),
 		ast_channel_readtrans(c) ? "Yes" : "No",

Modified: team/group/media_formats/apps/app_festival.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/apps/app_festival.c?view=diff&rev=407409&r1=407408&r2=407409
==============================================================================
--- team/group/media_formats/apps/app_festival.c (original)
+++ team/group/media_formats/apps/app_festival.c Wed Feb  5 09:59:29 2014
@@ -63,6 +63,7 @@
 #include "asterisk/lock.h"
 #include "asterisk/app.h"
 #include "asterisk/endian.h"
+#include "asterisk/format_cache.h"
 
 #define FESTIVAL_CONFIG "festival.conf"
 #define MAXLEN 180
@@ -177,7 +178,7 @@
 	int res = 0;
 	int fds[2];
 	int needed = 0;
-	struct ast_format owriteformat;
+	struct ast_format *owriteformat;
 	struct ast_frame *f;
 	struct myframe {
 		struct ast_frame f;
@@ -187,7 +188,6 @@
 		.f = { 0, },
 	};
 
-	ast_format_clear(&owriteformat);
 	if (pipe(fds)) {
 		ast_log(LOG_WARNING, "Unable to create pipe\n");
 		return -1;
@@ -199,12 +199,18 @@
 	ast_stopstream(chan);
 	ast_indicate(chan, -1);
 	
-	ast_format_copy(&owriteformat, ast_channel_writeformat(chan));
-	res = ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR);
+	owriteformat = ast_format_copy(ast_channel_writeformat(chan));
+	res = ast_set_write_format(chan, ast_format_slin);
 	if (res < 0) {
 		ast_log(LOG_WARNING, "Unable to set write format to signed linear\n");
 		return -1;
 	}
+
+	myf.f.frametype = AST_FRAME_VOICE;
+	myf.f.subclass.format = ast_format_copy(ast_format_slin);
+	myf.f.offset = AST_FRIENDLY_OFFSET;
+	myf.f.src = __PRETTY_FUNCTION__;
+	myf.f.data.ptr = myf.frdata;
 	
 	res = send_waveform_to_fd(waveform, length, fds[1]);
 	if (res >= 0) {
@@ -240,13 +246,8 @@
 				}
 				res = read(fds[0], myf.frdata, needed);
 				if (res > 0) {
-					myf.f.frametype = AST_FRAME_VOICE;
-					ast_format_set(&myf.f.subclass.format, AST_FORMAT_SLINEAR, 0);
 					myf.f.datalen = res;
 					myf.f.samples = res / 2;
-					myf.f.offset = AST_FRIENDLY_OFFSET;
-					myf.f.src = __PRETTY_FUNCTION__;
-					myf.f.data.ptr = myf.frdata;
 					if (ast_write(chan, &myf.f) < 0) {
 						res = -1;
 						ast_frfree(f);
@@ -269,8 +270,10 @@
 	close(fds[0]);
 	close(fds[1]);
 
-	if (!res && owriteformat.id)
-		ast_set_write_format(chan, &owriteformat);
+	if (!res && owriteformat)
+		ast_set_write_format(chan, owriteformat);
+	ao2_cleanup(owriteformat);
+
 	return res;
 }
 

Modified: team/group/media_formats/apps/app_ices.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/apps/app_ices.c?view=diff&rev=407409&r1=407408&r2=407409
==============================================================================
--- team/group/media_formats/apps/app_ices.c (original)
+++ team/group/media_formats/apps/app_ices.c Wed Feb  5 09:59:29 2014
@@ -48,6 +48,7 @@
 #include "asterisk/module.h"
 #include "asterisk/translate.h"
 #include "asterisk/app.h"
+#include "asterisk/format_cache.h"
 
 /*** DOCUMENTATION
 	<application name="ICES" language="en_US">
@@ -115,12 +116,11 @@
 	int ms = -1;
 	int pid = -1;
 	int flags;
-	struct ast_format oreadformat;
+	struct ast_format *oreadformat;
 	struct ast_frame *f;
 	char filename[256]="";
 	char *c;
 
-	ast_format_clear(&oreadformat);
 	if (ast_strlen_zero(data)) {
 		ast_log(LOG_WARNING, "ICES requires an argument (configfile.xml)\n");
 		return -1;
@@ -145,8 +145,8 @@
 		return -1;
 	}
 
-	ast_format_copy(&oreadformat, ast_channel_readformat(chan));
-	res = ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR);
+	oreadformat = ast_format_copy(ast_channel_readformat(chan));
+	res = ast_set_read_format(chan, ast_format_slin);
 	if (res < 0) {
 		close(fds[0]);
 		close(fds[1]);
@@ -197,8 +197,9 @@
 
 	if (pid > -1)
 		kill(pid, SIGKILL);
-	if (!res && oreadformat.id)
-		ast_set_read_format(chan, &oreadformat);
+	if (!res && oreadformat)
+		ast_set_read_format(chan, oreadformat);
+	ao2_cleanup(oreadformat);
 
 	return res;
 }

Modified: team/group/media_formats/apps/app_milliwatt.c
URL: http://svnview.digium.com/svn/asterisk/team/group/media_formats/apps/app_milliwatt.c?view=diff&rev=407409&r1=407408&r2=407409
==============================================================================
--- team/group/media_formats/apps/app_milliwatt.c (original)
+++ team/group/media_formats/apps/app_milliwatt.c Wed Feb  5 09:59:29 2014
@@ -37,6 +37,7 @@
 #include "asterisk/channel.h"
 #include "asterisk/pbx.h"
 #include "asterisk/indications.h"
+#include "asterisk/format_cache.h"
 
 /*** DOCUMENTATION
 	<application name="Milliwatt" language="en_US">
@@ -79,13 +80,14 @@
 {
 	unsigned char buf[AST_FRIENDLY_OFFSET + 640];
 	const int maxsamples = ARRAY_LEN(buf) - (AST_FRIENDLY_OFFSET / sizeof(buf[0]));
-	int i, *indexp = (int *) data;
+	int i, *indexp = (int *) data, res;
 	struct ast_frame wf = {
 		.frametype = AST_FRAME_VOICE,
 		.offset = AST_FRIENDLY_OFFSET,
 		.src = __FUNCTION__,
 	};
-	ast_format_set(&wf.subclass.format, AST_FORMAT_ULAW, 0);
+
+	wf.subclass.format = ast_format_copy(ast_format_ulaw);
 	wf.data.ptr = buf + AST_FRIENDLY_OFFSET;
 
 	/* Instead of len, use samples, because channel.c generator_force
@@ -108,7 +110,10 @@
 		*indexp &= 7;
 	}
 
-	if (ast_write(chan,&wf) < 0) {
+	res = ast_write(chan, &wf);
+	ast_frfree(&wf);
+
+	if (res < 0) {
 		ast_log(LOG_WARNING,"Failed to write frame to '%s': %s\n",ast_channel_name(chan),strerror(errno));
 		return -1;
 	}
@@ -124,8 +129,8 @@
 
 static int old_milliwatt_exec(struct ast_channel *chan)
 {
-	ast_set_write_format_by_id(chan, AST_FORMAT_ULAW);
-	ast_set_read_format_by_id(chan, AST_FORMAT_ULAW);
+	ast_set_write_format(chan, ast_format_ulaw);
+	ast_set_read_format(chan, ast_format_ulaw);
 
 	if (ast_channel_state(chan) != AST_STATE_UP) {
 		ast_answer(chan);




More information about the svn-commits mailing list