Asterisk - The Open Source Telephony Project  21.4.1
Data Structures | Macros | Enumerations | Functions
bridge_technology.h File Reference

Channel Bridging API. More...

Go to the source code of this file.

Data Structures

struct  ast_bridge_tech_optimizations
 Structure specific to bridge technologies capable of performing talking optimizations. More...
 
struct  ast_bridge_technology
 Structure that is the essence of a bridge technology. More...
 

Macros

#define ast_bridge_technology_register(technology)   __ast_bridge_technology_register(technology, AST_MODULE_SELF)
 See __ast_bridge_technology_register()
 

Enumerations

enum  ast_bridge_preference {
  AST_BRIDGE_PREFERENCE_BASE_HOLDING = 50, AST_BRIDGE_PREFERENCE_BASE_EARLY = 100, AST_BRIDGE_PREFERENCE_BASE_NATIVE = 90, AST_BRIDGE_PREFERENCE_BASE_1TO1MIX = 50,
  AST_BRIDGE_PREFERENCE_BASE_MULTIMIX = 10
}
 Base preference values for choosing a bridge technology. More...
 

Functions

int __ast_bridge_technology_register (struct ast_bridge_technology *technology, struct ast_module *mod)
 Register a bridge technology for use. More...
 
void ast_bridge_technology_suspend (struct ast_bridge_technology *technology)
 Suspend a bridge technology from consideration. More...
 
int ast_bridge_technology_unregister (struct ast_bridge_technology *technology)
 Unregister a bridge technology from use. More...
 
void ast_bridge_technology_unsuspend (struct ast_bridge_technology *technology)
 Unsuspend a bridge technology. More...
 

Detailed Description

Channel Bridging API.

Author
Joshua Colp jcolp.nosp@m.@dig.nosp@m.ium.c.nosp@m.om

Definition in file bridge_technology.h.

Enumeration Type Documentation

Base preference values for choosing a bridge technology.

Note
Higher is more preference.

Definition at line 36 of file bridge_technology.h.

36  {
37  AST_BRIDGE_PREFERENCE_BASE_HOLDING = 50,
38  AST_BRIDGE_PREFERENCE_BASE_EARLY = 100,
39  AST_BRIDGE_PREFERENCE_BASE_NATIVE = 90,
40  AST_BRIDGE_PREFERENCE_BASE_1TO1MIX = 50,
41  AST_BRIDGE_PREFERENCE_BASE_MULTIMIX = 10,
42 };

Function Documentation

int __ast_bridge_technology_register ( struct ast_bridge_technology technology,
struct ast_module mod 
)

Register a bridge technology for use.

Parameters
technologyThe bridge technology to register
modThe module that is registering the bridge technology
Return values
0on success
-1on failure

Example usage:

1 ast_bridge_technology_register(&simple_bridge_tech);

This registers a bridge technology declared as the structure simple_bridge_tech with the bridging core and makes it available for use when creating bridges.

Definition at line 212 of file bridge.c.

References AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_bridge_technology::capabilities, ast_bridge_technology::mod, ast_bridge_technology::name, ast_bridge_technology::preference, and ast_bridge_technology::write.

213 {
214  struct ast_bridge_technology *current;
215 
216  /* Perform a sanity check to make sure the bridge technology conforms to our needed requirements */
217  if (ast_strlen_zero(technology->name)
218  || !technology->capabilities
219  || !technology->write) {
220  ast_log(LOG_WARNING, "Bridge technology %s failed registration sanity check.\n",
221  technology->name);
222  return -1;
223  }
224 
226 
227  /* Look for duplicate bridge technology already using this name, or already registered */
228  AST_RWLIST_TRAVERSE(&bridge_technologies, current, entry) {
229  if ((!strcasecmp(current->name, technology->name)) || (current == technology)) {
230  ast_log(LOG_WARNING, "A bridge technology of %s already claims to exist in our world.\n",
231  technology->name);
233  return -1;
234  }
235  }
236 
237  /* Copy module pointer so reference counting can keep the module from unloading */
238  technology->mod = module;
239 
240  /* Find the correct position to insert the technology. */
241  AST_RWLIST_TRAVERSE_SAFE_BEGIN(&bridge_technologies, current, entry) {
242  /* Put the highest preference tech's first in the list. */
243  if (technology->preference >= current->preference) {
244  AST_RWLIST_INSERT_BEFORE_CURRENT(technology, entry);
245 
246  break;
247  }
248  }
249  AST_RWLIST_TRAVERSE_SAFE_END;
250 
251  if (!current) {
252  /* Insert our new bridge technology to the end of the list. */
253  AST_RWLIST_INSERT_TAIL(&bridge_technologies, technology, entry);
254  }
255 
257 
258  ast_verb(5, "Registered bridge technology %s\n", technology->name);
259 
260  return 0;
261 }
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:52
int(* write)(struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_frame *frame)
Write a frame into the bridging technology instance for a bridge.
enum ast_bridge_preference preference
struct ast_module * mod
Structure that is the essence of a bridge technology.
Definition: search.h:40
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:151
void ast_bridge_technology_suspend ( struct ast_bridge_technology technology)

Suspend a bridge technology from consideration.

Parameters
technologyThe bridge technology to suspend

Example usage:

1 ast_bridge_technology_suspend(&simple_bridge_tech);

This suspends the bridge technology simple_bridge_tech from being considered when creating a new bridge. Existing bridges using the bridge technology are not affected.

Definition at line 3047 of file bridge.c.

References ast_bridge_technology::suspended.

3048 {
3049  technology->suspended = 1;
3050 }
int ast_bridge_technology_unregister ( struct ast_bridge_technology technology)

Unregister a bridge technology from use.

Parameters
technologyThe bridge technology to unregister
Return values
0on success
-1on failure

Example usage:

1 ast_bridge_technology_unregister(&simple_bridge_tech);

This unregisters a bridge technlogy declared as the structure simple_bridge_tech with the bridging core. It will no longer be considered when creating a new bridge.

Definition at line 263 of file bridge.c.

References AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, and ast_bridge_technology::name.

264 {
265  struct ast_bridge_technology *current;
266 
268 
269  /* Ensure the bridge technology is registered before removing it */
270  AST_RWLIST_TRAVERSE_SAFE_BEGIN(&bridge_technologies, current, entry) {
271  if (current == technology) {
272  AST_RWLIST_REMOVE_CURRENT(entry);
273  ast_verb(5, "Unregistered bridge technology %s\n", technology->name);
274  break;
275  }
276  }
277  AST_RWLIST_TRAVERSE_SAFE_END;
278 
280 
281  return current ? 0 : -1;
282 }
#define AST_RWLIST_WRLOCK(head)
Write locks a list.
Definition: linkedlists.h:52
Structure that is the essence of a bridge technology.
Definition: search.h:40
#define AST_RWLIST_UNLOCK(head)
Attempts to unlock a read/write based list.
Definition: linkedlists.h:151
void ast_bridge_technology_unsuspend ( struct ast_bridge_technology technology)

Unsuspend a bridge technology.

Parameters
technologyThe bridge technology to unsuspend

Example usage:

1 ast_bridge_technology_unsuspend(&simple_bridge_tech);

This makes the bridge technology simple_bridge_tech considered when creating a new bridge again.

Definition at line 3052 of file bridge.c.

References ast_bridge_technology::suspended.

3053 {
3054  /*
3055  * XXX We may want the act of unsuspending a bridge technology
3056  * to prod all existing bridges to see if they should start
3057  * using it.
3058  */
3059  technology->suspended = 0;
3060 }