[asterisk-dev] How to bridge a channel after swapping
Henry Margies
henry.margies at gmx.de
Wed Jun 14 08:32:16 MST 2006
Hello,
I wrote a small zaptel application for the zaptel channel. This
function/application is just swapping the active channel and the channel
on hold.
I just took this from the place where chan_zap.c is swapping the
channels for call waiting.
It works well but the channel which is put on hold is not hearing the
music on hold.
I just do:
if (ast_bridged_channel(p->subs[sub].owner))
ast_moh_start(ast_bridged_channel(p->subs[sub].owner), NULL);
But it seems that this channel is not bridged. Any comments on how to
achieve that would be fine.
Background: Using the feature application mapping I would like to swap
between active channel and channel on hold. But this function should
also work for swapping to the channel which is doing call waiting.
The whole function is here:
static int app_zap_swap(struct ast_channel *chan, void *data)
{
struct zt_pvt *p = chan->tech_pvt;
int sub;
ast_log(LOG_ERROR, "Swapping channels\n");
if (p->subs[SUB_THREEWAY].owner)
sub = SUB_THREEWAY;
else if (p->subs[SUB_CALLWAIT].owner)
sub = SUB_CALLWAIT;
else {
ast_log(LOG_ERROR, "No third party for swapping channels\n");
return RESULT_SUCCESS;
}
/* Swap to call-wait */
swap_subs(p, SUB_REAL, sub);
tone_zone_play_tone(p->subs[SUB_REAL].zfd, -1);
p->owner = p->subs[SUB_REAL].owner;
ast_log(LOG_DEBUG, "Making %s the new owner\n", p->owner->name);
if (p->owner->_state == AST_STATE_RINGING) {
ast_setstate(p->owner, AST_STATE_UP);
p->subs[SUB_REAL].needanswer = 1;
}
p->callwaitingrepeat = 0;
p->cidcwexpire = 0;
/* Start music on hold if appropriate */
if (ast_bridged_channel(p->subs[sub].owner))
ast_moh_start(ast_bridged_channel(p->subs[sub].owner), NULL);
if (ast_bridged_channel(p->subs[SUB_REAL].owner))
ast_moh_stop(ast_bridged_channel(p->subs[SUB_REAL].owner));
update_conf(p);
return RESULT_SUCCESS;
}
Any help would be great,
Henry
More information about the asterisk-dev
mailing list