Asterisk - The Open Source Telephony Project  18.5.0
Functions | Variables
chan_bridge_media.c File Reference

Bridge Media Channels driver. More...

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

Go to the source code of this file.

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
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)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static void cleanup_capabilities (void)
 
static int load_module (void)
 
static int media_call (struct ast_channel *chan, const char *addr, int timeout)
 
static int media_hangup (struct ast_channel *ast)
 
static struct ast_channelmedia_request_helper (struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *data, struct ast_channel_tech *tech, const char *role)
 
static struct ast_channelrecord_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 int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Bridge Media Channel Driver" , .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" , .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, }
 
static struct ast_channel_tech announce_tech
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static struct ast_channel_tech record_tech
 

Detailed Description

Bridge Media Channels driver.

Author
Jonathan Rose jrose.nosp@m.@dig.nosp@m.ium.c.nosp@m.om
Richard Mudgett rmudg.nosp@m.ett@.nosp@m.digiu.nosp@m.m.co.nosp@m.m

Bridge Media Channels

Definition in file chan_bridge_media.c.

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 219 of file chan_bridge_media.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 219 of file chan_bridge_media.c.

◆ 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 150 of file chan_bridge_media.c.

References media_request_helper().

Referenced by media_hangup().

152 {
153  return media_request_helper(cap, assignedids, requestor, data, &announce_tech, "announcer");
154 }
static struct ast_channel_tech announce_tech
static struct ast_channel * media_request_helper(struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *data, struct ast_channel_tech *tech, const char *role)

◆ AST_MODULE_SELF_SYM()

struct ast_module* AST_MODULE_SELF_SYM ( void  )

Definition at line 219 of file chan_bridge_media.c.

◆ cleanup_capabilities()

static void cleanup_capabilities ( void  )
static

Definition at line 162 of file chan_bridge_media.c.

References ao2_ref, ast_channel_tech::capabilities, and NULL.

Referenced by load_module(), and unload_module().

163 {
167  }
168 
172  }
173 }
#define NULL
Definition: resample.c:96
#define ao2_ref(o, delta)
Definition: astobj2.h:464
static struct ast_channel_tech announce_tech
struct ast_format_cap * capabilities
Definition: channel.h:633
static struct ast_channel_tech record_tech

◆ load_module()

static int load_module ( void  )
static

Definition at line 183 of file chan_bridge_media.c.

References ast_channel_register(), ast_format_cap_alloc, ast_format_cap_append_by_type(), AST_FORMAT_CAP_FLAG_DEFAULT, ast_log, AST_MEDIA_TYPE_UNKNOWN, AST_MODFLAG_DEFAULT, AST_MODULE_INFO(), AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, AST_MODULE_SUPPORT_CORE, ASTERISK_GPL_KEY, ast_channel_tech::capabilities, cleanup_capabilities(), ast_channel_tech::description, LOG_ERROR, ast_channel_tech::type, and unload_module().

184 {
188  }
189 
191  if (!record_tech.capabilities) {
193  }
194 
197 
199  ast_log(LOG_ERROR, "Unable to register channel technology %s(%s).\n",
203  }
204 
206  ast_log(LOG_ERROR, "Unable to register channel technology %s(%s).\n",
210  }
211 
213 }
const char *const type
Definition: channel.h:630
int ast_format_cap_append_by_type(struct ast_format_cap *cap, enum ast_media_type type)
Add all codecs Asterisk knows about for a specific type to the capabilities structure.
Definition: format_cap.c:216
int ast_channel_register(const struct ast_channel_tech *tech)
Register a channel technology (a new channel driver) Called by a channel module to register the kind ...
Definition: channel.c:539
#define ast_log
Definition: astobj2.c:42
#define ast_format_cap_alloc(flags)
Definition: format_cap.h:52
#define LOG_ERROR
Definition: logger.h:285
static struct ast_channel_tech announce_tech
struct ast_format_cap * capabilities
Definition: channel.h:633
Module has failed to load, may be in an inconsistent state.
Definition: module.h:78
const char *const description
Definition: channel.h:631
static struct ast_channel_tech record_tech
static void cleanup_capabilities(void)

◆ media_call()

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

Definition at line 42 of file chan_bridge_media.c.

43 {
44  /* ast_call() will fail unconditionally against channels provided by this driver */
45  return -1;
46 }

◆ media_hangup()

static int media_hangup ( struct ast_channel ast)
static

Definition at line 48 of file chan_bridge_media.c.

References announce_request(), ao2_ref, ast_channel_tech_pvt(), ast_unreal_hangup(), ast_channel::data, record_request(), and type.

49 {
50  struct ast_unreal_pvt *p = ast_channel_tech_pvt(ast);
51  int res;
52 
53  if (!p) {
54  return -1;
55  }
56 
57  /* Give the pvt a ref to fulfill calling requirements. */
58  ao2_ref(p, +1);
59  res = ast_unreal_hangup(p, ast);
60  ao2_ref(p, -1);
61 
62  return res;
63 }
void * ast_channel_tech_pvt(const struct ast_channel *chan)
#define ao2_ref(o, delta)
Definition: astobj2.h:464
The base pvt structure for local channel derivatives.
Definition: core_unreal.h:91
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

◆ media_request_helper()

static struct ast_channel* media_request_helper ( struct ast_format_cap cap,
const struct ast_assigned_ids assignedids,
const struct ast_channel requestor,
const char *  data,
struct ast_channel_tech tech,
const char *  role 
)
static

Definition at line 115 of file chan_bridge_media.c.

References ao2_cleanup, ast_answer(), ast_channel_add_bridge_role(), ast_copy_string(), ast_hangup(), ast_read_threadstorage_callid(), ast_set_flag, AST_STATE_UP, ast_unreal_alloc(), ast_unreal_destructor(), ast_unreal_new_channels(), AST_UNREAL_NO_OPTIMIZATION, ast_channel::callid, NULL, and RAII_VAR.

Referenced by announce_request(), and record_request().

117 {
118  struct ast_channel *chan;
120 
121  RAII_VAR(struct ast_unreal_pvt *, pvt, NULL, ao2_cleanup);
122 
123  if (!(pvt = ast_unreal_alloc(sizeof(*pvt), ast_unreal_destructor, cap))) {
124  return NULL;
125  }
126 
127  ast_copy_string(pvt->name, data, sizeof(pvt->name));
128 
130 
132 
133  chan = ast_unreal_new_channels(pvt, tech,
134  AST_STATE_UP, AST_STATE_UP, NULL, NULL, assignedids, requestor, callid);
135  if (!chan) {
136  return NULL;
137  }
138 
139  ast_answer(pvt->owner);
140  ast_answer(pvt->chan);
141 
142  if (ast_channel_add_bridge_role(pvt->chan, role)) {
143  ast_hangup(chan);
144  return NULL;
145  }
146 
147  return chan;
148 }
Main Channel structure associated with a channel.
#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
unsigned int ast_callid
Definition: logger.h:87
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
ast_callid ast_read_threadstorage_callid(void)
extracts the callerid from the thread
Definition: logger.c:1962
#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
void ast_unreal_destructor(void *vdoomed)
struct ast_unreal_pvt destructor.
Definition: core_unreal.c:1099
The base pvt structure for local channel derivatives.
Definition: core_unreal.h:91
void ast_hangup(struct ast_channel *chan)
Hang up a channel.
Definition: channel.c:2548
#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

◆ record_request()

static struct ast_channel * record_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 156 of file chan_bridge_media.c.

References media_request_helper().

Referenced by media_hangup().

158 {
159  return media_request_helper(cap, assignedids, requestor, data, &record_tech, "recorder");
160 }
const char * data
static struct ast_channel_tech record_tech
static struct ast_channel * media_request_helper(struct ast_format_cap *cap, const struct ast_assigned_ids *assignedids, const struct ast_channel *requestor, const char *data, struct ast_channel_tech *tech, const char *role)

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 175 of file chan_bridge_media.c.

References ast_channel_unregister(), and cleanup_capabilities().

Referenced by load_module().

176 {
180  return 0;
181 }
void ast_channel_unregister(const struct ast_channel_tech *tech)
Unregister a channel technology.
Definition: channel.c:570
static struct ast_channel_tech announce_tech
static struct ast_channel_tech record_tech
static void cleanup_capabilities(void)

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "Bridge Media Channel Driver" , .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" , .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, }
static

Definition at line 219 of file chan_bridge_media.c.

◆ announce_tech

struct ast_channel_tech announce_tech
static

Definition at line 71 of file chan_bridge_media.c.

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 219 of file chan_bridge_media.c.

◆ record_tech

struct ast_channel_tech record_tech
static

Definition at line 93 of file chan_bridge_media.c.