#include "asterisk/bridging_features.h"
#include "asterisk/dsp.h"


Go to the source code of this file.
Data Structures | |
| struct | ast_bridge |
| Structure that contains information about a bridge. More... | |
| struct | ast_bridge_channel |
| Structure that contains information regarding a channel in a bridge. More... | |
| struct | ast_bridge_tech_optimizations |
| Structure specific to bridge technologies capable of performing talking optimizations. More... | |
| struct | ast_bridge_video_mode |
| struct | ast_bridge_video_single_src_data |
| struct | ast_bridge_video_talker_src_data |
Enumerations | |
| enum | ast_bridge_capability { AST_BRIDGE_CAPABILITY_1TO1MIX = (1 << 1), AST_BRIDGE_CAPABILITY_MULTIMIX = (1 << 2), AST_BRIDGE_CAPABILITY_NATIVE = (1 << 3), AST_BRIDGE_CAPABILITY_MULTITHREADED = (1 << 4), AST_BRIDGE_CAPABILITY_THREAD = (1 << 5), AST_BRIDGE_CAPABILITY_VIDEO = (1 << 6), AST_BRIDGE_CAPABILITY_OPTIMIZE = (1 << 7) } |
| Capabilities for a bridge technology. More... | |
| enum | ast_bridge_channel_state { AST_BRIDGE_CHANNEL_STATE_WAIT = 0, AST_BRIDGE_CHANNEL_STATE_END, AST_BRIDGE_CHANNEL_STATE_HANGUP, AST_BRIDGE_CHANNEL_STATE_DEPART, AST_BRIDGE_CHANNEL_STATE_FEATURE, AST_BRIDGE_CHANNEL_STATE_DTMF, AST_BRIDGE_CHANNEL_STATE_START_TALKING, AST_BRIDGE_CHANNEL_STATE_STOP_TALKING } |
| State information about a bridged channel. More... | |
| enum | ast_bridge_video_mode_type { AST_BRIDGE_VIDEO_MODE_NONE = 0, AST_BRIDGE_VIDEO_MODE_SINGLE_SRC, AST_BRIDGE_VIDEO_MODE_TALKER_SRC } |
| enum | ast_bridge_write_result { AST_BRIDGE_WRITE_SUCCESS = 0, AST_BRIDGE_WRITE_FAILED, AST_BRIDGE_WRITE_UNSUPPORTED } |
| Return values for bridge technology write function. More... | |
Functions | |
| void | ast_bridge_change_state (struct ast_bridge_channel *bridge_channel, enum ast_bridge_channel_state new_state) |
| Change the state of a bridged channel. | |
| int | ast_bridge_check (uint32_t capabilities) |
| See if it is possible to create a bridge. | |
| int | ast_bridge_depart (struct ast_bridge *bridge, struct ast_channel *chan) |
| Depart a channel from a bridge. | |
| int | ast_bridge_destroy (struct ast_bridge *bridge) |
| Destroy a bridge. | |
| int | ast_bridge_impart (struct ast_bridge *bridge, struct ast_channel *chan, struct ast_channel *swap, struct ast_bridge_features *features, int allow_hangup) |
| Impart (non-blocking) a channel on a bridge. | |
| int | ast_bridge_is_video_src (struct ast_bridge *bridge, struct ast_channel *chan) |
| Determine if a channel is a video src for the bridge. | |
| enum ast_bridge_channel_state | ast_bridge_join (struct ast_bridge *bridge, struct ast_channel *chan, struct ast_channel *swap, struct ast_bridge_features *features, struct ast_bridge_tech_optimizations *tech_args) |
| Join (blocking) a channel to a bridge. | |
| int | ast_bridge_merge (struct ast_bridge *bridge0, struct ast_bridge *bridge1) |
| Merge two bridges together. | |
| struct ast_bridge * | ast_bridge_new (uint32_t capabilities, int flags) |
| Create a new bridge. | |
| int | ast_bridge_number_video_src (struct ast_bridge *bridge) |
| Returns the number of video sources currently active in the bridge. | |
| int | ast_bridge_remove (struct ast_bridge *bridge, struct ast_channel *chan) |
| Remove a channel from a bridge. | |
| void | ast_bridge_remove_video_src (struct ast_bridge *bridge, struct ast_channel *chan) |
| remove a channel as a source of video for the bridge. | |
| void | ast_bridge_set_internal_sample_rate (struct ast_bridge *bridge, unsigned int sample_rate) |
| Adjust the internal mixing sample rate of a bridge used during multimix mode. | |
| void | ast_bridge_set_mixing_interval (struct ast_bridge *bridge, unsigned int mixing_interval) |
| Adjust the internal mixing interval of a bridge used during multimix mode. | |
| void | ast_bridge_set_single_src_video_mode (struct ast_bridge *bridge, struct ast_channel *video_src_chan) |
| Set a bridge to feed a single video source to all participants. | |
| void | ast_bridge_set_talker_src_video_mode (struct ast_bridge *bridge) |
| Set the bridge to pick the strongest talker supporting video as the single source video feed. | |
| int | ast_bridge_suspend (struct ast_bridge *bridge, struct ast_channel *chan) |
| Suspend a channel temporarily from a bridge. | |
| int | ast_bridge_unsuspend (struct ast_bridge *bridge, struct ast_channel *chan) |
| Unsuspend a channel from a bridge. | |
| void | ast_bridge_update_talker_src_video_mode (struct ast_bridge *bridge, struct ast_channel *chan, int talker_energy, int is_keyfame) |
| Update information about talker energy for talker src video mode. | |
Definition in file bridging.h.
Capabilities for a bridge technology.
| AST_BRIDGE_CAPABILITY_1TO1MIX | Bridge is only capable of mixing 2 channels |
| AST_BRIDGE_CAPABILITY_MULTIMIX | Bridge is capable of mixing 2 or more channels |
| AST_BRIDGE_CAPABILITY_NATIVE | Bridge should natively bridge two channels if possible |
| AST_BRIDGE_CAPABILITY_MULTITHREADED | Bridge should run using the multithreaded model |
| AST_BRIDGE_CAPABILITY_THREAD | Bridge should run a central bridge thread |
| AST_BRIDGE_CAPABILITY_VIDEO | Bridge technology can do video mixing (or something along those lines) |
| AST_BRIDGE_CAPABILITY_OPTIMIZE | Bridge technology can optimize things based on who is talking |
Definition at line 69 of file bridging.h.
00069 { 00070 /*! Bridge is only capable of mixing 2 channels */ 00071 AST_BRIDGE_CAPABILITY_1TO1MIX = (1 << 1), 00072 /*! Bridge is capable of mixing 2 or more channels */ 00073 AST_BRIDGE_CAPABILITY_MULTIMIX = (1 << 2), 00074 /*! Bridge should natively bridge two channels if possible */ 00075 AST_BRIDGE_CAPABILITY_NATIVE = (1 << 3), 00076 /*! Bridge should run using the multithreaded model */ 00077 AST_BRIDGE_CAPABILITY_MULTITHREADED = (1 << 4), 00078 /*! Bridge should run a central bridge thread */ 00079 AST_BRIDGE_CAPABILITY_THREAD = (1 << 5), 00080 /*! Bridge technology can do video mixing (or something along those lines) */ 00081 AST_BRIDGE_CAPABILITY_VIDEO = (1 << 6), 00082 /*! Bridge technology can optimize things based on who is talking */ 00083 AST_BRIDGE_CAPABILITY_OPTIMIZE = (1 << 7), 00084 };
State information about a bridged channel.
Definition at line 87 of file bridging.h.
00087 { 00088 /*! Waiting for a signal */ 00089 AST_BRIDGE_CHANNEL_STATE_WAIT = 0, 00090 /*! Bridged channel has ended itself (it has hung up) */ 00091 AST_BRIDGE_CHANNEL_STATE_END, 00092 /*! Bridged channel should be hung up */ 00093 AST_BRIDGE_CHANNEL_STATE_HANGUP, 00094 /*! Bridged channel should be removed from the bridge without being hung up */ 00095 AST_BRIDGE_CHANNEL_STATE_DEPART, 00096 /*! Bridged channel is executing a feature hook */ 00097 AST_BRIDGE_CHANNEL_STATE_FEATURE, 00098 /*! Bridged channel is sending a DTMF stream out */ 00099 AST_BRIDGE_CHANNEL_STATE_DTMF, 00100 /*! Bridged channel began talking */ 00101 AST_BRIDGE_CHANNEL_STATE_START_TALKING, 00102 /*! Bridged channel has stopped talking */ 00103 AST_BRIDGE_CHANNEL_STATE_STOP_TALKING, 00104 };
| AST_BRIDGE_VIDEO_MODE_NONE | Video is not allowed in the bridge |
| AST_BRIDGE_VIDEO_MODE_SINGLE_SRC | A single user is picked as the only distributed of video across the bridge |
| AST_BRIDGE_VIDEO_MODE_TALKER_SRC | A single user's video feed is distributed to all bridge channels, but that feed is automatically picked based on who is talking the most. |
Definition at line 172 of file bridging.h.
00172 { 00173 /*! Video is not allowed in the bridge */ 00174 AST_BRIDGE_VIDEO_MODE_NONE = 0, 00175 /*! A single user is picked as the only distributed of video across the bridge */ 00176 AST_BRIDGE_VIDEO_MODE_SINGLE_SRC, 00177 /*! A single user's video feed is distributed to all bridge channels, but 00178 * that feed is automatically picked based on who is talking the most. */ 00179 AST_BRIDGE_VIDEO_MODE_TALKER_SRC, 00180 };
Return values for bridge technology write function.
Definition at line 107 of file bridging.h.
00107 { 00108 /*! Bridge technology wrote out frame fine */ 00109 AST_BRIDGE_WRITE_SUCCESS = 0, 00110 /*! Bridge technology attempted to write out the frame but failed */ 00111 AST_BRIDGE_WRITE_FAILED, 00112 /*! Bridge technology does not support writing out a frame of this type */ 00113 AST_BRIDGE_WRITE_UNSUPPORTED, 00114 };
| void ast_bridge_change_state | ( | struct ast_bridge_channel * | bridge_channel, | |
| enum ast_bridge_channel_state | new_state | |||
| ) |
Change the state of a bridged channel.
| bridge_channel | Channel to change the state on | |
| new_state | The new state to place the channel into |
ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_WAIT);
This places the channel pointed to by bridge_channel into the state AST_BRIDGE_CHANNEL_STATE_WAIT.
Definition at line 117 of file bridging.c.
References ao2_lock, ao2_unlock, ast_cond_signal, ast_bridge_channel::cond, ast_bridge_channel::state, and ast_bridge_channel::thread.
Referenced by ast_bridge_depart(), ast_bridge_destroy(), ast_bridge_dtmf_stream(), ast_bridge_handle_trip(), ast_bridge_notify_talking(), ast_bridge_remove(), attended_abort_transfer(), attended_threeway_transfer(), bridge_channel_dtmf_stream(), bridge_channel_feature(), bridge_channel_join(), bridge_channel_talking(), bridge_check_dissolve(), bridge_handle_dtmf(), feature_attended_transfer(), feature_blind_transfer(), and feature_hangup().
00118 { 00119 /* Change the state on the bridge channel */ 00120 bridge_channel->state = new_state; 00121 00122 /* Only poke the channel's thread if it is not us */ 00123 if (!pthread_equal(pthread_self(), bridge_channel->thread)) { 00124 pthread_kill(bridge_channel->thread, SIGURG); 00125 ao2_lock(bridge_channel); 00126 ast_cond_signal(&bridge_channel->cond); 00127 ao2_unlock(bridge_channel); 00128 } 00129 00130 return; 00131 }
| int ast_bridge_check | ( | uint32_t | capabilities | ) |
See if it is possible to create a bridge.
| capabilities | The capabilities that the bridge will use |
| 1 | if possible | |
| 0 | if not possible |
int possible = ast_bridge_check(AST_BRIDGE_CAPABILITY_1TO1MIX);
This sees if it is possible to create a bridge capable of bridging two channels together.
Definition at line 516 of file bridging.c.
References ast_module_unref(), find_best_technology(), and ast_bridge_technology::mod.
00517 { 00518 struct ast_bridge_technology *bridge_technology = NULL; 00519 00520 if (!(bridge_technology = find_best_technology(capabilities))) { 00521 return 0; 00522 } 00523 00524 ast_module_unref(bridge_technology->mod); 00525 00526 return 1; 00527 }
| int ast_bridge_depart | ( | struct ast_bridge * | bridge, | |
| struct ast_channel * | chan | |||
| ) |
Depart a channel from a bridge.
| bridge | Bridge to depart from | |
| chan | Channel to depart |
| 0 | on success | |
| -1 | on failure |
ast_bridge_depart(bridge, chan);
This removes the channel pointed to by the chan pointer from the bridge pointed to by the bridge pointer and gives control to the calling thread. This does not hang up the channel.
Definition at line 1164 of file bridging.c.
References ao2_lock, ao2_unlock, ast_bridge_change_state(), AST_BRIDGE_CHANNEL_STATE_DEPART, find_bridge_channel(), ast_bridge_channel::thread, and thread.
Referenced by feature_attended_transfer(), and play_sound_helper().
01165 { 01166 struct ast_bridge_channel *bridge_channel = NULL; 01167 pthread_t thread; 01168 01169 ao2_lock(bridge); 01170 01171 /* Try to find the channel that we want to depart */ 01172 if (!(bridge_channel = find_bridge_channel(bridge, chan))) { 01173 ao2_unlock(bridge); 01174 return -1; 01175 } 01176 01177 ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_DEPART); 01178 thread = bridge_channel->thread; 01179 01180 ao2_unlock(bridge); 01181 01182 pthread_join(thread, NULL); 01183 01184 return 0; 01185 }
| int ast_bridge_destroy | ( | struct ast_bridge * | bridge | ) |
Destroy a bridge.
| bridge | Bridge to destroy |
| 0 | on success | |
| -1 | on failure |
ast_bridge_destroy(bridge);
This destroys a bridge that was previously created using ast_bridge_new.
Definition at line 529 of file bridging.c.
References ao2_lock, ao2_ref, ao2_unlock, ast_bridge_change_state(), AST_BRIDGE_CHANNEL_STATE_END, ast_debug, AST_LIST_TRAVERSE, bridge_poke(), and ast_bridge::stop.
Referenced by ast_bridge_new(), destroy_conference_bridge(), and feature_attended_transfer().
00530 { 00531 struct ast_bridge_channel *bridge_channel = NULL; 00532 00533 ao2_lock(bridge); 00534 00535 bridge->stop = 1; 00536 00537 bridge_poke(bridge); 00538 00539 ast_debug(1, "Telling all channels in bridge %p to end and leave the party\n", bridge); 00540 00541 /* Drop every bridged channel, the last one will cause the bridge thread (if it exists) to exit */ 00542 AST_LIST_TRAVERSE(&bridge->channels, bridge_channel, entry) { 00543 ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_END); 00544 } 00545 00546 ao2_unlock(bridge); 00547 00548 ao2_ref(bridge, -1); 00549 00550 return 0; 00551 }
| int ast_bridge_impart | ( | struct ast_bridge * | bridge, | |
| struct ast_channel * | chan, | |||
| struct ast_channel * | swap, | |||
| struct ast_bridge_features * | features, | |||
| int | allow_hangup | |||
| ) |
Impart (non-blocking) a channel on a bridge.
| bridge | Bridge to impart on | |
| chan | Channel to impart | |
| swap | Channel to swap out if swapping | |
| features | Bridge features structure | |
| allow_hangup | Indicates if the bridge thread should manage hanging up of the channel or not. |
| 0 | on success | |
| -1 | on failure |
ast_bridge_impart(bridge, chan, NULL, NULL, 0);
This adds a channel pointed to by the chan pointer to the bridge pointed to by the bridge pointer. This function will return immediately and will not wait until the channel is no longer part of the bridge.
If this channel will be replacing another channel the other channel can be specified in the swap parameter. The other channel will be thrown out of the bridge in an atomic fashion.
If channel specific features are enabled a pointer to the features structure can be specified in the features parameter.
Definition at line 1140 of file bridging.c.
References ast_bridge_channel::allow_impart_hangup, ao2_ref, ast_pthread_create, bridge_channel_alloc(), bridge_channel_thread(), ast_bridge_channel::chan, ast_bridge_channel::features, ast_bridge_channel::swap, and ast_bridge_channel::thread.
Referenced by bridge_call(), feature_attended_transfer(), feature_blind_transfer(), and play_sound_helper().
01141 { 01142 struct ast_bridge_channel *bridge_channel = bridge_channel_alloc(bridge); 01143 /* Try to allocate a structure for the bridge channel */ 01144 if (!(bridge_channel)) { 01145 return -1; 01146 } 01147 01148 /* Setup various parameters */ 01149 bridge_channel->chan = chan; 01150 bridge_channel->swap = swap; 01151 bridge_channel->features = features; 01152 bridge_channel->allow_impart_hangup = allow_hangup; 01153 01154 01155 /* Actually create the thread that will handle the channel */ 01156 if (ast_pthread_create(&bridge_channel->thread, NULL, bridge_channel_thread, bridge_channel)) { 01157 ao2_ref(bridge_channel, -1); 01158 return -1; 01159 } 01160 01161 return 0; 01162 }
| int ast_bridge_is_video_src | ( | struct ast_bridge * | bridge, | |
| struct ast_channel * | chan | |||
| ) |
Determine if a channel is a video src for the bridge.
| 0 | Not a current video source of the bridge. | |
| None | 0, is a video source of the bridge, The number returned represents the priority this video stream has on the bridge where 1 is the highest priority. |
Definition at line 1594 of file bridging.c.
References ao2_lock, ao2_unlock, AST_BRIDGE_VIDEO_MODE_NONE, AST_BRIDGE_VIDEO_MODE_SINGLE_SRC, AST_BRIDGE_VIDEO_MODE_TALKER_SRC, ast_bridge_video_talker_src_data::chan_old_vsrc, ast_bridge_video_talker_src_data::chan_vsrc, ast_bridge_video_single_src_data::chan_vsrc, ast_bridge_video_mode::mode, ast_bridge_video_mode::mode_data, ast_bridge_video_mode::single_src_data, ast_bridge_video_mode::talker_src_data, and ast_bridge::video_mode.
Referenced by handle_video_on_exit(), handle_video_on_join(), softmix_bridge_write(), and softmix_pass_video_top_priority().
01595 { 01596 int res = 0; 01597 01598 ao2_lock(bridge); 01599 switch (bridge->video_mode.mode) { 01600 case AST_BRIDGE_VIDEO_MODE_NONE: 01601 break; 01602 case AST_BRIDGE_VIDEO_MODE_SINGLE_SRC: 01603 if (bridge->video_mode.mode_data.single_src_data.chan_vsrc == chan) { 01604 res = 1; 01605 } 01606 break; 01607 case AST_BRIDGE_VIDEO_MODE_TALKER_SRC: 01608 if (bridge->video_mode.mode_data.talker_src_data.chan_vsrc == chan) { 01609 res = 1; 01610 } else if (bridge->video_mode.mode_data.talker_src_data.chan_old_vsrc == chan) { 01611 res = 2; 01612 } 01613 01614 } 01615 ao2_unlock(bridge); 01616 return res; 01617 }
| enum ast_bridge_channel_state ast_bridge_join | ( | struct ast_bridge * | bridge, | |
| struct ast_channel * | chan, | |||
| struct ast_channel * | swap, | |||
| struct ast_bridge_features * | features, | |||
| struct ast_bridge_tech_optimizations * | tech_args | |||
| ) |
Join (blocking) a channel to a bridge.
| bridge | Bridge to join | |
| chan | Channel to join | |
| swap | Channel to swap out if swapping | |
| features | Bridge features structure | |
| (Optional) | Bridging tech optimization parameters for this channel. |
| state | that channel exited the bridge with |
ast_bridge_join(bridge, chan, NULL, NULL);
This adds a channel pointed to by the chan pointer to the bridge pointed to by the bridge pointer. This function will not return until the channel has been removed from the bridge, swapped out for another channel, or has hung up.
If this channel will be replacing another channel the other channel can be specified in the swap parameter. The other channel will be thrown out of the bridge in an atomic fashion.
If channel specific features are enabled a pointer to the features structure can be specified in the features parameter.
Definition at line 1080 of file bridging.c.
References ao2_lock, ao2_ref, ao2_unlock, AST_BRIDGE_CHANNEL_STATE_HANGUP, bridge_channel_alloc(), bridge_channel_join(), ast_bridge_channel::chan, ast_bridge_channel::features, ast_bridge_channel::swap, and ast_bridge_channel::tech_args.
Referenced by confbridge_exec(), feature_attended_transfer(), and record_thread().
01085 { 01086 struct ast_bridge_channel *bridge_channel = bridge_channel_alloc(bridge); 01087 enum ast_bridge_channel_state state = AST_BRIDGE_CHANNEL_STATE_HANGUP; 01088 01089 if (!bridge_channel) { 01090 return state; 01091 } 01092 if (tech_args) { 01093 memcpy(&bridge_channel->tech_args, tech_args, sizeof(bridge_channel->tech_args)); 01094 } 01095 01096 /* Initialize various other elements of the bridge channel structure that we can't do above */ 01097 bridge_channel->chan = chan; 01098 bridge_channel->swap = swap; 01099 bridge_channel->features = features; 01100 01101 state = bridge_channel_join(bridge_channel); 01102 01103 /* Cleanup all the data in the bridge channel after it leaves the bridge. */ 01104 ao2_lock(bridge_channel); 01105 bridge_channel->chan = NULL; 01106 bridge_channel->swap = NULL; 01107 bridge_channel->features = NULL; 01108 ao2_unlock(bridge_channel); 01109 01110 ao2_ref(bridge_channel, -1); 01111 01112 return state; 01113 }
| int ast_bridge_merge | ( | struct ast_bridge * | bridge0, | |
| struct ast_bridge * | bridge1 | |||
| ) |
Merge two bridges together.
| bridge0 | First bridge | |
| bridge1 | Second bridge |
| 0 | on success | |
| -1 | on failure |
ast_bridge_merge(bridge0, bridge1);
This merges the bridge pointed to by bridge1 with the bridge pointed to by bridge0. In reality all of the channels in bridge1 are simply moved to bridge0.
Definition at line 1206 of file bridging.c.
References ao2_lock, ao2_ref, ao2_unlock, AST_BRIDGE_CAPABILITY_MULTIMIX, AST_BRIDGE_FLAG_SMART, ast_cond_signal, ast_debug, AST_LIST_INSERT_TAIL, AST_LIST_REMOVE_HEAD, AST_PTHREADT_STOP, ast_test_flag, ast_bridge_channel::bridge, bridge_array_add(), bridge_array_remove(), bridge_make_compatible(), ast_bridge_technology::capabilities, ast_bridge_channel::chan, ast_bridge_channel::cond, ast_bridge::feature_flags, ast_bridge_technology::join, ast_bridge_technology::leave, ast_bridge_technology::name, ast_bridge::num, smart_bridge_operation(), ast_bridge::technology, ast_bridge_channel::thread, and ast_bridge::thread.
01207 { 01208 struct ast_bridge_channel *bridge_channel = NULL; 01209 01210 ao2_lock(bridge0); 01211 ao2_lock(bridge1); 01212 01213 /* If the first bridge currently has 2 channels and is not capable of becoming a multimixing bridge we can not merge */ 01214 if ((bridge0->num + bridge1->num) > 2 && (!(bridge0->technology->capabilities & AST_BRIDGE_CAPABILITY_MULTIMIX) && !ast_test_flag(&bridge0->feature_flags, AST_BRIDGE_FLAG_SMART))) { 01215 ao2_unlock(bridge1); 01216 ao2_unlock(bridge0); 01217 ast_debug(1, "Can't merge bridge %p into bridge %p, multimix is needed and it could not be acquired.\n", bridge1, bridge0); 01218 return -1; 01219 } 01220 01221 ast_debug(1, "Merging channels from bridge %p into bridge %p\n", bridge1, bridge0); 01222 01223 /* Perform smart bridge operation on bridge we are merging into so it can change bridge technology if needed */ 01224 if (smart_bridge_operation(bridge0, NULL, bridge0->num + bridge1->num)) { 01225 ao2_unlock(bridge1); 01226 ao2_unlock(bridge0); 01227 ast_debug(1, "Can't merge bridge %p into bridge %p, tried to perform smart bridge operation and failed.\n", bridge1, bridge0); 01228 return -1; 01229 } 01230 01231 /* If a thread is currently executing on bridge1 tell it to stop */ 01232 if (bridge1->thread) { 01233 ast_debug(1, "Telling bridge thread on bridge %p to stop as it is being merged into %p\n", bridge1, bridge0); 01234 bridge1->thread = AST_PTHREADT_STOP; 01235 } 01236 01237 /* Move channels from bridge1 over to bridge0 */ 01238 while ((bridge_channel = AST_LIST_REMOVE_HEAD(&bridge1->channels, entry))) { 01239 /* Tell the technology handling bridge1 that the bridge channel is leaving */ 01240 if (bridge1->technology->leave) { 01241 ast_debug(1, "Giving bridge technology %s notification that %p is leaving bridge %p\n", bridge1->technology->name, bridge_channel, bridge1); 01242 if (bridge1->technology->leave(bridge1, bridge_channel)) { 01243 ast_debug(1, "Bridge technology %s failed to allow %p to leave bridge %p\n", bridge1->technology->name, bridge_channel, bridge1); 01244 } 01245 } 01246 01247 /* Drop channel count and reference count on the bridge they are leaving */ 01248 bridge1->num--; 01249 ao2_ref(bridge1, -1); 01250 01251 bridge_array_remove(bridge1, bridge_channel->chan); 01252 01253 /* Now add them into the bridge they are joining, increase channel count, and bump up reference count */ 01254 bridge_channel->bridge = bridge0; 01255 AST_LIST_INSERT_TAIL(&bridge0->channels, bridge_channel, entry); 01256 bridge0->num++; 01257 ao2_ref(bridge0, +1); 01258 01259 bridge_array_add(bridge0, bridge_channel->chan); 01260 01261 /* Make the channel compatible with the new bridge it is joining or else formats would go amuck */ 01262 bridge_make_compatible(bridge0, bridge_channel); 01263 01264 /* Tell the technology handling bridge0 that the bridge channel is joining */ 01265 if (bridge0->technology->join) { 01266 ast_debug(1, "Giving bridge technology %s notification that %p is joining bridge %p\n", bridge0->technology->name, bridge_channel, bridge0); 01267 if (bridge0->technology->join(bridge0, bridge_channel)) { 01268 ast_debug(1, "Bridge technology %s failed to join %p to bridge %p\n", bridge0->technology->name, bridge_channel, bridge0); 01269 } 01270 } 01271 01272 /* Poke the bridge channel, this will cause it to wake up and execute the proper threading model for the new bridge it is in */ 01273 pthread_kill(bridge_channel->thread, SIGURG); 01274 ao2_lock(bridge_channel); 01275 ast_cond_signal(&bridge_channel->cond); 01276 ao2_unlock(bridge_channel); 01277 } 01278 01279 ast_debug(1, "Merged channels from bridge %p into bridge %p\n", bridge1, bridge0); 01280 01281 ao2_unlock(bridge1); 01282 ao2_unlock(bridge0); 01283 01284 return 0; 01285 }
| struct ast_bridge* ast_bridge_new | ( | uint32_t | capabilities, | |
| int | flags | |||
| ) | [read] |
Create a new bridge.
| capabilities | The capabilities that we require to be used on the bridge | |
| flags | Flags that will alter the behavior of the bridge |
| a | pointer to a new bridge on success | |
| NULL | on failure |
struct ast_bridge *bridge; bridge = ast_bridge_new(AST_BRIDGE_CAPABILITY_1TO1MIX, AST_BRIDGE_FLAG_DISSOLVE);
This creates a simple two party bridge that will be destroyed once one of the channels hangs up.
Definition at line 464 of file bridging.c.
References ao2_alloc, ao2_ref, ast_bridge::array, ast_bridge::array_size, AST_BRIDGE_CAPABILITY_1TO1MIX, AST_BRIDGE_CAPABILITY_MULTIMIX, ast_bridge_destroy(), AST_BRIDGE_FLAG_SMART, ast_bridge_new(), ast_calloc, ast_debug, AST_PTHREADT_NULL, ast_set_flag, BRIDGE_ARRAY_START, ast_bridge_technology::create, destroy_bridge(), ast_bridge::feature_flags, find_best_technology(), ast_bridge_technology::name, ast_bridge::technology, and ast_bridge::thread.
Referenced by ast_bridge_new(), feature_attended_transfer(), and join_conference_bridge().
00465 { 00466 struct ast_bridge *bridge = NULL; 00467 struct ast_bridge_technology *bridge_technology = NULL; 00468 00469 /* If we need to be a smart bridge see if we can move between 1to1 and multimix bridges */ 00470 if (flags & AST_BRIDGE_FLAG_SMART) { 00471 struct ast_bridge *other_bridge; 00472 00473 if (!(other_bridge = ast_bridge_new((capabilities & AST_BRIDGE_CAPABILITY_1TO1MIX) ? AST_BRIDGE_CAPABILITY_MULTIMIX : AST_BRIDGE_CAPABILITY_1TO1MIX, 0))) { 00474 return NULL; 00475 } 00476 00477 ast_bridge_destroy(other_bridge); 00478 } 00479 00480 /* If capabilities were provided use our helper function to find the "best" bridge technology, otherwise we can 00481 * just look for the most basic capability needed, single 1to1 mixing. */ 00482 bridge_technology = (capabilities ? find_best_technology(capabilities) : find_best_technology(AST_BRIDGE_CAPABILITY_1TO1MIX)); 00483 00484 /* If no bridge technology was found we can't possibly do bridging so fail creation of the bridge */ 00485 if (!bridge_technology) { 00486 return NULL; 00487 } 00488 00489 /* We have everything we need to create this bridge... so allocate the memory, link things together, and fire her up! */ 00490 if (!(bridge = ao2_alloc(sizeof(*bridge), destroy_bridge))) { 00491 return NULL; 00492 } 00493 00494 bridge->technology = bridge_technology; 00495 bridge->thread = AST_PTHREADT_NULL; 00496 00497 /* Create an array of pointers for the channels that will be joining us */ 00498 bridge->array = ast_calloc(BRIDGE_ARRAY_START, sizeof(struct ast_channel*)); 00499 bridge->array_size = BRIDGE_ARRAY_START; 00500 00501 ast_set_flag(&bridge->feature_flags, flags); 00502 00503 /* Pass off the bridge to the technology to manipulate if needed */ 00504 if (bridge->technology->create) { 00505 ast_debug(1, "Giving bridge technology %s the bridge structure %p to setup\n", bridge->technology->name, bridge); 00506 if (bridge->technology->create(bridge)) { 00507 ast_debug(1, "Bridge technology %s failed to setup bridge structure %p\n", bridge->technology->name, bridge); 00508 ao2_ref(bridge, -1); 00509 bridge = NULL; 00510 } 00511 } 00512 00513 return bridge; 00514 }
| int ast_bridge_number_video_src | ( | struct ast_bridge * | bridge | ) |
Returns the number of video sources currently active in the bridge.
Definition at line 1569 of file bridging.c.
References ao2_lock, ao2_unlock, AST_BRIDGE_VIDEO_MODE_NONE, AST_BRIDGE_VIDEO_MODE_SINGLE_SRC, AST_BRIDGE_VIDEO_MODE_TALKER_SRC, ast_bridge_video_talker_src_data::chan_old_vsrc, ast_bridge_video_talker_src_data::chan_vsrc, ast_bridge_video_single_src_data::chan_vsrc, ast_bridge_video_mode::mode, ast_bridge_video_mode::mode_data, ast_bridge_video_mode::single_src_data, ast_bridge_video_mode::talker_src_data, and ast_bridge::video_mode.
Referenced by softmix_bridge_write().
01570 { 01571 int res = 0; 01572 01573 ao2_lock(bridge); 01574 switch (bridge->video_mode.mode) { 01575 case AST_BRIDGE_VIDEO_MODE_NONE: 01576 break; 01577 case AST_BRIDGE_VIDEO_MODE_SINGLE_SRC: 01578 if (bridge->video_mode.mode_data.single_src_data.chan_vsrc) { 01579 res = 1; 01580 } 01581 break; 01582 case AST_BRIDGE_VIDEO_MODE_TALKER_SRC: 01583 if (bridge->video_mode.mode_data.talker_src_data.chan_vsrc) { 01584 res++; 01585 } 01586 if (bridge->video_mode.mode_data.talker_src_data.chan_old_vsrc) { 01587 res++; 01588 } 01589 } 01590 ao2_unlock(bridge); 01591 return res; 01592 }
| int ast_bridge_remove | ( | struct ast_bridge * | bridge, | |
| struct ast_channel * | chan | |||
| ) |
Remove a channel from a bridge.
| bridge | Bridge that the channel is to be removed from | |
| chan | Channel to remove |
| 0 | on success | |
| -1 | on failure |
ast_bridge_remove(bridge, chan);
This removes the channel pointed to by the chan pointer from the bridge pointed to by the bridge pointer and requests that it be hung up. Control over the channel will NOT be given to the calling thread.
Definition at line 1187 of file bridging.c.
References ao2_lock, ao2_unlock, ast_bridge_change_state(), AST_BRIDGE_CHANNEL_STATE_HANGUP, and find_bridge_channel().
Referenced by action_confbridgekick(), action_kick_last(), conf_stop_record(), execute_menu_entry(), handle_cli_confbridge_kick(), and leave_conference_bridge().
01188 { 01189 struct ast_bridge_channel *bridge_channel = NULL; 01190 01191 ao2_lock(bridge); 01192 01193 /* Try to find the channel that we want to remove */ 01194 if (!(bridge_channel = find_bridge_channel(bridge, chan))) { 01195 ao2_unlock(bridge); 01196 return -1; 01197 } 01198 01199 ast_bridge_change_state(bridge_channel, AST_BRIDGE_CHANNEL_STATE_HANGUP); 01200 01201 ao2_unlock(bridge); 01202 01203 return 0; 01204 }
| void ast_bridge_remove_video_src | ( | struct ast_bridge * | bridge, | |
| struct ast_channel * | chan | |||
| ) |
remove a channel as a source of video for the bridge.
Definition at line 1619 of file bridging.c.
References ao2_lock, ao2_unlock, AST_BRIDGE_VIDEO_MODE_NONE, AST_BRIDGE_VIDEO_MODE_SINGLE_SRC, AST_BRIDGE_VIDEO_MODE_TALKER_SRC, ast_channel_unref, ast_bridge_video_talker_src_data::average_talking_energy, ast_bridge_video_talker_src_data::chan_old_vsrc, ast_bridge_video_talker_src_data::chan_vsrc, ast_bridge_video_single_src_data::chan_vsrc, ast_bridge_video_mode::mode, ast_bridge_video_mode::mode_data, ast_bridge_video_mode::single_src_data, ast_bridge_video_mode::talker_src_data, and ast_bridge::video_mode.
Referenced by handle_video_on_exit().
01620 { 01621 ao2_lock(bridge); 01622 switch (bridge->video_mode.mode) { 01623 case AST_BRIDGE_VIDEO_MODE_NONE: 01624 break; 01625 case AST_BRIDGE_VIDEO_MODE_SINGLE_SRC: 01626 if (bridge->video_mode.mode_data.single_src_data.chan_vsrc == chan) { 01627 if (bridge->video_mode.mode_data.single_src_data.chan_vsrc) { 01628 ast_channel_unref(bridge->video_mode.mode_data.single_src_data.chan_vsrc); 01629 } 01630 bridge->video_mode.mode_data.single_src_data.chan_vsrc = NULL; 01631 } 01632 break; 01633 case AST_BRIDGE_VIDEO_MODE_TALKER_SRC: 01634 if (bridge->video_mode.mode_data.talker_src_data.chan_vsrc == chan) { 01635 if (bridge->video_mode.mode_data.talker_src_data.chan_vsrc) { 01636 ast_channel_unref(bridge->video_mode.mode_data.talker_src_data.chan_vsrc); 01637 } 01638 bridge->video_mode.mode_data.talker_src_data.chan_vsrc = NULL; 01639 bridge->video_mode.mode_data.talker_src_data.average_talking_energy = 0; 01640 } 01641 if (bridge->video_mode.mode_data.talker_src_data.chan_old_vsrc == chan) { 01642 if (bridge->video_mode.mode_data.talker_src_data.chan_old_vsrc) { 01643 ast_channel_unref(bridge->video_mode.mode_data.talker_src_data.chan_old_vsrc); 01644 } 01645 bridge->video_mode.mode_data.talker_src_data.chan_old_vsrc = NULL; 01646 } 01647 } 01648 ao2_unlock(bridge); 01649 }
| void ast_bridge_set_internal_sample_rate | ( | struct ast_bridge * | bridge, | |
| unsigned int | sample_rate | |||
| ) |
Adjust the internal mixing sample rate of a bridge used during multimix mode.
| bridge_channel | Channel to change the sample rate on. | |
| sample | rate, the sample rate to change to. If a value of 0 is passed here, the bridge will be free to pick what ever sample rate it chooses. |
Definition at line 1481 of file bridging.c.
References ao2_lock, ao2_unlock, and ast_bridge::internal_sample_rate.
Referenced by join_conference_bridge().
01482 { 01483 01484 ao2_lock(bridge); 01485 bridge->internal_sample_rate = sample_rate; 01486 ao2_unlock(bridge); 01487 }
| void ast_bridge_set_mixing_interval | ( | struct ast_bridge * | bridge, | |
| unsigned int | mixing_interval | |||
| ) |
Adjust the internal mixing interval of a bridge used during multimix mode.
| bridge_channel | Channel to change the sample rate on. | |
| mixing_interval,the | sample rate to change to. If 0 is set the bridge tech is free to choose any mixing interval it uses by default. |
Definition at line 1474 of file bridging.c.
References ao2_lock, ao2_unlock, and ast_bridge::internal_mixing_interval.
Referenced by join_conference_bridge().
01475 { 01476 ao2_lock(bridge); 01477 bridge->internal_mixing_interval = mixing_interval; 01478 ao2_unlock(bridge); 01479 }
| void ast_bridge_set_single_src_video_mode | ( | struct ast_bridge * | bridge, | |
| struct ast_channel * | video_src_chan | |||
| ) |
Set a bridge to feed a single video source to all participants.
Definition at line 1510 of file bridging.c.
References ao2_lock, ao2_unlock, AST_BRIDGE_VIDEO_MODE_SINGLE_SRC, ast_channel_name(), ast_channel_ref, AST_CONTROL_VIDUPDATE, ast_indicate(), ast_test_suite_event_notify, ast_bridge_video_single_src_data::chan_vsrc, cleanup_video_mode(), ast_bridge_video_mode::mode, ast_bridge_video_mode::mode_data, ast_bridge_video_mode::single_src_data, and ast_bridge::video_mode.
Referenced by action_confbridgesetsinglevideosrc(), execute_menu_entry(), handle_video_on_exit(), and handle_video_on_join().
01511 { 01512 ao2_lock(bridge); 01513 cleanup_video_mode(bridge); 01514 bridge->video_mode.mode = AST_BRIDGE_VIDEO_MODE_SINGLE_SRC; 01515 bridge->video_mode.mode_data.single_src_data.chan_vsrc = ast_channel_ref(video_src_chan); 01516 ast_test_suite_event_notify("BRIDGE_VIDEO_MODE", "Message: video mode set to single source\r\nVideo Mode: %d\r\nVideo Channel: %s", bridge->video_mode.mode, ast_channel_name(video_src_chan)); 01517 ast_indicate(video_src_chan, AST_CONTROL_VIDUPDATE); 01518 ao2_unlock(bridge); 01519 }
| void ast_bridge_set_talker_src_video_mode | ( | struct ast_bridge * | bridge | ) |
Set the bridge to pick the strongest talker supporting video as the single source video feed.
Definition at line 1521 of file bridging.c.
References ao2_lock, ao2_unlock, AST_BRIDGE_VIDEO_MODE_TALKER_SRC, ast_test_suite_event_notify, cleanup_video_mode(), ast_bridge_video_mode::mode, and ast_bridge::video_mode.
Referenced by handle_video_on_exit(), and join_conference_bridge().
01522 { 01523 ao2_lock(bridge); 01524 cleanup_video_mode(bridge); 01525 bridge->video_mode.mode = AST_BRIDGE_VIDEO_MODE_TALKER_SRC; 01526 ast_test_suite_event_notify("BRIDGE_VIDEO_MODE", "Message: video mode set to talker source\r\nVideo Mode: %d", bridge->video_mode.mode); 01527 ao2_unlock(bridge); 01528 }
| int ast_bridge_suspend | ( | struct ast_bridge * | bridge, | |
| struct ast_channel * | chan | |||
| ) |
Suspend a channel temporarily from a bridge.
| bridge | Bridge to suspend the channel from | |
| chan | Channel to suspend |
| 0 | on success | |
| -1 | on failure |
ast_bridge_suspend(bridge, chan);
This suspends the channel pointed to by chan from the bridge pointed to by bridge temporarily. Control of the channel is given to the calling thread. This differs from ast_bridge_depart as the channel will not be removed from the bridge.
Definition at line 1287 of file bridging.c.
References ao2_lock, ao2_unlock, bridge_channel_suspend(), and find_bridge_channel().
Referenced by leave_conference_bridge(), post_join_marked(), and post_join_unmarked().
01288 { 01289 struct ast_bridge_channel *bridge_channel; 01290 01291 ao2_lock(bridge); 01292 01293 if (!(bridge_channel = find_bridge_channel(bridge, chan))) { 01294 ao2_unlock(bridge); 01295 return -1; 01296 } 01297 01298 bridge_channel_suspend(bridge, bridge_channel); 01299 01300 ao2_unlock(bridge); 01301 01302 return 0; 01303 }
| int ast_bridge_unsuspend | ( | struct ast_bridge * | bridge, | |
| struct ast_channel * | chan | |||
| ) |
Unsuspend a channel from a bridge.
| bridge | Bridge to unsuspend the channel from | |
| chan | Channel to unsuspend |
| 0 | on success | |
| -1 | on failure |
ast_bridge_unsuspend(bridge, chan);
This unsuspends the channel pointed to by chan from the bridge pointed to by bridge. The bridge will go back to handling the channel once this function returns.
Definition at line 1305 of file bridging.c.
References ao2_lock, ao2_unlock, bridge_channel_unsuspend(), and find_bridge_channel().
Referenced by leave_conference_bridge(), post_join_marked(), and post_join_unmarked().
01306 { 01307 struct ast_bridge_channel *bridge_channel; 01308 01309 ao2_lock(bridge); 01310 01311 if (!(bridge_channel = find_bridge_channel(bridge, chan))) { 01312 ao2_unlock(bridge); 01313 return -1; 01314 } 01315 01316 bridge_channel_unsuspend(bridge, bridge_channel); 01317 01318 ao2_unlock(bridge); 01319 01320 return 0; 01321 }
| void ast_bridge_update_talker_src_video_mode | ( | struct ast_bridge * | bridge, | |
| struct ast_channel * | chan, | |||
| int | talker_energy, | |||
| int | is_keyfame | |||
| ) |
Update information about talker energy for talker src video mode.
Definition at line 1530 of file bridging.c.
References ao2_lock, ao2_unlock, ast_channel_name(), ast_channel_ref, ast_channel_unref, AST_CONTROL_VIDUPDATE, ast_format_cap_has_type(), AST_FORMAT_TYPE_VIDEO, ast_indicate(), ast_test_suite_event_notify, ast_bridge_video_talker_src_data::average_talking_energy, ast_bridge_video_talker_src_data::chan_old_vsrc, ast_bridge_video_talker_src_data::chan_vsrc, ast_bridge_video_mode::mode_data, ast_channel::nativeformats, ast_bridge_video_mode::talker_src_data, and ast_bridge::video_mode.
Referenced by softmix_bridge_write().
01531 { 01532 struct ast_bridge_video_talker_src_data *data; 01533 /* If the channel doesn't support video, we don't care about it */ 01534 if (!ast_format_cap_has_type(chan->nativeformats, AST_FORMAT_TYPE_VIDEO)) { 01535 return; 01536 } 01537 01538 ao2_lock(bridge); 01539 data = &bridge->video_mode.mode_data.talker_src_data; 01540 01541 if (data->chan_vsrc == chan) { 01542 data->average_talking_energy = talker_energy; 01543 } else if ((data->average_talking_energy < talker_energy) && is_keyframe) { 01544 if (data->chan_old_vsrc) { 01545 ast_channel_unref(data->chan_old_vsrc); 01546 } 01547 if (data->chan_vsrc) { 01548 data->chan_old_vsrc = data->chan_vsrc; 01549 ast_indicate(data->chan_old_vsrc, AST_CONTROL_VIDUPDATE); 01550 } 01551 data->chan_vsrc = ast_channel_ref(chan); 01552 data->average_talking_energy = talker_energy; 01553 ast_test_suite_event_notify("BRIDGE_VIDEO_SRC", "Message: video source updated\r\nVideo Channel: %s", ast_channel_name(data->chan_vsrc)); 01554 ast_indicate(data->chan_vsrc, AST_CONTROL_VIDUPDATE); 01555 } else if ((data->average_talking_energy < talker_energy) && !is_keyframe) { 01556 ast_indicate(chan, AST_CONTROL_VIDUPDATE); 01557 } else if (!data->chan_vsrc && is_keyframe) { 01558 data->chan_vsrc = ast_channel_ref(chan); 01559 data->average_talking_energy = talker_energy; 01560 ast_test_suite_event_notify("BRIDGE_VIDEO_SRC", "Message: video source updated\r\nVideo Channel: %s", ast_channel_name(data->chan_vsrc)); 01561 ast_indicate(chan, AST_CONTROL_VIDUPDATE); 01562 } else if (!data->chan_old_vsrc && is_keyframe) { 01563 data->chan_old_vsrc = ast_channel_ref(chan); 01564 ast_indicate(chan, AST_CONTROL_VIDUPDATE); 01565 } 01566 ao2_unlock(bridge); 01567 }
1.5.6