Asterisk - The Open Source Telephony Project  GIT-master-9ed6387
Data Structures | Macros | Typedefs | Enumerations | Functions
bridge_channel.h File Reference
#include "asterisk/bridge_features.h"
#include "asterisk/bridge_technology.h"

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...
 
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 204 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 598 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 510 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 600 of file bridge_channel.h.

600  {
601  /*! The callback temporarily affects media. (Like a custom playfile.) */
603 };

◆ 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 218 of file bridge_channel.h.

References __ao2_lock(), and AO2_LOCK_REQ_MUTEX.

219 {
220  __ao2_lock(bridge_channel, AO2_LOCK_REQ_MUTEX, file, function, line, var);
221 }
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 205 of file bridge_channel.h.

References __ao2_trylock(), and AO2_LOCK_REQ_MUTEX.

206 {
207  return __ao2_trylock(bridge_channel, AO2_LOCK_REQ_MUTEX, file, function, line, var);
208 }
#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 1740 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().

1741 {
1742  struct ast_bridge_features *features = bridge_channel->features;
1743  struct ast_bridge_hook_dtmf *hook = NULL;
1744  size_t dtmf_len;
1745 
1746  struct sanity_check_of_dtmf_size {
1747  char check[1 / (ARRAY_LEN(bridge_channel->dtmf_hook_state.collected) == ARRAY_LEN(hook->dtmf.code))];
1748  };
1749 
1750  dtmf_len = strlen(bridge_channel->dtmf_hook_state.collected);
1751  if (!dtmf_len && !digit) {
1752  /* Nothing to do */
1753  return;
1754  }
1755 
1756  if (digit) {
1757  dtmf_len = bridge_channel_feature_digit_add(bridge_channel, digit, dtmf_len);
1758  }
1759 
1760  while (digit) {
1761  /* See if a DTMF feature hook matches or can match */
1762  hook = ao2_find(features->dtmf_hooks, bridge_channel->dtmf_hook_state.collected,
1764  if (!hook) {
1765  ast_debug(1, "No DTMF feature hooks on %p(%s) match '%s'\n",
1766  bridge_channel, ast_channel_name(bridge_channel->chan),
1767  bridge_channel->dtmf_hook_state.collected);
1768  break;
1769  } else if (dtmf_len != strlen(hook->dtmf.code)) {
1770  unsigned int digit_timeout;
1771  /* Need more digits to match */
1772  ao2_ref(hook, -1);
1773  digit_timeout = bridge_channel_feature_digit_timeout(bridge_channel);
1774  bridge_channel->dtmf_hook_state.interdigit_timeout =
1775  ast_tvadd(ast_tvnow(), ast_samp2tv(digit_timeout, 1000));
1776  return;
1777  } else {
1778  int remove_me;
1779  int already_suspended;
1780 
1781  ast_debug(1, "DTMF feature hook %p matched DTMF string '%s' on %p(%s)\n",
1782  hook, bridge_channel->dtmf_hook_state.collected, bridge_channel,
1783  ast_channel_name(bridge_channel->chan));
1784 
1785  /*
1786  * Clear the collected digits before executing the hook
1787  * in case the hook starts another sequence.
1788  */
1789  bridge_channel->dtmf_hook_state.collected[0] = '\0';
1790 
1791  ast_bridge_channel_lock_bridge(bridge_channel);
1792  already_suspended = bridge_channel->suspended;
1793  if (!already_suspended) {
1795  }
1796  ast_bridge_unlock(bridge_channel->bridge);
1797  ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
1798 
1799  /* Execute the matched hook on this channel. */
1800  remove_me = hook->generic.callback(bridge_channel, hook->generic.hook_pvt);
1801  if (remove_me) {
1802  ast_debug(1, "DTMF hook %p is being removed from %p(%s)\n",
1803  hook, bridge_channel, ast_channel_name(bridge_channel->chan));
1804  ao2_unlink(features->dtmf_hooks, hook);
1805  }
1806  testsuite_notify_feature_success(bridge_channel->chan, hook->dtmf.code);
1807  ao2_ref(hook, -1);
1808 
1809  ast_indicate(bridge_channel->chan, AST_CONTROL_SRCUPDATE);
1810  if (!already_suspended) {
1811  bridge_channel_unsuspend(bridge_channel);
1812  }
1813 
1814  /*
1815  * If we are handing the channel off to an external hook for
1816  * ownership, we are not guaranteed what kind of state it will
1817  * come back in. If the channel hungup, we need to detect that
1818  * here if the hook did not already change the state.
1819  */
1820  if (bridge_channel->chan && ast_check_hangup_locked(bridge_channel->chan)) {
1821  ast_bridge_channel_kick(bridge_channel, 0);
1822  bridge_channel->dtmf_hook_state.collected[0] = '\0';
1823  return;
1824  }
1825 
1826  /* if there is dtmf that has been collected then loop back through,
1827  but set digit to -1 so it doesn't try to do an add since the dtmf
1828  is already in the buffer */
1829  dtmf_len = strlen(bridge_channel->dtmf_hook_state.collected);
1830  if (!dtmf_len) {
1831  return;
1832  }
1833  }
1834  }
1835 
1836  if (!digit) {
1837  ast_debug(1, "DTMF feature string collection on %p(%s) timed out\n",
1838  bridge_channel, ast_channel_name(bridge_channel->chan));
1839  }
1840 
1841  /* Timeout or DTMF digit didn't allow a match with any hooks. */
1842  if (features->dtmf_passthrough) {
1843  /* Stream the collected DTMF to the other channels. */
1844  bridge_channel_write_dtmf_stream(bridge_channel,
1845  bridge_channel->dtmf_hook_state.collected);
1846  }
1847  bridge_channel->dtmf_hook_state.collected[0] = '\0';
1848 
1849  ast_test_suite_event_notify("FEATURE_DETECTION", "Result: fail");
1850 }
char digit
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:4271
int ast_check_hangup_locked(struct ast_channel *chan)
Definition: channel.c:455
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:444
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:489
#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)
struct ast_bridge_channel::@227 dtmf_hook_state
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 1732 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().

1733 {
1734  if (digit) {
1736  bridge_channel, digit, strlen(bridge_channel->dtmf_hook_state.collected));
1737  }
1738 }
char digit
char collected[MAXIMUM_DTMF_FEATURE_STRING]
struct ast_bridge_channel::@227 dtmf_hook_state
static int bridge_channel_feature_digit_add(struct ast_bridge_channel *bridge_channel, int digit, size_t dtmf_len)

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

595 {
596  struct ast_bridge_features *features = bridge_channel->features;
597  struct ast_bridge_hook *hook;
598  struct ao2_iterator iter;
599 
600  ast_bridge_channel_lock(bridge_channel);
601  if (bridge_channel->state == BRIDGE_CHANNEL_STATE_WAIT) {
602  channel_set_cause(bridge_channel->chan, cause);
603  cause = 0;
604  }
605  ast_bridge_channel_unlock(bridge_channel);
606 
607  /* Run any hangup hooks. */
608  iter = ao2_iterator_init(features->other_hooks, 0);
609  for (; (hook = ao2_iterator_next(&iter)); ao2_ref(hook, -1)) {
610  int remove_me;
611 
612  if (hook->type != AST_BRIDGE_HOOK_TYPE_HANGUP) {
613  continue;
614  }
615  remove_me = hook->callback(bridge_channel, hook->hook_pvt);
616  if (remove_me) {
617  ast_debug(1, "Hangup hook %p is being removed from %p(%s)\n",
618  hook, bridge_channel, ast_channel_name(bridge_channel->chan));
619  ao2_unlink(features->other_hooks, hook);
620  }
621  }
622  ao2_iterator_destroy(&iter);
623 
624  /* Default hangup action. */
626 }
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:444
#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 303 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().

304 {
305  ast_bridge_channel_lock(bridge_channel);
306  ast_bridge_channel_leave_bridge_nolock(bridge_channel, new_state, cause);
307  ast_bridge_channel_unlock(bridge_channel);
308 }
#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 281 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().

282 {
283  if (bridge_channel->state != BRIDGE_CHANNEL_STATE_WAIT) {
284  return;
285  }
286 
287  ast_debug(1, "Setting %p(%s) state from:%u to:%u\n",
288  bridge_channel, ast_channel_name(bridge_channel->chan), bridge_channel->state,
289  new_state);
290 
291  channel_set_cause(bridge_channel->chan, cause);
292 
293  ast_channel_lock(bridge_channel->chan);
294  ast_bridge_vars_set(bridge_channel->chan, NULL, NULL);
295  ast_channel_unlock(bridge_channel->chan);
296 
297  /* Change the state on the bridge channel */
298  bridge_channel->state = new_state;
299 
300  bridge_channel_poke(bridge_channel);
301 }
#define ast_channel_lock(chan)
Definition: channel.h:2837
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:444
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:2838
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 211 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().

212 {
213  struct ast_bridge *bridge;
214 
215  for (;;) {
216  /* Safely get the bridge pointer */
217  ast_bridge_channel_lock(bridge_channel);
218  bridge = bridge_channel->bridge;
219  ao2_ref(bridge, +1);
220  ast_bridge_channel_unlock(bridge_channel);
221 
222  /* Lock the bridge and see if it is still the bridge we need to lock. */
223  ast_bridge_lock(bridge);
224  if (bridge == bridge_channel->bridge) {
225  ao2_ref(bridge, -1);
226  return;
227  }
228  ast_bridge_unlock(bridge);
229  ao2_ref(bridge, -1);
230  }
231 }
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:353
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition: bridge.h:489
#define ast_bridge_lock(bridge)
Lock the bridge.
Definition: bridge.h:476

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

359 {
360  struct ast_bridge *bridge;
361 
362  ast_bridge_channel_lock_bridge(bridge_channel);
363  bridge = bridge_channel->bridge;
364  ao2_ref(bridge, +1);
366  ast_bridge_unlock(bridge);
367  return bridge;
368 }
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:353
void bridge_merge_inhibit_nolock(struct ast_bridge *bridge, int request)
Definition: bridge.c:3043
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition: bridge.h:489
static int request(void *obj)
Definition: chan_pjsip.c:2626
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 233 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().

234 {
235  struct ast_frame action = {
237  .subclass.integer = started_talking
239  };
240 
241  return ast_bridge_channel_queue_frame(bridge_channel, &action);
242 }
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 310 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().

311 {
312  struct ast_bridge *bridge = bridge_channel->bridge;
313  struct ast_bridge_channel *other = NULL;
314 
315  if (bridge_channel->in_bridge && bridge->num_channels == 2) {
316  AST_LIST_TRAVERSE(&bridge->channels, other, entry) {
317  if (other != bridge_channel) {
318  break;
319  }
320  }
321  }
322 
323  return other;
324 }
#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:353
#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:367
Structure that contains information regarding a channel in a bridge.
Definition: search.h:40
unsigned int num_channels
Definition: bridge.h:377

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

1300 {
1301  if (moh_class) {
1302  ast_bridge_channel_write_hold(bridge_channel, moh_class);
1303  }
1304  if (custom_play) {
1305  custom_play(bridge_channel, playfile);
1306  } else {
1307  ast_stream_and_wait(bridge_channel->chan, playfile, AST_DIGIT_NONE);
1308  }
1309  if (moh_class) {
1310  ast_bridge_channel_write_unhold(bridge_channel);
1311  }
1312 
1313  /*
1314  * It may be necessary to resume music on hold after we finish
1315  * playing the announcment.
1316  */
1317  if (ast_test_flag(ast_channel_flags(bridge_channel->chan), AST_FLAG_MOH)) {
1318  const char *latest_musicclass;
1319 
1320  ast_channel_lock(bridge_channel->chan);
1321  latest_musicclass = ast_strdupa(ast_channel_latest_musicclass(bridge_channel->chan));
1322  ast_channel_unlock(bridge_channel->chan);
1323  ast_moh_start(bridge_channel->chan, latest_musicclass, NULL);
1324  }
1325 }
#define ast_channel_lock(chan)
Definition: channel.h:2837
#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:7705
#define ast_channel_unlock(chan)
Definition: channel.h:2838
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:1813
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 1293 of file bridge_channel.c.

References bridge_channel_queue_action_data(), and payload_helper_app().

Referenced by _ast_bridge_channel_unlock().

1294 {
1296  bridge_channel, app_name, app_args, moh_class);
1297 }
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 1470 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().

1473 {
1475  bridge_channel, flags, callback, payload, payload_size);
1476 }
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 1128 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().

1129 {
1130  struct ast_frame frame = {
1132  .subclass.integer = control,
1133  .datalen = datalen,
1134  .data.ptr = (void *) data,
1135  };
1136 
1137  return ast_bridge_channel_queue_frame(bridge_channel, &frame);
1138 }
int ast_bridge_channel_queue_frame(struct ast_bridge_channel *bridge_channel, struct ast_frame *fr)
Write a frame to the specified bridge_channel.
union ast_frame::@255 data
Data structure associated with a single frame of 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 1029 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().

1030 {
1031  struct ast_frame *dup;
1032 
1033  if (bridge_channel->suspended
1034  /* Also defer DTMF frames. */
1036  && fr->frametype != AST_FRAME_DTMF_END
1037  && !ast_is_deferrable_frame(fr)) {
1038  /* Drop non-deferable frames when suspended. */
1039  return 0;
1040  }
1041  if (fr->frametype == AST_FRAME_NULL) {
1042  /* "Accept" the frame and discard it. */
1043  return 0;
1044  }
1045 
1046  if ((fr->frametype == AST_FRAME_VOICE || fr->frametype == AST_FRAME_VIDEO ||
1048  fr->frametype == AST_FRAME_RTCP) && fr->stream_num > -1) {
1049  int num = -1;
1050 
1051  ast_bridge_channel_lock(bridge_channel);
1052  if (fr->stream_num < (int)AST_VECTOR_SIZE(&bridge_channel->stream_map.to_channel)) {
1053  num = AST_VECTOR_GET(&bridge_channel->stream_map.to_channel, fr->stream_num);
1054  }
1055  ast_bridge_channel_unlock(bridge_channel);
1056 
1057  if (num == -1) {
1058  /* We don't have a mapped stream so just discard this frame. */
1059  return 0;
1060  }
1061  }
1062 
1063  dup = ast_frdup(fr);
1064  if (!dup) {
1065  return -1;
1066  }
1067 
1068  ast_bridge_channel_lock(bridge_channel);
1069  if (bridge_channel->state != BRIDGE_CHANNEL_STATE_WAIT) {
1070  /* Drop frames on channels leaving the bridge. */
1071  ast_bridge_channel_unlock(bridge_channel);
1072  bridge_frame_free(dup);
1073  return 0;
1074  }
1075 
1076  if ((fr->frametype == AST_FRAME_TEXT || fr->frametype == AST_FRAME_TEXT_DATA) &&
1077  !bridge_channel->features->text_messaging) {
1078  /* This channel is not accepting text messages. */
1079  ast_bridge_channel_unlock(bridge_channel);
1080  bridge_frame_free(dup);
1081  return 0;
1082  }
1083 
1084  if (DEBUG_ATLEAST(1)) {
1085  if (fr->frametype == AST_FRAME_TEXT) {
1086  ast_log(LOG_DEBUG, "Queuing TEXT frame to '%s': %*.s\n", ast_channel_name(bridge_channel->chan),
1087  fr->datalen, (char *)fr->data.ptr);
1088  } else if (fr->frametype == AST_FRAME_TEXT_DATA) {
1089  struct ast_msg_data *msg = fr->data.ptr;
1090  ast_log(LOG_DEBUG, "Queueing TEXT_DATA frame from '%s' to '%s:%s': %s\n",
1093  ast_channel_name(bridge_channel->chan),
1095  }
1096  }
1097 
1098  AST_LIST_INSERT_TAIL(&bridge_channel->wr_queue, dup, frame_list);
1099  if (ast_alertpipe_write(bridge_channel->alert_pipe)) {
1100  ast_log(LOG_ERROR, "We couldn't write alert pipe for %p(%s)... something is VERY wrong\n",
1101  bridge_channel, ast_channel_name(bridge_channel->chan));
1102  }
1103  ast_bridge_channel_unlock(bridge_channel);
1104  return 0;
1105 }
#define ast_frdup(fr)
Copies a frame.
struct ast_bridge_features * features
struct ast_bridge_channel::@224 wr_queue
enum bridge_channel_state state
unsigned int suspended
Structure used to transport a message through the frame core.
Definition: message.c:1369
#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
union ast_frame::@255 data
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:1496
#define AST_VECTOR_GET(vec, idx)
Get an element from a vector.
Definition: vector.h:678
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:1452
Data structure associated with a single frame of data.
struct ast_bridge_channel::@230 stream_map
enum ast_frame_type frametype
static void bridge_frame_free(struct ast_frame *frame)
#define DEBUG_ATLEAST(level)
Definition: logger.h:433
#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 1382 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().

1383 {
1385  bridge_channel, custom_play, playfile, moh_class);
1386 }
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 1388 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().

1390 {
1392  bridge_channel, custom_play, playfile, moh_class);
1393 }
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 326 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().

327 {
328  ast_assert(bridge_channel->read_format != NULL);
329  ast_assert(bridge_channel->write_format != NULL);
330 
331  ast_channel_lock(bridge_channel->chan);
332 
333  /* Restore original formats of the channel as they came in */
334  if (ast_format_cmp(ast_channel_readformat(bridge_channel->chan), bridge_channel->read_format) == AST_FORMAT_CMP_NOT_EQUAL) {
335  ast_debug(1, "Bridge is returning %p(%s) to read format %s\n",
336  bridge_channel, ast_channel_name(bridge_channel->chan),
337  ast_format_get_name(bridge_channel->read_format));
338  if (ast_set_read_format(bridge_channel->chan, bridge_channel->read_format)) {
339  ast_debug(1, "Bridge failed to return %p(%s) to read format %s\n",
340  bridge_channel, ast_channel_name(bridge_channel->chan),
341  ast_format_get_name(bridge_channel->read_format));
342  }
343  }
344  if (ast_format_cmp(ast_channel_writeformat(bridge_channel->chan), bridge_channel->write_format) == AST_FORMAT_CMP_NOT_EQUAL) {
345  ast_debug(1, "Bridge is returning %p(%s) to write format %s\n",
346  bridge_channel, ast_channel_name(bridge_channel->chan),
347  ast_format_get_name(bridge_channel->write_format));
348  if (ast_set_write_format(bridge_channel->chan, bridge_channel->write_format)) {
349  ast_debug(1, "Bridge failed to return %p(%s) to write format %s\n",
350  bridge_channel, ast_channel_name(bridge_channel->chan),
351  ast_format_get_name(bridge_channel->write_format));
352  }
353  }
354 
355  ast_channel_unlock(bridge_channel->chan);
356 }
#define ast_channel_lock(chan)
Definition: channel.h:2837
#define ast_assert(a)
Definition: utils.h:650
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:444
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:5724
int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
Sets write format on channel chan.
Definition: channel.c:5765
struct ast_format * write_format
struct ast_format * read_format
#define ast_channel_unlock(chan)
Definition: channel.h:2838
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 1219 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().

1220 {
1221  if (moh_class) {
1222  ast_bridge_channel_write_hold(bridge_channel, moh_class);
1223  }
1224  if (run_app_helper(bridge_channel->chan, app_name, S_OR(app_args, ""))) {
1225  /* Break the bridge if the app returns non-zero. */
1227  }
1228  if (moh_class) {
1229  ast_bridge_channel_write_unhold(bridge_channel);
1230  }
1231 }
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 3117 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().

3118 {
3119  ast_bridge_channel_lock(bridge_channel);
3120  ast_channel_lock(bridge_channel->chan);
3122  &bridge_channel->bridge->media_types, &bridge_channel->stream_map.to_bridge,
3123  &bridge_channel->stream_map.to_channel);
3124  ast_channel_unlock(bridge_channel->chan);
3125  ast_bridge_channel_unlock(bridge_channel);
3126 }
#define ast_channel_lock(chan)
Definition: channel.h:2837
struct ast_stream_topology * ast_channel_get_stream_topology(const struct ast_channel *chan)
Retrieve the topology of streams on a channel.
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:2838
struct ast_channel * chan
struct ast_vector_int media_types
Definition: bridge.h:408
struct ast_bridge_channel::@230 stream_map
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:970

◆ ast_bridge_channel_update_accountcodes()

void ast_bridge_channel_update_accountcodes ( struct ast_bridge_channel joining,
struct ast_bridge_channel leaving 
)

Definition at line 585 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().

586 {
587  if (joining) {
589  } else {
591  }
592 }
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 370 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().

371 {
372  struct ast_bridge_channel *other;
373  struct ast_bridge *bridge = bridge_channel->bridge;
374  struct ast_channel *oldest_linkedid_chan = bridge_channel->chan;
375 
376  AST_LIST_TRAVERSE(&bridge->channels, other, entry) {
377  if (other == swap) {
378  continue;
379  }
380  oldest_linkedid_chan = ast_channel_internal_oldest_linkedid(
381  oldest_linkedid_chan, other->chan);
382  }
383 
384  ast_channel_lock(bridge_channel->chan);
385  ast_channel_internal_copy_linkedid(bridge_channel->chan, oldest_linkedid_chan);
386  ast_channel_unlock(bridge_channel->chan);
387  AST_LIST_TRAVERSE(&bridge->channels, other, entry) {
388  if (other == swap) {
389  continue;
390  }
391  ast_channel_lock(other->chan);
392  ast_channel_internal_copy_linkedid(other->chan, oldest_linkedid_chan);
393  ast_channel_unlock(other->chan);
394  }
395 }
#define ast_channel_lock(chan)
Definition: channel.h:2837
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:353
#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:2838
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:367
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 1287 of file bridge_channel.c.

References bridge_channel_write_action_data(), and payload_helper_app().

Referenced by _ast_bridge_channel_unlock().

1288 {
1290  bridge_channel, app_name, app_args, moh_class);
1291 }
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 1462 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().

1465 {
1467  bridge_channel, flags, callback, payload, payload_size);
1468 }
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 1140 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().

1141 {
1142  struct ast_frame frame = {
1144  .subclass.integer = control,
1145  .datalen = datalen,
1146  .data.ptr = (void *) data,
1147  };
1148 
1149  return bridge_channel_write_frame(bridge_channel, &frame);
1150 }
static int bridge_channel_write_frame(struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
union ast_frame::@255 data
Data structure associated with a single frame of 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 1152 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().

1153 {
1154  struct ast_json *blob;
1155  int res;
1156  size_t datalen;
1157 
1158  if (!ast_strlen_zero(moh_class)) {
1159  datalen = strlen(moh_class) + 1;
1160 
1161  blob = ast_json_pack("{s: s}",
1162  "musicclass", moh_class);
1163  } else {
1164  moh_class = NULL;
1165  datalen = 0;
1166  blob = NULL;
1167  }
1168 
1170 
1172  moh_class, datalen);
1173 
1174  ast_json_unref(blob);
1175  return res;
1176 }
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(a)
Definition: muted.c:73
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 1533 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().

1534 {
1536  bridge_channel, parkee_uuid, parker_uuid, app_data);
1537 }
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 1376 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().

1377 {
1379  bridge_channel, custom_play, playfile, moh_class);
1380 }
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 1178 of file bridge_channel.c.

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

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

1179 {
1181 
1183 }
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.
#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.
struct ast_channel * chan