[asterisk-commits] dvossel: branch dvossel/fixtheworld_phase1_step3 r301881 - in /team/dvossel/f...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Jan 14 14:23:39 CST 2011


Author: dvossel
Date: Fri Jan 14 14:23:33 2011
New Revision: 301881

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=301881
Log:
all the changes required to convert the res/ directory

Modified:
    team/dvossel/fixtheworld_phase1_step3/include/asterisk/callerid.h
    team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_cap.h
    team/dvossel/fixtheworld_phase1_step3/include/asterisk/speech.h
    team/dvossel/fixtheworld_phase1_step3/main/format_cap.c
    team/dvossel/fixtheworld_phase1_step3/res/res_adsi.c
    team/dvossel/fixtheworld_phase1_step3/res/res_agi.c
    team/dvossel/fixtheworld_phase1_step3/res/res_calendar.c
    team/dvossel/fixtheworld_phase1_step3/res/res_clioriginate.c
    team/dvossel/fixtheworld_phase1_step3/res/res_fax.c
    team/dvossel/fixtheworld_phase1_step3/res/res_fax_spandsp.c
    team/dvossel/fixtheworld_phase1_step3/res/res_musiconhold.c
    team/dvossel/fixtheworld_phase1_step3/res/res_rtp_multicast.c
    team/dvossel/fixtheworld_phase1_step3/res/res_speech.c

Modified: team/dvossel/fixtheworld_phase1_step3/include/asterisk/callerid.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/include/asterisk/callerid.h?view=diff&rev=301881&r1=301880&r2=301881
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/include/asterisk/callerid.h (original)
+++ team/dvossel/fixtheworld_phase1_step3/include/asterisk/callerid.h Fri Jan 14 14:23:33 2011
@@ -45,7 +45,7 @@
 #ifndef _ASTERISK_CALLERID_H
 #define _ASTERISK_CALLERID_H
 
-#include "asterisk/frame_defs.h"
+#include "asterisk/format.h"
 
 #define MAX_CALLERID_SIZE 32000
 

Modified: team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_cap.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_cap.h?view=diff&rev=301881&r1=301880&r2=301881
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_cap.h (original)
+++ team/dvossel/fixtheworld_phase1_step3/include/asterisk/format_cap.h Fri Jan 14 14:23:33 2011
@@ -151,7 +151,7 @@
  * \retval !NULL success
  * \retval NULL failure
  */
-struct ast_cap *ast_cap_joint(struct ast_cap *cap1, struct ast_cap *cap2);
+struct ast_cap *ast_cap_joint(const struct ast_cap *cap1, const struct ast_cap *cap2);
 
 /*!
  * \brief Get joint capability structure, copy into result capabilities structure

Modified: team/dvossel/fixtheworld_phase1_step3/include/asterisk/speech.h
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/include/asterisk/speech.h?view=diff&rev=301881&r1=301880&r2=301881
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/include/asterisk/speech.h (original)
+++ team/dvossel/fixtheworld_phase1_step3/include/asterisk/speech.h Fri Jan 14 14:23:33 2011
@@ -131,7 +131,7 @@
 /*! \brief Indicate to the speech engine that audio is now going to start being written */
 void ast_speech_start(struct ast_speech *speech);
 /*! \brief Create a new speech structure */
-struct ast_speech *ast_speech_new(const char *engine_name, struct ast_cap *formats);
+struct ast_speech *ast_speech_new(const char *engine_name, const struct ast_cap *formats);
 /*! \brief Destroy a speech structure */
 int ast_speech_destroy(struct ast_speech *speech);
 /*! \brief Write audio to the speech engine */

Modified: team/dvossel/fixtheworld_phase1_step3/main/format_cap.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/main/format_cap.c?view=diff&rev=301881&r1=301880&r2=301881
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/main/format_cap.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/main/format_cap.c Fri Jan 14 14:23:33 2011
@@ -352,12 +352,13 @@
 	return 1;
 }
 
-struct ast_cap *ast_cap_joint(struct ast_cap *cap1, struct ast_cap *cap2)
+struct ast_cap *ast_cap_joint(const struct ast_cap *cap1, const struct ast_cap *cap2)
 {
 	struct ao2_iterator it;
 	struct ast_cap *result = ast_cap_alloc();
 	struct ast_format *tmp;
 	struct find_joint_data data;
+
 	if (!result) {
 		return NULL;
 	}

Modified: team/dvossel/fixtheworld_phase1_step3/res/res_adsi.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/res/res_adsi.c?view=diff&rev=301881&r1=301880&r2=301881
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/res/res_adsi.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/res/res_adsi.c Fri Jan 14 14:23:33 2011
@@ -69,7 +69,7 @@
 
 static int alignment = 0;
 
-static int adsi_generate(unsigned char *buf, int msgtype, unsigned char *msg, int msglen, int msgnum, int last, format_t codec)
+static int adsi_generate(unsigned char *buf, int msgtype, unsigned char *msg, int msglen, int msgnum, int last, struct ast_format *codec)
 {
 	int sum, x, bytes = 0;
 	/* Initial carrier (imaginary) */
@@ -139,7 +139,7 @@
 			*remain = *remain - amt;
 		}
 		outf.frametype = AST_FRAME_VOICE;
-		outf.subclass.codec = AST_FORMAT_ULAW;
+		ast_format_set(&outf.subclass.format, AST_FORMAT_ULAW, 0);
 		outf.data.ptr = buf;
 		outf.datalen = amt;
 		outf.samples = amt;
@@ -170,7 +170,7 @@
 			continue;
 		}
 
-		if (inf->subclass.codec != AST_FORMAT_ULAW) {
+		if (inf->subclass.format.id != AST_FORMAT_ULAW) {
 			ast_log(LOG_WARNING, "Channel not in ulaw?\n");
 			ast_frfree(inf);
 			return -1;
@@ -182,7 +182,7 @@
 			*remain = inf->datalen - amt;
 		}
 		outf.frametype = AST_FRAME_VOICE;
-		outf.subclass.codec = AST_FORMAT_ULAW;
+		ast_format_set(&outf.subclass.format, AST_FORMAT_ULAW, 0);
 		outf.data.ptr = buf;
 		outf.datalen = amt;
 		outf.samples = amt;
@@ -214,9 +214,11 @@
 	}
 
 	while (retries < maxretries) {
+		struct ast_format tmpfmt;
 		if (!(chan->adsicpe & ADSI_FLAG_DATAMODE)) {
 			/* Generate CAS (no SAS) */
-			ast_gen_cas(buf, 0, 680, AST_FORMAT_ULAW);
+			ast_format_set(&tmpfmt, AST_FORMAT_ULAW, 0);
+			ast_gen_cas(buf, 0, 680, &tmpfmt);
 
 			/* Send CAS */
 			if (adsi_careful_send(chan, buf, 680, NULL)) {
@@ -275,7 +277,7 @@
 		def= ast_channel_defer_dtmf(chan);
 #endif
 		while ((x < 6) && msg[x]) {
-			if ((res = adsi_generate(buf + pos, msgtype[x], msg[x], msglen[x], x+1 - start, (x == 5) || !msg[x+1], AST_FORMAT_ULAW)) < 0) {
+			if ((res = adsi_generate(buf + pos, msgtype[x], msg[x], msglen[x], x+1 - start, (x == 5) || !msg[x+1], ast_format_set(&tmpfmt, AST_FORMAT_ULAW,0))) < 0) {
 				ast_log(LOG_WARNING, "Failed to generate ADSI message %d on channel %s\n", x + 1, chan->name);
 				return -1;
 			}
@@ -361,7 +363,12 @@
 int AST_OPTIONAL_API_NAME(ast_adsi_transmit_message_full)(struct ast_channel *chan, unsigned char *msg, int msglen, int msgtype, int dowait)
 {
 	unsigned char *msgs[5] = { NULL, NULL, NULL, NULL, NULL };
-	int msglens[5], msgtypes[5], newdatamode = (chan->adsicpe & ADSI_FLAG_DATAMODE), res, x, writeformat = chan->writeformat, readformat = chan->readformat, waitforswitch = 0;
+	int msglens[5], msgtypes[5], newdatamode = (chan->adsicpe & ADSI_FLAG_DATAMODE), res, x, waitforswitch = 0;
+	struct ast_format writeformat;
+	struct ast_format readformat;
+
+	ast_format_copy(&writeformat, &chan->writeformat);
+	ast_format_copy(&readformat, &chan->readformat);
 
 	for (x = 0; x < msglen; x += (msg[x+1]+2)) {
 		if (msg[x] == ADSI_SWITCH_TO_DATA) {
@@ -388,16 +395,16 @@
 
 	ast_stopstream(chan);
 
-	if (ast_set_write_format(chan, AST_FORMAT_ULAW)) {
+	if (ast_set_write_format_by_id(chan, AST_FORMAT_ULAW)) {
 		ast_log(LOG_WARNING, "Unable to set write format to ULAW\n");
 		return -1;
 	}
 
-	if (ast_set_read_format(chan, AST_FORMAT_ULAW)) {
+	if (ast_set_read_format_by_id(chan, AST_FORMAT_ULAW)) {
 		ast_log(LOG_WARNING, "Unable to set read format to ULAW\n");
-		if (writeformat) {
-			if (ast_set_write_format(chan, writeformat)) {
-				ast_log(LOG_WARNING, "Unable to restore write format to %d\n", writeformat);
+		if (writeformat.id) {
+			if (ast_set_write_format(chan, &writeformat)) {
+				ast_log(LOG_WARNING, "Unable to restore write format to %s\n", ast_getformatname(&writeformat));
 			}
 		}
 		return -1;
@@ -416,11 +423,11 @@
 		chan->adsicpe = (chan->adsicpe & ~ADSI_FLAG_DATAMODE) | newdatamode;
 	}
 
-	if (writeformat) {
-		ast_set_write_format(chan, writeformat);
-	}
-	if (readformat) {
-		ast_set_read_format(chan, readformat);
+	if (writeformat.id) {
+		ast_set_write_format(chan, &writeformat);
+	}
+	if (readformat.id) {
+		ast_set_read_format(chan, &readformat);
 	}
 
 	if (!res) {

Modified: team/dvossel/fixtheworld_phase1_step3/res/res_agi.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/res/res_agi.c?view=diff&rev=301881&r1=301880&r2=301881
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/res/res_agi.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/res/res_agi.c Fri Jan 14 14:23:33 2011
@@ -2146,7 +2146,8 @@
 	int silence = 0;                /* amount of silence to allow */
 	int gotsilence = 0;             /* did we timeout for silence? */
 	char *silencestr = NULL;
-	int rfmt = 0;
+	struct ast_format rfmt;
+	ast_format_clear(&rfmt);
 
 	/* XXX EAGI FIXME XXX */
 
@@ -2176,8 +2177,8 @@
 	}
 
 	if (silence > 0) {
-		rfmt = chan->readformat;
-		res = ast_set_read_format(chan, AST_FORMAT_SLINEAR);
+		ast_format_copy(&rfmt, &chan->readformat);
+		res = ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR);
 		if (res < 0) {
 			ast_log(LOG_WARNING, "Unable to set to linear mode, giving up\n");
 			return -1;
@@ -2299,7 +2300,7 @@
 	}
 
 	if (silence > 0) {
-		res = ast_set_read_format(chan, rfmt);
+		res = ast_set_read_format(chan, &rfmt);
 		if (res)
 			ast_log(LOG_WARNING, "Unable to restore read format on '%s'\n", chan->name);
 		ast_dsp_free(sildet);
@@ -2650,16 +2651,25 @@
 
 static int handle_speechcreate(struct ast_channel *chan, AGI *agi, int argc, const char * const argv[])
 {
+	struct ast_cap *cap;
+	struct ast_format tmpfmt;
+
 	/* If a structure already exists, return an error */
-        if (agi->speech) {
+	if (agi->speech) {
 		ast_agi_send(agi->fd, chan, "200 result=0\n");
 		return RESULT_SUCCESS;
 	}
 
-	if ((agi->speech = ast_speech_new(argv[2], AST_FORMAT_SLINEAR)))
+	if (!(cap = ast_cap_alloc())) {
+		return RESULT_FAILURE;
+	}
+	ast_cap_add(cap, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));
+	if ((agi->speech = ast_speech_new(argv[2], cap))) {
 		ast_agi_send(agi->fd, chan, "200 result=1\n");
-	else
+	} else {
 		ast_agi_send(agi->fd, chan, "200 result=0\n");
+	}
+	cap = ast_cap_destroy(cap);
 
 	return RESULT_SUCCESS;
 }
@@ -2791,7 +2801,8 @@
 	struct ast_speech *speech = agi->speech;
 	const char *prompt;
 	char dtmf = 0, tmp[4096] = "", *buf = tmp;
-	int timeout = 0, offset = 0, old_read_format = 0, res = 0, i = 0;
+	int timeout = 0, offset = 0, res = 0, i = 0;
+	struct ast_format old_read_format;
 	long current_offset = 0;
 	const char *reason = NULL;
 	struct ast_frame *fr = NULL;
@@ -2815,8 +2826,8 @@
 		offset = atoi(argv[4]);
 
 	/* We want frames coming in signed linear */
-	old_read_format = chan->readformat;
-	if (ast_set_read_format(chan, AST_FORMAT_SLINEAR)) {
+	ast_format_copy(&old_read_format, &chan->readformat);
+	if (ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR)) {
 		ast_agi_send(agi->fd, chan, "200 result=0\n");
 		return RESULT_SUCCESS;
 	}
@@ -3759,21 +3770,22 @@
 
 static int eagi_exec(struct ast_channel *chan, const char *data)
 {
-	int readformat, res;
+	int res;
+	struct ast_format readformat;
 
 	if (ast_check_hangup(chan)) {
 		ast_log(LOG_ERROR, "EAGI cannot be run on a dead/hungup channel, please use AGI.\n");
 		return 0;
 	}
-	readformat = chan->readformat;
-	if (ast_set_read_format(chan, AST_FORMAT_SLINEAR)) {
+	ast_format_copy(&readformat, &chan->readformat);
+	if (ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR)) {
 		ast_log(LOG_WARNING, "Unable to set channel '%s' to linear mode\n", chan->name);
 		return -1;
 	}
 	res = agi_exec_full(chan, data, 1, 0);
 	if (!res) {
-		if (ast_set_read_format(chan, readformat)) {
-			ast_log(LOG_WARNING, "Unable to restore channel '%s' to format %s\n", chan->name, ast_getformatname(readformat));
+		if (ast_set_read_format(chan, &readformat)) {
+			ast_log(LOG_WARNING, "Unable to restore channel '%s' to format %s\n", chan->name, ast_getformatname(&readformat));
 		}
 	}
 	return res;

Modified: team/dvossel/fixtheworld_phase1_step3/res/res_calendar.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/res/res_calendar.c?view=diff&rev=301881&r1=301880&r2=301881
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/res/res_calendar.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/res/res_calendar.c Fri Jan 14 14:23:33 2011
@@ -672,8 +672,13 @@
 	}
 
 	chan->tech = &null_tech;
-	chan->nativeformats = chan->writeformat = chan->rawwriteformat =
-		chan->readformat = chan->rawreadformat = AST_FORMAT_SLINEAR;
+	ast_format_set(&chan->writeformat, AST_FORMAT_SLINEAR, 0);
+	ast_format_set(&chan->readformat, AST_FORMAT_SLINEAR, 0);
+	ast_format_set(&chan->rawwriteformat, AST_FORMAT_SLINEAR, 0);
+	ast_format_set(&chan->rawreadformat, AST_FORMAT_SLINEAR, 0);
+	/* clear native formats and set to slinear. write format is signlear so just use that to set it */
+	ast_cap_remove_all(chan->nativeformats);
+	ast_cap_add(chan->nativeformats, &chan->writeformat);
 
 	if (!(datastore = ast_datastore_alloc(&event_notification_datastore, NULL))) {
 		ast_log(LOG_ERROR, "Could not allocate datastore, notification not being sent!\n");

Modified: team/dvossel/fixtheworld_phase1_step3/res/res_clioriginate.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/res/res_clioriginate.c?view=diff&rev=301881&r1=301880&r2=301881
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/res/res_clioriginate.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/res/res_clioriginate.c Fri Jan 14 14:23:33 2011
@@ -52,6 +52,8 @@
 	char *chantech;
 	char *chandata;
 	int reason = 0;
+	struct ast_cap *cap;
+	struct ast_format tmpfmt;
 
 	if (ast_strlen_zero(app))
 		return CLI_SHOWUSAGE;
@@ -64,7 +66,12 @@
 		return CLI_SHOWUSAGE;
 	}
 
-	ast_pbx_outgoing_app(chantech, AST_FORMAT_SLINEAR, chandata, TIMEOUT * 1000, app, appdata, &reason, 0, NULL, NULL, NULL, NULL, NULL);
+	if (!(cap = ast_cap_alloc())) {
+		return CLI_FAILURE;
+	}
+	ast_cap_add(cap, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));
+	ast_pbx_outgoing_app(chantech, cap, chandata, TIMEOUT * 1000, app, appdata, &reason, 0, NULL, NULL, NULL, NULL, NULL);
+	cap = ast_cap_destroy(cap);
 
 	return CLI_SUCCESS;
 }
@@ -84,6 +91,8 @@
 	char *exten = NULL;
 	char *context = NULL;
 	int reason = 0;
+	struct ast_cap *cap;
+	struct ast_format tmpfmt;
 
 	chandata = ast_strdupa(chan);
 
@@ -102,8 +111,12 @@
 		exten = "s";
 	if (ast_strlen_zero(context))
 		context = "default";
-
-	ast_pbx_outgoing_exten(chantech, AST_FORMAT_SLINEAR, chandata, TIMEOUT * 1000, context, exten, 1, &reason, 0, NULL, NULL, NULL, NULL, NULL);
+	if (!(cap = ast_cap_alloc())) {
+		return CLI_FAILURE;
+	}
+	ast_cap_add(cap, ast_format_set(&tmpfmt, AST_FORMAT_SLINEAR, 0));
+	ast_pbx_outgoing_exten(chantech, cap, chandata, TIMEOUT * 1000, context, exten, 1, &reason, 0, NULL, NULL, NULL, NULL, NULL);
+	cap = ast_cap_destroy(cap);
 
 	return CLI_SUCCESS;
 }

Modified: team/dvossel/fixtheworld_phase1_step3/res/res_fax.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/res/res_fax.c?view=diff&rev=301881&r1=301880&r2=301881
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/res/res_fax.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/res/res_fax.c Fri Jan 14 14:23:33 2011
@@ -1082,8 +1082,11 @@
 	struct ast_fax_session *fax = NULL;
 	struct ast_frame *frame = NULL;
 	struct ast_channel *c = chan;
-	unsigned int orig_write_format = 0, orig_read_format = 0;
-
+	struct ast_format orig_write_format;
+	struct ast_format orig_read_format;
+
+	ast_format_clear(&orig_write_format);
+	ast_format_clear(&orig_read_format);
 	chancount = 1;
 
 	/* create the FAX session */
@@ -1108,9 +1111,9 @@
 
 	if (details->caps & AST_FAX_TECH_AUDIO) {
 		expected_frametype = AST_FRAME_VOICE;;
-		expected_framesubclass.codec = AST_FORMAT_SLINEAR;
-		orig_write_format = chan->writeformat;
-		if (ast_set_write_format(chan, AST_FORMAT_SLINEAR) < 0) {
+		ast_format_set(&expected_framesubclass.format, AST_FORMAT_SLINEAR, 0);
+		ast_format_copy(&orig_write_format, &chan->writeformat);
+		if (ast_set_write_format_by_id(chan, AST_FORMAT_SLINEAR) < 0) {
 			ast_log(LOG_ERROR, "channel '%s' failed to set write format to signed linear'.\n", chan->name);
  			ao2_lock(faxregistry.container);
  			ao2_unlink(faxregistry.container, fax);
@@ -1119,8 +1122,8 @@
 			ast_channel_unlock(chan);
 			return -1;
 		}
-		orig_read_format = chan->readformat;
-		if (ast_set_read_format(chan, AST_FORMAT_SLINEAR) < 0) {
+		ast_format_copy(&orig_read_format, &chan->readformat);
+		if (ast_set_read_format_by_id(chan, AST_FORMAT_SLINEAR) < 0) {
 			ast_log(LOG_ERROR, "channel '%s' failed to set read format to signed linear.\n", chan->name);
  			ao2_lock(faxregistry.container);
  			ao2_unlink(faxregistry.container, fax);
@@ -1138,7 +1141,7 @@
 		}
 	} else {
 		expected_frametype = AST_FRAME_MODEM;
-		expected_framesubclass.codec = AST_MODEM_T38;
+		expected_framesubclass.integer = AST_MODEM_T38;
 	}
 
 	if (fax->debug_info) {
@@ -1213,7 +1216,7 @@
 					fax->tech->switch_to_t38(fax);
 					details->caps &= ~AST_FAX_TECH_AUDIO;
 					expected_frametype = AST_FRAME_MODEM;
-					expected_framesubclass.codec = AST_MODEM_T38;
+					expected_framesubclass.integer = AST_MODEM_T38;
 					if (fax->smoother) {
 						ast_smoother_free(fax->smoother);
 						fax->smoother = NULL;
@@ -1314,11 +1317,11 @@
 	 * restore them now
 	 */
 	if (chancount) {
-		if (orig_read_format) {
-			ast_set_read_format(chan, orig_read_format);
-		}
-		if (orig_write_format) {
-			ast_set_write_format(chan, orig_write_format);
+		if (orig_read_format.id) {
+			ast_set_read_format(chan, &orig_read_format);
+		}
+		if (orig_write_format.id) {
+			ast_set_write_format(chan, &orig_write_format);
 		}
 	}
 

Modified: team/dvossel/fixtheworld_phase1_step3/res/res_fax_spandsp.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/res/res_fax_spandsp.c?view=diff&rev=301881&r1=301880&r2=301881
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/res/res_fax_spandsp.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/res/res_fax_spandsp.c Fri Jan 14 14:23:33 2011
@@ -492,11 +492,10 @@
 
 	struct ast_frame fax_frame = {
 		.frametype = AST_FRAME_VOICE,
-		.subclass.codec = AST_FORMAT_SLINEAR,
 		.src = "res_fax_spandsp_g711",
 	};
-
 	struct ast_frame *f = &fax_frame;
+	ast_format_set(&fax_frame.subclass.format, AST_FORMAT_SLINEAR, 0);
 
 	ast_timer_ack(p->timer, 1);
 

Modified: team/dvossel/fixtheworld_phase1_step3/res/res_musiconhold.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/res/res_musiconhold.c?view=diff&rev=301881&r1=301880&r2=301881
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/res/res_musiconhold.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/res/res_musiconhold.c Fri Jan 14 14:23:33 2011
@@ -152,7 +152,7 @@
 struct moh_files_state {
 	struct mohclass *class;
 	char name[MAX_MUSICCLASS];
-	format_t origwfmt;
+	struct ast_format origwfmt;
 	int samples;
 	int sample_queue;
 	int pos;
@@ -188,7 +188,7 @@
 	int total_files;
 	unsigned int flags;
 	/*! The format from the MOH source, not applicable to "files" mode */
-	format_t format;
+	struct ast_format format;
 	/*! The pid of the external application delivering MOH */
 	int pid;
 	time_t start;
@@ -206,7 +206,7 @@
 
 struct mohdata {
 	int pipe[2];
-	format_t origwfmt;
+	struct ast_format origwfmt;
 	struct mohclass *parent;
 	struct ast_frame f;
 	AST_LIST_ENTRY(mohdata) list;
@@ -267,8 +267,8 @@
 		ast_verbose(VERBOSE_PREFIX_3 "Stopped music on hold on %s\n", chan->name);
 	}
 
-	if (state->origwfmt && ast_set_write_format(chan, state->origwfmt)) {
-		ast_log(LOG_WARNING, "Unable to restore channel '%s' to format '%s'\n", chan->name, ast_getformatname(state->origwfmt));
+	if (state->origwfmt.id && ast_set_write_format(chan, &state->origwfmt)) {
+		ast_log(LOG_WARNING, "Unable to restore channel '%s' to format '%s'\n", chan->name, ast_getformatname(&state->origwfmt));
 	}
 
 	state->save_pos = state->pos;
@@ -666,7 +666,7 @@
 		if ((strncasecmp(class->dir, "http://", 7) && strcasecmp(class->dir, "nodir")) && AST_LIST_EMPTY(&class->members))
 			continue;
 		/* Read mp3 audio */
-		len = ast_codec_get_len(class->format, res);
+		len = ast_codec_get_len(&class->format, res);
 
 		if ((res2 = read(class->srcfd, sbuf, len)) != len) {
 			if (!res2) {
@@ -869,7 +869,7 @@
 	fcntl(moh->pipe[1], F_SETFL, flags | O_NONBLOCK);
 
 	moh->f.frametype = AST_FRAME_VOICE;
-	moh->f.subclass.codec = cl->format;
+	ast_format_copy(&moh->f.subclass.format, &cl->format);
 	moh->f.offset = AST_FRIENDLY_OFFSET;
 
 	moh->parent = mohclass_ref(cl, "Reffing music class for mohdata parent");
@@ -885,7 +885,7 @@
 {
 	struct mohdata *moh = data;
 	struct mohclass *class = moh->parent;
-	format_t oldwfmt;
+	struct ast_format oldwfmt;
 
 	ao2_lock(class);
 	AST_LIST_REMOVE(&moh->parent->members, moh, list);	
@@ -894,16 +894,16 @@
 	close(moh->pipe[0]);
 	close(moh->pipe[1]);
 
-	oldwfmt = moh->origwfmt;
+	ast_format_copy(&oldwfmt, &moh->origwfmt);
 
 	moh->parent = class = mohclass_unref(class, "unreffing moh->parent upon deactivation of generator");
 
 	ast_free(moh);
 
 	if (chan) {
-		if (oldwfmt && ast_set_write_format(chan, oldwfmt)) {
+		if (oldwfmt.id && ast_set_write_format(chan, &oldwfmt)) {
 			ast_log(LOG_WARNING, "Unable to restore channel '%s' to format %s\n",
-					chan->name, ast_getformatname(oldwfmt));
+					chan->name, ast_getformatname(&oldwfmt));
 		}
 
 		ast_verb(3, "Stopped music on hold on %s\n", chan->name);
@@ -930,8 +930,8 @@
 
 	if ((res = mohalloc(class))) {
 		res->origwfmt = chan->writeformat;
-		if (ast_set_write_format(chan, class->format)) {
-			ast_log(LOG_WARNING, "Unable to set channel '%s' to format '%s'\n", chan->name, ast_codec2str(class->format));
+		if (ast_set_write_format(chan, &class->format)) {
+			ast_log(LOG_WARNING, "Unable to set channel '%s' to format '%s'\n", chan->name, ast_codec2str(&class->format));
 			moh_release(NULL, res);
 			res = NULL;
 		}
@@ -946,7 +946,7 @@
 	short buf[1280 + AST_FRIENDLY_OFFSET / 2];
 	int res;
 
-	len = ast_codec_get_len(moh->parent->format, samples);
+	len = ast_codec_get_len(&moh->parent->format, samples);
 
 	if (len > sizeof(buf) - AST_FRIENDLY_OFFSET) {
 		ast_log(LOG_WARNING, "Only doing %d of %d requested bytes on %s\n", (int)sizeof(buf), len, chan->name);
@@ -1276,7 +1276,7 @@
 			ao2_alloc(sizeof(*class), moh_class_destructor)
 #endif
 		)) {
-		class->format = AST_FORMAT_SLINEAR;
+		ast_format_set(&class->format, AST_FORMAT_SLINEAR, 0);
 	}
 
 	return class;
@@ -1353,10 +1353,10 @@
 				else if (!strcasecmp(tmp->name, "sort") && !strcasecmp(tmp->value, "alpha")) 
 					ast_set_flag(mohclass, MOH_SORTALPHA);
 				else if (!strcasecmp(tmp->name, "format")) {
-					mohclass->format = ast_getformatbyname(tmp->value);
-					if (!mohclass->format) {
+					ast_getformatbyname(tmp->value, &mohclass->format);
+					if (!mohclass->format.id) {
 						ast_log(LOG_WARNING, "Unknown format '%s' -- defaulting to SLIN\n", tmp->value);
-						mohclass->format = AST_FORMAT_SLINEAR;
+						ast_format_set(&mohclass->format, AST_FORMAT_SLINEAR, 0);
 					}
 				}
 			}
@@ -1677,10 +1677,10 @@
 			else if (!strcasecmp(var->name, "sort") && !strcasecmp(var->value, "alpha")) 
 				ast_set_flag(class, MOH_SORTALPHA);
 			else if (!strcasecmp(var->name, "format")) {
-				class->format = ast_getformatbyname(var->value);
-				if (!class->format) {
+				ast_getformatbyname(var->value, &class->format);
+				if (!class->format.id) {
 					ast_log(LOG_WARNING, "Unknown format '%s' -- defaulting to SLIN\n", var->value);
-					class->format = AST_FORMAT_SLINEAR;
+					ast_format_set(&class->format, AST_FORMAT_SLINEAR, 0);
 				}
 			}
 		}
@@ -1813,7 +1813,7 @@
 			ast_cli(a->fd, "\tApplication: %s\n", S_OR(class->args, "<none>"));
 		}
 		if (strcasecmp(class->mode, "files")) {
-			ast_cli(a->fd, "\tFormat: %s\n", ast_getformatname(class->format));
+			ast_cli(a->fd, "\tFormat: %s\n", ast_getformatname(&class->format));
 		}
 	}
 	ao2_iterator_destroy(&i);

Modified: team/dvossel/fixtheworld_phase1_step3/res/res_rtp_multicast.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/res/res_rtp_multicast.c?view=diff&rev=301881&r1=301880&r2=301881
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/res/res_rtp_multicast.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/res/res_rtp_multicast.c Fri Jan 14 14:23:33 2011
@@ -213,7 +213,7 @@
 	}
 
 	/* Grab the actual payload number for when we create the RTP packet */
-	if ((codec = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(instance), 1, frame->subclass.codec)) < 0) {
+	if ((codec = ast_rtp_codecs_payload_code(ast_rtp_instance_get_codecs(instance), 1, &frame->subclass.format, 0)) < 0) {
 		return -1;
 	}
 

Modified: team/dvossel/fixtheworld_phase1_step3/res/res_speech.c
URL: http://svnview.digium.com/svn/asterisk/team/dvossel/fixtheworld_phase1_step3/res/res_speech.c?view=diff&rev=301881&r1=301880&r2=301881
==============================================================================
--- team/dvossel/fixtheworld_phase1_step3/res/res_speech.c (original)
+++ team/dvossel/fixtheworld_phase1_step3/res/res_speech.c Fri Jan 14 14:23:33 2011
@@ -185,7 +185,7 @@
 	/* Before even allocating the memory below do some codec negotiation, we choose the best codec possible and fall back to signed linear if possible */
 	if ((joint = ast_cap_joint(engine->formats, cap))) {
 		ast_best_codec(joint, &best);
-		joint = ast_cap_destoy(joint);
+		joint = ast_cap_destroy(joint);
 	} else if (!ast_cap_iscompatible(engine->formats, &best)) {
 		return NULL;
 	}
@@ -204,7 +204,7 @@
 	new_speech->engine = engine;
 
 	/* Can't forget the format audio is going to be in */
-	ast_format_copy(&new_speech->format, &best)
+	ast_format_copy(&new_speech->format, &best);
 
 	/* We are not ready to accept audio yet */
 	ast_speech_change_state(new_speech, AST_SPEECH_STATE_NOT_READY);




More information about the asterisk-commits mailing list