[asterisk-commits] branch oej/test-this-branch r22262 - in
/team/oej/test-this-branch: ./ apps/ ...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Mon Apr 24 06:03:23 MST 2006
Author: oej
Date: Mon Apr 24 08:03:22 2006
New Revision: 22262
URL: http://svn.digium.com/view/asterisk?rev=22262&view=rev
Log:
Make this branch useful again...
Modified:
team/oej/test-this-branch/ (props changed)
team/oej/test-this-branch/apps/app_senddtmf.c
team/oej/test-this-branch/channel.c
team/oej/test-this-branch/channels/chan_skinny.c
team/oej/test-this-branch/formats/format_pcm.c
team/oej/test-this-branch/pbx.c
team/oej/test-this-branch/res/res_features.c
Propchange: team/oej/test-this-branch/
------------------------------------------------------------------------------
automerge = http://edvina.net/training/
Propchange: team/oej/test-this-branch/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Apr 24 08:03:22 2006
@@ -1,1 +1,1 @@
-/trunk:1-20507
+/trunk:1-20789
Modified: team/oej/test-this-branch/apps/app_senddtmf.c
URL: http://svn.digium.com/view/asterisk/team/oej/test-this-branch/apps/app_senddtmf.c?rev=22262&r1=22261&r2=22262&view=diff
==============================================================================
--- team/oej/test-this-branch/apps/app_senddtmf.c (original)
+++ team/oej/test-this-branch/apps/app_senddtmf.c Mon Apr 24 08:03:22 2006
@@ -94,7 +94,6 @@
return res;
}
-<<<<<<< .working
static char mandescr_playdtmf[] =
"Description: Plays a DTMF digit on the specified channel.\n"
"Variables: (all are required)\n"
Modified: team/oej/test-this-branch/channel.c
URL: http://svn.digium.com/view/asterisk/team/oej/test-this-branch/channel.c?rev=22262&r1=22261&r2=22262&view=diff
==============================================================================
--- team/oej/test-this-branch/channel.c (original)
+++ team/oej/test-this-branch/channel.c Mon Apr 24 08:03:22 2006
@@ -795,60 +795,48 @@
const char *context, const char *exten)
{
const char *msg = prev ? "deadlock" : "initial deadlock";
- int retries, done;
+ int retries;
struct ast_channel *c;
for (retries = 0; retries < 10; retries++) {
+ int done;
AST_LIST_LOCK(&channels);
AST_LIST_TRAVERSE(&channels, c, chan_list) {
- if (!prev) {
- /* want head of list */
- if (!name && !exten)
- break;
- if (name) {
- /* want match by full name */
- if (!namelen) {
- if (!strcasecmp(c->name, name))
- break;
- else
- continue;
- }
- /* want match by name prefix */
- if (!strncasecmp(c->name, name, namelen))
- break;
- } else if (exten) {
- /* want match by context and exten */
- if (context && (strcasecmp(c->context, context) &&
- strcasecmp(c->macrocontext, context)))
- continue;
- /* match by exten */
- if (strcasecmp(c->exten, exten) &&
- strcasecmp(c->macroexten, exten))
- continue;
- else
- break;
- }
- } else if (c == prev) { /* found, return c->next */
+ if (prev) { /* look for next item */
+ if (c != prev) /* not this one */
+ continue;
+ /* found, prepare to return c->next */
c = AST_LIST_NEXT(c, chan_list);
- break;
+ } else if (name) { /* want match by name */
+ if ( (!namelen && strcasecmp(c->name, name)) ||
+ (namelen && strncasecmp(c->name, name, namelen)) )
+ continue; /* name match failed */
+ } else if (exten) {
+ if (context && strcasecmp(c->context, context) &&
+ strcasecmp(c->macrocontext, context))
+ continue; /* context match failed */
+ if (strcasecmp(c->exten, exten) &&
+ strcasecmp(c->macroexten, exten))
+ continue; /* exten match failed */
}
+ /* if we get here, c points to the desired record */
+ break;
}
/* exit if chan not found or mutex acquired successfully */
- done = (c == NULL) || (ast_mutex_trylock(&c->lock) == 0);
- /* this is slightly unsafe, as we _should_ hold the lock to access c->name */
- if (!done && c)
- ast_log(LOG_DEBUG, "Avoiding %s for '%s'\n", msg, c->name);
+ done = c == NULL || ast_mutex_trylock(&c->lock) == 0;
+ if (!done)
+ ast_log(LOG_DEBUG, "Avoiding %s for channel '%p'\n", msg, c);
AST_LIST_UNLOCK(&channels);
if (done)
return c;
- usleep(1);
+ usleep(1); /* give other threads a chance before retrying */
}
/*
* c is surely not null, but we don't have the lock so cannot
* access c->name
*/
- ast_log(LOG_WARNING, "Avoided %s for '%p', %d retries!\n",
- msg, c, retries);
+ ast_log(LOG_WARNING, "Failure, could not lock '%p' after %d retries!\n",
+ c, retries);
return NULL;
}
@@ -1277,13 +1265,15 @@
{
struct ast_frame *translated_frame = NULL;
struct ast_channel_spy *spy;
- struct ast_channel_spy_queue *queue;
struct channel_spy_trans *trans;
- struct ast_frame *last;
trans = (dir == SPY_READ) ? &chan->spies->read_translator : &chan->spies->write_translator;
AST_LIST_TRAVERSE(&chan->spies->list, spy, list) {
+ struct ast_frame *last;
+ struct ast_frame *f1; /* the frame to append */
+ struct ast_channel_spy_queue *queue;
+
ast_mutex_lock(&spy->lock);
queue = (dir == SPY_READ) ? &spy->read_queue : &spy->write_queue;
@@ -1313,12 +1303,7 @@
break;
}
}
-
- for (last = queue->head; last && last->next; last = last->next);
- if (last)
- last->next = ast_frdup(translated_frame);
- else
- queue->head = ast_frdup(translated_frame);
+ f1 = translated_frame;
} else {
if (f->subclass != queue->format) {
ast_log(LOG_WARNING, "Spy '%s' on channel '%s' wants format '%s', but frame is '%s', dropping\n",
@@ -1327,13 +1312,17 @@
ast_mutex_unlock(&spy->lock);
continue;
}
-
- for (last = queue->head; last && last->next; last = last->next);
- if (last)
- last->next = ast_frdup(f);
- else
- queue->head = ast_frdup(f);
- }
+ f1 = f;
+ }
+ /* duplicate and append f1 to the tail */
+ f1 = ast_frdup(f1);
+
+ for (last = queue->head; last && last->next; last = last->next)
+ ;
+ if (last)
+ last->next = f1;
+ else
+ queue->head = f1;
queue->samples += f->samples;
@@ -1503,8 +1492,6 @@
ast_setstate(chan, AST_STATE_UP);
if (chan->cdr)
ast_cdr_answer(chan->cdr);
- ast_channel_unlock(chan);
- return res;
break;
case AST_STATE_UP:
if (chan->cdr)
@@ -1512,7 +1499,7 @@
break;
}
ast_channel_unlock(chan);
- return 0;
+ return res;
}
void ast_deactivate_generator(struct ast_channel *chan)
@@ -1836,23 +1823,24 @@
int blah;
int prestate;
+ /* this function is very long so make sure there is only one return
+ * point at the end (there is only one exception to this).
+ */
ast_channel_lock(chan);
if (chan->masq) {
if (ast_do_masquerade(chan)) {
ast_log(LOG_WARNING, "Failed to perform masquerade\n");
- f = NULL;
- } else
+ } else {
f = &ast_null_frame;
- ast_channel_unlock(chan);
- return f;
+ }
+ goto done;
}
/* Stop if we're a zombie or need a soft hangup */
if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) {
if (chan->generator)
ast_deactivate_generator(chan);
- ast_channel_unlock(chan);
- return NULL;
+ goto done;
}
prestate = chan->_state;
@@ -1860,16 +1848,17 @@
/* We have DTMF that has been deferred. Return it now */
chan->dtmff.frametype = AST_FRAME_DTMF;
chan->dtmff.subclass = chan->dtmfq[0];
- /* Drop first digit */
+ /* Drop first digit from the buffer */
memmove(chan->dtmfq, chan->dtmfq + 1, sizeof(chan->dtmfq) - 1);
- ast_channel_unlock(chan);
- return &chan->dtmff;
+ f = &chan->dtmff;
+ goto done;
}
/* Read and ignore anything on the alertpipe, but read only
one sizeof(blah) per frame that we send from it */
if (chan->alertpipe[0] > -1)
read(chan->alertpipe[0], &blah, sizeof(blah));
+
#ifdef ZAPTEL_OPTIMIZATIONS
if (chan->timingfd > -1 && chan->fdno == AST_TIMING_FD && ast_test_flag(chan, AST_FLAG_EXCEPTION)) {
int res;
@@ -1902,20 +1891,22 @@
chan->timingdata = NULL;
ast_channel_unlock(chan);
}
+ /* cannot 'goto done' because the channel is already unlocked */
return &ast_null_frame;
} else
ast_log(LOG_NOTICE, "No/unknown event '%d' on timer for '%s'?\n", blah, chan->name);
} else
#endif
- /* Check for AST_GENERATOR_FD if not null. If so, call generator with -1
- arguments now so it can do whatever it needs to. */
if (chan->fds[AST_GENERATOR_FD] > -1 && chan->fdno == AST_GENERATOR_FD) {
+ /* if the AST_GENERATOR_FD is set, call the generator with args
+ * set to -1 so it can do whatever it needs to.
+ */
void *tmp = chan->generatordata;
chan->generatordata = NULL; /* reset to let ast_write get through */
chan->generator->generate(chan, tmp, -1, -1);
chan->generatordata = tmp;
- ast_channel_unlock(chan);
- return &ast_null_frame;
+ f = &ast_null_frame;
+ goto done;
}
/* Check for pending read queue */
@@ -2027,9 +2018,8 @@
/* Run generator sitting on the line if timing device not available
* and synchronous generation of outgoing frames is necessary */
if (chan->generatordata && !ast_internal_timing_enabled(chan)) {
- void *tmp;
+ void *tmp = chan->generatordata;
int res;
- int (*generate)(struct ast_channel *chan, void *tmp, int datalen, int samples);
if (chan->timingfunc) {
if (option_debug > 1)
@@ -2037,10 +2027,8 @@
ast_settimeout(chan, 0, NULL, NULL);
}
- tmp = chan->generatordata;
- chan->generatordata = NULL;
- generate = chan->generator->generate;
- res = generate(chan, tmp, f->datalen, f->samples);
+ chan->generatordata = NULL; /* reset, to let writes go through */
+ res = chan->generator->generate(chan, tmp, f->datalen, f->samples);
chan->generatordata = tmp;
if (res) {
if (option_debug > 1)
@@ -2074,8 +2062,9 @@
chan->fin &= 0x80000000;
else
chan->fin++;
+
+done:
ast_mutex_unlock(&chan->lock);
-
return f;
}
@@ -2476,101 +2465,100 @@
struct ast_channel *__ast_request_and_dial(const char *type, int format, void *data, int timeout, int *outstate, const char *cid_num, const char *cid_name, struct outgoing_helper *oh)
{
- int state = 0;
+ int dummy_outstate;
int cause = 0;
struct ast_channel *chan;
- struct ast_frame *f;
int res = 0;
+ if (outstate)
+ *outstate = 0;
+ else
+ outstate = &dummy_outstate; /* make outstate always a valid pointer */
+
chan = ast_request(type, format, data, &cause);
- if (chan) {
- if (oh) {
- if (oh->vars)
- ast_set_variables(chan, oh->vars);
- if (oh->cid_num && *oh->cid_num && oh->cid_name && *oh->cid_name)
- ast_set_callerid(chan, oh->cid_num, oh->cid_name, oh->cid_num);
- if (oh->parent_channel)
- ast_channel_inherit_variables(oh->parent_channel, chan);
- if (oh->account)
- ast_cdr_setaccount(chan, oh->account);
- }
- ast_set_callerid(chan, cid_num, cid_name, cid_num);
-
- if (!ast_call(chan, data, 0)) {
- res = 1; /* in case chan->_state is already AST_STATE_UP */
- while (timeout && (chan->_state != AST_STATE_UP)) {
- res = ast_waitfor(chan, timeout);
- if (res < 0) {
- /* Something not cool, or timed out */
+ if (!chan) {
+ ast_log(LOG_NOTICE, "Unable to request channel %s/%s\n", type, (char *)data);
+ /* compute error and return */
+ if (cause == AST_CAUSE_BUSY)
+ *outstate = AST_CONTROL_BUSY;
+ else if (cause == AST_CAUSE_CONGESTION)
+ *outstate = AST_CONTROL_CONGESTION;
+ return NULL;
+ }
+
+ if (oh) {
+ if (oh->vars)
+ ast_set_variables(chan, oh->vars);
+ /* XXX why is this necessary, for the parent_channel perhaps ? */
+ if (!ast_strlen_zero(oh->cid_num) && !ast_strlen_zero(oh->cid_name))
+ ast_set_callerid(chan, oh->cid_num, oh->cid_name, oh->cid_num);
+ if (oh->parent_channel)
+ ast_channel_inherit_variables(oh->parent_channel, chan);
+ if (oh->account)
+ ast_cdr_setaccount(chan, oh->account);
+ }
+ ast_set_callerid(chan, cid_num, cid_name, cid_num);
+
+ if (ast_call(chan, data, 0)) { /* ast_call failed... */
+ ast_log(LOG_NOTICE, "Unable to call channel %s/%s\n", type, (char *)data);
+ } else {
+ res = 1; /* mark success in case chan->_state is already AST_STATE_UP */
+ while (timeout && chan->_state != AST_STATE_UP) {
+ struct ast_frame *f;
+ res = ast_waitfor(chan, timeout);
+ if (res <= 0) /* error, timeout, or done */
+ break;
+ if (timeout > -1)
+ timeout = res;
+ f = ast_read(chan);
+ if (!f) {
+ *outstate = AST_CONTROL_HANGUP;
+ res = 0;
+ break;
+ }
+ if (f->frametype == AST_FRAME_CONTROL) {
+ switch (f->subclass) {
+ case AST_CONTROL_RINGING: /* record but keep going */
+ *outstate = f->subclass;
break;
+
+ case AST_CONTROL_BUSY:
+ case AST_CONTROL_CONGESTION:
+ case AST_CONTROL_ANSWER:
+ *outstate = f->subclass;
+ timeout = 0; /* trick to force exit from the while() */
+ break;
+
+ case AST_CONTROL_PROGRESS: /* Ignore */
+ case -1: /* Ignore -- just stopping indications */
+ break;
+
+ default:
+ ast_log(LOG_NOTICE, "Don't know what to do with control frame %d\n", f->subclass);
}
- /* If done, break out */
- if (!res)
- break;
- if (timeout > -1)
- timeout = res;
- f = ast_read(chan);
- if (!f) {
- state = AST_CONTROL_HANGUP;
- res = 0;
- break;
- }
- if (f->frametype == AST_FRAME_CONTROL) {
- if (f->subclass == AST_CONTROL_RINGING)
- state = AST_CONTROL_RINGING;
- else if ((f->subclass == AST_CONTROL_BUSY) || (f->subclass == AST_CONTROL_CONGESTION)) {
- state = f->subclass;
- ast_frfree(f);
- break;
- } else if (f->subclass == AST_CONTROL_ANSWER) {
- state = f->subclass;
- ast_frfree(f);
- break;
- } else if (f->subclass == AST_CONTROL_PROGRESS) {
- /* Ignore */
- } else if (f->subclass == -1) {
- /* Ignore -- just stopping indications */
- } else {
- ast_log(LOG_NOTICE, "Don't know what to do with control frame %d\n", f->subclass);
- }
- }
- ast_frfree(f);
}
- } else
- ast_log(LOG_NOTICE, "Unable to call channel %s/%s\n", type, (char *)data);
- } else {
- ast_log(LOG_NOTICE, "Unable to request channel %s/%s\n", type, (char *)data);
- switch(cause) {
- case AST_CAUSE_BUSY:
- state = AST_CONTROL_BUSY;
- break;
- case AST_CAUSE_CONGESTION:
- state = AST_CONTROL_CONGESTION;
- break;
- }
- }
- if (chan) {
- /* Final fixups */
- if (oh) {
- if (oh->context && *oh->context)
- ast_copy_string(chan->context, oh->context, sizeof(chan->context));
- if (oh->exten && *oh->exten)
- ast_copy_string(chan->exten, oh->exten, sizeof(chan->exten));
- if (oh->priority)
- chan->priority = oh->priority;
- }
- if (chan->_state == AST_STATE_UP)
- state = AST_CONTROL_ANSWER;
- }
- if (outstate)
- *outstate = state;
- if (chan && res <= 0) {
- if (!chan->cdr && (chan->cdr = ast_cdr_alloc())) {
+ ast_frfree(f);
+ }
+ }
+
+ /* Final fixups */
+ if (oh) {
+ if (!ast_strlen_zero(oh->context))
+ ast_copy_string(chan->context, oh->context, sizeof(chan->context));
+ if (!ast_strlen_zero(oh->exten))
+ ast_copy_string(chan->exten, oh->exten, sizeof(chan->exten));
+ if (oh->priority)
+ chan->priority = oh->priority;
+ }
+ if (chan->_state == AST_STATE_UP)
+ *outstate = AST_CONTROL_ANSWER;
+
+ if (res <= 0) {
+ if (!chan->cdr && (chan->cdr = ast_cdr_alloc()))
ast_cdr_init(chan->cdr, chan);
- }
if (chan->cdr) {
char tmp[256];
- snprintf(tmp, 256, "%s/%s", type, (char *)data);
+ snprintf(tmp, sizeof(tmp), "%s/%s", type, (char *)data);
ast_cdr_setapp(chan->cdr,"Dial",tmp);
ast_cdr_update(chan);
ast_cdr_start(chan->cdr);
@@ -3293,7 +3281,6 @@
/* Copy voice back and forth between the two channels. */
struct ast_channel *cs[3];
struct ast_frame *f;
- struct ast_channel *who = NULL;
enum ast_bridge_result res = AST_BRIDGE_COMPLETE;
int o0nativeformats;
int o1nativeformats;
@@ -3321,6 +3308,8 @@
#endif /* AST_JB */
for (;;) {
+ struct ast_channel *who, *other;
+
if ((c0->tech_pvt != pvt0) || (c1->tech_pvt != pvt1) ||
(o0nativeformats != c0->nativeformats) ||
(o1nativeformats != c1->nativeformats)) {
@@ -3372,10 +3361,12 @@
frame_put_in_jb = !ast_jb_put((who == c0) ? c1 : c0, f);
#endif /* AST_JB */
+ other = (who == c0) ? c1 : c0; /* the 'other' channel */
+
if ((f->frametype == AST_FRAME_CONTROL) && !(config->flags & AST_BRIDGE_IGNORE_SIGS)) {
if ((f->subclass == AST_CONTROL_HOLD) || (f->subclass == AST_CONTROL_UNHOLD) ||
(f->subclass == AST_CONTROL_VIDUPDATE)) {
- ast_indicate(who == c0 ? c1 : c0, f->subclass);
+ ast_indicate(other, f->subclass);
} else {
*fo = f;
*rc = who;
@@ -3391,39 +3382,29 @@
(f->frametype == AST_FRAME_HTML) ||
(f->frametype == AST_FRAME_MODEM) ||
(f->frametype == AST_FRAME_TEXT)) {
- if (f->frametype == AST_FRAME_DTMF) {
- if (((who == c0) && watch_c0_dtmf) ||
- ((who == c1) && watch_c1_dtmf)) {
- *rc = who;
- *fo = f;
- res = AST_BRIDGE_COMPLETE;
- ast_log(LOG_DEBUG, "Got DTMF on channel (%s)\n", who->name);
- break;
- } else {
- goto tackygoto;
- }
- } else {
-#if 0
- ast_log(LOG_DEBUG, "Read from %s\n", who->name);
- if (who == last)
- ast_log(LOG_DEBUG, "Servicing channel %s twice in a row?\n", last->name);
- last = who;
+ /* monitored dtmf causes exit from bridge */
+ int monitored_source = (who == c0) ? watch_c0_dtmf : watch_c1_dtmf;
+
+ if (f->frametype == AST_FRAME_DTMF && monitored_source) {
+ *fo = f;
+ *rc = who;
+ res = AST_BRIDGE_COMPLETE;
+ ast_log(LOG_DEBUG, "Got DTMF on channel (%s)\n", who->name);
+ break;
+ }
+#ifdef AST_JB
+ /* Write immediately frames, not passed through jb */
+ if(!frame_put_in_jb)
+ ast_write(other, f);
+
+ /* Check if we have to deliver now */
+ ast_jb_get_and_deliver(c0, c1);
+#else /* AST_JB */
+ /* other frames go to the other side */
+ ast_write(other, f);
#endif
-tackygoto:
-#ifdef AST_JB
- /* Write immediately frames, not passed through jb */
- if(!frame_put_in_jb)
- {
- ast_write((who == c0) ? c1 : c0, f);
- }
-
- /* Check if we have to deliver now */
- ast_jb_get_and_deliver(c0, c1);
-#else /* AST_JB */
- ast_write((who == c0) ? c1 : c0, f);
-#endif /* AST_JB */
- }
- }
+ }
+ /* XXX do we want to pass on also frames not matched above ? */
ast_frfree(f);
/* Swap who gets priority */
@@ -3518,10 +3499,10 @@
if (time_left_ms < to)
to = time_left_ms;
- if (time_left_ms <= 0) {
- if (caller_warning && config->end_sound)
+ if (time_left_ms <= 0 && config->end_sound) {
+ if (caller_warning)
bridge_playfile(c0, c1, config->end_sound, 0);
- if (callee_warning && config->end_sound)
+ if (callee_warning)
bridge_playfile(c1, c0, config->end_sound, 0);
*fo = NULL;
if (who)
@@ -3531,14 +3512,12 @@
}
if (!to) {
- if (time_left_ms >= 5000) {
- /* force the time left to round up if appropriate */
- if (caller_warning && config->warning_sound && config->play_warning)
- bridge_playfile(c0, c1, config->warning_sound,
- (time_left_ms + 500) / 1000);
- if (callee_warning && config->warning_sound && config->play_warning)
- bridge_playfile(c1, c0, config->warning_sound,
- (time_left_ms + 500) / 1000);
+ if (time_left_ms >= 5000 && config->warning_sound && config->play_warning) {
+ int t = (time_left_ms + 500) / 1000; /* round to nearest second */
+ if (caller_warning)
+ bridge_playfile(c0, c1, config->warning_sound, t);
+ if (callee_warning)
+ bridge_playfile(c1, c0, config->warning_sound, t);
}
if (config->warning_freq) {
nexteventts = ast_tvadd(nexteventts, ast_samp2tv(config->warning_freq, 1000));
@@ -3991,8 +3970,6 @@
result = spy->read_queue.head;
spy->read_queue.head = NULL;
spy->read_queue.samples = 0;
- ast_clear_flag(spy, CHANSPY_TRIGGER_FLUSH);
- return result;
} else {
if (ast_test_flag(spy, CHANSPY_WRITE_VOLADJUST)) {
for (result = spy->write_queue.head; result; result = result->next)
@@ -4001,9 +3978,9 @@
result = spy->write_queue.head;
spy->write_queue.head = NULL;
spy->write_queue.samples = 0;
- ast_clear_flag(spy, CHANSPY_TRIGGER_FLUSH);
- return result;
- }
+ }
+ ast_clear_flag(spy, CHANSPY_TRIGGER_FLUSH);
+ return result;
}
if ((spy->read_queue.samples < samples) || (spy->write_queue.samples < samples))
Modified: team/oej/test-this-branch/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/team/oej/test-this-branch/channels/chan_skinny.c?rev=22262&r1=22261&r2=22262&view=diff
==============================================================================
--- team/oej/test-this-branch/channels/chan_skinny.c (original)
+++ team/oej/test-this-branch/channels/chan_skinny.c Mon Apr 24 08:03:22 2006
@@ -121,10 +121,10 @@
* Protocol Messages *
*********************/
/* message types */
-#define KEEP_ALIVE_MESSAGE 0x0000
+#define KEEP_ALIVE_MESSAGE 0x0000
/* no additional struct */
-#define REGISTER_MESSAGE 0x0001
+#define REGISTER_MESSAGE 0x0001
typedef struct register_message {
char name[16];
int userId;
@@ -150,7 +150,7 @@
#define OFFHOOK_MESSAGE 0x0006
#define ONHOOK_MESSAGE 0x0007
-#define CAPABILITIES_RES_MESSAGE 0x0010
+#define CAPABILITIES_RES_MESSAGE 0x0010
typedef struct station_capabilities {
int codec;
int frames;
@@ -170,30 +170,30 @@
int speedDialNumber;
} speed_dial_stat_req_message;
-#define LINE_STATE_REQ_MESSAGE 0x000B
+#define LINE_STATE_REQ_MESSAGE 0x000B
typedef struct line_state_req_message {
int lineNumber;
} line_state_req_message;
-#define TIME_DATE_REQ_MESSAGE 0x000D
-#define VERSION_REQ_MESSAGE 0x000F
+#define TIME_DATE_REQ_MESSAGE 0x000D
#define BUTTON_TEMPLATE_REQ_MESSAGE 0x000E
+#define VERSION_REQ_MESSAGE 0x000F
#define SERVER_REQUEST_MESSAGE 0x0012
#define ALARM_MESSAGE 0x0020
-#define OPEN_RECIEVE_CHANNEL_ACK_MESSAGE 0x0022
-typedef struct open_recieve_channel_ack_message {
+#define OPEN_RECEIVE_CHANNEL_ACK_MESSAGE 0x0022
+typedef struct open_receive_channel_ack_message {
int status;
char ipAddr[4];
int port;
int passThruId;
-} open_recieve_channel_ack_message;
-
-#define SOFT_KEY_SET_REQ_MESSAGE 0x0025
+} open_receive_channel_ack_message;
+
+#define SOFT_KEY_SET_REQ_MESSAGE 0x0025
#define UNREGISTER_MESSAGE 0x0027
-#define SOFT_KEY_TEMPLATE_REQ_MESSAGE 0x0028
-
-#define REGISTER_ACK_MESSAGE 0x0081
+#define SOFT_KEY_TEMPLATE_REQ_MESSAGE 0x0028
+
+#define REGISTER_ACK_MESSAGE 0x0081
typedef struct register_ack_message {
int keepAlive;
char dateTemplate[6];
@@ -202,7 +202,7 @@
char res2[4];
} register_ack_message;
-#define START_TONE_MESSAGE 0x0082
+#define START_TONE_MESSAGE 0x0082
typedef struct start_tone_message {
int tone;
} start_tone_message;
@@ -290,31 +290,6 @@
int milliseconds;
int timestamp;
} definetimedate_message;
-
-#define DISPLAYTEXT_MESSAGE 0x0099
-typedef struct displaytext_message {
- char text[40];
-} displaytext_message;
-
-#define CLEAR_DISPLAY_MESSAGE 0x009A
-
-#define REGISTER_REJ_MESSAGE 0x009D
-typedef struct register_rej_message {
- char errMsg[33];
-} register_rej_message;
-
-#define CAPABILITIES_REQ_MESSAGE 0x009B
-
-#define SERVER_RES_MESSAGE 0x009E
-typedef struct server_identifier {
- char serverName[48];
-} server_identifier;
-
-typedef struct server_res_message {
- server_identifier server[5];
- int serverListenPort[5];
- int serverIpAddr[5];
-} server_res_message;
#define BUTTON_TEMPLATE_RES_MESSAGE 0x0097
@@ -477,30 +452,54 @@
button_definition definition[42];
} button_template_res_message;
-#define VERSION_RES_MESSAGE 0x0098
+#define VERSION_RES_MESSAGE 0x0098
typedef struct version_res_message {
char version[16];
} version_res_message;
-#define KEEP_ALIVE_ACK_MESSAGE 0x0100
-
-#define OPEN_RECIEVE_CHANNEL_MESSAGE 0x0105
-typedef struct open_recieve_channel_message {
+#define DISPLAYTEXT_MESSAGE 0x0099
+typedef struct displaytext_message {
+ char text[40];
+} displaytext_message;
+
+#define CLEAR_DISPLAY_MESSAGE 0x009A
+#define CAPABILITIES_REQ_MESSAGE 0x009B
+
+#define REGISTER_REJ_MESSAGE 0x009D
+typedef struct register_rej_message {
+ char errMsg[33];
+} register_rej_message;
+
+#define SERVER_RES_MESSAGE 0x009E
+typedef struct server_identifier {
+ char serverName[48];
+} server_identifier;
+
+typedef struct server_res_message {
+ server_identifier server[5];
+ int serverListenPort[5];
+ int serverIpAddr[5];
+} server_res_message;
+
+#define KEEP_ALIVE_ACK_MESSAGE 0x0100
+
+#define OPEN_RECEIVE_CHANNEL_MESSAGE 0x0105
+typedef struct open_receive_channel_message {
int conferenceId;
int partyId;
int packets;
int capability;
int echo;
int bitrate;
-} open_recieve_channel_message;
-
-#define CLOSE_RECIEVE_CHANNEL_MESSAGE 0x0106
-typedef struct close_recieve_channel_message {
+} open_receive_channel_message;
+
+#define CLOSE_RECEIVE_CHANNEL_MESSAGE 0x0106
+typedef struct close_receive_channel_message {
int conferenceId;
int partyId;
-} close_recieve_channel_message;
-
-#define SOFT_KEY_TEMPLATE_RES_MESSAGE 0x0108
+} close_receive_channel_message;
+
+#define SOFT_KEY_TEMPLATE_RES_MESSAGE 0x0108
typedef struct soft_key_template_definition {
char softKeyLabel[16];
@@ -535,7 +534,7 @@
soft_key_template_definition softKeyTemplateDefinition[32];
} soft_key_template;
-#define SOFT_KEY_SET_RES_MESSAGE 0x0109
+#define SOFT_KEY_SET_RES_MESSAGE 0x0109
static const char *soft_key_set_hack = {
"\x01\x02\x05\x03\x09\x0a\x0b\x10\x11\x12\x04\x0e\x0d\x00\x00\x00"
"\x2d\x01\x2e\x01\x31\x01\x2f\x01\x35\x01\x36\x01\x37\x01\x3c\x01"
@@ -660,9 +659,9 @@
call_info_message callinfo;
start_media_transmission_message startmedia;
stop_media_transmission_message stopmedia;
- open_recieve_channel_message openrecievechannel;
- open_recieve_channel_ack_message openrecievechannelack;
- close_recieve_channel_message closerecievechannel;
+ open_receive_channel_message openreceivechannel;
+ open_receive_channel_ack_message openreceivechannelack;
+ close_receive_channel_message closereceivechannel;
display_notify_message displaynotify;
dialed_number_message dialednumber;
} data;
@@ -1056,10 +1055,10 @@
req->data.activatecallplane.lineInstance = 0;
transmit_response(s, req);
memset(req, 0, memsize);
- req->len = htolel(sizeof(close_recieve_channel_message)+4);
- req->e = htolel(CLOSE_RECIEVE_CHANNEL_MESSAGE);
- req->data.closerecievechannel.conferenceId = 0;
- req->data.closerecievechannel.partyId = 0;
+ req->len = htolel(sizeof(close_receive_channel_message)+4);
+ req->e = htolel(CLOSE_RECEIVE_CHANNEL_MESSAGE);
+ req->data.closereceivechannel.conferenceId = 0;
+ req->data.closereceivechannel.partyId = 0;
transmit_response(s, req);
memset(req, 0, memsize);
req->len = htolel(sizeof(stop_media_transmission_message)+4);
@@ -1106,19 +1105,19 @@
skinny_req *req;
struct skinny_line *l = s->device->lines;
- req = req_alloc(sizeof(struct open_recieve_channel_message));
+ req = req_alloc(sizeof(struct open_receive_channel_message));
if (!req) {
ast_log(LOG_ERROR, "Unable to allocate skinny_request, this is bad\n");
return;
}
- req->len = htolel(sizeof(struct open_recieve_channel_message));
- req->e = htolel(OPEN_RECIEVE_CHANNEL_MESSAGE);
- req->data.openrecievechannel.conferenceId = 0;
- req->data.openrecievechannel.partyId = 0;
- req->data.openrecievechannel.packets = htolel(20);
- req->data.openrecievechannel.capability = htolel(convert_cap(l->capability));
- req->data.openrecievechannel.echo = 0;
- req->data.openrecievechannel.bitrate = 0;
+ req->len = htolel(sizeof(struct open_receive_channel_message));
+ req->e = htolel(OPEN_RECEIVE_CHANNEL_MESSAGE);
+ req->data.openreceivechannel.conferenceId = 0;
+ req->data.openreceivechannel.partyId = 0;
+ req->data.openreceivechannel.packets = htolel(20);
+ req->data.openreceivechannel.capability = htolel(convert_cap(l->capability));
+ req->data.openreceivechannel.echo = 0;
+ req->data.openreceivechannel.bitrate = 0;
transmit_response(s, req);
}
@@ -2397,43 +2396,43 @@
and dirty redial, feeding the frames we last got into the queue
function */
if (skinnydebug) {
- ast_verbose("Recieved Stimulus: Redial(%d)\n", stimulusInstance);
+ ast_verbose("Received Stimulus: Redial(%d)\n", stimulusInstance);
}
break;
case STIMULUS_SPEEDDIAL:
if (skinnydebug) {
- ast_verbose("Recieved Stimulus: SpeedDial(%d)\n", stimulusInstance);
+ ast_verbose("Received Stimulus: SpeedDial(%d)\n", stimulusInstance);
}
break;
case STIMULUS_HOLD:
/* start moh? set RTP to 0.0.0.0? */
if (skinnydebug) {
- ast_verbose("Recieved Stimulus: Hold(%d)\n", stimulusInstance);
+ ast_verbose("Received Stimulus: Hold(%d)\n", stimulusInstance);
}
break;
case STIMULUS_TRANSFER:
if (skinnydebug) {
- ast_verbose("Recieved Stimulus: Transfer(%d)\n", stimulusInstance);
+ ast_verbose("Received Stimulus: Transfer(%d)\n", stimulusInstance);
}
transmit_tone(s, SKINNY_DIALTONE);
/* XXX figure out how to transfer */
break;
case STIMULUS_CONFERENCE:
if (skinnydebug) {
- ast_verbose("Recieved Stimulus: Transfer(%d)\n", stimulusInstance);
+ ast_verbose("Received Stimulus: Transfer(%d)\n", stimulusInstance);
}
transmit_tone(s, SKINNY_DIALTONE);
/* XXX determine the best way to pull off a conference. Meetme? */
break;
case STIMULUS_VOICEMAIL:
if (skinnydebug) {
- ast_verbose("Recieved Stimulus: Voicemail(%d)\n", stimulusInstance);
+ ast_verbose("Received Stimulus: Voicemail(%d)\n", stimulusInstance);
}
/* XXX Find and dial voicemail extension */
break;
case STIMULUS_CALLPARK:
if (skinnydebug) {
- ast_verbose("Recieved Stimulus: Park Call(%d)\n", stimulusInstance);
+ ast_verbose("Received Stimulus: Park Call(%d)\n", stimulusInstance);
}
/* XXX Park the call */
break;
@@ -2460,18 +2459,18 @@
case STIMULUS_FORWARDNOANSWER:
/* Gonna be fun, not */
if (skinnydebug) {
- ast_verbose("Recieved Stimulus: Forward (%d)\n", stimulusInstance);
+ ast_verbose("Received Stimulus: Forward (%d)\n", stimulusInstance);
}
break;
case STIMULUS_DISPLAY:
/* Not sure what this is */
if (skinnydebug) {
- ast_verbose("Recieved Stimulus: Display(%d)\n", stimulusInstance);
+ ast_verbose("Received Stimulus: Display(%d)\n", stimulusInstance);
}
break;
case STIMULUS_LINE:
if (skinnydebug) {
- ast_verbose("Recieved Stimulus: Line(%d)\n", stimulusInstance);
+ ast_verbose("Received Stimulus: Line(%d)\n", stimulusInstance);
}
sub = find_subchannel_by_line(s->device->lines);
/* turn the speaker on */
@@ -2496,7 +2495,7 @@
break;
case SERVER_REQUEST_MESSAGE:
if (skinnydebug) {
- ast_verbose("Recieved Server Request\n");
+ ast_verbose("Received Server Request\n");
}
memset(req, 0, SKINNY_MAX_PACKET);
req->len = htolel(sizeof(server_res_message)+4);
@@ -2566,7 +2565,7 @@
break;
case SOFT_KEY_TEMPLATE_REQ_MESSAGE:
if (skinnydebug) {
- ast_verbose("Recieved SoftKey Template Request\n");
+ ast_verbose("Received SoftKey Template Request\n");
}
memset(req, 0, SKINNY_MAX_PACKET);
req->len = htolel(sizeof(soft_key_template)+4);
@@ -2775,18 +2774,18 @@
}
}
break;
- case OPEN_RECIEVE_CHANNEL_ACK_MESSAGE:
+ case OPEN_RECEIVE_CHANNEL_ACK_MESSAGE:
if (skinnydebug) {
- ast_verbose("Recieved Open Recieve Channel Ack\n");
- }
- status = letohl(req->data.openrecievechannelack.status);
+ ast_verbose("Received Open Receive Channel Ack\n");
+ }
+ status = letohl(req->data.openreceivechannelack.status);
if (status) {
- ast_log(LOG_ERROR, "Open Recieve Channel Failure\n");
+ ast_log(LOG_ERROR, "Open Receive Channel Failure\n");
break;
}
/* ENDIAN */
- memcpy(addr, req->data.openrecievechannelack.ipAddr, sizeof(addr));
- port = htolel(req->data.openrecievechannelack.port);
+ memcpy(addr, req->data.openreceivechannelack.ipAddr, sizeof(addr));
+ port = htolel(req->data.openreceivechannelack.port);
sin.sin_family = AF_INET;
/* I smell endian problems */
memcpy(&sin.sin_addr, addr, sizeof(sin.sin_addr));
Modified: team/oej/test-this-branch/formats/format_pcm.c
URL: http://svn.digium.com/view/asterisk/team/oej/test-this-branch/formats/format_pcm.c?rev=22262&r1=22261&r2=22262&view=diff
==============================================================================
--- team/oej/test-this-branch/formats/format_pcm.c (original)
+++ team/oej/test-this-branch/formats/format_pcm.c Mon Apr 24 08:03:22 2006
@@ -455,7 +455,7 @@
.tell = pcm_tell,
.read = pcm_read,
.buf_size = (BUF_SIZE * 2) + AST_FRIENDLY_OFFSET,
- .lockp = &me,
+ .module = &mod_data,
};
static const struct ast_format au_f = {
Modified: team/oej/test-this-branch/pbx.c
URL: http://svn.digium.com/view/asterisk/team/oej/test-this-branch/pbx.c?rev=22262&r1=22261&r2=22262&view=diff
==============================================================================
--- team/oej/test-this-branch/pbx.c (original)
+++ team/oej/test-this-branch/pbx.c Mon Apr 24 08:03:22 2006
@@ -1025,7 +1025,6 @@
{
struct ast_custom_function *acf;
int count_acf = 0;
- int print_acf = 0;
int like = 0;
if (argc == 4 && (!strcmp(argv[2], "like")) ) {
@@ -1037,18 +1036,8 @@
ast_cli(fd, "%s Custom Functions:\n--------------------------------------------------------------------------------\n", like ? "Matching" : "Installed");
for (acf = acf_root ; acf; acf = acf->next) {
- print_acf = 0;
- if (like) {
- if (strstr(acf->name, argv[3])) {
- print_acf = 1;
- count_acf++;
- }
- } else {
- print_acf = 1;
+ if (!like || strstr(acf->name, argv[3])) {
count_acf++;
- }
-
- if (print_acf) {
ast_cli(fd, "%-20.20s %-35.35s %s\n", acf->name, acf->syntax, acf->synopsis);
}
}
@@ -1067,7 +1056,8 @@
char stxtitle[40], *syntax = NULL;
int synopsis_size, description_size, syntax_size;
- if (argc < 3) return RESULT_SHOWUSAGE;
+ if (argc < 3)
+ return RESULT_SHOWUSAGE;
if (!(acf = ast_custom_function_find(argv[2]))) {
ast_cli(fd, "No function by that name registered.\n");
@@ -1159,7 +1149,7 @@
int ast_custom_function_unregister(struct ast_custom_function *acf)
{
- struct ast_custom_function *acfptr, *lastacf = NULL;
+ struct ast_custom_function *cur, *prev = NULL;
int res = -1;
if (!acf)
@@ -1171,22 +1161,20 @@
return -1;
}
- for (acfptr = acf_root; acfptr; acfptr = acfptr->next) {
- if (acfptr == acf) {
- if (lastacf) {
- lastacf->next = acf->next;
- } else {
+ for (cur = acf_root; cur; prev = cur, cur = cur->next) {
+ if (cur == acf) {
+ if (prev)
+ prev->next = acf->next;
+ else
acf_root = acf->next;
- }
res = 0;
break;
}
- lastacf = acfptr;
}
ast_mutex_unlock(&acflock);
- if (!res && (option_verbose > 1))
+ if (!res && option_verbose > 1)
ast_verbose(VERBOSE_PREFIX_2 "Unregistered custom function %s\n", acf->name);
return res;
Modified: team/oej/test-this-branch/res/res_features.c
URL: http://svn.digium.com/view/asterisk/team/oej/test-this-branch/res/res_features.c?rev=22262&r1=22261&r2=22262&view=diff
==============================================================================
--- team/oej/test-this-branch/res/res_features.c (original)
+++ team/oej/test-this-branch/res/res_features.c Mon Apr 24 08:03:22 2006
@@ -194,6 +194,14 @@
int ast_park_call_full(struct ast_channel *chan, struct ast_channel *peer, int timeout, int *extout, struct ast_parkinglot *parkinglot);
struct ast_parkinglot *find_parkinglot(const char *name);
+/* store context, priority and extension */
+static void set_c_e_p(struct ast_channel *chan, const char *ctx, const char *ext, int pri)
+{
+ ast_copy_string(chan->context, ctx, sizeof(chan->context));
+ ast_copy_string(chan->exten, ext, sizeof(chan->exten));
+ chan->priority = pri;
+}
+
/*! If GOTO_ON_BLINDXFR is set, transferer in a blind transfer will be sent there. */
static void check_goto_on_transfer(struct ast_channel *chan)
{
@@ -248,7 +256,7 @@
ast_bridge_call(tobj->peer, tobj->chan, &tobj->bconfig);
ast_hangup(tobj->chan);
ast_hangup(tobj->peer);
- tobj->chan = tobj->peer = NULL;
+ bzero(tobj, sizeof(*tobj)); /* XXX for safety */
free(tobj);
return NULL;
}
@@ -447,10 +455,7 @@
pu->parkingnum = x;
pu->parkinglot = parkinglot;
- if (timeout > 0)
- pu->parkingtime = timeout;
- else
- pu->parkingtime = parkingtime;
+ pu->parkingtime = (timeout > 0) ? timeout : parkingtime;
if (extout)
*extout = x;
@@ -536,9 +541,7 @@
ast_channel_masquerade(chan, rchan);
/* Setup the extensions and such */
- ast_copy_string(chan->context, rchan->context, sizeof(chan->context));
- ast_copy_string(chan->exten, rchan->exten, sizeof(chan->exten));
- chan->priority = rchan->priority;
+ set_c_e_p(chan, rchan->context, rchan->exten, rchan->priority);
/* Make the masq execute */
f = ast_read(chan);
@@ -564,6 +567,39 @@
#define FEATURE_SENSE_CHAN (1 << 0)
#define FEATURE_SENSE_PEER (1 << 1)
+/*
+ * if the file name is non-empty, try to play it.
+ * Return 0 if success, -1 if error, digit if interrupted by a digit.
+ * If digits == "" then we can simply check for non-zero.
+ *
+ * XXX there are probably many replicas of this function in the source tree,
+ * that should be merged.
+ */
+static int stream_and_wait(struct ast_channel *chan, const char *file, const char *language, const char *digits)
+{
+ int res = 0;
+ if (!ast_strlen_zero(file)) {
+ res = ast_streamfile(chan, file, language);
+ if (!res)
+ res = ast_waitstream(chan, digits);
+ }
+ return res;
+}
+
+/*
+ * set caller and callee according to the direction
+ */
+static void set_peers(struct ast_channel **caller, struct ast_channel **callee,
+ struct ast_channel *peer, struct ast_channel *chan, int sense)
+{
+ if (sense == FEATURE_SENSE_PEER) {
+ *caller = peer;
+ *callee = chan;
+ } else {
+ *callee = peer;
+ *caller = chan;
+ }
+}
static int builtin_automonitor(struct ast_channel *chan, struct ast_channel *peer, struct ast_bridge_config *config, char *code, int sense)
{
@@ -572,36 +608,26 @@
size_t len;
struct ast_channel *caller_chan = NULL, *callee_chan = NULL;
-
- if(sense == 2) {
- caller_chan = peer;
- callee_chan = chan;
- } else {
- callee_chan = peer;
- caller_chan = chan;
- }
-
if (!monitor_ok) {
ast_log(LOG_ERROR,"Cannot record the call. The monitor application is disabled.\n");
return -1;
}
- if (!monitor_app) {
- if (!(monitor_app = pbx_findapp("Monitor"))) {
- monitor_ok=0;
- ast_log(LOG_ERROR,"Cannot record the call. The monitor application is disabled.\n");
- return -1;
- }
- }
+ if (!monitor_app && !(monitor_app = pbx_findapp("Monitor"))) {
+ monitor_ok=0;
+ ast_log(LOG_ERROR,"Cannot record the call. The monitor application is disabled.\n");
+ return -1;
+ }
+
+ set_peers(&caller_chan, &callee_chan, peer, chan, sense);
+
if (!ast_strlen_zero(courtesytone)) {
if (ast_autoservice_start(callee_chan))
return -1;
- if (!ast_streamfile(caller_chan, courtesytone, caller_chan->language)) {
- if (ast_waitstream(caller_chan, "") < 0) {
- ast_log(LOG_WARNING, "Failed to play courtesy tone!\n");
- ast_autoservice_stop(callee_chan);
- return -1;
- }
+ if (stream_and_wait(caller_chan, courtesytone, caller_chan->language, "")) {
+ ast_log(LOG_WARNING, "Failed to play courtesy tone!\n");
+ ast_autoservice_stop(callee_chan);
+ return -1;
}
if (ast_autoservice_stop(callee_chan))
return -1;
@@ -666,70 +692,65 @@
return FEATURE_RETURN_HANGUP;
}
+static int finishup(struct ast_channel *chan)
+{
+ int res;
+
+ ast_moh_stop(chan);
+ res = ast_autoservice_stop(chan);
+ ast_indicate(chan, AST_CONTROL_UNHOLD);
+ return res;
+}
+
[... 732 lines stripped ...]
More information about the asterisk-commits
mailing list