Asterisk - The Open Source Telephony Project  18.5.0
Data Structures | Macros | Typedefs | Enumerations | Functions
bridge_channel.h File Reference
#include "asterisk/bridge_features.h"
#include "asterisk/bridge_technology.h"
Include dependency graph for bridge_channel.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

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

Macros

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

Typedefs

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

Enumerations

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

Functions

static void _ast_bridge_channel_lock (struct ast_bridge_channel *bridge_channel, const char *file, const char *function, int line, const char *var)
 
static int _ast_bridge_channel_trylock (struct ast_bridge_channel *bridge_channel, const char *file, const char *function, int line, const char *var)
 
static void _ast_bridge_channel_unlock (struct ast_bridge_channel *bridge_channel, const char *file, const char *function, int line, const char *var)
 
void ast_bridge_channel_feature_digit (struct ast_bridge_channel *bridge_channel, int digit)
 Add a DTMF digit to the collected digits to match against DTMF features. 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...
 

Macro Definition Documentation

◆ ast_bridge_channel_lock

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

◆ ast_bridge_channel_trylock

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

Try locking the bridge_channel.

Parameters
bridge_channelWhat to try locking
Return values
0on success.
non-zeroon error.

Definition at line 218 of file bridge_channel.h.

Referenced by optimize_lock_chan_stack(), and optimize_lock_peer_stack().

◆ ast_bridge_channel_unlock

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

Typedef Documentation

◆ ast_bridge_custom_callback_fn

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

Custom callback run on a bridge channel.

Parameters
bridge_channelWhich channel to operate on.
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.
Returns
Nothing

Definition at line 612 of file bridge_channel.h.

◆ ast_bridge_custom_play_fn

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

Custom interpretation of the playfile name.

Parameters
bridge_channelWhich channel to play the file on
playfileSound filename to play.
Returns
Nothing

Definition at line 524 of file bridge_channel.h.

Enumeration Type Documentation

◆ ast_bridge_channel_custom_callback_option

Enumerator
AST_BRIDGE_CHANNEL_CB_OPTION_MEDIA 

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

Definition at line 614 of file bridge_channel.h.

614  {
615  /*! The callback temporarily affects media. (Like a custom playfile.) */
617 };

◆ bridge_channel_state

State information about a bridged channel.

Enumerator
BRIDGE_CHANNEL_STATE_WAIT 

Waiting for a signal (Channel in the bridge)

BRIDGE_CHANNEL_STATE_END 

Bridged channel was forced out and should be hung up (Bridge may dissolve.)

BRIDGE_CHANNEL_STATE_END_NO_DISSOLVE 

Bridged channel was forced out. Don't dissolve the bridge regardless

Definition at line 60 of file bridge_channel.h.

60  {
61  /*! Waiting for a signal (Channel in the bridge) */
63  /*! Bridged channel was forced out and should be hung up (Bridge may dissolve.) */
65  /*! Bridged channel was forced out. Don't dissolve the bridge regardless */
67 };

◆ bridge_channel_thread_state

Enumerator
BRIDGE_CHANNEL_THREAD_IDLE 

Bridge channel thread is idle/waiting.

BRIDGE_CHANNEL_THREAD_SIMPLE 

Bridge channel thread is writing a normal/simple frame.

BRIDGE_CHANNEL_THREAD_FRAME 

Bridge channel thread is processing a frame.

Definition at line 69 of file bridge_channel.h.

69  {
70  /*! Bridge channel thread is idle/waiting. */
72  /*! Bridge channel thread is writing a normal/simple frame. */
74  /*! Bridge channel thread is processing a frame. */
76 };

Function Documentation

◆ _ast_bridge_channel_lock()

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

Definition at line 232 of file bridge_channel.h.

References __ao2_lock(), and AO2_LOCK_REQ_MUTEX.

233 {
234  __ao2_lock(bridge_channel, AO2_LOCK_REQ_MUTEX, file, function, line, var);
235 }
int __ao2_lock(void *a, enum ao2_lock_req lock_how, const char *file, const char *func, int line, const char *var)
Lock an object.
Definition: astobj2.c:222
#define var
Definition: ast_expr2f.c:614

◆ _ast_bridge_channel_trylock()

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

Definition at line 219 of file bridge_channel.h.

References __ao2_trylock(), and AO2_LOCK_REQ_MUTEX.

220 {
221  return __ao2_trylock(bridge_channel, AO2_LOCK_REQ_MUTEX, file, function, line, var);
222 }
#define var
Definition: ast_expr2f.c:614
int __ao2_trylock(void *a, enum ao2_lock_req lock_how, const char *file, const char *func, int line, const char *var)
Try locking– (don&#39;t block if fail)
Definition: astobj2.c:342

◆ _ast_bridge_channel_unlock()

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

◆ 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.
clear_digitsclear the digits array prior to calling hooks
Note
Neither the bridge nor the bridge_channel locks should be held when entering this function.
This is intended to be called by bridge hooks and the bridge channel thread.
This is intended to be called by non-DTMF bridge hooks and the bridge channel thread. Calling from a DTMF bridge hook can potentially cause unbounded recursion.
Returns
Nothing

Definition at line 1762 of file bridge_channel.c.

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

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

1763 {
1764  struct ast_bridge_features *features = bridge_channel->features;
1765  struct ast_bridge_hook_dtmf *hook = NULL;
1766  size_t dtmf_len;
1767 
1768  struct sanity_check_of_dtmf_size {
1769  char check[1 / (ARRAY_LEN(bridge_channel->dtmf_hook_state.collected) == ARRAY_LEN(hook->dtmf.code))];
1770  };
1771 
1772  dtmf_len = strlen(bridge_channel->dtmf_hook_state.collected);
1773  if (!dtmf_len && !digit) {
1774  /* Nothing to do */
1775  return;
1776  }
1777 
1778  if (digit) {
1779  dtmf_len = bridge_channel_feature_digit_add(bridge_channel, digit, dtmf_len);
1780  }
1781 
1782  while (digit) {
1783  /* See if a DTMF feature hook matches or can match */
1784  hook = ao2_find(features->dtmf_hooks, bridge_channel->dtmf_hook_state.collected,
1786  if (!hook) {
1787  ast_debug(1, "No DTMF feature hooks on %p(%s) match '%s'\n",
1788  bridge_channel, ast_channel_name(bridge_channel->chan),
1789  bridge_channel->dtmf_hook_state.collected);
1790  break;
1791  } else if (dtmf_len != strlen(hook->dtmf.code)) {
1792  unsigned int digit_timeout;
1793  /* Need more digits to match */
1794  ao2_ref(hook, -1);
1795  digit_timeout = bridge_channel_feature_digit_timeout(bridge_channel);
1796  bridge_channel->dtmf_hook_state.interdigit_timeout =
1797  ast_tvadd(ast_tvnow(), ast_samp2tv(digit_timeout, 1000));
1798  return;
1799  } else {
1800  int remove_me;
1801  int already_suspended;
1802 
1803  ast_debug(1, "DTMF feature hook %p matched DTMF string '%s' on %p(%s)\n",
1804  hook, bridge_channel->dtmf_hook_state.collected, bridge_channel,
1805  ast_channel_name(bridge_channel->chan));
1806 
1807  /*
1808  * Clear the collected digits before executing the hook
1809  * in case the hook starts another sequence.
1810  */
1811  bridge_channel->dtmf_hook_state.collected[0] = '\0';
1812 
1813  ast_bridge_channel_lock_bridge(bridge_channel);
1814  already_suspended = bridge_channel->suspended;
1815  if (!already_suspended) {
1817  }
1818  ast_bridge_unlock(bridge_channel->bridge);
1819  ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
1820 
1821  /* Execute the matched hook on this channel. */
1822  remove_me = hook->generic.callback(bridge_channel, hook->generic.hook_pvt);
1823  if (remove_me) {
1824  ast_debug(1, "DTMF hook %p is being removed from %p(%s)\n",
1825  hook, bridge_channel, ast_channel_name(bridge_channel->chan));
1826  ao2_unlink(features->dtmf_hooks, hook);
1827  }
1828  testsuite_notify_feature_success(bridge_channel->chan, hook->dtmf.code);
1829  ao2_ref(hook, -1);
1830 
1831  ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
1832  if (!already_suspended) {
1833  bridge_channel_unsuspend(bridge_channel);
1834  }
1835 
1836  /*
1837  * If we are handing the channel off to an external hook for
1838  * ownership, we are not guaranteed what kind of state it will
1839  * come back in. If the channel hungup, we need to detect that
1840  * here if the hook did not already change the state.
1841  */
1842  if (bridge_channel->chan && ast_check_hangup_locked(bridge_channel->chan)) {
1843  ast_bridge_channel_kick(bridge_channel, 0);
1844  bridge_channel->dtmf_hook_state.collected[0] = '\0';
1845  return;
1846  }
1847 
1848  /* if there is dtmf that has been collected then loop back through,
1849  but set digit to -1 so it doesn't try to do an add since the dtmf
1850  is already in the buffer */
1851  dtmf_len = strlen(bridge_channel->dtmf_hook_state.collected);
1852  if (!dtmf_len) {
1853  return;
1854  }
1855  }
1856  }
1857 
1858  if (!digit) {
1859  ast_debug(1, "DTMF feature string collection on %p(%s) timed out\n",
1860  bridge_channel, ast_channel_name(bridge_channel->chan));
1861  }
1862 
1863  /* Timeout or DTMF digit didn't allow a match with any hooks. */
1864  if (features->dtmf_passthrough) {
1865  /* Stream the collected DTMF to the other channels. */
1866  bridge_channel_write_dtmf_stream(bridge_channel,
1867  bridge_channel->dtmf_hook_state.collected);
1868  }
1869  bridge_channel->dtmf_hook_state.collected[0] = '\0';
1870 
1871  ast_test_suite_event_notify("FEATURE_DETECTION", "Result: fail");
1872 }
char digit
struct ast_bridge_channel::@233 dtmf_hook_state
struct ast_bridge_features * features
#define ARRAY_LEN(a)
Definition: isdn_lib.c:42
void bridge_channel_internal_suspend_nolock(struct ast_bridge_channel *bridge_channel)
Structure that contains features information.
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
Definition: channel.c:4322
int ast_check_hangup_locked(struct ast_channel *chan)
Definition: channel.c:459
unsigned int suspended
struct ao2_container * dtmf_hooks
struct timeval ast_tvnow(void)
Returns current timeval. Meant to replace calls to gettimeofday().
Definition: time.h:150
#define NULL
Definition: resample.c:96
char collected[MAXIMUM_DTMF_FEATURE_STRING]
struct ast_bridge * bridge
Bridge this channel is participating in.
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
The arg parameter is a partial search key similar to OBJ_SEARCH_KEY.
Definition: astobj2.h:1120
void ast_bridge_channel_kick(struct ast_bridge_channel *bridge_channel, int cause)
Kick the channel out of the bridge.
static unsigned int bridge_channel_feature_digit_timeout(struct ast_bridge_channel *bridge_channel)
#define ao2_ref(o, delta)
Definition: astobj2.h:464
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:238
struct ast_bridge_hook_dtmf_parms dtmf
struct timeval interdigit_timeout
#define ast_test_suite_event_notify(s, f,...)
Definition: test.h:196
unsigned int dtmf_passthrough
#define ao2_unlink(container, obj)
Definition: astobj2.h:1598
ast_bridge_hook_callback callback
struct timeval ast_tvadd(struct timeval a, struct timeval b)
Returns the sum of two timevals a + b.
Definition: extconf.c:2283
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition: bridge.h:493
#define ao2_find(container, arg, flags)
Definition: astobj2.h:1756
struct ast_bridge_hook generic
struct ast_channel * chan
const char * ast_channel_name(const struct ast_channel *chan)
static void testsuite_notify_feature_success(struct ast_channel *chan, const char *dtmf)
static int bridge_channel_write_dtmf_stream(struct ast_bridge_channel *bridge_channel, const char *dtmf)
void ast_bridge_channel_lock_bridge(struct ast_bridge_channel *bridge_channel)
Lock the bridge associated with the bridge channel.
char code[MAXIMUM_DTMF_FEATURE_STRING]
static void bridge_channel_unsuspend(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)

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

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

Referenced by play_file().

1755 {
1756  if (digit) {
1758  bridge_channel, digit, strlen(bridge_channel->dtmf_hook_state.collected));
1759  }
1760 }
char digit
struct ast_bridge_channel::@233 dtmf_hook_state
char collected[MAXIMUM_DTMF_FEATURE_STRING]
static int bridge_channel_feature_digit_add(struct ast_bridge_channel *bridge_channel, int digit, size_t dtmf_len)

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

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

Referenced by ast_bridge_channel_write_unhold().

212 {
213  struct ast_channel *chan;
214 
215  ao2_lock(bridge_channel);
216  chan = ao2_bump(bridge_channel->chan);
217  ao2_unlock(bridge_channel);
218 
219  return chan;
220 }
Main Channel structure associated with a channel.
#define ao2_unlock(a)
Definition: astobj2.h:730
#define ao2_bump(obj)
Definition: astobj2.h:491
#define ao2_lock(a)
Definition: astobj2.h:718
struct ast_channel * chan

◆ 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.
Returns
Nothing

Definition at line 605 of file bridge_channel.c.

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

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

606 {
607  struct ast_bridge_features *features = bridge_channel->features;
608  struct ast_bridge_hook *hook;
609  struct ao2_iterator iter;
610 
611  ast_bridge_channel_lock(bridge_channel);
612  if (bridge_channel->state == BRIDGE_CHANNEL_STATE_WAIT) {
613  channel_set_cause(bridge_channel->chan, cause);
614  cause = 0;
615  }
616  ast_bridge_channel_unlock(bridge_channel);
617 
618  /* Run any hangup hooks. */
619  iter = ao2_iterator_init(features->other_hooks, 0);
620  for (; (hook = ao2_iterator_next(&iter)); ao2_ref(hook, -1)) {
621  int remove_me;
622 
623  if (hook->type != AST_BRIDGE_HOOK_TYPE_HANGUP) {
624  continue;
625  }
626  remove_me = hook->callback(bridge_channel, hook->hook_pvt);
627  if (remove_me) {
628  ast_debug(1, "Hangup hook %p is being removed from %p(%s)\n",
629  hook, bridge_channel, ast_channel_name(bridge_channel->chan));
630  ao2_unlink(features->other_hooks, hook);
631  }
632  }
633  ao2_iterator_destroy(&iter);
634 
635  /* Default hangup action. */
637 }
struct ast_bridge_features * features
Structure that contains features information.
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).
enum bridge_channel_state state
void ao2_iterator_destroy(struct ao2_iterator *iter)
Destroy a container iterator.
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
#define ast_bridge_channel_lock(bridge_channel)
Lock the bridge_channel.
enum ast_bridge_hook_type type
static int channel_set_cause(struct ast_channel *chan, int cause)
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define ast_bridge_channel_unlock(bridge_channel)
Unlock the bridge_channel.
#define ao2_unlink(container, obj)
Definition: astobj2.h:1598
ast_bridge_hook_callback callback
#define ao2_iterator_next(iter)
Definition: astobj2.h:1933
struct ast_channel * chan
When we need to walk through a container, we use an ao2_iterator to keep track of the current positio...
Definition: astobj2.h:1841
struct ao2_container * other_hooks
const char * ast_channel_name(const struct ast_channel *chan)
struct ao2_iterator ao2_iterator_init(struct ao2_container *c, int flags) attribute_warn_unused_result
Create an iterator for a container.
Structure that is the essence of a feature hook.

◆ 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:

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

References ast_bridge_channel_leave_bridge_nolock(), ast_bridge_channel_lock, and ast_bridge_channel_unlock.

Referenced by _ast_bridge_channel_unlock(), 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().

315 {
316  ast_bridge_channel_lock(bridge_channel);
317  ast_bridge_channel_leave_bridge_nolock(bridge_channel, new_state, cause);
318  ast_bridge_channel_unlock(bridge_channel);
319 }
#define ast_bridge_channel_lock(bridge_channel)
Lock the bridge_channel.
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).
#define ast_bridge_channel_unlock(bridge_channel)
Unlock the bridge_channel.

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

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_unlock(), ast_bridge_channel_leave_bridge(), bridge_do_merge(), and caller_abort_agent().

293 {
294  if (bridge_channel->state != BRIDGE_CHANNEL_STATE_WAIT) {
295  return;
296  }
297 
298  ast_debug(1, "Setting %p(%s) state from:%u to:%u\n",
299  bridge_channel, ast_channel_name(bridge_channel->chan), bridge_channel->state,
300  new_state);
301 
302  channel_set_cause(bridge_channel->chan, cause);
303 
304  ast_channel_lock(bridge_channel->chan);
305  ast_bridge_vars_set(bridge_channel->chan, NULL, NULL);
306  ast_channel_unlock(bridge_channel->chan);
307 
308  /* Change the state on the bridge channel */
309  bridge_channel->state = new_state;
310 
311  bridge_channel_poke(bridge_channel);
312 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
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:1242
enum bridge_channel_state state
#define NULL
Definition: resample.c:96
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
static int channel_set_cause(struct ast_channel *chan, int cause)
static void bridge_channel_poke(struct ast_bridge_channel *bridge_channel)
#define ast_channel_unlock(chan)
Definition: channel.h:2946
struct ast_channel * chan
const char * ast_channel_name(const struct ast_channel *chan)

◆ 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.
Returns
Nothing

Definition at line 222 of file bridge_channel.c.

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

Referenced by _ast_bridge_channel_unlock(), 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(), feature_automonitor(), and parking_blind_transfer_park().

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

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

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

Referenced by _ast_bridge_channel_unlock(), and feature_attended_transfer().

370 {
371  struct ast_bridge *bridge;
372 
373  ast_bridge_channel_lock_bridge(bridge_channel);
374  bridge = bridge_channel->bridge;
375  ao2_ref(bridge, +1);
377  ast_bridge_unlock(bridge);
378  return bridge;
379 }
struct ast_bridge * bridge
Bridge this channel is participating in.
#define ao2_ref(o, delta)
Definition: astobj2.h:464
Structure that contains information about a bridge.
Definition: bridge.h:357
void bridge_merge_inhibit_nolock(struct ast_bridge *bridge, int request)
Definition: bridge.c:3052
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition: bridge.h:493
static int request(void *obj)
Definition: chan_pjsip.c:2559
void ast_bridge_channel_lock_bridge(struct ast_bridge_channel *bridge_channel)
Lock the bridge associated with the bridge channel.

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

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

Referenced by _ast_bridge_channel_unlock(), clear_talking(), and softmix_bridge_write_voice().

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

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

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

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

322 {
323  struct ast_bridge *bridge = bridge_channel->bridge;
324  struct ast_bridge_channel *other = NULL;
325 
326  if (bridge_channel->in_bridge && bridge->num_channels == 2) {
327  AST_LIST_TRAVERSE(&bridge->channels, other, entry) {
328  if (other != bridge_channel) {
329  break;
330  }
331  }
332  }
333 
334  return other;
335 }
#define NULL
Definition: resample.c:96
struct ast_bridge * bridge
Bridge this channel is participating in.
Structure that contains information about a bridge.
Definition: bridge.h:357
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
unsigned int in_bridge
struct ast_bridge_channels_list channels
Definition: bridge.h:371
Structure that contains information regarding a channel in a bridge.
Definition: search.h:40
unsigned int num_channels
Definition: bridge.h:381

◆ 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.
Returns
Nothing

Definition at line 1321 of file bridge_channel.c.

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

Referenced by bridge_channel_playfile().

1322 {
1323  if (moh_class) {
1324  ast_bridge_channel_write_hold(bridge_channel, moh_class);
1325  }
1326  if (custom_play) {
1327  custom_play(bridge_channel, playfile);
1328  } else {
1329  ast_stream_and_wait(bridge_channel->chan, playfile, AST_DIGIT_NONE);
1330  }
1331  if (moh_class) {
1332  ast_bridge_channel_write_unhold(bridge_channel);
1333  }
1334 
1335  /*
1336  * It may be necessary to resume music on hold after we finish
1337  * playing the announcment.
1338  */
1339  if (ast_test_flag(ast_channel_flags(bridge_channel->chan), AST_FLAG_MOH)) {
1340  const char *latest_musicclass;
1341 
1342  ast_channel_lock(bridge_channel->chan);
1343  latest_musicclass = ast_strdupa(ast_channel_latest_musicclass(bridge_channel->chan));
1344  ast_channel_unlock(bridge_channel->chan);
1345  ast_moh_start(bridge_channel->chan, latest_musicclass, NULL);
1346  }
1347 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
#define ast_test_flag(p, flag)
Definition: utils.h:63
#define NULL
Definition: resample.c:96
int ast_bridge_channel_write_unhold(struct ast_bridge_channel *bridge_channel)
Write an unhold frame into the bridge.
const char * ast_channel_latest_musicclass(const struct ast_channel *chan)
#define ast_strdupa(s)
duplicate a string in memory from the stack
Definition: astmm.h:300
#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:7866
#define ast_channel_unlock(chan)
Definition: channel.h:2946
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:1814
struct ast_channel * chan
int ast_bridge_channel_write_hold(struct ast_bridge_channel *bridge_channel, const char *moh_class)
Write a hold frame into the bridge.
struct ast_flags * ast_channel_flags(struct ast_channel *chan)

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

References bridge_channel_queue_action_data(), and payload_helper_app().

Referenced by _ast_bridge_channel_unlock().

1316 {
1318  bridge_channel, app_name, app_args, moh_class);
1319 }
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

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

References bridge_channel_queue_action_data(), and payload_helper_cb().

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

1495 {
1497  bridge_channel, flags, callback, payload, payload_size);
1498 }
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_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)

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

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

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

1144 {
1145  struct ast_frame frame = {
1147  .subclass.integer = control,
1148  .datalen = datalen,
1149  .data.ptr = (void *) data,
1150  };
1151 
1152  return ast_bridge_channel_queue_frame(bridge_channel, &frame);
1153 }
int ast_bridge_channel_queue_frame(struct ast_bridge_channel *bridge_channel, struct ast_frame *fr)
Write a frame to the specified bridge_channel.
Data structure associated with a single frame of data.
union ast_frame::@263 data
enum ast_frame_type frametype

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

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

1045 {
1046  struct ast_frame *dup;
1047 
1048  if (bridge_channel->suspended
1049  /* Also defer DTMF frames. */
1051  && fr->frametype != AST_FRAME_DTMF_END
1052  && !ast_is_deferrable_frame(fr)) {
1053  /* Drop non-deferable frames when suspended. */
1054  return 0;
1055  }
1056  if (fr->frametype == AST_FRAME_NULL) {
1057  /* "Accept" the frame and discard it. */
1058  return 0;
1059  }
1060 
1061  if ((fr->frametype == AST_FRAME_VOICE || fr->frametype == AST_FRAME_VIDEO ||
1063  fr->frametype == AST_FRAME_RTCP) && fr->stream_num > -1) {
1064  int num = -1;
1065 
1066  ast_bridge_channel_lock(bridge_channel);
1067  if (fr->stream_num < (int)AST_VECTOR_SIZE(&bridge_channel->stream_map.to_channel)) {
1068  num = AST_VECTOR_GET(&bridge_channel->stream_map.to_channel, fr->stream_num);
1069  }
1070  ast_bridge_channel_unlock(bridge_channel);
1071 
1072  if (num == -1) {
1073  /* We don't have a mapped stream so just discard this frame. */
1074  return 0;
1075  }
1076  }
1077 
1078  dup = ast_frdup(fr);
1079  if (!dup) {
1080  return -1;
1081  }
1082 
1083  ast_bridge_channel_lock(bridge_channel);
1084  if (bridge_channel->state != BRIDGE_CHANNEL_STATE_WAIT) {
1085  /* Drop frames on channels leaving the bridge. */
1086  ast_bridge_channel_unlock(bridge_channel);
1087  bridge_frame_free(dup);
1088  return 0;
1089  }
1090 
1091  if ((fr->frametype == AST_FRAME_TEXT || fr->frametype == AST_FRAME_TEXT_DATA) &&
1092  !bridge_channel->features->text_messaging) {
1093  /* This channel is not accepting text messages. */
1094  ast_bridge_channel_unlock(bridge_channel);
1095  bridge_frame_free(dup);
1096  return 0;
1097  }
1098 
1099  if (DEBUG_ATLEAST(1)) {
1100  if (fr->frametype == AST_FRAME_TEXT) {
1101  ast_log(LOG_DEBUG, "Queuing TEXT frame to '%s': %*.s\n", ast_channel_name(bridge_channel->chan),
1102  fr->datalen, (char *)fr->data.ptr);
1103  } else if (fr->frametype == AST_FRAME_TEXT_DATA) {
1104  struct ast_msg_data *msg = fr->data.ptr;
1105  ast_log(LOG_DEBUG, "Queueing TEXT_DATA frame from '%s' to '%s:%s': %s\n",
1108  ast_channel_name(bridge_channel->chan),
1110  }
1111  }
1112 
1113  AST_LIST_INSERT_TAIL(&bridge_channel->wr_queue, dup, frame_list);
1114  if (ast_alertpipe_write(bridge_channel->alert_pipe)) {
1115  ast_log(LOG_ERROR, "We couldn't write alert pipe for %p(%s)... something is VERY wrong\n",
1116  bridge_channel, ast_channel_name(bridge_channel->chan));
1117  }
1118  ast_bridge_channel_unlock(bridge_channel);
1119  return 0;
1120 }
#define ast_frdup(fr)
Copies a frame.
struct ast_bridge_channel::@230 wr_queue
struct ast_bridge_features * features
enum bridge_channel_state state
unsigned int suspended
Structure used to transport a message through the frame core.
Definition: message.c:1406
struct ast_bridge_channel::@236 stream_map
#define LOG_DEBUG
Definition: logger.h:241
ssize_t ast_alertpipe_write(int alert_pipe[2])
Write an event to an alert pipe.
Definition: alertpipe.c:120
unsigned int text_messaging
#define ast_log
Definition: astobj2.c:42
#define ast_bridge_channel_lock(bridge_channel)
Lock the bridge_channel.
#define ast_bridge_channel_unlock(bridge_channel)
Unlock the bridge_channel.
struct ast_vector_int to_channel
#define LOG_ERROR
Definition: logger.h:285
#define AST_LIST_INSERT_TAIL(head, elm, field)
Appends a list entry to the tail of a list.
Definition: linkedlists.h:730
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.
Definition: message.c:1533
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:682
struct ast_channel * chan
const char * ast_channel_name(const struct ast_channel *chan)
int ast_is_deferrable_frame(const struct ast_frame *frame)
Should we keep this frame for later?
Definition: channel.c:1467
Data structure associated with a single frame of data.
union ast_frame::@263 data
enum ast_frame_type frametype
static void bridge_frame_free(struct ast_frame *frame)
#define DEBUG_ATLEAST(level)
Definition: logger.h:441
#define AST_VECTOR_SIZE(vec)
Get the number of elements in a vector.
Definition: vector.h:611

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

References bridge_channel_queue_action_data(), and payload_helper_playfile().

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

1405 {
1407  bridge_channel, custom_play, playfile, moh_class);
1408 }
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 bridge_channel_queue_action_data(struct ast_bridge_channel *bridge_channel, enum bridge_channel_action_type action, const void *data, size_t datalen)

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

References bridge_channel_queue_action_data_sync(), and payload_helper_playfile().

Referenced by parker_parked_call_message_response(), and play_uri().

1412 {
1414  bridge_channel, custom_play, playfile, moh_class);
1415 }
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 bridge_channel_queue_action_data_sync(struct ast_bridge_channel *bridge_channel, enum bridge_channel_action_type action, const void *data, size_t datalen)

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

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

Referenced by _ast_bridge_channel_unlock(), bridge_channel_internal_join(), and participant_reaction_announcer_leave().

338 {
339  ast_assert(bridge_channel->read_format != NULL);
340  ast_assert(bridge_channel->write_format != NULL);
341 
342  ast_channel_lock(bridge_channel->chan);
343 
344  /* Restore original formats of the channel as they came in */
345  if (ast_format_cmp(ast_channel_readformat(bridge_channel->chan), bridge_channel->read_format) == AST_FORMAT_CMP_NOT_EQUAL) {
346  ast_debug(1, "Bridge is returning %p(%s) to read format %s\n",
347  bridge_channel, ast_channel_name(bridge_channel->chan),
348  ast_format_get_name(bridge_channel->read_format));
349  if (ast_set_read_format(bridge_channel->chan, bridge_channel->read_format)) {
350  ast_debug(1, "Bridge failed to return %p(%s) to read format %s\n",
351  bridge_channel, ast_channel_name(bridge_channel->chan),
352  ast_format_get_name(bridge_channel->read_format));
353  }
354  }
355  if (ast_format_cmp(ast_channel_writeformat(bridge_channel->chan), bridge_channel->write_format) == AST_FORMAT_CMP_NOT_EQUAL) {
356  ast_debug(1, "Bridge is returning %p(%s) to write format %s\n",
357  bridge_channel, ast_channel_name(bridge_channel->chan),
358  ast_format_get_name(bridge_channel->write_format));
359  if (ast_set_write_format(bridge_channel->chan, bridge_channel->write_format)) {
360  ast_debug(1, "Bridge failed to return %p(%s) to write format %s\n",
361  bridge_channel, ast_channel_name(bridge_channel->chan),
362  ast_format_get_name(bridge_channel->write_format));
363  }
364  }
365 
366  ast_channel_unlock(bridge_channel->chan);
367 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
#define ast_assert(a)
Definition: utils.h:695
const char * ast_format_get_name(const struct ast_format *format)
Get the name associated with a format.
Definition: format.c:334
#define NULL
Definition: resample.c:96
struct ast_format * ast_channel_readformat(struct ast_channel *chan)
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
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
int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
Sets read format on channel chan.
Definition: channel.c:5849
int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
Sets write format on channel chan.
Definition: channel.c:5890
struct ast_format * write_format
struct ast_format * read_format
#define ast_channel_unlock(chan)
Definition: channel.h:2946
struct ast_channel * chan
const char * ast_channel_name(const struct ast_channel *chan)
struct ast_format * ast_channel_writeformat(struct ast_channel *chan)

◆ 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.
Returns
Nothing

Definition at line 1241 of file bridge_channel.c.

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

Referenced by _ast_bridge_channel_unlock(), bridge_channel_run_app(), and dynamic_dtmf_hook_callback().

1242 {
1243  if (moh_class) {
1244  ast_bridge_channel_write_hold(bridge_channel, moh_class);
1245  }
1246  if (run_app_helper(bridge_channel->chan, app_name, S_OR(app_args, ""))) {
1247  /* Break the bridge if the app returns non-zero. */
1249  }
1250  if (moh_class) {
1251  ast_bridge_channel_write_unhold(bridge_channel);
1252  }
1253 }
static int run_app_helper(struct ast_channel *chan, const char *app_name, const char *app_args)
int ast_bridge_channel_write_unhold(struct ast_bridge_channel *bridge_channel)
Write an unhold frame into the bridge.
void ast_bridge_channel_kick(struct ast_bridge_channel *bridge_channel, int cause)
Kick the channel out of the bridge.
#define AST_CAUSE_NORMAL_CLEARING
Definition: causes.h:105
const char * app_name(struct ast_app *app)
Definition: pbx_app.c:463
struct ast_channel * chan
#define S_OR(a, b)
returns the equivalent of logic or for strings: first one if not empty, otherwise second one...
Definition: strings.h:79
int ast_bridge_channel_write_hold(struct ast_bridge_channel *bridge_channel, const char *moh_class)
Write a hold frame into the bridge.

◆ 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.
Returns
Nothing

Definition at line 3174 of file bridge_channel.c.

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

3175 {
3176  ast_bridge_channel_lock(bridge_channel);
3177  ast_channel_lock(bridge_channel->chan);
3179  &bridge_channel->bridge->media_types, &bridge_channel->stream_map.to_bridge,
3180  &bridge_channel->stream_map.to_channel);
3181  ast_channel_unlock(bridge_channel->chan);
3182  ast_bridge_channel_unlock(bridge_channel);
3183 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
struct ast_stream_topology * ast_channel_get_stream_topology(const struct ast_channel *chan)
Retrieve the topology of streams on a channel.
struct ast_bridge_channel::@236 stream_map
struct ast_vector_int to_bridge
struct ast_bridge * bridge
Bridge this channel is participating in.
#define ast_bridge_channel_lock(bridge_channel)
Lock the bridge_channel.
#define ast_bridge_channel_unlock(bridge_channel)
Unlock the bridge_channel.
struct ast_vector_int to_channel
#define ast_channel_unlock(chan)
Definition: channel.h:2946
struct ast_channel * chan
struct ast_vector_int media_types
Definition: bridge.h:412
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&#39;s streams to the given types.
Definition: stream.c:985

◆ ast_bridge_channel_update_accountcodes()

void ast_bridge_channel_update_accountcodes ( struct ast_bridge_channel joining,
struct ast_bridge_channel leaving 
)

Definition at line 596 of file bridge_channel.c.

References bridge_channel_update_accountcodes_joining(), and bridge_channel_update_accountcodes_leaving().

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

597 {
598  if (joining) {
600  } else {
602  }
603 }
static void bridge_channel_update_accountcodes_leaving(struct ast_bridge_channel *leaving)
static void bridge_channel_update_accountcodes_joining(struct ast_bridge_channel *joining, struct ast_bridge_channel *swap)

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

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

Referenced by _ast_bridge_channel_unlock(), bridge_basic_push(), and bridge_stasis_push().

382 {
383  struct ast_bridge_channel *other;
384  struct ast_bridge *bridge = bridge_channel->bridge;
385  struct ast_channel *oldest_linkedid_chan = bridge_channel->chan;
386 
387  AST_LIST_TRAVERSE(&bridge->channels, other, entry) {
388  if (other == swap) {
389  continue;
390  }
391  oldest_linkedid_chan = ast_channel_internal_oldest_linkedid(
392  oldest_linkedid_chan, other->chan);
393  }
394 
395  ast_channel_lock(bridge_channel->chan);
396  ast_channel_internal_copy_linkedid(bridge_channel->chan, oldest_linkedid_chan);
397  ast_channel_unlock(bridge_channel->chan);
398  AST_LIST_TRAVERSE(&bridge->channels, other, entry) {
399  if (other == swap) {
400  continue;
401  }
402  ast_channel_lock(other->chan);
403  ast_channel_internal_copy_linkedid(other->chan, oldest_linkedid_chan);
404  ast_channel_unlock(other->chan);
405  }
406 }
#define ast_channel_lock(chan)
Definition: channel.h:2945
Main Channel structure associated with a channel.
struct ast_bridge * bridge
Bridge this channel is participating in.
Structure that contains information about a bridge.
Definition: bridge.h:357
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
#define ast_channel_unlock(chan)
Definition: channel.h:2946
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_bridge_channels_list channels
Definition: bridge.h:371
struct ast_channel * chan
Structure that contains information regarding a channel in a bridge.
Definition: search.h:40
struct ast_channel * ast_channel_internal_oldest_linkedid(struct ast_channel *a, struct ast_channel *b)
Determine which channel has an older linkedid.

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

References bridge_channel_write_action_data(), and payload_helper_app().

Referenced by _ast_bridge_channel_unlock().

1310 {
1312  bridge_channel, app_name, app_args, moh_class);
1313 }
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 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

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

References bridge_channel_write_action_data(), and payload_helper_cb().

Referenced by agent_connect_caller(), and dynamic_dtmf_hook_trip().

1487 {
1489  bridge_channel, flags, callback, payload, payload_size);
1490 }
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 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)

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

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

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

1156 {
1157  struct ast_frame frame = {
1159  .subclass.integer = control,
1160  .datalen = datalen,
1161  .data.ptr = (void *) data,
1162  };
1163 
1164  return bridge_channel_write_frame(bridge_channel, &frame);
1165 }
static int bridge_channel_write_frame(struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
Data structure associated with a single frame of data.
union ast_frame::@263 data
enum ast_frame_type frametype

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

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

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

1168 {
1169  struct ast_json *blob;
1170  int res;
1171  size_t datalen;
1172 
1173  if (!ast_strlen_zero(moh_class)) {
1174  datalen = strlen(moh_class) + 1;
1175 
1176  blob = ast_json_pack("{s: s}",
1177  "musicclass", moh_class);
1178  } else {
1179  moh_class = NULL;
1180  datalen = 0;
1181  blob = NULL;
1182  }
1183 
1185 
1187  moh_class, datalen);
1188 
1189  ast_json_unref(blob);
1190  return res;
1191 }
struct stasis_message_type * ast_channel_hold_type(void)
Message type for when a channel is placed on hold.
struct ast_json * ast_json_pack(char const *format,...)
Helper for creating complex JSON values.
Definition: json.c:591
void ast_json_unref(struct ast_json *value)
Decrease refcount on value. If refcount reaches zero, value is freed.
Definition: json.c:73
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.
#define NULL
Definition: resample.c:96
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.
#define ast_strlen_zero(foo)
Definition: strings.h:52
struct ast_channel * chan
Abstract JSON element (object, array, string, int, ...).

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

References bridge_channel_write_action_data(), and payload_helper_park().

Referenced by manager_park_bridged(), and parking_blind_transfer_park().

1556 {
1558  bridge_channel, parkee_uuid, parker_uuid, app_data);
1559 }
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 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)

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

References bridge_channel_write_action_data(), and payload_helper_playfile().

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

1399 {
1401  bridge_channel, custom_play, playfile, moh_class);
1402 }
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 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)

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

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, and NULL.

Referenced by _ast_bridge_channel_unlock(), 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().

1194 {
1195  struct ast_channel *chan = ast_bridge_channel_get_chan(bridge_channel);
1196 
1197  if (!chan) {
1198  return -1;
1199  }
1200 
1202  ao2_ref(chan, -1);
1203 
1205 }
Main Channel structure associated with a channel.
struct stasis_message_type * ast_channel_unhold_type(void)
Message type for when a channel is removed from 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.
struct ast_channel * ast_bridge_channel_get_chan(struct ast_bridge_channel *bridge_channel)
Get a ref to the bridge_channel&#39;s ast_channel.
#define NULL
Definition: resample.c:96
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.
#define ao2_ref(o, delta)
Definition: astobj2.h:464