automerge commit

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2-netsec@43516 65c4cc65-6c06-0410-ace0-fbb531ad65f3
1.2-netsec
Automerge script 19 years ago
parent bb63a367e3
commit c5056e1736

@ -237,106 +237,98 @@ static void set_volume(struct ast_channel *chan, struct chanspy_translation_help
static int channel_spy(struct ast_channel *chan, struct ast_channel *spyee, int *volfactor, int fd) static int channel_spy(struct ast_channel *chan, struct ast_channel *spyee, int *volfactor, int fd)
{ {
struct chanspy_translation_helper csth; struct chanspy_translation_helper csth;
int running, res = 0, x = 0; int running = 0, res = 0, x = 0;
char inp[24]; char inp[24] = "", *name = NULL;
char *name=NULL; struct ast_frame *f = NULL;
struct ast_frame *f;
if ((chan && ast_check_hangup(chan)) || (spyee && ast_check_hangup(spyee)))
return 0;
running = (chan && !ast_check_hangup(chan) && spyee && !ast_check_hangup(spyee)); name = ast_strdupa(spyee->name);
if (option_verbose > 1)
if (running) { ast_verbose(VERBOSE_PREFIX_2 "Spying on channel %s\n", name);
memset(inp, 0, sizeof(inp));
name = ast_strdupa(spyee->name); memset(&csth, 0, sizeof(csth));
if (option_verbose >= 2) ast_set_flag(&csth.spy, CHANSPY_FORMAT_AUDIO);
ast_verbose(VERBOSE_PREFIX_2 "Spying on channel %s\n", name); ast_set_flag(&csth.spy, CHANSPY_TRIGGER_NONE);
ast_set_flag(&csth.spy, CHANSPY_MIXAUDIO);
memset(&csth, 0, sizeof(csth)); csth.spy.type = chanspy_spy_type;
ast_set_flag(&csth.spy, CHANSPY_FORMAT_AUDIO); csth.spy.status = CHANSPY_RUNNING;
ast_set_flag(&csth.spy, CHANSPY_TRIGGER_NONE); csth.spy.read_queue.format = AST_FORMAT_SLINEAR;
ast_set_flag(&csth.spy, CHANSPY_MIXAUDIO); csth.spy.write_queue.format = AST_FORMAT_SLINEAR;
csth.spy.type = chanspy_spy_type; ast_mutex_init(&csth.spy.lock);
csth.spy.status = CHANSPY_RUNNING; csth.volfactor = *volfactor;
csth.spy.read_queue.format = AST_FORMAT_SLINEAR; set_volume(chan, &csth);
csth.spy.write_queue.format = AST_FORMAT_SLINEAR; csth.spy.read_vol_adjustment = csth.volfactor;
ast_mutex_init(&csth.spy.lock); csth.spy.write_vol_adjustment = csth.volfactor;
csth.volfactor = *volfactor; csth.fd = fd;
set_volume(chan, &csth);
csth.spy.read_vol_adjustment = csth.volfactor; if (start_spying(spyee, chan, &csth.spy)) {
csth.spy.write_vol_adjustment = csth.volfactor; ast_channel_spy_free(&csth.spy);
csth.fd = fd; return 0;
if (start_spying(spyee, chan, &csth.spy))
running = 0;
} }
if (running) { ast_activate_generator(chan, &spygen, &csth);
running = 1;
ast_activate_generator(chan, &spygen, &csth); while (csth.spy.status == CHANSPY_RUNNING &&
(res = ast_waitfor(chan, -1) > -1)) {
while (csth.spy.status == CHANSPY_RUNNING &&
chan && !ast_check_hangup(chan) && /* Read in frame from channel, break out if no frame */
spyee && if (!(f = ast_read(chan)))
!ast_check_hangup(spyee) && break;
running == 1 &&
(res = ast_waitfor(chan, -1) > -1)) { /* Now if this is DTMF then we have to handle it as such, otherwise just skip it */
if ((f = ast_read(chan))) { res = 0;
res = 0; if (f->frametype == AST_FRAME_DTMF)
if (f->frametype == AST_FRAME_DTMF) { res = f->subclass;
res = f->subclass; ast_frfree(f);
} if (!res)
ast_frfree(f); continue;
if (!res) {
continue; if (x == sizeof(inp))
} x = 0;
} else {
if (res < 0) {
running = -1;
break;
}
/* Process DTMF digits */
if (res == '#') {
if (!ast_strlen_zero(inp)) {
running = x ? atoi(inp) : -1;
break; break;
} else {
(*volfactor)++;
if (*volfactor > 4)
*volfactor = -1;
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "Setting spy volume on %s to %d\n", chan->name, *volfactor);
csth.volfactor = *volfactor;
set_volume(chan, &csth);
csth.spy.read_vol_adjustment = csth.volfactor;
csth.spy.write_vol_adjustment = csth.volfactor;
} }
if (x == sizeof(inp)) { } else if (res == '*') {
x = 0; break;
} } else if (res >= 48 && res <= 57) {
if (res < 0) { inp[x++] = res;
running = -1;
}
if (res == 0) {
continue;
} else if (res == '*') {
running = 0;
} else if (res == '#') {
if (!ast_strlen_zero(inp)) {
running = x ? atoi(inp) : -1;
break;
} else {
(*volfactor)++;
if (*volfactor > 4) {
*volfactor = -4;
}
if (option_verbose > 2) {
ast_verbose(VERBOSE_PREFIX_3 "Setting spy volume on %s to %d\n", chan->name, *volfactor);
}
csth.volfactor = *volfactor;
set_volume(chan, &csth);
csth.spy.read_vol_adjustment = csth.volfactor;
csth.spy.write_vol_adjustment = csth.volfactor;
}
} else if (res >= 48 && res <= 57) {
inp[x++] = res;
}
}
ast_deactivate_generator(chan);
if (csth.spy.chan) {
csth.spy.status = CHANSPY_DONE;
ast_mutex_lock(&csth.spy.chan->lock);
ast_channel_spy_remove(csth.spy.chan, &csth.spy);
ast_mutex_unlock(&csth.spy.chan->lock);
} }
}
if (option_verbose >= 2) { ast_deactivate_generator(chan);
ast_verbose(VERBOSE_PREFIX_2 "Done Spying on channel %s\n", name);
} ast_mutex_lock(&csth.spy.lock);
} else { if (csth.spy.chan) {
running = 0; csth.spy.status = CHANSPY_DONE;
ast_mutex_lock(&csth.spy.chan->lock);
ast_channel_spy_remove(csth.spy.chan, &csth.spy);
ast_mutex_unlock(&csth.spy.chan->lock);
} }
ast_mutex_unlock(&csth.spy.lock);
if (option_verbose > 1)
ast_verbose(VERBOSE_PREFIX_2 "Done Spying on channel %s\n", name);
ast_channel_spy_free(&csth.spy); ast_channel_spy_free(&csth.spy);

@ -1020,7 +1020,7 @@ int ast_channel_spy_add(struct ast_channel *chan, struct ast_channel_spy *spy)
/* Clean up a channel's spy information */ /* Clean up a channel's spy information */
static void spy_cleanup(struct ast_channel *chan) static void spy_cleanup(struct ast_channel *chan)
{ {
if (AST_LIST_EMPTY(&chan->spies->list)) if (AST_LIST_FIRST(&chan->spies->list))
return; return;
if (chan->spies->read_translator.path) if (chan->spies->read_translator.path)
ast_translator_free_path(chan->spies->read_translator.path); ast_translator_free_path(chan->spies->read_translator.path);

Loading…
Cancel
Save