Freeswitch-svn
Threads by month
- ----- 2026 -----
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- 12151 discussions
[commit] r11045 - in freeswitch/trunk/src/mod: applications/mod_dptools endpoints/mod_sofia
by FreeSWITCH SVN 01 Jan '09
by FreeSWITCH SVN 01 Jan '09
01 Jan '09
Author: mikej
Date: Thu Jan 1 14:11:49 2009
New Revision: 11045
Log:
build fixes
Modified:
freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
Modified: freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c
==============================================================================
--- freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c (original)
+++ freeswitch/trunk/src/mod/applications/mod_dptools/mod_dptools.c Thu Jan 1 14:11:49 2009
@@ -2037,7 +2037,7 @@
switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags)
{
char *group;
- switch_call_cause_t cause;
+ switch_call_cause_t cause = SWITCH_CAUSE_NONE;
char *template = NULL, *dest = NULL;
switch_originate_flag_t myflags = SOF_NONE;
char *cid_name_override = NULL;
Modified: freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c (original)
+++ freeswitch/trunk/src/mod/endpoints/mod_sofia/sofia_glue.c Thu Jan 1 14:11:49 2009
@@ -71,7 +71,7 @@
"s=FreeSWITCH\n"
"c=IN %s %s\n"
"t=0 0\n"
- "m=image %d udptl t38\n",
+ "m=image %d udptl t38\n"
"a=T38MaxBitRate:%d\n"
"%s"
"%s"
1
0
Author: mikej
Date: Thu Jan 1 13:57:30 2009
New Revision: 11044
Log:
fix help
Modified:
freeswitch/trunk/libs/esl/fs_cli.c
Modified: freeswitch/trunk/libs/esl/fs_cli.c
==============================================================================
--- freeswitch/trunk/libs/esl/fs_cli.c (original)
+++ freeswitch/trunk/libs/esl/fs_cli.c Thu Jan 1 13:57:30 2009
@@ -243,24 +243,23 @@
static int process_command(esl_handle_t *handle, const char *cmd)
{
-
- if (!strcasecmp(cmd, "help")) {
- printf(
- "Command \tDescription\n"
- "-----------------------------------------------\n"
- "/help \tHelp\n"
- "/exit, /quit, /bye, ... \tExit the program.\n"
- "/event, /noevent, /nixevent\tEvent commands.\n"
- "/log, /nolog \tLog commands.\n"
- "/filter \tFilter commands.\n"
- "\n"
- );
-
- goto end;
- }
-
if ((*cmd == '/' && cmd++) || !strncasecmp(cmd, "...", 3)) {
+ if (!strcasecmp(cmd, "help")) {
+ printf(
+ "Command \tDescription\n"
+ "-----------------------------------------------\n"
+ "/help \tHelp\n"
+ "/exit, /quit, /bye, ... \tExit the program.\n"
+ "/event, /noevent, /nixevent\tEvent commands.\n"
+ "/log, /nolog \tLog commands.\n"
+ "/filter \tFilter commands.\n"
+ "\n"
+ );
+
+ goto end;
+ }
+
if (
!strcasecmp(cmd, "exit") ||
!strcasecmp(cmd, "quit") ||
@@ -737,10 +736,8 @@
}
-
- done:
-
#ifdef HAVE_EDITLINE
+ done:
history(myhistory, &ev, H_SAVE, hfile);
/* Clean up our memory */
1
0
[commit] r11043 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax
by FreeSWITCH SVN 01 Jan '09
by FreeSWITCH SVN 01 Jan '09
01 Jan '09
Author: gmaruzz
Date: Thu Jan 1 12:14:54 2009
New Revision: 11043
Log:
skypiax: looping on recv, will not compile on win, needs to be finished
Modified:
freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c
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 Thu Jan 1 12:14:54 2009
@@ -96,6 +96,7 @@
int rt;
fd_set fs;
struct timeval to;
+ int received = 0;
if (!running)
break;
@@ -108,13 +109,25 @@
to.tv_sec = 0;
rt = select(fdselect + 1, &fs, NULL, NULL, &to);
- //rt=0;
+ //rt=1;
if (rt > 0) {
#ifdef WIN32
len = recv(fd, (char *) srv_in, 320, 0); //seems that Skype only sends 320 bytes at time
#else /* WIN32 */
- len = recv(fd, (char *) srv_in, 320, 0); //seems that Skype only sends 320 bytes at time
+ 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 */
if ((SAMPLERATE_SKYPIAX - 8000) == 0) {
@@ -171,20 +184,20 @@
/****************************************************************/
if (len > 0) {
if (len == SAMPLES_PER_FRAME * sizeof(short)) {
- unsigned int howmany;
- howmany = len;
+ //unsigned int howmany;
+ //howmany = len;
- WARNINGA("SRV recv %d\n", SKYPIAX_P_LOG, len);
+ //WARNINGA("SRV recv %d\n", SKYPIAX_P_LOG, len);
#ifdef WIN32
switch_file_write(p->audiopipe[1], srv_in, &howmany);
#else /* WIN32 */
- howmany = write(p->audiopipe[1], srv_in, howmany);
+ len = write(p->audiopipe[1], srv_in, len);
#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);
+ //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);
} else if (len == SAMPLES_PER_FRAME * sizeof(short) / 2) {
#if 1
1
0
[commit] r11042 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax
by FreeSWITCH SVN 01 Jan '09
by FreeSWITCH SVN 01 Jan '09
01 Jan '09
Author: gmaruzz
Date: Thu Jan 1 08:15:13 2009
New Revision: 11042
Log:
skypiax: all remaining switch_log_printf are now converted to skypiax equivalent funcs
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 Thu Jan 1 08:15:13 2009
@@ -63,11 +63,12 @@
static switch_status_t skypiax_codec(private_t * tech_pvt, int sample_rate, int codec_ms)
{
+ skypiax_interface_t *p = NULL;
if (switch_core_codec_init
(&tech_pvt->read_codec, "L16", NULL, sample_rate, codec_ms, 1,
SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,
NULL) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
+ ERRORA( "Can't load codec?\n", SKYPIAX_P_LOG);
return SWITCH_STATUS_FALSE;
}
@@ -75,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) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n");
+ ERRORA( "Can't load codec?\n", SKYPIAX_P_LOG);
switch_core_codec_destroy(&tech_pvt->read_codec);
return SWITCH_STATUS_FALSE;
}
@@ -109,9 +110,9 @@
}
if (skypiax_codec(tech_pvt, SAMPLERATE_SKYPIAX, 20) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "skypiax_docec FAILED\n");
+ ERRORA( "skypiax_docec FAILED\n", SKYPIAX_P_LOG);
} else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "skypiax_codec SUCCESS\n");
+ DEBUGA_SKYPE( "skypiax_codec SUCCESS\n", SKYPIAX_P_LOG);
}
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
@@ -126,6 +127,7 @@
{
switch_channel_t *channel;
private_t *tech_pvt = NULL;
+ skypiax_interface_t *p = NULL;
tech_pvt = switch_core_session_get_private(session);
assert(tech_pvt != NULL);
@@ -143,7 +145,7 @@
globals.calls++;
switch_mutex_unlock(globals.mutex);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL INIT\n",
+ DEBUGA_SKYPE( "%s CHANNEL INIT\n", SKYPIAX_P_LOG,
switch_channel_get_name(channel));
return SWITCH_STATUS_SUCCESS;
}
@@ -152,7 +154,7 @@
{
switch_channel_t *channel = NULL;
private_t *tech_pvt = NULL;
- skypiax_interface_t *p;
+ skypiax_interface_t *p = NULL;
char msg_to_skype[256];
channel = switch_core_session_get_channel(session);
@@ -183,7 +185,7 @@
switch_core_codec_destroy(&tech_pvt->write_codec);
}
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL HANGUP\n",
+ DEBUGA_SKYPE( "%s CHANNEL HANGUP\n", SKYPIAX_P_LOG,
switch_channel_get_name(channel));
switch_mutex_lock(globals.mutex);
globals.calls--;
@@ -199,6 +201,7 @@
{
switch_channel_t *channel = NULL;
private_t *tech_pvt = NULL;
+ skypiax_interface_t *p = NULL;
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
@@ -206,7 +209,7 @@
tech_pvt = switch_core_session_get_private(session);
assert(tech_pvt != NULL);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL ROUTING\n",
+ DEBUGA_SKYPE( "%s CHANNEL ROUTING\n", SKYPIAX_P_LOG,
switch_channel_get_name(channel));
return SWITCH_STATUS_SUCCESS;
@@ -217,6 +220,7 @@
switch_channel_t *channel = NULL;
private_t *tech_pvt = NULL;
+ skypiax_interface_t *p = NULL;
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
@@ -224,7 +228,7 @@
tech_pvt = switch_core_session_get_private(session);
assert(tech_pvt != NULL);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL EXECUTE\n",
+ DEBUGA_SKYPE( "%s CHANNEL EXECUTE\n", SKYPIAX_P_LOG,
switch_channel_get_name(channel));
return SWITCH_STATUS_SUCCESS;
@@ -234,6 +238,7 @@
{
switch_channel_t *channel = NULL;
private_t *tech_pvt = NULL;
+ skypiax_interface_t *p = NULL;
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
@@ -243,16 +248,16 @@
switch (sig) {
case SWITCH_SIG_KILL:
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
- "%s CHANNEL got SWITCH_SIG_KILL\n",
+ 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:
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
- "%s CHANNEL got SWITCH_SIG_BREAK\n",
+ 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;
@@ -265,13 +270,15 @@
static switch_status_t channel_on_exchange_media(switch_core_session_t * session)
{
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL LOOPBACK\n");
+ skypiax_interface_t *p = NULL;
+ 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)
{
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL TRANSMIT\n");
+ skypiax_interface_t *p = NULL;
+ DEBUGA_SKYPE( "CHANNEL TRANSMIT\n", SKYPIAX_P_LOG);
return SWITCH_STATUS_SUCCESS;
}
@@ -291,6 +298,7 @@
switch_channel_t *channel = NULL;
private_t *tech_pvt = NULL;
switch_byte_t *data;
+ skypiax_interface_t *p = NULL;
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
@@ -302,35 +310,35 @@
if (skypiax_skypeaudio_read(tech_pvt) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
- "skypiax_skypeaudio_read ERROR\n");
+ ERRORA(
+ "skypiax_skypeaudio_read ERROR\n", SKYPIAX_P_LOG);
} else {
switch_set_flag_locked(tech_pvt, TFLAG_VOICE);
- //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "skypiax_skypeaudio_read SUCCESS\n");
+ //ERRORA( "skypiax_skypeaudio_read SUCCESS\n");
}
while (switch_test_flag(tech_pvt, TFLAG_IO)) {
if (switch_test_flag(tech_pvt, TFLAG_BREAK)) {
switch_clear_flag(tech_pvt, TFLAG_BREAK);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
- "CHANNEL READ FRAME goto CNG\n");
+ DEBUGA_SKYPE(
+ "CHANNEL READ FRAME goto CNG\n", SKYPIAX_P_LOG);
goto cng;
}
if (!switch_test_flag(tech_pvt, TFLAG_IO)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
- "CHANNEL READ FRAME not IO\n");
+ DEBUGA_SKYPE(
+ "CHANNEL READ FRAME not IO\n", SKYPIAX_P_LOG);
return SWITCH_STATUS_FALSE;
}
- //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "============>\n");
+ //DEBUGA_SKYPE( "============>\n");
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) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
- "CHANNEL READ CONTINUE\n");
+ DEBUGA_SKYPE(
+ "CHANNEL READ CONTINUE\n", SKYPIAX_P_LOG);
continue;
}
*frame = &tech_pvt->read_frame;
@@ -342,12 +350,12 @@
return SWITCH_STATUS_SUCCESS;
}
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL READ no TFLAG_IO\n");
+ DEBUGA_SKYPE( "CHANNEL READ no TFLAG_IO\n", SKYPIAX_P_LOG);
return SWITCH_STATUS_FALSE;
}
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL READ FALSE\n");
+ DEBUGA_SKYPE( "CHANNEL READ FALSE\n", SKYPIAX_P_LOG);
return SWITCH_STATUS_FALSE;
cng:
@@ -370,7 +378,7 @@
unsigned int sent;
struct skypiax_interface *p = NULL;
- //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL WRITE FRAME\n");
+ //DEBUGA_SKYPE( "CHANNEL WRITE FRAME\n");
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
@@ -465,13 +473,14 @@
{
struct private_object *tech_pvt = switch_core_session_get_private(session);
char *body = switch_event_get_body(event);
+ skypiax_interface_t *p = NULL;
switch_assert(tech_pvt != NULL);
if (!body) {
body = "";
}
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "event: |||%s|||\n", body);
+ WARNINGA( "event: |||%s|||\n", SKYPIAX_P_LOG, body);
return SWITCH_STATUS_SUCCESS;
}
@@ -507,6 +516,7 @@
private_t *tech_pvt;
switch_channel_t *channel;
switch_caller_profile_t *caller_profile;
+ skypiax_interface_t *p = NULL;
switch_core_session_add_stream(*new_session, NULL);
if ((tech_pvt =
@@ -516,8 +526,8 @@
channel = switch_core_session_get_channel(*new_session);
skypiax_tech_init(tech_pvt, *new_session, NULL);
} else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
- "Hey where is my memory pool?\n");
+ ERRORA(
+ "Hey where is my memory pool?\n", SKYPIAX_P_LOG);
switch_core_session_destroy(new_session);
return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
}
@@ -532,7 +542,7 @@
switch_channel_set_caller_profile(channel, caller_profile);
tech_pvt->caller_profile = caller_profile;
} else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Doh! no caller profile\n");
+ ERRORA( "Doh! no caller profile\n", SKYPIAX_P_LOG);
switch_core_session_destroy(new_session);
return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
}
@@ -632,44 +642,44 @@
char *val = (char *) switch_xml_attr_soft(param, "value");
if (!strcasecmp(var, "debug")) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "globals.debug=%d\n",
+ DEBUGA_SKYPE( "globals.debug=%d\n", SKYPIAX_P_LOG,
globals.debug);
globals.debug = atoi(val);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "globals.debug=%d\n",
+ DEBUGA_SKYPE( "globals.debug=%d\n", SKYPIAX_P_LOG,
globals.debug);
} else if (!strcasecmp(var, "hold-music")) {
switch_set_string(globals.hold_music, val);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "globals.hold_music=%s\n",
+ DEBUGA_SKYPE( "globals.hold_music=%s\n", SKYPIAX_P_LOG,
globals.hold_music);
} else if (!strcmp(var, "port")) {
globals.port = atoi(val);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "globals.port=%d\n",
+ DEBUGA_SKYPE( "globals.port=%d\n", SKYPIAX_P_LOG,
globals.port);
} else if (!strcmp(var, "ip")) {
set_global_ip(val);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "globals.ip=%s\n",
+ 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);
}
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
- "codec-master globals.debug=%d\n", globals.debug);
+ DEBUGA_SKYPE(
+ "codec-master globals.debug=%d\n", SKYPIAX_P_LOG, globals.debug);
} else if (!strcmp(var, "dialplan")) {
set_global_dialplan(val);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "globals.dialplan=%s\n",
+ DEBUGA_SKYPE( "globals.dialplan=%s\n", SKYPIAX_P_LOG,
globals.dialplan);
} else if (!strcmp(var, "codec-prefs")) {
set_global_codec_string(val);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
- "globals.codec_string=%s\n", 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);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
- "globals.codec_rates_string=%s\n", 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);
@@ -741,50 +751,50 @@
}
if (!skype_user) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
- "interface missing REQUIRED param 'skype_user'\n");
+ ERRORA(
+ "interface missing REQUIRED param 'skype_user'\n", SKYPIAX_P_LOG);
continue;
}
if (!skype_password) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
- "interface missing REQUIRED param 'skype_password'\n");
+ ERRORA(
+ "interface missing REQUIRED param 'skype_password'\n", SKYPIAX_P_LOG);
continue;
}
if (!X11_display) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
- "interface missing REQUIRED param 'X11_display'\n");
+ ERRORA(
+ "interface missing REQUIRED param 'X11_display'\n", SKYPIAX_P_LOG);
continue;
}
if (!tcp_cli_port) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
- "interface missing REQUIRED param 'tcp_cli_port'\n");
+ ERRORA(
+ "interface missing REQUIRED param 'tcp_cli_port'\n", SKYPIAX_P_LOG);
continue;
}
if (!tcp_srv_port) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
- "interface missing REQUIRED param 'tcp_srv_port'\n");
+ ERRORA(
+ "interface missing REQUIRED param 'tcp_srv_port'\n", SKYPIAX_P_LOG);
continue;
}
if (!id) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
- "interface missing REQUIRED param 'id'\n");
+ ERRORA(
+ "interface missing REQUIRED param 'id'\n", SKYPIAX_P_LOG);
continue;
}
if (switch_is_number(id)) {
interface_id = atoi(id);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "interface_id=%d\n",
+ DEBUGA_SKYPE( "interface_id=%d\n", SKYPIAX_P_LOG,
interface_id);
} else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
- "interface param 'id' MUST be a number, now id='%s'\n", id);
+ ERRORA(
+ "interface param 'id' MUST be a number, now id='%s'\n", SKYPIAX_P_LOG, id);
continue;
}
if (!name) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
- "interface missing param 'name', not nice, but works\n");
+ WARNINGA(
+ "interface missing param 'name', not nice, but works\n", SKYPIAX_P_LOG);
}
if (!tonegroup) {
@@ -800,7 +810,7 @@
}
if (name) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "name=%s\n", name);
+ DEBUGA_SKYPE( "name=%s\n", SKYPIAX_P_LOG, name);
}
#ifndef WIN32
if (!XInitThreads()) {
@@ -818,8 +828,8 @@
memset(&newconf, '\0', sizeof(newconf));
globals.SKYPIAX_INTERFACES[interface_id] = newconf;
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
- "CONFIGURING interface_id=%d\n", 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);
@@ -846,38 +856,38 @@
switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].context, context);
switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].dialplan, dialplan);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
- "interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].X11_display=%s\n",
+ 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);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
- "interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].skype_user=%s\n",
+ 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);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
- "interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].skype_password=%s\n",
+ 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);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
- "interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].tcp_cli_port=%d\n",
+ 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);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
- "interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].tcp_srv_port=%d\n",
+ 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);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
- "interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].name=%s\n",
+ DEBUGA_SKYPE(
+ "interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].name=%s\n", SKYPIAX_P_LOG,
interface_id, globals.SKYPIAX_INTERFACES[interface_id].name);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
- "interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].context=%s\n",
+ DEBUGA_SKYPE(
+ "interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].context=%s\n", SKYPIAX_P_LOG,
interface_id, globals.SKYPIAX_INTERFACES[interface_id].context);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
- "interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].dialplan=%s\n",
+ DEBUGA_SKYPE(
+ "interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].dialplan=%s\n", SKYPIAX_P_LOG,
interface_id,
globals.SKYPIAX_INTERFACES[interface_id].dialplan);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,
- "STARTING interface_id=%d\n", interface_id);
+ 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);
@@ -905,12 +915,12 @@
skypiax_skypeaudio_init(&globals.SKYPIAX_INTERFACES[interface_id]);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
- "STARTED interface_id=%d\n", interface_id);
+ NOTICA(
+ "STARTED interface_id=%d\n", SKYPIAX_P_LOG, interface_id);
} else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
- "interface id %d is higher than SKYPIAX_MAX_INTERFACES (%d)\n",
+ ERRORA(
+ "interface id %d is higher than SKYPIAX_MAX_INTERFACES (%d)\n", SKYPIAX_P_LOG,
interface_id, SKYPIAX_MAX_INTERFACES);
continue;
}
@@ -919,20 +929,20 @@
for (i = 0; i < SKYPIAX_MAX_INTERFACES; i++) {
if (strlen(globals.SKYPIAX_INTERFACES[i].name)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
- "i=%d globals.SKYPIAX_INTERFACES[%d].interface_id=%s\n", i, i,
+ DEBUGA_SKYPE(
+ "i=%d globals.SKYPIAX_INTERFACES[%d].interface_id=%s\n", SKYPIAX_P_LOG, i, i,
globals.SKYPIAX_INTERFACES[i].interface_id);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
- "i=%d globals.SKYPIAX_INTERFACES[%d].X11_display=%s\n", i, i,
+ DEBUGA_SKYPE(
+ "i=%d globals.SKYPIAX_INTERFACES[%d].X11_display=%s\n", SKYPIAX_P_LOG, i, i,
globals.SKYPIAX_INTERFACES[i].X11_display);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
- "i=%d globals.SKYPIAX_INTERFACES[%d].name=%s\n", i, i,
+ DEBUGA_SKYPE(
+ "i=%d globals.SKYPIAX_INTERFACES[%d].name=%s\n", SKYPIAX_P_LOG, i, i,
globals.SKYPIAX_INTERFACES[i].name);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
- "i=%d globals.SKYPIAX_INTERFACES[%d].context=%s\n", i, i,
+ DEBUGA_SKYPE(
+ "i=%d globals.SKYPIAX_INTERFACES[%d].context=%s\n", SKYPIAX_P_LOG, i, i,
globals.SKYPIAX_INTERFACES[i].context);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
- "i=%d globals.SKYPIAX_INTERFACES[%d].dialplan=%s\n", i, i,
+ 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 Thu Jan 1 08:15:13 2009
@@ -1024,12 +1024,12 @@
//disp = XOpenDisplay(getenv("DISPLAY"));
disp = XOpenDisplay(p->X11_display);
if (!disp) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
- "Cannot open X Display '%s', exiting skype thread\n",
+ ERRORA(
+ "Cannot open X Display '%s', exiting skype thread\n", SKYPIAX_P_LOG,
p->X11_display);
return NULL;
} else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "X Display '%s' opened\n",
+ DEBUGA_SKYPE( "X Display '%s' opened\n", SKYPIAX_P_LOG,
p->X11_display);
}
@@ -1401,7 +1401,7 @@
if (channel) {
switch_dtmf_t dtmf =
{ (char) value[0], switch_core_default_dtmf_duration(0) };
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%c DTMF %s\n",
+ 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);
@@ -1615,8 +1615,8 @@
private_t *tech_pvt = NULL;
switch_channel_t *channel = NULL;
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
- "New Inbound Channel!\n");
+ NOTICA(
+ "New Inbound Channel!\n", SKYPIAX_P_LOG);
if ((session =
switch_core_session_request(skypiax_endpoint_interface,
@@ -1629,8 +1629,8 @@
channel = switch_core_session_get_channel(session);
skypiax_tech_init(tech_pvt, session, p);
} else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
- "Hey where is my memory pool?\n");
+ ERRORA(
+ "Hey where is my memory pool?\n", SKYPIAX_P_LOG);
switch_core_session_destroy(&session);
break;
}
@@ -1654,8 +1654,8 @@
switch_channel_set_state(channel, CS_INIT);
if (switch_core_session_thread_launch(session) !=
SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
- "Error spawning thread\n");
+ ERRORA(
+ "Error spawning thread\n", SKYPIAX_P_LOG);
switch_core_session_destroy(&session);
}
}
1
0
[commit] r11041 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax
by FreeSWITCH SVN 01 Jan '09
by FreeSWITCH SVN 01 Jan '09
01 Jan '09
Author: gmaruzz
Date: Thu Jan 1 07:10:03 2009
New Revision: 11041
Log:
skypiax: let's switch_channel_mark_answered the channel when it's actually answered, and *NOT* after having been pre_answered. Also, indent all
Modified:
freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c
freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h
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 Thu Jan 1 07:10:03 2009
@@ -393,15 +393,15 @@
sent = frame->datalen;
//DEBUGA_SKYPE("CLI PIPE to write %d\n", SKYPIAX_P_LOG, sent);
-#ifdef WIN32
+#ifdef WIN32
switch_file_write(p->audioskypepipe[1], frame->data, &sent);
#else /* WIN32 */
sent = write(p->audioskypepipe[1], frame->data, sent);
#endif /* WIN32 */
- if(sent != frame->datalen){
- ERRORA("CLI PIPE write %d\n", SKYPIAX_P_LOG, sent);
- }else{
- //NOTICA("CLI PIPE write %d\n", SKYPIAX_P_LOG, sent);
+ if (sent != frame->datalen && sent != -1) {
+ DEBUGA_SKYPE("CLI PIPE write %d\n", SKYPIAX_P_LOG, sent);
+ } else {
+ //NOTICA("CLI PIPE write %d\n", SKYPIAX_P_LOG, sent);
}
return SWITCH_STATUS_SUCCESS;
@@ -511,8 +511,8 @@
switch_core_session_add_stream(*new_session, NULL);
if ((tech_pvt =
(private_t *) switch_core_session_alloc(*new_session, sizeof(private_t))) != 0) {
- tech_pvt->p = &globals.SKYPIAX_INTERFACES[19]; //FIXME
- globals.SKYPIAX_INTERFACES[19].tech_pvt = tech_pvt; //FIXME
+ 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 {
@@ -542,7 +542,7 @@
switch_channel_set_flag(channel, CF_OUTBOUND);
switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND);
switch_channel_set_state(channel, CS_INIT);
- switch_channel_mark_pre_answered(channel);
+ //switch_channel_mark_pre_answered(channel);
return SWITCH_CAUSE_SUCCESS;
}
@@ -590,20 +590,20 @@
if (channel) {
switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
//DEBUGA_SKYPE("after channel_on_hangup\n", SKYPIAX_P_LOG);
-
- } else {
- ERRORA("no channel?\n", SKYPIAX_P_LOG);
- }
+
+ } else {
+ ERRORA("no channel?\n", SKYPIAX_P_LOG);
+ }
+
+ } else {
+ ERRORA("no session?\n", SKYPIAX_P_LOG);
+ }
} else {
- ERRORA("no session?\n", SKYPIAX_P_LOG);
- }
-
- } else {
- ERRORA("no tech_pvt?\n", SKYPIAX_P_LOG);
+ ERRORA("no tech_pvt?\n", SKYPIAX_P_LOG);
}
- p->interface_state = SKYPIAX_STATE_DOWN;
- global_session = NULL; //FIXME
+ p->interface_state = SKYPIAX_STATE_DOWN;
+ global_session = NULL; //FIXME
}
}
@@ -802,14 +802,13 @@
if (name) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "name=%s\n", name);
}
-
#ifndef WIN32
- if (!XInitThreads()) {
- ERRORA("Not initialized XInitThreads!\n", SKYPIAX_P_LOG);
- } else {
- DEBUGA_SKYPE("Initialized XInitThreads!\n", SKYPIAX_P_LOG);
- }
- switch_sleep(100);
+ if (!XInitThreads()) {
+ ERRORA("Not initialized XInitThreads!\n", SKYPIAX_P_LOG);
+ } else {
+ DEBUGA_SKYPE("Initialized XInitThreads!\n", SKYPIAX_P_LOG);
+ }
+ switch_sleep(100);
#endif /* WIN32 */
if (interface_id && interface_id < SKYPIAX_MAX_INTERFACES) {
@@ -828,36 +827,45 @@
switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].name, "N/A");
}
#ifdef WIN32
- globals.SKYPIAX_INTERFACES[interface_id].tcp_cli_port = (unsigned short)atoi(tcp_cli_port);
- globals.SKYPIAX_INTERFACES[interface_id].tcp_srv_port = (unsigned short)atoi(tcp_srv_port);
+ globals.SKYPIAX_INTERFACES[interface_id].tcp_cli_port =
+ (unsigned short) atoi(tcp_cli_port);
+ globals.SKYPIAX_INTERFACES[interface_id].tcp_srv_port =
+ (unsigned short) atoi(tcp_srv_port);
#else /* WIN32 */
- globals.SKYPIAX_INTERFACES[interface_id].tcp_cli_port = atoi(tcp_cli_port);
- globals.SKYPIAX_INTERFACES[interface_id].tcp_srv_port = atoi(tcp_srv_port);
+ globals.SKYPIAX_INTERFACES[interface_id].tcp_cli_port = atoi(tcp_cli_port);
+ globals.SKYPIAX_INTERFACES[interface_id].tcp_srv_port = atoi(tcp_srv_port);
#endif /* WIN32 */
//switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].tcp_cli_port, tcp_cli_port);
//switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].tcp_srv_port, tcp_srv_port);
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].X11_display, X11_display);
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].skype_user, skype_user);
- switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].skype_password, skype_password);
+ switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].X11_display,
+ X11_display);
+ switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].skype_user,
+ skype_user);
+ switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].skype_password,
+ skype_password);
switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].context, context);
switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].dialplan, dialplan);
-
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
"interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].X11_display=%s\n",
- interface_id, globals.SKYPIAX_INTERFACES[interface_id].X11_display);
+ interface_id,
+ globals.SKYPIAX_INTERFACES[interface_id].X11_display);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
"interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].skype_user=%s\n",
- interface_id, globals.SKYPIAX_INTERFACES[interface_id].skype_user);
+ interface_id,
+ globals.SKYPIAX_INTERFACES[interface_id].skype_user);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
"interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].skype_password=%s\n",
- interface_id, globals.SKYPIAX_INTERFACES[interface_id].skype_password);
+ interface_id,
+ globals.SKYPIAX_INTERFACES[interface_id].skype_password);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
"interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].tcp_cli_port=%d\n",
- interface_id, globals.SKYPIAX_INTERFACES[interface_id].tcp_cli_port);
+ interface_id,
+ globals.SKYPIAX_INTERFACES[interface_id].tcp_cli_port);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
"interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].tcp_srv_port=%d\n",
- interface_id, globals.SKYPIAX_INTERFACES[interface_id].tcp_srv_port);
+ interface_id,
+ globals.SKYPIAX_INTERFACES[interface_id].tcp_srv_port);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
"interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].name=%s\n",
interface_id, globals.SKYPIAX_INTERFACES[interface_id].name);
@@ -866,15 +874,18 @@
interface_id, globals.SKYPIAX_INTERFACES[interface_id].context);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
"interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].dialplan=%s\n",
- interface_id, globals.SKYPIAX_INTERFACES[interface_id].dialplan);
+ interface_id,
+ globals.SKYPIAX_INTERFACES[interface_id].dialplan);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,
"STARTING interface_id=%d\n", interface_id);
switch_threadattr_create(&do_skype_thd_attr, skypiax_module_pool);
//switch_threadattr_detach_set(do_skype_thd_attr, 1);
switch_threadattr_stacksize_set(do_skype_thd_attr, SWITCH_THREAD_STACKSIZE);
- switch_thread_create(&globals.SKYPIAX_INTERFACES[interface_id].skypiax_do_skype_thread_thread, do_skype_thd_attr, do_skype_thread,
- &globals.SKYPIAX_INTERFACES[interface_id], skypiax_module_pool);
+ switch_thread_create(&globals.SKYPIAX_INTERFACES[interface_id].
+ skypiax_do_skype_thread_thread, do_skype_thd_attr,
+ do_skype_thread, &globals.SKYPIAX_INTERFACES[interface_id],
+ skypiax_module_pool);
switch_sleep(100000);
@@ -883,10 +894,12 @@
//switch_threadattr_detach_set(skypiax_do_controldev_thread_thd_attr, 1);
switch_threadattr_stacksize_set(skypiax_do_controldev_thread_thd_attr,
SWITCH_THREAD_STACKSIZE);
- switch_thread_create(&globals.SKYPIAX_INTERFACES[interface_id].skypiax_do_controldev_thread_thread,
+ switch_thread_create(&globals.SKYPIAX_INTERFACES[interface_id].
+ skypiax_do_controldev_thread_thread,
skypiax_do_controldev_thread_thd_attr,
skypiax_do_controldev_thread,
- &globals.SKYPIAX_INTERFACES[interface_id], skypiax_module_pool);
+ &globals.SKYPIAX_INTERFACES[interface_id],
+ skypiax_module_pool);
switch_sleep(1000000);
@@ -932,7 +945,7 @@
SWITCH_MODULE_LOAD_FUNCTION(mod_skypiax_load)
{
- struct skypiax_interface *p = NULL; //for logging
+ struct skypiax_interface *p = NULL; //for logging
skypiax_module_pool = pool;
@@ -966,58 +979,61 @@
struct skypiax_interface *p = NULL;
switch_status_t status;
unsigned int howmany = 8;
-int interface_id;
+ int interface_id;
//p = &globals.SKYPIAX_INTERFACES[2];
running = 0;
-for(interface_id=0; interface_id < SKYPIAX_MAX_INTERFACES; interface_id++){
- p = &globals.SKYPIAX_INTERFACES[interface_id];
+ for (interface_id = 0; interface_id < SKYPIAX_MAX_INTERFACES; interface_id++) {
+ p = &globals.SKYPIAX_INTERFACES[interface_id];
-if(globals.SKYPIAX_INTERFACES[interface_id].skypiax_do_controldev_thread_thread){
+ if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_do_controldev_thread_thread) {
#ifdef WIN32
- switch_file_write(p->AsteriskHandlesAst.fdesc[1], "sciutati", &howmany); // let's the controldev_thread die
+ switch_file_write(p->AsteriskHandlesAst.fdesc[1], "sciutati", &howmany); // let's the controldev_thread die
#else /* WIN32 */
- write(p->AsteriskHandlesAst.fdesc[1], "sciutati", howmany);
+ write(p->AsteriskHandlesAst.fdesc[1], "sciutati", howmany);
#endif /* WIN32 */
- }
+ }
-if(globals.SKYPIAX_INTERFACES[interface_id].skypiax_do_skype_thread_thread){
+ if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_do_skype_thread_thread) {
#ifdef WIN32
- if (SendMessage(p->AsteriskHandlesAst.win32_hInit_MainWindowHandle, WM_DESTROY, 0, 0) == FALSE) { // let's the do_skype_thread die
- ERRORA("WHY FALSE HERE? %d\n", SKYPIAX_P_LOG, GetLastError());
- }
+ if (SendMessage(p->AsteriskHandlesAst.win32_hInit_MainWindowHandle, WM_DESTROY, 0, 0) == FALSE) { // let's the do_skype_thread die
+ ERRORA("WHY FALSE HERE? %d\n", SKYPIAX_P_LOG, GetLastError());
+ }
#else
- XEvent e;
- Atom atom1 =
- XInternAtom(p->AsteriskHandlesAst.disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", False);
- memset(&e, 0, sizeof(e));
- e.xclient.type = ClientMessage;
- e.xclient.message_type = atom1; /* leading message */
- e.xclient.display = p->AsteriskHandlesAst.disp;
- e.xclient.window = p->AsteriskHandlesAst.skype_win;
- e.xclient.format = 8;
+ XEvent e;
+ Atom atom1 =
+ XInternAtom(p->AsteriskHandlesAst.disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", False);
+ memset(&e, 0, sizeof(e));
+ e.xclient.type = ClientMessage;
+ e.xclient.message_type = atom1; /* leading message */
+ e.xclient.display = p->AsteriskHandlesAst.disp;
+ e.xclient.window = p->AsteriskHandlesAst.skype_win;
+ e.xclient.format = 8;
- XSendEvent(p->AsteriskHandlesAst.disp, p->AsteriskHandlesAst.win, False, 0, &e);
- XSync(p->AsteriskHandlesAst.disp, False);
+ XSendEvent(p->AsteriskHandlesAst.disp, p->AsteriskHandlesAst.win, False, 0, &e);
+ XSync(p->AsteriskHandlesAst.disp, False);
#endif
- }
- while (x) {
- x--;
- switch_yield(20000);
- }
-if(globals.SKYPIAX_INTERFACES[interface_id].skypiax_do_controldev_thread_thread){
- switch_thread_join(&status, globals.SKYPIAX_INTERFACES[interface_id].skypiax_do_controldev_thread_thread);
- }
-if(globals.SKYPIAX_INTERFACES[interface_id].skypiax_do_skype_thread_thread){
- switch_thread_join(&status, globals.SKYPIAX_INTERFACES[interface_id].skypiax_do_skype_thread_thread);
- }
+ }
+ while (x) {
+ x--;
+ switch_yield(20000);
+ }
+ if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_do_controldev_thread_thread) {
+ switch_thread_join(&status,
+ globals.SKYPIAX_INTERFACES[interface_id].
+ skypiax_do_controldev_thread_thread);
+ }
+ if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_do_skype_thread_thread) {
+ switch_thread_join(&status,
+ globals.SKYPIAX_INTERFACES[interface_id].
+ skypiax_do_skype_thread_thread);
+ }
}
return SWITCH_STATUS_SUCCESS;
}
-
/* For Emacs:
* Local Variables:
* mode:c
Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h
==============================================================================
--- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h (original)
+++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h Thu Jan 1 07:10:03 2009
@@ -136,7 +136,7 @@
Window skype_win;
Display *disp;
Window win;
-int api_connected;
+ int api_connected;
int fdesc[2];
};
#else //WIN32
@@ -144,11 +144,11 @@
struct AsteriskHandles {
HWND win32_hInit_MainWindowHandle;
HWND win32_hGlobal_SkypeAPIWindowHandle;
-HINSTANCE win32_hInit_ProcessHandle;
-char win32_acInit_WindowClassName[128];
-UINT win32_uiGlobal_MsgID_SkypeControlAPIAttach;
-UINT win32_uiGlobal_MsgID_SkypeControlAPIDiscover;
-int api_connected;
+ HINSTANCE win32_hInit_ProcessHandle;
+ char win32_acInit_WindowClassName[128];
+ UINT win32_uiGlobal_MsgID_SkypeControlAPIAttach;
+ UINT win32_uiGlobal_MsgID_SkypeControlAPIDiscover;
+ int api_connected;
switch_file_t *fdesc[2];
};
@@ -195,10 +195,10 @@
#ifdef WIN32
switch_file_t *audiopipe[2];
switch_file_t *audioskypepipe[2];
-#else /* WIN32 */
+#else /* WIN32 */
int audiopipe[2];
int audioskypepipe[2];
-#endif /* WIN32 */
+#endif /* WIN32 */
switch_thread_t *tcp_srv_thread;
switch_thread_t *tcp_cli_thread;
switch_thread_t *skypiax_do_controldev_thread_thread;
@@ -247,4 +247,5 @@
int skypiax_skype_write(struct skypiax_interface *p, char *msg_to_skype);
int skypiax_skype_read(struct skypiax_interface *p);
-int skypiax_skype_call(struct skypiax_interface *p, char *idest, int timeout, switch_core_session_t * session);
+int skypiax_skype_call(struct skypiax_interface *p, char *idest, int timeout,
+ switch_core_session_t * session);
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 Thu Jan 1 07:10:03 2009
@@ -6,23 +6,17 @@
extern switch_endpoint_interface_t *skypiax_endpoint_interface;
extern int running;
-
-
/**********************************************************/
/**********************************************************/
/**********************************************************/
-
extern switch_core_session_t *global_session;
-
#ifdef WIN32
#else /* NOT WIN32 */
#define SKYPE_X11_BUF_SIZE 512
#endif /* WIN32 */
-
-
/**********************************************************/
/**********************************************************/
/**********************************************************/
@@ -57,27 +51,26 @@
short totalbuf[SAMPLES_PER_FRAME];
//int one = 1;
- if (option_debug > 10) {
- WARNINGA("ENTERING FUNC\n", SKYPIAX_P_LOG);
+ if (option_debug > 100) {
+ DEBUGA_SKYPE("ENTERING FUNC\n", SKYPIAX_P_LOG);
}
memset(&my_addr, 0, sizeof(my_addr));
my_addr.sin_family = AF_INET;
my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */
- my_addr.sin_port = htons(p->tcp_srv_port);
+ my_addr.sin_port = htons(p->tcp_srv_port);
if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
ERRORA("socket Error\n", SKYPIAX_P_LOG);
- if (option_debug > 10) {
+ if (option_debug > 100) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
return NULL;
}
-
//setsockopt(s, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one));
if (bind(s, (struct sockaddr *) &my_addr, sizeof(struct sockaddr)) < 0) {
ERRORA("bind Error\n", SKYPIAX_P_LOG);
- if (option_debug > 10) {
+ if (option_debug > 100) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
return NULL;
@@ -111,152 +104,147 @@
fdselect = fd;
FD_ZERO(&fs);
FD_SET(fdselect, &fs);
- to.tv_usec = 2000000; //20 msec
+ to.tv_usec = 2000000; //20 msec
to.tv_sec = 0;
rt = select(fdselect + 1, &fs, NULL, NULL, &to);
- //rt=0;
+ //rt=0;
if (rt > 0) {
#ifdef WIN32
- len = recv(fd, (char *)srv_in, 320, 0); //seems that Skype only sends 320 bytes at time
+ len = recv(fd, (char *) srv_in, 320, 0); //seems that Skype only sends 320 bytes at time
#else /* WIN32 */
- len = recv(fd, (char *)srv_in, 320, 0); //seems that Skype only sends 320 bytes at time
+ len = recv(fd, (char *) srv_in, 320, 0); //seems that Skype only sends 320 bytes at time
#endif /* WIN32 */
- if ((SAMPLERATE_SKYPIAX - 8000) == 0) {
+ if ((SAMPLERATE_SKYPIAX - 8000) == 0) {
- /****************************************************************/
- if (len > 0) {
- a = 0;
- for (i = 0; i < len / sizeof(short); i++) {
- srv_out[a] = srv_in[i];
- i++;
- a++;
- }
-
- if (!p->audiobuf_is_loaded) {
- for (i = 0; i < (len / sizeof(short)) / 2; i++) {
- p->audiobuf[i] = srv_out[i];
- }
- p->audiobuf_is_loaded = 1;
- } else {
- unsigned int howmany;
-
- howmany = len / 2 / 2;
- for (i = 0; i < howmany; i++)
- totalbuf[i] = p->audiobuf[i];
-
- howmany = len / 2 / 2;
- for (a = 0; a < howmany; a++) {
- totalbuf[i] = srv_out[a];
- i++;
- }
+ /****************************************************************/
+ if (len > 0) {
+ a = 0;
+ for (i = 0; i < len / sizeof(short); i++) {
+ srv_out[a] = srv_in[i];
+ i++;
+ a++;
+ }
- howmany = len;
+ if (!p->audiobuf_is_loaded) {
+ for (i = 0; i < (len / sizeof(short)) / 2; i++) {
+ p->audiobuf[i] = srv_out[i];
+ }
+ p->audiobuf_is_loaded = 1;
+ } else {
+ unsigned int howmany;
-#ifdef WIN32
- switch_file_write(p->audiopipe[1], totalbuf, &howmany);
-#else /* WIN32 */
- howmany = write(p->audiopipe[1], totalbuf, howmany);
-#endif /* WIN32 */
- p->audiobuf_is_loaded = 0;
- //DEBUGA_SKYPE("read=====> req=%d recv=%d to sent=%d sent=%d\n", SKYPIAX_P_LOG, sizeof(short)*SAMPLES_PER_FRAME, len, (len*sizeof(short))/2, howmany);
- }
-
- } else if (len == 0) {
- DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG);
- switch_sleep(1000);
- } else {
- ERRORA("len=%d\n", SKYPIAX_P_LOG, len);
- exit = 1;
- break;
- }
- /****************************************************************/
- } else if (SAMPLERATE_SKYPIAX == 16000) {
-
-
- /****************************************************************/
- if (len > 0) {
- if (len == SAMPLES_PER_FRAME * sizeof(short)) {
- unsigned int howmany;
- howmany = len;
+ howmany = len / 2 / 2;
+ for (i = 0; i < howmany; i++)
+ totalbuf[i] = p->audiobuf[i];
+
+ howmany = len / 2 / 2;
+ for (a = 0; a < howmany; a++) {
+ totalbuf[i] = srv_out[a];
+ i++;
+ }
- WARNINGA("SRV recv %d\n", SKYPIAX_P_LOG, len);
+ howmany = len;
-#ifdef WIN32
- switch_file_write(p->audiopipe[1], srv_in, &howmany);
+#ifdef WIN32
+ switch_file_write(p->audiopipe[1], totalbuf, &howmany);
#else /* WIN32 */
- howmany = write(p->audiopipe[1], srv_in, howmany);
+ howmany = write(p->audiopipe[1], totalbuf, howmany);
#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);
- }else if (len == SAMPLES_PER_FRAME * sizeof(short) / 2) {
+ p->audiobuf_is_loaded = 0;
+ //DEBUGA_SKYPE("read=====> req=%d recv=%d to sent=%d sent=%d\n", SKYPIAX_P_LOG, sizeof(short)*SAMPLES_PER_FRAME, len, (len*sizeof(short))/2, howmany);
+ }
-#if 1
+ } else if (len == 0) {
+ DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG);
+ switch_sleep(1000);
+ } else {
+ ERRORA("len=%d\n", SKYPIAX_P_LOG, len);
+ exit = 1;
+ break;
+ }
+ /****************************************************************/
+ } else if (SAMPLERATE_SKYPIAX == 16000) {
+ /****************************************************************/
+ if (len > 0) {
+ if (len == SAMPLES_PER_FRAME * sizeof(short)) {
+ unsigned int howmany;
+ howmany = len;
- if (!p->audiobuf_is_loaded) {
- for (i = 0; i < (len / sizeof(short)); i++) {
- p->audiobuf[i] = srv_in[i];
- }
- p->audiobuf_is_loaded = 1;
- } else {
- unsigned int howmany = SAMPLES_PER_FRAME * sizeof(short);
- //short totalbuf[SAMPLES_PER_FRAME];
-
- for (i = 0; i < (len / sizeof(short)); i++)
- totalbuf[i] = p->audiobuf[i];
- for (a = 0; a < (len / sizeof(short)); a++) {
- totalbuf[i] = srv_in[a];
- i++;
- }
+ WARNINGA("SRV recv %d\n", SKYPIAX_P_LOG, len);
-#ifdef WIN32
- switch_file_write(p->audiopipe[1], totalbuf, &howmany);
+#ifdef WIN32
+ switch_file_write(p->audiopipe[1], srv_in, &howmany);
#else /* WIN32 */
- howmany = write(p->audiopipe[1], totalbuf, howmany);
+ howmany = write(p->audiopipe[1], srv_in, howmany);
#endif /* WIN32 */
- p->audiobuf_is_loaded = 0;
- //NOTICA("SRV PIPE WRITE=====> req=%d recv=%d to sent=%d sent=%d\n", SKYPIAX_P_LOG, SAMPLES_PER_FRAME * sizeof(short), len, SAMPLES_PER_FRAME * sizeof(short), howmany);
- }
-#endif
-
+ 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);
+ } else if (len == SAMPLES_PER_FRAME * sizeof(short) / 2) {
+#if 1
+ if (!p->audiobuf_is_loaded) {
+ for (i = 0; i < (len / sizeof(short)); i++) {
+ p->audiobuf[i] = srv_in[i];
+ }
+ p->audiobuf_is_loaded = 1;
+ } else {
+ unsigned int howmany = SAMPLES_PER_FRAME * sizeof(short);
+ //short totalbuf[SAMPLES_PER_FRAME];
- } else {
+ for (i = 0; i < (len / sizeof(short)); i++)
+ totalbuf[i] = p->audiobuf[i];
+ for (a = 0; a < (len / sizeof(short)); a++) {
+ totalbuf[i] = srv_in[a];
+ i++;
+ }
- ERRORA("SRV len=%d\n", SKYPIAX_P_LOG, len);
+#ifdef WIN32
+ switch_file_write(p->audiopipe[1], totalbuf, &howmany);
+#else /* WIN32 */
+ howmany = write(p->audiopipe[1], totalbuf, howmany);
+#endif /* WIN32 */
+ p->audiobuf_is_loaded = 0;
+ //NOTICA("SRV PIPE WRITE=====> req=%d recv=%d to sent=%d sent=%d\n", SKYPIAX_P_LOG, SAMPLES_PER_FRAME * sizeof(short), len, SAMPLES_PER_FRAME * sizeof(short), howmany);
+ }
+#endif
- }
+ } else {
- } else if (len == 0) {
- DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG);
- switch_sleep(1000);
- //break;
- } else {
- ERRORA("SRV len=%d\n", SKYPIAX_P_LOG, len);
- exit = 1;
- break;
- }
- /****************************************************************/
+ ERRORA("SRV len=%d\n", SKYPIAX_P_LOG, len);
+ }
+ } else if (len == 0) {
+ DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG);
+ switch_sleep(1000);
+ //break;
+ } else {
+ ERRORA("SRV len=%d\n", SKYPIAX_P_LOG, len);
+ exit = 1;
+ break;
+ }
+ /****************************************************************/
- } else {
+ } else {
- ERRORA("SAMPLERATE_SKYPIAX can only be 8000 or 16000\n", SKYPIAX_P_LOG);
- }
+ ERRORA("SAMPLERATE_SKYPIAX can only be 8000 or 16000\n", SKYPIAX_P_LOG);
+ }
} else {
- if(rt)
- ERRORA("SRV rt=%d\n", SKYPIAX_P_LOG, rt);
- switch_sleep(10000);
- }
+ if (rt)
+ ERRORA("SRV rt=%d\n", SKYPIAX_P_LOG, rt);
+ switch_sleep(10000);
+ }
}
-#ifdef WIN32
+#ifdef WIN32
kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
switch_file_write(p->audiopipe[1], kill_cli_buff, &kill_cli_size);
kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
@@ -295,7 +283,7 @@
#else
closesocket(s);
#endif
- if (option_debug > 10) {
+ if (option_debug > 100) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
return NULL;
@@ -328,27 +316,26 @@
#endif /* WIN32 */
//int one = 1;
- if (option_debug > 10) {
- WARNINGA("ENTERING FUNC\n", SKYPIAX_P_LOG);
+ if (option_debug > 100) {
+ DEBUGA_SKYPE("ENTERING FUNC\n", SKYPIAX_P_LOG);
}
memset(&my_addr, 0, sizeof(my_addr));
my_addr.sin_family = AF_INET;
my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */
- my_addr.sin_port = htons(p->tcp_cli_port); //FIXME configurable!
+ my_addr.sin_port = htons(p->tcp_cli_port); //FIXME configurable!
if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
ERRORA("socket Error\n", SKYPIAX_P_LOG);
- if (option_debug > 10) {
+ if (option_debug > 100) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
return NULL;
}
-
//setsockopt(s, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one));
if (bind(s, (struct sockaddr *) &my_addr, sizeof(struct sockaddr)) < 0) {
ERRORA("bind Error\n", SKYPIAX_P_LOG);
- if (option_debug > 10) {
+ if (option_debug > 100) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
#ifndef WIN32
@@ -382,99 +369,99 @@
if (!running)
break;
#ifdef WIN32
- fdselect = fd; //cannot select on audioskypepipe, let's select on socket write
+ fdselect = fd; //cannot select on audioskypepipe, let's select on socket write
#else /* WIN32 */
fdselect = p->audioskypepipe[0];
#endif /* WIN32 */
FD_ZERO(&fs);
FD_SET(fdselect, &fs);
- to.tv_usec = 2000000; //20 msec
+ to.tv_usec = 2000000; //20 msec
to.tv_sec = 0;
#ifdef WIN32
- rt = select(fdselect + 1, NULL, &fs, NULL, &to);//cannot select on audioskypepipe, let's select on socket write
+ rt = select(fdselect + 1, NULL, &fs, NULL, &to); //cannot select on audioskypepipe, let's select on socket write
#else /* WIN32 */
rt = select(fdselect + 1, &fs, NULL, NULL, &to);
#endif /* WIN32 */
- //switch_sleep(1000);//FIXME
- //memset(cli_in, '\0', sizeof(cli_in));
+ //switch_sleep(1000);//FIXME
+ //memset(cli_in, '\0', sizeof(cli_in));
//rt = 0;
- if (rt > 0) {
- /*********************************************/
- if ((SAMPLERATE_SKYPIAX - 8000) == 0) {
- got = SAMPLES_PER_FRAME * sizeof(short);
-#ifdef WIN32
- switch_file_read(p->audioskypepipe[0], cli_in, &got);
+ if (rt > 0) {
+ /*********************************************/
+ if ((SAMPLERATE_SKYPIAX - 8000) == 0) {
+ got = SAMPLES_PER_FRAME * sizeof(short);
+#ifdef WIN32
+ switch_file_read(p->audioskypepipe[0], cli_in, &got);
#else /* WIN32 */
- got = read(p->audioskypepipe[0], cli_in, got);
+ got = read(p->audioskypepipe[0], cli_in, got);
#endif /* WIN32 */
- if (got > 0) {
- //DEBUGA_SKYPE("CLI PIPE read %d\n", SKYPIAX_P_LOG, got);
- a = 0;
- for (i = 0; i < got / sizeof(short); i++) {
- cli_out[a] = cli_in[i];
- a++;
- cli_out[a] = cli_in[i];
- a++;
- }
+ if (got > 0) {
+ //DEBUGA_SKYPE("CLI PIPE read %d\n", SKYPIAX_P_LOG, got);
+ a = 0;
+ for (i = 0; i < got / sizeof(short); i++) {
+ cli_out[a] = cli_in[i];
+ a++;
+ cli_out[a] = cli_in[i];
+ a++;
+ }
#ifdef WIN32
- len = send(fd, (char *)cli_out, got * 2, 0);
+ len = send(fd, (char *) cli_out, got * 2, 0);
#else /* WIN32 */
- len = send(fd, cli_out, got * 2, 0);
+ len = send(fd, cli_out, got * 2, 0);
#endif /* WIN32 */
- //DEBUGA_SKYPE("CLI PIPE send %d\n", SKYPIAX_P_LOG, len);
+ //DEBUGA_SKYPE("CLI PIPE send %d\n", SKYPIAX_P_LOG, len);
- if (len == 0) {
- ERRORA("Skype server GONE\n", SKYPIAX_P_LOG);
- break;
- }
- } else {
- switch_sleep(1000);
- ERRORA("CLI PIPE give us: %u\n", SKYPIAX_P_LOG, got);
- //break;
- }
- }
- /*********************************************/
- /*********************************************/
- else if (SAMPLERATE_SKYPIAX == 16000) {
- got = SAMPLES_PER_FRAME * sizeof(short);
-#ifdef WIN32
- switch_file_read(p->audioskypepipe[0], cli_in, &got);
+ if (len == 0) {
+ ERRORA("Skype server GONE\n", SKYPIAX_P_LOG);
+ break;
+ }
+ } else {
+ switch_sleep(1000);
+ ERRORA("CLI PIPE give us: %u\n", SKYPIAX_P_LOG, got);
+ //break;
+ }
+ }
+ /*********************************************/
+ /*********************************************/
+ else if (SAMPLERATE_SKYPIAX == 16000) {
+ got = SAMPLES_PER_FRAME * sizeof(short);
+#ifdef WIN32
+ switch_file_read(p->audioskypepipe[0], cli_in, &got);
#else /* WIN32 */
- got = read(p->audioskypepipe[0], cli_in, got);
+ got = read(p->audioskypepipe[0], cli_in, got);
#endif /* WIN32 */
- if (got > 0) {
- if(got != SAMPLES_PER_FRAME * sizeof(short) )
- ERRORA("CLI PIPE read %d\n", SKYPIAX_P_LOG, got);
+ if (got > 0) {
+ if (got != SAMPLES_PER_FRAME * sizeof(short))
+ ERRORA("CLI PIPE read %d\n", SKYPIAX_P_LOG, got);
#ifdef WIN32
- len = send(fd, (char *)cli_in, got, 0);
+ len = send(fd, (char *) cli_in, got, 0);
#else /* WIN32 */
- len = send(fd, cli_in, got, 0);
+ len = send(fd, cli_in, got, 0);
#endif /* WIN32 */
- if(len != got )
- ERRORA("CLI PIPE send %d\n", SKYPIAX_P_LOG, len);
+ if (len != got && len != -1)
+ DEBUGA_SKYPE("CLI PIPE send %d\n", SKYPIAX_P_LOG, len);
- if (len == 0) {
- ERRORA("Skype server GONE\n", SKYPIAX_P_LOG);
- break;
- }
- } else {
- switch_sleep(1000);
- ERRORA("CLI PIPE give us: %u\n", SKYPIAX_P_LOG, got);
- }
- }
- /*********************************************/
-
- } else {
- switch_sleep(1000);
- if(rt)
- ERRORA("select give us: %u\n", SKYPIAX_P_LOG, rt);
- }
+ if (len == 0) {
+ ERRORA("Skype server GONE\n", SKYPIAX_P_LOG);
+ break;
+ }
+ } else {
+ switch_sleep(1000);
+ ERRORA("CLI PIPE give us: %u\n", SKYPIAX_P_LOG, got);
+ }
+ }
+ /*********************************************/
+
+ } else {
+ switch_sleep(1000);
+ if (rt)
+ ERRORA("select give us: %u\n", SKYPIAX_P_LOG, rt);
+ }
}
DEBUGA_SKYPE("Skype server GONE\n", SKYPIAX_P_LOG);
@@ -492,7 +479,7 @@
#else
closesocket(s);
#endif
- if (option_debug > 10) {
+ if (option_debug > 100) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
return NULL;
@@ -501,13 +488,12 @@
int skypiax_skypeaudio_init(struct skypiax_interface *p)
{
-
#ifdef WIN32
switch_status_t rv;
+ rv = switch_file_pipe_create(&p->audiopipe[0], &p->audiopipe[1], skypiax_module_pool);
rv =
- switch_file_pipe_create(&p->audiopipe[0], &p->audiopipe[1], skypiax_module_pool);
- rv =
- switch_file_pipe_create(&p->audioskypepipe[0], &p->audioskypepipe[1], skypiax_module_pool);
+ switch_file_pipe_create(&p->audioskypepipe[0], &p->audioskypepipe[1],
+ skypiax_module_pool);
#else /* WIN32 */
pipe(p->audiopipe);
fcntl(p->audiopipe[0], F_SETFL, O_NONBLOCK);
@@ -539,7 +525,6 @@
struct timeval to;
#endif /* WIN32 */
-
p = tech_pvt->p;
//DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
@@ -551,7 +536,7 @@
fdselect = p->audiopipe[0];
FD_ZERO(&fs);
FD_SET(fdselect, &fs);
- to.tv_usec = 2000000; //20 msec
+ to.tv_usec = 2000000; //20 msec
to.tv_sec = 0;
rt = select(fdselect + 1, &fs, NULL, NULL, &to);
#endif /* WIN32 */
@@ -564,14 +549,14 @@
switch_file_read(p->audiopipe[0], tech_pvt->read_frame.data, &samples);
#else /* WIN32 */
- //samples = read(p->audiopipe[0], buf, SAMPLES_PER_FRAME * sizeof(short));
+ //samples = read(p->audiopipe[0], buf, SAMPLES_PER_FRAME * sizeof(short));
samples = read(p->audiopipe[0], tech_pvt->read_frame.data, samples);
#endif /* WIN32 */
if (samples != SAMPLES_PER_FRAME * sizeof(short)) {
if (samples)
ERRORA("SRV PIPE READ=====> NOT GOOD samples=%u expected=%lu\n", SKYPIAX_P_LOG,
- samples, SAMPLES_PER_FRAME * sizeof(short));
+ samples, SAMPLES_PER_FRAME * sizeof(short));
//do nothing
} else {
tech_pvt->read_frame.datalen = samples;
@@ -579,8 +564,8 @@
/* A real frame */
}
} else {
- if(rt)
- DEBUGA_SKYPE("select returned %d\n", SKYPIAX_P_LOG, rt);
+ if (rt)
+ DEBUGA_SKYPE("select returned %d\n", SKYPIAX_P_LOG, rt);
}
@@ -589,38 +574,32 @@
return SWITCH_STATUS_SUCCESS;
}
-
#ifdef WIN32
int LaunchSkype(struct skypiax_interface *p)
{
- LPTSTR pszMessage;
- DWORD dwLastError;
- char skypelogin[256];
-
- memset(skypelogin, '\0', sizeof(skypelogin));
- sprintf(skypelogin, "/secondary /username:%s /password:%s", p->skype_user, p->skype_password);
-
-
- ShellExecute(NULL, "open", "C:\\Program Files\\Skype\\Phone\\Skype.exe", skypelogin, ".", SW_SHOWNORMAL);
-
- dwLastError = GetLastError();
-
- FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL,
- dwLastError,
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
- (LPTSTR)&pszMessage,
- 0, NULL );
-
- NOTICA("ShellExecute gave: %s\n", SKYPIAX_P_LOG,pszMessage);
- LocalFree(pszMessage);
- return 1;
+ LPTSTR pszMessage;
+ DWORD dwLastError;
+ char skypelogin[256];
+
+ memset(skypelogin, '\0', sizeof(skypelogin));
+ sprintf(skypelogin, "/secondary /username:%s /password:%s", p->skype_user,
+ p->skype_password);
+
+ ShellExecute(NULL, "open", "C:\\Program Files\\Skype\\Phone\\Skype.exe", skypelogin,
+ ".", SW_SHOWNORMAL);
+
+ dwLastError = GetLastError();
+
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dwLastError, MAKELANGID(LANG_NEUTRAL,
+ SUBLANG_DEFAULT),
+ (LPTSTR) & pszMessage, 0, NULL);
-}
+ NOTICA("ShellExecute gave: %s\n", SKYPIAX_P_LOG, pszMessage);
+ LocalFree(pszMessage);
+ return 1;
+}
enum {
SKYPECONTROLAPI_ATTACH_SUCCESS = 0, /* Client is successfully
@@ -673,11 +652,11 @@
lReturnCode = 0;
fIssueDefProc = 0;
- p = ( struct skypiax_interface *)GetWindowLong(hWindow, GWL_USERDATA);
+ p = (struct skypiax_interface *) GetWindowLong(hWindow, GWL_USERDATA);
switch (uiMessage) {
case WM_CREATE:
- p=( struct skypiax_interface *)((LPCREATESTRUCT)ulParam)->lpCreateParams;
- SetWindowLong(hWindow, GWL_USERDATA, (LONG)p);
+ p = (struct skypiax_interface *) ((LPCREATESTRUCT) ulParam)->lpCreateParams;
+ SetWindowLong(hWindow, GWL_USERDATA, (LONG) p);
DEBUGA_SKYPE("got CREATE\n", SKYPIAX_P_LOG);
break;
case WM_DESTROY:
@@ -703,50 +682,52 @@
}
break;
default:
- if(p && p->AsteriskHandlesAst.win32_uiGlobal_MsgID_SkypeControlAPIAttach) {
- if (uiMessage == p->AsteriskHandlesAst.win32_uiGlobal_MsgID_SkypeControlAPIAttach) {
- switch (ulParam) {
- case SKYPECONTROLAPI_ATTACH_SUCCESS:
- if(!p->AsteriskHandlesAst.api_connected){
- NOTICA("\n\n\tConnected to Skype API!\n", SKYPIAX_P_LOG);
- p->AsteriskHandlesAst.win32_hGlobal_SkypeAPIWindowHandle = (HWND) uiParam;
- //switch_sleep(5000);
- p->AsteriskHandlesAst.win32_hGlobal_SkypeAPIWindowHandle =
- p->AsteriskHandlesAst.win32_hGlobal_SkypeAPIWindowHandle;
- }
- break;
- case SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION:
- WARNINGA
- ("\n\n\tIf I do not (almost) immediately connect to Skype API,\n\tplease give the Skype client authorization to be connected \n\tby Asterisk and to not ask you again.\n\n",
- SKYPIAX_P_LOG);
- switch_sleep(5000);
- if(!p->AsteriskHandlesAst.api_connected){
- SendMessage
- (HWND_BROADCAST, p->AsteriskHandlesAst.win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
- (WPARAM) p->AsteriskHandlesAst.win32_hInit_MainWindowHandle, 0);
- }
- break;
- case SKYPECONTROLAPI_ATTACH_REFUSED:
- ERRORA("Skype client refused to be connected by Skypiax!\n", SKYPIAX_P_LOG);
- break;
- case SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE:
- ERRORA("Skype API not (yet?) available\n", SKYPIAX_P_LOG);
- break;
- case SKYPECONTROLAPI_ATTACH_API_AVAILABLE:
- DEBUGA_SKYPE("Skype API available\n", SKYPIAX_P_LOG);
- switch_sleep(5000);
- if(!p->AsteriskHandlesAst.api_connected){
- SendMessage
- (HWND_BROADCAST, p->AsteriskHandlesAst.win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
- (WPARAM) p->AsteriskHandlesAst.win32_hInit_MainWindowHandle, 0);
- }
+ if (p && p->AsteriskHandlesAst.win32_uiGlobal_MsgID_SkypeControlAPIAttach) {
+ if (uiMessage == p->AsteriskHandlesAst.win32_uiGlobal_MsgID_SkypeControlAPIAttach) {
+ switch (ulParam) {
+ case SKYPECONTROLAPI_ATTACH_SUCCESS:
+ if (!p->AsteriskHandlesAst.api_connected) {
+ NOTICA("\n\n\tConnected to Skype API!\n", SKYPIAX_P_LOG);
+ p->AsteriskHandlesAst.win32_hGlobal_SkypeAPIWindowHandle = (HWND) uiParam;
+ //switch_sleep(5000);
+ p->AsteriskHandlesAst.win32_hGlobal_SkypeAPIWindowHandle =
+ p->AsteriskHandlesAst.win32_hGlobal_SkypeAPIWindowHandle;
+ }
+ break;
+ case SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION:
+ WARNINGA
+ ("\n\n\tIf I do not (almost) immediately connect to Skype API,\n\tplease give the Skype client authorization to be connected \n\tby Asterisk and to not ask you again.\n\n",
+ SKYPIAX_P_LOG);
+ switch_sleep(5000);
+ if (!p->AsteriskHandlesAst.api_connected) {
+ SendMessage(HWND_BROADCAST,
+ p->AsteriskHandlesAst.
+ win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
+ (WPARAM) p->AsteriskHandlesAst.win32_hInit_MainWindowHandle, 0);
+ }
+ break;
+ case SKYPECONTROLAPI_ATTACH_REFUSED:
+ ERRORA("Skype client refused to be connected by Skypiax!\n", SKYPIAX_P_LOG);
+ break;
+ case SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE:
+ ERRORA("Skype API not (yet?) available\n", SKYPIAX_P_LOG);
+ break;
+ case SKYPECONTROLAPI_ATTACH_API_AVAILABLE:
+ DEBUGA_SKYPE("Skype API available\n", SKYPIAX_P_LOG);
+ switch_sleep(5000);
+ if (!p->AsteriskHandlesAst.api_connected) {
+ SendMessage(HWND_BROADCAST,
+ p->AsteriskHandlesAst.
+ win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
+ (WPARAM) p->AsteriskHandlesAst.win32_hInit_MainWindowHandle, 0);
+ }
+ break;
+ default:
+ WARNINGA("GOT AN UNKNOWN SKYPE WINDOWS MSG\n", SKYPIAX_P_LOG);
+ }
+ lReturnCode = 1;
break;
- default:
- WARNINGA("GOT AN UNKNOWN SKYPE WINDOWS MSG\n", SKYPIAX_P_LOG);
}
- lReturnCode = 1;
- break;
- }
}
fIssueDefProc = 1;
break;
@@ -793,20 +774,24 @@
}
}
if (fReturnStatus == 0)
- CloseHandle(p->AsteriskHandlesAst.win32_hInit_ProcessHandle), p->AsteriskHandlesAst.win32_hInit_ProcessHandle = NULL;
+ CloseHandle(p->AsteriskHandlesAst.win32_hInit_ProcessHandle),
+ p->AsteriskHandlesAst.win32_hInit_ProcessHandle = NULL;
return (fReturnStatus);
}
void win32_DeInitialize_DestroyWindowClass(struct skypiax_interface *p)
{
- UnregisterClass(p->AsteriskHandlesAst.win32_acInit_WindowClassName, p->AsteriskHandlesAst.win32_hInit_ProcessHandle);
- CloseHandle(p->AsteriskHandlesAst.win32_hInit_ProcessHandle), p->AsteriskHandlesAst.win32_hInit_ProcessHandle = NULL;
+ UnregisterClass(p->AsteriskHandlesAst.win32_acInit_WindowClassName,
+ p->AsteriskHandlesAst.win32_hInit_ProcessHandle);
+ CloseHandle(p->AsteriskHandlesAst.win32_hInit_ProcessHandle),
+ p->AsteriskHandlesAst.win32_hInit_ProcessHandle = NULL;
}
int win32_Initialize_CreateMainWindow(struct skypiax_interface *p)
{
p->AsteriskHandlesAst.win32_hInit_MainWindowHandle =
- CreateWindowEx(WS_EX_APPWINDOW | WS_EX_WINDOWEDGE, p->AsteriskHandlesAst.win32_acInit_WindowClassName, "",
+ CreateWindowEx(WS_EX_APPWINDOW | WS_EX_WINDOWEDGE,
+ p->AsteriskHandlesAst.win32_acInit_WindowClassName, "",
WS_BORDER | WS_SYSMENU | WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT,
128, 128, NULL, 0, p->AsteriskHandlesAst.win32_hInit_ProcessHandle, p);
return (p->AsteriskHandlesAst.win32_hInit_MainWindowHandle != NULL ? 1 : 0);
@@ -815,7 +800,8 @@
void win32_DeInitialize_DestroyMainWindow(struct skypiax_interface *p)
{
if (p->AsteriskHandlesAst.win32_hInit_MainWindowHandle != NULL)
- DestroyWindow(p->AsteriskHandlesAst.win32_hInit_MainWindowHandle), p->AsteriskHandlesAst.win32_hInit_MainWindowHandle = NULL;
+ DestroyWindow(p->AsteriskHandlesAst.win32_hInit_MainWindowHandle),
+ p->AsteriskHandlesAst.win32_hInit_MainWindowHandle = NULL;
}
DWORD win32_dwThreadId;
@@ -835,19 +821,17 @@
//DWORD MsgWaitResult;
p = obj;
-
-
- switch_file_pipe_create(&p->AsteriskHandlesAst.fdesc[0], &p->AsteriskHandlesAst.fdesc[1], skypiax_module_pool);
+ switch_file_pipe_create(&p->AsteriskHandlesAst.fdesc[0],
+ &p->AsteriskHandlesAst.fdesc[1], skypiax_module_pool);
//switch_file_pipe_timeout_set(p->AsteriskHandlesAst.fdesc[0], 100);
-
p->AsteriskHandlesAst.win32_uiGlobal_MsgID_SkypeControlAPIAttach =
RegisterWindowMessage("SkypeControlAPIAttach");
p->AsteriskHandlesAst.win32_uiGlobal_MsgID_SkypeControlAPIDiscover =
RegisterWindowMessage("SkypeControlAPIDiscover");
LaunchSkype(p);
- switch_sleep(2000000);
+ switch_sleep(2000000);
if (p->AsteriskHandlesAst.win32_uiGlobal_MsgID_SkypeControlAPIAttach != 0
&& p->AsteriskHandlesAst.win32_uiGlobal_MsgID_SkypeControlAPIDiscover != 0) {
@@ -855,7 +839,8 @@
if (win32_Initialize_CreateMainWindow(p)) {
#if 1
if (SendMessage
- (HWND_BROADCAST, p->AsteriskHandlesAst.win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
+ (HWND_BROADCAST,
+ p->AsteriskHandlesAst.win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
(WPARAM) p->AsteriskHandlesAst.win32_hInit_MainWindowHandle, 0) != 0) {
#else
@@ -974,8 +959,10 @@
//X11_errors_trap();
//XLockDisplay(disp);
status =
- XGetWindowProperty(AsteriskHandlesAst->disp, DefaultRootWindow(AsteriskHandlesAst->disp), skype_inst, 0, 1, False, XA_WINDOW,
- &type_ret, &format_ret, &nitems_ret, &bytes_after_ret, &prop);
+ XGetWindowProperty(AsteriskHandlesAst->disp,
+ DefaultRootWindow(AsteriskHandlesAst->disp), skype_inst, 0, 1,
+ False, XA_WINDOW, &type_ret, &format_ret, &nitems_ret,
+ &bytes_after_ret, &prop);
//XUnlockDisplay(disp);
//X11_errors_untrap();
@@ -1053,7 +1040,7 @@
//FIXME pthread_cleanup_push(skypiax_skype_clean_disp, &xfd);
DEBUGA_SKYPE("PUSH disp %d\n", SKYPIAX_P_LOG, xfd);
- AsteriskHandlesAst->disp = disp;
+ AsteriskHandlesAst->disp = disp;
if (skypiax_skype_present(AsteriskHandlesAst)) {
root = DefaultRootWindow(disp);
@@ -1098,7 +1085,7 @@
b = buffer;
while (1) {
- //switch_sleep(10000);
+ //switch_sleep(10000);
XNextEvent(disp, &an_event);
if (!running)
break;
@@ -1158,7 +1145,7 @@
struct AsteriskHandles *AsteriskHandlesAst;
#endif /* WIN32 */
- DEBUGA_SKYPE("SENDING: |||%s||||\n", SKYPIAX_P_LOG, msg_to_skype);
+ DEBUGA_SKYPE("SENDING: |||%s||||\n", SKYPIAX_P_LOG, msg_to_skype);
#ifdef WIN32
@@ -1196,7 +1183,6 @@
}
AsteriskHandlesAst = &p->AsteriskHandlesAst;
-
if (!skypiax_skype_send_message(AsteriskHandlesAst, msg_to_skype)) {
ERRORA
("Sending message failed - probably Skype crashed.\n\nPlease shutdown Skypiax (Asterisk), then restart Skype from the menu, then launch Skypiax and try again.\n",
@@ -1248,459 +1234,464 @@
fdselect = p->AsteriskHandlesAst.fdesc[0];
FD_ZERO(&fs);
FD_SET(fdselect, &fs);
- to.tv_usec = 2000000; //500 msec
+ to.tv_usec = 2000000; //500 msec
to.tv_sec = 0;
rt = select(fdselect + 1, &fs, NULL, NULL, &to);
#endif /* WIN32 */
if (rt > 0) {
- if (p->AsteriskHandlesAst.fdesc[0]) {
- howmany = sizeof(read_from_pipe);
+ if (p->AsteriskHandlesAst.fdesc[0]) {
+ howmany = sizeof(read_from_pipe);
#ifdef WIN32
- switch_file_read(p->AsteriskHandlesAst.fdesc[0], read_from_pipe, &howmany);
+ switch_file_read(p->AsteriskHandlesAst.fdesc[0], read_from_pipe, &howmany);
#else /* WIN32 */
- howmany =
- read(p->AsteriskHandlesAst.fdesc[0], read_from_pipe, sizeof(read_from_pipe));
+ howmany =
+ read(p->AsteriskHandlesAst.fdesc[0], read_from_pipe, sizeof(read_from_pipe));
#endif /* WIN32 */
- a = 0;
- for (i = 0; i < howmany; i++) {
- messaggio[a] = read_from_pipe[i];
- a++;
-
- if (read_from_pipe[i] == '\0') {
-
- //if (option_debug > 101)
- DEBUGA_SKYPE("read_skype: howmany=%d, i=%d, a=%d, |||%s||| \n", SKYPIAX_P_LOG,
- howmany, i, a, messaggio);
-
- if (!strncasecmp(messaggio, "ERROR 92 CALL", 12)) {
- ERRORA("Skype got ERROR: |||%s|||, the number we called was not recognized\n",
- SKYPIAX_P_LOG, messaggio);
- p->skype_callflow = CALLFLOW_STATUS_FINISHED;
- if (option_debug)
- DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG);
- p->skype_call_id[0] = '\0';
-
- if (p->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ a = 0;
+ for (i = 0; i < howmany; i++) {
+ messaggio[a] = read_from_pipe[i];
+ a++;
+
+ if (read_from_pipe[i] == '\0') {
+
+ //if (option_debug > 101)
+ DEBUGA_SKYPE("read_skype: howmany=%d, i=%d, a=%d, |||%s||| \n", SKYPIAX_P_LOG,
+ howmany, i, a, messaggio);
+
+ if (!strncasecmp(messaggio, "ERROR 92 CALL", 12)) {
+ ERRORA("Skype got ERROR: |||%s|||, the number we called was not recognized\n",
+ SKYPIAX_P_LOG, messaggio);
+ p->skype_callflow = CALLFLOW_STATUS_FINISHED;
+ if (option_debug)
+ DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG);
+ p->skype_call_id[0] = '\0';
+
+ if (p->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
+ if (option_debug > 100) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+ p->interface_state = SKYPIAX_STATE_DOWN;
+ return CALLFLOW_INCOMING_HANGUP;
+ } else {
+ p->interface_state = SKYPIAX_STATE_DOWN;
}
- p->interface_state = SKYPIAX_STATE_DOWN;
- return CALLFLOW_INCOMING_HANGUP;
- } else {
- p->interface_state = SKYPIAX_STATE_DOWN;
}
- }
- strncpy(messaggio_2, messaggio, sizeof(messaggio) - 1);
+ strncpy(messaggio_2, messaggio, sizeof(messaggio) - 1);
- buf = messaggio;
- stringp = &buf;
- where = strsep(stringp, " ");
- if (!where) {
- WARNINGA("Skype MSG without spaces: %s\n", SKYPIAX_P_LOG, messaggio);
- }
+ buf = messaggio;
+ stringp = &buf;
+ where = strsep(stringp, " ");
+ if (!where) {
+ WARNINGA("Skype MSG without spaces: %s\n", SKYPIAX_P_LOG, messaggio);
+ }
- if (!strcasecmp(messaggio, "#333")) {
- /* DEBUGA_SKYPE("Skype MSG: messaggio_2: %s, messaggio2[11]: %s\n", SKYPIAX_P_LOG,
- * messaggio_2, &messaggio_2[11]); */
- memset(p->skype_friends, 0, 4096);
- strncpy(p->skype_friends, &messaggio_2[11], 4095);
- }
- if (!strcasecmp(messaggio, "#222")) {
- /* DEBUGA_SKYPE("Skype MSG: messaggio_2: %s, messaggio2[10]: %s\n", SKYPIAX_P_LOG,
- * messaggio_2, &messaggio_2[10]); */
- memset(p->skype_fullname, 0, 512);
- strncpy(p->skype_fullname, &messaggio_2[10], 511);
- }
- if (!strcasecmp(messaggio, "#765")) {
- /* DEBUGA_SKYPE("Skype MSG: messaggio_2: %s, messaggio2[10]: %s\n", SKYPIAX_P_LOG,
- * messaggio_2, &messaggio_2[10]); */
- memset(p->skype_displayname, 0, 512);
- strncpy(p->skype_displayname, &messaggio_2[10], 511);
- }
- if (!strcasecmp(messaggio, "ERROR")) {
- ERRORA("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, messaggio);
- p->skype_callflow = CALLFLOW_STATUS_FINISHED;
- if (option_debug)
- DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG);
- p->skype_call_id[0] = '\0';
-
- if (p->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
- p->interface_state = SKYPIAX_STATE_DOWN;
- return CALLFLOW_INCOMING_HANGUP;
- } else {
- p->interface_state = SKYPIAX_STATE_DOWN;
+ if (!strcasecmp(messaggio, "#333")) {
+ /* DEBUGA_SKYPE("Skype MSG: messaggio_2: %s, messaggio2[11]: %s\n", SKYPIAX_P_LOG,
+ * messaggio_2, &messaggio_2[11]); */
+ memset(p->skype_friends, 0, 4096);
+ strncpy(p->skype_friends, &messaggio_2[11], 4095);
}
- }
- if (!strcasecmp(messaggio, "CURRENTUSERHANDLE") ) {
- strncpy(obj, where, sizeof(obj) - 1);
+ if (!strcasecmp(messaggio, "#222")) {
+ /* DEBUGA_SKYPE("Skype MSG: messaggio_2: %s, messaggio2[10]: %s\n", SKYPIAX_P_LOG,
+ * messaggio_2, &messaggio_2[10]); */
+ memset(p->skype_fullname, 0, 512);
+ strncpy(p->skype_fullname, &messaggio_2[10], 511);
+ }
+ if (!strcasecmp(messaggio, "#765")) {
+ /* DEBUGA_SKYPE("Skype MSG: messaggio_2: %s, messaggio2[10]: %s\n", SKYPIAX_P_LOG,
+ * messaggio_2, &messaggio_2[10]); */
+ memset(p->skype_displayname, 0, 512);
+ strncpy(p->skype_displayname, &messaggio_2[10], 511);
+ }
+ if (!strcasecmp(messaggio, "ERROR")) {
+ ERRORA("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, messaggio);
+ p->skype_callflow = CALLFLOW_STATUS_FINISHED;
+ if (option_debug)
+ DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG);
+ p->skype_call_id[0] = '\0';
- where = strsep(stringp, " ");
+ if (p->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
+ if (option_debug > 100) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+ p->interface_state = SKYPIAX_STATE_DOWN;
+ return CALLFLOW_INCOMING_HANGUP;
+ } else {
+ p->interface_state = SKYPIAX_STATE_DOWN;
+ }
+ }
+ if (!strcasecmp(messaggio, "CURRENTUSERHANDLE")) {
+ strncpy(obj, where, sizeof(obj) - 1);
- strncpy(id, where, sizeof(id) - 1);
+ where = strsep(stringp, " ");
+ strncpy(id, where, sizeof(id) - 1);
- if (!strcasecmp(id, p->skype_user)) {
- p->AsteriskHandlesAst.api_connected = 1;
- //DEBUGA_SKYPE ("Skype MSG: messaggio: %s, currentuserhandle: %s, cuh: %s, skype_user: %s!\n", SKYPIAX_P_LOG, messaggio, obj, id, p->skype_user);
- }
+ if (!strcasecmp(id, p->skype_user)) {
+ p->AsteriskHandlesAst.api_connected = 1;
+ //DEBUGA_SKYPE ("Skype MSG: messaggio: %s, currentuserhandle: %s, cuh: %s, skype_user: %s!\n", SKYPIAX_P_LOG, messaggio, obj, id, p->skype_user);
+ }
}
- if (!strcasecmp(messaggio, "CALL")) {
-
- strncpy(obj, where, sizeof(obj) - 1);
+ if (!strcasecmp(messaggio, "CALL")) {
- where = strsep(stringp, " ");
+ strncpy(obj, where, sizeof(obj) - 1);
- strncpy(id, where, sizeof(id) - 1);
+ where = strsep(stringp, " ");
- where = strsep(stringp, " ");
+ strncpy(id, where, sizeof(id) - 1);
- strncpy(prop, where, sizeof(prop) - 1);
+ where = strsep(stringp, " ");
- where = strsep(stringp, " ");
+ strncpy(prop, where, sizeof(prop) - 1);
- strncpy(value, where, sizeof(value) - 1);
+ where = strsep(stringp, " ");
- where = strsep(stringp, " ");
+ strncpy(value, where, sizeof(value) - 1);
- if (option_debug > 101)
- DEBUGA_SKYPE
- ("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s, value: %s,where: %s!\n",
- SKYPIAX_P_LOG, messaggio, obj, id, prop, value, where ? where : "NULL");
+ where = strsep(stringp, " ");
+ if (option_debug > 101)
+ DEBUGA_SKYPE
+ ("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s, value: %s,where: %s!\n",
+ SKYPIAX_P_LOG, messaggio, obj, id, prop, value, where ? where : "NULL");
- if (!strcasecmp(prop, "PARTNER_HANDLE")) {
- strncpy(p->callid_number, value, sizeof(p->callid_number) - 1);
- WARNINGA
- ("the skype_call %s caller PARTNER_HANDLE (p->callid_number) is: %s\n",
- SKYPIAX_P_LOG, id, p->callid_number);
- return CALLFLOW_INCOMING_RING;
- }
- if (!strcasecmp(prop, "PARTNER_DISPNAME")) {
- snprintf(p->callid_name, sizeof(p->callid_name) - 1, "%s%s%s", value,
- where ? " " : "", where ? where : "");
- WARNINGA
- ("the skype_call %s caller PARTNER_DISPNAME (p->callid_name) is: %s\n",
- SKYPIAX_P_LOG, id, p->callid_name);
- }
- if (!strcasecmp(prop, "CONF_ID") && !strcasecmp(value, "0")) {
- DEBUGA_SKYPE("the skype_call %s is NOT a conference call\n", SKYPIAX_P_LOG,
- id);
- if (p->interface_state == SKYPIAX_STATE_DOWN)
- p->interface_state = SKYPIAX_STATE_PRERING;
- }
- if (!strcasecmp(prop, "CONF_ID") && strcasecmp(value, "0")) {
- DEBUGA_SKYPE("the skype_call %s is a conference call\n", SKYPIAX_P_LOG, id);
- if (p->interface_state == SKYPIAX_STATE_DOWN)
- p->interface_state = SKYPIAX_STATE_PRERING;
- }
+ if (!strcasecmp(prop, "PARTNER_HANDLE")) {
+ strncpy(p->callid_number, value, sizeof(p->callid_number) - 1);
+ WARNINGA
+ ("the skype_call %s caller PARTNER_HANDLE (p->callid_number) is: %s\n",
+ SKYPIAX_P_LOG, id, p->callid_number);
+ return CALLFLOW_INCOMING_RING;
+ }
+ if (!strcasecmp(prop, "PARTNER_DISPNAME")) {
+ snprintf(p->callid_name, sizeof(p->callid_name) - 1, "%s%s%s", value,
+ where ? " " : "", where ? where : "");
+ WARNINGA
+ ("the skype_call %s caller PARTNER_DISPNAME (p->callid_name) is: %s\n",
+ SKYPIAX_P_LOG, id, p->callid_name);
+ }
+ if (!strcasecmp(prop, "CONF_ID") && !strcasecmp(value, "0")) {
+ DEBUGA_SKYPE("the skype_call %s is NOT a conference call\n", SKYPIAX_P_LOG,
+ id);
+ if (p->interface_state == SKYPIAX_STATE_DOWN)
+ p->interface_state = SKYPIAX_STATE_PRERING;
+ }
+ if (!strcasecmp(prop, "CONF_ID") && strcasecmp(value, "0")) {
+ DEBUGA_SKYPE("the skype_call %s is a conference call\n", SKYPIAX_P_LOG, id);
+ if (p->interface_state == SKYPIAX_STATE_DOWN)
+ p->interface_state = SKYPIAX_STATE_PRERING;
+ }
- if (!strcasecmp(prop, "DTMF")) {
- switch_core_session_t *session = NULL;
- private_t *tech_pvt = NULL;
- switch_channel_t *channel = NULL;
-
- DEBUGA_SKYPE("Call %s received a DTMF: %s\n", SKYPIAX_P_LOG, id, value);
-
- tech_pvt = p->tech_pvt;
- //if(tech_pvt)
- session = tech_pvt->session;
- //if(session)
- channel = switch_core_session_get_channel(session);
-
- if (channel) {
- switch_dtmf_t dtmf =
- { (char) value[0], switch_core_default_dtmf_duration(0) };
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%c DTMF %s\n",
- 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);
- switch_mutex_unlock(tech_pvt->flag_mutex);
+ if (!strcasecmp(prop, "DTMF")) {
+ switch_core_session_t *session = NULL;
+ private_t *tech_pvt = NULL;
+ switch_channel_t *channel = NULL;
+
+ DEBUGA_SKYPE("Call %s received a DTMF: %s\n", SKYPIAX_P_LOG, id, value);
+
+ tech_pvt = p->tech_pvt;
+ //if(tech_pvt)
+ session = tech_pvt->session;
+ //if(session)
+ channel = switch_core_session_get_channel(session);
+
+ if (channel) {
+ switch_dtmf_t dtmf =
+ { (char) value[0], switch_core_default_dtmf_duration(0) };
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%c DTMF %s\n",
+ 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);
+ switch_mutex_unlock(tech_pvt->flag_mutex);
+ }
}
- }
- if (!strcasecmp(prop, "FAILUREREASON")) {
- DEBUGA_SKYPE
- ("Skype has FAILED on skype_call %s. Let's wait for the FAILED message.\n",
- SKYPIAX_P_LOG, id);
- }
- if (!strcasecmp(prop, "DURATION") && (!strcasecmp(value, "1"))) {
- if (strcasecmp(id, p->skype_call_id)) {
- strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1);
- if (option_debug > 1)
- DEBUGA_SKYPE
- ("We called a Skype contact and he answered us on skype_call: %s.\n",
- SKYPIAX_P_LOG, id);
+ if (!strcasecmp(prop, "FAILUREREASON")) {
+ DEBUGA_SKYPE
+ ("Skype has FAILED on skype_call %s. Let's wait for the FAILED message.\n",
+ SKYPIAX_P_LOG, id);
}
- }
+ if (!strcasecmp(prop, "DURATION") && (!strcasecmp(value, "1"))) {
+ if (strcasecmp(id, p->skype_call_id)) {
+ strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1);
+ if (option_debug > 1)
+ DEBUGA_SKYPE
+ ("We called a Skype contact and he answered us on skype_call: %s.\n",
+ SKYPIAX_P_LOG, id);
+ }
+ }
+
+ if (!strcasecmp(prop, "STATUS")) {
- if (!strcasecmp(prop, "STATUS")) {
+ if (!strcasecmp(value, "RINGING")) {
+ char msg_to_skype[1024];
+ if (p->interface_state != SKYPIAX_STATE_DIALING) {
+ /* we are not calling out */
- if (!strcasecmp(value, "RINGING")) {
- char msg_to_skype[1024];
- if (p->interface_state != SKYPIAX_STATE_DIALING) {
- /* we are not calling out */
+ if (!strlen(p->skype_call_id)) { //FIXME
+ /* we are not inside an active call */
+ p->skype_callflow = CALLFLOW_STATUS_RINGING;
+ p->interface_state = SKYPIAX_STATE_RING;
+ /* no owner, no active call, let's answer */
+ skypiax_skype_write(p, "SET AGC OFF");
+ switch_sleep(10000);
+ skypiax_skype_write(p, "SET AEC OFF");
+ switch_sleep(10000);
+ sprintf(msg_to_skype, "GET CALL %s PARTNER_DISPNAME", id);
+ skypiax_skype_write(p, msg_to_skype);
+ switch_sleep(10000);
+ sprintf(msg_to_skype, "GET CALL %s PARTNER_HANDLE", id);
+ skypiax_skype_write(p, msg_to_skype);
+ switch_sleep(10000);
+ sprintf(msg_to_skype, "ALTER CALL %s ANSWER", id);
+ skypiax_skype_write(p, msg_to_skype);
+ if (option_debug)
+ DEBUGA_SKYPE("We answered a Skype RING on skype_call %s\n",
+ SKYPIAX_P_LOG, id);
+ strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1);
+ } else {
+ /* we're owned, we're in a call, let's refuse */
+ //sprintf(msg_to_skype, "SET CALL %s STATUS REFUSED", id);
+ sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", id);
+ skypiax_skype_write(p, msg_to_skype);
+ switch_sleep(10000);
+ DEBUGA_SKYPE
+ ("We have NOT answered a Skype RING on skype_call %s, because we are already in a skypiax call\n",
+ SKYPIAX_P_LOG, id);
- if (!strlen(p->skype_call_id)) { //FIXME
- /* we are not inside an active call */
+ }
+ } else {
+ /* we are calling out */
p->skype_callflow = CALLFLOW_STATUS_RINGING;
- p->interface_state = SKYPIAX_STATE_RING;
- /* no owner, no active call, let's answer */
- skypiax_skype_write(p, "SET AGC OFF");
- switch_sleep(10000);
- skypiax_skype_write(p, "SET AEC OFF");
- switch_sleep(10000);
- sprintf(msg_to_skype, "GET CALL %s PARTNER_DISPNAME", id);
- skypiax_skype_write(p, msg_to_skype);
- switch_sleep(10000);
- sprintf(msg_to_skype, "GET CALL %s PARTNER_HANDLE", id);
- skypiax_skype_write(p, msg_to_skype);
- switch_sleep(10000);
- sprintf(msg_to_skype, "ALTER CALL %s ANSWER", id);
- skypiax_skype_write(p, msg_to_skype);
- if (option_debug)
- DEBUGA_SKYPE("We answered a Skype RING on skype_call %s\n",
- SKYPIAX_P_LOG, id);
+ p->interface_state = SKYPIAX_STATE_RINGING;
+ //FIXME ast_queue_control(p->owner, SKYPIAX_CONTROL_RINGING);
strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1);
- } else {
- /* we're owned, we're in a call, let's refuse */
- //sprintf(msg_to_skype, "SET CALL %s STATUS REFUSED", id);
- sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", id);
- skypiax_skype_write(p, msg_to_skype);
- switch_sleep(10000);
- DEBUGA_SKYPE
- ("We have NOT answered a Skype RING on skype_call %s, because we are already in a skypiax call\n",
- SKYPIAX_P_LOG, id);
-
+ DEBUGA_SKYPE("Our remote party in skype_call %s is RINGING\n",
+ SKYPIAX_P_LOG, id);
}
- } else {
- /* we are calling out */
- p->skype_callflow = CALLFLOW_STATUS_RINGING;
- p->interface_state = SKYPIAX_STATE_RINGING;
+ } else if (!strcasecmp(value, "EARLYMEDIA")) {
+ p->skype_callflow = CALLFLOW_STATUS_EARLYMEDIA;
+ p->interface_state = SKYPIAX_STATE_DIALING;
//FIXME ast_queue_control(p->owner, SKYPIAX_CONTROL_RINGING);
- strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1);
- DEBUGA_SKYPE("Our remote party in skype_call %s is RINGING\n",
+ DEBUGA_SKYPE("Our remote party in skype_call %s is EARLYMEDIA\n",
SKYPIAX_P_LOG, id);
- }
- } else if (!strcasecmp(value, "EARLYMEDIA")) {
- p->skype_callflow = CALLFLOW_STATUS_EARLYMEDIA;
- p->interface_state = SKYPIAX_STATE_DIALING;
- //FIXME ast_queue_control(p->owner, SKYPIAX_CONTROL_RINGING);
- DEBUGA_SKYPE("Our remote party in skype_call %s is EARLYMEDIA\n",
- SKYPIAX_P_LOG, id);
- } else if (!strcasecmp(value, "MISSED")) {
- DEBUGA_SKYPE("We missed skype_call %s\n", SKYPIAX_P_LOG, id);
-
- } else if (!strcasecmp(value, "FINISHED")) {
- //p->skype_callflow = CALLFLOW_STATUS_FINISHED;
- if (option_debug)
- DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id);
- p->skype_call_id[0] = '\0';
+ } else if (!strcasecmp(value, "MISSED")) {
+ DEBUGA_SKYPE("We missed skype_call %s\n", SKYPIAX_P_LOG, id);
- if (p->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ } else if (!strcasecmp(value, "FINISHED")) {
+ //p->skype_callflow = CALLFLOW_STATUS_FINISHED;
+ if (option_debug)
+ DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id);
+ p->skype_call_id[0] = '\0';
+
+ if (p->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
+ if (option_debug > 100) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+ //p->interface_state = SKYPIAX_STATE_DOWN;
+ return CALLFLOW_INCOMING_HANGUP;
+ } else {
+ p->interface_state = SKYPIAX_STATE_DOWN;
}
- //p->interface_state = SKYPIAX_STATE_DOWN;
- return CALLFLOW_INCOMING_HANGUP;
- } else {
- p->interface_state = SKYPIAX_STATE_DOWN;
- }
- } else if (!strcasecmp(value, "CANCELLED")) {
- p->skype_callflow = CALLFLOW_STATUS_CANCELLED;
- if (option_debug)
- DEBUGA_SKYPE
- ("we tried to call Skype on skype_call %s and Skype has now CANCELLED\n",
- SKYPIAX_P_LOG, id);
- p->skype_call_id[0] = '\0';
+ } else if (!strcasecmp(value, "CANCELLED")) {
+ p->skype_callflow = CALLFLOW_STATUS_CANCELLED;
+ if (option_debug)
+ DEBUGA_SKYPE
+ ("we tried to call Skype on skype_call %s and Skype has now CANCELLED\n",
+ SKYPIAX_P_LOG, id);
+ p->skype_call_id[0] = '\0';
- if (p->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ if (p->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
+ if (option_debug > 100) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+ p->interface_state = SKYPIAX_STATE_DOWN;
+ return CALLFLOW_INCOMING_HANGUP;
+ } else {
+ p->interface_state = SKYPIAX_STATE_DOWN;
}
- p->interface_state = SKYPIAX_STATE_DOWN;
- return CALLFLOW_INCOMING_HANGUP;
- } else {
- p->interface_state = SKYPIAX_STATE_DOWN;
- }
- } else if (!strcasecmp(value, "FAILED")) {
- p->skype_callflow = CALLFLOW_STATUS_FAILED;
- if (option_debug)
- DEBUGA_SKYPE
- ("we tried to call Skype on skype_call %s and Skype has now FAILED\n",
- SKYPIAX_P_LOG, id);
- p->skype_call_id[0] = '\0';
- strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1);
- p->interface_state = SKYPIAX_STATE_DOWN;
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
- return CALLFLOW_INCOMING_HANGUP;
- } else if (!strcasecmp(value, "REFUSED")) {
- if (!strcasecmp(id, p->skype_call_id)) {
- /* this is the id of the call we are in, probably we generated it */
- p->skype_callflow = CALLFLOW_STATUS_REFUSED;
+ } else if (!strcasecmp(value, "FAILED")) {
+ p->skype_callflow = CALLFLOW_STATUS_FAILED;
if (option_debug)
DEBUGA_SKYPE
- ("we tried to call Skype on skype_call %s and Skype has now REFUSED\n",
+ ("we tried to call Skype on skype_call %s and Skype has now FAILED\n",
SKYPIAX_P_LOG, id);
+ p->skype_call_id[0] = '\0';
strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1);
p->interface_state = SKYPIAX_STATE_DOWN;
- p->skype_call_id[0] = '\0';
if (option_debug > 100) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
return CALLFLOW_INCOMING_HANGUP;
- } else {
- /* we're here because were us that refused an incoming call */
- DEBUGA_SKYPE("we REFUSED skype_call %s\n", SKYPIAX_P_LOG, id);
-
- }
- } else if (!strcasecmp(value, "ROUTING")) {
- p->skype_callflow = CALLFLOW_STATUS_ROUTING;
- p->interface_state = SKYPIAX_STATE_DIALING;
- strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1);
- DEBUGA_SKYPE("skype_call: %s is now ROUTING\n", SKYPIAX_P_LOG, id);
- } else if (!strcasecmp(value, "UNPLACED")) {
- p->skype_callflow = CALLFLOW_STATUS_UNPLACED;
- p->interface_state = SKYPIAX_STATE_DIALING;
- strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1);
- DEBUGA_SKYPE("skype_call: %s is now UNPLACED\n", SKYPIAX_P_LOG, id);
- } else if (!strcasecmp(value, "INPROGRESS")) {
- p->skype_callflow = CALLFLOW_STATUS_INPROGRESS;
- strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1);
- p->interface_state = SKYPIAX_STATE_UP;
- if (option_debug > 1)
- DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id);
-
- if (option_debug > 1)
- DEBUGA_SKYPE("skype_call: %s SKYPIAX_CONTROL_ANSWER sent\n",
- SKYPIAX_P_LOG, id);
+ } else if (!strcasecmp(value, "REFUSED")) {
+ if (!strcasecmp(id, p->skype_call_id)) {
+ /* this is the id of the call we are in, probably we generated it */
+ p->skype_callflow = CALLFLOW_STATUS_REFUSED;
+ if (option_debug)
+ DEBUGA_SKYPE
+ ("we tried to call Skype on skype_call %s and Skype has now REFUSED\n",
+ SKYPIAX_P_LOG, id);
+ strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1);
+ p->interface_state = SKYPIAX_STATE_DOWN;
+ p->skype_call_id[0] = '\0';
+ if (option_debug > 100) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+ return CALLFLOW_INCOMING_HANGUP;
+ } else {
+ /* we're here because were us that refused an incoming call */
+ DEBUGA_SKYPE("we REFUSED skype_call %s\n", SKYPIAX_P_LOG, id);
- if (1) { //FIXME
- char msg_to_skype[1024];
+ }
+ } else if (!strcasecmp(value, "ROUTING")) {
+ p->skype_callflow = CALLFLOW_STATUS_ROUTING;
+ p->interface_state = SKYPIAX_STATE_DIALING;
+ strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1);
+ DEBUGA_SKYPE("skype_call: %s is now ROUTING\n", SKYPIAX_P_LOG, id);
+ } else if (!strcasecmp(value, "UNPLACED")) {
+ p->skype_callflow = CALLFLOW_STATUS_UNPLACED;
+ p->interface_state = SKYPIAX_STATE_DIALING;
+ strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1);
+ DEBUGA_SKYPE("skype_call: %s is now UNPLACED\n", SKYPIAX_P_LOG, id);
+ } else if (!strcasecmp(value, "INPROGRESS")) {
+ p->skype_callflow = CALLFLOW_STATUS_INPROGRESS;
+ strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1);
+ p->interface_state = SKYPIAX_STATE_UP;
+ if (option_debug > 1)
+ DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id);
+
+ if (option_debug > 1)
+ DEBUGA_SKYPE("skype_call: %s SKYPIAX_CONTROL_ANSWER sent\n",
+ SKYPIAX_P_LOG, id);
if (1) { //FIXME
- switch_threadattr_t *thd_attr = NULL;
+ char msg_to_skype[1024];
- switch_threadattr_create(&thd_attr, skypiax_module_pool);
- switch_threadattr_detach_set(thd_attr, 1);
- switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
- switch_thread_create(&p->tcp_srv_thread, thd_attr,
- skypiax_do_tcp_srv_thread, p, skypiax_module_pool);
- DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG);
-
- switch_threadattr_create(&thd_attr, skypiax_module_pool);
- switch_threadattr_detach_set(thd_attr, 1);
- switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
- switch_thread_create(&p->tcp_cli_thread, thd_attr,
- skypiax_do_tcp_cli_thread, p, skypiax_module_pool);
- DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
+ if (1) { //FIXME
+ switch_threadattr_t *thd_attr = NULL;
+
+ switch_threadattr_create(&thd_attr, skypiax_module_pool);
+ switch_threadattr_detach_set(thd_attr, 1);
+ switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+ switch_thread_create(&p->tcp_srv_thread, thd_attr,
+ skypiax_do_tcp_srv_thread, p,
+ skypiax_module_pool);
+ DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG);
+
+ switch_threadattr_create(&thd_attr, skypiax_module_pool);
+ switch_threadattr_detach_set(thd_attr, 1);
+ switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE);
+ switch_thread_create(&p->tcp_cli_thread, thd_attr,
+ skypiax_do_tcp_cli_thread, p,
+ skypiax_module_pool);
+ DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
+ }
+ switch_sleep(100000);
+ sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id,
+ p->tcp_srv_port);
+ skypiax_skype_write(p, msg_to_skype);
+ switch_sleep(100000);
+ sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id,
+ p->tcp_cli_port);
+ skypiax_skype_write(p, msg_to_skype);
+ switch_sleep(100000);
}
- switch_sleep(100000);
- sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id, p->tcp_srv_port);
- skypiax_skype_write(p, msg_to_skype);
- switch_sleep(100000);
- sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id, p->tcp_cli_port);
- skypiax_skype_write(p, msg_to_skype);
- switch_sleep(100000);
- }
- p->skype_callflow = SKYPIAX_STATE_UP;
+ p->skype_callflow = SKYPIAX_STATE_UP;
/**************************/
- //FIXME switch_core_session_t **new_session;
+ //FIXME switch_core_session_t **new_session;
- //FIXME *new_session=switch_loadable_module_create_interface(skypiax_endpoint_interface, pool);
+ //FIXME *new_session=switch_loadable_module_create_interface(skypiax_endpoint_interface, pool);
- if (!global_session) { //FIXME FIXME FIXME
- switch_core_session_t *session = NULL;
- private_t *tech_pvt = NULL;
- switch_channel_t *channel = NULL;
-
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
- "New Inbound Channel!\n");
-
- if ((session =
- switch_core_session_request(skypiax_endpoint_interface,
- NULL)) != 0) {
- switch_core_session_add_stream(session, NULL);
- if ((tech_pvt =
- (private_t *) switch_core_session_alloc(session,
- sizeof(private_t))) != 0) {
- channel = switch_core_session_get_channel(session);
- skypiax_tech_init(tech_pvt, session, p);
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
- "Hey where is my memory pool?\n");
- switch_core_session_destroy(&session);
- break;
+ if (!global_session) { //FIXME FIXME FIXME
+ switch_core_session_t *session = NULL;
+ private_t *tech_pvt = NULL;
+ switch_channel_t *channel = NULL;
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE,
+ "New Inbound Channel!\n");
+
+ if ((session =
+ switch_core_session_request(skypiax_endpoint_interface,
+ NULL)) != 0) {
+ switch_core_session_add_stream(session, NULL);
+ if ((tech_pvt =
+ (private_t *) switch_core_session_alloc(session,
+ sizeof(private_t))) !=
+ 0) {
+ channel = switch_core_session_get_channel(session);
+ skypiax_tech_init(tech_pvt, session, p);
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
+ "Hey where is my memory pool?\n");
+ switch_core_session_destroy(&session);
+ break;
+ }
+
+ // if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session), NULL, dialplan, cid_name, cid_num, ip, NULL, NULL, NULL, modname, NULL, dest)) != 0)
+
+ if ((tech_pvt->caller_profile =
+ switch_caller_profile_new(switch_core_session_get_pool(session),
+ "skypiax", "XML", p->callid_name,
+ p->callid_number, NULL, "calling_ani",
+ NULL, NULL, "mod_skypiax", "public",
+ "5000")) != 0) {
+ char name[128];
+ switch_snprintf(name, sizeof(name), "skypiax/%s-%04x",
+ tech_pvt->caller_profile->destination_number,
+ rand() & 0xffff);
+ switch_channel_set_name(channel, name);
+ switch_channel_set_caller_profile(channel,
+ tech_pvt->caller_profile);
+ }
+ switch_channel_set_state(channel, CS_INIT);
+ if (switch_core_session_thread_launch(session) !=
+ SWITCH_STATUS_SUCCESS) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
+ "Error spawning thread\n");
+ switch_core_session_destroy(&session);
+ }
}
+ //DEBUGA_SKYPE("skype_call: %s, answered\n", SKYPIAX_P_LOG, id);
+ switch_channel_mark_answered(channel);
+ } else {
+ switch_core_session_t *session = NULL;
+ private_t *tech_pvt = NULL;
+ switch_channel_t *channel = NULL;
+
+ tech_pvt = p->tech_pvt;
+ //session = tech_pvt->session;
+ session = global_session;
+ channel = switch_core_session_get_channel(session);
+ //DEBUGA_SKYPE("skype_call: %s, answered\n", SKYPIAX_P_LOG, id);
+ switch_channel_mark_answered(channel);
- // if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session), NULL, dialplan, cid_name, cid_num, ip, NULL, NULL, NULL, modname, NULL, dest)) != 0)
+ //switch_channel_set_state(channel, CS_EXECUTE);
- if ((tech_pvt->caller_profile =
- switch_caller_profile_new(switch_core_session_get_pool(session),
- "skypiax", "XML", p->callid_name,
- p->callid_number, NULL, "calling_ani",
- NULL, NULL, "mod_skypiax", "public",
- "5000")) != 0) {
- char name[128];
- switch_snprintf(name, sizeof(name), "skypiax/%s-%04x",
- tech_pvt->caller_profile->destination_number,
- rand() & 0xffff);
- switch_channel_set_name(channel, name);
- switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
- }
- switch_channel_set_state(channel, CS_INIT);
- if (switch_core_session_thread_launch(session) != SWITCH_STATUS_SUCCESS) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT,
- "Error spawning thread\n");
- switch_core_session_destroy(&session);
- }
}
- WARNINGA("skype_call: %s, answered\n", SKYPIAX_P_LOG, id);
- switch_channel_mark_answered(channel);
- } else {
- switch_core_session_t *session = NULL;
- private_t *tech_pvt = NULL;
- switch_channel_t *channel = NULL;
-
- tech_pvt = p->tech_pvt;
- //session = tech_pvt->session;
- session = global_session;
- channel = switch_core_session_get_channel(session);
- WARNINGA("skype_call: %s, answered\n", SKYPIAX_P_LOG, id);
- switch_channel_mark_answered(channel);
-
- //switch_channel_set_state(channel, CS_EXECUTE);
-
- }
/**************************/
- } else {
- WARNINGA("skype_call: %s, STATUS: %s is not recognized\n", SKYPIAX_P_LOG,
- id, value);
+ } else {
+ WARNINGA("skype_call: %s, STATUS: %s is not recognized\n", SKYPIAX_P_LOG,
+ id, value);
- }
- } //STATUS
+ }
+ } //STATUS
- } //CALL
+ } //CALL
- a = 0;
- } //message end
- } //read_from_pipe
+ a = 0;
+ } //message end
+ } //read_from_pipe
- }
+ }
}
if (option_debug > 100) {
@@ -1710,7 +1701,8 @@
return 0;
}
-int skypiax_skype_call(struct skypiax_interface *p, char *idest, int timeout, switch_core_session_t * session)
+int skypiax_skype_call(struct skypiax_interface *p, char *idest, int timeout,
+ switch_core_session_t * session)
{
char *rdest;
char msg_to_skype[1024];
@@ -1745,5 +1737,3 @@
//FIXME ast_queue_control(p->owner, SKYPIAX_CONTROL_RINGING);
return 0;
}
-
-
1
0
[commit] r11040 - in freeswitch/trunk/src: . mod/event_handlers/mod_event_socket
by FreeSWITCH SVN 31 Dec '08
by FreeSWITCH SVN 31 Dec '08
31 Dec '08
Author: anthm
Date: Wed Dec 31 17:44:23 2008
New Revision: 11040
Log:
wash behind your ears
Modified:
freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
freeswitch/trunk/src/switch_event.c
Modified: freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c
==============================================================================
--- freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c (original)
+++ freeswitch/trunk/src/mod/event_handlers/mod_event_socket/mod_event_socket.c Wed Dec 31 17:44:23 2008
@@ -628,15 +628,67 @@
switch_mutex_unlock(listener->filter_mutex);
+ } else if (!strcasecmp(wcmd, "stop-logging")) {
+ char *id = switch_event_get_header(stream->param_event, "listen-id");
+ uint32_t idl = 0;
+
+ if (id) {
+ idl = (uint32_t) atol(id);
+ }
+
+ if (!(listener = find_listener(idl))) {
+ stream->write_function(stream, "<data><reply type=\"error\">Invalid Listen-ID</reply></data>\n");
+ goto end;
+ }
+
+ if (switch_test_flag(listener, LFLAG_LOG)) {
+ switch_clear_flag_locked(listener, LFLAG_LOG);
+ stream->write_function(stream, "<data><reply type=\"success\">Not Logging</reply></data>\n");
+ } else {
+ stream->write_function(stream, "<data><reply type=\"error\">Not Logging</reply></data>\n");
+ }
+
+ goto end;
+
+ } else if (!strcasecmp(wcmd, "set-loglevel")) {
+ char *loglevel = switch_event_get_header(stream->param_event, "loglevel");
+ char *id = switch_event_get_header(stream->param_event, "listen-id");
+ uint32_t idl = 0;
+
+ if (id) {
+ idl = (uint32_t) atol(id);
+ }
+
+ if (!(listener = find_listener(idl))) {
+ stream->write_function(stream, "<data><reply type=\"error\">Invalid Listen-ID</reply></data>\n");
+ goto end;
+ }
+
+ if (loglevel) {
+ switch_log_level_t ltype = switch_log_str2level(loglevel);
+ if (ltype != SWITCH_LOG_INVALID) {
+ listener->level = ltype;
+ switch_set_flag(listener, LFLAG_LOG);
+ stream->write_function(stream, "<data><reply type=\"success\">Log Level %s</reply></data>\n", loglevel);
+ } else {
+ stream->write_function(stream, "<data><reply type=\"error\">Invalid Level</reply></data>\n");
+ }
+ } else {
+ stream->write_function(stream, "<data><reply type=\"error\">Invalid Syntax</reply></data>\n");
+ }
+
+ goto end;
+
} else if (!strcasecmp(wcmd, "create-listener")) {
char *events = switch_event_get_header(stream->param_event, "events");
+ char *loglevel = switch_event_get_header(stream->param_event, "loglevel");
switch_memory_pool_t *pool;
char *next, *cur;
uint32_t count = 0, key_count = 0;
uint8_t custom = 0;
char *edup;
- if (switch_strlen_zero(events)) {
+ if (switch_strlen_zero(events) && switch_strlen_zero(loglevel)) {
stream->write_function(stream, "<data><reply type=\"error\">Missing parameter!</reply></data>\n");
goto end;
}
@@ -652,58 +704,69 @@
switch_set_flag(listener, LFLAG_AUTHED);
switch_set_flag(listener, LFLAG_STATEFUL);
switch_queue_create(&listener->event_queue, SWITCH_CORE_QUEUE_LEN, listener->pool);
+ switch_queue_create(&listener->log_queue, SWITCH_CORE_QUEUE_LEN, listener->pool);
+
+ if (loglevel) {
+ switch_log_level_t ltype = switch_log_str2level(loglevel);
+ if (ltype != SWITCH_LOG_INVALID) {
+ listener->level = ltype;
+ switch_set_flag(listener, LFLAG_LOG);
+ }
+ }
switch_thread_rwlock_create(&listener->rwlock, listener->pool);
listener->id = next_id();
listener->timeout = 60;
listener->last_flush = switch_timestamp(NULL);
- if (switch_stristr("xml", format)) {
- listener->format = EVENT_FORMAT_XML;
- } else {
- listener->format = EVENT_FORMAT_PLAIN;
- }
+ if (events) {
- edup = strdup(events);
-
- for (cur = edup; cur; count++) {
- switch_event_types_t type;
-
- if ((next = strchr(cur, ' '))) {
- *next++ = '\0';
+ if (switch_stristr("xml", format)) {
+ listener->format = EVENT_FORMAT_XML;
+ } else {
+ listener->format = EVENT_FORMAT_PLAIN;
}
+
+ edup = strdup(events);
+
+ for (cur = edup; cur; count++) {
+ switch_event_types_t type;
+
+ if ((next = strchr(cur, ' '))) {
+ *next++ = '\0';
+ }
- if (custom) {
- switch_core_hash_insert(listener->event_hash, cur, MARKER);
- } else if (switch_name_event(cur, &type) == SWITCH_STATUS_SUCCESS) {
- key_count++;
- if (type == SWITCH_EVENT_ALL) {
- uint32_t x = 0;
- for (x = 0; x < SWITCH_EVENT_ALL; x++) {
- listener->event_list[x] = 1;
+ if (custom) {
+ switch_core_hash_insert(listener->event_hash, cur, MARKER);
+ } else if (switch_name_event(cur, &type) == SWITCH_STATUS_SUCCESS) {
+ key_count++;
+ if (type == SWITCH_EVENT_ALL) {
+ uint32_t x = 0;
+ for (x = 0; x < SWITCH_EVENT_ALL; x++) {
+ listener->event_list[x] = 1;
+ }
+ }
+ if (type <= SWITCH_EVENT_ALL) {
+ listener->event_list[type] = 1;
+ }
+ if (type == SWITCH_EVENT_CUSTOM) {
+ custom++;
}
}
- if (type <= SWITCH_EVENT_ALL) {
- listener->event_list[type] = 1;
- }
- if (type == SWITCH_EVENT_CUSTOM) {
- custom++;
- }
+
+ cur = next;
}
-
- cur = next;
- }
- switch_safe_free(edup);
+ switch_safe_free(edup);
- if (!key_count) {
- switch_core_hash_destroy(&listener->event_hash);
- switch_core_destroy_memory_pool(&listener->pool);
- stream->write_function(stream, "<data><reply type=\"error\">No keywords supplied</reply></data>\n");
- goto end;
+ if (!key_count) {
+ switch_core_hash_destroy(&listener->event_hash);
+ switch_core_destroy_memory_pool(&listener->pool);
+ stream->write_function(stream, "<data><reply type=\"error\">No keywords supplied</reply></data>\n");
+ goto end;
+ }
}
-
switch_set_flag_locked(listener, LFLAG_EVENTS);
add_listener(listener);
stream->write_function(stream, "<data>\n");
@@ -750,7 +813,38 @@
listener->last_flush = switch_timestamp(NULL);
stream->write_function(stream, "<data>\n <reply type=\"success\">Current Events Follow</reply>\n");
xmlize_listener(listener, stream);
- stream->write_function(stream, "<events>\n");
+
+ if (switch_test_flag(listener, LFLAG_LOG)) {
+ stream->write_function(stream, "<log_data>\n");
+
+ while (switch_queue_trypop(listener->log_queue, &pop) == SWITCH_STATUS_SUCCESS) {
+ switch_log_node_t *dnode = (switch_log_node_t *) pop;
+ int encode_len = (strlen(dnode->data) * 3) + 1;
+ char *encode_buf = malloc(encode_len);
+
+ switch_assert(encode_buf);
+
+ memset(encode_buf, 0, encode_len);
+ switch_url_encode((char *) dnode->data, encode_buf, encode_len);
+
+
+ stream->write_function(stream, "<log log-level=\"%d\" text-channel=\"%d\" log-file=\"%s\" log-func=\"%s\" log-line=\"%d\">%s</log>\n",
+ dnode->level,
+ dnode->channel,
+ dnode->file,
+ dnode->func,
+ dnode->line,
+ encode_buf
+ );
+ free(encode_buf);
+ free(dnode->data);
+ free(dnode);
+ }
+
+ stream->write_function(stream, "</log_data>\n");
+ }
+
+ stream->write_function(stream, "<events>\n");
while (switch_queue_trypop(listener->event_queue, &pop) == SWITCH_STATUS_SUCCESS) {
char *etype;
Modified: freeswitch/trunk/src/switch_event.c
==============================================================================
--- freeswitch/trunk/src/switch_event.c (original)
+++ freeswitch/trunk/src/switch_event.c Wed Dec 31 17:44:23 2008
@@ -930,13 +930,20 @@
static switch_xml_t add_xml_header(switch_xml_t xml, char *name, char *value, int offset)
{
- switch_xml_t header = switch_xml_add_child_d(xml, "header", offset);
-
+ switch_xml_t header = switch_xml_add_child_d(xml, name, offset);
+
if (header) {
- switch_xml_set_attr_d(header, "name", name);
- switch_xml_set_attr_d(header, "value", value);
+ int encode_len = (strlen(value) * 3) + 1;
+ char *encode_buf = malloc(encode_len);
+
+ switch_assert(encode_buf);
+
+ memset(encode_buf, 0, encode_len);
+ switch_url_encode((char *) value, encode_buf, encode_len);
+ switch_xml_set_txt_d(header, encode_buf);
+ free(encode_buf);
}
-
+
return header;
}
@@ -948,6 +955,7 @@
switch_xml_t xml = NULL;
uint32_t off = 0;
va_list ap;
+ switch_xml_t xheaders = NULL;
if (!(xml = switch_xml_new("event"))) {
return xml;
@@ -972,8 +980,11 @@
}
}
- for (hp = event->headers; hp; hp = hp->next) {
- add_xml_header(xml, hp->name, hp->value, off++);
+ if ((xheaders = switch_xml_add_child_d(xml, "headers", off++))) {
+ int hoff = 0;
+ for (hp = event->headers; hp; hp = hp->next) {
+ add_xml_header(xheaders, hp->name, hp->value, hoff++);
+ }
}
if (!switch_strlen_zero(data)) {
@@ -1032,7 +1043,7 @@
switch_event_add_header_string(*event, SWITCH_STACK_BOTTOM, "Event-Date-Local", date);
switch_rfc822_date(date, ts);
switch_event_add_header_string(*event, SWITCH_STACK_BOTTOM, "Event-Date-GMT", date);
- switch_event_add_header(*event, SWITCH_STACK_BOTTOM, "Event-Date-timestamp", "%" SWITCH_UINT64_T_FMT, (uint64_t) ts);
+ switch_event_add_header(*event, SWITCH_STACK_BOTTOM, "Event-Date-Timestamp", "%" SWITCH_UINT64_T_FMT, (uint64_t) ts);
switch_event_add_header_string(*event, SWITCH_STACK_BOTTOM, "Event-Calling-File", switch_cut_path(file));
switch_event_add_header_string(*event, SWITCH_STACK_BOTTOM, "Event-Calling-Function", func);
switch_event_add_header(*event, SWITCH_STACK_BOTTOM, "Event-Calling-Line-Number", "%d", line);
1
0
31 Dec '08
Author: mikej
Date: Wed Dec 31 17:26:30 2008
New Revision: 11039
Log:
fix silly compiler warning caused by freebsd not making int same size as void* on some 64 bit amd (SFSIP-113)
Modified:
freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_kqueue_port.c
Modified: freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_kqueue_port.c
==============================================================================
--- freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_kqueue_port.c (original)
+++ freeswitch/trunk/libs/sofia-sip/libsofia-sip-ua/su/su_kqueue_port.c Wed Dec 31 17:26:30 2008
@@ -242,21 +242,21 @@
i = ser->ser_id;
flags = (wait->events & SU_WAIT_IN) ? EV_ADD : EV_ADD | EV_DISABLE;
- EV_SET(ev, wait->fd, EVFILT_READ, flags, 0, 0, (void *)i);
+ EV_SET(ev, wait->fd, EVFILT_READ, flags, 0, 0, (void *)(intptr_t)i);
if (kevent(self->sup_kqueue, ev, 1, NULL, 0, NULL) == -1) {
SU_DEBUG_0(("kevent((%u, %s, %u, %p)) failed: %s\n",
- wait->fd, "EVFILT_READ", flags, (void *)i, strerror(errno)));
+ wait->fd, "EVFILT_READ", flags, (void *)(intptr_t)i, strerror(errno)));
return -1;
}
flags = (wait->events & SU_WAIT_OUT) ? EV_ADD : EV_ADD | EV_DISABLE;
- EV_SET(ev, wait->fd, EVFILT_WRITE, flags, 0, 0, (void *)i);
+ EV_SET(ev, wait->fd, EVFILT_WRITE, flags, 0, 0, (void *)(intptr_t)i);
if (kevent(self->sup_kqueue, ev, 1, NULL, 0, NULL) == -1) {
int error = errno;
SU_DEBUG_0(("kevent((%u, %s, %u, %p)) failed: %s\n",
- wait->fd, "EVFILT_WRITE", flags, (void *)i, strerror(error)));
+ wait->fd, "EVFILT_WRITE", flags, (void *)(intptr_t)i, strerror(error)));
- EV_SET(ev, wait->fd, EVFILT_READ, EV_DELETE, 0, 0, (void *)i);
+ EV_SET(ev, wait->fd, EVFILT_READ, EV_DELETE, 0, 0, (void *)(intptr_t)i);
kevent(self->sup_kqueue, ev, 1, NULL, 0, NULL);
errno = error;
@@ -294,17 +294,17 @@
wait = ser->ser_wait;
- EV_SET(ev, wait->fd, EVFILT_READ, EV_DELETE, 0, 0, (void *)i);
+ EV_SET(ev, wait->fd, EVFILT_READ, EV_DELETE, 0, 0, (void *)(intptr_t)i);
if (kevent(self->sup_kqueue, ev, 1, NULL, 0, NULL) == -1) {
SU_DEBUG_0(("remove kevent((%u, %s, %s, %p)) failed: %s\n",
- wait->fd, "EVFILT_READ", "EV_DELETE", (void *)i,
+ wait->fd, "EVFILT_READ", "EV_DELETE", (void *)(intptr_t)i,
strerror(errno)));
}
- EV_SET(ev, wait->fd, EVFILT_WRITE, EV_DELETE, 0, 0, (void *)i);
+ EV_SET(ev, wait->fd, EVFILT_WRITE, EV_DELETE, 0, 0, (void *)(intptr_t)i);
if (kevent(self->sup_kqueue, ev, 1, NULL, 0, NULL) == -1) {
SU_DEBUG_0(("remove kevent((%u, %s, %s, %p)) failed: %s\n",
- wait->fd, "EVFILT_WRITE", "EV_DELETE", (void *)i,
+ wait->fd, "EVFILT_WRITE", "EV_DELETE", (void *)(intptr_t)i,
strerror(errno)));
}
@@ -461,21 +461,21 @@
wait->events = events;
flags = (wait->events & SU_WAIT_IN) ? EV_ADD | EV_ENABLE : EV_ADD | EV_DISABLE;
- EV_SET(ev, wait->fd, EVFILT_READ, flags, 0, 0, (void *)index);
+ EV_SET(ev, wait->fd, EVFILT_READ, flags, 0, 0, (void *)(intptr_t)index);
if (kevent(self->sup_kqueue, ev, 1, NULL, 0, NULL) == -1) {
SU_DEBUG_0(("modify kevent((%u, %s, %s, %p)) failed: %s\n",
wait->fd, "EVFILT_READ",
(events & SU_WAIT_IN) ? "EV_ENABLE" : "EV_DISABLE",
- (void *)index, strerror(errno)));
+ (void *)(intptr_t)index, strerror(errno)));
}
flags = (wait->events & SU_WAIT_OUT) ? EV_ADD | EV_ENABLE : EV_ADD | EV_DISABLE;
- EV_SET(ev, wait->fd, EVFILT_WRITE, flags, 0, 0, (void *)index);
+ EV_SET(ev, wait->fd, EVFILT_WRITE, flags, 0, 0, (void *)(intptr_t)index);
if (kevent(self->sup_kqueue, ev, 1, NULL, 0, NULL) == -1) {
SU_DEBUG_0(("modify kevent((%u, %s, %s, %p)) failed: %s\n",
wait->fd, "EVFILT_WRITE",
(events & SU_WAIT_OUT) ? "EV_ENABLE" : "EV_DISABLE",
- (void *)index, strerror(errno)));
+ (void *)(intptr_t)index, strerror(errno)));
}
return 0;
@@ -539,7 +539,7 @@
struct su_register *ser;
su_root_magic_t *magic;
- index = (int)ev[j].udata;
+ index = (int)(intptr_t)ev[j].udata;
if (index <= 0 || self->sup_max_index < index)
continue;
ser = self->sup_indices[index];
1
0
Author: anthm
Date: Wed Dec 31 16:02:22 2008
New Revision: 11038
Log:
fix typo in comment
Modified:
freeswitch/trunk/src/include/switch_types.h
Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h (original)
+++ freeswitch/trunk/src/include/switch_types.h Wed Dec 31 16:02:22 2008
@@ -486,7 +486,7 @@
Always sending a duration of 0 with a new timestamp should be tolerated but is rarely intentional
and is mistakenly done by many devices.
- The issue is that the Sonus expects everyone to do it this way instead of tolerating eiher way.
+ The issue is that the Sonus expects everyone to do it this way instead of tolerating either way.
Sonus will actually ignore every packet with the same timestamp before concluding if it's DTMF.
This flag will cause each packet to have a new timestamp.
1
0
Author: mikej
Date: Wed Dec 31 14:58:52 2008
New Revision: 11037
Log:
fix bsd fs_cli build
Modified:
freeswitch/trunk/libs/esl/fs_cli.c
Modified: freeswitch/trunk/libs/esl/fs_cli.c
==============================================================================
--- freeswitch/trunk/libs/esl/fs_cli.c (original)
+++ freeswitch/trunk/libs/esl/fs_cli.c Wed Dec 31 14:58:52 2008
@@ -1,5 +1,5 @@
#ifndef _XOPEN_SOURCE
-#define _XOPEN_SOURCE 500
+#define _XOPEN_SOURCE 600
#endif
#include <stdio.h>
1
0
Author: anthm
Date: Wed Dec 31 14:44:16 2008
New Revision: 11036
Log:
allow unix build without libedit
Modified:
freeswitch/trunk/libs/esl/Makefile
freeswitch/trunk/libs/esl/fs_cli.c
Modified: freeswitch/trunk/libs/esl/Makefile
==============================================================================
--- freeswitch/trunk/libs/esl/Makefile (original)
+++ freeswitch/trunk/libs/esl/Makefile Wed Dec 31 14:44:16 2008
@@ -2,7 +2,7 @@
LIBEDIT_DIR=../../libs/libedit
DEBUG=-g -ggdb
PICKY=-O2 -ffast-math -Wall -Werror -Wunused-variable -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes
-CFLAGS=$(INCS) $(DEBUG) -I$(LIBEDIT_DIR)/src/ $(PICKY)
+CFLAGS=$(INCS) -DHAVE_EDITLINE $(DEBUG) -I$(LIBEDIT_DIR)/src/ $(PICKY)
MYLIB=libesl.a
LIBS=-lncurses -lpthread -lesl
LDFLAGS=-L.
Modified: freeswitch/trunk/libs/esl/fs_cli.c
==============================================================================
--- freeswitch/trunk/libs/esl/fs_cli.c (original)
+++ freeswitch/trunk/libs/esl/fs_cli.c Wed Dec 31 14:44:16 2008
@@ -16,14 +16,14 @@
#else
#include <sys/select.h>
#include <unistd.h>
-#include <histedit.h>
-#ifndef HAVE_EDITLINE
-#define HAVE_EDITLINE
-#endif
#endif
#include <getopt.h>
+#ifdef HAVE_EDITLINE
+#include <histedit.h>
+#endif
+
static char prompt_str[512] = "";
typedef struct {
1
0