Run predial routine on local;2 channel where you would expect.

Before this patch, the predial routine executes on the ;1 channel of a
local channel pair.  Executing predial on the ;1 channel of a local
channel pair is of limited utility.  Any channel variables set by the
predial routine executing on the ;1 channel will not be available when the
local channel executes dialplan on the ;2 channel.

* Create ast_pre_call() and an associated pre_call() technology callback
to handle running the predial routine.  If a channel technology does not
provide the callback, the predial routine is simply run on the channel.

Review: https://reviewboard.asterisk.org/r/1903/


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@366183 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Richard Mudgett
2012-05-10 21:29:41 +00:00
parent dd81b047db
commit 4ea636c776
4 changed files with 80 additions and 1 deletions

View File

@@ -95,6 +95,7 @@ static struct ast_jb_conf g_jb_conf = {
static struct ast_channel *local_request(const char *type, struct ast_format_cap *cap, const struct ast_channel *requestor, const char *data, int *cause);
static int local_digit_begin(struct ast_channel *ast, char digit);
static int local_digit_end(struct ast_channel *ast, char digit, unsigned int duration);
static int local_pre_call(struct ast_channel *ast, const char *sub_args);
static int local_call(struct ast_channel *ast, const char *dest, int timeout);
static int local_hangup(struct ast_channel *ast);
static int local_answer(struct ast_channel *ast);
@@ -116,6 +117,7 @@ static struct ast_channel_tech local_tech = {
.requester = local_request,
.send_digit_begin = local_digit_begin,
.send_digit_end = local_digit_end,
.pre_call = local_pre_call,
.call = local_call,
.hangup = local_hangup,
.answer = local_answer,
@@ -1257,6 +1259,34 @@ static struct ast_channel *local_request(const char *type, struct ast_format_cap
return chan;
}
static int local_pre_call(struct ast_channel *ast, const char *sub_args)
{
struct local_pvt *p = ast_channel_tech_pvt(ast);
struct ast_channel *chan;
int res;
ao2_lock(p);
chan = p->chan;
if (chan) {
ast_channel_ref(chan);
}
ao2_unlock(p);
if (!chan) {
return -1;
}
/*
* Execute the predial routine on the ;2 channel so any channel
* variables set by the predial will be available to the local
* channel PBX.
*/
ast_channel_unlock(ast);
res = ast_app_exec_sub(NULL, chan, sub_args);
ast_channel_unref(chan);
ast_channel_lock(ast);
return res;
}
/*! \brief CLI command "local show channels" */
static char *locals_show(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
{