[svn-commits] oej: branch oej/astum r48486 - in /team/oej/astum: ./ apps/ build_tools/ chan...

svn-commits at lists.digium.com svn-commits at lists.digium.com
Fri Dec 15 03:54:41 MST 2006


Author: oej
Date: Fri Dec 15 04:54:40 2006
New Revision: 48486

URL: http://svn.digium.com/view/asterisk?view=rev&rev=48486
Log:
Update to trunk

Modified:
    team/oej/astum/   (props changed)
    team/oej/astum/apps/app_externalivr.c
    team/oej/astum/apps/app_voicemail.c
    team/oej/astum/build_tools/prep_tarball
    team/oej/astum/channels/chan_iax2.c
    team/oej/astum/channels/chan_sip.c
    team/oej/astum/codecs/codec_zap.c
    team/oej/astum/include/asterisk/app.h
    team/oej/astum/include/asterisk/channel.h
    team/oej/astum/include/asterisk/lock.h
    team/oej/astum/include/asterisk/pbx.h
    team/oej/astum/include/asterisk/rtp.h
    team/oej/astum/main/app.c
    team/oej/astum/main/channel.c
    team/oej/astum/main/cli.c
    team/oej/astum/main/manager.c
    team/oej/astum/main/pbx.c
    team/oej/astum/main/rtp.c
    team/oej/astum/sounds/Makefile

Propchange: team/oej/astum/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/oej/astum/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Fri Dec 15 04:54:40 2006
@@ -1,1 +1,1 @@
-/trunk:1-48384
+/trunk:1-48482

Modified: team/oej/astum/apps/app_externalivr.c
URL: http://svn.digium.com/view/asterisk/team/oej/astum/apps/app_externalivr.c?view=diff&rev=48486&r1=48485&r2=48486
==============================================================================
--- team/oej/astum/apps/app_externalivr.c (original)
+++ team/oej/astum/apps/app_externalivr.c Fri Dec 15 04:54:40 2006
@@ -154,7 +154,7 @@
 		if (state->current) {
 			file_to_stream = state->current->filename;
 		} else {
-			file_to_stream = "silence-10";
+			file_to_stream = "silence/10";
 			u->playing_silence = 1;
 		}
 

Modified: team/oej/astum/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/oej/astum/apps/app_voicemail.c?view=diff&rev=48486&r1=48485&r2=48486
==============================================================================
--- team/oej/astum/apps/app_voicemail.c (original)
+++ team/oej/astum/apps/app_voicemail.c Fri Dec 15 04:54:40 2006
@@ -2428,7 +2428,7 @@
 		ast_log(LOG_WARNING, "Unable to store '%s' (can't create temporary file)\n", fn);
 		return -1;
 	} else {
-		make_email_file(p, myserveremail, vmu, msgnum, vmu->context, vmu->mailbox, chan->cid.cid_num, chan->cid.cid_name, fn, fmt, duration, 1, chan, NULL, 1);
+		make_email_file(p, myserveremail, vmu, msgnum, vmu->context, vmu->mailbox, S_OR(chan->cid.cid_num, NULL), S_OR(chan->cid.cid_name, NULL), fn, fmt, duration, 1, chan, NULL, 1);
 		/* read mail file to memory */		
 		len = ftell(p);
 		rewind(p);
@@ -2658,7 +2658,7 @@
 		ast_log(LOG_ERROR, "Recipient mailbox %s@%s is full\n", recip->mailbox, recip->context);
 	}
 	ast_unlock_path(todir);
-	notify_new_message(chan, recip, recipmsgnum, duration, fmt, chan->cid.cid_num, chan->cid.cid_name);
+	notify_new_message(chan, recip, recipmsgnum, duration, fmt, S_OR(chan->cid.cid_num, NULL), S_OR(chan->cid.cid_name, NULL));
 	
 	return 0;
 }
@@ -3080,7 +3080,7 @@
 				chan->exten,
 				chan->priority,
 				chan->name,
-				ast_callerid_merge(callerid, sizeof(callerid), chan->cid.cid_name, chan->cid.cid_num, "Unknown"),
+				ast_callerid_merge(callerid, sizeof(callerid), S_OR(chan->cid.cid_name, NULL), S_OR(chan->cid.cid_num, NULL), "Unknown"),
 				date, (long)time(NULL),
 				category ? category : ""); 
 		} else
@@ -3142,7 +3142,7 @@
 #endif
 					if (ast_fileexists(fn, NULL, NULL)) {
 						STORE(dir, vmu->mailbox, vmu->context, msgnum, chan, vmu, fmt, duration, vms);
-						notify_new_message(chan, vmu, msgnum, duration, fmt, chan->cid.cid_num, chan->cid.cid_name);
+						notify_new_message(chan, vmu, msgnum, duration, fmt, S_OR(chan->cid.cid_num, NULL), S_OR(chan->cid.cid_name, NULL));
 						DISPOSE(dir, msgnum);
 					}
 				}
@@ -4129,13 +4129,14 @@
  
 				STORE(todir, vmtmp->mailbox, vmtmp->context, vms->curmsg, chan, vmtmp, fmt, duration, vms);
 
- 				char *myserveremail = serveremail;
- 				if (!ast_strlen_zero(vmtmp->serveremail))
- 					myserveremail = vmtmp->serveremail;
- 				int attach_user_voicemail = ast_test_flag((&globalflags), VM_ATTACH);
- 				attach_user_voicemail = ast_test_flag(vmtmp, VM_ATTACH);
- 				/* NULL category for IMAP storage */
- 				sendmail(myserveremail, vmtmp, todircount, vmtmp->context, vmtmp->mailbox, chan->cid.cid_num, chan->cid.cid_name, vms->fn, fmt, duration, attach_user_voicemail, chan, NULL);
+				char *myserveremail = serveremail;
+				if (!ast_strlen_zero(vmtmp->serveremail))
+					myserveremail = vmtmp->serveremail;
+				int attach_user_voicemail = ast_test_flag((&globalflags), VM_ATTACH);
+				attach_user_voicemail = ast_test_flag(vmtmp, VM_ATTACH);
+				/* NULL category for IMAP storage */
+				sendmail(myserveremail, vmtmp, todircount, vmtmp->context, vmtmp->mailbox, S_OR(chan->cid.cid_num, NULL), S_OR(chan->cid.cid_name, NULL), vms->fn, fmt, duration, attach_user_voicemail, chan, NULL);
+
 #else
 				copy_message(chan, sender, 0, curmsg, duration, vmtmp, fmt);
 #endif

Modified: team/oej/astum/build_tools/prep_tarball
URL: http://svn.digium.com/view/asterisk/team/oej/astum/build_tools/prep_tarball?view=diff&rev=48486&r1=48485&r2=48486
==============================================================================
--- team/oej/astum/build_tools/prep_tarball (original)
+++ team/oej/astum/build_tools/prep_tarball Fri Dec 15 04:54:40 2006
@@ -5,4 +5,4 @@
 #
 # It will be executed from the top-level directory of the project.
 
-make -C sounds all MENUSELECT_CORE_SOUNDS=CORE-SOUNDS-EN-GSM MENUSELECT_MOH=MOH-FREEPLAY-WAV
+make -C sounds all MENUSELECT_CORE_SOUNDS=CORE-SOUNDS-EN-GSM MENUSELECT_MOH=MOH-FREEPLAY-WAV WGET=wget

Modified: team/oej/astum/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/oej/astum/channels/chan_iax2.c?view=diff&rev=48486&r1=48485&r2=48486
==============================================================================
--- team/oej/astum/channels/chan_iax2.c (original)
+++ team/oej/astum/channels/chan_iax2.c Fri Dec 15 04:54:40 2006
@@ -8098,7 +8098,7 @@
 {
 	/* Our job is simple: Send queued messages, retrying if necessary.  Read frames 
 	   from the network, and queue them for delivery to the channels */
-	int res, count;
+	int res, count, wakeup;
 	struct iax_frame *f;
 
 	if (timingfd > -1)
@@ -8109,13 +8109,16 @@
 		   sent, and scheduling retransmissions if appropriate */
 		AST_LIST_LOCK(&iaxq.queue);
 		count = 0;
+		wakeup = -1;
 		AST_LIST_TRAVERSE_SAFE_BEGIN(&iaxq.queue, f, list) {
 			if (f->sentyet)
 				continue;
 			
 			/* Try to lock the pvt, if we can't... don't fret - defer it till later */
-			if (ast_mutex_trylock(&iaxsl[f->callno]))
+			if (ast_mutex_trylock(&iaxsl[f->callno])) {
+				wakeup = 1;
 				continue;
+			}
 
 			f->sentyet++;
 
@@ -8146,7 +8149,7 @@
 			ast_log(LOG_DEBUG, "chan_iax2: Sent %d queued outbound frames all at once\n", count);
 
 		/* Now do the IO, and run scheduled tasks */
-		res = ast_io_wait(io, -1);
+		res = ast_io_wait(io, wakeup);
 		if (res >= 0) {
 			if (res >= 20 && option_debug)
 				ast_log(LOG_DEBUG, "chan_iax2: ast_io_wait ran %d I/Os all at once\n", res);

Modified: team/oej/astum/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/astum/channels/chan_sip.c?view=diff&rev=48486&r1=48485&r2=48486
==============================================================================
--- team/oej/astum/channels/chan_sip.c (original)
+++ team/oej/astum/channels/chan_sip.c Fri Dec 15 04:54:40 2006
@@ -811,7 +811,7 @@
 #define T38FAX_RATE_12000			(1 << 12)	/*!< 12000 bps t38FaxRate */
 #define T38FAX_RATE_14400			(1 << 13)	/*!< 14400 bps t38FaxRate */
 
-/*!< This is default: NO MMR and JBIG trancoding, NO fill bit removal, transferredTCF TCF, UDP FEC, Version 0 and 9600 max fax rate */
+/*!< This is default: NO MMR and JBIG transcoding, NO fill bit removal, transferredTCF TCF, UDP FEC, Version 0 and 9600 max fax rate */
 static int global_t38_capability = T38FAX_VERSION_0 | T38FAX_RATE_2400 | T38FAX_RATE_4800 | T38FAX_RATE_7200 | T38FAX_RATE_9600;
 
 #define sipdebug		ast_test_flag(&global_flags[1], SIP_PAGE2_DEBUG)
@@ -841,7 +841,7 @@
 enum referstatus {
         REFER_IDLE,                    /*!< No REFER is in progress */
         REFER_SENT,                    /*!< Sent REFER to transferee */
-        REFER_RECEIVED,                /*!< Received REFER from transferer */
+        REFER_RECEIVED,                /*!< Received REFER from transferrer */
         REFER_CONFIRMED,               /*!< Refer confirmed with a 100 TRYING */
         REFER_ACCEPTED,                /*!< Accepted by transferee */
         REFER_RINGING,                 /*!< Target Ringing */
@@ -1159,7 +1159,7 @@
 	int refresh;			/*!< How often to refresh */
 	struct sip_pvt *call;		/*!< create a sip_pvt structure for each outbound "registration dialog" in progress */
 	enum sipregistrystate regstate;	/*!< Registration state (see above) */
-	time_t regtime;		/*!< Last succesful registration time */
+	time_t regtime;		/*!< Last successful registration time */
 	int callid_valid;		/*!< 0 means we haven't chosen callid for this registry yet. */
 	unsigned int ocseq;		/*!< Sequence number we got to for REGISTERs for this registry */
 	struct sockaddr_in us;		/*!< Who the server thinks we are */
@@ -1179,7 +1179,7 @@
 	ASTOBJ_CONTAINER_COMPONENTS(struct sip_peer);
 } peerl;
 
-/*! \brief  The register list: Other SIP proxys we register with and place calls to */
+/*! \brief  The register list: Other SIP proxies we register with and place calls to */
 static struct ast_register_list {
 	ASTOBJ_CONTAINER_COMPONENTS(struct sip_registry);
 	int recheck;
@@ -2872,7 +2872,7 @@
 	struct sip_pvt *p;
 	struct varshead *headp;
 	struct ast_var_t *current;
-	const char *referer = NULL;   /* SIP refererer */	
+	const char *referer = NULL;   /* SIP referrer */	
 
 	p = ast->tech_pvt;
 	if ((ast->_state != AST_STATE_DOWN) && (ast->_state != AST_STATE_RESERVED)) {
@@ -2895,7 +2895,7 @@
 			/* This is a transfered call */
 			p->options->transfer = 1;
 		} else if (!strcasecmp(ast_var_name(current), "SIPTRANSFER_REFERER")) {
-			/* This is the referer */
+			/* This is the referrer */
 			referer = ast_var_value(current);
 		} else if (!strcasecmp(ast_var_name(current), "SIPTRANSFER_REPLACES")) {
 			/* We're replacing a call. */
@@ -3082,9 +3082,9 @@
  * This will cause unexpected behaviour in subscriptions, since a "friend"
  * is *two* devices in Asterisk, not one.
  *
- * Thought: For realtime, we should propably update storage with inuse counter... 
+ * Thought: For realtime, we should probably update storage with inuse counter... 
  *
- * \return 0 if call is ok (no call limit, below treshold)
+ * \return 0 if call is ok (no call limit, below threshold)
  *	-1 on rejection of call
  *		
  */
@@ -3244,7 +3244,7 @@
 			return AST_CAUSE_NO_ANSWER;
 		case 484:	/* Address incomplete */
 			return AST_CAUSE_INVALID_NUMBER_FORMAT;
-		case 485:	/* Ambigous */
+		case 485:	/* Ambiguous */
 			return AST_CAUSE_UNALLOCATED;
 		case 486:	/* Busy everywhere */
 			return AST_CAUSE_BUSY;

Modified: team/oej/astum/codecs/codec_zap.c
URL: http://svn.digium.com/view/asterisk/team/oej/astum/codecs/codec_zap.c?view=diff&rev=48486&r1=48485&r2=48486
==============================================================================
--- team/oej/astum/codecs/codec_zap.c (original)
+++ team/oej/astum/codecs/codec_zap.c Fri Dec 15 04:54:40 2006
@@ -50,6 +50,7 @@
 #include "asterisk/config.h"
 #include "asterisk/options.h"
 #include "asterisk/module.h"
+#include "asterisk/cli.h"
 #include "asterisk/logger.h"
 #include "asterisk/channel.h"
 #include "asterisk/utils.h"
@@ -60,6 +61,24 @@
 static unsigned int global_useplc = 0;
 static int cardsmode = 0;
 
+static int totalchannels = 0;
+static int complexinuse = 0;
+static int simpleinuse = 0;
+AST_MUTEX_DEFINE_STATIC(channelcount);
+
+
+static const char show_transcoder_usage[] =
+"Usage: show transcoder\n"
+"       Displays transcoder utilization.\n";
+
+static int show_transcoder(int fd, int argc, char *argv[]);
+
+static struct ast_cli_entry transcoder_cli[] = {
+	{ { "show", "transcoder", NULL},
+	show_transcoder, "Displays transcoder utilization.",
+	show_transcoder_usage }
+};
+
 struct format_map {
 	unsigned int map[32][32];
 };
@@ -71,11 +90,12 @@
 	AST_LIST_ENTRY(translator) entry;
 };
 
-static AST_LIST_HEAD_STATIC(translators, translator);
+static AST_LIST_HEAD_STATIC(zap_translators, translator);
 
 struct pvt {
 	int fd;
 	int fake;
+	int inuse;
 #ifdef DEBUG_TRANSCODE
 	int totalms;
 	int lasttotalms;
@@ -84,6 +104,29 @@
 	struct ast_frame f;
 };
 
+static void activate_translator(int simple);
+static void deactivate_translator(int simple);
+
+
+static int show_transcoder(int fd, int argc, char *argv[])
+{
+	ast_mutex_lock(&channelcount);
+	if (!totalchannels) { 
+		ast_verbose("No transcoder card registered\n");
+		ast_mutex_unlock(&channelcount);
+		return RESULT_SUCCESS;
+	}
+	if(!cardsmode)             
+		ast_verbose("%d/%d encoders/decoders of %d channels (G.729a / G.723.1 5.3 kbps) are in use.\n",complexinuse, simpleinuse, totalchannels);
+	else if (cardsmode == 1)
+		ast_verbose("%d/%d encoders/decoders of %d channels (G.729a) are in use.\n",complexinuse, simpleinuse, totalchannels);
+	else if (cardsmode == 2)
+		ast_verbose("%d/%d encoders/decoders of %d channels (G.723.1 5.3 kbps) are in use.\n",complexinuse, simpleinuse, totalchannels);
+
+	ast_mutex_unlock(&channelcount);
+	return RESULT_SUCCESS;
+}
+
 static int zap_framein(struct ast_trans_pvt *pvt, struct ast_frame *f)
 {
 	struct pvt *ztp = pvt->pvt;
@@ -95,7 +138,20 @@
 		pvt->samples = f->samples;
 		return 0;
 	}
-
+	if(!ztp->inuse) {
+		ast_mutex_lock(&channelcount);
+		if(pvt->t->dstfmt == 8 || pvt->t->dstfmt == 0 ) {
+			complexinuse++;
+			if(complexinuse == totalchannels)
+				deactivate_translator(0);
+		} else {
+			simpleinuse++;
+			if(simpleinuse == totalchannels)
+				deactivate_translator(1);
+		}
+		ast_mutex_unlock(&channelcount);
+		ztp->inuse = 1;
+	}
 	if (!hdr->srclen)
 		/* Copy at front of buffer */
 		hdr->srcoffset = 0;
@@ -128,7 +184,7 @@
 		ztp->fake = 1;
 		ztp->f.frametype = AST_FRAME_VOICE;
 		ztp->f.subclass = 0;
-		ztp->f.samples = (hdr->srcfmt == ZT_FORMAT_G729A || hdr->dstfmt == ZT_FORMAT_G729A) ? 160: 240;
+		ztp->f.samples = 240;
 		ztp->f.data = NULL;
 		ztp->f.offset = 0;
 		ztp->f.datalen = 0;
@@ -141,7 +197,7 @@
 #ifdef DEBUG_TRANSCODE
 			ztp->totalms += hdr->dstsamples;
 			if ((ztp->totalms - ztp->lasttotalms) > 8000) {
-				printf("Whee %p, %d (%d to %d)\n", ztp, hdr->dstlen, ztp->lasttotalms, ztp->totalms);
+				ast_verbose("Whee %p, %d (%d to %d)\n", ztp, hdr->dstlen, ztp->lasttotalms, ztp->totalms);
 				ztp->lasttotalms = ztp->totalms;
 			}
 #endif
@@ -172,8 +228,26 @@
 static void zap_destroy(struct ast_trans_pvt *pvt)
 {
 	struct pvt *ztp = pvt->pvt;
-
+	unsigned int x;
+
+	x = ZT_TCOP_RELEASE;
+	if (ioctl(ztp->fd, ZT_TRANSCODE_OP, &x))
+		ast_log(LOG_WARNING, "Failed to release transcoder channel: %s\n", strerror(errno));
+				
 	munmap(ztp->hdr, sizeof(*ztp->hdr));
+	if(ztp->inuse) {
+		ast_mutex_lock(&channelcount);
+		if(pvt->t->dstfmt == 8 || pvt->t->dstfmt == 0) {
+			if(complexinuse == totalchannels)
+				activate_translator(0);
+			complexinuse--;
+		} else {
+			if(simpleinuse == totalchannels)
+				activate_translator(1);
+			simpleinuse--;
+		}
+		ast_mutex_unlock(&channelcount);
+	}
 	close(ztp->fd);
 }
 
@@ -232,19 +306,7 @@
 	return zap_translate(pvt, pvt->t->dstfmt, pvt->t->srcfmt);
 }
 
-static struct ast_frame *g729_fakesrc_sample(void)
-{
-	/* Don't bother really trying to test hardware ones. */
-	static struct ast_frame f = {
-		.frametype = AST_FRAME_VOICE,
-		.samples = 160,
-		.src = __PRETTY_FUNCTION__
-	};
-
-	return &f;
-}
-
-static struct ast_frame *g723_fakesrc_sample(void)
+static struct ast_frame *fakesrc_sample(void)
 {
 	/* Don't bother really trying to test hardware ones. */
 	static struct ast_frame f = {
@@ -260,71 +322,111 @@
 {
 	struct translator *zt;
 	int res;
-	
-	if (!((cardsmode  == 1 && (dst == 8 || src == 8)) || (cardsmode == 2 && (dst == 0 || src == 0)) || (cardsmode == 0))) {
-		return -1;
-	}
-		if (!(zt = ast_calloc(1, sizeof(*zt))))
-			return -1;
-	
-		snprintf((char *) (zt->t.name), sizeof(zt->t.name), "zap%sto%s", 
-			 ast_getformatname((1 << src)), ast_getformatname((1 << dst)));
-		zt->t.srcfmt = (1 << src);
-		zt->t.dstfmt = (1 << dst);
-		zt->t.newpvt = zap_new;
-		zt->t.framein = zap_framein;
-		zt->t.frameout = zap_frameout;
-		zt->t.destroy = zap_destroy;
-		zt->t.sample = (dst == 8 || src == 8) ? g729_fakesrc_sample : g723_fakesrc_sample;
-		zt->t.useplc = global_useplc;
-		zt->t.buf_size = BUFFER_SAMPLES * 2;
-		zt->t.desc_size = sizeof(struct pvt);
-		if ((res = ast_register_translator(&zt->t))) {
-			free(zt);
-			return -1;
-		}
-	
-		AST_LIST_LOCK(&translators);
-		AST_LIST_INSERT_HEAD(&translators, zt, entry);
-		AST_LIST_UNLOCK(&translators);
-	
-		global_format_map.map[dst][src] = 1;
-	
-		return res;
+
+	if (!(zt = ast_calloc(1, sizeof(*zt))))
+		return -1;
+	if (!((cardsmode  == 1 && (dst == 8 || src == 8)) || (cardsmode == 2 && (dst == 0 || src == 0)) || (cardsmode == 0)))
+		return -1;
+	snprintf((char *) (zt->t.name), sizeof(zt->t.name), "zap%sto%s", 
+		 ast_getformatname((1 << src)), ast_getformatname((1 << dst)));
+	zt->t.srcfmt = (1 << src);
+	zt->t.dstfmt = (1 << dst);
+	zt->t.newpvt = zap_new;
+	zt->t.framein = zap_framein;
+	zt->t.frameout = zap_frameout;
+	zt->t.destroy = zap_destroy;
+	zt->t.sample = fakesrc_sample;
+	zt->t.useplc = global_useplc;
+	zt->t.buf_size = BUFFER_SAMPLES * 2;
+	zt->t.desc_size = sizeof(struct pvt);
+	if ((res = ast_register_translator(&zt->t))) {
+		free(zt);
+		return -1;
+	}
+
+	AST_LIST_LOCK(&zap_translators);
+	AST_LIST_INSERT_HEAD(&zap_translators, zt, entry);
+	AST_LIST_UNLOCK(&zap_translators);
+
+	global_format_map.map[dst][src] = 1;
+
+	return res;
 }
 
 static void drop_translator(int dst, int src)
 {
 	struct translator *cur;
 
-	AST_LIST_LOCK(&translators);
-	AST_LIST_TRAVERSE_SAFE_BEGIN(&translators, cur, entry) {
+	AST_LIST_LOCK(&zap_translators);
+	AST_LIST_TRAVERSE_SAFE_BEGIN(&zap_translators, cur, entry) {
 		if (cur->t.srcfmt != src)
 			continue;
 
 		if (cur->t.dstfmt != dst)
 			continue;
 
-		AST_LIST_REMOVE_CURRENT(&translators, entry);
+		AST_LIST_REMOVE_CURRENT(&zap_translators, entry);
 		ast_unregister_translator(&cur->t);
 		free(cur);
 		global_format_map.map[dst][src] = 0;
 		break;
 	}
 	AST_LIST_TRAVERSE_SAFE_END;
-	AST_LIST_UNLOCK(&translators);
+	AST_LIST_UNLOCK(&zap_translators);
 }
 
 static void unregister_translators(void)
 {
 	struct translator *cur;
 
-	AST_LIST_LOCK(&translators);
-	while ((cur = AST_LIST_REMOVE_HEAD(&translators, entry))) {
+	AST_LIST_LOCK(&zap_translators);
+	while ((cur = AST_LIST_REMOVE_HEAD(&zap_translators, entry))) {
 		ast_unregister_translator(&cur->t);
 		free(cur);
 	}
-	AST_LIST_UNLOCK(&translators);
+	AST_LIST_UNLOCK(&zap_translators);
+}
+
+
+static void activate_translator(int simple)
+{
+	struct translator *cur;
+
+	AST_LIST_LOCK(&zap_translators);
+	AST_LIST_TRAVERSE_SAFE_BEGIN(&zap_translators, cur, entry) {
+		if(!simple) {
+			if (cur->t.dstfmt == 0 || cur->t.dstfmt == 8) {
+				ast_translator_activate(&cur->t);
+			}
+		} else {
+			if(cur->t.dstfmt == 2 || cur->t.dstfmt == 3) {
+				ast_translator_activate(&cur->t);
+			}
+		}
+	}
+	AST_LIST_TRAVERSE_SAFE_END;
+	AST_LIST_UNLOCK(&zap_translators);
+}
+
+
+static void deactivate_translator(int simple)
+{
+	struct translator *cur;
+
+	AST_LIST_LOCK(&zap_translators);
+	AST_LIST_TRAVERSE_SAFE_BEGIN(&zap_translators, cur, entry) {
+		if(!simple) {
+			if (cur->t.dstfmt == 0 || cur->t.dstfmt == 8) {
+				ast_translator_deactivate(&cur->t);
+			}
+		} else {
+			if(cur->t.dstfmt == 2 || cur->t.dstfmt == 3) {
+				ast_translator_deactivate(&cur->t);
+			}
+		}
+	}
+	AST_LIST_TRAVERSE_SAFE_END;
+	AST_LIST_UNLOCK(&zap_translators);
 }
 
 static void parse_config(void)
@@ -358,7 +460,7 @@
 	ast_config_destroy(cfg);
 }
 
-static void build_translators(struct format_map *map, unsigned int dstfmts, unsigned int srcfmts)
+static int build_translators(struct format_map *map, unsigned int dstfmts, unsigned int srcfmts)
 {
 	unsigned int src, dst;
 
@@ -375,8 +477,11 @@
 
 			if (!register_translator(dst, src))
 				map->map[dst][src] = 1;
-		}
-	}
+			else
+				return 0;
+		}
+	}
+	return 1;
 }
 
 static int find_transcoders(void)
@@ -394,7 +499,12 @@
 	for (info.tcnum = 0; !(res = ioctl(fd, ZT_TRANSCODE_OP, &info)); info.tcnum++) {
 		if (option_verbose > 1)
 			ast_verbose(VERBOSE_PREFIX_2 "Found transcoder '%s'.\n", info.name);
-		build_translators(&map, info.dstfmts, info.srcfmts);
+
+		if(build_translators(&map, info.dstfmts, info.srcfmts)) {
+			ast_mutex_lock(&channelcount);
+			totalchannels += info.numchannels;
+			ast_mutex_unlock(&channelcount);
+		}
 	}
 	close(fd);
 
@@ -407,7 +517,9 @@
 				drop_translator(x, y);
 		}
 	}
-
+	ast_mutex_lock(&channelcount);
+	totalchannels = totalchannels/2;
+	ast_mutex_unlock(&channelcount);
 	return 0;
 }
 
@@ -418,10 +530,10 @@
 	parse_config();
 	find_transcoders();
 
-	AST_LIST_LOCK(&translators);
-	AST_LIST_TRAVERSE(&translators, cur, entry)
+	AST_LIST_LOCK(&zap_translators);
+	AST_LIST_TRAVERSE(&zap_translators, cur, entry)
 		cur->t.useplc = global_useplc;
-	AST_LIST_UNLOCK(&translators);
+	AST_LIST_UNLOCK(&zap_translators);
 
 	return 0;
 }
@@ -429,15 +541,17 @@
 static int unload_module(void)
 {
 	unregister_translators();
-
+	ast_cli_unregister_multiple(transcoder_cli, sizeof(transcoder_cli) / sizeof(struct ast_cli_entry));
 	return 0;
 }
 
 static int load_module(void)
 {
+	ast_mutex_init(&channelcount);
 	parse_config();
+
 	find_transcoders();
-
+	ast_cli_register_multiple(transcoder_cli, sizeof(transcoder_cli) / sizeof(struct ast_cli_entry));
 	return 0;
 }
 

Modified: team/oej/astum/include/asterisk/app.h
URL: http://svn.digium.com/view/asterisk/team/oej/astum/include/asterisk/app.h?view=diff&rev=48486&r1=48485&r2=48486
==============================================================================
--- team/oej/astum/include/asterisk/app.h (original)
+++ team/oej/astum/include/asterisk/app.h Fri Dec 15 04:54:40 2006
@@ -127,7 +127,7 @@
  * Normally, Asterisk has a SIGCHLD handler that is cleaning up all zombie
  * processes from forking elsewhere in Asterisk.  However, if you want to
  * wait*() on the process to retrieve information about it's exit status,
- * then this signal handler needs to be temporaraly replaced.
+ * then this signal handler needs to be temporarily replaced.
  *
  * Code that executes this function *must* call ast_unreplace_sigchld()
  * after it is finished doing the wait*().

Modified: team/oej/astum/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/team/oej/astum/include/asterisk/channel.h?view=diff&rev=48486&r1=48485&r2=48486
==============================================================================
--- team/oej/astum/include/asterisk/channel.h (original)
+++ team/oej/astum/include/asterisk/channel.h Fri Dec 15 04:54:40 2006
@@ -91,7 +91,7 @@
 	The Core bridge handles two channels (a "phone call") and bridge
 	them together.
 	
-	The conference bridge (meetme) handles several channels simultaneosly
+	The conference bridge (meetme) handles several channels simultaneously
 	with the support of an external timer (zaptel timer). This is used
 	not only by the Conference application (meetme) but also by the
 	page application and the SLA system introduced in 1.4.
@@ -543,17 +543,6 @@
 
 struct chanmon;
 
-#define LOAD_OH(oh) {	\
-	oh.context = context; \
-	oh.exten = exten; \
-	oh.priority = priority; \
-	oh.cid_num = cid_num; \
-	oh.cid_name = cid_name; \
-	oh.account = account; \
-	oh.vars = vars; \
-	oh.parent_channel = NULL; \
-} 
-
 struct outgoing_helper {
 	const char *context;
 	const char *exten;
@@ -679,7 +668,7 @@
  * \param format requested channel format
  * \param data data to pass to the channel requester
  * \param timeout maximum amount of time to wait for an answer
- * \param reason why unsuccessful (if unsuceessful)
+ * \param reason why unsuccessful (if unsuccessful)
  * \param cidnum Caller-ID Number
  * \param cidname Caller-ID Name
  * \return Returns an ast_channel on success or no answer, NULL on failure.  Check the value of chan->_state
@@ -745,7 +734,7 @@
  * This function compares a offset from current time with the absolute time 
  * out on a channel (when to hang up). If the absolute time out on a channel
  * is earlier than current time plus the offset, it returns 1, if the two
- * time values are equal, it return 0, otherwise, it retturn -1.
+ * time values are equal, it return 0, otherwise, it return -1.
  */
 int ast_channel_cmpwhentohangup(struct ast_channel *chan, time_t offset);
 
@@ -802,7 +791,7 @@
   \return Returns < 0 on  failure, 0 if nothing ever arrived, and the # of ms remaining otherwise */
 int ast_waitfor(struct ast_channel *chan, int ms);
 
-/*! \brief Wait for a specied amount of time, looking for hangups 
+/*! \brief Wait for a specified amount of time, looking for hangups 
  * \param chan channel to wait for
  * \param ms length of time in milliseconds to sleep
  * Waits for a specified amount of time, servicing the channel as required.
@@ -810,7 +799,7 @@
  */
 int ast_safe_sleep(struct ast_channel *chan, int ms);
 
-/*! \brief Wait for a specied amount of time, looking for hangups and a condition argument 
+/*! \brief Wait for a specified amount of time, looking for hangups and a condition argument 
  * \param chan channel to wait for
  * \param ms length of time in milliseconds to sleep
  * \param cond a function pointer for testing continue condition
@@ -893,7 +882,7 @@
 int ast_set_read_format(struct ast_channel *chan, int format);
 
 /*! \brief Sets write format on channel chan
- * Set write format for channel to whichever compoent of "format" is best. 
+ * Set write format for channel to whichever component of "format" is best. 
  * \param chan channel to change
  * \param format new format for writing
  * \return Returns 0 on success, -1 on failure
@@ -1071,14 +1060,14 @@
  * Give a name to a state 
  * Returns the text form of the binary state given
  */
-char *ast_state2str(enum ast_channel_state);
+const char *ast_state2str(enum ast_channel_state);
 
 /*! Gives the string form of a given transfer capability */
 /*!
  * \param transfercapability transfercapabilty to get the name of
  * Give a name to a transfercapbility
  * See above
- * Returns the text form of the binary transfer capbility
+ * Returns the text form of the binary transfer capbaility
  */
 char *ast_transfercapability2str(int transfercapability) attribute_const;
 
@@ -1129,7 +1118,6 @@
    being DTMF-deferred */
 int ast_channel_defer_dtmf(struct ast_channel *chan);
 
-/*! Undeos a defer */
 /*! Undo defer.  ast_read will return any dtmf characters that were queued */
 void ast_channel_undefer_dtmf(struct ast_channel *chan);
 
@@ -1150,7 +1138,7 @@
 /*! Activate a given generator */
 int ast_activate_generator(struct ast_channel *chan, struct ast_generator *gen, void *params);
 
-/*! Deactive an active generator */
+/*! Deactivate an active generator */
 void ast_deactivate_generator(struct ast_channel *chan);
 
 void ast_set_callerid(struct ast_channel *chan, const char *cidnum, const char *cidname, const char *ani);
@@ -1196,7 +1184,7 @@
 int ast_transfer(struct ast_channel *chan, char *dest);
 
 /*!	\brief  Start masquerading a channel
-	XXX This is a seriously wacked out operation.  We're essentially putting the guts of
+	XXX This is a seriously whacked out operation.  We're essentially putting the guts of
            the clone channel into the original channel.  Start by killing off the original
            channel's backend.   I'm not sure we're going to keep this function, because
            while the features are nice, the cost is very high in terms of pure nastiness. XXX

Modified: team/oej/astum/include/asterisk/lock.h
URL: http://svn.digium.com/view/asterisk/team/oej/astum/include/asterisk/lock.h?view=diff&rev=48486&r1=48485&r2=48486
==============================================================================
--- team/oej/astum/include/asterisk/lock.h (original)
+++ team/oej/astum/include/asterisk/lock.h Fri Dec 15 04:54:40 2006
@@ -303,8 +303,11 @@
 			t->reentrancy++;
 		} else {
 			__ast_mutex_logger("%s line %d (%s): '%s' really deep reentrancy!\n",
-							   filename, lineno, func, mutex_name);
+					   filename, lineno, func, mutex_name);
 		}
+	} else {
+		__ast_mutex_logger("%s line %d (%s): Error: '%s' was locked here.\n",
+                                   t->file[t->reentrancy-1], t->lineno[t->reentrancy-1], t->func[t->reentrancy-1], mutex_name);
 	}
 
 	return res;

Modified: team/oej/astum/include/asterisk/pbx.h
URL: http://svn.digium.com/view/asterisk/team/oej/astum/include/asterisk/pbx.h?view=diff&rev=48486&r1=48485&r2=48486
==============================================================================
--- team/oej/astum/include/asterisk/pbx.h (original)
+++ team/oej/astum/include/asterisk/pbx.h Fri Dec 15 04:54:40 2006
@@ -156,7 +156,7 @@
  * \param data the data passed into the app
  *
  * This application executes an application on a given channel.  It
- * saves the stack and executes the given appliation passing in
+ * saves the stack and executes the given application passing in
  * the given data.
  *
  * \return 0 on success, and -1 on failure

Modified: team/oej/astum/include/asterisk/rtp.h
URL: http://svn.digium.com/view/asterisk/team/oej/astum/include/asterisk/rtp.h?view=diff&rev=48486&r1=48485&r2=48486
==============================================================================
--- team/oej/astum/include/asterisk/rtp.h (original)
+++ team/oej/astum/include/asterisk/rtp.h Fri Dec 15 04:54:40 2006
@@ -162,7 +162,7 @@
 void ast_rtp_pt_default(struct ast_rtp* rtp);
 
 /*! \brief Copy payload types between RTP structures */
-void ast_rtp_pt_copy(struct ast_rtp *dest, const struct ast_rtp *src);
+void ast_rtp_pt_copy(struct ast_rtp *dest, struct ast_rtp *src);
 
 void ast_rtp_set_m_type(struct ast_rtp* rtp, int pt);
 void ast_rtp_set_rtpmap_type(struct ast_rtp* rtp, int pt,

Modified: team/oej/astum/main/app.c
URL: http://svn.digium.com/view/asterisk/team/oej/astum/main/app.c?view=diff&rev=48486&r1=48485&r2=48486
==============================================================================
--- team/oej/astum/main/app.c (original)
+++ team/oej/astum/main/app.c Fri Dec 15 04:54:40 2006
@@ -115,14 +115,16 @@
 	if (maxlen)
 		s[0] = '\0';
 
-	if (ast_strlen_zero(prompt))
-		return -1;
+	if (!prompt)
+		prompt="";
 
 	filename = ast_strdupa(prompt);
 	while ((front = strsep(&filename, "&"))) {
-		res = ast_streamfile(c, front, c->language);
-		if (res)
-			continue;
+		if (!ast_strlen_zero(front)) {
+			res = ast_streamfile(c, front, c->language);
+			if (res)
+				continue;
+		}
 		if (ast_strlen_zero(filename)) {
 			/* set timeouts for the last prompt */
 			fto = c->pbx ? c->pbx->rtimeout * 1000 : 6000;

Modified: team/oej/astum/main/channel.c
URL: http://svn.digium.com/view/asterisk/team/oej/astum/main/channel.c?view=diff&rev=48486&r1=48485&r2=48486
==============================================================================
--- team/oej/astum/main/channel.c (original)
+++ team/oej/astum/main/channel.c Fri Dec 15 04:54:40 2006
@@ -516,8 +516,10 @@
 	return -1;
 }
 
-/*! \brief Gives the string form of a given channel state */
-char *ast_state2str(enum ast_channel_state state)
+/*! \brief Gives the string form of a given channel state.
+	\note This function is not reentrant.
+ */
+const char *ast_state2str(enum ast_channel_state state)
 {
 	char *buf;
 

Modified: team/oej/astum/main/cli.c
URL: http://svn.digium.com/view/asterisk/team/oej/astum/main/cli.c?view=diff&rev=48486&r1=48485&r2=48486
==============================================================================
--- team/oej/astum/main/cli.c (original)
+++ team/oej/astum/main/cli.c Fri Dec 15 04:54:40 2006
@@ -1598,12 +1598,16 @@
 	char *ret = NULL;
 	char matchstr[80] = "";
 	int tws = 0;
+	/* Split the argument into an array of words */
 	char *dup = parse_args(text, &x, argv, sizeof(argv) / sizeof(argv[0]), &tws);
 
 	if (!dup)	/* malloc error */
 		return NULL;
+
+	/* Compute the index of the last argument (could be an empty string) */
 	argindex = (!ast_strlen_zero(word) && x>0) ? x-1 : x;
-	/* rebuild the command, ignore tws */
+
+	/* rebuild the command, ignore terminating white space and flatten space */
 	ast_join(matchstr, sizeof(matchstr)-1, argv);
 	matchlen = strlen(matchstr);
 	if (tws) {
@@ -1616,7 +1620,12 @@
 	while ( (e = cli_next(&i)) ) {
 		/* XXX repeated code */
 		int src = 0, dst = 0, n = 0;
-		for (;; dst++, src += n) {
+
+		/*
+		 * Try to match words, up to and excluding the last word, which
+		 * is either a blank or something that we want to extend.
+		 */
+		for (;src < argindex; dst++, src += n) {
 			n = word_match(argv[src], e->cmda[dst]);
 			if (n < 0)
 				break;
@@ -1627,12 +1636,17 @@
 		ret = is_prefix(argv[src], e->cmda[dst], state - matchnum, &n);
 		matchnum += n;	/* this many matches here */
 		if (ret) {
+			/*
+			 * argv[src] is a valid prefix of the next word in this
+			 * command. If this is also the correct entry, return it.
+			 */
 			if (matchnum > state)
 				break;
 			free(ret);
 			ret = NULL;
 		} else if (ast_strlen_zero(e->cmda[dst])) {
-			/* This entry is a prefix of the command string entered
+			/*
+			 * This entry is a prefix of the command string entered
 			 * (only one entry in the list should have this property).
 			 * Run the generator if one is available. In any case we are done.
 			 */

Modified: team/oej/astum/main/manager.c
URL: http://svn.digium.com/view/asterisk/team/oej/astum/main/manager.c?view=diff&rev=48486&r1=48485&r2=48486
==============================================================================
--- team/oej/astum/main/manager.c (original)
+++ team/oej/astum/main/manager.c Fri Dec 15 04:54:40 2006
@@ -105,7 +105,6 @@
 
 static AST_LIST_HEAD_STATIC(all_events, eventqent);
 
-static int portno = DEFAULT_MANAGER_PORT;
 static int displayconnects = 1;
 static int timestampevents = 0;
 static int httptimeout = 60;
@@ -2599,11 +2598,12 @@
 		else if (strchr("&\"<>", in[x]))
 			escaped++;
 	}
-	len = (size_t) (strlen(in) + colons * 5 + breaks * (40 + strlen(dest) + strlen(objtype)) + escaped * 10); /* foo="bar", "<response type=\"object\" id=\"dest\"", "&amp;" */
+	len = (size_t) (1 + strlen(in) + colons * 5 + breaks * (40 + strlen(dest) + strlen(objtype)) + escaped * 10); /* foo="bar", "<response type=\"object\" id=\"dest\"", "&amp;" */
 	out = ast_malloc(len);
 	if (!out)
 		return NULL;
 	tmp = out;
+	*tmp = '\0';
 	/* we want to stop when we find an empty line */
 	while (in && *in) {
 		val = strsep(&in, "\r\n");	/* mark start and end of line */
@@ -2910,6 +2910,7 @@
 	struct hostent *hp;
 	struct ast_hostent ahp;
 	struct ast_manager_user *user = NULL;
+	struct ast_variable *var;
 
 	if (!registered) {
 		/* Register default actions */
@@ -2942,7 +2943,6 @@
 		/* Append placeholder event so master_eventq never runs dry */
 		append_event("Event: Placeholder\r\n\r\n", 0);
 	}
-	portno = DEFAULT_MANAGER_PORT;
 	displayconnects = 1;
 	cfg = ast_config_load("manager.conf");
 	if (!cfg) {
@@ -2951,8 +2951,10 @@
 	}
 
 	/* default values */
+	memset(&ami_desc.sin, 0, sizeof(struct sockaddr_in));
 	memset(&amis_desc.sin, 0, sizeof(amis_desc.sin));
 	amis_desc.sin.sin_port = htons(5039);
+	ami_desc.sin.sin_port = htons(DEFAULT_MANAGER_PORT);
 
 	ami_tls_cfg.enabled = 0;
 	if (ami_tls_cfg.certfile)
@@ -2962,71 +2964,54 @@
 		free(ami_tls_cfg.cipher);
 	ami_tls_cfg.cipher = ast_strdup("");
 
-	/* XXX change this into a loop on  ast_variable_browse(cfg, "general"); */
-
-	if ((val = ast_variable_retrieve(cfg, "general", "sslenable")))
-		ami_tls_cfg.enabled = ast_true(val);
-	if ((val = ast_variable_retrieve(cfg, "general", "sslbindport")))
-		amis_desc.sin.sin_port = htons(atoi(val));
-	if ((val = ast_variable_retrieve(cfg, "general", "sslbindaddr"))) {
-		if ((hp = ast_gethostbyname(val, &ahp))) {
-			memcpy(&amis_desc.sin.sin_addr, hp->h_addr, sizeof(amis_desc.sin.sin_addr));
-			have_sslbindaddr = 1;
+	for (var = ast_variable_browse(cfg, "general"); var; var = var->next) {
+		val = var->value;
+		if (!strcasecmp(var->name, "ssenable"))
+			ami_tls_cfg.enabled = ast_true(val);
+		else if (!strcasecmp(var->name, "ssbindport"))
+			amis_desc.sin.sin_port = htons(atoi(val));
+		else if (!strcasecmp(var->name, "ssbindaddr")) {
+			if ((hp = ast_gethostbyname(val, &ahp))) {
+				memcpy(&amis_desc.sin.sin_addr, hp->h_addr, sizeof(amis_desc.sin.sin_addr));
+				have_sslbindaddr = 1;
+			} else {
+				ast_log(LOG_WARNING, "Invalid bind address '%s'\n", val);
+			}
+		} else if (!strcasecmp(var->name, "sslcert")) {
+			free(ami_tls_cfg.certfile);
+			ami_tls_cfg.certfile = ast_strdup(val);
+		} else if (!strcasecmp(var->name, "sslcipher")) {
+			free(ami_tls_cfg.cipher);
+			ami_tls_cfg.cipher = ast_strdup(val);
+		} else if (!strcasecmp(var->name, "enabled")) {
+			enabled = ast_true(val);
+		} else if (!strcasecmp(var->name, "block-sockets")) {
+			block_sockets = ast_true(val);
+		} else if (!strcasecmp(var->name, "webenabled")) {
+			webenabled = ast_true(val);
+		} else if (!strcasecmp(var->name, "port")) {
+			ami_desc.sin.sin_port = htons(atoi(val));
+		} else if (!strcasecmp(var->name, "bindaddr")) {
+			if (!inet_aton(val, &ami_desc.sin.sin_addr)) {
+				ast_log(LOG_WARNING, "Invalid address '%s' specified, using 0.0.0.0\n", val);
+				memset(&ami_desc.sin.sin_addr, 0, sizeof(ami_desc.sin.sin_addr));
+			}
+		} else if (!strcasecmp(var->name, "displayconnects")) {
+			displayconnects = ast_true(val);
+		} else if (!strcasecmp(var->name, "timestampevents")) {
+			timestampevents = ast_true(val);
+		} else if (!strcasecmp(var->name, "debug")) {
+			manager_debug = ast_true(val);
+		} else if (!strcasecmp(var->name, "httptimeout")) {
+			newhttptimeout = atoi(val);
 		} else {
-			ast_log(LOG_WARNING, "Invalid bind address '%s'\n", val);
-		}
-	}
-	if ((val = ast_variable_retrieve(cfg, "general", "sslcert"))) {
-		free(ami_tls_cfg.certfile);
-		ami_tls_cfg.certfile = ast_strdup(val);
-	}
-	if ((val = ast_variable_retrieve(cfg, "general", "sslcipher"))) {
-		free(ami_tls_cfg.cipher);
-		ami_tls_cfg.cipher = ast_strdup(val);
-	}
-
-	val = ast_variable_retrieve(cfg, "general", "enabled");
-	if (val)
-		enabled = ast_true(val);
-
-	val = ast_variable_retrieve(cfg, "general", "block-sockets");
-	if (val)
-		block_sockets = ast_true(val);
-
-	val = ast_variable_retrieve(cfg, "general", "webenabled");
-	if (val)
-		webenabled = ast_true(val);
-
-	if ((val = ast_variable_retrieve(cfg, "general", "port"))) {
-		if (sscanf(val, "%d", &portno) != 1) {
-			ast_log(LOG_WARNING, "Invalid port number '%s'\n", val);
-			portno = DEFAULT_MANAGER_PORT;
-		}
-	}
-
-	if ((val = ast_variable_retrieve(cfg, "general", "displayconnects")))
-		displayconnects = ast_true(val);
-
-	if ((val = ast_variable_retrieve(cfg, "general", "timestampevents")))
-		timestampevents = ast_true(val);
-
-	if ((val = ast_variable_retrieve(cfg, "general", "debug")))
-		manager_debug = ast_true(val);
-
-	if ((val = ast_variable_retrieve(cfg, "general", "httptimeout")))
-		newhttptimeout = atoi(val);
-
-	memset(&ami_desc.sin, 0, sizeof(struct sockaddr_in));
+			ast_log(LOG_NOTICE, "Invalid keyword <%s> = <%s> in manager.conf [general]\n",
+				var->name, val);
+		}	
+	}
+
 	if (enabled)
 		ami_desc.sin.sin_family = AF_INET;
-	ami_desc.sin.sin_port = htons(portno);
-
-	if ((val = ast_variable_retrieve(cfg, "general", "bindaddr"))) {

[... 695 lines stripped ...]


More information about the svn-commits mailing list