bridge_channel.h File Reference

#include "asterisk/bridge_features.h"
#include "asterisk/bridge_technology.h"

Include dependency graph for bridge_channel.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ast_bridge_channel
 Structure that contains information regarding a channel in a bridge. More...

Defines

#define ast_bridge_channel_lock(bridge_channel)   _ast_bridge_channel_lock(bridge_channel, __FILE__, __PRETTY_FUNCTION__, __LINE__, #bridge_channel)
 Lock the bridge_channel.
#define ast_bridge_channel_trylock(bridge_channel)   _ast_bridge_channel_trylock(bridge_channel, __FILE__, __PRETTY_FUNCTION__, __LINE__, #bridge_channel)
 Try locking the bridge_channel.
#define ast_bridge_channel_unlock(bridge_channel)   _ast_bridge_channel_unlock(bridge_channel, __FILE__, __PRETTY_FUNCTION__, __LINE__, #bridge_channel)
 Unlock the bridge_channel.

Typedefs

typedef void(* ast_bridge_custom_callback_fn )(struct ast_bridge_channel *bridge_channel, const void *payload, size_t payload_size)
 Custom callback run on a bridge channel.
typedef void(* ast_bridge_custom_play_fn )(struct ast_bridge_channel *bridge_channel, const char *playfile)
 Custom interpretation of the playfile name.

Enumerations

enum  ast_bridge_channel_custom_callback_option { AST_BRIDGE_CHANNEL_CB_OPTION_MEDIA = (1 << 0) }
enum  bridge_channel_state { BRIDGE_CHANNEL_STATE_WAIT = 0, BRIDGE_CHANNEL_STATE_END, BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE }
 State information about a bridged channel. More...
enum  bridge_channel_thread_state { BRIDGE_CHANNEL_THREAD_IDLE, BRIDGE_CHANNEL_THREAD_SIMPLE, BRIDGE_CHANNEL_THREAD_FRAME }

Functions

static void _ast_bridge_channel_lock (struct ast_bridge_channel *bridge_channel, const char *file, const char *function, int line, const char *var)
static int _ast_bridge_channel_trylock (struct ast_bridge_channel *bridge_channel, const char *file, const char *function, int line, const char *var)
static void _ast_bridge_channel_unlock (struct ast_bridge_channel *bridge_channel, const char *file, const char *function, int line, const char *var)
void ast_bridge_channel_feature_digit (struct ast_bridge_channel *bridge_channel, int digit)
 Add a DTMF digit to the collected digits to match against DTMF features.
void ast_bridge_channel_feature_digit_add (struct ast_bridge_channel *bridge_channel, int digit)
 Add a DTMF digit to the collected digits.
void ast_bridge_channel_kick (struct ast_bridge_channel *bridge_channel, int cause)
 Kick the channel out of the bridge.
void ast_bridge_channel_leave_bridge (struct ast_bridge_channel *bridge_channel, enum bridge_channel_state new_state, int cause)
 Set bridge channel state to leave bridge (if not leaving already).
void ast_bridge_channel_leave_bridge_nolock (struct ast_bridge_channel *bridge_channel, enum bridge_channel_state new_state, int cause)
 Set bridge channel state to leave bridge (if not leaving already).
void ast_bridge_channel_lock_bridge (struct ast_bridge_channel *bridge_channel)
 Lock the bridge associated with the bridge channel.
struct ast_bridgeast_bridge_channel_merge_inhibit (struct ast_bridge_channel *bridge_channel, int request)
 Adjust the bridge_channel's bridge merge inhibit request count.
int ast_bridge_channel_notify_talking (struct ast_bridge_channel *bridge_channel, int started_talking)
 Lets the bridging indicate when a bridge channel has stopped or started talking.
struct ast_bridge_channelast_bridge_channel_peer (struct ast_bridge_channel *bridge_channel)
 Get the peer bridge channel of a two party bridge.
void ast_bridge_channel_playfile (struct ast_bridge_channel *bridge_channel, ast_bridge_custom_play_fn custom_play, const char *playfile, const char *moh_class)
 Play a file on the bridge channel.
int ast_bridge_channel_queue_app (struct ast_bridge_channel *bridge_channel, const char *app_name, const char *app_args, const char *moh_class)
 Queue a bridge action run application frame onto the bridge channel.
int ast_bridge_channel_queue_callback (struct ast_bridge_channel *bridge_channel, enum ast_bridge_channel_custom_callback_option flags, ast_bridge_custom_callback_fn callback, const void *payload, size_t payload_size)
 Queue a bridge action custom callback frame onto the bridge channel.
int ast_bridge_channel_queue_control_data (struct ast_bridge_channel *bridge_channel, enum ast_control_frame_type control, const void *data, size_t datalen)
 Queue a control frame onto the bridge channel with data.
int ast_bridge_channel_queue_frame (struct ast_bridge_channel *bridge_channel, struct ast_frame *fr)
 Write a frame to the specified bridge_channel.
int ast_bridge_channel_queue_playfile (struct ast_bridge_channel *bridge_channel, ast_bridge_custom_play_fn custom_play, const char *playfile, const char *moh_class)
 Queue a bridge action play file frame onto the bridge channel.
int ast_bridge_channel_queue_playfile_sync (struct ast_bridge_channel *bridge_channel, ast_bridge_custom_play_fn custom_play, const char *playfile, const char *moh_class)
 Synchronously queue a bridge action play file frame onto the bridge channel.
void ast_bridge_channel_restore_formats (struct ast_bridge_channel *bridge_channel)
 Restore the formats of a bridge channel's channel to how they were before bridge_channel_internal_join.
void ast_bridge_channel_run_app (struct ast_bridge_channel *bridge_channel, const char *app_name, const char *app_args, const char *moh_class)
 Run an application on the bridge channel.
void ast_bridge_channel_update_accountcodes (struct ast_bridge_channel *joining, struct ast_bridge_channel *leaving)
void ast_bridge_channel_update_linkedids (struct ast_bridge_channel *bridge_channel, struct ast_bridge_channel *swap)
int ast_bridge_channel_write_app (struct ast_bridge_channel *bridge_channel, const char *app_name, const char *app_args, const char *moh_class)
 Write a bridge action run application frame into the bridge.
int ast_bridge_channel_write_callback (struct ast_bridge_channel *bridge_channel, enum ast_bridge_channel_custom_callback_option flags, ast_bridge_custom_callback_fn callback, const void *payload, size_t payload_size)
 Write a bridge action custom callback frame into the bridge.
int ast_bridge_channel_write_control_data (struct ast_bridge_channel *bridge_channel, enum ast_control_frame_type control, const void *data, size_t datalen)
 Write a control frame into the bridge with data.
int ast_bridge_channel_write_hold (struct ast_bridge_channel *bridge_channel, const char *moh_class)
 Write a hold frame into the bridge.
int ast_bridge_channel_write_park (struct ast_bridge_channel *bridge_channel, const char *parkee_uuid, const char *parker_uuid, const char *app_data)
 Have a bridge channel park a channel in the bridge.
int ast_bridge_channel_write_playfile (struct ast_bridge_channel *bridge_channel, ast_bridge_custom_play_fn custom_play, const char *playfile, const char *moh_class)
 Write a bridge action play file frame into the bridge.
int ast_bridge_channel_write_unhold (struct ast_bridge_channel *bridge_channel)
 Write an unhold frame into the bridge.


Detailed Description

Definition in file bridge_channel.h.


Define Documentation

#define ast_bridge_channel_lock ( bridge_channel   )     _ast_bridge_channel_lock(bridge_channel, __FILE__, __PRETTY_FUNCTION__, __LINE__, #bridge_channel)

#define ast_bridge_channel_trylock ( bridge_channel   )     _ast_bridge_channel_trylock(bridge_channel, __FILE__, __PRETTY_FUNCTION__, __LINE__, #bridge_channel)

Try locking the bridge_channel.

Parameters:
bridge_channel What to try locking
Return values:
0 on success.
non-zero on error.

Definition at line 183 of file bridge_channel.h.

Referenced by optimize_lock_chan_stack(), and optimize_lock_peer_stack().

#define ast_bridge_channel_unlock ( bridge_channel   )     _ast_bridge_channel_unlock(bridge_channel, __FILE__, __PRETTY_FUNCTION__, __LINE__, #bridge_channel)


Typedef Documentation

typedef void(* ast_bridge_custom_callback_fn)(struct ast_bridge_channel *bridge_channel, const void *payload, size_t payload_size)

Custom callback run on a bridge channel.

Parameters:
bridge_channel Which channel to operate on.
payload Data to pass to the callback. (NULL if none).
payload_size Size of the payload if payload is non-NULL. A number otherwise.
Note:
The payload MUST NOT have any resources that need to be freed.
Returns:
Nothing

Definition at line 577 of file bridge_channel.h.

typedef void(* ast_bridge_custom_play_fn)(struct ast_bridge_channel *bridge_channel, const char *playfile)

Custom interpretation of the playfile name.

Parameters:
bridge_channel Which channel to play the file on
playfile Sound filename to play.
Returns:
Nothing

Definition at line 489 of file bridge_channel.h.


Enumeration Type Documentation

Enumerator:
AST_BRIDGE_CHANNEL_CB_OPTION_MEDIA  The callback temporarily affects media. (Like a custom playfile.)

Definition at line 579 of file bridge_channel.h.

00579                                                {
00580    /*! The callback temporarily affects media. (Like a custom playfile.) */
00581    AST_BRIDGE_CHANNEL_CB_OPTION_MEDIA = (1 << 0),
00582 };

State information about a bridged channel.

Enumerator:
BRIDGE_CHANNEL_STATE_WAIT  Waiting for a signal (Channel in the bridge)
BRIDGE_CHANNEL_STATE_END  Bridged channel was forced out and should be hung up (Bridge may dissolve.)
BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE  Bridged channel was forced out. Don't dissolve the bridge regardless

Definition at line 60 of file bridge_channel.h.

00060                           {
00061    /*! Waiting for a signal (Channel in the bridge) */
00062    BRIDGE_CHANNEL_STATE_WAIT = 0,
00063    /*! Bridged channel was forced out and should be hung up (Bridge may dissolve.) */
00064    BRIDGE_CHANNEL_STATE_END,
00065    /*! Bridged channel was forced out. Don't dissolve the bridge regardless */
00066    BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE,
00067 };

Enumerator:
BRIDGE_CHANNEL_THREAD_IDLE  Bridge channel thread is idle/waiting.
BRIDGE_CHANNEL_THREAD_SIMPLE  Bridge channel thread is writing a normal/simple frame.
BRIDGE_CHANNEL_THREAD_FRAME  Bridge channel thread is processing a frame.

Definition at line 69 of file bridge_channel.h.

00069                                  {
00070    /*! Bridge channel thread is idle/waiting. */
00071    BRIDGE_CHANNEL_THREAD_IDLE,
00072    /*! Bridge channel thread is writing a normal/simple frame. */
00073    BRIDGE_CHANNEL_THREAD_SIMPLE,
00074    /*! Bridge channel thread is processing a frame. */
00075    BRIDGE_CHANNEL_THREAD_FRAME,
00076 };


Function Documentation

static void _ast_bridge_channel_lock ( struct ast_bridge_channel bridge_channel,
const char *  file,
const char *  function,
int  line,
const char *  var 
) [inline, static]

Definition at line 197 of file bridge_channel.h.

References __ao2_lock(), and AO2_LOCK_REQ_MUTEX.

00198 {
00199    __ao2_lock(bridge_channel, AO2_LOCK_REQ_MUTEX, file, function, line, var);
00200 }

static int _ast_bridge_channel_trylock ( struct ast_bridge_channel bridge_channel,
const char *  file,
const char *  function,
int  line,
const char *  var 
) [inline, static]

Definition at line 184 of file bridge_channel.h.

References __ao2_trylock(), and AO2_LOCK_REQ_MUTEX.

00185 {
00186    return __ao2_trylock(bridge_channel, AO2_LOCK_REQ_MUTEX, file, function, line, var);
00187 }

static void _ast_bridge_channel_unlock ( struct ast_bridge_channel bridge_channel,
const char *  file,
const char *  function,
int  line,
const char *  var 
) [inline, static]

Definition at line 210 of file bridge_channel.h.

References __ao2_unlock().

00211 {
00212    __ao2_unlock(bridge_channel, file, function, line, var);
00213 }

void ast_bridge_channel_feature_digit ( struct ast_bridge_channel bridge_channel,
int  digit 
)

Add a DTMF digit to the collected digits to match against DTMF features.

Since:
12.8.0
Parameters:
bridge_channel Channel that received a DTMF digit.
digit DTMF digit to add to collected digits or 0 for timeout event.
clear_digits clear the digits array prior to calling hooks
Note:
Neither the bridge nor the bridge_channel locks should be held when entering this function.

This is intended to be called by bridge hooks and the bridge channel thread.

This is intended to be called by non-DTMF bridge hooks and the bridge channel thread. Calling from a DTMF bridge hook can potentially cause unbounded recursion.

Returns:
Nothing

Definition at line 1563 of file bridge_channel.c.

References ao2_find, ao2_ref, ao2_unlink, ARRAY_LEN, ast_bridge_channel_kick(), ast_bridge_channel_lock_bridge(), ast_bridge_unlock, ast_channel_name(), ast_check_hangup_locked(), AST_CONTROL_SRCUPDATE, ast_debug, ast_indicate(), ast_samp2tv(), ast_test_suite_event_notify, ast_tvadd(), ast_tvnow(), ast_bridge_channel::bridge, bridge_channel_feature_digit_add(), bridge_channel_feature_digit_timeout(), bridge_channel_internal_suspend_nolock(), bridge_channel_unsuspend(), bridge_channel_write_dtmf_stream(), ast_bridge_hook::callback, ast_bridge_channel::chan, ast_bridge_hook_dtmf_parms::code, ast_bridge_channel::collected, ast_bridge_hook_dtmf::dtmf, ast_bridge_channel::dtmf_hook_state, ast_bridge_features::dtmf_hooks, ast_bridge_features::dtmf_passthrough, ast_bridge_channel::features, ast_bridge_hook_dtmf::generic, ast_bridge_hook::hook_pvt, ast_bridge_channel::interdigit_timeout, NULL, OBJ_SEARCH_PARTIAL_KEY, ast_bridge_channel::suspended, and testsuite_notify_feature_success().

Referenced by agent_alert(), bridge_channel_handle_feature_timeout(), bridge_channel_internal_join(), and bridge_handle_dtmf().

01564 {
01565    struct ast_bridge_features *features = bridge_channel->features;
01566    struct ast_bridge_hook_dtmf *hook = NULL;
01567    size_t dtmf_len;
01568 
01569    struct sanity_check_of_dtmf_size {
01570       char check[1 / (ARRAY_LEN(bridge_channel->dtmf_hook_state.collected) == ARRAY_LEN(hook->dtmf.code))];
01571    };
01572 
01573    dtmf_len = strlen(bridge_channel->dtmf_hook_state.collected);
01574    if (!dtmf_len && !digit) {
01575       /* Nothing to do */
01576       return;
01577    }
01578 
01579    if (digit) {
01580       dtmf_len = bridge_channel_feature_digit_add(bridge_channel, digit, dtmf_len);
01581    }
01582 
01583    while (digit) {
01584       /* See if a DTMF feature hook matches or can match */
01585       hook = ao2_find(features->dtmf_hooks, bridge_channel->dtmf_hook_state.collected,
01586          OBJ_SEARCH_PARTIAL_KEY);
01587       if (!hook) {
01588          ast_debug(1, "No DTMF feature hooks on %p(%s) match '%s'\n",
01589             bridge_channel, ast_channel_name(bridge_channel->chan),
01590             bridge_channel->dtmf_hook_state.collected);
01591          break;
01592       } else if (dtmf_len != strlen(hook->dtmf.code)) {
01593          unsigned int digit_timeout;
01594          /* Need more digits to match */
01595          ao2_ref(hook, -1);
01596          digit_timeout = bridge_channel_feature_digit_timeout(bridge_channel);
01597          bridge_channel->dtmf_hook_state.interdigit_timeout =
01598             ast_tvadd(ast_tvnow(), ast_samp2tv(digit_timeout, 1000));
01599          return;
01600       } else {
01601          int remove_me;
01602          int already_suspended;
01603 
01604          ast_debug(1, "DTMF feature hook %p matched DTMF string '%s' on %p(%s)\n",
01605             hook, bridge_channel->dtmf_hook_state.collected, bridge_channel,
01606             ast_channel_name(bridge_channel->chan));
01607 
01608          /*
01609           * Clear the collected digits before executing the hook
01610           * in case the hook starts another sequence.
01611           */
01612          bridge_channel->dtmf_hook_state.collected[0] = '\0';
01613 
01614          ast_bridge_channel_lock_bridge(bridge_channel);
01615          already_suspended = bridge_channel->suspended;
01616          if (!already_suspended) {
01617             bridge_channel_internal_suspend_nolock(bridge_channel);
01618          }
01619          ast_bridge_unlock(bridge_channel->bridge);
01620          ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
01621 
01622          /* Execute the matched hook on this channel. */
01623          remove_me = hook->generic.callback(bridge_channel, hook->generic.hook_pvt);
01624          if (remove_me) {
01625             ast_debug(1, "DTMF hook %p is being removed from %p(%s)\n",
01626                hook, bridge_channel, ast_channel_name(bridge_channel->chan));
01627             ao2_unlink(features->dtmf_hooks, hook);
01628          }
01629          testsuite_notify_feature_success(bridge_channel->chan, hook->dtmf.code);
01630          ao2_ref(hook, -1);
01631 
01632          ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
01633          if (!already_suspended) {
01634             bridge_channel_unsuspend(bridge_channel);
01635          }
01636 
01637          /*
01638           * If we are handing the channel off to an external hook for
01639           * ownership, we are not guaranteed what kind of state it will
01640           * come back in.  If the channel hungup, we need to detect that
01641           * here if the hook did not already change the state.
01642           */
01643          if (bridge_channel->chan && ast_check_hangup_locked(bridge_channel->chan)) {
01644             ast_bridge_channel_kick(bridge_channel, 0);
01645             bridge_channel->dtmf_hook_state.collected[0] = '\0';
01646             return;
01647          }
01648 
01649          /* if there is dtmf that has been collected then loop back through,
01650             but set digit to -1 so it doesn't try to do an add since the dtmf
01651             is already in the buffer */
01652          dtmf_len = strlen(bridge_channel->dtmf_hook_state.collected);
01653          if (!dtmf_len) {
01654             return;
01655          }
01656       }
01657    }
01658 
01659    if (!digit) {
01660       ast_debug(1, "DTMF feature string collection on %p(%s) timed out\n",
01661          bridge_channel, ast_channel_name(bridge_channel->chan));
01662    }
01663 
01664    /* Timeout or DTMF digit didn't allow a match with any hooks. */
01665    if (features->dtmf_passthrough) {
01666       /* Stream the collected DTMF to the other channels. */
01667       bridge_channel_write_dtmf_stream(bridge_channel,
01668          bridge_channel->dtmf_hook_state.collected);
01669    }
01670    bridge_channel->dtmf_hook_state.collected[0] = '\0';
01671 
01672    ast_test_suite_event_notify("FEATURE_DETECTION", "Result: fail");
01673 }

void ast_bridge_channel_feature_digit_add ( struct ast_bridge_channel bridge_channel,
int  digit 
)

Add a DTMF digit to the collected digits.

Since:
13.3.0
Parameters:
bridge_channel Channel that received a DTMF digit.
digit DTMF digit to add to collected digits
Note:
Neither the bridge nor the bridge_channel locks should be held when entering this function.

This is can only be called from within DTMF bridge hooks.

Definition at line 1555 of file bridge_channel.c.

References bridge_channel_feature_digit_add(), ast_bridge_channel::collected, and ast_bridge_channel::dtmf_hook_state.

Referenced by play_file().

01556 {
01557    if (digit) {
01558       bridge_channel_feature_digit_add(
01559          bridge_channel, digit, strlen(bridge_channel->dtmf_hook_state.collected));
01560    }
01561 }

void ast_bridge_channel_kick ( struct ast_bridge_channel bridge_channel,
int  cause 
)

Kick the channel out of the bridge.

Since:
12.0.0
Parameters:
bridge_channel Which channel is being kicked or hungup.
cause Cause of channel being kicked. If cause <= 0 then use cause on channel if cause still <= 0 use AST_CAUSE_NORMAL_CLEARING.
Note:
This is intended to be called by bridge hooks and the bridge channel thread.
Returns:
Nothing

Definition at line 589 of file bridge_channel.c.

References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, ao2_unlink, ast_bridge_channel_leave_bridge(), ast_bridge_channel_lock, ast_bridge_channel_unlock, AST_BRIDGE_HOOK_TYPE_HANGUP, ast_channel_name(), ast_debug, BRIDGE_CHANNEL_STATE_END, BRIDGE_CHANNEL_STATE_WAIT, ast_bridge_hook::callback, ast_bridge_channel::chan, channel_set_cause(), ast_bridge_channel::features, ast_bridge_hook::hook_pvt, ast_bridge_features::other_hooks, ast_bridge_channel::state, and ast_bridge_hook::type.

Referenced by ast_bridge_channel_feature_digit(), ast_bridge_channel_run_app(), bridge_channel_attended_transfer(), bridge_channel_blind_transfer(), bridge_channel_internal_join(), bridge_handle_trip(), and kick_it().

00590 {
00591    struct ast_bridge_features *features = bridge_channel->features;
00592    struct ast_bridge_hook *hook;
00593    struct ao2_iterator iter;
00594 
00595    ast_bridge_channel_lock(bridge_channel);
00596    if (bridge_channel->state == BRIDGE_CHANNEL_STATE_WAIT) {
00597       channel_set_cause(bridge_channel->chan, cause);
00598       cause = 0;
00599    }
00600    ast_bridge_channel_unlock(bridge_channel);
00601 
00602    /* Run any hangup hooks. */
00603    iter = ao2_iterator_init(features->other_hooks, 0);
00604    for (; (hook = ao2_iterator_next(&iter)); ao2_ref(hook, -1)) {
00605       int remove_me;
00606 
00607       if (hook->type != AST_BRIDGE_HOOK_TYPE_HANGUP) {
00608          continue;
00609       }
00610       remove_me = hook->callback(bridge_channel, hook->hook_pvt);
00611       if (remove_me) {
00612          ast_debug(1, "Hangup hook %p is being removed from %p(%s)\n",
00613             hook, bridge_channel, ast_channel_name(bridge_channel->chan));
00614          ao2_unlink(features->other_hooks, hook);
00615       }
00616    }
00617    ao2_iterator_destroy(&iter);
00618 
00619    /* Default hangup action. */
00620    ast_bridge_channel_leave_bridge(bridge_channel, BRIDGE_CHANNEL_STATE_END, cause);
00621 }

void ast_bridge_channel_leave_bridge ( struct ast_bridge_channel bridge_channel,
enum bridge_channel_state  new_state,
int  cause 
)

Set bridge channel state to leave bridge (if not leaving already).

Parameters:
bridge_channel Channel to change the state on
new_state The new state to place the channel into
cause Cause of channel leaving bridge. If cause <= 0 then use cause on channel if cause still <= 0 use AST_CAUSE_NORMAL_CLEARING.
Example usage:

This places the channel pointed to by bridge_channel into the state BRIDGE_CHANNEL_STATE_END if it was BRIDGE_CHANNEL_STATE_WAIT before.

Definition at line 298 of file bridge_channel.c.

References ast_bridge_channel_leave_bridge_nolock(), ast_bridge_channel_lock, and ast_bridge_channel_unlock.

Referenced by agent_connect_caller(), ast_bridge_channel_kick(), ast_bridge_depart(), ast_bridge_remove(), basic_hangup_hook(), bridge_agent_hold_heartbeat(), bridge_agent_hold_push(), bridge_channel_dissolve_check(), bridge_channel_internal_push(), bridge_dissolve(), bridge_do_merge(), bridge_do_move(), bridge_features_duration_callback(), bridge_stasis_push(), bridge_swap_attended_transfer(), bridgewait_timeout_callback(), caller_joined_bridge(), caller_safety_timeout(), feature_hangup(), parking_duration_callback(), say_parking_space(), and try_swap_optimize_out().

00299 {
00300    ast_bridge_channel_lock(bridge_channel);
00301    ast_bridge_channel_leave_bridge_nolock(bridge_channel, new_state, cause);
00302    ast_bridge_channel_unlock(bridge_channel);
00303 }

void ast_bridge_channel_leave_bridge_nolock ( struct ast_bridge_channel bridge_channel,
enum bridge_channel_state  new_state,
int  cause 
)

Set bridge channel state to leave bridge (if not leaving already).

Parameters:
bridge_channel Channel to change the state on
new_state The new state to place the channel into
cause Cause of channel leaving bridge. If cause <= 0 then use cause on channel if cause still <= 0 use AST_CAUSE_NORMAL_CLEARING.
Example usage:

This places the channel pointed to by bridge_channel into the state BRIDGE_CHANNEL_STATE_END if it was BRIDGE_CHANNEL_STATE_WAIT before.

Definition at line 280 of file bridge_channel.c.

References ast_channel_name(), ast_debug, bridge_channel_poke(), BRIDGE_CHANNEL_STATE_WAIT, ast_bridge_channel::chan, channel_set_cause(), and ast_bridge_channel::state.

Referenced by ast_bridge_channel_leave_bridge(), bridge_do_merge(), and caller_abort_agent().

00281 {
00282    if (bridge_channel->state != BRIDGE_CHANNEL_STATE_WAIT) {
00283       return;
00284    }
00285 
00286    ast_debug(1, "Setting %p(%s) state from:%u to:%u\n",
00287       bridge_channel, ast_channel_name(bridge_channel->chan), bridge_channel->state,
00288       new_state);
00289 
00290    channel_set_cause(bridge_channel->chan, cause);
00291 
00292    /* Change the state on the bridge channel */
00293    bridge_channel->state = new_state;
00294 
00295    bridge_channel_poke(bridge_channel);
00296 }

void ast_bridge_channel_lock_bridge ( struct ast_bridge_channel bridge_channel  ) 

Lock the bridge associated with the bridge channel.

Since:
12.0.0
Parameters:
bridge_channel Channel that wants to lock the bridge.
This is an upstream lock operation. The defined locking order is bridge then bridge_channel.

Note:
On entry, neither the bridge nor bridge_channel is locked.

The bridge_channel->bridge pointer changes because of a bridge-merge/channel-move operation between bridges.

Returns:
Nothing

Definition at line 210 of file bridge_channel.c.

References ao2_ref, ast_bridge_channel_lock, ast_bridge_channel_unlock, ast_bridge_lock, ast_bridge_unlock, and ast_bridge_channel::bridge.

Referenced by agent_alert(), ast_bridge_channel_feature_digit(), ast_bridge_channel_merge_inhibit(), ast_bridge_notify_masquerade(), basic_hangup_hook(), bridge_channel_internal_join(), bridge_channel_suspend(), bridge_channel_unsuspend(), bridge_channel_wait(), bridge_channel_write_frame(), deferred_action(), feature_automixmonitor(), feature_automonitor(), and parking_blind_transfer_park().

00211 {
00212    struct ast_bridge *bridge;
00213 
00214    for (;;) {
00215       /* Safely get the bridge pointer */
00216       ast_bridge_channel_lock(bridge_channel);
00217       bridge = bridge_channel->bridge;
00218       ao2_ref(bridge, +1);
00219       ast_bridge_channel_unlock(bridge_channel);
00220 
00221       /* Lock the bridge and see if it is still the bridge we need to lock. */
00222       ast_bridge_lock(bridge);
00223       if (bridge == bridge_channel->bridge) {
00224          ao2_ref(bridge, -1);
00225          return;
00226       }
00227       ast_bridge_unlock(bridge);
00228       ao2_ref(bridge, -1);
00229    }
00230 }

struct ast_bridge* ast_bridge_channel_merge_inhibit ( struct ast_bridge_channel bridge_channel,
int  request 
) [read]

Adjust the bridge_channel's bridge merge inhibit request count.

Since:
12.0.0
Parameters:
bridge_channel What to operate on.
request Inhibit request increment. (Positive to add requests. Negative to remove requests.)
Note:
This API call is meant for internal bridging operations.
Return values:
bridge adjusted merge inhibit with reference count.

Definition at line 353 of file bridge_channel.c.

References ao2_ref, ast_bridge_channel_lock_bridge(), ast_bridge_unlock, ast_bridge_channel::bridge, and bridge_merge_inhibit_nolock().

Referenced by feature_attended_transfer().

00354 {
00355    struct ast_bridge *bridge;
00356 
00357    ast_bridge_channel_lock_bridge(bridge_channel);
00358    bridge = bridge_channel->bridge;
00359    ao2_ref(bridge, +1);
00360    bridge_merge_inhibit_nolock(bridge, request);
00361    ast_bridge_unlock(bridge);
00362    return bridge;
00363 }

int ast_bridge_channel_notify_talking ( struct ast_bridge_channel bridge_channel,
int  started_talking 
)

Lets the bridging indicate when a bridge channel has stopped or started talking.

Note:
All DSP functionality on the bridge has been pushed down to the lowest possible layer, which in this case is the specific bridging technology being used. Since it is necessary for the knowledge of which channels are talking to make its way up to the application, this function has been created to allow the bridging technology to communicate that information with the bridging core.
Parameters:
bridge_channel The bridge channel that has either started or stopped talking.
started_talking set to 1 when this indicates the channel has started talking set to 0 when this indicates the channel has stopped talking.
Return values:
0 on success.
-1 on error.

Definition at line 232 of file bridge_channel.c.

References ast_bridge_channel_queue_frame(), AST_FRAME_BRIDGE_ACTION, BRIDGE_CHANNEL_ACTION_TALKING_START, BRIDGE_CHANNEL_ACTION_TALKING_STOP, and ast_frame::frametype.

Referenced by softmix_bridge_write_voice().

00233 {
00234    struct ast_frame action = {
00235       .frametype = AST_FRAME_BRIDGE_ACTION,
00236       .subclass.integer = started_talking
00237          ? BRIDGE_CHANNEL_ACTION_TALKING_START : BRIDGE_CHANNEL_ACTION_TALKING_STOP,
00238    };
00239 
00240    return ast_bridge_channel_queue_frame(bridge_channel, &action);
00241 }

struct ast_bridge_channel* ast_bridge_channel_peer ( struct ast_bridge_channel bridge_channel  )  [read]

Get the peer bridge channel of a two party bridge.

Since:
12.0.0
Parameters:
bridge_channel What to get the peer of.
Note:
On entry, bridge_channel->bridge is already locked.

This is an internal bridge function.

Return values:
peer on success.
NULL no peer channel.

Definition at line 305 of file bridge_channel.c.

References AST_LIST_TRAVERSE, ast_bridge_channel::bridge, ast_bridge::channels, ast_bridge_channel::in_bridge, NULL, and ast_bridge::num_channels.

Referenced by bridge_reconfigured_connected_line_update(), bridge_swap_attended_transfer(), parking_blind_transfer_park(), and try_swap_optimize_out().

00306 {
00307    struct ast_bridge *bridge = bridge_channel->bridge;
00308    struct ast_bridge_channel *other = NULL;
00309 
00310    if (bridge_channel->in_bridge && bridge->num_channels == 2) {
00311       AST_LIST_TRAVERSE(&bridge->channels, other, entry) {
00312          if (other != bridge_channel) {
00313             break;
00314          }
00315       }
00316    }
00317 
00318    return other;
00319 }

void ast_bridge_channel_playfile ( struct ast_bridge_channel bridge_channel,
ast_bridge_custom_play_fn  custom_play,
const char *  playfile,
const char *  moh_class 
)

Play a file on the bridge channel.

Since:
12.0.0
Parameters:
bridge_channel Which channel to play the file on
custom_play Call this function to play the playfile. (NULL if normal sound file to play)
playfile Sound filename to play.
moh_class MOH class to request bridge peers to hear while file is played. NULL if no MOH. Empty if default MOH class.
Note:
This is intended to be called by bridge hooks.
Returns:
Nothing

Definition at line 1127 of file bridge_channel.c.

References ast_bridge_channel_write_hold(), ast_bridge_channel_write_unhold(), ast_channel_flags(), ast_channel_latest_musicclass(), ast_channel_lock, ast_channel_unlock, AST_DIGIT_NONE, AST_FLAG_MOH, ast_moh_start(), ast_strdupa, ast_stream_and_wait(), ast_test_flag, ast_bridge_channel::chan, and NULL.

Referenced by bridge_channel_playfile().

01128 {
01129    if (moh_class) {
01130       ast_bridge_channel_write_hold(bridge_channel, moh_class);
01131    }
01132    if (custom_play) {
01133       custom_play(bridge_channel, playfile);
01134    } else {
01135       ast_stream_and_wait(bridge_channel->chan, playfile, AST_DIGIT_NONE);
01136    }
01137    if (moh_class) {
01138       ast_bridge_channel_write_unhold(bridge_channel);
01139    }
01140 
01141    /*
01142     * It may be necessary to resume music on hold after we finish
01143     * playing the announcment.
01144     */
01145    if (ast_test_flag(ast_channel_flags(bridge_channel->chan), AST_FLAG_MOH)) {
01146       const char *latest_musicclass;
01147 
01148       ast_channel_lock(bridge_channel->chan);
01149       latest_musicclass = ast_strdupa(ast_channel_latest_musicclass(bridge_channel->chan));
01150       ast_channel_unlock(bridge_channel->chan);
01151       ast_moh_start(bridge_channel->chan, latest_musicclass, NULL);
01152    }
01153 }

int ast_bridge_channel_queue_app ( struct ast_bridge_channel bridge_channel,
const char *  app_name,
const char *  app_args,
const char *  moh_class 
)

Queue a bridge action run application frame onto the bridge channel.

Since:
12.0.0
Parameters:
bridge_channel Which channel to put the frame onto
app_name Dialplan application name.
app_args Arguments for the application. (NULL or empty for no arguments)
moh_class MOH class to request bridge peers to hear while application is running. NULL if no MOH. Empty if default MOH class.
Note:
This is intended to be called by bridge hooks.
Return values:
0 on success.
-1 on error.

Definition at line 1121 of file bridge_channel.c.

References bridge_channel_queue_action_data(), and payload_helper_app().

01122 {
01123    return payload_helper_app(bridge_channel_queue_action_data,
01124       bridge_channel, app_name, app_args, moh_class);
01125 }

int ast_bridge_channel_queue_callback ( struct ast_bridge_channel bridge_channel,
enum ast_bridge_channel_custom_callback_option  flags,
ast_bridge_custom_callback_fn  callback,
const void *  payload,
size_t  payload_size 
)

Queue a bridge action custom callback frame onto the bridge channel.

Since:
12.0.0
Parameters:
bridge_channel Which channel to put the frame onto.
flags Custom callback option flags.
callback Custom callback run on a bridge channel.
payload Data to pass to the callback. (NULL if none).
payload_size Size of the payload if payload is non-NULL. A number otherwise.
Note:
The payload MUST NOT have any resources that need to be freed.

This is intended to be called by bridge hooks.

Return values:
0 on success.
-1 on error.

Definition at line 1298 of file bridge_channel.c.

References bridge_channel_queue_action_data(), and payload_helper_cb().

Referenced by ast_bridge_kick(), defer_action(), handle_bridge_kick_channel(), and send_alert_to_agent().

01301 {
01302    return payload_helper_cb(bridge_channel_queue_action_data,
01303       bridge_channel, flags, callback, payload, payload_size);
01304 }

int ast_bridge_channel_queue_control_data ( struct ast_bridge_channel bridge_channel,
enum ast_control_frame_type  control,
const void *  data,
size_t  datalen 
)

Queue a control frame onto the bridge channel with data.

Since:
12.0.0
Parameters:
bridge_channel Which channel to queue the frame onto.
control Type of control frame.
data Frame payload data to pass.
datalen Frame payload data length to pass.
Return values:
0 on success.
-1 on error.

Definition at line 956 of file bridge_channel.c.

References ast_bridge_channel_queue_frame(), AST_FRAME_CONTROL, and ast_frame::frametype.

Referenced by bridge_reconfigured_connected_line_update(), send_colp_to_agent(), and softmix_src_change().

00957 {
00958    struct ast_frame frame = {
00959       .frametype = AST_FRAME_CONTROL,
00960       .subclass.integer = control,
00961       .datalen = datalen,
00962       .data.ptr = (void *) data,
00963    };
00964 
00965    return ast_bridge_channel_queue_frame(bridge_channel, &frame);
00966 }

int ast_bridge_channel_queue_frame ( struct ast_bridge_channel bridge_channel,
struct ast_frame fr 
)

Write a frame to the specified bridge_channel.

Since:
12.0.0
Parameters:
bridge_channel Channel to queue the frame.
fr Frame to write.
Return values:
0 on success.
-1 on error.

Definition at line 895 of file bridge_channel.c.

References ast_bridge_channel::alert_pipe, ast_bridge_channel_lock, ast_bridge_channel_unlock, ast_channel_name(), AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, AST_FRAME_NULL, ast_frdup(), ast_is_deferrable_frame(), AST_LIST_INSERT_TAIL, ast_log, BRIDGE_CHANNEL_STATE_WAIT, bridge_frame_free(), ast_bridge_channel::chan, ast_frame::frametype, LOG_ERROR, ast_bridge_channel::state, ast_bridge_channel::suspended, and ast_bridge_channel::wr_queue.

Referenced by ast_bridge_channel_notify_talking(), ast_bridge_channel_queue_control_data(), ast_bridge_queue_everyone_else(), bridge_channel_queue_action_data(), bridge_channel_queue_action_data_sync(), softmix_mixing_loop(), and softmix_pass_video_top_priority().

00896 {
00897    struct ast_frame *dup;
00898    char nudge = 0;
00899 
00900    if (bridge_channel->suspended
00901       /* Also defer DTMF frames. */
00902       && fr->frametype != AST_FRAME_DTMF_BEGIN
00903       && fr->frametype != AST_FRAME_DTMF_END
00904       && !ast_is_deferrable_frame(fr)) {
00905       /* Drop non-deferable frames when suspended. */
00906       return 0;
00907    }
00908    if (fr->frametype == AST_FRAME_NULL) {
00909       /* "Accept" the frame and discard it. */
00910       return 0;
00911    }
00912 
00913    dup = ast_frdup(fr);
00914    if (!dup) {
00915       return -1;
00916    }
00917 
00918    ast_bridge_channel_lock(bridge_channel);
00919    if (bridge_channel->state != BRIDGE_CHANNEL_STATE_WAIT) {
00920       /* Drop frames on channels leaving the bridge. */
00921       ast_bridge_channel_unlock(bridge_channel);
00922       bridge_frame_free(dup);
00923       return 0;
00924    }
00925 
00926    AST_LIST_INSERT_TAIL(&bridge_channel->wr_queue, dup, frame_list);
00927    if (write(bridge_channel->alert_pipe[1], &nudge, sizeof(nudge)) != sizeof(nudge)) {
00928       ast_log(LOG_ERROR, "We couldn't write alert pipe for %p(%s)... something is VERY wrong\n",
00929          bridge_channel, ast_channel_name(bridge_channel->chan));
00930    }
00931    ast_bridge_channel_unlock(bridge_channel);
00932    return 0;
00933 }

int ast_bridge_channel_queue_playfile ( struct ast_bridge_channel bridge_channel,
ast_bridge_custom_play_fn  custom_play,
const char *  playfile,
const char *  moh_class 
)

Queue a bridge action play file frame onto the bridge channel.

Since:
12.0.0
Parameters:
bridge_channel Which channel to put the frame onto.
custom_play Call this function to play the playfile. (NULL if normal sound file to play)
playfile Sound filename to play.
moh_class MOH class to request bridge peers to hear while file is played. NULL if no MOH. Empty if default MOH class.
Note:
This is intended to be called by bridge hooks.
Return values:
0 on success.
-1 on error.

Definition at line 1210 of file bridge_channel.c.

References bridge_channel_queue_action_data(), and payload_helper_playfile().

Referenced by ast_bridge_add_channel(), bridge_parking_pull(), bridge_parking_push(), check_bridge_play_sound(), feature_automixmonitor(), feature_automonitor(), parker_parked_call_message_response(), play_sound(), start_automixmonitor(), start_automonitor(), stop_automixmonitor(), and stop_automonitor().

01211 {
01212    return payload_helper_playfile(bridge_channel_queue_action_data,
01213       bridge_channel, custom_play, playfile, moh_class);
01214 }

int ast_bridge_channel_queue_playfile_sync ( struct ast_bridge_channel bridge_channel,
ast_bridge_custom_play_fn  custom_play,
const char *  playfile,
const char *  moh_class 
)

Synchronously queue a bridge action play file frame onto the bridge channel.

Since:
12.2.0
Parameters:
bridge_channel Which channel to put the frame onto.
custom_play Call this function to play the playfile. (NULL if normal sound file to play)
playfile Sound filename to play.
moh_class MOH class to request bridge peers to hear while file is played. NULL if no MOH. Empty if default MOH class.
This function will block until the queued frame has been destroyed. This will happen either if an error occurs or if the queued playback finishes.

Note:
No locks may be held when calling this function.
Return values:
0 The playback was successfully queued.
-1 The playback could not be queued.

Definition at line 1216 of file bridge_channel.c.

References bridge_channel_queue_action_data_sync(), and payload_helper_playfile().

Referenced by parker_parked_call_message_response(), and play_uri().

01218 {
01219    return payload_helper_playfile(bridge_channel_queue_action_data_sync,
01220       bridge_channel, custom_play, playfile, moh_class);
01221 }

void ast_bridge_channel_restore_formats ( struct ast_bridge_channel bridge_channel  ) 

Restore the formats of a bridge channel's channel to how they were before bridge_channel_internal_join.

Since:
12.0.0
Parameters:
bridge_channel Channel to restore

Definition at line 321 of file bridge_channel.c.

References ast_assert, ast_channel_lock, ast_channel_name(), ast_channel_readformat(), ast_channel_unlock, ast_channel_writeformat(), ast_debug, ast_format_cmp(), AST_FORMAT_CMP_NOT_EQUAL, ast_format_get_name(), ast_set_read_format(), ast_set_write_format(), ast_bridge_channel::chan, NULL, ast_bridge_channel::read_format, and ast_bridge_channel::write_format.

Referenced by bridge_channel_internal_join(), and participant_reaction_announcer_leave().

00322 {
00323    ast_assert(bridge_channel->read_format != NULL);
00324    ast_assert(bridge_channel->write_format != NULL);
00325 
00326    ast_channel_lock(bridge_channel->chan);
00327 
00328    /* Restore original formats of the channel as they came in */
00329    if (ast_format_cmp(ast_channel_readformat(bridge_channel->chan), bridge_channel->read_format) == AST_FORMAT_CMP_NOT_EQUAL) {
00330       ast_debug(1, "Bridge is returning %p(%s) to read format %s\n",
00331          bridge_channel, ast_channel_name(bridge_channel->chan),
00332          ast_format_get_name(bridge_channel->read_format));
00333       if (ast_set_read_format(bridge_channel->chan, bridge_channel->read_format)) {
00334          ast_debug(1, "Bridge failed to return %p(%s) to read format %s\n",
00335             bridge_channel, ast_channel_name(bridge_channel->chan),
00336             ast_format_get_name(bridge_channel->read_format));
00337       }
00338    }
00339    if (ast_format_cmp(ast_channel_writeformat(bridge_channel->chan), bridge_channel->write_format) == AST_FORMAT_CMP_NOT_EQUAL) {
00340       ast_debug(1, "Bridge is returning %p(%s) to write format %s\n",
00341          bridge_channel, ast_channel_name(bridge_channel->chan),
00342          ast_format_get_name(bridge_channel->write_format));
00343       if (ast_set_write_format(bridge_channel->chan, bridge_channel->write_format)) {
00344          ast_debug(1, "Bridge failed to return %p(%s) to write format %s\n",
00345             bridge_channel, ast_channel_name(bridge_channel->chan),
00346             ast_format_get_name(bridge_channel->write_format));
00347       }
00348    }
00349 
00350    ast_channel_unlock(bridge_channel->chan);
00351 }

void ast_bridge_channel_run_app ( struct ast_bridge_channel bridge_channel,
const char *  app_name,
const char *  app_args,
const char *  moh_class 
)

Run an application on the bridge channel.

Since:
12.0.0
Parameters:
bridge_channel Which channel to run the application on.
app_name Dialplan application name.
app_args Arguments for the application. (NULL tolerant)
moh_class MOH class to request bridge peers to hear while application is running. NULL if no MOH. Empty if default MOH class.
Note:
This is intended to be called by bridge hooks.
Returns:
Nothing

Definition at line 1047 of file bridge_channel.c.

References ast_bridge_channel_kick(), ast_bridge_channel_write_hold(), ast_bridge_channel_write_unhold(), AST_CAUSE_NORMAL_CLEARING, ast_bridge_channel::chan, run_app_helper(), and S_OR.

Referenced by bridge_channel_run_app(), and dynamic_dtmf_hook_callback().

01048 {
01049    if (moh_class) {
01050       ast_bridge_channel_write_hold(bridge_channel, moh_class);
01051    }
01052    if (run_app_helper(bridge_channel->chan, app_name, S_OR(app_args, ""))) {
01053       /* Break the bridge if the app returns non-zero. */
01054       ast_bridge_channel_kick(bridge_channel, AST_CAUSE_NORMAL_CLEARING);
01055    }
01056    if (moh_class) {
01057       ast_bridge_channel_write_unhold(bridge_channel);
01058    }
01059 }

void ast_bridge_channel_update_accountcodes ( struct ast_bridge_channel joining,
struct ast_bridge_channel leaving 
)

void ast_bridge_channel_update_linkedids ( struct ast_bridge_channel bridge_channel,
struct ast_bridge_channel swap 
)

Definition at line 365 of file bridge_channel.c.

References ast_channel_internal_copy_linkedid(), ast_channel_internal_oldest_linkedid(), ast_channel_lock, ast_channel_unlock, AST_LIST_TRAVERSE, ast_bridge_channel::bridge, ast_bridge_channel::chan, and ast_bridge::channels.

Referenced by bridge_basic_push(), and bridge_stasis_push().

00366 {
00367    struct ast_bridge_channel *other;
00368    struct ast_bridge *bridge = bridge_channel->bridge;
00369    struct ast_channel *oldest_linkedid_chan = bridge_channel->chan;
00370 
00371    AST_LIST_TRAVERSE(&bridge->channels, other, entry) {
00372       if (other == swap) {
00373          continue;
00374       }
00375       oldest_linkedid_chan = ast_channel_internal_oldest_linkedid(
00376          oldest_linkedid_chan, other->chan);
00377    }
00378 
00379    ast_channel_lock(bridge_channel->chan);
00380    ast_channel_internal_copy_linkedid(bridge_channel->chan, oldest_linkedid_chan);
00381    ast_channel_unlock(bridge_channel->chan);
00382    AST_LIST_TRAVERSE(&bridge->channels, other, entry) {
00383       if (other == swap) {
00384          continue;
00385       }
00386       ast_channel_lock(other->chan);
00387       ast_channel_internal_copy_linkedid(other->chan, oldest_linkedid_chan);
00388       ast_channel_unlock(other->chan);
00389    }
00390 }

int ast_bridge_channel_write_app ( struct ast_bridge_channel bridge_channel,
const char *  app_name,
const char *  app_args,
const char *  moh_class 
)

Write a bridge action run application frame into the bridge.

Since:
12.0.0
Parameters:
bridge_channel Which channel is putting the frame into the bridge
app_name Dialplan application name.
app_args Arguments for the application. (NULL or empty for no arguments)
moh_class MOH class to request bridge peers to hear while application is running. NULL if no MOH. Empty if default MOH class.
Note:
This is intended to be called by bridge hooks.
Return values:
0 on success.
-1 on error.

Definition at line 1115 of file bridge_channel.c.

References bridge_channel_write_action_data(), and payload_helper_app().

01116 {
01117    return payload_helper_app(bridge_channel_write_action_data,
01118       bridge_channel, app_name, app_args, moh_class);
01119 }

int ast_bridge_channel_write_callback ( struct ast_bridge_channel bridge_channel,
enum ast_bridge_channel_custom_callback_option  flags,
ast_bridge_custom_callback_fn  callback,
const void *  payload,
size_t  payload_size 
)

Write a bridge action custom callback frame into the bridge.

Since:
12.0.0
Parameters:
bridge_channel Which channel is putting the frame into the bridge
flags Custom callback option flags.
callback Custom callback run on a bridge channel.
payload Data to pass to the callback. (NULL if none).
payload_size Size of the payload if payload is non-NULL. A number otherwise.
Note:
The payload MUST NOT have any resources that need to be freed.

This is intended to be called by bridge hooks.

Return values:
0 on success.
-1 on error.

Definition at line 1290 of file bridge_channel.c.

References bridge_channel_write_action_data(), and payload_helper_cb().

Referenced by agent_connect_caller(), and dynamic_dtmf_hook_trip().

01293 {
01294    return payload_helper_cb(bridge_channel_write_action_data,
01295       bridge_channel, flags, callback, payload, payload_size);
01296 }

int ast_bridge_channel_write_control_data ( struct ast_bridge_channel bridge_channel,
enum ast_control_frame_type  control,
const void *  data,
size_t  datalen 
)

Write a control frame into the bridge with data.

Since:
12.0.0
Parameters:
bridge_channel Which channel is putting the frame into the bridge.
control Type of control frame.
data Frame payload data to pass.
datalen Frame payload data length to pass.
Return values:
0 on success.
-1 on error.

Definition at line 968 of file bridge_channel.c.

References AST_FRAME_CONTROL, bridge_channel_write_frame(), and ast_frame::frametype.

Referenced by agent_connect_caller(), ast_bridge_channel_write_hold(), ast_bridge_channel_write_unhold(), and ringing().

00969 {
00970    struct ast_frame frame = {
00971       .frametype = AST_FRAME_CONTROL,
00972       .subclass.integer = control,
00973       .datalen = datalen,
00974       .data.ptr = (void *) data,
00975    };
00976 
00977    return bridge_channel_write_frame(bridge_channel, &frame);
00978 }

int ast_bridge_channel_write_hold ( struct ast_bridge_channel bridge_channel,
const char *  moh_class 
)

Write a hold frame into the bridge.

Since:
12.0.0
Parameters:
bridge_channel Which channel is putting the hold into the bridge.
moh_class The suggested music class for the other end to use.
Return values:
0 on success.
-1 on error.

Definition at line 980 of file bridge_channel.c.

References ast_bridge_channel_write_control_data(), ast_channel_hold_type(), ast_channel_publish_cached_blob(), AST_CONTROL_HOLD, ast_json_pack(), ast_json_unref(), ast_strlen_zero, ast_bridge_channel::chan, and NULL.

Referenced by ast_bridge_channel_playfile(), ast_bridge_channel_run_app(), feature_attended_transfer(), feature_blind_transfer(), and hold().

00981 {
00982    struct ast_json *blob;
00983    int res;
00984    size_t datalen;
00985 
00986    if (!ast_strlen_zero(moh_class)) {
00987       datalen = strlen(moh_class) + 1;
00988 
00989       blob = ast_json_pack("{s: s}",
00990          "musicclass", moh_class);
00991    } else {
00992       moh_class = NULL;
00993       datalen = 0;
00994       blob = NULL;
00995    }
00996 
00997    ast_channel_publish_cached_blob(bridge_channel->chan, ast_channel_hold_type(), blob);
00998 
00999    res = ast_bridge_channel_write_control_data(bridge_channel, AST_CONTROL_HOLD,
01000       moh_class, datalen);
01001 
01002    ast_json_unref(blob);
01003    return res;
01004 }

int ast_bridge_channel_write_park ( struct ast_bridge_channel bridge_channel,
const char *  parkee_uuid,
const char *  parker_uuid,
const char *  app_data 
)

Have a bridge channel park a channel in the bridge.

Since:
12.0.0
Parameters:
bridge_channel Bridge channel performing the parking
parkee_uuid Unique id of the channel we want to park
parker_uuid Unique id of the channel parking the call
app_data string indicating data used for park application (NULL allowed)
Note:
This is intended to be called by bridge hooks.
Return values:
0 on success.
-1 on error.

Definition at line 1361 of file bridge_channel.c.

References bridge_channel_write_action_data(), and payload_helper_park().

Referenced by manager_park_bridged(), and parking_blind_transfer_park().

01362 {
01363    return payload_helper_park(bridge_channel_write_action_data,
01364       bridge_channel, parkee_uuid, parker_uuid, app_data);
01365 }

int ast_bridge_channel_write_playfile ( struct ast_bridge_channel bridge_channel,
ast_bridge_custom_play_fn  custom_play,
const char *  playfile,
const char *  moh_class 
)

Write a bridge action play file frame into the bridge.

Since:
12.0.0
Parameters:
bridge_channel Which channel is putting the frame into the bridge
custom_play Call this function to play the playfile. (NULL if normal sound file to play)
playfile Sound filename to play.
moh_class MOH class to request bridge peers to hear while file is played. NULL if no MOH. Empty if default MOH class.
Note:
This is intended to be called by bridge hooks.
Return values:
0 on success.
-1 on error.

Definition at line 1204 of file bridge_channel.c.

References bridge_channel_write_action_data(), and payload_helper_playfile().

Referenced by ast_bridge_transfer_attended(), start_automixmonitor(), start_automonitor(), stop_automixmonitor(), and stop_automonitor().

01205 {
01206    return payload_helper_playfile(bridge_channel_write_action_data,
01207       bridge_channel, custom_play, playfile, moh_class);
01208 }

int ast_bridge_channel_write_unhold ( struct ast_bridge_channel bridge_channel  ) 

Write an unhold frame into the bridge.

Since:
12.0.0
Parameters:
bridge_channel Which channel is putting the hold into the bridge.
Return values:
0 on success.
-1 on error.

Definition at line 1006 of file bridge_channel.c.

References ast_bridge_channel_write_control_data(), ast_channel_publish_cached_blob(), ast_channel_unhold_type(), AST_CONTROL_UNHOLD, ast_bridge_channel::chan, and NULL.

Referenced by ast_bridge_channel_playfile(), ast_bridge_channel_run_app(), ast_bridge_transfer_attended(), ast_bridge_transfer_blind(), feature_attended_transfer(), feature_blind_transfer(), and unhold().

01007 {
01008    ast_channel_publish_cached_blob(bridge_channel->chan, ast_channel_unhold_type(), NULL);
01009 
01010    return ast_bridge_channel_write_control_data(bridge_channel, AST_CONTROL_UNHOLD, NULL, 0);
01011 }


Generated on Thu Apr 16 06:29:10 2015 for Asterisk - The Open Source Telephony Project by  doxygen 1.5.6