[asterisk-commits] nadi: branch group/trunk-cm-csel-hash r48463 - in /team/group/trunk-cm-csel-h...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Dec 14 03:54:53 MST 2006


Author: nadi
Date: Thu Dec 14 04:54:51 2006
New Revision: 48463

URL: http://svn.digium.com/view/asterisk?view=rev&rev=48463
Log:
Merged revisions 48388-48390,48392,48397,48400,48402,48408-48410,48415-48417,48432-48433,48455,48458-48459,48462 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
r48388 | murf | 2006-12-11 18:00:36 +0100 (Mo, 11 Dez 2006) | 1 line

This update fixes the problem reported in bug 8551; that ast_app_getdata() behaves differently in trunk for the case of a null prompt.
................
r48389 | rizzo | 2006-12-11 19:11:58 +0100 (Mo, 11 Dez 2006) | 13 lines

make sure the argument to ast_malloc() is > 0.

Long explaination:

The behaviour of the underlying malloc(0) differs depending on the
operating system.  Some return NULL (SysV behaviour); some still
allocate a small chunk of memory and return a valid pointer (e.g.
traditional BSD); some (e.g. FreeBSD 6.x) return a non-null pointer
that causes a memory fault if used, even just for reading.

Given the above variety, better never call malloc(0).


................
r48390 | mogorman | 2006-12-11 22:04:41 +0100 (Mo, 11 Dez 2006) | 3 lines

add support for dynamic channel creation and destruction, and
show transcoder to show number of channels in use.

................
r48392 | file | 2006-12-11 22:35:28 +0100 (Mo, 11 Dez 2006) | 10 lines

Merged revisions 48391 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r48391 | file | 2006-12-11 16:31:23 -0500 (Mon, 11 Dec 2006) | 2 lines

Return non-existant callerid handling to that which it was before. In 1.4 and trunk callerid can be allocated but not have any contents so we have to use ast_strlen_zero before passing it to the relevant functions. (issue #8567 reported by pabelanger)

........

................
r48397 | mogorman | 2006-12-11 23:31:20 +0100 (Mo, 11 Dez 2006) | 20 lines

Merged revisions 48396 via svnmerge from 
https://svn.digium.com/svn/asterisk/branches/1.4

................
r48396 | mogorman | 2006-12-11 16:11:35 -0600 (Mon, 11 Dec 2006) | 12 lines

Merged revisions 48394 via svnmerge from 
https://svn.digium.com/svn/asterisk/branches/1.2

........
r48394 | mogorman | 2006-12-11 15:55:43 -0600 (Mon, 11 Dec 2006) | 4 lines

app_externalivr needs a real silence file, and additional
changes to add silence files into core instead of extra
patch provided by bug 8177 with minor additions.

........

................

................
r48400 | mogorman | 2006-12-12 00:02:47 +0100 (Di, 12 Dez 2006) | 10 lines

Merged revisions 48399 via svnmerge from 
https://svn.digium.com/svn/asterisk/branches/1.4

........
r48399 | mogorman | 2006-12-11 17:02:10 -0600 (Mon, 11 Dec 2006) | 2 lines

new sounds package with 100% more silence

........

................
r48402 | file | 2006-12-12 05:14:50 +0100 (Di, 12 Dez 2006) | 10 lines

Merged revisions 48401 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r48401 | file | 2006-12-11 23:13:48 -0500 (Mon, 11 Dec 2006) | 2 lines

Use S_OR in my previous app_voicemail. This is the way it should have been done.

........

................
r48408 | rizzo | 2006-12-12 10:40:45 +0100 (Di, 12 Dez 2006) | 10 lines

Make sure tab-completion works even when we have typed a fully
matching word (e.g. "sip<TAB>"); this is implemented by this one-line change

-               for (;; dst++, src += n) {
+               for (;src < argindex; dst++, src += n) {

However this code is not exactly trivial to understand, so
i am also adding some comments to help figuring out what it does.


................
r48409 | rizzo | 2006-12-12 11:35:10 +0100 (Di, 12 Dez 2006) | 3 lines

normalize the scanning of "general" options in the config file.


................
r48410 | rizzo | 2006-12-12 11:36:15 +0100 (Di, 12 Dez 2006) | 3 lines

properly initialize a malloc'ed buffer


................
r48415 | mogorman | 2006-12-12 20:55:39 +0100 (Di, 12 Dez 2006) | 2 lines

fixed nubb error on my part, transcoder now unlocks and locks correctly, as well as counts in the correct direction.

................
r48416 | russell | 2006-12-12 23:27:22 +0100 (Di, 12 Dez 2006) | 7 lines

Make chan_zap inform you that your version of zaptel is too old instead of
just failing to compile.

It seems like the proper way to do this would be in the configure script.
However, that wouldn't help existing checkouts unless we forced the configure
script to be executed after any code was changed.

................
r48417 | russell | 2006-12-12 23:32:20 +0100 (Di, 12 Dez 2006) | 2 lines

Fix various spelling mistakes in comments.

................
r48432 | kpfleming | 2006-12-13 00:28:15 +0100 (Mi, 13 Dez 2006) | 10 lines

Merged revisions 48427 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r48427 | kpfleming | 2006-12-12 17:18:14 -0600 (Tue, 12 Dec 2006) | 2 lines

when making a release, we can always use wget and we can't run the configure script to find that out...

........

................
r48433 | russell | 2006-12-13 01:56:30 +0100 (Mi, 13 Dez 2006) | 3 lines

revert check for a zaptel transcoder related definition that was done in the
wrong module.

................
r48455 | mogorman | 2006-12-13 22:23:54 +0100 (Mi, 13 Dez 2006) | 4 lines

support for deactivating translation paths that are no longer available
and more descriptive show transcoder cli command.


................
r48458 | rizzo | 2006-12-13 23:54:41 +0100 (Mi, 13 Dez 2006) | 14 lines

clean up function manager_show_dialplan_helper()
reducing indentation and normalizing loops.

While doing this, remove some unused variables,
fix an uninitialized string (idaction), and mark
some places where the behaviour is not what we would expect
(e.g. an empty context is reported as an error same as
a non-existent one). Given that this function is
not in 1.4, the above can be changed without too many
backward compatibility concerns.

Not applicable to 1.4 or below.


................
r48459 | rizzo | 2006-12-14 00:08:02 +0100 (Do, 14 Dez 2006) | 5 lines

make sure that showdialplan sends only one
'Response: Success ' message even in case of
a recursive call.


................
r48462 | file | 2006-12-14 04:39:39 +0100 (Do, 14 Dez 2006) | 10 lines

Merged revisions 48461 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
r48461 | file | 2006-12-13 22:33:30 -0500 (Wed, 13 Dec 2006) | 2 lines

Remove direct RTCP bridging. I've come to the conclusion that we should handle this through the core and not just forward it on. Should solve a few bugs.

........

................

Modified:
    team/group/trunk-cm-csel-hash/   (props changed)
    team/group/trunk-cm-csel-hash/apps/app_externalivr.c
    team/group/trunk-cm-csel-hash/apps/app_voicemail.c
    team/group/trunk-cm-csel-hash/build_tools/prep_tarball
    team/group/trunk-cm-csel-hash/channels/chan_sip.c
    team/group/trunk-cm-csel-hash/codecs/codec_zap.c
    team/group/trunk-cm-csel-hash/include/asterisk/app.h
    team/group/trunk-cm-csel-hash/include/asterisk/channel.h
    team/group/trunk-cm-csel-hash/include/asterisk/pbx.h
    team/group/trunk-cm-csel-hash/main/app.c
    team/group/trunk-cm-csel-hash/main/cli.c
    team/group/trunk-cm-csel-hash/main/manager.c
    team/group/trunk-cm-csel-hash/main/pbx.c
    team/group/trunk-cm-csel-hash/main/rtp.c
    team/group/trunk-cm-csel-hash/sounds/Makefile

Propchange: team/group/trunk-cm-csel-hash/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/group/trunk-cm-csel-hash/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Thu Dec 14 04:54:51 2006
@@ -1,1 +1,1 @@
-/trunk:1-48384
+/trunk:1-48462

Modified: team/group/trunk-cm-csel-hash/apps/app_externalivr.c
URL: http://svn.digium.com/view/asterisk/team/group/trunk-cm-csel-hash/apps/app_externalivr.c?view=diff&rev=48463&r1=48462&r2=48463
==============================================================================
--- team/group/trunk-cm-csel-hash/apps/app_externalivr.c (original)
+++ team/group/trunk-cm-csel-hash/apps/app_externalivr.c Thu Dec 14 04:54:51 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/group/trunk-cm-csel-hash/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/group/trunk-cm-csel-hash/apps/app_voicemail.c?view=diff&rev=48463&r1=48462&r2=48463
==============================================================================
--- team/group/trunk-cm-csel-hash/apps/app_voicemail.c (original)
+++ team/group/trunk-cm-csel-hash/apps/app_voicemail.c Thu Dec 14 04:54:51 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/group/trunk-cm-csel-hash/build_tools/prep_tarball
URL: http://svn.digium.com/view/asterisk/team/group/trunk-cm-csel-hash/build_tools/prep_tarball?view=diff&rev=48463&r1=48462&r2=48463
==============================================================================
--- team/group/trunk-cm-csel-hash/build_tools/prep_tarball (original)
+++ team/group/trunk-cm-csel-hash/build_tools/prep_tarball Thu Dec 14 04:54:51 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/group/trunk-cm-csel-hash/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/group/trunk-cm-csel-hash/channels/chan_sip.c?view=diff&rev=48463&r1=48462&r2=48463
==============================================================================
--- team/group/trunk-cm-csel-hash/channels/chan_sip.c (original)
+++ team/group/trunk-cm-csel-hash/channels/chan_sip.c Thu Dec 14 04:54:51 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/group/trunk-cm-csel-hash/codecs/codec_zap.c
URL: http://svn.digium.com/view/asterisk/team/group/trunk-cm-csel-hash/codecs/codec_zap.c?view=diff&rev=48463&r1=48462&r2=48463
==============================================================================
--- team/group/trunk-cm-csel-hash/codecs/codec_zap.c (original)
+++ team/group/trunk-cm-csel-hash/codecs/codec_zap.c Thu Dec 14 04:54:51 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/group/trunk-cm-csel-hash/include/asterisk/app.h
URL: http://svn.digium.com/view/asterisk/team/group/trunk-cm-csel-hash/include/asterisk/app.h?view=diff&rev=48463&r1=48462&r2=48463
==============================================================================
--- team/group/trunk-cm-csel-hash/include/asterisk/app.h (original)
+++ team/group/trunk-cm-csel-hash/include/asterisk/app.h Thu Dec 14 04:54:51 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/group/trunk-cm-csel-hash/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/team/group/trunk-cm-csel-hash/include/asterisk/channel.h?view=diff&rev=48463&r1=48462&r2=48463
==============================================================================
--- team/group/trunk-cm-csel-hash/include/asterisk/channel.h (original)
+++ team/group/trunk-cm-csel-hash/include/asterisk/channel.h Thu Dec 14 04:54:51 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.
@@ -679,7 +679,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 +745,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 +802,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 +810,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 +893,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
@@ -1078,7 +1078,7 @@
  * \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 +1129,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 +1149,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 +1195,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/group/trunk-cm-csel-hash/include/asterisk/pbx.h
URL: http://svn.digium.com/view/asterisk/team/group/trunk-cm-csel-hash/include/asterisk/pbx.h?view=diff&rev=48463&r1=48462&r2=48463
==============================================================================
--- team/group/trunk-cm-csel-hash/include/asterisk/pbx.h (original)
+++ team/group/trunk-cm-csel-hash/include/asterisk/pbx.h Thu Dec 14 04:54:51 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/group/trunk-cm-csel-hash/main/app.c
URL: http://svn.digium.com/view/asterisk/team/group/trunk-cm-csel-hash/main/app.c?view=diff&rev=48463&r1=48462&r2=48463
==============================================================================
--- team/group/trunk-cm-csel-hash/main/app.c (original)
+++ team/group/trunk-cm-csel-hash/main/app.c Thu Dec 14 04:54:51 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/group/trunk-cm-csel-hash/main/cli.c
URL: http://svn.digium.com/view/asterisk/team/group/trunk-cm-csel-hash/main/cli.c?view=diff&rev=48463&r1=48462&r2=48463
==============================================================================
--- team/group/trunk-cm-csel-hash/main/cli.c (original)
+++ team/group/trunk-cm-csel-hash/main/cli.c Thu Dec 14 04:54:51 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/group/trunk-cm-csel-hash/main/manager.c
URL: http://svn.digium.com/view/asterisk/team/group/trunk-cm-csel-hash/main/manager.c?view=diff&rev=48463&r1=48462&r2=48463
==============================================================================
--- team/group/trunk-cm-csel-hash/main/manager.c (original)
+++ team/group/trunk-cm-csel-hash/main/manager.c Thu Dec 14 04:54:51 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 {

[... 541 lines stripped ...]


More information about the asterisk-commits mailing list