37 #include "asterisk/stasis_channels.h"
49 static void bridge_stasis_run_cb(
struct ast_channel *chan,
void *data)
57 ast_log(LOG_ERROR,
"Failed to get app name for %s (%p)\n", ast_channel_name(chan), chan);
64 ast_log(LOG_WARNING,
"Could not find application (Stasis)\n");
68 if (ast_check_hangup_locked(chan)) {
88 static void defer_bridge_add_dtor(
void *obj)
92 ao2_cleanup(defer->
bridge);
96 static int defer_bridge_add(
105 static void bridge_stasis_queue_join_action(
struct ast_bridge *
self,
110 defer = ao2_alloc_options(
sizeof(*defer), defer_bridge_add_dtor,
122 ast_channel_lock(bridge_channel->
chan);
125 ast_channel_unlock(bridge_channel->
chan);
153 ast_log(LOG_ERROR,
"Failed to find stasis app control for swapped channel %s\n", ast_channel_name(swap->
chan));
159 ast_channel_name(swap->
chan), ast_channel_name(bridge_channel->
chan));
161 ast_channel_lock(bridge_channel->
chan);
169 ast_channel_unlock(bridge_channel->
chan);
172 ao2_cleanup(to_be_replaced);
198 ast_debug(1,
"Bridge %s: pushing non-stasis %p(%s) setup to come back in under stasis\n",
199 self->uniqueid, bridge_channel, ast_channel_name(bridge_channel->
chan));
203 bridge_stasis_run_cb, NULL, NULL)) {
205 "Failed to set after bridge callback for bridge %s non-stasis push of %s\n",
206 self->uniqueid, ast_channel_name(bridge_channel->
chan));
210 bridge_stasis_queue_join_action(
self, bridge_channel, swap);
218 ao2_cleanup(control);
228 ast_log(LOG_ERROR,
"Failed to set holding participant on %s\n", ast_channel_name(bridge_channel->
chan));
233 ast_log(LOG_ERROR,
"Failed to set holding participant mode on %s\n", ast_channel_name(bridge_channel->
chan));
239 ast_bridge_channel_update_linkedids(bridge_channel, swap);
241 ast_bridge_channel_update_accountcodes(bridge_channel, swap);
248 static int bridge_stasis_moving(
struct ast_bridge_channel *bridge_channel,
void *hook_pvt,
251 if (src->
v_table == &bridge_stasis_v_table &&
252 dst->
v_table != &bridge_stasis_v_table) {
256 chan = bridge_channel->
chan;
257 ast_assert(chan != NULL);
286 ast_bridge_channel_update_accountcodes(NULL, bridge_channel);
302 bridge = bridge_alloc(
sizeof(
struct ast_bridge), &bridge_stasis_v_table);
320 if (send_sdp_label) {
329 void bridge_stasis_init(
void)
333 bridge_stasis_v_table.
name =
"stasis";
334 bridge_stasis_v_table.
push = bridge_stasis_push;
335 bridge_stasis_v_table.
pull = bridge_stasis_pull;
336 bridge_stasis_v_table.
push_peek = bridge_stasis_push_peek;
int ast_bridge_move_hook(struct ast_bridge_features *features, ast_bridge_move_indicate_callback callback, void *hook_pvt, ast_bridge_hook_pvt_destructor destructor, enum ast_bridge_hook_remove_flags remove_flags)
Attach a bridge channel move detection hook to a bridge features structure.
void ast_bridge_set_sfu_video_mode(struct ast_bridge *bridge)
Set the bridge to be a selective forwarding unit.
int app_set_replace_channel_app(struct ast_channel *chan, const char *replace_app)
Set the app that the replacement channel will be controlled by.
Main Channel structure associated with a channel.
int control_swap_channel_in_bridge(struct stasis_app_control *control, struct ast_bridge *bridge, struct ast_channel *chan, struct ast_channel *swap)
Command for swapping a channel in a bridge.
int command_prestart_queue_command(struct ast_channel *chan, stasis_app_command_cb command_fn, void *data, command_data_destructor_fn data_destructor)
Queue a Stasis() prestart command for a channel.
Asterisk main include file. File version handling, generic pbx functions.
struct ast_bridge_features * features
ast_bridge_video_mode_type
Video source modes.
struct ast_bridge * bridge_register(struct ast_bridge *bridge)
Register the new bridge with the system.
int pbx_exec(struct ast_channel *c, struct ast_app *app, const char *data)
Execute an application.
Internal API for the Stasis application commands.
struct ast_bridge * bridge
void __ao2_cleanup(void *obj)
const ast_string_field name
Structure representing a snapshot of channel state.
int app_set_replace_channel_snapshot(struct ast_channel *chan, struct ast_channel_snapshot *replace_snapshot)
Set the snapshot of the channel that this channel will replace.
int ast_channel_add_bridge_role(struct ast_channel *chan, const char *role_name)
Adds a bridge role to a channel.
struct stasis_app * control_app(struct stasis_app_control *control)
Returns the pointer (non-reffed) to the app associated with this control.
int ast_bridge_set_after_callback(struct ast_channel *chan, ast_bridge_after_cb callback, ast_bridge_after_cb_failed failed, void *data)
Setup an after bridge callback for when the channel leaves the bridging system.
void stasis_app_channel_set_stasis_end_published(struct ast_channel *chan)
Indicate that this channel has had a StasisEnd published for it.
struct ast_bridge_methods ast_bridge_base_v_table
Bridge base class virtual method table.
int app_send_end_msg(struct stasis_app *app, struct ast_channel *chan)
Send StasisEnd message to the listening app.
int ast_channel_set_bridge_role_option(struct ast_channel *channel, const char *role_name, const char *option, const char *value)
Set a role option on a channel.
void ast_bridge_set_send_sdp_label(struct ast_bridge *bridge, unsigned int send_sdp_label)
Controls whether to send a "label" attribute in each stream in an SDP.
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
const char * stasis_app_name(const struct stasis_app *app)
Retrieve an application's name.
#define ast_channel_cleanup(c)
Cleanup a channel reference.
#define ast_debug(level,...)
Log a DEBUG message.
Internal API for the Stasis application controller.
Core PBX routines and definitions.
void ast_bridge_set_video_update_discard(struct ast_bridge *bridge, unsigned int video_update_discard)
Set the amount of time to discard subsequent video updates after a video update has been sent...
struct ast_bridge * bridge_base_init(struct ast_bridge *self, uint32_t capabilities, unsigned int flags, const char *creator, const char *name, const char *id)
Initialize the base class of the bridge.
const struct ast_bridge_methods * v_table
int ast_channel_has_role(struct ast_channel *channel, const char *role_name)
Check if a role exists on a channel.
Structure that contains information about a bridge.
Internal API for the Stasis bridge subclass.
const char * app_name(struct ast_app *app)
Bridge virtual methods table definition.
#define STASIS_BRIDGE_MIXING_CAPABILITIES
void ast_bridge_set_talker_src_video_mode(struct ast_bridge *bridge)
Set the bridge to pick the strongest talker supporting video as the single source video feed...
struct ast_channel * swap
Channel to swap with in the bridge. (has ref)
void ast_bridge_set_single_src_video_mode(struct ast_bridge *bridge, struct ast_channel *video_src_chan)
Set a bridge to feed a single video source to all participants.
int stasis_app_channel_is_internal(struct ast_channel *chan)
Is this channel internal to Stasis?
void ast_channel_clear_bridge_roles(struct ast_channel *chan)
Removes all bridge roles currently on a channel.
struct ast_channel * chan
Structure that contains information regarding a channel in a bridge.
After Bridge Execution API.
#define ast_channel_ref(c)
Increase channel reference count.
ast_bridge_push_channel_fn push_peek
struct ast_channel_snapshot * ast_channel_snapshot_get_latest(const char *uniqueid)
Obtain the latest ast_channel_snapshot from the Stasis Message Bus API cache. This is an ao2 object...
Internal API for the Stasis application controller.
ast_app: A registered application
ast_bridge_pull_channel_fn pull
ast_bridge_push_channel_fn push
Stasis Application API. See Stasis Application API for detailed documentation.
struct ast_app * pbx_findapp(const char *app)
Look up an application.
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
char * app_get_replace_channel_app(struct ast_channel *chan)
Get the app that the replacement channel will be controlled by.
struct stasis_app_control * stasis_app_control_find_by_channel(const struct ast_channel *chan)
Returns the handler for the given channel.