[asterisk-commits] file: branch file/bridge_native r385859 - /team/file/bridge_native/main/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Apr 16 10:24:32 CDT 2013
Author: file
Date: Tue Apr 16 10:24:30 2013
New Revision: 385859
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=385859
Log:
First stab at making the core aware of native bridging.
Modified:
team/file/bridge_native/main/bridging.c
Modified: team/file/bridge_native/main/bridging.c
URL: http://svnview.digium.com/svn/asterisk/team/file/bridge_native/main/bridging.c?view=diff&rev=385859&r1=385858&r2=385859
==============================================================================
--- team/file/bridge_native/main/bridging.c (original)
+++ team/file/bridge_native/main/bridging.c Tue Apr 16 10:24:30 2013
@@ -1019,7 +1019,7 @@
}
/*! \brief Helper function used to find the "best" bridge technology given a specified capabilities */
-static struct ast_bridge_technology *find_best_technology(uint32_t capabilities)
+static struct ast_bridge_technology *find_best_technology(uint32_t capabilities, struct ast_bridge *bridge)
{
struct ast_bridge_technology *current;
struct ast_bridge_technology *best = NULL;
@@ -1036,9 +1036,19 @@
current->name);
continue;
}
+ if (bridge && current->compatible && current->compatible(bridge)) {
+ ast_debug(1, "Bridge technology %s is not compatible with properties of existing bridge.\n",
+ current->name);
+ continue;
+ }
if (best && best->preference < current->preference) {
ast_debug(1, "Bridge technology %s has preference %d while %s has preference %d. Skipping.\n",
current->name, current->preference, best->name, best->preference);
+ continue;
+ }
+ if (bridge && (bridge->technology == current)) {
+ ast_debug(1, "Bridge technology %s is already being used on existing provided bridge.\n",
+ current->name);
continue;
}
best = current;
@@ -1254,8 +1264,8 @@
* the most basic capability needed, single 1to1 mixing.
*/
self->technology = capabilities
- ? find_best_technology(capabilities)
- : find_best_technology(AST_BRIDGE_CAPABILITY_1TO1MIX);
+ ? find_best_technology(capabilities, NULL)
+ : find_best_technology(AST_BRIDGE_CAPABILITY_1TO1MIX, NULL);
if (!self->technology) {
ao2_ref(self, -1);
return NULL;
@@ -1405,7 +1415,7 @@
{
struct ast_bridge_technology *bridge_technology;
- if (!(bridge_technology = find_best_technology(capabilities))) {
+ if (!(bridge_technology = find_best_technology(capabilities, NULL))) {
return 0;
}
@@ -1522,25 +1532,39 @@
return 0;
}
-/* BUGBUG the bridge tech compatible callback should be asking if the specified bridge is compatible with the tech. */
/*
* Based on current capabilities determine whether we want to
* change bridge technologies.
*/
- if (bridge->technology->capabilities & AST_BRIDGE_CAPABILITY_1TO1MIX) {
+ if (bridge->technology->compatible && bridge->technology->compatible(bridge)) {
+ /* Circumstances have changed and the bridging technology is no longer able to
+ * bridge the channels. By simply using the capabilities as presented on the
+ * technology we will naturally find, and skip, this technology during our check.
+ */
+ new_capabilities = bridge->technology->capabilities;
+ } else if (bridge->technology->capabilities & AST_BRIDGE_CAPABILITY_1TO1MIX) {
if (bridge->num_channels <= 2) {
- ast_debug(1, "Bridge %s channel count (%u) is within limits for %s technology, not performing smart bridge operation.\n",
- bridge->uniqueid, bridge->num_channels, bridge->technology->name);
- return 0;
- }
- new_capabilities = AST_BRIDGE_CAPABILITY_MULTIMIX;
+ if (bridge->technology->capabilities & AST_BRIDGE_CAPABILITY_NATIVE) {
+ ast_debug(1, "Bridge %s channel count (%u) is within limits for %s technology, not performing smart bridge operation.\n",
+ bridge->uniqueid, bridge->num_channels, bridge->technology->name);
+ return 0;
+ }
+ /* If we start out as a generic 1to1mix technology try to migrate to native for performance reasons */
+ new_capabilities = AST_BRIDGE_CAPABILITY_1TO1MIX | AST_BRIDGE_CAPABILITY_NATIVE;
+ } else {
+ new_capabilities = AST_BRIDGE_CAPABILITY_MULTIMIX | AST_BRIDGE_CAPABILITY_NATIVE;
+ }
} else if (bridge->technology->capabilities & AST_BRIDGE_CAPABILITY_MULTIMIX) {
if (2 < bridge->num_channels) {
- ast_debug(1, "Bridge %s channel count (%u) is within limits for %s technology, not performing smart bridge operation.\n",
- bridge->uniqueid, bridge->num_channels, bridge->technology->name);
- return 0;
- }
- new_capabilities = AST_BRIDGE_CAPABILITY_1TO1MIX;
+ if (bridge->technology->capabilities & AST_BRIDGE_CAPABILITY_NATIVE) {
+ ast_debug(1, "Bridge %s channel count (%u) is within limits for %s technology, not performing smart bridge operation.\n",
+ bridge->uniqueid, bridge->num_channels, bridge->technology->name);
+ return 0;
+ }
+ new_capabilities = AST_BRIDGE_CAPABILITY_MULTIMIX | AST_BRIDGE_CAPABILITY_NATIVE;
+ } else {
+ new_capabilities = AST_BRIDGE_CAPABILITY_1TO1MIX | AST_BRIDGE_CAPABILITY_NATIVE;
+ }
}
if (!new_capabilities) {
@@ -1550,7 +1574,13 @@
}
/* Attempt to find a new bridge technology to satisfy the capabilities */
- new_technology = find_best_technology(new_capabilities);
+ new_technology = find_best_technology(new_capabilities, bridge);
+ if (!new_technology) {
+ /* We favor native bridging if possible but if not then move on without it */
+ new_capabilities &= ~AST_BRIDGE_CAPABILITY_NATIVE;
+ new_technology = find_best_technology(new_capabilities, bridge);
+ }
+
if (!new_technology) {
if (bridge->technology->capabilities & AST_BRIDGE_CAPABILITY_MULTIMIX) {
ast_debug(1, "Bridge %s could not get a new bridge technology, staying with old technology.\n",
More information about the asterisk-commits
mailing list