[asterisk-commits] branch crichter/0.4.0 r34341 - in
/team/crichter/0.4.0: ./ apps/ channels/ ch...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Thu Jun 15 13:43:50 MST 2006
Author: crichter
Date: Thu Jun 15 15:43:49 2006
New Revision: 34341
URL: http://svn.digium.com/view/asterisk?rev=34341&view=rev
Log:
Merged revisions 32571,32609,32778,32822,33010,33040,33175,33239,33269,33304,33453,33485,33520,33552,33618,33645,33696,33727,33757,33789,33817,33845,33999,34096,34164,34245,34277,34309 via svnmerge from
https://origsvn.digium.com/svn/asterisk/team/crichter/0.3.0
........
r32571 | root | 2006-06-06 18:00:39 +0200 (Tue, 06 Jun 2006) | 1 line
automerge commit
........
r32609 | root | 2006-06-06 19:00:37 +0200 (Tue, 06 Jun 2006) | 1 line
automerge commit
........
r32778 | crichter | 2006-06-07 14:59:09 +0200 (Wed, 07 Jun 2006) | 1 line
changed the clean_up_bc function to work proper again. fixed the print with the conference nr. when bridged
........
r32822 | root | 2006-06-07 20:00:41 +0200 (Wed, 07 Jun 2006) | 1 line
automerge commit
........
r33010 | crichter | 2006-06-08 11:46:54 +0200 (Thu, 08 Jun 2006) | 1 line
Fixed detection of dtmfs with bridged channels.
........
r33040 | root | 2006-06-08 19:00:33 +0200 (Thu, 08 Jun 2006) | 1 line
automerge commit
........
r33175 | crichter | 2006-06-09 11:53:32 +0200 (Fri, 09 Jun 2006) | 1 line
when we don't want the call we need to release_complete it.. ignoring it breaks the ETSI rules ..
........
r33239 | root | 2006-06-09 18:00:37 +0200 (Fri, 09 Jun 2006) | 1 line
automerge commit
........
r33269 | root | 2006-06-09 19:00:33 +0200 (Fri, 09 Jun 2006) | 1 line
automerge commit
........
r33304 | root | 2006-06-09 21:00:35 +0200 (Fri, 09 Jun 2006) | 1 line
automerge commit
........
r33453 | root | 2006-06-11 17:00:36 +0200 (Sun, 11 Jun 2006) | 1 line
automerge commit
........
r33485 | root | 2006-06-11 18:00:33 +0200 (Sun, 11 Jun 2006) | 1 line
automerge commit
........
r33520 | root | 2006-06-11 23:00:34 +0200 (Sun, 11 Jun 2006) | 1 line
automerge commit
........
r33552 | root | 2006-06-12 00:00:24 +0200 (Mon, 12 Jun 2006) | 1 line
automerge commit
........
r33618 | root | 2006-06-12 18:00:24 +0200 (Mon, 12 Jun 2006) | 1 line
automerge commit
........
r33645 | root | 2006-06-12 19:00:24 +0200 (Mon, 12 Jun 2006) | 1 line
automerge commit
........
r33696 | root | 2006-06-12 23:00:24 +0200 (Mon, 12 Jun 2006) | 1 line
automerge commit
........
r33727 | root | 2006-06-13 00:00:24 +0200 (Tue, 13 Jun 2006) | 1 line
automerge commit
........
r33757 | root | 2006-06-13 06:00:35 +0200 (Tue, 13 Jun 2006) | 1 line
automerge commit
........
r33789 | root | 2006-06-13 07:00:34 +0200 (Tue, 13 Jun 2006) | 1 line
automerge commit
........
r33817 | root | 2006-06-13 15:00:39 +0200 (Tue, 13 Jun 2006) | 1 line
automerge commit
........
r33845 | root | 2006-06-13 16:00:32 +0200 (Tue, 13 Jun 2006) | 1 line
automerge commit
........
r33999 | root | 2006-06-14 05:00:33 +0200 (Wed, 14 Jun 2006) | 1 line
automerge commit
........
r34096 | root | 2006-06-14 17:00:42 +0200 (Wed, 14 Jun 2006) | 1 line
automerge commit
........
r34164 | root | 2006-06-15 01:00:26 +0200 (Thu, 15 Jun 2006) | 1 line
automerge commit
........
r34245 | root | 2006-06-15 15:00:38 +0200 (Thu, 15 Jun 2006) | 1 line
automerge commit
........
r34277 | root | 2006-06-15 16:00:29 +0200 (Thu, 15 Jun 2006) | 1 line
automerge commit
........
r34309 | root | 2006-06-15 17:00:29 +0200 (Thu, 15 Jun 2006) | 1 line
automerge commit
........
Modified:
team/crichter/0.4.0/ (props changed)
team/crichter/0.4.0/apps/app_alarmreceiver.c
team/crichter/0.4.0/apps/app_chanspy.c
team/crichter/0.4.0/apps/app_dial.c
team/crichter/0.4.0/apps/app_dumpchan.c
team/crichter/0.4.0/apps/app_festival.c
team/crichter/0.4.0/apps/app_ices.c
team/crichter/0.4.0/apps/app_meetme.c
team/crichter/0.4.0/apps/app_mixmonitor.c
team/crichter/0.4.0/apps/app_queue.c
team/crichter/0.4.0/apps/app_test.c
team/crichter/0.4.0/apps/app_url.c
team/crichter/0.4.0/apps/app_voicemail.c
team/crichter/0.4.0/apps/app_zapbarge.c
team/crichter/0.4.0/apps/app_zapscan.c
team/crichter/0.4.0/asterisk.c
team/crichter/0.4.0/callerid.c
team/crichter/0.4.0/channel.c
team/crichter/0.4.0/channels/chan_iax2.c
team/crichter/0.4.0/channels/chan_local.c
team/crichter/0.4.0/channels/chan_misdn.c
team/crichter/0.4.0/channels/chan_sip.c
team/crichter/0.4.0/channels/misdn/isdn_lib.c
team/crichter/0.4.0/file.c
team/crichter/0.4.0/frame.c
team/crichter/0.4.0/include/asterisk/chanspy.h
team/crichter/0.4.0/include/asterisk/plc.h
team/crichter/0.4.0/jitterbuf.c
team/crichter/0.4.0/pbx.c
team/crichter/0.4.0/plc.c
team/crichter/0.4.0/res/res_agi.c
Propchange: team/crichter/0.4.0/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Thu Jun 15 15:43:49 2006
@@ -1,1 +1,1 @@
-/team/crichter/0.3.0:1-32524
+/team/crichter/0.3.0:1-34340
Modified: team/crichter/0.4.0/apps/app_alarmreceiver.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/apps/app_alarmreceiver.c?rev=34341&r1=34340&r2=34341&view=diff
==============================================================================
--- team/crichter/0.4.0/apps/app_alarmreceiver.c (original)
+++ team/crichter/0.4.0/apps/app_alarmreceiver.c Thu Jun 15 15:43:49 2006
@@ -215,6 +215,7 @@
i += wf.datalen / 8;
if (i > duration) {
+ ast_frfree(f);
break;
}
if (ast_write(chan, &wf)){
@@ -222,6 +223,7 @@
ast_verbose(VERBOSE_PREFIX_4 "AlarmReceiver: Failed to write frame on %s\n", chan->name);
ast_log(LOG_WARNING, "AlarmReceiver Failed to write frame on %s\n",chan->name);
res = -1;
+ ast_frfree(f);
break;
}
}
Modified: team/crichter/0.4.0/apps/app_chanspy.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/apps/app_chanspy.c?rev=34341&r1=34340&r2=34341&view=diff
==============================================================================
--- team/crichter/0.4.0/apps/app_chanspy.c (original)
+++ team/crichter/0.4.0/apps/app_chanspy.c Thu Jun 15 15:43:49 2006
@@ -3,7 +3,8 @@
*
* Copyright (C) 2005 Anthony Minessale II (anthmct at yahoo.com)
*
- * Disclaimed to Digium
+ * A license has been granted to Digium (via disclaimer) for the use of
+ * this code.
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
Modified: team/crichter/0.4.0/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/apps/app_dial.c?rev=34341&r1=34340&r2=34341&view=diff
==============================================================================
--- team/crichter/0.4.0/apps/app_dial.c (original)
+++ team/crichter/0.4.0/apps/app_dial.c Thu Jun 15 15:43:49 2006
@@ -982,9 +982,18 @@
"At the tone, please say your name:"
*/
- ast_play_and_record(chan, "priv-recordintro", privintro, 4, "gsm", &duration, 128, 2000, 0); /* NOTE: I've reduced the total time to 4 sec */
- /* don't think we'll need a lock removed, we took care of
- conflicts by naming the privintro file */
+ res = ast_play_and_record(chan, "priv-recordintro", privintro, 4, "gsm", &duration, 128, 2000, 0); /* NOTE: I've reduced the total time to */
+ /* 4 sec don't think we'll need a lock removed, we
+ took care of conflicts by naming the privintro file */
+ if (res == -1) {
+ /* Delete the file regardless since they hung up during recording */
+ ast_filedelete(privintro, NULL);
+ if( ast_fileexists(privintro,NULL,NULL ) > 0 )
+ ast_log(LOG_NOTICE,"privacy: ast_filedelete didn't do its job on %s\n", privintro);
+ else if (option_verbose > 2)
+ ast_verbose( VERBOSE_PREFIX_3 "Successfully deleted %s intro file\n", privintro);
+ goto out;
+ }
}
}
}
@@ -1258,18 +1267,18 @@
do {
if (!res2)
res2 = ast_play_and_wait(peer,"priv-callpending");
- if( res2 < '1' || (ast_test_flag(&opts, OPT_PRIVACY) && res2>'5') || (ast_test_flag(&opts, OPT_SCREENING) && res2 > '4') ) /* uh, interrupting with a bad answer is ... ignorable! */
+ if ( res2 < '1' || (ast_test_flag(&opts, OPT_PRIVACY) && res2>'5') || (ast_test_flag(&opts, OPT_SCREENING) && res2 > '4') ) /* uh, interrupting with a bad answer is ... ignorable! */
res2 = 0;
/* priv-callpending script:
"I have a caller waiting, who introduces themselves as:"
*/
if (!res2)
- res2 = ast_play_and_wait(peer,privintro);
- if( res2 < '1' || (ast_test_flag(&opts, OPT_PRIVACY) && res2>'5') || (ast_test_flag(&opts, OPT_SCREENING) && res2 > '4') ) /* uh, interrupting with a bad answer is ... ignorable! */
+ res2 = ast_play_and_wait(peer, privintro);
+ if ( res2 < '1' || (ast_test_flag(&opts, OPT_PRIVACY) && res2>'5') || (ast_test_flag(&opts, OPT_SCREENING) && res2 > '4') ) /* uh, interrupting with a bad answer is ... ignorable! */
res2 = 0;
/* now get input from the called party, as to their choice */
- if( !res2 ) {
+ if (!res2) {
if( ast_test_flag(&opts, OPT_PRIVACY) )
res2 = ast_play_and_wait(peer,"priv-callee-options");
if( ast_test_flag(&opts, OPT_SCREENING) )
Modified: team/crichter/0.4.0/apps/app_dumpchan.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/apps/app_dumpchan.c?rev=34341&r1=34340&r2=34341&view=diff
==============================================================================
--- team/crichter/0.4.0/apps/app_dumpchan.c (original)
+++ team/crichter/0.4.0/apps/app_dumpchan.c Thu Jun 15 15:43:49 2006
@@ -5,7 +5,8 @@
*
* Anthony Minessale <anthmct at yahoo.com>
*
- * disclaimed to Digium
+ * A license has been granted to Digium (via disclaimer) for the use of
+ * this code.
*
* See http://www.asterisk.org for more information about
* the Asterisk project. Please do not directly contact
Modified: team/crichter/0.4.0/apps/app_festival.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/apps/app_festival.c?rev=34341&r1=34340&r2=34341&view=diff
==============================================================================
--- team/crichter/0.4.0/apps/app_festival.c (original)
+++ team/crichter/0.4.0/apps/app_festival.c Thu Jun 15 15:43:49 2006
@@ -234,11 +234,13 @@
myf.f.data = myf.frdata;
if (ast_write(chan, &myf.f) < 0) {
res = -1;
+ ast_frfree(f);
break;
}
if (res < needed) { /* last frame */
ast_log(LOG_DEBUG, "Last frame\n");
res=0;
+ ast_frfree(f);
break;
}
} else {
@@ -470,6 +472,9 @@
if ( read_data == -1 )
{
ast_log(LOG_WARNING,"Unable to read from cache/festival fd");
+ close(fd);
+ ast_config_destroy(cfg);
+ LOCAL_USER_REMOVE(u);
return -1;
}
n += read_data;
Modified: team/crichter/0.4.0/apps/app_ices.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/apps/app_ices.c?rev=34341&r1=34340&r2=34341&view=diff
==============================================================================
--- team/crichter/0.4.0/apps/app_ices.c (original)
+++ team/crichter/0.4.0/apps/app_ices.c Thu Jun 15 15:43:49 2006
@@ -175,6 +175,7 @@
if (errno != EAGAIN) {
ast_log(LOG_WARNING, "Write failed to pipe: %s\n", strerror(errno));
res = -1;
+ ast_frfree(f);
break;
}
}
Modified: team/crichter/0.4.0/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/apps/app_meetme.c?rev=34341&r1=34340&r2=34341&view=diff
==============================================================================
--- team/crichter/0.4.0/apps/app_meetme.c (original)
+++ team/crichter/0.4.0/apps/app_meetme.c Thu Jun 15 15:43:49 2006
@@ -1327,16 +1327,19 @@
tmp[1] = '\0';
if (!ast_goto_if_exists(chan, exitcontext, tmp, 1)) {
ret = 0;
+ ast_frfree(f);
break;
} else if (option_debug > 1)
ast_log(LOG_DEBUG, "Exit by single digit did not work in meetme. Extension %s does not exist in context %s\n", tmp, exitcontext);
} else if ((f->frametype == AST_FRAME_DTMF) && (f->subclass == '#') && (confflags & CONFFLAG_POUNDEXIT)) {
ret = 0;
+ ast_frfree(f);
break;
} else if (((f->frametype == AST_FRAME_DTMF) && (f->subclass == '*') && (confflags & CONFFLAG_STARMENU)) || ((f->frametype == AST_FRAME_DTMF) && menu_active)) {
if (ioctl(fd, ZT_SETCONF, &ztc_empty)) {
ast_log(LOG_WARNING, "Error setting conference\n");
close(fd);
+ ast_frfree(f);
goto outrun;
}
@@ -1494,7 +1497,7 @@
if (ioctl(fd, ZT_SETCONF, &ztc)) {
ast_log(LOG_WARNING, "Error setting conference\n");
close(fd);
- ast_mutex_unlock(&conflock);
+ ast_frfree(f);
goto outrun;
}
@@ -2011,20 +2014,25 @@
return res;
}
-static struct ast_conf_user* find_user(struct ast_conference *conf, char *callerident) {
+static struct ast_conf_user* find_user(struct ast_conference *conf, char *callerident)
+{
struct ast_conf_user *user = NULL;
- char usrno[1024] = "";
-
- if (conf && callerident) {
- user = conf->firstuser;
- while (user) {
- snprintf(usrno, sizeof(usrno), "%d", user->user_no);
- if (strcmp(usrno, callerident) == 0)
- return user;
- user = user->nextuser;
- }
- }
- return NULL;
+ int cid;
+
+ if (!conf || !callerident) {
+ return NULL;
+ }
+
+ sscanf(callerident, "%i", &cid);
+
+ user = conf->firstuser;
+ while (user) {
+ if (user->user_no == cid)
+ break;
+ user = user->nextuser;
+ }
+
+ return user;
}
/*--- admin_exec: The MeetMeadmin application */
@@ -2109,7 +2117,7 @@
if (user && (user->adminflags & ADMINFLAG_MUTED)) {
user->adminflags ^= ADMINFLAG_MUTED;
} else {
- ast_log(LOG_NOTICE, "Specified User not found or he muted himself!");
+ ast_log(LOG_NOTICE, "Specified User not found or he muted himself!\n");
}
break;
case 110: /* n: Unmute all users */
@@ -2129,7 +2137,7 @@
if (user) {
user->adminflags |= ADMINFLAG_KICKME;
} else {
- ast_log(LOG_NOTICE, "Specified User not found!");
+ ast_log(LOG_NOTICE, "Specified User not found!\n");
}
break;
}
@@ -2169,8 +2177,10 @@
}
if (f->frametype == AST_FRAME_VOICE) {
res = ast_writestream(s, f);
- if (res)
+ if (res) {
+ ast_frfree(f);
break;
+ }
}
ast_frfree(f);
if (cnf->recording == MEETME_RECORD_TERMINATE) {
Modified: team/crichter/0.4.0/apps/app_mixmonitor.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/apps/app_mixmonitor.c?rev=34341&r1=34340&r2=34341&view=diff
==============================================================================
--- team/crichter/0.4.0/apps/app_mixmonitor.c (original)
+++ team/crichter/0.4.0/apps/app_mixmonitor.c Thu Jun 15 15:43:49 2006
@@ -79,12 +79,11 @@
static const char *mixmonitor_spy_type = "MixMonitor";
struct mixmonitor {
- struct ast_channel *chan;
- char *filename;
+ struct ast_channel_spy spy;
+ struct ast_filestream *fs;
char *post_process;
+ char *name;
unsigned int flags;
- int readvol;
- int writevol;
};
enum {
@@ -110,13 +109,15 @@
AST_APP_OPTION_ARG('W', MUXFLAG_VOLUME, OPT_ARG_VOLUME),
});
-static void stopmon(struct ast_channel *chan, struct ast_channel_spy *spy)
-{
+static void stopmon(struct ast_channel_spy *spy)
+{
+ struct ast_channel *chan = spy->chan;
+
/* If our status has changed to DONE, then the channel we're spying on is gone....
DON'T TOUCH IT!!! RUN AWAY!!! */
if (spy->status == CHANSPY_DONE)
return;
-
+
if (!chan)
return;
@@ -136,7 +137,7 @@
ast_mutex_lock(&chan->lock);
res = ast_channel_spy_add(chan, spy);
ast_mutex_unlock(&chan->lock);
-
+
if (!res && ast_test_flag(chan, AST_FLAG_NBRIDGE) && (peer = ast_bridged_channel(chan)))
ast_softhangup(peer, AST_SOFTHANGUP_UNBRIDGE);
@@ -148,91 +149,31 @@
static void *mixmonitor_thread(void *obj)
{
struct mixmonitor *mixmonitor = obj;
- struct ast_channel_spy spy;
- struct ast_filestream *fs = NULL;
- char *ext, *name;
- unsigned int oflags;
- struct ast_frame *f;
- char post_process[1024] = "";
+ struct ast_frame *f = NULL;
STANDARD_INCREMENT_USECOUNT;
-
- name = ast_strdupa(mixmonitor->chan->name);
-
- oflags = O_CREAT|O_WRONLY;
- oflags |= ast_test_flag(mixmonitor, MUXFLAG_APPEND) ? O_APPEND : O_TRUNC;
-
- if ((ext = strrchr(mixmonitor->filename, '.'))) {
- *(ext++) = '\0';
- } else {
- ext = "raw";
- }
-
- fs = ast_writefile(mixmonitor->filename, ext, NULL, oflags, 0, 0644);
- if (!fs) {
- ast_log(LOG_ERROR, "Cannot open %s.%s\n", mixmonitor->filename, ext);
- goto out;
- }
-
- if (ast_test_flag(mixmonitor, MUXFLAG_APPEND))
- ast_seekstream(fs, 0, SEEK_END);
-
- memset(&spy, 0, sizeof(spy));
- ast_set_flag(&spy, CHANSPY_FORMAT_AUDIO);
- ast_set_flag(&spy, CHANSPY_MIXAUDIO);
- spy.type = mixmonitor_spy_type;
- spy.status = CHANSPY_RUNNING;
- spy.read_queue.format = AST_FORMAT_SLINEAR;
- spy.write_queue.format = AST_FORMAT_SLINEAR;
- if (mixmonitor->readvol) {
- ast_set_flag(&spy, CHANSPY_READ_VOLADJUST);
- spy.read_vol_adjustment = mixmonitor->readvol;
- }
- if (mixmonitor->writevol) {
- ast_set_flag(&spy, CHANSPY_WRITE_VOLADJUST);
- spy.write_vol_adjustment = mixmonitor->writevol;
- }
- ast_mutex_init(&spy.lock);
-
- if (startmon(mixmonitor->chan, &spy)) {
- ast_log(LOG_WARNING, "Unable to add '%s' spy to channel '%s'\n",
- spy.type, mixmonitor->chan->name);
- goto out2;
- }
-
+
if (option_verbose > 1)
- ast_verbose(VERBOSE_PREFIX_2 "Begin MixMonitor Recording %s\n", name);
-
- if (mixmonitor->post_process) {
- char *p;
-
- for (p = mixmonitor->post_process; *p ; p++) {
- if (*p == '^' && *(p+1) == '{') {
- *p = '$';
- }
- }
- pbx_substitute_variables_helper(mixmonitor->chan, mixmonitor->post_process, post_process, sizeof(post_process) - 1);
- }
-
- while (1) {
+ ast_verbose(VERBOSE_PREFIX_2 "Begin MixMonitor Recording %s\n", mixmonitor->name);
+
+ ast_mutex_lock(&mixmonitor->spy.lock);
+
+ while (mixmonitor->spy.chan) {
struct ast_frame *next;
int write;
- ast_mutex_lock(&spy.lock);
-
- ast_channel_spy_trigger_wait(&spy);
+ ast_channel_spy_trigger_wait(&mixmonitor->spy);
- if (ast_check_hangup(mixmonitor->chan) || spy.status != CHANSPY_RUNNING) {
- ast_mutex_unlock(&spy.lock);
+ if (!mixmonitor->spy.chan || mixmonitor->spy.status != CHANSPY_RUNNING) {
break;
}
while (1) {
- if (!(f = ast_channel_spy_read_frame(&spy, SAMPLES_PER_FRAME)))
+ if (!(f = ast_channel_spy_read_frame(&mixmonitor->spy, SAMPLES_PER_FRAME)))
break;
write = (!ast_test_flag(mixmonitor, MUXFLAG_BRIDGED) ||
- ast_bridged_channel(mixmonitor->chan));
+ ast_bridged_channel(mixmonitor->spy.chan));
/* it is possible for ast_channel_spy_read_frame() to return a chain
of frames if a queue flush was necessary, so process them
@@ -240,32 +181,29 @@
for (; f; f = next) {
next = f->next;
if (write)
- ast_writestream(fs, f);
+ ast_writestream(mixmonitor->fs, f);
ast_frfree(f);
}
}
-
- ast_mutex_unlock(&spy.lock);
- }
-
- stopmon(mixmonitor->chan, &spy);
+ }
+
+ ast_mutex_unlock(&mixmonitor->spy.lock);
+
+ stopmon(&mixmonitor->spy);
if (option_verbose > 1)
- ast_verbose(VERBOSE_PREFIX_2 "End MixMonitor Recording %s\n", name);
-
- if (!ast_strlen_zero(post_process)) {
+ ast_verbose(VERBOSE_PREFIX_2 "End MixMonitor Recording %s\n", mixmonitor->name);
+
+ if (mixmonitor->post_process) {
if (option_verbose > 2)
- ast_verbose(VERBOSE_PREFIX_2 "Executing [%s]\n", post_process);
- ast_safe_system(post_process);
- }
-
-out2:
- ast_mutex_destroy(&spy.lock);
-
- if (fs)
- ast_closestream(fs);
-
-out:
+ ast_verbose(VERBOSE_PREFIX_2 "Executing [%s]\n", mixmonitor->post_process);
+ ast_safe_system(mixmonitor->post_process);
+ }
+
+ ast_mutex_destroy(&mixmonitor->spy.lock);
+
+ ast_closestream(mixmonitor->fs);
+
free(mixmonitor);
STANDARD_DECREMENT_USECOUNT;
@@ -279,32 +217,94 @@
pthread_attr_t attr;
pthread_t thread;
struct mixmonitor *mixmonitor;
- int len;
-
- len = sizeof(*mixmonitor) + strlen(filename) + 1;
- if (!ast_strlen_zero(post_process))
- len += strlen(post_process) + 1;
-
+ char *file_name, *ext;
+ char postprocess2[1024] = "";
+ unsigned int oflags;
+ size_t len;
+
+ len = sizeof(*mixmonitor) + strlen(chan->name) + 1;
+
+ /* If a post process system command is given attach it to the structure */
+ if (!ast_strlen_zero(post_process)) {
+ char *p1, *p2;
+
+ p1 = ast_strdupa(post_process);
+ for (p2 = p1; *p2 ; p2++) {
+ if (*p2 == '^' && *(p2+1) == '{') {
+ *p2 = '$';
+ }
+ }
+
+ pbx_substitute_variables_helper(chan, p1, postprocess2, sizeof(postprocess2) - 1);
+ if (!ast_strlen_zero(postprocess2))
+ len += strlen(postprocess2) + 1;
+ }
+
+ /* Pre-allocate mixmonitor structure and spy */
if (!(mixmonitor = calloc(1, len))) {
ast_log(LOG_ERROR, "Memory Error!\n");
return;
}
- mixmonitor->chan = chan;
- mixmonitor->filename = (char *) mixmonitor + sizeof(*mixmonitor);
- strcpy(mixmonitor->filename, filename);
- if (!ast_strlen_zero(post_process)) {
- mixmonitor->post_process = mixmonitor->filename + strlen(filename) + 1;
- strcpy(mixmonitor->post_process, post_process);
- }
- mixmonitor->readvol = readvol;
- mixmonitor->writevol = writevol;
+ /* Copy over flags and channel name */
mixmonitor->flags = flags;
+ mixmonitor->name = (char *) mixmonitor + sizeof(*mixmonitor);
+ strcpy(mixmonitor->name, chan->name);
+ if (!ast_strlen_zero(postprocess2)) {
+ mixmonitor->post_process = mixmonitor->name + strlen(mixmonitor->name) + 1;
+ strcpy(mixmonitor->post_process, postprocess2);
+ }
+
+ /* Determine creation flags and filename plus extension for filestream */
+ oflags = O_CREAT | O_WRONLY;
+ oflags |= ast_test_flag(mixmonitor, MUXFLAG_APPEND) ? O_APPEND : O_TRUNC;
+ file_name = ast_strdupa(filename);
+ if ((ext = strrchr(file_name, '.'))) {
+ *(ext++) = '\0';
+ } else {
+ ext = "raw";
+ }
+
+ /* Move onto actually creating the filestream */
+ mixmonitor->fs = ast_writefile(file_name, ext, NULL, oflags, 0, 0644);
+ if (!mixmonitor->fs) {
+ ast_log(LOG_ERROR, "Cannot open %s.%s\n", file_name, ext);
+ free(mixmonitor);
+ return;
+ }
+
+ /* Setup the actual spy before creating our thread */
+ ast_set_flag(&mixmonitor->spy, CHANSPY_FORMAT_AUDIO);
+ ast_set_flag(&mixmonitor->spy, CHANSPY_MIXAUDIO);
+ mixmonitor->spy.type = mixmonitor_spy_type;
+ mixmonitor->spy.status = CHANSPY_RUNNING;
+ mixmonitor->spy.read_queue.format = AST_FORMAT_SLINEAR;
+ mixmonitor->spy.write_queue.format = AST_FORMAT_SLINEAR;
+ if (readvol) {
+ ast_set_flag(&mixmonitor->spy, CHANSPY_READ_VOLADJUST);
+ mixmonitor->spy.read_vol_adjustment = readvol;
+ }
+ if (writevol) {
+ ast_set_flag(&mixmonitor->spy, CHANSPY_WRITE_VOLADJUST);
+ mixmonitor->spy.write_vol_adjustment = writevol;
+ }
+ ast_mutex_init(&mixmonitor->spy.lock);
+
+ if (startmon(chan, &mixmonitor->spy)) {
+ ast_log(LOG_WARNING, "Unable to add '%s' spy to channel '%s'\n",
+ mixmonitor->spy.type, chan->name);
+ /* Since we couldn't add ourselves - bail out! */
+ ast_mutex_destroy(&mixmonitor->spy.lock);
+ ast_closestream(mixmonitor->fs);
+ free(mixmonitor);
+ return;
+ }
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
ast_pthread_create(&thread, &attr, mixmonitor_thread, mixmonitor);
pthread_attr_destroy(&attr);
+
}
static int mixmonitor_exec(struct ast_channel *chan, void *data)
Modified: team/crichter/0.4.0/apps/app_queue.c
URL: http://svn.digium.com/view/asterisk/team/crichter/0.4.0/apps/app_queue.c?rev=34341&r1=34340&r2=34341&view=diff
==============================================================================
--- team/crichter/0.4.0/apps/app_queue.c (original)
+++ team/crichter/0.4.0/apps/app_queue.c Thu Jun 15 15:43:49 2006
@@ -272,7 +272,7 @@
struct queue_ent {
- struct ast_call_queue *parent; /*!< What queue is our parent */
+ struct call_queue *parent; /*!< What queue is our parent */
char moh[80]; /*!< Name of musiconhold to be used */
char announce[80]; /*!< Announcement to play for member when call is answered */
char context[AST_MAX_CONTEXT]; /*!< Context when user exits queue */
@@ -303,20 +303,20 @@
struct member *next; /*!< Next member */
};
-struct ast_member_interfaces {
+struct member_interface {
char interface[80];
- AST_LIST_ENTRY(ast_member_interfaces) list; /*!< Next call queue */
+ AST_LIST_ENTRY(member_interface) list; /*!< Next call queue */
};
-static AST_LIST_HEAD_STATIC(interfaces, ast_member_interfaces);
-
-/* values used in multi-bit flags in ast_call_queue */
+static AST_LIST_HEAD_STATIC(interfaces, member_interface);
+
+/* values used in multi-bit flags in call_queue */
#define QUEUE_EMPTY_NORMAL 1
#define QUEUE_EMPTY_STRICT 2
#define ANNOUNCEHOLDTIME_ALWAYS 1
#define ANNOUNCEHOLDTIME_ONCE 2
-struct ast_call_queue {
+struct call_queue {
ast_mutex_t lock;
char name[80]; /*!< Name */
char moh[80]; /*!< Music On Hold class to be used */
@@ -368,10 +368,10 @@
struct member *members; /*!< Head of the list of members */
struct queue_ent *head; /*!< Head of the list of callers */
- struct ast_call_queue *next; /*!< Next call queue */
+ struct call_queue *next; /*!< Next call queue */
};
-static struct ast_call_queue *queues = NULL;
+static struct call_queue *queues = NULL;
AST_MUTEX_DEFINE_STATIC(qlock);
static void set_queue_result(struct ast_channel *chan, enum queue_result res)
@@ -407,7 +407,7 @@
}
/*! \brief Insert the 'new' entry after the 'prev' entry of queue 'q' */
-static inline void insert_entry(struct ast_call_queue *q, struct queue_ent *prev, struct queue_ent *new, int *pos)
+static inline void insert_entry(struct call_queue *q, struct queue_ent *prev, struct queue_ent *new, int *pos)
{
struct queue_ent *cur;
@@ -432,7 +432,7 @@
QUEUE_NORMAL
};
-static enum queue_member_status get_member_status(const struct ast_call_queue *q)
+static enum queue_member_status get_member_status(const struct call_queue *q)
{
struct member *member;
enum queue_member_status result = QUEUE_NO_MEMBERS;
@@ -462,18 +462,17 @@
static void *changethread(void *data)
{
- struct ast_call_queue *q;
+ struct call_queue *q;
struct statechange *sc = data;
struct member *cur;
- struct ast_member_interfaces *curint;
+ struct member_interface *curint;
char *loc;
char *technology;
technology = ast_strdupa(sc->dev);
loc = strchr(technology, '/');
if (loc) {
- *loc = '\0';
- loc++;
+ *loc++ = '\0';
} else {
free(sc);
return NULL;
@@ -486,43 +485,44 @@
}
AST_LIST_UNLOCK(&interfaces);
- if (curint) {
-
- if (option_debug)
- ast_log(LOG_DEBUG, "Device '%s/%s' changed to state '%d' (%s)\n", technology, loc, sc->state, devstate2str(sc->state));
- ast_mutex_lock(&qlock);
- for (q = queues; q; q = q->next) {
- ast_mutex_lock(&q->lock);
- cur = q->members;
- while(cur) {
- if (!strcasecmp(sc->dev, cur->interface)) {
- if (cur->status != sc->state) {
- cur->status = sc->state;
- if (!q->maskmemberstatus) {
- manager_event(EVENT_FLAG_AGENT, "QueueMemberStatus",
- "Queue: %s\r\n"
- "Location: %s\r\n"
- "Membership: %s\r\n"
- "Penalty: %d\r\n"
- "CallsTaken: %d\r\n"
- "LastCall: %d\r\n"
- "Status: %d\r\n"
- "Paused: %d\r\n",
- q->name, cur->interface, cur->dynamic ? "dynamic" : "static",
- cur->penalty, cur->calls, (int)cur->lastcall, cur->status, cur->paused);
- }
- }
- }
- cur = cur->next;
- }
- ast_mutex_unlock(&q->lock);
- }
- ast_mutex_unlock(&qlock);
- } else {
+ if (!curint) {
if (option_debug)
ast_log(LOG_DEBUG, "Device '%s/%s' changed to state '%d' (%s) but we don't care because they're not a member of any queue.\n", technology, loc, sc->state, devstate2str(sc->state));
+ free(sc);
+ return NULL;
}
- free(sc);
+
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Device '%s/%s' changed to state '%d' (%s)\n", technology, loc, sc->state, devstate2str(sc->state));
+ ast_mutex_lock(&qlock);
+ for (q = queues; q; q = q->next) {
+ ast_mutex_lock(&q->lock);
+ for (cur = q->members; cur; cur = cur->next) {
+ if (strcasecmp(sc->dev, cur->interface))
+ continue;
+
+ if (cur->status != sc->state) {
+ cur->status = sc->state;
+ if (q->maskmemberstatus)
+ continue;
+
+ manager_event(EVENT_FLAG_AGENT, "QueueMemberStatus",
+ "Queue: %s\r\n"
+ "Location: %s\r\n"
+ "Membership: %s\r\n"
+ "Penalty: %d\r\n"
+ "CallsTaken: %d\r\n"
+ "LastCall: %d\r\n"
+ "Status: %d\r\n"
+ "Paused: %d\r\n",
+ q->name, cur->interface, cur->dynamic ? "dynamic" : "static",
+ cur->penalty, cur->calls, (int)cur->lastcall, cur->status, cur->paused);
+ }
+ }
+ ast_mutex_unlock(&q->lock);
+ }
+ ast_mutex_unlock(&qlock);
+
return NULL;
}
@@ -534,17 +534,18 @@
pthread_t t;
pthread_attr_t attr;
- sc = malloc(sizeof(struct statechange) + strlen(dev) + 1);
- if (sc) {
- sc->state = state;
- strcpy(sc->dev, dev);
- pthread_attr_init(&attr);
- pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
- if (ast_pthread_create(&t, &attr, changethread, sc)) {
- ast_log(LOG_WARNING, "Failed to create update thread!\n");
- free(sc);
- }
- }
+ if (!(sc = malloc(sizeof(*sc) + strlen(dev) + 1)))
+ return 0;
+
+ sc->state = state;
+ strcpy(sc->dev, dev);
+ pthread_attr_init(&attr);
+ pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+ if (ast_pthread_create(&t, &attr, changethread, sc)) {
+ ast_log(LOG_WARNING, "Failed to create update thread!\n");
+ free(sc);
+ }
+
return 0;
}
@@ -569,9 +570,9 @@
return cur;
}
-static struct ast_call_queue *alloc_queue(const char *queuename)
-{
- struct ast_call_queue *q;
+static struct call_queue *alloc_queue(const char *queuename)
+{
+ struct call_queue *q;
q = malloc(sizeof(*q));
if (q) {
@@ -582,7 +583,7 @@
return q;
}
-static void init_queue(struct ast_call_queue *q)
+static void init_queue(struct call_queue *q)
{
q->dead = 0;
q->retry = DEFAULT_RETRY;
@@ -609,7 +610,7 @@
ast_copy_string(q->sound_periodicannounce, "queue-periodic-announce", sizeof(q->sound_periodicannounce));
}
-static void clear_queue(struct ast_call_queue *q)
+static void clear_queue(struct call_queue *q)
{
q->holdtime = 0;
q->callscompleted = 0;
@@ -620,7 +621,7 @@
static int add_to_interfaces(char *interface)
{
- struct ast_member_interfaces *curint, *newint;
+ struct member_interface *curint;
if (!interface)
return 0;
@@ -631,24 +632,27 @@
break;
}
- if (!curint) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Adding %s to the list of interfaces that make up all of our queue members.\n", interface);
-
- if ((newint = malloc(sizeof(*newint)))) {
- memset(newint, 0, sizeof(*newint));
- ast_copy_string(newint->interface, interface, sizeof(newint->interface));
- AST_LIST_INSERT_HEAD(&interfaces, newint, list);
- }
+ if (curint) {
+ AST_LIST_UNLOCK(&interfaces);
+ return 0;
+ }
+
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Adding %s to the list of interfaces that make up all of our queue members.\n", interface);
+
+ if ((curint = malloc(sizeof(*curint)))) {
+ memset(curint, 0, sizeof(*curint));
+ ast_copy_string(curint->interface, interface, sizeof(curint->interface));
+ AST_LIST_INSERT_HEAD(&interfaces, curint, list);
}
AST_LIST_UNLOCK(&interfaces);
- return 0;
+ return 0;
}
static int interface_exists_global(char *interface)
{
- struct ast_call_queue *q;
+ struct call_queue *q;
struct member *mem;
int ret = 0;
@@ -658,13 +662,9 @@
ast_mutex_lock(&qlock);
for (q = queues; q && !ret; q = q->next) {
ast_mutex_lock(&q->lock);
- mem = q->members;
- while(mem) {
- if (!strcasecmp(interface, mem->interface)) {
+ for (mem = q->members; mem && !ret; mem = mem->next) {
+ if (!strcasecmp(interface, mem->interface))
ret = 1;
- break;
- }
- mem = mem->next;
}
ast_mutex_unlock(&q->lock);
}
@@ -673,21 +673,23 @@
return ret;
}
-
static int remove_from_interfaces(char *interface)
{
- struct ast_member_interfaces *curint;
+ struct member_interface *curint;
if (!interface)
return 0;
AST_LIST_LOCK(&interfaces);
AST_LIST_TRAVERSE_SAFE_BEGIN(&interfaces, curint, list) {
- if (!strcasecmp(curint->interface, interface) && !interface_exists_global(interface)) {
- if (option_debug)
- ast_log(LOG_DEBUG, "Removing %s from the list of interfaces that make up all of our queue members.\n", interface);
- AST_LIST_REMOVE_CURRENT(&interfaces, list);
- free(curint);
+ if (!strcasecmp(curint->interface, interface)) {
+ if (!interface_exists_global(interface)) {
+ if (option_debug)
+ ast_log(LOG_DEBUG, "Removing %s from the list of interfaces that make up all of our queue members.\n", interface);
+ AST_LIST_REMOVE_CURRENT(&interfaces, list);
+ free(curint);
+ }
+ break;
}
}
AST_LIST_TRAVERSE_SAFE_END;
@@ -698,17 +700,12 @@
static void clear_and_free_interfaces(void)
{
- struct ast_member_interfaces *curint;
+ struct member_interface *curint;
AST_LIST_LOCK(&interfaces);
- AST_LIST_TRAVERSE_SAFE_BEGIN(&interfaces, curint, list) {
- AST_LIST_REMOVE_CURRENT(&interfaces, list);
+ while ((curint = AST_LIST_REMOVE_HEAD(&interfaces, list)))
free(curint);
- }
- AST_LIST_TRAVERSE_SAFE_END;
AST_LIST_UNLOCK(&interfaces);
-
- return;
}
/*! \brief Configure a queue parameter.
@@ -718,7 +715,7 @@
The failunknown flag is set for config files (and static realtime) to show
errors for unknown parameters. It is cleared for dynamic realtime to allow
extra fields in the tables. */
-static void queue_set_param(struct ast_call_queue *q, const char *param, const char *val, int linenum, int failunknown)
+static void queue_set_param(struct call_queue *q, const char *param, const char *val, int linenum, int failunknown)
{
if (!strcasecmp(param, "music") || !strcasecmp(param, "musiconhold")) {
ast_copy_string(q->moh, val, sizeof(q->moh));
@@ -837,7 +834,7 @@
}
}
-static void rt_handle_member_record(struct ast_call_queue *q, char *interface, const char *penalty_str)
+static void rt_handle_member_record(struct call_queue *q, char *interface, const char *penalty_str)
{
struct member *m, *prev_m;
int penalty = 0;
@@ -874,7 +871,7 @@
}
}
-static void free_members(struct ast_call_queue *q, int all)
+static void free_members(struct call_queue *q, int all)
{
/* Free non-dynamic members */
struct member *curm, *next, *prev = NULL;
@@ -893,16 +890,16 @@
}
}
-static void destroy_queue(struct ast_call_queue *q)
+static void destroy_queue(struct call_queue *q)
{
free_members(q, 1);
ast_mutex_destroy(&q->lock);
free(q);
}
-static void remove_queue(struct ast_call_queue *q)
-{
- struct ast_call_queue *cur, *prev = NULL;
+static void remove_queue(struct call_queue *q)
+{
+ struct call_queue *cur, *prev = NULL;
ast_mutex_lock(&qlock);
for (cur = queues; cur; cur = cur->next) {
@@ -921,10 +918,10 @@
/*!\brief Reload a single queue via realtime.
\return Return the queue, or NULL if it doesn't exist.
\note Should be called with the global qlock locked. */
-static struct ast_call_queue *find_queue_by_name_rt(const char *queuename, struct ast_variable *queue_vars, struct ast_config *member_config)
+static struct call_queue *find_queue_by_name_rt(const char *queuename, struct ast_variable *queue_vars, struct ast_config *member_config)
{
struct ast_variable *v;
- struct ast_call_queue *q, *prev_q = NULL;
+ struct call_queue *q, *prev_q = NULL;
struct member *m, *prev_m, *next_m;
char *interface;
char *tmp, *tmp_name;
@@ -1047,11 +1044,11 @@
return q;
}
-static struct ast_call_queue *load_realtime_queue(char *queuename)
+static struct call_queue *load_realtime_queue(char *queuename)
{
struct ast_variable *queue_vars = NULL;
struct ast_config *member_config = NULL;
- struct ast_call_queue *q;
+ struct call_queue *q;
/* Find the queue in the in-core list first. */
ast_mutex_lock(&qlock);
@@ -1096,7 +1093,7 @@
static int join_queue(char *queuename, struct queue_ent *qe, enum queue_result *reason)
{
- struct ast_call_queue *q;
+ struct call_queue *q;
struct queue_ent *cur, *prev = NULL;
int res = -1;
int pos = 0;
@@ -1335,7 +1332,7 @@
static void leave_queue(struct queue_ent *qe)
{
- struct ast_call_queue *q;
+ struct call_queue *q;
struct queue_ent *cur, *prev = NULL;
int pos = 0;
@@ -1392,7 +1389,7 @@
}
}
-static int update_status(struct ast_call_queue *q, struct member *member, int status)
+static int update_status(struct call_queue *q, struct member *member, int status)
{
struct member *cur;
@@ -1424,7 +1421,7 @@
return 0;
}
-static int update_dial_status(struct ast_call_queue *q, struct member *member, int status)
+static int update_dial_status(struct call_queue *q, struct member *member, int status)
{
if (status == AST_CAUSE_BUSY)
status = AST_DEVICE_BUSY;
@@ -1439,9 +1436,9 @@
/* traverse all defined queues which have calls waiting and contain this member
return 0 if no other queue has precedence (higher weight) or 1 if found */
-static int compare_weight(struct ast_call_queue *rq, struct member *member)
-{
- struct ast_call_queue *q;
+static int compare_weight(struct call_queue *rq, struct member *member)
+{
+ struct call_queue *q;
struct member *mem;
int found = 0;
@@ -2058,7 +2055,7 @@
return res;
}
-static int update_queue(struct ast_call_queue *q, struct member *member)
+static int update_queue(struct call_queue *q, struct member *member)
{
struct member *cur;
@@ -2079,7 +2076,7 @@
return 0;
}
-static int calc_metric(struct ast_call_queue *q, struct member *mem, int pos, struct queue_ent *qe, struct localuser *tmp)
+static int calc_metric(struct call_queue *q, struct member *mem, int pos, struct queue_ent *qe, struct localuser *tmp)
{
switch (q->strategy) {
case QUEUE_STRATEGY_RINGALL:
@@ -2446,7 +2443,7 @@
return ast_waitfordigit(qe->chan, retrywait);
}
-static struct member * interface_exists(struct ast_call_queue *q, char *interface)
+static struct member *interface_exists(struct call_queue *q, char *interface)
{
struct member *mem;
@@ -2464,7 +2461,7 @@
* <pm_family>/<queuename> = <interface>;<penalty>;<paused>[|...]
*
*/
-static void dump_queue_members(struct ast_call_queue *pm_queue)
+static void dump_queue_members(struct call_queue *pm_queue)
{
struct member *cur_member;
char value[PM_MAX_LEN];
@@ -2500,7 +2497,7 @@
static int remove_from_queue(char *queuename, char *interface)
{
- struct ast_call_queue *q;
+ struct call_queue *q;
struct member *last_member, *look;
int res = RES_NOSUCHQUEUE;
@@ -2547,7 +2544,7 @@
static int add_to_queue(char *queuename, char *interface, int penalty, int paused, int dump)
{
- struct ast_call_queue *q;
+ struct call_queue *q;
struct member *new_member;
int res = RES_NOSUCHQUEUE;
@@ -2600,7 +2597,7 @@
static int set_member_paused(char *queuename, char *interface, int paused)
{
int found = 0;
- struct ast_call_queue *q;
+ struct call_queue *q;
struct member *mem;
/* Special event for when all queues are paused - individual events still generated */
@@ -2653,7 +2650,7 @@
int paused = 0;
struct ast_db_entry *db_tree;
struct ast_db_entry *entry;
- struct ast_call_queue *cur_queue;
+ struct call_queue *cur_queue;
char queue_data[PM_MAX_LEN];
[... 856 lines stripped ...]
More information about the asterisk-commits
mailing list