Channel Bridging API. More...
Go to the source code of this file.
Data Structures | |
struct | ast_bridge_technology |
Structure that is the essence of a bridge technology. More... | |
Defines | |
#define | ast_bridge_technology_register(technology) __ast_bridge_technology_register(technology, ast_module_info->self) |
See __ast_bridge_technology_register(). | |
Enumerations | |
enum | ast_bridge_preference { AST_BRIDGE_PREFERENCE_HIGH = 0, AST_BRIDGE_PREFERENCE_MEDIUM, AST_BRIDGE_PREFERENCE_LOW } |
Preference for choosing the bridge technology. More... | |
Functions | |
int | __ast_bridge_technology_register (struct ast_bridge_technology *technology, struct ast_module *mod) |
Register a bridge technology for use. | |
void | ast_bridge_handle_trip (struct ast_bridge *bridge, struct ast_bridge_channel *bridge_channel, struct ast_channel *chan, int outfd) |
Feed notification that a frame is waiting on a channel into the bridging core. | |
void | ast_bridge_technology_suspend (struct ast_bridge_technology *technology) |
Suspend a bridge technology from consideration. | |
int | ast_bridge_technology_unregister (struct ast_bridge_technology *technology) |
Unregister a bridge technology from use. | |
void | ast_bridge_technology_unsuspend (struct ast_bridge_technology *technology) |
Unsuspend a bridge technology. |
Channel Bridging API.
Definition in file bridging_technology.h.
#define ast_bridge_technology_register | ( | technology | ) | __ast_bridge_technology_register(technology, ast_module_info->self) |
See __ast_bridge_technology_register().
Definition at line 104 of file bridging_technology.h.
Referenced by load_module().
Preference for choosing the bridge technology.
Definition at line 32 of file bridging_technology.h.
00032 { 00033 /*! Bridge technology should have high precedence over other bridge technologies */ 00034 AST_BRIDGE_PREFERENCE_HIGH = 0, 00035 /*! Bridge technology is decent, not the best but should still be considered over low */ 00036 AST_BRIDGE_PREFERENCE_MEDIUM, 00037 /*! Bridge technology is low, it should not be considered unless it is absolutely needed */ 00038 AST_BRIDGE_PREFERENCE_LOW, 00039 };
int __ast_bridge_technology_register | ( | struct ast_bridge_technology * | technology, | |
struct ast_module * | mod | |||
) |
Register a bridge technology for use.
technology | The bridge technology to register | |
mod | The module that is registering the bridge technology |
0 | on success | |
-1 | on failure |
Example usage:
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 63 of file bridging.c.
References ast_log(), AST_RWLIST_INSERT_TAIL, AST_RWLIST_TRAVERSE, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_strlen_zero(), ast_verbose, ast_bridge_technology::capabilities, LOG_WARNING, ast_bridge_technology::mod, ast_bridge_technology::name, option_verbose, VERBOSE_PREFIX_2, and ast_bridge_technology::write.
00064 { 00065 struct ast_bridge_technology *current = NULL; 00066 00067 /* Perform a sanity check to make sure the bridge technology conforms to our needed requirements */ 00068 if (ast_strlen_zero(technology->name) || !technology->capabilities || !technology->write) { 00069 ast_log(LOG_WARNING, "Bridge technology %s failed registration sanity check.\n", technology->name); 00070 return -1; 00071 } 00072 00073 AST_RWLIST_WRLOCK(&bridge_technologies); 00074 00075 /* Look for duplicate bridge technology already using this name, or already registered */ 00076 AST_RWLIST_TRAVERSE(&bridge_technologies, current, entry) { 00077 if ((!strcasecmp(current->name, technology->name)) || (current == technology)) { 00078 ast_log(LOG_WARNING, "A bridge technology of %s already claims to exist in our world.\n", technology->name); 00079 AST_RWLIST_UNLOCK(&bridge_technologies); 00080 return -1; 00081 } 00082 } 00083 00084 /* Copy module pointer so reference counting can keep the module from unloading */ 00085 technology->mod = module; 00086 00087 /* Insert our new bridge technology into the list and print out a pretty message */ 00088 AST_RWLIST_INSERT_TAIL(&bridge_technologies, technology, entry); 00089 00090 AST_RWLIST_UNLOCK(&bridge_technologies); 00091 00092 if (option_verbose > 1) { 00093 ast_verbose(VERBOSE_PREFIX_2 "Registered bridge technology %s\n", technology->name); 00094 } 00095 00096 return 0; 00097 }
void ast_bridge_handle_trip | ( | struct ast_bridge * | bridge, | |
struct ast_bridge_channel * | bridge_channel, | |||
struct ast_channel * | chan, | |||
int | outfd | |||
) |
Feed notification that a frame is waiting on a channel into the bridging core.
bridge | The bridge that the notification should influence | |
bridge_channel | Bridge channel the notification was received on (if known) | |
chan | Channel the notification was received on (if known) | |
outfd | File descriptor that the notification was received on (if known) |
Example usage:
ast_bridge_handle_trip(bridge, NULL, chan, -1);
This tells the bridging core that a frame has been received on the channel pointed to by chan and that it should be read and handled.
Definition at line 277 of file bridging.c.
References ast_bridge_change_state(), AST_BRIDGE_CHANNEL_STATE_END, AST_CONTROL_HANGUP, ast_debug, AST_FRAME_CONTROL, AST_FRAME_DTMF_BEGIN, ast_frfree, ast_read(), ast_read_noaudio(), bridge_drop_control_frame(), bridge_handle_dtmf(), ast_bridge_technology::fd, ast_bridge_channel::features, ast_bridge::features, find_bridge_channel(), ast_frame::frametype, ast_frame_subclass::integer, ast_bridge_features::mute, ast_bridge_technology::poke, ast_frame::subclass, ast_bridge::technology, and ast_bridge_technology::write.
Referenced by bridge_channel_join_multithreaded(), generic_thread_loop(), and multiplexed_thread_function().
00278 { 00279 /* If no bridge channel has been provided and the actual channel has been provided find it */ 00280 if (chan && !bridge_channel) { 00281 bridge_channel = find_bridge_channel(bridge, chan); 00282 } 00283 00284 /* If a bridge channel with actual channel is present read a frame and handle it */ 00285 if (chan && bridge_channel) { 00286 struct ast_frame *frame = (((bridge->features.mute) || (bridge_channel->features && bridge_channel->features->mute)) ? ast_read_noaudio(chan) : ast_read(chan)); 00287 00288 /* This is pretty simple... see if they hung up */ 00289 if (!frame || (frame->frametype == AST_FRAME_CONTROL && frame->subclass.integer == AST_CONTROL_HANGUP)) { 00290 /* Signal the thread that is handling the bridged channel that it should be ended */ 00291 ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END); 00292 } else if (frame->frametype == AST_FRAME_CONTROL && bridge_drop_control_frame(frame->subclass.integer)) { 00293 ast_debug(1, "Dropping control frame from bridge channel %p\n", bridge_channel); 00294 } else { 00295 if (frame->frametype == AST_FRAME_DTMF_BEGIN) { 00296 frame = bridge_handle_dtmf(bridge, bridge_channel, frame); 00297 } 00298 /* Simply write the frame out to the bridge technology if it still exists */ 00299 if (frame) { 00300 bridge->technology->write(bridge, bridge_channel, frame); 00301 } 00302 } 00303 00304 if (frame) { 00305 ast_frfree(frame); 00306 } 00307 return; 00308 } 00309 00310 /* If a file descriptor actually tripped pass it off to the bridge technology */ 00311 if (outfd > -1 && bridge->technology->fd) { 00312 bridge->technology->fd(bridge, bridge_channel, outfd); 00313 return; 00314 } 00315 00316 /* If all else fails just poke the bridge */ 00317 if (bridge->technology->poke && bridge_channel) { 00318 bridge->technology->poke(bridge, bridge_channel); 00319 return; 00320 } 00321 00322 return; 00323 }
void ast_bridge_technology_suspend | ( | struct ast_bridge_technology * | technology | ) |
Suspend a bridge technology from consideration.
technology | The bridge technology to suspend |
Example usage:
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 1236 of file bridging.c.
References ast_bridge_technology::suspended.
01237 { 01238 technology->suspended = 1; 01239 return; 01240 }
int ast_bridge_technology_unregister | ( | struct ast_bridge_technology * | technology | ) |
Unregister a bridge technology from use.
technology | The bridge technology to unregister |
0 | on success | |
-1 | on failure |
Example usage:
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 99 of file bridging.c.
References AST_RWLIST_REMOVE_CURRENT, AST_RWLIST_TRAVERSE_SAFE_BEGIN, AST_RWLIST_TRAVERSE_SAFE_END, AST_RWLIST_UNLOCK, AST_RWLIST_WRLOCK, ast_verbose, ast_bridge_technology::name, option_verbose, and VERBOSE_PREFIX_2.
Referenced by unload_module().
00100 { 00101 struct ast_bridge_technology *current = NULL; 00102 00103 AST_RWLIST_WRLOCK(&bridge_technologies); 00104 00105 /* Ensure the bridge technology is registered before removing it */ 00106 AST_RWLIST_TRAVERSE_SAFE_BEGIN(&bridge_technologies, current, entry) { 00107 if (current == technology) { 00108 AST_RWLIST_REMOVE_CURRENT(entry); 00109 if (option_verbose > 1) { 00110 ast_verbose(VERBOSE_PREFIX_2 "Unregistered bridge technology %s\n", technology->name); 00111 } 00112 break; 00113 } 00114 } 00115 AST_RWLIST_TRAVERSE_SAFE_END; 00116 00117 AST_RWLIST_UNLOCK(&bridge_technologies); 00118 00119 return current ? 0 : -1; 00120 }
void ast_bridge_technology_unsuspend | ( | struct ast_bridge_technology * | technology | ) |
Unsuspend a bridge technology.
technology | The bridge technology to unsuspend |
Example usage:
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 1242 of file bridging.c.
References ast_bridge_technology::suspended.
01243 { 01244 technology->suspended = 0; 01245 return; 01246 }