[commit] r11116 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax
Author: gmaruzz Date: Sun Jan 11 02:47:02 2009 New Revision: 11116 Log: skypiax: cosmetics Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c Sun Jan 11 02:47:02 2009 @@ -1,26 +1,10 @@ #include "skypiax.h" -//#include <netinet/tcp.h> extern switch_memory_pool_t *skypiax_module_pool; extern int option_debug; extern switch_endpoint_interface_t *skypiax_endpoint_interface; extern int running; -/**********************************************************/ -/**********************************************************/ -/**********************************************************/ - -//extern switch_core_session_t *global_session; - -#ifdef WIN32 -#else /* NOT WIN32 */ -#define SKYPE_X11_BUF_SIZE 512 -#endif /* WIN32 */ - -/**********************************************************/ -/**********************************************************/ -/**********************************************************/ - static void *SWITCH_THREAD_FUNC skypiax_do_tcp_srv_thread(switch_thread_t * thread, void *obj) { @@ -49,7 +33,6 @@ unsigned int kill_cli_size; short kill_cli_buff[SAMPLES_PER_FRAME]; short totalbuf[SAMPLES_PER_FRAME]; - //int one = 1; if (option_debug > 100) { DEBUGA_SKYPE("ENTERING FUNC\n", SKYPIAX_P_LOG); @@ -66,7 +49,6 @@ } return NULL; } - //setsockopt(s, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one)); if (bind(s, (struct sockaddr *) &my_addr, sizeof(struct sockaddr)) < 0) { ERRORA("bind Error\n", SKYPIAX_P_LOG); @@ -105,11 +87,10 @@ fdselect = fd; FD_ZERO(&fs); FD_SET(fdselect, &fs); - to.tv_usec = 2000000; //20 msec + to.tv_usec = 2000000; //2000 msec to.tv_sec = 0; rt = select(fdselect + 1, &fs, NULL, NULL, &to); - //rt=1; if (rt > 0) { #ifdef WIN32 @@ -123,13 +104,10 @@ } if (len) len = received; - - //len = recv(fd, srv_in, SAMPLES_PER_FRAME * sizeof(short), 0); //seems that Skype only sends 320 bytes at time #endif /* WIN32 */ if ((SAMPLERATE_SKYPIAX - 8000) == 0) { - /****************************************************************/ if (len > 0) { a = 0; for (i = 0; i < len / sizeof(short); i++) { @@ -164,7 +142,6 @@ howmany = write(p->audiopipe[1], totalbuf, howmany); #endif /* WIN32 */ p->audiobuf_is_loaded = 0; - //DEBUGA_SKYPE("read=====> req=%d recv=%d to sent=%d sent=%d\n", SKYPIAX_P_LOG, sizeof(short)*SAMPLES_PER_FRAME, len, (len*sizeof(short))/2, howmany); } } else if (len == 0) { @@ -175,30 +152,19 @@ exit = 1; break; } - /****************************************************************/ } else if (SAMPLERATE_SKYPIAX == 16000) { - /****************************************************************/ if (len > 0) { if (len == SAMPLES_PER_FRAME * sizeof(short)) { #ifdef WIN32 unsigned int howmany; - howmany = len; - - //WARNINGA("SRV recv %d\n", SKYPIAX_P_LOG, len); + howmany = len; switch_file_write(p->audiopipe[1], srv_in, &howmany); #else /* WIN32 */ len = write(p->audiopipe[1], srv_in, len); #endif /* WIN32 */ - //p->audiobuf_is_loaded = 0; - //WARNINGA("SRV PIPE WRITE=====> req=%lu recv=%d to sent=%d sent=%u\n", - //SKYPIAX_P_LOG, sizeof(short) * SAMPLES_PER_FRAME, len, len, - //howmany); } else if (len == SAMPLES_PER_FRAME * sizeof(short) / 2) { - -#if 1 - if (!p->audiobuf_is_loaded) { for (i = 0; i < (len / sizeof(short)); i++) { p->audiobuf[i] = srv_in[i]; @@ -206,7 +172,6 @@ p->audiobuf_is_loaded = 1; } else { unsigned int howmany = SAMPLES_PER_FRAME * sizeof(short); - //short totalbuf[SAMPLES_PER_FRAME]; for (i = 0; i < (len / sizeof(short)); i++) totalbuf[i] = p->audiobuf[i]; @@ -221,39 +186,30 @@ howmany = write(p->audiopipe[1], totalbuf, howmany); #endif /* WIN32 */ p->audiobuf_is_loaded = 0; - //NOTICA("SRV PIPE WRITE=====> req=%d recv=%d to sent=%d sent=%d\n", SKYPIAX_P_LOG, SAMPLES_PER_FRAME * sizeof(short), len, SAMPLES_PER_FRAME * sizeof(short), howmany); } -#endif } else { - ERRORA("SRV len=%d\n", SKYPIAX_P_LOG, len); - } } else if (len == 0) { DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG); switch_sleep(1000); - //break; } else { ERRORA("SRV len=%d\n", SKYPIAX_P_LOG, len); exit = 1; break; } - /****************************************************************/ } else { - ERRORA("SAMPLERATE_SKYPIAX can only be 8000 or 16000\n", SKYPIAX_P_LOG); } } else { - if (rt) ERRORA("SRV rt=%d\n", SKYPIAX_P_LOG, rt); switch_sleep(10000); } } - #ifdef WIN32 kill_cli_size = SAMPLES_PER_FRAME * sizeof(short); switch_file_write(p->audiopipe[1], kill_cli_buff, &kill_cli_size); @@ -275,9 +231,7 @@ kill_cli_size = SAMPLES_PER_FRAME * sizeof(short); len = write(p->audioskypepipe[1], kill_cli_buff, kill_cli_size); #endif /* WIN32 */ - DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG); - #ifndef WIN32 close(fd); #else @@ -300,7 +254,6 @@ } static void *SWITCH_THREAD_FUNC skypiax_do_tcp_cli_thread(switch_thread_t * thread, void *obj) -//void *skypiax_do_tcp_cli_thread(void *data) { struct skypiax_interface *p = obj; int s; @@ -324,7 +277,6 @@ short cli_out[SAMPLES_PER_FRAME * 2]; short cli_in[SAMPLES_PER_FRAME]; #endif /* WIN32 */ - //int one = 1; if (option_debug > 100) { DEBUGA_SKYPE("ENTERING FUNC\n", SKYPIAX_P_LOG); @@ -341,7 +293,6 @@ } return NULL; } - //setsockopt(s, IPPROTO_TCP, TCP_NODELAY, &one, sizeof(one)); if (bind(s, (struct sockaddr *) &my_addr, sizeof(struct sockaddr)) < 0) { ERRORA("bind Error\n", SKYPIAX_P_LOG); @@ -385,7 +336,7 @@ #endif /* WIN32 */ FD_ZERO(&fs); FD_SET(fdselect, &fs); - to.tv_usec = 2000000; //20 msec + to.tv_usec = 2000000; //2000 msec to.tv_sec = 0; #ifdef WIN32 @@ -393,11 +344,7 @@ #else /* WIN32 */ rt = select(fdselect + 1, &fs, NULL, NULL, &to); #endif /* WIN32 */ - //switch_sleep(1000);//FIXME - //memset(cli_in, '\0', sizeof(cli_in)); - //rt = 0; if (rt > 0) { - /*********************************************/ if ((SAMPLERATE_SKYPIAX - 8000) == 0) { got = SAMPLES_PER_FRAME * sizeof(short); #ifdef WIN32 @@ -407,7 +354,6 @@ #endif /* WIN32 */ if (got > 0) { - //DEBUGA_SKYPE("CLI PIPE read %d\n", SKYPIAX_P_LOG, got); a = 0; for (i = 0; i < got / sizeof(short); i++) { cli_out[a] = cli_in[i]; @@ -421,8 +367,6 @@ #else /* WIN32 */ len = send(fd, cli_out, got * 2, 0); #endif /* WIN32 */ - //DEBUGA_SKYPE("CLI PIPE send %d\n", SKYPIAX_P_LOG, len); - if (len == 0) { ERRORA("Skype server GONE\n", SKYPIAX_P_LOG); break; @@ -430,12 +374,8 @@ } else { switch_sleep(1000); ERRORA("CLI PIPE give us: %u\n", SKYPIAX_P_LOG, got); - //break; } - } - /*********************************************/ - /*********************************************/ - else if (SAMPLERATE_SKYPIAX == 16000) { + } else if (SAMPLERATE_SKYPIAX == 16000) { got = SAMPLES_PER_FRAME * sizeof(short); #ifdef WIN32 switch_file_read(p->audioskypepipe[0], cli_in, &got); @@ -465,7 +405,6 @@ ERRORA("CLI PIPE give us: %u\n", SKYPIAX_P_LOG, got); } } - /*********************************************/ } else { switch_sleep(1000); @@ -514,12 +453,6 @@ fcntl(p->audioskypepipe[1], F_SETFL, O_NONBLOCK); } #endif /* WIN32 */ - //rv = switch_file_pipe_timeout_set(p->audiopipe[0], 100); - -/* the pipe is our audio fd for pbx to poll on */ - //p->skypiax_sound_capt_fd = p->audiopipe[0]; - - //rv = switch_file_pipe_timeout_set(p->audioskypepipe[0], 20000); if (option_debug > 10) { DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); } @@ -538,30 +471,21 @@ #endif /* WIN32 */ p = tech_pvt->p; - - //DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - #ifdef WIN32 rt = 1; #else /* WIN32 */ - fdselect = p->audiopipe[0]; FD_ZERO(&fs); FD_SET(fdselect, &fs); - to.tv_usec = 2000000; //20 msec + to.tv_usec = 2000000; //2000 msec to.tv_sec = 0; rt = select(fdselect + 1, &fs, NULL, NULL, &to); #endif /* WIN32 */ - if (rt > 0) { - samples = SAMPLES_PER_FRAME * sizeof(short); - #ifdef WIN32 switch_file_read(p->audiopipe[0], tech_pvt->read_frame.data, &samples); #else /* WIN32 */ - - //samples = read(p->audiopipe[0], buf, SAMPLES_PER_FRAME * sizeof(short)); samples = read(p->audiopipe[0], tech_pvt->read_frame.data, samples); #endif /* WIN32 */ @@ -571,49 +495,17 @@ samples, SAMPLES_PER_FRAME * sizeof(short)); //do nothing } else { - tech_pvt->read_frame.datalen = samples; - //NOTICA("SRV PIPE READ=====> GOOD samples=%d\n", SKYPIAX_P_LOG, samples); /* A real frame */ + tech_pvt->read_frame.datalen = samples; } } else { if (rt) DEBUGA_SKYPE("select returned %d\n", SKYPIAX_P_LOG, rt); - } - - //DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - return SWITCH_STATUS_SUCCESS; } #ifdef WIN32 -#if 0 -int LaunchSkype(struct skypiax_interface *p) -{ - LPTSTR pszMessage; - DWORD dwLastError; - char skypelogin[256]; - - memset(skypelogin, '\0', sizeof(skypelogin)); - sprintf(skypelogin, "/secondary /username:%s /password:%s", p->skype_user, - p->skype_password); - - ShellExecute(NULL, "open", "C:\\Program Files\\Skype\\Phone\\Skype.exe", skypelogin, - ".", SW_SHOWNORMAL); - - dwLastError = GetLastError(); - - FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | - FORMAT_MESSAGE_IGNORE_INSERTS, NULL, dwLastError, MAKELANGID(LANG_NEUTRAL, - SUBLANG_DEFAULT), - (LPTSTR) & pszMessage, 0, NULL); - - NOTICA("ShellExecute gave: %s\n", SKYPIAX_P_LOG, pszMessage); - LocalFree(pszMessage); - return 1; - -} -#endif enum { SKYPECONTROLAPI_ATTACH_SUCCESS = 0, /* Client is successfully @@ -703,13 +595,14 @@ if (!p->AsteriskHandlesAst.api_connected) { NOTICA("\n\n\tConnected to Skype API!\n", SKYPIAX_P_LOG); p->AsteriskHandlesAst.win32_hGlobal_SkypeAPIWindowHandle = (HWND) uiParam; - //switch_sleep(5000); p->AsteriskHandlesAst.win32_hGlobal_SkypeAPIWindowHandle = p->AsteriskHandlesAst.win32_hGlobal_SkypeAPIWindowHandle; } break; case SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION: - //WARNINGA ("\n\n\tIf I do not (almost) immediately connect to Skype API,\n\tplease give the Skype client authorization to be connected \n\tby Asterisk and to not ask you again.\n\n", SKYPIAX_P_LOG); + DEBUGA_SKYPE + ("\n\n\tIf I do not (almost) immediately connect to Skype API,\n\tplease give the Skype client authorization to be connected \n\tby Asterisk and to not ask you again.\n\n", + SKYPIAX_P_LOG); switch_sleep(5000); if (!p->AsteriskHandlesAst.api_connected) { SendMessage(HWND_BROADCAST, @@ -830,34 +723,25 @@ /* destroy window class */ struct skypiax_interface *p; - //DWORD MsgWaitResult; - p = obj; + p = obj; switch_file_pipe_create(&p->AsteriskHandlesAst.fdesc[0], &p->AsteriskHandlesAst.fdesc[1], skypiax_module_pool); - //switch_file_pipe_timeout_set(p->AsteriskHandlesAst.fdesc[0], 100); - p->AsteriskHandlesAst.win32_uiGlobal_MsgID_SkypeControlAPIAttach = RegisterWindowMessage("SkypeControlAPIAttach"); p->AsteriskHandlesAst.win32_uiGlobal_MsgID_SkypeControlAPIDiscover = RegisterWindowMessage("SkypeControlAPIDiscover"); - //LaunchSkype(p); switch_sleep(2000000); if (p->AsteriskHandlesAst.win32_uiGlobal_MsgID_SkypeControlAPIAttach != 0 && p->AsteriskHandlesAst.win32_uiGlobal_MsgID_SkypeControlAPIDiscover != 0) { if (win32_Initialize_CreateWindowClass(p)) { if (win32_Initialize_CreateMainWindow(p)) { -#if 1 if (SendMessage (HWND_BROADCAST, p->AsteriskHandlesAst.win32_uiGlobal_MsgID_SkypeControlAPIDiscover, (WPARAM) p->AsteriskHandlesAst.win32_hInit_MainWindowHandle, 0) != 0) { -#else - - if (1) { -#endif p->AsteriskHandlesAst.win32_hInit_MainWindowHandle = p->AsteriskHandlesAst.win32_hInit_MainWindowHandle; while (1) { @@ -865,7 +749,6 @@ if (!running) break; while (GetMessage(&oMessage, 0, 0, 0)) { - //break; TranslateMessage(&oMessage); DispatchMessage(&oMessage); } @@ -883,30 +766,6 @@ } #else /* NOT WIN32 */ -#if 0 -int X11_errors_handler(Display * dpy, XErrorEvent * err) -{ - (void) dpy; - struct skypiax_interface *p = NULL; - - xerror = err->error_code; - DEBUGA_SKYPE("Received error code %d from X Server\n", SKYPIAX_P_LOG, xerror); - return 0; /* ignore the error */ -} - -static void X11_errors_trap(void) -{ - xerror = 0; - old_handler = XSetErrorHandler(X11_errors_handler); -} - -static int X11_errors_untrap(void) -{ - XSetErrorHandler(old_handler); - return (xerror != BadValue) && (xerror != BadWindow); -} -#endif - int skypiax_skype_send_message(struct AsteriskHandles *AsteriskHandlesAst, const char *message_P) { @@ -914,7 +773,6 @@ Window w_P; Display *disp; Window handle_P; - //struct skypiax_interface *p = NULL; w_P = AsteriskHandlesAst->skype_win; disp = AsteriskHandlesAst->disp; @@ -925,7 +783,6 @@ unsigned int pos = 0; unsigned int len = strlen(message_P); XEvent e; - //int ok; memset(&e, 0, sizeof(e)); e.xclient.type = ClientMessage; @@ -934,7 +791,6 @@ e.xclient.window = handle_P; e.xclient.format = 8; - //X11_errors_trap(); //XLockDisplay(disp); do { unsigned int i; @@ -948,11 +804,7 @@ XSync(disp, False); //XUnlockDisplay(disp); - //ok = X11_errors_untrap(); - - //if (!ok) DEBUGA_SKYPE("Sending message failed with status %d\n", SKYPIAX_P_LOG, xerror); - //return ok; return 1; } @@ -968,7 +820,6 @@ int status; struct skypiax_interface *p = NULL; - //X11_errors_trap(); //XLockDisplay(disp); status = XGetWindowProperty(AsteriskHandlesAst->disp, @@ -976,7 +827,6 @@ False, XA_WINDOW, &type_ret, &format_ret, &nitems_ret, &bytes_after_ret, &prop); //XUnlockDisplay(disp); - //X11_errors_untrap(); /* sanity check */ if (status != Success || format_ret != 32 || nitems_ret != 1) { @@ -986,7 +836,6 @@ } AsteriskHandlesAst->skype_win = *(const unsigned long *) prop & 0xffffffff; - //DEBUGA_SKYPE("Skype instance found with id #%x\n", SKYPIAX_P_LOG, DEBUGA_SKYPE("Skype instance found with id #%d\n", SKYPIAX_P_LOG, (unsigned int) AsteriskHandlesAst->skype_win); return 1; @@ -1018,7 +867,7 @@ struct skypiax_interface *p; struct AsteriskHandles *AsteriskHandlesAst; - char buf[SKYPE_X11_BUF_SIZE]; + char buf[512]; Display *disp = NULL; Window root = -1; Window win = -1; @@ -1026,14 +875,11 @@ p = obj; DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - //switch_file_pipe_create(&p->AsteriskHandlesAst.fdesc[0], &p->AsteriskHandlesAst.fdesc[1], skypiax_module_pool); if (pipe(p->AsteriskHandlesAst.fdesc)) { fcntl(p->AsteriskHandlesAst.fdesc[0], F_SETFL, O_NONBLOCK); fcntl(p->AsteriskHandlesAst.fdesc[1], F_SETFL, O_NONBLOCK); } - //switch_file_pipe_timeout_set(p->AsteriskHandlesAst.fdesc[0], 100); AsteriskHandlesAst = &p->AsteriskHandlesAst; - //disp = XOpenDisplay(getenv("DISPLAY")); disp = XOpenDisplay(p->X11_display); if (!disp) { ERRORA("Cannot open X Display '%s', exiting skype thread\n", SKYPIAX_P_LOG, @@ -1048,7 +894,6 @@ fcntl(xfd, F_SETFD, FD_CLOEXEC); //FIXME pthread_cleanup_push(skypiax_skype_clean_disp, &xfd); - DEBUGA_SKYPE("PUSH disp %d\n", SKYPIAX_P_LOG, xfd); AsteriskHandlesAst->disp = disp; @@ -1060,13 +905,9 @@ DefaultScreen (disp))); - //DEBUGA_SKYPE("skype_win=%d win=%d\n", SKYPIAX_P_LOG, (unsigned int) skype_win, (unsigned int) win); - - //AsteriskHandlesAst->skype_win = skype_win; - //AsteriskHandlesAst->disp = disp; AsteriskHandlesAst->win = win; - snprintf(buf, SKYPE_X11_BUF_SIZE, "NAME skypiax"); + snprintf(buf, 512, "NAME skypiax"); if (!skypiax_skype_send_message(AsteriskHandlesAst, buf)) { ERRORA @@ -1076,7 +917,7 @@ return NULL; } - snprintf(buf, SKYPE_X11_BUF_SIZE, "PROTOCOL 6"); + snprintf(buf, 512, "PROTOCOL 6"); if (!skypiax_skype_send_message(AsteriskHandlesAst, buf)) { ERRORA ("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypiax again\n", @@ -1095,7 +936,6 @@ b = buffer; while (1) { - //switch_sleep(10000); XNextEvent(disp, &an_event); if (!running) break; @@ -1110,10 +950,6 @@ buf[i] = '\0'; - //NOTICA("ClientMessage buf:|||%s||| buffer:|||%s||| serial=%ld|||\r\n",SKYPIAX_P_LOG,buf, buffer,an_event.xclient.serial); - //NOTICA ("SKYPE read: |||%s|||%d\n", SKYPIAX_P_LOG, buf, strlen(buf)); - //NOTICA ("SKYPE buffer: |||%s|||%d\n", SKYPIAX_P_LOG, buffer, strlen(buffer)); - strcat(buffer, buf); if (i < 20) { /* last fragment */ @@ -1121,11 +957,7 @@ howmany = strlen(b) + 1; - //switch_file_write(AsteriskHandlesAst->fdesc[1], b, &howmany); howmany = write(AsteriskHandlesAst->fdesc[1], b, howmany); - //write(AsteriskHandlesAst->fdesc[1], "\0", 1); - //FIXME DEBUGA_SKYPE("SKYPE pipewrite: |||%s|||len=%d serial=%ld\n\n\n", SKYPIAX_P_LOG, b, strlen(b) + 1, an_event.xclient.serial); - //switch_sleep(1000); memset(buffer, '\0', 17000); } @@ -1178,7 +1010,6 @@ ("Sending message failed - probably Skype crashed.\n\nPlease shutdown Skypiax (Asterisk), then restart Skype from the menu, then launch Skypiax and try again.\n", SKYPIAX_P_LOG); p->skype = 0; - //FIXME p->skype_thread = SKYPIAX_PTHREADT_NULL; p->skype_thread = NULL; if (option_debug > 100) { DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); @@ -1243,7 +1074,6 @@ #ifdef WIN32 rt = 1; #else /* WIN32 */ - fdselect = p->AsteriskHandlesAst.fdesc[0]; FD_ZERO(&fs); FD_SET(fdselect, &fs); @@ -1269,7 +1099,6 @@ if (read_from_pipe[i] == '\0') { - //if (option_debug > 101) DEBUGA_SKYPE("read_skype: howmany=%d, i=%d, a=%d, |||%s||| \n", SKYPIAX_P_LOG, howmany, i, a, messaggio); @@ -1479,9 +1308,7 @@ DEBUGA_SKYPE("Call %s received a DTMF: %s\n", SKYPIAX_P_LOG, id, value); tech_pvt = p->tech_pvt; - //if(tech_pvt) session = tech_pvt->session; - //if(session) channel = switch_core_session_get_channel(session); if (channel) { @@ -1541,7 +1368,6 @@ strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1); } else { /* we're owned, we're in a call, let's refuse */ - //sprintf(msg_to_skype, "SET CALL %s STATUS REFUSED", id); sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", id); skypiax_skype_write(p, msg_to_skype); switch_sleep(10000); @@ -1657,26 +1483,21 @@ if (1) { //FIXME char msg_to_skype[1024]; + switch_threadattr_t *thd_attr = NULL; - if (1) { //FIXME - switch_threadattr_t *thd_attr = NULL; - - switch_threadattr_create(&thd_attr, skypiax_module_pool); - switch_threadattr_detach_set(thd_attr, 1); - switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); - switch_thread_create(&p->tcp_srv_thread, thd_attr, - skypiax_do_tcp_srv_thread, p, - skypiax_module_pool); - DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG); - - switch_threadattr_create(&thd_attr, skypiax_module_pool); - switch_threadattr_detach_set(thd_attr, 1); - switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); - switch_thread_create(&p->tcp_cli_thread, thd_attr, - skypiax_do_tcp_cli_thread, p, - skypiax_module_pool); - DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG); - } + switch_threadattr_create(&thd_attr, skypiax_module_pool); + switch_threadattr_detach_set(thd_attr, 1); + switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); + switch_thread_create(&p->tcp_srv_thread, thd_attr, + skypiax_do_tcp_srv_thread, p, skypiax_module_pool); + DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG); + + switch_threadattr_create(&thd_attr, skypiax_module_pool); + switch_threadattr_detach_set(thd_attr, 1); + switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); + switch_thread_create(&p->tcp_cli_thread, thd_attr, + skypiax_do_tcp_cli_thread, p, skypiax_module_pool); + DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG); switch_sleep(100000); sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id, p->tcp_srv_port); @@ -1690,8 +1511,6 @@ p->skype_callflow = SKYPIAX_STATE_UP; - /**************************/ - //FIXME switch_core_session_t **new_session; //FIXME *new_session=switch_loadable_module_create_interface(skypiax_endpoint_interface, pool); @@ -1719,8 +1538,6 @@ break; } - // if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session), NULL, dialplan, cid_name, cid_num, ip, NULL, NULL, NULL, modname, NULL, dest)) != 0) - if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session), "skypiax", "XML", p->callid_name, @@ -1757,23 +1574,20 @@ session = tech_pvt->session; } else { ERRORA("No tech_pvt->session???\n", SKYPIAX_P_LOG); - } - //session = global_session; if (session) { channel = switch_core_session_get_channel(session); - //DEBUGA_SKYPE("skype_call: %s, answered\n", SKYPIAX_P_LOG, id); - switch_channel_mark_answered(channel); } else { - ERRORA("No session???\n", SKYPIAX_P_LOG); - } - - //switch_channel_set_state(channel, CS_EXECUTE); + if (channel) { + switch_channel_mark_answered(channel); + //DEBUGA_SKYPE("skype_call: %s, answered\n", SKYPIAX_P_LOG, id); + } else { + ERRORA("No channel???\n", SKYPIAX_P_LOG); + } } - /**************************/ } else { WARNINGA("skype_call: %s, STATUS: %s is not recognized\n", SKYPIAX_P_LOG,
participants (1)
-
FreeSWITCH SVN