[Freeswitch-branches] [commit] r11919 - freeswitch/branches/gmaruzz/mod_skypiax/asterisk
Author: gmaruzz Date: Thu Feb 12 05:32:11 2009 New Revision: 11919 Log: skypiax: outbound interface automatic selection for * too: you can call skypiax/ANY/another_skypename, it will automatically chose first available channel. Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c (original) +++ freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c Thu Feb 12 05:32:11 2009 @@ -285,6 +285,7 @@ struct skypiax_pvt *p = NULL; struct ast_channel *tmp = NULL; char *name = data; + int found = 0; DEBUGA_PBX("Try to request type: %s, name: %s, cause: %d," " format: %d\n", SKYPIAX_P_LOG, type, name, *cause, format); @@ -298,9 +299,28 @@ LOKKA(&skypiax_iflock); /* make a pointer to the first interface in the interfaces list */ p = skypiax_iflist; + + + if (strncmp("ANY", name, 3) == 0) { + /* we've been asked for the "ANY" interface, let's find the first idle interface */ + DEBUGA_SKYPE("Finding one available skype interface\n", SKYPIAX_P_LOG); + p = find_available_skypiax_interface(); + if (p){ + found = 1; + + /* create a new channel owning this interface */ + tmp = skypiax_new(p, SKYPIAX_STATE_DOWN, p->context); + if (!tmp) { + /* the channel was not created, probable memory allocation error */ + *cause = AST_CAUSE_SWITCH_CONGESTION; + } + + } + + } + /* Search for the requested interface and verify if is unowned and format compatible */ - //TODO implement groups a la chan_zap - while (p) { + while (p && !found) { size_t length = strlen(p->name); /* is this the requested interface? */ if (strncmp(name, p->name, length) == 0) { @@ -870,7 +890,7 @@ i++; } if (p->SkypiaxHandles.api_connected) { - NOTICA("Interface %s is now STARTED\n", SKYPIAX_P_LOG, p->name); + NOTICA("STARTED interface %s\n", SKYPIAX_P_LOG, p->name); } else { ERRORA("Interface %s FAILED to start\n", SKYPIAX_P_LOG, p->name); running = 0;
participants (1)
-
FreeSWITCH SVN