[Freeswitch-branches] [commit] r11115 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax
FreeSWITCH SVN
gmaruzz at freeswitch.org
Sat Jan 10 23:56:56 PST 2009
Author: gmaruzz
Date: Sun Jan 11 01:56:56 2009
New Revision: 11115
Log:
skypiax: indent -gnu -ts4 -br -brs -cdw -lp -ce -nbfda -npcs -nprs -npsl -nbbo -saf -sai -saw -cs -bbo -nhnl -nut -sob -l90
Modified:
freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c
freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c
Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c
==============================================================================
--- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c (original)
+++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c Sun Jan 11 01:56:56 2009
@@ -1,6 +1,5 @@
#include "skypiax.h"
-
SWITCH_MODULE_LOAD_FUNCTION(mod_skypiax_load);
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypiax_shutdown);
SWITCH_MODULE_DEFINITION(mod_skypiax, mod_skypiax_load, mod_skypiax_shutdown, NULL); //mod_skypiax_runtime);
@@ -69,7 +68,7 @@
(&tech_pvt->read_codec, "L16", NULL, sample_rate, codec_ms, 1,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
NULL) != SWITCH_STATUS_SUCCESS) {
- ERRORA( "Can't load codec?\n", SKYPIAX_P_LOG);
+ ERRORA("Can't load codec?\n", SKYPIAX_P_LOG);
return SWITCH_STATUS_FALSE;
}
@@ -77,7 +76,7 @@
(&tech_pvt->write_codec, "L16", NULL, sample_rate, codec_ms, 1,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
NULL) != SWITCH_STATUS_SUCCESS) {
- ERRORA( "Can't load codec?\n", SKYPIAX_P_LOG);
+ ERRORA("Can't load codec?\n", SKYPIAX_P_LOG);
switch_core_codec_destroy(&tech_pvt->read_codec);
return SWITCH_STATUS_FALSE;
}
@@ -111,9 +110,9 @@
}
if (skypiax_codec(tech_pvt, SAMPLERATE_SKYPIAX, 20) != SWITCH_STATUS_SUCCESS) {
- ERRORA( "skypiax_docec FAILED\n", SKYPIAX_P_LOG);
+ ERRORA("skypiax_docec FAILED\n", SKYPIAX_P_LOG);
} else {
- DEBUGA_SKYPE( "skypiax_codec SUCCESS\n", SKYPIAX_P_LOG);
+ DEBUGA_SKYPE("skypiax_codec SUCCESS\n", SKYPIAX_P_LOG);
}
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
@@ -146,8 +145,7 @@
globals.calls++;
switch_mutex_unlock(globals.mutex);
- DEBUGA_SKYPE( "%s CHANNEL INIT\n", SKYPIAX_P_LOG,
- switch_channel_get_name(channel));
+ DEBUGA_SKYPE("%s CHANNEL INIT\n", SKYPIAX_P_LOG, switch_channel_get_name(channel));
return SWITCH_STATUS_SUCCESS;
}
@@ -186,8 +184,7 @@
switch_core_codec_destroy(&tech_pvt->write_codec);
}
- DEBUGA_SKYPE( "%s CHANNEL HANGUP\n", SKYPIAX_P_LOG,
- switch_channel_get_name(channel));
+ DEBUGA_SKYPE("%s CHANNEL HANGUP\n", SKYPIAX_P_LOG, switch_channel_get_name(channel));
switch_mutex_lock(globals.mutex);
globals.calls--;
if (globals.calls < 0) {
@@ -210,8 +207,7 @@
tech_pvt = switch_core_session_get_private(session);
assert(tech_pvt != NULL);
- DEBUGA_SKYPE( "%s CHANNEL ROUTING\n", SKYPIAX_P_LOG,
- switch_channel_get_name(channel));
+ DEBUGA_SKYPE("%s CHANNEL ROUTING\n", SKYPIAX_P_LOG, switch_channel_get_name(channel));
return SWITCH_STATUS_SUCCESS;
}
@@ -229,8 +225,7 @@
tech_pvt = switch_core_session_get_private(session);
assert(tech_pvt != NULL);
- DEBUGA_SKYPE( "%s CHANNEL EXECUTE\n", SKYPIAX_P_LOG,
- switch_channel_get_name(channel));
+ DEBUGA_SKYPE("%s CHANNEL EXECUTE\n", SKYPIAX_P_LOG, switch_channel_get_name(channel));
return SWITCH_STATUS_SUCCESS;
}
@@ -249,17 +244,15 @@
switch (sig) {
case SWITCH_SIG_KILL:
- DEBUGA_SKYPE(
- "%s CHANNEL got SWITCH_SIG_KILL\n", SKYPIAX_P_LOG,
- switch_channel_get_name(channel));
+ DEBUGA_SKYPE("%s CHANNEL got SWITCH_SIG_KILL\n", SKYPIAX_P_LOG,
+ switch_channel_get_name(channel));
switch_clear_flag_locked(tech_pvt, TFLAG_IO);
switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
switch_set_flag_locked(tech_pvt, TFLAG_HANGUP);
break;
case SWITCH_SIG_BREAK:
- DEBUGA_SKYPE(
- "%s CHANNEL got SWITCH_SIG_BREAK\n", SKYPIAX_P_LOG,
- switch_channel_get_name(channel));
+ DEBUGA_SKYPE("%s CHANNEL got SWITCH_SIG_BREAK\n", SKYPIAX_P_LOG,
+ switch_channel_get_name(channel));
switch_set_flag_locked(tech_pvt, TFLAG_BREAK);
break;
default:
@@ -272,14 +265,14 @@
static switch_status_t channel_on_exchange_media(switch_core_session_t * session)
{
skypiax_interface_t *p = NULL;
- DEBUGA_SKYPE( "CHANNEL LOOPBACK\n", SKYPIAX_P_LOG);
+ DEBUGA_SKYPE("CHANNEL LOOPBACK\n", SKYPIAX_P_LOG);
return SWITCH_STATUS_SUCCESS;
}
static switch_status_t channel_on_soft_execute(switch_core_session_t * session)
{
skypiax_interface_t *p = NULL;
- DEBUGA_SKYPE( "CHANNEL TRANSMIT\n", SKYPIAX_P_LOG);
+ DEBUGA_SKYPE("CHANNEL TRANSMIT\n", SKYPIAX_P_LOG);
return SWITCH_STATUS_SUCCESS;
}
@@ -292,9 +285,9 @@
p = tech_pvt->p;
- NOTICA( "DTMF: %c\n", SKYPIAX_P_LOG, dtmf->digit);
+ NOTICA("DTMF: %c\n", SKYPIAX_P_LOG, dtmf->digit);
-skypiax_skype_senddigit(p, dtmf->digit);
+ skypiax_skype_senddigit(p, dtmf->digit);
return SWITCH_STATUS_SUCCESS;
}
@@ -318,8 +311,7 @@
if (skypiax_skypeaudio_read(tech_pvt) != SWITCH_STATUS_SUCCESS) {
- ERRORA(
- "skypiax_skypeaudio_read ERROR\n", SKYPIAX_P_LOG);
+ ERRORA("skypiax_skypeaudio_read ERROR\n", SKYPIAX_P_LOG);
} else {
switch_set_flag_locked(tech_pvt, TFLAG_VOICE);
@@ -330,14 +322,12 @@
while (switch_test_flag(tech_pvt, TFLAG_IO)) {
if (switch_test_flag(tech_pvt, TFLAG_BREAK)) {
switch_clear_flag(tech_pvt, TFLAG_BREAK);
- DEBUGA_SKYPE(
- "CHANNEL READ FRAME goto CNG\n", SKYPIAX_P_LOG);
+ DEBUGA_SKYPE("CHANNEL READ FRAME goto CNG\n", SKYPIAX_P_LOG);
goto cng;
}
if (!switch_test_flag(tech_pvt, TFLAG_IO)) {
- DEBUGA_SKYPE(
- "CHANNEL READ FRAME not IO\n", SKYPIAX_P_LOG);
+ DEBUGA_SKYPE("CHANNEL READ FRAME not IO\n", SKYPIAX_P_LOG);
return SWITCH_STATUS_FALSE;
}
//DEBUGA_SKYPE( "============>\n");
@@ -345,8 +335,7 @@
if (switch_test_flag(tech_pvt, TFLAG_IO) && switch_test_flag(tech_pvt, TFLAG_VOICE)) {
switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
if (!tech_pvt->read_frame.datalen) {
- DEBUGA_SKYPE(
- "CHANNEL READ CONTINUE\n", SKYPIAX_P_LOG);
+ DEBUGA_SKYPE("CHANNEL READ CONTINUE\n", SKYPIAX_P_LOG);
continue;
}
*frame = &tech_pvt->read_frame;
@@ -358,12 +347,12 @@
return SWITCH_STATUS_SUCCESS;
}
- DEBUGA_SKYPE( "CHANNEL READ no TFLAG_IO\n", SKYPIAX_P_LOG);
+ DEBUGA_SKYPE("CHANNEL READ no TFLAG_IO\n", SKYPIAX_P_LOG);
return SWITCH_STATUS_FALSE;
}
- DEBUGA_SKYPE( "CHANNEL READ FALSE\n", SKYPIAX_P_LOG);
+ DEBUGA_SKYPE("CHANNEL READ FALSE\n", SKYPIAX_P_LOG);
return SWITCH_STATUS_FALSE;
cng:
@@ -488,7 +477,7 @@
body = "";
}
- WARNINGA( "event: |||%s|||\n", SKYPIAX_P_LOG, body);
+ WARNINGA("event: |||%s|||\n", SKYPIAX_P_LOG, body);
return SWITCH_STATUS_SUCCESS;
}
@@ -524,58 +513,60 @@
private_t *tech_pvt;
switch_channel_t *channel;
switch_caller_profile_t *caller_profile;
- skypiax_interface_t *p = NULL;
+ skypiax_interface_t *p = NULL;
switch_core_session_add_stream(*new_session, NULL);
-
if ((tech_pvt =
(private_t *) switch_core_session_alloc(*new_session, sizeof(private_t))) != 0) {
- int found=0;
- char interface_name[256];
-
-
- if (strlen(outbound_profile->destination_number)) {
- int i;
- char *slash;
-
- strncpy(interface_name, outbound_profile->destination_number, 255);
- slash=strrchr(interface_name, '/');
- *slash='\0';
+ int found = 0;
+ char interface_name[256];
+ if (strlen(outbound_profile->destination_number)) {
+ int i;
+ char *slash;
+
+ strncpy(interface_name, outbound_profile->destination_number, 255);
+ slash = strrchr(interface_name, '/');
+ *slash = '\0';
+
+ for (i = 0; i < SKYPIAX_MAX_INTERFACES; i++) {
+
+ if (strlen(globals.SKYPIAX_INTERFACES[i].name)
+ &&
+ (strncmp
+ (globals.SKYPIAX_INTERFACES[i].name, interface_name,
+ strlen(interface_name)) == 0)) {
+
+ DEBUGA_SKYPE("globals.SKYPIAX_INTERFACES[%d].name=|||%s|||?\n", SKYPIAX_P_LOG,
+ i, globals.SKYPIAX_INTERFACES[i].name);
+ tech_pvt->p = &globals.SKYPIAX_INTERFACES[i]; //FIXME
+ globals.SKYPIAX_INTERFACES[i].tech_pvt = tech_pvt; //FIXME
+ found = 1;
+ break;
+ }
- for(i=0; i< SKYPIAX_MAX_INTERFACES; i++){
-
- if( strlen(globals.SKYPIAX_INTERFACES[i].name) && (strncmp(globals.SKYPIAX_INTERFACES[i].name, interface_name, strlen(interface_name)) == 0 )) {
-
- DEBUGA_SKYPE( "globals.SKYPIAX_INTERFACES[%d].name=|||%s|||?\n", SKYPIAX_P_LOG, i, globals.SKYPIAX_INTERFACES[i].name);
- tech_pvt->p = &globals.SKYPIAX_INTERFACES[i]; //FIXME
- globals.SKYPIAX_INTERFACES[i].tech_pvt = tech_pvt; //FIXME
- found=1;
- break;
- }
-
- }
+ }
- } else {
- ERRORA( "Doh! no destination number?\n", SKYPIAX_P_LOG);
- switch_core_session_destroy(new_session);
- return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
- }
+ } else {
+ ERRORA("Doh! no destination number?\n", SKYPIAX_P_LOG);
+ switch_core_session_destroy(new_session);
+ return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
+ }
- if(!found){
- ERRORA( "Doh! no matching interface for |||%s|||?\n", SKYPIAX_P_LOG, interface_name);
- switch_core_session_destroy(new_session);
- return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
+ if (!found) {
+ ERRORA("Doh! no matching interface for |||%s|||?\n", SKYPIAX_P_LOG,
+ interface_name);
+ switch_core_session_destroy(new_session);
+ return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
- }
+ }
//tech_pvt->p = &globals.SKYPIAX_INTERFACES[19]; //FIXME
//globals.SKYPIAX_INTERFACES[19].tech_pvt = tech_pvt; //FIXME
channel = switch_core_session_get_channel(*new_session);
skypiax_tech_init(tech_pvt, *new_session, NULL);
} else {
- ERRORA(
- "Hey where is my memory pool?\n", SKYPIAX_P_LOG);
+ ERRORA("Hey where is my memory pool?\n", SKYPIAX_P_LOG);
switch_core_session_destroy(new_session);
return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
}
@@ -586,23 +577,26 @@
snprintf(name, sizeof(name), "skypiax/%s", outbound_profile->destination_number);
//snprintf(name, sizeof(name), "skypiax/%s", p->name);
switch_channel_set_name(channel, name);
- NOTICA( "outbound_profile->destination_number=|||%s|||\n", SKYPIAX_P_LOG, outbound_profile->destination_number);
- NOTICA( "outbound_profile->username=|||%s|||\n", SKYPIAX_P_LOG, outbound_profile->username);
- NOTICA( "outbound_profile->caller_id_name=|||%s|||\n", SKYPIAX_P_LOG, outbound_profile->caller_id_name);
- NOTICA( "outbound_profile->caller_id_number=|||%s|||\n", SKYPIAX_P_LOG, outbound_profile->caller_id_number);
+ NOTICA("outbound_profile->destination_number=|||%s|||\n", SKYPIAX_P_LOG,
+ outbound_profile->destination_number);
+ NOTICA("outbound_profile->username=|||%s|||\n", SKYPIAX_P_LOG,
+ outbound_profile->username);
+ NOTICA("outbound_profile->caller_id_name=|||%s|||\n", SKYPIAX_P_LOG,
+ outbound_profile->caller_id_name);
+ NOTICA("outbound_profile->caller_id_number=|||%s|||\n", SKYPIAX_P_LOG,
+ outbound_profile->caller_id_number);
caller_profile = switch_caller_profile_clone(*new_session, outbound_profile);
switch_channel_set_caller_profile(channel, caller_profile);
tech_pvt->caller_profile = caller_profile;
} else {
- ERRORA( "Doh! no caller profile\n", SKYPIAX_P_LOG);
+ ERRORA("Doh! no caller profile\n", SKYPIAX_P_LOG);
switch_core_session_destroy(new_session);
return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
}
skypiax_skype_call(tech_pvt->p, caller_profile->destination_number, 30, *new_session);
-
switch_channel_set_flag(channel, CF_OUTBOUND);
switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND);
switch_channel_set_state(channel, CS_INIT);
@@ -667,7 +661,7 @@
ERRORA("no tech_pvt?\n", SKYPIAX_P_LOG);
}
p->interface_state = SKYPIAX_STATE_DOWN;
- tech_pvt->session = NULL; //FIXME
+ tech_pvt->session = NULL; //FIXME
}
}
@@ -696,44 +690,36 @@
char *val = (char *) switch_xml_attr_soft(param, "value");
if (!strcasecmp(var, "debug")) {
- DEBUGA_SKYPE( "globals.debug=%d\n", SKYPIAX_P_LOG,
- globals.debug);
+ DEBUGA_SKYPE("globals.debug=%d\n", SKYPIAX_P_LOG, globals.debug);
globals.debug = atoi(val);
- DEBUGA_SKYPE( "globals.debug=%d\n", SKYPIAX_P_LOG,
- globals.debug);
+ DEBUGA_SKYPE("globals.debug=%d\n", SKYPIAX_P_LOG, globals.debug);
} else if (!strcasecmp(var, "hold-music")) {
switch_set_string(globals.hold_music, val);
- DEBUGA_SKYPE( "globals.hold_music=%s\n", SKYPIAX_P_LOG,
- globals.hold_music);
+ DEBUGA_SKYPE("globals.hold_music=%s\n", SKYPIAX_P_LOG, globals.hold_music);
} else if (!strcmp(var, "port")) {
globals.port = atoi(val);
- DEBUGA_SKYPE( "globals.port=%d\n", SKYPIAX_P_LOG,
- globals.port);
+ DEBUGA_SKYPE("globals.port=%d\n", SKYPIAX_P_LOG, globals.port);
} else if (!strcmp(var, "ip")) {
set_global_ip(val);
- DEBUGA_SKYPE( "globals.ip=%s\n", SKYPIAX_P_LOG,
- globals.ip);
+ DEBUGA_SKYPE("globals.ip=%s\n", SKYPIAX_P_LOG, globals.ip);
} else if (!strcmp(var, "codec-master")) {
if (!strcasecmp(val, "us")) {
switch_set_flag(&globals, GFLAG_MY_CODEC_PREFS);
}
- DEBUGA_SKYPE(
- "codec-master globals.debug=%d\n", SKYPIAX_P_LOG, globals.debug);
+ DEBUGA_SKYPE("codec-master globals.debug=%d\n", SKYPIAX_P_LOG, globals.debug);
} else if (!strcmp(var, "dialplan")) {
set_global_dialplan(val);
- DEBUGA_SKYPE( "globals.dialplan=%s\n", SKYPIAX_P_LOG,
- globals.dialplan);
+ DEBUGA_SKYPE("globals.dialplan=%s\n", SKYPIAX_P_LOG, globals.dialplan);
} else if (!strcmp(var, "codec-prefs")) {
set_global_codec_string(val);
- DEBUGA_SKYPE(
- "globals.codec_string=%s\n", SKYPIAX_P_LOG, globals.codec_string);
+ DEBUGA_SKYPE("globals.codec_string=%s\n", SKYPIAX_P_LOG, globals.codec_string);
globals.codec_order_last =
switch_separate_string(globals.codec_string, ',', globals.codec_order,
SWITCH_MAX_CODECS);
} else if (!strcmp(var, "codec-rates")) {
set_global_codec_rates_string(val);
- DEBUGA_SKYPE(
- "globals.codec_rates_string=%s\n", SKYPIAX_P_LOG, globals.codec_rates_string);
+ DEBUGA_SKYPE("globals.codec_rates_string=%s\n", SKYPIAX_P_LOG,
+ globals.codec_rates_string);
globals.codec_rates_last =
switch_separate_string(globals.codec_rates_string, ',', globals.codec_rates,
SWITCH_MAX_CODECS);
@@ -805,50 +791,41 @@
}
if (!skype_user) {
- ERRORA(
- "interface missing REQUIRED param 'skype_user'\n", SKYPIAX_P_LOG);
+ ERRORA("interface missing REQUIRED param 'skype_user'\n", SKYPIAX_P_LOG);
continue;
}
if (!skype_password) {
- ERRORA(
- "interface missing REQUIRED param 'skype_password'\n", SKYPIAX_P_LOG);
+ ERRORA("interface missing REQUIRED param 'skype_password'\n", SKYPIAX_P_LOG);
continue;
}
if (!X11_display) {
- ERRORA(
- "interface missing REQUIRED param 'X11_display'\n", SKYPIAX_P_LOG);
+ ERRORA("interface missing REQUIRED param 'X11_display'\n", SKYPIAX_P_LOG);
continue;
}
if (!tcp_cli_port) {
- ERRORA(
- "interface missing REQUIRED param 'tcp_cli_port'\n", SKYPIAX_P_LOG);
+ ERRORA("interface missing REQUIRED param 'tcp_cli_port'\n", SKYPIAX_P_LOG);
continue;
}
if (!tcp_srv_port) {
- ERRORA(
- "interface missing REQUIRED param 'tcp_srv_port'\n", SKYPIAX_P_LOG);
+ ERRORA("interface missing REQUIRED param 'tcp_srv_port'\n", SKYPIAX_P_LOG);
continue;
}
if (!id) {
- ERRORA(
- "interface missing REQUIRED param 'id'\n", SKYPIAX_P_LOG);
+ ERRORA("interface missing REQUIRED param 'id'\n", SKYPIAX_P_LOG);
continue;
}
if (switch_is_number(id)) {
interface_id = atoi(id);
- DEBUGA_SKYPE( "interface_id=%d\n", SKYPIAX_P_LOG,
- interface_id);
+ DEBUGA_SKYPE("interface_id=%d\n", SKYPIAX_P_LOG, interface_id);
} else {
- ERRORA(
- "interface param 'id' MUST be a number, now id='%s'\n", SKYPIAX_P_LOG, id);
+ ERRORA("interface param 'id' MUST be a number, now id='%s'\n", SKYPIAX_P_LOG, id);
continue;
}
if (!name) {
- WARNINGA(
- "interface missing param 'name', not nice, but works\n", SKYPIAX_P_LOG);
+ WARNINGA("interface missing param 'name', not nice, but works\n", SKYPIAX_P_LOG);
}
if (!tonegroup) {
@@ -864,7 +841,7 @@
}
if (name) {
- DEBUGA_SKYPE( "name=%s\n", SKYPIAX_P_LOG, name);
+ DEBUGA_SKYPE("name=%s\n", SKYPIAX_P_LOG, name);
}
#ifndef WIN32
if (!XInitThreads()) {
@@ -882,8 +859,7 @@
memset(&newconf, '\0', sizeof(newconf));
globals.SKYPIAX_INTERFACES[interface_id] = newconf;
- DEBUGA_SKYPE(
- "CONFIGURING interface_id=%d\n", SKYPIAX_P_LOG, interface_id);
+ DEBUGA_SKYPE("CONFIGURING interface_id=%d\n", SKYPIAX_P_LOG, interface_id);
switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].interface_id, id);
if (name) {
switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].name, name);
@@ -910,38 +886,37 @@
switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].context, context);
switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].dialplan, dialplan);
- DEBUGA_SKYPE(
- "interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].X11_display=%s\n", SKYPIAX_P_LOG,
- interface_id,
- globals.SKYPIAX_INTERFACES[interface_id].X11_display);
- DEBUGA_SKYPE(
- "interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].skype_user=%s\n", SKYPIAX_P_LOG,
- interface_id,
- globals.SKYPIAX_INTERFACES[interface_id].skype_user);
- DEBUGA_SKYPE(
- "interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].skype_password=%s\n", SKYPIAX_P_LOG,
- interface_id,
- globals.SKYPIAX_INTERFACES[interface_id].skype_password);
- DEBUGA_SKYPE(
- "interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].tcp_cli_port=%d\n", SKYPIAX_P_LOG,
- interface_id,
- globals.SKYPIAX_INTERFACES[interface_id].tcp_cli_port);
- DEBUGA_SKYPE(
- "interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].tcp_srv_port=%d\n", SKYPIAX_P_LOG,
- interface_id,
- globals.SKYPIAX_INTERFACES[interface_id].tcp_srv_port);
- DEBUGA_SKYPE(
- "interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].name=%s\n", SKYPIAX_P_LOG,
- interface_id, globals.SKYPIAX_INTERFACES[interface_id].name);
- DEBUGA_SKYPE(
- "interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].context=%s\n", SKYPIAX_P_LOG,
- interface_id, globals.SKYPIAX_INTERFACES[interface_id].context);
- DEBUGA_SKYPE(
- "interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].dialplan=%s\n", SKYPIAX_P_LOG,
- interface_id,
- globals.SKYPIAX_INTERFACES[interface_id].dialplan);
- NOTICA(
- "STARTING interface_id=%d\n", SKYPIAX_P_LOG, interface_id);
+ DEBUGA_SKYPE
+ ("interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].X11_display=%s\n",
+ SKYPIAX_P_LOG, interface_id,
+ globals.SKYPIAX_INTERFACES[interface_id].X11_display);
+ DEBUGA_SKYPE
+ ("interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].skype_user=%s\n",
+ SKYPIAX_P_LOG, interface_id,
+ globals.SKYPIAX_INTERFACES[interface_id].skype_user);
+ DEBUGA_SKYPE
+ ("interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].skype_password=%s\n",
+ SKYPIAX_P_LOG, interface_id,
+ globals.SKYPIAX_INTERFACES[interface_id].skype_password);
+ DEBUGA_SKYPE
+ ("interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].tcp_cli_port=%d\n",
+ SKYPIAX_P_LOG, interface_id,
+ globals.SKYPIAX_INTERFACES[interface_id].tcp_cli_port);
+ DEBUGA_SKYPE
+ ("interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].tcp_srv_port=%d\n",
+ SKYPIAX_P_LOG, interface_id,
+ globals.SKYPIAX_INTERFACES[interface_id].tcp_srv_port);
+ DEBUGA_SKYPE("interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].name=%s\n",
+ SKYPIAX_P_LOG, interface_id,
+ globals.SKYPIAX_INTERFACES[interface_id].name);
+ DEBUGA_SKYPE
+ ("interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].context=%s\n",
+ SKYPIAX_P_LOG, interface_id, globals.SKYPIAX_INTERFACES[interface_id].context);
+ DEBUGA_SKYPE
+ ("interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].dialplan=%s\n",
+ SKYPIAX_P_LOG, interface_id,
+ globals.SKYPIAX_INTERFACES[interface_id].dialplan);
+ NOTICA("STARTING interface_id=%d\n", SKYPIAX_P_LOG, interface_id);
switch_threadattr_create(&do_skype_thd_attr, skypiax_module_pool);
//switch_threadattr_detach_set(do_skype_thd_attr, 1);
@@ -969,16 +944,14 @@
skypiax_skypeaudio_init(&globals.SKYPIAX_INTERFACES[interface_id]);
-
- while(globals.SKYPIAX_INTERFACES[interface_id].AsteriskHandlesAst.api_connected == 0)
- switch_sleep(1000);
- NOTICA(
- "STARTED interface_id=%d\n", SKYPIAX_P_LOG, interface_id);
+ while (globals.SKYPIAX_INTERFACES[interface_id].AsteriskHandlesAst.
+ api_connected == 0)
+ switch_sleep(1000);
+ NOTICA("STARTED interface_id=%d\n", SKYPIAX_P_LOG, interface_id);
} else {
- ERRORA(
- "interface id %d is higher than SKYPIAX_MAX_INTERFACES (%d)\n", SKYPIAX_P_LOG,
- interface_id, SKYPIAX_MAX_INTERFACES);
+ ERRORA("interface id %d is higher than SKYPIAX_MAX_INTERFACES (%d)\n",
+ SKYPIAX_P_LOG, interface_id, SKYPIAX_MAX_INTERFACES);
continue;
}
@@ -986,21 +959,16 @@
for (i = 0; i < SKYPIAX_MAX_INTERFACES; i++) {
if (strlen(globals.SKYPIAX_INTERFACES[i].name)) {
- DEBUGA_SKYPE(
- "i=%d globals.SKYPIAX_INTERFACES[%d].interface_id=%s\n", SKYPIAX_P_LOG, i, i,
- globals.SKYPIAX_INTERFACES[i].interface_id);
- DEBUGA_SKYPE(
- "i=%d globals.SKYPIAX_INTERFACES[%d].X11_display=%s\n", SKYPIAX_P_LOG, i, i,
- globals.SKYPIAX_INTERFACES[i].X11_display);
- DEBUGA_SKYPE(
- "i=%d globals.SKYPIAX_INTERFACES[%d].name=%s\n", SKYPIAX_P_LOG, i, i,
- globals.SKYPIAX_INTERFACES[i].name);
- DEBUGA_SKYPE(
- "i=%d globals.SKYPIAX_INTERFACES[%d].context=%s\n", SKYPIAX_P_LOG, i, i,
- globals.SKYPIAX_INTERFACES[i].context);
- DEBUGA_SKYPE(
- "i=%d globals.SKYPIAX_INTERFACES[%d].dialplan=%s\n", SKYPIAX_P_LOG, i, i,
- globals.SKYPIAX_INTERFACES[i].dialplan);
+ DEBUGA_SKYPE("i=%d globals.SKYPIAX_INTERFACES[%d].interface_id=%s\n",
+ SKYPIAX_P_LOG, i, i, globals.SKYPIAX_INTERFACES[i].interface_id);
+ DEBUGA_SKYPE("i=%d globals.SKYPIAX_INTERFACES[%d].X11_display=%s\n",
+ SKYPIAX_P_LOG, i, i, globals.SKYPIAX_INTERFACES[i].X11_display);
+ DEBUGA_SKYPE("i=%d globals.SKYPIAX_INTERFACES[%d].name=%s\n", SKYPIAX_P_LOG, i, i,
+ globals.SKYPIAX_INTERFACES[i].name);
+ DEBUGA_SKYPE("i=%d globals.SKYPIAX_INTERFACES[%d].context=%s\n", SKYPIAX_P_LOG, i,
+ i, globals.SKYPIAX_INTERFACES[i].context);
+ DEBUGA_SKYPE("i=%d globals.SKYPIAX_INTERFACES[%d].dialplan=%s\n", SKYPIAX_P_LOG,
+ i, i, globals.SKYPIAX_INTERFACES[i].dialplan);
}
}
}
Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c
==============================================================================
--- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c (original)
+++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c Sun Jan 11 01:56:56 2009
@@ -115,17 +115,14 @@
#ifdef WIN32
len = recv(fd, (char *) srv_in, 320, 0); //seems that Skype only sends 320 bytes at time
#else /* WIN32 */
- while(received < SAMPLES_PER_FRAME * sizeof(short)){
- len = recv(fd, srv_in + (received / sizeof(short)), (SAMPLES_PER_FRAME * sizeof(short)) - received, 0); //seems that Skype only sends 320 bytes at time
- received += len;
- if(len == 0)
- break;
- }
- if(len)
- len = received;
-
-
-
+ while (received < SAMPLES_PER_FRAME * sizeof(short)) {
+ len = recv(fd, srv_in + (received / sizeof(short)), (SAMPLES_PER_FRAME * sizeof(short)) - received, 0); //seems that Skype only sends 320 bytes at time
+ received += len;
+ if (len == 0)
+ break;
+ }
+ if (len)
+ len = received;
//len = recv(fd, srv_in, SAMPLES_PER_FRAME * sizeof(short), 0); //seems that Skype only sends 320 bytes at time
#endif /* WIN32 */
@@ -196,8 +193,8 @@
#endif /* WIN32 */
//p->audiobuf_is_loaded = 0;
//WARNINGA("SRV PIPE WRITE=====> req=%lu recv=%d to sent=%d sent=%u\n",
- //SKYPIAX_P_LOG, sizeof(short) * SAMPLES_PER_FRAME, len, len,
- //howmany);
+ //SKYPIAX_P_LOG, sizeof(short) * SAMPLES_PER_FRAME, len, len,
+ //howmany);
} else if (len == SAMPLES_PER_FRAME * sizeof(short) / 2) {
#if 1
@@ -508,14 +505,14 @@
switch_file_pipe_create(&p->audioskypepipe[0], &p->audioskypepipe[1],
skypiax_module_pool);
#else /* WIN32 */
- if(pipe(p->audiopipe)){
- fcntl(p->audiopipe[0], F_SETFL, O_NONBLOCK);
- fcntl(p->audiopipe[1], F_SETFL, O_NONBLOCK);
-}
- if (pipe(p->audioskypepipe)){
- fcntl(p->audioskypepipe[0], F_SETFL, O_NONBLOCK);
- fcntl(p->audioskypepipe[1], F_SETFL, O_NONBLOCK);
-}
+ if (pipe(p->audiopipe)) {
+ fcntl(p->audiopipe[0], F_SETFL, O_NONBLOCK);
+ fcntl(p->audiopipe[1], F_SETFL, O_NONBLOCK);
+ }
+ if (pipe(p->audioskypepipe)) {
+ fcntl(p->audioskypepipe[0], F_SETFL, O_NONBLOCK);
+ fcntl(p->audioskypepipe[1], F_SETFL, O_NONBLOCK);
+ }
#endif /* WIN32 */
//rv = switch_file_pipe_timeout_set(p->audiopipe[0], 100);
@@ -1030,23 +1027,20 @@
DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
//switch_file_pipe_create(&p->AsteriskHandlesAst.fdesc[0], &p->AsteriskHandlesAst.fdesc[1], skypiax_module_pool);
-if(pipe(p->AsteriskHandlesAst.fdesc)){
- fcntl(p->AsteriskHandlesAst.fdesc[0], F_SETFL, O_NONBLOCK);
- fcntl(p->AsteriskHandlesAst.fdesc[1], F_SETFL, O_NONBLOCK);
-}
-
+ if (pipe(p->AsteriskHandlesAst.fdesc)) {
+ fcntl(p->AsteriskHandlesAst.fdesc[0], F_SETFL, O_NONBLOCK);
+ fcntl(p->AsteriskHandlesAst.fdesc[1], F_SETFL, O_NONBLOCK);
+ }
//switch_file_pipe_timeout_set(p->AsteriskHandlesAst.fdesc[0], 100);
AsteriskHandlesAst = &p->AsteriskHandlesAst;
//disp = XOpenDisplay(getenv("DISPLAY"));
disp = XOpenDisplay(p->X11_display);
if (!disp) {
- ERRORA(
- "Cannot open X Display '%s', exiting skype thread\n", SKYPIAX_P_LOG,
- p->X11_display);
+ ERRORA("Cannot open X Display '%s', exiting skype thread\n", SKYPIAX_P_LOG,
+ p->X11_display);
return NULL;
} else {
- DEBUGA_SKYPE( "X Display '%s' opened\n", SKYPIAX_P_LOG,
- p->X11_display);
+ DEBUGA_SKYPE("X Display '%s' opened\n", SKYPIAX_P_LOG, p->X11_display);
}
int xfd;
@@ -1234,10 +1228,9 @@
fd_set fs;
struct timeval to;
#endif /* WIN32 */
- private_t *tech_pvt = NULL;
-
- tech_pvt = p->tech_pvt;
+ private_t *tech_pvt = NULL;
+ tech_pvt = p->tech_pvt;
if (option_debug > 100) {
DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
@@ -1280,15 +1273,17 @@
DEBUGA_SKYPE("read_skype: howmany=%d, i=%d, a=%d, |||%s||| \n", SKYPIAX_P_LOG,
howmany, i, a, messaggio);
- if (!strcasecmp(messaggio, "ERROR 68")) { /* not yet protocol specified,
- just authorized */
- DEBUGA_SKYPE ("If I don't connect immediately, please give the Skype client authorization to be connected by Skypiax (and to not ask you again)\n", SKYPIAX_P_LOG);
+ if (!strcasecmp(messaggio, "ERROR 68")) { /* not yet protocol specified,
+ just authorized */
+ DEBUGA_SKYPE
+ ("If I don't connect immediately, please give the Skype client authorization to be connected by Skypiax (and to not ask you again)\n",
+ SKYPIAX_P_LOG);
switch_sleep(1000000);
skypiax_skype_write(p, "PROTOCOL 6");
switch_sleep(10000);
return 0;
}
-
+
if (!strncasecmp(messaggio, "ERROR 92 CALL", 12)) {
ERRORA("Skype got ERROR: |||%s|||, the number we called was not recognized\n",
SKYPIAX_P_LOG, messaggio);
@@ -1365,66 +1360,67 @@
}
}
- if (!strcasecmp(messaggio, "USER")) {
- strncpy(obj, where, sizeof(obj) - 1);
-
- where = strsep(stringp, " ");
-
- strncpy(id, where, sizeof(id) - 1);
-
- where = strsep(stringp, " ");
-
- strncpy(prop, where, sizeof(prop) - 1);
-
- if (!strcasecmp(prop,"RECEIVEDAUTHREQUEST" )) {
- char msg_to_skype[256];
- DEBUGA_SKYPE ("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s!\n", SKYPIAX_P_LOG, messaggio, obj, id, prop);
+ if (!strcasecmp(messaggio, "USER")) {
+ strncpy(obj, where, sizeof(obj) - 1);
- //FIXME: TODO: allow authorization based on config param
- sprintf(msg_to_skype, "SET USER %s ISAUTHORIZED TRUE", id);
- skypiax_skype_write(p, msg_to_skype);
- }
- }
+ where = strsep(stringp, " ");
+ strncpy(id, where, sizeof(id) - 1);
- if (!strcasecmp(messaggio, "MESSAGE")) {
- strncpy(obj, where, sizeof(obj) - 1);
+ where = strsep(stringp, " ");
- where = strsep(stringp, " ");
+ strncpy(prop, where, sizeof(prop) - 1);
- strncpy(id, where, sizeof(id) - 1);
+ if (!strcasecmp(prop, "RECEIVEDAUTHREQUEST")) {
+ char msg_to_skype[256];
+ DEBUGA_SKYPE("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s!\n",
+ SKYPIAX_P_LOG, messaggio, obj, id, prop);
+
+ //FIXME: TODO: allow authorization based on config param
+ sprintf(msg_to_skype, "SET USER %s ISAUTHORIZED TRUE", id);
+ skypiax_skype_write(p, msg_to_skype);
+ }
+ }
- where = strsep(stringp, " ");
+ if (!strcasecmp(messaggio, "MESSAGE")) {
+ strncpy(obj, where, sizeof(obj) - 1);
- strncpy(prop, where, sizeof(prop) - 1);
+ where = strsep(stringp, " ");
- if (!strcasecmp(prop,"STATUS" )) {
+ strncpy(id, where, sizeof(id) - 1);
- where = strsep(stringp, " ");
+ where = strsep(stringp, " ");
- strncpy(value, where, sizeof(value) - 1);
+ strncpy(prop, where, sizeof(prop) - 1);
+ if (!strcasecmp(prop, "STATUS")) {
- if (!strcasecmp(value,"RECEIVED" )) {
- char msg_to_skype[256];
- DEBUGA_SKYPE ("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s value: %s!\n", SKYPIAX_P_LOG, messaggio, obj, id, prop, value);
+ where = strsep(stringp, " ");
- //FIXME: TODO: allow authorization based on config param
- sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id);
- skypiax_skype_write(p, msg_to_skype);
- }
- } else if (!strcasecmp(prop,"BODY" )) {
- char msg_to_skype[256];
+ strncpy(value, where, sizeof(value) - 1);
- DEBUGA_SKYPE ("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s!\n", SKYPIAX_P_LOG, messaggio, obj, id, prop);
+ if (!strcasecmp(value, "RECEIVED")) {
+ char msg_to_skype[256];
+ DEBUGA_SKYPE
+ ("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s value: %s!\n",
+ SKYPIAX_P_LOG, messaggio, obj, id, prop, value);
+
+ //FIXME: TODO: allow authorization based on config param
+ sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id);
+ skypiax_skype_write(p, msg_to_skype);
+ }
+ } else if (!strcasecmp(prop, "BODY")) {
+ char msg_to_skype[256];
- //FIXME: TODO: on config param ???
- sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id);
- skypiax_skype_write(p, msg_to_skype);
- }
+ DEBUGA_SKYPE("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s!\n",
+ SKYPIAX_P_LOG, messaggio, obj, id, prop);
- }
+ //FIXME: TODO: on config param ???
+ sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id);
+ skypiax_skype_write(p, msg_to_skype);
+ }
+ }
if (!strcasecmp(messaggio, "CALL")) {
@@ -1491,8 +1487,8 @@
if (channel) {
switch_dtmf_t dtmf =
{ (char) value[0], switch_core_default_dtmf_duration(0) };
- NOTICA("%c DTMF %s\n", SKYPIAX_P_LOG,
- dtmf.digit, switch_channel_get_name(channel));
+ NOTICA("%c DTMF %s\n", SKYPIAX_P_LOG, dtmf.digit,
+ switch_channel_get_name(channel));
switch_mutex_lock(tech_pvt->flag_mutex);
switch_channel_queue_dtmf(channel, &dtmf);
switch_set_flag(tech_pvt, TFLAG_DTMF);
@@ -1700,13 +1696,12 @@
//FIXME *new_session=switch_loadable_module_create_interface(skypiax_endpoint_interface, pool);
- if (!p->tech_pvt || !tech_pvt->session) { //FIXME FIXME FIXME
+ if (!p->tech_pvt || !tech_pvt->session) { //FIXME FIXME FIXME
switch_core_session_t *session = NULL;
private_t *tech_pvt = NULL;
switch_channel_t *channel = NULL;
- NOTICA(
- "New Inbound Channel!\n", SKYPIAX_P_LOG);
+ NOTICA("New Inbound Channel!\n", SKYPIAX_P_LOG);
if ((session =
switch_core_session_request(skypiax_endpoint_interface,
@@ -1719,8 +1714,7 @@
channel = switch_core_session_get_channel(session);
skypiax_tech_init(tech_pvt, session, p);
} else {
- ERRORA(
- "Hey where is my memory pool?\n", SKYPIAX_P_LOG);
+ ERRORA("Hey where is my memory pool?\n", SKYPIAX_P_LOG);
switch_core_session_destroy(&session);
break;
}
@@ -1743,8 +1737,7 @@
switch_channel_set_state(channel, CS_INIT);
if (switch_core_session_thread_launch(session) !=
SWITCH_STATUS_SUCCESS) {
- ERRORA(
- "Error spawning thread\n", SKYPIAX_P_LOG);
+ ERRORA("Error spawning thread\n", SKYPIAX_P_LOG);
switch_core_session_destroy(&session);
}
}
@@ -1755,27 +1748,27 @@
private_t *tech_pvt = NULL;
switch_channel_t *channel = NULL;
- if(p->tech_pvt){
- tech_pvt = p->tech_pvt;
- } else {
- ERRORA("No p->tech_pvt???\n", SKYPIAX_P_LOG);
- }
- if(tech_pvt->session){
- session = tech_pvt->session;
- }else {
- ERRORA("No tech_pvt->session???\n", SKYPIAX_P_LOG);
+ if (p->tech_pvt) {
+ tech_pvt = p->tech_pvt;
+ } else {
+ ERRORA("No p->tech_pvt???\n", SKYPIAX_P_LOG);
+ }
+ if (tech_pvt->session) {
+ session = tech_pvt->session;
+ } else {
+ ERRORA("No tech_pvt->session???\n", SKYPIAX_P_LOG);
- }
+ }
//session = global_session;
- if(session){
- channel = switch_core_session_get_channel(session);
- //DEBUGA_SKYPE("skype_call: %s, answered\n", SKYPIAX_P_LOG, id);
- switch_channel_mark_answered(channel);
- }else {
+ if (session) {
+ channel = switch_core_session_get_channel(session);
+ //DEBUGA_SKYPE("skype_call: %s, answered\n", SKYPIAX_P_LOG, id);
+ switch_channel_mark_answered(channel);
+ } else {
- ERRORA("No session???\n", SKYPIAX_P_LOG);
+ ERRORA("No session???\n", SKYPIAX_P_LOG);
- }
+ }
//switch_channel_set_state(channel, CS_EXECUTE);
@@ -1830,7 +1823,7 @@
char *rdest;
char msg_to_skype[1024];
private_t *tech_pvt;
- switch_caller_profile_t *caller_profile;
+ switch_caller_profile_t *caller_profile;
tech_pvt = p->tech_pvt;
@@ -1863,7 +1856,6 @@
caller_profile = tech_pvt->caller_profile;
caller_profile->destination_number = rdest;
-
//FIXME ast_queue_control(p->owner, SKYPIAX_CONTROL_RINGING);
return 0;
}
More information about the Freeswitch-branches
mailing list