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

ConfBridge announcer channel driver. More...

#include "asterisk.h"
#include "asterisk/channel.h"
#include "asterisk/bridge.h"
#include "asterisk/core_unreal.h"
#include "include/confbridge.h"
Include dependency graph for conf_chan_announce.c:

Go to the source code of this file.

Data Structures

struct  announce_pvt
 

Functions

static int announce_call (struct ast_channel *chan, const char *addr, int timeout)
 
static int announce_hangup (struct ast_channel *ast)
 
static void announce_pvt_destructor (void *vdoomed)
 
static struct ast_channelannounce_request (const char *type, struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *data, int *cause)
 
int conf_announce_channel_push (struct ast_channel *ast)
 Push the announcer channel into the conference. More...
 
struct ast_channel_techconf_announce_get_tech (void)
 Get ConfBridge announce channel technology struct. More...
 

Variables

static struct ast_channel_tech announce_tech
 

Detailed Description

ConfBridge announcer channel driver.

Author
Richard Mudgett rmudg.nosp@m.ett@.nosp@m.digiu.nosp@m.m.co.nosp@m.m

See Also:

Definition in file conf_chan_announce.c.

Function Documentation

◆ announce_call()

static int announce_call ( struct ast_channel chan,
const char *  addr,
int  timeout 
)
static

Definition at line 47 of file conf_chan_announce.c.

48 {
49  /* Make sure anyone calling ast_call() for this channel driver is going to fail. */
50  return -1;
51 }

◆ announce_hangup()

static int announce_hangup ( struct ast_channel ast)
static

Definition at line 53 of file conf_chan_announce.c.

References ao2_ref, ast_channel_tech_pvt(), ast_unreal_hangup(), and announce_pvt::base.

54 {
55  struct announce_pvt *p = ast_channel_tech_pvt(ast);
56  int res;
57 
58  if (!p) {
59  return -1;
60  }
61 
62  /* give the pvt a ref to fulfill calling requirements. */
63  ao2_ref(p, +1);
64  res = ast_unreal_hangup(&p->base, ast);
65  ao2_ref(p, -1);
66 
67  return res;
68 }
void * ast_channel_tech_pvt(const struct ast_channel *chan)
struct ast_unreal_pvt base
#define ao2_ref(o, delta)
Definition: astobj2.h:464
int ast_unreal_hangup(struct ast_unreal_pvt *p, struct ast_channel *ast)
Hangup one end (maybe both ends) of an unreal channel derivative.
Definition: core_unreal.c:1018

◆ announce_pvt_destructor()

static void announce_pvt_destructor ( void *  vdoomed)
static

Definition at line 70 of file conf_chan_announce.c.

References ao2_cleanup, ast_unreal_destructor(), announce_pvt::base, announce_pvt::bridge, and NULL.

Referenced by announce_request().

71 {
72  struct announce_pvt *doomed = vdoomed;
73 
74  ao2_cleanup(doomed->bridge);
75  doomed->bridge = NULL;
76  ast_unreal_destructor(&doomed->base);
77 }
#define NULL
Definition: resample.c:96
struct ast_unreal_pvt base
void ast_unreal_destructor(void *vdoomed)
struct ast_unreal_pvt destructor.
Definition: core_unreal.c:1099
struct ast_bridge * bridge
#define ao2_cleanup(obj)
Definition: astobj2.h:1958

◆ announce_request()

static struct ast_channel* announce_request ( const char *  type,
struct ast_format_cap cap,
const struct ast_assigned_ids assignedids,
const struct ast_channel requestor,
const char *  data,
int *  cause 
)
static

Definition at line 79 of file conf_chan_announce.c.

References announce_pvt_destructor(), ao2_cleanup, ao2_find, ao2_ref, ast_answer(), ast_assert, ast_channel_add_bridge_role(), ast_copy_string(), ast_hangup(), ast_set_flag, AST_STATE_UP, ast_unreal_alloc(), ast_unreal_new_channels(), AST_UNREAL_NO_OPTIMIZATION, conf_announce_get_tech(), conference_bridges, ast_channel::data, NULL, OBJ_KEY, and RAII_VAR.

80 {
81  struct ast_channel *chan;
82  const char *conf_name = data;
83  RAII_VAR(struct confbridge_conference *, conference, NULL, ao2_cleanup);
84  RAII_VAR(struct announce_pvt *, pvt, NULL, ao2_cleanup);
85 
86  conference = ao2_find(conference_bridges, conf_name, OBJ_KEY);
87  if (!conference) {
88  return NULL;
89  }
90  ast_assert(conference->bridge != NULL);
91 
92  /* Allocate a new private structure and then Asterisk channels */
93  pvt = (struct announce_pvt *) ast_unreal_alloc(sizeof(*pvt), announce_pvt_destructor,
94  cap);
95  if (!pvt) {
96  return NULL;
97  }
99  ast_copy_string(pvt->base.name, conf_name, sizeof(pvt->base.name));
100  pvt->bridge = conference->bridge;
101  ao2_ref(pvt->bridge, +1);
102 
103  chan = ast_unreal_new_channels(&pvt->base, conf_announce_get_tech(),
104  AST_STATE_UP, AST_STATE_UP, NULL, NULL, assignedids, requestor, 0);
105  if (chan) {
106  ast_answer(pvt->base.owner);
107  ast_answer(pvt->base.chan);
108  if (ast_channel_add_bridge_role(pvt->base.chan, "announcer")) {
109  ast_hangup(chan);
110  chan = NULL;
111  }
112  }
113 
114  return chan;
115 }
Main Channel structure associated with a channel.
#define OBJ_KEY
Definition: astobj2.h:1155
#define ast_set_flag(p, flag)
Definition: utils.h:70
struct ast_unreal_pvt * ast_unreal_alloc(size_t size, ao2_destructor_fn destructor, struct ast_format_cap *cap)
Allocate the base unreal struct for a derivative.
Definition: core_unreal.c:1111
#define AST_UNREAL_NO_OPTIMIZATION
Definition: core_unreal.h:108
#define ast_assert(a)
Definition: utils.h:695
struct ast_channel * ast_unreal_new_channels(struct ast_unreal_pvt *p, const struct ast_channel_tech *tech, int semi1_state, int semi2_state, const char *exten, const char *context, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, ast_callid callid)
Create the semi1 and semi2 unreal channels.
Definition: core_unreal.c:1162
int ast_channel_add_bridge_role(struct ast_channel *chan, const char *role_name)
Adds a bridge role to a channel.
Definition: bridge_roles.c:317
#define NULL
Definition: resample.c:96
const char * data
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
#define ao2_ref(o, delta)
Definition: astobj2.h:464
struct ast_channel_tech * conf_announce_get_tech(void)
Get ConfBridge announce channel technology struct.
struct ao2_container * conference_bridges
Container to hold all conference bridges in progress.
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition: channel.c:2548
The structure that represents a conference bridge.
Definition: confbridge.h:244
#define ao2_find(container, arg, flags)
Definition: astobj2.h:1756
#define ao2_cleanup(obj)
Definition: astobj2.h:1958
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:401
int ast_answer(struct ast_channel *chan)
Answer a channel.
Definition: channel.c:2814
static void announce_pvt_destructor(void *vdoomed)

◆ conf_announce_channel_push()

int conf_announce_channel_push ( struct ast_channel ast)

Push the announcer channel into the conference.

Since
12.0.0
Parameters
astEither channel in the announcer channel pair.
Return values
0on success.
-1on error.

Definition at line 144 of file conf_chan_announce.c.

References ao2_cleanup, ao2_lock, ao2_ref, ao2_unlock, AST_BRIDGE_CHANNEL_FLAG_IMMOVABLE, ast_bridge_features_new(), ast_bridge_impart(), AST_BRIDGE_IMPART_CHAN_INDEPENDENT, ast_channel_tech_pvt(), ast_set_flag, AST_UNREAL_CARETAKER_THREAD, ast_bridge_features::feature_flags, lock, NULL, RAII_VAR, and SCOPED_CHANNELLOCK.

Referenced by push_announcer().

145 {
146  struct ast_bridge_features *features;
147  struct ast_channel *chan;
148  RAII_VAR(struct announce_pvt *, p, NULL, ao2_cleanup);
149 
150  {
151  SCOPED_CHANNELLOCK(lock, ast);
152 
153  p = ast_channel_tech_pvt(ast);
154  if (!p) {
155  return -1;
156  }
157  ao2_ref(p, +1);
158  chan = p->base.chan;
159  if (!chan) {
160  return -1;
161  }
162  }
163 
164  features = ast_bridge_features_new();
165  if (!features) {
166  return -1;
167  }
169 
170  /* Impart the output channel into the bridge */
171  if (ast_bridge_impart(p->bridge, chan, NULL, features,
173  return -1;
174  }
175  ao2_lock(p);
177  ao2_unlock(p);
178  return 0;
179 }
Main Channel structure associated with a channel.
Structure that contains features information.
void * ast_channel_tech_pvt(const struct ast_channel *chan)
#define ast_set_flag(p, flag)
Definition: utils.h:70
#define AST_UNREAL_CARETAKER_THREAD
Definition: core_unreal.h:107
#define ao2_unlock(a)
Definition: astobj2.h:730
#define NULL
Definition: resample.c:96
struct ast_flags feature_flags
int ast_bridge_impart(struct ast_bridge *bridge, struct ast_channel *chan, struct ast_channel *swap, struct ast_bridge_features *features, enum ast_bridge_impart_flags flags) attribute_warn_unused_result
Impart a channel to a bridge (non-blocking)
Definition: bridge.c:1924
#define SCOPED_CHANNELLOCK(varname, chan)
scoped lock specialization for channels.
Definition: lock.h:617
#define RAII_VAR(vartype, varname, initval, dtor)
Declare a variable that will call a destructor function when it goes out of scope.
Definition: utils.h:911
ast_mutex_t lock
Definition: app_meetme.c:1091
#define ao2_ref(o, delta)
Definition: astobj2.h:464
#define ao2_lock(a)
Definition: astobj2.h:718
struct ast_bridge_features * ast_bridge_features_new(void)
Allocate a new bridge features struct.
Definition: bridge.c:3750
#define ao2_cleanup(obj)
Definition: astobj2.h:1958

◆ conf_announce_get_tech()

struct ast_channel_tech* conf_announce_get_tech ( void  )

Get ConfBridge announce channel technology struct.

Since
12.0.0
Returns
ConfBridge announce channel technology.

Definition at line 139 of file conf_chan_announce.c.

References announce_tech.

Referenced by announce_request(), load_module(), and unload_module().

140 {
141  return &announce_tech;
142 }
static struct ast_channel_tech announce_tech

Variable Documentation

◆ announce_tech

struct ast_channel_tech announce_tech
static

Definition at line 117 of file conf_chan_announce.c.

Referenced by conf_announce_get_tech().