[asterisk-commits] branch file/coremedia - r7309 in /team/file/coremedia: ./ apps/ channels/ cod...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sat Dec 3 13:53:25 CST 2005


Author: file
Date: Sat Dec  3 13:53:13 2005
New Revision: 7309

URL: http://svn.digium.com/view/asterisk?rev=7309&view=rev
Log:
Merge coremedia from my local working tree to SVN

Added:
    team/file/coremedia/coremedia.c
    team/file/coremedia/include/asterisk/coremedia.h
Modified:
    team/file/coremedia/Makefile
    team/file/coremedia/app.c
    team/file/coremedia/apps/Makefile
    team/file/coremedia/apps/app_chanisavail.c
    team/file/coremedia/apps/app_chanspy.c
    team/file/coremedia/apps/app_dial.c
    team/file/coremedia/apps/app_dictate.c
    team/file/coremedia/apps/app_dumpchan.c
    team/file/coremedia/apps/app_echo.c
    team/file/coremedia/apps/app_festival.c
    team/file/coremedia/apps/app_ices.c
    team/file/coremedia/apps/app_mp3.c
    team/file/coremedia/apps/app_nbscat.c
    team/file/coremedia/apps/app_queue.c
    team/file/coremedia/apps/app_record.c
    team/file/coremedia/apps/app_talkdetect.c
    team/file/coremedia/apps/app_test.c
    team/file/coremedia/apps/app_waitforsilence.c
    team/file/coremedia/asterisk.c
    team/file/coremedia/channel.c
    team/file/coremedia/channels/Makefile
    team/file/coremedia/channels/chan_sip.c
    team/file/coremedia/cli.c
    team/file/coremedia/codecs/Makefile
    team/file/coremedia/codecs/codec_gsm.c
    team/file/coremedia/codecs/codec_ulaw.c
    team/file/coremedia/file.c
    team/file/coremedia/formats/Makefile
    team/file/coremedia/image.c
    team/file/coremedia/include/asterisk/channel.h
    team/file/coremedia/include/asterisk/slinfactory.h
    team/file/coremedia/indications.c
    team/file/coremedia/res/res_adsi.c
    team/file/coremedia/res/res_agi.c
    team/file/coremedia/res/res_features.c
    team/file/coremedia/res/res_musiconhold.c
    team/file/coremedia/rtp.c
    team/file/coremedia/slinfactory.c

Modified: team/file/coremedia/Makefile
URL: http://svn.digium.com/view/asterisk/team/file/coremedia/Makefile?rev=7309&r1=7308&r2=7309&view=diff
==============================================================================
--- team/file/coremedia/Makefile (original)
+++ team/file/coremedia/Makefile Sat Dec  3 13:53:13 2005
@@ -175,11 +175,13 @@
     PROC=$(CROSS_PROC)
   endif
 
+  MPG123TARG=linux
   ifeq ($(PROC),x86_64)
     # You must have GCC 3.4 to use k8, otherwise use athlon
     PROC=k8
     #PROC=athlon
     OPTIONS+=-m64
+    MPG123TARG=linux-devel
   endif
 
   ifeq ($(PROC),sparc64)
@@ -206,7 +208,6 @@
       endif
     endif
   endif
-  MPG123TARG=linux
 endif
 
 PWD=$(shell pwd)
@@ -336,14 +337,14 @@
 SUBDIRS=res channels pbx apps codecs formats agi cdr funcs utils stdtime
 
 OBJS=io.o sched.o logger.o frame.o loader.o config.o channel.o \
-	translate.o file.o say.o pbx.o cli.o md5.o term.o \
+	file.o say.o pbx.o cli.o md5.o term.o \
 	ulaw.o alaw.o callerid.o fskmodem.o image.o app.o \
 	cdr.o tdd.o acl.o rtp.o manager.o asterisk.o \
 	dsp.o chanvars.o indications.o autoservice.o db.o privacy.o \
 	astmm.o enum.o srv.o dns.o aescrypt.o aestab.o aeskey.o \
 	utils.o plc.o jitterbuf.o dnsmgr.o devicestate.o \
 	netsock.o slinfactory.o ast_expr2.o ast_expr2f.o \
-	cryptostub.o
+	cryptostub.o coremedia.o
 
 ifeq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/sys/poll.h),)
   OBJS+= poll.o

Modified: team/file/coremedia/app.c
URL: http://svn.digium.com/view/asterisk/team/file/coremedia/app.c?rev=7309&r1=7308&r2=7309&view=diff
==============================================================================
--- team/file/coremedia/app.c (original)
+++ team/file/coremedia/app.c Sat Dec  3 13:53:13 2005
@@ -151,7 +151,7 @@
 {
 	int res;
 	struct ast_filestream *writer;
-	int rfmt;
+	ast_coremedia_t *rfmt;
 	int totalms=0, total;
 	
 	struct ast_frame *f;
@@ -222,7 +222,7 @@
 			ast_frfree(f);
 		}
 	}
-	res = ast_set_read_format(c, rfmt);
+	res = ast_set_read_format_cm(c, rfmt);
 	if (res)
 		ast_log(LOG_WARNING, "Unable to restore read format on '%s'\n", c->name);
 	ast_dsp_free(sildet);
@@ -326,14 +326,14 @@
 	int fd;
 	int autoclose;
 	int allowoverride;
-	int origwfmt;
+	ast_coremedia_t *origwfmt;
 };
 
 static void linear_release(struct ast_channel *chan, void *params)
 {
 	struct linear_state *ls = params;
-	if (ls->origwfmt && ast_set_write_format(chan, ls->origwfmt)) {
-		ast_log(LOG_WARNING, "Unable to restore channel '%s' to format '%d'\n", chan->name, ls->origwfmt);
+	if (ls->origwfmt && ast_set_write_format_cm(chan, ls->origwfmt)) {
+		ast_log(LOG_WARNING, "Unable to restore channel '%s' to format '%d'\n", chan->name, ls->origwfmt->format);
 	}
 	if (ls->autoclose)
 		close(ls->fd);
@@ -560,7 +560,7 @@
 	int totalsilence = 0;
 	int dspsilence = 0;
 	int gotsilence = 0;		/* did we timeout for silence? */
-	int rfmt=0;
+	ast_coremedia_t *rfmt = NULL;
 	struct ast_silence_generator *silgen = NULL;
 
 	if (silencethreshold < 0)
@@ -757,8 +757,8 @@
 		ast_closestream(others[x]);
 	}
 	if (rfmt) {
-		if (ast_set_read_format(chan, rfmt)) {
-			ast_log(LOG_WARNING, "Unable to restore format %s to channel '%s'\n", ast_getformatname(rfmt), chan->name);
+		if (ast_set_read_format_cm(chan, rfmt)) {
+			ast_log(LOG_WARNING, "Unable to restore format %s to channel '%s'\n", ast_getformatname(rfmt->format), chan->name);
 		}
 	}
 	if (outmsg > 1) {
@@ -787,7 +787,7 @@
 	int totalsilence = 0;
 	int dspsilence = 0;
 	int gotsilence = 0;		/* did we timeout for silence? */
-	int rfmt=0;	
+	ast_coremedia_t *rfmt = NULL;	
 	char prependfile[80];
 	
 	if (silencethreshold < 0)
@@ -990,8 +990,8 @@
 		}
 	}
 	if (rfmt) {
-		if (ast_set_read_format(chan, rfmt)) {
-			ast_log(LOG_WARNING, "Unable to restore format %s to channel '%s'\n", ast_getformatname(rfmt), chan->name);
+		if (ast_set_read_format_cm(chan, rfmt)) {
+			ast_log(LOG_WARNING, "Unable to restore format %s to channel '%s'\n", ast_getformatname(rfmt->format), chan->name);
 		}
 	}
 	if (outmsg) {

Modified: team/file/coremedia/apps/Makefile
URL: http://svn.digium.com/view/asterisk/team/file/coremedia/apps/Makefile?rev=7309&r1=7308&r2=7309&view=diff
==============================================================================
--- team/file/coremedia/apps/Makefile (original)
+++ team/file/coremedia/apps/Makefile Sat Dec  3 13:53:13 2005
@@ -11,25 +11,7 @@
 # the GNU General Public License
 #
 
-APPS=app_dial.so app_playback.so app_voicemail.so app_directory.so app_mp3.so\
-     app_system.so app_echo.so app_record.so app_image.so app_url.so app_disa.so \
-     app_adsiprog.so app_getcpeid.so app_milliwatt.so \
-     app_zapateller.so app_setcallerid.so app_festival.so \
-     app_queue.so app_senddtmf.so app_parkandannounce.so \
-     app_setcidname.so app_lookupcidname.so app_macro.so \
-     app_authenticate.so app_softhangup.so app_lookupblacklist.so \
-     app_waitforring.so app_privacy.so app_db.so app_chanisavail.so \
-     app_enumlookup.so app_transfer.so app_setcidnum.so app_cdr.so \
-     app_hasnewvoicemail.so app_sayunixtime.so app_cut.so app_read.so \
-     app_setcdruserfield.so app_random.so app_ices.so app_eval.so \
-     app_nbscat.so app_sendtext.so app_exec.so \
-     app_groupcount.so app_txtcidname.so app_controlplayback.so \
-     app_talkdetect.so app_alarmreceiver.so app_userevent.so app_verbose.so \
-     app_test.so app_forkcdr.so app_math.so app_realtime.so \
-     app_dumpchan.so app_waitforsilence.so app_while.so app_setrdnis.so \
-     app_md5.so app_readfile.so app_chanspy.so app_settransfercapability.so \
-     app_dictate.so app_externalivr.so app_directed_pickup.so \
-     app_mixmonitor.so app_stack.so
+APPS=app_dial.so app_playback.so
 
 #
 # Obsolete things...
@@ -44,7 +26,7 @@
 #APPS+=app_skel.so
 #APPS+=app_rpt.so
 
-ifndef WITHOUT_ZAPTEL
+ifdef WITHOUT_ZAPTEL
 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/linux/zaptel.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/zaptel.h),)
   APPS+=app_zapras.so app_meetme.so app_flash.so app_zapbarge.so app_zapscan.so app_page.so
 endif

Modified: team/file/coremedia/apps/app_chanisavail.c
URL: http://svn.digium.com/view/asterisk/team/file/coremedia/apps/app_chanisavail.c?rev=7309&r1=7308&r2=7309&view=diff
==============================================================================
--- team/file/coremedia/apps/app_chanisavail.c (original)
+++ team/file/coremedia/apps/app_chanisavail.c Sat Dec  3 13:53:13 2005
@@ -122,7 +122,7 @@
 				snprintf(trychan, sizeof(trychan), "%s/%s",cur,number);
 				status = inuse = ast_device_state(trychan);
 			}
-			if ((inuse <= 1) && (tempchan = ast_request(tech, chan->nativeformats, number, &status))) {
+			if ((inuse <= 1) && (tempchan = ast_request(tech, chan->nativeformat->format, number, &status))) {
 					pbx_builtin_setvar_helper(chan, "AVAILCHAN", tempchan->name);
 					/* Store the originally used channel too */
 					snprintf(tmp, sizeof(tmp), "%s/%s", tech, number);

Modified: team/file/coremedia/apps/app_chanspy.c
URL: http://svn.digium.com/view/asterisk/team/file/coremedia/apps/app_chanspy.c?rev=7309&r1=7308&r2=7309&view=diff
==============================================================================
--- team/file/coremedia/apps/app_chanspy.c (original)
+++ team/file/coremedia/apps/app_chanspy.c Sat Dec  3 13:53:13 2005
@@ -373,9 +373,9 @@
 		count=0,
 		waitms = 100,
 		num = 0,
-		oldrf = 0,
-		oldwf = 0,
 		fd = 0;
+	ast_coremedia_t *oldrf = NULL;
+	ast_coremedia_t *oldwf = NULL;
 	struct ast_flags flags;
 	signed char zero_volume = 0;
 
@@ -538,11 +538,11 @@
 		close(fd);
 	}
 
-	if (oldrf && ast_set_read_format(chan, oldrf) < 0) {
+	if (oldrf && ast_set_read_format_cm(chan, oldrf) < 0) {
 		ast_log(LOG_ERROR, "Could Not Set Read Format.\n");
 	}
 	
-	if (oldwf && ast_set_write_format(chan, oldwf) < 0) {
+	if (oldwf && ast_set_write_format_cm(chan, oldwf) < 0) {
 		ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
 	}
 

Modified: team/file/coremedia/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/team/file/coremedia/apps/app_dial.c?rev=7309&r1=7308&r2=7309&view=diff
==============================================================================
--- team/file/coremedia/apps/app_dial.c (original)
+++ team/file/coremedia/apps/app_dial.c Sat Dec  3 13:53:13 2005
@@ -462,7 +462,7 @@
 						if (option_verbose > 2)
 							ast_verbose(VERBOSE_PREFIX_3 "Now forwarding %s to '%s/%s' (thanks to %s)\n", in->name, tech, stuff, o->chan->name);
 						/* Setup parameters */
-						o->chan = ast_request(tech, in->nativeformats, stuff, &cause);
+						o->chan = ast_request(tech, in->nativeformat, stuff, &cause);
 						if (!o->chan)
 							ast_log(LOG_NOTICE, "Unable to create local channel for call forward to '%s/%s' (cause = %d)\n", tech, stuff, cause);
 					} else {
@@ -1004,7 +1004,7 @@
 				ast_log(LOG_DEBUG, "Dialing by extension %s\n", numsubst);
 		}
 		/* Request the peer */
-		tmp->chan = ast_request(tech, chan->nativeformats, numsubst, &cause);
+		tmp->chan = ast_request(tech, chan->nativeformat, numsubst, &cause);
 		if (!tmp->chan) {
 			/* If we can't, just go on to the next call */
 			ast_log(LOG_NOTICE, "Unable to create channel of type '%s' (cause %d - %s)\n", tech, cause, ast_cause2str(cause));
@@ -1035,7 +1035,7 @@
 					ast_verbose(VERBOSE_PREFIX_3 "Now forwarding %s to '%s/%s' (thanks to %s)\n", chan->name, tech, stuff, tmp->chan->name);
 				ast_hangup(tmp->chan);
 				/* Setup parameters */
-				tmp->chan = ast_request(tech, chan->nativeformats, stuff, &cause);
+				tmp->chan = ast_request(tech, chan->nativeformat, stuff, &cause);
 				if (!tmp->chan)
 					ast_log(LOG_NOTICE, "Unable to create local channel for call forward to '%s/%s' (cause = %d)\n", tech, stuff, cause);
 			} else {

Modified: team/file/coremedia/apps/app_dictate.c
URL: http://svn.digium.com/view/asterisk/team/file/coremedia/apps/app_dictate.c?rev=7309&r1=7308&r2=7309&view=diff
==============================================================================
--- team/file/coremedia/apps/app_dictate.c (original)
+++ team/file/coremedia/apps/app_dictate.c Sat Dec  3 13:53:13 2005
@@ -91,7 +91,6 @@
 		res = 0,
 		argc = 0,
 		done = 0,
-		oldr = 0,
 		lastop = 0,
 		samples = 0,
 		speed = 1,
@@ -99,6 +98,7 @@
 		len = 0,
 		maxlen = 0,
 		mode = 0;
+	ast_coremedia_t *oldr = NULL;
 		
 	LOCAL_USER_ADD(u);
 	
@@ -317,7 +317,7 @@
 		}
 	}
 	if (oldr) {
-		ast_set_read_format(chan, oldr);
+		ast_set_read_format_cm(chan, oldr);
 	}
 	LOCAL_USER_REMOVE(u);
 	return res;

Modified: team/file/coremedia/apps/app_dumpchan.c
URL: http://svn.digium.com/view/asterisk/team/file/coremedia/apps/app_dumpchan.c?rev=7309&r1=7308&r2=7309&view=diff
==============================================================================
--- team/file/coremedia/apps/app_dumpchan.c (original)
+++ team/file/coremedia/apps/app_dumpchan.c Sat Dec  3 13:53:13 2005
@@ -112,9 +112,9 @@
 			 ast_state2str(c->_state),
 			 c->_state,
 			 c->rings,
-			 c->nativeformats,
-			 c->writeformat,
-			 c->readformat,
+			 c->nativeformat->format,
+			 c->writeformat->format,
+			 c->readformat->format,
 			 c->fds[0], c->fin & 0x7fffffff, (c->fin & 0x80000000) ? " (DEBUGGED)" : "",
 			 c->fout & 0x7fffffff, (c->fout & 0x80000000) ? " (DEBUGGED)" : "", (long)c->whentohangup,
 			 hour,

Modified: team/file/coremedia/apps/app_echo.c
URL: http://svn.digium.com/view/asterisk/team/file/coremedia/apps/app_echo.c?rev=7309&r1=7308&r2=7309&view=diff
==============================================================================
--- team/file/coremedia/apps/app_echo.c (original)
+++ team/file/coremedia/apps/app_echo.c Sat Dec  3 13:53:13 2005
@@ -57,15 +57,13 @@
 static int echo_exec(struct ast_channel *chan, void *data)
 {
 	int res = -1;
-	int format;
 	struct localuser *u;
 	struct ast_frame *f;
 
 	LOCAL_USER_ADD(u);
 
-	format = ast_best_codec(chan->nativeformats);
-	ast_set_write_format(chan, format);
-	ast_set_read_format(chan, format);
+	ast_set_write_format_cm(chan, chan->nativeformat);
+	ast_set_read_format_cm(chan, chan->nativeformat);
 
 	while (ast_waitfor(chan, -1) > -1) {
 		f = ast_read(chan);

Modified: team/file/coremedia/apps/app_festival.c
URL: http://svn.digium.com/view/asterisk/team/file/coremedia/apps/app_festival.c?rev=7309&r1=7308&r2=7309&view=diff
==============================================================================
--- team/file/coremedia/apps/app_festival.c (original)
+++ team/file/coremedia/apps/app_festival.c Sat Dec  3 13:53:13 2005
@@ -158,8 +158,8 @@
 	int ms = -1;
 	int pid = -1;
 	int needed = 0;
-	int owriteformat;
 	struct ast_frame *f;
+	ast_coremedia_t *owriteformat = NULL;
 	struct myframe {
 		struct ast_frame f;
 		char offset[AST_FRIENDLY_OFFSET];
@@ -250,7 +250,7 @@
 /*	if (pid > -1) */
 /*		kill(pid, SIGKILL); */
 	if (!res && owriteformat)
-		ast_set_write_format(chan, owriteformat);
+		ast_set_write_format_cm(chan, owriteformat);
 	return res;
 }
 

Modified: team/file/coremedia/apps/app_ices.c
URL: http://svn.digium.com/view/asterisk/team/file/coremedia/apps/app_ices.c?rev=7309&r1=7308&r2=7309&view=diff
==============================================================================
--- team/file/coremedia/apps/app_ices.c (original)
+++ team/file/coremedia/apps/app_ices.c Sat Dec  3 13:53:13 2005
@@ -95,7 +95,7 @@
 	int ms = -1;
 	int pid = -1;
 	int flags;
-	int oreadformat;
+	ast_coremedia_t *oreadformat = NULL;
 	struct timeval last;
 	struct ast_frame *f;
 	char filename[256]="";
@@ -184,7 +184,7 @@
 	if (pid > -1)
 		kill(pid, SIGKILL);
 	if (!res && oreadformat)
-		ast_set_read_format(chan, oreadformat);
+		ast_set_read_format_cm(chan, oreadformat);
 
 	LOCAL_USER_REMOVE(u);
 

Modified: team/file/coremedia/apps/app_mp3.c
URL: http://svn.digium.com/view/asterisk/team/file/coremedia/apps/app_mp3.c?rev=7309&r1=7308&r2=7309&view=diff
==============================================================================
--- team/file/coremedia/apps/app_mp3.c (original)
+++ team/file/coremedia/apps/app_mp3.c Sat Dec  3 13:53:13 2005
@@ -119,10 +119,10 @@
 	int fds[2];
 	int ms = -1;
 	int pid = -1;
-	int owriteformat;
 	int timeout = 2000;
 	struct timeval next;
 	struct ast_frame *f;
+	ast_coremedia_t *owriteformat = NULL;
 	struct myframe {
 		struct ast_frame f;
 		char offset[AST_FRIENDLY_OFFSET];
@@ -219,7 +219,7 @@
 	if (pid > -1)
 		kill(pid, SIGKILL);
 	if (!res && owriteformat)
-		ast_set_write_format(chan, owriteformat);
+		ast_set_write_format_cm(chan, owriteformat);
 
 	LOCAL_USER_REMOVE(u);
 	

Modified: team/file/coremedia/apps/app_nbscat.c
URL: http://svn.digium.com/view/asterisk/team/file/coremedia/apps/app_nbscat.c?rev=7309&r1=7308&r2=7309&view=diff
==============================================================================
--- team/file/coremedia/apps/app_nbscat.c (original)
+++ team/file/coremedia/apps/app_nbscat.c Sat Dec  3 13:53:13 2005
@@ -109,7 +109,7 @@
 	int fds[2];
 	int ms = -1;
 	int pid = -1;
-	int owriteformat;
+	ast_coremedia_t *owriteformat = NULL;
 	struct timeval next;
 	struct ast_frame *f;
 	struct myframe {
@@ -200,7 +200,7 @@
 	if (pid > -1)
 		kill(pid, SIGKILL);
 	if (!res && owriteformat)
-		ast_set_write_format(chan, owriteformat);
+		ast_set_write_format_cm(chan, owriteformat);
 
 	LOCAL_USER_REMOVE(u);
 

Modified: team/file/coremedia/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/file/coremedia/apps/app_queue.c?rev=7309&r1=7308&r2=7309&view=diff
==============================================================================
--- team/file/coremedia/apps/app_queue.c (original)
+++ team/file/coremedia/apps/app_queue.c Sat Dec  3 13:53:13 2005
@@ -1363,7 +1363,7 @@
 		location = "";
 
 	/* Request the peer */
-	tmp->chan = ast_request(tech, qe->chan->nativeformats, location, &status);
+	tmp->chan = ast_request(tech, qe->chan->nativeformat->format, location, &status);
 	if (!tmp->chan) {			/* If we can't, just go on to the next call */
 #if 0
 		ast_log(LOG_NOTICE, "Unable to create channel of type '%s' for Queue\n", cur->tech);
@@ -1669,7 +1669,7 @@
 					if (option_verbose > 2)
 						ast_verbose(VERBOSE_PREFIX_3 "Now forwarding %s to '%s/%s' (thanks to %s)\n", in->name, tech, stuff, o->chan->name);
 					/* Setup parameters */
-					o->chan = ast_request(tech, in->nativeformats, stuff, &status);
+					o->chan = ast_request(tech, in->nativeformat->format, stuff, &status);
 					if (status != o->oldstatus) 
 						update_dial_status(qe->parent, o->member, status);						
 					if (!o->chan) {

Modified: team/file/coremedia/apps/app_record.c
URL: http://svn.digium.com/view/asterisk/team/file/coremedia/apps/app_record.c?rev=7309&r1=7308&r2=7309&view=diff
==============================================================================
--- team/file/coremedia/apps/app_record.c (original)
+++ team/file/coremedia/apps/app_record.c Sat Dec  3 13:53:13 2005
@@ -100,9 +100,9 @@
 	int option_append = 0;
 	int terminator = '#';
 	int option_quiet = 0;
-	int rfmt = 0;
 	int flags;
 	int waitres;
+	ast_coremedia_t *rfmt = NULL;
 	struct ast_silence_generator *silgen = NULL;
 	
 	/* The next few lines of code parse out the filename and header from the input string */
@@ -331,7 +331,7 @@
 	
  out:
 	if ((silence > 0) && rfmt) {
-		res = ast_set_read_format(chan, rfmt);
+		res = ast_set_read_format_cm(chan, rfmt);
 		if (res)
 			ast_log(LOG_WARNING, "Unable to restore read format on '%s'\n", chan->name);
 		if (sildet)

Modified: team/file/coremedia/apps/app_talkdetect.c
URL: http://svn.digium.com/view/asterisk/team/file/coremedia/apps/app_talkdetect.c?rev=7309&r1=7308&r2=7309&view=diff
==============================================================================
--- team/file/coremedia/apps/app_talkdetect.c (original)
+++ team/file/coremedia/apps/app_talkdetect.c Sat Dec  3 13:53:13 2005
@@ -76,7 +76,7 @@
 	int min = 100;
 	int max = -1;
 	int x;
-	int origrformat=0;
+	ast_coremedia_t *origrformat = NULL;
 	struct ast_dsp *dsp;
 	
 	if (ast_strlen_zero(data)) {
@@ -205,9 +205,9 @@
 		}
 	}
 	if (res > -1) {
-		if (origrformat && ast_set_read_format(chan, origrformat)) {
+		if (origrformat && ast_set_read_format_cm(chan, origrformat)) {
 			ast_log(LOG_WARNING, "Failed to restore read format for %s to %s\n", 
-				chan->name, ast_getformatname(origrformat));
+				chan->name, ast_getformatname(origrformat->format));
 		}
 	}
 	if (dsp)

Modified: team/file/coremedia/apps/app_test.c
URL: http://svn.digium.com/view/asterisk/team/file/coremedia/apps/app_test.c?rev=7309&r1=7308&r2=7309&view=diff
==============================================================================
--- team/file/coremedia/apps/app_test.c (original)
+++ team/file/coremedia/apps/app_test.c Sat Dec  3 13:53:13 2005
@@ -74,7 +74,7 @@
 	short *foo;
 	struct timeval start;
 	struct ast_frame *f;
-	int rformat;
+	ast_coremedia_t *rformat = NULL;
 	rformat = chan->readformat;
 	if (ast_set_read_format(chan, AST_FORMAT_SLINEAR)) {
 		ast_log(LOG_NOTICE, "Unable to set to linear mode!\n");
@@ -103,7 +103,7 @@
 	}
 
 	if (rformat) {
-		if (ast_set_read_format(chan, rformat)) {
+		if (ast_set_read_format_cm(chan, rformat)) {
 			ast_log(LOG_NOTICE, "Unable to restore original format!\n");
 			return -1;
 		}

Modified: team/file/coremedia/apps/app_waitforsilence.c
URL: http://svn.digium.com/view/asterisk/team/file/coremedia/apps/app_waitforsilence.c?rev=7309&r1=7308&r2=7309&view=diff
==============================================================================
--- team/file/coremedia/apps/app_waitforsilence.c (original)
+++ team/file/coremedia/apps/app_waitforsilence.c Sat Dec  3 13:53:13 2005
@@ -70,8 +70,8 @@
 	int dspsilence = 0;
 	int gotsilence = 0; 
 	static int silencethreshold = 64;
-	int rfmt = 0;
 	int res = 0;
+	ast_coremedia_t *rfmt = NULL;
 	struct ast_dsp *sildet;	 /* silence detector dsp */
 	time_t start, now;
 	time(&start);
@@ -139,8 +139,8 @@
 		}
 		ast_frfree(f);
 	}
-	if (rfmt && ast_set_read_format(chan, rfmt)) {
-		ast_log(LOG_WARNING, "Unable to restore format %s to channel '%s'\n", ast_getformatname(rfmt), chan->name);
+	if (rfmt && ast_set_read_format_cm(chan, rfmt)) {
+		ast_log(LOG_WARNING, "Unable to restore format %s to channel '%s'\n", ast_getformatname(rfmt->format), chan->name);
 	}
 	ast_dsp_free(sildet);
 	return gotsilence;

Modified: team/file/coremedia/asterisk.c
URL: http://svn.digium.com/view/asterisk/team/file/coremedia/asterisk.c?rev=7309&r1=7308&r2=7309&view=diff
==============================================================================
--- team/file/coremedia/asterisk.c (original)
+++ team/file/coremedia/asterisk.c Sat Dec  3 13:53:13 2005
@@ -112,6 +112,7 @@
 #include "asterisk/linkedlists.h"
 #include "asterisk/devicestate.h"
 #include "asterisk/compat.h"
+#include "asterisk/coremedia.h"
 
 #include "asterisk/doxyref.h"		/* Doxygen documentation */
 
@@ -2240,6 +2241,7 @@
 		printf(term_quit());
 		exit(1);
 	}
+	ast_coremedia_init();
 	ast_rtp_init();
 	if (ast_image_init()) {
 		printf(term_quit());

Modified: team/file/coremedia/channel.c
URL: http://svn.digium.com/view/asterisk/team/file/coremedia/channel.c?rev=7309&r1=7308&r2=7309&view=diff
==============================================================================
--- team/file/coremedia/channel.c (original)
+++ team/file/coremedia/channel.c Sat Dec  3 13:53:13 2005
@@ -74,7 +74,7 @@
 
 struct channel_spy_trans {
 	int last_format;
-	struct ast_trans_pvt *path;
+	struct ast_coremedia_translator_path *path;
 };
 
 struct ast_channel_spy_list {
@@ -925,9 +925,9 @@
 
 	/* Free translatosr */
 	if (chan->readtrans)
-		ast_translator_free_path(chan->readtrans);
+		ast_coremedia_translate_free(chan->readtrans);
 	if (chan->writetrans)
-		ast_translator_free_path(chan->writetrans);
+		ast_coremedia_translate_free(chan->writetrans);
 	if (chan->pbx) 
 		ast_log(LOG_WARNING, "PBX may not have been terminated properly on '%s'\n", chan->name);
 	free_cid(&chan->cid);
@@ -1064,9 +1064,9 @@
 
 	if (AST_LIST_EMPTY(&chan->spies->list)) {
 		if (chan->spies->read_translator.path)
-			ast_translator_free_path(chan->spies->read_translator.path);
+			ast_coremedia_translate_free(chan->spies->read_translator.path);
 		if (chan->spies->write_translator.path)
-			ast_translator_free_path(chan->spies->write_translator.path);
+			ast_coremedia_translate_free(chan->spies->write_translator.path);
 		free(chan->spies);
 		chan->spies = NULL;
 	}
@@ -1146,22 +1146,21 @@
 		if ((queue->format == AST_FORMAT_SLINEAR) && (f->subclass != AST_FORMAT_SLINEAR)) {
 			if (!translated_frame) {
 				if (trans->path && (trans->last_format != f->subclass)) {
-					ast_translator_free_path(trans->path);
+					ast_coremedia_translate_free(trans->path);
 					trans->path = NULL;
 				}
 				if (!trans->path) {
 					ast_log(LOG_DEBUG, "Building translator from %s to SLINEAR for spies on channel %s\n",
 						ast_getformatname(f->subclass), chan->name);
-					if ((trans->path = ast_translator_build_path(AST_FORMAT_SLINEAR, f->subclass)) == NULL) {
-						ast_log(LOG_WARNING, "Cannot build a path from %s to %s\n",
-							ast_getformatname(f->subclass), ast_getformatname(AST_FORMAT_SLINEAR));
+					/* TODO: We need to get the entry so we can build the path in coremedia f->subclass */
+					if ((trans->path = ast_coremedia_translate_new(NULL, NULL)) == NULL) {
 						ast_mutex_unlock(&spy->lock);
 						continue;
 					} else {
 						trans->last_format = f->subclass;
 					}
 				}
-				translated_frame = ast_translate(trans->path, f, 0);
+				translated_frame = ast_coremedia_translate(trans->path, f, 0);
 			}
 
 			for (last = queue->head; last && last->next; last = last->next);
@@ -1255,13 +1254,13 @@
 static void free_translation(struct ast_channel *clone)
 {
 	if (clone->writetrans)
-		ast_translator_free_path(clone->writetrans);
+		ast_coremedia_translate_free(clone->writetrans);
 	if (clone->readtrans)
-		ast_translator_free_path(clone->readtrans);
+		ast_coremedia_translate_free(clone->readtrans);
 	clone->writetrans = NULL;
 	clone->readtrans = NULL;
-	clone->rawwriteformat = clone->nativeformats;
-	clone->rawreadformat = clone->nativeformats;
+	clone->rawwriteformat = clone->nativeformat;
+	clone->rawreadformat = clone->nativeformat;
 }
 
 /*--- ast_hangup: Hangup a channel */
@@ -1897,10 +1896,15 @@
 
 
 	if (f && (f->frametype == AST_FRAME_VOICE)) {
-		if (!(f->subclass & chan->nativeformats)) {
+	  if (chan->nativeformat == NULL) {
+	    ast_log(LOG_NOTICE, "No native format on channel %s -- dropping frame\n", chan->name);
+	    ast_frfree(f);
+	    f = &null_frame;
+	  }
+	  else if (f->subclass != chan->nativeformat->subclass) {
 			/* This frame can't be from the current native formats -- drop it on the
 			   floor */
-			ast_log(LOG_NOTICE, "Dropping incompatible voice frame on %s of format %s since our native format has changed to %s\n", chan->name, ast_getformatname(f->subclass), ast_getformatname(chan->nativeformats));
+			ast_log(LOG_NOTICE, "Dropping incompatible voice frame on %s Sub: %d Nat: %d\n", chan->name, f->subclass, chan->nativeformat->subclass);
 			ast_frfree(f);
 			f = &null_frame;
 		} else {
@@ -1929,7 +1933,7 @@
 					ast_log(LOG_WARNING, "Failed to write data to channel monitor read stream\n");
 			}
 			if (chan->readtrans) {
-				f = ast_translate(chan->readtrans, f, 1);
+				f = ast_coremedia_translate(chan->readtrans, f, 1);
 				if (!f)
 					f = &null_frame;
 			}
@@ -2160,7 +2164,7 @@
 	/* Send an empty audio frame to get things moving */
 	if (chan->_state != AST_STATE_UP) {
 		ast_log(LOG_DEBUG, "Prodding channel '%s'\n", chan->name);
-		a.subclass = chan->rawwriteformat;
+		a.subclass = chan->rawwriteformat->subclass;
 		a.data = nothing + AST_FRIENDLY_OFFSET;
 		a.src = "ast_prod";
 		if (ast_write(chan, &a))
@@ -2247,7 +2251,7 @@
 		break;
 	default:
 		if (chan->tech->write) {
-			f = (chan->writetrans) ? ast_translate(chan->writetrans, fr, 0) : fr;
+			f = (chan->writetrans) ? ast_coremedia_translate(chan->writetrans, fr, 0) : fr;
 			if (f) {
 				if (f->frametype == AST_FRAME_VOICE && chan->spies)
 					queue_frame_to_spies(chan, f, SPY_WRITE);
@@ -2304,62 +2308,86 @@
 	return res;
 }
 
-static int set_format(struct ast_channel *chan, int fmt, int *rawformat, int *format,
-		      struct ast_trans_pvt **trans, const int direction)
-{
-	int native;
-	int res;
-	
-	native = chan->nativeformats;
-	/* Find a translation path from the native format to one of the desired formats */
-	if (!direction)
-		/* reading */
-		res = ast_translator_best_choice(&fmt, &native);
-	else
-		/* writing */
-		res = ast_translator_best_choice(&native, &fmt);
-
-	if (res < 0) {
-		ast_log(LOG_WARNING, "Unable to find a codec translation path from %s to %s\n",
-			ast_getformatname(native), ast_getformatname(fmt));
-		return -1;
-	}
-	
-	/* Now we have a good choice for both. */
-	ast_mutex_lock(&chan->lock);
-	*rawformat = native;
-	/* User perspective is fmt */
-	*format = fmt;
-	/* Free any read translation we have right now */
-	if (*trans)
-		ast_translator_free_path(*trans);
-	/* Build a translation path from the raw format to the desired format */
-	if (!direction)
-		/* reading */
-		*trans = ast_translator_build_path(*format, *rawformat);
-	else
-		/* writing */
-		*trans = ast_translator_build_path(*rawformat, *format);
-	ast_mutex_unlock(&chan->lock);
-	if (option_debug)
-		ast_log(LOG_DEBUG, "Set channel %s to %s format %s\n", chan->name,
-			direction ? "write" : "read", ast_getformatname(fmt));
-	return 0;
-}
-
+static int set_format(struct ast_channel *chan, ast_coremedia_t *fmt, const int direction)
+{
+
+  /* Okay we probably need to setup a translation path */
+  ast_mutex_lock(&chan->lock);
+  switch (direction) {
+  case 0:
+    /* Reading */
+    if (chan->readtrans != NULL) {
+      ast_coremedia_translate_free(chan->readtrans);
+      chan->readtrans = NULL;
+    }
+    if (chan->nativeformat != fmt) {
+      /* Build the translation path */
+      chan->readtrans = ast_coremedia_translate_new(chan->nativeformat, fmt);
+    } else {
+      /* No translation required */
+      chan->rawreadformat = fmt;
+      chan->writeformat = fmt;
+    }
+    break;
+  case 1:
+    /* Writing */
+    if (chan->writetrans != NULL) {
+      ast_coremedia_translate_free(chan->writetrans);
+      chan->writetrans = NULL;
+    }
+    if (chan->nativeformat != fmt) {
+      /* Build the translation path */
+      chan->writetrans = ast_coremedia_translate_new(fmt, chan->nativeformat);
+    } else {
+      /* No translation required */
+      chan->rawwriteformat = fmt;
+      chan->writeformat = fmt;
+    }
+    break;
+  default:
+    break;
+  }
+  ast_mutex_unlock(&chan->lock);
+  
+  return 0;
+}
+
+/* New coremedia APIs */
+int ast_set_read_format_cm(struct ast_channel *chan, ast_coremedia_t *fmt)
+{
+  return set_format(chan, fmt, 0);
+}
+
+int ast_set_write_format_cm(struct ast_channel *chan, ast_coremedia_t *fmt)
+{
+  return set_format(chan, fmt, 1);
+}
+
+/* Set read format wrapper for coremedia */
 int ast_set_read_format(struct ast_channel *chan, int fmt)
 {
-	return set_format(chan, fmt, &chan->rawreadformat, &chan->readformat,
-			  &chan->readtrans, 0);
-}
-
+  ast_coremedia_t *entry = NULL;
+
+  entry = ast_coremedia_get_by_format(fmt);
+  if (entry == NULL)
+    return -1;
+  else /* Set read format to this coremedia entry */
+    return set_format(chan, entry, 0);
+}
+
+/* Set write format wrapper for coremedia */
 int ast_set_write_format(struct ast_channel *chan, int fmt)
 {
-	return set_format(chan, fmt, &chan->rawwriteformat, &chan->writeformat,
-			  &chan->writetrans, 1);
-}
-
-struct ast_channel *__ast_request_and_dial(const char *type, int format, void *data, int timeout, int *outstate, const char *cid_num, const char *cid_name, struct outgoing_helper *oh)
+  ast_coremedia_t *entry = NULL;
+
+  entry = ast_coremedia_get_by_format(fmt);
+  if (entry == NULL)
+    return -1;
+  else /* Set write format to this coremedia entry */
+    return set_format(chan, entry, 1);
+}
+
+struct ast_channel *__ast_request_and_dial(const char *type, struct ast_coremedia_entry *format, void *data, int timeout, int *outstate, const char *cid_num, const char *cid_name, struct outgoing_helper *oh)
 {
 	int state = 0;
 	int cause = 0;
@@ -2470,18 +2498,18 @@
 	return chan;
 }
 
-struct ast_channel *ast_request_and_dial(const char *type, int format, void *data, int timeout, int *outstate, const char *cidnum, const char *cidname)
+struct ast_channel *ast_request_and_dial(const char *type, struct ast_coremedia_entry *format, void *data, int timeout, int *outstate, const char *cidnum, const char *cidname)
 {
 	return __ast_request_and_dial(type, format, data, timeout, outstate, cidnum, cidname, NULL);
 }
 
-struct ast_channel *ast_request(const char *type, int format, void *data, int *cause)
+struct ast_channel *ast_request(const char *type, struct ast_coremedia_entry *format, void *data, int *cause)
 {
 	struct chanlist *chan;
 	struct ast_channel *c;
-	int capabilities;
-	int fmt;
-	int res;
+	struct ast_coremedia_handle *temp_handle = NULL;
+	struct ast_coremedia_handle *chan_capabilities = NULL;
+	struct ast_coremedia_handle *combined = NULL;
 	int foo;
 
 	if (!cause)
@@ -2497,19 +2525,14 @@
 		if (strcasecmp(type, chan->tech->type))
 			continue;
 
-		capabilities = chan->tech->capabilities;
-		fmt = format;
-		res = ast_translator_best_choice(&fmt, &capabilities);
-		if (res < 0) {
-			ast_log(LOG_WARNING, "No translator path exists for channel type %s (native %d) to %d\n", type, chan->tech->capabilities, format);
-			ast_mutex_unlock(&chlock);
-			return NULL;
-		}
+		/* Grab capabilites of channel and do a handle combine */
+
 		ast_mutex_unlock(&chlock);
+
 		if (!chan->tech->requester)
 			return NULL;
 		
-		if (!(c = chan->tech->requester(type, capabilities, data, cause)))
+		if (!(c = chan->tech->requester(type, format, data, cause)))
 			return NULL;
 
 		if (c->_state == AST_STATE_DOWN) {
@@ -2675,52 +2698,17 @@
 
 int ast_channel_make_compatible(struct ast_channel *chan, struct ast_channel *peer)
 {
-	int src;
-	int dst;
-
-	/* Set up translation from the chan to the peer */
-	src = chan->nativeformats;
-	dst = peer->nativeformats;
-	if (ast_translator_best_choice(&dst, &src) < 0) {
-		ast_log(LOG_WARNING, "No path to translate from %s(%d) to %s(%d)\n", chan->name, src, peer->name, dst);
-		return -1;
-	}
-
-	/* if the best path is not 'pass through', then
-	   transcoding is needed; if desired, force transcode path
-	   to use SLINEAR between channels */
-	if ((src != dst) && option_transcode_slin)
-		dst = AST_FORMAT_SLINEAR;
-	if (ast_set_read_format(chan, dst) < 0) {
-		ast_log(LOG_WARNING, "Unable to set read format on channel %s to %d\n", chan->name, dst);
-		return -1;
-	}
-	if (ast_set_write_format(peer, dst) < 0) {
-		ast_log(LOG_WARNING, "Unable to set write format on channel %s to %d\n", peer->name, dst);
-		return -1;
-	}
-
-	/* Set up translation from the peer to the chan */
-	src = peer->nativeformats;
-	dst = chan->nativeformats;
-	if (ast_translator_best_choice(&dst, &src) < 0) {
-		ast_log(LOG_WARNING, "No path to translate from %s(%d) to %s(%d)\n", peer->name, src, chan->name, dst);
-		return -1;
-	}
-	/* if the best path is not 'pass through', then
-	   transcoding is needed; if desired, force transcode path
-	   to use SLINEAR between channels */
-	if ((src != dst) && option_transcode_slin)
-		dst = AST_FORMAT_SLINEAR;
-	if (ast_set_read_format(peer, dst) < 0) {
-		ast_log(LOG_WARNING, "Unable to set read format on channel %s to %d\n", peer->name, dst);
-		return -1;
-	}
-	if (ast_set_write_format(chan, dst) < 0) {
-		ast_log(LOG_WARNING, "Unable to set write format on channel %s to %d\n", chan->name, dst);
-		return -1;
-	}
-	return 0;
+
+  /* Make both sides compatible through the coremedia core */
+  if (chan->nativeformat != peer->nativeformat) {
+    /* Route everything through signed linear */
+    ast_set_read_format_cm(chan, NULL);
+    ast_set_write_format_cm(chan, NULL);
+    ast_set_read_format_cm(peer, NULL);
+    ast_set_write_format_cm(peer, NULL);
+  }
+
+  return 0;
 }
 
 int ast_channel_masquerade(struct ast_channel *original, struct ast_channel *clone)
@@ -2845,7 +2833,7 @@
 /* Assumes channel will be locked when called */
 int ast_do_masquerade(struct ast_channel *original)
 {
-	int x,i;
+	int i,x;
 	int res=0;
 	int origstate;
 	struct ast_frame *cur, *prev;
@@ -2853,8 +2841,9 @@
 	void *t_pvt;
 	struct ast_callerid tmpcid;
 	struct ast_channel *clone = original->masq;
-	int rformat = original->readformat;
-	int wformat = original->writeformat;
+	ast_coremedia_t *rformat = original->readformat;
+	ast_coremedia_t *wformat = original->writeformat;
+	ast_coremedia_t *y = NULL;
 	char newn[100];
 	char orig[100];
 	char masqn[100];
@@ -2923,12 +2912,12 @@
 	}
 
 	/* Swap the raw formats */
-	x = original->rawreadformat;
+	y = original->rawreadformat;
 	original->rawreadformat = clone->rawreadformat;
-	clone->rawreadformat = x;
-	x = original->rawwriteformat;
+	clone->rawreadformat = y;
+	y = original->rawwriteformat;
 	original->rawwriteformat = clone->rawwriteformat;
-	clone->rawwriteformat = x;
+	clone->rawwriteformat = y;
 
 	/* Save any pending frames on both sides.  Start by counting
 	 * how many we're going to need... */
@@ -3019,21 +3008,21 @@
 	original->fds[AST_MAX_FDS - 2] = original->timingfd;
 	
 	/* Our native formats are different now */
-	original->nativeformats = clone->nativeformats;
+	original->nativeformat = clone->nativeformat;
 	
 	/* Context, extension, priority, app data, jump table,  remain the same */
 	/* pvt switches.  pbx stays the same, as does next */
 	
 	/* Set the write format */
-	ast_set_write_format(original, wformat);
+	ast_set_write_format_cm(original, wformat);
 
 	/* Set the read format */
-	ast_set_read_format(original, rformat);
+	ast_set_read_format_cm(original, rformat);
 
 	/* Copy the music class */
 	ast_copy_string(original->musicclass, clone->musicclass, sizeof(original->musicclass));
 
-	ast_log(LOG_DEBUG, "Putting channel %s in %d/%d formats\n", original->name, wformat, rformat);
+	//	ast_log(LOG_DEBUG, "Putting channel %s in %d/%d formats\n", original->name, wformat, rformat);
 
 	/* Okay.  Last thing is to let the channel driver know about all this mess, so he
 	   can fix up everything as best as possible */
@@ -3205,8 +3194,8 @@
 	struct ast_frame *f;
 	struct ast_channel *who = NULL;
 	enum ast_bridge_result res = AST_BRIDGE_COMPLETE;
-	int o0nativeformats;
-	int o1nativeformats;
+	ast_coremedia_t *o0nativeformat;
+	ast_coremedia_t *o1nativeformat;
 	int watch_c0_dtmf;
 	int watch_c1_dtmf;
 	void *pvt0, *pvt1;
@@ -3215,15 +3204,15 @@
 	cs[1] = c1;
 	pvt0 = c0->tech_pvt;
 	pvt1 = c1->tech_pvt;
-	o0nativeformats = c0->nativeformats;
-	o1nativeformats = c1->nativeformats;
+	o0nativeformat = c0->nativeformat;
+	o1nativeformat = c1->nativeformat;
 	watch_c0_dtmf = config->flags & AST_BRIDGE_DTMF_CHANNEL_0;
 	watch_c1_dtmf = config->flags & AST_BRIDGE_DTMF_CHANNEL_1;
 
 	for (;;) {
 		if ((c0->tech_pvt != pvt0) || (c1->tech_pvt != pvt1) ||
-		    (o0nativeformats != c0->nativeformats) ||
-		    (o1nativeformats != c1->nativeformats)) {
+		    (o0nativeformat != c0->nativeformat) ||
+		    (o1nativeformat != c1->nativeformat)) {
 			/* Check for Masquerade, codec changes, etc */
 			res = AST_BRIDGE_RETRY;
 			break;
@@ -3312,8 +3301,8 @@
 	enum ast_bridge_result res = AST_BRIDGE_COMPLETE;
 	int nativefailed=0;
 	int firstpass;
-	int o0nativeformats;
-	int o1nativeformats;
+	ast_coremedia_t *o0nativeformat;
+	ast_coremedia_t *o1nativeformat;
 	long time_left_ms=0;
 	struct timeval nexteventts = { 0, };
 	char caller_warning = 0;
@@ -3367,8 +3356,8 @@
 		      "CallerID2: %s\r\n",
 		      c0->name, c1->name, c0->uniqueid, c1->uniqueid, c0->cid.cid_num, c1->cid.cid_num);
                                                                         
-	o0nativeformats = c0->nativeformats;
-	o1nativeformats = c1->nativeformats;
+	o0nativeformat = c0->nativeformat;
+	o1nativeformat = c1->nativeformat;
 
 	if (config->timelimit) {

[... 1867 lines stripped ...]


More information about the asterisk-commits mailing list