Asterisk - The Open Source Telephony Project  18.5.0
Data Structures | Typedefs | Enumerations | Functions | Variables
bridge_holding.c File Reference

Bridging technology for storing channels in a bridge for the purpose of holding, parking, queues, and other such states where a channel may need to be in a bridge but not actually communicating with anything. More...

#include "asterisk.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "asterisk/module.h"
#include "asterisk/channel.h"
#include "asterisk/bridge.h"
#include "asterisk/bridge_technology.h"
#include "asterisk/frame.h"
#include "asterisk/musiconhold.h"
#include "asterisk/format_cache.h"
Include dependency graph for bridge_holding.c:

Go to the source code of this file.

Data Structures

struct  deferred_data
 
struct  holding_channel
 Structure which contains per-channel role information. More...
 

Typedefs

typedef void(* deferred_cb) (struct ast_bridge_channel *bridge_channel)
 

Enumerations

enum  holding_roles { HOLDING_ROLE_PARTICIPANT, HOLDING_ROLE_ANNOUNCER }
 
enum  idle_modes {
  IDLE_MODE_NONE, IDLE_MODE_MOH, IDLE_MODE_RINGING, IDLE_MODE_SILENCE,
  IDLE_MODE_HOLD
}
 

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static int defer_action (struct ast_bridge_channel *bridge_channel, deferred_cb callback)
 
static void deferred_action (struct ast_bridge_channel *bridge_channel, const void *payload, size_t payload_size)
 
static void handle_participant_join (struct ast_bridge_channel *bridge_channel, struct ast_bridge_channel *announcer_channel)
 
static int holding_bridge_join (struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
 
static void holding_bridge_leave (struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
 
static void holding_bridge_suspend (struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
 
static void holding_bridge_unsuspend (struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel)
 
static int holding_bridge_write (struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
 
static int load_module (void)
 
static void participant_entertainment_start (struct ast_bridge_channel *bridge_channel)
 
static void participant_entertainment_stop (struct ast_bridge_channel *bridge_channel)
 
static void participant_idle_mode_setup (struct ast_bridge_channel *bridge_channel)
 
static void participant_reaction_announcer_join (struct ast_bridge_channel *bridge_channel)
 
static void participant_reaction_announcer_leave (struct ast_bridge_channel *bridge_channel)
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Holding bridge module" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "30ef0c93b36035ec78c9cfd712d36d9b" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static struct ast_bridge_technology holding_bridge
 

Detailed Description

Bridging technology for storing channels in a bridge for the purpose of holding, parking, queues, and other such states where a channel may need to be in a bridge but not actually communicating with anything.

Author
Jonathan Rose jrose.nosp@m.@dig.nosp@m.ium.c.nosp@m.om

Definition in file bridge_holding.c.

Typedef Documentation

◆ deferred_cb

typedef void(* deferred_cb) (struct ast_bridge_channel *bridge_channel)

Definition at line 73 of file bridge_holding.c.

Enumeration Type Documentation

◆ holding_roles

Enumerator
HOLDING_ROLE_PARTICIPANT 
HOLDING_ROLE_ANNOUNCER 

Definition at line 51 of file bridge_holding.c.

◆ idle_modes

enum idle_modes
Enumerator
IDLE_MODE_NONE 
IDLE_MODE_MOH 
IDLE_MODE_RINGING 
IDLE_MODE_SILENCE 
IDLE_MODE_HOLD 

Definition at line 56 of file bridge_holding.c.

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 446 of file bridge_holding.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 446 of file bridge_holding.c.

◆ AST_MODULE_SELF_SYM()

struct ast_module* AST_MODULE_SELF_SYM ( void  )

Definition at line 446 of file bridge_holding.c.

◆ defer_action()

static int defer_action ( struct ast_bridge_channel bridge_channel,
deferred_cb  callback 
)
static

Definition at line 93 of file bridge_holding.c.

References ast_bridge_channel_queue_callback(), ast_channel_name(), ast_log, ast_bridge_channel::bridge, deferred_data::callback, ast_bridge_channel::chan, deferred_action(), LOG_WARNING, and ast_bridge::uniqueid.

Referenced by handle_participant_join(), holding_bridge_join(), and holding_bridge_leave().

94 {
95  struct deferred_data data = { .callback = callback };
96  int res;
97 
98  res = ast_bridge_channel_queue_callback(bridge_channel, 0, deferred_action,
99  &data, sizeof(data));
100  if (res) {
101  ast_log(LOG_WARNING, "Bridge %s: Could not defer action on %s.\n",
102  bridge_channel->bridge->uniqueid, ast_channel_name(bridge_channel->chan));
103  }
104  return res;
105 }
const ast_string_field uniqueid
Definition: bridge.h:409
#define LOG_WARNING
Definition: logger.h:274
struct ast_bridge * bridge
Bridge this channel is participating in.
#define ast_log
Definition: astobj2.c:42
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.
deferred_cb callback
struct ast_channel * chan
const char * ast_channel_name(const struct ast_channel *chan)
static void deferred_action(struct ast_bridge_channel *bridge_channel, const void *payload, size_t payload_size)

◆ deferred_action()

static void deferred_action ( struct ast_bridge_channel bridge_channel,
const void *  payload,
size_t  payload_size 
)
static

Definition at line 416 of file bridge_holding.c.

References ast_bridge_channel_lock_bridge(), ast_bridge_unlock, ast_bridge_channel::bridge, deferred_data::callback, ast_bridge_channel::tech_pvt, and ast_bridge::technology.

Referenced by defer_action(), and smart_bridge_operation().

417 {
418  const struct deferred_data *data = payload;
419 
420  ast_bridge_channel_lock_bridge(bridge_channel);
421  if (bridge_channel->bridge->technology != &holding_bridge
422  || !bridge_channel->tech_pvt) {
423  /* Not valid anymore. */
424  ast_bridge_unlock(bridge_channel->bridge);
425  return;
426  }
427  data->callback(bridge_channel);
428  ast_bridge_unlock(bridge_channel->bridge);
429 }
struct ast_bridge * bridge
Bridge this channel is participating in.
struct ast_bridge_technology * technology
Definition: bridge.h:363
static struct ast_bridge_technology holding_bridge
#define ast_bridge_unlock(bridge)
Unlock the bridge.
Definition: bridge.h:493
deferred_cb callback
void * tech_pvt
Private information unique to the bridge technology.
void ast_bridge_channel_lock_bridge(struct ast_bridge_channel *bridge_channel)
Lock the bridge associated with the bridge channel.

◆ handle_participant_join()

static void handle_participant_join ( struct ast_bridge_channel bridge_channel,
struct ast_bridge_channel announcer_channel 
)
static

Definition at line 228 of file bridge_holding.c.

References ast_channel_name(), ast_format_slin, ast_log, ast_set_write_format(), ast_bridge_channel::chan, defer_action(), LOG_WARNING, and participant_entertainment_start().

Referenced by holding_bridge_join().

229 {
230  struct ast_channel *us = bridge_channel->chan;
231 
232  /* If the announcer channel isn't present, we need to set up ringing, music on hold, or whatever. */
233  if (!announcer_channel) {
235  return;
236  }
237 
238  /* We need to get compatible with the announcer. */
240  ast_log(LOG_WARNING, "Could not make participant %s compatible.\n", ast_channel_name(us));
241  }
242 }
Main Channel structure associated with a channel.
static void participant_entertainment_start(struct ast_bridge_channel *bridge_channel)
#define LOG_WARNING
Definition: logger.h:274
static int defer_action(struct ast_bridge_channel *bridge_channel, deferred_cb callback)
#define ast_log
Definition: astobj2.c:42
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_channel * chan
const char * ast_channel_name(const struct ast_channel *chan)
struct ast_format * ast_format_slin
Built-in cached signed linear 8kHz format.
Definition: format_cache.c:41

◆ holding_bridge_join()

static int holding_bridge_join ( struct ast_bridge bridge,
struct ast_bridge_channel bridge_channel 
)
static

Definition at line 244 of file bridge_holding.c.

References ast_assert, ast_bridge_channel_has_role(), ast_calloc, ast_channel_name(), ast_format_slin, ast_free, AST_LIST_TRAVERSE, ast_log, ast_set_read_format(), ast_bridge_channel::chan, ast_bridge::channels, defer_action(), handle_participant_join(), HOLDING_ROLE_ANNOUNCER, HOLDING_ROLE_PARTICIPANT, LOG_ERROR, LOG_WARNING, NULL, participant_reaction_announcer_join(), holding_channel::role, ast_bridge_channel::tech_pvt, ast_bridge::tech_pvt, and ast_bridge::uniqueid.

245 {
246  struct ast_bridge_channel *other_channel;
247  struct ast_bridge_channel *announcer_channel;
248  struct holding_channel *hc;
249  struct ast_channel *us = bridge_channel->chan; /* The joining channel */
250 
251  ast_assert(bridge_channel->tech_pvt == NULL);
252 
253  if (!(hc = ast_calloc(1, sizeof(*hc)))) {
254  return -1;
255  }
256 
257  bridge_channel->tech_pvt = hc;
258 
259  /* The bridge pvt holds the announcer channel if we have one. */
260  announcer_channel = bridge->tech_pvt;
261 
262  if (ast_bridge_channel_has_role(bridge_channel, "announcer")) {
263  if (announcer_channel) {
264  /* Another announcer already exists. */
265  bridge_channel->tech_pvt = NULL;
266  ast_free(hc);
267  ast_log(LOG_WARNING, "Bridge %s: Channel %s tried to be an announcer. Bridge already has one.\n",
268  bridge->uniqueid, ast_channel_name(bridge_channel->chan));
269  return -1;
270  }
271 
272  bridge->tech_pvt = bridge_channel;
274 
275  /* The announcer should always be made compatible with signed linear */
277  ast_log(LOG_ERROR, "Could not make announcer %s compatible.\n", ast_channel_name(us));
278  }
279 
280  /* Make everyone listen to the announcer. */
281  AST_LIST_TRAVERSE(&bridge->channels, other_channel, entry) {
282  /* Skip the reaction if we are the channel in question */
283  if (bridge_channel == other_channel) {
284  continue;
285  }
287  }
288 
289  return 0;
290  }
291 
293  handle_participant_join(bridge_channel, announcer_channel);
294  return 0;
295 }
int ast_bridge_channel_has_role(struct ast_bridge_channel *bridge_channel, const char *role_name)
Check to see if a bridge channel inherited a specific role from its channel.
Definition: bridge_roles.c:418
Main Channel structure associated with a channel.
const ast_string_field uniqueid
Definition: bridge.h:409
#define LOG_WARNING
Definition: logger.h:274
static void handle_participant_join(struct ast_bridge_channel *bridge_channel, struct ast_bridge_channel *announcer_channel)
#define ast_assert(a)
Definition: utils.h:695
#define NULL
Definition: resample.c:96
static int defer_action(struct ast_bridge_channel *bridge_channel, deferred_cb callback)
#define ast_log
Definition: astobj2.c:42
Structure which contains per-channel role information.
int ast_set_read_format(struct ast_channel *chan, struct ast_format *format)
Sets read format on channel chan.
Definition: channel.c:5849
static void participant_reaction_announcer_join(struct ast_bridge_channel *bridge_channel)
#define LOG_ERROR
Definition: logger.h:285
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
#define ast_free(a)
Definition: astmm.h:182
#define ast_calloc(num, len)
A wrapper for calloc()
Definition: astmm.h:204
void * tech_pvt
Private information unique to the bridge technology.
struct ast_bridge_channels_list channels
Definition: bridge.h:371
struct ast_channel * chan
Structure that contains information regarding a channel in a bridge.
const char * ast_channel_name(const struct ast_channel *chan)
void * tech_pvt
Definition: bridge.h:365
Definition: search.h:40
struct ast_format * ast_format_slin
Built-in cached signed linear 8kHz format.
Definition: format_cache.c:41
enum holding_roles role

◆ holding_bridge_leave()

static void holding_bridge_leave ( struct ast_bridge bridge,
struct ast_bridge_channel bridge_channel 
)
static

Definition at line 303 of file bridge_holding.c.

References ast_free, AST_LIST_TRAVERSE, ast_bridge::channels, defer_action(), HOLDING_ROLE_ANNOUNCER, NULL, participant_entertainment_stop(), participant_reaction_announcer_leave(), holding_channel::role, ast_bridge_channel::tech_pvt, and ast_bridge::tech_pvt.

304 {
305  struct ast_bridge_channel *other_channel;
306  struct holding_channel *hc = bridge_channel->tech_pvt;
307 
308  if (!hc) {
309  return;
310  }
311 
312  switch (hc->role) {
314  /* The announcer is leaving */
315  bridge->tech_pvt = NULL;
316 
317  /* Reset the other channels back to moh/ringing. */
318  AST_LIST_TRAVERSE(&bridge->channels, other_channel, entry) {
320  }
321  break;
322  default:
323  /* Nothing needs to react to its departure. */
324  participant_entertainment_stop(bridge_channel);
325  break;
326  }
327  bridge_channel->tech_pvt = NULL;
328  ast_free(hc);
329 }
#define NULL
Definition: resample.c:96
static int defer_action(struct ast_bridge_channel *bridge_channel, deferred_cb callback)
Structure which contains per-channel role information.
static void participant_entertainment_stop(struct ast_bridge_channel *bridge_channel)
#define AST_LIST_TRAVERSE(head, var, field)
Loops over (traverses) the entries in a list.
Definition: linkedlists.h:490
#define ast_free(a)
Definition: astmm.h:182
void * tech_pvt
Private information unique to the bridge technology.
struct ast_bridge_channels_list channels
Definition: bridge.h:371
Structure that contains information regarding a channel in a bridge.
void * tech_pvt
Definition: bridge.h:365
Definition: search.h:40
static void participant_reaction_announcer_leave(struct ast_bridge_channel *bridge_channel)
enum holding_roles role

◆ holding_bridge_suspend()

static void holding_bridge_suspend ( struct ast_bridge bridge,
struct ast_bridge_channel bridge_channel 
)
static

Definition at line 354 of file bridge_holding.c.

References HOLDING_ROLE_PARTICIPANT, participant_entertainment_stop(), holding_channel::role, and ast_bridge_channel::tech_pvt.

355 {
356  struct holding_channel *hc = bridge_channel->tech_pvt;
357 
358  if (!hc) {
359  return;
360  }
361 
362  switch (hc->role) {
364  participant_entertainment_stop(bridge_channel);
365  break;
366  default:
367  break;
368  }
369 }
Structure which contains per-channel role information.
static void participant_entertainment_stop(struct ast_bridge_channel *bridge_channel)
void * tech_pvt
Private information unique to the bridge technology.
enum holding_roles role

◆ holding_bridge_unsuspend()

static void holding_bridge_unsuspend ( struct ast_bridge bridge,
struct ast_bridge_channel bridge_channel 
)
static

Definition at line 371 of file bridge_holding.c.

References HOLDING_ROLE_PARTICIPANT, participant_entertainment_start(), holding_channel::role, ast_bridge_channel::tech_pvt, and ast_bridge::tech_pvt.

372 {
373  struct holding_channel *hc = bridge_channel->tech_pvt;
374  struct ast_bridge_channel *announcer_channel = bridge->tech_pvt;
375 
376  if (!hc) {
377  return;
378  }
379 
380  switch (hc->role) {
382  if (announcer_channel) {
383  /* There is an announcer channel in the bridge. */
384  break;
385  }
386  /* We need to restart the entertainment. */
387  participant_entertainment_start(bridge_channel);
388  break;
389  default:
390  break;
391  }
392 }
static void participant_entertainment_start(struct ast_bridge_channel *bridge_channel)
Structure which contains per-channel role information.
void * tech_pvt
Private information unique to the bridge technology.
Structure that contains information regarding a channel in a bridge.
void * tech_pvt
Definition: bridge.h:365
enum holding_roles role

◆ holding_bridge_write()

static int holding_bridge_write ( struct ast_bridge bridge,
struct ast_bridge_channel bridge_channel,
struct ast_frame frame 
)
static

Definition at line 331 of file bridge_holding.c.

References ast_bridge_queue_everyone_else(), HOLDING_ROLE_ANNOUNCER, NULL, holding_channel::role, and ast_bridge_channel::tech_pvt.

332 {
333  struct holding_channel *hc = bridge_channel ? bridge_channel->tech_pvt : NULL;
334 
335  /* If there is no tech_pvt, then the channel failed to allocate one when it joined and is borked. Don't listen to him. */
336  if (!hc) {
337  /* "Accept" the frame and discard it. */
338  return 0;
339  }
340 
341  switch (hc->role) {
343  /* Write the frame to all other channels if any. */
344  ast_bridge_queue_everyone_else(bridge, bridge_channel, frame);
345  break;
346  default:
347  /* "Accept" the frame and discard it. */
348  break;
349  }
350 
351  return 0;
352 }
#define NULL
Definition: resample.c:96
int ast_bridge_queue_everyone_else(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
Queue the given frame to everyone else.
Structure which contains per-channel role information.
void * tech_pvt
Private information unique to the bridge technology.
enum holding_roles role

◆ load_module()

static int load_module ( void  )
static

Definition at line 437 of file bridge_holding.c.

References ast_bridge_technology_register, AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, and unload_module().

438 {
440  unload_module();
442  }
444 }
static int unload_module(void)
#define ast_bridge_technology_register(technology)
See __ast_bridge_technology_register()
static struct ast_bridge_technology holding_bridge
Module has failed to load, may be in an inconsistent state.
Definition: module.h:78

◆ participant_entertainment_start()

static void participant_entertainment_start ( struct ast_bridge_channel bridge_channel)
static

Definition at line 188 of file bridge_holding.c.

References ast_assert, ast_bridge_channel_get_role_option(), ast_channel_start_silence_generator(), AST_CONTROL_HOLD, AST_CONTROL_RINGING, ast_indicate(), ast_indicate_data(), ast_log, ast_moh_start(), ast_bridge_channel::chan, holding_channel::entertainment_active, holding_channel::idle_mode, IDLE_MODE_HOLD, IDLE_MODE_MOH, IDLE_MODE_NONE, IDLE_MODE_RINGING, IDLE_MODE_SILENCE, LOG_WARNING, NULL, participant_idle_mode_setup(), holding_channel::silence_generator, and ast_bridge_channel::tech_pvt.

Referenced by handle_participant_join(), holding_bridge_unsuspend(), and participant_reaction_announcer_leave().

189 {
190  struct holding_channel *hc = bridge_channel->tech_pvt;
191  const char *moh_class;
192  size_t moh_length;
193 
194  ast_assert(hc != NULL);
195 
196  if (hc->entertainment_active) {
197  /* Already started */
198  return;
199  }
200  hc->entertainment_active = 1;
201 
202  participant_idle_mode_setup(bridge_channel);
203  switch(hc->idle_mode) {
204  case IDLE_MODE_MOH:
205  moh_class = ast_bridge_channel_get_role_option(bridge_channel, "holding_participant", "moh_class");
206  if (ast_moh_start(bridge_channel->chan, moh_class, NULL)) {
207  ast_log(LOG_WARNING, "Failed to start moh, starting silence generator instead\n");
210  }
211  break;
212  case IDLE_MODE_RINGING:
213  ast_indicate(bridge_channel->chan, AST_CONTROL_RINGING);
214  break;
215  case IDLE_MODE_NONE:
216  break;
217  case IDLE_MODE_SILENCE:
219  break;
220  case IDLE_MODE_HOLD:
221  moh_class = ast_bridge_channel_get_role_option(bridge_channel, "holding_participant", "moh_class");
222  moh_length = moh_class ? strlen(moh_class + 1) : 0;
223  ast_indicate_data(bridge_channel->chan, AST_CONTROL_HOLD, moh_class, moh_length);
224  break;
225  }
226 }
struct ast_silence_generator * silence_generator
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
Definition: channel.c:4322
#define LOG_WARNING
Definition: logger.h:274
enum idle_modes idle_mode
int ast_indicate_data(struct ast_channel *chan, int condition, const void *data, size_t datalen)
Indicates condition of channel, with payload.
Definition: channel.c:4698
#define ast_assert(a)
Definition: utils.h:695
#define NULL
Definition: resample.c:96
#define ast_log
Definition: astobj2.c:42
Structure which contains per-channel role information.
struct ast_silence_generator * ast_channel_start_silence_generator(struct ast_channel *chan)
Starts a silence generator on the given channel.
Definition: channel.c:8266
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
void * tech_pvt
Private information unique to the bridge technology.
struct ast_channel * chan
const char * ast_bridge_channel_get_role_option(struct ast_bridge_channel *bridge_channel, const char *role_name, const char *option)
Retrieve the value of a requested role option from a bridge channel.
Definition: bridge_roles.c:427
static void participant_idle_mode_setup(struct ast_bridge_channel *bridge_channel)
unsigned int entertainment_active

◆ participant_entertainment_stop()

static void participant_entertainment_stop ( struct ast_bridge_channel bridge_channel)
static

Definition at line 143 of file bridge_holding.c.

References ast_assert, ast_channel_stop_silence_generator(), AST_CONTROL_UNHOLD, ast_indicate(), ast_moh_stop(), ast_bridge_channel::chan, holding_channel::entertainment_active, holding_channel::idle_mode, IDLE_MODE_HOLD, IDLE_MODE_MOH, IDLE_MODE_NONE, IDLE_MODE_RINGING, IDLE_MODE_SILENCE, NULL, holding_channel::silence_generator, and ast_bridge_channel::tech_pvt.

Referenced by holding_bridge_leave(), holding_bridge_suspend(), and participant_reaction_announcer_join().

144 {
145  struct holding_channel *hc = bridge_channel->tech_pvt;
146 
147  ast_assert(hc != NULL);
148 
149  if (!hc->entertainment_active) {
150  /* Already stopped */
151  return;
152  }
153  hc->entertainment_active = 0;
154 
155  switch (hc->idle_mode) {
156  case IDLE_MODE_MOH:
157  ast_moh_stop(bridge_channel->chan);
158  break;
159  case IDLE_MODE_RINGING:
160  ast_indicate(bridge_channel->chan, -1);
161  break;
162  case IDLE_MODE_NONE:
163  break;
164  case IDLE_MODE_SILENCE:
165  if (hc->silence_generator) {
167  hc->silence_generator = NULL;
168  }
169  break;
170  case IDLE_MODE_HOLD:
171  ast_indicate(bridge_channel->chan, AST_CONTROL_UNHOLD);
172  break;
173  }
174 }
struct ast_silence_generator * silence_generator
int ast_indicate(struct ast_channel *chan, int condition)
Indicates condition of channel.
Definition: channel.c:4322
enum idle_modes idle_mode
#define ast_assert(a)
Definition: utils.h:695
#define NULL
Definition: resample.c:96
void ast_moh_stop(struct ast_channel *chan)
Turn off music on hold on a given channel.
Definition: channel.c:7876
Structure which contains per-channel role information.
void ast_channel_stop_silence_generator(struct ast_channel *chan, struct ast_silence_generator *state)
Stops a previously-started silence generator on the given channel.
Definition: channel.c:8312
void * tech_pvt
Private information unique to the bridge technology.
struct ast_channel * chan
unsigned int entertainment_active

◆ participant_idle_mode_setup()

static void participant_idle_mode_setup ( struct ast_bridge_channel bridge_channel)
static

Definition at line 116 of file bridge_holding.c.

References ast_assert, ast_bridge_channel_get_role_option(), ast_channel_name(), ast_debug, ast_strlen_zero, ast_bridge_channel::chan, holding_channel::idle_mode, IDLE_MODE_HOLD, IDLE_MODE_MOH, IDLE_MODE_NONE, IDLE_MODE_RINGING, IDLE_MODE_SILENCE, NULL, and ast_bridge_channel::tech_pvt.

Referenced by participant_entertainment_start().

117 {
118  const char *idle_mode = ast_bridge_channel_get_role_option(bridge_channel, "holding_participant", "idle_mode");
119  struct holding_channel *hc = bridge_channel->tech_pvt;
120 
121  ast_assert(hc != NULL);
122 
123  if (ast_strlen_zero(idle_mode)) {
124  hc->idle_mode = IDLE_MODE_MOH;
125  } else if (!strcmp(idle_mode, "musiconhold")) {
126  hc->idle_mode = IDLE_MODE_MOH;
127  } else if (!strcmp(idle_mode, "ringing")) {
129  } else if (!strcmp(idle_mode, "none")) {
131  } else if (!strcmp(idle_mode, "silence")) {
133  } else if (!strcmp(idle_mode, "hold")) {
135  } else {
136  /* Invalid idle mode requested. */
137  ast_debug(1, "channel %s idle mode '%s' doesn't match any defined idle mode\n",
138  ast_channel_name(bridge_channel->chan), idle_mode);
139  ast_assert(0);
140  }
141 }
enum idle_modes idle_mode
#define ast_assert(a)
Definition: utils.h:695
#define NULL
Definition: resample.c:96
#define ast_strlen_zero(foo)
Definition: strings.h:52
#define ast_debug(level,...)
Log a DEBUG message.
Definition: logger.h:452
Structure which contains per-channel role information.
void * tech_pvt
Private information unique to the bridge technology.
struct ast_channel * chan
const char * ast_channel_name(const struct ast_channel *chan)
const char * ast_bridge_channel_get_role_option(struct ast_bridge_channel *bridge_channel, const char *role_name, const char *option)
Retrieve the value of a requested role option from a bridge channel.
Definition: bridge_roles.c:427

◆ participant_reaction_announcer_join()

static void participant_reaction_announcer_join ( struct ast_bridge_channel bridge_channel)
static

Definition at line 176 of file bridge_holding.c.

References ast_channel_name(), ast_format_slin, ast_log, ast_set_write_format(), ast_bridge_channel::chan, LOG_WARNING, and participant_entertainment_stop().

Referenced by holding_bridge_join().

177 {
178  struct ast_channel *chan;
179 
180  chan = bridge_channel->chan;
181  participant_entertainment_stop(bridge_channel);
183  ast_log(LOG_WARNING, "Could not make participant %s compatible.\n", ast_channel_name(chan));
184  }
185 }
Main Channel structure associated with a channel.
#define LOG_WARNING
Definition: logger.h:274
#define ast_log
Definition: astobj2.c:42
int ast_set_write_format(struct ast_channel *chan, struct ast_format *format)
Sets write format on channel chan.
Definition: channel.c:5890
static void participant_entertainment_stop(struct ast_bridge_channel *bridge_channel)
struct ast_channel * chan
const char * ast_channel_name(const struct ast_channel *chan)
struct ast_format * ast_format_slin
Built-in cached signed linear 8kHz format.
Definition: format_cache.c:41

◆ participant_reaction_announcer_leave()

static void participant_reaction_announcer_leave ( struct ast_bridge_channel bridge_channel)
static

Definition at line 297 of file bridge_holding.c.

References ast_bridge_channel_restore_formats(), and participant_entertainment_start().

Referenced by holding_bridge_leave().

298 {
299  ast_bridge_channel_restore_formats(bridge_channel);
300  participant_entertainment_start(bridge_channel);
301 }
static void participant_entertainment_start(struct ast_bridge_channel *bridge_channel)
void ast_bridge_channel_restore_formats(struct ast_bridge_channel *bridge_channel)
Restore the formats of a bridge channel&#39;s channel to how they were before bridge_channel_internal_joi...

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 431 of file bridge_holding.c.

References ast_bridge_technology_unregister().

Referenced by load_module().

432 {
434  return 0;
435 }
int ast_bridge_technology_unregister(struct ast_bridge_technology *technology)
Unregister a bridge technology from use.
Definition: bridge.c:265
static struct ast_bridge_technology holding_bridge

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "Holding bridge module" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "30ef0c93b36035ec78c9cfd712d36d9b" , .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_DEFAULT, .support_level = AST_MODULE_SUPPORT_CORE, }
static

Definition at line 446 of file bridge_holding.c.

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 446 of file bridge_holding.c.

◆ holding_bridge

struct ast_bridge_technology holding_bridge
static

Definition at line 394 of file bridge_holding.c.