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
December 2008
- 13 participants
- 473 discussions
09 Dec '08
Author: mikej
Date: Tue Dec 9 10:59:07 2008
New Revision: 10678
Log:
fix download filename
Modified:
freeswitch/trunk/src/mod/xml_int/mod_xml_ldap/Makefile
Modified: freeswitch/trunk/src/mod/xml_int/mod_xml_ldap/Makefile
==============================================================================
--- freeswitch/trunk/src/mod/xml_int/mod_xml_ldap/Makefile (original)
+++ freeswitch/trunk/src/mod/xml_int/mod_xml_ldap/Makefile Tue Dec 9 10:59:07 2008
@@ -17,7 +17,7 @@
include $(switch_srcdir)/build/modmake.rules
$(LDAP_DIR):
- $(GETLIB) $(LDAP).tgz
+ $(GETLIB) $(LDAP).tar.gz
cd $(LDAP_DIR) && CFLAGS="`echo $(CFLAGS) | sed -e 's:-std=c99::'`" ./configure $(DEFAULT_ARGS)
$(LIBLUTILA) $(LDAPLA) $(LIBLBERLA): $(LDAP_DIR)
1
0
[commit] r10677 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax
by FreeSWITCH SVN 09 Dec '08
by FreeSWITCH SVN 09 Dec '08
09 Dec '08
Author: gmaruzz
Date: Tue Dec 9 09:35:38 2008
New Revision: 10677
Log:
skypiax: indent -gnu -ts4 -br -brs -cdw -lp -ce -nbfda -npcs -nprs -npsl -nbbo -saf -sai -saw -cs -bbo -nhnl -nut -sob -l90
Modified:
freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c
freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.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 Tue Dec 9 09:35:38 2008
@@ -36,7 +36,6 @@
/*************************************************/
/*************************************************/
-
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, globals.dialplan);
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_string, globals.codec_string);
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_rates_string,
@@ -63,7 +62,6 @@
int stream_id);
static switch_status_t channel_kill_channel(switch_core_session_t * session, int sig);
-
static switch_status_t skypiax_codec(private_t * tech_pvt, int sample_rate, int codec_ms)
{
if (switch_core_codec_init
@@ -93,7 +91,8 @@
}
-void skypiax_tech_init(private_t * tech_pvt, switch_core_session_t * session, skypiax_interface_t * p)
+void skypiax_tech_init(private_t * tech_pvt, switch_core_session_t * session,
+ skypiax_interface_t * p)
{
DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
@@ -539,7 +538,7 @@
{
struct skypiax_interface *p = obj;
int res;
- int forever=1;
+ int forever = 1;
DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
@@ -575,7 +574,6 @@
}
-
static switch_status_t load_config(void)
{
char *cf = "skypiax.conf";
@@ -733,10 +731,10 @@
}
if (interface_id && interface_id < SKYPIAX_MAX_INTERFACES) {
struct skypiax_interface newconf;
- switch_thread_t *do_skype_thread_thread;
- switch_threadattr_t *do_skype_thd_attr = NULL;
- switch_thread_t *skypiax_do_controldev_thread_thread;
- switch_threadattr_t *skypiax_do_controldev_thread_thd_attr = NULL;
+ switch_thread_t *do_skype_thread_thread;
+ switch_threadattr_t *do_skype_thd_attr = NULL;
+ switch_thread_t *skypiax_do_controldev_thread_thread;
+ switch_threadattr_t *skypiax_do_controldev_thread_thd_attr = NULL;
memset(&newconf, '\0', sizeof(newconf));
SKYPIAX_INTERFACES[interface_id] = newconf;
@@ -766,20 +764,23 @@
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(&do_skype_thread_thread, do_skype_thd_attr, do_skype_thread,
- &SKYPIAX_INTERFACES[interface_id], skypiax_module_pool);
+ 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(&do_skype_thread_thread, do_skype_thd_attr, do_skype_thread,
+ &SKYPIAX_INTERFACES[interface_id], skypiax_module_pool);
switch_sleep(100000);
- switch_threadattr_create(&skypiax_do_controldev_thread_thd_attr, skypiax_module_pool);
- 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(&skypiax_do_controldev_thread_thread, skypiax_do_controldev_thread_thd_attr, skypiax_do_controldev_thread,
- &SKYPIAX_INTERFACES[interface_id], skypiax_module_pool);
+ switch_threadattr_create(&skypiax_do_controldev_thread_thd_attr,
+ skypiax_module_pool);
+ 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(&skypiax_do_controldev_thread_thread,
+ skypiax_do_controldev_thread_thd_attr,
+ skypiax_do_controldev_thread,
+ &SKYPIAX_INTERFACES[interface_id], skypiax_module_pool);
switch_sleep(1000000);
@@ -832,7 +833,7 @@
memset(&globals, '\0', sizeof(globals));
memset(SKYPIAX_INTERFACES, '\0', sizeof(SKYPIAX_INTERFACES));
-#ifndef WIN32 //FIXME
+#ifndef WIN32 //FIXME
if (!XInitThreads()) {
ERRORA("Not initialized XInitThreads!\n", SKYPIAX_P_LOG);
} else {
@@ -850,7 +851,7 @@
skypiax_endpoint_interface->io_routines = &skypiax_io_routines;
skypiax_endpoint_interface->state_handler = &skypiax_state_handlers;
- DEBUGA_SKYPE("EXITING FUNC!\n", SKYPIAX_P_LOG);
+ DEBUGA_SKYPE("EXITING FUNC!\n", SKYPIAX_P_LOG);
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}
@@ -934,4 +935,3 @@
* For VIM:
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
*/
-
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 Tue Dec 9 09:35:38 2008
@@ -44,7 +44,6 @@
//FIXME include?
#endif //WIN32
-
#define SKYPIAX_SVN_VERSION "SVN 123456"
typedef enum {
@@ -63,7 +62,6 @@
GFLAG_MY_CODEC_PREFS = (1 << 0)
} GFLAGS;
-
#define DEBUGA_SKYPE(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_SKYPE %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ );
#define DEBUGA_CALL(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_CALL %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ );
#define DEBUGA_PBX(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_PBX %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ );
@@ -209,9 +207,9 @@
typedef struct private_object private_t;
-
void *SWITCH_THREAD_FUNC do_skype_thread(switch_thread_t * thread, void *obj);
-void skypiax_tech_init(private_t * tech_pvt, switch_core_session_t * session, skypiax_interface_t * p);
+void skypiax_tech_init(private_t * tech_pvt, switch_core_session_t * session,
+ skypiax_interface_t * p);
switch_status_t skypiax_skypeaudio_read(private_t * tech_pvt);
int skypiax_skypeaudio_init(struct skypiax_interface *p);
int skypiax_skype_write(struct skypiax_interface *p, char *msg_to_skype);
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 Tue Dec 9 09:35:38 2008
@@ -303,7 +303,9 @@
switch_status_t rv;
- rv = switch_file_pipe_create_ex(&p->audiopipe[0], &p->audiopipe[1], 2, skypiax_module_pool);
+ rv =
+ switch_file_pipe_create_ex(&p->audiopipe[0], &p->audiopipe[1], 2,
+ skypiax_module_pool);
rv = switch_file_pipe_timeout_set(p->audiopipe[0], 100000);
/* the pipe is our audio fd for pbx to poll on */
@@ -318,6 +320,7 @@
}
return 0;
}
+
switch_status_t skypiax_skypeaudio_read(private_t * tech_pvt)
{
struct skypiax_interface *p;
@@ -862,7 +865,6 @@
}
#endif // WIN32
-
int skypiax_skype_write(struct skypiax_interface *p, char *msg_to_skype)
{
#ifdef WIN32
@@ -963,8 +965,8 @@
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);
+ 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",
@@ -1092,8 +1094,8 @@
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_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);
@@ -1123,7 +1125,7 @@
if (p->interface_state != SKYPIAX_STATE_DIALING) {
/* we are not calling out */
- if (1) { //FIXME
+ if (1) { //FIXME
/* we are not inside an active call */
p->skype_callflow = CALLFLOW_STATUS_RINGING;
p->interface_state = SKYPIAX_STATE_RING;
@@ -1260,10 +1262,10 @@
DEBUGA_SKYPE("skype_call: %s SKYPIAX_CONTROL_ANSWER sent\n",
SKYPIAX_P_LOG, id);
- if (1) { //FIXME
+ if (1) { //FIXME
char msg_to_skype[1024];
- if (1) { //FIXME
+ if (1) { //FIXME
switch_threadattr_t *thd_attr = NULL;
switch_threadattr_create(&thd_attr, skypiax_module_pool);
@@ -1380,5 +1382,3 @@
//DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
return 0;
}
-
-
1
0
[commit] r10676 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax
by FreeSWITCH SVN 09 Dec '08
by FreeSWITCH SVN 09 Dec '08
09 Dec '08
Author: gmaruzz
Date: Tue Dec 9 09:33:55 2008
New Revision: 10676
Log:
skypiax: less warnings on windows
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 Tue Dec 9 09:33:55 2008
@@ -1,6 +1,5 @@
#include "skypiax.h"
-
extern switch_memory_pool_t *skypiax_module_pool;
extern int option_debug;
extern switch_core_session_t *global_session;
@@ -16,21 +15,26 @@
void *obj)
{
struct skypiax_interface *p = obj;
- short in[GG];
short out[GG / 2];
- int s, len;
+ int s;
#ifdef WIN32
+ unsigned int len;
+ unsigned int i;
+ unsigned int a;
+ char in[GG];
int sin_size;
unsigned int fd;
#else
+ int len;
+ int i;
+ int a;
+ short in[GG];
unsigned int sin_size;
int fd;
#endif /* WIN32 */
struct sockaddr_in my_addr;
struct sockaddr_in remote_addr;
int exit = 0;
- int a;
- int i;
unsigned int kill_cli_size;
short kill_cli_buff[320];
@@ -171,15 +175,27 @@
//void *skypiax_do_tcp_cli_thread(void *data)
{
struct skypiax_interface *p = obj;
- int s, fd, len;
- short in[NN / 2];
- short out[NN];
- unsigned int sin_size;
+ int s;
struct sockaddr_in my_addr;
struct sockaddr_in remote_addr;
- int a;
- int i;
unsigned int got;
+#ifdef WIN32
+ unsigned int len;
+ unsigned int i;
+ unsigned int a;
+ char in[NN / 2];
+ char out[NN];
+ int sin_size;
+ unsigned int fd;
+#else
+ int len;
+ int i;
+ int a;
+ short in[NN / 2];
+ short out[NN];
+ unsigned int sin_size;
+ int fd;
+#endif /* WIN32 */
if (option_debug > 10) {
WARNINGA("ENTERING FUNC\n", SKYPIAX_P_LOG);
@@ -219,7 +235,11 @@
while (p->interface_state != SKYPIAX_STATE_DOWN
&& (p->skype_callflow == CALLFLOW_STATUS_INPROGRESS
|| p->skype_callflow == SKYPIAX_STATE_UP)) {
+#ifdef WIN32
+ unsigned int fdselect;
+#else
int fdselect;
+#endif /* WIN32 */
int rt;
fd_set fs;
struct timeval to;
@@ -918,8 +938,9 @@
int rt;
//fd_set fs;
//struct timeval to;
- int i, a;
+ int a;
unsigned int howmany;
+ unsigned int i;
if (option_debug > 100) {
DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
1
0
[commit] r10675 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax
by FreeSWITCH SVN 09 Dec '08
by FreeSWITCH SVN 09 Dec '08
09 Dec '08
Author: gmaruzz
Date: Tue Dec 9 06:41:55 2008
New Revision: 10675
Log:
skypiax: works on linux
Modified:
freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.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 Tue Dec 9 06:41:55 2008
@@ -825,14 +825,14 @@
SWITCH_MODULE_LOAD_FUNCTION(mod_skypiax_load)
{
- //struct skypiax_interface *p = NULL;
+ struct skypiax_interface *p = NULL;
skypiax_module_pool = pool;
memset(&globals, '\0', sizeof(globals));
memset(SKYPIAX_INTERFACES, '\0', sizeof(SKYPIAX_INTERFACES));
-#ifndef _WINDOWS_ //FIXME
+#ifndef WIN32 //FIXME
if (!XInitThreads()) {
ERRORA("Not initialized XInitThreads!\n", SKYPIAX_P_LOG);
} else {
@@ -850,6 +850,7 @@
skypiax_endpoint_interface->io_routines = &skypiax_io_routines;
skypiax_endpoint_interface->state_handler = &skypiax_state_handlers;
+ DEBUGA_SKYPE("EXITING FUNC!\n", SKYPIAX_P_LOG);
/* indicate that the module should continue to be loaded */
return SWITCH_STATUS_SUCCESS;
}
1
0
[commit] r10674 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax
by FreeSWITCH SVN 09 Dec '08
by FreeSWITCH SVN 09 Dec '08
09 Dec '08
Author: gmaruzz
Date: Tue Dec 9 06:39:00 2008
New Revision: 10674
Log:
skypiax: less warnings on windows
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 Tue Dec 9 06:39:00 2008
@@ -1,6 +1,5 @@
#include "skypiax.h"
-
SWITCH_MODULE_LOAD_FUNCTION(mod_skypiax_load);
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypiax_shutdown);
//SWITCH_MODULE_RUNTIME_FUNCTION(mod_skypiax_runtime);
@@ -540,16 +539,16 @@
{
struct skypiax_interface *p = obj;
int res;
+ int forever=1;
DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
DEBUGA_SKYPE("In skypiax_do_controldev_thread: started, p=%p\n", SKYPIAX_P_LOG,
(void *) p);
- while (1) {
+ while (forever) {
switch_sleep(1000);
res = skypiax_skype_read(p);
-#if 1
//if (res == CALLFLOW_INCOMING_HANGUP && p->interface_state != SKYPIAX_STATE_DOWN)
if (res == CALLFLOW_INCOMING_HANGUP) {
switch_core_session_t *session = NULL;
@@ -566,10 +565,7 @@
switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
DEBUGA_SKYPE("after channel_on_hangup\n", SKYPIAX_P_LOG);
-
- //DEBUGA_SKYPE("set state to CS_HANGUP\n", SKYPIAX_P_LOG);
}
-#endif
}
//if (option_debug > 10) {
@@ -737,6 +733,11 @@
}
if (interface_id && interface_id < SKYPIAX_MAX_INTERFACES) {
struct skypiax_interface newconf;
+ switch_thread_t *do_skype_thread_thread;
+ switch_threadattr_t *do_skype_thd_attr = NULL;
+ switch_thread_t *skypiax_do_controldev_thread_thread;
+ switch_threadattr_t *skypiax_do_controldev_thread_thd_attr = NULL;
+
memset(&newconf, '\0', sizeof(newconf));
SKYPIAX_INTERFACES[interface_id] = newconf;
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG,
@@ -765,28 +766,20 @@
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO,
"STARTING interface_id=%d\n", interface_id);
- if (1) {
- switch_thread_t *thread;
- 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(&thread, thd_attr, do_skype_thread,
+
+ 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(&do_skype_thread_thread, do_skype_thd_attr, do_skype_thread,
&SKYPIAX_INTERFACES[interface_id], skypiax_module_pool);
- }
switch_sleep(100000);
- if (1) {
- switch_thread_t *thread;
- 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(&thread, thd_attr, skypiax_do_controldev_thread,
+
+ switch_threadattr_create(&skypiax_do_controldev_thread_thd_attr, skypiax_module_pool);
+ 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(&skypiax_do_controldev_thread_thread, skypiax_do_controldev_thread_thd_attr, skypiax_do_controldev_thread,
&SKYPIAX_INTERFACES[interface_id], skypiax_module_pool);
- }
switch_sleep(1000000);
@@ -832,7 +825,7 @@
SWITCH_MODULE_LOAD_FUNCTION(mod_skypiax_load)
{
- struct skypiax_interface *p = NULL;
+ //struct skypiax_interface *p = NULL;
skypiax_module_pool = pool;
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 Tue Dec 9 06:39:00 2008
@@ -1,4 +1,6 @@
#include "skypiax.h"
+
+
extern switch_memory_pool_t *skypiax_module_pool;
extern int option_debug;
extern switch_core_session_t *global_session;
@@ -16,8 +18,14 @@
struct skypiax_interface *p = obj;
short in[GG];
short out[GG / 2];
- int s, fd, len;
+ int s, len;
+#ifdef WIN32
+ int sin_size;
+ unsigned int fd;
+#else
unsigned int sin_size;
+ int fd;
+#endif /* WIN32 */
struct sockaddr_in my_addr;
struct sockaddr_in remote_addr;
int exit = 0;
@@ -60,7 +68,11 @@
&& (p->skype_callflow == CALLFLOW_STATUS_INPROGRESS
|| p->skype_callflow == SKYPIAX_STATE_UP)) {
+#ifdef WIN32
+ unsigned int fdselect;
+#else
int fdselect;
+#endif /* WIN32 */
int rt;
fd_set fs;
struct timeval to;
@@ -1090,7 +1102,7 @@
if (p->interface_state != SKYPIAX_STATE_DIALING) {
/* we are not calling out */
- if (1) {
+ if (1) { //FIXME
/* we are not inside an active call */
p->skype_callflow = CALLFLOW_STATUS_RINGING;
p->interface_state = SKYPIAX_STATE_RING;
@@ -1227,10 +1239,10 @@
DEBUGA_SKYPE("skype_call: %s SKYPIAX_CONTROL_ANSWER sent\n",
SKYPIAX_P_LOG, id);
- if (1) {
+ if (1) { //FIXME
char msg_to_skype[1024];
- if (1) {
+ if (1) { //FIXME
switch_threadattr_t *thd_attr = NULL;
switch_threadattr_create(&thd_attr, skypiax_module_pool);
1
0
[commit] r10673 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax
by FreeSWITCH SVN 09 Dec '08
by FreeSWITCH SVN 09 Dec '08
09 Dec '08
Author: gmaruzz
Date: Tue Dec 9 05:56:50 2008
New Revision: 10673
Log:
skypiax: updated Makefile, works
Modified:
freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/Makefile
freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c
Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/Makefile
==============================================================================
--- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/Makefile (original)
+++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/Makefile Tue Dec 9 05:56:50 2008
@@ -1,3 +1,4 @@
MODNAME=mod_skypiax
LOCAL_LDFLAGS=-lX11
+LOCAL_OBJS=skypiax_protocol.o
include ../../../../build/modmake.rules
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 Tue Dec 9 05:56:50 2008
@@ -703,7 +703,7 @@
switch_sleep(1000);
}
-static void *SWITCH_THREAD_FUNC do_skype_thread(switch_thread_t * thread, void *obj)
+void *SWITCH_THREAD_FUNC do_skype_thread(switch_thread_t * thread, void *obj)
{
struct skypiax_interface *p;
1
0
[commit] r10672 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax
by FreeSWITCH SVN 09 Dec '08
by FreeSWITCH SVN 09 Dec '08
09 Dec '08
Author: gmaruzz
Date: Tue Dec 9 05:52:03 2008
New Revision: 10672
Log:
skypiax: continuing files structuring
Added:
freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c
Modified:
freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.2008.vcproj
freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c
freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h
Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.2008.vcproj
==============================================================================
--- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.2008.vcproj (original)
+++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.2008.vcproj Tue Dec 9 05:52:03 2008
@@ -153,6 +153,10 @@
RelativePath=".\skypiax.h"
>
</File>
+ <File
+ RelativePath=".\skypiax_protocol.c"
+ >
+ </File>
</Files>
<Globals>
</Globals>
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 Tue Dec 9 05:52:03 2008
@@ -6,26 +6,6 @@
//SWITCH_MODULE_RUNTIME_FUNCTION(mod_skypiax_runtime);
SWITCH_MODULE_DEFINITION(mod_skypiax, mod_skypiax_load, mod_skypiax_shutdown, NULL); //mod_skypiax_runtime);
-switch_endpoint_interface_t *skypiax_endpoint_interface;
-static switch_memory_pool_t *module_pool = NULL;
-static int running = 1;
-
-typedef enum {
- TFLAG_IO = (1 << 0),
- TFLAG_INBOUND = (1 << 1),
- TFLAG_OUTBOUND = (1 << 2),
- TFLAG_DTMF = (1 << 3),
- TFLAG_VOICE = (1 << 4),
- TFLAG_HANGUP = (1 << 5),
- TFLAG_LINEAR = (1 << 6),
- TFLAG_CODEC = (1 << 7),
- TFLAG_BREAK = (1 << 8)
-} TFLAGS;
-
-typedef enum {
- GFLAG_MY_CODEC_PREFS = (1 << 0)
-} GFLAGS;
-
static struct {
int debug;
char *ip;
@@ -44,13 +24,18 @@
switch_mutex_t *mutex;
} globals;
-static skypiax_interface_t SKYPIAX_INTERFACES[SKYPIAX_MAX_INTERFACES];
-
+/*************************************************/
+/*************************************************/
+/*************************************************/
int option_debug = 100;
+switch_endpoint_interface_t *skypiax_endpoint_interface;
+switch_memory_pool_t *skypiax_module_pool = NULL;
+static int running = 1;
+static skypiax_interface_t SKYPIAX_INTERFACES[SKYPIAX_MAX_INTERFACES];
switch_core_session_t *global_session = NULL;
-
-
-
+/*************************************************/
+/*************************************************/
+/*************************************************/
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, globals.dialplan);
@@ -80,252 +65,6 @@
static switch_status_t channel_kill_channel(switch_core_session_t * session, int sig);
-#ifdef WIN32
-#ifdef WIN32
-struct AsteriskHandles *win32_AsteriskHandlesSkype;
-HWND win32_hInit_MainWindowHandle;
-HINSTANCE win32_hInit_ProcessHandle;
-char win32_acInit_WindowClassName[128];
-HANDLE win32_hGlobal_ThreadShutdownEvent;
-UINT win32_uiGlobal_MsgID_SkypeControlAPIAttach;
-UINT win32_uiGlobal_MsgID_SkypeControlAPIDiscover;
-HWND win32_hGlobal_SkypeAPIWindowHandle = NULL;
-DWORD win32_ulGlobal_PromptConsoleMode = 0;
-HANDLE volatile win32_hGlobal_PromptConsoleHandle = NULL;
-
-enum {
- SKYPECONTROLAPI_ATTACH_SUCCESS = 0, /* Client is successfully
- attached and API window handle can be found
- in wParam parameter */
- SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION = 1, /* Skype has acknowledged
- connection request and is waiting
- for confirmation from the user. */
- /* The client is not yet attached
- * and should wait for SKYPECONTROLAPI_ATTACH_SUCCESS message */
- SKYPECONTROLAPI_ATTACH_REFUSED = 2, /* User has explicitly
- denied access to client */
- SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE = 3, /* API is not available
- at the moment.
- For example, this happens when no user
- is currently logged in. */
- /* Client should wait for
- * SKYPECONTROLAPI_ATTACH_API_AVAILABLE
- * broadcast before making any further */
- /* connection attempts. */
- SKYPECONTROLAPI_ATTACH_API_AVAILABLE = 0x8001
-};
-
-char
- *strsep(char **stringp, const char *delim)
-{
- char *res;
-
- if (!stringp || !*stringp || !**stringp)
- return (char *) 0;
-
- res = *stringp;
- while (**stringp && !strchr(delim, **stringp))
- ++(*stringp);
-
- if (**stringp) {
- **stringp = '\0';
- ++(*stringp);
- }
-
- return res;
-}
-
-LRESULT APIENTRY skypiax_skype_present(HWND hWindow, UINT uiMessage, WPARAM uiParam,
- LPARAM ulParam)
-{
- LRESULT lReturnCode;
- int fIssueDefProc;
- struct skypiax_interface *p = NULL;
-
- lReturnCode = 0;
- fIssueDefProc = 0;
- switch (uiMessage) {
- case WM_DESTROY:
- win32_hInit_MainWindowHandle = NULL;
- PostQuitMessage(0);
- break;
- case WM_COPYDATA:
- if (win32_hGlobal_SkypeAPIWindowHandle == (HWND) uiParam) {
- unsigned int howmany;
- char msg_from_skype[2048];
-
- PCOPYDATASTRUCT poCopyData = (PCOPYDATASTRUCT) ulParam;
-
- memset(msg_from_skype, '\0', sizeof(msg_from_skype));
- strncpy(msg_from_skype, (const char *) poCopyData->lpData,
- sizeof(msg_from_skype) - 2);
-
- howmany = strlen(msg_from_skype) + 1;
- switch_file_write(win32_AsteriskHandlesSkype->fdesc[1], msg_from_skype, &howmany);
- NOTICA("From Skype API: %s\n", SKYPIAX_P_LOG, (const char *) poCopyData->lpData);
- lReturnCode = 1;
- }
- break;
- default:
- if (uiMessage == win32_uiGlobal_MsgID_SkypeControlAPIAttach) {
- switch (ulParam) {
- case SKYPECONTROLAPI_ATTACH_SUCCESS:
- NOTICA("\n\n\tConnected to Skype API!\n", SKYPIAX_P_LOG);
- win32_hGlobal_SkypeAPIWindowHandle = (HWND) uiParam;
- switch_sleep(5000);
- win32_AsteriskHandlesSkype->win32_hGlobal_SkypeAPIWindowHandle =
- win32_hGlobal_SkypeAPIWindowHandle;
- break;
- case SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION:
- WARNINGA
- ("\n\n\tIf I do not 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);
- 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 available\n", SKYPIAX_P_LOG);
- break;
- case SKYPECONTROLAPI_ATTACH_API_AVAILABLE:
- DEBUGA_SKYPE("Skype API available\n", SKYPIAX_P_LOG);
- break;
- default:
- WARNINGA("GOT AN UNKNOWN SKYPE WINDOWS MSG\n", SKYPIAX_P_LOG);
- }
- lReturnCode = 1;
- break;
- }
- fIssueDefProc = 1;
- break;
- }
- if (fIssueDefProc)
- lReturnCode = DefWindowProc(hWindow, uiMessage, uiParam, ulParam);
- return (lReturnCode);
-}
-
-int win32_Initialize_CreateWindowClass(void)
-{
- unsigned char *paucUUIDString;
- RPC_STATUS lUUIDResult;
- int fReturnStatus;
- UUID oUUID;
-
- fReturnStatus = 0;
- lUUIDResult = UuidCreate(&oUUID);
- win32_hInit_ProcessHandle =
- (HINSTANCE) OpenProcess(PROCESS_DUP_HANDLE, FALSE, GetCurrentProcessId());
- if (win32_hInit_ProcessHandle != NULL
- && (lUUIDResult == RPC_S_OK || lUUIDResult == RPC_S_UUID_LOCAL_ONLY)) {
- if (UuidToString(&oUUID, &paucUUIDString) == RPC_S_OK) {
- WNDCLASS oWindowClass;
-
- strcpy(win32_acInit_WindowClassName, "Skype-API-Skypiax-");
- strcat(win32_acInit_WindowClassName, (char *) paucUUIDString);
-
- oWindowClass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
- oWindowClass.lpfnWndProc = (WNDPROC) & skypiax_skype_present;
- oWindowClass.cbClsExtra = 0;
- oWindowClass.cbWndExtra = 0;
- oWindowClass.hInstance = win32_hInit_ProcessHandle;
- oWindowClass.hIcon = NULL;
- oWindowClass.hCursor = NULL;
- oWindowClass.hbrBackground = NULL;
- oWindowClass.lpszMenuName = NULL;
- oWindowClass.lpszClassName = win32_acInit_WindowClassName;
-
- if (RegisterClass(&oWindowClass) != 0)
- fReturnStatus = 1;
-
- RpcStringFree(&paucUUIDString);
- }
- }
- if (fReturnStatus == 0)
- CloseHandle(win32_hInit_ProcessHandle), win32_hInit_ProcessHandle = NULL;
- return (fReturnStatus);
-}
-
-void win32_DeInitialize_DestroyWindowClass(void)
-{
- UnregisterClass(win32_acInit_WindowClassName, win32_hInit_ProcessHandle);
- CloseHandle(win32_hInit_ProcessHandle), win32_hInit_ProcessHandle = NULL;
-}
-
-int win32_Initialize_CreateMainWindow(void)
-{
- win32_hInit_MainWindowHandle =
- CreateWindowEx(WS_EX_APPWINDOW | WS_EX_WINDOWEDGE, win32_acInit_WindowClassName, "",
- WS_BORDER | WS_SYSMENU | WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT,
- 128, 128, NULL, 0, win32_hInit_ProcessHandle, 0);
- return (win32_hInit_MainWindowHandle != NULL ? 1 : 0);
-}
-
-void win32_DeInitialize_DestroyMainWindow(void)
-{
- if (win32_hInit_MainWindowHandle != NULL)
- DestroyWindow(win32_hInit_MainWindowHandle), win32_hInit_MainWindowHandle = NULL;
-}
-
-DWORD win32_dwThreadId;
-
-static void *SWITCH_THREAD_FUNC do_skype_thread(switch_thread_t * thread, void *obj)
-{
- /* create window class */
- /* create dummy/hidden window for processing messages */
- /* run message loop thread */
- /* do application control until exit */
- /* exit: send QUIT message to our own window */
- /* wait until thred terminates */
- /* destroy main window */
- /* destroy window class */
-
- struct skypiax_interface *p;
- p = obj;
-
- switch_file_pipe_create_ex(&p->AsteriskHandlesAst.fdesc[0],
- &p->AsteriskHandlesAst.fdesc[1], 2, module_pool);
-
- win32_AsteriskHandlesSkype = &p->AsteriskHandlesAst;
-
- win32_uiGlobal_MsgID_SkypeControlAPIAttach =
- RegisterWindowMessage("SkypeControlAPIAttach");
- win32_uiGlobal_MsgID_SkypeControlAPIDiscover =
- RegisterWindowMessage("SkypeControlAPIDiscover");
-
- if (win32_uiGlobal_MsgID_SkypeControlAPIAttach != 0
- && win32_uiGlobal_MsgID_SkypeControlAPIDiscover != 0) {
- if (win32_Initialize_CreateWindowClass()) {
- if (win32_Initialize_CreateMainWindow()) {
- win32_hGlobal_ThreadShutdownEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
- if (win32_hGlobal_ThreadShutdownEvent != NULL) {
- if (SendMessage
- (HWND_BROADCAST, win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
- (WPARAM) win32_hInit_MainWindowHandle, 0) != 0) {
- win32_AsteriskHandlesSkype->win32_hInit_MainWindowHandle =
- win32_hInit_MainWindowHandle;
- while (1) {
- MSG oMessage;
-
- while (GetMessage(&oMessage, 0, 0, 0) != FALSE) {
- TranslateMessage(&oMessage);
- DispatchMessage(&oMessage);
- }
- }
- }
- CloseHandle(win32_hGlobal_ThreadShutdownEvent);
- }
- win32_DeInitialize_DestroyMainWindow();
- }
- win32_DeInitialize_DestroyWindowClass();
- }
- }
- return NULL;
-}
-
-#endif /* WIN32 */
-
-#endif //WIN32
-
static switch_status_t skypiax_codec(private_t * tech_pvt, int sample_rate, int codec_ms)
{
if (switch_core_codec_init
@@ -355,332 +94,7 @@
}
-#define SKYPE_AUDIO
-#ifdef SKYPE_AUDIO
-
-#define SAMPLES_PER_FRAME 160
-#define NN 160
-#define GG 160
-static void *SWITCH_THREAD_FUNC skypiax_do_tcp_srv_thread(switch_thread_t * thread,
- void *obj)
-{
- struct skypiax_interface *p = obj;
- short in[GG];
- short out[GG / 2];
- int s, fd, len;
- unsigned int sin_size;
- struct sockaddr_in my_addr;
- struct sockaddr_in remote_addr;
- int exit = 0;
- int a;
- int i;
- unsigned int kill_cli_size;
- short kill_cli_buff[320];
-
- if (option_debug > 10) {
- WARNINGA("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(5556); //FIXME configurable!
-
- if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
- ERRORA("socket Error\n", SKYPIAX_P_LOG);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
- return NULL;
- }
-
- if (bind(s, (struct sockaddr *) &my_addr, sizeof(struct sockaddr)) < 0) {
- ERRORA("bind Error\n", SKYPIAX_P_LOG);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
- return NULL;
- }
- DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG);
-
- listen(s, 6);
-
- sin_size = sizeof(remote_addr);
- while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) {
- DEBUGA_SKYPE("ACCEPTED\n", SKYPIAX_P_LOG);
- while (p->interface_state != SKYPIAX_STATE_DOWN
- && (p->skype_callflow == CALLFLOW_STATUS_INPROGRESS
- || p->skype_callflow == SKYPIAX_STATE_UP)) {
-
- int fdselect;
- int rt;
- fd_set fs;
- struct timeval to;
-
- exit = 1;
-
- fdselect = fd;
- FD_ZERO(&fs);
- FD_SET(fdselect, &fs);
- to.tv_usec = 100;
- to.tv_sec = 0;
- rt = select(fdselect + 1, &fs, NULL, NULL, &to);
- if (rt > 0) {
-
- len = recv(fd, in, sizeof(short) * GG, 0);
- //DEBUGA_SKYPE("recv %d\n", SKYPIAX_P_LOG, len);
- if (len > 0) {
- a = 0;
- for (i = 0; i < len / sizeof(short); i++) {
- out[a] = in[i];
- i++;
- a++;
- }
-
- if (!p->audiobuf_is_loaded) {
- for (i = 0; i < (len / sizeof(short)) / 2; i++) {
- p->audiobuf[i] = out[i];
- }
- p->audiobuf_is_loaded = 1;
- } else {
- unsigned int howmany;
- short totalbuf[GG];
-
- 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] = out[a];
- i++;
- }
-
- howmany = len;
-
- switch_file_write(p->audiopipe[1], totalbuf, &howmany);
- p->audiobuf_is_loaded = 0;
- //DEBUGA_SKYPE("read=====> req=%d recv=%d to sent=%d sent=%d\n", SKYPIAX_P_LOG, sizeof(short)*GG, len, (len*sizeof(short))/2, howmany);
- }
-
- } else if (len == 0) {
- DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG);
- break;
- } else {
- ERRORA("len=%d\n", SKYPIAX_P_LOG, len);
- exit = 1;
- break;
- }
- }
- }
-
- kill_cli_size = 320;
- switch_file_write(p->audiopipe[1], kill_cli_buff, &kill_cli_size);
- kill_cli_size = 320;
- switch_file_write(p->audioskypepipe[1], kill_cli_buff, &kill_cli_size);
- p->interface_state = SKYPIAX_STATE_DOWN;
- kill_cli_size = 320;
- switch_file_write(p->audiopipe[1], kill_cli_buff, &kill_cli_size);
- kill_cli_size = 320;
- switch_file_write(p->audioskypepipe[1], kill_cli_buff, &kill_cli_size);
-
- DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG);
-
-#ifndef WIN32
- close(fd);
-#else
- closesocket(fd);
-#endif
- if (exit)
- break;
- }
-
- WARNINGA("server (I am it) GONE\n", SKYPIAX_P_LOG);
-#ifndef WIN32
- close(s);
-#else
- closesocket(s);
-#endif
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
- return NULL;
-}
-static void *SWITCH_THREAD_FUNC skypiax_do_tcp_cli_thread(switch_thread_t * thread,
- void *obj)
-//void *skypiax_do_tcp_cli_thread(void *data)
-{
- struct skypiax_interface *p = obj;
- int s, fd, len;
- short in[NN / 2];
- short out[NN];
- unsigned int sin_size;
- struct sockaddr_in my_addr;
- struct sockaddr_in remote_addr;
- int a;
- int i;
- unsigned int got;
-
- if (option_debug > 10) {
- WARNINGA("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(5558); //FIXME configurable!
-
- if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
- ERRORA("socket Error\n", SKYPIAX_P_LOG);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
- return NULL;
- }
-
- if (bind(s, (struct sockaddr *) &my_addr, sizeof(struct sockaddr)) < 0) {
- ERRORA("bind Error\n", SKYPIAX_P_LOG);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
-#ifndef WIN32
- close(s);
-#else
- closesocket(s);
-#endif
- return NULL;
- }
- DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
-
- listen(s, 6);
-
- sin_size = sizeof(remote_addr);
- while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) {
- DEBUGA_SKYPE("ACCEPTED\n", SKYPIAX_P_LOG);
- while (p->interface_state != SKYPIAX_STATE_DOWN
- && (p->skype_callflow == CALLFLOW_STATUS_INPROGRESS
- || p->skype_callflow == SKYPIAX_STATE_UP)) {
- int fdselect;
- int rt;
- fd_set fs;
- struct timeval to;
-
- fdselect = 1;
- FD_ZERO(&fs);
- FD_SET(fdselect, &fs);
- to.tv_usec = 100;
- to.tv_sec = 0;
- rt = 1;
- if (rt > 0) {
-
- got = (NN / 2) * sizeof(short);
- switch_file_read(p->audioskypepipe[0], in, &got);
-
- if (got > 0) {
- a = 0;
- for (i = 0; i < got / sizeof(short); i++) {
- out[a] = in[i];
- a++;
- out[a] = in[i];
- a++;
- }
-
- len = send(fd, out, got * 2, 0);
-
- if (len == 0) {
- ERRORA("Skype server GONE\n", SKYPIAX_P_LOG);
- break;
- }
- } else {
- switch_sleep(1000);
- //ERRORA("Audio skype pipe give us: %u\n", SKYPIAX_P_LOG, got);
- }
- }
-
- }
- ERRORA("Skype server GONE\n", SKYPIAX_P_LOG);
-#ifndef WIN32
- close(fd);
-#else
- closesocket(fd);
-#endif
- break;
- }
-
- WARNINGA("client (I am it) GONE\n", SKYPIAX_P_LOG);
-#ifndef WIN32
- close(s);
-#else
- closesocket(s);
-#endif
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
- return NULL;
-}
-
-int skypiax_skypeaudio_init(struct skypiax_interface *p)
-{
-
- switch_status_t rv;
-
- rv = switch_file_pipe_create_ex(&p->audiopipe[0], &p->audiopipe[1], 2, module_pool);
- rv = switch_file_pipe_timeout_set(p->audiopipe[0], 100000);
-
-/* the pipe is our audio fd for pbx to poll on */
- p->skypiax_sound_capt_fd = p->audiopipe[0];
-
- rv =
- switch_file_pipe_create_ex(&p->audioskypepipe[0], &p->audioskypepipe[1], 2,
- module_pool);
- rv = switch_file_pipe_timeout_set(p->audioskypepipe[0], 100);
- if (option_debug > 10) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
- return 0;
-}
-static switch_status_t skypiax_skypeaudio_read(private_t * tech_pvt)
-{
- struct skypiax_interface *p;
- short buf[640];
- unsigned int samples;
- int rt;
-
- p = tech_pvt->p;
-
- //DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-
- memset(buf, '\0', sizeof(buf));
-
- rt = 1;
- if (rt > 0) {
-
- samples = SAMPLES_PER_FRAME * sizeof(short);
-
- switch_file_read(p->audiopipe[0], tech_pvt->read_frame.data, &samples);
-
- //if ((samples = read(p->audiopipe[0], buf, SAMPLES_PER_FRAME * sizeof(short))) != 320)
- if (samples != SAMPLES_PER_FRAME * sizeof(short)) {
- if (samples)
- DEBUGA_SKYPE("read=====> NOT GOOD samples=%d expected=%d\n", SKYPIAX_P_LOG,
- samples, SAMPLES_PER_FRAME * sizeof(short));
- //do nothing
- } else {
- tech_pvt->read_frame.datalen = samples;
- //DEBUGA_SKYPE("read=====> GOOD samples=%d\n", SKYPIAX_P_LOG, samples);
- /* A real frame */
- }
- } else {
- DEBUGA_SKYPE("select returned %d\n", SKYPIAX_P_LOG, rt);
-
- }
-
- //DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-
- return SWITCH_STATUS_SUCCESS;
-}
-
-#endif /* SKYPE_AUDIO */
-static void tech_init(private_t * tech_pvt, switch_core_session_t * session,
- skypiax_interface_t * p)
+void skypiax_tech_init(private_t * tech_pvt, switch_core_session_t * session, skypiax_interface_t * p)
{
DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
@@ -1028,799 +442,6 @@
/*.receive_event */ channel_receive_event
};
-#define SKYPE_THREAD
-#ifndef WIN32
-#ifdef SKYPE_THREAD
-
-#define SKYPE_X11_BUF_SIZE 512
-Window skype_win = (Window) - 1;
-static XErrorHandler old_handler = 0;
-static int xerror = 0;
-
-int X11_errors_handler(Display * dpy, XErrorEvent * err)
-{
- (void) dpy;
- struct skypiax_interface *p = NULL;
-
- xerror = err->error_code;
- DEBUGA_SKYPE("Received error code %d from X Server\n", SKYPIAX_P_LOG, xerror);
- return 0; /* ignore the error */
-}
-
-static void X11_errors_trap(void)
-{
- xerror = 0;
- old_handler = XSetErrorHandler(X11_errors_handler);
-}
-
-static int X11_errors_untrap(void)
-{
- XSetErrorHandler(old_handler);
- return (xerror != BadValue) && (xerror != BadWindow);
-}
-
-int skypiax_skype_send_message(struct AsteriskHandles *AsteriskHandlesAst,
- const char *message_P)
-{
-
- Window w_P;
- Display *disp;
- Window handle_P;
- struct skypiax_interface *p = NULL;
-
- w_P = AsteriskHandlesAst->skype_win;
- disp = AsteriskHandlesAst->disp;
- handle_P = AsteriskHandlesAst->win;
-
- Atom atom1 = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", False);
- Atom atom2 = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE", False);
- unsigned int pos = 0;
- unsigned int len = strlen(message_P);
- XEvent e;
- int ok;
-
- memset(&e, 0, sizeof(e));
- e.xclient.type = ClientMessage;
- e.xclient.message_type = atom1; /* leading message */
- e.xclient.display = disp;
- e.xclient.window = handle_P;
- e.xclient.format = 8;
-
- X11_errors_trap();
- //XLockDisplay(disp);
- do {
- unsigned int i;
- for (i = 0; i < 20 && i + pos <= len; ++i)
- e.xclient.data.b[i] = message_P[i + pos];
- XSendEvent(disp, w_P, False, 0, &e);
-
- e.xclient.message_type = atom2; /* following messages */
- pos += i;
- } while (pos <= len);
-
- XSync(disp, False);
- //XUnlockDisplay(disp);
- ok = X11_errors_untrap();
-
- if (!ok)
- DEBUGA_SKYPE("Sending message failed with status %d\n", SKYPIAX_P_LOG, xerror);
-
- return ok;
-}
-
-int skypiax_skype_present(Display * disp)
-{
- Atom skype_inst = XInternAtom(disp, "_SKYPE_INSTANCE", True);
-
- Atom type_ret;
- int format_ret;
- unsigned long nitems_ret;
- unsigned long bytes_after_ret;
- unsigned char *prop;
- int status;
- struct skypiax_interface *p = NULL;
-
- X11_errors_trap();
- //XLockDisplay(disp);
- status =
- XGetWindowProperty(disp, DefaultRootWindow(disp), skype_inst, 0, 1, False, XA_WINDOW,
- &type_ret, &format_ret, &nitems_ret, &bytes_after_ret, &prop);
- //XUnlockDisplay(disp);
- X11_errors_untrap();
-
- /* sanity check */
- if (status != Success || format_ret != 32 || nitems_ret != 1) {
- skype_win = (Window) - 1;
- DEBUGA_SKYPE("Skype instance not found\n", SKYPIAX_P_LOG);
- return 0;
- }
-
- skype_win = *(const unsigned long *) prop & 0xffffffff;
- //DEBUGA_SKYPE("Skype instance found with id #%x\n", SKYPIAX_P_LOG,
- DEBUGA_SKYPE("Skype instance found with id #%d\n", SKYPIAX_P_LOG,
- (unsigned int) skype_win);
- return 1;
-}
-
-void skypiax_skype_clean_disp(void *data)
-{
-
- int *dispptr;
- int disp;
- struct skypiax_interface *p = NULL;
-
- dispptr = data;
- disp = *dispptr;
-
- if (disp) {
- DEBUGA_SKYPE("to be destroyed disp %d\n", SKYPIAX_P_LOG, disp);
- close(disp);
- DEBUGA_SKYPE("destroyed disp\n", SKYPIAX_P_LOG);
- } else {
- DEBUGA_SKYPE("NOT destroyed disp\n", SKYPIAX_P_LOG);
- }
- DEBUGA_SKYPE("OUT destroyed disp\n", SKYPIAX_P_LOG);
- switch_sleep(1000);
-}
-
-static void *SWITCH_THREAD_FUNC do_skype_thread(switch_thread_t * thread, void *obj)
-{
-
- struct skypiax_interface *p;
- struct AsteriskHandles *AsteriskHandlesAst;
- char buf[SKYPE_X11_BUF_SIZE];
- Display *disp = NULL;
- Window root = -1;
- Window win = -1;
-
- p = obj;
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-
- switch_file_pipe_create_ex(&p->AsteriskHandlesAst.fdesc[0],
- &p->AsteriskHandlesAst.fdesc[1], 2, module_pool);
-
- AsteriskHandlesAst = &p->AsteriskHandlesAst;
- //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",
- p->X11_display);
- return NULL;
- } else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "X Display '%s' opened\n",
- p->X11_display);
- }
-
- int xfd;
- xfd = XConnectionNumber(disp);
- fcntl(xfd, F_SETFD, FD_CLOEXEC);
-
- //FIXME pthread_cleanup_push(skypiax_skype_clean_disp, &xfd);
- DEBUGA_SKYPE("PUSH disp %d\n", SKYPIAX_P_LOG, xfd);
-
- if (skypiax_skype_present(disp)) {
- root = DefaultRootWindow(disp);
- win =
- XCreateSimpleWindow(disp, root, 0, 0, 1, 1, 0,
- BlackPixel(disp, DefaultScreen(disp)), BlackPixel(disp,
- DefaultScreen
- (disp)));
-
- DEBUGA_SKYPE("skype_win=%d win=%d\n", SKYPIAX_P_LOG, (unsigned int) skype_win,
- (unsigned int) win);
-
- AsteriskHandlesAst->skype_win = skype_win;
- AsteriskHandlesAst->disp = disp;
- AsteriskHandlesAst->win = win;
-
- snprintf(buf, SKYPE_X11_BUF_SIZE, "NAME skypiax");
-
- if (!skypiax_skype_send_message(AsteriskHandlesAst, buf)) {
- ERRORA
- ("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypiax again\n",
- SKYPIAX_P_LOG);
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- return NULL;
- }
-
- snprintf(buf, SKYPE_X11_BUF_SIZE, "PROTOCOL 6");
- if (!skypiax_skype_send_message(AsteriskHandlesAst, buf)) {
- ERRORA
- ("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypiax again\n",
- SKYPIAX_P_LOG);
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- return NULL;
- }
-
- /* perform an events loop */
- XEvent an_event;
- char buf[21]; /* can't be longer */
- char buffer[17000];
- char *b;
- int i;
-
- b = buffer;
-
- while (1) {
- XNextEvent(disp, &an_event);
- switch (an_event.type) {
- case ClientMessage:
-
- if (an_event.xclient.format != 8)
- break;
-
- for (i = 0; i < 20 && an_event.xclient.data.b[i] != '\0'; ++i)
- buf[i] = an_event.xclient.data.b[i];
-
- buf[i] = '\0';
-
- //NOTICA("ClientMessage buf:|||%s||| buffer:|||%s||| serial=%ld|||\r\n",SKYPIAX_P_LOG,buf, buffer,an_event.xclient.serial);
- //NOTICA ("SKYPE read: |||%s|||%d\n", SKYPIAX_P_LOG, buf, strlen(buf));
- //NOTICA ("SKYPE buffer: |||%s|||%d\n", SKYPIAX_P_LOG, buffer, strlen(buffer));
-
- strcat(buffer, buf);
-
- if (i < 20) { /* last fragment */
- unsigned int howmany;
-
- howmany = strlen(b) + 1;
-
- switch_file_write(AsteriskHandlesAst->fdesc[1], b, &howmany);
- //write(AsteriskHandlesAst->fdesc[1], "\0", 1);
- //FIXME DEBUGA_SKYPE("SKYPE pipewrite: |||%s|||len=%d serial=%ld\n\n\n", SKYPIAX_P_LOG, b, strlen(b) + 1, an_event.xclient.serial);
- //switch_sleep(1000);
- memset(buffer, '\0', 17000);
- }
-
- break;
- default:
- break;
- }
- }
- } else {
- ERRORA
- ("Skype is not running, maybe crashed. Please run/restart Skype and relaunch Skypiax\n",
- SKYPIAX_P_LOG);
- return NULL;
- }
- //DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- return NULL;
-
-}
-
-#endif /* SKYPE_THREAD */
-#else // WIN32
-
-#endif // WIN32
-
-#define CONTROLDEV_THREAD
-#ifdef CONTROLDEV_THREAD
-#if 1
-
-#define WANT_SKYPE_X11
-int skypiax_skype_write(struct skypiax_interface *p, char *msg_to_skype)
-{
-#ifdef WIN32
- static char acInputRow[1024];
- COPYDATASTRUCT oCopyData;
-
- if (option_debug > 100) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
- sprintf(acInputRow, "%s", msg_to_skype);
- if (option_debug > 1)
- DEBUGA_SKYPE("acInputRow: |||%s||||\n", SKYPIAX_P_LOG, acInputRow);
- /* send command to skype */
- oCopyData.dwData = 0;
- oCopyData.lpData = acInputRow;
- oCopyData.cbData = strlen(acInputRow) + 1;
- if (oCopyData.cbData != 1) {
- if (SendMessage
- (p->AsteriskHandlesAst.win32_hGlobal_SkypeAPIWindowHandle, WM_COPYDATA,
- (WPARAM) p->AsteriskHandlesAst.win32_hInit_MainWindowHandle,
- (LPARAM) & oCopyData) == FALSE) {
- 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",
- SKYPIAX_P_LOG);
- p->skype = 0;
- //FIXME p->skype_thread = SKYPIAX_PTHREADT_NULL;
- p->skype_thread = NULL;
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
- return -1;
- }
- }
-#else /* WIN32 */
-#ifdef WANT_SKYPE_X11
- struct AsteriskHandles *AsteriskHandlesAst;
-
- if (option_debug > 100) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
- AsteriskHandlesAst = &p->AsteriskHandlesAst;
-
- if (option_debug > 101) {
- DEBUGA_SKYPE("SENDING: |||%s||||\n", SKYPIAX_P_LOG, msg_to_skype);
- }
-
- 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",
- SKYPIAX_P_LOG);
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
- return -1;
- }
-#endif /* WANT_SKYPE_X11 */
-#endif /* WIN32 */
-
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
- return 0;
-
-}
-#endif //0
-
-int skypiax_skype_read(struct skypiax_interface *p)
-{
-
- char read_from_pipe[4096];
- char messaggio[4096];
- char messaggio_2[4096];
- char *buf, obj[512] = "", id[512] = "", prop[512] = "", value[512] = "", *where;
- char **stringp = NULL;
- //int fd;
- int rt;
- //fd_set fs;
- //struct timeval to;
- int i, a;
- unsigned int howmany;
-
- if (option_debug > 100) {
- DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- }
-
- memset(read_from_pipe, 0, 4096);
- memset(messaggio, 0, 4096);
- memset(messaggio_2, 0, 4096);
-
- rt = 1;
- if (rt > 0) {
- howmany = sizeof(read_from_pipe);
- switch_file_read(p->AsteriskHandlesAst.fdesc[0], read_from_pipe, &howmany);
-
- 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;
- }
- }
-
- 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);
- }
-
- 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, "CALL")) {
-
- strncpy(obj, where, sizeof(obj) - 1);
-
- where = strsep(stringp, " ");
-
- strncpy(id, where, sizeof(id) - 1);
-
- where = strsep(stringp, " ");
-
- strncpy(prop, where, sizeof(prop) - 1);
-
- where = strsep(stringp, " ");
-
- strncpy(value, where, sizeof(value) - 1);
-
- 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, "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;
- session = tech_pvt->session;
- channel = switch_core_session_get_channel(session);
-
- if (channel) {
- switch_dtmf_t dtmf =
- { (char) value[0], switch_core_default_dtmf_duration(0) };
- if (globals.debug) {
- 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, "STATUS")) {
-
- if (!strcasecmp(value, "RINGING")) {
- char msg_to_skype[1024];
- if (p->interface_state != SKYPIAX_STATE_DIALING) {
- /* we are not calling out */
-
- if (1) {
- /* 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 FINISHED", 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);
-
- }
- } else {
- /* we are calling out */
- p->skype_callflow = CALLFLOW_STATUS_RINGING;
- 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);
- DEBUGA_SKYPE("Our remote party in skype_call %s is RINGING\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")) {
- global_session = NULL; //FIXME
- //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;
- }
-
- } 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);
- }
- 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;
- 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);
-
- }
- } 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) {
- char msg_to_skype[1024];
-
- if (1) {
- switch_threadattr_t *thd_attr = NULL;
-
- switch_threadattr_create(&thd_attr, 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, module_pool);
- DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG);
-
- switch_threadattr_create(&thd_attr, 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, 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=\"5556\"", id);
- skypiax_skype_write(p, msg_to_skype);
- switch_sleep(100000);
- sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"5558\"", id);
- skypiax_skype_write(p, msg_to_skype);
- switch_sleep(100000);
- }
-
- p->skype_callflow = SKYPIAX_STATE_UP;
-
- /**************************/
-
- //FIXME switch_core_session_t **new_session;
-
- //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);
- 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", "gmaruzz_from_skype",
- "calling_number", NULL, "calling_ani",
- NULL, NULL, (char *) modname, "default",
- "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);
- }
- }
- } 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);
- switch_channel_mark_pre_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);
-
- }
- } //STATUS
-
- } //CALL
-
- a = 0;
- } //message end
- } //read_from_pipe
-
- }
-
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
- //DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- return 0;
-}
-
int skypiax_skype_call(struct skypiax_interface *p, char *idest, int timeout,
switch_core_session_t * session)
{
@@ -1874,7 +495,7 @@
(private_t *) switch_core_session_alloc(*new_session, sizeof(private_t))) != 0) {
tech_pvt->p = &SKYPIAX_INTERFACES[2]; //FIXME
channel = switch_core_session_get_channel(*new_session);
- tech_init(tech_pvt, *new_session, NULL);
+ 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");
@@ -1958,14 +579,13 @@
}
-#endif // CONTROLDEV_THREAD
static switch_status_t load_config(void)
{
char *cf = "skypiax.conf";
switch_xml_t cfg, xml, global_settings, param, interfaces, myinterface;
- switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, module_pool);
+ switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, skypiax_module_pool);
if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
return SWITCH_STATUS_TERM;
@@ -2149,11 +769,11 @@
switch_thread_t *thread;
switch_threadattr_t *thd_attr = NULL;
- switch_threadattr_create(&thd_attr, module_pool);
+ 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(&thread, thd_attr, do_skype_thread,
- &SKYPIAX_INTERFACES[interface_id], module_pool);
+ &SKYPIAX_INTERFACES[interface_id], skypiax_module_pool);
}
switch_sleep(100000);
@@ -2161,11 +781,11 @@
switch_thread_t *thread;
switch_threadattr_t *thd_attr = NULL;
- switch_threadattr_create(&thd_attr, module_pool);
+ 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(&thread, thd_attr, skypiax_do_controldev_thread,
- &SKYPIAX_INTERFACES[interface_id], module_pool);
+ &SKYPIAX_INTERFACES[interface_id], skypiax_module_pool);
}
switch_sleep(1000000);
@@ -2214,7 +834,7 @@
{
struct skypiax_interface *p = NULL;
- module_pool = pool;
+ skypiax_module_pool = pool;
memset(&globals, '\0', sizeof(globals));
memset(SKYPIAX_INTERFACES, '\0', sizeof(SKYPIAX_INTERFACES));
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 Tue Dec 9 05:52:03 2008
@@ -47,6 +47,23 @@
#define SKYPIAX_SVN_VERSION "SVN 123456"
+typedef enum {
+ TFLAG_IO = (1 << 0),
+ TFLAG_INBOUND = (1 << 1),
+ TFLAG_OUTBOUND = (1 << 2),
+ TFLAG_DTMF = (1 << 3),
+ TFLAG_VOICE = (1 << 4),
+ TFLAG_HANGUP = (1 << 5),
+ TFLAG_LINEAR = (1 << 6),
+ TFLAG_CODEC = (1 << 7),
+ TFLAG_BREAK = (1 << 8)
+} TFLAGS;
+
+typedef enum {
+ GFLAG_MY_CODEC_PREFS = (1 << 0)
+} GFLAGS;
+
+
#define DEBUGA_SKYPE(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_SKYPE %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ );
#define DEBUGA_CALL(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_CALL %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ );
#define DEBUGA_PBX(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_PBX %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ );
@@ -193,3 +210,9 @@
typedef struct private_object private_t;
+void *SWITCH_THREAD_FUNC do_skype_thread(switch_thread_t * thread, void *obj);
+void skypiax_tech_init(private_t * tech_pvt, switch_core_session_t * session, skypiax_interface_t * p);
+switch_status_t skypiax_skypeaudio_read(private_t * tech_pvt);
+int skypiax_skypeaudio_init(struct skypiax_interface *p);
+int skypiax_skype_write(struct skypiax_interface *p, char *msg_to_skype);
+int skypiax_skype_read(struct skypiax_interface *p);
Added: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c
==============================================================================
--- (empty file)
+++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c Tue Dec 9 05:52:03 2008
@@ -0,0 +1,1351 @@
+#include "skypiax.h"
+extern switch_memory_pool_t *skypiax_module_pool;
+extern int option_debug;
+extern switch_core_session_t *global_session;
+extern switch_endpoint_interface_t *skypiax_endpoint_interface;
+
+#define SKYPE_AUDIO
+#ifdef SKYPE_AUDIO
+
+#define SAMPLES_PER_FRAME 160
+#define NN 160
+#define GG 160
+static void *SWITCH_THREAD_FUNC skypiax_do_tcp_srv_thread(switch_thread_t * thread,
+ void *obj)
+{
+ struct skypiax_interface *p = obj;
+ short in[GG];
+ short out[GG / 2];
+ int s, fd, len;
+ unsigned int sin_size;
+ struct sockaddr_in my_addr;
+ struct sockaddr_in remote_addr;
+ int exit = 0;
+ int a;
+ int i;
+ unsigned int kill_cli_size;
+ short kill_cli_buff[320];
+
+ if (option_debug > 10) {
+ WARNINGA("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(5556); //FIXME configurable!
+
+ if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
+ ERRORA("socket Error\n", SKYPIAX_P_LOG);
+ if (option_debug > 10) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+ return NULL;
+ }
+
+ if (bind(s, (struct sockaddr *) &my_addr, sizeof(struct sockaddr)) < 0) {
+ ERRORA("bind Error\n", SKYPIAX_P_LOG);
+ if (option_debug > 10) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+ return NULL;
+ }
+ DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG);
+
+ listen(s, 6);
+
+ sin_size = sizeof(remote_addr);
+ while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) {
+ DEBUGA_SKYPE("ACCEPTED\n", SKYPIAX_P_LOG);
+ while (p->interface_state != SKYPIAX_STATE_DOWN
+ && (p->skype_callflow == CALLFLOW_STATUS_INPROGRESS
+ || p->skype_callflow == SKYPIAX_STATE_UP)) {
+
+ int fdselect;
+ int rt;
+ fd_set fs;
+ struct timeval to;
+
+ exit = 1;
+
+ fdselect = fd;
+ FD_ZERO(&fs);
+ FD_SET(fdselect, &fs);
+ to.tv_usec = 100;
+ to.tv_sec = 0;
+ rt = select(fdselect + 1, &fs, NULL, NULL, &to);
+ if (rt > 0) {
+
+ len = recv(fd, in, sizeof(short) * GG, 0);
+ //DEBUGA_SKYPE("recv %d\n", SKYPIAX_P_LOG, len);
+ if (len > 0) {
+ a = 0;
+ for (i = 0; i < len / sizeof(short); i++) {
+ out[a] = in[i];
+ i++;
+ a++;
+ }
+
+ if (!p->audiobuf_is_loaded) {
+ for (i = 0; i < (len / sizeof(short)) / 2; i++) {
+ p->audiobuf[i] = out[i];
+ }
+ p->audiobuf_is_loaded = 1;
+ } else {
+ unsigned int howmany;
+ short totalbuf[GG];
+
+ 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] = out[a];
+ i++;
+ }
+
+ howmany = len;
+
+ switch_file_write(p->audiopipe[1], totalbuf, &howmany);
+ p->audiobuf_is_loaded = 0;
+ //DEBUGA_SKYPE("read=====> req=%d recv=%d to sent=%d sent=%d\n", SKYPIAX_P_LOG, sizeof(short)*GG, len, (len*sizeof(short))/2, howmany);
+ }
+
+ } else if (len == 0) {
+ DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG);
+ break;
+ } else {
+ ERRORA("len=%d\n", SKYPIAX_P_LOG, len);
+ exit = 1;
+ break;
+ }
+ }
+ }
+
+ kill_cli_size = 320;
+ switch_file_write(p->audiopipe[1], kill_cli_buff, &kill_cli_size);
+ kill_cli_size = 320;
+ switch_file_write(p->audioskypepipe[1], kill_cli_buff, &kill_cli_size);
+ p->interface_state = SKYPIAX_STATE_DOWN;
+ kill_cli_size = 320;
+ switch_file_write(p->audiopipe[1], kill_cli_buff, &kill_cli_size);
+ kill_cli_size = 320;
+ switch_file_write(p->audioskypepipe[1], kill_cli_buff, &kill_cli_size);
+
+ DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG);
+
+#ifndef WIN32
+ close(fd);
+#else
+ closesocket(fd);
+#endif
+ if (exit)
+ break;
+ }
+
+ WARNINGA("server (I am it) GONE\n", SKYPIAX_P_LOG);
+#ifndef WIN32
+ close(s);
+#else
+ closesocket(s);
+#endif
+ if (option_debug > 10) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+ return NULL;
+}
+static void *SWITCH_THREAD_FUNC skypiax_do_tcp_cli_thread(switch_thread_t * thread,
+ void *obj)
+//void *skypiax_do_tcp_cli_thread(void *data)
+{
+ struct skypiax_interface *p = obj;
+ int s, fd, len;
+ short in[NN / 2];
+ short out[NN];
+ unsigned int sin_size;
+ struct sockaddr_in my_addr;
+ struct sockaddr_in remote_addr;
+ int a;
+ int i;
+ unsigned int got;
+
+ if (option_debug > 10) {
+ WARNINGA("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(5558); //FIXME configurable!
+
+ if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
+ ERRORA("socket Error\n", SKYPIAX_P_LOG);
+ if (option_debug > 10) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+ return NULL;
+ }
+
+ if (bind(s, (struct sockaddr *) &my_addr, sizeof(struct sockaddr)) < 0) {
+ ERRORA("bind Error\n", SKYPIAX_P_LOG);
+ if (option_debug > 10) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+#ifndef WIN32
+ close(s);
+#else
+ closesocket(s);
+#endif
+ return NULL;
+ }
+ DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
+
+ listen(s, 6);
+
+ sin_size = sizeof(remote_addr);
+ while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) {
+ DEBUGA_SKYPE("ACCEPTED\n", SKYPIAX_P_LOG);
+ while (p->interface_state != SKYPIAX_STATE_DOWN
+ && (p->skype_callflow == CALLFLOW_STATUS_INPROGRESS
+ || p->skype_callflow == SKYPIAX_STATE_UP)) {
+ int fdselect;
+ int rt;
+ fd_set fs;
+ struct timeval to;
+
+ fdselect = 1;
+ FD_ZERO(&fs);
+ FD_SET(fdselect, &fs);
+ to.tv_usec = 100;
+ to.tv_sec = 0;
+ rt = 1;
+ if (rt > 0) {
+
+ got = (NN / 2) * sizeof(short);
+ switch_file_read(p->audioskypepipe[0], in, &got);
+
+ if (got > 0) {
+ a = 0;
+ for (i = 0; i < got / sizeof(short); i++) {
+ out[a] = in[i];
+ a++;
+ out[a] = in[i];
+ a++;
+ }
+
+ len = send(fd, out, got * 2, 0);
+
+ if (len == 0) {
+ ERRORA("Skype server GONE\n", SKYPIAX_P_LOG);
+ break;
+ }
+ } else {
+ switch_sleep(1000);
+ //ERRORA("Audio skype pipe give us: %u\n", SKYPIAX_P_LOG, got);
+ }
+ }
+
+ }
+ ERRORA("Skype server GONE\n", SKYPIAX_P_LOG);
+#ifndef WIN32
+ close(fd);
+#else
+ closesocket(fd);
+#endif
+ break;
+ }
+
+ WARNINGA("client (I am it) GONE\n", SKYPIAX_P_LOG);
+#ifndef WIN32
+ close(s);
+#else
+ closesocket(s);
+#endif
+ if (option_debug > 10) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+ return NULL;
+}
+
+int skypiax_skypeaudio_init(struct skypiax_interface *p)
+{
+
+ switch_status_t rv;
+
+ rv = switch_file_pipe_create_ex(&p->audiopipe[0], &p->audiopipe[1], 2, skypiax_module_pool);
+ rv = switch_file_pipe_timeout_set(p->audiopipe[0], 100000);
+
+/* the pipe is our audio fd for pbx to poll on */
+ p->skypiax_sound_capt_fd = p->audiopipe[0];
+
+ rv =
+ switch_file_pipe_create_ex(&p->audioskypepipe[0], &p->audioskypepipe[1], 2,
+ skypiax_module_pool);
+ rv = switch_file_pipe_timeout_set(p->audioskypepipe[0], 100);
+ if (option_debug > 10) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+ return 0;
+}
+switch_status_t skypiax_skypeaudio_read(private_t * tech_pvt)
+{
+ struct skypiax_interface *p;
+ short buf[640];
+ unsigned int samples;
+ int rt;
+
+ p = tech_pvt->p;
+
+ //DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
+
+ memset(buf, '\0', sizeof(buf));
+
+ rt = 1;
+ if (rt > 0) {
+
+ samples = SAMPLES_PER_FRAME * sizeof(short);
+
+ switch_file_read(p->audiopipe[0], tech_pvt->read_frame.data, &samples);
+
+ //if ((samples = read(p->audiopipe[0], buf, SAMPLES_PER_FRAME * sizeof(short))) != 320)
+ if (samples != SAMPLES_PER_FRAME * sizeof(short)) {
+ if (samples)
+ DEBUGA_SKYPE("read=====> NOT GOOD samples=%d expected=%d\n", SKYPIAX_P_LOG,
+ samples, SAMPLES_PER_FRAME * sizeof(short));
+ //do nothing
+ } else {
+ tech_pvt->read_frame.datalen = samples;
+ //DEBUGA_SKYPE("read=====> GOOD samples=%d\n", SKYPIAX_P_LOG, samples);
+ /* A real frame */
+ }
+ } else {
+ DEBUGA_SKYPE("select returned %d\n", SKYPIAX_P_LOG, rt);
+
+ }
+
+ //DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+
+ return SWITCH_STATUS_SUCCESS;
+}
+
+#endif /* SKYPE_AUDIO */
+
+#ifdef WIN32
+struct AsteriskHandles *win32_AsteriskHandlesSkype;
+HWND win32_hInit_MainWindowHandle;
+HINSTANCE win32_hInit_ProcessHandle;
+char win32_acInit_WindowClassName[128];
+HANDLE win32_hGlobal_ThreadShutdownEvent;
+UINT win32_uiGlobal_MsgID_SkypeControlAPIAttach;
+UINT win32_uiGlobal_MsgID_SkypeControlAPIDiscover;
+HWND win32_hGlobal_SkypeAPIWindowHandle = NULL;
+DWORD win32_ulGlobal_PromptConsoleMode = 0;
+HANDLE volatile win32_hGlobal_PromptConsoleHandle = NULL;
+
+enum {
+ SKYPECONTROLAPI_ATTACH_SUCCESS = 0, /* Client is successfully
+ attached and API window handle can be found
+ in wParam parameter */
+ SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION = 1, /* Skype has acknowledged
+ connection request and is waiting
+ for confirmation from the user. */
+ /* The client is not yet attached
+ * and should wait for SKYPECONTROLAPI_ATTACH_SUCCESS message */
+ SKYPECONTROLAPI_ATTACH_REFUSED = 2, /* User has explicitly
+ denied access to client */
+ SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE = 3, /* API is not available
+ at the moment.
+ For example, this happens when no user
+ is currently logged in. */
+ /* Client should wait for
+ * SKYPECONTROLAPI_ATTACH_API_AVAILABLE
+ * broadcast before making any further */
+ /* connection attempts. */
+ SKYPECONTROLAPI_ATTACH_API_AVAILABLE = 0x8001
+};
+
+char
+ *strsep(char **stringp, const char *delim)
+{
+ char *res;
+
+ if (!stringp || !*stringp || !**stringp)
+ return (char *) 0;
+
+ res = *stringp;
+ while (**stringp && !strchr(delim, **stringp))
+ ++(*stringp);
+
+ if (**stringp) {
+ **stringp = '\0';
+ ++(*stringp);
+ }
+
+ return res;
+}
+
+LRESULT APIENTRY skypiax_skype_present(HWND hWindow, UINT uiMessage, WPARAM uiParam,
+ LPARAM ulParam)
+{
+ LRESULT lReturnCode;
+ int fIssueDefProc;
+ struct skypiax_interface *p = NULL;
+
+ lReturnCode = 0;
+ fIssueDefProc = 0;
+ switch (uiMessage) {
+ case WM_DESTROY:
+ win32_hInit_MainWindowHandle = NULL;
+ PostQuitMessage(0);
+ break;
+ case WM_COPYDATA:
+ if (win32_hGlobal_SkypeAPIWindowHandle == (HWND) uiParam) {
+ unsigned int howmany;
+ char msg_from_skype[2048];
+
+ PCOPYDATASTRUCT poCopyData = (PCOPYDATASTRUCT) ulParam;
+
+ memset(msg_from_skype, '\0', sizeof(msg_from_skype));
+ strncpy(msg_from_skype, (const char *) poCopyData->lpData,
+ sizeof(msg_from_skype) - 2);
+
+ howmany = strlen(msg_from_skype) + 1;
+ switch_file_write(win32_AsteriskHandlesSkype->fdesc[1], msg_from_skype, &howmany);
+ //NOTICA("From Skype API: %s\n", SKYPIAX_P_LOG, (const char *) poCopyData->lpData);
+ lReturnCode = 1;
+ }
+ break;
+ default:
+ if (uiMessage == win32_uiGlobal_MsgID_SkypeControlAPIAttach) {
+ switch (ulParam) {
+ case SKYPECONTROLAPI_ATTACH_SUCCESS:
+ NOTICA("\n\n\tConnected to Skype API!\n", SKYPIAX_P_LOG);
+ win32_hGlobal_SkypeAPIWindowHandle = (HWND) uiParam;
+ switch_sleep(5000);
+ win32_AsteriskHandlesSkype->win32_hGlobal_SkypeAPIWindowHandle =
+ win32_hGlobal_SkypeAPIWindowHandle;
+ break;
+ case SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION:
+ WARNINGA
+ ("\n\n\tIf I do not 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);
+ 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 available\n", SKYPIAX_P_LOG);
+ break;
+ case SKYPECONTROLAPI_ATTACH_API_AVAILABLE:
+ DEBUGA_SKYPE("Skype API available\n", SKYPIAX_P_LOG);
+ break;
+ default:
+ WARNINGA("GOT AN UNKNOWN SKYPE WINDOWS MSG\n", SKYPIAX_P_LOG);
+ }
+ lReturnCode = 1;
+ break;
+ }
+ fIssueDefProc = 1;
+ break;
+ }
+ if (fIssueDefProc)
+ lReturnCode = DefWindowProc(hWindow, uiMessage, uiParam, ulParam);
+ return (lReturnCode);
+}
+
+int win32_Initialize_CreateWindowClass(void)
+{
+ unsigned char *paucUUIDString;
+ RPC_STATUS lUUIDResult;
+ int fReturnStatus;
+ UUID oUUID;
+
+ fReturnStatus = 0;
+ lUUIDResult = UuidCreate(&oUUID);
+ win32_hInit_ProcessHandle =
+ (HINSTANCE) OpenProcess(PROCESS_DUP_HANDLE, FALSE, GetCurrentProcessId());
+ if (win32_hInit_ProcessHandle != NULL
+ && (lUUIDResult == RPC_S_OK || lUUIDResult == RPC_S_UUID_LOCAL_ONLY)) {
+ if (UuidToString(&oUUID, &paucUUIDString) == RPC_S_OK) {
+ WNDCLASS oWindowClass;
+
+ strcpy(win32_acInit_WindowClassName, "Skype-API-Skypiax-");
+ strcat(win32_acInit_WindowClassName, (char *) paucUUIDString);
+
+ oWindowClass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
+ oWindowClass.lpfnWndProc = (WNDPROC) & skypiax_skype_present;
+ oWindowClass.cbClsExtra = 0;
+ oWindowClass.cbWndExtra = 0;
+ oWindowClass.hInstance = win32_hInit_ProcessHandle;
+ oWindowClass.hIcon = NULL;
+ oWindowClass.hCursor = NULL;
+ oWindowClass.hbrBackground = NULL;
+ oWindowClass.lpszMenuName = NULL;
+ oWindowClass.lpszClassName = win32_acInit_WindowClassName;
+
+ if (RegisterClass(&oWindowClass) != 0)
+ fReturnStatus = 1;
+
+ RpcStringFree(&paucUUIDString);
+ }
+ }
+ if (fReturnStatus == 0)
+ CloseHandle(win32_hInit_ProcessHandle), win32_hInit_ProcessHandle = NULL;
+ return (fReturnStatus);
+}
+
+void win32_DeInitialize_DestroyWindowClass(void)
+{
+ UnregisterClass(win32_acInit_WindowClassName, win32_hInit_ProcessHandle);
+ CloseHandle(win32_hInit_ProcessHandle), win32_hInit_ProcessHandle = NULL;
+}
+
+int win32_Initialize_CreateMainWindow(void)
+{
+ win32_hInit_MainWindowHandle =
+ CreateWindowEx(WS_EX_APPWINDOW | WS_EX_WINDOWEDGE, win32_acInit_WindowClassName, "",
+ WS_BORDER | WS_SYSMENU | WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT,
+ 128, 128, NULL, 0, win32_hInit_ProcessHandle, 0);
+ return (win32_hInit_MainWindowHandle != NULL ? 1 : 0);
+}
+
+void win32_DeInitialize_DestroyMainWindow(void)
+{
+ if (win32_hInit_MainWindowHandle != NULL)
+ DestroyWindow(win32_hInit_MainWindowHandle), win32_hInit_MainWindowHandle = NULL;
+}
+
+DWORD win32_dwThreadId;
+
+void *SWITCH_THREAD_FUNC do_skype_thread(switch_thread_t * thread, void *obj)
+{
+ /* create window class */
+ /* create dummy/hidden window for processing messages */
+ /* run message loop thread */
+ /* do application control until exit */
+ /* exit: send QUIT message to our own window */
+ /* wait until thred terminates */
+ /* destroy main window */
+ /* destroy window class */
+
+ struct skypiax_interface *p;
+ p = obj;
+
+ switch_file_pipe_create_ex(&p->AsteriskHandlesAst.fdesc[0],
+ &p->AsteriskHandlesAst.fdesc[1], 2, skypiax_module_pool);
+
+ win32_AsteriskHandlesSkype = &p->AsteriskHandlesAst;
+
+ win32_uiGlobal_MsgID_SkypeControlAPIAttach =
+ RegisterWindowMessage("SkypeControlAPIAttach");
+ win32_uiGlobal_MsgID_SkypeControlAPIDiscover =
+ RegisterWindowMessage("SkypeControlAPIDiscover");
+
+ if (win32_uiGlobal_MsgID_SkypeControlAPIAttach != 0
+ && win32_uiGlobal_MsgID_SkypeControlAPIDiscover != 0) {
+ if (win32_Initialize_CreateWindowClass()) {
+ if (win32_Initialize_CreateMainWindow()) {
+ win32_hGlobal_ThreadShutdownEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
+ if (win32_hGlobal_ThreadShutdownEvent != NULL) {
+ if (SendMessage
+ (HWND_BROADCAST, win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
+ (WPARAM) win32_hInit_MainWindowHandle, 0) != 0) {
+ win32_AsteriskHandlesSkype->win32_hInit_MainWindowHandle =
+ win32_hInit_MainWindowHandle;
+ while (1) {
+ MSG oMessage;
+
+ while (GetMessage(&oMessage, 0, 0, 0) != FALSE) {
+ TranslateMessage(&oMessage);
+ DispatchMessage(&oMessage);
+ }
+ }
+ }
+ CloseHandle(win32_hGlobal_ThreadShutdownEvent);
+ }
+ win32_DeInitialize_DestroyMainWindow();
+ }
+ win32_DeInitialize_DestroyWindowClass();
+ }
+ }
+ return NULL;
+}
+
+#else /* NOT WIN32 */
+
+#define SKYPE_X11_BUF_SIZE 512
+Window skype_win = (Window) - 1;
+static XErrorHandler old_handler = 0;
+static int xerror = 0;
+
+int X11_errors_handler(Display * dpy, XErrorEvent * err)
+{
+ (void) dpy;
+ struct skypiax_interface *p = NULL;
+
+ xerror = err->error_code;
+ DEBUGA_SKYPE("Received error code %d from X Server\n", SKYPIAX_P_LOG, xerror);
+ return 0; /* ignore the error */
+}
+
+static void X11_errors_trap(void)
+{
+ xerror = 0;
+ old_handler = XSetErrorHandler(X11_errors_handler);
+}
+
+static int X11_errors_untrap(void)
+{
+ XSetErrorHandler(old_handler);
+ return (xerror != BadValue) && (xerror != BadWindow);
+}
+
+int skypiax_skype_send_message(struct AsteriskHandles *AsteriskHandlesAst,
+ const char *message_P)
+{
+
+ Window w_P;
+ Display *disp;
+ Window handle_P;
+ struct skypiax_interface *p = NULL;
+
+ w_P = AsteriskHandlesAst->skype_win;
+ disp = AsteriskHandlesAst->disp;
+ handle_P = AsteriskHandlesAst->win;
+
+ Atom atom1 = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", False);
+ Atom atom2 = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE", False);
+ unsigned int pos = 0;
+ unsigned int len = strlen(message_P);
+ XEvent e;
+ int ok;
+
+ memset(&e, 0, sizeof(e));
+ e.xclient.type = ClientMessage;
+ e.xclient.message_type = atom1; /* leading message */
+ e.xclient.display = disp;
+ e.xclient.window = handle_P;
+ e.xclient.format = 8;
+
+ X11_errors_trap();
+ //XLockDisplay(disp);
+ do {
+ unsigned int i;
+ for (i = 0; i < 20 && i + pos <= len; ++i)
+ e.xclient.data.b[i] = message_P[i + pos];
+ XSendEvent(disp, w_P, False, 0, &e);
+
+ e.xclient.message_type = atom2; /* following messages */
+ pos += i;
+ } while (pos <= len);
+
+ XSync(disp, False);
+ //XUnlockDisplay(disp);
+ ok = X11_errors_untrap();
+
+ if (!ok)
+ DEBUGA_SKYPE("Sending message failed with status %d\n", SKYPIAX_P_LOG, xerror);
+
+ return ok;
+}
+
+int skypiax_skype_present(Display * disp)
+{
+ Atom skype_inst = XInternAtom(disp, "_SKYPE_INSTANCE", True);
+
+ Atom type_ret;
+ int format_ret;
+ unsigned long nitems_ret;
+ unsigned long bytes_after_ret;
+ unsigned char *prop;
+ int status;
+ struct skypiax_interface *p = NULL;
+
+ X11_errors_trap();
+ //XLockDisplay(disp);
+ status =
+ XGetWindowProperty(disp, DefaultRootWindow(disp), skype_inst, 0, 1, False, XA_WINDOW,
+ &type_ret, &format_ret, &nitems_ret, &bytes_after_ret, &prop);
+ //XUnlockDisplay(disp);
+ X11_errors_untrap();
+
+ /* sanity check */
+ if (status != Success || format_ret != 32 || nitems_ret != 1) {
+ skype_win = (Window) - 1;
+ DEBUGA_SKYPE("Skype instance not found\n", SKYPIAX_P_LOG);
+ return 0;
+ }
+
+ skype_win = *(const unsigned long *) prop & 0xffffffff;
+ //DEBUGA_SKYPE("Skype instance found with id #%x\n", SKYPIAX_P_LOG,
+ DEBUGA_SKYPE("Skype instance found with id #%d\n", SKYPIAX_P_LOG,
+ (unsigned int) skype_win);
+ return 1;
+}
+
+void skypiax_skype_clean_disp(void *data)
+{
+
+ int *dispptr;
+ int disp;
+ struct skypiax_interface *p = NULL;
+
+ dispptr = data;
+ disp = *dispptr;
+
+ if (disp) {
+ DEBUGA_SKYPE("to be destroyed disp %d\n", SKYPIAX_P_LOG, disp);
+ close(disp);
+ DEBUGA_SKYPE("destroyed disp\n", SKYPIAX_P_LOG);
+ } else {
+ DEBUGA_SKYPE("NOT destroyed disp\n", SKYPIAX_P_LOG);
+ }
+ DEBUGA_SKYPE("OUT destroyed disp\n", SKYPIAX_P_LOG);
+ switch_sleep(1000);
+}
+
+static void *SWITCH_THREAD_FUNC do_skype_thread(switch_thread_t * thread, void *obj)
+{
+
+ struct skypiax_interface *p;
+ struct AsteriskHandles *AsteriskHandlesAst;
+ char buf[SKYPE_X11_BUF_SIZE];
+ Display *disp = NULL;
+ Window root = -1;
+ Window win = -1;
+
+ p = obj;
+ DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
+
+ switch_file_pipe_create_ex(&p->AsteriskHandlesAst.fdesc[0],
+ &p->AsteriskHandlesAst.fdesc[1], 2, skypiax_module_pool);
+
+ AsteriskHandlesAst = &p->AsteriskHandlesAst;
+ //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",
+ p->X11_display);
+ return NULL;
+ } else {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "X Display '%s' opened\n",
+ p->X11_display);
+ }
+
+ int xfd;
+ xfd = XConnectionNumber(disp);
+ fcntl(xfd, F_SETFD, FD_CLOEXEC);
+
+ //FIXME pthread_cleanup_push(skypiax_skype_clean_disp, &xfd);
+ DEBUGA_SKYPE("PUSH disp %d\n", SKYPIAX_P_LOG, xfd);
+
+ if (skypiax_skype_present(disp)) {
+ root = DefaultRootWindow(disp);
+ win =
+ XCreateSimpleWindow(disp, root, 0, 0, 1, 1, 0,
+ BlackPixel(disp, DefaultScreen(disp)), BlackPixel(disp,
+ DefaultScreen
+ (disp)));
+
+ DEBUGA_SKYPE("skype_win=%d win=%d\n", SKYPIAX_P_LOG, (unsigned int) skype_win,
+ (unsigned int) win);
+
+ AsteriskHandlesAst->skype_win = skype_win;
+ AsteriskHandlesAst->disp = disp;
+ AsteriskHandlesAst->win = win;
+
+ snprintf(buf, SKYPE_X11_BUF_SIZE, "NAME skypiax");
+
+ if (!skypiax_skype_send_message(AsteriskHandlesAst, buf)) {
+ ERRORA
+ ("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypiax again\n",
+ SKYPIAX_P_LOG);
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ return NULL;
+ }
+
+ snprintf(buf, SKYPE_X11_BUF_SIZE, "PROTOCOL 6");
+ if (!skypiax_skype_send_message(AsteriskHandlesAst, buf)) {
+ ERRORA
+ ("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypiax again\n",
+ SKYPIAX_P_LOG);
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ return NULL;
+ }
+
+ /* perform an events loop */
+ XEvent an_event;
+ char buf[21]; /* can't be longer */
+ char buffer[17000];
+ char *b;
+ int i;
+
+ b = buffer;
+
+ while (1) {
+ XNextEvent(disp, &an_event);
+ switch (an_event.type) {
+ case ClientMessage:
+
+ if (an_event.xclient.format != 8)
+ break;
+
+ for (i = 0; i < 20 && an_event.xclient.data.b[i] != '\0'; ++i)
+ buf[i] = an_event.xclient.data.b[i];
+
+ buf[i] = '\0';
+
+ //NOTICA("ClientMessage buf:|||%s||| buffer:|||%s||| serial=%ld|||\r\n",SKYPIAX_P_LOG,buf, buffer,an_event.xclient.serial);
+ //NOTICA ("SKYPE read: |||%s|||%d\n", SKYPIAX_P_LOG, buf, strlen(buf));
+ //NOTICA ("SKYPE buffer: |||%s|||%d\n", SKYPIAX_P_LOG, buffer, strlen(buffer));
+
+ strcat(buffer, buf);
+
+ if (i < 20) { /* last fragment */
+ unsigned int howmany;
+
+ howmany = strlen(b) + 1;
+
+ switch_file_write(AsteriskHandlesAst->fdesc[1], b, &howmany);
+ //write(AsteriskHandlesAst->fdesc[1], "\0", 1);
+ //FIXME DEBUGA_SKYPE("SKYPE pipewrite: |||%s|||len=%d serial=%ld\n\n\n", SKYPIAX_P_LOG, b, strlen(b) + 1, an_event.xclient.serial);
+ //switch_sleep(1000);
+ memset(buffer, '\0', 17000);
+ }
+
+ break;
+ default:
+ break;
+ }
+ }
+ } else {
+ ERRORA
+ ("Skype is not running, maybe crashed. Please run/restart Skype and relaunch Skypiax\n",
+ SKYPIAX_P_LOG);
+ return NULL;
+ }
+ //DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ return NULL;
+
+}
+#endif // WIN32
+
+
+int skypiax_skype_write(struct skypiax_interface *p, char *msg_to_skype)
+{
+#ifdef WIN32
+ static char acInputRow[1024];
+ COPYDATASTRUCT oCopyData;
+
+ if (option_debug > 100) {
+ DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
+ }
+ sprintf(acInputRow, "%s", msg_to_skype);
+ if (option_debug > 1)
+ DEBUGA_SKYPE("acInputRow: |||%s||||\n", SKYPIAX_P_LOG, acInputRow);
+ /* send command to skype */
+ oCopyData.dwData = 0;
+ oCopyData.lpData = acInputRow;
+ oCopyData.cbData = strlen(acInputRow) + 1;
+ if (oCopyData.cbData != 1) {
+ if (SendMessage
+ (p->AsteriskHandlesAst.win32_hGlobal_SkypeAPIWindowHandle, WM_COPYDATA,
+ (WPARAM) p->AsteriskHandlesAst.win32_hInit_MainWindowHandle,
+ (LPARAM) & oCopyData) == FALSE) {
+ 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",
+ SKYPIAX_P_LOG);
+ p->skype = 0;
+ //FIXME p->skype_thread = SKYPIAX_PTHREADT_NULL;
+ p->skype_thread = NULL;
+ if (option_debug > 100) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+ return -1;
+ }
+ }
+#else /* WIN32 */
+ struct AsteriskHandles *AsteriskHandlesAst;
+
+ if (option_debug > 100) {
+ DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
+ }
+ AsteriskHandlesAst = &p->AsteriskHandlesAst;
+
+ if (option_debug > 101) {
+ DEBUGA_SKYPE("SENDING: |||%s||||\n", SKYPIAX_P_LOG, msg_to_skype);
+ }
+
+ 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",
+ SKYPIAX_P_LOG);
+ if (option_debug > 100) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+ return -1;
+ }
+#endif /* WIN32 */
+
+ if (option_debug > 100) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+ return 0;
+
+}
+
+int skypiax_skype_read(struct skypiax_interface *p)
+{
+
+ char read_from_pipe[4096];
+ char messaggio[4096];
+ char messaggio_2[4096];
+ char *buf, obj[512] = "", id[512] = "", prop[512] = "", value[512] = "", *where;
+ char **stringp = NULL;
+ //int fd;
+ int rt;
+ //fd_set fs;
+ //struct timeval to;
+ int i, a;
+ unsigned int howmany;
+
+ if (option_debug > 100) {
+ DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
+ }
+
+ memset(read_from_pipe, 0, 4096);
+ memset(messaggio, 0, 4096);
+ memset(messaggio_2, 0, 4096);
+
+ rt = 1;
+ if (rt > 0) {
+ howmany = sizeof(read_from_pipe);
+ switch_file_read(p->AsteriskHandlesAst.fdesc[0], read_from_pipe, &howmany);
+
+ 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;
+ }
+ }
+
+ 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);
+ }
+
+ 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, "CALL")) {
+
+ strncpy(obj, where, sizeof(obj) - 1);
+
+ where = strsep(stringp, " ");
+
+ strncpy(id, where, sizeof(id) - 1);
+
+ where = strsep(stringp, " ");
+
+ strncpy(prop, where, sizeof(prop) - 1);
+
+ where = strsep(stringp, " ");
+
+ strncpy(value, where, sizeof(value) - 1);
+
+ 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, "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;
+ session = tech_pvt->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, "STATUS")) {
+
+ if (!strcasecmp(value, "RINGING")) {
+ char msg_to_skype[1024];
+ if (p->interface_state != SKYPIAX_STATE_DIALING) {
+ /* we are not calling out */
+
+ if (1) {
+ /* 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 FINISHED", 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);
+
+ }
+ } else {
+ /* we are calling out */
+ p->skype_callflow = CALLFLOW_STATUS_RINGING;
+ 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);
+ DEBUGA_SKYPE("Our remote party in skype_call %s is RINGING\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")) {
+ global_session = NULL; //FIXME
+ //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;
+ }
+
+ } 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);
+ }
+ 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;
+ 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);
+
+ }
+ } 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) {
+ char msg_to_skype[1024];
+
+ if (1) {
+ 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=\"5556\"", id);
+ skypiax_skype_write(p, msg_to_skype);
+ switch_sleep(100000);
+ sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"5558\"", id);
+ skypiax_skype_write(p, msg_to_skype);
+ switch_sleep(100000);
+ }
+
+ p->skype_callflow = SKYPIAX_STATE_UP;
+
+ /**************************/
+
+ //FIXME switch_core_session_t **new_session;
+
+ //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 ((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", "gmaruzz_from_skype",
+ "calling_number", NULL, "calling_ani",
+ NULL, NULL, "mod_skypiax", "default",
+ "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);
+ }
+ }
+ } 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);
+ switch_channel_mark_pre_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);
+
+ }
+ } //STATUS
+
+ } //CALL
+
+ a = 0;
+ } //message end
+ } //read_from_pipe
+
+ }
+
+ if (option_debug > 100) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+ //DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ return 0;
+}
+
+
1
0
[commit] r10671 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax
by FreeSWITCH SVN 09 Dec '08
by FreeSWITCH SVN 09 Dec '08
09 Dec '08
Author: gmaruzz
Date: Tue Dec 9 04:56:46 2008
New Revision: 10671
Log:
skypiax: now ifdeffed on WIN32 for automatic understanding of platform
Modified:
freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.2008.vcproj
freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c
freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h
Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.2008.vcproj
==============================================================================
--- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.2008.vcproj (original)
+++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.2008.vcproj Tue Dec 9 04:56:46 2008
@@ -149,6 +149,10 @@
RelativePath="..\mod_skypiax\mod_skypiax.c"
>
</File>
+ <File
+ RelativePath=".\skypiax.h"
+ >
+ </File>
</Files>
<Globals>
</Globals>
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 Tue Dec 9 04:56:46 2008
@@ -80,8 +80,8 @@
static switch_status_t channel_kill_channel(switch_core_session_t * session, int sig);
-#ifdef WIN32_SKYPIAX
-#ifdef __CYGWIN__
+#ifdef WIN32
+#ifdef WIN32
struct AsteriskHandles *win32_AsteriskHandlesSkype;
HWND win32_hInit_MainWindowHandle;
HINSTANCE win32_hInit_ProcessHandle;
@@ -322,9 +322,9 @@
return NULL;
}
-#endif /* __CYGWIN__ */
+#endif /* WIN32 */
-#endif //WIN32_SKYPIAX
+#endif //WIN32
static switch_status_t skypiax_codec(private_t * tech_pvt, int sample_rate, int codec_ms)
{
@@ -485,7 +485,7 @@
DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG);
-#ifndef WIN32_SKYPIAX
+#ifndef WIN32
close(fd);
#else
closesocket(fd);
@@ -495,7 +495,7 @@
}
WARNINGA("server (I am it) GONE\n", SKYPIAX_P_LOG);
-#ifndef WIN32_SKYPIAX
+#ifndef WIN32
close(s);
#else
closesocket(s);
@@ -541,7 +541,7 @@
if (option_debug > 10) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
-#ifndef WIN32_SKYPIAX
+#ifndef WIN32
close(s);
#else
closesocket(s);
@@ -597,7 +597,7 @@
}
ERRORA("Skype server GONE\n", SKYPIAX_P_LOG);
-#ifndef WIN32_SKYPIAX
+#ifndef WIN32
close(fd);
#else
closesocket(fd);
@@ -606,7 +606,7 @@
}
WARNINGA("client (I am it) GONE\n", SKYPIAX_P_LOG);
-#ifndef WIN32_SKYPIAX
+#ifndef WIN32
close(s);
#else
closesocket(s);
@@ -1029,7 +1029,7 @@
};
#define SKYPE_THREAD
-#ifndef WIN32_SKYPIAX
+#ifndef WIN32
#ifdef SKYPE_THREAD
#define SKYPE_X11_BUF_SIZE 512
@@ -1290,9 +1290,9 @@
}
#endif /* SKYPE_THREAD */
-#else // WIN32_SKYPIAX
+#else // WIN32
-#endif // WIN32_SKYPIAX
+#endif // WIN32
#define CONTROLDEV_THREAD
#ifdef CONTROLDEV_THREAD
@@ -1301,7 +1301,7 @@
#define WANT_SKYPE_X11
int skypiax_skype_write(struct skypiax_interface *p, char *msg_to_skype)
{
-#ifdef __CYGWIN__
+#ifdef WIN32
static char acInputRow[1024];
COPYDATASTRUCT oCopyData;
@@ -1332,7 +1332,7 @@
return -1;
}
}
-#else /* __CYGWIN__ */
+#else /* WIN32 */
#ifdef WANT_SKYPE_X11
struct AsteriskHandles *AsteriskHandlesAst;
@@ -1355,7 +1355,7 @@
return -1;
}
#endif /* WANT_SKYPE_X11 */
-#endif /* __CYGWIN__ */
+#endif /* WIN32 */
if (option_debug > 100) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
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 Tue Dec 9 04:56:46 2008
@@ -34,18 +34,16 @@
*
*/
-#undef WIN32_SKYPIAX
-#undef __CYGWIN__
+#include <switch.h>
-#ifndef WIN32_SKYPIAX
+#ifndef WIN32
#include <X11/Xlib.h>
#include <X11/Xlibint.h>
#include <X11/Xatom.h>
-#else //WIN32_SKYPIAX
+#else //WIN32
//FIXME include?
-#endif //WIN32_SKYPIAX
+#endif //WIN32
-#include <switch.h>
#define SKYPIAX_SVN_VERSION "SVN 123456"
@@ -108,14 +106,14 @@
#define SKYPIAX_MAX_INTERFACES 64
-#ifndef WIN32_SKYPIAX
+#ifndef WIN32
struct AsteriskHandles {
Window skype_win;
Display *disp;
Window win;
switch_file_t *fdesc[2];
};
-#else //WIN32_SKYPIAX
+#else //WIN32
struct AsteriskHandles {
HWND win32_hInit_MainWindowHandle;
@@ -123,7 +121,7 @@
switch_file_t *fdesc[2];
};
-#endif //WIN32_SKYPIAX
+#endif //WIN32
struct skypiax_interface {
char interface_id[80];
1
0
[commit] r10670 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax
by FreeSWITCH SVN 09 Dec '08
by FreeSWITCH SVN 09 Dec '08
09 Dec '08
Author: gmaruzz
Date: Tue Dec 9 04:43:33 2008
New Revision: 10670
Log:
skypiax: added skypiax.h, beginning to structure files
Added:
freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h
Modified:
freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.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 Tue Dec 9 04:43:33 2008
@@ -1,114 +1,5 @@
-/*
- * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
- * Copyright (C) 2005/2006, Anthony Minessale II <anthmct(a)yahoo.com>
- *
- * Version: MPL 1.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
- *
- * The Initial Developer of the Original Code is
- * Anthony Minessale II <anthmct(a)yahoo.com>
- * Portions created by the Initial Developer are Copyright (C)
- * the Initial Developer. All Rights Reserved.
- *
- * This module (mod_skypiax) has been contributed by:
- *
- * Giovanni Maruzzelli (gmaruzz(a)gmail.com)
- *
- *
- * Further Contributors:
- *
- *
- *
- * mod_skypiax.c -- Skype compatible Endpoint Module
- *
- */
-
-#undef WIN32_SKYPIAX
-#undef __CYGWIN__
-#define MOD_SKYPIAX
-#ifdef MOD_SKYPIAX
-
-#ifndef WIN32_SKYPIAX
-#include <X11/Xlib.h>
-#include <X11/Xlibint.h>
-#include <X11/Xatom.h>
-#else //WIN32_SKYPIAX
-//FIXME include?
-#endif //WIN32_SKYPIAX
-
-#include <switch.h>
-
-#define SKYPIAX_SVN_VERSION "SVN 123456"
-
-#define DEBUGA_SKYPE(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_SKYPE %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ );
-#define DEBUGA_CALL(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_CALL %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ );
-#define DEBUGA_PBX(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_PBX %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ );
-#define ERRORA(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][ERRORA %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ );
-#define WARNINGA(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][WARNINGA %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ );
-#define NOTICA(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][NOTICA %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ );
-
-#define SKYPIAX_P_LOG NULL, (unsigned long)55, __LINE__, p ? p->name ? p->name : "none" : "none", -1, p ? p->interface_state : -1, p ? p->skype_callflow : -1
-
-/*********************************/
-#define SKYPIAX_CAUSE_NORMAL 1
-/*********************************/
-#define SKYPIAX_FRAME_DTMF 1
-/*********************************/
-#define SKYPIAX_CONTROL_RINGING 1
-#define SKYPIAX_CONTROL_ANSWER 2
-
-/*********************************/
-#define SKYPIAX_STATE_DOWN 1
-#define SKYPIAX_STATE_RING 2
-#define SKYPIAX_STATE_DIALING 3
-#define SKYPIAX_STATE_BUSY 4
-#define SKYPIAX_STATE_UP 5
-#define SKYPIAX_STATE_RINGING 6
-#define SKYPIAX_STATE_PRERING 7
-/*********************************/
-/* call flow from the device */
-#define CALLFLOW_CALL_IDLE SKYPIAX_STATE_DOWN
-#define CALLFLOW_INCOMING_RING SKYPIAX_STATE_RING
-#define CALLFLOW_CALL_DIALING SKYPIAX_STATE_DIALING
-#define CALLFLOW_CALL_LINEBUSY SKYPIAX_STATE_BUSY
-#define CALLFLOW_CALL_ACTIVE 300
-#define CALLFLOW_INCOMING_HANGUP 100
-#define CALLFLOW_CALL_RELEASED 101
-#define CALLFLOW_CALL_NOCARRIER 102
-#define CALLFLOW_CALL_INFLUX 103
-#define CALLFLOW_CALL_INCOMING 104
-#define CALLFLOW_CALL_FAILED 105
-#define CALLFLOW_CALL_NOSERVICE 106
-#define CALLFLOW_CALL_OUTGOINGRESTRICTED 107
-#define CALLFLOW_CALL_SECURITYFAIL 108
-#define CALLFLOW_CALL_NOANSWER 109
-#define CALLFLOW_STATUS_FINISHED 110
-#define CALLFLOW_STATUS_CANCELLED 111
-#define CALLFLOW_STATUS_FAILED 112
-#define CALLFLOW_STATUS_REFUSED 113
-#define CALLFLOW_STATUS_RINGING 114
-#define CALLFLOW_STATUS_INPROGRESS 115
-#define CALLFLOW_STATUS_UNPLACED 116
-#define CALLFLOW_STATUS_ROUTING 117
-#define CALLFLOW_STATUS_EARLYMEDIA 118
-#define SKYPIAX_STATE_HANGUP_REQUESTED 200
- //FIXME CALLFLOW_INCOMING_CALLID to be removed
-#define CALLFLOW_INCOMING_CALLID 1019
+#include "skypiax.h"
-/*********************************/
-
-#define SKYPIAX_MAX_INTERFACES 64
SWITCH_MODULE_LOAD_FUNCTION(mod_skypiax_load);
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypiax_shutdown);
@@ -119,23 +10,6 @@
static switch_memory_pool_t *module_pool = NULL;
static int running = 1;
-#ifndef WIN32_SKYPIAX
-struct AsteriskHandles {
- Window skype_win;
- Display *disp;
- Window win;
- switch_file_t *fdesc[2];
-};
-#else //WIN32_SKYPIAX
-
-struct AsteriskHandles {
- HWND win32_hInit_MainWindowHandle;
- HWND win32_hGlobal_SkypeAPIWindowHandle;
- switch_file_t *fdesc[2];
-};
-
-#endif //WIN32_SKYPIAX
-
typedef enum {
TFLAG_IO = (1 << 0),
TFLAG_INBOUND = (1 << 1),
@@ -170,76 +44,14 @@
switch_mutex_t *mutex;
} globals;
-struct skypiax_interface {
- char interface_id[80];
- char name[80];
- char dialplan[80];
- char context[80];
- char dial_regex[256];
- char fail_dial_regex[256];
- char hold_music[256];
- char type[256];
- char X11_display[256];
- struct AsteriskHandles AsteriskHandlesAst;
-
- int interface_state; /*!< \brief 'state' of the interface (channel) */
- char language[80]; /*!< \brief default Asterisk dialplan language for this interface */
- char exten[80]; /*!< \brief default Asterisk dialplan extension for this interface */
- int skypiax_sound_rate; /*!< \brief rate of the sound device, in Hz, eg: 8000 */
- switch_file_t *skypiax_sound_capt_fd; /*!< \brief file descriptor for sound capture dev */
- char callid_name[50];
- char callid_number[50];
- double playback_boost;
- double capture_boost;
- int stripmsd;
- switch_thread_t *skype_thread;
- char skype_call_id[512];
- int skype_call_ongoing;
- char skype_friends[4096];
- char skype_fullname[512];
- char skype_displayname[512];
- int skype_callflow; /*!< \brief 'callflow' of the skype interface (as opposed to phone interface) */
- int skype; /*!< \brief config flag, bool, Skype support on this interface (0 if false, -1 if true) */
- int control_to_send;
- switch_file_t *audiopipe[2];
- switch_file_t *audioskypepipe[2];
- switch_thread_t *tcp_srv_thread;
- switch_thread_t *tcp_cli_thread;
- short audiobuf[160];
- int audiobuf_is_loaded;
-
- //int phonebook_listing;
- //int phonebook_querying;
- //int phonebook_listing_received_calls;
-
- //int phonebook_first_entry;
- //int phonebook_last_entry;
- //int phonebook_number_lenght;
- //int phonebook_text_lenght;
- FILE *phonebook_writing_fp;
- int skypiax_dir_entry_extension_prefix;
- void *tech_pvt;
-};
+static skypiax_interface_t SKYPIAX_INTERFACES[SKYPIAX_MAX_INTERFACES];
+
+int option_debug = 100;
+switch_core_session_t *global_session = NULL;
-typedef struct skypiax_interface skypiax_interface_t;
-static skypiax_interface_t SKYPIAX_INTERFACES[SKYPIAX_MAX_INTERFACES];
-struct private_object {
- unsigned int flags;
- switch_codec_t read_codec;
- switch_codec_t write_codec;
- switch_frame_t read_frame;
- unsigned char databuf[SWITCH_RECOMMENDED_BUFFER_SIZE];
- switch_core_session_t *session;
- switch_caller_profile_t *caller_profile;
- switch_mutex_t *mutex;
- switch_mutex_t *flag_mutex;
- skypiax_interface_t *p;
- //switch_thread_cond_t *cond;
-};
-typedef struct private_object private_t;
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, globals.dialplan);
SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_string, globals.codec_string);
@@ -267,8 +79,6 @@
int stream_id);
static switch_status_t channel_kill_channel(switch_core_session_t * session, int sig);
-int option_debug = 100;
-switch_core_session_t *global_session = NULL;
#ifdef WIN32_SKYPIAX
#ifdef __CYGWIN__
@@ -1590,7 +1400,7 @@
if (read_from_pipe[i] == '\0') {
- if (option_debug > 101)
+ //if (option_debug > 101)
DEBUGA_SKYPE("read_skype: howmany=%d, i=%d, a=%d, |||%s||| \n", SKYPIAX_P_LOG,
howmany, i, a, messaggio);
@@ -2511,4 +2321,3 @@
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab:
*/
-#endif /* MOD_SKYPIAX */
Added: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h
==============================================================================
--- (empty file)
+++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h Tue Dec 9 04:43:33 2008
@@ -0,0 +1,197 @@
+/*
+ * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ * Copyright (C) 2005/2006, Anthony Minessale II <anthmct(a)yahoo.com>
+ *
+ * Version: MPL 1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
+ *
+ * The Initial Developer of the Original Code is
+ * Anthony Minessale II <anthmct(a)yahoo.com>
+ * Portions created by the Initial Developer are Copyright (C)
+ * the Initial Developer. All Rights Reserved.
+ *
+ * This module (mod_skypiax) has been contributed by:
+ *
+ * Giovanni Maruzzelli (gmaruzz(a)gmail.com)
+ *
+ *
+ * Further Contributors:
+ *
+ *
+ *
+ * mod_skypiax.c -- Skype compatible Endpoint Module
+ *
+ */
+
+#undef WIN32_SKYPIAX
+#undef __CYGWIN__
+
+#ifndef WIN32_SKYPIAX
+#include <X11/Xlib.h>
+#include <X11/Xlibint.h>
+#include <X11/Xatom.h>
+#else //WIN32_SKYPIAX
+//FIXME include?
+#endif //WIN32_SKYPIAX
+
+#include <switch.h>
+
+#define SKYPIAX_SVN_VERSION "SVN 123456"
+
+#define DEBUGA_SKYPE(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_SKYPE %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ );
+#define DEBUGA_CALL(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_CALL %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ );
+#define DEBUGA_PBX(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_PBX %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ );
+#define ERRORA(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][ERRORA %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ );
+#define WARNINGA(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][WARNINGA %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ );
+#define NOTICA(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][NOTICA %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ );
+
+#define SKYPIAX_P_LOG NULL, (unsigned long)55, __LINE__, p ? p->name ? p->name : "none" : "none", -1, p ? p->interface_state : -1, p ? p->skype_callflow : -1
+
+/*********************************/
+#define SKYPIAX_CAUSE_NORMAL 1
+/*********************************/
+#define SKYPIAX_FRAME_DTMF 1
+/*********************************/
+#define SKYPIAX_CONTROL_RINGING 1
+#define SKYPIAX_CONTROL_ANSWER 2
+
+/*********************************/
+#define SKYPIAX_STATE_DOWN 1
+#define SKYPIAX_STATE_RING 2
+#define SKYPIAX_STATE_DIALING 3
+#define SKYPIAX_STATE_BUSY 4
+#define SKYPIAX_STATE_UP 5
+#define SKYPIAX_STATE_RINGING 6
+#define SKYPIAX_STATE_PRERING 7
+/*********************************/
+/* call flow from the device */
+#define CALLFLOW_CALL_IDLE SKYPIAX_STATE_DOWN
+#define CALLFLOW_INCOMING_RING SKYPIAX_STATE_RING
+#define CALLFLOW_CALL_DIALING SKYPIAX_STATE_DIALING
+#define CALLFLOW_CALL_LINEBUSY SKYPIAX_STATE_BUSY
+#define CALLFLOW_CALL_ACTIVE 300
+#define CALLFLOW_INCOMING_HANGUP 100
+#define CALLFLOW_CALL_RELEASED 101
+#define CALLFLOW_CALL_NOCARRIER 102
+#define CALLFLOW_CALL_INFLUX 103
+#define CALLFLOW_CALL_INCOMING 104
+#define CALLFLOW_CALL_FAILED 105
+#define CALLFLOW_CALL_NOSERVICE 106
+#define CALLFLOW_CALL_OUTGOINGRESTRICTED 107
+#define CALLFLOW_CALL_SECURITYFAIL 108
+#define CALLFLOW_CALL_NOANSWER 109
+#define CALLFLOW_STATUS_FINISHED 110
+#define CALLFLOW_STATUS_CANCELLED 111
+#define CALLFLOW_STATUS_FAILED 112
+#define CALLFLOW_STATUS_REFUSED 113
+#define CALLFLOW_STATUS_RINGING 114
+#define CALLFLOW_STATUS_INPROGRESS 115
+#define CALLFLOW_STATUS_UNPLACED 116
+#define CALLFLOW_STATUS_ROUTING 117
+#define CALLFLOW_STATUS_EARLYMEDIA 118
+#define SKYPIAX_STATE_HANGUP_REQUESTED 200
+ //FIXME CALLFLOW_INCOMING_CALLID to be removed
+#define CALLFLOW_INCOMING_CALLID 1019
+
+/*********************************/
+
+#define SKYPIAX_MAX_INTERFACES 64
+
+#ifndef WIN32_SKYPIAX
+struct AsteriskHandles {
+ Window skype_win;
+ Display *disp;
+ Window win;
+ switch_file_t *fdesc[2];
+};
+#else //WIN32_SKYPIAX
+
+struct AsteriskHandles {
+ HWND win32_hInit_MainWindowHandle;
+ HWND win32_hGlobal_SkypeAPIWindowHandle;
+ switch_file_t *fdesc[2];
+};
+
+#endif //WIN32_SKYPIAX
+
+struct skypiax_interface {
+ char interface_id[80];
+ char name[80];
+ char dialplan[80];
+ char context[80];
+ char dial_regex[256];
+ char fail_dial_regex[256];
+ char hold_music[256];
+ char type[256];
+ char X11_display[256];
+ struct AsteriskHandles AsteriskHandlesAst;
+
+ int interface_state; /*!< \brief 'state' of the interface (channel) */
+ char language[80]; /*!< \brief default Asterisk dialplan language for this interface */
+ char exten[80]; /*!< \brief default Asterisk dialplan extension for this interface */
+ int skypiax_sound_rate; /*!< \brief rate of the sound device, in Hz, eg: 8000 */
+ switch_file_t *skypiax_sound_capt_fd; /*!< \brief file descriptor for sound capture dev */
+ char callid_name[50];
+ char callid_number[50];
+ double playback_boost;
+ double capture_boost;
+ int stripmsd;
+ switch_thread_t *skype_thread;
+ char skype_call_id[512];
+ int skype_call_ongoing;
+ char skype_friends[4096];
+ char skype_fullname[512];
+ char skype_displayname[512];
+ int skype_callflow; /*!< \brief 'callflow' of the skype interface (as opposed to phone interface) */
+ int skype; /*!< \brief config flag, bool, Skype support on this interface (0 if false, -1 if true) */
+ int control_to_send;
+ switch_file_t *audiopipe[2];
+ switch_file_t *audioskypepipe[2];
+ switch_thread_t *tcp_srv_thread;
+ switch_thread_t *tcp_cli_thread;
+ short audiobuf[160];
+ int audiobuf_is_loaded;
+
+ //int phonebook_listing;
+ //int phonebook_querying;
+ //int phonebook_listing_received_calls;
+
+ //int phonebook_first_entry;
+ //int phonebook_last_entry;
+ //int phonebook_number_lenght;
+ //int phonebook_text_lenght;
+ FILE *phonebook_writing_fp;
+ int skypiax_dir_entry_extension_prefix;
+ void *tech_pvt;
+};
+
+typedef struct skypiax_interface skypiax_interface_t;
+
+struct private_object {
+ unsigned int flags;
+ switch_codec_t read_codec;
+ switch_codec_t write_codec;
+ switch_frame_t read_frame;
+ unsigned char databuf[SWITCH_RECOMMENDED_BUFFER_SIZE];
+ switch_core_session_t *session;
+ switch_caller_profile_t *caller_profile;
+ switch_mutex_t *mutex;
+ switch_mutex_t *flag_mutex;
+ skypiax_interface_t *p;
+ //switch_thread_cond_t *cond;
+};
+
+typedef struct private_object private_t;
+
+
1
0
Author: stkn
Date: Tue Dec 9 04:41:37 2008
New Revision: 10669
Log:
C&P fail
Modified:
freeswitch/trunk/configure.in
Modified: freeswitch/trunk/configure.in
==============================================================================
--- freeswitch/trunk/configure.in (original)
+++ freeswitch/trunk/configure.in Tue Dec 9 04:41:37 2008
@@ -46,7 +46,7 @@
fi
AC_SUBST(confdir)
-AC_DEFINE_UNQUOTED([SWITCH_CONF_DIR],"${confdir}",[where to install the modules to])
+AC_DEFINE_UNQUOTED([SWITCH_CONF_DIR],"${confdir}",[directory for configuration files])
#Set default language
AC_LANG_C
1
0