Author: gmaruzz Date: Sat Dec 13 05:29:42 2008 New Revision: 10751 Log: skypiax: cleaning, restructuring Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c (original) +++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c Sat Dec 13 05:29:42 2008 @@ -33,7 +33,6 @@ int running = 1; switch_core_session_t *global_session = NULL; #ifdef WIN32 -HANDLE win32_hGlobal_ThreadShutdownEvent; HWND win32_hInit_MainWindowHandle; #endif /* WIN32 */ /*************************************************/ Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c Sat Dec 13 05:29:42 2008 @@ -8,31 +8,50 @@ #ifdef WIN32 extern HWND win32_hInit_MainWindowHandle; #endif /* WIN32 */ +/**********************************************************/ +/**********************************************************/ +/**********************************************************/ +#ifdef WIN32 +struct AsteriskHandles *win32_AsteriskHandlesSkype; +HINSTANCE win32_hInit_ProcessHandle; +char win32_acInit_WindowClassName[128]; +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; +#else /* NOT WIN32 */ +#define SKYPE_X11_BUF_SIZE 512 +Window skype_win = (Window) - 1; +static XErrorHandler old_handler = 0; +static int xerror = 0; +#endif /* WIN32 */ +/**********************************************************/ +/**********************************************************/ +/**********************************************************/ +#define SAMPLES_PER_FRAME 160 +#define SAMPLES_PER_FRAME 160 +#define SAMPLES_PER_FRAME 160 -#define SKYPE_AUDIO -#ifdef SKYPE_AUDIO -#define SAMPLES_PER_FRAME 160 -#define NN 160 -#define GG 160 static void *SWITCH_THREAD_FUNC skypiax_do_tcp_srv_thread(switch_thread_t * thread, void *obj) { struct skypiax_interface *p = obj; - short srv_out[GG / 2]; + short srv_out[SAMPLES_PER_FRAME / 2]; int s; #ifdef WIN32 unsigned int len; unsigned int i; unsigned int a; - short srv_in[GG]; + short srv_in[SAMPLES_PER_FRAME]; int sin_size; unsigned int fd; #else int len; int i; int a; - short srv_in[GG]; + short srv_in[SAMPLES_PER_FRAME]; unsigned int sin_size; int fd; #endif /* WIN32 */ @@ -99,7 +118,7 @@ rt = select(fdselect + 1, &fs, NULL, NULL, &to); if (rt > 0) { - len = recv(fd, srv_in, sizeof(short) * GG, 0); + len = recv(fd, srv_in, sizeof(short) * SAMPLES_PER_FRAME, 0); //DEBUGA_SKYPE("recv %d\n", SKYPIAX_P_LOG, len); if (len > 0) { a = 0; @@ -116,7 +135,7 @@ p->audiobuf_is_loaded = 1; } else { unsigned int howmany; - short totalbuf[GG]; + short totalbuf[SAMPLES_PER_FRAME]; howmany = len / 2 / 2; for (i = 0; i < howmany; i++) @@ -132,7 +151,7 @@ switch_file_write(p->audiopipe[1], totalbuf, &howmany); p->audiobuf_is_loaded = 0; - //DEBUGA_SKYPE("read=====> req=%d recv=%d to sent=%d sent=%d\n", SKYPIAX_P_LOG, sizeof(short)*GG, len, (len*sizeof(short))/2, howmany); + //DEBUGA_SKYPE("read=====> req=%d recv=%d to sent=%d sent=%d\n", SKYPIAX_P_LOG, sizeof(short)*SAMPLES_PER_FRAME, len, (len*sizeof(short))/2, howmany); } } else if (len == 0) { @@ -191,16 +210,16 @@ unsigned int len; unsigned int i; unsigned int a; - short cli_in[NN / 2]; - short cli_out[NN]; + short cli_in[SAMPLES_PER_FRAME / 2]; + short cli_out[SAMPLES_PER_FRAME]; int sin_size; unsigned int fd; #else int len; int i; int a; - short cli_in[NN / 2]; - short cli_out[NN]; + short cli_in[SAMPLES_PER_FRAME / 2]; + short cli_out[SAMPLES_PER_FRAME]; unsigned int sin_size; int fd; #endif /* WIN32 */ @@ -264,7 +283,7 @@ rt = 1; if (rt > 0) { - got = (NN / 2) * sizeof(short); + got = (SAMPLES_PER_FRAME / 2) * sizeof(short); switch_file_read(p->audioskypepipe[0], cli_in, &got); if (got > 0) { @@ -374,17 +393,8 @@ return SWITCH_STATUS_SUCCESS; } -#endif /* SKYPE_AUDIO */ #ifdef WIN32 -struct AsteriskHandles *win32_AsteriskHandlesSkype; -HINSTANCE win32_hInit_ProcessHandle; -char win32_acInit_WindowClassName[128]; -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 @@ -620,12 +630,6 @@ } #else /* NOT WIN32 */ - -#define SKYPE_X11_BUF_SIZE 512 -Window skype_win = (Window) - 1; -static XErrorHandler old_handler = 0; -static int xerror = 0; - int X11_errors_handler(Display * dpy, XErrorEvent * err) { (void) dpy;