Freeswitch-branches
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
- 1655 discussions
[commit] r10590 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax
by FreeSWITCH SVN 04 Dec '08
by FreeSWITCH SVN 04 Dec '08
04 Dec '08
Author: gmaruzz
Date: Thu Dec 4 04:47:39 2008
New Revision: 10590
Log:
skypiax: added implementation for strsep, let's see it it works on win32
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 Thu Dec 4 04:47:39 2008
@@ -310,6 +310,29 @@
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)
{
1
0
[commit] r10589 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax
by FreeSWITCH SVN 04 Dec '08
by FreeSWITCH SVN 04 Dec '08
04 Dec '08
Author: gmaruzz
Date: Thu Dec 4 04:32:52 2008
New Revision: 10589
Log:
skypiax: converting to use APR pipes, compiles and works. Now let's eliminate strsep
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 Thu Dec 4 04:32:52 2008
@@ -130,7 +130,7 @@
Window skype_win;
Display *disp;
Window win;
- int fdesc[2];
+ switch_file_t *fdesc[2];
};
#else //WIN32_SKYPIAX
@@ -812,6 +812,7 @@
//fdselect = p->audioskypepipe[0];
+ fdselect=1;
FD_ZERO(&fs);
FD_SET(fdselect, &fs);
to.tv_usec = 100;
@@ -863,7 +864,18 @@
int skypiax_skypeaudio_init(struct skypiax_interface *p)
{
- int c;
+
+//switch_file_t *readp = NULL;
+//switch_file_t *writep = NULL;
+
+ switch_status_t rv;
+
+ //rv = switch_file_pipe_create_ex(&readp, &writep, APR_FULL_NONBLOCK, module_pool);
+ rv = switch_file_pipe_create_ex(&p->audiopipe[0], &p->audiopipe[1], 2, module_pool);
+ //rv = switch_file_pipe_create(&readp, &writep, module_pool);
+
+
+ //FIXME int c;
#if 0
/* build the pipe that will be polled on by pbx */
c = pipe(p->audiopipe);
@@ -891,6 +903,7 @@
}
*/
+ rv = switch_file_pipe_create_ex(&p->audioskypepipe[0], &p->audioskypepipe[1], 2, module_pool);
#ifdef NOTDEF_WIN32_SKYPIAX
c = pipe(p->audioskypepipe);
if (c) {
@@ -913,11 +926,11 @@
{
struct skypiax_interface *p;
short buf[640];
- int samples;
- int fd;
+ unsigned int samples;
+ //int fd;
int rt;
- fd_set fs;
- struct timeval to;
+ //fd_set fs;
+ //struct timeval to;
p = tech_pvt->p;
@@ -926,17 +939,24 @@
memset(buf, '\0', sizeof(buf));
+#if 0
fd = p->audiopipe[0];
FD_ZERO(&fs);
FD_SET(fd, &fs);
to.tv_usec = 100000;
to.tv_sec = 0;
rt = select(fd + 1, &fs, NULL, NULL, &to);
+#endif
+ 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 = read(p->audiopipe[0], tech_pvt->read_frame.data, SAMPLES_PER_FRAME * sizeof(short))) != 320) {
+ if (samples != 320) {
DEBUGA_SKYPE("read=====> NOT GOOD samples=%d expected=%d\n", SKYPIAX_P_LOG, samples,
320);
switch_sleep(1000);
@@ -957,7 +977,7 @@
return SWITCH_STATUS_SUCCESS;
}
-#ifdef NOTDEF
+#if 0
//cicopet
struct ast_frame *skypiax_skypeaudio_read(struct skypiax_interface *p)
{
@@ -1007,7 +1027,7 @@
}
return &f;
}
-#endif //NOTDEF
+#endif //0
#endif /* SKYPE_AUDIO */
static void tech_init(private_t *tech_pvt, switch_core_session_t *session, skypiax_interface_t *p)
@@ -1254,7 +1274,7 @@
switch_channel_t *channel = NULL;
private_t *tech_pvt = NULL;
//switch_frame_t *pframe;
- int sent;
+ unsigned int sent;
struct skypiax_interface *p=NULL;
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL WRITE FRAME\n");
@@ -1278,7 +1298,8 @@
}
#endif
- sent = write(p->audioskypepipe[1], (short *) frame->data, frame->datalen);
+ sent = frame->datalen;
+ switch_file_write(p->audioskypepipe[1], (short *) frame->data, &sent);
//ERRORA("sent %d\n", SKYPIAX_P_LOG, sent);
@@ -1286,7 +1307,7 @@
}
-#if 1
+#if 0
switch_file_t *readp = NULL;
switch_file_t *writep = NULL;
@@ -1561,7 +1582,7 @@
return SWITCH_STATUS_SUCCESS;
}
-#ifdef NOTDEF //FIXME: moved below
+#if 0
/* Make sure when you have 2 sessions in the same scope that you pass the appropriate one to the routines
that allocate memory or you will have 1 channel with memory allocated from another channel's pool!
*/
@@ -1612,7 +1633,7 @@
return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
}
-#endif // NOTDEF //FIXME: moved below
+#endif // 0 //FIXME: moved below
static switch_status_t channel_receive_event(switch_core_session_t *session, switch_event_t *event)
{
@@ -1793,7 +1814,7 @@
Display *disp = NULL;
Window root = -1;
Window win = -1;
-int res;
+//int res;
p = obj;
DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
@@ -1808,6 +1829,9 @@
}
*/
+ switch_file_pipe_create_ex(&p->AsteriskHandlesAst.fdesc[0], &p->AsteriskHandlesAst.fdesc[1], 2, module_pool);
+
+#if 0
res = pipe(p->AsteriskHandlesAst.fdesc);
if (res) {
ERRORA("Unable to create skype pipe, exiting skype thread\n", SKYPIAX_P_LOG);
@@ -1816,6 +1840,7 @@
}
fcntl(p->AsteriskHandlesAst.fdesc[0], F_SETFL, O_NONBLOCK);
fcntl(p->AsteriskHandlesAst.fdesc[1], F_SETFL, O_NONBLOCK);
+#endif
AsteriskHandlesAst = &p->AsteriskHandlesAst;
@@ -1903,7 +1928,11 @@
strcat(buffer, buf);
if (i < 20) { /* last fragment */
- write(AsteriskHandlesAst->fdesc[1], b, strlen(b) + 1);
+ 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);
@@ -2021,28 +2050,33 @@
char messaggio_2[4096];
char *buf, obj[512] = "", id[512] = "", prop[512] = "", value[512] = "", *where;
char **stringp = NULL;
- int fd;
+ //int fd;
int rt;
- fd_set fs;
- struct timeval to;
- int howmany, i, a;
+ //fd_set fs;
+ //struct timeval to;
+ int i, a;
+ unsigned int howmany;
if (option_debug > 100) {
DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
}
+ DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
memset(read_from_pipe, 0, 4096);
memset(messaggio, 0, 4096);
memset(messaggio_2, 0, 4096);
+#if 0
fd = p->AsteriskHandlesAst.fdesc[0];
FD_ZERO(&fs);
FD_SET(fd, &fs);
to.tv_usec = 100;
to.tv_sec = 0;
rt = select(fd + 1, &fs, NULL, NULL, &to);
+#endif
+ rt=1;
if (rt > 0) {
- howmany =
- read(p->AsteriskHandlesAst.fdesc[0], read_from_pipe, sizeof(read_from_pipe));
+ howmany = sizeof(read_from_pipe);
+ switch_file_read(p->AsteriskHandlesAst.fdesc[0], read_from_pipe, &howmany);
a = 0;
for (i = 0; i < howmany; i++) {
@@ -2051,7 +2085,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);
@@ -2556,6 +2590,7 @@
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] r10577 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax
by FreeSWITCH SVN 03 Dec '08
by FreeSWITCH SVN 03 Dec '08
03 Dec '08
Author: gmaruzz
Date: Wed Dec 3 13:11:48 2008
New Revision: 10577
Log:
skypiax: converting to use APR pipes, not finished, do not compile... gotta go now
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 Wed Dec 3 13:11:48 2008
@@ -34,8 +34,8 @@
*
*/
-#define WIN32_SKYPIAX
-#define __CYGWIN__
+#undef WIN32_SKYPIAX
+#undef __CYGWIN__
#define MOD_SKYPIAX
#ifdef MOD_SKYPIAX
@@ -194,7 +194,7 @@
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 */
- int skypiax_sound_capt_fd; /*!< \brief file descriptor for sound capture dev */
+ 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;
@@ -209,8 +209,8 @@
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;
- int audiopipe[2];
- int audioskypepipe[2];
+ 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];
@@ -640,7 +640,8 @@
struct skypiax_interface *p = obj;
short in[GG];
short out[GG / 2];
- int s, fd, len, sent;
+ //int s, fd, len, sent;
+ int s, fd, len;
unsigned int sin_size;
struct sockaddr_in my_addr;
struct sockaddr_in remote_addr;
@@ -717,8 +718,11 @@
}
p->audiobuf_is_loaded = 1;
} else {
- sent = write(p->audiopipe[1], p->audiobuf, len / 2);
- sent = write(p->audiopipe[1], out, len / 2);
+ unsigned int howmany;
+ howmany = len/2;
+ switch_file_write(p->audiopipe[1], p->audiobuf, &howmany);
+ howmany = len/2;
+ switch_file_write(p->audiopipe[1], out, &howmany);
p->audiobuf_is_loaded = 0;
//DEBUGA_SOUND("read=====> req=%d recv=%d to sent=%d sent=%d\n", SKYPIAX_P_LOG, sizeof(short)*GG, len, (len*sizeof(short))/2, sent);
}
@@ -758,7 +762,7 @@
struct sockaddr_in remote_addr;
int a;
int i;
- int got;
+ unsigned int got;
int exit=0;
if (option_debug > 10) {
@@ -807,16 +811,18 @@
- fdselect = p->audioskypepipe[0];
+ //fdselect = p->audioskypepipe[0];
FD_ZERO(&fs);
FD_SET(fdselect, &fs);
to.tv_usec = 100;
to.tv_sec = 0;
- rt = select(fdselect + 1, &fs, NULL, NULL, &to);
+ //rt = select(fdselect + 1, &fs, NULL, NULL, &to);
+ rt=1;
if (rt > 0) {
- got = read(p->audioskypepipe[0], in, (NN / 2) * sizeof(short));
+ got = (NN / 2) * sizeof(short);
+ switch_file_read(p->audioskypepipe[0], in, &got);
//ERRORA("got %d\n", SKYPIAX_P_LOG, got);
if (got > 0) {
@@ -858,6 +864,7 @@
int skypiax_skypeaudio_init(struct skypiax_interface *p)
{
int c;
+#if 0
/* build the pipe that will be polled on by pbx */
c = pipe(p->audiopipe);
if (c) {
@@ -867,6 +874,7 @@
}
return -1;
}
+#endif
/* the pipe is our audio fd for pbx to poll on */
p->skypiax_sound_capt_fd = p->audiopipe[0];
@@ -883,6 +891,7 @@
}
*/
+#ifdef NOTDEF_WIN32_SKYPIAX
c = pipe(p->audioskypepipe);
if (c) {
ERRORA("Unable to create audioskypepipe\n", SKYPIAX_P_LOG);
@@ -891,7 +900,6 @@
}
return -1;
}
-#ifndef WIN32_SKYPIAX
fcntl(p->audioskypepipe[0], F_SETFL, O_NONBLOCK);
fcntl(p->audioskypepipe[1], F_SETFL, O_NONBLOCK);
#endif// WIN32_SKYPIAX
1
0
[commit] r10575 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax
by FreeSWITCH SVN 03 Dec '08
by FreeSWITCH SVN 03 Dec '08
03 Dec '08
Author: gmaruzz
Date: Wed Dec 3 12:23:18 2008
New Revision: 10575
Log:
skypiax: added mod_skypiax.2008.vcproj, the makefile for VC++ on Windows
Added:
freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.2008.vcproj
Added: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.2008.vcproj
==============================================================================
--- (empty file)
+++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.2008.vcproj Wed Dec 3 12:23:18 2008
@@ -0,0 +1,155 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="mod_skypiax"
+ ProjectGUID="{FE3540C5-3303-46E0-A69E-D92F775687F1}"
+ RootNamespace="mod_skypiax"
+ Keyword="Win32Proj"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ ConfigurationType="2"
+ InheritedPropertySheets="..\..\..\..\w32\module_debug.vsprops"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ WarningLevel="4"
+ WarnAsError="false"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalOptions="rpcrt4.lib"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ ConfigurationType="2"
+ InheritedPropertySheets="..\..\..\..\w32\module_release.vsprops"
+ CharacterSet="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <File
+ RelativePath="..\mod_skypiax\mod_skypiax.c"
+ >
+ </File>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
1
0
[commit] r10574 - in freeswitch/branches/gmaruzz/src: . include mod/endpoints/mod_skypiax mod/endpoints/mod_woomera
by FreeSWITCH SVN 03 Dec '08
by FreeSWITCH SVN 03 Dec '08
03 Dec '08
Author: gmaruzz
Date: Wed Dec 3 12:19:42 2008
New Revision: 10574
Log:
freeswitch_core_lib: added switch_file_pipe_create to switch_apr.c and switch_apr.h. skypiax: added stuff to compile on visual C. Almost there
Modified:
freeswitch/branches/gmaruzz/src/include/switch_apr.h
freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c
freeswitch/branches/gmaruzz/src/mod/endpoints/mod_woomera/mod_woomera.2008.vcproj
freeswitch/branches/gmaruzz/src/switch_apr.c
Modified: freeswitch/branches/gmaruzz/src/include/switch_apr.h
==============================================================================
--- freeswitch/branches/gmaruzz/src/include/switch_apr.h (original)
+++ freeswitch/branches/gmaruzz/src/include/switch_apr.h Wed Dec 3 12:19:42 2008
@@ -1303,6 +1303,7 @@
SWITCH_DECLARE(switch_status_t) switch_match_glob(const char *pattern, switch_array_header_t **result, switch_memory_pool_t *p);
SWITCH_DECLARE(switch_status_t) switch_socket_addr_get(switch_sockaddr_t **sa, switch_bool_t remote, switch_socket_t *sock);
+SWITCH_DECLARE(switch_status_t) switch_file_pipe_create_ex(switch_file_t **in, switch_file_t **out, int32_t blocking, switch_memory_pool_t *p);
/** @} */
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 Wed Dec 3 12:19:42 2008
@@ -34,12 +34,19 @@
*
*/
+#define WIN32_SKYPIAX
+#define __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"
@@ -118,12 +125,22 @@
static switch_memory_pool_t *module_pool = NULL;
static int running = 1;
+#ifndef WIN32_SKYPIAX
struct AsteriskHandles {
Window skype_win;
Display *disp;
Window win;
int fdesc[2];
};
+#else //WIN32_SKYPIAX
+
+struct AsteriskHandles {
+ HWND win32_hInit_MainWindowHandle;
+ HWND win32_hGlobal_SkypeAPIWindowHandle;
+ int fdesc[2];
+};
+
+#endif //WIN32_SKYPIAX
typedef enum {
@@ -183,7 +200,7 @@
double playback_boost;
double capture_boost;
int stripmsd;
- pthread_t skype_thread;
+ switch_thread_t *skype_thread;
char skype_call_id[512];
int skype_call_ongoing;
char skype_friends[4096];
@@ -258,6 +275,232 @@
int option_debug = 100;
switch_core_session_t *global_session = NULL;
+#ifdef WIN32_SKYPIAX
+#ifdef __CYGWIN__
+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
+};
+
+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) {
+
+ PCOPYDATASTRUCT poCopyData = (PCOPYDATASTRUCT) ulParam;
+ write(win32_AsteriskHandlesSkype->fdesc[1], (const char *) poCopyData->lpData,
+ strlen((const char *) poCopyData->lpData));
+ write(win32_AsteriskHandlesSkype->fdesc[1], "\0", 1);
+ 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 *do_skype_thread(void *data)
+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 */
+
+#if 0
+ res = pipe(p->AsteriskHandlesAst.fdesc);
+ if (res) {
+ ERRORA("Unable to create skype pipe, exiting skype thread\n", SKYPIAX_P_LOG);
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ return NULL;
+ }
+#endif //0
+
+ win32_AsteriskHandlesSkype = (struct AsteriskHandles *) obj;
+
+ 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 /* __CYGWIN__ */
+
+
+
+#endif //WIN32_SKYPIAX
+
+
static switch_status_t skypiax_codec(private_t *tech_pvt, int sample_rate, int codec_ms)
{
if (switch_core_codec_init(&tech_pvt->read_codec,
@@ -592,7 +835,7 @@
break;
}
} else {
- usleep(1000);
+ switch_sleep(1000);
}
}
@@ -648,8 +891,10 @@
}
return -1;
}
+#ifndef WIN32_SKYPIAX
fcntl(p->audioskypepipe[0], F_SETFL, O_NONBLOCK);
fcntl(p->audioskypepipe[1], F_SETFL, O_NONBLOCK);
+#endif// WIN32_SKYPIAX
if (option_debug > 10) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
@@ -686,7 +931,7 @@
if ((samples = read(p->audiopipe[0], tech_pvt->read_frame.data, SAMPLES_PER_FRAME * sizeof(short))) != 320) {
DEBUGA_SKYPE("read=====> NOT GOOD samples=%d expected=%d\n", SKYPIAX_P_LOG, samples,
320);
- usleep(1000);
+ switch_sleep(1000);
//do nothing
} else {
tech_pvt->read_frame.datalen=samples;
@@ -734,7 +979,7 @@
if ((samples = read(p->audiopipe[0], buf, SAMPLES_PER_FRAME * sizeof(short))) != 320) {
DEBUGA_SOUND("read=====> NOT GOOD samples=%d expected=%d\n", SKYPIAX_P_LOG, samples,
SAMPLES_PER_FRAME * sizeof(short));
- usleep(100);
+ switch_sleep(100);
//do nothing
} else {
//DEBUGA_SOUND("read=====> GOOD samples=%d\n", SKYPIAX_P_LOG, samples);
@@ -942,7 +1187,7 @@
if ((samples = read(p->audiopipe[0], buf, SAMPLES_PER_FRAME * sizeof(short))) != 320) {
DEBUGA_SOUND("read=====> NOT GOOD samples=%d expected=%d\n", SKYPIAX_P_LOG, samples,
SAMPLES_PER_FRAME * sizeof(short));
- usleep(100);
+ switch_sleep(100);
//do nothing
} else {
//DEBUGA_SOUND("read=====> GOOD samples=%d\n", SKYPIAX_P_LOG, samples);
@@ -1033,6 +1278,230 @@
}
+#if 1
+switch_file_t *readp = NULL;
+switch_file_t *writep = NULL;
+
+void create_pipe(void *data)
+{
+ switch_status_t rv;
+
+ //rv = switch_file_pipe_create_ex(&readp, &writep, APR_FULL_NONBLOCK, module_pool);
+ rv = switch_file_pipe_create_ex(&readp, &writep, 2, module_pool);
+ //rv = switch_file_pipe_create(&readp, &writep, module_pool);
+}
+#if 0
+//testpipe.c
+
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (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.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+
+#include "testutil.h"
+#include "apr_file_io.h"
+#include "apr_errno.h"
+#include "apr_general.h"
+#include "apr_lib.h"
+#include "apr_thread_proc.h"
+#include "apr_strings.h"
+
+static apr_file_t *readp = NULL;
+static apr_file_t *writep = NULL;
+
+static void create_pipe(abts_case *tc, void *data)
+{
+ apr_status_t rv;
+
+ rv = apr_file_pipe_create(&readp, &writep, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ ABTS_PTR_NOTNULL(tc, readp);
+ ABTS_PTR_NOTNULL(tc, writep);
+}
+
+static void close_pipe(abts_case *tc, void *data)
+{
+ apr_status_t rv;
+ apr_size_t nbytes = 256;
+ char buf[256];
+
+ rv = apr_file_close(readp);
+ rv = apr_file_close(writep);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_file_read(readp, buf, &nbytes);
+ ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_EBADF(rv));
+}
+
+static void set_timeout(abts_case *tc, void *data)
+{
+ apr_status_t rv;
+ apr_interval_time_t timeout;
+
+ rv = apr_file_pipe_create_ex(&readp, &writep, APR_WRITE_BLOCK, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ ABTS_PTR_NOTNULL(tc, readp);
+ ABTS_PTR_NOTNULL(tc, writep);
+
+ rv = apr_file_pipe_timeout_get(writep, &timeout);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ ABTS_ASSERT(tc, "Timeout mismatch, expected -1", timeout == -1);
+
+ rv = apr_file_pipe_timeout_set(readp, apr_time_from_sec(1));
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_file_pipe_timeout_get(readp, &timeout);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ ABTS_ASSERT(tc, "Timeout mismatch, expected 1 second",
+ timeout == apr_time_from_sec(1));
+}
+
+static void read_write(abts_case *tc, void *data)
+{
+ apr_status_t rv;
+ char *buf;
+ apr_size_t nbytes;
+
+ nbytes = strlen("this is a test");
+ buf = (char *)apr_palloc(p, nbytes + 1);
+
+ rv = apr_file_pipe_create_ex(&readp, &writep, APR_WRITE_BLOCK, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ ABTS_PTR_NOTNULL(tc, readp);
+ ABTS_PTR_NOTNULL(tc, writep);
+
+ rv = apr_file_pipe_timeout_set(readp, apr_time_from_sec(1));
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ if (!rv) {
+ rv = apr_file_read(readp, buf, &nbytes);
+ ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_TIMEUP(rv));
+ ABTS_SIZE_EQUAL(tc, 0, nbytes);
+ }
+}
+
+static void read_write_notimeout(abts_case *tc, void *data)
+{
+ apr_status_t rv;
+ char *buf = "this is a test";
+ char *input;
+ apr_size_t nbytes;
+
+ nbytes = strlen("this is a test");
+
+ rv = apr_file_pipe_create(&readp, &writep, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ ABTS_PTR_NOTNULL(tc, readp);
+ ABTS_PTR_NOTNULL(tc, writep);
+
+ rv = apr_file_write(writep, buf, &nbytes);
+ ABTS_SIZE_EQUAL(tc, strlen("this is a test"), nbytes);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ nbytes = 256;
+ input = apr_pcalloc(p, nbytes + 1);
+ rv = apr_file_read(readp, input, &nbytes);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ ABTS_SIZE_EQUAL(tc, strlen("this is a test"), nbytes);
+ ABTS_STR_EQUAL(tc, "this is a test", input);
+}
+
+static void test_pipe_writefull(abts_case *tc, void *data)
+{
+ int iterations = 1000;
+ int i;
+ int bytes_per_iteration = 8000;
+ char *buf = (char *)malloc(bytes_per_iteration);
+ char responsebuf[128];
+ apr_size_t nbytes;
+ int bytes_processed;
+ apr_proc_t proc = {0};
+ apr_procattr_t *procattr;
+ const char *args[2];
+ apr_status_t rv;
+ apr_exit_why_e why;
+
+ rv = apr_procattr_create(&procattr, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_procattr_io_set(procattr, APR_CHILD_BLOCK, APR_CHILD_BLOCK,
+ APR_CHILD_BLOCK);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_procattr_error_check_set(procattr, 1);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ args[0] = "readchild" EXTENSION;
+ args[1] = NULL;
+ rv = apr_proc_create(&proc, TESTBINPATH "readchild" EXTENSION, args, NULL, procattr, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_file_pipe_timeout_set(proc.in, apr_time_from_sec(10));
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_file_pipe_timeout_set(proc.out, apr_time_from_sec(10));
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ i = iterations;
+ do {
+ rv = apr_file_write_full(proc.in, buf, bytes_per_iteration, NULL);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ } while (--i);
+
+ free(buf);
+
+ rv = apr_file_close(proc.in);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ nbytes = sizeof(responsebuf);
+ rv = apr_file_read(proc.out, responsebuf, &nbytes);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ bytes_processed = (int)apr_strtoi64(responsebuf, NULL, 10);
+ ABTS_INT_EQUAL(tc, iterations * bytes_per_iteration, bytes_processed);
+
+ ABTS_ASSERT(tc, "wait for child process",
+ apr_proc_wait(&proc, NULL, &why, APR_WAIT) == APR_CHILD_DONE);
+
+ ABTS_ASSERT(tc, "child terminated normally", why == APR_PROC_EXIT);
+}
+
+abts_suite *testpipe(abts_suite *suite)
+{
+ suite = ADD_SUITE(suite)
+
+ abts_run_test(suite, create_pipe, NULL);
+ abts_run_test(suite, close_pipe, NULL);
+ abts_run_test(suite, set_timeout, NULL);
+ abts_run_test(suite, close_pipe, NULL);
+ abts_run_test(suite, read_write, NULL);
+ abts_run_test(suite, close_pipe, NULL);
+ abts_run_test(suite, read_write_notimeout, NULL);
+ abts_run_test(suite, test_pipe_writefull, NULL);
+ abts_run_test(suite, close_pipe, NULL);
+
+ return suite;
+}
+
+
+
+
+#endif
+
+
+#endif
static switch_status_t channel_answer_channel(switch_core_session_t *session)
{
private_t *tech_pvt;
@@ -1173,7 +1642,9 @@
/*.receive_event */ channel_receive_event
};
#define SKYPE_THREAD
+#ifndef WIN32_SKYPIAX
#ifdef SKYPE_THREAD
+
#define SKYPE_X11_BUF_SIZE 512
Window skype_win = (Window) - 1;
static XErrorHandler old_handler = 0;
@@ -1302,7 +1773,7 @@
DEBUGA_SKYPE("NOT destroyed disp\n", SKYPIAX_P_LOG);
}
DEBUGA_SKYPE("OUT destroyed disp\n", SKYPIAX_P_LOG);
- usleep(1000);
+ switch_sleep(1000);
}
static void *SWITCH_THREAD_FUNC do_skype_thread(switch_thread_t *thread, void *obj)
@@ -1427,7 +1898,7 @@
write(AsteriskHandlesAst->fdesc[1], b, strlen(b) + 1);
//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);
- //usleep(1000);
+ //switch_sleep(1000);
memset(buffer, '\0', 17000);
}
@@ -1454,6 +1925,11 @@
#endif /* SKYPE_THREAD */
+#else // WIN32_SKYPIAX
+
+
+
+#endif // WIN32_SKYPIAX
#define CONTROLDEV_THREAD
#ifdef CONTROLDEV_THREAD
@@ -1485,7 +1961,8 @@
("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;
- p->skype_thread = SKYPIAX_PTHREADT_NULL;
+ //FIXME p->skype_thread = SKYPIAX_PTHREADT_NULL;
+ p->skype_thread = NULL;
if (option_debug > 100) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
@@ -1578,7 +2055,7 @@
SKYPIAX_P_LOG);
sleep(1);
skypiax_skype_write(p, "PROTOCOL 6");
- usleep(10000);
+ switch_sleep(10000);
}
#endif
@@ -1758,15 +2235,15 @@
p->interface_state = SKYPIAX_STATE_RING;
/* no owner, no active call, let's answer */
skypiax_skype_write(p, "SET AGC OFF");
- usleep(10000);
+ switch_sleep(10000);
skypiax_skype_write(p, "SET AEC OFF");
- usleep(10000);
+ switch_sleep(10000);
sprintf(msg_to_skype, "GET CALL %s PARTNER_DISPNAME", id);
skypiax_skype_write(p, msg_to_skype);
- usleep(10000);
+ switch_sleep(10000);
sprintf(msg_to_skype, "GET CALL %s PARTNER_HANDLE", id);
skypiax_skype_write(p, msg_to_skype);
- usleep(10000);
+ switch_sleep(10000);
sprintf(msg_to_skype, "ALTER CALL %s ANSWER", id);
skypiax_skype_write(p, msg_to_skype);
if (option_debug)
@@ -1777,7 +2254,7 @@
/* 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);
- usleep(10000);
+ 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);
@@ -1952,13 +2429,13 @@
}
#endif
- usleep(100000);
+ switch_sleep(100000);
sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"5556\"", id);
skypiax_skype_write(p, msg_to_skype);
- usleep(100000);
+ switch_sleep(100000);
sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"5558\"", id);
skypiax_skype_write(p, msg_to_skype);
- usleep(100000);
+ switch_sleep(100000);
}
p->skype_callflow = SKYPIAX_STATE_UP;
@@ -2077,30 +2554,30 @@
int skypiax_skype_call(struct skypiax_interface *p, char *idest, int timeout, switch_core_session_t *session)
{
char rdest[80];
+ char msg_to_skype[1024];
if (option_debug > 10) {
DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
}
-usleep(5000);
+switch_sleep(5000);
//FIXME strncpy(rdest, idest, sizeof(rdest) - 1);
strncpy(rdest, "echo123", sizeof(rdest) - 1);
if (option_debug)
DEBUGA_SKYPE("Calling Skype, rdest is: %s\n", SKYPIAX_P_LOG, rdest);
//skypiax_skype_write(p, "GET AGC");
- //usleep(10000);
+ //switch_sleep(10000);
skypiax_skype_write(p, "SET AGC OFF");
- usleep(10000);
+ switch_sleep(10000);
//skypiax_skype_write(p, "GET AGC");
- //usleep(10000);
+ //switch_sleep(10000);
//skypiax_skype_write(p, "GET AEC");
- //usleep(10000);
+ //switch_sleep(10000);
skypiax_skype_write(p, "SET AEC OFF");
- usleep(10000);
+ switch_sleep(10000);
//skypiax_skype_write(p, "GET AEC");
- //usleep(300000);
+ //switch_sleep(300000);
- char msg_to_skype[1024];
sprintf(msg_to_skype, "CALL %s", rdest);
if (skypiax_skype_write(p, msg_to_skype) < 0) {
@@ -2184,7 +2661,7 @@
while (1) {
- usleep(1000);
+ switch_sleep(1000);
res = skypiax_skype_read(p);
#if 1
//if (res == CALLFLOW_INCOMING_HANGUP && p->interface_state != SKYPIAX_STATE_DOWN)
@@ -2393,7 +2870,7 @@
switch_thread_create(&thread, thd_attr, do_skype_thread, &SKYPIAX_INTERFACES[interface_id], module_pool);
}
-usleep(100000);
+switch_sleep(100000);
if(1)
{
switch_thread_t *thread;
@@ -2406,7 +2883,7 @@
}
-usleep(1000000);
+switch_sleep(1000000);
skypiax_skypeaudio_init(&SKYPIAX_INTERFACES[interface_id]);
@@ -2451,7 +2928,7 @@
} else {
DEBUGA_SKYPE("Initialized XInitThreads!\n", SKYPIAX_P_LOG);
}
-usleep(10000); //FIXME
+switch_sleep(10000); //FIXME
#endif /* _WINDOWS_ */
Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_woomera/mod_woomera.2008.vcproj
==============================================================================
--- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_woomera/mod_woomera.2008.vcproj (original)
+++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_woomera/mod_woomera.2008.vcproj Wed Dec 3 12:19:42 2008
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
- Version="9.00"
- Name="mod_woomera"
+ Version="9,00"
+ Name="mod_skypiax"
ProjectGUID="{FE3540C5-3303-46E0-A69E-D92F775687F1}"
RootNamespace="mod_woomera"
Keyword="Win32Proj"
@@ -40,6 +40,8 @@
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
+ WarningLevel="4"
+ WarnAsError="false"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@@ -52,6 +54,7 @@
/>
<Tool
Name="VCLinkerTool"
+ AdditionalOptions="rpcrt4.lib"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
/>
@@ -143,7 +146,7 @@
</References>
<Files>
<File
- RelativePath=".\mod_woomera.c"
+ RelativePath="..\mod_skypiax\mod_skypiax.c"
>
</File>
</Files>
Modified: freeswitch/branches/gmaruzz/src/switch_apr.c
==============================================================================
--- freeswitch/branches/gmaruzz/src/switch_apr.c (original)
+++ freeswitch/branches/gmaruzz/src/switch_apr.c Wed Dec 3 12:19:42 2008
@@ -942,6 +942,12 @@
return apr_match_glob(pattern, (apr_array_header_t **) result, p);
}
+SWITCH_DECLARE(switch_status_t) switch_file_pipe_create_ex(switch_file_t **in, switch_file_t **out, int32_t blocking, switch_memory_pool_t *p)
+{
+ //return apr_file_pipe_create_ex ((apr_file_t **) in, (apr_file_t **) out, blocking, p);
+ return apr_file_pipe_create ((apr_file_t **) in, (apr_file_t **) out, p);
+}
+
/* For Emacs:
* Local Variables:
* mode:c
1
0
[commit] r10523 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax
by FreeSWITCH SVN 24 Nov '08
by FreeSWITCH SVN 24 Nov '08
24 Nov '08
Author: gmaruzz
Date: Mon Nov 24 04:54:38 2008
New Revision: 10523
Log:
skypiax: cosmetics. After receiving at least one skype call, it can make outgoing calls and hangup them. If it has never answered a call, crashes when it hangup the call he originated
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 Mon Nov 24 04:54:38 2008
@@ -549,7 +549,7 @@
sin_size = sizeof(remote_addr);
while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) {
- ERRORA("ACCEPTED\n", SKYPIAX_P_LOG);
+ DEBUGA_SKYPE("ACCEPTED\n", SKYPIAX_P_LOG);
//while (1 && p->owner && p->owner->_state == SKYPIAX_STATE_UP) FIXME FIXME FIXME
while (p->interface_state != SKYPIAX_STATE_DOWN && (p->skype_callflow == CALLFLOW_STATUS_INPROGRESS ||p->skype_callflow == SKYPIAX_STATE_UP)) {
int fdselect;
@@ -777,7 +777,7 @@
{
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "skypiax_docec FAILED\n");
} else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "skypiax_codec SUCCESS\n");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "skypiax_codec SUCCESS\n");
}
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
@@ -808,6 +808,7 @@
globals.calls++;
switch_mutex_unlock(globals.mutex);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL INIT\n", switch_channel_get_name(channel));
return SWITCH_STATUS_SUCCESS;
}
@@ -839,7 +840,7 @@
tech_pvt = switch_core_session_get_private(session);
assert(tech_pvt != NULL);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s CHANNEL EXECUTE\n", switch_channel_get_name(channel));
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL EXECUTE\n", switch_channel_get_name(channel));
return SWITCH_STATUS_SUCCESS;
@@ -858,7 +859,7 @@
switch (sig) {
case SWITCH_SIG_KILL:
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s CHANNEL got SWITCH_SIG_KILL\n", switch_channel_get_name(channel));
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL got SWITCH_SIG_KILL\n", switch_channel_get_name(channel));
switch_clear_flag_locked(tech_pvt, TFLAG_IO);
switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
switch_set_flag_locked(tech_pvt, TFLAG_HANGUP);
@@ -867,7 +868,7 @@
//switch_thread_cond_signal(tech_pvt->cond);
break;
case SWITCH_SIG_BREAK:
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s CHANNEL got SWITCH_SIG_BREAK\n", switch_channel_get_name(channel));
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL got SWITCH_SIG_BREAK\n", switch_channel_get_name(channel));
switch_set_flag_locked(tech_pvt, TFLAG_BREAK);
break;
default:
@@ -1046,7 +1047,7 @@
p=tech_pvt->p;
- ERRORA("ANSWERED! \n", SKYPIAX_P_LOG);
+ DEBUGA_SKYPE("ANSWERED! \n", SKYPIAX_P_LOG);
return SWITCH_STATUS_SUCCESS;
}
@@ -1070,7 +1071,7 @@
case SWITCH_MESSAGE_INDICATE_ANSWER:
{
//WARNINGA("TO BE ANSWERED! \n", SKYPIAX_P_LOG);
- WARNINGA("MSG_ID=%d, TO BE ANSWERED!\n", SKYPIAX_P_LOG, msg->message_id);
+ DEBUGA_SKYPE("MSG_ID=%d, TO BE ANSWERED!\n", SKYPIAX_P_LOG, msg->message_id);
channel_answer_channel(session);
}
break;
@@ -1500,7 +1501,9 @@
}
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
@@ -1675,11 +1678,13 @@
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,
@@ -1964,7 +1969,6 @@
//FIXME *new_session=switch_loadable_module_create_interface(skypiax_endpoint_interface, pool);
-#ifndef NOTDEF
if (!global_session) { //FIXME FIXME FIXME
switch_core_session_t *session = NULL;
private_t *tech_pvt = NULL;
@@ -1987,7 +1991,6 @@
// 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 1
if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session),
"skypiax",
"XML",
@@ -2005,17 +2008,12 @@
switch_channel_set_name(channel, name);
switch_channel_set_caller_profile(channel, tech_pvt->caller_profile);
}
- WARNINGA("skype_call: HERE\n", SKYPIAX_P_LOG);
switch_channel_set_state(channel, CS_INIT);
- WARNINGA("skype_call: HERE\n", SKYPIAX_P_LOG);
if (switch_core_session_thread_launch(session) != SWITCH_STATUS_SUCCESS) {
- WARNINGA("skype_call: HERE\n", SKYPIAX_P_LOG);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error spawning thread\n");
switch_core_session_destroy(&session);
}
- WARNINGA("skype_call: HERE\n", SKYPIAX_P_LOG);
-#endif //0
#if 0
if (iax_set_codec(tech_pvt, iaxevent->session,
&iaxevent->ies.format, &iaxevent->ies.capability, &iaxevent->ies.samprate, IAX_SET) != SWITCH_STATUS_SUCCESS) {
@@ -2039,30 +2037,15 @@
private_t *tech_pvt = NULL;
switch_channel_t *channel = NULL;
- WARNINGA("skype_call: HERE\n", SKYPIAX_P_LOG);
- usleep(50000);
tech_pvt = p->tech_pvt;
- WARNINGA("skype_call: HERE\n", SKYPIAX_P_LOG);
- usleep(50000);
//session = tech_pvt->session;
session = global_session;
- WARNINGA("skype_call: HERE\n", SKYPIAX_P_LOG);
- usleep(5000000);
channel = switch_core_session_get_channel(session);
-
- WARNINGA("skype_call: HERE\n", SKYPIAX_P_LOG);
- usleep(50000);
-
-
switch_channel_mark_pre_answered(channel);
//switch_channel_set_state(channel, CS_EXECUTE);
- WARNINGA("skype_call: HERE\n", SKYPIAX_P_LOG);
- usleep(50000);
-
}
-#endif //NOTDEF
/**************************/
1
0
Author: gmaruzz
Date: Fri Nov 21 10:46:42 2008
New Revision: 10492
Log:
skypiax: config files
Modified:
freeswitch/branches/gmaruzz/stuff/skypiax.conf.xml
Modified: freeswitch/branches/gmaruzz/stuff/skypiax.conf.xml
==============================================================================
--- freeswitch/branches/gmaruzz/stuff/skypiax.conf.xml (original)
+++ freeswitch/branches/gmaruzz/stuff/skypiax.conf.xml Fri Nov 21 10:46:42 2008
@@ -1,5 +1,5 @@
<configuration name="skypiax.conf" description="Skypiax Configuration">
- <settings>
+ <global_settings>
<param name="debug" value="8"/>
<param name="port" value="4569"/>
<param name="ip" value="127.0.0.1"/>
@@ -8,10 +8,10 @@
<param name="codec-prefs" value="gsm,ulaw"/>
<param name="codec-rates" value="8000,16000"/>
<param name="hold-music" value="$${moh_uri}"/>
- </settings>
- <!-- one entry here per skypiax span -->
- <analog_spans>
- <span id="2" name="testing">
+ </global_settings>
+ <!-- one entry here per skypiax interface -->
+ <per_interface_settings>
+ <interface id="2" name="testing">
<param name="hold-music" value="$${moh_uri}"/>
<param name="tonegroup" value="us"/>
<param name="digit-timeout" value="2000"/>
@@ -22,9 +22,9 @@
<param name="dial-regex" value="9996"/>
<param name="dial-regex-fail" value="9996"/>
<param name="X11-display" value=":99"/>
- </span>
+ </interface>
<!-- following has no id, error! -->
- <span name="ciapalo">
+ <interface name="ciapalo">
<param name="hold-music" value="$${moh_uri}"/>
<param name="tonegroup" value="us"/>
<param name="digit-timeout" value="2000"/>
@@ -35,9 +35,9 @@
<param name="dial-regex" value="9996"/>
<param name="dial-regex-fail" value="9996"/>
<param name="X11-display" value=":991"/>
- </span>
+ </interface>
<!-- following has no id, error! -->
- <span>
+ <interface>
<param name="hold-music" value="$${moh_uri}"/>
<param name="tonegroup" value="us"/>
<param name="digit-timeout" value="2000"/>
@@ -48,8 +48,8 @@
<param name="dial-regex" value="9996"/>
<param name="dial-regex-fail" value="9996"/>
<param name="X11-display" value=":991"/>
- </span>
- <span id="55" name="cucu">
+ </interface>
+ <interface id="55" name="cucu">
<param name="hold-music" value="$${moh_uri}"/>
<param name="tonegroup" value="us"/>
<param name="digit-timeout" value="2000"/>
@@ -59,8 +59,8 @@
<param name="enable-callerid" value="true"/>
<param name="dial-regex" value="9996"/>
<param name="dial-regex-fail" value="9996"/>
- </span>
- <span id="55c" name="cucu">
+ </interface>
+ <interface id="55c" name="cucu">
<param name="hold-music" value="$${moh_uri}"/>
<param name="tonegroup" value="us"/>
<param name="digit-timeout" value="2000"/>
@@ -71,8 +71,8 @@
<param name="dial-regex" value="9996"/>
<param name="dial-regex-fail" value="9996"/>
<param name="X11-display" value=":991"/>
- </span>
- <span id="73">
+ </interface>
+ <interface id="73">
<param name="hold-music" value="$${moh_uri}"/>
<param name="tonegroup" value="us"/>
<param name="digit-timeout" value="2000"/>
@@ -83,8 +83,8 @@
<param name="dial-regex" value="9996"/>
<param name="dial-regex-fail" value="9996"/>
<param name="X11-display" value=":991"/>
- </span>
- <span id="3">
+ </interface>
+ <interface id="3">
<param name="hold-music" value="$${moh_uri}"/>
<param name="tonegroup" value="us"/>
<param name="digit-timeout" value="2000"/>
@@ -94,6 +94,6 @@
<param name="enable-callerid" value="true"/>
<param name="dial-regex" value="9996"/>
<param name="dial-regex-fail" value="9996"/>
- </span>
- </analog_spans>
+ </interface>
+ </per_interface_settings>
</configuration>
1
0
[commit] r10491 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax
by FreeSWITCH SVN 21 Nov '08
by FreeSWITCH SVN 21 Nov '08
21 Nov '08
Author: gmaruzz
Date: Fri Nov 21 10:44:46 2008
New Revision: 10491
Log:
skypiax: now it can be used for multiple consecutive calls, incoming and outbound. Time to begin a general rewriting.
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 Fri Nov 21 10:44:46 2008
@@ -194,8 +194,8 @@
int control_to_send;
int audiopipe[2];
int audioskypepipe[2];
- pthread_t tcp_srv_thread;
- pthread_t tcp_cli_thread;
+ switch_thread_t *tcp_srv_thread;
+ switch_thread_t *tcp_cli_thread;
short audiobuf[160];
int audiobuf_is_loaded;
@@ -436,7 +436,28 @@
sin_size = sizeof(remote_addr);
while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) {
DEBUGA_SKYPE("ACCEPTED\n", SKYPIAX_P_LOG);
- while (1) {
+ 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) {
@@ -467,6 +488,7 @@
exit = 1;
break;
}
+ }
}
DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG);
close(fd);
@@ -494,6 +516,7 @@
int a;
int i;
int got;
+ int exit=0;
if (option_debug > 10) {
DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
@@ -517,6 +540,7 @@
if (option_debug > 10) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
+ close(s);
return NULL;
}
DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
@@ -527,7 +551,27 @@
while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) {
ERRORA("ACCEPTED\n", SKYPIAX_P_LOG);
//while (1 && p->owner && p->owner->_state == SKYPIAX_STATE_UP) FIXME FIXME FIXME
- while (1) {
+ 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 = p->audioskypepipe[0];
+ 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) {
+
got = read(p->audioskypepipe[0], in, (NN / 2) * sizeof(short));
//ERRORA("got %d\n", SKYPIAX_P_LOG, got);
@@ -550,10 +594,13 @@
} else {
usleep(1000);
}
+ }
}
DEBUGA_SKYPE("Skype server GONE\n", SKYPIAX_P_LOG);
close(fd);
+ if (exit)
+ break;
}
DEBUGA_SKYPE("client (I am it) GONE\n", SKYPIAX_P_LOG);
@@ -614,6 +661,10 @@
struct skypiax_interface *p;
short buf[640];
int samples;
+ int fd;
+ int rt;
+ fd_set fs;
+ struct timeval to;
p = tech_pvt->p;
@@ -622,6 +673,14 @@
memset(buf, '\0', sizeof(buf));
+ fd = p->audiopipe[0];
+ FD_ZERO(&fs);
+ FD_SET(fd, &fs);
+ to.tv_usec = 100000;
+ to.tv_sec = 0;
+ rt = select(fd + 1, &fs, NULL, NULL, &to);
+ if (rt > 0) {
+
//if ((samples = read(p->audiopipe[0], buf, SAMPLES_PER_FRAME * sizeof(short))) != 320)
if ((samples = read(p->audiopipe[0], tech_pvt->read_frame.data, SAMPLES_PER_FRAME * sizeof(short))) != 320) {
@@ -634,6 +693,11 @@
//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);
@@ -794,12 +858,16 @@
switch (sig) {
case SWITCH_SIG_KILL:
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s CHANNEL got SWITCH_SIG_KILL\n", switch_channel_get_name(channel));
switch_clear_flag_locked(tech_pvt, TFLAG_IO);
switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
- switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
+ switch_set_flag_locked(tech_pvt, TFLAG_HANGUP);
+ //switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
+ //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "CHANNEL after TFLAG_HUP\n");
//switch_thread_cond_signal(tech_pvt->cond);
break;
case SWITCH_SIG_BREAK:
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%s CHANNEL got SWITCH_SIG_BREAK\n", switch_channel_get_name(channel));
switch_set_flag_locked(tech_pvt, TFLAG_BREAK);
break;
default:
@@ -852,7 +920,8 @@
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "skypiax_skypeaudio_read ERROR\n");
} else {
- //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "skypiax_skypeaudio_read SUCCESS\n");
+ switch_set_flag_locked(tech_pvt, TFLAG_VOICE);
+ //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "skypiax_skypeaudio_read SUCCESS\n");
}
@@ -888,8 +957,8 @@
}
#endif
+ //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "============>\n");
- switch_set_flag_locked(tech_pvt, TFLAG_VOICE); //FIXME
if (switch_test_flag(tech_pvt, TFLAG_IO) && switch_test_flag(tech_pvt, TFLAG_VOICE)) {
switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
@@ -904,9 +973,11 @@
}
#endif
return SWITCH_STATUS_SUCCESS;
- }
+ }
+
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL READ no TFLAG_IO\n");
+ return SWITCH_STATUS_FALSE;
- switch_yield(1000);
}
@@ -1831,52 +1902,50 @@
+#if 0
if (!p->tcp_srv_thread) {
if(1)
{
- switch_thread_t *thread;
+#endif
+ //switch_thread_t *thread;
+ 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(&thread, thd_attr, skypiax_do_tcp_srv_thread, p, module_pool);
+ 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);
+#if 0
}
}
+#endif
+#if 0
if (!p->tcp_cli_thread) {
if(1)
{
- switch_thread_t *thread;
- switch_threadattr_t *thd_attr = NULL;
+#endif
+ //switch_thread_t *thread;
+ //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(&thread, thd_attr, skypiax_do_tcp_cli_thread, p, module_pool);
+ 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);
}
+#if 0
+ }
-#ifdef NOTDEF
- if (ast_pthread_create
- (&p->tcp_cli_thread, NULL, skypiax_do_tcp_cli_thread, p) < 0) {
- ERRORA("Unable to start tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
- return -1;
- } else {
- DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
- }
-#endif //NOTDEF
}
+#endif
usleep(100000);
sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"5556\"", id);
@@ -2134,14 +2203,30 @@
while (1) {
usleep(1000);
res = skypiax_skype_read(p);
-#if 0
+#if 1
+ //if (res == CALLFLOW_INCOMING_HANGUP && p->interface_state != SKYPIAX_STATE_DOWN)
if (res == CALLFLOW_INCOMING_HANGUP) {
+ switch_core_session_t *session = NULL;
+ private_t *tech_pvt;
+ switch_channel_t *channel;
+
+
+ p->interface_state=SKYPIAX_STATE_DOWN;
//if (option_debug)
DEBUGA_SKYPE("skype call ended\n", SKYPIAX_P_LOG);
- if (p->owner) {
- pthread_testcancel();
- ast_queue_control(p->owner, SKYPIAX_CONTROL_HANGUP);
- }
+
+ tech_pvt = p->tech_pvt;
+ session = tech_pvt->session;
+
+ channel = switch_core_session_get_channel(session);
+ DEBUGA_SKYPE("before channel_on_hangup\n", SKYPIAX_P_LOG);
+
+ //switch_channel_set_state(channel, CS_HANGUP);
+
+ 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
}
@@ -2440,11 +2525,15 @@
switch_clear_flag_locked(tech_pvt, TFLAG_IO);
switch_clear_flag_locked(tech_pvt, TFLAG_VOICE);
- //switch_thread_cond_signal(tech_pvt->cond);
- WARNINGA("hanging up skype call: %s\n", SKYPIAX_P_LOG, p->skype_call_id);
- //sprintf(msg_to_skype, "SET CALL %s STATUS FINISHED", p->skype_call_id);
- sprintf(msg_to_skype, "ALTER CALL %s HANGUP", p->skype_call_id);
- skypiax_skype_write(p, msg_to_skype);
+ //switch_set_flag_locked(tech_pvt, TFLAG_HANGUP);
+
+ if(strlen(p->skype_call_id)) {
+ //switch_thread_cond_signal(tech_pvt->cond);
+ WARNINGA("hanging up skype call: %s\n", SKYPIAX_P_LOG, p->skype_call_id);
+ //sprintf(msg_to_skype, "SET CALL %s STATUS FINISHED", p->skype_call_id);
+ sprintf(msg_to_skype, "ALTER CALL %s HANGUP", p->skype_call_id);
+ skypiax_skype_write(p, msg_to_skype);
+ }
if (tech_pvt->read_codec.implementation) {
switch_core_codec_destroy(&tech_pvt->read_codec);
1
0
[commit] r10475 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax
by FreeSWITCH SVN 20 Nov '08
by FreeSWITCH SVN 20 Nov '08
20 Nov '08
Author: gmaruzz
Date: Thu Nov 20 07:33:09 2008
New Revision: 10475
Log:
skypiax: moved the launch of the audio server thread to the start of the call. The audio srv thread need to be made to die when the call ends
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 Thu Nov 20 07:33:09 2008
@@ -583,17 +583,6 @@
/* let's start the serial monitoring thread too, so we can have serial signaling */
-if(1)
-{
- switch_thread_t *thread;
- 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(&thread, thd_attr, skypiax_do_tcp_srv_thread, p, module_pool);
-}
-
/*
if (ast_pthread_create(&p->tcp_srv_thread, NULL, skypiax_do_tcp_srv_thread, p) < 0) {
ERRORA("Unable to start tcp_srv_thread thread.\n", SKYPIAX_P_LOG);
@@ -1836,44 +1825,67 @@
id);
//FIXME if (p->owner)
- if (1) {
- char msg_to_skype[1024];
- if (!p->tcp_cli_thread) {
-if(1)
-{
- switch_thread_t *thread;
- 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(&thread, thd_attr, skypiax_do_tcp_cli_thread, p, module_pool);
- DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
-}
+ if (1) {
+ char msg_to_skype[1024];
+
+
+
+ if (!p->tcp_srv_thread) {
+ if(1)
+ {
+ switch_thread_t *thread;
+ 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(&thread, thd_attr, skypiax_do_tcp_srv_thread, p, module_pool);
+ DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG);
+ }
+ }
+
+
+
+
+
+
+ if (!p->tcp_cli_thread) {
+ if(1)
+ {
+ switch_thread_t *thread;
+ 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(&thread, thd_attr, skypiax_do_tcp_cli_thread, p, module_pool);
+ DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
+ }
#ifdef NOTDEF
- if (ast_pthread_create
- (&p->tcp_cli_thread, NULL, skypiax_do_tcp_cli_thread, p) < 0) {
- ERRORA("Unable to start tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
- if (option_debug > 100) {
- DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
- }
- return -1;
- } else {
- DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
- }
+ if (ast_pthread_create
+ (&p->tcp_cli_thread, NULL, skypiax_do_tcp_cli_thread, p) < 0) {
+ ERRORA("Unable to start tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
+ if (option_debug > 100) {
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ }
+ return -1;
+ } else {
+ DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
+ }
#endif //NOTDEF
- }
+ }
- usleep(100000);
- sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"5556\"", id);
- skypiax_skype_write(p, msg_to_skype);
- usleep(100000);
- sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"5558\"", id);
- skypiax_skype_write(p, msg_to_skype);
- usleep(100000);
- }
+ usleep(100000);
+ sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"5556\"", id);
+ skypiax_skype_write(p, msg_to_skype);
+ usleep(100000);
+ sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"5558\"", id);
+ skypiax_skype_write(p, msg_to_skype);
+ usleep(100000);
+ }
p->skype_callflow = SKYPIAX_STATE_UP;
1
0
[commit] r10474 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax
by FreeSWITCH SVN 20 Nov '08
by FreeSWITCH SVN 20 Nov '08
20 Nov '08
Author: gmaruzz
Date: Thu Nov 20 07:17:01 2008
New Revision: 10474
Log:
skypiax: cosmetics
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 Thu Nov 20 07:17:01 2008
@@ -57,27 +57,27 @@
/*********************************/
-#define AST_CAUSE_NORMAL 1
+#define SKYPIAX_CAUSE_NORMAL 1
/*********************************/
-#define AST_FRAME_DTMF 1
+#define SKYPIAX_FRAME_DTMF 1
/*********************************/
-#define AST_CONTROL_RINGING 1
-#define AST_CONTROL_ANSWER 2
+#define SKYPIAX_CONTROL_RINGING 1
+#define SKYPIAX_CONTROL_ANSWER 2
/*********************************/
-#define AST_STATE_DOWN 1
-#define AST_STATE_RING 2
-#define AST_STATE_DIALING 3
-#define AST_STATE_BUSY 4
-#define AST_STATE_UP 5
-#define AST_STATE_RINGING 6
-#define AST_STATE_PRERING 7
+#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 AST_STATE_DOWN
-#define CALLFLOW_INCOMING_RING AST_STATE_RING
-#define CALLFLOW_CALL_DIALING AST_STATE_DIALING
-#define CALLFLOW_CALL_LINEBUSY AST_STATE_BUSY
+#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
@@ -98,7 +98,7 @@
#define CALLFLOW_STATUS_UNPLACED 116
#define CALLFLOW_STATUS_ROUTING 117
#define CALLFLOW_STATUS_EARLYMEDIA 118
-#define AST_STATE_HANGUP_REQUESTED 200
+#define SKYPIAX_STATE_HANGUP_REQUESTED 200
//FIXME CALLFLOW_INCOMING_CALLID to be removed
#define CALLFLOW_INCOMING_CALLID 1019
@@ -161,8 +161,8 @@
switch_mutex_t *mutex;
} globals;
-struct skypiax_config {
- char span_id[80];
+struct skypiax_interface {
+ char interface_id[80];
char name[80];
char dialplan[80];
char context[80];
@@ -212,9 +212,9 @@
void *tech_pvt;
};
-typedef struct skypiax_config skypiax_config_t;
+typedef struct skypiax_interface skypiax_interface_t;
-static skypiax_config_t SKYPIAX_CONFIGS[SKYPIAX_MAX_INTERFACES];
+static skypiax_interface_t SKYPIAX_INTERFACES[SKYPIAX_MAX_INTERFACES];
struct private_object {
@@ -227,7 +227,7 @@
switch_caller_profile_t *caller_profile;
switch_mutex_t *mutex;
switch_mutex_t *flag_mutex;
- skypiax_config_t *p;
+ skypiax_interface_t *p;
//switch_thread_cond_t *cond;
};
@@ -394,7 +394,7 @@
#define GG 160
static void *SWITCH_THREAD_FUNC skypiax_do_tcp_srv_thread(switch_thread_t *thread, void *obj)
{
- struct skypiax_config *p = obj;
+ struct skypiax_interface *p = obj;
short in[GG];
short out[GG / 2];
int s, fd, len, sent;
@@ -484,7 +484,7 @@
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_config *p = obj;
+ struct skypiax_interface *p = obj;
int s, fd, len;
short in[NN / 2];
short out[NN];
@@ -526,7 +526,7 @@
sin_size = sizeof(remote_addr);
while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) {
ERRORA("ACCEPTED\n", SKYPIAX_P_LOG);
- //while (1 && p->owner && p->owner->_state == AST_STATE_UP) FIXME FIXME FIXME
+ //while (1 && p->owner && p->owner->_state == SKYPIAX_STATE_UP) FIXME FIXME FIXME
while (1) {
got = read(p->audioskypepipe[0], in, (NN / 2) * sizeof(short));
@@ -565,7 +565,7 @@
}
-int skypiax_skypeaudio_init(struct skypiax_config *p)
+int skypiax_skypeaudio_init(struct skypiax_interface *p)
{
int c;
/* build the pipe that will be polled on by pbx */
@@ -622,7 +622,7 @@
}
static switch_status_t skypiax_skypeaudio_read(private_t *tech_pvt)
{
- struct skypiax_config *p;
+ struct skypiax_interface *p;
short buf[640];
int samples;
@@ -653,21 +653,21 @@
#ifdef NOTDEF
//cicopet
-struct ast_frame *skypiax_skypeaudio_read(struct skypiax_config *p)
+struct ast_frame *skypiax_skypeaudio_read(struct skypiax_interface *p)
{
static struct ast_frame f;
- static short __buf[SKYPIAX_FRAME_SIZE + AST_FRIENDLY_OFFSET / 2];
+ static short __buf[SKYPIAX_FRAME_SIZE + SKYPIAX_FRIENDLY_OFFSET / 2];
short *buf;
int samples;
if (option_debug > 100) {
DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
}
- memset(__buf, '\0', (SKYPIAX_FRAME_SIZE + AST_FRIENDLY_OFFSET / 2));
+ memset(__buf, '\0', (SKYPIAX_FRAME_SIZE + SKYPIAX_FRIENDLY_OFFSET / 2));
- buf = __buf + AST_FRIENDLY_OFFSET / 2;
+ buf = __buf + SKYPIAX_FRIENDLY_OFFSET / 2;
- f.frametype = AST_FRAME_NULL;
+ f.frametype = SKYPIAX_FRAME_NULL;
f.subclass = 0;
f.samples = 0;
f.datalen = 0;
@@ -686,12 +686,12 @@
} else {
//DEBUGA_SOUND("read=====> GOOD samples=%d\n", SKYPIAX_P_LOG, samples);
/* A real frame */
- f.frametype = AST_FRAME_VOICE;
- f.subclass = AST_FORMAT_SLINEAR;
+ f.frametype = SKYPIAX_FRAME_VOICE;
+ f.subclass = SKYPIAX_FORMAT_SLINEAR;
f.samples = SKYPIAX_FRAME_SIZE;
f.datalen = SKYPIAX_FRAME_SIZE * 2;
f.data = buf;
- f.offset = AST_FRIENDLY_OFFSET;
+ f.offset = SKYPIAX_FRIENDLY_OFFSET;
f.src = skypiax_type;
f.mallocd = 0;
}
@@ -704,9 +704,9 @@
#endif //NOTDEF
#endif /* SKYPE_AUDIO */
-static void tech_init(private_t *tech_pvt, switch_core_session_t *session, skypiax_config_t *p)
+static void tech_init(private_t *tech_pvt, switch_core_session_t *session, skypiax_interface_t *p)
{
- //struct skypiax_config *p = NULL;
+ //struct skypiax_interface *p = NULL;
DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
tech_pvt->read_frame.data = tech_pvt->databuf;
@@ -888,12 +888,12 @@
} else {
//DEBUGA_SOUND("read=====> GOOD samples=%d\n", SKYPIAX_P_LOG, samples);
/* A real frame */
- f.frametype = AST_FRAME_VOICE;
- f.subclass = AST_FORMAT_SLINEAR;
+ f.frametype = SKYPIAX_FRAME_VOICE;
+ f.subclass = SKYPIAX_FORMAT_SLINEAR;
f.samples = SKYPIAX_FRAME_SIZE;
f.datalen = SKYPIAX_FRAME_SIZE * 2;
f.data = buf;
- f.offset = AST_FRIENDLY_OFFSET;
+ f.offset = SKYPIAX_FRIENDLY_OFFSET;
f.src = skypiax_type;
f.mallocd = 0;
}
@@ -941,7 +941,7 @@
private_t *tech_pvt = NULL;
//switch_frame_t *pframe;
int sent;
- struct skypiax_config *p=NULL;
+ struct skypiax_interface *p=NULL;
//switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL WRITE FRAME\n");
@@ -976,7 +976,7 @@
{
private_t *tech_pvt;
switch_channel_t *channel = NULL;
- struct skypiax_config *p;
+ struct skypiax_interface *p;
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
@@ -996,7 +996,7 @@
{
switch_channel_t *channel;
private_t *tech_pvt;
- struct skypiax_config *p;
+ struct skypiax_interface *p;
channel = switch_core_session_get_channel(session);
assert(channel != NULL);
@@ -1038,7 +1038,7 @@
switch_core_session_add_stream(*new_session, NULL);
if ((tech_pvt = (private_t *) switch_core_session_alloc(*new_session, sizeof(private_t))) != 0) {
- tech_pvt->p = SKYPIAX_CONFIGS[2]; //FIXME
+ tech_pvt->p = SKYPIAX_INTERFACES[2]; //FIXME
channel = switch_core_session_get_channel(*new_session);
tech_init(tech_pvt, *new_session, NULL);
} else {
@@ -1121,7 +1121,7 @@
int X11_errors_handler(Display * dpy, XErrorEvent * err)
{
(void) dpy;
- struct skypiax_config *p = NULL;
+ struct skypiax_interface *p = NULL;
xerror = err->error_code;
DEBUGA_SKYPE("Received error code %d from X Server\n", SKYPIAX_P_LOG, xerror);
@@ -1147,7 +1147,7 @@
Window w_P;
Display *disp;
Window handle_P;
- struct skypiax_config *p = NULL;
+ struct skypiax_interface *p = NULL;
w_P = AsteriskHandlesAst->skype_win;
disp = AsteriskHandlesAst->disp;
@@ -1199,7 +1199,7 @@
unsigned long bytes_after_ret;
unsigned char *prop;
int status;
- struct skypiax_config *p = NULL;
+ struct skypiax_interface *p = NULL;
X11_errors_trap();
//XLockDisplay(disp);
@@ -1228,7 +1228,7 @@
int *dispptr;
int disp;
- struct skypiax_config *p = NULL;
+ struct skypiax_interface *p = NULL;
dispptr = data;
disp = *dispptr;
@@ -1247,7 +1247,7 @@
static void *SWITCH_THREAD_FUNC do_skype_thread(switch_thread_t *thread, void *obj)
{
- struct skypiax_config *p;
+ struct skypiax_interface *p;
struct AsteriskHandles *AsteriskHandlesAst;
char buf[SKYPE_X11_BUF_SIZE];
Display *disp = NULL;
@@ -1317,7 +1317,7 @@
("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypiax again\n",
SKYPIAX_P_LOG);
//p->skype = 0;
- //p->skype_thread = AST_PTHREADT_NULL;
+ //p->skype_thread = SKYPIAX_PTHREADT_NULL;
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
return NULL;
}
@@ -1328,7 +1328,7 @@
("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypiax again\n",
SKYPIAX_P_LOG);
//p->skype = 0;
- //p->skype_thread = AST_PTHREADT_NULL;
+ //p->skype_thread = SKYPIAX_PTHREADT_NULL;
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
return NULL;
}
@@ -1380,11 +1380,11 @@
("Skype is not running, maybe crashed. Please run/restart Skype and relaunch Skypiax\n",
SKYPIAX_P_LOG);
//p->skype = 0;
- //p->skype_thread = AST_PTHREADT_NULL;
+ //p->skype_thread = SKYPIAX_PTHREADT_NULL;
return NULL;
}
//p->skype = 0;
- //p->skype_thread = AST_PTHREADT_NULL;
+ //p->skype_thread = SKYPIAX_PTHREADT_NULL;
//pthread_cleanup_pop(1);
//DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
return NULL;
@@ -1399,7 +1399,7 @@
#if 1
#define WANT_SKYPE_X11
-int skypiax_skype_write(struct skypiax_config *p, char *msg_to_skype)
+int skypiax_skype_write(struct skypiax_interface *p, char *msg_to_skype)
{
#ifdef __CYGWIN__
static char acInputRow[1024];
@@ -1424,7 +1424,7 @@
("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;
- p->skype_thread = AST_PTHREADT_NULL;
+ p->skype_thread = SKYPIAX_PTHREADT_NULL;
if (option_debug > 100) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
@@ -1447,7 +1447,7 @@
("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;
- //p->skype_thread = AST_PTHREADT_NULL;
+ //p->skype_thread = SKYPIAX_PTHREADT_NULL;
if (option_debug > 100) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
@@ -1465,7 +1465,7 @@
#endif //0
-int skypiax_skype_read(struct skypiax_config *p)
+int skypiax_skype_read(struct skypiax_interface *p)
{
char read_from_pipe[4096];
@@ -1528,16 +1528,16 @@
DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG);
p->skype_call_id[0] = '\0';
- if (p->interface_state != AST_STATE_HANGUP_REQUESTED) {
+ if (p->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
if (option_debug > 100) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
- p->interface_state = AST_STATE_DOWN;
+ p->interface_state = SKYPIAX_STATE_DOWN;
//FIXME if(p->owner)
- //FIXME p->owner->hangupcause = AST_CAUSE_NORMAL;
+ //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL;
return CALLFLOW_INCOMING_HANGUP;
} else {
- p->interface_state = AST_STATE_DOWN;
+ p->interface_state = SKYPIAX_STATE_DOWN;
}
}
@@ -1577,17 +1577,17 @@
DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG);
p->skype_call_id[0] = '\0';
- if (p->interface_state != AST_STATE_HANGUP_REQUESTED) {
+ if (p->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
if (option_debug > 100) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
- p->interface_state = AST_STATE_DOWN;
+ p->interface_state = SKYPIAX_STATE_DOWN;
//FIXME if(p->owner){
- //FIXME p->owner->hangupcause = AST_CAUSE_NORMAL;
+ //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL;
//FIXME }
return CALLFLOW_INCOMING_HANGUP;
} else {
- p->interface_state = AST_STATE_DOWN;
+ p->interface_state = SKYPIAX_STATE_DOWN;
}
}
if (!strcasecmp(messaggio, "CALL")) {
@@ -1624,13 +1624,13 @@
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 == AST_STATE_DOWN)
- p->interface_state = AST_STATE_PRERING;
+ 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 == AST_STATE_DOWN)
- p->interface_state = AST_STATE_PRERING;
+ if (p->interface_state == SKYPIAX_STATE_DOWN)
+ p->interface_state = SKYPIAX_STATE_PRERING;
}
if (!strcasecmp(prop, "DTMF")) {
@@ -1638,7 +1638,7 @@
private_t *tech_pvt = NULL;
switch_channel_t *channel = NULL;
- //FIXME struct ast_frame f2 = { AST_FRAME_DTMF, value[0], };
+ //FIXME struct ast_frame f2 = { SKYPIAX_FRAME_DTMF, value[0], };
DEBUGA_SKYPE("Call %s received a DTMF: %s\n", SKYPIAX_P_LOG, id, value);
tech_pvt = p->tech_pvt;
@@ -1683,14 +1683,14 @@
if (!strcasecmp(value, "RINGING")) {
char msg_to_skype[1024];
- if (p->interface_state != AST_STATE_DIALING) {
+ if (p->interface_state != SKYPIAX_STATE_DIALING) {
/* we are not calling out */
//FIXME if (!p->owner)
if (1) {
/* we are not inside an active call */
p->skype_callflow = CALLFLOW_STATUS_RINGING;
- p->interface_state = AST_STATE_RING;
+ p->interface_state = SKYPIAX_STATE_RING;
/* no owner, no active call, let's answer */
skypiax_skype_write(p, "SET AGC OFF");
usleep(10000);
@@ -1721,16 +1721,16 @@
} else {
/* we are calling out */
p->skype_callflow = CALLFLOW_STATUS_RINGING;
- p->interface_state = AST_STATE_RINGING;
- //FIXME ast_queue_control(p->owner, AST_CONTROL_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 = AST_STATE_DIALING;
- //FIXME ast_queue_control(p->owner, AST_CONTROL_RINGING);
+ 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")) {
@@ -1743,16 +1743,16 @@
DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id);
p->skype_call_id[0] = '\0';
- if (p->interface_state != AST_STATE_HANGUP_REQUESTED) {
+ if (p->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
if (option_debug > 100) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
- p->interface_state = AST_STATE_DOWN;
+ p->interface_state = SKYPIAX_STATE_DOWN;
//FIXME if(p->owner)
- //FIXME p->owner->hangupcause = AST_CAUSE_NORMAL;
+ //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL;
return CALLFLOW_INCOMING_HANGUP;
} else {
- p->interface_state = AST_STATE_DOWN;
+ p->interface_state = SKYPIAX_STATE_DOWN;
}
} else if (!strcasecmp(value, "CANCELLED")) {
@@ -1763,16 +1763,16 @@
SKYPIAX_P_LOG, id);
p->skype_call_id[0] = '\0';
- if (p->interface_state != AST_STATE_HANGUP_REQUESTED) {
+ if (p->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
if (option_debug > 100) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
- p->interface_state = AST_STATE_DOWN;
+ p->interface_state = SKYPIAX_STATE_DOWN;
//FIXME if(p->owner)
- //FIXME p->owner->hangupcause = AST_CAUSE_NORMAL;
+ //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL;
return CALLFLOW_INCOMING_HANGUP;
} else {
- p->interface_state = AST_STATE_DOWN;
+ p->interface_state = SKYPIAX_STATE_DOWN;
}
} else if (!strcasecmp(value, "FAILED")) {
p->skype_callflow = CALLFLOW_STATUS_FAILED;
@@ -1782,12 +1782,12 @@
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 = AST_STATE_DOWN;
+ p->interface_state = SKYPIAX_STATE_DOWN;
if (option_debug > 100) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
//FIXME if(p->owner)
- //FIXME p->owner->hangupcause = AST_CAUSE_NORMAL;
+ //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL;
return CALLFLOW_INCOMING_HANGUP;
} else if (!strcasecmp(value, "REFUSED")) {
if (!strcasecmp(id, p->skype_call_id)) {
@@ -1798,13 +1798,13 @@
("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 = AST_STATE_DOWN;
+ p->interface_state = SKYPIAX_STATE_DOWN;
p->skype_call_id[0] = '\0';
if (option_debug > 100) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
//FIXME if(p->owner)
- //FIXME p->owner->hangupcause = AST_CAUSE_NORMAL;
+ //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL;
return CALLFLOW_INCOMING_HANGUP;
} else {
/* we're here because were us that refused an incoming call */
@@ -1813,26 +1813,26 @@
}
} else if (!strcasecmp(value, "ROUTING")) {
p->skype_callflow = CALLFLOW_STATUS_ROUTING;
- p->interface_state = AST_STATE_DIALING;
+ 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 = AST_STATE_DIALING;
+ 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 = AST_STATE_UP;
+ p->interface_state = SKYPIAX_STATE_UP;
if (option_debug > 1)
DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id);
//FIXME if (p->owner) {
- //FIXME ast_queue_control(p->owner, AST_CONTROL_ANSWER);
+ //FIXME ast_queue_control(p->owner, SKYPIAX_CONTROL_ANSWER);
//FIXME }
if (option_debug > 1)
- DEBUGA_SKYPE("skype_call: %s AST_CONTROL_ANSWER sent\n", SKYPIAX_P_LOG,
+ DEBUGA_SKYPE("skype_call: %s SKYPIAX_CONTROL_ANSWER sent\n", SKYPIAX_P_LOG,
id);
//FIXME if (p->owner)
@@ -1875,7 +1875,7 @@
usleep(100000);
}
- p->skype_callflow = AST_STATE_UP;
+ p->skype_callflow = SKYPIAX_STATE_UP;
/**************************/
@@ -2010,7 +2010,7 @@
return 0;
}
-int skypiax_skype_call(struct skypiax_config *p, char *idest, int timeout, switch_core_session_t *session)
+int skypiax_skype_call(struct skypiax_interface *p, char *idest, int timeout, switch_core_session_t *session)
{
char rdest[80];
@@ -2050,9 +2050,9 @@
//p->skype_call_ongoing = 1;
//if (p->owner) {
- //ast_setstate(p->owner, AST_STATE_RINGING);
+ //ast_setstate(p->owner, SKYPIAX_STATE_RINGING);
//}
- //FIXME ast_queue_control(p->owner, AST_CONTROL_RINGING);
+ //FIXME ast_queue_control(p->owner, SKYPIAX_CONTROL_RINGING);
return 0;
}
@@ -2067,7 +2067,7 @@
switch_core_session_add_stream(*new_session, NULL);
if ((tech_pvt = (private_t *) switch_core_session_alloc(*new_session, sizeof(private_t))) != 0) {
- tech_pvt->p = &SKYPIAX_CONFIGS[2]; //FIXME
+ tech_pvt->p = &SKYPIAX_INTERFACES[2]; //FIXME
channel = switch_core_session_get_channel(*new_session);
tech_init(tech_pvt, *new_session, NULL);
} else {
@@ -2111,7 +2111,7 @@
static void *SWITCH_THREAD_FUNC skypiax_do_controldev_thread(switch_thread_t *thread, void *obj)
//void *skypiax_do_controldev_thread(void *data)
{
- struct skypiax_config *p = obj;
+ struct skypiax_interface *p = obj;
int res;
DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
@@ -2128,7 +2128,7 @@
DEBUGA_SKYPE("skype call ended\n", SKYPIAX_P_LOG);
if (p->owner) {
pthread_testcancel();
- ast_queue_control(p->owner, AST_CONTROL_HANGUP);
+ ast_queue_control(p->owner, SKYPIAX_CONTROL_HANGUP);
}
}
#endif
@@ -2147,21 +2147,21 @@
static switch_status_t load_config(void)
{
char *cf = "skypiax.conf";
- switch_xml_t cfg, xml, settings, param, spans, myspan;
+ switch_xml_t cfg, xml, global_settings, param, interfaces, myinterface;
- memset(&globals, 0, sizeof(globals));
switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, 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;
}
- if ((settings = switch_xml_child(cfg, "settings"))) {
- for (param = switch_xml_child(settings, "param"); param; param = param->next) {
+ if ((global_settings = switch_xml_child(cfg, "global_settings"))) {
+ for (param = switch_xml_child(global_settings, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr_soft(param, "name");
char *val = (char *) switch_xml_attr_soft(param, "value");
if (!strcasecmp(var, "debug")) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "globals.debug=%d\n", globals.debug);
globals.debug = atoi(val);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "globals.debug=%d\n", globals.debug);
} else if (!strcasecmp(var, "hold-music")) {
@@ -2194,12 +2194,12 @@
}
}
- if ((spans = switch_xml_child(cfg, "analog_spans"))) {
+ if ((interfaces = switch_xml_child(cfg, "per_interface_settings"))) {
int i=0;
- for (myspan = switch_xml_child(spans, "span"); myspan; myspan = myspan->next) {
- char *id = (char *) switch_xml_attr(myspan, "id");
- char *name = (char *) switch_xml_attr(myspan, "name");
+ for (myinterface = switch_xml_child(interfaces, "interface"); myinterface; myinterface = myinterface->next) {
+ char *id = (char *) switch_xml_attr(myinterface, "id");
+ char *name = (char *) switch_xml_attr(myinterface, "name");
char *context = "default";
char *dialplan = "XML";
char *tonegroup = NULL;
@@ -2212,9 +2212,9 @@
char *enable_callerid = "true";
char *X11_display = NULL;
- uint32_t span_id = 0, to = 0, max = 0;
+ uint32_t interface_id = 0, to = 0, max = 0;
- for (param = switch_xml_child(myspan, "param"); param; param = param->next) {
+ for (param = switch_xml_child(myinterface, "param"); param; param = param->next) {
char *var = (char *) switch_xml_attr_soft(param, "name");
char *val = (char *) switch_xml_attr_soft(param, "value");
@@ -2245,25 +2245,25 @@
}
if (!X11_display) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "span missing REQUIRED param 'X11_display'\n");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "interface missing REQUIRED param 'X11_display'\n");
continue;
}
if (!id) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "span missing REQUIRED param 'id'\n");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "interface missing REQUIRED param 'id'\n");
continue;
}
if (switch_is_number(id)) {
- span_id = atoi(id);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "span_id=%d\n", span_id);
+ interface_id = atoi(id);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "interface_id=%d\n", interface_id);
} else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "span param 'id' MUST be a number, now id='%s'\n", id);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "interface param 'id' MUST be a number, now id='%s'\n", id);
continue;
}
if (!name) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "span missing param 'name', not nice, but works\n");
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "interface missing param 'name', not nice, but works\n");
}
if (!tonegroup) {
@@ -2281,25 +2281,25 @@
if (name) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "name=%s\n", name);
}
- if(span_id && span_id < SKYPIAX_MAX_INTERFACES ) {
- struct skypiax_config newconf;
+ if(interface_id && interface_id < SKYPIAX_MAX_INTERFACES ) {
+ struct skypiax_interface newconf;
memset(&newconf, '\0', sizeof(newconf));
- SKYPIAX_CONFIGS[span_id]=newconf;
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CONFIGURING span_id=%d\n", span_id);
- switch_set_string(SKYPIAX_CONFIGS[span_id].span_id, id);
+ SKYPIAX_INTERFACES[interface_id]=newconf;
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CONFIGURING interface_id=%d\n", interface_id);
+ switch_set_string(SKYPIAX_INTERFACES[interface_id].interface_id, id);
if (name) {
- switch_set_string(SKYPIAX_CONFIGS[span_id].name, name);
+ switch_set_string(SKYPIAX_INTERFACES[interface_id].name, name);
} else {
- switch_set_string(SKYPIAX_CONFIGS[span_id].name, "N/A");
+ switch_set_string(SKYPIAX_INTERFACES[interface_id].name, "N/A");
}
- switch_set_string(SKYPIAX_CONFIGS[span_id].X11_display, X11_display);
- switch_set_string(SKYPIAX_CONFIGS[span_id].context, context);
- switch_set_string(SKYPIAX_CONFIGS[span_id].dialplan, dialplan);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "span_id=%d SKYPIAX_CONFIGS[span_id].X11_display=%s\n", span_id, SKYPIAX_CONFIGS[span_id].X11_display);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "span_id=%d SKYPIAX_CONFIGS[span_id].name=%s\n", span_id, SKYPIAX_CONFIGS[span_id].name);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "span_id=%d SKYPIAX_CONFIGS[span_id].context=%s\n", span_id, SKYPIAX_CONFIGS[span_id].context);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "span_id=%d SKYPIAX_CONFIGS[span_id].dialplan=%s\n", span_id, SKYPIAX_CONFIGS[span_id].dialplan);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "STARTING span_id=%d\n", span_id);
+ switch_set_string(SKYPIAX_INTERFACES[interface_id].X11_display, X11_display);
+ switch_set_string(SKYPIAX_INTERFACES[interface_id].context, context);
+ switch_set_string(SKYPIAX_INTERFACES[interface_id].dialplan, dialplan);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "interface_id=%d SKYPIAX_INTERFACES[interface_id].X11_display=%s\n", interface_id, SKYPIAX_INTERFACES[interface_id].X11_display);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "interface_id=%d SKYPIAX_INTERFACES[interface_id].name=%s\n", interface_id, SKYPIAX_INTERFACES[interface_id].name);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "interface_id=%d SKYPIAX_INTERFACES[interface_id].context=%s\n", interface_id, SKYPIAX_INTERFACES[interface_id].context);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "interface_id=%d SKYPIAX_INTERFACES[interface_id].dialplan=%s\n", interface_id, SKYPIAX_INTERFACES[interface_id].dialplan);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "STARTING interface_id=%d\n", interface_id);
if(1)
@@ -2310,7 +2310,7 @@
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(&thread, thd_attr, do_skype_thread, &SKYPIAX_CONFIGS[span_id], module_pool);
+ switch_thread_create(&thread, thd_attr, do_skype_thread, &SKYPIAX_INTERFACES[interface_id], module_pool);
}
usleep(100000);
@@ -2322,31 +2322,31 @@
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(&thread, thd_attr, skypiax_do_controldev_thread, &SKYPIAX_CONFIGS[span_id], module_pool);
+ switch_thread_create(&thread, thd_attr, skypiax_do_controldev_thread, &SKYPIAX_INTERFACES[interface_id], module_pool);
}
usleep(1000000);
-skypiax_skypeaudio_init(&SKYPIAX_CONFIGS[span_id]);
+skypiax_skypeaudio_init(&SKYPIAX_INTERFACES[interface_id]);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "STARTED span_id=%d\n", span_id);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "STARTED interface_id=%d\n", interface_id);
} else {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "span id %d is higher than SKYPIAX_MAX_INTERFACES (%d)\n", span_id, SKYPIAX_MAX_INTERFACES);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "interface id %d is higher than SKYPIAX_MAX_INTERFACES (%d)\n", interface_id, SKYPIAX_MAX_INTERFACES);
continue;
}
}
for(i=0; i < SKYPIAX_MAX_INTERFACES; i++) {
- if(strlen(SKYPIAX_CONFIGS[i].name)) {
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "i=%d SKYPIAX_CONFIGS[i].span_id=%s\n", i, SKYPIAX_CONFIGS[i].span_id);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "i=%d SKYPIAX_CONFIGS[i].X11_display=%s\n", i, SKYPIAX_CONFIGS[i].X11_display);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "i=%d SKYPIAX_CONFIGS[i].name=%s\n", i, SKYPIAX_CONFIGS[i].name);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "i=%d SKYPIAX_CONFIGS[i].context=%s\n", i, SKYPIAX_CONFIGS[i].context);
- switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "i=%d SKYPIAX_CONFIGS[i].dialplan=%s\n", i, SKYPIAX_CONFIGS[i].dialplan);
+ if(strlen(SKYPIAX_INTERFACES[i].name)) {
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "i=%d SKYPIAX_INTERFACES[%d].interface_id=%s\n", i, i, SKYPIAX_INTERFACES[i].interface_id);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "i=%d SKYPIAX_INTERFACES[%d].X11_display=%s\n", i, i, SKYPIAX_INTERFACES[i].X11_display);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "i=%d SKYPIAX_INTERFACES[%d].name=%s\n", i, i, SKYPIAX_INTERFACES[i].name);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "i=%d SKYPIAX_INTERFACES[%d].context=%s\n", i, i, SKYPIAX_INTERFACES[i].context);
+ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "i=%d SKYPIAX_INTERFACES[%d].dialplan=%s\n", i, i, SKYPIAX_INTERFACES[i].dialplan);
}
}
}
@@ -2358,10 +2358,13 @@
SWITCH_MODULE_LOAD_FUNCTION(mod_skypiax_load)
{
- struct skypiax_config *p = NULL;
+ struct skypiax_interface *p = NULL;
module_pool = pool;
+ memset(&globals, '\0', sizeof(globals));
+ memset(SKYPIAX_INTERFACES, '\0', sizeof(SKYPIAX_INTERFACES));
+
#ifndef _WINDOWS_ //FIXME
if (!XInitThreads()) {
ERRORA("Not initialized XInitThreads!\n", SKYPIAX_P_LOG);
@@ -2412,7 +2415,7 @@
{
switch_channel_t *channel = NULL;
private_t *tech_pvt = NULL;
- skypiax_config_t *p;
+ skypiax_interface_t *p;
char msg_to_skype[256];
channel = switch_core_session_get_channel(session);
1
0