[asterisk-dev] Modification to ChanisAvail to save BRIDGEDCHAN

Alexander Lopez alex.lopez at opsys.com
Sun Jan 29 11:00:49 MST 2006


I had not defined the variable as struct and was expecting a
one-dementional answer. SO I am now using a struct def for bc and I am
trying to get bc->name to be placed into the variable, but I do not get
errors or any results.

Index: apps/app_chanisavail.c
===================================================================
--- apps/app_chanisavail.c      (revision 8848)
+++ apps/app_chanisavail.c      (working copy)
@@ -61,6 +61,7 @@
 "  ${AVAILCHAN}     - the name of the available channel, if one
exists\n"
 "  ${AVAILORIGCHAN} - the canonical channel name that was used to
create the channel\n"
 "  ${AVAILSTATUS}   - the status code for the available channel\n"
+"  ${BRIDGEDCHAN}   - the canonical channel name of the Bridged channel
(only with 's')\n"
 "  Options:\n"
 "    s - Consider the channel unavailable if the channel is in use at
all\n"
 "    j - Support jumping to priority n+101 if no channel is
available\n";
@@ -75,7 +76,7 @@
        int status;
        struct localuser *u;
        char *info, tmp[512], trychan[512], *peers, *tech, *number,
*rest, *cur;
-       struct ast_channel *tempchan;
+       struct ast_channel *tempchan, *bc = NULL;
        AST_DECLARE_APP_ARGS(args,
                AST_APP_ARG(reqchans);
                AST_APP_ARG(options);
@@ -133,6 +134,8 @@
                                        pbx_builtin_setvar_helper(chan,
"AVAILORIGCHAN", tmp);
                                        snprintf(tmp, sizeof(tmp), "%d",
status);
                                        pbx_builtin_setvar_helper(chan,
"AVAILSTATUS", tmp);
+                                       bc = ast_bridged_channel(chan);
+                                       pbx_builtin_setvar_helper(chan,
"BRIDGEDCHAN", bc->name);
                                        ast_hangup(tempchan);
                                        tempchan = NULL;
                                        res = 1;
@@ -140,6 +143,8 @@
                        } else {
                                snprintf(tmp, sizeof(tmp), "%d",
status);
                                pbx_builtin_setvar_helper(chan,
"AVAILSTATUS", tmp);
+                               bc = ast_bridged_channel(chan);
+                               pbx_builtin_setvar_helper(chan,
"BRIDGEDCHAN", bc->name);
                        }
                        cur = rest;
                } while (cur); 

> -----Original Message-----
> From: asterisk-dev-bounces at lists.digium.com 
> [mailto:asterisk-dev-bounces at lists.digium.com] On Behalf Of BJ Weschke
> Sent: Sunday, January 29, 2006 6:41 AM
> To: Asterisk Developers Mailing List
> Subject: Re: [asterisk-dev] Modification to ChanisAvail to 
> save BRIDGEDCHAN
> 
>  You're looking for chan->name instead of the return of
> ast_bridged_channel(..) which is the entire channel structure.
> 



More information about the asterisk-dev mailing list