aboutsummaryrefslogtreecommitdiffstats
path: root/channel.c
diff options
context:
space:
mode:
author(no author) <(no author)@f38db490-d61c-443f-a65b-d21fe96a405b>2005-11-21 16:53:51 +0000
committer(no author) <(no author)@f38db490-d61c-443f-a65b-d21fe96a405b>2005-11-21 16:53:51 +0000
commit0721731e93eb315ab19418b95fad8690417b8994 (patch)
tree84965a610f6ae7e51cd499f8bd89464f247db803 /channel.c
parent27a9c96742202c8188b53a0173649de479256b69 (diff)
This commit was manufactured by cvs2svn to create tag 'v1-0-10'.
git-svn-id: http://svn.digium.com/svn/asterisk/tags/v1-0-10@7178 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'channel.c')
-rwxr-xr-xchannel.c55
1 files changed, 41 insertions, 14 deletions
diff --git a/channel.c b/channel.c
index 2f6f28d7f..cb43057f1 100755
--- a/channel.c
+++ b/channel.c
@@ -1089,11 +1089,11 @@ int ast_waitfor(struct ast_channel *c, int ms)
return ms;
}
-char ast_waitfordigit(struct ast_channel *c, int ms)
+int ast_waitfordigit(struct ast_channel *c, int ms)
{
/* XXX Should I be merged with waitfordigit_full XXX */
struct ast_frame *f;
- char result = 0;
+ int result = 0;
/* Stop if we're a zombie or need a soft hangup */
if (c->zombie || ast_check_hangup(c))
return -1;
@@ -1133,7 +1133,7 @@ int ast_settimeout(struct ast_channel *c, int samples, int (*func)(void *data),
#endif
return res;
}
-char ast_waitfordigit_full(struct ast_channel *c, int ms, int audiofd, int cmdfd)
+int ast_waitfordigit_full(struct ast_channel *c, int ms, int audiofd, int cmdfd)
{
struct ast_frame *f;
struct ast_channel *rchan;
@@ -1144,8 +1144,11 @@ char ast_waitfordigit_full(struct ast_channel *c, int ms, int audiofd, int cmdfd
return -1;
/* Wait for a digit, no more than ms milliseconds total. */
while(ms) {
+ errno = 0;
rchan = ast_waitfor_nandfds(&c, 1, &cmdfd, (cmdfd > -1) ? 1 : 0, NULL, &outfd, &ms);
if ((!rchan) && (outfd < 0) && (ms)) {
+ if (errno == 0 || errno == EINTR)
+ continue;
ast_log(LOG_WARNING, "Wait failed (%s)\n", strerror(errno));
return -1;
} else if (outfd > -1) {
@@ -1394,6 +1397,7 @@ struct ast_frame *ast_read(struct ast_channel *chan)
ast_settimeout(chan, 160, generator_force, chan);
}
}
+ /* High bit prints debugging */
if (chan->fin & 0x80000000)
ast_frame_dump(chan->name, f, "<<");
if ((chan->fin & 0x7fffffff) == 0x7fffffff)
@@ -1598,6 +1602,7 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
return 0;
}
}
+ /* High bit prints debugging */
if (chan->fout & 0x80000000)
ast_frame_dump(chan->name, fr, ">>");
CHECK_BLOCKING(chan);
@@ -1616,6 +1621,14 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
case AST_FRAME_TEXT:
if (chan->pvt->send_text)
res = chan->pvt->send_text(chan, (char *) fr->data);
+ else
+ res = 0;
+ break;
+ case AST_FRAME_HTML:
+ if (chan->pvt->send_html)
+ res = chan->pvt->send_html(chan, fr->subclass, (char *) fr->data, fr->datalen);
+ else
+ res = 0;
break;
case AST_FRAME_VIDEO:
/* XXX Handle translation of video codecs one day XXX */
@@ -1670,7 +1683,6 @@ int ast_write(struct ast_channel *chan, struct ast_frame *fr)
chan->fout &= 0x80000000;
else
chan->fout++;
- chan->fout++;
}
ast_mutex_unlock(&chan->lock);
return res;
@@ -1888,7 +1900,7 @@ struct ast_channel *ast_request(char *type, int format, void *data)
manager_event(EVENT_FLAG_CALL, "Newchannel",
"Channel: %s\r\n"
"State: %s\r\n"
- "Callerid: %s\r\n"
+ "CallerID: %s\r\n"
"Uniqueid: %s\r\n",
c->name, ast_state2str(c->_state), c->callerid ? c->callerid : "<unknown>", c->uniqueid);
}
@@ -2001,7 +2013,7 @@ int ast_readstring(struct ast_channel *c, char *s, int len, int timeout, int fti
{
int pos=0;
int to = ftimeout;
- char d;
+ int d;
/* XXX Merge with full version? XXX */
/* Stop if we're a zombie or need a soft hangup */
if (c->zombie || ast_check_hangup(c))
@@ -2040,7 +2052,7 @@ int ast_readstring_full(struct ast_channel *c, char *s, int len, int timeout, in
{
int pos=0;
int to = ftimeout;
- char d;
+ int d;
/* Stop if we're a zombie or need a soft hangup */
if (c->zombie || ast_check_hangup(c))
return -1;
@@ -2199,13 +2211,14 @@ int ast_do_masquerade(struct ast_channel *original)
struct ast_frame *cur, *prev;
struct ast_channel_pvt *p;
struct ast_channel *clone = original->masq;
+ struct ast_channel_monitor *monitor;
int rformat = original->readformat;
int wformat = original->writeformat;
char newn[100];
char orig[100];
char masqn[100];
char zombn[100];
-
+
#if 1
ast_log(LOG_DEBUG, "Actually Masquerading %s(%d) into the structure of %s(%d)\n",
clone->name, clone->_state, original->name, original->_state);
@@ -2304,9 +2317,17 @@ int ast_do_masquerade(struct ast_channel *original)
strncpy(clone->name, zombn, sizeof(clone->name) - 1);
manager_event(EVENT_FLAG_CALL, "Rename", "Oldname: %s\r\nNewname: %s\r\nUniqueid: %s\r\n", masqn, zombn, clone->uniqueid);
- /* Keep the same language. */
/* Update the type. */
original->type = clone->type;
+
+ /* copy the monitor */
+ monitor = original->monitor;
+ original->monitor = clone->monitor;
+ clone->monitor = monitor;
+
+ /* Keep the same language. */
+ strncpy(original->language, clone->language, sizeof(original->language));
+
/* Copy the FD's */
for (x=0;x<AST_MAX_FDS;x++) {
original->fds[x] = clone->fds[x];
@@ -2362,6 +2383,9 @@ int ast_do_masquerade(struct ast_channel *original)
/* Set the read format */
ast_set_read_format(original, rformat);
+ /* Copy the music class */
+ strncpy(original->musicclass, clone->musicclass, sizeof(original->musicclass) - 1);
+
ast_log(LOG_DEBUG, "Putting channel %s in %d/%d formats\n", original->name, wformat, rformat);
/* Okay. Last thing is to let the channel driver know about all this mess, so he
@@ -2387,8 +2411,10 @@ int ast_do_masquerade(struct ast_channel *original)
ast_channel_free(clone);
manager_event(EVENT_FLAG_CALL, "Hangup", "Channel: %s\r\n", zombn);
} else {
+ struct ast_frame null_frame = { AST_FRAME_NULL, };
ast_log(LOG_DEBUG, "Released clone lock on '%s'\n", clone->name);
clone->zombie=1;
+ ast_queue_frame(clone, &null_frame);
ast_mutex_unlock(&clone->lock);
}
@@ -2419,7 +2445,7 @@ void ast_set_callerid(struct ast_channel *chan, char *callerid, int anitoo)
ast_cdr_setcid(chan->cdr, chan);
manager_event(EVENT_FLAG_CALL, "Newcallerid",
"Channel: %s\r\n"
- "Callerid: %s\r\n"
+ "CallerID: %s\r\n"
"Uniqueid: %s\r\n",
chan->name, chan->callerid ?
chan->callerid : "<Unknown>",
@@ -2436,14 +2462,14 @@ int ast_setstate(struct ast_channel *chan, int state)
manager_event(EVENT_FLAG_CALL, "Newchannel",
"Channel: %s\r\n"
"State: %s\r\n"
- "Callerid: %s\r\n"
+ "CallerID: %s\r\n"
"Uniqueid: %s\r\n",
chan->name, ast_state2str(chan->_state), chan->callerid ? chan->callerid : "<unknown>", chan->uniqueid);
} else {
manager_event(EVENT_FLAG_CALL, "Newstate",
"Channel: %s\r\n"
"State: %s\r\n"
- "Callerid: %s\r\n"
+ "CallerID: %s\r\n"
"Uniqueid: %s\r\n",
chan->name, ast_state2str(chan->_state), chan->callerid ? chan->callerid : "<unknown>", chan->uniqueid);
}
@@ -2667,6 +2693,7 @@ int ast_channel_bridge(struct ast_channel *c0, struct ast_channel *c1, struct as
(f->frametype == AST_FRAME_TEXT) ||
(f->frametype == AST_FRAME_VIDEO) ||
(f->frametype == AST_FRAME_IMAGE) ||
+ (f->frametype == AST_FRAME_HTML) ||
(f->frametype == AST_FRAME_DTMF)) {
if ((f->frametype == AST_FRAME_DTMF) &&
(flags & (AST_BRIDGE_DTMF_CHANNEL_0 | AST_BRIDGE_DTMF_CHANNEL_1))) {
@@ -2899,8 +2926,8 @@ unsigned int ast_get_group(char *s)
/* Just one */
finish = start;
} else {
- ast_log(LOG_ERROR, "Syntax error parsing '%s' at '%s'. Using '0'\n", s,piece);
- return 0;
+ ast_log(LOG_ERROR, "Syntax error parsing '%s' at '%s'.\n", s, piece);
+ continue;
}
for (x=start;x<=finish;x++) {
if ((x > 31) || (x < 0)) {