Asterisk - The Open Source Telephony Project GIT-master-7e7a603
Data Structures | Macros | Typedefs | Functions | Variables
bridge_channel.c File Reference

Bridging Channel API. More...

#include "asterisk.h"
#include <signal.h>
#include "asterisk/heap.h"
#include "asterisk/alertpipe.h"
#include "asterisk/astobj2.h"
#include "asterisk/stringfields.h"
#include "asterisk/app.h"
#include "asterisk/pbx.h"
#include "asterisk/channel.h"
#include "asterisk/timing.h"
#include "asterisk/bridge.h"
#include "asterisk/bridge_channel.h"
#include "asterisk/bridge_after.h"
#include "asterisk/bridge_channel_internal.h"
#include "asterisk/bridge_internal.h"
#include "asterisk/stasis_bridges.h"
#include "asterisk/stasis_channels.h"
#include "asterisk/musiconhold.h"
#include "asterisk/features_config.h"
#include "asterisk/parking.h"
#include "asterisk/causes.h"
#include "asterisk/test.h"
#include "asterisk/sem.h"
#include "asterisk/stream.h"
#include "asterisk/message.h"
#include "asterisk/core_local.h"
Include dependency graph for bridge_channel.c:

Go to the source code of this file.

Data Structures

struct  blind_transfer_data
 Data specifying where a blind transfer is going to. More...
 
struct  bridge_custom_callback
 
struct  bridge_park
 
struct  bridge_playfile
 
struct  bridge_run_app
 
struct  bridge_sync
 Synchronous bridge action object. More...
 
struct  sync_payload
 Frame payload for synchronous bridge actions. More...
 
struct  sync_structs
 List holding active synchronous action objects. More...
 

Macros

#define PLAYBACK_TIMEOUT   (600 * 1000)
 Failsafe for synchronous bridge action waiting. More...
 

Typedefs

typedef int(* ast_bridge_channel_post_action_data) (struct ast_bridge_channel *bridge_channel, enum bridge_channel_action_type action, const void *data, size_t datalen)
 Used to queue an action frame onto a bridge channel and write an action frame into a bridge. More...
 

Functions

static void after_bridge_move_channel (struct ast_channel *chan_bridged, void *data)
 
static void after_bridge_move_channel_fail (enum ast_bridge_after_cb_reason reason, void *data)
 
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. More...
 
void ast_bridge_channel_feature_digit_add (struct ast_bridge_channel *bridge_channel, int digit)
 Add a DTMF digit to the collected digits. More...
 
struct ast_channelast_bridge_channel_get_chan (struct ast_bridge_channel *bridge_channel)
 Get a ref to the bridge_channel's ast_channel. More...
 
void ast_bridge_channel_kick (struct ast_bridge_channel *bridge_channel, int cause)
 Kick the channel out of the bridge. More...
 
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). More...
 
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). More...
 
void ast_bridge_channel_lock_bridge (struct ast_bridge_channel *bridge_channel)
 Lock the bridge associated with the bridge channel. More...
 
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. More...
 
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. More...
 
struct ast_bridge_channelast_bridge_channel_peer (struct ast_bridge_channel *bridge_channel)
 Get the peer bridge channel of a two party bridge. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
int ast_bridge_channel_queue_frame (struct ast_bridge_channel *bridge_channel, struct ast_frame *fr)
 Write a frame to the specified bridge_channel. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
void ast_bridge_channel_stream_map (struct ast_bridge_channel *bridge_channel)
 Maps a channel's stream topology to and from the bridge. More...
 
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. More...
 
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. More...
 
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. More...
 
int ast_bridge_channel_write_hold (struct ast_bridge_channel *bridge_channel, const char *moh_class)
 Write a hold frame into the bridge. More...
 
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. More...
 
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. More...
 
int ast_bridge_channel_write_unhold (struct ast_bridge_channel *bridge_channel)
 Write an unhold frame into the bridge. More...
 
int ast_bridge_queue_everyone_else (struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
 Queue the given frame to everyone else. More...
 
static void bridge_channel_attended_transfer (struct ast_bridge_channel *bridge_channel, const char *target_chan_name)
 
static void bridge_channel_blind_transfer (struct ast_bridge_channel *bridge_channel, struct blind_transfer_data *blind_data)
 
static void bridge_channel_cancel_owed_events (struct ast_bridge_channel *bridge_channel)
 
static void bridge_channel_destroy (void *obj)
 
static void bridge_channel_dissolve_check (struct ast_bridge_channel *bridge_channel)
 
static void bridge_channel_do_callback (struct ast_bridge_channel *bridge_channel, struct bridge_custom_callback *data)
 
static void bridge_channel_dtmf_stream (struct ast_bridge_channel *bridge_channel, const char *dtmf)
 
static void bridge_channel_event_join_leave (struct ast_bridge_channel *bridge_channel, enum ast_bridge_hook_type type)
 
static int bridge_channel_feature_digit_add (struct ast_bridge_channel *bridge_channel, int digit, size_t dtmf_len)
 
static unsigned int bridge_channel_feature_digit_timeout (struct ast_bridge_channel *bridge_channel)
 
static int bridge_channel_feature_timeout (struct ast_bridge_channel *bridge_channel)
 
static void bridge_channel_handle_action (struct ast_bridge_channel *bridge_channel, enum bridge_channel_action_type action, void *data)
 
static void bridge_channel_handle_control (struct ast_bridge_channel *bridge_channel, struct ast_frame *fr)
 
static void bridge_channel_handle_feature_timeout (struct ast_bridge_channel *bridge_channel)
 
static void bridge_channel_handle_interval (struct ast_bridge_channel *bridge_channel)
 
static void bridge_channel_handle_write (struct ast_bridge_channel *bridge_channel)
 
struct ast_bridge_channelbridge_channel_internal_alloc (struct ast_bridge *bridge)
 
int bridge_channel_internal_allows_optimization (struct ast_bridge_channel *bridge_channel)
 
int bridge_channel_internal_join (struct ast_bridge_channel *bridge_channel)
 
void bridge_channel_internal_pull (struct ast_bridge_channel *bridge_channel)
 
int bridge_channel_internal_push (struct ast_bridge_channel *bridge_channel)
 
int bridge_channel_internal_push_full (struct ast_bridge_channel *bridge_channel, int optimized)
 
int bridge_channel_internal_queue_attended_transfer (struct ast_channel *transferee, struct ast_channel *unbridged_chan)
 
int bridge_channel_internal_queue_blind_transfer (struct ast_channel *transferee, const char *exten, const char *context, transfer_channel_cb new_channel_cb, void *user_data)
 
void bridge_channel_internal_suspend_nolock (struct ast_bridge_channel *bridge_channel)
 
void bridge_channel_internal_unsuspend_nolock (struct ast_bridge_channel *bridge_channel)
 
static int bridge_channel_next_interval (struct ast_bridge_channel *bridge_channel)
 
static int bridge_channel_next_timeout (struct ast_bridge_channel *bridge_channel)
 
static void bridge_channel_park (struct ast_bridge_channel *bridge_channel, struct bridge_park *payload)
 
static void bridge_channel_playfile (struct ast_bridge_channel *bridge_channel, struct bridge_playfile *payload)
 
static void bridge_channel_poke (struct ast_bridge_channel *bridge_channel)
 
static int bridge_channel_queue_action_data (struct ast_bridge_channel *bridge_channel, enum bridge_channel_action_type action, const void *data, size_t datalen)
 
static int bridge_channel_queue_action_data_sync (struct ast_bridge_channel *bridge_channel, enum bridge_channel_action_type action, const void *data, size_t datalen)
 
void bridge_channel_queue_deferred_frames (struct ast_bridge_channel *bridge_channel)
 
static void bridge_channel_run_app (struct ast_bridge_channel *bridge_channel, struct bridge_run_app *data)
 
void bridge_channel_settle_owed_events (struct ast_bridge *orig_bridge, struct ast_bridge_channel *bridge_channel)
 
static void bridge_channel_suspend (struct ast_bridge_channel *bridge_channel)
 
static void bridge_channel_talking (struct ast_bridge_channel *bridge_channel, int talking)
 
static void bridge_channel_unsuspend (struct ast_bridge_channel *bridge_channel)
 
static void bridge_channel_update_accountcodes_joining (struct ast_bridge_channel *joining, struct ast_bridge_channel *swap)
 
static void bridge_channel_update_accountcodes_leaving (struct ast_bridge_channel *leaving)
 
static void bridge_channel_wait (struct ast_bridge_channel *bridge_channel)
 
static int bridge_channel_write_action_data (struct ast_bridge_channel *bridge_channel, enum bridge_channel_action_type action, const void *data, size_t datalen)
 
static int bridge_channel_write_dtmf_stream (struct ast_bridge_channel *bridge_channel, const char *dtmf)
 
static int bridge_channel_write_frame (struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
 
static void bridge_frame_free (struct ast_frame *frame)
 
static struct ast_framebridge_handle_dtmf (struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
 
static void bridge_handle_trip (struct ast_bridge_channel *bridge_channel)
 
static void bridge_sync_cleanup (struct bridge_sync *sync_struct)
 Clean up a synchronization bridge object. More...
 
static void bridge_sync_init (struct bridge_sync *sync_struct, unsigned int id)
 Initialize a synchronous bridge object. More...
 
static void bridge_sync_signal (struct bridge_sync *sync_struct)
 Signal that waiting for a synchronous bridge action is no longer necessary. More...
 
static void bridge_sync_wait (struct bridge_sync *sync_struct)
 Wait for a synchronous bridge action to complete. More...
 
static void channel_fill_empty_accountcode (struct ast_channel *dest, struct ast_channel *src)
 
static void channel_fill_empty_peeraccount (struct ast_channel *dest, struct ast_channel *src)
 
static int channel_set_cause (struct ast_channel *chan, int cause)
 
static void channel_set_empty_accountcodes (struct ast_channel *c0, struct ast_channel *c1)
 
static void channel_update_peeraccount (struct ast_channel *dest, struct ast_channel *src)
 
static void channel_update_peeraccounts (struct ast_channel *c0, struct ast_channel *c1)
 
static int payload_helper_app (ast_bridge_channel_post_action_data post_it, struct ast_bridge_channel *bridge_channel, const char *app_name, const char *app_args, const char *moh_class)
 
static int payload_helper_cb (ast_bridge_channel_post_action_data post_it, 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)
 
static int payload_helper_park (ast_bridge_channel_post_action_data post_it, struct ast_bridge_channel *bridge_channel, const char *parkee_uuid, const char *parker_uuid, const char *app_data)
 
static int payload_helper_playfile (ast_bridge_channel_post_action_data post_it, struct ast_bridge_channel *bridge_channel, ast_bridge_custom_play_fn custom_play, const char *playfile, const char *moh_class)
 
static int run_app_helper (struct ast_channel *chan, const char *app_name, const char *app_args)
 
static void sendtext_safe (struct ast_channel *chan, const struct ast_frame *f)
 
static void testsuite_notify_feature_success (struct ast_channel *chan, const char *dtmf)
 

Variables

static const char * controls []
 
static int sync_ids
 Counter used for assigning synchronous bridge action IDs. More...
 
static struct sync_structs sync_structs = { .first = NULL, .last = NULL, .lock = { PTHREAD_RWLOCK_INITIALIZER , NULL, {1, 0} } , }
 

Detailed Description

Bridging Channel API.

Author
Joshua Colp jcolp.nosp@m.@dig.nosp@m.ium.c.nosp@m.om
Richard Mudgett rmudg.nosp@m.ett@.nosp@m.digiu.nosp@m.m.co.nosp@m.m
Matt Jordan mjord.nosp@m.an@d.nosp@m.igium.nosp@m..com

Definition in file bridge_channel.c.

Macro Definition Documentation

◆ PLAYBACK_TIMEOUT

#define PLAYBACK_TIMEOUT   (600 * 1000)

Failsafe for synchronous bridge action waiting.

When waiting for a synchronous bridge action to complete, if there is a frame resource leak somewhere, it is possible that we will never get notified that the synchronous action completed.

If a significant amount of time passes, then we will abandon waiting for the synchrnous bridge action to complete.

This constant represents the number of milliseconds we will wait for the bridge action to complete.

Definition at line 179 of file bridge_channel.c.

Typedef Documentation

◆ ast_bridge_channel_post_action_data

typedef int(* ast_bridge_channel_post_action_data) (struct ast_bridge_channel *bridge_channel, enum bridge_channel_action_type action, const void *data, size_t datalen)

Used to queue an action frame onto a bridge channel and write an action frame into a bridge.

Since
12.0.0
Parameters
bridge_channelWhich channel work with.
actionType of bridge action frame.
dataFrame payload data to pass.
datalenFrame payload data length to pass.
Return values
0on success.
-1on error.

Definition at line 74 of file bridge_channel.c.

Function Documentation

◆ after_bridge_move_channel()

static void after_bridge_move_channel ( struct ast_channel chan_bridged,
void *  data 
)
static

Definition at line 1877 of file bridge_channel.c.

1878{
1879 RAII_VAR(struct ast_channel *, chan_target, data, ao2_cleanup);
1880 struct ast_party_connected_line connected_target;
1881 unsigned char connected_line_data[1024];
1882 int payload_size;
1883
1884 ast_party_connected_line_init(&connected_target);
1885
1886 ast_channel_lock(chan_target);
1887 ast_party_connected_line_copy(&connected_target, ast_channel_connected(chan_target));
1888 ast_channel_unlock(chan_target);
1889 ast_party_id_reset(&connected_target.priv);
1890
1891 if (ast_channel_move(chan_target, chan_bridged)) {
1892 ast_softhangup(chan_target, AST_SOFTHANGUP_DEV);
1893 ast_party_connected_line_free(&connected_target);
1894 return;
1895 }
1896
1897 /* The ast_channel_move function will end up updating the connected line information
1898 * on chan_target to the value we have here, but will not inform it. To ensure that
1899 * AST_FRAME_READ_ACTION_CONNECTED_LINE_MACRO is executed we wipe it away here. If
1900 * we don't do this then the change will be considered redundant, since the connected
1901 * line information is already there (despite the channel not being told).
1902 */
1903 ast_channel_lock(chan_target);
1906 ast_channel_unlock(chan_target);
1907
1908 if ((payload_size = ast_connected_line_build_data(connected_line_data,
1909 sizeof(connected_line_data), &connected_target, NULL)) != -1) {
1910 struct ast_control_read_action_payload *frame_payload;
1911 int frame_size;
1912
1913 frame_size = payload_size + sizeof(*frame_payload);
1914 frame_payload = ast_alloca(frame_size);
1916 frame_payload->payload_size = payload_size;
1917 memcpy(frame_payload->payload, connected_line_data, payload_size);
1918 ast_queue_control_data(chan_target, AST_CONTROL_READ_ACTION, frame_payload, frame_size);
1919 }
1920
1921 /* A connected line update is queued so that if chan_target is remotely involved with
1922 * anything (such as dialing a channel) the other channel(s) will be informed of the
1923 * new channel they are involved with.
1924 */
1925 ast_channel_lock(chan_target);
1926 ast_connected_line_copy_from_caller(&connected_target, ast_channel_caller(chan_target));
1927 ast_channel_queue_connected_line_update(chan_target, &connected_target, NULL);
1928 ast_channel_unlock(chan_target);
1929
1930 ast_party_connected_line_free(&connected_target);
1931}
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
Definition: astmm.h:288
#define ao2_cleanup(obj)
Definition: astobj2.h:1934
void ast_party_connected_line_free(struct ast_party_connected_line *doomed)
Destroy the connected line information contents.
Definition: channel.c:2072
#define ast_channel_lock(chan)
Definition: channel.h:2922
void ast_party_connected_line_copy(struct ast_party_connected_line *dest, const struct ast_party_connected_line *src)
Copy the source connected line information to the destination connected line.
Definition: channel.c:2031
struct ast_party_connected_line * ast_channel_connected(struct ast_channel *chan)
int ast_queue_control_data(struct ast_channel *chan, enum ast_control_frame_type control, const void *data, size_t datalen)
Queue a control frame with payload.
Definition: channel.c:1238
int ast_channel_move(struct ast_channel *dest, struct ast_channel *source)
Move a channel from its current location to a new location.
Definition: channel.c:10666
int ast_softhangup(struct ast_channel *chan, int cause)
Softly hangup up a channel.
Definition: channel.c:2471
void ast_party_id_reset(struct ast_party_id *id)
Destroy and initialize the given party id structure.
Definition: channel.c:1896
int ast_connected_line_build_data(unsigned char *data, size_t datalen, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
Build the connected line information data frame.
Definition: channel.c:8697
@ AST_SOFTHANGUP_DEV
Definition: channel.h:1121
void ast_party_connected_line_init(struct ast_party_connected_line *init)
Initialize the given connected line structure.
Definition: channel.c:2022
struct ast_party_connected_line * ast_channel_connected_indicated(struct ast_channel *chan)
void ast_connected_line_copy_from_caller(struct ast_party_connected_line *dest, const struct ast_party_caller *src)
Copy the caller information to the connected line information.
Definition: channel.c:8293
struct ast_party_caller * ast_channel_caller(struct ast_channel *chan)
void ast_channel_queue_connected_line_update(struct ast_channel *chan, const struct ast_party_connected_line *connected, const struct ast_set_party_connected_line *update)
Queue a connected line update frame on a channel.
Definition: channel.c:9106
#define ast_channel_unlock(chan)
Definition: channel.h:2923
static int frame_size[4]
Definition: format_g726.c:52
@ AST_FRAME_READ_ACTION_CONNECTED_LINE_MACRO
@ AST_CONTROL_READ_ACTION
#define NULL
Definition: resample.c:96
Main Channel structure associated with a channel.
enum ast_frame_read_action action
Connected Line/Party information.
Definition: channel.h:456
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:941

References ast_control_read_action_payload::action, ao2_cleanup, ast_alloca, ast_channel_caller(), ast_channel_connected(), ast_channel_connected_indicated(), ast_channel_lock, ast_channel_move(), ast_channel_queue_connected_line_update(), ast_channel_unlock, ast_connected_line_build_data(), ast_connected_line_copy_from_caller(), AST_CONTROL_READ_ACTION, AST_FRAME_READ_ACTION_CONNECTED_LINE_MACRO, ast_party_connected_line_copy(), ast_party_connected_line_free(), ast_party_connected_line_init(), ast_party_id_reset(), ast_queue_control_data(), ast_softhangup(), AST_SOFTHANGUP_DEV, frame_size, NULL, ast_control_read_action_payload::payload, ast_control_read_action_payload::payload_size, ast_party_connected_line::priv, and RAII_VAR.

Referenced by bridge_channel_attended_transfer().

◆ after_bridge_move_channel_fail()

static void after_bridge_move_channel_fail ( enum ast_bridge_after_cb_reason  reason,
void *  data 
)
static

Definition at line 1937 of file bridge_channel.c.

1938{
1939 RAII_VAR(struct ast_channel *, chan_target, data, ao2_cleanup);
1940
1941 ast_log(LOG_WARNING, "Unable to complete transfer: %s\n",
1943 ast_softhangup(chan_target, AST_SOFTHANGUP_DEV);
1944}
#define ast_log
Definition: astobj2.c:42
const char * ast_bridge_after_cb_reason_string(enum ast_bridge_after_cb_reason reason)
Get a string representation of an after bridge callback reason.
Definition: bridge_after.c:288
#define LOG_WARNING

References ao2_cleanup, ast_bridge_after_cb_reason_string(), ast_log, ast_softhangup(), AST_SOFTHANGUP_DEV, LOG_WARNING, and RAII_VAR.

Referenced by bridge_channel_attended_transfer().

◆ ast_bridge_channel_feature_digit()

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_channelChannel that received a DTMF digit.
digitDTMF digit to add to collected digits or 0 for timeout event.
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.

Definition at line 1695 of file bridge_channel.c.

1696{
1697 struct ast_bridge_features *features = bridge_channel->features;
1698 struct ast_bridge_hook_dtmf *hook = NULL;
1699 size_t dtmf_len;
1700
1701 struct sanity_check_of_dtmf_size {
1702 char check[1 / (ARRAY_LEN(bridge_channel->dtmf_hook_state.collected) == ARRAY_LEN(hook->dtmf.code))];
1703 };
1704
1705 dtmf_len = strlen(bridge_channel->dtmf_hook_state.collected);
1706 if (!dtmf_len && !digit) {
1707 /* Nothing to do */
1708 return;
1709 }
1710
1711 if (digit) {
1712 dtmf_len = bridge_channel_feature_digit_add(bridge_channel, digit, dtmf_len);
1713 }
1714
1715 while (digit) {
1716 /* See if a DTMF feature hook matches or can match */
1717 hook = ao2_find(features->dtmf_hooks, bridge_channel->dtmf_hook_state.collected,
1719 if (!hook) {
1720 ast_debug(1, "No DTMF feature hooks on %p(%s) match '%s'\n",
1721 bridge_channel, ast_channel_name(bridge_channel->chan),
1722 bridge_channel->dtmf_hook_state.collected);
1723 break;
1724 } else if (dtmf_len != strlen(hook->dtmf.code)) {
1725 unsigned int digit_timeout;
1726 /* Need more digits to match */
1727 ao2_ref(hook, -1);
1728 digit_timeout = bridge_channel_feature_digit_timeout(bridge_channel);
1729 bridge_channel->dtmf_hook_state.interdigit_timeout =
1730 ast_tvadd(ast_tvnow(), ast_samp2tv(digit_timeout, 1000));
1731 return;
1732 } else {
1733 int remove_me;
1734 int already_suspended;
1735
1736 ast_debug(1, "DTMF feature hook %p matched DTMF string '%s' on %p(%s)\n",
1737 hook, bridge_channel->dtmf_hook_state.collected, bridge_channel,
1738 ast_channel_name(bridge_channel->chan));
1739
1740 /*
1741 * Clear the collected digits before executing the hook
1742 * in case the hook starts another sequence.
1743 */
1744 bridge_channel->dtmf_hook_state.collected[0] = '\0';
1745
1746 ast_bridge_channel_lock_bridge(bridge_channel);
1747 already_suspended = bridge_channel->suspended;
1748 if (!already_suspended) {
1750 }
1751 ast_bridge_unlock(bridge_channel->bridge);
1752 ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
1753
1754 /* Execute the matched hook on this channel. */
1755 remove_me = hook->generic.callback(bridge_channel, hook->generic.hook_pvt);
1756 if (remove_me) {
1757 ast_debug(1, "DTMF hook %p is being removed from %p(%s)\n",
1758 hook, bridge_channel, ast_channel_name(bridge_channel->chan));
1759 ao2_unlink(features->dtmf_hooks, hook);
1760 }
1761 testsuite_notify_feature_success(bridge_channel->chan, hook->dtmf.code);
1762 ao2_ref(hook, -1);
1763
1764 ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
1765 if (!already_suspended) {
1766 bridge_channel_unsuspend(bridge_channel);
1767 }
1768
1769 /*
1770 * If we are handing the channel off to an external hook for
1771 * ownership, we are not guaranteed what kind of state it will
1772 * come back in. If the channel hungup, we need to detect that
1773 * here if the hook did not already change the state.
1774 */
1775 if (bridge_channel->chan && ast_check_hangup_locked(bridge_channel->chan)) {
1776 ast_bridge_channel_kick(bridge_channel, 0);
1777 bridge_channel->dtmf_hook_state.collected[0] = '\0';
1778 return;
1779 }
1780
1781 /* if there is dtmf that has been collected then loop back through,
1782 but set digit to -1 so it doesn't try to do an add since the dtmf
1783 is already in the buffer */
1784 dtmf_len = strlen(bridge_channel->dtmf_hook_state.collected);
1785 if (!dtmf_len) {
1786 return;
1787 }
1788 }
1789 }
1790
1791 if (!digit) {
1792 ast_debug(1, "DTMF feature string collection on %p(%s) timed out\n",
1793 bridge_channel, ast_channel_name(bridge_channel->chan));
1794 }
1795
1796 /* Timeout or DTMF digit didn't allow a match with any hooks. */
1797 if (features->dtmf_passthrough) {
1798 /* Stream the collected DTMF to the other channels. */
1799 bridge_channel_write_dtmf_stream(bridge_channel,
1800 bridge_channel->dtmf_hook_state.collected);
1801 }
1802 bridge_channel->dtmf_hook_state.collected[0] = '\0';
1803
1804 ast_test_suite_event_notify("FEATURE_DETECTION", "Result: fail");
1805}
char digit
#define ao2_unlink(container, obj)
Remove an object from a container.
Definition: astobj2.h:1578
#define ao2_find(container, arg, flags)
Definition: astobj2.h:1736
#define ao2_ref(o, delta)
Reference/unreference an object and return the old refcount.
Definition: astobj2.h:459
@ OBJ_SEARCH_PARTIAL_KEY
The arg parameter is a partial search key similar to OBJ_SEARCH_KEY.
Definition: astobj2.h:1116
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition: bridge.h:481
static void testsuite_notify_feature_success(struct ast_channel *chan, const char *dtmf)
void bridge_channel_internal_suspend_nolock(struct ast_bridge_channel *bridge_channel)
void ast_bridge_channel_lock_bridge(struct ast_bridge_channel *bridge_channel)
Lock the bridge associated with the bridge channel.
void ast_bridge_channel_kick(struct ast_bridge_channel *bridge_channel, int cause)
Kick the channel out of the bridge.
static void bridge_channel_unsuspend(struct ast_bridge_channel *bridge_channel)
static int bridge_channel_write_dtmf_stream(struct ast_bridge_channel *bridge_channel, const char *dtmf)
static unsigned int bridge_channel_feature_digit_timeout(struct ast_bridge_channel *bridge_channel)
static int bridge_channel_feature_digit_add(struct ast_bridge_channel *bridge_channel, int digit, size_t dtmf_len)
const char * ast_channel_name(const struct ast_channel *chan)
int ast_check_hangup_locked(struct ast_channel *chan)
Definition: channel.c:459
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
Definition: channel.c:4277
@ AST_CONTROL_SRCUPDATE
#define ast_debug(level,...)
Log a DEBUG message.
unsigned int suspended
struct ast_bridge_channel::@195 dtmf_hook_state
struct ast_bridge * bridge
Bridge this channel is participating in.
struct timeval interdigit_timeout
char collected[MAXIMUM_DTMF_FEATURE_STRING]
struct ast_bridge_features * features
struct ast_channel * chan
Structure that contains features information.
struct ao2_container * dtmf_hooks
unsigned int dtmf_passthrough
char code[MAXIMUM_DTMF_FEATURE_STRING]
struct ast_bridge_hook generic
struct ast_bridge_hook_dtmf_parms dtmf
ast_bridge_hook_callback callback
#define ast_test_suite_event_notify(s, f,...)
Definition: test.h:189
struct timeval ast_samp2tv(unsigned int _nsamp, unsigned int _rate)
Returns a timeval corresponding to the duration of n samples at rate r. Useful to convert samples to ...
Definition: time.h:282
struct timeval ast_tvadd(struct timeval a, struct timeval b)
Returns the sum of two timevals a + b.
Definition: extconf.c:2282
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:159
#define ARRAY_LEN(a)
Definition: utils.h:666

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, digit, 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().

◆ ast_bridge_channel_feature_digit_add()

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_channelChannel that received a DTMF digit.
digitDTMF 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 1687 of file bridge_channel.c.

1688{
1689 if (digit) {
1691 bridge_channel, digit, strlen(bridge_channel->dtmf_hook_state.collected));
1692 }
1693}

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

Referenced by play_file().

◆ ast_bridge_channel_get_chan()

struct ast_channel * ast_bridge_channel_get_chan ( struct ast_bridge_channel bridge_channel)

Get a ref to the bridge_channel's ast_channel.

Parameters
bridge_channelThe bridge channel
Note
The returned channel NEEDS to be unref'd once you are done with it. In general, this function is best used when accessing the bridge_channel chan from outside of a bridging thread.
Return values
ref'dast_channel on success
NULLotherwise

Definition at line 212 of file bridge_channel.c.

213{
214 struct ast_channel *chan;
215
219
220 return chan;
221}
#define ao2_unlock(a)
Definition: astobj2.h:729
#define ao2_lock(a)
Definition: astobj2.h:717
#define ao2_bump(obj)
Bump refcount on an AO2 object by one, returning the object.
Definition: astobj2.h:480
struct ast_bridge_channel * bridge_channel

References ao2_bump, ao2_lock, ao2_unlock, ast_channel::bridge_channel, and ast_bridge_channel::chan.

Referenced by ast_bridge_channel_write_unhold().

◆ ast_bridge_channel_kick()

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_channelWhich channel is being kicked or hungup.
causeCause 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.

Definition at line 592 of file bridge_channel.c.

593{
594 struct ast_bridge_features *features = bridge_channel->features;
595 struct ast_bridge_hook *hook;
596 struct ao2_iterator iter;
597
598 ast_bridge_channel_lock(bridge_channel);
599 if (bridge_channel->state == BRIDGE_CHANNEL_STATE_WAIT) {
600 channel_set_cause(bridge_channel->chan, cause);
601 cause = 0;
602 }
603 ast_bridge_channel_unlock(bridge_channel);
604
605 /* Run any hangup hooks. */
606 iter = ao2_iterator_init(features->other_hooks, 0);
607 for (; (hook = ao2_iterator_next(&iter)); ao2_ref(hook, -1)) {
608 int remove_me;
609
610 if (hook->type != AST_BRIDGE_HOOK_TYPE_HANGUP) {
611 continue;
612 }
613 remove_me = hook->callback(bridge_channel, hook->hook_pvt);
614 if (remove_me) {
615 ast_debug(1, "Hangup hook %p is being removed from %p(%s)\n",
616 hook, bridge_channel, ast_channel_name(bridge_channel->chan));
617 ao2_unlink(features->other_hooks, hook);
618 }
619 }
621
622 /* Default hangup action. */
624}
#define ao2_iterator_next(iter)
Definition: astobj2.h:1911
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
static int channel_set_cause(struct ast_channel *chan, int cause)
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).
#define ast_bridge_channel_unlock(bridge_channel)
Unlock the bridge_channel.
#define ast_bridge_channel_lock(bridge_channel)
Lock the bridge_channel.
@ BRIDGE_CHANNEL_STATE_WAIT
@ BRIDGE_CHANNEL_STATE_END
@ AST_BRIDGE_HOOK_TYPE_HANGUP
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Definition: astobj2.h:1821
enum bridge_channel_state state
struct ao2_container * other_hooks
Structure that is the essence of a feature hook.
enum ast_bridge_hook_type type

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_handle_action(), bridge_channel_internal_join(), bridge_handle_trip(), and kick_it().

◆ ast_bridge_channel_leave_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).

Parameters
bridge_channelChannel to change the state on
new_stateThe new state to place the channel into
causeCause of channel leaving bridge. If cause <= 0 then use cause on channel if cause still <= 0 use AST_CAUSE_NORMAL_CLEARING.

Example usage:

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).
#define AST_CAUSE_NORMAL_CLEARING
Definition: causes.h:106

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 315 of file bridge_channel.c.

316{
317 ast_bridge_channel_lock(bridge_channel);
318 ast_bridge_channel_leave_bridge_nolock(bridge_channel, new_state, cause);
319 ast_bridge_channel_unlock(bridge_channel);
320}
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).

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_complete_join(), bridge_channel_dissolve_check(), bridge_channel_internal_push_full(), bridge_dissolve(), bridge_do_merge(), bridge_do_move(), bridge_features_duration_callback(), bridge_swap_attended_transfer(), bridgewait_timeout_callback(), caller_joined_bridge(), caller_safety_timeout(), feature_hangup(), parking_duration_callback(), say_parking_space(), set_softmix_bridge_data(), try_swap_optimize_out(), and user_timeout().

◆ ast_bridge_channel_leave_bridge_nolock()

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_channelChannel to change the state on
new_stateThe new state to place the channel into
causeCause 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 293 of file bridge_channel.c.

294{
295 if (bridge_channel->state != BRIDGE_CHANNEL_STATE_WAIT) {
296 return;
297 }
298
299 ast_debug(1, "Setting %p(%s) state from:%u to:%u\n",
300 bridge_channel, ast_channel_name(bridge_channel->chan), bridge_channel->state,
301 new_state);
302
303 channel_set_cause(bridge_channel->chan, cause);
304
305 ast_channel_lock(bridge_channel->chan);
306 ast_bridge_vars_set(bridge_channel->chan, NULL, NULL);
307 ast_channel_unlock(bridge_channel->chan);
308
309 /* Change the state on the bridge channel */
310 bridge_channel->state = new_state;
311
312 bridge_channel_poke(bridge_channel);
313}
void ast_bridge_vars_set(struct ast_channel *chan, const char *name, const char *pvtid)
Sets BRIDGECHANNEL and BRIDGEPVTCALLID for a channel.
Definition: bridge.c:1212
static void bridge_channel_poke(struct ast_bridge_channel *bridge_channel)

References ast_bridge_vars_set(), ast_channel_lock, ast_channel_name(), ast_channel_unlock, ast_debug, bridge_channel_poke(), BRIDGE_CHANNEL_STATE_WAIT, ast_bridge_channel::chan, channel_set_cause(), NULL, and ast_bridge_channel::state.

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

◆ ast_bridge_channel_lock_bridge()

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_channelChannel 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.

Definition at line 223 of file bridge_channel.c.

224{
225 struct ast_bridge *bridge;
226
227 for (;;) {
228 /* Safely get the bridge pointer */
229 ast_bridge_channel_lock(bridge_channel);
230 bridge = bridge_channel->bridge;
231 ao2_ref(bridge, +1);
232 ast_bridge_channel_unlock(bridge_channel);
233
234 /* Lock the bridge and see if it is still the bridge we need to lock. */
235 ast_bridge_lock(bridge);
236 if (bridge == bridge_channel->bridge) {
237 ao2_ref(bridge, -1);
238 return;
239 }
240 ast_bridge_unlock(bridge);
241 ao2_ref(bridge, -1);
242 }
243}
#define ast_bridge_lock(bridge)
Lock the bridge.
Definition: bridge.h:470
Structure that contains information about a bridge.
Definition: bridge.h:349

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

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

◆ ast_bridge_channel_merge_inhibit()

struct ast_bridge * ast_bridge_channel_merge_inhibit ( struct ast_bridge_channel bridge_channel,
int  request 
)

Adjust the bridge_channel's bridge merge inhibit request count.

Since
12.0.0
Parameters
bridge_channelWhat to operate on.
requestInhibit request increment. (Positive to add requests. Negative to remove requests.)
Note
This API call is meant for internal bridging operations.
Return values
bridgeadjusted merge inhibit with reference count.

Definition at line 370 of file bridge_channel.c.

371{
372 struct ast_bridge *bridge;
373
374 ast_bridge_channel_lock_bridge(bridge_channel);
375 bridge = bridge_channel->bridge;
376 ao2_ref(bridge, +1);
378 ast_bridge_unlock(bridge);
379 return bridge;
380}
void bridge_merge_inhibit_nolock(struct ast_bridge *bridge, int request)
Definition: bridge.c:2991
static int request(void *obj)
Definition: chan_pjsip.c:2601

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

Referenced by feature_attended_transfer().

◆ ast_bridge_channel_notify_talking()

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_channelThe bridge channel that has either started or stopped talking.
started_talkingset to 1 when this indicates the channel has started talking set to 0 when this indicates the channel has stopped talking.
Return values
0on success.
-1on error.

Definition at line 245 of file bridge_channel.c.

246{
247 struct ast_frame action = {
249 .subclass.integer = started_talking
251 };
252
253 return ast_bridge_channel_queue_frame(bridge_channel, &action);
254}
int ast_bridge_channel_queue_frame(struct ast_bridge_channel *bridge_channel, struct ast_frame *fr)
Write a frame to the specified bridge_channel.
@ BRIDGE_CHANNEL_ACTION_TALKING_STOP
@ BRIDGE_CHANNEL_ACTION_TALKING_START
@ AST_FRAME_BRIDGE_ACTION
Data structure associated with a single frame of data.
enum ast_frame_type frametype

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 clear_talking(), and softmix_bridge_write_voice().

◆ ast_bridge_channel_peer()

struct ast_bridge_channel * ast_bridge_channel_peer ( struct ast_bridge_channel bridge_channel)

Get the peer bridge channel of a two party bridge.

Since
12.0.0
Parameters
bridge_channelWhat to get the peer of.
Note
On entry, bridge_channel->bridge is already locked.
This is an internal bridge function.
Return values
peeron success.
NULLno peer channel.

Definition at line 322 of file bridge_channel.c.

323{
324 struct ast_bridge *bridge = bridge_channel->bridge;
325 struct ast_bridge_channel *other = NULL;
326
327 if (bridge_channel->in_bridge && bridge->num_channels == 2) {
329 if (other != bridge_channel) {
330 break;
331 }
332 }
333 }
334
335 return other;
336}
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:491
Structure that contains information regarding a channel in a bridge.
unsigned int in_bridge
struct ast_bridge_channels_list channels
Definition: bridge.h:363
unsigned int num_channels
Definition: bridge.h:373
Definition: search.h:40

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().

◆ ast_bridge_channel_playfile()

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_channelWhich channel to play the file on
custom_playCall this function to play the playfile. (NULL if normal sound file to play)
playfileSound filename to play.
moh_classMOH 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.

Definition at line 1262 of file bridge_channel.c.

1263{
1264 if (moh_class) {
1265 ast_bridge_channel_write_hold(bridge_channel, moh_class);
1266 }
1267 if (custom_play) {
1268 custom_play(bridge_channel, playfile);
1269 } else {
1270 ast_stream_and_wait(bridge_channel->chan, playfile, AST_DIGIT_NONE);
1271 }
1272 if (moh_class) {
1273 ast_bridge_channel_write_unhold(bridge_channel);
1274 }
1275
1276 /*
1277 * It may be necessary to resume music on hold after we finish
1278 * playing the announcment.
1279 */
1280 if (ast_test_flag(ast_channel_flags(bridge_channel->chan), AST_FLAG_MOH)) {
1281 const char *latest_musicclass;
1282
1283 ast_channel_lock(bridge_channel->chan);
1284 latest_musicclass = ast_strdupa(ast_channel_latest_musicclass(bridge_channel->chan));
1285 ast_channel_unlock(bridge_channel->chan);
1286 ast_moh_start(bridge_channel->chan, latest_musicclass, NULL);
1287 }
1288}
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:298
int ast_bridge_channel_write_unhold(struct ast_bridge_channel *bridge_channel)
Write an unhold frame into the bridge.
int ast_bridge_channel_write_hold(struct ast_bridge_channel *bridge_channel, const char *moh_class)
Write a hold frame into the bridge.
const char * ast_channel_latest_musicclass(const struct ast_channel *chan)
struct ast_flags * ast_channel_flags(struct ast_channel *chan)
@ AST_FLAG_MOH
Definition: channel.h:991
int ast_stream_and_wait(struct ast_channel *chan, const char *file, const char *digits)
stream file until digit If the file name is non-empty, try to play it.
Definition: file.c:1878
#define AST_DIGIT_NONE
Definition: file.h:47
int ast_moh_start(struct ast_channel *chan, const char *mclass, const char *interpclass)
Turn on music on hold on a given channel.
Definition: channel.c:7766
#define ast_test_flag(p, flag)
Definition: utils.h:63

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().

◆ ast_bridge_channel_queue_app()

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_channelWhich channel to put the frame onto
app_nameDialplan application name.
app_argsArguments for the application. (NULL or empty for no arguments)
moh_classMOH 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
0on success.
-1on error.

Definition at line 1256 of file bridge_channel.c.

1257{
1259 bridge_channel, app_name, app_args, moh_class);
1260}
static int bridge_channel_queue_action_data(struct ast_bridge_channel *bridge_channel, enum bridge_channel_action_type action, const void *data, size_t datalen)
static int payload_helper_app(ast_bridge_channel_post_action_data post_it, struct ast_bridge_channel *bridge_channel, const char *app_name, const char *app_args, const char *moh_class)
const char * app_name(struct ast_app *app)
Definition: pbx_app.c:463

References app_name(), bridge_channel_queue_action_data(), and payload_helper_app().

◆ ast_bridge_channel_queue_callback()

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_channelWhich channel to put the frame onto.
flagsCustom callback option flags.
callbackCustom callback run on a bridge channel.
payloadData to pass to the callback. (NULL if none).
payload_sizeSize 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
0on success.
-1on error.

Definition at line 1429 of file bridge_channel.c.

1432{
1434 bridge_channel, flags, callback, payload, payload_size);
1435}
static int payload_helper_cb(ast_bridge_channel_post_action_data post_it, 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)

References bridge_channel_queue_action_data(), bridge_custom_callback::callback, bridge_custom_callback::flags, bridge_custom_callback::payload, payload_helper_cb(), and bridge_custom_callback::payload_size.

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

◆ ast_bridge_channel_queue_control_data()

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_channelWhich channel to queue the frame onto.
controlType of control frame.
dataFrame payload data to pass.
datalenFrame payload data length to pass.
Return values
0on success.
-1on error.

Definition at line 1104 of file bridge_channel.c.

1105{
1106 struct ast_frame frame = {
1108 .subclass.integer = control,
1109 .datalen = datalen,
1110 .data.ptr = (void *) data,
1111 };
1112
1113 return ast_bridge_channel_queue_frame(bridge_channel, &frame);
1114}
@ AST_FRAME_CONTROL
union ast_frame::@226 data

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

Referenced by bridge_reconfigured_connected_line_update(), and send_colp_to_agent().

◆ ast_bridge_channel_queue_frame()

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_channelChannel to queue the frame.
frFrame to write.
Return values
0on success.
-1on error.

Definition at line 1005 of file bridge_channel.c.

1006{
1007 struct ast_frame *dup;
1008
1009 if (bridge_channel->suspended
1010 /* Also defer DTMF frames. */
1013 && !ast_is_deferrable_frame(fr)) {
1014 /* Drop non-deferable frames when suspended. */
1015 return 0;
1016 }
1017 if (fr->frametype == AST_FRAME_NULL) {
1018 /* "Accept" the frame and discard it. */
1019 return 0;
1020 }
1021
1022 if ((fr->frametype == AST_FRAME_VOICE || fr->frametype == AST_FRAME_VIDEO ||
1024 fr->frametype == AST_FRAME_RTCP) && fr->stream_num > -1) {
1025 int num = -1;
1026
1027 ast_bridge_channel_lock(bridge_channel);
1028 if (fr->stream_num < (int)AST_VECTOR_SIZE(&bridge_channel->stream_map.to_channel)) {
1029 num = AST_VECTOR_GET(&bridge_channel->stream_map.to_channel, fr->stream_num);
1030 }
1031 ast_bridge_channel_unlock(bridge_channel);
1032
1033 if (num == -1) {
1034 /* We don't have a mapped stream so just discard this frame. */
1035 return 0;
1036 }
1037 }
1038
1039 dup = ast_frdup(fr);
1040 if (!dup) {
1041 return -1;
1042 }
1043
1044 ast_bridge_channel_lock(bridge_channel);
1045 if (bridge_channel->state != BRIDGE_CHANNEL_STATE_WAIT) {
1046 /* Drop frames on channels leaving the bridge. */
1047 ast_bridge_channel_unlock(bridge_channel);
1048 bridge_frame_free(dup);
1049 return 0;
1050 }
1051
1052 if ((fr->frametype == AST_FRAME_TEXT || fr->frametype == AST_FRAME_TEXT_DATA) &&
1053 !bridge_channel->features->text_messaging) {
1054 /* This channel is not accepting text messages. */
1055 ast_bridge_channel_unlock(bridge_channel);
1056 bridge_frame_free(dup);
1057 return 0;
1058 }
1059
1060 if (DEBUG_ATLEAST(1)) {
1061 if (fr->frametype == AST_FRAME_TEXT) {
1062 ast_log(LOG_DEBUG, "Queuing TEXT frame to '%s': %*.s\n", ast_channel_name(bridge_channel->chan),
1063 fr->datalen, (char *)fr->data.ptr);
1064 } else if (fr->frametype == AST_FRAME_TEXT_DATA) {
1065 struct ast_msg_data *msg = fr->data.ptr;
1066 ast_log(LOG_DEBUG, "Queueing TEXT_DATA frame from '%s' to '%s:%s': %s\n",
1069 ast_channel_name(bridge_channel->chan),
1071 }
1072 }
1073
1074 AST_LIST_INSERT_TAIL(&bridge_channel->wr_queue, dup, frame_list);
1075 if (ast_alertpipe_write(bridge_channel->alert_pipe)) {
1076 ast_log(LOG_ERROR, "We couldn't write alert pipe for %p(%s)... something is VERY wrong\n",
1077 bridge_channel, ast_channel_name(bridge_channel->chan));
1078 }
1079 ast_bridge_channel_unlock(bridge_channel);
1080 return 0;
1081}
ssize_t ast_alertpipe_write(int alert_pipe[2])
Write an event to an alert pipe.
Definition: alertpipe.c:120
static void bridge_frame_free(struct ast_frame *frame)
int ast_is_deferrable_frame(const struct ast_frame *frame)
Should we keep this frame for later?
Definition: channel.c:1467
const char * ast_msg_data_get_attribute(struct ast_msg_data *msg, enum ast_msg_data_attribute_type attribute_type)
Get attribute from ast_msg_data.
@ AST_MSG_DATA_ATTR_BODY
Definition: message.h:458
@ AST_MSG_DATA_ATTR_TO
Definition: message.h:455
@ AST_MSG_DATA_ATTR_FROM
Definition: message.h:456
#define ast_frdup(fr)
Copies a frame.
@ AST_FRAME_VIDEO
@ AST_FRAME_NULL
@ AST_FRAME_IMAGE
@ AST_FRAME_DTMF_END
@ AST_FRAME_DTMF_BEGIN
@ AST_FRAME_VOICE
@ AST_FRAME_RTCP
@ AST_FRAME_TEXT_DATA
@ AST_FRAME_TEXT
#define DEBUG_ATLEAST(level)
#define LOG_DEBUG
#define LOG_ERROR
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Definition: linkedlists.h:731
struct ast_bridge_channel::@198 stream_map
struct ast_vector_int to_channel
struct ast_bridge_channel::@192 wr_queue
unsigned int text_messaging
Structure used to transport a message through the frame core.
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:609
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:680

References ast_bridge_channel::alert_pipe, ast_alertpipe_write(), ast_bridge_channel_lock, ast_bridge_channel_unlock, ast_channel_name(), AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, AST_FRAME_IMAGE, AST_FRAME_NULL, AST_FRAME_RTCP, AST_FRAME_TEXT, AST_FRAME_TEXT_DATA, AST_FRAME_VIDEO, AST_FRAME_VOICE, ast_frdup, ast_is_deferrable_frame(), AST_LIST_INSERT_TAIL, ast_log, AST_MSG_DATA_ATTR_BODY, AST_MSG_DATA_ATTR_FROM, AST_MSG_DATA_ATTR_TO, ast_msg_data_get_attribute(), AST_VECTOR_GET, AST_VECTOR_SIZE, BRIDGE_CHANNEL_STATE_WAIT, bridge_frame_free(), ast_bridge_channel::chan, ast_frame::data, ast_frame::datalen, DEBUG_ATLEAST, ast_bridge_channel::features, ast_frame::frametype, LOG_DEBUG, LOG_ERROR, ast_frame::ptr, ast_bridge_channel::state, ast_bridge_channel::stream_map, ast_frame::stream_num, ast_bridge_channel::suspended, ast_bridge_features::text_messaging, ast_bridge_channel::to_channel, 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(), remb_send_report(), send_message(), softmix_mixing_loop(), and softmix_pass_video_top_priority().

◆ ast_bridge_channel_queue_playfile()

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_channelWhich channel to put the frame onto.
custom_playCall this function to play the playfile. (NULL if normal sound file to play)
playfileSound filename to play.
moh_classMOH 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
0on success.
-1on error.

Definition at line 1343 of file bridge_channel.c.

1344{
1346 bridge_channel, custom_play, playfile, moh_class);
1347}
static int payload_helper_playfile(ast_bridge_channel_post_action_data post_it, struct ast_bridge_channel *bridge_channel, ast_bridge_custom_play_fn custom_play, const char *playfile, const char *moh_class)

References bridge_channel_queue_action_data(), bridge_playfile::custom_play, payload_helper_playfile(), and bridge_playfile::playfile.

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

◆ ast_bridge_channel_queue_playfile_sync()

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_channelWhich channel to put the frame onto.
custom_playCall this function to play the playfile. (NULL if normal sound file to play)
playfileSound filename to play.
moh_classMOH 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
0The playback was successfully queued.
-1The playback could not be queued.

Definition at line 1349 of file bridge_channel.c.

1351{
1353 bridge_channel, custom_play, playfile, moh_class);
1354}
static int bridge_channel_queue_action_data_sync(struct ast_bridge_channel *bridge_channel, enum bridge_channel_action_type action, const void *data, size_t datalen)

References bridge_channel_queue_action_data_sync(), bridge_playfile::custom_play, payload_helper_playfile(), and bridge_playfile::playfile.

Referenced by parker_parked_call_message_response(), and play_uri().

◆ ast_bridge_channel_restore_formats()

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_channelChannel to restore

Definition at line 338 of file bridge_channel.c.

339{
340 ast_assert(bridge_channel->read_format != NULL);
341 ast_assert(bridge_channel->write_format != NULL);
342
343 ast_channel_lock(bridge_channel->chan);
344
345 /* Restore original formats of the channel as they came in */
346 if (ast_format_cmp(ast_channel_readformat(bridge_channel->chan), bridge_channel->read_format) == AST_FORMAT_CMP_NOT_EQUAL) {
347 ast_debug(1, "Bridge is returning %p(%s) to read format %s\n",
348 bridge_channel, ast_channel_name(bridge_channel->chan),
349 ast_format_get_name(bridge_channel->read_format));
350 if (ast_set_read_format(bridge_channel->chan, bridge_channel->read_format)) {
351 ast_debug(1, "Bridge failed to return %p(%s) to read format %s\n",
352 bridge_channel, ast_channel_name(bridge_channel->chan),
353 ast_format_get_name(bridge_channel->read_format));
354 }
355 }
356 if (ast_format_cmp(ast_channel_writeformat(bridge_channel->chan), bridge_channel->write_format) == AST_FORMAT_CMP_NOT_EQUAL) {
357 ast_debug(1, "Bridge is returning %p(%s) to write format %s\n",
358 bridge_channel, ast_channel_name(bridge_channel->chan),
359 ast_format_get_name(bridge_channel->write_format));
360 if (ast_set_write_format(bridge_channel->chan, bridge_channel->write_format)) {
361 ast_debug(1, "Bridge failed to return %p(%s) to write format %s\n",
362 bridge_channel, ast_channel_name(bridge_channel->chan),
363 ast_format_get_name(bridge_channel->write_format));
364 }
365 }
366
367 ast_channel_unlock(bridge_channel->chan);
368}
int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
Sets read format on channel chan.
Definition: channel.c:5762
struct ast_format * ast_channel_writeformat(struct ast_channel *chan)
int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
Sets write format on channel chan.
Definition: channel.c:5803
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
enum ast_format_cmp_res ast_format_cmp(const struct ast_format *format1, const struct ast_format *format2)
Compare two formats.
Definition: format.c:201
@ AST_FORMAT_CMP_NOT_EQUAL
Definition: format.h:38
const char * ast_format_get_name(const struct ast_format *format)
Get the name associated with a format.
Definition: format.c:334
struct ast_format * write_format
struct ast_format * read_format
#define ast_assert(a)
Definition: utils.h:739

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().

◆ ast_bridge_channel_run_app()

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_channelWhich channel to run the application on.
app_nameDialplan application name.
app_argsArguments for the application. (NULL tolerant)
moh_classMOH 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.

Definition at line 1184 of file bridge_channel.c.

1185{
1186 if (moh_class) {
1187 ast_bridge_channel_write_hold(bridge_channel, moh_class);
1188 }
1189 if (run_app_helper(bridge_channel->chan, app_name, S_OR(app_args, ""))) {
1190 /* Break the bridge if the app returns non-zero. */
1192 }
1193 if (moh_class) {
1194 ast_bridge_channel_write_unhold(bridge_channel);
1195 }
1196}
static int run_app_helper(struct ast_channel *chan, const char *app_name, const char *app_args)
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one.
Definition: strings.h:80

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

Referenced by bridge_channel_run_app(), and dynamic_dtmf_hook_callback().

◆ ast_bridge_channel_stream_map()

void ast_bridge_channel_stream_map ( struct ast_bridge_channel bridge_channel)

Maps a channel's stream topology to and from the bridge.

Since
15.0.0

When a channel joins a bridge or its associated stream topology is updated, each stream in the topology needs to be mapped according to its media type to the bridge. Calling this method creates a mapping of each stream on the channel indexed to the bridge's supported media types and vice versa (i.e. bridge's media types indexed to channel streams).

The first channel to join the bridge creates the initial order for the bridge's media types (e.g. a one to one mapping is made). Subsequently added channels are mapped to that order adding more media types if/when the newly added channel has more streams and/or media types specified by the bridge.

Parameters
bridge_channelChannel to map
Note
The bridge_channel's bridge must be locked prior to calling this function.

Definition at line 3119 of file bridge_channel.c.

3120{
3121 ast_bridge_channel_lock(bridge_channel);
3122 ast_channel_lock(bridge_channel->chan);
3124 &bridge_channel->bridge->media_types, &bridge_channel->stream_map.to_bridge,
3125 &bridge_channel->stream_map.to_channel);
3126 ast_channel_unlock(bridge_channel->chan);
3127 ast_bridge_channel_unlock(bridge_channel);
3128}
struct ast_stream_topology * ast_channel_get_stream_topology(const struct ast_channel *chan)
Retrieve the topology of streams on a channel.
void ast_stream_topology_map(const struct ast_stream_topology *topology, struct ast_vector_int *types, struct ast_vector_int *v0, struct ast_vector_int *v1)
Map a given topology's streams to the given types.
Definition: stream.c:985
struct ast_vector_int to_bridge
struct ast_vector_int media_types
Definition: bridge.h:404

References ast_bridge_channel_lock, ast_bridge_channel_unlock, ast_channel_get_stream_topology(), ast_channel_lock, ast_channel_unlock, ast_stream_topology_map(), ast_bridge_channel::bridge, ast_bridge_channel::chan, ast_bridge::media_types, ast_bridge_channel::stream_map, ast_bridge_channel::to_bridge, and ast_bridge_channel::to_channel.

Referenced by bridge_channel_complete_join(), bridge_handle_trip(), native_rtp_stream_topology_changed(), simple_bridge_stream_topology_changed(), and softmix_bridge_stream_topology_changed().

◆ ast_bridge_channel_update_accountcodes()

void ast_bridge_channel_update_accountcodes ( struct ast_bridge_channel joining,
struct ast_bridge_channel leaving 
)

Definition at line 583 of file bridge_channel.c.

584{
585 if (joining) {
587 } else {
589 }
590}
static void bridge_channel_update_accountcodes_joining(struct ast_bridge_channel *joining, struct ast_bridge_channel *swap)
static void bridge_channel_update_accountcodes_leaving(struct ast_bridge_channel *leaving)

References bridge_channel_update_accountcodes_joining(), and bridge_channel_update_accountcodes_leaving().

Referenced by bridge_basic_pull(), bridge_basic_push(), bridge_stasis_pull(), and bridge_stasis_push().

◆ ast_bridge_channel_update_linkedids()

void ast_bridge_channel_update_linkedids ( struct ast_bridge_channel bridge_channel,
struct ast_bridge_channel swap 
)

Definition at line 382 of file bridge_channel.c.

383{
384 struct ast_bridge_channel *other;
385 struct ast_bridge *bridge = bridge_channel->bridge;
386 struct ast_channel *oldest_linkedid_chan = bridge_channel->chan;
387
389 if (other == swap) {
390 continue;
391 }
392 oldest_linkedid_chan = ast_channel_internal_oldest_linkedid(
393 oldest_linkedid_chan, other->chan);
394 }
395
400 if (other == swap) {
401 continue;
402 }
403 ast_channel_lock(other->chan);
404 ast_channel_internal_copy_linkedid(other->chan, oldest_linkedid_chan);
405 ast_channel_unlock(other->chan);
406 }
407}
void ast_channel_internal_copy_linkedid(struct ast_channel *dest, struct ast_channel *source)
Copy the full linkedid channel id structure from one channel to another.
struct ast_channel * ast_channel_internal_oldest_linkedid(struct ast_channel *a, struct ast_channel *b)
Determine which channel has an older linkedid.
struct ast_bridge * bridge

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_channel::bridge, ast_channel::bridge_channel, ast_bridge_channel::chan, and ast_bridge::channels.

Referenced by bridge_basic_push(), and bridge_stasis_push().

◆ ast_bridge_channel_write_app()

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_channelWhich channel is putting the frame into the bridge
app_nameDialplan application name.
app_argsArguments for the application. (NULL or empty for no arguments)
moh_classMOH 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
0on success.
-1on error.

Definition at line 1250 of file bridge_channel.c.

1251{
1253 bridge_channel, app_name, app_args, moh_class);
1254}
static int bridge_channel_write_action_data(struct ast_bridge_channel *bridge_channel, enum bridge_channel_action_type action, const void *data, size_t datalen)

References app_name(), bridge_channel_write_action_data(), and payload_helper_app().

◆ ast_bridge_channel_write_callback()

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_channelWhich channel is putting the frame into the bridge
flagsCustom callback option flags.
callbackCustom callback run on a bridge channel.
payloadData to pass to the callback. (NULL if none).
payload_sizeSize 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
0on success.
-1on error.

Definition at line 1421 of file bridge_channel.c.

1424{
1426 bridge_channel, flags, callback, payload, payload_size);
1427}

References bridge_channel_write_action_data(), bridge_custom_callback::callback, bridge_custom_callback::flags, bridge_custom_callback::payload, payload_helper_cb(), and bridge_custom_callback::payload_size.

Referenced by agent_connect_caller(), and dynamic_dtmf_hook_trip().

◆ ast_bridge_channel_write_control_data()

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_channelWhich channel is putting the frame into the bridge.
controlType of control frame.
dataFrame payload data to pass.
datalenFrame payload data length to pass.
Return values
0on success.
-1on error.

Definition at line 1116 of file bridge_channel.c.

1117{
1118 struct ast_frame frame = {
1120 .subclass.integer = control,
1121 .datalen = datalen,
1122 .data.ptr = (void *) data,
1123 };
1124
1125 return bridge_channel_write_frame(bridge_channel, &frame);
1126}
static int bridge_channel_write_frame(struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)

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

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

◆ ast_bridge_channel_write_hold()

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_channelWhich channel is putting the hold into the bridge.
moh_classThe suggested music class for the other end to use.
Return values
0on success.
-1on error.

Definition at line 1128 of file bridge_channel.c.

1129{
1130 struct ast_json *blob;
1131 int res;
1132 size_t datalen;
1133
1134 if (!ast_strlen_zero(moh_class)) {
1135 datalen = strlen(moh_class) + 1;
1136
1137 blob = ast_json_pack("{s: s}",
1138 "musicclass", moh_class);
1139 } else {
1140 moh_class = NULL;
1141 datalen = 0;
1142 blob = NULL;
1143 }
1144
1146
1148 moh_class, datalen);
1149
1150 ast_json_unref(blob);
1151 return res;
1152}
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.
struct stasis_message_type * ast_channel_hold_type(void)
Message type for when a channel is placed on hold.
void ast_channel_publish_cached_blob(struct ast_channel *chan, struct stasis_message_type *type, struct ast_json *blob)
Publish a channel blob message using the latest snapshot from the cache.
@ AST_CONTROL_HOLD
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
Definition: json.c:73
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
Definition: json.c:612
static force_inline int attribute_pure ast_strlen_zero(const char *s)
Definition: strings.h:65
Abstract JSON element (object, array, string, int, ...).

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().

◆ ast_bridge_channel_write_park()

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_channelBridge channel performing the parking
parkee_uuidUnique id of the channel we want to park
parker_uuidUnique id of the channel parking the call
app_datastring indicating data used for park application (NULL allowed)
Note
This is intended to be called by bridge hooks.
Return values
0on success.
-1on error.

Definition at line 1492 of file bridge_channel.c.

1493{
1495 bridge_channel, parkee_uuid, parker_uuid, app_data);
1496}
static int payload_helper_park(ast_bridge_channel_post_action_data post_it, struct ast_bridge_channel *bridge_channel, const char *parkee_uuid, const char *parker_uuid, const char *app_data)

References bridge_channel_write_action_data(), bridge_park::parkee_uuid, and payload_helper_park().

Referenced by manager_park_bridged(), and parking_blind_transfer_park().

◆ ast_bridge_channel_write_playfile()

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_channelWhich channel is putting the frame into the bridge
custom_playCall this function to play the playfile. (NULL if normal sound file to play)
playfileSound filename to play.
moh_classMOH 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
0on success.
-1on error.

Definition at line 1337 of file bridge_channel.c.

1338{
1340 bridge_channel, custom_play, playfile, moh_class);
1341}

References bridge_channel_write_action_data(), bridge_playfile::custom_play, payload_helper_playfile(), and bridge_playfile::playfile.

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

◆ ast_bridge_channel_write_unhold()

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_channelWhich channel is putting the hold into the bridge.
Return values
0on success.
-1on error.

Definition at line 1154 of file bridge_channel.c.

1155{
1157
1158 if (!chan) {
1159 return -1;
1160 }
1161
1163 ao2_ref(chan, -1);
1164
1166}
struct ast_channel * ast_bridge_channel_get_chan(struct ast_bridge_channel *bridge_channel)
Get a ref to the bridge_channel's ast_channel.
struct stasis_message_type * ast_channel_unhold_type(void)
Message type for when a channel is removed from hold.
@ AST_CONTROL_UNHOLD

References ao2_ref, ast_bridge_channel_get_chan(), ast_bridge_channel_write_control_data(), ast_channel_publish_cached_blob(), ast_channel_unhold_type(), AST_CONTROL_UNHOLD, ast_channel::bridge_channel, 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().

◆ ast_bridge_queue_everyone_else()

int ast_bridge_queue_everyone_else ( struct ast_bridge bridge,
struct ast_bridge_channel bridge_channel,
struct ast_frame frame 
)

Queue the given frame to everyone else.

Since
12.0.0
Parameters
bridgeWhat bridge to distribute frame.
bridge_channelChannel to optionally not pass frame to. (NULL to pass to everyone)
frameFrame to pass.
Note
This is intended to be called by bridge hooks and bridge technologies.
Return values
0Frame written to at least one channel.
-1Frame written to no channels.

Definition at line 1083 of file bridge_channel.c.

1084{
1085 struct ast_bridge_channel *cur;
1086 int not_written = -1;
1087
1088 if (frame->frametype == AST_FRAME_NULL) {
1089 /* "Accept" the frame and discard it. */
1090 return 0;
1091 }
1092
1094 if (cur == bridge_channel) {
1095 continue;
1096 }
1097 if (!ast_bridge_channel_queue_frame(cur, frame)) {
1098 not_written = 0;
1099 }
1100 }
1101 return not_written;
1102}

References ast_bridge_channel_queue_frame(), AST_FRAME_NULL, AST_LIST_TRAVERSE, ast_bridge_channel::bridge, ast_bridge::channels, and ast_frame::frametype.

Referenced by ari_bridges_play_new(), bridge_hold(), bridge_ringing(), bridge_unhold(), holding_bridge_write(), native_bridge_write(), native_rtp_bridge_write(), simple_bridge_write(), softmix_bridge_write(), softmix_bridge_write_control(), softmix_bridge_write_text(), and softmix_bridge_write_video().

◆ bridge_channel_attended_transfer()

static void bridge_channel_attended_transfer ( struct ast_bridge_channel bridge_channel,
const char *  target_chan_name 
)
static

Definition at line 1961 of file bridge_channel.c.

1963{
1964 RAII_VAR(struct ast_channel *, chan_target, NULL, ao2_cleanup);
1965 RAII_VAR(struct ast_channel *, chan_bridged, NULL, ao2_cleanup);
1966
1967 chan_target = ast_channel_get_by_name(target_chan_name);
1968 if (!chan_target) {
1969 /* Dang, it disappeared somehow */
1971 return;
1972 }
1973
1974 ast_bridge_channel_lock(bridge_channel);
1975 chan_bridged = bridge_channel->chan;
1976 ast_assert(chan_bridged != NULL);
1977 ao2_ref(chan_bridged, +1);
1978 ast_bridge_channel_unlock(bridge_channel);
1979
1982 ast_softhangup(chan_target, AST_SOFTHANGUP_DEV);
1983
1984 /* Release the ref we tried to pass to ast_bridge_set_after_callback(). */
1985 ast_channel_unref(chan_target);
1986 }
1988}
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.
Definition: bridge_after.c:251
static void after_bridge_move_channel_fail(enum ast_bridge_after_cb_reason reason, void *data)
static void after_bridge_move_channel(struct ast_channel *chan_bridged, void *data)
#define ast_channel_ref(c)
Increase channel reference count.
Definition: channel.h:2947
#define ast_channel_unref(c)
Decrease channel reference count.
Definition: channel.h:2958
struct ast_channel * ast_channel_get_by_name(const char *name)
Find a channel by name.
Definition: channel.c:1454

References after_bridge_move_channel(), after_bridge_move_channel_fail(), ao2_cleanup, ao2_ref, ast_assert, ast_bridge_channel_kick(), ast_bridge_channel_lock, ast_bridge_channel_unlock, ast_bridge_set_after_callback(), AST_CAUSE_NORMAL_CLEARING, ast_channel_get_by_name(), ast_channel_ref, ast_channel_unref, ast_softhangup(), AST_SOFTHANGUP_DEV, ast_bridge_channel::chan, NULL, and RAII_VAR.

Referenced by bridge_channel_handle_action().

◆ bridge_channel_blind_transfer()

static void bridge_channel_blind_transfer ( struct ast_bridge_channel bridge_channel,
struct blind_transfer_data blind_data 
)
static

Definition at line 1950 of file bridge_channel.c.

1952{
1953 ast_async_goto(bridge_channel->chan, blind_data->context, blind_data->exten, 1);
1955}
int ast_async_goto(struct ast_channel *chan, const char *context, const char *exten, int priority)
Set the channel to next execute the specified dialplan location.
Definition: pbx.c:6969
char exten[AST_MAX_EXTENSION]
char context[AST_MAX_CONTEXT]

References ast_async_goto(), ast_bridge_channel_kick(), AST_CAUSE_NORMAL_CLEARING, ast_bridge_channel::chan, blind_transfer_data::context, and blind_transfer_data::exten.

Referenced by bridge_channel_handle_action().

◆ bridge_channel_cancel_owed_events()

static void bridge_channel_cancel_owed_events ( struct ast_bridge_channel bridge_channel)
static

Definition at line 771 of file bridge_channel.c.

772{
773 bridge_channel->owed.dtmf_digit = '\0';
774 bridge_channel->owed.t38_terminate = 0;
775}
struct ast_bridge_channel::@194 owed

References ast_bridge_channel::dtmf_digit, ast_bridge_channel::owed, and ast_bridge_channel::t38_terminate.

Referenced by bridge_channel_internal_push_full().

◆ bridge_channel_destroy()

static void bridge_channel_destroy ( void *  obj)
static

Definition at line 3062 of file bridge_channel.c.

3063{
3064 struct ast_bridge_channel *bridge_channel = obj;
3065 struct ast_frame *fr;
3066
3067 if (bridge_channel->callid) {
3068 bridge_channel->callid = 0;
3069 }
3070
3071 if (bridge_channel->bridge) {
3072 ao2_ref(bridge_channel->bridge, -1);
3073 bridge_channel->bridge = NULL;
3074 }
3075
3076 /* Flush any unhandled wr_queue frames. */
3077 while ((fr = AST_LIST_REMOVE_HEAD(&bridge_channel->wr_queue, frame_list))) {
3079 }
3080 ast_alertpipe_close(bridge_channel->alert_pipe);
3081
3082 /* Flush any unhandled deferred_queue frames. */
3083 while ((fr = AST_LIST_REMOVE_HEAD(&bridge_channel->deferred_queue, frame_list))) {
3084 ast_frfree(fr);
3085 }
3086
3087 ast_cond_destroy(&bridge_channel->cond);
3088
3089 ao2_cleanup(bridge_channel->write_format);
3090 ao2_cleanup(bridge_channel->read_format);
3091
3092 AST_VECTOR_FREE(&bridge_channel->stream_map.to_bridge);
3093 AST_VECTOR_FREE(&bridge_channel->stream_map.to_channel);
3094}
void ast_alertpipe_close(int alert_pipe[2])
Close an alert pipe.
Definition: alertpipe.c:79
#define ast_frfree(fr)
#define AST_LIST_REMOVE_HEAD(head, field)
Removes and returns the head entry from a list.
Definition: linkedlists.h:833
#define ast_cond_destroy(cond)
Definition: lock.h:202
struct ast_bridge_channel::@193 deferred_queue
#define AST_VECTOR_FREE(vec)
Deallocates this vector.
Definition: vector.h:174

References ast_bridge_channel::alert_pipe, ao2_cleanup, ao2_ref, ast_alertpipe_close(), ast_cond_destroy, ast_frfree, AST_LIST_REMOVE_HEAD, AST_VECTOR_FREE, ast_bridge_channel::bridge, bridge_frame_free(), ast_bridge_channel::callid, ast_bridge_channel::cond, ast_bridge_channel::deferred_queue, NULL, ast_bridge_channel::read_format, ast_bridge_channel::stream_map, ast_bridge_channel::to_bridge, ast_bridge_channel::to_channel, ast_bridge_channel::wr_queue, and ast_bridge_channel::write_format.

Referenced by bridge_channel_internal_alloc().

◆ bridge_channel_dissolve_check()

static void bridge_channel_dissolve_check ( struct ast_bridge_channel bridge_channel)
static

Definition at line 2066 of file bridge_channel.c.

2067{
2068 struct ast_bridge *bridge = bridge_channel->bridge;
2069
2070 if (bridge->dissolved) {
2071 return;
2072 }
2073
2074 if (!bridge->num_channels
2076 /* Last channel leaving the bridge turns off the lights. */
2077 bridge_dissolve(bridge, ast_channel_hangupcause(bridge_channel->chan));
2078 return;
2079 }
2080
2081 switch (bridge_channel->state) {
2083 /* Do we need to dissolve the bridge because this channel hung up? */
2085 || (bridge_channel->features->usable
2086 && ast_test_flag(&bridge_channel->features->feature_flags,
2088 bridge_dissolve(bridge, ast_channel_hangupcause(bridge_channel->chan));
2089 return;
2090 }
2091 break;
2092 default:
2093 break;
2094 }
2095
2096 if (bridge->num_lonely && bridge->num_lonely == bridge->num_channels) {
2097 /*
2098 * This will start a chain reaction where each channel leaving
2099 * enters this function and causes the next to leave as long as
2100 * there aren't non-lonely channels in the bridge.
2101 */
2104 ast_channel_hangupcause(bridge_channel->chan));
2105 }
2106}
@ BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE
@ AST_BRIDGE_FLAG_DISSOLVE_EMPTY
@ AST_BRIDGE_FLAG_DISSOLVE_HANGUP
@ AST_BRIDGE_CHANNEL_FLAG_DISSOLVE_HANGUP
void bridge_dissolve(struct ast_bridge *bridge, int cause)
Definition: bridge.c:315
int ast_channel_hangupcause(const struct ast_channel *chan)
#define AST_LIST_FIRST(head)
Returns the first entry contained in a list.
Definition: linkedlists.h:421
struct ast_flags feature_flags
unsigned int dissolved
Definition: bridge.h:390
unsigned int num_lonely
Definition: bridge.h:377
struct ast_flags feature_flags
Definition: bridge.h:369

References AST_BRIDGE_CHANNEL_FLAG_DISSOLVE_HANGUP, ast_bridge_channel_leave_bridge(), AST_BRIDGE_FLAG_DISSOLVE_EMPTY, AST_BRIDGE_FLAG_DISSOLVE_HANGUP, ast_channel_hangupcause(), AST_LIST_FIRST, ast_test_flag, ast_bridge_channel::bridge, BRIDGE_CHANNEL_STATE_END, BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE, bridge_dissolve(), ast_bridge_channel::chan, ast_bridge::channels, ast_bridge::dissolved, ast_bridge::feature_flags, ast_bridge_features::feature_flags, ast_bridge_channel::features, ast_bridge::num_channels, ast_bridge::num_lonely, ast_bridge_channel::state, and ast_bridge_features::usable.

Referenced by bridge_channel_internal_join(), and bridge_channel_internal_pull().

◆ bridge_channel_do_callback()

static void bridge_channel_do_callback ( struct ast_bridge_channel bridge_channel,
struct bridge_custom_callback data 
)
static

Definition at line 1377 of file bridge_channel.c.

1378{
1380 bridge_channel_suspend(bridge_channel);
1381 ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
1382 }
1383 data->callback(bridge_channel, data->payload_exists ? data->payload : NULL, data->payload_size);
1385 ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
1386 bridge_channel_unsuspend(bridge_channel);
1387 }
1388}
static void bridge_channel_suspend(struct ast_bridge_channel *bridge_channel)
@ AST_BRIDGE_CHANNEL_CB_OPTION_MEDIA
ast_bridge_custom_callback_fn callback

References AST_BRIDGE_CHANNEL_CB_OPTION_MEDIA, AST_CONTROL_SRCUPDATE, ast_indicate(), ast_test_flag, bridge_channel_suspend(), bridge_channel_unsuspend(), bridge_custom_callback::callback, ast_bridge_channel::chan, NULL, bridge_custom_callback::payload, bridge_custom_callback::payload_exists, and bridge_custom_callback::payload_size.

Referenced by bridge_channel_handle_action().

◆ bridge_channel_dtmf_stream()

static void bridge_channel_dtmf_stream ( struct ast_bridge_channel bridge_channel,
const char *  dtmf 
)
static

Definition at line 1860 of file bridge_channel.c.

1861{
1862 ast_debug(1, "Playing DTMF stream '%s' out to %p(%s)\n",
1863 dtmf, bridge_channel, ast_channel_name(bridge_channel->chan));
1864 ast_dtmf_stream(bridge_channel->chan, NULL, dtmf, 0, 0);
1865}
int ast_dtmf_stream(struct ast_channel *chan, struct ast_channel *peer, const char *digits, int between, unsigned int duration)
Send a string of DTMF digits to a channel.
Definition: main/app.c:1127

References ast_channel_name(), ast_debug, ast_dtmf_stream(), ast_bridge_channel::chan, and NULL.

Referenced by bridge_channel_handle_action().

◆ bridge_channel_event_join_leave()

static void bridge_channel_event_join_leave ( struct ast_bridge_channel bridge_channel,
enum ast_bridge_hook_type  type 
)
static

Definition at line 2790 of file bridge_channel.c.

2791{
2792 struct ast_bridge_features *features = bridge_channel->features;
2793 struct ast_bridge_hook *hook;
2794 struct ao2_iterator iter;
2795
2796 /* Run the specified hooks. */
2797 iter = ao2_iterator_init(features->other_hooks, 0);
2798 for (; (hook = ao2_iterator_next(&iter)); ao2_ref(hook, -1)) {
2799 if (hook->type == type) {
2800 break;
2801 }
2802 }
2803 if (hook) {
2804 /* Found the first specified hook to run. */
2805 bridge_channel_suspend(bridge_channel);
2806 ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
2807 do {
2808 if (hook->type == type) {
2809 hook->callback(bridge_channel, hook->hook_pvt);
2810 ao2_unlink(features->other_hooks, hook);
2811 }
2812 ao2_ref(hook, -1);
2813 } while ((hook = ao2_iterator_next(&iter)));
2814 ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
2815 bridge_channel_unsuspend(bridge_channel);
2816 }
2817 ao2_iterator_destroy(&iter);
2818}
static const char type[]
Definition: chan_ooh323.c:109

References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, ao2_unlink, AST_CONTROL_SRCUPDATE, ast_indicate(), bridge_channel_suspend(), bridge_channel_unsuspend(), ast_bridge_hook::callback, ast_bridge_channel::chan, ast_bridge_channel::features, ast_bridge_hook::hook_pvt, ast_bridge_features::other_hooks, type, and ast_bridge_hook::type.

Referenced by bridge_channel_internal_join().

◆ bridge_channel_feature_digit_add()

static int bridge_channel_feature_digit_add ( struct ast_bridge_channel bridge_channel,
int  digit,
size_t  dtmf_len 
)
static

Definition at line 1650 of file bridge_channel.c.

1652{
1653 if (dtmf_len < ARRAY_LEN(bridge_channel->dtmf_hook_state.collected) - 1) {
1654 /* Add the new digit to the DTMF string so we can do our matching */
1655 bridge_channel->dtmf_hook_state.collected[dtmf_len++] = digit;
1656 bridge_channel->dtmf_hook_state.collected[dtmf_len] = '\0';
1657
1658 ast_debug(1, "DTMF feature string on %p(%s) is now '%s'\n",
1659 bridge_channel, ast_channel_name(bridge_channel->chan),
1660 bridge_channel->dtmf_hook_state.collected);
1661 }
1662
1663 return dtmf_len;
1664}

References ARRAY_LEN, ast_channel_name(), ast_debug, ast_bridge_channel::chan, ast_bridge_channel::collected, digit, and ast_bridge_channel::dtmf_hook_state.

Referenced by ast_bridge_channel_feature_digit(), and ast_bridge_channel_feature_digit_add().

◆ bridge_channel_feature_digit_timeout()

static unsigned int bridge_channel_feature_digit_timeout ( struct ast_bridge_channel bridge_channel)
static

Definition at line 1666 of file bridge_channel.c.

1667{
1668 unsigned int digit_timeout;
1669 struct ast_features_general_config *gen_cfg;
1670
1671 /* Determine interdigit timeout */
1672 ast_channel_lock(bridge_channel->chan);
1673 gen_cfg = ast_get_chan_features_general_config(bridge_channel->chan);
1674 ast_channel_unlock(bridge_channel->chan);
1675
1676 if (!gen_cfg) {
1677 ast_log(LOG_ERROR, "Unable to retrieve features configuration.\n");
1678 return 3000; /* Pick a reasonable failsafe timeout in ms */
1679 }
1680
1681 digit_timeout = gen_cfg->featuredigittimeout;
1682 ao2_ref(gen_cfg, -1);
1683
1684 return digit_timeout;
1685}
struct ast_features_general_config * ast_get_chan_features_general_config(struct ast_channel *chan)
Get the general configuration options for a channel.
General features configuration items.

References ao2_ref, ast_channel_lock, ast_channel_unlock, ast_get_chan_features_general_config(), ast_log, ast_bridge_channel::chan, ast_features_general_config::featuredigittimeout, and LOG_ERROR.

Referenced by ast_bridge_channel_feature_digit().

◆ bridge_channel_feature_timeout()

static int bridge_channel_feature_timeout ( struct ast_bridge_channel bridge_channel)
static

Definition at line 2675 of file bridge_channel.c.

2676{
2677 int ms;
2678
2679 if (bridge_channel->dtmf_hook_state.collected[0]) {
2681 ast_tvnow());
2682 if (ms < 0) {
2683 /* Expire immediately. */
2684 ms = 0;
2685 }
2686 } else {
2687 /* Timer is not active so wait forever. */
2688 ms = -1;
2689 }
2690
2691 return ms;
2692}
int64_t ast_tvdiff_ms(struct timeval end, struct timeval start)
Computes the difference (in milliseconds) between two struct timeval instances.
Definition: time.h:107

References ast_tvdiff_ms(), ast_tvnow(), ast_bridge_channel::collected, ast_bridge_channel::dtmf_hook_state, and ast_bridge_channel::interdigit_timeout.

Referenced by bridge_channel_next_timeout().

◆ bridge_channel_handle_action()

static void bridge_channel_handle_action ( struct ast_bridge_channel bridge_channel,
enum bridge_channel_action_type  action,
void *  data 
)
static

Definition at line 1999 of file bridge_channel.c.

2001{
2002 switch (action) {
2004 bridge_channel_suspend(bridge_channel);
2005 ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
2006 bridge_channel_dtmf_stream(bridge_channel, data);
2007 ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
2008 bridge_channel_unsuspend(bridge_channel);
2009 break;
2012 bridge_channel_talking(bridge_channel,
2014 break;
2016 bridge_channel_suspend(bridge_channel);
2017 ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
2018 bridge_channel_playfile(bridge_channel, data);
2019 ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
2020 bridge_channel_unsuspend(bridge_channel);
2021 break;
2023 bridge_channel_suspend(bridge_channel);
2024 ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
2025 bridge_channel_run_app(bridge_channel, data);
2026 ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
2027 bridge_channel_unsuspend(bridge_channel);
2028 break;
2030 bridge_channel_do_callback(bridge_channel, data);
2031 break;
2033 bridge_channel_suspend(bridge_channel);
2034 ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
2035 bridge_channel_park(bridge_channel, data);
2036 ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
2037 bridge_channel_unsuspend(bridge_channel);
2038 break;
2040 bridge_channel_blind_transfer(bridge_channel, data);
2041 break;
2043 bridge_channel_attended_transfer(bridge_channel, data);
2044 break;
2045 default:
2046 break;
2047 }
2048
2049 /* While invoking an action it is possible for the channel to be hung up. So
2050 * that the bridge respects this we check here and if hung up kick it out.
2051 */
2052 if (bridge_channel->chan && ast_check_hangup_locked(bridge_channel->chan)) {
2053 ast_bridge_channel_kick(bridge_channel, 0);
2054 }
2055}
static void bridge_channel_run_app(struct ast_bridge_channel *bridge_channel, struct bridge_run_app *data)
static void bridge_channel_attended_transfer(struct ast_bridge_channel *bridge_channel, const char *target_chan_name)
static void bridge_channel_do_callback(struct ast_bridge_channel *bridge_channel, struct bridge_custom_callback *data)
static void bridge_channel_dtmf_stream(struct ast_bridge_channel *bridge_channel, const char *dtmf)
static void bridge_channel_blind_transfer(struct ast_bridge_channel *bridge_channel, struct blind_transfer_data *blind_data)
static void bridge_channel_park(struct ast_bridge_channel *bridge_channel, struct bridge_park *payload)
static void bridge_channel_playfile(struct ast_bridge_channel *bridge_channel, struct bridge_playfile *payload)
static void bridge_channel_talking(struct ast_bridge_channel *bridge_channel, int talking)
@ BRIDGE_CHANNEL_ACTION_ATTENDED_TRANSFER
@ BRIDGE_CHANNEL_ACTION_DTMF_STREAM
@ BRIDGE_CHANNEL_ACTION_PLAY_FILE
@ BRIDGE_CHANNEL_ACTION_BLIND_TRANSFER
@ BRIDGE_CHANNEL_ACTION_CALLBACK
@ BRIDGE_CHANNEL_ACTION_RUN_APP
@ BRIDGE_CHANNEL_ACTION_PARK

References ast_control_read_action_payload::action, ast_bridge_channel_kick(), ast_check_hangup_locked(), AST_CONTROL_SRCUPDATE, ast_indicate(), BRIDGE_CHANNEL_ACTION_ATTENDED_TRANSFER, BRIDGE_CHANNEL_ACTION_BLIND_TRANSFER, BRIDGE_CHANNEL_ACTION_CALLBACK, BRIDGE_CHANNEL_ACTION_DTMF_STREAM, BRIDGE_CHANNEL_ACTION_PARK, BRIDGE_CHANNEL_ACTION_PLAY_FILE, BRIDGE_CHANNEL_ACTION_RUN_APP, BRIDGE_CHANNEL_ACTION_TALKING_START, BRIDGE_CHANNEL_ACTION_TALKING_STOP, bridge_channel_attended_transfer(), bridge_channel_blind_transfer(), bridge_channel_do_callback(), bridge_channel_dtmf_stream(), bridge_channel_park(), bridge_channel_playfile(), bridge_channel_run_app(), bridge_channel_suspend(), bridge_channel_talking(), bridge_channel_unsuspend(), and ast_bridge_channel::chan.

Referenced by bridge_channel_handle_write().

◆ bridge_channel_handle_control()

static void bridge_channel_handle_control ( struct ast_bridge_channel bridge_channel,
struct ast_frame fr 
)
static

Definition at line 2258 of file bridge_channel.c.

2259{
2260 struct ast_channel *chan;
2261 struct ast_option_header *aoh;
2262
2263 chan = bridge_channel->chan;
2264 switch (fr->subclass.integer) {
2266 if (ast_channel_redirecting_sub(NULL, chan, fr, 1)) {
2267 ast_indicate_data(chan, fr->subclass.integer, fr->data.ptr, fr->datalen);
2268 }
2269 break;
2271 if (ast_channel_connected_line_sub(NULL, chan, fr, 1)) {
2272 ast_indicate_data(chan, fr->subclass.integer, fr->data.ptr, fr->datalen);
2273 }
2274 break;
2275 case AST_CONTROL_OPTION:
2276 /*
2277 * Forward option Requests, but only ones we know are safe These
2278 * are ONLY sent by chan_iax2 and I'm not convinced that they
2279 * are useful. I haven't deleted them entirely because I just am
2280 * not sure of the ramifications of removing them.
2281 */
2282 aoh = fr->data.ptr;
2283 if (aoh && aoh->flag == AST_OPTION_FLAG_REQUEST) {
2284 switch (ntohs(aoh->option)) {
2286 case AST_OPTION_TDD:
2291 ast_channel_setoption(chan, ntohs(aoh->option), aoh->data,
2292 fr->datalen - sizeof(*aoh), 0);
2293 break;
2294 default:
2295 break;
2296 }
2297 }
2298 break;
2299 case AST_CONTROL_ANSWER:
2300 if (ast_channel_state(chan) != AST_STATE_UP) {
2301 ast_answer(chan);
2302 ast_bridge_channel_lock_bridge(bridge_channel);
2303 bridge_channel->bridge->reconfigured = 1;
2304 bridge_reconfigured(bridge_channel->bridge, 0);
2305 ast_bridge_unlock(bridge_channel->bridge);
2306 } else {
2307 ast_indicate(chan, -1);
2308 }
2309 break;
2311 /* Should never happen. */
2312 ast_assert(0);
2313 break;
2315 ast_indicate_data(chan, fr->subclass.integer, fr->data.ptr, fr->datalen);
2316 break;
2317 default:
2318 ast_indicate_data(chan, fr->subclass.integer, fr->data.ptr, fr->datalen);
2319 break;
2320 }
2321}
void bridge_reconfigured(struct ast_bridge *bridge, unsigned int colp_update)
Definition: bridge.c:1403
int ast_channel_connected_line_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *connected_info, int frame)
Run a connected line interception subroutine and update a channel's connected line information.
Definition: channel.c:10338
int ast_channel_redirecting_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const void *redirecting_info, int is_frame)
Run a redirecting interception subroutine and update a channel's redirecting information.
Definition: channel.c:10383
int ast_indicate_data(struct ast_channel *chan, int condition, const void *data, size_t datalen)
Indicates condition of channel, with payload.
Definition: channel.c:4653
int ast_channel_setoption(struct ast_channel *channel, int option, void *data, int datalen, int block)
Sets an option on a channel.
Definition: channel.c:7422
int ast_answer(struct ast_channel *chan)
Answer a channel.
Definition: channel.c:2805
ast_channel_state
ast_channel states
Definition: channelstate.h:35
@ AST_STATE_UP
Definition: channelstate.h:42
#define AST_OPTION_RELAXDTMF
#define AST_OPTION_TONE_VERIFY
#define AST_OPTION_DIGIT_DETECT
#define AST_OPTION_TDD
#define AST_OPTION_FLAG_REQUEST
#define AST_OPTION_FAX_DETECT
@ AST_CONTROL_REDIRECTING
@ AST_CONTROL_ANSWER
@ AST_CONTROL_OPTION
@ AST_CONTROL_STREAM_TOPOLOGY_CHANGED
@ AST_CONTROL_CONNECTED_LINE
@ AST_CONTROL_MASQUERADE_NOTIFY
#define AST_OPTION_AUDIO_MODE
unsigned int reconfigured
Definition: bridge.h:388
struct ast_frame_subclass subclass

References ast_answer(), ast_assert, ast_bridge_channel_lock_bridge(), ast_bridge_unlock, ast_channel_connected_line_sub(), ast_channel_redirecting_sub(), ast_channel_setoption(), AST_CONTROL_ANSWER, AST_CONTROL_CONNECTED_LINE, AST_CONTROL_MASQUERADE_NOTIFY, AST_CONTROL_OPTION, AST_CONTROL_REDIRECTING, AST_CONTROL_STREAM_TOPOLOGY_CHANGED, ast_indicate(), ast_indicate_data(), AST_OPTION_AUDIO_MODE, AST_OPTION_DIGIT_DETECT, AST_OPTION_FAX_DETECT, AST_OPTION_FLAG_REQUEST, AST_OPTION_RELAXDTMF, AST_OPTION_TDD, AST_OPTION_TONE_VERIFY, AST_STATE_UP, ast_bridge_channel::bridge, bridge_reconfigured(), ast_bridge_channel::chan, ast_frame::data, ast_option_header::data, ast_frame::datalen, ast_frame_subclass::integer, NULL, ast_frame::ptr, ast_bridge::reconfigured, and ast_frame::subclass.

Referenced by bridge_channel_handle_write().

◆ bridge_channel_handle_feature_timeout()

static void bridge_channel_handle_feature_timeout ( struct ast_bridge_channel bridge_channel)
static

Definition at line 1814 of file bridge_channel.c.

1815{
1816 if (!bridge_channel->dtmf_hook_state.collected[0]
1817 || 0 < ast_tvdiff_ms(bridge_channel->dtmf_hook_state.interdigit_timeout,
1818 ast_tvnow())) {
1819 /* Not within a sequence or not timed out. */
1820 return;
1821 }
1822
1823 ast_bridge_channel_feature_digit(bridge_channel, 0);
1824}
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.

References ast_bridge_channel_feature_digit(), ast_tvdiff_ms(), ast_tvnow(), ast_bridge_channel::collected, ast_bridge_channel::dtmf_hook_state, and ast_bridge_channel::interdigit_timeout.

Referenced by bridge_channel_wait().

◆ bridge_channel_handle_interval()

static void bridge_channel_handle_interval ( struct ast_bridge_channel bridge_channel)
static

Definition at line 1505 of file bridge_channel.c.

1506{
1507 struct ast_heap *interval_hooks;
1508 struct ast_bridge_hook_timer *hook;
1509 struct timeval start;
1510 int chan_suspended = 0;
1511
1512 interval_hooks = bridge_channel->features->interval_hooks;
1513 ast_heap_wrlock(interval_hooks);
1514 start = ast_tvnow();
1515 while ((hook = ast_heap_peek(interval_hooks, 1))) {
1516 int interval;
1517 unsigned int execution_time;
1518
1519 if (ast_tvdiff_ms(hook->timer.trip_time, start) > 0) {
1520 ast_debug(1, "Hook %p on %p(%s) wants to happen in the future, stopping our traversal\n",
1521 hook, bridge_channel, ast_channel_name(bridge_channel->chan));
1522 break;
1523 }
1524 ao2_ref(hook, +1);
1525 ast_heap_unlock(interval_hooks);
1526
1527 if (!chan_suspended
1529 chan_suspended = 1;
1530 bridge_channel_suspend(bridge_channel);
1531 ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
1532 }
1533
1534 ast_debug(1, "Executing hook %p on %p(%s)\n",
1535 hook, bridge_channel, ast_channel_name(bridge_channel->chan));
1536 interval = hook->generic.callback(bridge_channel, hook->generic.hook_pvt);
1537
1538 ast_heap_wrlock(interval_hooks);
1539 if (ast_heap_peek(interval_hooks, hook->timer.heap_index) != hook
1540 || !ast_heap_remove(interval_hooks, hook)) {
1541 /* Interval hook is already removed from the bridge_channel. */
1542 ao2_ref(hook, -1);
1543 continue;
1544 }
1545 ao2_ref(hook, -1);
1546
1547 if (interval < 0) {
1548 ast_debug(1, "Removed interval hook %p from %p(%s)\n",
1549 hook, bridge_channel, ast_channel_name(bridge_channel->chan));
1550 ao2_ref(hook, -1);
1551 continue;
1552 }
1553 if (interval) {
1554 /* Set new interval for the hook. */
1555 hook->timer.interval = interval;
1556 }
1557
1558 ast_debug(1, "Updating interval hook %p with interval %u on %p(%s)\n",
1559 hook, hook->timer.interval, bridge_channel,
1560 ast_channel_name(bridge_channel->chan));
1561
1562 /* resetting start */
1563 start = ast_tvnow();
1564
1565 /*
1566 * Resetup the interval hook for the next interval. We may need
1567 * to skip over any missed intervals because the hook was
1568 * delayed or took too long.
1569 */
1570 execution_time = ast_tvdiff_ms(start, hook->timer.trip_time);
1571 while (hook->timer.interval < execution_time) {
1572 execution_time -= hook->timer.interval;
1573 }
1574 hook->timer.trip_time = ast_tvadd(start, ast_samp2tv(hook->timer.interval - execution_time, 1000));
1575 hook->timer.seqno = ast_atomic_fetchadd_int((int *) &bridge_channel->features->interval_sequence, +1);
1576
1577 if (ast_heap_push(interval_hooks, hook)) {
1578 /* Could not push the hook back onto the heap. */
1579 ao2_ref(hook, -1);
1580 }
1581 }
1582 ast_heap_unlock(interval_hooks);
1583
1584 if (chan_suspended) {
1585 ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
1586 bridge_channel_unsuspend(bridge_channel);
1587 }
1588}
@ AST_BRIDGE_HOOK_TIMER_OPTION_MEDIA
#define ast_heap_unlock(h)
Definition: heap.h:249
void * ast_heap_remove(struct ast_heap *h, void *elm)
Remove a specific element from a heap.
Definition: heap.c:251
#define ast_heap_push(h, elm)
Push an element on to a heap.
Definition: heap.h:125
#define ast_heap_wrlock(h)
Definition: heap.h:247
void * ast_heap_peek(struct ast_heap *h, unsigned int index)
Peek at an element on a heap.
Definition: heap.c:267
int ast_atomic_fetchadd_int(volatile int *p, int v)
Atomically add v to *p and return the previous value of *p.
Definition: lock.h:757
unsigned int interval_sequence
struct ast_heap * interval_hooks
struct ast_bridge_hook generic
struct ast_bridge_hook_timer_parms timer
Definition: heap.c:36

References ao2_ref, ast_atomic_fetchadd_int(), AST_BRIDGE_HOOK_TIMER_OPTION_MEDIA, ast_channel_name(), AST_CONTROL_SRCUPDATE, ast_debug, ast_heap_peek(), ast_heap_push, ast_heap_remove(), ast_heap_unlock, ast_heap_wrlock, ast_indicate(), ast_samp2tv(), ast_test_flag, ast_tvadd(), ast_tvdiff_ms(), ast_tvnow(), bridge_channel_suspend(), bridge_channel_unsuspend(), ast_bridge_hook::callback, ast_bridge_channel::chan, ast_bridge_channel::features, ast_bridge_hook_timer::generic, ast_bridge_hook_timer_parms::heap_index, ast_bridge_hook::hook_pvt, ast_bridge_hook_timer_parms::interval, ast_bridge_features::interval_hooks, ast_bridge_features::interval_sequence, ast_bridge_hook_timer_parms::seqno, ast_bridge_hook_timer::timer, and ast_bridge_hook_timer_parms::trip_time.

Referenced by bridge_channel_wait().

◆ bridge_channel_handle_write()

static void bridge_channel_handle_write ( struct ast_bridge_channel bridge_channel)
static

Definition at line 2363 of file bridge_channel.c.

2364{
2365 struct ast_frame *fr;
2366 struct sync_payload *sync_payload;
2367 int num;
2368 struct ast_msg_data *msg;
2369
2370 ast_bridge_channel_lock(bridge_channel);
2371
2372 /* It's not good to have unbalanced frames and alert_pipe alerts. */
2373 ast_assert(!AST_LIST_EMPTY(&bridge_channel->wr_queue));
2374 if (AST_LIST_EMPTY(&bridge_channel->wr_queue)) {
2375 /* No frame, flush the alert pipe of excess alerts. */
2376 ast_log(LOG_WARNING, "Weird. No frame from bridge for %s to process?\n",
2377 ast_channel_name(bridge_channel->chan));
2378 ast_alertpipe_read(bridge_channel->alert_pipe);
2379 ast_bridge_channel_unlock(bridge_channel);
2380 return;
2381 }
2382
2383 AST_LIST_TRAVERSE_SAFE_BEGIN(&bridge_channel->wr_queue, fr, frame_list) {
2384 if (bridge_channel->dtmf_hook_state.collected[0]) {
2385 switch (fr->frametype) {
2388 /* Defer processing these frames while DTMF is collected. */
2389 continue;
2390 default:
2391 break;
2392 }
2393 }
2394 ast_alertpipe_read(bridge_channel->alert_pipe);
2396 break;
2397 }
2399
2400 ast_bridge_channel_unlock(bridge_channel);
2401
2402 if (!fr) {
2403 /*
2404 * Wait some to reduce CPU usage from a tight loop
2405 * without any wait because we only have deferred
2406 * frames in the wr_queue.
2407 */
2408 usleep(1);
2409 return;
2410 }
2411
2412 switch (fr->frametype) {
2414 bridge_channel_handle_action(bridge_channel, fr->subclass.integer, fr->data.ptr);
2415 break;
2417 sync_payload = fr->data.ptr;
2419 break;
2420 case AST_FRAME_CONTROL:
2421 bridge_channel_handle_control(bridge_channel, fr);
2422 break;
2423 case AST_FRAME_NULL:
2424 break;
2425 case AST_FRAME_TEXT:
2426 ast_debug(1, "Sending TEXT frame to '%s': %*.s\n",
2427 ast_channel_name(bridge_channel->chan), fr->datalen, (char *)fr->data.ptr);
2428 sendtext_safe(bridge_channel->chan, fr);
2429 break;
2431 msg = (struct ast_msg_data *)fr->data.ptr;
2432 ast_debug(1, "Sending TEXT_DATA frame from '%s' to '%s:%s': %s\n",
2435 ast_channel_name(bridge_channel->chan),
2437 ast_sendtext_data(bridge_channel->chan, msg);
2438 break;
2439 default:
2440 /* Assume that there is no mapped stream for this */
2441 num = -1;
2442
2443 if (fr->stream_num > -1) {
2444 ast_bridge_channel_lock(bridge_channel);
2445 if (fr->stream_num < (int)AST_VECTOR_SIZE(&bridge_channel->stream_map.to_channel)) {
2446 num = AST_VECTOR_GET(&bridge_channel->stream_map.to_channel, fr->stream_num);
2447 }
2448 ast_bridge_channel_unlock(bridge_channel);
2449
2450 /* If there is no mapped stream after checking the mapping then there is nowhere
2451 * to write this frame to, so drop it.
2452 */
2453 if (num == -1) {
2454 break;
2455 }
2456 }
2457
2458 /* Write the frame to the channel. */
2459 bridge_channel->activity = BRIDGE_CHANNEL_THREAD_SIMPLE;
2460 ast_write_stream(bridge_channel->chan, num, fr);
2461 break;
2462 }
2464}
ast_alert_status_t ast_alertpipe_read(int alert_pipe[2])
Read an event from an alert pipe.
Definition: alertpipe.c:102
static void sendtext_safe(struct ast_channel *chan, const struct ast_frame *f)
static void bridge_channel_handle_control(struct ast_bridge_channel *bridge_channel, struct ast_frame *fr)
static void bridge_channel_handle_action(struct ast_bridge_channel *bridge_channel, enum bridge_channel_action_type action, void *data)
@ BRIDGE_CHANNEL_THREAD_SIMPLE
int ast_sendtext_data(struct ast_channel *chan, struct ast_msg_data *msg)
Sends text to a channel in an ast_msg_data structure wrapper with ast_sendtext as fallback.
Definition: channel.c:4751
int ast_write_stream(struct ast_channel *chan, int stream_num, struct ast_frame *frame)
Write a frame to a stream This function writes the given frame to the indicated stream on the channel...
Definition: channel.c:5149
@ AST_FRAME_BRIDGE_ACTION_SYNC
#define AST_LIST_EMPTY(head)
Checks whether the specified list contains any entries.
Definition: linkedlists.h:450
#define AST_LIST_TRAVERSE_SAFE_END
Closes a safe loop traversal block.
Definition: linkedlists.h:615
#define AST_LIST_TRAVERSE_SAFE_BEGIN(head, var, field)
Loops safely over (traverses) the entries in a list.
Definition: linkedlists.h:529
#define AST_LIST_REMOVE_CURRENT(field)
Removes the current entry from a list during a traversal.
Definition: linkedlists.h:557
enum bridge_channel_thread_state activity
The bridge channel thread activity.
Frame payload for synchronous bridge actions.
unsigned char data[0]

References ast_bridge_channel::activity, ast_bridge_channel::alert_pipe, ast_alertpipe_read(), ast_assert, ast_bridge_channel_lock, ast_bridge_channel_unlock, ast_channel_name(), ast_debug, AST_FRAME_BRIDGE_ACTION, AST_FRAME_BRIDGE_ACTION_SYNC, AST_FRAME_CONTROL, AST_FRAME_NULL, AST_FRAME_TEXT, AST_FRAME_TEXT_DATA, AST_LIST_EMPTY, AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_log, AST_MSG_DATA_ATTR_BODY, AST_MSG_DATA_ATTR_FROM, AST_MSG_DATA_ATTR_TO, ast_msg_data_get_attribute(), ast_sendtext_data(), AST_VECTOR_GET, AST_VECTOR_SIZE, ast_write_stream(), bridge_channel_handle_action(), bridge_channel_handle_control(), BRIDGE_CHANNEL_THREAD_SIMPLE, bridge_frame_free(), ast_bridge_channel::chan, ast_bridge_channel::collected, ast_frame::data, sync_payload::data, ast_frame::datalen, ast_bridge_channel::dtmf_hook_state, ast_frame::frametype, ast_frame_subclass::integer, LOG_WARNING, ast_frame::ptr, sendtext_safe(), ast_bridge_channel::stream_map, ast_frame::stream_num, ast_frame::subclass, ast_bridge_channel::to_channel, and ast_bridge_channel::wr_queue.

Referenced by bridge_channel_wait().

◆ bridge_channel_internal_alloc()

struct ast_bridge_channel * bridge_channel_internal_alloc ( struct ast_bridge bridge)

Definition at line 3096 of file bridge_channel.c.

3097{
3098 struct ast_bridge_channel *bridge_channel;
3099
3100 bridge_channel = ao2_alloc(sizeof(struct ast_bridge_channel), bridge_channel_destroy);
3101 if (!bridge_channel) {
3102 return NULL;
3103 }
3104 ast_cond_init(&bridge_channel->cond, NULL);
3105 if (ast_alertpipe_init(bridge_channel->alert_pipe)) {
3106 ao2_ref(bridge_channel, -1);
3107 return NULL;
3108 }
3109 if (bridge) {
3110 bridge_channel->bridge = bridge;
3111 ao2_ref(bridge_channel->bridge, +1);
3112 }
3113
3114 /* The stream_map is initialized later - see ast_bridge_channel_stream_map */
3115
3116 return bridge_channel;
3117}
int ast_alertpipe_init(int alert_pipe[2])
Initialize an alert pipe.
Definition: alertpipe.c:38
#define ao2_alloc(data_size, destructor_fn)
Definition: astobj2.h:409
static void bridge_channel_destroy(void *obj)
#define ast_cond_init(cond, attr)
Definition: lock.h:201

References ast_bridge_channel::alert_pipe, ao2_alloc, ao2_ref, ast_alertpipe_init(), ast_cond_init, ast_bridge_channel::bridge, bridge_channel_destroy(), ast_bridge_channel::cond, and NULL.

Referenced by ast_bridge_join(), and bridge_impart_internal().

◆ bridge_channel_internal_allows_optimization()

int bridge_channel_internal_allows_optimization ( struct ast_bridge_channel bridge_channel)

Definition at line 3055 of file bridge_channel.c.

3056{
3057 return bridge_channel->in_bridge
3058 && AST_LIST_EMPTY(&bridge_channel->wr_queue);
3059}

References AST_LIST_EMPTY, ast_bridge_channel::in_bridge, and ast_bridge_channel::wr_queue.

Referenced by optimize_lock_chan_stack(), and optimize_lock_peer_stack().

◆ bridge_channel_internal_join()

int bridge_channel_internal_join ( struct ast_bridge_channel bridge_channel)

Definition at line 2820 of file bridge_channel.c.

2821{
2822 int res = 0;
2823 uint8_t indicate_src_change = 0;
2824 struct ast_bridge_features *channel_features;
2825 struct ast_channel *peer;
2826 struct ast_channel *swap;
2827
2828 ast_debug(1, "Bridge %s: %p(%s) is joining\n",
2831
2832 /*
2833 * Directly locking the bridge is safe here because nobody else
2834 * knows about this bridge_channel yet.
2835 */
2837
2840
2841 if (peer) {
2842 struct ast_bridge *peer_bridge;
2843
2844 ast_channel_unlock(bridge_channel->chan);
2845
2846 ast_channel_lock(peer);
2847 peer_bridge = ast_channel_internal_bridge(peer);
2848 ast_channel_unlock(peer);
2849 ast_channel_unref(peer);
2850
2851 /* As we are only doing a pointer comparison we don't need the peer_bridge
2852 * to be reference counted or locked.
2853 */
2854 if (peer_bridge == bridge_channel->bridge) {
2855 ast_bridge_unlock(bridge_channel->bridge);
2856 ast_debug(1, "Bridge %s: %p(%s) denying Bridge join to prevent Local channel loop\n",
2857 bridge_channel->bridge->uniqueid,
2858 bridge_channel,
2859 ast_channel_name(bridge_channel->chan));
2860 return -1;
2861 }
2862
2863 ast_channel_lock(bridge_channel->chan);
2864 }
2865
2866 bridge_channel->read_format = ao2_bump(ast_channel_readformat(bridge_channel->chan));
2867 bridge_channel->write_format = ao2_bump(ast_channel_writeformat(bridge_channel->chan));
2868
2869 /* Make sure we're still good to be put into a bridge */
2870 if (ast_channel_internal_bridge(bridge_channel->chan)
2871 || ast_test_flag(ast_channel_flags(bridge_channel->chan), AST_FLAG_ZOMBIE)) {
2872 ast_channel_unlock(bridge_channel->chan);
2873 ast_bridge_unlock(bridge_channel->bridge);
2874 ast_debug(1, "Bridge %s: %p(%s) failed to join Bridge\n",
2875 bridge_channel->bridge->uniqueid,
2876 bridge_channel,
2877 ast_channel_name(bridge_channel->chan));
2878 return -1;
2879 }
2880 ast_channel_internal_bridge_set(bridge_channel->chan, bridge_channel->bridge);
2881
2882 /* Attach features requested by the channel */
2883 channel_features = ast_channel_feature_hooks_get(bridge_channel->chan);
2884 if (channel_features) {
2885 ast_bridge_features_merge(bridge_channel->features, channel_features);
2886 }
2887 ast_channel_unlock(bridge_channel->chan);
2888
2889 /* Add the jitterbuffer if the channel requires it */
2890 ast_jb_enable_for_channel(bridge_channel->chan);
2891
2892 if (!bridge_channel->bridge->callid) {
2893 bridge_channel->bridge->callid = ast_read_threadstorage_callid();
2894 }
2895
2896 /* Take the swap channel ref from the bridge_channel struct. */
2897 swap = bridge_channel->swap;
2898
2899 if (bridge_channel_internal_push(bridge_channel)) {
2900 int cause = bridge_channel->bridge->cause;
2901
2902 ast_bridge_unlock(bridge_channel->bridge);
2903 ast_bridge_channel_kick(bridge_channel, cause);
2904 ast_bridge_channel_lock_bridge(bridge_channel);
2905 ast_bridge_features_remove(bridge_channel->features,
2907 bridge_channel_dissolve_check(bridge_channel);
2908 res = -1;
2909 }
2910 bridge_reconfigured(bridge_channel->bridge, !bridge_channel->inhibit_colp);
2911
2912 if (bridge_channel->state == BRIDGE_CHANNEL_STATE_WAIT) {
2913 /*
2914 * Indicate a source change since this channel is entering the
2915 * bridge system only if the bridge technology is not MULTIMIX
2916 * capable. The MULTIMIX technology has already done it.
2917 */
2918 if (!(bridge_channel->bridge->technology->capabilities
2920 indicate_src_change = 1;
2921 }
2922
2923 bridge_channel_impart_signal(bridge_channel->chan);
2924 ast_bridge_unlock(bridge_channel->bridge);
2925
2926 /* Must release any swap ref after unlocking the bridge. */
2927 ao2_t_cleanup(swap, "Bridge push with swap successful");
2928 swap = NULL;
2929
2930 if (indicate_src_change) {
2931 ast_indicate(bridge_channel->chan, AST_CONTROL_SRCCHANGE);
2932 }
2933
2935
2936 while (bridge_channel->state == BRIDGE_CHANNEL_STATE_WAIT) {
2937 /* Wait for something to do. */
2938 bridge_channel_wait(bridge_channel);
2939 }
2940
2941 /* Force a timeout on any accumulated DTMF hook digits. */
2942 ast_bridge_channel_feature_digit(bridge_channel, 0);
2943
2945 ast_bridge_channel_lock_bridge(bridge_channel);
2946 }
2947
2948 bridge_channel_internal_pull(bridge_channel);
2949 bridge_channel_settle_owed_events(bridge_channel->bridge, bridge_channel);
2950 bridge_reconfigured(bridge_channel->bridge, 1);
2951
2952 /* Remove ourselves if we are the video source */
2953 ast_bridge_remove_video_src(bridge_channel->bridge, bridge_channel->chan);
2954
2955 ast_bridge_unlock(bridge_channel->bridge);
2956
2957 /* Must release any swap ref after unlocking the bridge. */
2958 ao2_t_cleanup(swap, "Bridge push with swap failed or exited immediately");
2959
2960 /* Complete any active hold before exiting the bridge. */
2961 if (ast_channel_hold_state(bridge_channel->chan) == AST_CONTROL_HOLD) {
2962 ast_debug(1, "Channel %s simulating UNHOLD for bridge end.\n",
2963 ast_channel_name(bridge_channel->chan));
2964 ast_indicate(bridge_channel->chan, AST_CONTROL_UNHOLD);
2965 }
2966
2967 /* Complete any partial DTMF digit before exiting the bridge. */
2968 if (ast_channel_sending_dtmf_digit(bridge_channel->chan)) {
2969 ast_channel_end_dtmf(bridge_channel->chan,
2970 ast_channel_sending_dtmf_digit(bridge_channel->chan),
2971 ast_channel_sending_dtmf_tv(bridge_channel->chan), "bridge end");
2972 }
2973
2974 /* Complete any T.38 session before exiting the bridge. */
2975 if (ast_channel_is_t38_active(bridge_channel->chan)) {
2976 struct ast_control_t38_parameters t38_parameters = {
2978 };
2979
2980 ast_debug(1, "Channel %s simulating T.38 terminate for bridge end.\n",
2981 ast_channel_name(bridge_channel->chan));
2983 &t38_parameters, sizeof(t38_parameters));
2984 }
2985
2986 /* Indicate a source change since this channel is leaving the bridge system. */
2987 ast_indicate(bridge_channel->chan, AST_CONTROL_SRCCHANGE);
2988
2989 /*
2990 * Wait for any dual redirect to complete.
2991 *
2992 * Must be done while "still in the bridge" for ast_async_goto()
2993 * to work right.
2994 */
2996 sched_yield();
2997 }
2998 ast_channel_lock(bridge_channel->chan);
2999 ast_channel_internal_bridge_set(bridge_channel->chan, NULL);
3000 ast_channel_unlock(bridge_channel->chan);
3001
3002 ast_bridge_channel_restore_formats(bridge_channel);
3003
3004 return res;
3005}
void ast_jb_enable_for_channel(struct ast_channel *chan)
Sets a jitterbuffer frame hook on the channel based on the channel's stored jitterbuffer configuratio...
Definition: abstract_jb.c:585
#define ao2_t_cleanup(obj, tag)
Definition: astobj2.h:1935
void ast_bridge_features_remove(struct ast_bridge_features *features, enum ast_bridge_hook_remove_flags flags)
Remove marked bridge channel feature hooks.
Definition: bridge.c:3501
@ AST_BRIDGE_CAPABILITY_MULTIMIX
Definition: bridge.h:94
void ast_bridge_remove_video_src(struct ast_bridge *bridge, struct ast_channel *chan)
remove a channel as a source of video for the bridge.
Definition: bridge.c:3917
void bridge_channel_settle_owed_events(struct ast_bridge *orig_bridge, struct ast_bridge_channel *bridge_channel)
static void bridge_channel_wait(struct ast_bridge_channel *bridge_channel)
int bridge_channel_internal_push(struct ast_bridge_channel *bridge_channel)
static void bridge_channel_dissolve_check(struct ast_bridge_channel *bridge_channel)
static void bridge_channel_event_join_leave(struct ast_bridge_channel *bridge_channel, enum ast_bridge_hook_type type)
void bridge_channel_internal_pull(struct ast_bridge_channel *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_joi...
void bridge_channel_impart_signal(struct ast_channel *chan)
Definition: bridge.c:1582
@ AST_BRIDGE_HOOK_TYPE_JOIN
@ AST_BRIDGE_HOOK_TYPE_LEAVE
@ AST_BRIDGE_HOOK_REMOVE_ON_PULL
void ast_bridge_features_merge(struct ast_bridge_features *into, const struct ast_bridge_features *from)
Merge one ast_bridge_features into another.
Definition: bridge.c:3595
struct ast_bridge * ast_channel_internal_bridge(const struct ast_channel *chan)
void ast_channel_end_dtmf(struct ast_channel *chan, char digit, struct timeval start, const char *why)
Simulate a DTMF end on a broken bridge channel.
Definition: channel.c:10869
struct timeval ast_channel_sending_dtmf_tv(const struct ast_channel *chan)
struct ast_bridge_features * ast_channel_feature_hooks_get(struct ast_channel *chan)
Gets the channel-attached features a channel has access to upon being bridged.
Definition: channel.c:10903
void ast_channel_internal_bridge_set(struct ast_channel *chan, struct ast_bridge *value)
int ast_channel_hold_state(const struct ast_channel *chan)
@ AST_FLAG_BRIDGE_DUAL_REDIRECT_WAIT
Definition: channel.h:1035
@ AST_FLAG_ZOMBIE
Definition: channel.h:987
char ast_channel_sending_dtmf_digit(const struct ast_channel *chan)
int ast_channel_is_t38_active(struct ast_channel *chan)
This function will check if T.38 is active on the channel.
struct ast_channel * ast_local_get_peer(struct ast_channel *ast)
Get the other local channel in the pair.
Definition: core_local.c:276
@ AST_T38_TERMINATED
@ AST_CONTROL_T38_PARAMETERS
@ AST_CONTROL_SRCCHANGE
ast_callid ast_read_threadstorage_callid(void)
extracts the callerid from the thread
Definition: logger.c:2286
struct ast_channel * swap
unsigned int inhibit_colp
ast_callid callid
Definition: bridge.h:361
const ast_string_field uniqueid
Definition: bridge.h:401
int cause
Definition: bridge.h:386
struct ast_bridge_technology * technology
Definition: bridge.h:355
enum ast_control_t38 request_response

References ao2_bump, ao2_t_cleanup, AST_BRIDGE_CAPABILITY_MULTIMIX, ast_bridge_channel_feature_digit(), ast_bridge_channel_kick(), ast_bridge_channel_lock_bridge(), ast_bridge_channel_restore_formats(), ast_bridge_features_merge(), ast_bridge_features_remove(), AST_BRIDGE_HOOK_REMOVE_ON_PULL, AST_BRIDGE_HOOK_TYPE_JOIN, AST_BRIDGE_HOOK_TYPE_LEAVE, ast_bridge_lock, ast_bridge_remove_video_src(), ast_bridge_unlock, ast_channel_end_dtmf(), ast_channel_feature_hooks_get(), ast_channel_flags(), ast_channel_hold_state(), ast_channel_internal_bridge(), ast_channel_internal_bridge_set(), ast_channel_is_t38_active(), ast_channel_lock, ast_channel_name(), ast_channel_readformat(), ast_channel_sending_dtmf_digit(), ast_channel_sending_dtmf_tv(), ast_channel_unlock, ast_channel_unref, ast_channel_writeformat(), AST_CONTROL_HOLD, AST_CONTROL_SRCCHANGE, AST_CONTROL_T38_PARAMETERS, AST_CONTROL_UNHOLD, ast_debug, AST_FLAG_BRIDGE_DUAL_REDIRECT_WAIT, AST_FLAG_ZOMBIE, ast_indicate(), ast_indicate_data(), ast_jb_enable_for_channel(), ast_local_get_peer(), ast_read_threadstorage_callid(), AST_T38_TERMINATED, ast_test_flag, ast_bridge_channel::bridge, ast_channel::bridge_channel, bridge_channel_dissolve_check(), bridge_channel_event_join_leave(), bridge_channel_impart_signal(), bridge_channel_internal_pull(), bridge_channel_internal_push(), bridge_channel_settle_owed_events(), BRIDGE_CHANNEL_STATE_WAIT, bridge_channel_wait(), bridge_reconfigured(), ast_bridge::callid, ast_bridge_technology::capabilities, ast_bridge::cause, ast_bridge_channel::chan, ast_bridge_channel::features, ast_bridge_channel::inhibit_colp, NULL, ast_bridge_channel::read_format, ast_control_t38_parameters::request_response, ast_bridge_channel::state, ast_bridge_channel::swap, ast_bridge::technology, ast_bridge::uniqueid, and ast_bridge_channel::write_format.

Referenced by ast_bridge_join(), bridge_channel_depart_thread(), and bridge_channel_ind_thread().

◆ bridge_channel_internal_pull()

void bridge_channel_internal_pull ( struct ast_bridge_channel bridge_channel)

Definition at line 2108 of file bridge_channel.c.

2109{
2110 struct ast_bridge *bridge = bridge_channel->bridge;
2111
2112 if (!bridge_channel->in_bridge) {
2113 return;
2114 }
2115 bridge_channel->in_bridge = 0;
2116
2117 ast_debug(1, "Bridge %s: pulling %p(%s)\n",
2118 bridge->uniqueid, bridge_channel, ast_channel_name(bridge_channel->chan));
2119
2120 ast_verb(3, "Channel %s left '%s' %s-bridge <%s>\n",
2121 ast_channel_name(bridge_channel->chan),
2122 bridge->technology->name,
2123 bridge->v_table->name,
2124 bridge->uniqueid);
2125
2126 if (!bridge_channel->just_joined) {
2127 /* Tell the bridge technology we are leaving so they tear us down */
2128 ast_debug(1, "Bridge %s: %p(%s) is leaving %s technology\n",
2129 bridge->uniqueid, bridge_channel, ast_channel_name(bridge_channel->chan),
2130 bridge->technology->name);
2131 if (bridge->technology->leave) {
2132 bridge->technology->leave(bridge, bridge_channel);
2133 }
2134 }
2135
2136 /* Remove channel from the bridge */
2137 if (!bridge_channel->suspended) {
2138 --bridge->num_active;
2139 }
2141 --bridge->num_lonely;
2142 }
2143 --bridge->num_channels;
2144 AST_LIST_REMOVE(&bridge->channels, bridge_channel, entry);
2145
2146 bridge_channel_dissolve_check(bridge_channel);
2147 bridge->v_table->pull(bridge, bridge_channel);
2148
2149 ast_bridge_channel_clear_roles(bridge_channel);
2150
2151 /* If we are not going to be hung up after leaving a bridge, and we were an
2152 * outgoing channel, clear the outgoing flag.
2153 */
2155 && (ast_channel_is_leaving_bridge(bridge_channel->chan)
2156 || bridge_channel->state == BRIDGE_CHANNEL_STATE_WAIT)) {
2157 ast_debug(2, "Channel %s will survive this bridge; clearing outgoing (dialed) flag\n", ast_channel_name(bridge_channel->chan));
2159 }
2160
2161 bridge->reconfigured = 1;
2162 ast_bridge_publish_leave(bridge, bridge_channel->chan);
2163}
@ AST_BRIDGE_CHANNEL_FLAG_LONELY
void ast_bridge_channel_clear_roles(struct ast_bridge_channel *bridge_channel)
Clear all roles from a bridge_channel's role list.
Definition: bridge_roles.c:491
void ast_channel_clear_flag(struct ast_channel *chan, unsigned int flag)
Clear a flag on a channel.
Definition: channel.c:11034
int ast_channel_is_leaving_bridge(struct ast_channel *chan)
Determine if a channel is leaving a bridge, but not hung up.
Definition: channel.c:10550
@ AST_FLAG_OUTGOING
Definition: channel.h:999
#define ast_verb(level,...)
#define AST_LIST_REMOVE(head, elm, field)
Removes a specific entry from a list.
Definition: linkedlists.h:856
void ast_bridge_publish_leave(struct ast_bridge *bridge, struct ast_channel *chan)
Publish a bridge channel leave event.
unsigned int just_joined
const char * name
Definition: bridge.h:259
ast_bridge_pull_channel_fn pull
Definition: bridge.h:267
void(* leave)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
Remove a channel from a bridging technology instance for a bridge.
const struct ast_bridge_methods * v_table
Definition: bridge.h:351
unsigned int num_active
Definition: bridge.h:375

References ast_bridge_channel_clear_roles(), AST_BRIDGE_CHANNEL_FLAG_LONELY, ast_bridge_publish_leave(), ast_channel_clear_flag(), ast_channel_flags(), ast_channel_is_leaving_bridge(), ast_channel_name(), ast_debug, AST_FLAG_OUTGOING, AST_LIST_REMOVE, ast_test_flag, ast_verb, ast_bridge_channel::bridge, bridge_channel_dissolve_check(), BRIDGE_CHANNEL_STATE_WAIT, ast_bridge_channel::chan, ast_bridge::channels, ast_bridge_features::feature_flags, ast_bridge_channel::features, ast_bridge_channel::in_bridge, ast_bridge_channel::just_joined, ast_bridge_technology::leave, ast_bridge_methods::name, ast_bridge_technology::name, ast_bridge::num_active, ast_bridge::num_channels, ast_bridge::num_lonely, ast_bridge_methods::pull, ast_bridge::reconfigured, ast_bridge_channel::state, ast_bridge_channel::suspended, ast_bridge::technology, ast_bridge::uniqueid, and ast_bridge::v_table.

Referenced by bridge_channel_internal_join(), bridge_channel_internal_push_full(), bridge_do_merge(), and bridge_do_move().

◆ bridge_channel_internal_push()

int bridge_channel_internal_push ( struct ast_bridge_channel bridge_channel)

Definition at line 2245 of file bridge_channel.c.

2246{
2247 return bridge_channel_internal_push_full(bridge_channel, 0);
2248}
int bridge_channel_internal_push_full(struct ast_bridge_channel *bridge_channel, int optimized)

References bridge_channel_internal_push_full().

Referenced by bridge_channel_internal_join(), bridge_do_merge(), and bridge_do_move().

◆ bridge_channel_internal_push_full()

int bridge_channel_internal_push_full ( struct ast_bridge_channel bridge_channel,
int  optimized 
)

Definition at line 2165 of file bridge_channel.c.

2166{
2167 struct ast_bridge *bridge = bridge_channel->bridge;
2168 struct ast_bridge_channel *swap;
2169
2170 ast_assert(!bridge_channel->in_bridge);
2171
2172 swap = bridge_find_channel(bridge, bridge_channel->swap);
2173 bridge_channel->swap = NULL;
2174
2175 if (swap) {
2176 ast_debug(1, "Bridge %s: pushing %p(%s) by swapping with %p(%s)\n",
2177 bridge->uniqueid, bridge_channel, ast_channel_name(bridge_channel->chan),
2178 swap, ast_channel_name(swap->chan));
2179 } else {
2180 ast_debug(1, "Bridge %s: pushing %p(%s)\n",
2181 bridge->uniqueid, bridge_channel, ast_channel_name(bridge_channel->chan));
2182 }
2183
2184 /* Add channel to the bridge */
2185 if (bridge->dissolved
2186 || bridge_channel->state != BRIDGE_CHANNEL_STATE_WAIT
2188 || bridge->v_table->push(bridge, bridge_channel, swap)) {
2189 ast_debug(1, "Bridge %s: pushing %p(%s) into bridge failed\n",
2190 bridge->uniqueid, bridge_channel, ast_channel_name(bridge_channel->chan));
2191 return -1;
2192 }
2193
2194 ast_bridge_channel_establish_roles(bridge_channel);
2195
2196 if (swap) {
2198
2199 /* This flag is cleared so the act of this channel leaving does not cause it to dissolve if need be */
2201
2202 if (optimized) {
2204 }
2207
2209 }
2210
2211 bridge_channel->in_bridge = 1;
2212 bridge_channel->just_joined = 1;
2213 AST_LIST_INSERT_TAIL(&bridge->channels, bridge_channel, entry);
2216 ++bridge->num_lonely;
2217 }
2218 if (!bridge_channel->suspended) {
2219 ++bridge->num_active;
2220 }
2221
2222 ast_verb(3, "Channel %s %s%s%s '%s' %s-bridge <%s>\n",
2223 ast_channel_name(bridge_channel->chan),
2224 swap ? "swapped with " : "joined",
2225 swap ? ast_channel_name(swap->chan) : "",
2226 swap ? " into" : "",
2229 bridge->uniqueid);
2230
2231 ast_bridge_publish_enter(bridge, bridge_channel->chan, swap ? swap->chan : NULL);
2232
2233 /* Clear any BLINDTRANSFER,ATTENDEDTRANSFER and FORWARDERNAME since the transfer has completed. */
2234 pbx_builtin_setvar_helper(bridge_channel->chan, "BLINDTRANSFER", NULL);
2235 pbx_builtin_setvar_helper(bridge_channel->chan, "ATTENDEDTRANSFER", NULL);
2236 pbx_builtin_setvar_helper(bridge_channel->chan, "FORWARDERNAME", NULL);
2237
2238 /* Wake up the bridge channel thread to reevaluate any interval timers. */
2239 ast_queue_frame(bridge_channel->chan, &ast_null_frame);
2240
2241 bridge->reconfigured = 1;
2242 return 0;
2243}
static void bridge_channel_cancel_owed_events(struct ast_bridge_channel *bridge_channel)
struct ast_bridge_channel * bridge_find_channel(struct ast_bridge *bridge, struct ast_channel *chan)
Definition: bridge.c:1429
int ast_bridge_channel_establish_roles(struct ast_bridge_channel *bridge_channel)
Clone the roles from a bridge_channel's attached ast_channel onto the bridge_channel's role list.
Definition: bridge_roles.c:443
int ast_queue_frame(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to a channel's frame queue.
Definition: channel.c:1139
struct ast_frame ast_null_frame
Definition: main/frame.c:79
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.
void ast_bridge_publish_enter(struct ast_bridge *bridge, struct ast_channel *chan, struct ast_channel *swap)
Publish a bridge channel enter event.
ast_bridge_push_channel_fn push
Definition: bridge.h:265
enum ast_channel_state state
#define ast_set2_flag(p, value, flag)
Definition: utils.h:94
#define ast_clear_flag(p, flag)
Definition: utils.h:77

References ast_assert, ast_bridge_channel_establish_roles(), AST_BRIDGE_CHANNEL_FLAG_LONELY, ast_bridge_channel_leave_bridge(), AST_BRIDGE_FLAG_DISSOLVE_EMPTY, ast_bridge_publish_enter(), ast_channel_name(), ast_clear_flag, ast_debug, AST_LIST_INSERT_TAIL, ast_null_frame, ast_queue_frame(), ast_set2_flag, ast_test_flag, ast_verb, ast_bridge_channel::bridge, bridge_channel_cancel_owed_events(), bridge_channel_internal_pull(), BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE, BRIDGE_CHANNEL_STATE_WAIT, bridge_find_channel(), ast_bridge_channel::chan, ast_bridge::channels, ast_bridge::dissolved, ast_bridge::feature_flags, ast_bridge_features::feature_flags, ast_bridge_channel::features, ast_bridge_channel::in_bridge, ast_bridge_channel::just_joined, ast_bridge_methods::name, ast_bridge_technology::name, NULL, ast_bridge::num_active, ast_bridge::num_channels, ast_bridge::num_lonely, pbx_builtin_setvar_helper(), ast_bridge_methods::push, ast_bridge::reconfigured, ast_bridge_channel::state, ast_channel::state, ast_bridge_channel::suspended, ast_bridge_channel::swap, ast_bridge::technology, ast_bridge::uniqueid, and ast_bridge::v_table.

Referenced by bridge_channel_internal_push(), and bridge_do_move().

◆ bridge_channel_internal_queue_attended_transfer()

int bridge_channel_internal_queue_attended_transfer ( struct ast_channel transferee,
struct ast_channel unbridged_chan 
)

Definition at line 3033 of file bridge_channel.c.

3035{
3036 RAII_VAR(struct ast_bridge_channel *, transferee_bridge_channel, NULL, ao2_cleanup);
3037 char unbridged_chan_name[AST_CHANNEL_NAME];
3038
3039 ast_channel_lock(transferee);
3040 transferee_bridge_channel = ast_channel_get_bridge_channel(transferee);
3041 ast_channel_unlock(transferee);
3042
3043 if (!transferee_bridge_channel) {
3044 return -1;
3045 }
3046
3047 ast_copy_string(unbridged_chan_name, ast_channel_name(unbridged_chan),
3048 sizeof(unbridged_chan_name));
3049
3050 return bridge_channel_queue_action_data(transferee_bridge_channel,
3051 BRIDGE_CHANNEL_ACTION_ATTENDED_TRANSFER, unbridged_chan_name,
3052 sizeof(unbridged_chan_name));
3053}
#define AST_CHANNEL_NAME
Definition: channel.h:171
struct ast_bridge_channel * ast_channel_get_bridge_channel(struct ast_channel *chan)
Get a reference to the channel's bridge pointer.
Definition: channel.c:10582
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425

References ao2_cleanup, ast_channel_get_bridge_channel(), ast_channel_lock, AST_CHANNEL_NAME, ast_channel_name(), ast_channel_unlock, ast_copy_string(), BRIDGE_CHANNEL_ACTION_ATTENDED_TRANSFER, bridge_channel_queue_action_data(), NULL, and RAII_VAR.

Referenced by ast_bridge_transfer_attended().

◆ bridge_channel_internal_queue_blind_transfer()

int bridge_channel_internal_queue_blind_transfer ( struct ast_channel transferee,
const char *  exten,
const char *  context,
transfer_channel_cb  new_channel_cb,
void *  user_data 
)

Definition at line 3007 of file bridge_channel.c.

3010{
3011 RAII_VAR(struct ast_bridge_channel *, transferee_bridge_channel, NULL, ao2_cleanup);
3012 struct blind_transfer_data blind_data;
3013
3014 ast_channel_lock(transferee);
3015 transferee_bridge_channel = ast_channel_get_bridge_channel(transferee);
3016 ast_channel_unlock(transferee);
3017
3018 if (!transferee_bridge_channel) {
3019 return -1;
3020 }
3021
3022 if (new_channel_cb) {
3023 new_channel_cb(transferee, user_data, AST_BRIDGE_TRANSFER_SINGLE_PARTY);
3024 }
3025
3026 ast_copy_string(blind_data.exten, exten, sizeof(blind_data.exten));
3027 ast_copy_string(blind_data.context, context, sizeof(blind_data.context));
3028
3029 return bridge_channel_queue_action_data(transferee_bridge_channel,
3030 BRIDGE_CHANNEL_ACTION_BLIND_TRANSFER, &blind_data, sizeof(blind_data));
3031}
@ AST_BRIDGE_TRANSFER_SINGLE_PARTY
Definition: bridge.h:1111
Data specifying where a blind transfer is going to.

References ao2_cleanup, AST_BRIDGE_TRANSFER_SINGLE_PARTY, ast_channel_get_bridge_channel(), ast_channel_lock, ast_channel_unlock, ast_copy_string(), BRIDGE_CHANNEL_ACTION_BLIND_TRANSFER, bridge_channel_queue_action_data(), voicemailpwcheck::context, blind_transfer_data::context, blind_transfer_data::exten, NULL, and RAII_VAR.

Referenced by ast_bridge_transfer_blind().

◆ bridge_channel_internal_suspend_nolock()

void bridge_channel_internal_suspend_nolock ( struct ast_bridge_channel bridge_channel)

Definition at line 829 of file bridge_channel.c.

830{
831 bridge_channel->suspended = 1;
832 if (bridge_channel->in_bridge) {
833 --bridge_channel->bridge->num_active;
834 }
835
836 /* Get technology bridge threads off of the channel. */
837 if (bridge_channel->bridge->technology->suspend) {
838 bridge_channel->bridge->technology->suspend(bridge_channel->bridge, bridge_channel);
839 }
840}
void(* suspend)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
Suspend a channel on a bridging technology instance for a bridge.

References ast_bridge_channel::bridge, ast_bridge_channel::in_bridge, ast_bridge::num_active, ast_bridge_technology::suspend, ast_bridge_channel::suspended, and ast_bridge::technology.

Referenced by ast_bridge_channel_feature_digit(), ast_bridge_suspend(), and bridge_channel_suspend().

◆ bridge_channel_internal_unsuspend_nolock()

void bridge_channel_internal_unsuspend_nolock ( struct ast_bridge_channel bridge_channel)

Definition at line 855 of file bridge_channel.c.

856{
857 bridge_channel->suspended = 0;
858 if (bridge_channel->in_bridge) {
859 ++bridge_channel->bridge->num_active;
860 }
861
862 /* Wake technology bridge threads to take care of channel again. */
863 if (bridge_channel->bridge->technology->unsuspend) {
864 bridge_channel->bridge->technology->unsuspend(bridge_channel->bridge, bridge_channel);
865 }
866
867 /* Wake suspended channel. */
868 ast_bridge_channel_lock(bridge_channel);
869 ast_cond_signal(&bridge_channel->cond);
870 ast_bridge_channel_unlock(bridge_channel);
871}
#define ast_cond_signal(cond)
Definition: lock.h:203
void(* unsuspend)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
Unsuspend a channel on a bridging technology instance for a bridge.

References ast_bridge_channel_lock, ast_bridge_channel_unlock, ast_cond_signal, ast_bridge_channel::bridge, ast_bridge_channel::cond, ast_bridge_channel::in_bridge, ast_bridge::num_active, ast_bridge_channel::suspended, ast_bridge::technology, and ast_bridge_technology::unsuspend.

Referenced by ast_bridge_unsuspend(), and bridge_channel_unsuspend().

◆ bridge_channel_next_interval()

static int bridge_channel_next_interval ( struct ast_bridge_channel bridge_channel)
static

Definition at line 2642 of file bridge_channel.c.

2643{
2644 struct ast_heap *interval_hooks = bridge_channel->features->interval_hooks;
2645 struct ast_bridge_hook_timer *hook;
2646 int ms;
2647
2648 ast_heap_wrlock(interval_hooks);
2649 hook = ast_heap_peek(interval_hooks, 1);
2650 if (hook) {
2651 ms = ast_tvdiff_ms(hook->timer.trip_time, ast_tvnow());
2652 if (ms < 0) {
2653 /* Expire immediately. An interval hook is ready to run. */
2654 ms = 0;
2655 }
2656 } else {
2657 /* No hook so wait forever. */
2658 ms = -1;
2659 }
2660 ast_heap_unlock(interval_hooks);
2661
2662 return ms;
2663}

References ast_heap_peek(), ast_heap_unlock, ast_heap_wrlock, ast_tvdiff_ms(), ast_tvnow(), ast_bridge_channel::features, ast_bridge_features::interval_hooks, ast_bridge_hook_timer::timer, and ast_bridge_hook_timer_parms::trip_time.

Referenced by bridge_channel_next_timeout().

◆ bridge_channel_next_timeout()

static int bridge_channel_next_timeout ( struct ast_bridge_channel bridge_channel)
static

Definition at line 2704 of file bridge_channel.c.

2705{
2706 int ms_interval;
2707 int ms;
2708
2709 ms_interval = bridge_channel_next_interval(bridge_channel);
2710 ms = bridge_channel_feature_timeout(bridge_channel);
2711 if (ms < 0 || (0 <= ms_interval && ms_interval < ms)) {
2712 /* Interval hook timeout is next. */
2713 ms = ms_interval;
2714 }
2715
2716 return ms;
2717}
static int bridge_channel_feature_timeout(struct ast_bridge_channel *bridge_channel)
static int bridge_channel_next_interval(struct ast_bridge_channel *bridge_channel)

References bridge_channel_feature_timeout(), and bridge_channel_next_interval().

Referenced by bridge_channel_wait().

◆ bridge_channel_park()

static void bridge_channel_park ( struct ast_bridge_channel bridge_channel,
struct bridge_park payload 
)
static

Definition at line 1448 of file bridge_channel.c.

1449{
1451 ast_log(AST_LOG_WARNING, "Unable to park %s: No parking provider loaded!\n",
1452 ast_channel_name(bridge_channel->chan));
1453 return;
1454 }
1455
1456 if (ast_parking_park_bridge_channel(bridge_channel, payload->parkee_uuid,
1457 &payload->parkee_uuid[payload->parker_uuid_offset],
1458 payload->app_data_offset ? &payload->parkee_uuid[payload->app_data_offset] : NULL)) {
1459 ast_log(AST_LOG_WARNING, "Error occurred while parking %s\n",
1460 ast_channel_name(bridge_channel->chan));
1461 }
1462}
#define AST_LOG_WARNING
int ast_parking_park_bridge_channel(struct ast_bridge_channel *parkee, const char *parkee_uuid, const char *parker_uuid, const char *app_data)
Perform a direct park on a channel in a bridge.
Definition: parking.c:126
int ast_parking_provider_registered(void)
Check whether a parking provider is registered.
Definition: parking.c:241
char parkee_uuid[0]

References bridge_park::app_data_offset, ast_channel_name(), ast_log, AST_LOG_WARNING, ast_parking_park_bridge_channel(), ast_parking_provider_registered(), ast_bridge_channel::chan, NULL, bridge_park::parkee_uuid, and bridge_park::parker_uuid_offset.

Referenced by bridge_channel_handle_action().

◆ bridge_channel_playfile()

static void bridge_channel_playfile ( struct ast_bridge_channel bridge_channel,
struct bridge_playfile payload 
)
static

Definition at line 1307 of file bridge_channel.c.

1308{
1309 ast_bridge_channel_playfile(bridge_channel, payload->custom_play, payload->playfile,
1310 payload->moh_offset ? &payload->playfile[payload->moh_offset] : NULL);
1311}
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.
ast_bridge_custom_play_fn custom_play

References ast_bridge_channel_playfile(), bridge_playfile::custom_play, bridge_playfile::moh_offset, NULL, and bridge_playfile::playfile.

Referenced by bridge_channel_handle_action().

◆ bridge_channel_poke()

static void bridge_channel_poke ( struct ast_bridge_channel bridge_channel)
static

Definition at line 260 of file bridge_channel.c.

261{
262 if (!pthread_equal(pthread_self(), bridge_channel->thread)) {
263 /* Wake up the bridge channel thread. */
264 ast_queue_frame(bridge_channel->chan, &ast_null_frame);
265 }
266}

References ast_null_frame, ast_queue_frame(), ast_bridge_channel::chan, and ast_bridge_channel::thread.

Referenced by ast_bridge_channel_leave_bridge_nolock().

◆ bridge_channel_queue_action_data()

static int bridge_channel_queue_action_data ( struct ast_bridge_channel bridge_channel,
enum bridge_channel_action_type  action,
const void *  data,
size_t  datalen 
)
static

◆ bridge_channel_queue_action_data_sync()

static int bridge_channel_queue_action_data_sync ( struct ast_bridge_channel bridge_channel,
enum bridge_channel_action_type  action,
const void *  data,
size_t  datalen 
)
static

Definition at line 927 of file bridge_channel.c.

929{
931 int sync_payload_len = sizeof(*sync_payload) + datalen;
932 struct bridge_sync sync_struct;
933 struct ast_frame frame = {
935 .subclass.integer = action,
936 };
937
938 /* Make sure we don't end up trying to wait on ourself to deliver the frame */
939 ast_assert(!pthread_equal(pthread_self(), bridge_channel->thread));
940
941 sync_payload = ast_alloca(sync_payload_len);
943 memcpy(sync_payload->data, data, datalen);
944
945 frame.datalen = sync_payload_len;
946 frame.data.ptr = sync_payload;
947
948 bridge_sync_init(&sync_struct, sync_payload->id);
949 if (ast_bridge_channel_queue_frame(bridge_channel, &frame)) {
950 bridge_sync_cleanup(&sync_struct);
951 return -1;
952 }
953
954 bridge_sync_wait(&sync_struct);
955 bridge_sync_cleanup(&sync_struct);
956 return 0;
957}
static void bridge_sync_init(struct bridge_sync *sync_struct, unsigned int id)
Initialize a synchronous bridge object.
static void bridge_sync_wait(struct bridge_sync *sync_struct)
Wait for a synchronous bridge action to complete.
static void bridge_sync_cleanup(struct bridge_sync *sync_struct)
Clean up a synchronization bridge object.
static int sync_ids
Counter used for assigning synchronous bridge action IDs.
Synchronous bridge action object.
unsigned int id

References ast_alloca, ast_assert, ast_atomic_fetchadd_int(), ast_bridge_channel_queue_frame(), AST_FRAME_BRIDGE_ACTION_SYNC, bridge_sync_cleanup(), bridge_sync_init(), bridge_sync_wait(), ast_frame::data, sync_payload::data, ast_frame::datalen, ast_frame::frametype, sync_payload::id, ast_frame::ptr, sync_ids, and ast_bridge_channel::thread.

Referenced by ast_bridge_channel_queue_playfile_sync().

◆ bridge_channel_queue_deferred_frames()

void bridge_channel_queue_deferred_frames ( struct ast_bridge_channel bridge_channel)

Definition at line 815 of file bridge_channel.c.

816{
817 struct ast_frame *frame;
818
819 ast_bridge_channel_lock(bridge_channel);
820 ast_channel_lock(bridge_channel->chan);
821 while ((frame = AST_LIST_REMOVE_HEAD(&bridge_channel->deferred_queue, frame_list))) {
822 ast_queue_frame_head(bridge_channel->chan, frame);
823 ast_frfree(frame);
824 }
825 ast_channel_unlock(bridge_channel->chan);
826 ast_bridge_channel_unlock(bridge_channel);
827}
int ast_queue_frame_head(struct ast_channel *chan, struct ast_frame *f)
Queue one or more frames to the head of a channel's frame queue.
Definition: channel.c:1144

References ast_bridge_channel_lock, ast_bridge_channel_unlock, ast_channel_lock, ast_channel_unlock, ast_frfree, AST_LIST_REMOVE_HEAD, ast_queue_frame_head(), ast_bridge_channel::chan, and ast_bridge_channel::deferred_queue.

Referenced by bridge_complete_join().

◆ bridge_channel_run_app()

static void bridge_channel_run_app ( struct ast_bridge_channel bridge_channel,
struct bridge_run_app data 
)
static

Definition at line 1215 of file bridge_channel.c.

1216{
1217 ast_bridge_channel_run_app(bridge_channel, data->app_name,
1218 data->app_args_offset ? &data->app_name[data->app_args_offset] : NULL,
1219 data->moh_offset ? &data->app_name[data->moh_offset] : NULL);
1220}
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.

References bridge_run_app::app_args_offset, bridge_run_app::app_name, ast_bridge_channel_run_app(), bridge_run_app::moh_offset, and NULL.

Referenced by bridge_channel_handle_action().

◆ bridge_channel_settle_owed_events()

void bridge_channel_settle_owed_events ( struct ast_bridge orig_bridge,
struct ast_bridge_channel bridge_channel 
)

Definition at line 777 of file bridge_channel.c.

778{
779 if (bridge_channel->owed.dtmf_digit) {
780 struct ast_frame frame = {
782 .subclass.integer = bridge_channel->owed.dtmf_digit,
783 .src = "Bridge channel owed DTMF",
784 };
785
786 frame.len = ast_tvdiff_ms(ast_tvnow(), bridge_channel->owed.dtmf_tv);
787 if (frame.len < option_dtmfminduration) {
789 }
790 ast_log(LOG_DTMF, "DTMF end '%c' simulated to bridge %s because %s left. Duration %ld ms.\n",
791 bridge_channel->owed.dtmf_digit, orig_bridge->uniqueid,
792 ast_channel_name(bridge_channel->chan), frame.len);
793 bridge_channel->owed.dtmf_digit = '\0';
794 orig_bridge->technology->write(orig_bridge, NULL, &frame);
795 }
796 if (bridge_channel->owed.t38_terminate) {
797 struct ast_control_t38_parameters t38_parameters = {
799 };
800 struct ast_frame frame = {
802 .subclass.integer = AST_CONTROL_T38_PARAMETERS,
803 .data.ptr = &t38_parameters,
804 .datalen = sizeof(t38_parameters),
805 .src = "Bridge channel owed T.38 terminate",
806 };
807
808 ast_debug(1, "T.38 terminate simulated to bridge %s because %s left.\n",
809 orig_bridge->uniqueid, ast_channel_name(bridge_channel->chan));
810 bridge_channel->owed.t38_terminate = 0;
811 orig_bridge->technology->write(orig_bridge, NULL, &frame);
812 }
813}
unsigned int option_dtmfminduration
Definition: options.c:83
#define LOG_DTMF
struct timeval dtmf_tv
int(* write)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
Write a frame into the bridging technology instance for a bridge.
const char * src

References ast_channel_name(), AST_CONTROL_T38_PARAMETERS, ast_debug, AST_FRAME_CONTROL, AST_FRAME_DTMF_END, ast_log, AST_T38_TERMINATED, ast_tvdiff_ms(), ast_tvnow(), ast_bridge_channel::chan, ast_bridge_channel::dtmf_digit, ast_bridge_channel::dtmf_tv, ast_frame::frametype, ast_frame::len, LOG_DTMF, NULL, option_dtmfminduration, ast_bridge_channel::owed, ast_control_t38_parameters::request_response, ast_frame::src, ast_bridge_channel::t38_terminate, ast_bridge::technology, ast_bridge::uniqueid, and ast_bridge_technology::write.

Referenced by bridge_channel_internal_join(), and bridge_do_move().

◆ bridge_channel_suspend()

static void bridge_channel_suspend ( struct ast_bridge_channel bridge_channel)
static

◆ bridge_channel_talking()

static void bridge_channel_talking ( struct ast_bridge_channel bridge_channel,
int  talking 
)
static

Definition at line 1830 of file bridge_channel.c.

1831{
1832 struct ast_bridge_features *features = bridge_channel->features;
1833 struct ast_bridge_hook *hook;
1834 struct ao2_iterator iter;
1835
1836 /* Run any talk detection hooks. */
1837 iter = ao2_iterator_init(features->other_hooks, 0);
1838 for (; (hook = ao2_iterator_next(&iter)); ao2_ref(hook, -1)) {
1839 int remove_me;
1841
1842 if (hook->type != AST_BRIDGE_HOOK_TYPE_TALK) {
1843 continue;
1844 }
1846 remove_me = talk_cb(bridge_channel, hook->hook_pvt, talking);
1847 if (remove_me) {
1848 ast_debug(1, "Talk detection hook %p is being removed from %p(%s)\n",
1849 hook, bridge_channel, ast_channel_name(bridge_channel->chan));
1850 ao2_unlink(features->other_hooks, hook);
1851 }
1852 }
1853 ao2_iterator_destroy(&iter);
1854}
@ AST_BRIDGE_HOOK_TYPE_TALK
int(* ast_bridge_talking_indicate_callback)(struct ast_bridge_channel *bridge_channel, void *hook_pvt, int talking)
Talking indicator callback.

References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, ao2_unlink, AST_BRIDGE_HOOK_TYPE_TALK, ast_channel_name(), ast_debug, ast_bridge_hook::callback, ast_bridge_channel::chan, ast_bridge_channel::features, ast_bridge_hook::hook_pvt, ast_bridge_features::other_hooks, and ast_bridge_hook::type.

Referenced by bridge_channel_handle_action().

◆ bridge_channel_unsuspend()

static void bridge_channel_unsuspend ( struct ast_bridge_channel bridge_channel)
static

◆ bridge_channel_update_accountcodes_joining()

static void bridge_channel_update_accountcodes_joining ( struct ast_bridge_channel joining,
struct ast_bridge_channel swap 
)
static

Definition at line 518 of file bridge_channel.c.

519{
520 struct ast_bridge *bridge = joining->bridge;
521 struct ast_bridge_channel *other;
522 unsigned int swap_in_bridge = 0;
523 unsigned int will_be_two_party;
524
525 /*
526 * Only update the peeraccount to match if the joining channel
527 * will make it a two party bridge.
528 */
529 if (bridge->num_channels <= 2 && swap) {
531 if (other == swap) {
532 swap_in_bridge = 1;
533 break;
534 }
535 }
536 }
537 will_be_two_party = (1 == bridge->num_channels - swap_in_bridge);
538
540 if (other == swap) {
541 continue;
542 }
543 ast_assert(joining != other);
544 ast_channel_lock_both(joining->chan, other->chan);
545 channel_set_empty_accountcodes(joining->chan, other->chan);
546 if (will_be_two_party) {
547 channel_update_peeraccounts(joining->chan, other->chan);
548 }
549 ast_channel_unlock(joining->chan);
550 ast_channel_unlock(other->chan);
551 }
552}
static void channel_set_empty_accountcodes(struct ast_channel *c0, struct ast_channel *c1)
static void channel_update_peeraccounts(struct ast_channel *c0, struct ast_channel *c1)
#define ast_channel_lock_both(chan1, chan2)
Lock two channels.
Definition: channel.h:2929

References ast_assert, ast_channel_lock_both, ast_channel_unlock, AST_LIST_TRAVERSE, ast_bridge_channel::bridge, ast_bridge_channel::chan, channel_set_empty_accountcodes(), channel_update_peeraccounts(), ast_bridge::channels, ast_bridge::num_channels, and ast_bridge_channel::swap.

Referenced by ast_bridge_channel_update_accountcodes().

◆ bridge_channel_update_accountcodes_leaving()

static void bridge_channel_update_accountcodes_leaving ( struct ast_bridge_channel leaving)
static

Definition at line 563 of file bridge_channel.c.

564{
565 struct ast_bridge *bridge = leaving->bridge;
567 struct ast_bridge_channel *second;
568
569 if (bridge->num_channels != 2 || bridge->dissolved) {
570 return;
571 }
572
574 second = AST_LIST_LAST(&bridge->channels);
575 ast_assert(first && first != second);
576 ast_channel_lock_both(first->chan, second->chan);
578 channel_update_peeraccounts(first->chan, second->chan);
579 ast_channel_unlock(second->chan);
581}
struct sla_ringing_trunk * first
Definition: app_sla.c:332
#define AST_LIST_LAST(head)
Returns the last entry contained in a list.
Definition: linkedlists.h:429

References ast_assert, ast_channel_lock_both, ast_channel_unlock, AST_LIST_FIRST, AST_LIST_LAST, ast_bridge_channel::bridge, ast_bridge_channel::chan, channel_set_empty_accountcodes(), channel_update_peeraccounts(), ast_bridge::channels, ast_bridge::dissolved, first, and ast_bridge::num_channels.

Referenced by ast_bridge_channel_update_accountcodes().

◆ bridge_channel_wait()

static void bridge_channel_wait ( struct ast_bridge_channel bridge_channel)
static

Definition at line 2728 of file bridge_channel.c.

2729{
2730 int ms;
2731 int outfd;
2732 struct ast_channel *chan;
2733
2734 /* Wait for data to either come from the channel or us to be signaled */
2737 } else if (bridge_channel->suspended) {
2738/* XXX ASTERISK-21271 the external party use of suspended will go away as will these references because this is the bridge channel thread */
2739 ast_debug(1, "Bridge %s: %p(%s) is going into a signal wait\n",
2743 } else {
2745 outfd = -1;
2748 &bridge_channel->alert_pipe[0], 1, NULL, &outfd, &ms);
2755 }
2761 if (chan) {
2763 } else if (ms == 0) {
2764 /* An interdigit timeout or interval expired. */
2767 } else if (-1 < outfd) {
2768 /*
2769 * Must do this after checking timeouts or may have
2770 * an infinite loop due to deferring write queue
2771 * actions while trying to match DTMF feature hooks.
2772 */
2774 }
2775 }
2777 return;
2778 }
2780}
void * ao2_object_get_lockaddr(void *obj)
Return the mutex lock address of an object.
Definition: astobj2.c:476
static void bridge_handle_trip(struct ast_bridge_channel *bridge_channel)
static int bridge_channel_next_timeout(struct ast_bridge_channel *bridge_channel)
static void bridge_channel_handle_interval(struct ast_bridge_channel *bridge_channel)
static void bridge_channel_handle_write(struct ast_bridge_channel *bridge_channel)
static void bridge_channel_handle_feature_timeout(struct ast_bridge_channel *bridge_channel)
@ BRIDGE_CHANNEL_THREAD_FRAME
@ BRIDGE_CHANNEL_THREAD_IDLE
struct ast_channel * ast_waitfor_nandfds(struct ast_channel **c, int n, int *fds, int nfds, int *exception, int *outfd, int *ms)
Waits for activity on a group of channels.
Definition: channel.c:2988
void ast_channel_set_unbridged(struct ast_channel *chan, int value)
Sets the unbridged flag and queues a NULL frame on the channel to trigger a check by bridge_channel_w...
int ast_channel_unbridged(struct ast_channel *chan)
This function will check if the bridge needs to be re-evaluated due to external changes.
#define ast_cond_wait(cond, mutex)
Definition: lock.h:205

References ast_bridge_channel::activity, ast_bridge_channel::alert_pipe, ao2_object_get_lockaddr(), ast_bridge_channel_lock, ast_bridge_channel_lock_bridge(), ast_bridge_channel_unlock, ast_bridge_unlock, ast_channel_name(), ast_channel_set_unbridged(), ast_channel_unbridged(), ast_cond_wait, ast_debug, ast_waitfor_nandfds(), ast_bridge_channel::bridge, ast_channel::bridge_channel, bridge_channel_handle_feature_timeout(), bridge_channel_handle_interval(), bridge_channel_handle_write(), bridge_channel_next_timeout(), BRIDGE_CHANNEL_STATE_WAIT, BRIDGE_CHANNEL_THREAD_FRAME, BRIDGE_CHANNEL_THREAD_IDLE, bridge_handle_trip(), bridge_reconfigured(), ast_bridge_channel::chan, ast_bridge_channel::cond, NULL, ast_bridge::reconfigured, ast_bridge_channel::state, ast_bridge_channel::suspended, and ast_bridge::uniqueid.

Referenced by bridge_channel_internal_join().

◆ bridge_channel_write_action_data()

static int bridge_channel_write_action_data ( struct ast_bridge_channel bridge_channel,
enum bridge_channel_action_type  action,
const void *  data,
size_t  datalen 
)
static

Definition at line 971 of file bridge_channel.c.

973{
974 struct ast_frame frame = {
976 .subclass.integer = action,
977 .datalen = datalen,
978 .data.ptr = (void *) data,
979 };
980
981 return bridge_channel_write_frame(bridge_channel, &frame);
982}

References AST_FRAME_BRIDGE_ACTION, bridge_channel_write_frame(), ast_frame::data, ast_frame::datalen, and ast_frame::frametype.

Referenced by ast_bridge_channel_write_app(), ast_bridge_channel_write_callback(), ast_bridge_channel_write_park(), ast_bridge_channel_write_playfile(), and bridge_channel_write_dtmf_stream().

◆ bridge_channel_write_dtmf_stream()

static int bridge_channel_write_dtmf_stream ( struct ast_bridge_channel bridge_channel,
const char *  dtmf 
)
static

Definition at line 1594 of file bridge_channel.c.

1595{
1596 return bridge_channel_write_action_data(bridge_channel,
1597 BRIDGE_CHANNEL_ACTION_DTMF_STREAM, dtmf, strlen(dtmf) + 1);
1598}

References BRIDGE_CHANNEL_ACTION_DTMF_STREAM, and bridge_channel_write_action_data().

Referenced by ast_bridge_channel_feature_digit().

◆ bridge_channel_write_frame()

static int bridge_channel_write_frame ( struct ast_bridge_channel bridge_channel,
struct ast_frame frame 
)
static

Definition at line 637 of file bridge_channel.c.

638{
639 const struct ast_control_t38_parameters *t38_parameters;
640 int unmapped_stream_num;
641 int deferred;
642
644
645 ast_bridge_channel_lock_bridge(bridge_channel);
646
647 /*
648 * Map the frame to the bridge.
649 * We need to lock the bridge_channel to make sure that bridge_channel->chan
650 * isn't NULL and keep it locked while we do multistream processing.
651 */
652 ast_bridge_channel_lock(bridge_channel);
653 if (bridge_channel->chan && ast_channel_is_multistream(bridge_channel->chan)) {
654 unmapped_stream_num = frame->stream_num;
655 switch (frame->frametype) {
656 case AST_FRAME_VOICE:
657 case AST_FRAME_VIDEO:
658 case AST_FRAME_TEXT:
659 case AST_FRAME_IMAGE:
660 case AST_FRAME_RTCP:
661 /* These frames need to be mapped to an appropriate write stream */
662 if (frame->stream_num < 0) {
663 /* Map to default stream */
664 frame->stream_num = -1;
665 break;
666 }
667 if (frame->stream_num < (int)AST_VECTOR_SIZE(&bridge_channel->stream_map.to_bridge)) {
668 frame->stream_num = AST_VECTOR_GET(
669 &bridge_channel->stream_map.to_bridge, frame->stream_num);
670 if (0 <= frame->stream_num) {
671 break;
672 }
673 }
674 ast_bridge_channel_unlock(bridge_channel);
675 ast_bridge_unlock(bridge_channel->bridge);
676 /*
677 * Ignore frame because we don't know how to map the frame
678 * or the bridge is not expecting any media from that
679 * stream.
680 */
681 return 0;
684 /*
685 * XXX It makes sense that DTMF could be on any audio stream.
686 * For now we will only put it on the default audio stream.
687 */
688 default:
689 frame->stream_num = -1;
690 break;
691 }
692 } else {
693 unmapped_stream_num = -1;
694 frame->stream_num = -1;
695 }
696 ast_bridge_channel_unlock(bridge_channel);
697
698 deferred = bridge_channel->bridge->technology->write(bridge_channel->bridge, bridge_channel, frame);
699 if (deferred) {
700 struct ast_frame *dup;
701
702 dup = ast_frdup(frame);
703 if (dup) {
704 /*
705 * We have to unmap the deferred frame so it comes back
706 * in like a new frame.
707 */
708 dup->stream_num = unmapped_stream_num;
709 ast_bridge_channel_lock(bridge_channel);
710 AST_LIST_INSERT_HEAD(&bridge_channel->deferred_queue, dup, frame_list);
711 ast_bridge_channel_unlock(bridge_channel);
712 }
713 }
714
715 /* Remember any owed events to the bridge. */
716 switch (frame->frametype) {
718 bridge_channel->owed.dtmf_tv = ast_tvnow();
719 bridge_channel->owed.dtmf_digit = frame->subclass.integer;
720 break;
722 bridge_channel->owed.dtmf_digit = '\0';
723 break;
725 /*
726 * We explicitly will not remember HOLD/UNHOLD frames because
727 * things like attended transfers will handle them.
728 */
729 switch (frame->subclass.integer) {
731 t38_parameters = frame->data.ptr;
732 switch (t38_parameters->request_response) {
735 bridge_channel->owed.t38_terminate = 1;
736 break;
739 case AST_T38_REFUSED:
740 bridge_channel->owed.t38_terminate = 0;
741 break;
742 default:
743 break;
744 }
745 break;
746 default:
747 break;
748 }
749 break;
750 default:
751 break;
752 }
753 ast_bridge_unlock(bridge_channel->bridge);
754
755 /*
756 * Claim successful write to bridge. If deferred frame
757 * support is added, claim successfully deferred.
758 */
759 return 0;
760}
int ast_channel_is_multistream(struct ast_channel *chan)
Determine if a channel is multi-stream capable.
@ AST_T38_REFUSED
@ AST_T38_REQUEST_TERMINATE
@ AST_T38_NEGOTIATED
@ AST_T38_REQUEST_NEGOTIATE
#define AST_LIST_INSERT_HEAD(head, elm, field)
Inserts a list entry at the head of a list.
Definition: linkedlists.h:711

References ast_assert, ast_bridge_channel_lock, ast_bridge_channel_lock_bridge(), ast_bridge_channel_unlock, ast_bridge_unlock, ast_channel_is_multistream(), AST_CONTROL_T38_PARAMETERS, AST_FRAME_BRIDGE_ACTION_SYNC, AST_FRAME_CONTROL, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, AST_FRAME_IMAGE, AST_FRAME_RTCP, AST_FRAME_TEXT, AST_FRAME_VIDEO, AST_FRAME_VOICE, ast_frdup, AST_LIST_INSERT_HEAD, AST_T38_NEGOTIATED, AST_T38_REFUSED, AST_T38_REQUEST_NEGOTIATE, AST_T38_REQUEST_TERMINATE, AST_T38_TERMINATED, ast_tvnow(), AST_VECTOR_GET, AST_VECTOR_SIZE, ast_bridge_channel::bridge, ast_bridge_channel::chan, ast_frame::data, ast_bridge_channel::deferred_queue, ast_bridge_channel::dtmf_digit, ast_bridge_channel::dtmf_tv, ast_frame::frametype, ast_frame_subclass::integer, ast_bridge_channel::owed, ast_frame::ptr, ast_control_t38_parameters::request_response, ast_bridge_channel::stream_map, ast_frame::stream_num, ast_frame::subclass, ast_bridge_channel::t38_terminate, ast_bridge::technology, ast_bridge_channel::to_bridge, and ast_bridge_technology::write.

Referenced by ast_bridge_channel_write_control_data(), bridge_channel_write_action_data(), and bridge_handle_trip().

◆ bridge_frame_free()

static void bridge_frame_free ( struct ast_frame frame)
static

Definition at line 984 of file bridge_channel.c.

985{
987 struct sync_payload *sync_payload = frame->data.ptr;
988 struct bridge_sync *sync;
989
992 if (sync->id == sync_payload->id) {
993 break;
994 }
995 }
996 if (sync) {
997 bridge_sync_signal(sync);
998 }
1000 }
1001
1002 ast_frfree(frame);
1003}
static void bridge_sync_signal(struct bridge_sync *sync_struct)
Signal that waiting for a synchronous bridge action is no longer necessary.
#define AST_RWLIST_RDLOCK(head)
Read locks a list.
Definition: linkedlists.h:78
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:151
#define AST_RWLIST_TRAVERSE
Definition: linkedlists.h:494
struct bridge_sync::@314 list
unsigned int id
List holding active synchronous action objects.

References AST_FRAME_BRIDGE_ACTION_SYNC, ast_frfree, AST_RWLIST_RDLOCK, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, bridge_sync_signal(), ast_frame::data, ast_frame::frametype, sync_payload::id, bridge_sync::id, bridge_sync::list, and ast_frame::ptr.

Referenced by ast_bridge_channel_queue_frame(), bridge_channel_destroy(), bridge_channel_handle_write(), bridge_handle_dtmf(), and bridge_handle_trip().

◆ bridge_handle_dtmf()

static struct ast_frame * bridge_handle_dtmf ( struct ast_bridge_channel bridge_channel,
struct ast_frame frame 
)
static

Definition at line 2470 of file bridge_channel.c.

2471{
2472 struct ast_bridge_features *features = bridge_channel->features;
2473 struct ast_bridge_hook_dtmf *hook = NULL;
2474 char dtmf[2];
2475
2476 /*
2477 * See if we are already matching a DTMF feature hook sequence or
2478 * if this DTMF matches the beginning of any DTMF feature hooks.
2479 */
2480 dtmf[0] = frame->subclass.integer;
2481 dtmf[1] = '\0';
2482 if (bridge_channel->dtmf_hook_state.collected[0]
2483 || (hook = ao2_find(features->dtmf_hooks, dtmf, OBJ_SEARCH_PARTIAL_KEY))) {
2484 enum ast_frame_type frametype = frame->frametype;
2485
2486 bridge_frame_free(frame);
2487 frame = NULL;
2488
2489 ao2_cleanup(hook);
2490
2491 switch (frametype) {
2493 /* Just eat the frame. */
2494 break;
2495 case AST_FRAME_DTMF_END:
2496 ast_bridge_channel_feature_digit(bridge_channel, dtmf[0]);
2497 break;
2498 default:
2499 /* Unexpected frame type. */
2500 ast_assert(0);
2501 break;
2502 }
2503#ifdef TEST_FRAMEWORK
2504 } else if (frame->frametype == AST_FRAME_DTMF_END) {
2505 /* Only transmit this event on DTMF end or else every DTMF
2506 * press will result in the event being broadcast twice
2507 */
2508 ast_test_suite_event_notify("FEATURE_DETECTION", "Result: fail");
2509#endif
2510 }
2511
2512 return frame;
2513}
ast_frame_type
Frame types.

References ao2_cleanup, ao2_find, ast_assert, ast_bridge_channel_feature_digit(), AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, ast_test_suite_event_notify, bridge_frame_free(), ast_bridge_channel::collected, ast_bridge_hook_dtmf::dtmf, ast_bridge_channel::dtmf_hook_state, ast_bridge_features::dtmf_hooks, ast_bridge_channel::features, ast_frame::frametype, ast_frame_subclass::integer, NULL, OBJ_SEARCH_PARTIAL_KEY, and ast_frame::subclass.

Referenced by bridge_handle_trip().

◆ bridge_handle_trip()

static void bridge_handle_trip ( struct ast_bridge_channel bridge_channel)
static

Definition at line 2530 of file bridge_channel.c.

2531{
2532 struct ast_frame *frame;
2533 int blocked;
2534
2535 if (!ast_strlen_zero(ast_channel_call_forward(bridge_channel->chan))) {
2536 /* TODO If early bridging is ever used by anything other than ARI,
2537 * it's important that we actually attempt to handle the call forward
2538 * attempt, as well as expand features on a bridge channel to allow/disallow
2539 * call forwarding. For now, all we do is raise an event, showing that
2540 * a call forward is being attempted.
2541 */
2542 ast_channel_publish_dial_forward(NULL, bridge_channel->chan, NULL, NULL, "CANCEL",
2543 ast_channel_call_forward(bridge_channel->chan));
2544 }
2545
2546 if (bridge_channel->features->mute) {
2547 frame = ast_read_stream_noaudio(bridge_channel->chan);
2548 } else {
2549 frame = ast_read_stream(bridge_channel->chan);
2550 }
2551
2552 if (!frame) {
2553 ast_bridge_channel_kick(bridge_channel, 0);
2554 return;
2555 }
2556
2557 if (!ast_channel_is_multistream(bridge_channel->chan)) {
2558 /* This may not be initialized by non-multistream channel drivers */
2559 frame->stream_num = -1;
2560 }
2561
2562 switch (frame->frametype) {
2563 case AST_FRAME_CONTROL:
2564 switch (frame->subclass.integer) {
2566 case AST_CONTROL_BUSY:
2567 ast_channel_publish_dial(NULL, bridge_channel->chan, NULL, controls[frame->subclass.integer]);
2568 break;
2569 case AST_CONTROL_HANGUP:
2570 ast_bridge_channel_kick(bridge_channel, 0);
2571 bridge_frame_free(frame);
2572 return;
2576 case AST_CONTROL_ANSWER:
2577 ast_channel_publish_dial(NULL, bridge_channel->chan, NULL, controls[frame->subclass.integer]);
2578 break;
2580 ast_bridge_channel_lock_bridge(bridge_channel);
2581 blocked = bridge_channel->bridge->technology->stream_topology_request_change
2583 bridge_channel->bridge, bridge_channel);
2584 ast_bridge_unlock(bridge_channel->bridge);
2585 if (blocked) {
2586 /*
2587 * Topology change was intercepted by the bridge technology
2588 * so drop frame.
2589 */
2590 bridge_frame_free(frame);
2591 return;
2592 }
2593 break;
2595 /*
2596 * If a stream topology has changed then the bridge_channel's
2597 * media mapping needs to be updated.
2598 */
2599 ast_bridge_channel_lock_bridge(bridge_channel);
2600 if (bridge_channel->bridge->technology->stream_topology_changed) {
2601 bridge_channel->bridge->technology->stream_topology_changed(
2602 bridge_channel->bridge, bridge_channel);
2603 } else {
2604 ast_bridge_channel_stream_map(bridge_channel);
2605 }
2606 ast_bridge_unlock(bridge_channel->bridge);
2607 break;
2608 default:
2609 break;
2610 }
2611 break;
2613 case AST_FRAME_DTMF_END:
2614 frame = bridge_handle_dtmf(bridge_channel, frame);
2615 if (!frame) {
2616 return;
2617 }
2618 if (!bridge_channel->features->dtmf_passthrough) {
2619 bridge_frame_free(frame);
2620 return;
2621 }
2622 break;
2623 default:
2624 break;
2625 }
2626
2627 /* Simply write the frame out to the bridge technology. */
2628 bridge_channel_write_frame(bridge_channel, frame);
2629 bridge_frame_free(frame);
2630}
static struct ast_frame * bridge_handle_dtmf(struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
static const char * controls[]
void ast_bridge_channel_stream_map(struct ast_bridge_channel *bridge_channel)
Maps a channel's stream topology to and from the bridge.
struct ast_frame * ast_read_stream(struct ast_channel *chan)
Reads a frame, but does not filter to just the default streams.
Definition: channel.c:4262
struct ast_frame * ast_read_stream_noaudio(struct ast_channel *chan)
Reads a frame, but does not filter to just the default streams, returning AST_FRAME_NULL frame if aud...
Definition: channel.c:4272
const char * ast_channel_call_forward(const struct ast_channel *chan)
void ast_channel_publish_dial(struct ast_channel *caller, struct ast_channel *peer, const char *dialstring, const char *dialstatus)
Publish in the ast_channel_topic or ast_channel_topic_all topics a stasis message for the channels in...
void ast_channel_publish_dial_forward(struct ast_channel *caller, struct ast_channel *peer, struct ast_channel *forwarded, const char *dialstring, const char *dialstatus, const char *forward)
Publish in the ast_channel_topic or ast_channel_topic_all topics a stasis message for the channels in...
@ AST_CONTROL_PROGRESS
@ AST_CONTROL_BUSY
@ AST_CONTROL_STREAM_TOPOLOGY_REQUEST_CHANGE
@ AST_CONTROL_PROCEEDING
@ AST_CONTROL_CONGESTION
@ AST_CONTROL_RINGING
@ AST_CONTROL_HANGUP
int(* stream_topology_request_change)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
Callback for when a request has been made to change a stream topology on a channel.
void(* stream_topology_changed)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
Callback for when a stream topology changes on the channel.

References ast_bridge_channel_kick(), ast_bridge_channel_lock_bridge(), ast_bridge_channel_stream_map(), ast_bridge_unlock, ast_channel_call_forward(), ast_channel_is_multistream(), ast_channel_publish_dial(), ast_channel_publish_dial_forward(), AST_CONTROL_ANSWER, AST_CONTROL_BUSY, AST_CONTROL_CONGESTION, AST_CONTROL_HANGUP, AST_CONTROL_PROCEEDING, AST_CONTROL_PROGRESS, AST_CONTROL_RINGING, AST_CONTROL_STREAM_TOPOLOGY_CHANGED, AST_CONTROL_STREAM_TOPOLOGY_REQUEST_CHANGE, AST_FRAME_CONTROL, AST_FRAME_DTMF_BEGIN, AST_FRAME_DTMF_END, ast_read_stream(), ast_read_stream_noaudio(), ast_strlen_zero(), ast_bridge_channel::bridge, bridge_channel_write_frame(), bridge_frame_free(), bridge_handle_dtmf(), ast_bridge_channel::chan, controls, ast_bridge_features::dtmf_passthrough, ast_bridge_channel::features, ast_frame::frametype, ast_frame_subclass::integer, ast_bridge_features::mute, NULL, ast_frame::stream_num, ast_bridge_technology::stream_topology_changed, ast_bridge_technology::stream_topology_request_change, ast_frame::subclass, and ast_bridge::technology.

Referenced by bridge_channel_wait().

◆ bridge_sync_cleanup()

static void bridge_sync_cleanup ( struct bridge_sync sync_struct)
static

Clean up a synchronization bridge object.

This frees fields within the synchronization object and removes it from the list of active synchronization objects.

Since synchronization objects are stack-allocated, it is vital that this is called before the synchronization object goes out of scope.

Parameters
sync_structSynchronization object to clean up.

Definition at line 148 of file bridge_channel.c.

149{
150 struct bridge_sync *iter;
151
154 if (iter->id == sync_struct->id) {
156 break;
157 }
158 }
161
162 ast_sem_destroy(&sync_struct->sem);
163}
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:52
int ast_sem_destroy(struct ast_sem *sem)
Destroy a semaphore.
struct ast_sem sem

References AST_LIST_REMOVE_CURRENT, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_sem_destroy(), bridge_sync::id, bridge_sync::list, and bridge_sync::sem.

Referenced by bridge_channel_queue_action_data_sync().

◆ bridge_sync_init()

static void bridge_sync_init ( struct bridge_sync sync_struct,
unsigned int  id 
)
static

Initialize a synchronous bridge object.

This both initializes the structure and adds it to the list of synchronization structures.

Parameters
sync_structThe synchronization object to initialize.
idID to assign to the synchronization object.

Definition at line 125 of file bridge_channel.c.

126{
127 memset(sync_struct, 0, sizeof(*sync_struct));
128 sync_struct->id = id;
129 ast_sem_init(&sync_struct->sem, 0, 0);
130
132 AST_RWLIST_INSERT_TAIL(&sync_structs, sync_struct, list);
134}
enum queue_result id
Definition: app_queue.c:1638
#define AST_RWLIST_INSERT_TAIL
Definition: linkedlists.h:741
int ast_sem_init(struct ast_sem *sem, int pshared, unsigned int value)
Initialize a semaphore.

References AST_RWLIST_INSERT_TAIL, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_sem_init(), id, bridge_sync::id, and bridge_sync::sem.

Referenced by bridge_channel_queue_action_data_sync().

◆ bridge_sync_signal()

static void bridge_sync_signal ( struct bridge_sync sync_struct)
static

Signal that waiting for a synchronous bridge action is no longer necessary.

This may occur for several reasons

  • The synchronous bridge action has completed.
  • The bridge channel has been removed from the bridge.
  • The synchronous bridge action could not be queued.
Parameters
sync_structSynchronization object corresponding to the bridge action.

Definition at line 207 of file bridge_channel.c.

208{
209 ast_sem_post(&sync_struct->sem);
210}
int ast_sem_post(struct ast_sem *sem)
Increments the semaphore, unblocking a waiter if necessary.

References ast_sem_post(), and bridge_sync::sem.

Referenced by bridge_frame_free().

◆ bridge_sync_wait()

static void bridge_sync_wait ( struct bridge_sync sync_struct)
static

Wait for a synchronous bridge action to complete.

Parameters
sync_structSynchronization object corresponding to the bridge action.

Definition at line 186 of file bridge_channel.c.

187{
188 struct timeval timeout_val = ast_tvadd(ast_tvnow(), ast_samp2tv(PLAYBACK_TIMEOUT, 1000));
189 struct timespec timeout_spec = {
190 .tv_sec = timeout_val.tv_sec,
191 .tv_nsec = timeout_val.tv_usec * 1000,
192 };
193
194 ast_sem_timedwait(&sync_struct->sem, &timeout_spec);
195}
#define PLAYBACK_TIMEOUT
Failsafe for synchronous bridge action waiting.
int ast_sem_timedwait(struct ast_sem *sem, const struct timespec *abs_timeout)
Decrements the semaphore, waiting until abs_timeout.

References ast_samp2tv(), ast_sem_timedwait(), ast_tvadd(), ast_tvnow(), PLAYBACK_TIMEOUT, and bridge_sync::sem.

Referenced by bridge_channel_queue_action_data_sync().

◆ channel_fill_empty_accountcode()

static void channel_fill_empty_accountcode ( struct ast_channel dest,
struct ast_channel src 
)
static

Definition at line 440 of file bridge_channel.c.

441{
444 ast_debug(1, "Setting channel %s accountcode with channel %s peeraccount '%s'.\n",
445 ast_channel_name(dest),
447 ast_channel_accountcode_set(dest, ast_channel_peeraccount(src));
448 }
449}
const char * ast_channel_accountcode(const struct ast_channel *chan)
const char * ast_channel_peeraccount(const struct ast_channel *chan)

References ast_channel_accountcode(), ast_channel_name(), ast_channel_peeraccount(), ast_debug, and ast_strlen_zero().

Referenced by channel_set_empty_accountcodes().

◆ channel_fill_empty_peeraccount()

static void channel_fill_empty_peeraccount ( struct ast_channel dest,
struct ast_channel src 
)
static

Definition at line 419 of file bridge_channel.c.

420{
423 ast_debug(1, "Setting channel %s peeraccount with channel %s accountcode '%s'.\n",
424 ast_channel_name(dest),
426 ast_channel_peeraccount_set(dest, ast_channel_accountcode(src));
427 }
428}

References ast_channel_accountcode(), ast_channel_name(), ast_channel_peeraccount(), ast_debug, and ast_strlen_zero().

Referenced by channel_set_empty_accountcodes().

◆ channel_set_cause()

static int channel_set_cause ( struct ast_channel chan,
int  cause 
)
static

Definition at line 279 of file bridge_channel.c.

280{
281 ast_channel_lock(chan);
282 if (cause <= 0) {
283 cause = ast_channel_hangupcause(chan);
284 if (cause <= 0) {
286 }
287 }
288 ast_channel_hangupcause_set(chan, cause);
289 ast_channel_unlock(chan);
290 return cause;
291}
void ast_channel_hangupcause_set(struct ast_channel *chan, int value)

References AST_CAUSE_NORMAL_CLEARING, ast_channel_hangupcause(), ast_channel_hangupcause_set(), ast_channel_lock, and ast_channel_unlock.

Referenced by ast_bridge_channel_kick(), and ast_bridge_channel_leave_bridge_nolock().

◆ channel_set_empty_accountcodes()

static void channel_set_empty_accountcodes ( struct ast_channel c0,
struct ast_channel c1 
)
static

Definition at line 461 of file bridge_channel.c.

462{
463 /* Set empty peeraccount from the other channel's accountcode. */
466
467 /* Set empty accountcode from the other channel's peeraccount. */
470}
static void channel_fill_empty_peeraccount(struct ast_channel *dest, struct ast_channel *src)
static void channel_fill_empty_accountcode(struct ast_channel *dest, struct ast_channel *src)

References channel_fill_empty_accountcode(), and channel_fill_empty_peeraccount().

Referenced by bridge_channel_update_accountcodes_joining(), and bridge_channel_update_accountcodes_leaving().

◆ channel_update_peeraccount()

static void channel_update_peeraccount ( struct ast_channel dest,
struct ast_channel src 
)
static

Definition at line 482 of file bridge_channel.c.

483{
484 if (strcmp(ast_channel_accountcode(src), ast_channel_peeraccount(dest))) {
485 ast_debug(1, "Changing channel %s peeraccount '%s' to match channel %s accountcode '%s'.\n",
488 ast_channel_peeraccount_set(dest, ast_channel_accountcode(src));
489 }
490}

References ast_channel_accountcode(), ast_channel_name(), ast_channel_peeraccount(), and ast_debug.

Referenced by channel_update_peeraccounts().

◆ channel_update_peeraccounts()

static void channel_update_peeraccounts ( struct ast_channel c0,
struct ast_channel c1 
)
static

Definition at line 502 of file bridge_channel.c.

503{
506}
static void channel_update_peeraccount(struct ast_channel *dest, struct ast_channel *src)

References channel_update_peeraccount().

Referenced by bridge_channel_update_accountcodes_joining(), and bridge_channel_update_accountcodes_leaving().

◆ payload_helper_app()

static int payload_helper_app ( ast_bridge_channel_post_action_data  post_it,
struct ast_bridge_channel bridge_channel,
const char *  app_name,
const char *  app_args,
const char *  moh_class 
)
static

Definition at line 1226 of file bridge_channel.c.

1228{
1229 struct bridge_run_app *app_data;
1230 size_t len_name = strlen(app_name) + 1;
1231 size_t len_args = ast_strlen_zero(app_args) ? 0 : strlen(app_args) + 1;
1232 size_t len_moh = !moh_class ? 0 : strlen(moh_class) + 1;
1233 size_t len_data = sizeof(*app_data) + len_name + len_args + len_moh;
1234
1235 /* Fill in application run frame data. */
1236 app_data = alloca(len_data);
1237 app_data->app_args_offset = len_args ? len_name : 0;
1238 app_data->moh_offset = len_moh ? len_name + len_args : 0;
1239 strcpy(app_data->app_name, app_name);/* Safe */
1240 if (len_args) {
1241 strcpy(&app_data->app_name[app_data->app_args_offset], app_args);/* Safe */
1242 }
1243 if (moh_class) {
1244 strcpy(&app_data->app_name[app_data->moh_offset], moh_class);/* Safe */
1245 }
1246
1247 return post_it(bridge_channel, BRIDGE_CHANNEL_ACTION_RUN_APP, app_data, len_data);
1248}

References app_name(), ast_strlen_zero(), and BRIDGE_CHANNEL_ACTION_RUN_APP.

Referenced by ast_bridge_channel_queue_app(), and ast_bridge_channel_write_app().

◆ payload_helper_cb()

static int payload_helper_cb ( ast_bridge_channel_post_action_data  post_it,
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 
)
static

Definition at line 1394 of file bridge_channel.c.

1398{
1399 struct bridge_custom_callback *cb_data;
1400 size_t len_data = sizeof(*cb_data) + (payload ? payload_size : 0);
1401
1402 /* Sanity check. */
1403 if (!callback) {
1404 ast_assert(0);
1405 return -1;
1406 }
1407
1408 /* Fill in custom callback frame data. */
1409 cb_data = alloca(len_data);
1410 cb_data->callback = callback;
1411 cb_data->payload_size = payload_size;
1412 cb_data->flags = flags;
1413 cb_data->payload_exists = payload && payload_size;
1414 if (cb_data->payload_exists) {
1415 memcpy(cb_data->payload, payload, payload_size);/* Safe */
1416 }
1417
1418 return post_it(bridge_channel, BRIDGE_CHANNEL_ACTION_CALLBACK, cb_data, len_data);
1419}

References ast_assert, BRIDGE_CHANNEL_ACTION_CALLBACK, bridge_custom_callback::callback, bridge_custom_callback::flags, bridge_custom_callback::payload, bridge_custom_callback::payload_exists, and bridge_custom_callback::payload_size.

Referenced by ast_bridge_channel_queue_callback(), and ast_bridge_channel_write_callback().

◆ payload_helper_park()

static int payload_helper_park ( ast_bridge_channel_post_action_data  post_it,
struct ast_bridge_channel bridge_channel,
const char *  parkee_uuid,
const char *  parker_uuid,
const char *  app_data 
)
static

Definition at line 1468 of file bridge_channel.c.

1473{
1474 struct bridge_park *payload;
1475 size_t len_parkee_uuid = strlen(parkee_uuid) + 1;
1476 size_t len_parker_uuid = strlen(parker_uuid) + 1;
1477 size_t len_app_data = !app_data ? 0 : strlen(app_data) + 1;
1478 size_t len_payload = sizeof(*payload) + len_parker_uuid + len_parkee_uuid + len_app_data;
1479
1480 payload = alloca(len_payload);
1481 payload->app_data_offset = len_app_data ? len_parkee_uuid + len_parker_uuid : 0;
1482 payload->parker_uuid_offset = len_parkee_uuid;
1483 strcpy(payload->parkee_uuid, parkee_uuid);
1484 strcpy(&payload->parkee_uuid[payload->parker_uuid_offset], parker_uuid);
1485 if (app_data) {
1486 strcpy(&payload->parkee_uuid[payload->app_data_offset], app_data);
1487 }
1488
1489 return post_it(bridge_channel, BRIDGE_CHANNEL_ACTION_PARK, payload, len_payload);
1490}

References bridge_park::app_data_offset, BRIDGE_CHANNEL_ACTION_PARK, bridge_park::parkee_uuid, and bridge_park::parker_uuid_offset.

Referenced by ast_bridge_channel_write_park().

◆ payload_helper_playfile()

static int payload_helper_playfile ( ast_bridge_channel_post_action_data  post_it,
struct ast_bridge_channel bridge_channel,
ast_bridge_custom_play_fn  custom_play,
const char *  playfile,
const char *  moh_class 
)
static

Definition at line 1317 of file bridge_channel.c.

1319{
1320 struct bridge_playfile *payload;
1321 size_t len_name = strlen(playfile) + 1;
1322 size_t len_moh = !moh_class ? 0 : strlen(moh_class) + 1;
1323 size_t len_payload = sizeof(*payload) + len_name + len_moh;
1324
1325 /* Fill in play file frame data. */
1326 payload = ast_alloca(len_payload);
1327 payload->custom_play = custom_play;
1328 payload->moh_offset = len_moh ? len_name : 0;
1329 strcpy(payload->playfile, playfile);/* Safe */
1330 if (moh_class) {
1331 strcpy(&payload->playfile[payload->moh_offset], moh_class);/* Safe */
1332 }
1333
1334 return post_it(bridge_channel, BRIDGE_CHANNEL_ACTION_PLAY_FILE, payload, len_payload);
1335}

References ast_alloca, BRIDGE_CHANNEL_ACTION_PLAY_FILE, bridge_playfile::custom_play, bridge_playfile::moh_offset, and bridge_playfile::playfile.

Referenced by ast_bridge_channel_queue_playfile(), ast_bridge_channel_queue_playfile_sync(), and ast_bridge_channel_write_playfile().

◆ run_app_helper()

static int run_app_helper ( struct ast_channel chan,
const char *  app_name,
const char *  app_args 
)
static

Definition at line 1172 of file bridge_channel.c.

1173{
1174 int res = 0;
1175
1176 if (!strcasecmp("Gosub", app_name)) {
1177 ast_app_exec_sub(NULL, chan, app_args, 0);
1178 } else {
1179 res = ast_pbx_exec_application(chan, app_name, app_args);
1180 }
1181 return res;
1182}
int ast_app_exec_sub(struct ast_channel *autoservice_chan, struct ast_channel *sub_chan, const char *sub_args, int ignore_hangup)
Run a subroutine on a channel, placing an optional second channel into autoservice.
Definition: main/app.c:297
int ast_pbx_exec_application(struct ast_channel *chan, const char *app_name, const char *app_args)
Execute an application.
Definition: pbx_app.c:501

References app_name(), ast_app_exec_sub(), ast_pbx_exec_application(), and NULL.

Referenced by ast_bridge_channel_run_app().

◆ sendtext_safe()

static void sendtext_safe ( struct ast_channel chan,
const struct ast_frame f 
)
static

Definition at line 2330 of file bridge_channel.c.

2331{
2332 if (f->datalen) {
2333 char *text = f->data.ptr;
2334
2335 if (text[f->datalen - 1]) {
2336 /* Not zero terminated, we need to allocate */
2338 if (!text) {
2339 return;
2340 }
2341 }
2342
2343 ast_sendtext(chan, text);
2344
2345 if (text != f->data.ptr) {
2346 /* Only free if we allocated */
2347 ast_free(text);
2348 }
2349 } else {
2350 /* Special case if the frame length is zero (although I
2351 * am not sure this is possible?) */
2352 ast_sendtext(chan, "");
2353 }
2354}
char * text
Definition: app_queue.c:1639
#define ast_free(a)
Definition: astmm.h:180
#define ast_strndup(str, len)
A wrapper for strndup()
Definition: astmm.h:256
int ast_sendtext(struct ast_channel *chan, const char *text)
Sends text to a channel.
Definition: channel.c:4809

References ast_free, ast_sendtext(), ast_strndup, ast_frame::data, ast_frame::datalen, ast_frame::ptr, and text.

Referenced by bridge_channel_handle_write().

◆ testsuite_notify_feature_success()

static void testsuite_notify_feature_success ( struct ast_channel chan,
const char *  dtmf 
)
static

Definition at line 1610 of file bridge_channel.c.

1611{
1612#ifdef TEST_FRAMEWORK
1613 char *feature = "unknown";
1614 struct ast_featuremap_config *featuremap;
1615 struct ast_features_xfer_config *xfer;
1616
1617 ast_channel_lock(chan);
1618 featuremap = ast_get_chan_featuremap_config(chan);
1620 ast_channel_unlock(chan);
1621
1622 if (featuremap) {
1623 if (!strcmp(dtmf, featuremap->blindxfer)) {
1624 feature = "blindxfer";
1625 } else if (!strcmp(dtmf, featuremap->atxfer)) {
1626 feature = "atxfer";
1627 } else if (!strcmp(dtmf, featuremap->disconnect)) {
1628 feature = "disconnect";
1629 } else if (!strcmp(dtmf, featuremap->automixmon)) {
1630 feature = "automixmon";
1631 } else if (!strcmp(dtmf, featuremap->parkcall)) {
1632 feature = "parkcall";
1633 }
1634 }
1635 if (xfer) {
1636 if (!strcmp(dtmf, xfer->atxferthreeway)) {
1637 feature = "atxferthreeway";
1638 }
1639 }
1640
1641 ao2_cleanup(featuremap);
1642 ao2_cleanup(xfer);
1643
1644 ast_test_suite_event_notify("FEATURE_DETECTION",
1645 "Result: success\r\n"
1646 "Feature: %s", feature);
1647#endif /* TEST_FRAMEWORK */
1648}
struct ast_featuremap_config * ast_get_chan_featuremap_config(struct ast_channel *chan)
Get the featuremap configuration options for a channel.
struct ast_features_xfer_config * ast_get_chan_features_xfer_config(struct ast_channel *chan)
Get the transfer configuration options for a channel.
Configuration for the builtin features.
Feature configuration relating to transfers.

References ao2_cleanup, ast_channel_lock, ast_channel_unlock, ast_get_chan_featuremap_config(), ast_get_chan_features_xfer_config(), ast_test_suite_event_notify, ast_featuremap_config::atxfer, ast_features_xfer_config::atxferthreeway, ast_featuremap_config::automixmon, ast_featuremap_config::blindxfer, ast_featuremap_config::disconnect, and ast_featuremap_config::parkcall.

Referenced by ast_bridge_channel_feature_digit().

Variable Documentation

◆ controls

const char* controls[]
static

Definition at line 2515 of file bridge_channel.c.

Referenced by bridge_handle_trip().

◆ sync_ids

int sync_ids
static

Counter used for assigning synchronous bridge action IDs.

Definition at line 79 of file bridge_channel.c.

Referenced by bridge_channel_queue_action_data_sync().

◆ sync_structs

struct sync_structs sync_structs = { .first = NULL, .last = NULL, .lock = { PTHREAD_RWLOCK_INITIALIZER , NULL, {1, 0} } , }
static