Asterisk - The Open Source Telephony Project GIT-master-f36a736
Functions | Variables
app_bridgeaddchan.c File Reference

Application to place the channel into an existing Bridge. More...

#include "asterisk.h"
#include "asterisk/file.h"
#include "asterisk/module.h"
#include "asterisk/channel.h"
#include "asterisk/bridge.h"
#include "asterisk/features.h"
Include dependency graph for app_bridgeaddchan.c:

Go to the source code of this file.

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static int bridgeadd_exec (struct ast_channel *chan, const char *data)
 
static int load_module (void)
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Bridge Add Channel Application" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
 
static const char app [] = "BridgeAdd"
 
static const struct ast_module_infoast_module_info = &__mod_info
 

Detailed Description

Application to place the channel into an existing Bridge.

Author
Alec Davis

Definition in file app_bridgeaddchan.c.

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 144 of file app_bridgeaddchan.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 144 of file app_bridgeaddchan.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 144 of file app_bridgeaddchan.c.

◆ bridgeadd_exec()

static int bridgeadd_exec ( struct ast_channel chan,
const char *  data 
)
static

Definition at line 74 of file app_bridgeaddchan.c.

75{
76 struct ast_channel *c_ref;
77 struct ast_bridge_features chan_features;
78 struct ast_bridge *bridge;
79 char *c_name;
80 int failed;
81
82 /* Answer the channel if needed */
83 if (ast_channel_state(chan) != AST_STATE_UP) {
84 ast_answer(chan);
85 }
86
87 if (ast_strlen_zero(data)) {
88 data = "";
89 c_ref = NULL;
90 } else {
91 c_ref = ast_channel_get_by_name_prefix(data, strlen(data));
92 }
93 if (!c_ref) {
94 ast_verb(4, "Channel '%s' not found\n", data);
95 pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "NONEXISTENT");
96 return 0;
97 }
98 if (chan == c_ref) {
99 ast_channel_unref(c_ref);
100 pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "LOOP");
101 return 0;
102 }
103
104 c_name = ast_strdupa(ast_channel_name(c_ref));
105
106 ast_channel_lock(c_ref);
107 bridge = ast_channel_get_bridge(c_ref);
108 ast_channel_unlock(c_ref);
109
110 ast_channel_unref(c_ref);
111
112 if (!bridge) {
113 ast_verb(4, "Channel '%s' is not in a bridge\n", c_name);
114 pbx_builtin_setvar_helper(chan, "BRIDGERESULT", "FAILURE");
115 return 0;
116 }
117
118 ast_verb(4, "%s is joining %s in bridge %s\n",
119 ast_channel_name(chan), c_name, bridge->uniqueid);
120
121 failed = ast_bridge_features_init(&chan_features)
122 || ast_bridge_join(bridge, chan, NULL, &chan_features, NULL, 0);
123 if (failed) {
124 ast_verb(4, "%s failed to join %s in bridge %s\n",
125 ast_channel_name(chan), c_name, bridge->uniqueid);
126 }
127
128 ast_bridge_features_cleanup(&chan_features);
129 ao2_cleanup(bridge);
130 pbx_builtin_setvar_helper(chan, "BRIDGERESULT", failed ? "FAILURE" : "SUCCESS");
131 return 0;
132}
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
#define ao2_cleanup(obj)
Definition: astobj2.h:1934
int ast_bridge_join(struct ast_bridge *bridge, struct ast_channel *chan, struct ast_channel *swap, struct ast_bridge_features *features, struct ast_bridge_tech_optimizations *tech_args, enum ast_bridge_join_flags flags)
Join a channel to a bridge (blocking)
Definition: bridge.c:1621
int ast_bridge_features_init(struct ast_bridge_features *features)
Initialize bridge features structure.
Definition: bridge.c:3620
void ast_bridge_features_cleanup(struct ast_bridge_features *features)
Clean up the contents of a bridge features structure.
Definition: bridge.c:3653
const char * ast_channel_name(const struct ast_channel *chan)
#define ast_channel_lock(chan)
Definition: channel.h:2968
struct ast_channel * ast_channel_get_by_name_prefix(const char *name, size_t name_len)
Find a channel by a name prefix.
Definition: channel.c:1453
struct ast_bridge * ast_channel_get_bridge(const struct ast_channel *chan)
Get the bridge associated with a channel.
Definition: channel.c:10556
#define ast_channel_unref(c)
Decrease channel reference count.
Definition: channel.h:3004
int ast_answer(struct ast_channel *chan)
Answer a channel.
Definition: channel.c:2824
#define ast_channel_unlock(chan)
Definition: channel.h:2969
ast_channel_state
ast_channel states
Definition: channelstate.h:35
@ AST_STATE_UP
Definition: channelstate.h:42
#define ast_verb(level,...)
int pbx_builtin_setvar_helper(struct ast_channel *chan, const char *name, const char *value)
Add a variable to the channel variable stack, removing the most recently set value for the same name.
#define NULL
Definition: resample.c:96
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
Structure that contains features information.
Structure that contains information about a bridge.
Definition: bridge.h:349
const ast_string_field uniqueid
Definition: bridge.h:401
Main Channel structure associated with a channel.

References ao2_cleanup, ast_answer(), ast_bridge_features_cleanup(), ast_bridge_features_init(), ast_bridge_join(), ast_channel_get_bridge(), ast_channel_get_by_name_prefix(), ast_channel_lock, ast_channel_name(), ast_channel_unlock, ast_channel_unref, AST_STATE_UP, ast_strdupa, ast_strlen_zero(), ast_verb, NULL, pbx_builtin_setvar_helper(), and ast_bridge::uniqueid.

Referenced by load_module().

◆ load_module()

static int load_module ( void  )
static

Definition at line 139 of file app_bridgeaddchan.c.

140{
142}
static const char app[]
static int bridgeadd_exec(struct ast_channel *chan, const char *data)
#define ast_register_application_xml(app, execute)
Register an application using XML documentation.
Definition: module.h:640

References app, ast_register_application_xml, and bridgeadd_exec().

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 134 of file app_bridgeaddchan.c.

135{
137}
int ast_unregister_application(const char *app)
Unregister an application.
Definition: pbx_app.c:392

References app, and ast_unregister_application().

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Bridge Add Channel Application" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
static

Definition at line 144 of file app_bridgeaddchan.c.

◆ app

const char app[] = "BridgeAdd"
static

Definition at line 72 of file app_bridgeaddchan.c.

Referenced by load_module(), and unload_module().

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 144 of file app_bridgeaddchan.c.