summaryrefslogtreecommitdiff
path: root/channels/chan_local.c
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2012-05-10 21:29:41 +0000
committerRichard Mudgett <rmudgett@digium.com>2012-05-10 21:29:41 +0000
commit4ea636c7768bca2e2decb96f1b08bfdd9f32bca9 (patch)
tree3abc3aa14879d0e0f6d80218499a4f6b86f4d5ff /channels/chan_local.c
parentdd81b047dbf15a501b81354db505daf50703a1a0 (diff)
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
Diffstat (limited to 'channels/chan_local.c')
-rw-r--r--channels/chan_local.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/channels/chan_local.c b/channels/chan_local.c
index a7e83bcfa..a37a4a4ed 100644
--- a/channels/chan_local.c
+++ b/channels/chan_local.c
@@ -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)
{