From gmaruzz at freeswitch.org Wed Dec 3 09:19:43 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Wed, 03 Dec 2008 12:19:43 -0500 Subject: [Freeswitch-branches] [commit] r10574 - in freeswitch/branches/gmaruzz/src: . include mod/endpoints/mod_skypiax mod/endpoints/mod_woomera Message-ID: 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 #include #include +#else //WIN32_SKYPIAX +//FIXME include? +#endif //WIN32_SKYPIAX + #include #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 + +#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 @@ @@ -143,7 +146,7 @@ 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 From gmaruzz at freeswitch.org Wed Dec 3 09:23:18 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Wed, 03 Dec 2008 12:23:18 -0500 Subject: [Freeswitch-branches] [commit] r10575 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax Message-ID: 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 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From gmaruzz at freeswitch.org Wed Dec 3 10:11:48 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Wed, 03 Dec 2008 13:11:48 -0500 Subject: [Freeswitch-branches] [commit] r10577 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax Message-ID: 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 From gmaruzz at freeswitch.org Thu Dec 4 01:32:52 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Thu, 04 Dec 2008 04:32:52 -0500 Subject: [Freeswitch-branches] [commit] r10589 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax Message-ID: 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; } From gmaruzz at freeswitch.org Thu Dec 4 01:47:40 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Thu, 04 Dec 2008 04:47:40 -0500 Subject: [Freeswitch-branches] [commit] r10590 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax Message-ID: 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) { From gmaruzz at freeswitch.org Thu Dec 4 03:46:58 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Thu, 04 Dec 2008 06:46:58 -0500 Subject: [Freeswitch-branches] [commit] r10591 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Thu Dec 4 06:46:57 2008 New Revision: 10591 Log: skypiax: now compiles and kind of works in win32, let see if works in linux Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c (original) +++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c Thu Dec 4 06:46:57 2008 @@ -34,8 +34,8 @@ * */ -#undef WIN32_SKYPIAX -#undef __CYGWIN__ +#define WIN32_SKYPIAX +#define __CYGWIN__ #define MOD_SKYPIAX #ifdef MOD_SKYPIAX @@ -137,7 +137,7 @@ struct AsteriskHandles { HWND win32_hInit_MainWindowHandle; HWND win32_hGlobal_SkypeAPIWindowHandle; - int fdesc[2]; + switch_file_t *fdesc[2]; }; #endif //WIN32_SKYPIAX @@ -349,11 +349,22 @@ break; case WM_COPYDATA: if (win32_hGlobal_SkypeAPIWindowHandle == (HWND) uiParam) { + unsigned int howmany; + char msg_from_skype[2048]; + 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); + + memset(msg_from_skype, '\0', sizeof(msg_from_skype)); + strncpy(msg_from_skype, (const char *) poCopyData->lpData, sizeof(msg_from_skype) -2); + + //howmany = strlen((const char *) poCopyData->lpData); + howmany = strlen(msg_from_skype) + 1; + //switch_file_write(win32_AsteriskHandlesSkype->fdesc[1], (const char *) poCopyData->lpData, &howmany); + switch_file_write(win32_AsteriskHandlesSkype->fdesc[1], msg_from_skype, &howmany); + NOTICA("From Skype API: %s\n", SKYPIAX_P_LOG, (const char *) poCopyData->lpData); + //howmany=1; + //switch_file_write(win32_AsteriskHandlesSkype->fdesc[1], "\0", &howmany); lReturnCode = 1; } break; @@ -480,7 +491,12 @@ } #endif //0 - win32_AsteriskHandlesSkype = (struct AsteriskHandles *) obj; + struct skypiax_interface *p; + p = obj; + + switch_file_pipe_create_ex(&p->AsteriskHandlesAst.fdesc[0], &p->AsteriskHandlesAst.fdesc[1], 2, module_pool); + + win32_AsteriskHandlesSkype = &p->AsteriskHandlesAst; win32_uiGlobal_MsgID_SkypeControlAPIAttach = RegisterWindowMessage("SkypeControlAPIAttach"); @@ -742,10 +758,22 @@ p->audiobuf_is_loaded = 1; } else { unsigned int howmany; + short totalbuf[320]; + howmany = len/2; - switch_file_write(p->audiopipe[1], p->audiobuf, &howmany); - howmany = len/2; - switch_file_write(p->audiopipe[1], out, &howmany); + for(i=0; iaudiobuf[i]; + + for(a=0; aaudiopipe[1], totalbuf, &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); } @@ -761,13 +789,19 @@ } } DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG); + //switch_sleep(1000000); + +#ifndef WIN32_SKYPIAX close(fd); +#endif if (exit) break; } DEBUGA_SKYPE("server (I am it) GONE\n", SKYPIAX_P_LOG); +#ifndef WIN32_SKYPIAX close(s); +#endif if (option_debug > 10) { DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); } @@ -810,7 +844,9 @@ if (option_debug > 10) { DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); } +#ifndef WIN32_SKYPIAX close(s); +#endif return NULL; } DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG); @@ -871,13 +907,17 @@ } DEBUGA_SKYPE("Skype server GONE\n", SKYPIAX_P_LOG); +#ifndef WIN32_SKYPIAX close(fd); +#endif if (exit) break; } DEBUGA_SKYPE("client (I am it) GONE\n", SKYPIAX_P_LOG); +#ifndef WIN32_SKYPIAX close(s); +#endif if (option_debug > 10) { DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); } @@ -979,9 +1019,9 @@ 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 != 320) { + if (samples != SAMPLES_PER_FRAME * sizeof(short)) { DEBUGA_SKYPE("read=====> NOT GOOD samples=%d expected=%d\n", SKYPIAX_P_LOG, samples, - 320); + SAMPLES_PER_FRAME * sizeof(short)); switch_sleep(1000); //do nothing } else { @@ -2084,6 +2124,8 @@ DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); } DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); +//switch_sleep(1000000); + memset(read_from_pipe, 0, 4096); memset(messaggio, 0, 4096); memset(messaggio_2, 0, 4096); From gmaruzz at freeswitch.org Thu Dec 4 04:31:37 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Thu, 04 Dec 2008 07:31:37 -0500 Subject: [Freeswitch-branches] [commit] r10592 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Thu Dec 4 07:31:37 2008 New Revision: 10592 Log: skypiax: on linux, the problem with tcp_srv_thread audio seems solved, let's see in 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 07:31:37 2008 @@ -34,8 +34,8 @@ * */ -#define WIN32_SKYPIAX -#define __CYGWIN__ +#undef WIN32_SKYPIAX +#undef __CYGWIN__ #define MOD_SKYPIAX #ifdef MOD_SKYPIAX @@ -758,12 +758,13 @@ p->audiobuf_is_loaded = 1; } else { unsigned int howmany; - short totalbuf[320]; + short totalbuf[GG]; - howmany = len/2; + howmany = len/2/2; for(i=0; iaudiobuf[i]; + howmany = len/2/2; for(a=0; aaudiopipe[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); + //DEBUGA_SKYPE("read=====> req=%d recv=%d to sent=%d sent=%d\n", SKYPIAX_P_LOG, sizeof(short)*GG, len, (len*sizeof(short))/2, howmany); } } else if (len == 0) { From gmaruzz at freeswitch.org Thu Dec 4 04:36:15 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Thu, 04 Dec 2008 07:36:15 -0500 Subject: [Freeswitch-branches] [commit] r10593 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Thu Dec 4 07:36:15 2008 New Revision: 10593 Log: skypiax: compiles and works on linux and win32, crashes on exit, works only for one call (Heroes... :-) ) 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 07:36:15 2008 @@ -34,8 +34,8 @@ * */ -#undef WIN32_SKYPIAX -#undef __CYGWIN__ +#define WIN32_SKYPIAX +#define __CYGWIN__ #define MOD_SKYPIAX #ifdef MOD_SKYPIAX From gmaruzz at freeswitch.org Thu Dec 4 07:27:27 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Thu, 04 Dec 2008 10:27:27 -0500 Subject: [Freeswitch-branches] [commit] r10595 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_woomera Message-ID: Author: gmaruzz Date: Thu Dec 4 10:27:26 2008 New Revision: 10595 Log: mod_woomera: reverted mod_woomera.2008.vcproj, the makefile for VC++ on Windows Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_woomera/mod_woomera.2008.vcproj 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 Thu Dec 4 10:27:26 2008 @@ -1,8 +1,8 @@ @@ -146,7 +143,7 @@ From gmaruzz at freeswitch.org Thu Dec 4 12:42:17 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Thu, 04 Dec 2008 15:42:17 -0500 Subject: [Freeswitch-branches] [commit] r10599 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Thu Dec 4 15:42:15 2008 New Revision: 10599 Log: skypiax: giving timeouts to pipes at least on linux seems to works well. Lets see 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 15:42:15 2008 @@ -34,8 +34,8 @@ * */ -#define WIN32_SKYPIAX -#define __CYGWIN__ +#undef WIN32_SKYPIAX +#undef __CYGWIN__ #define MOD_SKYPIAX #ifdef MOD_SKYPIAX @@ -689,7 +689,7 @@ int i; if (option_debug > 10) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); + WARNINGA("ENTERING FUNC\n", SKYPIAX_P_LOG); } memset(&my_addr, 0, sizeof(my_addr)); my_addr.sin_family = AF_INET; @@ -799,7 +799,7 @@ break; } - DEBUGA_SKYPE("server (I am it) GONE\n", SKYPIAX_P_LOG); + WARNINGA("server (I am it) GONE\n", SKYPIAX_P_LOG); #ifndef WIN32_SKYPIAX close(s); #endif @@ -821,10 +821,10 @@ int a; int i; unsigned int got; - int exit=0; + //int exit=0; if (option_debug > 10) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); + WARNINGA("ENTERING FUNC\n", SKYPIAX_P_LOG); } memset(&my_addr, 0, sizeof(my_addr)); my_addr.sin_family = AF_INET; @@ -864,7 +864,7 @@ fd_set fs; struct timeval to; - exit=1; + //exit=1; @@ -898,24 +898,25 @@ len = send(fd, out, got * 2, 0); if (len == 0) { - DEBUGA_SKYPE("Skype server GONE\n", SKYPIAX_P_LOG); + ERRORA("Skype server GONE\n", SKYPIAX_P_LOG); break; } } else { switch_sleep(1000); + //ERRORA("Audio skype pipe give us: %u\n", SKYPIAX_P_LOG, got); } } } - DEBUGA_SKYPE("Skype server GONE\n", SKYPIAX_P_LOG); + ERRORA("Skype server GONE\n", SKYPIAX_P_LOG); #ifndef WIN32_SKYPIAX close(fd); #endif - if (exit) + //if (exit) break; } - DEBUGA_SKYPE("client (I am it) GONE\n", SKYPIAX_P_LOG); + WARNINGA("client (I am it) GONE\n", SKYPIAX_P_LOG); #ifndef WIN32_SKYPIAX close(s); #endif @@ -936,6 +937,8 @@ //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_timeout_set(p->audiopipe[0], 100000); + //rv = switch_file_pipe_timeout_set(p->audiopipe[1], 10000); //rv = switch_file_pipe_create(&readp, &writep, module_pool); @@ -968,6 +971,8 @@ */ rv = switch_file_pipe_create_ex(&p->audioskypepipe[0], &p->audioskypepipe[1], 2, module_pool); + rv = switch_file_pipe_timeout_set(p->audioskypepipe[0], 100); + //rv = switch_file_pipe_timeout_set(p->audioskypepipe[1], 10000); #ifdef NOTDEF_WIN32_SKYPIAX c = pipe(p->audioskypepipe); if (c) { @@ -1021,9 +1026,9 @@ //if ((samples = read(p->audiopipe[0], buf, SAMPLES_PER_FRAME * sizeof(short))) != 320) if (samples != SAMPLES_PER_FRAME * sizeof(short)) { - DEBUGA_SKYPE("read=====> NOT GOOD samples=%d expected=%d\n", SKYPIAX_P_LOG, samples, - SAMPLES_PER_FRAME * sizeof(short)); - switch_sleep(1000); + if(samples) + DEBUGA_SKYPE("read=====> NOT GOOD samples=%d expected=%d\n", SKYPIAX_P_LOG, samples, SAMPLES_PER_FRAME * sizeof(short)); + //switch_sleep(1000); //do nothing } else { tech_pvt->read_frame.datalen=samples; @@ -2124,7 +2129,7 @@ if (option_debug > 100) { DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); } - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); + //DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); //switch_sleep(1000000); memset(read_from_pipe, 0, 4096); @@ -2151,7 +2156,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); @@ -2656,7 +2661,7 @@ if (option_debug > 100) { DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); } - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + //DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); return 0; } From gmaruzz at freeswitch.org Thu Dec 4 12:46:10 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Thu, 04 Dec 2008 15:46:10 -0500 Subject: [Freeswitch-branches] [commit] r10600 - in freeswitch/branches/gmaruzz/src: . include Message-ID: Author: gmaruzz Date: Thu Dec 4 15:46:10 2008 New Revision: 10600 Log: switch_apr.c and switch_apr.h: added switch_file_pipe_timeout_set and switch_file_pipe_timeout_get Modified: freeswitch/branches/gmaruzz/src/include/switch_apr.h 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 Thu Dec 4 15:46:10 2008 @@ -1305,6 +1305,22 @@ 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); +/** + * Get the timeout value for a pipe or manipulate the blocking state. + * @param thepipe The pipe we are getting a timeout for. + * @param timeout The current timeout value in microseconds. + */ +SWITCH_DECLARE(switch_status_t) switch_file_pipe_timeout_get(switch_file_t *thepipe, switch_interval_time_t *timeout); + +/** + * Set the timeout value for a pipe or manipulate the blocking state. + * @param thepipe The pipe we are setting a timeout on. + * @param timeout The timeout value in microseconds. Values < 0 mean wait + * forever, 0 means do not wait at all. + */ +SWITCH_DECLARE(switch_status_t) switch_file_pipe_timeout_set(switch_file_t *thepipe, switch_interval_time_t timeout); + + /** @} */ Modified: freeswitch/branches/gmaruzz/src/switch_apr.c ============================================================================== --- freeswitch/branches/gmaruzz/src/switch_apr.c (original) +++ freeswitch/branches/gmaruzz/src/switch_apr.c Thu Dec 4 15:46:10 2008 @@ -948,6 +948,28 @@ return apr_file_pipe_create ((apr_file_t **) in, (apr_file_t **) out, p); } +/** + * Get the timeout value for a pipe or manipulate the blocking state. + * @param thepipe The pipe we are getting a timeout for. + * @param timeout The current timeout value in microseconds. + */ +SWITCH_DECLARE(switch_status_t) switch_file_pipe_timeout_get(switch_file_t *thepipe, switch_interval_time_t *timeout) +{ + return apr_file_pipe_timeout_get( (apr_file_t *)thepipe, (apr_interval_time_t *)timeout); +} + +/** + * Set the timeout value for a pipe or manipulate the blocking state. + * @param thepipe The pipe we are setting a timeout on. + * @param timeout The timeout value in microseconds. Values < 0 mean wait + * forever, 0 means do not wait at all. + */ +SWITCH_DECLARE(switch_status_t) switch_file_pipe_timeout_set(switch_file_t *thepipe, switch_interval_time_t timeout) +{ + return apr_file_pipe_timeout_set( (apr_file_t *)thepipe, (apr_interval_time_t)timeout); +} + + /* For Emacs: * Local Variables: * mode:c From gmaruzz at freeswitch.org Thu Dec 4 19:51:12 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Thu, 04 Dec 2008 22:51:12 -0500 Subject: [Freeswitch-branches] [commit] r10605 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Thu Dec 4 22:51:12 2008 New Revision: 10605 Log: skypiax: let's try to overcome the lack of timeout on pipe's read on Windows. And closesocket the sockets Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.2008.vcproj freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.2008.vcproj ============================================================================== --- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.2008.vcproj (original) +++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.2008.vcproj Thu Dec 4 22:51:12 2008 @@ -3,7 +3,7 @@ ProjectType="Visual C++" Version="9,00" Name="mod_skypiax" - ProjectGUID="{FE3540C5-3303-46E0-A69E-D92F775687F1}" + ProjectGUID="{C6E78A4C-DB1E-47F4-9B63-4DC27D86343F}" RootNamespace="mod_skypiax" Keyword="Win32Proj" TargetFrameworkVersion="131072" @@ -54,7 +54,7 @@ /> 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 22:51:12 2008 @@ -34,8 +34,8 @@ * */ -#undef WIN32_SKYPIAX -#undef __CYGWIN__ +#define WIN32_SKYPIAX +#define __CYGWIN__ #define MOD_SKYPIAX #ifdef MOD_SKYPIAX @@ -687,6 +687,9 @@ int exit = 0; int a; int i; + unsigned int kill_cli_size; + short kill_cli_buff[320]; + private_t *tech_pvt; if (option_debug > 10) { WARNINGA("ENTERING FUNC\n", SKYPIAX_P_LOG); @@ -789,11 +792,20 @@ } } } + + + + p->interface_state = SKYPIAX_STATE_DOWN; + kill_cli_size=320; + switch_file_write(p->audioskypepipe[1], kill_cli_buff, &kill_cli_size); + DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG); //switch_sleep(1000000); #ifndef WIN32_SKYPIAX close(fd); +#else + closesocket(fd); #endif if (exit) break; @@ -802,6 +814,8 @@ WARNINGA("server (I am it) GONE\n", SKYPIAX_P_LOG); #ifndef WIN32_SKYPIAX close(s); +#else + closesocket(s); #endif if (option_debug > 10) { DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); @@ -847,6 +861,8 @@ } #ifndef WIN32_SKYPIAX close(s); +#else + closesocket(s); #endif return NULL; } @@ -911,6 +927,8 @@ ERRORA("Skype server GONE\n", SKYPIAX_P_LOG); #ifndef WIN32_SKYPIAX close(fd); +#else + closesocket(fd); #endif //if (exit) break; @@ -919,6 +937,8 @@ WARNINGA("client (I am it) GONE\n", SKYPIAX_P_LOG); #ifndef WIN32_SKYPIAX close(s); +#else + closesocket(s); #endif if (option_debug > 10) { DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); From gmaruzz at freeswitch.org Thu Dec 4 21:36:24 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Fri, 05 Dec 2008 00:36:24 -0500 Subject: [Freeswitch-branches] [commit] r10606 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Fri Dec 5 00:36:24 2008 New Revision: 10606 Log: skypiax: let's try to overcome the lack of timeout on pipe's read on Windows 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 Dec 5 00:36:24 2008 @@ -795,8 +795,14 @@ + kill_cli_size=320; + switch_file_write(p->audiopipe[1], kill_cli_buff, &kill_cli_size); + kill_cli_size=320; + switch_file_write(p->audioskypepipe[1], kill_cli_buff, &kill_cli_size); p->interface_state = SKYPIAX_STATE_DOWN; kill_cli_size=320; + switch_file_write(p->audiopipe[1], kill_cli_buff, &kill_cli_size); + kill_cli_size=320; switch_file_write(p->audioskypepipe[1], kill_cli_buff, &kill_cli_size); DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG); @@ -2413,7 +2419,7 @@ } else if (!strcasecmp(value, "FINISHED")) { global_session = NULL; //FIXME - p->skype_callflow = CALLFLOW_STATUS_FINISHED; + //p->skype_callflow = CALLFLOW_STATUS_FINISHED; if (option_debug) DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id); p->skype_call_id[0] = '\0'; @@ -2422,7 +2428,7 @@ if (option_debug > 100) { DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); } - p->interface_state = SKYPIAX_STATE_DOWN; + //p->interface_state = SKYPIAX_STATE_DOWN; //FIXME if(p->owner) //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL; return CALLFLOW_INCOMING_HANGUP; @@ -2805,7 +2811,7 @@ switch_channel_t *channel; - p->interface_state=SKYPIAX_STATE_DOWN; + //p->interface_state=SKYPIAX_STATE_DOWN; //if (option_debug) DEBUGA_SKYPE("skype call ended\n", SKYPIAX_P_LOG); From gmaruzz at freeswitch.org Thu Dec 4 21:58:44 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Fri, 05 Dec 2008 00:58:44 -0500 Subject: [Freeswitch-branches] [commit] r10607 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Fri Dec 5 00:58:44 2008 New Revision: 10607 Log: skypiax: compile clean on linux Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c (original) +++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c Fri Dec 5 00:58:44 2008 @@ -34,8 +34,8 @@ * */ -#define WIN32_SKYPIAX -#define __CYGWIN__ +#undef WIN32_SKYPIAX +#undef __CYGWIN__ #define MOD_SKYPIAX #ifdef MOD_SKYPIAX @@ -689,7 +689,6 @@ int i; unsigned int kill_cli_size; short kill_cli_buff[320]; - private_t *tech_pvt; if (option_debug > 10) { WARNINGA("ENTERING FUNC\n", SKYPIAX_P_LOG); From gmaruzz at freeswitch.org Thu Dec 4 23:06:43 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Fri, 05 Dec 2008 02:06:43 -0500 Subject: [Freeswitch-branches] [commit] r10608 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Fri Dec 5 02:06:43 2008 New Revision: 10608 Log: skypiax: indent -gnu -ts4 -br -brs -cdw -lp -ce -nbfda -npcs -nprs -npsl -nbbo -saf -sai -saw -cs -bbo -nhnl -nut -sob -l90 Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c 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 Dec 5 02:06:43 2008 @@ -58,11 +58,9 @@ #define WARNINGA(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][WARNINGA %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); #define NOTICA(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][NOTICA %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); - //#define SKYPIAX_P_LOG p ? p->owner : NULL, (unsigned long)pthread_self(), __LINE__, p ? p->name ? p->name : "none" : "none", p ? p->owner ? p->owner->_state : -1 : -1, p ? p->interface_state : -1, p ? p->skype_callflow : -1 #define SKYPIAX_P_LOG NULL, (unsigned long)55, __LINE__, p ? p->name ? p->name : "none" : "none", -1, p ? p->interface_state : -1, p ? p->skype_callflow : -1 - /*********************************/ #define SKYPIAX_CAUSE_NORMAL 1 /*********************************/ @@ -111,15 +109,12 @@ /*********************************/ - - #define SKYPIAX_MAX_INTERFACES 64 SWITCH_MODULE_LOAD_FUNCTION(mod_skypiax_load); SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypiax_shutdown); //SWITCH_MODULE_RUNTIME_FUNCTION(mod_skypiax_runtime); -SWITCH_MODULE_DEFINITION(mod_skypiax, mod_skypiax_load, mod_skypiax_shutdown, NULL); //mod_skypiax_runtime); - +SWITCH_MODULE_DEFINITION(mod_skypiax, mod_skypiax_load, mod_skypiax_shutdown, NULL); //mod_skypiax_runtime); switch_endpoint_interface_t *skypiax_endpoint_interface; static switch_memory_pool_t *module_pool = NULL; @@ -142,135 +137,136 @@ #endif //WIN32_SKYPIAX - typedef enum { - TFLAG_IO = (1 << 0), - TFLAG_INBOUND = (1 << 1), - TFLAG_OUTBOUND = (1 << 2), - TFLAG_DTMF = (1 << 3), - TFLAG_VOICE = (1 << 4), - TFLAG_HANGUP = (1 << 5), - TFLAG_LINEAR = (1 << 6), - TFLAG_CODEC = (1 << 7), - TFLAG_BREAK = (1 << 8) + TFLAG_IO = (1 << 0), + TFLAG_INBOUND = (1 << 1), + TFLAG_OUTBOUND = (1 << 2), + TFLAG_DTMF = (1 << 3), + TFLAG_VOICE = (1 << 4), + TFLAG_HANGUP = (1 << 5), + TFLAG_LINEAR = (1 << 6), + TFLAG_CODEC = (1 << 7), + TFLAG_BREAK = (1 << 8) } TFLAGS; typedef enum { - GFLAG_MY_CODEC_PREFS = (1 << 0) + GFLAG_MY_CODEC_PREFS = (1 << 0) } GFLAGS; - static struct { - int debug; - char *ip; - int port; - char *dialplan; - char *codec_string; - char *codec_order[SWITCH_MAX_CODECS]; - int codec_order_last; - char *codec_rates_string; - char *codec_rates[SWITCH_MAX_CODECS]; - int codec_rates_last; - unsigned int flags; - int fd; - int calls; - char hold_music[256]; - switch_mutex_t *mutex; + int debug; + char *ip; + int port; + char *dialplan; + char *codec_string; + char *codec_order[SWITCH_MAX_CODECS]; + int codec_order_last; + char *codec_rates_string; + char *codec_rates[SWITCH_MAX_CODECS]; + int codec_rates_last; + unsigned int flags; + int fd; + int calls; + char hold_music[256]; + switch_mutex_t *mutex; } globals; struct skypiax_interface { - char interface_id[80]; - char name[80]; - char dialplan[80]; - char context[80]; - char dial_regex[256]; - char fail_dial_regex[256]; - char hold_music[256]; - char type[256]; - char X11_display[256]; - struct AsteriskHandles AsteriskHandlesAst; - - int interface_state; /*!< \brief 'state' of the interface (channel) */ - char language[80]; /*!< \brief default Asterisk dialplan language for this interface */ - char exten[80]; /*!< \brief default Asterisk dialplan extension for this interface */ - int skypiax_sound_rate; /*!< \brief rate of the sound device, in Hz, eg: 8000 */ - switch_file_t *skypiax_sound_capt_fd; /*!< \brief file descriptor for sound capture dev */ - char callid_name[50]; - char callid_number[50]; - double playback_boost; - double capture_boost; - int stripmsd; - switch_thread_t *skype_thread; - char skype_call_id[512]; - int skype_call_ongoing; - char skype_friends[4096]; - char skype_fullname[512]; - char skype_displayname[512]; - int skype_callflow; /*!< \brief 'callflow' of the skype interface (as opposed to phone interface) */ - int skype; /*!< \brief config flag, bool, Skype support on this interface (0 if false, -1 if true) */ - int control_to_send; - switch_file_t *audiopipe[2]; - switch_file_t *audioskypepipe[2]; - switch_thread_t *tcp_srv_thread; - switch_thread_t *tcp_cli_thread; - short audiobuf[160]; - int audiobuf_is_loaded; - - //int phonebook_listing; - //int phonebook_querying; - //int phonebook_listing_received_calls; - - //int phonebook_first_entry; - //int phonebook_last_entry; - //int phonebook_number_lenght; - //int phonebook_text_lenght; - FILE *phonebook_writing_fp; - int skypiax_dir_entry_extension_prefix; - void *tech_pvt; + char interface_id[80]; + char name[80]; + char dialplan[80]; + char context[80]; + char dial_regex[256]; + char fail_dial_regex[256]; + char hold_music[256]; + char type[256]; + char X11_display[256]; + struct AsteriskHandles AsteriskHandlesAst; + + int interface_state; /*!< \brief 'state' of the interface (channel) */ + char language[80]; /*!< \brief default Asterisk dialplan language for this interface */ + char exten[80]; /*!< \brief default Asterisk dialplan extension for this interface */ + int skypiax_sound_rate; /*!< \brief rate of the sound device, in Hz, eg: 8000 */ + switch_file_t *skypiax_sound_capt_fd; /*!< \brief file descriptor for sound capture dev */ + char callid_name[50]; + char callid_number[50]; + double playback_boost; + double capture_boost; + int stripmsd; + switch_thread_t *skype_thread; + char skype_call_id[512]; + int skype_call_ongoing; + char skype_friends[4096]; + char skype_fullname[512]; + char skype_displayname[512]; + int skype_callflow; /*!< \brief 'callflow' of the skype interface (as opposed to phone interface) */ + int skype; /*!< \brief config flag, bool, Skype support on this interface (0 if false, -1 if true) */ + int control_to_send; + switch_file_t *audiopipe[2]; + switch_file_t *audioskypepipe[2]; + switch_thread_t *tcp_srv_thread; + switch_thread_t *tcp_cli_thread; + short audiobuf[160]; + int audiobuf_is_loaded; + + //int phonebook_listing; + //int phonebook_querying; + //int phonebook_listing_received_calls; + + //int phonebook_first_entry; + //int phonebook_last_entry; + //int phonebook_number_lenght; + //int phonebook_text_lenght; + FILE *phonebook_writing_fp; + int skypiax_dir_entry_extension_prefix; + void *tech_pvt; }; typedef struct skypiax_interface skypiax_interface_t; static skypiax_interface_t SKYPIAX_INTERFACES[SKYPIAX_MAX_INTERFACES]; - struct private_object { - unsigned int flags; - switch_codec_t read_codec; - switch_codec_t write_codec; - switch_frame_t read_frame; - unsigned char databuf[SWITCH_RECOMMENDED_BUFFER_SIZE]; - switch_core_session_t *session; - switch_caller_profile_t *caller_profile; - switch_mutex_t *mutex; - switch_mutex_t *flag_mutex; - skypiax_interface_t *p; - //switch_thread_cond_t *cond; + unsigned int flags; + switch_codec_t read_codec; + switch_codec_t write_codec; + switch_frame_t read_frame; + unsigned char databuf[SWITCH_RECOMMENDED_BUFFER_SIZE]; + switch_core_session_t *session; + switch_caller_profile_t *caller_profile; + switch_mutex_t *mutex; + switch_mutex_t *flag_mutex; + skypiax_interface_t *p; + //switch_thread_cond_t *cond; }; typedef struct private_object private_t; - - - SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, globals.dialplan); SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_string, globals.codec_string); -SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_rates_string, globals.codec_rates_string); +SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_rates_string, + globals.codec_rates_string); SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_ip, globals.ip); - - -static switch_status_t channel_on_init(switch_core_session_t *session); -static switch_status_t channel_on_hangup(switch_core_session_t *session); -static switch_status_t channel_on_routing(switch_core_session_t *session); -static switch_status_t channel_on_exchange_media(switch_core_session_t *session); -static switch_status_t channel_on_soft_execute(switch_core_session_t *session); -static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event, - switch_caller_profile_t *outbound_profile, - switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags); -static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id); -static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id); -static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig); +static switch_status_t channel_on_init(switch_core_session_t * session); +static switch_status_t channel_on_hangup(switch_core_session_t * session); +static switch_status_t channel_on_routing(switch_core_session_t * session); +static switch_status_t channel_on_exchange_media(switch_core_session_t * session); +static switch_status_t channel_on_soft_execute(switch_core_session_t * session); +static switch_call_cause_t channel_outgoing_channel(switch_core_session_t * session, + switch_event_t * var_event, + switch_caller_profile_t * + outbound_profile, + switch_core_session_t ** new_session, + switch_memory_pool_t ** pool, + switch_originate_flag_t flags); +static switch_status_t channel_read_frame(switch_core_session_t * session, + switch_frame_t ** frame, switch_io_flag_t flags, + int stream_id); +static switch_status_t channel_write_frame(switch_core_session_t * session, + switch_frame_t * frame, switch_io_flag_t flags, + int stream_id); +static switch_status_t channel_kill_channel(switch_core_session_t * session, int sig); int option_debug = 100; switch_core_session_t *global_session = NULL; @@ -310,17 +306,16 @@ SKYPECONTROLAPI_ATTACH_API_AVAILABLE = 0x8001 }; - char -*strsep(char **stringp, const char *delim) + *strsep(char **stringp, const char *delim) { char *res; if (!stringp || !*stringp || !**stringp) - return (char*)0; + return (char *) 0; res = *stringp; - while(**stringp && !strchr(delim, **stringp)) + while (**stringp && !strchr(delim, **stringp)) ++(*stringp); if (**stringp) { @@ -331,8 +326,6 @@ return res; } - - LRESULT APIENTRY skypiax_skype_present(HWND hWindow, UINT uiMessage, WPARAM uiParam, LPARAM ulParam) { @@ -349,20 +342,20 @@ break; case WM_COPYDATA: if (win32_hGlobal_SkypeAPIWindowHandle == (HWND) uiParam) { - unsigned int howmany; - char msg_from_skype[2048]; - + unsigned int howmany; + char msg_from_skype[2048]; PCOPYDATASTRUCT poCopyData = (PCOPYDATASTRUCT) ulParam; - memset(msg_from_skype, '\0', sizeof(msg_from_skype)); - strncpy(msg_from_skype, (const char *) poCopyData->lpData, sizeof(msg_from_skype) -2); + memset(msg_from_skype, '\0', sizeof(msg_from_skype)); + strncpy(msg_from_skype, (const char *) poCopyData->lpData, + sizeof(msg_from_skype) - 2); //howmany = strlen((const char *) poCopyData->lpData); howmany = strlen(msg_from_skype) + 1; //switch_file_write(win32_AsteriskHandlesSkype->fdesc[1], (const char *) poCopyData->lpData, &howmany); switch_file_write(win32_AsteriskHandlesSkype->fdesc[1], msg_from_skype, &howmany); - NOTICA("From Skype API: %s\n", SKYPIAX_P_LOG, (const char *) poCopyData->lpData); + NOTICA("From Skype API: %s\n", SKYPIAX_P_LOG, (const char *) poCopyData->lpData); //howmany=1; //switch_file_write(win32_AsteriskHandlesSkype->fdesc[1], "\0", &howmany); lReturnCode = 1; @@ -471,7 +464,7 @@ DWORD win32_dwThreadId; //void *do_skype_thread(void *data) -static void *SWITCH_THREAD_FUNC do_skype_thread(switch_thread_t *thread, void *obj) +static void *SWITCH_THREAD_FUNC do_skype_thread(switch_thread_t * thread, void *obj) { /* create window class */ /* create dummy/hidden window for processing messages */ @@ -487,14 +480,15 @@ 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; + return NULL; } #endif //0 struct skypiax_interface *p; p = obj; - switch_file_pipe_create_ex(&p->AsteriskHandlesAst.fdesc[0], &p->AsteriskHandlesAst.fdesc[1], 2, module_pool); + switch_file_pipe_create_ex(&p->AsteriskHandlesAst.fdesc[0], + &p->AsteriskHandlesAst.fdesc[1], 2, module_pool); win32_AsteriskHandlesSkype = &p->AsteriskHandlesAst; @@ -535,146 +529,149 @@ #endif /* __CYGWIN__ */ - - #endif //WIN32_SKYPIAX - -static switch_status_t skypiax_codec(private_t *tech_pvt, int sample_rate, int codec_ms) +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, - "L16", - NULL, sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, - NULL) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n"); - return SWITCH_STATUS_FALSE; - } - - if (switch_core_codec_init(&tech_pvt->write_codec, - "L16", - NULL, - sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, - NULL) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n"); - switch_core_codec_destroy(&tech_pvt->read_codec); - return SWITCH_STATUS_FALSE; - } - - tech_pvt->read_frame.rate = sample_rate; - tech_pvt->read_frame.codec = &tech_pvt->read_codec; + if (switch_core_codec_init + (&tech_pvt->read_codec, "L16", NULL, sample_rate, codec_ms, 1, + SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, + NULL) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n"); + return SWITCH_STATUS_FALSE; + } + + if (switch_core_codec_init + (&tech_pvt->write_codec, "L16", NULL, sample_rate, codec_ms, 1, + SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, + NULL) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n"); + switch_core_codec_destroy(&tech_pvt->read_codec); + return SWITCH_STATUS_FALSE; + } + tech_pvt->read_frame.rate = sample_rate; + tech_pvt->read_frame.codec = &tech_pvt->read_codec; - switch_core_session_set_read_codec(tech_pvt->session, &tech_pvt->read_codec); - switch_core_session_set_write_codec(tech_pvt->session, &tech_pvt->write_codec); + switch_core_session_set_read_codec(tech_pvt->session, &tech_pvt->read_codec); + switch_core_session_set_write_codec(tech_pvt->session, &tech_pvt->write_codec); - return SWITCH_STATUS_SUCCESS; + return SWITCH_STATUS_SUCCESS; } + #undef PORTAUDIO_ENGAGE #ifdef PORTAUDIO_ENGAGE static switch_status_t engage_device(int sample_rate, int codec_ms) { - PaStreamParameters inputParameters, outputParameters; - PaError err; + PaStreamParameters inputParameters, outputParameters; + PaError err; + + if (!globals.audio_stream) { + if (!sample_rate) { + sample_rate = globals.sample_rate; + } + if (!codec_ms) { + codec_ms = globals.codec_ms; + } + + if (!globals.read_codec.implementation) { + if (switch_core_codec_init + (&globals.read_codec, "L16", NULL, sample_rate, codec_ms, 1, + SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, + NULL) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n"); + return SWITCH_STATUS_FALSE; + } + } + + switch_assert(globals.read_codec.implementation); + + if (!globals.write_codec.implementation) { + if (switch_core_codec_init + (&globals.write_codec, "L16", NULL, sample_rate, codec_ms, 1, + SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, + NULL) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n"); + switch_core_codec_destroy(&globals.read_codec); + return SWITCH_STATUS_FALSE; + } + } + + if (!globals.timer.timer_interface) { + if (switch_core_timer_init + (&globals.timer, globals.timer_name, codec_ms, + globals.read_codec.implementation->samples_per_packet, + module_pool) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup timer failed!\n"); + switch_core_codec_destroy(&globals.read_codec); + switch_core_codec_destroy(&globals.write_codec); + return SWITCH_STATUS_FALSE; + } + } + + if (!globals.hold_timer.timer_interface) { + if (switch_core_timer_init + (&globals.hold_timer, globals.timer_name, codec_ms, + globals.read_codec.implementation->samples_per_packet, + module_pool) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, + "setup hold timer failed!\n"); + switch_core_codec_destroy(&globals.read_codec); + switch_core_codec_destroy(&globals.write_codec); + switch_core_timer_destroy(&globals.timer); + return SWITCH_STATUS_FALSE; + } + } + + globals.read_frame.rate = sample_rate; + globals.read_frame.codec = &globals.read_codec; - if (!globals.audio_stream) { - if (!sample_rate) { - sample_rate = globals.sample_rate; - } - if (!codec_ms) { - codec_ms = globals.codec_ms; - } - - if (!globals.read_codec.implementation) { - if (switch_core_codec_init(&globals.read_codec, - "L16", - NULL, sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, - NULL) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n"); - return SWITCH_STATUS_FALSE; - } - } - - switch_assert(globals.read_codec.implementation); - - if (!globals.write_codec.implementation) { - if (switch_core_codec_init(&globals.write_codec, - "L16", - NULL, - sample_rate, codec_ms, 1, SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, - NULL) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n"); - switch_core_codec_destroy(&globals.read_codec); - return SWITCH_STATUS_FALSE; - } - } - - if (!globals.timer.timer_interface) { - if (switch_core_timer_init(&globals.timer, - globals.timer_name, codec_ms, globals.read_codec.implementation->samples_per_packet, - module_pool) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup timer failed!\n"); - switch_core_codec_destroy(&globals.read_codec); - switch_core_codec_destroy(&globals.write_codec); - return SWITCH_STATUS_FALSE; - } - } - - if (!globals.hold_timer.timer_interface) { - if (switch_core_timer_init(&globals.hold_timer, - globals.timer_name, codec_ms, globals.read_codec.implementation->samples_per_packet, - module_pool) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup hold timer failed!\n"); - switch_core_codec_destroy(&globals.read_codec); - switch_core_codec_destroy(&globals.write_codec); - switch_core_timer_destroy(&globals.timer); - return SWITCH_STATUS_FALSE; - } - } - - globals.read_frame.rate = sample_rate; - globals.read_frame.codec = &globals.read_codec; - - switch_mutex_lock(globals.device_lock); - /* LOCKED ************************************************************************************************** */ - inputParameters.device = globals.indev; - inputParameters.channelCount = 1; - inputParameters.sampleFormat = SAMPLE_TYPE; - inputParameters.suggestedLatency = Pa_GetDeviceInfo(inputParameters.device)->defaultLowInputLatency; - inputParameters.hostApiSpecificStreamInfo = NULL; - - outputParameters.device = globals.outdev; - outputParameters.channelCount = 1; - outputParameters.sampleFormat = SAMPLE_TYPE; - outputParameters.suggestedLatency = Pa_GetDeviceInfo(outputParameters.device)->defaultLowOutputLatency; - outputParameters.hostApiSpecificStreamInfo = NULL; - err = OpenAudioStream(&globals.audio_stream, &inputParameters, &outputParameters, sample_rate, paClipOff, - globals.read_codec.implementation->samples_per_packet); - /* UNLOCKED ************************************************************************************************* */ - switch_mutex_unlock(globals.device_lock); - - if (err != paNoError) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't open audio device!\n"); - switch_core_codec_destroy(&globals.read_codec); - switch_core_codec_destroy(&globals.write_codec); - switch_core_timer_destroy(&globals.timer); - switch_core_timer_destroy(&globals.hold_timer); - return SWITCH_STATUS_FALSE; - } - } + switch_mutex_lock(globals.device_lock); + /* LOCKED ************************************************************************************************** */ + inputParameters.device = globals.indev; + inputParameters.channelCount = 1; + inputParameters.sampleFormat = SAMPLE_TYPE; + inputParameters.suggestedLatency = + Pa_GetDeviceInfo(inputParameters.device)->defaultLowInputLatency; + inputParameters.hostApiSpecificStreamInfo = NULL; + + outputParameters.device = globals.outdev; + outputParameters.channelCount = 1; + outputParameters.sampleFormat = SAMPLE_TYPE; + outputParameters.suggestedLatency = + Pa_GetDeviceInfo(outputParameters.device)->defaultLowOutputLatency; + outputParameters.hostApiSpecificStreamInfo = NULL; + err = + OpenAudioStream(&globals.audio_stream, &inputParameters, &outputParameters, + sample_rate, paClipOff, + globals.read_codec.implementation->samples_per_packet); + /* UNLOCKED ************************************************************************************************* */ + switch_mutex_unlock(globals.device_lock); + + if (err != paNoError) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, + "Can't open audio device!\n"); + switch_core_codec_destroy(&globals.read_codec); + switch_core_codec_destroy(&globals.write_codec); + switch_core_timer_destroy(&globals.timer); + switch_core_timer_destroy(&globals.hold_timer); + return SWITCH_STATUS_FALSE; + } + } - return SWITCH_STATUS_SUCCESS; + return SWITCH_STATUS_SUCCESS; } #endif // PORTAUDIO_ENGAGE - #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) +static void *SWITCH_THREAD_FUNC skypiax_do_tcp_srv_thread(switch_thread_t * thread, + void *obj) { struct skypiax_interface *p = obj; short in[GG]; @@ -696,8 +693,8 @@ memset(&my_addr, 0, sizeof(my_addr)); my_addr.sin_family = AF_INET; //my_addr.sin_addr.s_addr = INADDR_ANY; - my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */ - my_addr.sin_port = htons(5556); //FIXME configurable! + my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */ + my_addr.sin_port = htons(5556); //FIXME configurable! if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) { ERRORA("socket Error\n", SKYPIAX_P_LOG); @@ -721,87 +718,82 @@ sin_size = sizeof(remote_addr); while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) { DEBUGA_SKYPE("ACCEPTED\n", SKYPIAX_P_LOG); - while (p->interface_state != SKYPIAX_STATE_DOWN && (p->skype_callflow == CALLFLOW_STATUS_INPROGRESS ||p->skype_callflow == SKYPIAX_STATE_UP)) { - - int fdselect; - int rt; - fd_set fs; - struct timeval to; - - exit=1; - - - - - - - fdselect = fd; - FD_ZERO(&fs); - FD_SET(fdselect, &fs); - to.tv_usec = 100; - to.tv_sec = 0; - rt = select(fdselect + 1, &fs, NULL, NULL, &to); - if (rt > 0) { - - len = recv(fd, in, sizeof(short) * GG, 0); - //DEBUGA_SKYPE("recv %d\n", SKYPIAX_P_LOG, len); - if (len > 0) { - a = 0; - for (i = 0; i < len / sizeof(short); i++) { - out[a] = in[i]; - i++; - a++; - } - - if (!p->audiobuf_is_loaded) { - for (i = 0; i < (len / sizeof(short)) / 2; i++) { - p->audiobuf[i] = out[i]; + while (p->interface_state != SKYPIAX_STATE_DOWN + && (p->skype_callflow == CALLFLOW_STATUS_INPROGRESS + || p->skype_callflow == SKYPIAX_STATE_UP)) { + + int fdselect; + int rt; + fd_set fs; + struct timeval to; + + exit = 1; + + fdselect = fd; + FD_ZERO(&fs); + FD_SET(fdselect, &fs); + to.tv_usec = 100; + to.tv_sec = 0; + rt = select(fdselect + 1, &fs, NULL, NULL, &to); + if (rt > 0) { + + len = recv(fd, in, sizeof(short) * GG, 0); + //DEBUGA_SKYPE("recv %d\n", SKYPIAX_P_LOG, len); + if (len > 0) { + a = 0; + for (i = 0; i < len / sizeof(short); i++) { + out[a] = in[i]; + i++; + a++; } - p->audiobuf_is_loaded = 1; - } else { - unsigned int howmany; + + if (!p->audiobuf_is_loaded) { + for (i = 0; i < (len / sizeof(short)) / 2; i++) { + p->audiobuf[i] = out[i]; + } + p->audiobuf_is_loaded = 1; + } else { + unsigned int howmany; short totalbuf[GG]; - howmany = len/2/2; - for(i=0; iaudiobuf[i]; - - howmany = len/2/2; - for(a=0; aaudiobuf[i]; + + howmany = len / 2 / 2; + for (a = 0; a < howmany; a++) { + totalbuf[i] = out[a]; + i++; } howmany = len; - switch_file_write(p->audiopipe[1], totalbuf, &howmany); - //howmany = len/2; - //switch_file_write(p->audiopipe[1], out, &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); - } + switch_file_write(p->audiopipe[1], totalbuf, &howmany); + //howmany = len/2; + //switch_file_write(p->audiopipe[1], out, &howmany); + p->audiobuf_is_loaded = 0; + //DEBUGA_SKYPE("read=====> req=%d recv=%d to sent=%d sent=%d\n", SKYPIAX_P_LOG, sizeof(short)*GG, len, (len*sizeof(short))/2, howmany); + } - } else if (len == 0) { - DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG); - break; - } else { - ERRORA("len=%d\n", SKYPIAX_P_LOG, len); - exit = 1; - break; + } else if (len == 0) { + DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG); + break; + } else { + ERRORA("len=%d\n", SKYPIAX_P_LOG, len); + exit = 1; + break; + } } - } } - - - kill_cli_size=320; + kill_cli_size = 320; switch_file_write(p->audiopipe[1], kill_cli_buff, &kill_cli_size); - kill_cli_size=320; + kill_cli_size = 320; switch_file_write(p->audioskypepipe[1], kill_cli_buff, &kill_cli_size); p->interface_state = SKYPIAX_STATE_DOWN; - kill_cli_size=320; + kill_cli_size = 320; switch_file_write(p->audiopipe[1], kill_cli_buff, &kill_cli_size); - kill_cli_size=320; + kill_cli_size = 320; switch_file_write(p->audioskypepipe[1], kill_cli_buff, &kill_cli_size); DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG); @@ -827,7 +819,8 @@ } return NULL; } -static void *SWITCH_THREAD_FUNC skypiax_do_tcp_cli_thread(switch_thread_t *thread, void *obj) +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; @@ -848,8 +841,8 @@ memset(&my_addr, 0, sizeof(my_addr)); my_addr.sin_family = AF_INET; //my_addr.sin_addr.s_addr = INADDR_ANY; - my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */ - my_addr.sin_port = htons(5558); //FIXME configurable! + my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */ + my_addr.sin_port = htons(5558); //FIXME configurable! if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) { ERRORA("socket Error\n", SKYPIAX_P_LOG); @@ -865,9 +858,9 @@ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); } #ifndef WIN32_SKYPIAX - close(s); + close(s); #else - closesocket(s); + closesocket(s); #endif return NULL; } @@ -879,54 +872,50 @@ while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) { 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; - int rt; - fd_set fs; - struct timeval to; - - //exit=1; - - - - - - - //fdselect = p->audioskypepipe[0]; - fdselect=1; - FD_ZERO(&fs); - FD_SET(fdselect, &fs); - to.tv_usec = 100; - to.tv_sec = 0; - //rt = select(fdselect + 1, &fs, NULL, NULL, &to); - rt=1; - if (rt > 0) { - - - got = (NN / 2) * sizeof(short); - switch_file_read(p->audioskypepipe[0], in, &got); - //ERRORA("got %d\n", SKYPIAX_P_LOG, got); - - if (got > 0) { - a = 0; - for (i = 0; i < got / sizeof(short); i++) { - out[a] = in[i]; - a++; - out[a] = in[i]; - a++; - } + 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]; + fdselect = 1; + FD_ZERO(&fs); + FD_SET(fdselect, &fs); + to.tv_usec = 100; + to.tv_sec = 0; + //rt = select(fdselect + 1, &fs, NULL, NULL, &to); + rt = 1; + if (rt > 0) { + + got = (NN / 2) * sizeof(short); + switch_file_read(p->audioskypepipe[0], in, &got); + //ERRORA("got %d\n", SKYPIAX_P_LOG, got); + + if (got > 0) { + a = 0; + for (i = 0; i < got / sizeof(short); i++) { + out[a] = in[i]; + a++; + out[a] = in[i]; + a++; + } - len = send(fd, out, got * 2, 0); + len = send(fd, out, got * 2, 0); - if (len == 0) { - ERRORA("Skype server GONE\n", SKYPIAX_P_LOG); - break; + if (len == 0) { + ERRORA("Skype server GONE\n", SKYPIAX_P_LOG); + break; + } + } else { + switch_sleep(1000); + //ERRORA("Audio skype pipe give us: %u\n", SKYPIAX_P_LOG, got); } - } else { - switch_sleep(1000); - //ERRORA("Audio skype pipe give us: %u\n", SKYPIAX_P_LOG, got); } - } } ERRORA("Skype server GONE\n", SKYPIAX_P_LOG); @@ -936,7 +925,7 @@ closesocket(fd); #endif //if (exit) - break; + break; } WARNINGA("client (I am it) GONE\n", SKYPIAX_P_LOG); @@ -951,21 +940,19 @@ return NULL; } - int skypiax_skypeaudio_init(struct skypiax_interface *p) { //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_timeout_set(p->audiopipe[0], 100000); - //rv = switch_file_pipe_timeout_set(p->audiopipe[1], 10000); - //rv = switch_file_pipe_create(&readp, &writep, module_pool); + 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_timeout_set(p->audiopipe[0], 100000); + //rv = switch_file_pipe_timeout_set(p->audiopipe[1], 10000); + //rv = switch_file_pipe_create(&readp, &writep, module_pool); //FIXME int c; #if 0 @@ -995,9 +982,11 @@ } */ - rv = switch_file_pipe_create_ex(&p->audioskypepipe[0], &p->audioskypepipe[1], 2, module_pool); - rv = switch_file_pipe_timeout_set(p->audioskypepipe[0], 100); - //rv = switch_file_pipe_timeout_set(p->audioskypepipe[1], 10000); + rv = + switch_file_pipe_create_ex(&p->audioskypepipe[0], &p->audioskypepipe[1], 2, + module_pool); + rv = switch_file_pipe_timeout_set(p->audioskypepipe[0], 100); + //rv = switch_file_pipe_timeout_set(p->audioskypepipe[1], 10000); #ifdef NOTDEF_WIN32_SKYPIAX c = pipe(p->audioskypepipe); if (c) { @@ -1009,16 +998,16 @@ } fcntl(p->audioskypepipe[0], F_SETFL, O_NONBLOCK); fcntl(p->audioskypepipe[1], F_SETFL, O_NONBLOCK); -#endif// WIN32_SKYPIAX +#endif // WIN32_SKYPIAX if (option_debug > 10) { DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); } return 0; } -static switch_status_t skypiax_skypeaudio_read(private_t *tech_pvt) +static switch_status_t skypiax_skypeaudio_read(private_t * tech_pvt) { - struct skypiax_interface *p; + struct skypiax_interface *p; short buf[640]; unsigned int samples; //int fd; @@ -1026,10 +1015,9 @@ //fd_set fs; //struct timeval to; - p = tech_pvt->p; - - //DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); + p = tech_pvt->p; + //DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); memset(buf, '\0', sizeof(buf)); @@ -1041,32 +1029,31 @@ to.tv_sec = 0; rt = select(fd + 1, &fs, NULL, NULL, &to); #endif - rt=1; + rt = 1; if (rt > 0) { + samples = SAMPLES_PER_FRAME * sizeof(short); - samples = SAMPLES_PER_FRAME * sizeof(short); - - switch_file_read(p->audiopipe[0], tech_pvt->read_frame.data, &samples); + switch_file_read(p->audiopipe[0], tech_pvt->read_frame.data, &samples); - //if ((samples = read(p->audiopipe[0], buf, SAMPLES_PER_FRAME * sizeof(short))) != 320) - if (samples != SAMPLES_PER_FRAME * sizeof(short)) { - if(samples) - DEBUGA_SKYPE("read=====> NOT GOOD samples=%d expected=%d\n", SKYPIAX_P_LOG, samples, SAMPLES_PER_FRAME * sizeof(short)); - //switch_sleep(1000); - //do nothing - } else { - tech_pvt->read_frame.datalen=samples; - //DEBUGA_SKYPE("read=====> GOOD samples=%d\n", SKYPIAX_P_LOG, samples); - /* A real frame */ - } + //if ((samples = read(p->audiopipe[0], buf, SAMPLES_PER_FRAME * sizeof(short))) != 320) + if (samples != SAMPLES_PER_FRAME * sizeof(short)) { + if (samples) + DEBUGA_SKYPE("read=====> NOT GOOD samples=%d expected=%d\n", SKYPIAX_P_LOG, + samples, SAMPLES_PER_FRAME * sizeof(short)); + //switch_sleep(1000); + //do nothing + } else { + tech_pvt->read_frame.datalen = samples; + //DEBUGA_SKYPE("read=====> GOOD samples=%d\n", SKYPIAX_P_LOG, samples); + /* A real frame */ + } } else { DEBUGA_SKYPE("select returned %d\n", SKYPIAX_P_LOG, rt); - } - //DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + //DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); return SWITCH_STATUS_SUCCESS; } @@ -1124,280 +1111,292 @@ #endif //0 #endif /* SKYPE_AUDIO */ -static void tech_init(private_t *tech_pvt, switch_core_session_t *session, skypiax_interface_t *p) +static void tech_init(private_t * tech_pvt, switch_core_session_t * session, + skypiax_interface_t * p) { - //struct skypiax_interface *p = NULL; + //struct skypiax_interface *p = NULL; - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - tech_pvt->read_frame.data = tech_pvt->databuf; - tech_pvt->read_frame.buflen = sizeof(tech_pvt->databuf); - switch_mutex_init(&tech_pvt->mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session)); - switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, switch_core_session_get_pool(session)); - switch_core_session_set_private(session, tech_pvt); - tech_pvt->session = session; - if(p){ - tech_pvt->p=p; - p->tech_pvt=tech_pvt; - - } -if ( skypiax_codec(tech_pvt, 8000, 20) != SWITCH_STATUS_SUCCESS) -{ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "skypiax_docec FAILED\n"); -} else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "skypiax_codec SUCCESS\n"); -} + DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); + tech_pvt->read_frame.data = tech_pvt->databuf; + tech_pvt->read_frame.buflen = sizeof(tech_pvt->databuf); + switch_mutex_init(&tech_pvt->mutex, SWITCH_MUTEX_NESTED, + switch_core_session_get_pool(session)); + switch_mutex_init(&tech_pvt->flag_mutex, SWITCH_MUTEX_NESTED, + switch_core_session_get_pool(session)); + switch_core_session_set_private(session, tech_pvt); + tech_pvt->session = session; + if (p) { + tech_pvt->p = p; + p->tech_pvt = tech_pvt; - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + } + if (skypiax_codec(tech_pvt, 8000, 20) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "skypiax_docec FAILED\n"); + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "skypiax_codec SUCCESS\n"); + } + + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); } + /* State methods they get called when the state changes to the specific state returning SWITCH_STATUS_SUCCESS tells the core to execute the standard state method next so if you fully implement the state you can return SWITCH_STATUS_FALSE to skip it. */ -static switch_status_t channel_on_init(switch_core_session_t *session) +static switch_status_t channel_on_init(switch_core_session_t * session) { - switch_channel_t *channel; - private_t *tech_pvt = NULL; - - tech_pvt = switch_core_session_get_private(session); - assert(tech_pvt != NULL); + switch_channel_t *channel; + private_t *tech_pvt = NULL; - channel = switch_core_session_get_channel(session); - assert(channel != NULL); - switch_set_flag_locked(tech_pvt, TFLAG_IO); + tech_pvt = switch_core_session_get_private(session); + assert(tech_pvt != NULL); - /* Move channel's state machine to ROUTING. This means the call is trying - to get from the initial start where the call because, to the point - where a destination has been identified. If the channel is simply - left in the initial state, nothing will happen. */ - switch_channel_set_state(channel, CS_ROUTING); - switch_mutex_lock(globals.mutex); - globals.calls++; - switch_mutex_unlock(globals.mutex); + channel = switch_core_session_get_channel(session); + assert(channel != NULL); + switch_set_flag_locked(tech_pvt, TFLAG_IO); + + /* Move channel's state machine to ROUTING. This means the call is trying + to get from the initial start where the call because, to the point + where a destination has been identified. If the channel is simply + left in the initial state, nothing will happen. */ + switch_channel_set_state(channel, CS_ROUTING); + switch_mutex_lock(globals.mutex); + 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; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL INIT\n", + switch_channel_get_name(channel)); + return SWITCH_STATUS_SUCCESS; } -static switch_status_t channel_on_routing(switch_core_session_t *session) +static switch_status_t channel_on_routing(switch_core_session_t * session) { - switch_channel_t *channel = NULL; - private_t *tech_pvt = NULL; + switch_channel_t *channel = NULL; + private_t *tech_pvt = NULL; - channel = switch_core_session_get_channel(session); - assert(channel != NULL); + channel = switch_core_session_get_channel(session); + assert(channel != NULL); - tech_pvt = switch_core_session_get_private(session); - assert(tech_pvt != NULL); + tech_pvt = switch_core_session_get_private(session); + assert(tech_pvt != NULL); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL ROUTING\n", switch_channel_get_name(channel)); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL ROUTING\n", + switch_channel_get_name(channel)); - return SWITCH_STATUS_SUCCESS; + return SWITCH_STATUS_SUCCESS; } -static switch_status_t channel_on_execute(switch_core_session_t *session) +static switch_status_t channel_on_execute(switch_core_session_t * session) { - switch_channel_t *channel = NULL; - private_t *tech_pvt = NULL; - - channel = switch_core_session_get_channel(session); - assert(channel != NULL); + switch_channel_t *channel = NULL; + private_t *tech_pvt = NULL; - tech_pvt = switch_core_session_get_private(session); - assert(tech_pvt != NULL); + channel = switch_core_session_get_channel(session); + assert(channel != NULL); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL EXECUTE\n", switch_channel_get_name(channel)); + tech_pvt = switch_core_session_get_private(session); + assert(tech_pvt != NULL); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL EXECUTE\n", + switch_channel_get_name(channel)); - return SWITCH_STATUS_SUCCESS; + return SWITCH_STATUS_SUCCESS; } -static switch_status_t channel_kill_channel(switch_core_session_t *session, int sig) +static switch_status_t channel_kill_channel(switch_core_session_t * session, int sig) { - switch_channel_t *channel = NULL; - private_t *tech_pvt = NULL; - - channel = switch_core_session_get_channel(session); - assert(channel != NULL); + switch_channel_t *channel = NULL; + private_t *tech_pvt = NULL; - tech_pvt = switch_core_session_get_private(session); - assert(tech_pvt != NULL); + channel = switch_core_session_get_channel(session); + assert(channel != NULL); - switch (sig) { - case SWITCH_SIG_KILL: - 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); - //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_DEBUG, "%s CHANNEL got SWITCH_SIG_BREAK\n", switch_channel_get_name(channel)); - switch_set_flag_locked(tech_pvt, TFLAG_BREAK); - break; - default: - break; - } + tech_pvt = switch_core_session_get_private(session); + assert(tech_pvt != NULL); + + switch (sig) { + case SWITCH_SIG_KILL: + 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); + //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_DEBUG, + "%s CHANNEL got SWITCH_SIG_BREAK\n", + switch_channel_get_name(channel)); + switch_set_flag_locked(tech_pvt, TFLAG_BREAK); + break; + default: + break; + } - return SWITCH_STATUS_SUCCESS; + return SWITCH_STATUS_SUCCESS; } -static switch_status_t channel_on_exchange_media(switch_core_session_t *session) +static switch_status_t channel_on_exchange_media(switch_core_session_t * session) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL LOOPBACK\n"); - return SWITCH_STATUS_SUCCESS; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL LOOPBACK\n"); + return SWITCH_STATUS_SUCCESS; } -static switch_status_t channel_on_soft_execute(switch_core_session_t *session) +static switch_status_t channel_on_soft_execute(switch_core_session_t * session) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL TRANSMIT\n"); - return SWITCH_STATUS_SUCCESS; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL TRANSMIT\n"); + return SWITCH_STATUS_SUCCESS; } -static switch_status_t channel_send_dtmf(switch_core_session_t *session, const switch_dtmf_t *dtmf) +static switch_status_t channel_send_dtmf(switch_core_session_t * session, + const switch_dtmf_t * dtmf) { - private_t *tech_pvt = switch_core_session_get_private(session); - switch_assert(tech_pvt != NULL); + private_t *tech_pvt = switch_core_session_get_private(session); + switch_assert(tech_pvt != NULL); - return SWITCH_STATUS_SUCCESS; + return SWITCH_STATUS_SUCCESS; } -static switch_status_t channel_read_frame(switch_core_session_t *session, switch_frame_t **frame, switch_io_flag_t flags, int stream_id) -{ - switch_channel_t *channel = NULL; - private_t *tech_pvt = NULL; - //switch_time_t started = switch_time_now(); - //unsigned int elapsed; - switch_byte_t *data; - - - channel = switch_core_session_get_channel(session); - assert(channel != NULL); - - tech_pvt = switch_core_session_get_private(session); - assert(tech_pvt != NULL); - tech_pvt->read_frame.flags = SFF_NONE; - *frame = NULL; +static switch_status_t channel_read_frame(switch_core_session_t * session, + switch_frame_t ** frame, switch_io_flag_t flags, + int stream_id) +{ + switch_channel_t *channel = NULL; + private_t *tech_pvt = NULL; + //switch_time_t started = switch_time_now(); + //unsigned int elapsed; + switch_byte_t *data; + + channel = switch_core_session_get_channel(session); + assert(channel != NULL); + + tech_pvt = switch_core_session_get_private(session); + assert(tech_pvt != NULL); + tech_pvt->read_frame.flags = SFF_NONE; + *frame = NULL; + if (skypiax_skypeaudio_read(tech_pvt) != SWITCH_STATUS_SUCCESS) { -if ( skypiax_skypeaudio_read(tech_pvt) != SWITCH_STATUS_SUCCESS ) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, + "skypiax_skypeaudio_read ERROR\n"); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "skypiax_skypeaudio_read ERROR\n"); - -} else { - switch_set_flag_locked(tech_pvt, TFLAG_VOICE); - //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "skypiax_skypeaudio_read SUCCESS\n"); - -} + } else { + switch_set_flag_locked(tech_pvt, TFLAG_VOICE); + //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "skypiax_skypeaudio_read SUCCESS\n"); - while (switch_test_flag(tech_pvt, TFLAG_IO)) { - if (switch_test_flag(tech_pvt, TFLAG_BREAK)) { - switch_clear_flag(tech_pvt, TFLAG_BREAK); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL READ FRAME goto CNG\n"); - goto cng; - } + } - if (!switch_test_flag(tech_pvt, TFLAG_IO)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL READ FRAME not IO\n"); - return SWITCH_STATUS_FALSE; - } + while (switch_test_flag(tech_pvt, TFLAG_IO)) { + if (switch_test_flag(tech_pvt, TFLAG_BREAK)) { + switch_clear_flag(tech_pvt, TFLAG_BREAK); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, + "CHANNEL READ FRAME goto CNG\n"); + goto cng; + } + if (!switch_test_flag(tech_pvt, TFLAG_IO)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, + "CHANNEL READ FRAME not IO\n"); + return SWITCH_STATUS_FALSE; + } #if 0 - 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)); - switch_sleep(100); - //do nothing - } else { - //DEBUGA_SOUND("read=====> GOOD samples=%d\n", SKYPIAX_P_LOG, samples); - /* A real frame */ - 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 = SKYPIAX_FRIENDLY_OFFSET; - f.src = skypiax_type; - f.mallocd = 0; - } + 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)); + switch_sleep(100); + //do nothing + } else { + //DEBUGA_SOUND("read=====> GOOD samples=%d\n", SKYPIAX_P_LOG, samples); + /* A real frame */ + 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 = SKYPIAX_FRIENDLY_OFFSET; + f.src = skypiax_type; + f.mallocd = 0; + } #endif - //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "============>\n"); - + //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "============>\n"); - if (switch_test_flag(tech_pvt, TFLAG_IO) && switch_test_flag(tech_pvt, TFLAG_VOICE)) { - switch_clear_flag_locked(tech_pvt, TFLAG_VOICE); - if (!tech_pvt->read_frame.datalen) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL READ CONTINUE\n"); - continue; - } - *frame = &tech_pvt->read_frame; + if (switch_test_flag(tech_pvt, TFLAG_IO) && switch_test_flag(tech_pvt, TFLAG_VOICE)) { + switch_clear_flag_locked(tech_pvt, TFLAG_VOICE); + if (!tech_pvt->read_frame.datalen) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, + "CHANNEL READ CONTINUE\n"); + continue; + } + *frame = &tech_pvt->read_frame; #ifdef BIGENDIAN - if (switch_test_flag(tech_pvt, TFLAG_LINEAR)) { - switch_swap_linear((*frame)->data, (int) (*frame)->datalen / 2); - } + if (switch_test_flag(tech_pvt, TFLAG_LINEAR)) { + switch_swap_linear((*frame)->data, (int) (*frame)->datalen / 2); + } #endif - return SWITCH_STATUS_SUCCESS; - } - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL READ no TFLAG_IO\n"); - return SWITCH_STATUS_FALSE; + return SWITCH_STATUS_SUCCESS; + } - } + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL READ no TFLAG_IO\n"); + return SWITCH_STATUS_FALSE; + } - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL READ FALSE\n"); - return SWITCH_STATUS_FALSE; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL READ FALSE\n"); + return SWITCH_STATUS_FALSE; - cng: - data = (switch_byte_t *) tech_pvt->read_frame.data; - data[0] = 65; - data[1] = 0; - tech_pvt->read_frame.datalen = 2; - tech_pvt->read_frame.flags = SFF_CNG; - *frame = &tech_pvt->read_frame; - return SWITCH_STATUS_SUCCESS; +cng: + data = (switch_byte_t *) tech_pvt->read_frame.data; + data[0] = 65; + data[1] = 0; + tech_pvt->read_frame.datalen = 2; + tech_pvt->read_frame.flags = SFF_CNG; + *frame = &tech_pvt->read_frame; + return SWITCH_STATUS_SUCCESS; } -static switch_status_t channel_write_frame(switch_core_session_t *session, switch_frame_t *frame, switch_io_flag_t flags, int stream_id) -{ - switch_channel_t *channel = NULL; - private_t *tech_pvt = NULL; - //switch_frame_t *pframe; - unsigned int sent; - struct skypiax_interface *p=NULL; +static switch_status_t channel_write_frame(switch_core_session_t * session, + switch_frame_t * frame, switch_io_flag_t flags, + int stream_id) +{ + switch_channel_t *channel = NULL; + private_t *tech_pvt = NULL; + //switch_frame_t *pframe; + unsigned int sent; + struct skypiax_interface *p = NULL; - //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL WRITE FRAME\n"); + //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "CHANNEL WRITE FRAME\n"); - channel = switch_core_session_get_channel(session); - assert(channel != NULL); + channel = switch_core_session_get_channel(session); + assert(channel != NULL); - tech_pvt = switch_core_session_get_private(session); - assert(tech_pvt != NULL); + tech_pvt = switch_core_session_get_private(session); + assert(tech_pvt != NULL); - p=tech_pvt->p; - assert(p != NULL); + p = tech_pvt->p; + assert(p != NULL); - if (!switch_test_flag(tech_pvt, TFLAG_IO)) { + if (!switch_test_flag(tech_pvt, TFLAG_IO)) { ERRORA("CIAPA \n", SKYPIAX_P_LOG); - return SWITCH_STATUS_FALSE; - } + return SWITCH_STATUS_FALSE; + } #ifdef BIGENDIAN - if (switch_test_flag(tech_pvt, TFLAG_LINEAR)) { - switch_swap_linear(frame->data, (int) frame->datalen / 2); - } + if (switch_test_flag(tech_pvt, TFLAG_LINEAR)) { + switch_swap_linear(frame->data, (int) frame->datalen / 2); + } #endif - sent = frame->datalen; - switch_file_write(p->audioskypepipe[1], (short *) frame->data, &sent); - //ERRORA("sent %d\n", SKYPIAX_P_LOG, sent); + sent = frame->datalen; + switch_file_write(p->audioskypepipe[1], (short *) frame->data, &sent); + //ERRORA("sent %d\n", SKYPIAX_P_LOG, sent); - - return SWITCH_STATUS_SUCCESS; + return SWITCH_STATUS_SUCCESS; } @@ -1407,12 +1406,13 @@ void create_pipe(void *data) { - switch_status_t rv; + 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); +} - //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 @@ -1445,325 +1445,325 @@ static apr_file_t *readp = NULL; static apr_file_t *writep = NULL; -static void create_pipe(abts_case *tc, void *data) +static void create_pipe(abts_case * tc, void *data) { - apr_status_t rv; + 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_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_close(readp); - rv = apr_file_close(writep); - ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); +static void close_pipe(abts_case * tc, void *data) +{ + apr_status_t rv; + apr_size_t nbytes = 256; + char buf[256]; - rv = apr_file_read(readp, buf, &nbytes); - ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_EBADF(rv)); -} + rv = apr_file_close(readp); + rv = apr_file_close(writep); + ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); -static void set_timeout(abts_case *tc, void *data) + 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; + 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_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_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_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)); + 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) +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); + apr_status_t rv; + char *buf; + apr_size_t nbytes; - 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); + nbytes = strlen("this is a test"); + buf = (char *) apr_palloc(p, nbytes + 1); - rv = apr_file_pipe_timeout_set(readp, apr_time_from_sec(1)); - ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); + 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); - 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); - } + 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) +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"); + apr_status_t rv; + char *buf = "this is a test"; + char *input; + apr_size_t nbytes; - 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); + nbytes = strlen("this is a test"); - rv = apr_file_write(writep, buf, &nbytes); - ABTS_SIZE_EQUAL(tc, strlen("this is a test"), nbytes); - ABTS_INT_EQUAL(tc, APR_SUCCESS, 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); - 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); + 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) +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); + 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_procattr_error_check_set(procattr, 1); - 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); - 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.out, apr_time_from_sec(10)); + ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - rv = apr_file_pipe_timeout_set(proc.in, apr_time_from_sec(10)); + i = iterations; + do { + rv = apr_file_write_full(proc.in, buf, bytes_per_iteration, NULL); ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); + } while (--i); - rv = apr_file_pipe_timeout_set(proc.out, apr_time_from_sec(10)); - ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); + free(buf); - i = iterations; - do { - rv = apr_file_write_full(proc.in, buf, bytes_per_iteration, NULL); - ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - } while (--i); + rv = apr_file_close(proc.in); + ABTS_INT_EQUAL(tc, APR_SUCCESS, rv); - free(buf); + 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); - 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, "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_ASSERT(tc, "child terminated normally", why == APR_PROC_EXIT); } -abts_suite *testpipe(abts_suite *suite) +abts_suite *testpipe(abts_suite * suite) { - suite = ADD_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); + 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; + return suite; } - - - #endif - #endif -static switch_status_t channel_answer_channel(switch_core_session_t *session) +static switch_status_t channel_answer_channel(switch_core_session_t * session) { - private_t *tech_pvt; - switch_channel_t *channel = NULL; - struct skypiax_interface *p; + private_t *tech_pvt; + switch_channel_t *channel = NULL; + struct skypiax_interface *p; - channel = switch_core_session_get_channel(session); - assert(channel != NULL); + channel = switch_core_session_get_channel(session); + assert(channel != NULL); - tech_pvt = switch_core_session_get_private(session); - assert(tech_pvt != NULL); + tech_pvt = switch_core_session_get_private(session); + assert(tech_pvt != NULL); - p=tech_pvt->p; + p = tech_pvt->p; - DEBUGA_SKYPE("ANSWERED! \n", SKYPIAX_P_LOG); + DEBUGA_SKYPE("ANSWERED! \n", SKYPIAX_P_LOG); - return SWITCH_STATUS_SUCCESS; + return SWITCH_STATUS_SUCCESS; } - -static switch_status_t channel_receive_message(switch_core_session_t *session, switch_core_session_message_t *msg) +static switch_status_t channel_receive_message(switch_core_session_t * session, + switch_core_session_message_t * msg) { - switch_channel_t *channel; - private_t *tech_pvt; - struct skypiax_interface *p; + switch_channel_t *channel; + private_t *tech_pvt; + struct skypiax_interface *p; - channel = switch_core_session_get_channel(session); - assert(channel != NULL); + channel = switch_core_session_get_channel(session); + assert(channel != NULL); - tech_pvt = (private_t *) switch_core_session_get_private(session); - assert(tech_pvt != NULL); + tech_pvt = (private_t *) switch_core_session_get_private(session); + assert(tech_pvt != NULL); - p=tech_pvt->p; + p = tech_pvt->p; - switch (msg->message_id) { - case SWITCH_MESSAGE_INDICATE_ANSWER: - { - //WARNINGA("TO BE ANSWERED! \n", SKYPIAX_P_LOG); - DEBUGA_SKYPE("MSG_ID=%d, TO BE ANSWERED!\n", SKYPIAX_P_LOG, msg->message_id); - channel_answer_channel(session); - } - break; - default: - { - WARNINGA("MSG_ID=%d\n", SKYPIAX_P_LOG, msg->message_id); - } - break; - } + switch (msg->message_id) { + case SWITCH_MESSAGE_INDICATE_ANSWER: + { + //WARNINGA("TO BE ANSWERED! \n", SKYPIAX_P_LOG); + DEBUGA_SKYPE("MSG_ID=%d, TO BE ANSWERED!\n", SKYPIAX_P_LOG, msg->message_id); + channel_answer_channel(session); + } + break; + default: + { + WARNINGA("MSG_ID=%d\n", SKYPIAX_P_LOG, msg->message_id); + } + break; + } - return SWITCH_STATUS_SUCCESS; + return SWITCH_STATUS_SUCCESS; } + #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! */ -static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event, - switch_caller_profile_t *outbound_profile, - switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags) -{ - if ((*new_session = switch_core_session_request(skypiax_endpoint_interface, pool)) != 0) { - private_t *tech_pvt; - switch_channel_t *channel; - switch_caller_profile_t *caller_profile; - - 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_INTERFACES[2]; //FIXME - channel = switch_core_session_get_channel(*new_session); - tech_init(tech_pvt, *new_session, NULL); - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n"); - switch_core_session_destroy(new_session); - return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; - } - - if (outbound_profile) { - char name[128]; - - snprintf(name, sizeof(name), "skypiax/%s", outbound_profile->destination_number); - switch_channel_set_name(channel, name); - - caller_profile = switch_caller_profile_clone(*new_session, outbound_profile); - switch_channel_set_caller_profile(channel, caller_profile); - tech_pvt->caller_profile = caller_profile; - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Doh! no caller profile\n"); - switch_core_session_destroy(new_session); - return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; - } - - - skypiax_skype_call(tech_pvt->p, outbound_profile->destination_number, 30); - - switch_channel_set_flag(channel, CF_OUTBOUND); - switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND); - switch_channel_set_state(channel, CS_INIT); - return SWITCH_CAUSE_SUCCESS; - } +static switch_call_cause_t channel_outgoing_channel(switch_core_session_t * session, + switch_event_t * var_event, + switch_caller_profile_t * + outbound_profile, + switch_core_session_t ** new_session, + switch_memory_pool_t ** pool, + switch_originate_flag_t flags) +{ + if ((*new_session = switch_core_session_request(skypiax_endpoint_interface, pool)) != 0) { + private_t *tech_pvt; + switch_channel_t *channel; + switch_caller_profile_t *caller_profile; + + 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_INTERFACES[2]; //FIXME + channel = switch_core_session_get_channel(*new_session); + tech_init(tech_pvt, *new_session, NULL); + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, + "Hey where is my memory pool?\n"); + switch_core_session_destroy(new_session); + return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; + } + + if (outbound_profile) { + char name[128]; + + snprintf(name, sizeof(name), "skypiax/%s", outbound_profile->destination_number); + switch_channel_set_name(channel, name); + + caller_profile = switch_caller_profile_clone(*new_session, outbound_profile); + switch_channel_set_caller_profile(channel, caller_profile); + tech_pvt->caller_profile = caller_profile; + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Doh! no caller profile\n"); + switch_core_session_destroy(new_session); + return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; + } + + skypiax_skype_call(tech_pvt->p, outbound_profile->destination_number, 30); + + switch_channel_set_flag(channel, CF_OUTBOUND); + switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND); + switch_channel_set_state(channel, CS_INIT); + return SWITCH_CAUSE_SUCCESS; + } - return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; + return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; } #endif // 0 //FIXME: moved below -static switch_status_t channel_receive_event(switch_core_session_t *session, switch_event_t *event) +static switch_status_t channel_receive_event(switch_core_session_t * session, + switch_event_t * event) { - struct private_object *tech_pvt = switch_core_session_get_private(session); - char *body = switch_event_get_body(event); - switch_assert(tech_pvt != NULL); + struct private_object *tech_pvt = switch_core_session_get_private(session); + char *body = switch_event_get_body(event); + switch_assert(tech_pvt != NULL); - if (!body) { - body = ""; - } + if (!body) { + body = ""; + } - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "event: |||%s|||\n", body); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "event: |||%s|||\n", body); - return SWITCH_STATUS_SUCCESS; + return SWITCH_STATUS_SUCCESS; } - - switch_state_handler_table_t skypiax_state_handlers = { - /*.on_init */ channel_on_init, - /*.on_routing */ channel_on_routing, - /*.on_execute */ channel_on_execute, - /*.on_hangup */ channel_on_hangup, - /*.on_exchange_media */ channel_on_exchange_media, - /*.on_soft_execute */ channel_on_soft_execute + /*.on_init */ channel_on_init, + /*.on_routing */ channel_on_routing, + /*.on_execute */ channel_on_execute, + /*.on_hangup */ channel_on_hangup, + /*.on_exchange_media */ channel_on_exchange_media, + /*.on_soft_execute */ channel_on_soft_execute }; switch_io_routines_t skypiax_io_routines = { - /*.outgoing_channel */ channel_outgoing_channel, - /*.read_frame */ channel_read_frame, - /*.write_frame */ channel_write_frame, - /*.kill_channel */ channel_kill_channel, - /*.send_dtmf */ channel_send_dtmf, - /*.receive_message */ channel_receive_message, - /*.receive_event */ channel_receive_event + /*.outgoing_channel */ channel_outgoing_channel, + /*.read_frame */ channel_read_frame, + /*.write_frame */ channel_write_frame, + /*.kill_channel */ channel_kill_channel, + /*.send_dtmf */ channel_send_dtmf, + /*.receive_message */ channel_receive_message, + /*.receive_event */ channel_receive_event }; + #define SKYPE_THREAD #ifndef WIN32_SKYPIAX #ifdef SKYPE_THREAD @@ -1899,7 +1899,7 @@ switch_sleep(1000); } -static void *SWITCH_THREAD_FUNC do_skype_thread(switch_thread_t *thread, void *obj) +static void *SWITCH_THREAD_FUNC do_skype_thread(switch_thread_t * thread, void *obj) { struct skypiax_interface *p; @@ -1911,7 +1911,7 @@ //int res; p = obj; - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); + DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); /* if (pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL)) { @@ -1923,28 +1923,31 @@ } */ - switch_file_pipe_create_ex(&p->AsteriskHandlesAst.fdesc[0], &p->AsteriskHandlesAst.fdesc[1], 2, module_pool); + 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); DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - return NULL; + return NULL; } fcntl(p->AsteriskHandlesAst.fdesc[0], F_SETFL, O_NONBLOCK); fcntl(p->AsteriskHandlesAst.fdesc[1], F_SETFL, O_NONBLOCK); #endif - AsteriskHandlesAst = &p->AsteriskHandlesAst; //disp = XOpenDisplay(getenv("DISPLAY")); disp = XOpenDisplay(p->X11_display); if (!disp) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot open X Display '%s', exiting skype thread\n", p->X11_display); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, + "Cannot open X Display '%s', exiting skype thread\n", + p->X11_display); return NULL; } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "X Display '%s' opened\n", p->X11_display); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "X Display '%s' opened\n", + p->X11_display); } int xfd; @@ -1977,7 +1980,7 @@ SKYPIAX_P_LOG); //p->skype = 0; //p->skype_thread = SKYPIAX_PTHREADT_NULL; - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); return NULL; } @@ -1988,7 +1991,7 @@ SKYPIAX_P_LOG); //p->skype = 0; //p->skype_thread = SKYPIAX_PTHREADT_NULL; - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); return NULL; } @@ -2022,9 +2025,9 @@ strcat(buffer, buf); if (i < 20) { /* last fragment */ - unsigned int howmany; + unsigned int howmany; - howmany = strlen(b) + 1; + howmany = strlen(b) + 1; switch_file_write(AsteriskHandlesAst->fdesc[1], b, &howmany); //write(AsteriskHandlesAst->fdesc[1], "\0", 1); @@ -2049,17 +2052,14 @@ //p->skype = 0; //p->skype_thread = SKYPIAX_PTHREADT_NULL; //pthread_cleanup_pop(1); - //DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + //DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); return NULL; } - #endif /* SKYPE_THREAD */ #else // WIN32_SKYPIAX - - #endif // WIN32_SKYPIAX #define CONTROLDEV_THREAD @@ -2109,9 +2109,9 @@ } AsteriskHandlesAst = &p->AsteriskHandlesAst; - if (option_debug > 101) { - DEBUGA_SKYPE("SENDING: |||%s||||\n", SKYPIAX_P_LOG, msg_to_skype); - } + 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 @@ -2135,7 +2135,6 @@ } #endif //0 - int skypiax_skype_read(struct skypiax_interface *p) { @@ -2154,7 +2153,7 @@ if (option_debug > 100) { DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); } - //DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); + //DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); //switch_sleep(1000000); memset(read_from_pipe, 0, 4096); @@ -2169,10 +2168,10 @@ to.tv_sec = 0; rt = select(fd + 1, &fs, NULL, NULL, &to); #endif - rt=1; + rt = 1; if (rt > 0) { howmany = sizeof(read_from_pipe); - switch_file_read(p->AsteriskHandlesAst.fdesc[0], read_from_pipe, &howmany); + switch_file_read(p->AsteriskHandlesAst.fdesc[0], read_from_pipe, &howmany); a = 0; for (i = 0; i < howmany; i++) { @@ -2185,7 +2184,7 @@ DEBUGA_SKYPE("read_skype: howmany=%d, i=%d, a=%d, |||%s||| \n", SKYPIAX_P_LOG, howmany, i, a, messaggio); -#if 0 //FIXME wat's the use of this? +#if 0 //FIXME wat's the use of this? if (!strcasecmp(messaggio, "ERROR 68")) { /* not yet protocol specified, just authorized */ NOTICA @@ -2198,25 +2197,24 @@ #endif if (!strncasecmp(messaggio, "ERROR 92 CALL", 12)) { - ERRORA - ("Skype got ERROR: |||%s|||, the number we called was not recognized\n", - SKYPIAX_P_LOG, messaggio); - p->skype_callflow = CALLFLOW_STATUS_FINISHED; - if (option_debug) - DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG); - p->skype_call_id[0] = '\0'; - - if (p->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } - p->interface_state = SKYPIAX_STATE_DOWN; - //FIXME if(p->owner) - //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL; - return CALLFLOW_INCOMING_HANGUP; - } else { - p->interface_state = SKYPIAX_STATE_DOWN; - } + ERRORA("Skype got ERROR: |||%s|||, the number we called was not recognized\n", + SKYPIAX_P_LOG, messaggio); + p->skype_callflow = CALLFLOW_STATUS_FINISHED; + if (option_debug) + DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG); + p->skype_call_id[0] = '\0'; + + if (p->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { + if (option_debug > 100) { + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + } + p->interface_state = SKYPIAX_STATE_DOWN; + //FIXME if(p->owner) + //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL; + return CALLFLOW_INCOMING_HANGUP; + } else { + p->interface_state = SKYPIAX_STATE_DOWN; + } } strncpy(messaggio_2, messaggio, sizeof(messaggio) - 1); @@ -2247,26 +2245,24 @@ strncpy(p->skype_displayname, &messaggio_2[10], 511); } if (!strcasecmp(messaggio, "ERROR")) { - ERRORA - ("Skype got ERROR: |||%s|||\n", - SKYPIAX_P_LOG, messaggio); - p->skype_callflow = CALLFLOW_STATUS_FINISHED; - if (option_debug) - DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG); - p->skype_call_id[0] = '\0'; - - if (p->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } - p->interface_state = SKYPIAX_STATE_DOWN; - //FIXME if(p->owner){ - //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL; - //FIXME } - return CALLFLOW_INCOMING_HANGUP; - } else { - p->interface_state = SKYPIAX_STATE_DOWN; - } + ERRORA("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, messaggio); + p->skype_callflow = CALLFLOW_STATUS_FINISHED; + if (option_debug) + DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG); + p->skype_call_id[0] = '\0'; + + if (p->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { + if (option_debug > 100) { + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + } + p->interface_state = SKYPIAX_STATE_DOWN; + //FIXME if(p->owner){ + //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL; + //FIXME } + return CALLFLOW_INCOMING_HANGUP; + } else { + p->interface_state = SKYPIAX_STATE_DOWN; + } } if (!strcasecmp(messaggio, "CALL")) { @@ -2293,13 +2289,17 @@ 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); + 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); + 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, @@ -2313,32 +2313,30 @@ p->interface_state = SKYPIAX_STATE_PRERING; } - if (!strcasecmp(prop, "DTMF")) { - switch_core_session_t *session = NULL; - private_t *tech_pvt = NULL; - switch_channel_t *channel = NULL; + if (!strcasecmp(prop, "DTMF")) { + switch_core_session_t *session = NULL; + private_t *tech_pvt = NULL; + switch_channel_t *channel = NULL; //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; - session = tech_pvt->session; - channel = switch_core_session_get_channel(session); - - - - if (channel) { - switch_dtmf_t dtmf = { (char) value[0], switch_core_default_dtmf_duration(0) }; - if (globals.debug) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%c DTMF %s\n", dtmf.digit, switch_channel_get_name(channel)); - } - switch_mutex_lock(tech_pvt->flag_mutex); - switch_channel_queue_dtmf(channel, &dtmf); - switch_set_flag(tech_pvt, TFLAG_DTMF); - switch_mutex_unlock(tech_pvt->flag_mutex); - } - - + tech_pvt = p->tech_pvt; + session = tech_pvt->session; + channel = switch_core_session_get_channel(session); + + if (channel) { + switch_dtmf_t dtmf = + { (char) value[0], switch_core_default_dtmf_duration(0) }; + if (globals.debug) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%c DTMF %s\n", + dtmf.digit, switch_channel_get_name(channel)); + } + switch_mutex_lock(tech_pvt->flag_mutex); + switch_channel_queue_dtmf(channel, &dtmf); + switch_set_flag(tech_pvt, TFLAG_DTMF); + switch_mutex_unlock(tech_pvt->flag_mutex); + } //FIXME ast_queue_frame(p->owner, &f2); } @@ -2348,7 +2346,7 @@ ("Skype has FAILED on skype_call %s. Let's wait for the FAILED message.\n", SKYPIAX_P_LOG, id); } - if (!strcasecmp(prop, "DURATION") && (!strcasecmp(value, "1"))) { + if (!strcasecmp(prop, "DURATION") && (!strcasecmp(value, "1"))) { if (strcasecmp(id, p->skype_call_id)) { strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1); if (option_debug > 1) @@ -2358,7 +2356,6 @@ } } - if (!strcasecmp(prop, "STATUS")) { if (!strcasecmp(value, "RINGING")) { @@ -2417,7 +2414,7 @@ DEBUGA_SKYPE("We missed skype_call %s\n", SKYPIAX_P_LOG, id); } else if (!strcasecmp(value, "FINISHED")) { - global_session = NULL; //FIXME + global_session = NULL; //FIXME //p->skype_callflow = CALLFLOW_STATUS_FINISHED; if (option_debug) DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id); @@ -2429,7 +2426,7 @@ } //p->interface_state = SKYPIAX_STATE_DOWN; //FIXME if(p->owner) - //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL; + //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL; return CALLFLOW_INCOMING_HANGUP; } else { p->interface_state = SKYPIAX_STATE_DOWN; @@ -2449,7 +2446,7 @@ } p->interface_state = SKYPIAX_STATE_DOWN; //FIXME if(p->owner) - //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL; + //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL; return CALLFLOW_INCOMING_HANGUP; } else { p->interface_state = SKYPIAX_STATE_DOWN; @@ -2467,7 +2464,7 @@ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); } //FIXME if(p->owner) - //FIXME p->owner->hangupcause = SKYPIAX_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)) { @@ -2484,7 +2481,7 @@ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); } //FIXME if(p->owner) - //FIXME p->owner->hangupcause = SKYPIAX_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 */ @@ -2509,164 +2506,155 @@ DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id); //FIXME if (p->owner) { - //FIXME ast_queue_control(p->owner, SKYPIAX_CONTROL_ANSWER); + //FIXME ast_queue_control(p->owner, SKYPIAX_CONTROL_ANSWER); //FIXME } if (option_debug > 1) - DEBUGA_SKYPE("skype_call: %s SKYPIAX_CONTROL_ANSWER sent\n", SKYPIAX_P_LOG, - id); + DEBUGA_SKYPE("skype_call: %s SKYPIAX_CONTROL_ANSWER sent\n", + SKYPIAX_P_LOG, id); //FIXME if (p->owner) - if (1) { - char msg_to_skype[1024]; - - + if (1) { + char msg_to_skype[1024]; #if 0 - if (!p->tcp_srv_thread) { - if(1) - { + if (!p->tcp_srv_thread) { + if (1) { #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(&p->tcp_srv_thread, thd_attr, skypiax_do_tcp_srv_thread, p, module_pool); - DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG); + //switch_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(&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) - { + if (!p->tcp_cli_thread) { + if (1) { #endif - //switch_thread_t *thread; - //switch_threadattr_t *thd_attr = NULL; + //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(&p->tcp_cli_thread, thd_attr, skypiax_do_tcp_cli_thread, p, module_pool); - DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG); - } + switch_threadattr_create(&thd_attr, module_pool); + switch_threadattr_detach_set(thd_attr, 1); + switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); + switch_thread_create(&p->tcp_cli_thread, thd_attr, + skypiax_do_tcp_cli_thread, p, module_pool); + DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG); + } #if 0 - } - + } - } + } #endif - switch_sleep(100000); - sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"5556\"", id); - skypiax_skype_write(p, msg_to_skype); - switch_sleep(100000); - sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"5558\"", id); - skypiax_skype_write(p, msg_to_skype); - switch_sleep(100000); - } + switch_sleep(100000); + sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"5556\"", id); + skypiax_skype_write(p, msg_to_skype); + switch_sleep(100000); + sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"5558\"", id); + skypiax_skype_write(p, msg_to_skype); + switch_sleep(100000); + } p->skype_callflow = SKYPIAX_STATE_UP; - /**************************/ - - //FIXME switch_core_session_t **new_session; - - //FIXME *new_session=switch_loadable_module_create_interface(skypiax_endpoint_interface, pool); - - if (!global_session) { //FIXME FIXME FIXME - switch_core_session_t *session = NULL; - private_t *tech_pvt = NULL; - switch_channel_t *channel = NULL; - + /**************************/ + //FIXME switch_core_session_t **new_session; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "New Inbound Channel!\n"); - - if ((session = switch_core_session_request(skypiax_endpoint_interface, NULL)) != 0) { - switch_core_session_add_stream(session, NULL); - if ((tech_pvt = (private_t *) switch_core_session_alloc(session, sizeof(private_t))) != 0) { - channel = switch_core_session_get_channel(session); - tech_init(tech_pvt, session, p); - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n"); - switch_core_session_destroy(&session); - break; - } - - // if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session), NULL, dialplan, cid_name, cid_num, ip, NULL, NULL, NULL, modname, NULL, dest)) != 0) - - if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session), - "skypiax", - "XML", - "gmaruzz_from_skype", - "calling_number", - NULL, - "calling_ani", - NULL, - NULL, - (char *) modname, - "default", - "5000")) != 0) { - char name[128]; - switch_snprintf(name, sizeof(name), "skypiax/%s-%04x", tech_pvt->caller_profile->destination_number, rand() & 0xffff); - switch_channel_set_name(channel, name); - switch_channel_set_caller_profile(channel, tech_pvt->caller_profile); - } - switch_channel_set_state(channel, CS_INIT); - if (switch_core_session_thread_launch(session) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error spawning thread\n"); - switch_core_session_destroy(&session); - } + //FIXME *new_session=switch_loadable_module_create_interface(skypiax_endpoint_interface, pool); + if (!global_session) { //FIXME FIXME FIXME + switch_core_session_t *session = NULL; + private_t *tech_pvt = NULL; + switch_channel_t *channel = NULL; + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, + "New Inbound Channel!\n"); + + if ((session = + switch_core_session_request(skypiax_endpoint_interface, + NULL)) != 0) { + switch_core_session_add_stream(session, NULL); + if ((tech_pvt = + (private_t *) switch_core_session_alloc(session, + sizeof(private_t))) != 0) { + channel = switch_core_session_get_channel(session); + tech_init(tech_pvt, session, p); + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, + "Hey where is my memory pool?\n"); + switch_core_session_destroy(&session); + break; + } + + // if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session), NULL, dialplan, cid_name, cid_num, ip, NULL, NULL, NULL, modname, NULL, dest)) != 0) + + if ((tech_pvt->caller_profile = + switch_caller_profile_new(switch_core_session_get_pool(session), + "skypiax", "XML", "gmaruzz_from_skype", + "calling_number", NULL, "calling_ani", + NULL, NULL, (char *) modname, "default", + "5000")) != 0) { + char name[128]; + switch_snprintf(name, sizeof(name), "skypiax/%s-%04x", + tech_pvt->caller_profile->destination_number, + rand() & 0xffff); + switch_channel_set_name(channel, name); + switch_channel_set_caller_profile(channel, tech_pvt->caller_profile); + } + switch_channel_set_state(channel, CS_INIT); + if (switch_core_session_thread_launch(session) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, + "Error spawning thread\n"); + switch_core_session_destroy(&session); + } #if 0 - if (iax_set_codec(tech_pvt, iaxevent->session, - &iaxevent->ies.format, &iaxevent->ies.capability, &iaxevent->ies.samprate, IAX_SET) != SWITCH_STATUS_SUCCESS) { - iax_reject(iaxevent->session, "Codec Error!"); - switch_core_session_destroy(&session); - } else { - tech_pvt->iax_session = iaxevent->session; - tech_pvt->session = session; - iax_accept(tech_pvt->iax_session, tech_pvt->codec); - iax_ring_announce(tech_pvt->iax_session); - switch_channel_set_state(channel, CS_INIT); - if (switch_core_session_thread_launch(session) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Error spawning thread\n"); - switch_core_session_destroy(&session); - } - } + if (iax_set_codec + (tech_pvt, iaxevent->session, &iaxevent->ies.format, + &iaxevent->ies.capability, &iaxevent->ies.samprate, + IAX_SET) != SWITCH_STATUS_SUCCESS) { + iax_reject(iaxevent->session, "Codec Error!"); + switch_core_session_destroy(&session); + } else { + tech_pvt->iax_session = iaxevent->session; + tech_pvt->session = session; + iax_accept(tech_pvt->iax_session, tech_pvt->codec); + iax_ring_announce(tech_pvt->iax_session); + switch_channel_set_state(channel, CS_INIT); + if (switch_core_session_thread_launch(session) != + SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, + "Error spawning thread\n"); + switch_core_session_destroy(&session); + } + } #endif //0 - } - } else { - switch_core_session_t *session = NULL; - private_t *tech_pvt = NULL; - switch_channel_t *channel = NULL; - - tech_pvt = p->tech_pvt; - //session = tech_pvt->session; - session = global_session; - channel = switch_core_session_get_channel(session); - switch_channel_mark_pre_answered(channel); - - //switch_channel_set_state(channel, CS_EXECUTE); - - } - /**************************/ - - - + } + } else { + switch_core_session_t *session = NULL; + private_t *tech_pvt = NULL; + switch_channel_t *channel = NULL; + + tech_pvt = p->tech_pvt; + //session = tech_pvt->session; + session = global_session; + channel = switch_core_session_get_channel(session); + switch_channel_mark_pre_answered(channel); + //switch_channel_set_state(channel, CS_EXECUTE); + } + /**************************/ } else { WARNINGA("skype_call: %s, STATUS: %s is not recognized\n", SKYPIAX_P_LOG, @@ -2686,11 +2674,12 @@ if (option_debug > 100) { DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); } - //DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + //DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); return 0; } -int skypiax_skype_call(struct skypiax_interface *p, char *idest, int timeout, switch_core_session_t *session) +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]; @@ -2698,7 +2687,7 @@ if (option_debug > 10) { DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); } -switch_sleep(5000); + switch_sleep(5000); //FIXME strncpy(rdest, idest, sizeof(rdest) - 1); strncpy(rdest, "echo123", sizeof(rdest) - 1); @@ -2736,51 +2725,57 @@ return 0; } -static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session, switch_event_t *var_event, - switch_caller_profile_t *outbound_profile, - switch_core_session_t **new_session, switch_memory_pool_t **pool, switch_originate_flag_t flags) -{ - if ((*new_session = switch_core_session_request(skypiax_endpoint_interface, pool)) != 0) { - private_t *tech_pvt; - switch_channel_t *channel; - switch_caller_profile_t *caller_profile; - - 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_INTERFACES[2]; //FIXME - channel = switch_core_session_get_channel(*new_session); - tech_init(tech_pvt, *new_session, NULL); - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n"); - switch_core_session_destroy(new_session); - return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; - } - - if (outbound_profile) { - char name[128]; - - snprintf(name, sizeof(name), "skypiax/%s", outbound_profile->destination_number); - switch_channel_set_name(channel, name); - - caller_profile = switch_caller_profile_clone(*new_session, outbound_profile); - switch_channel_set_caller_profile(channel, caller_profile); - tech_pvt->caller_profile = caller_profile; - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Doh! no caller profile\n"); - switch_core_session_destroy(new_session); - return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; - } - - - skypiax_skype_call(tech_pvt->p, outbound_profile->destination_number, 30, *new_session); - - switch_channel_set_flag(channel, CF_OUTBOUND); - switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND); - switch_channel_set_state(channel, CS_INIT); - return SWITCH_CAUSE_SUCCESS; - } +static switch_call_cause_t channel_outgoing_channel(switch_core_session_t * session, + switch_event_t * var_event, + switch_caller_profile_t * + outbound_profile, + switch_core_session_t ** new_session, + switch_memory_pool_t ** pool, + switch_originate_flag_t flags) +{ + if ((*new_session = switch_core_session_request(skypiax_endpoint_interface, pool)) != 0) { + private_t *tech_pvt; + switch_channel_t *channel; + switch_caller_profile_t *caller_profile; + + 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_INTERFACES[2]; //FIXME + channel = switch_core_session_get_channel(*new_session); + tech_init(tech_pvt, *new_session, NULL); + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, + "Hey where is my memory pool?\n"); + switch_core_session_destroy(new_session); + return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; + } + + if (outbound_profile) { + char name[128]; + + snprintf(name, sizeof(name), "skypiax/%s", outbound_profile->destination_number); + switch_channel_set_name(channel, name); + + caller_profile = switch_caller_profile_clone(*new_session, outbound_profile); + switch_channel_set_caller_profile(channel, caller_profile); + tech_pvt->caller_profile = caller_profile; + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Doh! no caller profile\n"); + switch_core_session_destroy(new_session); + return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; + } + + skypiax_skype_call(tech_pvt->p, outbound_profile->destination_number, 30, + *new_session); + + switch_channel_set_flag(channel, CF_OUTBOUND); + switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND); + switch_channel_set_state(channel, CS_INIT); + return SWITCH_CAUSE_SUCCESS; + } - return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; + return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; } @@ -2788,301 +2783,336 @@ * \brief This thread runs during a call, and monitor the interface serial port for signaling, like hangup, caller id, etc * */ -static void *SWITCH_THREAD_FUNC skypiax_do_controldev_thread(switch_thread_t *thread, void *obj) +static void *SWITCH_THREAD_FUNC skypiax_do_controldev_thread(switch_thread_t * thread, + void *obj) //void *skypiax_do_controldev_thread(void *data) { struct skypiax_interface *p = obj; int res; - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - - DEBUGA_SKYPE("In skypiax_do_controldev_thread: started, p=%p\n", SKYPIAX_P_LOG, (void *)p); + DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); + DEBUGA_SKYPE("In skypiax_do_controldev_thread: started, p=%p\n", SKYPIAX_P_LOG, + (void *) p); while (1) { switch_sleep(1000); res = skypiax_skype_read(p); #if 1 - //if (res == CALLFLOW_INCOMING_HANGUP && p->interface_state != SKYPIAX_STATE_DOWN) - if (res == CALLFLOW_INCOMING_HANGUP) { - switch_core_session_t *session = NULL; - private_t *tech_pvt; - switch_channel_t *channel; + //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); - //p->interface_state=SKYPIAX_STATE_DOWN; - //if (option_debug) - DEBUGA_SKYPE("skype call ended\n", SKYPIAX_P_LOG); + tech_pvt = p->tech_pvt; + session = tech_pvt->session; - 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); + 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_set_state(channel, CS_HANGUP); - switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); - DEBUGA_SKYPE("after channel_on_hangup\n", SKYPIAX_P_LOG); + 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); - } + //DEBUGA_SKYPE("set state to CS_HANGUP\n", SKYPIAX_P_LOG); + } #endif } //if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); //} return NULL; } - #endif // CONTROLDEV_THREAD static switch_status_t load_config(void) { - char *cf = "skypiax.conf"; - switch_xml_t cfg, xml, global_settings, param, interfaces, myinterface; + char *cf = "skypiax.conf"; + switch_xml_t cfg, xml, global_settings, param, interfaces, myinterface; + + 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 ((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")) { + switch_set_string(globals.hold_music, val); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "globals.hold_music=%s\n", + globals.hold_music); + } else if (!strcmp(var, "port")) { + globals.port = atoi(val); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "globals.port=%d\n", + globals.port); + } else if (!strcmp(var, "ip")) { + set_global_ip(val); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "globals.ip=%s\n", + globals.ip); + } else if (!strcmp(var, "codec-master")) { + if (!strcasecmp(val, "us")) { + switch_set_flag(&globals, GFLAG_MY_CODEC_PREFS); + } + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, + "codec-master globals.debug=%d\n", globals.debug); + } else if (!strcmp(var, "dialplan")) { + set_global_dialplan(val); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "globals.dialplan=%s\n", + globals.dialplan); + } else if (!strcmp(var, "codec-prefs")) { + set_global_codec_string(val); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, + "globals.codec_string=%s\n", globals.codec_string); + globals.codec_order_last = + switch_separate_string(globals.codec_string, ',', globals.codec_order, + SWITCH_MAX_CODECS); + } else if (!strcmp(var, "codec-rates")) { + set_global_codec_rates_string(val); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, + "globals.codec_rates_string=%s\n", globals.codec_rates_string); + globals.codec_rates_last = + switch_separate_string(globals.codec_rates_string, ',', globals.codec_rates, + SWITCH_MAX_CODECS); + } + + } + } + + if ((interfaces = switch_xml_child(cfg, "per_interface_settings"))) { + int i = 0; + + 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; + char *digit_timeout = NULL; + char *max_digits = NULL; + char *hotline = NULL; + char *dial_regex = NULL; + char *hold_music = NULL; + char *fail_dial_regex = NULL; + char *enable_callerid = "true"; + char *X11_display = NULL; + + uint32_t interface_id = 0, to = 0, max = 0; + + 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"); + + if (!strcasecmp(var, "tonegroup")) { + tonegroup = val; + } else if (!strcasecmp(var, "digit_timeout") || !strcasecmp(var, "digit-timeout")) { + digit_timeout = val; + } else if (!strcasecmp(var, "context")) { + context = val; + } else if (!strcasecmp(var, "dialplan")) { + dialplan = val; + } else if (!strcasecmp(var, "dial-regex")) { + dial_regex = val; + } else if (!strcasecmp(var, "enable-callerid")) { + enable_callerid = val; + } else if (!strcasecmp(var, "fail-dial-regex")) { + fail_dial_regex = val; + } else if (!strcasecmp(var, "hold-music")) { + hold_music = val; + } else if (!strcasecmp(var, "X11-display") || !strcasecmp(var, "X11_display")) { + X11_display = val; + } else if (!strcasecmp(var, "max_digits") || !strcasecmp(var, "max-digits")) { + max_digits = val; + } else if (!strcasecmp(var, "hotline")) { + hotline = val; + } - 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 ((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")) { - switch_set_string(globals.hold_music, val); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "globals.hold_music=%s\n", globals.hold_music); - } else if (!strcmp(var, "port")) { - globals.port = atoi(val); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "globals.port=%d\n", globals.port); - } else if (!strcmp(var, "ip")) { - set_global_ip(val); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "globals.ip=%s\n", globals.ip); - } else if (!strcmp(var, "codec-master")) { - if (!strcasecmp(val, "us")) { - switch_set_flag(&globals, GFLAG_MY_CODEC_PREFS); - } - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "codec-master globals.debug=%d\n", globals.debug); - } else if (!strcmp(var, "dialplan")) { - set_global_dialplan(val); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "globals.dialplan=%s\n", globals.dialplan); - } else if (!strcmp(var, "codec-prefs")) { - set_global_codec_string(val); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "globals.codec_string=%s\n", globals.codec_string); - globals.codec_order_last = switch_separate_string(globals.codec_string, ',', globals.codec_order, SWITCH_MAX_CODECS); - } else if (!strcmp(var, "codec-rates")) { - set_global_codec_rates_string(val); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "globals.codec_rates_string=%s\n", globals.codec_rates_string); - globals.codec_rates_last = switch_separate_string(globals.codec_rates_string, ',', globals.codec_rates, SWITCH_MAX_CODECS); - } - - } - } - - if ((interfaces = switch_xml_child(cfg, "per_interface_settings"))) { - int i=0; - - 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; - char *digit_timeout = NULL; - char *max_digits = NULL; - char *hotline = NULL; - char *dial_regex = NULL; - char *hold_music = NULL; - char *fail_dial_regex = NULL; - char *enable_callerid = "true"; - char *X11_display = NULL; - - uint32_t interface_id = 0, to = 0, max = 0; - - 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"); - - if (!strcasecmp(var, "tonegroup")) { - tonegroup = val; - } else if (!strcasecmp(var, "digit_timeout") || !strcasecmp(var, "digit-timeout")) { - digit_timeout = val; - } else if (!strcasecmp(var, "context")) { - context = val; - } else if (!strcasecmp(var, "dialplan")) { - dialplan = val; - } else if (!strcasecmp(var, "dial-regex")) { - dial_regex = val; - } else if (!strcasecmp(var, "enable-callerid")) { - enable_callerid = val; - } else if (!strcasecmp(var, "fail-dial-regex")) { - fail_dial_regex = val; - } else if (!strcasecmp(var, "hold-music")) { - hold_music = val; - } else if (!strcasecmp(var, "X11-display") || !strcasecmp(var, "X11_display")) { - X11_display = val; - } else if (!strcasecmp(var, "max_digits") || !strcasecmp(var, "max-digits")) { - max_digits = val; - } else if (!strcasecmp(var, "hotline")) { - hotline = val; - } - - } - - if (!X11_display) { - 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, "interface missing REQUIRED param 'id'\n"); - continue; - } - if (switch_is_number(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, "interface param 'id' MUST be a number, now id='%s'\n", id); - continue; - } - - - if (!name) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "interface missing param 'name', not nice, but works\n"); - } - - if (!tonegroup) { - tonegroup = "us"; - } - - if (digit_timeout) { - to = atoi(digit_timeout); - } - - if (max_digits) { - max = atoi(max_digits); - } - - if (name) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "name=%s\n", name); - } - if(interface_id && interface_id < SKYPIAX_MAX_INTERFACES ) { - struct skypiax_interface newconf; - memset(&newconf, '\0', sizeof(newconf)); - 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_INTERFACES[interface_id].name, name); - } else { - switch_set_string(SKYPIAX_INTERFACES[interface_id].name, "N/A"); - } - 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) -{ - 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, do_skype_thread, &SKYPIAX_INTERFACES[interface_id], module_pool); -} - -switch_sleep(100000); -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_controldev_thread, &SKYPIAX_INTERFACES[interface_id], module_pool); -} - - -switch_sleep(1000000); - -skypiax_skypeaudio_init(&SKYPIAX_INTERFACES[interface_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, "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_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); - } - } - } + } + + if (!X11_display) { + 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, + "interface missing REQUIRED param 'id'\n"); + continue; + } + if (switch_is_number(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, + "interface param 'id' MUST be a number, now id='%s'\n", id); + continue; + } + + if (!name) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, + "interface missing param 'name', not nice, but works\n"); + } - switch_xml_free(xml); + if (!tonegroup) { + tonegroup = "us"; + } + + if (digit_timeout) { + to = atoi(digit_timeout); + } - return SWITCH_STATUS_SUCCESS; + if (max_digits) { + max = atoi(max_digits); + } + + if (name) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "name=%s\n", name); + } + if (interface_id && interface_id < SKYPIAX_MAX_INTERFACES) { + struct skypiax_interface newconf; + memset(&newconf, '\0', sizeof(newconf)); + 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_INTERFACES[interface_id].name, name); + } else { + switch_set_string(SKYPIAX_INTERFACES[interface_id].name, "N/A"); + } + 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) { + 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, do_skype_thread, + &SKYPIAX_INTERFACES[interface_id], module_pool); + } + + switch_sleep(100000); + 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_controldev_thread, + &SKYPIAX_INTERFACES[interface_id], module_pool); + } + + switch_sleep(1000000); + + skypiax_skypeaudio_init(&SKYPIAX_INTERFACES[interface_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, + "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_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); + } + } + } + + switch_xml_free(xml); + + return SWITCH_STATUS_SUCCESS; } SWITCH_MODULE_LOAD_FUNCTION(mod_skypiax_load) { struct skypiax_interface *p = NULL; - module_pool = pool; + module_pool = pool; - memset(&globals, '\0', sizeof(globals)); - memset(SKYPIAX_INTERFACES, '\0', sizeof(SKYPIAX_INTERFACES)); + memset(&globals, '\0', sizeof(globals)); + memset(SKYPIAX_INTERFACES, '\0', sizeof(SKYPIAX_INTERFACES)); -#ifndef _WINDOWS_ //FIXME +#ifndef _WINDOWS_ //FIXME if (!XInitThreads()) { - ERRORA("Not initialized XInitThreads!\n", SKYPIAX_P_LOG); + ERRORA("Not initialized XInitThreads!\n", SKYPIAX_P_LOG); } else { - DEBUGA_SKYPE("Initialized XInitThreads!\n", SKYPIAX_P_LOG); + DEBUGA_SKYPE("Initialized XInitThreads!\n", SKYPIAX_P_LOG); } -switch_sleep(10000); //FIXME + switch_sleep(10000); //FIXME #endif /* _WINDOWS_ */ + load_config(); + *module_interface = switch_loadable_module_create_module_interface(pool, modname); + skypiax_endpoint_interface = + switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE); + skypiax_endpoint_interface->interface_name = "skypiax"; + skypiax_endpoint_interface->io_routines = &skypiax_io_routines; + skypiax_endpoint_interface->state_handler = &skypiax_state_handlers; - load_config(); - - - *module_interface = switch_loadable_module_create_module_interface(pool, modname); - skypiax_endpoint_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE); - skypiax_endpoint_interface->interface_name = "skypiax"; - skypiax_endpoint_interface->io_routines = &skypiax_io_routines; - skypiax_endpoint_interface->state_handler = &skypiax_state_handlers; - - /* indicate that the module should continue to be loaded */ - return SWITCH_STATUS_SUCCESS; + /* indicate that the module should continue to be loaded */ + return SWITCH_STATUS_SUCCESS; } /* @@ -3094,64 +3124,64 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypiax_shutdown) { - int x = 0; + int x = 0; + + running = -1; + + while (running) { + if (x++ > 100) { + break; + } + switch_yield(20000); + } + return SWITCH_STATUS_SUCCESS; +} + +static switch_status_t channel_on_hangup(switch_core_session_t * session) +{ + switch_channel_t *channel = NULL; + private_t *tech_pvt = NULL; + skypiax_interface_t *p; + char msg_to_skype[256]; - running = -1; + channel = switch_core_session_get_channel(session); + assert(channel != NULL); - while (running) { - if (x++ > 100) { - break; - } - switch_yield(20000); - } - return SWITCH_STATUS_SUCCESS; -} - -static switch_status_t channel_on_hangup(switch_core_session_t *session) -{ - switch_channel_t *channel = NULL; - private_t *tech_pvt = NULL; - skypiax_interface_t *p; - char msg_to_skype[256]; - - channel = switch_core_session_get_channel(session); - assert(channel != NULL); - - tech_pvt = switch_core_session_get_private(session); - assert(tech_pvt != NULL); - - p = tech_pvt->p; - - switch_clear_flag_locked(tech_pvt, TFLAG_IO); - switch_clear_flag_locked(tech_pvt, TFLAG_VOICE); - //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); - } - - if (tech_pvt->write_codec.implementation) { - switch_core_codec_destroy(&tech_pvt->write_codec); - } - - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL HANGUP\n", switch_channel_get_name(channel)); - switch_mutex_lock(globals.mutex); - globals.calls--; - if (globals.calls < 0) { - globals.calls = 0; - } - switch_mutex_unlock(globals.mutex); + tech_pvt = switch_core_session_get_private(session); + assert(tech_pvt != NULL); - return SWITCH_STATUS_SUCCESS; + p = tech_pvt->p; + + switch_clear_flag_locked(tech_pvt, TFLAG_IO); + switch_clear_flag_locked(tech_pvt, TFLAG_VOICE); + //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); + } + + if (tech_pvt->write_codec.implementation) { + switch_core_codec_destroy(&tech_pvt->write_codec); + } + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL HANGUP\n", + switch_channel_get_name(channel)); + switch_mutex_lock(globals.mutex); + globals.calls--; + if (globals.calls < 0) { + globals.calls = 0; + } + switch_mutex_unlock(globals.mutex); + + return SWITCH_STATUS_SUCCESS; } /* For Emacs: From gmaruzz at freeswitch.org Thu Dec 4 23:25:01 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Fri, 05 Dec 2008 02:25:01 -0500 Subject: [Freeswitch-branches] [commit] r10609 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Fri Dec 5 02:25:00 2008 New Revision: 10609 Log: skypiax: cleaner 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 Dec 5 02:25:00 2008 @@ -58,7 +58,6 @@ #define WARNINGA(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][WARNINGA %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); #define NOTICA(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][NOTICA %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); -//#define SKYPIAX_P_LOG p ? p->owner : NULL, (unsigned long)pthread_self(), __LINE__, p ? p->name ? p->name : "none" : "none", p ? p->owner ? p->owner->_state : -1 : -1, p ? p->interface_state : -1, p ? p->skype_callflow : -1 #define SKYPIAX_P_LOG NULL, (unsigned long)55, __LINE__, p ? p->name ? p->name : "none" : "none", -1, p ? p->interface_state : -1, p ? p->skype_callflow : -1 /*********************************/ @@ -351,13 +350,9 @@ strncpy(msg_from_skype, (const char *) poCopyData->lpData, sizeof(msg_from_skype) - 2); - //howmany = strlen((const char *) poCopyData->lpData); howmany = strlen(msg_from_skype) + 1; - //switch_file_write(win32_AsteriskHandlesSkype->fdesc[1], (const char *) poCopyData->lpData, &howmany); switch_file_write(win32_AsteriskHandlesSkype->fdesc[1], msg_from_skype, &howmany); NOTICA("From Skype API: %s\n", SKYPIAX_P_LOG, (const char *) poCopyData->lpData); - //howmany=1; - //switch_file_write(win32_AsteriskHandlesSkype->fdesc[1], "\0", &howmany); lReturnCode = 1; } break; @@ -463,7 +458,6 @@ 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 */ @@ -475,15 +469,6 @@ /* 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 - struct skypiax_interface *p; p = obj; @@ -560,110 +545,6 @@ } -#undef PORTAUDIO_ENGAGE -#ifdef PORTAUDIO_ENGAGE -static switch_status_t engage_device(int sample_rate, int codec_ms) -{ - PaStreamParameters inputParameters, outputParameters; - PaError err; - - if (!globals.audio_stream) { - if (!sample_rate) { - sample_rate = globals.sample_rate; - } - if (!codec_ms) { - codec_ms = globals.codec_ms; - } - - if (!globals.read_codec.implementation) { - if (switch_core_codec_init - (&globals.read_codec, "L16", NULL, sample_rate, codec_ms, 1, - SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, - NULL) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n"); - return SWITCH_STATUS_FALSE; - } - } - - switch_assert(globals.read_codec.implementation); - - if (!globals.write_codec.implementation) { - if (switch_core_codec_init - (&globals.write_codec, "L16", NULL, sample_rate, codec_ms, 1, - SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, - NULL) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't load codec?\n"); - switch_core_codec_destroy(&globals.read_codec); - return SWITCH_STATUS_FALSE; - } - } - - if (!globals.timer.timer_interface) { - if (switch_core_timer_init - (&globals.timer, globals.timer_name, codec_ms, - globals.read_codec.implementation->samples_per_packet, - module_pool) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "setup timer failed!\n"); - switch_core_codec_destroy(&globals.read_codec); - switch_core_codec_destroy(&globals.write_codec); - return SWITCH_STATUS_FALSE; - } - } - - if (!globals.hold_timer.timer_interface) { - if (switch_core_timer_init - (&globals.hold_timer, globals.timer_name, codec_ms, - globals.read_codec.implementation->samples_per_packet, - module_pool) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, - "setup hold timer failed!\n"); - switch_core_codec_destroy(&globals.read_codec); - switch_core_codec_destroy(&globals.write_codec); - switch_core_timer_destroy(&globals.timer); - return SWITCH_STATUS_FALSE; - } - } - - globals.read_frame.rate = sample_rate; - globals.read_frame.codec = &globals.read_codec; - - switch_mutex_lock(globals.device_lock); - /* LOCKED ************************************************************************************************** */ - inputParameters.device = globals.indev; - inputParameters.channelCount = 1; - inputParameters.sampleFormat = SAMPLE_TYPE; - inputParameters.suggestedLatency = - Pa_GetDeviceInfo(inputParameters.device)->defaultLowInputLatency; - inputParameters.hostApiSpecificStreamInfo = NULL; - - outputParameters.device = globals.outdev; - outputParameters.channelCount = 1; - outputParameters.sampleFormat = SAMPLE_TYPE; - outputParameters.suggestedLatency = - Pa_GetDeviceInfo(outputParameters.device)->defaultLowOutputLatency; - outputParameters.hostApiSpecificStreamInfo = NULL; - err = - OpenAudioStream(&globals.audio_stream, &inputParameters, &outputParameters, - sample_rate, paClipOff, - globals.read_codec.implementation->samples_per_packet); - /* UNLOCKED ************************************************************************************************* */ - switch_mutex_unlock(globals.device_lock); - - if (err != paNoError) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, - "Can't open audio device!\n"); - switch_core_codec_destroy(&globals.read_codec); - switch_core_codec_destroy(&globals.write_codec); - switch_core_timer_destroy(&globals.timer); - switch_core_timer_destroy(&globals.hold_timer); - return SWITCH_STATUS_FALSE; - } - } - - return SWITCH_STATUS_SUCCESS; -} -#endif // PORTAUDIO_ENGAGE - #define SKYPE_AUDIO #ifdef SKYPE_AUDIO @@ -676,7 +557,6 @@ struct skypiax_interface *p = obj; short in[GG]; short out[GG / 2]; - //int s, fd, len, sent; int s, fd, len; unsigned int sin_size; struct sockaddr_in my_addr; @@ -692,7 +572,6 @@ } memset(&my_addr, 0, sizeof(my_addr)); my_addr.sin_family = AF_INET; - //my_addr.sin_addr.s_addr = INADDR_ANY; my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */ my_addr.sin_port = htons(5556); //FIXME configurable! @@ -769,8 +648,6 @@ howmany = len; switch_file_write(p->audiopipe[1], totalbuf, &howmany); - //howmany = len/2; - //switch_file_write(p->audiopipe[1], out, &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); } @@ -797,7 +674,6 @@ switch_file_write(p->audioskypepipe[1], kill_cli_buff, &kill_cli_size); DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG); - //switch_sleep(1000000); #ifndef WIN32_SKYPIAX close(fd); @@ -833,14 +709,12 @@ int a; int i; unsigned int got; - //int exit=0; if (option_debug > 10) { WARNINGA("ENTERING FUNC\n", SKYPIAX_P_LOG); } memset(&my_addr, 0, sizeof(my_addr)); my_addr.sin_family = AF_INET; - //my_addr.sin_addr.s_addr = INADDR_ANY; my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */ my_addr.sin_port = htons(5558); //FIXME configurable! @@ -871,7 +745,6 @@ sin_size = sizeof(remote_addr); while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) { DEBUGA_SKYPE("ACCEPTED\n", SKYPIAX_P_LOG); - //while (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)) { @@ -880,21 +753,16 @@ fd_set fs; struct timeval to; - //exit=1; - - //fdselect = p->audioskypepipe[0]; fdselect = 1; FD_ZERO(&fs); FD_SET(fdselect, &fs); to.tv_usec = 100; to.tv_sec = 0; - //rt = select(fdselect + 1, &fs, NULL, NULL, &to); rt = 1; if (rt > 0) { got = (NN / 2) * sizeof(short); switch_file_read(p->audioskypepipe[0], in, &got); - //ERRORA("got %d\n", SKYPIAX_P_LOG, got); if (got > 0) { a = 0; @@ -924,7 +792,6 @@ #else closesocket(fd); #endif - //if (exit) break; } @@ -943,63 +810,18 @@ int skypiax_skypeaudio_init(struct skypiax_interface *p) { -//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_timeout_set(p->audiopipe[0], 100000); - //rv = switch_file_pipe_timeout_set(p->audiopipe[1], 10000); - //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); - if (c) { - ERRORA("Unable to create audio pipe\n", SKYPIAX_P_LOG); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } - return -1; - } -#endif /* the pipe is our audio fd for pbx to poll on */ p->skypiax_sound_capt_fd = p->audiopipe[0]; - /* let's start the serial monitoring thread too, so we can have serial signaling */ - -/* - 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); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } - return -1; - } -*/ - rv = switch_file_pipe_create_ex(&p->audioskypepipe[0], &p->audioskypepipe[1], 2, module_pool); rv = switch_file_pipe_timeout_set(p->audioskypepipe[0], 100); - //rv = switch_file_pipe_timeout_set(p->audioskypepipe[1], 10000); -#ifdef NOTDEF_WIN32_SKYPIAX - c = pipe(p->audioskypepipe); - if (c) { - ERRORA("Unable to create audioskypepipe\n", SKYPIAX_P_LOG); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } - return -1; - } - 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); } @@ -1010,10 +832,7 @@ struct skypiax_interface *p; short buf[640]; unsigned int samples; - //int fd; int rt; - //fd_set fs; - //struct timeval to; p = tech_pvt->p; @@ -1021,14 +840,6 @@ 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) { @@ -1041,7 +852,6 @@ if (samples) DEBUGA_SKYPE("read=====> NOT GOOD samples=%d expected=%d\n", SKYPIAX_P_LOG, samples, SAMPLES_PER_FRAME * sizeof(short)); - //switch_sleep(1000); //do nothing } else { tech_pvt->read_frame.datalen = samples; @@ -1058,63 +868,10 @@ return SWITCH_STATUS_SUCCESS; } -#if 0 -//cicopet -struct ast_frame *skypiax_skypeaudio_read(struct skypiax_interface *p) -{ - static struct ast_frame f; - 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 + SKYPIAX_FRIENDLY_OFFSET / 2)); - - buf = __buf + SKYPIAX_FRIENDLY_OFFSET / 2; - - f.frametype = SKYPIAX_FRAME_NULL; - f.subclass = 0; - f.samples = 0; - f.datalen = 0; - f.data = NULL; - f.offset = 0; - f.src = skypiax_type; - f.mallocd = 0; - f.delivery.tv_sec = 0; - f.delivery.tv_usec = 0; - - 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)); - switch_sleep(100); - //do nothing - } else { - //DEBUGA_SOUND("read=====> GOOD samples=%d\n", SKYPIAX_P_LOG, samples); - /* A real frame */ - 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 = SKYPIAX_FRIENDLY_OFFSET; - f.src = skypiax_type; - f.mallocd = 0; - } - - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } - return &f; -} -#endif //0 - #endif /* SKYPE_AUDIO */ static void tech_init(private_t * tech_pvt, switch_core_session_t * session, skypiax_interface_t * p) { - //struct skypiax_interface *p = NULL; DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); tech_pvt->read_frame.data = tech_pvt->databuf; @@ -1224,9 +981,6 @@ switch_clear_flag_locked(tech_pvt, TFLAG_IO); switch_clear_flag_locked(tech_pvt, TFLAG_VOICE); 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_DEBUG, @@ -1268,8 +1022,6 @@ { switch_channel_t *channel = NULL; private_t *tech_pvt = NULL; - //switch_time_t started = switch_time_now(); - //unsigned int elapsed; switch_byte_t *data; channel = switch_core_session_get_channel(session); @@ -1304,26 +1056,6 @@ "CHANNEL READ FRAME not IO\n"); return SWITCH_STATUS_FALSE; } -#if 0 - 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)); - switch_sleep(100); - //do nothing - } else { - //DEBUGA_SOUND("read=====> GOOD samples=%d\n", SKYPIAX_P_LOG, samples); - /* A real frame */ - 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 = SKYPIAX_FRIENDLY_OFFSET; - f.src = skypiax_type; - f.mallocd = 0; - } -#endif - //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "============>\n"); if (switch_test_flag(tech_pvt, TFLAG_IO) && switch_test_flag(tech_pvt, TFLAG_VOICE)) { @@ -1367,7 +1099,6 @@ { switch_channel_t *channel = NULL; private_t *tech_pvt = NULL; - //switch_frame_t *pframe; unsigned int sent; struct skypiax_interface *p = NULL; @@ -1400,225 +1131,6 @@ } -#if 0 -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 - -#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; @@ -1671,64 +1183,6 @@ return SWITCH_STATUS_SUCCESS; } -#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! -*/ -static switch_call_cause_t channel_outgoing_channel(switch_core_session_t * session, - switch_event_t * var_event, - switch_caller_profile_t * - outbound_profile, - switch_core_session_t ** new_session, - switch_memory_pool_t ** pool, - switch_originate_flag_t flags) -{ - if ((*new_session = switch_core_session_request(skypiax_endpoint_interface, pool)) != 0) { - private_t *tech_pvt; - switch_channel_t *channel; - switch_caller_profile_t *caller_profile; - - 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_INTERFACES[2]; //FIXME - channel = switch_core_session_get_channel(*new_session); - tech_init(tech_pvt, *new_session, NULL); - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, - "Hey where is my memory pool?\n"); - switch_core_session_destroy(new_session); - return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; - } - - if (outbound_profile) { - char name[128]; - - snprintf(name, sizeof(name), "skypiax/%s", outbound_profile->destination_number); - switch_channel_set_name(channel, name); - - caller_profile = switch_caller_profile_clone(*new_session, outbound_profile); - switch_channel_set_caller_profile(channel, caller_profile); - tech_pvt->caller_profile = caller_profile; - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Doh! no caller profile\n"); - switch_core_session_destroy(new_session); - return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; - } - - skypiax_skype_call(tech_pvt->p, outbound_profile->destination_number, 30); - - switch_channel_set_flag(channel, CF_OUTBOUND); - switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND); - switch_channel_set_state(channel, CS_INIT); - return SWITCH_CAUSE_SUCCESS; - } - - return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; - -} -#endif // 0 //FIXME: moved below - static switch_status_t channel_receive_event(switch_core_session_t * session, switch_event_t * event) { @@ -1908,35 +1362,13 @@ Display *disp = NULL; Window root = -1; Window win = -1; -//int res; p = obj; DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); -/* - if (pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL)) { - ERRORA("Unable to set cancel type to deferred\n", SKYPIAX_P_LOG); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } - return NULL; - } -*/ - 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); - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - return NULL; - } - fcntl(p->AsteriskHandlesAst.fdesc[0], F_SETFL, O_NONBLOCK); - fcntl(p->AsteriskHandlesAst.fdesc[1], F_SETFL, O_NONBLOCK); -#endif - AsteriskHandlesAst = &p->AsteriskHandlesAst; //disp = XOpenDisplay(getenv("DISPLAY")); disp = XOpenDisplay(p->X11_display); @@ -1978,8 +1410,6 @@ ERRORA ("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 = SKYPIAX_PTHREADT_NULL; DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); return NULL; } @@ -1989,8 +1419,6 @@ ERRORA ("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 = SKYPIAX_PTHREADT_NULL; DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); return NULL; } @@ -2005,7 +1433,6 @@ b = buffer; while (1) { - //pthread_testcancel(); XNextEvent(disp, &an_event); switch (an_event.type) { case ClientMessage: @@ -2045,13 +1472,8 @@ ERRORA ("Skype is not running, maybe crashed. Please run/restart Skype and relaunch Skypiax\n", SKYPIAX_P_LOG); - //p->skype = 0; - //p->skype_thread = SKYPIAX_PTHREADT_NULL; return NULL; } - //p->skype = 0; - //p->skype_thread = SKYPIAX_PTHREADT_NULL; - //pthread_cleanup_pop(1); //DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); return NULL; @@ -2117,8 +1539,6 @@ ERRORA ("Sending message failed - probably Skype crashed.\n\nPlease shutdown Skypiax (Asterisk), then restart Skype from the menu, then launch Skypiax and try again.\n", SKYPIAX_P_LOG); - //p->skype = 0; - //p->skype_thread = SKYPIAX_PTHREADT_NULL; if (option_debug > 100) { DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); } @@ -2153,21 +1573,11 @@ if (option_debug > 100) { DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); } - //DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); -//switch_sleep(1000000); 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 = sizeof(read_from_pipe); @@ -2184,18 +1594,6 @@ DEBUGA_SKYPE("read_skype: howmany=%d, i=%d, a=%d, |||%s||| \n", SKYPIAX_P_LOG, howmany, i, a, messaggio); -#if 0 //FIXME wat's the use of this? - if (!strcasecmp(messaggio, "ERROR 68")) { /* not yet protocol specified, - just authorized */ - NOTICA - ("Please give the Skype client authorization to be connected by Skypiax (and to not ask you again)\n", - SKYPIAX_P_LOG); - sleep(1); - skypiax_skype_write(p, "PROTOCOL 6"); - switch_sleep(10000); - } -#endif - if (!strncasecmp(messaggio, "ERROR 92 CALL", 12)) { ERRORA("Skype got ERROR: |||%s|||, the number we called was not recognized\n", SKYPIAX_P_LOG, messaggio); @@ -2209,8 +1607,6 @@ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); } p->interface_state = SKYPIAX_STATE_DOWN; - //FIXME if(p->owner) - //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL; return CALLFLOW_INCOMING_HANGUP; } else { p->interface_state = SKYPIAX_STATE_DOWN; @@ -2256,9 +1652,6 @@ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); } p->interface_state = SKYPIAX_STATE_DOWN; - //FIXME if(p->owner){ - //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL; - //FIXME } return CALLFLOW_INCOMING_HANGUP; } else { p->interface_state = SKYPIAX_STATE_DOWN; @@ -2318,7 +1711,6 @@ private_t *tech_pvt = NULL; switch_channel_t *channel = NULL; - //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; @@ -2337,11 +1729,9 @@ switch_set_flag(tech_pvt, TFLAG_DTMF); switch_mutex_unlock(tech_pvt->flag_mutex); } - //FIXME ast_queue_frame(p->owner, &f2); } if (!strcasecmp(prop, "FAILUREREASON")) { - /* if (option_debug > 1) */ DEBUGA_SKYPE ("Skype has FAILED on skype_call %s. Let's wait for the FAILED message.\n", SKYPIAX_P_LOG, id); @@ -2363,7 +1753,6 @@ 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; @@ -2425,8 +1814,6 @@ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); } //p->interface_state = SKYPIAX_STATE_DOWN; - //FIXME if(p->owner) - //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL; return CALLFLOW_INCOMING_HANGUP; } else { p->interface_state = SKYPIAX_STATE_DOWN; @@ -2445,8 +1832,6 @@ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); } p->interface_state = SKYPIAX_STATE_DOWN; - //FIXME if(p->owner) - //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL; return CALLFLOW_INCOMING_HANGUP; } else { p->interface_state = SKYPIAX_STATE_DOWN; @@ -2463,8 +1848,6 @@ if (option_debug > 100) { DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); } - //FIXME if(p->owner) - //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL; return CALLFLOW_INCOMING_HANGUP; } else if (!strcasecmp(value, "REFUSED")) { if (!strcasecmp(id, p->skype_call_id)) { @@ -2480,8 +1863,6 @@ if (option_debug > 100) { DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); } - //FIXME if(p->owner) - //FIXME p->owner->hangupcause = SKYPIAX_CAUSE_NORMAL; return CALLFLOW_INCOMING_HANGUP; } else { /* we're here because were us that refused an incoming call */ @@ -2505,57 +1886,30 @@ 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, SKYPIAX_CONTROL_ANSWER); - //FIXME } if (option_debug > 1) DEBUGA_SKYPE("skype_call: %s SKYPIAX_CONTROL_ANSWER sent\n", SKYPIAX_P_LOG, id); - //FIXME if (p->owner) - if (1) { char msg_to_skype[1024]; -#if 0 - if (!p->tcp_srv_thread) { - if (1) { -#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(&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) { -#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(&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 - } + if (1) { + switch_threadattr_t *thd_attr = NULL; + switch_threadattr_create(&thd_attr, module_pool); + switch_threadattr_detach_set(thd_attr, 1); + switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); + switch_thread_create(&p->tcp_srv_thread, thd_attr, + skypiax_do_tcp_srv_thread, p, module_pool); + DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG); + + switch_threadattr_create(&thd_attr, module_pool); + switch_threadattr_detach_set(thd_attr, 1); + switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); + switch_thread_create(&p->tcp_cli_thread, thd_attr, + skypiax_do_tcp_cli_thread, p, module_pool); + DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG); } -#endif - switch_sleep(100000); sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"5556\"", id); skypiax_skype_write(p, msg_to_skype); @@ -2618,27 +1972,6 @@ "Error spawning thread\n"); switch_core_session_destroy(&session); } -#if 0 - if (iax_set_codec - (tech_pvt, iaxevent->session, &iaxevent->ies.format, - &iaxevent->ies.capability, &iaxevent->ies.samprate, - IAX_SET) != SWITCH_STATUS_SUCCESS) { - iax_reject(iaxevent->session, "Codec Error!"); - switch_core_session_destroy(&session); - } else { - tech_pvt->iax_session = iaxevent->session; - tech_pvt->session = session; - iax_accept(tech_pvt->iax_session, tech_pvt->codec); - iax_ring_announce(tech_pvt->iax_session); - switch_channel_set_state(channel, CS_INIT); - if (switch_core_session_thread_launch(session) != - SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, - "Error spawning thread\n"); - switch_core_session_destroy(&session); - } - } -#endif //0 } } else { switch_core_session_t *session = NULL; @@ -2693,18 +2026,10 @@ 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"); - //switch_sleep(10000); skypiax_skype_write(p, "SET AGC OFF"); switch_sleep(10000); - //skypiax_skype_write(p, "GET AGC"); - //switch_sleep(10000); - //skypiax_skype_write(p, "GET AEC"); - //switch_sleep(10000); skypiax_skype_write(p, "SET AEC OFF"); switch_sleep(10000); - //skypiax_skype_write(p, "GET AEC"); - //switch_sleep(300000); sprintf(msg_to_skype, "CALL %s", rdest); if (skypiax_skype_write(p, msg_to_skype) < 0) { @@ -2716,11 +2041,7 @@ return -1; } global_session = session; - //p->skype_call_ongoing = 1; - //if (p->owner) { - //ast_setstate(p->owner, SKYPIAX_STATE_RINGING); - //} //FIXME ast_queue_control(p->owner, SKYPIAX_CONTROL_RINGING); return 0; } @@ -2785,7 +2106,6 @@ */ static void *SWITCH_THREAD_FUNC skypiax_do_controldev_thread(switch_thread_t * thread, void *obj) -//void *skypiax_do_controldev_thread(void *data) { struct skypiax_interface *p = obj; int res; @@ -2805,8 +2125,6 @@ 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); tech_pvt = p->tech_pvt; @@ -2815,8 +2133,6 @@ 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); From gmaruzz at freeswitch.org Mon Dec 8 23:50:40 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Tue, 09 Dec 2008 02:50:40 -0500 Subject: [Freeswitch-branches] [commit] r10668 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Tue Dec 9 02:50:38 2008 New Revision: 10668 Log: skypiax: emended Makefile Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/Makefile Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/Makefile ============================================================================== --- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/Makefile (original) +++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/Makefile Tue Dec 9 02:50:38 2008 @@ -1,5 +1,3 @@ MODNAME=mod_skypiax -#LOCAL_CFLAGS=-I$(OZ_DIR)/src/include -I$(OZ_DIR)/src/isdn/include -MOD_CFLAGS=-I../../../../libs/openzap/src/include -I../../../../libs/openzap/src/isdn/include -LOCAL_LDFLAGS=-L../../../../libs/openzap -lopenzap -lX11 +LOCAL_LDFLAGS=-lX11 include ../../../../build/modmake.rules From gmaruzz at freeswitch.org Tue Dec 9 01:43:33 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Tue, 09 Dec 2008 04:43:33 -0500 Subject: [Freeswitch-branches] [commit] r10670 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Tue Dec 9 04:43:33 2008 New Revision: 10670 Log: skypiax: added skypiax.h, beginning to structure files Added: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c (original) +++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c Tue Dec 9 04:43:33 2008 @@ -1,114 +1,5 @@ -/* - * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005/2006, Anthony Minessale II - * - * Version: MPL 1.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * - * The Initial Developer of the Original Code is - * Anthony Minessale II - * Portions created by the Initial Developer are Copyright (C) - * the Initial Developer. All Rights Reserved. - * - * This module (mod_skypiax) has been contributed by: - * - * Giovanni Maruzzelli (gmaruzz at gmail.com) - * - * - * Further Contributors: - * - * - * - * mod_skypiax.c -- Skype compatible Endpoint Module - * - */ - -#undef WIN32_SKYPIAX -#undef __CYGWIN__ -#define MOD_SKYPIAX -#ifdef MOD_SKYPIAX - -#ifndef WIN32_SKYPIAX -#include -#include -#include -#else //WIN32_SKYPIAX -//FIXME include? -#endif //WIN32_SKYPIAX - -#include - -#define SKYPIAX_SVN_VERSION "SVN 123456" - -#define DEBUGA_SKYPE(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_SKYPE %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); -#define DEBUGA_CALL(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_CALL %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); -#define DEBUGA_PBX(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_PBX %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); -#define ERRORA(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][ERRORA %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); -#define WARNINGA(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][WARNINGA %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); -#define NOTICA(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][NOTICA %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); - -#define SKYPIAX_P_LOG NULL, (unsigned long)55, __LINE__, p ? p->name ? p->name : "none" : "none", -1, p ? p->interface_state : -1, p ? p->skype_callflow : -1 - -/*********************************/ -#define SKYPIAX_CAUSE_NORMAL 1 -/*********************************/ -#define SKYPIAX_FRAME_DTMF 1 -/*********************************/ -#define SKYPIAX_CONTROL_RINGING 1 -#define SKYPIAX_CONTROL_ANSWER 2 - -/*********************************/ -#define SKYPIAX_STATE_DOWN 1 -#define SKYPIAX_STATE_RING 2 -#define SKYPIAX_STATE_DIALING 3 -#define SKYPIAX_STATE_BUSY 4 -#define SKYPIAX_STATE_UP 5 -#define SKYPIAX_STATE_RINGING 6 -#define SKYPIAX_STATE_PRERING 7 -/*********************************/ -/* call flow from the device */ -#define CALLFLOW_CALL_IDLE SKYPIAX_STATE_DOWN -#define CALLFLOW_INCOMING_RING SKYPIAX_STATE_RING -#define CALLFLOW_CALL_DIALING SKYPIAX_STATE_DIALING -#define CALLFLOW_CALL_LINEBUSY SKYPIAX_STATE_BUSY -#define CALLFLOW_CALL_ACTIVE 300 -#define CALLFLOW_INCOMING_HANGUP 100 -#define CALLFLOW_CALL_RELEASED 101 -#define CALLFLOW_CALL_NOCARRIER 102 -#define CALLFLOW_CALL_INFLUX 103 -#define CALLFLOW_CALL_INCOMING 104 -#define CALLFLOW_CALL_FAILED 105 -#define CALLFLOW_CALL_NOSERVICE 106 -#define CALLFLOW_CALL_OUTGOINGRESTRICTED 107 -#define CALLFLOW_CALL_SECURITYFAIL 108 -#define CALLFLOW_CALL_NOANSWER 109 -#define CALLFLOW_STATUS_FINISHED 110 -#define CALLFLOW_STATUS_CANCELLED 111 -#define CALLFLOW_STATUS_FAILED 112 -#define CALLFLOW_STATUS_REFUSED 113 -#define CALLFLOW_STATUS_RINGING 114 -#define CALLFLOW_STATUS_INPROGRESS 115 -#define CALLFLOW_STATUS_UNPLACED 116 -#define CALLFLOW_STATUS_ROUTING 117 -#define CALLFLOW_STATUS_EARLYMEDIA 118 -#define SKYPIAX_STATE_HANGUP_REQUESTED 200 - //FIXME CALLFLOW_INCOMING_CALLID to be removed -#define CALLFLOW_INCOMING_CALLID 1019 +#include "skypiax.h" -/*********************************/ - -#define SKYPIAX_MAX_INTERFACES 64 SWITCH_MODULE_LOAD_FUNCTION(mod_skypiax_load); SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypiax_shutdown); @@ -119,23 +10,6 @@ static switch_memory_pool_t *module_pool = NULL; static int running = 1; -#ifndef WIN32_SKYPIAX -struct AsteriskHandles { - Window skype_win; - Display *disp; - Window win; - switch_file_t *fdesc[2]; -}; -#else //WIN32_SKYPIAX - -struct AsteriskHandles { - HWND win32_hInit_MainWindowHandle; - HWND win32_hGlobal_SkypeAPIWindowHandle; - switch_file_t *fdesc[2]; -}; - -#endif //WIN32_SKYPIAX - typedef enum { TFLAG_IO = (1 << 0), TFLAG_INBOUND = (1 << 1), @@ -170,76 +44,14 @@ switch_mutex_t *mutex; } globals; -struct skypiax_interface { - char interface_id[80]; - char name[80]; - char dialplan[80]; - char context[80]; - char dial_regex[256]; - char fail_dial_regex[256]; - char hold_music[256]; - char type[256]; - char X11_display[256]; - struct AsteriskHandles AsteriskHandlesAst; - - int interface_state; /*!< \brief 'state' of the interface (channel) */ - char language[80]; /*!< \brief default Asterisk dialplan language for this interface */ - char exten[80]; /*!< \brief default Asterisk dialplan extension for this interface */ - int skypiax_sound_rate; /*!< \brief rate of the sound device, in Hz, eg: 8000 */ - switch_file_t *skypiax_sound_capt_fd; /*!< \brief file descriptor for sound capture dev */ - char callid_name[50]; - char callid_number[50]; - double playback_boost; - double capture_boost; - int stripmsd; - switch_thread_t *skype_thread; - char skype_call_id[512]; - int skype_call_ongoing; - char skype_friends[4096]; - char skype_fullname[512]; - char skype_displayname[512]; - int skype_callflow; /*!< \brief 'callflow' of the skype interface (as opposed to phone interface) */ - int skype; /*!< \brief config flag, bool, Skype support on this interface (0 if false, -1 if true) */ - int control_to_send; - switch_file_t *audiopipe[2]; - switch_file_t *audioskypepipe[2]; - switch_thread_t *tcp_srv_thread; - switch_thread_t *tcp_cli_thread; - short audiobuf[160]; - int audiobuf_is_loaded; - - //int phonebook_listing; - //int phonebook_querying; - //int phonebook_listing_received_calls; - - //int phonebook_first_entry; - //int phonebook_last_entry; - //int phonebook_number_lenght; - //int phonebook_text_lenght; - FILE *phonebook_writing_fp; - int skypiax_dir_entry_extension_prefix; - void *tech_pvt; -}; +static skypiax_interface_t SKYPIAX_INTERFACES[SKYPIAX_MAX_INTERFACES]; + +int option_debug = 100; +switch_core_session_t *global_session = NULL; -typedef struct skypiax_interface skypiax_interface_t; -static skypiax_interface_t SKYPIAX_INTERFACES[SKYPIAX_MAX_INTERFACES]; -struct private_object { - unsigned int flags; - switch_codec_t read_codec; - switch_codec_t write_codec; - switch_frame_t read_frame; - unsigned char databuf[SWITCH_RECOMMENDED_BUFFER_SIZE]; - switch_core_session_t *session; - switch_caller_profile_t *caller_profile; - switch_mutex_t *mutex; - switch_mutex_t *flag_mutex; - skypiax_interface_t *p; - //switch_thread_cond_t *cond; -}; -typedef struct private_object private_t; SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, globals.dialplan); SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_string, globals.codec_string); @@ -267,8 +79,6 @@ int stream_id); static switch_status_t channel_kill_channel(switch_core_session_t * session, int sig); -int option_debug = 100; -switch_core_session_t *global_session = NULL; #ifdef WIN32_SKYPIAX #ifdef __CYGWIN__ @@ -1590,7 +1400,7 @@ if (read_from_pipe[i] == '\0') { - if (option_debug > 101) + //if (option_debug > 101) DEBUGA_SKYPE("read_skype: howmany=%d, i=%d, a=%d, |||%s||| \n", SKYPIAX_P_LOG, howmany, i, a, messaggio); @@ -2511,4 +2321,3 @@ * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab: */ -#endif /* MOD_SKYPIAX */ Added: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h ============================================================================== --- (empty file) +++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h Tue Dec 9 04:43:33 2008 @@ -0,0 +1,197 @@ +/* + * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * Copyright (C) 2005/2006, Anthony Minessale II + * + * Version: MPL 1.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application + * + * The Initial Developer of the Original Code is + * Anthony Minessale II + * Portions created by the Initial Developer are Copyright (C) + * the Initial Developer. All Rights Reserved. + * + * This module (mod_skypiax) has been contributed by: + * + * Giovanni Maruzzelli (gmaruzz at gmail.com) + * + * + * Further Contributors: + * + * + * + * mod_skypiax.c -- Skype compatible Endpoint Module + * + */ + +#undef WIN32_SKYPIAX +#undef __CYGWIN__ + +#ifndef WIN32_SKYPIAX +#include +#include +#include +#else //WIN32_SKYPIAX +//FIXME include? +#endif //WIN32_SKYPIAX + +#include + +#define SKYPIAX_SVN_VERSION "SVN 123456" + +#define DEBUGA_SKYPE(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_SKYPE %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); +#define DEBUGA_CALL(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_CALL %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); +#define DEBUGA_PBX(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_PBX %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); +#define ERRORA(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][ERRORA %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); +#define WARNINGA(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][WARNINGA %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); +#define NOTICA(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][NOTICA %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); + +#define SKYPIAX_P_LOG NULL, (unsigned long)55, __LINE__, p ? p->name ? p->name : "none" : "none", -1, p ? p->interface_state : -1, p ? p->skype_callflow : -1 + +/*********************************/ +#define SKYPIAX_CAUSE_NORMAL 1 +/*********************************/ +#define SKYPIAX_FRAME_DTMF 1 +/*********************************/ +#define SKYPIAX_CONTROL_RINGING 1 +#define SKYPIAX_CONTROL_ANSWER 2 + +/*********************************/ +#define SKYPIAX_STATE_DOWN 1 +#define SKYPIAX_STATE_RING 2 +#define SKYPIAX_STATE_DIALING 3 +#define SKYPIAX_STATE_BUSY 4 +#define SKYPIAX_STATE_UP 5 +#define SKYPIAX_STATE_RINGING 6 +#define SKYPIAX_STATE_PRERING 7 +/*********************************/ +/* call flow from the device */ +#define CALLFLOW_CALL_IDLE SKYPIAX_STATE_DOWN +#define CALLFLOW_INCOMING_RING SKYPIAX_STATE_RING +#define CALLFLOW_CALL_DIALING SKYPIAX_STATE_DIALING +#define CALLFLOW_CALL_LINEBUSY SKYPIAX_STATE_BUSY +#define CALLFLOW_CALL_ACTIVE 300 +#define CALLFLOW_INCOMING_HANGUP 100 +#define CALLFLOW_CALL_RELEASED 101 +#define CALLFLOW_CALL_NOCARRIER 102 +#define CALLFLOW_CALL_INFLUX 103 +#define CALLFLOW_CALL_INCOMING 104 +#define CALLFLOW_CALL_FAILED 105 +#define CALLFLOW_CALL_NOSERVICE 106 +#define CALLFLOW_CALL_OUTGOINGRESTRICTED 107 +#define CALLFLOW_CALL_SECURITYFAIL 108 +#define CALLFLOW_CALL_NOANSWER 109 +#define CALLFLOW_STATUS_FINISHED 110 +#define CALLFLOW_STATUS_CANCELLED 111 +#define CALLFLOW_STATUS_FAILED 112 +#define CALLFLOW_STATUS_REFUSED 113 +#define CALLFLOW_STATUS_RINGING 114 +#define CALLFLOW_STATUS_INPROGRESS 115 +#define CALLFLOW_STATUS_UNPLACED 116 +#define CALLFLOW_STATUS_ROUTING 117 +#define CALLFLOW_STATUS_EARLYMEDIA 118 +#define SKYPIAX_STATE_HANGUP_REQUESTED 200 + //FIXME CALLFLOW_INCOMING_CALLID to be removed +#define CALLFLOW_INCOMING_CALLID 1019 + +/*********************************/ + +#define SKYPIAX_MAX_INTERFACES 64 + +#ifndef WIN32_SKYPIAX +struct AsteriskHandles { + Window skype_win; + Display *disp; + Window win; + switch_file_t *fdesc[2]; +}; +#else //WIN32_SKYPIAX + +struct AsteriskHandles { + HWND win32_hInit_MainWindowHandle; + HWND win32_hGlobal_SkypeAPIWindowHandle; + switch_file_t *fdesc[2]; +}; + +#endif //WIN32_SKYPIAX + +struct skypiax_interface { + char interface_id[80]; + char name[80]; + char dialplan[80]; + char context[80]; + char dial_regex[256]; + char fail_dial_regex[256]; + char hold_music[256]; + char type[256]; + char X11_display[256]; + struct AsteriskHandles AsteriskHandlesAst; + + int interface_state; /*!< \brief 'state' of the interface (channel) */ + char language[80]; /*!< \brief default Asterisk dialplan language for this interface */ + char exten[80]; /*!< \brief default Asterisk dialplan extension for this interface */ + int skypiax_sound_rate; /*!< \brief rate of the sound device, in Hz, eg: 8000 */ + switch_file_t *skypiax_sound_capt_fd; /*!< \brief file descriptor for sound capture dev */ + char callid_name[50]; + char callid_number[50]; + double playback_boost; + double capture_boost; + int stripmsd; + switch_thread_t *skype_thread; + char skype_call_id[512]; + int skype_call_ongoing; + char skype_friends[4096]; + char skype_fullname[512]; + char skype_displayname[512]; + int skype_callflow; /*!< \brief 'callflow' of the skype interface (as opposed to phone interface) */ + int skype; /*!< \brief config flag, bool, Skype support on this interface (0 if false, -1 if true) */ + int control_to_send; + switch_file_t *audiopipe[2]; + switch_file_t *audioskypepipe[2]; + switch_thread_t *tcp_srv_thread; + switch_thread_t *tcp_cli_thread; + short audiobuf[160]; + int audiobuf_is_loaded; + + //int phonebook_listing; + //int phonebook_querying; + //int phonebook_listing_received_calls; + + //int phonebook_first_entry; + //int phonebook_last_entry; + //int phonebook_number_lenght; + //int phonebook_text_lenght; + FILE *phonebook_writing_fp; + int skypiax_dir_entry_extension_prefix; + void *tech_pvt; +}; + +typedef struct skypiax_interface skypiax_interface_t; + +struct private_object { + unsigned int flags; + switch_codec_t read_codec; + switch_codec_t write_codec; + switch_frame_t read_frame; + unsigned char databuf[SWITCH_RECOMMENDED_BUFFER_SIZE]; + switch_core_session_t *session; + switch_caller_profile_t *caller_profile; + switch_mutex_t *mutex; + switch_mutex_t *flag_mutex; + skypiax_interface_t *p; + //switch_thread_cond_t *cond; +}; + +typedef struct private_object private_t; + + From gmaruzz at freeswitch.org Tue Dec 9 01:56:47 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Tue, 09 Dec 2008 04:56:47 -0500 Subject: [Freeswitch-branches] [commit] r10671 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Tue Dec 9 04:56:46 2008 New Revision: 10671 Log: skypiax: now ifdeffed on WIN32 for automatic understanding of platform Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.2008.vcproj freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.2008.vcproj ============================================================================== --- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.2008.vcproj (original) +++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.2008.vcproj Tue Dec 9 04:56:46 2008 @@ -149,6 +149,10 @@ RelativePath="..\mod_skypiax\mod_skypiax.c" > + + Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c (original) +++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c Tue Dec 9 04:56:46 2008 @@ -80,8 +80,8 @@ static switch_status_t channel_kill_channel(switch_core_session_t * session, int sig); -#ifdef WIN32_SKYPIAX -#ifdef __CYGWIN__ +#ifdef WIN32 +#ifdef WIN32 struct AsteriskHandles *win32_AsteriskHandlesSkype; HWND win32_hInit_MainWindowHandle; HINSTANCE win32_hInit_ProcessHandle; @@ -322,9 +322,9 @@ return NULL; } -#endif /* __CYGWIN__ */ +#endif /* WIN32 */ -#endif //WIN32_SKYPIAX +#endif //WIN32 static switch_status_t skypiax_codec(private_t * tech_pvt, int sample_rate, int codec_ms) { @@ -485,7 +485,7 @@ DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG); -#ifndef WIN32_SKYPIAX +#ifndef WIN32 close(fd); #else closesocket(fd); @@ -495,7 +495,7 @@ } WARNINGA("server (I am it) GONE\n", SKYPIAX_P_LOG); -#ifndef WIN32_SKYPIAX +#ifndef WIN32 close(s); #else closesocket(s); @@ -541,7 +541,7 @@ if (option_debug > 10) { DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); } -#ifndef WIN32_SKYPIAX +#ifndef WIN32 close(s); #else closesocket(s); @@ -597,7 +597,7 @@ } ERRORA("Skype server GONE\n", SKYPIAX_P_LOG); -#ifndef WIN32_SKYPIAX +#ifndef WIN32 close(fd); #else closesocket(fd); @@ -606,7 +606,7 @@ } WARNINGA("client (I am it) GONE\n", SKYPIAX_P_LOG); -#ifndef WIN32_SKYPIAX +#ifndef WIN32 close(s); #else closesocket(s); @@ -1029,7 +1029,7 @@ }; #define SKYPE_THREAD -#ifndef WIN32_SKYPIAX +#ifndef WIN32 #ifdef SKYPE_THREAD #define SKYPE_X11_BUF_SIZE 512 @@ -1290,9 +1290,9 @@ } #endif /* SKYPE_THREAD */ -#else // WIN32_SKYPIAX +#else // WIN32 -#endif // WIN32_SKYPIAX +#endif // WIN32 #define CONTROLDEV_THREAD #ifdef CONTROLDEV_THREAD @@ -1301,7 +1301,7 @@ #define WANT_SKYPE_X11 int skypiax_skype_write(struct skypiax_interface *p, char *msg_to_skype) { -#ifdef __CYGWIN__ +#ifdef WIN32 static char acInputRow[1024]; COPYDATASTRUCT oCopyData; @@ -1332,7 +1332,7 @@ return -1; } } -#else /* __CYGWIN__ */ +#else /* WIN32 */ #ifdef WANT_SKYPE_X11 struct AsteriskHandles *AsteriskHandlesAst; @@ -1355,7 +1355,7 @@ return -1; } #endif /* WANT_SKYPE_X11 */ -#endif /* __CYGWIN__ */ +#endif /* WIN32 */ if (option_debug > 100) { DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h ============================================================================== --- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h (original) +++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h Tue Dec 9 04:56:46 2008 @@ -34,18 +34,16 @@ * */ -#undef WIN32_SKYPIAX -#undef __CYGWIN__ +#include -#ifndef WIN32_SKYPIAX +#ifndef WIN32 #include #include #include -#else //WIN32_SKYPIAX +#else //WIN32 //FIXME include? -#endif //WIN32_SKYPIAX +#endif //WIN32 -#include #define SKYPIAX_SVN_VERSION "SVN 123456" @@ -108,14 +106,14 @@ #define SKYPIAX_MAX_INTERFACES 64 -#ifndef WIN32_SKYPIAX +#ifndef WIN32 struct AsteriskHandles { Window skype_win; Display *disp; Window win; switch_file_t *fdesc[2]; }; -#else //WIN32_SKYPIAX +#else //WIN32 struct AsteriskHandles { HWND win32_hInit_MainWindowHandle; @@ -123,7 +121,7 @@ switch_file_t *fdesc[2]; }; -#endif //WIN32_SKYPIAX +#endif //WIN32 struct skypiax_interface { char interface_id[80]; From gmaruzz at freeswitch.org Tue Dec 9 02:52:03 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Tue, 09 Dec 2008 05:52:03 -0500 Subject: [Freeswitch-branches] [commit] r10672 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Tue Dec 9 05:52:03 2008 New Revision: 10672 Log: skypiax: continuing files structuring Added: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.2008.vcproj freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.2008.vcproj ============================================================================== --- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.2008.vcproj (original) +++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.2008.vcproj Tue Dec 9 05:52:03 2008 @@ -153,6 +153,10 @@ RelativePath=".\skypiax.h" > + + Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c (original) +++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c Tue Dec 9 05:52:03 2008 @@ -6,26 +6,6 @@ //SWITCH_MODULE_RUNTIME_FUNCTION(mod_skypiax_runtime); SWITCH_MODULE_DEFINITION(mod_skypiax, mod_skypiax_load, mod_skypiax_shutdown, NULL); //mod_skypiax_runtime); -switch_endpoint_interface_t *skypiax_endpoint_interface; -static switch_memory_pool_t *module_pool = NULL; -static int running = 1; - -typedef enum { - TFLAG_IO = (1 << 0), - TFLAG_INBOUND = (1 << 1), - TFLAG_OUTBOUND = (1 << 2), - TFLAG_DTMF = (1 << 3), - TFLAG_VOICE = (1 << 4), - TFLAG_HANGUP = (1 << 5), - TFLAG_LINEAR = (1 << 6), - TFLAG_CODEC = (1 << 7), - TFLAG_BREAK = (1 << 8) -} TFLAGS; - -typedef enum { - GFLAG_MY_CODEC_PREFS = (1 << 0) -} GFLAGS; - static struct { int debug; char *ip; @@ -44,13 +24,18 @@ switch_mutex_t *mutex; } globals; -static skypiax_interface_t SKYPIAX_INTERFACES[SKYPIAX_MAX_INTERFACES]; - +/*************************************************/ +/*************************************************/ +/*************************************************/ int option_debug = 100; +switch_endpoint_interface_t *skypiax_endpoint_interface; +switch_memory_pool_t *skypiax_module_pool = NULL; +static int running = 1; +static skypiax_interface_t SKYPIAX_INTERFACES[SKYPIAX_MAX_INTERFACES]; switch_core_session_t *global_session = NULL; - - - +/*************************************************/ +/*************************************************/ +/*************************************************/ SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, globals.dialplan); @@ -80,252 +65,6 @@ static switch_status_t channel_kill_channel(switch_core_session_t * session, int sig); -#ifdef WIN32 -#ifdef WIN32 -struct AsteriskHandles *win32_AsteriskHandlesSkype; -HWND win32_hInit_MainWindowHandle; -HINSTANCE win32_hInit_ProcessHandle; -char win32_acInit_WindowClassName[128]; -HANDLE win32_hGlobal_ThreadShutdownEvent; -UINT win32_uiGlobal_MsgID_SkypeControlAPIAttach; -UINT win32_uiGlobal_MsgID_SkypeControlAPIDiscover; -HWND win32_hGlobal_SkypeAPIWindowHandle = NULL; -DWORD win32_ulGlobal_PromptConsoleMode = 0; -HANDLE volatile win32_hGlobal_PromptConsoleHandle = NULL; - -enum { - SKYPECONTROLAPI_ATTACH_SUCCESS = 0, /* Client is successfully - attached and API window handle can be found - in wParam parameter */ - SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION = 1, /* Skype has acknowledged - connection request and is waiting - for confirmation from the user. */ - /* The client is not yet attached - * and should wait for SKYPECONTROLAPI_ATTACH_SUCCESS message */ - SKYPECONTROLAPI_ATTACH_REFUSED = 2, /* User has explicitly - denied access to client */ - SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE = 3, /* API is not available - at the moment. - For example, this happens when no user - is currently logged in. */ - /* Client should wait for - * SKYPECONTROLAPI_ATTACH_API_AVAILABLE - * broadcast before making any further */ - /* connection attempts. */ - SKYPECONTROLAPI_ATTACH_API_AVAILABLE = 0x8001 -}; - -char - *strsep(char **stringp, const char *delim) -{ - char *res; - - if (!stringp || !*stringp || !**stringp) - return (char *) 0; - - res = *stringp; - while (**stringp && !strchr(delim, **stringp)) - ++(*stringp); - - if (**stringp) { - **stringp = '\0'; - ++(*stringp); - } - - return res; -} - -LRESULT APIENTRY skypiax_skype_present(HWND hWindow, UINT uiMessage, WPARAM uiParam, - LPARAM ulParam) -{ - LRESULT lReturnCode; - int fIssueDefProc; - struct skypiax_interface *p = NULL; - - lReturnCode = 0; - fIssueDefProc = 0; - switch (uiMessage) { - case WM_DESTROY: - win32_hInit_MainWindowHandle = NULL; - PostQuitMessage(0); - break; - case WM_COPYDATA: - if (win32_hGlobal_SkypeAPIWindowHandle == (HWND) uiParam) { - unsigned int howmany; - char msg_from_skype[2048]; - - PCOPYDATASTRUCT poCopyData = (PCOPYDATASTRUCT) ulParam; - - memset(msg_from_skype, '\0', sizeof(msg_from_skype)); - strncpy(msg_from_skype, (const char *) poCopyData->lpData, - sizeof(msg_from_skype) - 2); - - howmany = strlen(msg_from_skype) + 1; - switch_file_write(win32_AsteriskHandlesSkype->fdesc[1], msg_from_skype, &howmany); - NOTICA("From Skype API: %s\n", SKYPIAX_P_LOG, (const char *) poCopyData->lpData); - lReturnCode = 1; - } - break; - default: - if (uiMessage == win32_uiGlobal_MsgID_SkypeControlAPIAttach) { - switch (ulParam) { - case SKYPECONTROLAPI_ATTACH_SUCCESS: - NOTICA("\n\n\tConnected to Skype API!\n", SKYPIAX_P_LOG); - win32_hGlobal_SkypeAPIWindowHandle = (HWND) uiParam; - switch_sleep(5000); - win32_AsteriskHandlesSkype->win32_hGlobal_SkypeAPIWindowHandle = - win32_hGlobal_SkypeAPIWindowHandle; - break; - case SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION: - WARNINGA - ("\n\n\tIf I do not immediately connect to Skype API,\n\tplease give the Skype client authorization to be connected \n\tby Asterisk and to not ask you again.\n\n", - SKYPIAX_P_LOG); - break; - case SKYPECONTROLAPI_ATTACH_REFUSED: - ERRORA("Skype client refused to be connected by Skypiax!\n", SKYPIAX_P_LOG); - break; - case SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE: - ERRORA("Skype API not available\n", SKYPIAX_P_LOG); - break; - case SKYPECONTROLAPI_ATTACH_API_AVAILABLE: - DEBUGA_SKYPE("Skype API available\n", SKYPIAX_P_LOG); - break; - default: - WARNINGA("GOT AN UNKNOWN SKYPE WINDOWS MSG\n", SKYPIAX_P_LOG); - } - lReturnCode = 1; - break; - } - fIssueDefProc = 1; - break; - } - if (fIssueDefProc) - lReturnCode = DefWindowProc(hWindow, uiMessage, uiParam, ulParam); - return (lReturnCode); -} - -int win32_Initialize_CreateWindowClass(void) -{ - unsigned char *paucUUIDString; - RPC_STATUS lUUIDResult; - int fReturnStatus; - UUID oUUID; - - fReturnStatus = 0; - lUUIDResult = UuidCreate(&oUUID); - win32_hInit_ProcessHandle = - (HINSTANCE) OpenProcess(PROCESS_DUP_HANDLE, FALSE, GetCurrentProcessId()); - if (win32_hInit_ProcessHandle != NULL - && (lUUIDResult == RPC_S_OK || lUUIDResult == RPC_S_UUID_LOCAL_ONLY)) { - if (UuidToString(&oUUID, &paucUUIDString) == RPC_S_OK) { - WNDCLASS oWindowClass; - - strcpy(win32_acInit_WindowClassName, "Skype-API-Skypiax-"); - strcat(win32_acInit_WindowClassName, (char *) paucUUIDString); - - oWindowClass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; - oWindowClass.lpfnWndProc = (WNDPROC) & skypiax_skype_present; - oWindowClass.cbClsExtra = 0; - oWindowClass.cbWndExtra = 0; - oWindowClass.hInstance = win32_hInit_ProcessHandle; - oWindowClass.hIcon = NULL; - oWindowClass.hCursor = NULL; - oWindowClass.hbrBackground = NULL; - oWindowClass.lpszMenuName = NULL; - oWindowClass.lpszClassName = win32_acInit_WindowClassName; - - if (RegisterClass(&oWindowClass) != 0) - fReturnStatus = 1; - - RpcStringFree(&paucUUIDString); - } - } - if (fReturnStatus == 0) - CloseHandle(win32_hInit_ProcessHandle), win32_hInit_ProcessHandle = NULL; - return (fReturnStatus); -} - -void win32_DeInitialize_DestroyWindowClass(void) -{ - UnregisterClass(win32_acInit_WindowClassName, win32_hInit_ProcessHandle); - CloseHandle(win32_hInit_ProcessHandle), win32_hInit_ProcessHandle = NULL; -} - -int win32_Initialize_CreateMainWindow(void) -{ - win32_hInit_MainWindowHandle = - CreateWindowEx(WS_EX_APPWINDOW | WS_EX_WINDOWEDGE, win32_acInit_WindowClassName, "", - WS_BORDER | WS_SYSMENU | WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, - 128, 128, NULL, 0, win32_hInit_ProcessHandle, 0); - return (win32_hInit_MainWindowHandle != NULL ? 1 : 0); -} - -void win32_DeInitialize_DestroyMainWindow(void) -{ - if (win32_hInit_MainWindowHandle != NULL) - DestroyWindow(win32_hInit_MainWindowHandle), win32_hInit_MainWindowHandle = NULL; -} - -DWORD win32_dwThreadId; - -static void *SWITCH_THREAD_FUNC do_skype_thread(switch_thread_t * thread, void *obj) -{ - /* create window class */ - /* create dummy/hidden window for processing messages */ - /* run message loop thread */ - /* do application control until exit */ - /* exit: send QUIT message to our own window */ - /* wait until thred terminates */ - /* destroy main window */ - /* destroy window class */ - - struct skypiax_interface *p; - p = obj; - - switch_file_pipe_create_ex(&p->AsteriskHandlesAst.fdesc[0], - &p->AsteriskHandlesAst.fdesc[1], 2, module_pool); - - win32_AsteriskHandlesSkype = &p->AsteriskHandlesAst; - - win32_uiGlobal_MsgID_SkypeControlAPIAttach = - RegisterWindowMessage("SkypeControlAPIAttach"); - win32_uiGlobal_MsgID_SkypeControlAPIDiscover = - RegisterWindowMessage("SkypeControlAPIDiscover"); - - if (win32_uiGlobal_MsgID_SkypeControlAPIAttach != 0 - && win32_uiGlobal_MsgID_SkypeControlAPIDiscover != 0) { - if (win32_Initialize_CreateWindowClass()) { - if (win32_Initialize_CreateMainWindow()) { - win32_hGlobal_ThreadShutdownEvent = CreateEvent(NULL, TRUE, FALSE, NULL); - if (win32_hGlobal_ThreadShutdownEvent != NULL) { - if (SendMessage - (HWND_BROADCAST, win32_uiGlobal_MsgID_SkypeControlAPIDiscover, - (WPARAM) win32_hInit_MainWindowHandle, 0) != 0) { - win32_AsteriskHandlesSkype->win32_hInit_MainWindowHandle = - win32_hInit_MainWindowHandle; - while (1) { - MSG oMessage; - - while (GetMessage(&oMessage, 0, 0, 0) != FALSE) { - TranslateMessage(&oMessage); - DispatchMessage(&oMessage); - } - } - } - CloseHandle(win32_hGlobal_ThreadShutdownEvent); - } - win32_DeInitialize_DestroyMainWindow(); - } - win32_DeInitialize_DestroyWindowClass(); - } - } - return NULL; -} - -#endif /* WIN32 */ - -#endif //WIN32 - static switch_status_t skypiax_codec(private_t * tech_pvt, int sample_rate, int codec_ms) { if (switch_core_codec_init @@ -355,332 +94,7 @@ } -#define SKYPE_AUDIO -#ifdef SKYPE_AUDIO - -#define SAMPLES_PER_FRAME 160 -#define NN 160 -#define GG 160 -static void *SWITCH_THREAD_FUNC skypiax_do_tcp_srv_thread(switch_thread_t * thread, - void *obj) -{ - struct skypiax_interface *p = obj; - short in[GG]; - short out[GG / 2]; - int s, fd, len; - unsigned int sin_size; - struct sockaddr_in my_addr; - struct sockaddr_in remote_addr; - int exit = 0; - int a; - int i; - unsigned int kill_cli_size; - short kill_cli_buff[320]; - - if (option_debug > 10) { - WARNINGA("ENTERING FUNC\n", SKYPIAX_P_LOG); - } - memset(&my_addr, 0, sizeof(my_addr)); - my_addr.sin_family = AF_INET; - my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */ - my_addr.sin_port = htons(5556); //FIXME configurable! - - if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - ERRORA("socket Error\n", SKYPIAX_P_LOG); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } - return NULL; - } - - if (bind(s, (struct sockaddr *) &my_addr, sizeof(struct sockaddr)) < 0) { - ERRORA("bind Error\n", SKYPIAX_P_LOG); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } - return NULL; - } - DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG); - - listen(s, 6); - - sin_size = sizeof(remote_addr); - while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) { - DEBUGA_SKYPE("ACCEPTED\n", SKYPIAX_P_LOG); - while (p->interface_state != SKYPIAX_STATE_DOWN - && (p->skype_callflow == CALLFLOW_STATUS_INPROGRESS - || p->skype_callflow == SKYPIAX_STATE_UP)) { - - int fdselect; - int rt; - fd_set fs; - struct timeval to; - - exit = 1; - - fdselect = fd; - FD_ZERO(&fs); - FD_SET(fdselect, &fs); - to.tv_usec = 100; - to.tv_sec = 0; - rt = select(fdselect + 1, &fs, NULL, NULL, &to); - if (rt > 0) { - - len = recv(fd, in, sizeof(short) * GG, 0); - //DEBUGA_SKYPE("recv %d\n", SKYPIAX_P_LOG, len); - if (len > 0) { - a = 0; - for (i = 0; i < len / sizeof(short); i++) { - out[a] = in[i]; - i++; - a++; - } - - if (!p->audiobuf_is_loaded) { - for (i = 0; i < (len / sizeof(short)) / 2; i++) { - p->audiobuf[i] = out[i]; - } - p->audiobuf_is_loaded = 1; - } else { - unsigned int howmany; - short totalbuf[GG]; - - howmany = len / 2 / 2; - for (i = 0; i < howmany; i++) - totalbuf[i] = p->audiobuf[i]; - - howmany = len / 2 / 2; - for (a = 0; a < howmany; a++) { - totalbuf[i] = out[a]; - i++; - } - - howmany = len; - - switch_file_write(p->audiopipe[1], totalbuf, &howmany); - p->audiobuf_is_loaded = 0; - //DEBUGA_SKYPE("read=====> req=%d recv=%d to sent=%d sent=%d\n", SKYPIAX_P_LOG, sizeof(short)*GG, len, (len*sizeof(short))/2, howmany); - } - - } else if (len == 0) { - DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG); - break; - } else { - ERRORA("len=%d\n", SKYPIAX_P_LOG, len); - exit = 1; - break; - } - } - } - - kill_cli_size = 320; - switch_file_write(p->audiopipe[1], kill_cli_buff, &kill_cli_size); - kill_cli_size = 320; - switch_file_write(p->audioskypepipe[1], kill_cli_buff, &kill_cli_size); - p->interface_state = SKYPIAX_STATE_DOWN; - kill_cli_size = 320; - switch_file_write(p->audiopipe[1], kill_cli_buff, &kill_cli_size); - kill_cli_size = 320; - switch_file_write(p->audioskypepipe[1], kill_cli_buff, &kill_cli_size); - - DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG); - -#ifndef WIN32 - close(fd); -#else - closesocket(fd); -#endif - if (exit) - break; - } - - WARNINGA("server (I am it) GONE\n", SKYPIAX_P_LOG); -#ifndef WIN32 - close(s); -#else - closesocket(s); -#endif - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } - return NULL; -} -static void *SWITCH_THREAD_FUNC skypiax_do_tcp_cli_thread(switch_thread_t * thread, - void *obj) -//void *skypiax_do_tcp_cli_thread(void *data) -{ - struct skypiax_interface *p = obj; - int s, fd, len; - short in[NN / 2]; - short out[NN]; - unsigned int sin_size; - struct sockaddr_in my_addr; - struct sockaddr_in remote_addr; - int a; - int i; - unsigned int got; - - if (option_debug > 10) { - WARNINGA("ENTERING FUNC\n", SKYPIAX_P_LOG); - } - memset(&my_addr, 0, sizeof(my_addr)); - my_addr.sin_family = AF_INET; - my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */ - my_addr.sin_port = htons(5558); //FIXME configurable! - - if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - ERRORA("socket Error\n", SKYPIAX_P_LOG); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } - return NULL; - } - - if (bind(s, (struct sockaddr *) &my_addr, sizeof(struct sockaddr)) < 0) { - ERRORA("bind Error\n", SKYPIAX_P_LOG); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } -#ifndef WIN32 - close(s); -#else - closesocket(s); -#endif - return NULL; - } - DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG); - - listen(s, 6); - - sin_size = sizeof(remote_addr); - while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) { - DEBUGA_SKYPE("ACCEPTED\n", SKYPIAX_P_LOG); - while (p->interface_state != SKYPIAX_STATE_DOWN - && (p->skype_callflow == CALLFLOW_STATUS_INPROGRESS - || p->skype_callflow == SKYPIAX_STATE_UP)) { - int fdselect; - int rt; - fd_set fs; - struct timeval to; - - fdselect = 1; - FD_ZERO(&fs); - FD_SET(fdselect, &fs); - to.tv_usec = 100; - to.tv_sec = 0; - rt = 1; - if (rt > 0) { - - got = (NN / 2) * sizeof(short); - switch_file_read(p->audioskypepipe[0], in, &got); - - if (got > 0) { - a = 0; - for (i = 0; i < got / sizeof(short); i++) { - out[a] = in[i]; - a++; - out[a] = in[i]; - a++; - } - - len = send(fd, out, got * 2, 0); - - if (len == 0) { - ERRORA("Skype server GONE\n", SKYPIAX_P_LOG); - break; - } - } else { - switch_sleep(1000); - //ERRORA("Audio skype pipe give us: %u\n", SKYPIAX_P_LOG, got); - } - } - - } - ERRORA("Skype server GONE\n", SKYPIAX_P_LOG); -#ifndef WIN32 - close(fd); -#else - closesocket(fd); -#endif - break; - } - - WARNINGA("client (I am it) GONE\n", SKYPIAX_P_LOG); -#ifndef WIN32 - close(s); -#else - closesocket(s); -#endif - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } - return NULL; -} - -int skypiax_skypeaudio_init(struct skypiax_interface *p) -{ - - switch_status_t rv; - - rv = switch_file_pipe_create_ex(&p->audiopipe[0], &p->audiopipe[1], 2, module_pool); - rv = switch_file_pipe_timeout_set(p->audiopipe[0], 100000); - -/* the pipe is our audio fd for pbx to poll on */ - p->skypiax_sound_capt_fd = p->audiopipe[0]; - - rv = - switch_file_pipe_create_ex(&p->audioskypepipe[0], &p->audioskypepipe[1], 2, - module_pool); - rv = switch_file_pipe_timeout_set(p->audioskypepipe[0], 100); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } - return 0; -} -static switch_status_t skypiax_skypeaudio_read(private_t * tech_pvt) -{ - struct skypiax_interface *p; - short buf[640]; - unsigned int samples; - int rt; - - p = tech_pvt->p; - - //DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - - memset(buf, '\0', sizeof(buf)); - - rt = 1; - if (rt > 0) { - - samples = SAMPLES_PER_FRAME * sizeof(short); - - switch_file_read(p->audiopipe[0], tech_pvt->read_frame.data, &samples); - - //if ((samples = read(p->audiopipe[0], buf, SAMPLES_PER_FRAME * sizeof(short))) != 320) - if (samples != SAMPLES_PER_FRAME * sizeof(short)) { - if (samples) - DEBUGA_SKYPE("read=====> NOT GOOD samples=%d expected=%d\n", SKYPIAX_P_LOG, - samples, SAMPLES_PER_FRAME * sizeof(short)); - //do nothing - } else { - tech_pvt->read_frame.datalen = samples; - //DEBUGA_SKYPE("read=====> GOOD samples=%d\n", SKYPIAX_P_LOG, samples); - /* A real frame */ - } - } else { - DEBUGA_SKYPE("select returned %d\n", SKYPIAX_P_LOG, rt); - - } - - //DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - - return SWITCH_STATUS_SUCCESS; -} - -#endif /* SKYPE_AUDIO */ -static void tech_init(private_t * tech_pvt, switch_core_session_t * session, - skypiax_interface_t * p) +void skypiax_tech_init(private_t * tech_pvt, switch_core_session_t * session, skypiax_interface_t * p) { DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); @@ -1028,799 +442,6 @@ /*.receive_event */ channel_receive_event }; -#define SKYPE_THREAD -#ifndef WIN32 -#ifdef SKYPE_THREAD - -#define SKYPE_X11_BUF_SIZE 512 -Window skype_win = (Window) - 1; -static XErrorHandler old_handler = 0; -static int xerror = 0; - -int X11_errors_handler(Display * dpy, XErrorEvent * err) -{ - (void) dpy; - struct skypiax_interface *p = NULL; - - xerror = err->error_code; - DEBUGA_SKYPE("Received error code %d from X Server\n", SKYPIAX_P_LOG, xerror); - return 0; /* ignore the error */ -} - -static void X11_errors_trap(void) -{ - xerror = 0; - old_handler = XSetErrorHandler(X11_errors_handler); -} - -static int X11_errors_untrap(void) -{ - XSetErrorHandler(old_handler); - return (xerror != BadValue) && (xerror != BadWindow); -} - -int skypiax_skype_send_message(struct AsteriskHandles *AsteriskHandlesAst, - const char *message_P) -{ - - Window w_P; - Display *disp; - Window handle_P; - struct skypiax_interface *p = NULL; - - w_P = AsteriskHandlesAst->skype_win; - disp = AsteriskHandlesAst->disp; - handle_P = AsteriskHandlesAst->win; - - Atom atom1 = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", False); - Atom atom2 = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE", False); - unsigned int pos = 0; - unsigned int len = strlen(message_P); - XEvent e; - int ok; - - memset(&e, 0, sizeof(e)); - e.xclient.type = ClientMessage; - e.xclient.message_type = atom1; /* leading message */ - e.xclient.display = disp; - e.xclient.window = handle_P; - e.xclient.format = 8; - - X11_errors_trap(); - //XLockDisplay(disp); - do { - unsigned int i; - for (i = 0; i < 20 && i + pos <= len; ++i) - e.xclient.data.b[i] = message_P[i + pos]; - XSendEvent(disp, w_P, False, 0, &e); - - e.xclient.message_type = atom2; /* following messages */ - pos += i; - } while (pos <= len); - - XSync(disp, False); - //XUnlockDisplay(disp); - ok = X11_errors_untrap(); - - if (!ok) - DEBUGA_SKYPE("Sending message failed with status %d\n", SKYPIAX_P_LOG, xerror); - - return ok; -} - -int skypiax_skype_present(Display * disp) -{ - Atom skype_inst = XInternAtom(disp, "_SKYPE_INSTANCE", True); - - Atom type_ret; - int format_ret; - unsigned long nitems_ret; - unsigned long bytes_after_ret; - unsigned char *prop; - int status; - struct skypiax_interface *p = NULL; - - X11_errors_trap(); - //XLockDisplay(disp); - status = - XGetWindowProperty(disp, DefaultRootWindow(disp), skype_inst, 0, 1, False, XA_WINDOW, - &type_ret, &format_ret, &nitems_ret, &bytes_after_ret, &prop); - //XUnlockDisplay(disp); - X11_errors_untrap(); - - /* sanity check */ - if (status != Success || format_ret != 32 || nitems_ret != 1) { - skype_win = (Window) - 1; - DEBUGA_SKYPE("Skype instance not found\n", SKYPIAX_P_LOG); - return 0; - } - - skype_win = *(const unsigned long *) prop & 0xffffffff; - //DEBUGA_SKYPE("Skype instance found with id #%x\n", SKYPIAX_P_LOG, - DEBUGA_SKYPE("Skype instance found with id #%d\n", SKYPIAX_P_LOG, - (unsigned int) skype_win); - return 1; -} - -void skypiax_skype_clean_disp(void *data) -{ - - int *dispptr; - int disp; - struct skypiax_interface *p = NULL; - - dispptr = data; - disp = *dispptr; - - if (disp) { - DEBUGA_SKYPE("to be destroyed disp %d\n", SKYPIAX_P_LOG, disp); - close(disp); - DEBUGA_SKYPE("destroyed disp\n", SKYPIAX_P_LOG); - } else { - DEBUGA_SKYPE("NOT destroyed disp\n", SKYPIAX_P_LOG); - } - DEBUGA_SKYPE("OUT destroyed disp\n", SKYPIAX_P_LOG); - switch_sleep(1000); -} - -static void *SWITCH_THREAD_FUNC do_skype_thread(switch_thread_t * thread, void *obj) -{ - - struct skypiax_interface *p; - struct AsteriskHandles *AsteriskHandlesAst; - char buf[SKYPE_X11_BUF_SIZE]; - Display *disp = NULL; - Window root = -1; - Window win = -1; - - p = obj; - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - - switch_file_pipe_create_ex(&p->AsteriskHandlesAst.fdesc[0], - &p->AsteriskHandlesAst.fdesc[1], 2, module_pool); - - AsteriskHandlesAst = &p->AsteriskHandlesAst; - //disp = XOpenDisplay(getenv("DISPLAY")); - disp = XOpenDisplay(p->X11_display); - if (!disp) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, - "Cannot open X Display '%s', exiting skype thread\n", - p->X11_display); - return NULL; - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "X Display '%s' opened\n", - p->X11_display); - } - - int xfd; - xfd = XConnectionNumber(disp); - fcntl(xfd, F_SETFD, FD_CLOEXEC); - - //FIXME pthread_cleanup_push(skypiax_skype_clean_disp, &xfd); - DEBUGA_SKYPE("PUSH disp %d\n", SKYPIAX_P_LOG, xfd); - - if (skypiax_skype_present(disp)) { - root = DefaultRootWindow(disp); - win = - XCreateSimpleWindow(disp, root, 0, 0, 1, 1, 0, - BlackPixel(disp, DefaultScreen(disp)), BlackPixel(disp, - DefaultScreen - (disp))); - - DEBUGA_SKYPE("skype_win=%d win=%d\n", SKYPIAX_P_LOG, (unsigned int) skype_win, - (unsigned int) win); - - AsteriskHandlesAst->skype_win = skype_win; - AsteriskHandlesAst->disp = disp; - AsteriskHandlesAst->win = win; - - snprintf(buf, SKYPE_X11_BUF_SIZE, "NAME skypiax"); - - if (!skypiax_skype_send_message(AsteriskHandlesAst, buf)) { - ERRORA - ("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypiax again\n", - SKYPIAX_P_LOG); - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - return NULL; - } - - snprintf(buf, SKYPE_X11_BUF_SIZE, "PROTOCOL 6"); - if (!skypiax_skype_send_message(AsteriskHandlesAst, buf)) { - ERRORA - ("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypiax again\n", - SKYPIAX_P_LOG); - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - return NULL; - } - - /* perform an events loop */ - XEvent an_event; - char buf[21]; /* can't be longer */ - char buffer[17000]; - char *b; - int i; - - b = buffer; - - while (1) { - XNextEvent(disp, &an_event); - switch (an_event.type) { - case ClientMessage: - - if (an_event.xclient.format != 8) - break; - - for (i = 0; i < 20 && an_event.xclient.data.b[i] != '\0'; ++i) - buf[i] = an_event.xclient.data.b[i]; - - buf[i] = '\0'; - - //NOTICA("ClientMessage buf:|||%s||| buffer:|||%s||| serial=%ld|||\r\n",SKYPIAX_P_LOG,buf, buffer,an_event.xclient.serial); - //NOTICA ("SKYPE read: |||%s|||%d\n", SKYPIAX_P_LOG, buf, strlen(buf)); - //NOTICA ("SKYPE buffer: |||%s|||%d\n", SKYPIAX_P_LOG, buffer, strlen(buffer)); - - strcat(buffer, buf); - - if (i < 20) { /* last fragment */ - unsigned int howmany; - - howmany = strlen(b) + 1; - - switch_file_write(AsteriskHandlesAst->fdesc[1], b, &howmany); - //write(AsteriskHandlesAst->fdesc[1], "\0", 1); - //FIXME DEBUGA_SKYPE("SKYPE pipewrite: |||%s|||len=%d serial=%ld\n\n\n", SKYPIAX_P_LOG, b, strlen(b) + 1, an_event.xclient.serial); - //switch_sleep(1000); - memset(buffer, '\0', 17000); - } - - break; - default: - break; - } - } - } else { - ERRORA - ("Skype is not running, maybe crashed. Please run/restart Skype and relaunch Skypiax\n", - SKYPIAX_P_LOG); - return NULL; - } - //DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - return NULL; - -} - -#endif /* SKYPE_THREAD */ -#else // WIN32 - -#endif // WIN32 - -#define CONTROLDEV_THREAD -#ifdef CONTROLDEV_THREAD -#if 1 - -#define WANT_SKYPE_X11 -int skypiax_skype_write(struct skypiax_interface *p, char *msg_to_skype) -{ -#ifdef WIN32 - static char acInputRow[1024]; - COPYDATASTRUCT oCopyData; - - if (option_debug > 100) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } - sprintf(acInputRow, "%s", msg_to_skype); - if (option_debug > 1) - DEBUGA_SKYPE("acInputRow: |||%s||||\n", SKYPIAX_P_LOG, acInputRow); - /* send command to skype */ - oCopyData.dwData = 0; - oCopyData.lpData = acInputRow; - oCopyData.cbData = strlen(acInputRow) + 1; - if (oCopyData.cbData != 1) { - if (SendMessage - (p->AsteriskHandlesAst.win32_hGlobal_SkypeAPIWindowHandle, WM_COPYDATA, - (WPARAM) p->AsteriskHandlesAst.win32_hInit_MainWindowHandle, - (LPARAM) & oCopyData) == FALSE) { - ERRORA - ("Sending message failed - probably Skype crashed.\n\nPlease shutdown Skypiax (Asterisk), then restart Skype from the menu, then launch Skypiax and try again.\n", - SKYPIAX_P_LOG); - p->skype = 0; - //FIXME p->skype_thread = SKYPIAX_PTHREADT_NULL; - p->skype_thread = NULL; - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } - return -1; - } - } -#else /* WIN32 */ -#ifdef WANT_SKYPE_X11 - struct AsteriskHandles *AsteriskHandlesAst; - - if (option_debug > 100) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } - AsteriskHandlesAst = &p->AsteriskHandlesAst; - - if (option_debug > 101) { - DEBUGA_SKYPE("SENDING: |||%s||||\n", SKYPIAX_P_LOG, msg_to_skype); - } - - if (!skypiax_skype_send_message(AsteriskHandlesAst, msg_to_skype)) { - ERRORA - ("Sending message failed - probably Skype crashed.\n\nPlease shutdown Skypiax (Asterisk), then restart Skype from the menu, then launch Skypiax and try again.\n", - SKYPIAX_P_LOG); - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } - return -1; - } -#endif /* WANT_SKYPE_X11 */ -#endif /* WIN32 */ - - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } - return 0; - -} -#endif //0 - -int skypiax_skype_read(struct skypiax_interface *p) -{ - - char read_from_pipe[4096]; - char messaggio[4096]; - char messaggio_2[4096]; - char *buf, obj[512] = "", id[512] = "", prop[512] = "", value[512] = "", *where; - char **stringp = NULL; - //int fd; - int rt; - //fd_set fs; - //struct timeval to; - int i, a; - unsigned int howmany; - - if (option_debug > 100) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } - - memset(read_from_pipe, 0, 4096); - memset(messaggio, 0, 4096); - memset(messaggio_2, 0, 4096); - - rt = 1; - if (rt > 0) { - howmany = sizeof(read_from_pipe); - switch_file_read(p->AsteriskHandlesAst.fdesc[0], read_from_pipe, &howmany); - - a = 0; - for (i = 0; i < howmany; i++) { - messaggio[a] = read_from_pipe[i]; - a++; - - if (read_from_pipe[i] == '\0') { - - //if (option_debug > 101) - DEBUGA_SKYPE("read_skype: howmany=%d, i=%d, a=%d, |||%s||| \n", SKYPIAX_P_LOG, - howmany, i, a, messaggio); - - if (!strncasecmp(messaggio, "ERROR 92 CALL", 12)) { - ERRORA("Skype got ERROR: |||%s|||, the number we called was not recognized\n", - SKYPIAX_P_LOG, messaggio); - p->skype_callflow = CALLFLOW_STATUS_FINISHED; - if (option_debug) - DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG); - p->skype_call_id[0] = '\0'; - - if (p->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } - p->interface_state = SKYPIAX_STATE_DOWN; - return CALLFLOW_INCOMING_HANGUP; - } else { - p->interface_state = SKYPIAX_STATE_DOWN; - } - } - - strncpy(messaggio_2, messaggio, sizeof(messaggio) - 1); - - buf = messaggio; - stringp = &buf; - where = strsep(stringp, " "); - if (!where) { - WARNINGA("Skype MSG without spaces: %s\n", SKYPIAX_P_LOG, messaggio); - } - - if (!strcasecmp(messaggio, "#333")) { - /* DEBUGA_SKYPE("Skype MSG: messaggio_2: %s, messaggio2[11]: %s\n", SKYPIAX_P_LOG, - * messaggio_2, &messaggio_2[11]); */ - memset(p->skype_friends, 0, 4096); - strncpy(p->skype_friends, &messaggio_2[11], 4095); - } - if (!strcasecmp(messaggio, "#222")) { - /* DEBUGA_SKYPE("Skype MSG: messaggio_2: %s, messaggio2[10]: %s\n", SKYPIAX_P_LOG, - * messaggio_2, &messaggio_2[10]); */ - memset(p->skype_fullname, 0, 512); - strncpy(p->skype_fullname, &messaggio_2[10], 511); - } - if (!strcasecmp(messaggio, "#765")) { - /* DEBUGA_SKYPE("Skype MSG: messaggio_2: %s, messaggio2[10]: %s\n", SKYPIAX_P_LOG, - * messaggio_2, &messaggio_2[10]); */ - memset(p->skype_displayname, 0, 512); - strncpy(p->skype_displayname, &messaggio_2[10], 511); - } - if (!strcasecmp(messaggio, "ERROR")) { - ERRORA("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, messaggio); - p->skype_callflow = CALLFLOW_STATUS_FINISHED; - if (option_debug) - DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG); - p->skype_call_id[0] = '\0'; - - if (p->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } - p->interface_state = SKYPIAX_STATE_DOWN; - return CALLFLOW_INCOMING_HANGUP; - } else { - p->interface_state = SKYPIAX_STATE_DOWN; - } - } - if (!strcasecmp(messaggio, "CALL")) { - - strncpy(obj, where, sizeof(obj) - 1); - - where = strsep(stringp, " "); - - strncpy(id, where, sizeof(id) - 1); - - where = strsep(stringp, " "); - - strncpy(prop, where, sizeof(prop) - 1); - - where = strsep(stringp, " "); - - strncpy(value, where, sizeof(value) - 1); - - where = strsep(stringp, " "); - - if (option_debug > 101) - DEBUGA_SKYPE - ("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s, value: %s,where: %s!\n", - SKYPIAX_P_LOG, messaggio, obj, id, prop, value, where ? where : "NULL"); - - if (!strcasecmp(prop, "PARTNER_HANDLE")) { - strncpy(p->callid_number, value, sizeof(p->callid_number) - 1); - WARNINGA - ("the skype_call %s caller PARTNER_HANDLE (p->callid_number) is: %s\n", - SKYPIAX_P_LOG, id, p->callid_number); - return CALLFLOW_INCOMING_RING; - } - if (!strcasecmp(prop, "PARTNER_DISPNAME")) { - snprintf(p->callid_name, sizeof(p->callid_name) - 1, "%s%s%s", value, - where ? " " : "", where ? where : ""); - WARNINGA - ("the skype_call %s caller PARTNER_DISPNAME (p->callid_name) is: %s\n", - SKYPIAX_P_LOG, id, p->callid_name); - } - if (!strcasecmp(prop, "CONF_ID") && !strcasecmp(value, "0")) { - DEBUGA_SKYPE("the skype_call %s is NOT a conference call\n", SKYPIAX_P_LOG, - id); - if (p->interface_state == SKYPIAX_STATE_DOWN) - p->interface_state = SKYPIAX_STATE_PRERING; - } - if (!strcasecmp(prop, "CONF_ID") && strcasecmp(value, "0")) { - DEBUGA_SKYPE("the skype_call %s is a conference call\n", SKYPIAX_P_LOG, id); - if (p->interface_state == SKYPIAX_STATE_DOWN) - p->interface_state = SKYPIAX_STATE_PRERING; - } - - if (!strcasecmp(prop, "DTMF")) { - switch_core_session_t *session = NULL; - private_t *tech_pvt = NULL; - switch_channel_t *channel = NULL; - - DEBUGA_SKYPE("Call %s received a DTMF: %s\n", SKYPIAX_P_LOG, id, value); - - tech_pvt = p->tech_pvt; - session = tech_pvt->session; - channel = switch_core_session_get_channel(session); - - if (channel) { - switch_dtmf_t dtmf = - { (char) value[0], switch_core_default_dtmf_duration(0) }; - if (globals.debug) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%c DTMF %s\n", - dtmf.digit, switch_channel_get_name(channel)); - } - switch_mutex_lock(tech_pvt->flag_mutex); - switch_channel_queue_dtmf(channel, &dtmf); - switch_set_flag(tech_pvt, TFLAG_DTMF); - switch_mutex_unlock(tech_pvt->flag_mutex); - } - } - - if (!strcasecmp(prop, "FAILUREREASON")) { - DEBUGA_SKYPE - ("Skype has FAILED on skype_call %s. Let's wait for the FAILED message.\n", - SKYPIAX_P_LOG, id); - } - if (!strcasecmp(prop, "DURATION") && (!strcasecmp(value, "1"))) { - if (strcasecmp(id, p->skype_call_id)) { - strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1); - if (option_debug > 1) - DEBUGA_SKYPE - ("We called a Skype contact and he answered us on skype_call: %s.\n", - SKYPIAX_P_LOG, id); - } - } - - if (!strcasecmp(prop, "STATUS")) { - - if (!strcasecmp(value, "RINGING")) { - char msg_to_skype[1024]; - if (p->interface_state != SKYPIAX_STATE_DIALING) { - /* we are not calling out */ - - if (1) { - /* we are not inside an active call */ - p->skype_callflow = CALLFLOW_STATUS_RINGING; - p->interface_state = SKYPIAX_STATE_RING; - /* no owner, no active call, let's answer */ - skypiax_skype_write(p, "SET AGC OFF"); - switch_sleep(10000); - skypiax_skype_write(p, "SET AEC OFF"); - switch_sleep(10000); - sprintf(msg_to_skype, "GET CALL %s PARTNER_DISPNAME", id); - skypiax_skype_write(p, msg_to_skype); - switch_sleep(10000); - sprintf(msg_to_skype, "GET CALL %s PARTNER_HANDLE", id); - skypiax_skype_write(p, msg_to_skype); - switch_sleep(10000); - sprintf(msg_to_skype, "ALTER CALL %s ANSWER", id); - skypiax_skype_write(p, msg_to_skype); - if (option_debug) - DEBUGA_SKYPE("We answered a Skype RING on skype_call %s\n", - SKYPIAX_P_LOG, id); - strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1); - } else { - /* we're owned, we're in a call, let's refuse */ - sprintf(msg_to_skype, "SET CALL %s STATUS FINISHED", id); - skypiax_skype_write(p, msg_to_skype); - switch_sleep(10000); - DEBUGA_SKYPE - ("We have NOT answered a Skype RING on skype_call %s, because we are already in a skypiax call\n", - SKYPIAX_P_LOG, id); - - } - } else { - /* we are calling out */ - p->skype_callflow = CALLFLOW_STATUS_RINGING; - p->interface_state = SKYPIAX_STATE_RINGING; - //FIXME ast_queue_control(p->owner, SKYPIAX_CONTROL_RINGING); - strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1); - DEBUGA_SKYPE("Our remote party in skype_call %s is RINGING\n", - SKYPIAX_P_LOG, id); - } - } else if (!strcasecmp(value, "EARLYMEDIA")) { - p->skype_callflow = CALLFLOW_STATUS_EARLYMEDIA; - p->interface_state = SKYPIAX_STATE_DIALING; - //FIXME ast_queue_control(p->owner, SKYPIAX_CONTROL_RINGING); - DEBUGA_SKYPE("Our remote party in skype_call %s is EARLYMEDIA\n", - SKYPIAX_P_LOG, id); - } else if (!strcasecmp(value, "MISSED")) { - DEBUGA_SKYPE("We missed skype_call %s\n", SKYPIAX_P_LOG, id); - - } else if (!strcasecmp(value, "FINISHED")) { - global_session = NULL; //FIXME - //p->skype_callflow = CALLFLOW_STATUS_FINISHED; - if (option_debug) - DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id); - p->skype_call_id[0] = '\0'; - - if (p->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } - //p->interface_state = SKYPIAX_STATE_DOWN; - return CALLFLOW_INCOMING_HANGUP; - } else { - p->interface_state = SKYPIAX_STATE_DOWN; - } - - } else if (!strcasecmp(value, "CANCELLED")) { - p->skype_callflow = CALLFLOW_STATUS_CANCELLED; - if (option_debug) - DEBUGA_SKYPE - ("we tried to call Skype on skype_call %s and Skype has now CANCELLED\n", - SKYPIAX_P_LOG, id); - p->skype_call_id[0] = '\0'; - - if (p->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } - p->interface_state = SKYPIAX_STATE_DOWN; - return CALLFLOW_INCOMING_HANGUP; - } else { - p->interface_state = SKYPIAX_STATE_DOWN; - } - } else if (!strcasecmp(value, "FAILED")) { - p->skype_callflow = CALLFLOW_STATUS_FAILED; - if (option_debug) - DEBUGA_SKYPE - ("we tried to call Skype on skype_call %s and Skype has now FAILED\n", - SKYPIAX_P_LOG, id); - p->skype_call_id[0] = '\0'; - strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1); - p->interface_state = SKYPIAX_STATE_DOWN; - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } - return CALLFLOW_INCOMING_HANGUP; - } else if (!strcasecmp(value, "REFUSED")) { - if (!strcasecmp(id, p->skype_call_id)) { - /* this is the id of the call we are in, probably we generated it */ - p->skype_callflow = CALLFLOW_STATUS_REFUSED; - if (option_debug) - DEBUGA_SKYPE - ("we tried to call Skype on skype_call %s and Skype has now REFUSED\n", - SKYPIAX_P_LOG, id); - strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1); - p->interface_state = SKYPIAX_STATE_DOWN; - p->skype_call_id[0] = '\0'; - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } - return CALLFLOW_INCOMING_HANGUP; - } else { - /* we're here because were us that refused an incoming call */ - DEBUGA_SKYPE("we REFUSED skype_call %s\n", SKYPIAX_P_LOG, id); - - } - } else if (!strcasecmp(value, "ROUTING")) { - p->skype_callflow = CALLFLOW_STATUS_ROUTING; - p->interface_state = SKYPIAX_STATE_DIALING; - strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1); - DEBUGA_SKYPE("skype_call: %s is now ROUTING\n", SKYPIAX_P_LOG, id); - } else if (!strcasecmp(value, "UNPLACED")) { - p->skype_callflow = CALLFLOW_STATUS_UNPLACED; - p->interface_state = SKYPIAX_STATE_DIALING; - strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1); - DEBUGA_SKYPE("skype_call: %s is now UNPLACED\n", SKYPIAX_P_LOG, id); - } else if (!strcasecmp(value, "INPROGRESS")) { - p->skype_callflow = CALLFLOW_STATUS_INPROGRESS; - strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1); - p->interface_state = SKYPIAX_STATE_UP; - if (option_debug > 1) - DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id); - - if (option_debug > 1) - DEBUGA_SKYPE("skype_call: %s SKYPIAX_CONTROL_ANSWER sent\n", - SKYPIAX_P_LOG, id); - - if (1) { - char msg_to_skype[1024]; - - if (1) { - switch_threadattr_t *thd_attr = NULL; - - switch_threadattr_create(&thd_attr, module_pool); - switch_threadattr_detach_set(thd_attr, 1); - switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); - switch_thread_create(&p->tcp_srv_thread, thd_attr, - skypiax_do_tcp_srv_thread, p, module_pool); - DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG); - - switch_threadattr_create(&thd_attr, module_pool); - switch_threadattr_detach_set(thd_attr, 1); - switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); - switch_thread_create(&p->tcp_cli_thread, thd_attr, - skypiax_do_tcp_cli_thread, p, module_pool); - DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG); - } - switch_sleep(100000); - sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"5556\"", id); - skypiax_skype_write(p, msg_to_skype); - switch_sleep(100000); - sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"5558\"", id); - skypiax_skype_write(p, msg_to_skype); - switch_sleep(100000); - } - - p->skype_callflow = SKYPIAX_STATE_UP; - - /**************************/ - - //FIXME switch_core_session_t **new_session; - - //FIXME *new_session=switch_loadable_module_create_interface(skypiax_endpoint_interface, pool); - - if (!global_session) { //FIXME FIXME FIXME - switch_core_session_t *session = NULL; - private_t *tech_pvt = NULL; - switch_channel_t *channel = NULL; - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, - "New Inbound Channel!\n"); - - if ((session = - switch_core_session_request(skypiax_endpoint_interface, - NULL)) != 0) { - switch_core_session_add_stream(session, NULL); - if ((tech_pvt = - (private_t *) switch_core_session_alloc(session, - sizeof(private_t))) != 0) { - channel = switch_core_session_get_channel(session); - tech_init(tech_pvt, session, p); - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, - "Hey where is my memory pool?\n"); - switch_core_session_destroy(&session); - break; - } - - // if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session), NULL, dialplan, cid_name, cid_num, ip, NULL, NULL, NULL, modname, NULL, dest)) != 0) - - if ((tech_pvt->caller_profile = - switch_caller_profile_new(switch_core_session_get_pool(session), - "skypiax", "XML", "gmaruzz_from_skype", - "calling_number", NULL, "calling_ani", - NULL, NULL, (char *) modname, "default", - "5000")) != 0) { - char name[128]; - switch_snprintf(name, sizeof(name), "skypiax/%s-%04x", - tech_pvt->caller_profile->destination_number, - rand() & 0xffff); - switch_channel_set_name(channel, name); - switch_channel_set_caller_profile(channel, tech_pvt->caller_profile); - } - switch_channel_set_state(channel, CS_INIT); - if (switch_core_session_thread_launch(session) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, - "Error spawning thread\n"); - switch_core_session_destroy(&session); - } - } - } else { - switch_core_session_t *session = NULL; - private_t *tech_pvt = NULL; - switch_channel_t *channel = NULL; - - tech_pvt = p->tech_pvt; - //session = tech_pvt->session; - session = global_session; - channel = switch_core_session_get_channel(session); - switch_channel_mark_pre_answered(channel); - - //switch_channel_set_state(channel, CS_EXECUTE); - - } - /**************************/ - - } else { - WARNINGA("skype_call: %s, STATUS: %s is not recognized\n", SKYPIAX_P_LOG, - id, value); - - } - } //STATUS - - } //CALL - - a = 0; - } //message end - } //read_from_pipe - - } - - if (option_debug > 100) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } - //DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - return 0; -} - int skypiax_skype_call(struct skypiax_interface *p, char *idest, int timeout, switch_core_session_t * session) { @@ -1874,7 +495,7 @@ (private_t *) switch_core_session_alloc(*new_session, sizeof(private_t))) != 0) { tech_pvt->p = &SKYPIAX_INTERFACES[2]; //FIXME channel = switch_core_session_get_channel(*new_session); - tech_init(tech_pvt, *new_session, NULL); + skypiax_tech_init(tech_pvt, *new_session, NULL); } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Hey where is my memory pool?\n"); @@ -1958,14 +579,13 @@ } -#endif // CONTROLDEV_THREAD static switch_status_t load_config(void) { char *cf = "skypiax.conf"; switch_xml_t cfg, xml, global_settings, param, interfaces, myinterface; - switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, module_pool); + switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, skypiax_module_pool); if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf); return SWITCH_STATUS_TERM; @@ -2149,11 +769,11 @@ switch_thread_t *thread; switch_threadattr_t *thd_attr = NULL; - switch_threadattr_create(&thd_attr, module_pool); + switch_threadattr_create(&thd_attr, skypiax_module_pool); switch_threadattr_detach_set(thd_attr, 1); switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); switch_thread_create(&thread, thd_attr, do_skype_thread, - &SKYPIAX_INTERFACES[interface_id], module_pool); + &SKYPIAX_INTERFACES[interface_id], skypiax_module_pool); } switch_sleep(100000); @@ -2161,11 +781,11 @@ switch_thread_t *thread; switch_threadattr_t *thd_attr = NULL; - switch_threadattr_create(&thd_attr, module_pool); + switch_threadattr_create(&thd_attr, skypiax_module_pool); switch_threadattr_detach_set(thd_attr, 1); switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); switch_thread_create(&thread, thd_attr, skypiax_do_controldev_thread, - &SKYPIAX_INTERFACES[interface_id], module_pool); + &SKYPIAX_INTERFACES[interface_id], skypiax_module_pool); } switch_sleep(1000000); @@ -2214,7 +834,7 @@ { struct skypiax_interface *p = NULL; - module_pool = pool; + skypiax_module_pool = pool; memset(&globals, '\0', sizeof(globals)); memset(SKYPIAX_INTERFACES, '\0', sizeof(SKYPIAX_INTERFACES)); Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h ============================================================================== --- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h (original) +++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h Tue Dec 9 05:52:03 2008 @@ -47,6 +47,23 @@ #define SKYPIAX_SVN_VERSION "SVN 123456" +typedef enum { + TFLAG_IO = (1 << 0), + TFLAG_INBOUND = (1 << 1), + TFLAG_OUTBOUND = (1 << 2), + TFLAG_DTMF = (1 << 3), + TFLAG_VOICE = (1 << 4), + TFLAG_HANGUP = (1 << 5), + TFLAG_LINEAR = (1 << 6), + TFLAG_CODEC = (1 << 7), + TFLAG_BREAK = (1 << 8) +} TFLAGS; + +typedef enum { + GFLAG_MY_CODEC_PREFS = (1 << 0) +} GFLAGS; + + #define DEBUGA_SKYPE(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_SKYPE %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); #define DEBUGA_CALL(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_CALL %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); #define DEBUGA_PBX(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_PBX %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); @@ -193,3 +210,9 @@ typedef struct private_object private_t; +void *SWITCH_THREAD_FUNC do_skype_thread(switch_thread_t * thread, void *obj); +void skypiax_tech_init(private_t * tech_pvt, switch_core_session_t * session, skypiax_interface_t * p); +switch_status_t skypiax_skypeaudio_read(private_t * tech_pvt); +int skypiax_skypeaudio_init(struct skypiax_interface *p); +int skypiax_skype_write(struct skypiax_interface *p, char *msg_to_skype); +int skypiax_skype_read(struct skypiax_interface *p); Added: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c ============================================================================== --- (empty file) +++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c Tue Dec 9 05:52:03 2008 @@ -0,0 +1,1351 @@ +#include "skypiax.h" +extern switch_memory_pool_t *skypiax_module_pool; +extern int option_debug; +extern switch_core_session_t *global_session; +extern switch_endpoint_interface_t *skypiax_endpoint_interface; + +#define SKYPE_AUDIO +#ifdef SKYPE_AUDIO + +#define SAMPLES_PER_FRAME 160 +#define NN 160 +#define GG 160 +static void *SWITCH_THREAD_FUNC skypiax_do_tcp_srv_thread(switch_thread_t * thread, + void *obj) +{ + struct skypiax_interface *p = obj; + short in[GG]; + short out[GG / 2]; + int s, fd, len; + unsigned int sin_size; + struct sockaddr_in my_addr; + struct sockaddr_in remote_addr; + int exit = 0; + int a; + int i; + unsigned int kill_cli_size; + short kill_cli_buff[320]; + + if (option_debug > 10) { + WARNINGA("ENTERING FUNC\n", SKYPIAX_P_LOG); + } + memset(&my_addr, 0, sizeof(my_addr)); + my_addr.sin_family = AF_INET; + my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */ + my_addr.sin_port = htons(5556); //FIXME configurable! + + if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) { + ERRORA("socket Error\n", SKYPIAX_P_LOG); + if (option_debug > 10) { + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + } + return NULL; + } + + if (bind(s, (struct sockaddr *) &my_addr, sizeof(struct sockaddr)) < 0) { + ERRORA("bind Error\n", SKYPIAX_P_LOG); + if (option_debug > 10) { + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + } + return NULL; + } + DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG); + + listen(s, 6); + + sin_size = sizeof(remote_addr); + while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) { + DEBUGA_SKYPE("ACCEPTED\n", SKYPIAX_P_LOG); + while (p->interface_state != SKYPIAX_STATE_DOWN + && (p->skype_callflow == CALLFLOW_STATUS_INPROGRESS + || p->skype_callflow == SKYPIAX_STATE_UP)) { + + int fdselect; + int rt; + fd_set fs; + struct timeval to; + + exit = 1; + + fdselect = fd; + FD_ZERO(&fs); + FD_SET(fdselect, &fs); + to.tv_usec = 100; + to.tv_sec = 0; + rt = select(fdselect + 1, &fs, NULL, NULL, &to); + if (rt > 0) { + + len = recv(fd, in, sizeof(short) * GG, 0); + //DEBUGA_SKYPE("recv %d\n", SKYPIAX_P_LOG, len); + if (len > 0) { + a = 0; + for (i = 0; i < len / sizeof(short); i++) { + out[a] = in[i]; + i++; + a++; + } + + if (!p->audiobuf_is_loaded) { + for (i = 0; i < (len / sizeof(short)) / 2; i++) { + p->audiobuf[i] = out[i]; + } + p->audiobuf_is_loaded = 1; + } else { + unsigned int howmany; + short totalbuf[GG]; + + howmany = len / 2 / 2; + for (i = 0; i < howmany; i++) + totalbuf[i] = p->audiobuf[i]; + + howmany = len / 2 / 2; + for (a = 0; a < howmany; a++) { + totalbuf[i] = out[a]; + i++; + } + + howmany = len; + + switch_file_write(p->audiopipe[1], totalbuf, &howmany); + p->audiobuf_is_loaded = 0; + //DEBUGA_SKYPE("read=====> req=%d recv=%d to sent=%d sent=%d\n", SKYPIAX_P_LOG, sizeof(short)*GG, len, (len*sizeof(short))/2, howmany); + } + + } else if (len == 0) { + DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG); + break; + } else { + ERRORA("len=%d\n", SKYPIAX_P_LOG, len); + exit = 1; + break; + } + } + } + + kill_cli_size = 320; + switch_file_write(p->audiopipe[1], kill_cli_buff, &kill_cli_size); + kill_cli_size = 320; + switch_file_write(p->audioskypepipe[1], kill_cli_buff, &kill_cli_size); + p->interface_state = SKYPIAX_STATE_DOWN; + kill_cli_size = 320; + switch_file_write(p->audiopipe[1], kill_cli_buff, &kill_cli_size); + kill_cli_size = 320; + switch_file_write(p->audioskypepipe[1], kill_cli_buff, &kill_cli_size); + + DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG); + +#ifndef WIN32 + close(fd); +#else + closesocket(fd); +#endif + if (exit) + break; + } + + WARNINGA("server (I am it) GONE\n", SKYPIAX_P_LOG); +#ifndef WIN32 + close(s); +#else + closesocket(s); +#endif + if (option_debug > 10) { + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + } + return NULL; +} +static void *SWITCH_THREAD_FUNC skypiax_do_tcp_cli_thread(switch_thread_t * thread, + void *obj) +//void *skypiax_do_tcp_cli_thread(void *data) +{ + struct skypiax_interface *p = obj; + int s, fd, len; + short in[NN / 2]; + short out[NN]; + unsigned int sin_size; + struct sockaddr_in my_addr; + struct sockaddr_in remote_addr; + int a; + int i; + unsigned int got; + + if (option_debug > 10) { + WARNINGA("ENTERING FUNC\n", SKYPIAX_P_LOG); + } + memset(&my_addr, 0, sizeof(my_addr)); + my_addr.sin_family = AF_INET; + my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */ + my_addr.sin_port = htons(5558); //FIXME configurable! + + if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) { + ERRORA("socket Error\n", SKYPIAX_P_LOG); + if (option_debug > 10) { + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + } + return NULL; + } + + if (bind(s, (struct sockaddr *) &my_addr, sizeof(struct sockaddr)) < 0) { + ERRORA("bind Error\n", SKYPIAX_P_LOG); + if (option_debug > 10) { + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + } +#ifndef WIN32 + close(s); +#else + closesocket(s); +#endif + return NULL; + } + DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG); + + listen(s, 6); + + sin_size = sizeof(remote_addr); + while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) { + DEBUGA_SKYPE("ACCEPTED\n", SKYPIAX_P_LOG); + while (p->interface_state != SKYPIAX_STATE_DOWN + && (p->skype_callflow == CALLFLOW_STATUS_INPROGRESS + || p->skype_callflow == SKYPIAX_STATE_UP)) { + int fdselect; + int rt; + fd_set fs; + struct timeval to; + + fdselect = 1; + FD_ZERO(&fs); + FD_SET(fdselect, &fs); + to.tv_usec = 100; + to.tv_sec = 0; + rt = 1; + if (rt > 0) { + + got = (NN / 2) * sizeof(short); + switch_file_read(p->audioskypepipe[0], in, &got); + + if (got > 0) { + a = 0; + for (i = 0; i < got / sizeof(short); i++) { + out[a] = in[i]; + a++; + out[a] = in[i]; + a++; + } + + len = send(fd, out, got * 2, 0); + + if (len == 0) { + ERRORA("Skype server GONE\n", SKYPIAX_P_LOG); + break; + } + } else { + switch_sleep(1000); + //ERRORA("Audio skype pipe give us: %u\n", SKYPIAX_P_LOG, got); + } + } + + } + ERRORA("Skype server GONE\n", SKYPIAX_P_LOG); +#ifndef WIN32 + close(fd); +#else + closesocket(fd); +#endif + break; + } + + WARNINGA("client (I am it) GONE\n", SKYPIAX_P_LOG); +#ifndef WIN32 + close(s); +#else + closesocket(s); +#endif + if (option_debug > 10) { + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + } + return NULL; +} + +int skypiax_skypeaudio_init(struct skypiax_interface *p) +{ + + switch_status_t rv; + + rv = switch_file_pipe_create_ex(&p->audiopipe[0], &p->audiopipe[1], 2, skypiax_module_pool); + rv = switch_file_pipe_timeout_set(p->audiopipe[0], 100000); + +/* the pipe is our audio fd for pbx to poll on */ + p->skypiax_sound_capt_fd = p->audiopipe[0]; + + rv = + switch_file_pipe_create_ex(&p->audioskypepipe[0], &p->audioskypepipe[1], 2, + skypiax_module_pool); + rv = switch_file_pipe_timeout_set(p->audioskypepipe[0], 100); + if (option_debug > 10) { + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + } + return 0; +} +switch_status_t skypiax_skypeaudio_read(private_t * tech_pvt) +{ + struct skypiax_interface *p; + short buf[640]; + unsigned int samples; + int rt; + + p = tech_pvt->p; + + //DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); + + memset(buf, '\0', sizeof(buf)); + + rt = 1; + if (rt > 0) { + + samples = SAMPLES_PER_FRAME * sizeof(short); + + switch_file_read(p->audiopipe[0], tech_pvt->read_frame.data, &samples); + + //if ((samples = read(p->audiopipe[0], buf, SAMPLES_PER_FRAME * sizeof(short))) != 320) + if (samples != SAMPLES_PER_FRAME * sizeof(short)) { + if (samples) + DEBUGA_SKYPE("read=====> NOT GOOD samples=%d expected=%d\n", SKYPIAX_P_LOG, + samples, SAMPLES_PER_FRAME * sizeof(short)); + //do nothing + } else { + tech_pvt->read_frame.datalen = samples; + //DEBUGA_SKYPE("read=====> GOOD samples=%d\n", SKYPIAX_P_LOG, samples); + /* A real frame */ + } + } else { + DEBUGA_SKYPE("select returned %d\n", SKYPIAX_P_LOG, rt); + + } + + //DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + + return SWITCH_STATUS_SUCCESS; +} + +#endif /* SKYPE_AUDIO */ + +#ifdef WIN32 +struct AsteriskHandles *win32_AsteriskHandlesSkype; +HWND win32_hInit_MainWindowHandle; +HINSTANCE win32_hInit_ProcessHandle; +char win32_acInit_WindowClassName[128]; +HANDLE win32_hGlobal_ThreadShutdownEvent; +UINT win32_uiGlobal_MsgID_SkypeControlAPIAttach; +UINT win32_uiGlobal_MsgID_SkypeControlAPIDiscover; +HWND win32_hGlobal_SkypeAPIWindowHandle = NULL; +DWORD win32_ulGlobal_PromptConsoleMode = 0; +HANDLE volatile win32_hGlobal_PromptConsoleHandle = NULL; + +enum { + SKYPECONTROLAPI_ATTACH_SUCCESS = 0, /* Client is successfully + attached and API window handle can be found + in wParam parameter */ + SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION = 1, /* Skype has acknowledged + connection request and is waiting + for confirmation from the user. */ + /* The client is not yet attached + * and should wait for SKYPECONTROLAPI_ATTACH_SUCCESS message */ + SKYPECONTROLAPI_ATTACH_REFUSED = 2, /* User has explicitly + denied access to client */ + SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE = 3, /* API is not available + at the moment. + For example, this happens when no user + is currently logged in. */ + /* Client should wait for + * SKYPECONTROLAPI_ATTACH_API_AVAILABLE + * broadcast before making any further */ + /* connection attempts. */ + SKYPECONTROLAPI_ATTACH_API_AVAILABLE = 0x8001 +}; + +char + *strsep(char **stringp, const char *delim) +{ + char *res; + + if (!stringp || !*stringp || !**stringp) + return (char *) 0; + + res = *stringp; + while (**stringp && !strchr(delim, **stringp)) + ++(*stringp); + + if (**stringp) { + **stringp = '\0'; + ++(*stringp); + } + + return res; +} + +LRESULT APIENTRY skypiax_skype_present(HWND hWindow, UINT uiMessage, WPARAM uiParam, + LPARAM ulParam) +{ + LRESULT lReturnCode; + int fIssueDefProc; + struct skypiax_interface *p = NULL; + + lReturnCode = 0; + fIssueDefProc = 0; + switch (uiMessage) { + case WM_DESTROY: + win32_hInit_MainWindowHandle = NULL; + PostQuitMessage(0); + break; + case WM_COPYDATA: + if (win32_hGlobal_SkypeAPIWindowHandle == (HWND) uiParam) { + unsigned int howmany; + char msg_from_skype[2048]; + + PCOPYDATASTRUCT poCopyData = (PCOPYDATASTRUCT) ulParam; + + memset(msg_from_skype, '\0', sizeof(msg_from_skype)); + strncpy(msg_from_skype, (const char *) poCopyData->lpData, + sizeof(msg_from_skype) - 2); + + howmany = strlen(msg_from_skype) + 1; + switch_file_write(win32_AsteriskHandlesSkype->fdesc[1], msg_from_skype, &howmany); + //NOTICA("From Skype API: %s\n", SKYPIAX_P_LOG, (const char *) poCopyData->lpData); + lReturnCode = 1; + } + break; + default: + if (uiMessage == win32_uiGlobal_MsgID_SkypeControlAPIAttach) { + switch (ulParam) { + case SKYPECONTROLAPI_ATTACH_SUCCESS: + NOTICA("\n\n\tConnected to Skype API!\n", SKYPIAX_P_LOG); + win32_hGlobal_SkypeAPIWindowHandle = (HWND) uiParam; + switch_sleep(5000); + win32_AsteriskHandlesSkype->win32_hGlobal_SkypeAPIWindowHandle = + win32_hGlobal_SkypeAPIWindowHandle; + break; + case SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION: + WARNINGA + ("\n\n\tIf I do not immediately connect to Skype API,\n\tplease give the Skype client authorization to be connected \n\tby Asterisk and to not ask you again.\n\n", + SKYPIAX_P_LOG); + break; + case SKYPECONTROLAPI_ATTACH_REFUSED: + ERRORA("Skype client refused to be connected by Skypiax!\n", SKYPIAX_P_LOG); + break; + case SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE: + ERRORA("Skype API not available\n", SKYPIAX_P_LOG); + break; + case SKYPECONTROLAPI_ATTACH_API_AVAILABLE: + DEBUGA_SKYPE("Skype API available\n", SKYPIAX_P_LOG); + break; + default: + WARNINGA("GOT AN UNKNOWN SKYPE WINDOWS MSG\n", SKYPIAX_P_LOG); + } + lReturnCode = 1; + break; + } + fIssueDefProc = 1; + break; + } + if (fIssueDefProc) + lReturnCode = DefWindowProc(hWindow, uiMessage, uiParam, ulParam); + return (lReturnCode); +} + +int win32_Initialize_CreateWindowClass(void) +{ + unsigned char *paucUUIDString; + RPC_STATUS lUUIDResult; + int fReturnStatus; + UUID oUUID; + + fReturnStatus = 0; + lUUIDResult = UuidCreate(&oUUID); + win32_hInit_ProcessHandle = + (HINSTANCE) OpenProcess(PROCESS_DUP_HANDLE, FALSE, GetCurrentProcessId()); + if (win32_hInit_ProcessHandle != NULL + && (lUUIDResult == RPC_S_OK || lUUIDResult == RPC_S_UUID_LOCAL_ONLY)) { + if (UuidToString(&oUUID, &paucUUIDString) == RPC_S_OK) { + WNDCLASS oWindowClass; + + strcpy(win32_acInit_WindowClassName, "Skype-API-Skypiax-"); + strcat(win32_acInit_WindowClassName, (char *) paucUUIDString); + + oWindowClass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; + oWindowClass.lpfnWndProc = (WNDPROC) & skypiax_skype_present; + oWindowClass.cbClsExtra = 0; + oWindowClass.cbWndExtra = 0; + oWindowClass.hInstance = win32_hInit_ProcessHandle; + oWindowClass.hIcon = NULL; + oWindowClass.hCursor = NULL; + oWindowClass.hbrBackground = NULL; + oWindowClass.lpszMenuName = NULL; + oWindowClass.lpszClassName = win32_acInit_WindowClassName; + + if (RegisterClass(&oWindowClass) != 0) + fReturnStatus = 1; + + RpcStringFree(&paucUUIDString); + } + } + if (fReturnStatus == 0) + CloseHandle(win32_hInit_ProcessHandle), win32_hInit_ProcessHandle = NULL; + return (fReturnStatus); +} + +void win32_DeInitialize_DestroyWindowClass(void) +{ + UnregisterClass(win32_acInit_WindowClassName, win32_hInit_ProcessHandle); + CloseHandle(win32_hInit_ProcessHandle), win32_hInit_ProcessHandle = NULL; +} + +int win32_Initialize_CreateMainWindow(void) +{ + win32_hInit_MainWindowHandle = + CreateWindowEx(WS_EX_APPWINDOW | WS_EX_WINDOWEDGE, win32_acInit_WindowClassName, "", + WS_BORDER | WS_SYSMENU | WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, + 128, 128, NULL, 0, win32_hInit_ProcessHandle, 0); + return (win32_hInit_MainWindowHandle != NULL ? 1 : 0); +} + +void win32_DeInitialize_DestroyMainWindow(void) +{ + if (win32_hInit_MainWindowHandle != NULL) + DestroyWindow(win32_hInit_MainWindowHandle), win32_hInit_MainWindowHandle = NULL; +} + +DWORD win32_dwThreadId; + +void *SWITCH_THREAD_FUNC do_skype_thread(switch_thread_t * thread, void *obj) +{ + /* create window class */ + /* create dummy/hidden window for processing messages */ + /* run message loop thread */ + /* do application control until exit */ + /* exit: send QUIT message to our own window */ + /* wait until thred terminates */ + /* destroy main window */ + /* destroy window class */ + + struct skypiax_interface *p; + p = obj; + + switch_file_pipe_create_ex(&p->AsteriskHandlesAst.fdesc[0], + &p->AsteriskHandlesAst.fdesc[1], 2, skypiax_module_pool); + + win32_AsteriskHandlesSkype = &p->AsteriskHandlesAst; + + win32_uiGlobal_MsgID_SkypeControlAPIAttach = + RegisterWindowMessage("SkypeControlAPIAttach"); + win32_uiGlobal_MsgID_SkypeControlAPIDiscover = + RegisterWindowMessage("SkypeControlAPIDiscover"); + + if (win32_uiGlobal_MsgID_SkypeControlAPIAttach != 0 + && win32_uiGlobal_MsgID_SkypeControlAPIDiscover != 0) { + if (win32_Initialize_CreateWindowClass()) { + if (win32_Initialize_CreateMainWindow()) { + win32_hGlobal_ThreadShutdownEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + if (win32_hGlobal_ThreadShutdownEvent != NULL) { + if (SendMessage + (HWND_BROADCAST, win32_uiGlobal_MsgID_SkypeControlAPIDiscover, + (WPARAM) win32_hInit_MainWindowHandle, 0) != 0) { + win32_AsteriskHandlesSkype->win32_hInit_MainWindowHandle = + win32_hInit_MainWindowHandle; + while (1) { + MSG oMessage; + + while (GetMessage(&oMessage, 0, 0, 0) != FALSE) { + TranslateMessage(&oMessage); + DispatchMessage(&oMessage); + } + } + } + CloseHandle(win32_hGlobal_ThreadShutdownEvent); + } + win32_DeInitialize_DestroyMainWindow(); + } + win32_DeInitialize_DestroyWindowClass(); + } + } + return NULL; +} + +#else /* NOT WIN32 */ + +#define SKYPE_X11_BUF_SIZE 512 +Window skype_win = (Window) - 1; +static XErrorHandler old_handler = 0; +static int xerror = 0; + +int X11_errors_handler(Display * dpy, XErrorEvent * err) +{ + (void) dpy; + struct skypiax_interface *p = NULL; + + xerror = err->error_code; + DEBUGA_SKYPE("Received error code %d from X Server\n", SKYPIAX_P_LOG, xerror); + return 0; /* ignore the error */ +} + +static void X11_errors_trap(void) +{ + xerror = 0; + old_handler = XSetErrorHandler(X11_errors_handler); +} + +static int X11_errors_untrap(void) +{ + XSetErrorHandler(old_handler); + return (xerror != BadValue) && (xerror != BadWindow); +} + +int skypiax_skype_send_message(struct AsteriskHandles *AsteriskHandlesAst, + const char *message_P) +{ + + Window w_P; + Display *disp; + Window handle_P; + struct skypiax_interface *p = NULL; + + w_P = AsteriskHandlesAst->skype_win; + disp = AsteriskHandlesAst->disp; + handle_P = AsteriskHandlesAst->win; + + Atom atom1 = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", False); + Atom atom2 = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE", False); + unsigned int pos = 0; + unsigned int len = strlen(message_P); + XEvent e; + int ok; + + memset(&e, 0, sizeof(e)); + e.xclient.type = ClientMessage; + e.xclient.message_type = atom1; /* leading message */ + e.xclient.display = disp; + e.xclient.window = handle_P; + e.xclient.format = 8; + + X11_errors_trap(); + //XLockDisplay(disp); + do { + unsigned int i; + for (i = 0; i < 20 && i + pos <= len; ++i) + e.xclient.data.b[i] = message_P[i + pos]; + XSendEvent(disp, w_P, False, 0, &e); + + e.xclient.message_type = atom2; /* following messages */ + pos += i; + } while (pos <= len); + + XSync(disp, False); + //XUnlockDisplay(disp); + ok = X11_errors_untrap(); + + if (!ok) + DEBUGA_SKYPE("Sending message failed with status %d\n", SKYPIAX_P_LOG, xerror); + + return ok; +} + +int skypiax_skype_present(Display * disp) +{ + Atom skype_inst = XInternAtom(disp, "_SKYPE_INSTANCE", True); + + Atom type_ret; + int format_ret; + unsigned long nitems_ret; + unsigned long bytes_after_ret; + unsigned char *prop; + int status; + struct skypiax_interface *p = NULL; + + X11_errors_trap(); + //XLockDisplay(disp); + status = + XGetWindowProperty(disp, DefaultRootWindow(disp), skype_inst, 0, 1, False, XA_WINDOW, + &type_ret, &format_ret, &nitems_ret, &bytes_after_ret, &prop); + //XUnlockDisplay(disp); + X11_errors_untrap(); + + /* sanity check */ + if (status != Success || format_ret != 32 || nitems_ret != 1) { + skype_win = (Window) - 1; + DEBUGA_SKYPE("Skype instance not found\n", SKYPIAX_P_LOG); + return 0; + } + + skype_win = *(const unsigned long *) prop & 0xffffffff; + //DEBUGA_SKYPE("Skype instance found with id #%x\n", SKYPIAX_P_LOG, + DEBUGA_SKYPE("Skype instance found with id #%d\n", SKYPIAX_P_LOG, + (unsigned int) skype_win); + return 1; +} + +void skypiax_skype_clean_disp(void *data) +{ + + int *dispptr; + int disp; + struct skypiax_interface *p = NULL; + + dispptr = data; + disp = *dispptr; + + if (disp) { + DEBUGA_SKYPE("to be destroyed disp %d\n", SKYPIAX_P_LOG, disp); + close(disp); + DEBUGA_SKYPE("destroyed disp\n", SKYPIAX_P_LOG); + } else { + DEBUGA_SKYPE("NOT destroyed disp\n", SKYPIAX_P_LOG); + } + DEBUGA_SKYPE("OUT destroyed disp\n", SKYPIAX_P_LOG); + switch_sleep(1000); +} + +static void *SWITCH_THREAD_FUNC do_skype_thread(switch_thread_t * thread, void *obj) +{ + + struct skypiax_interface *p; + struct AsteriskHandles *AsteriskHandlesAst; + char buf[SKYPE_X11_BUF_SIZE]; + Display *disp = NULL; + Window root = -1; + Window win = -1; + + p = obj; + DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); + + switch_file_pipe_create_ex(&p->AsteriskHandlesAst.fdesc[0], + &p->AsteriskHandlesAst.fdesc[1], 2, skypiax_module_pool); + + AsteriskHandlesAst = &p->AsteriskHandlesAst; + //disp = XOpenDisplay(getenv("DISPLAY")); + disp = XOpenDisplay(p->X11_display); + if (!disp) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, + "Cannot open X Display '%s', exiting skype thread\n", + p->X11_display); + return NULL; + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "X Display '%s' opened\n", + p->X11_display); + } + + int xfd; + xfd = XConnectionNumber(disp); + fcntl(xfd, F_SETFD, FD_CLOEXEC); + + //FIXME pthread_cleanup_push(skypiax_skype_clean_disp, &xfd); + DEBUGA_SKYPE("PUSH disp %d\n", SKYPIAX_P_LOG, xfd); + + if (skypiax_skype_present(disp)) { + root = DefaultRootWindow(disp); + win = + XCreateSimpleWindow(disp, root, 0, 0, 1, 1, 0, + BlackPixel(disp, DefaultScreen(disp)), BlackPixel(disp, + DefaultScreen + (disp))); + + DEBUGA_SKYPE("skype_win=%d win=%d\n", SKYPIAX_P_LOG, (unsigned int) skype_win, + (unsigned int) win); + + AsteriskHandlesAst->skype_win = skype_win; + AsteriskHandlesAst->disp = disp; + AsteriskHandlesAst->win = win; + + snprintf(buf, SKYPE_X11_BUF_SIZE, "NAME skypiax"); + + if (!skypiax_skype_send_message(AsteriskHandlesAst, buf)) { + ERRORA + ("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypiax again\n", + SKYPIAX_P_LOG); + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + return NULL; + } + + snprintf(buf, SKYPE_X11_BUF_SIZE, "PROTOCOL 6"); + if (!skypiax_skype_send_message(AsteriskHandlesAst, buf)) { + ERRORA + ("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypiax again\n", + SKYPIAX_P_LOG); + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + return NULL; + } + + /* perform an events loop */ + XEvent an_event; + char buf[21]; /* can't be longer */ + char buffer[17000]; + char *b; + int i; + + b = buffer; + + while (1) { + XNextEvent(disp, &an_event); + switch (an_event.type) { + case ClientMessage: + + if (an_event.xclient.format != 8) + break; + + for (i = 0; i < 20 && an_event.xclient.data.b[i] != '\0'; ++i) + buf[i] = an_event.xclient.data.b[i]; + + buf[i] = '\0'; + + //NOTICA("ClientMessage buf:|||%s||| buffer:|||%s||| serial=%ld|||\r\n",SKYPIAX_P_LOG,buf, buffer,an_event.xclient.serial); + //NOTICA ("SKYPE read: |||%s|||%d\n", SKYPIAX_P_LOG, buf, strlen(buf)); + //NOTICA ("SKYPE buffer: |||%s|||%d\n", SKYPIAX_P_LOG, buffer, strlen(buffer)); + + strcat(buffer, buf); + + if (i < 20) { /* last fragment */ + unsigned int howmany; + + howmany = strlen(b) + 1; + + switch_file_write(AsteriskHandlesAst->fdesc[1], b, &howmany); + //write(AsteriskHandlesAst->fdesc[1], "\0", 1); + //FIXME DEBUGA_SKYPE("SKYPE pipewrite: |||%s|||len=%d serial=%ld\n\n\n", SKYPIAX_P_LOG, b, strlen(b) + 1, an_event.xclient.serial); + //switch_sleep(1000); + memset(buffer, '\0', 17000); + } + + break; + default: + break; + } + } + } else { + ERRORA + ("Skype is not running, maybe crashed. Please run/restart Skype and relaunch Skypiax\n", + SKYPIAX_P_LOG); + return NULL; + } + //DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + return NULL; + +} +#endif // WIN32 + + +int skypiax_skype_write(struct skypiax_interface *p, char *msg_to_skype) +{ +#ifdef WIN32 + static char acInputRow[1024]; + COPYDATASTRUCT oCopyData; + + if (option_debug > 100) { + DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); + } + sprintf(acInputRow, "%s", msg_to_skype); + if (option_debug > 1) + DEBUGA_SKYPE("acInputRow: |||%s||||\n", SKYPIAX_P_LOG, acInputRow); + /* send command to skype */ + oCopyData.dwData = 0; + oCopyData.lpData = acInputRow; + oCopyData.cbData = strlen(acInputRow) + 1; + if (oCopyData.cbData != 1) { + if (SendMessage + (p->AsteriskHandlesAst.win32_hGlobal_SkypeAPIWindowHandle, WM_COPYDATA, + (WPARAM) p->AsteriskHandlesAst.win32_hInit_MainWindowHandle, + (LPARAM) & oCopyData) == FALSE) { + ERRORA + ("Sending message failed - probably Skype crashed.\n\nPlease shutdown Skypiax (Asterisk), then restart Skype from the menu, then launch Skypiax and try again.\n", + SKYPIAX_P_LOG); + p->skype = 0; + //FIXME p->skype_thread = SKYPIAX_PTHREADT_NULL; + p->skype_thread = NULL; + if (option_debug > 100) { + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + } + return -1; + } + } +#else /* WIN32 */ + struct AsteriskHandles *AsteriskHandlesAst; + + if (option_debug > 100) { + DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); + } + AsteriskHandlesAst = &p->AsteriskHandlesAst; + + if (option_debug > 101) { + DEBUGA_SKYPE("SENDING: |||%s||||\n", SKYPIAX_P_LOG, msg_to_skype); + } + + if (!skypiax_skype_send_message(AsteriskHandlesAst, msg_to_skype)) { + ERRORA + ("Sending message failed - probably Skype crashed.\n\nPlease shutdown Skypiax (Asterisk), then restart Skype from the menu, then launch Skypiax and try again.\n", + SKYPIAX_P_LOG); + if (option_debug > 100) { + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + } + return -1; + } +#endif /* WIN32 */ + + if (option_debug > 100) { + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + } + return 0; + +} + +int skypiax_skype_read(struct skypiax_interface *p) +{ + + char read_from_pipe[4096]; + char messaggio[4096]; + char messaggio_2[4096]; + char *buf, obj[512] = "", id[512] = "", prop[512] = "", value[512] = "", *where; + char **stringp = NULL; + //int fd; + int rt; + //fd_set fs; + //struct timeval to; + int i, a; + unsigned int howmany; + + if (option_debug > 100) { + DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); + } + + memset(read_from_pipe, 0, 4096); + memset(messaggio, 0, 4096); + memset(messaggio_2, 0, 4096); + + rt = 1; + if (rt > 0) { + howmany = sizeof(read_from_pipe); + switch_file_read(p->AsteriskHandlesAst.fdesc[0], read_from_pipe, &howmany); + + a = 0; + for (i = 0; i < howmany; i++) { + messaggio[a] = read_from_pipe[i]; + a++; + + if (read_from_pipe[i] == '\0') { + + //if (option_debug > 101) + DEBUGA_SKYPE("read_skype: howmany=%d, i=%d, a=%d, |||%s||| \n", SKYPIAX_P_LOG, + howmany, i, a, messaggio); + + if (!strncasecmp(messaggio, "ERROR 92 CALL", 12)) { + ERRORA("Skype got ERROR: |||%s|||, the number we called was not recognized\n", + SKYPIAX_P_LOG, messaggio); + p->skype_callflow = CALLFLOW_STATUS_FINISHED; + if (option_debug) + DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG); + p->skype_call_id[0] = '\0'; + + if (p->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { + if (option_debug > 100) { + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + } + p->interface_state = SKYPIAX_STATE_DOWN; + return CALLFLOW_INCOMING_HANGUP; + } else { + p->interface_state = SKYPIAX_STATE_DOWN; + } + } + + strncpy(messaggio_2, messaggio, sizeof(messaggio) - 1); + + buf = messaggio; + stringp = &buf; + where = strsep(stringp, " "); + if (!where) { + WARNINGA("Skype MSG without spaces: %s\n", SKYPIAX_P_LOG, messaggio); + } + + if (!strcasecmp(messaggio, "#333")) { + /* DEBUGA_SKYPE("Skype MSG: messaggio_2: %s, messaggio2[11]: %s\n", SKYPIAX_P_LOG, + * messaggio_2, &messaggio_2[11]); */ + memset(p->skype_friends, 0, 4096); + strncpy(p->skype_friends, &messaggio_2[11], 4095); + } + if (!strcasecmp(messaggio, "#222")) { + /* DEBUGA_SKYPE("Skype MSG: messaggio_2: %s, messaggio2[10]: %s\n", SKYPIAX_P_LOG, + * messaggio_2, &messaggio_2[10]); */ + memset(p->skype_fullname, 0, 512); + strncpy(p->skype_fullname, &messaggio_2[10], 511); + } + if (!strcasecmp(messaggio, "#765")) { + /* DEBUGA_SKYPE("Skype MSG: messaggio_2: %s, messaggio2[10]: %s\n", SKYPIAX_P_LOG, + * messaggio_2, &messaggio_2[10]); */ + memset(p->skype_displayname, 0, 512); + strncpy(p->skype_displayname, &messaggio_2[10], 511); + } + if (!strcasecmp(messaggio, "ERROR")) { + ERRORA("Skype got ERROR: |||%s|||\n", SKYPIAX_P_LOG, messaggio); + p->skype_callflow = CALLFLOW_STATUS_FINISHED; + if (option_debug) + DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPIAX_P_LOG); + p->skype_call_id[0] = '\0'; + + if (p->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { + if (option_debug > 100) { + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + } + p->interface_state = SKYPIAX_STATE_DOWN; + return CALLFLOW_INCOMING_HANGUP; + } else { + p->interface_state = SKYPIAX_STATE_DOWN; + } + } + if (!strcasecmp(messaggio, "CALL")) { + + strncpy(obj, where, sizeof(obj) - 1); + + where = strsep(stringp, " "); + + strncpy(id, where, sizeof(id) - 1); + + where = strsep(stringp, " "); + + strncpy(prop, where, sizeof(prop) - 1); + + where = strsep(stringp, " "); + + strncpy(value, where, sizeof(value) - 1); + + where = strsep(stringp, " "); + + if (option_debug > 101) + DEBUGA_SKYPE + ("Skype MSG: messaggio: %s, obj: %s, id: %s, prop: %s, value: %s,where: %s!\n", + SKYPIAX_P_LOG, messaggio, obj, id, prop, value, where ? where : "NULL"); + + if (!strcasecmp(prop, "PARTNER_HANDLE")) { + strncpy(p->callid_number, value, sizeof(p->callid_number) - 1); + WARNINGA + ("the skype_call %s caller PARTNER_HANDLE (p->callid_number) is: %s\n", + SKYPIAX_P_LOG, id, p->callid_number); + return CALLFLOW_INCOMING_RING; + } + if (!strcasecmp(prop, "PARTNER_DISPNAME")) { + snprintf(p->callid_name, sizeof(p->callid_name) - 1, "%s%s%s", value, + where ? " " : "", where ? where : ""); + WARNINGA + ("the skype_call %s caller PARTNER_DISPNAME (p->callid_name) is: %s\n", + SKYPIAX_P_LOG, id, p->callid_name); + } + if (!strcasecmp(prop, "CONF_ID") && !strcasecmp(value, "0")) { + DEBUGA_SKYPE("the skype_call %s is NOT a conference call\n", SKYPIAX_P_LOG, + id); + if (p->interface_state == SKYPIAX_STATE_DOWN) + p->interface_state = SKYPIAX_STATE_PRERING; + } + if (!strcasecmp(prop, "CONF_ID") && strcasecmp(value, "0")) { + DEBUGA_SKYPE("the skype_call %s is a conference call\n", SKYPIAX_P_LOG, id); + if (p->interface_state == SKYPIAX_STATE_DOWN) + p->interface_state = SKYPIAX_STATE_PRERING; + } + + if (!strcasecmp(prop, "DTMF")) { + switch_core_session_t *session = NULL; + private_t *tech_pvt = NULL; + switch_channel_t *channel = NULL; + + DEBUGA_SKYPE("Call %s received a DTMF: %s\n", SKYPIAX_P_LOG, id, value); + + tech_pvt = p->tech_pvt; + session = tech_pvt->session; + channel = switch_core_session_get_channel(session); + + if (channel) { + switch_dtmf_t dtmf = + { (char) value[0], switch_core_default_dtmf_duration(0) }; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%c DTMF %s\n", + dtmf.digit, switch_channel_get_name(channel)); + switch_mutex_lock(tech_pvt->flag_mutex); + switch_channel_queue_dtmf(channel, &dtmf); + switch_set_flag(tech_pvt, TFLAG_DTMF); + switch_mutex_unlock(tech_pvt->flag_mutex); + } + } + + if (!strcasecmp(prop, "FAILUREREASON")) { + DEBUGA_SKYPE + ("Skype has FAILED on skype_call %s. Let's wait for the FAILED message.\n", + SKYPIAX_P_LOG, id); + } + if (!strcasecmp(prop, "DURATION") && (!strcasecmp(value, "1"))) { + if (strcasecmp(id, p->skype_call_id)) { + strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1); + if (option_debug > 1) + DEBUGA_SKYPE + ("We called a Skype contact and he answered us on skype_call: %s.\n", + SKYPIAX_P_LOG, id); + } + } + + if (!strcasecmp(prop, "STATUS")) { + + if (!strcasecmp(value, "RINGING")) { + char msg_to_skype[1024]; + if (p->interface_state != SKYPIAX_STATE_DIALING) { + /* we are not calling out */ + + if (1) { + /* we are not inside an active call */ + p->skype_callflow = CALLFLOW_STATUS_RINGING; + p->interface_state = SKYPIAX_STATE_RING; + /* no owner, no active call, let's answer */ + skypiax_skype_write(p, "SET AGC OFF"); + switch_sleep(10000); + skypiax_skype_write(p, "SET AEC OFF"); + switch_sleep(10000); + sprintf(msg_to_skype, "GET CALL %s PARTNER_DISPNAME", id); + skypiax_skype_write(p, msg_to_skype); + switch_sleep(10000); + sprintf(msg_to_skype, "GET CALL %s PARTNER_HANDLE", id); + skypiax_skype_write(p, msg_to_skype); + switch_sleep(10000); + sprintf(msg_to_skype, "ALTER CALL %s ANSWER", id); + skypiax_skype_write(p, msg_to_skype); + if (option_debug) + DEBUGA_SKYPE("We answered a Skype RING on skype_call %s\n", + SKYPIAX_P_LOG, id); + strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1); + } else { + /* we're owned, we're in a call, let's refuse */ + sprintf(msg_to_skype, "SET CALL %s STATUS FINISHED", id); + skypiax_skype_write(p, msg_to_skype); + switch_sleep(10000); + DEBUGA_SKYPE + ("We have NOT answered a Skype RING on skype_call %s, because we are already in a skypiax call\n", + SKYPIAX_P_LOG, id); + + } + } else { + /* we are calling out */ + p->skype_callflow = CALLFLOW_STATUS_RINGING; + p->interface_state = SKYPIAX_STATE_RINGING; + //FIXME ast_queue_control(p->owner, SKYPIAX_CONTROL_RINGING); + strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1); + DEBUGA_SKYPE("Our remote party in skype_call %s is RINGING\n", + SKYPIAX_P_LOG, id); + } + } else if (!strcasecmp(value, "EARLYMEDIA")) { + p->skype_callflow = CALLFLOW_STATUS_EARLYMEDIA; + p->interface_state = SKYPIAX_STATE_DIALING; + //FIXME ast_queue_control(p->owner, SKYPIAX_CONTROL_RINGING); + DEBUGA_SKYPE("Our remote party in skype_call %s is EARLYMEDIA\n", + SKYPIAX_P_LOG, id); + } else if (!strcasecmp(value, "MISSED")) { + DEBUGA_SKYPE("We missed skype_call %s\n", SKYPIAX_P_LOG, id); + + } else if (!strcasecmp(value, "FINISHED")) { + global_session = NULL; //FIXME + //p->skype_callflow = CALLFLOW_STATUS_FINISHED; + if (option_debug) + DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id); + p->skype_call_id[0] = '\0'; + + if (p->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { + if (option_debug > 100) { + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + } + //p->interface_state = SKYPIAX_STATE_DOWN; + return CALLFLOW_INCOMING_HANGUP; + } else { + p->interface_state = SKYPIAX_STATE_DOWN; + } + + } else if (!strcasecmp(value, "CANCELLED")) { + p->skype_callflow = CALLFLOW_STATUS_CANCELLED; + if (option_debug) + DEBUGA_SKYPE + ("we tried to call Skype on skype_call %s and Skype has now CANCELLED\n", + SKYPIAX_P_LOG, id); + p->skype_call_id[0] = '\0'; + + if (p->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) { + if (option_debug > 100) { + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + } + p->interface_state = SKYPIAX_STATE_DOWN; + return CALLFLOW_INCOMING_HANGUP; + } else { + p->interface_state = SKYPIAX_STATE_DOWN; + } + } else if (!strcasecmp(value, "FAILED")) { + p->skype_callflow = CALLFLOW_STATUS_FAILED; + if (option_debug) + DEBUGA_SKYPE + ("we tried to call Skype on skype_call %s and Skype has now FAILED\n", + SKYPIAX_P_LOG, id); + p->skype_call_id[0] = '\0'; + strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1); + p->interface_state = SKYPIAX_STATE_DOWN; + if (option_debug > 100) { + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + } + return CALLFLOW_INCOMING_HANGUP; + } else if (!strcasecmp(value, "REFUSED")) { + if (!strcasecmp(id, p->skype_call_id)) { + /* this is the id of the call we are in, probably we generated it */ + p->skype_callflow = CALLFLOW_STATUS_REFUSED; + if (option_debug) + DEBUGA_SKYPE + ("we tried to call Skype on skype_call %s and Skype has now REFUSED\n", + SKYPIAX_P_LOG, id); + strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1); + p->interface_state = SKYPIAX_STATE_DOWN; + p->skype_call_id[0] = '\0'; + if (option_debug > 100) { + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + } + return CALLFLOW_INCOMING_HANGUP; + } else { + /* we're here because were us that refused an incoming call */ + DEBUGA_SKYPE("we REFUSED skype_call %s\n", SKYPIAX_P_LOG, id); + + } + } else if (!strcasecmp(value, "ROUTING")) { + p->skype_callflow = CALLFLOW_STATUS_ROUTING; + p->interface_state = SKYPIAX_STATE_DIALING; + strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1); + DEBUGA_SKYPE("skype_call: %s is now ROUTING\n", SKYPIAX_P_LOG, id); + } else if (!strcasecmp(value, "UNPLACED")) { + p->skype_callflow = CALLFLOW_STATUS_UNPLACED; + p->interface_state = SKYPIAX_STATE_DIALING; + strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1); + DEBUGA_SKYPE("skype_call: %s is now UNPLACED\n", SKYPIAX_P_LOG, id); + } else if (!strcasecmp(value, "INPROGRESS")) { + p->skype_callflow = CALLFLOW_STATUS_INPROGRESS; + strncpy(p->skype_call_id, id, sizeof(p->skype_call_id) - 1); + p->interface_state = SKYPIAX_STATE_UP; + if (option_debug > 1) + DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPIAX_P_LOG, id); + + if (option_debug > 1) + DEBUGA_SKYPE("skype_call: %s SKYPIAX_CONTROL_ANSWER sent\n", + SKYPIAX_P_LOG, id); + + if (1) { + char msg_to_skype[1024]; + + if (1) { + switch_threadattr_t *thd_attr = NULL; + + switch_threadattr_create(&thd_attr, skypiax_module_pool); + switch_threadattr_detach_set(thd_attr, 1); + switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); + switch_thread_create(&p->tcp_srv_thread, thd_attr, + skypiax_do_tcp_srv_thread, p, skypiax_module_pool); + DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG); + + switch_threadattr_create(&thd_attr, skypiax_module_pool); + switch_threadattr_detach_set(thd_attr, 1); + switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); + switch_thread_create(&p->tcp_cli_thread, thd_attr, + skypiax_do_tcp_cli_thread, p, skypiax_module_pool); + DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG); + } + switch_sleep(100000); + sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"5556\"", id); + skypiax_skype_write(p, msg_to_skype); + switch_sleep(100000); + sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"5558\"", id); + skypiax_skype_write(p, msg_to_skype); + switch_sleep(100000); + } + + p->skype_callflow = SKYPIAX_STATE_UP; + + /**************************/ + + //FIXME switch_core_session_t **new_session; + + //FIXME *new_session=switch_loadable_module_create_interface(skypiax_endpoint_interface, pool); + + if (!global_session) { //FIXME FIXME FIXME + switch_core_session_t *session = NULL; + private_t *tech_pvt = NULL; + switch_channel_t *channel = NULL; + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, + "New Inbound Channel!\n"); + + if ((session = + switch_core_session_request(skypiax_endpoint_interface, + NULL)) != 0) { + switch_core_session_add_stream(session, NULL); + if ((tech_pvt = + (private_t *) switch_core_session_alloc(session, + sizeof(private_t))) != 0) { + channel = switch_core_session_get_channel(session); + skypiax_tech_init(tech_pvt, session, p); + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, + "Hey where is my memory pool?\n"); + switch_core_session_destroy(&session); + break; + } + + // if ((tech_pvt->caller_profile = switch_caller_profile_new(switch_core_session_get_pool(session), NULL, dialplan, cid_name, cid_num, ip, NULL, NULL, NULL, modname, NULL, dest)) != 0) + + if ((tech_pvt->caller_profile = + switch_caller_profile_new(switch_core_session_get_pool(session), + "skypiax", "XML", "gmaruzz_from_skype", + "calling_number", NULL, "calling_ani", + NULL, NULL, "mod_skypiax", "default", + "5000")) != 0) { + char name[128]; + switch_snprintf(name, sizeof(name), "skypiax/%s-%04x", + tech_pvt->caller_profile->destination_number, + rand() & 0xffff); + switch_channel_set_name(channel, name); + switch_channel_set_caller_profile(channel, tech_pvt->caller_profile); + } + switch_channel_set_state(channel, CS_INIT); + if (switch_core_session_thread_launch(session) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, + "Error spawning thread\n"); + switch_core_session_destroy(&session); + } + } + } else { + switch_core_session_t *session = NULL; + private_t *tech_pvt = NULL; + switch_channel_t *channel = NULL; + + tech_pvt = p->tech_pvt; + //session = tech_pvt->session; + session = global_session; + channel = switch_core_session_get_channel(session); + switch_channel_mark_pre_answered(channel); + + //switch_channel_set_state(channel, CS_EXECUTE); + + } + /**************************/ + + } else { + WARNINGA("skype_call: %s, STATUS: %s is not recognized\n", SKYPIAX_P_LOG, + id, value); + + } + } //STATUS + + } //CALL + + a = 0; + } //message end + } //read_from_pipe + + } + + if (option_debug > 100) { + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + } + //DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + return 0; +} + + From gmaruzz at freeswitch.org Tue Dec 9 02:56:50 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Tue, 09 Dec 2008 05:56:50 -0500 Subject: [Freeswitch-branches] [commit] r10673 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Tue Dec 9 05:56:50 2008 New Revision: 10673 Log: skypiax: updated Makefile, works Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/Makefile freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/Makefile ============================================================================== --- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/Makefile (original) +++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/Makefile Tue Dec 9 05:56:50 2008 @@ -1,3 +1,4 @@ MODNAME=mod_skypiax LOCAL_LDFLAGS=-lX11 +LOCAL_OBJS=skypiax_protocol.o include ../../../../build/modmake.rules Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c Tue Dec 9 05:56:50 2008 @@ -703,7 +703,7 @@ switch_sleep(1000); } -static void *SWITCH_THREAD_FUNC do_skype_thread(switch_thread_t * thread, void *obj) +void *SWITCH_THREAD_FUNC do_skype_thread(switch_thread_t * thread, void *obj) { struct skypiax_interface *p; From gmaruzz at freeswitch.org Tue Dec 9 03:39:00 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Tue, 09 Dec 2008 06:39:00 -0500 Subject: [Freeswitch-branches] [commit] r10674 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Tue Dec 9 06:39:00 2008 New Revision: 10674 Log: skypiax: less warnings on windows Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c (original) +++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c Tue Dec 9 06:39:00 2008 @@ -1,6 +1,5 @@ #include "skypiax.h" - SWITCH_MODULE_LOAD_FUNCTION(mod_skypiax_load); SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypiax_shutdown); //SWITCH_MODULE_RUNTIME_FUNCTION(mod_skypiax_runtime); @@ -540,16 +539,16 @@ { struct skypiax_interface *p = obj; int res; + int forever=1; DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); DEBUGA_SKYPE("In skypiax_do_controldev_thread: started, p=%p\n", SKYPIAX_P_LOG, (void *) p); - while (1) { + while (forever) { switch_sleep(1000); res = skypiax_skype_read(p); -#if 1 //if (res == CALLFLOW_INCOMING_HANGUP && p->interface_state != SKYPIAX_STATE_DOWN) if (res == CALLFLOW_INCOMING_HANGUP) { switch_core_session_t *session = NULL; @@ -566,10 +565,7 @@ switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); DEBUGA_SKYPE("after channel_on_hangup\n", SKYPIAX_P_LOG); - - //DEBUGA_SKYPE("set state to CS_HANGUP\n", SKYPIAX_P_LOG); } -#endif } //if (option_debug > 10) { @@ -737,6 +733,11 @@ } if (interface_id && interface_id < SKYPIAX_MAX_INTERFACES) { struct skypiax_interface newconf; + switch_thread_t *do_skype_thread_thread; + switch_threadattr_t *do_skype_thd_attr = NULL; + switch_thread_t *skypiax_do_controldev_thread_thread; + switch_threadattr_t *skypiax_do_controldev_thread_thd_attr = NULL; + memset(&newconf, '\0', sizeof(newconf)); SKYPIAX_INTERFACES[interface_id] = newconf; switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, @@ -765,28 +766,20 @@ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "STARTING interface_id=%d\n", interface_id); - if (1) { - switch_thread_t *thread; - switch_threadattr_t *thd_attr = NULL; - - switch_threadattr_create(&thd_attr, skypiax_module_pool); - switch_threadattr_detach_set(thd_attr, 1); - switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); - switch_thread_create(&thread, thd_attr, do_skype_thread, + + switch_threadattr_create(&do_skype_thd_attr, skypiax_module_pool); + switch_threadattr_detach_set(do_skype_thd_attr, 1); + switch_threadattr_stacksize_set(do_skype_thd_attr, SWITCH_THREAD_STACKSIZE); + switch_thread_create(&do_skype_thread_thread, do_skype_thd_attr, do_skype_thread, &SKYPIAX_INTERFACES[interface_id], skypiax_module_pool); - } switch_sleep(100000); - if (1) { - switch_thread_t *thread; - switch_threadattr_t *thd_attr = NULL; - - switch_threadattr_create(&thd_attr, skypiax_module_pool); - switch_threadattr_detach_set(thd_attr, 1); - switch_threadattr_stacksize_set(thd_attr, SWITCH_THREAD_STACKSIZE); - switch_thread_create(&thread, thd_attr, skypiax_do_controldev_thread, + + switch_threadattr_create(&skypiax_do_controldev_thread_thd_attr, skypiax_module_pool); + switch_threadattr_detach_set(skypiax_do_controldev_thread_thd_attr, 1); + switch_threadattr_stacksize_set(skypiax_do_controldev_thread_thd_attr, SWITCH_THREAD_STACKSIZE); + switch_thread_create(&skypiax_do_controldev_thread_thread, skypiax_do_controldev_thread_thd_attr, skypiax_do_controldev_thread, &SKYPIAX_INTERFACES[interface_id], skypiax_module_pool); - } switch_sleep(1000000); @@ -832,7 +825,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_skypiax_load) { - struct skypiax_interface *p = NULL; + //struct skypiax_interface *p = NULL; skypiax_module_pool = pool; Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c Tue Dec 9 06:39:00 2008 @@ -1,4 +1,6 @@ #include "skypiax.h" + + extern switch_memory_pool_t *skypiax_module_pool; extern int option_debug; extern switch_core_session_t *global_session; @@ -16,8 +18,14 @@ struct skypiax_interface *p = obj; short in[GG]; short out[GG / 2]; - int s, fd, len; + int s, len; +#ifdef WIN32 + int sin_size; + unsigned int fd; +#else unsigned int sin_size; + int fd; +#endif /* WIN32 */ struct sockaddr_in my_addr; struct sockaddr_in remote_addr; int exit = 0; @@ -60,7 +68,11 @@ && (p->skype_callflow == CALLFLOW_STATUS_INPROGRESS || p->skype_callflow == SKYPIAX_STATE_UP)) { +#ifdef WIN32 + unsigned int fdselect; +#else int fdselect; +#endif /* WIN32 */ int rt; fd_set fs; struct timeval to; @@ -1090,7 +1102,7 @@ if (p->interface_state != SKYPIAX_STATE_DIALING) { /* we are not calling out */ - if (1) { + if (1) { //FIXME /* we are not inside an active call */ p->skype_callflow = CALLFLOW_STATUS_RINGING; p->interface_state = SKYPIAX_STATE_RING; @@ -1227,10 +1239,10 @@ DEBUGA_SKYPE("skype_call: %s SKYPIAX_CONTROL_ANSWER sent\n", SKYPIAX_P_LOG, id); - if (1) { + if (1) { //FIXME char msg_to_skype[1024]; - if (1) { + if (1) { //FIXME switch_threadattr_t *thd_attr = NULL; switch_threadattr_create(&thd_attr, skypiax_module_pool); From gmaruzz at freeswitch.org Tue Dec 9 03:41:55 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Tue, 09 Dec 2008 06:41:55 -0500 Subject: [Freeswitch-branches] [commit] r10675 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Tue Dec 9 06:41:55 2008 New Revision: 10675 Log: skypiax: works on linux Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c (original) +++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c Tue Dec 9 06:41:55 2008 @@ -825,14 +825,14 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_skypiax_load) { - //struct skypiax_interface *p = NULL; + struct skypiax_interface *p = NULL; skypiax_module_pool = pool; memset(&globals, '\0', sizeof(globals)); memset(SKYPIAX_INTERFACES, '\0', sizeof(SKYPIAX_INTERFACES)); -#ifndef _WINDOWS_ //FIXME +#ifndef WIN32 //FIXME if (!XInitThreads()) { ERRORA("Not initialized XInitThreads!\n", SKYPIAX_P_LOG); } else { @@ -850,6 +850,7 @@ skypiax_endpoint_interface->io_routines = &skypiax_io_routines; skypiax_endpoint_interface->state_handler = &skypiax_state_handlers; + DEBUGA_SKYPE("EXITING FUNC!\n", SKYPIAX_P_LOG); /* indicate that the module should continue to be loaded */ return SWITCH_STATUS_SUCCESS; } From gmaruzz at freeswitch.org Tue Dec 9 06:33:56 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Tue, 09 Dec 2008 09:33:56 -0500 Subject: [Freeswitch-branches] [commit] r10676 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Tue Dec 9 09:33:55 2008 New Revision: 10676 Log: skypiax: less warnings on windows Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c Tue Dec 9 09:33:55 2008 @@ -1,6 +1,5 @@ #include "skypiax.h" - extern switch_memory_pool_t *skypiax_module_pool; extern int option_debug; extern switch_core_session_t *global_session; @@ -16,21 +15,26 @@ void *obj) { struct skypiax_interface *p = obj; - short in[GG]; short out[GG / 2]; - int s, len; + int s; #ifdef WIN32 + unsigned int len; + unsigned int i; + unsigned int a; + char in[GG]; int sin_size; unsigned int fd; #else + int len; + int i; + int a; + short in[GG]; unsigned int sin_size; int fd; #endif /* WIN32 */ struct sockaddr_in my_addr; struct sockaddr_in remote_addr; int exit = 0; - int a; - int i; unsigned int kill_cli_size; short kill_cli_buff[320]; @@ -171,15 +175,27 @@ //void *skypiax_do_tcp_cli_thread(void *data) { struct skypiax_interface *p = obj; - int s, fd, len; - short in[NN / 2]; - short out[NN]; - unsigned int sin_size; + int s; struct sockaddr_in my_addr; struct sockaddr_in remote_addr; - int a; - int i; unsigned int got; +#ifdef WIN32 + unsigned int len; + unsigned int i; + unsigned int a; + char in[NN / 2]; + char out[NN]; + int sin_size; + unsigned int fd; +#else + int len; + int i; + int a; + short in[NN / 2]; + short out[NN]; + unsigned int sin_size; + int fd; +#endif /* WIN32 */ if (option_debug > 10) { WARNINGA("ENTERING FUNC\n", SKYPIAX_P_LOG); @@ -219,7 +235,11 @@ while (p->interface_state != SKYPIAX_STATE_DOWN && (p->skype_callflow == CALLFLOW_STATUS_INPROGRESS || p->skype_callflow == SKYPIAX_STATE_UP)) { +#ifdef WIN32 + unsigned int fdselect; +#else int fdselect; +#endif /* WIN32 */ int rt; fd_set fs; struct timeval to; @@ -918,8 +938,9 @@ int rt; //fd_set fs; //struct timeval to; - int i, a; + int a; unsigned int howmany; + unsigned int i; if (option_debug > 100) { DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); From gmaruzz at freeswitch.org Tue Dec 9 06:35:38 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Tue, 09 Dec 2008 09:35:38 -0500 Subject: [Freeswitch-branches] [commit] r10677 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Tue Dec 9 09:35:38 2008 New Revision: 10677 Log: skypiax: indent -gnu -ts4 -br -brs -cdw -lp -ce -nbfda -npcs -nprs -npsl -nbbo -saf -sai -saw -cs -bbo -nhnl -nut -sob -l90 Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c (original) +++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c Tue Dec 9 09:35:38 2008 @@ -36,7 +36,6 @@ /*************************************************/ /*************************************************/ - SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, globals.dialplan); SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_string, globals.codec_string); SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_rates_string, @@ -63,7 +62,6 @@ int stream_id); static switch_status_t channel_kill_channel(switch_core_session_t * session, int sig); - static switch_status_t skypiax_codec(private_t * tech_pvt, int sample_rate, int codec_ms) { if (switch_core_codec_init @@ -93,7 +91,8 @@ } -void skypiax_tech_init(private_t * tech_pvt, switch_core_session_t * session, skypiax_interface_t * p) +void skypiax_tech_init(private_t * tech_pvt, switch_core_session_t * session, + skypiax_interface_t * p) { DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); @@ -539,7 +538,7 @@ { struct skypiax_interface *p = obj; int res; - int forever=1; + int forever = 1; DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); @@ -575,7 +574,6 @@ } - static switch_status_t load_config(void) { char *cf = "skypiax.conf"; @@ -733,10 +731,10 @@ } if (interface_id && interface_id < SKYPIAX_MAX_INTERFACES) { struct skypiax_interface newconf; - switch_thread_t *do_skype_thread_thread; - switch_threadattr_t *do_skype_thd_attr = NULL; - switch_thread_t *skypiax_do_controldev_thread_thread; - switch_threadattr_t *skypiax_do_controldev_thread_thd_attr = NULL; + switch_thread_t *do_skype_thread_thread; + switch_threadattr_t *do_skype_thd_attr = NULL; + switch_thread_t *skypiax_do_controldev_thread_thread; + switch_threadattr_t *skypiax_do_controldev_thread_thd_attr = NULL; memset(&newconf, '\0', sizeof(newconf)); SKYPIAX_INTERFACES[interface_id] = newconf; @@ -766,20 +764,23 @@ switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "STARTING interface_id=%d\n", interface_id); - - switch_threadattr_create(&do_skype_thd_attr, skypiax_module_pool); - switch_threadattr_detach_set(do_skype_thd_attr, 1); - switch_threadattr_stacksize_set(do_skype_thd_attr, SWITCH_THREAD_STACKSIZE); - switch_thread_create(&do_skype_thread_thread, do_skype_thd_attr, do_skype_thread, - &SKYPIAX_INTERFACES[interface_id], skypiax_module_pool); + switch_threadattr_create(&do_skype_thd_attr, skypiax_module_pool); + switch_threadattr_detach_set(do_skype_thd_attr, 1); + switch_threadattr_stacksize_set(do_skype_thd_attr, SWITCH_THREAD_STACKSIZE); + switch_thread_create(&do_skype_thread_thread, do_skype_thd_attr, do_skype_thread, + &SKYPIAX_INTERFACES[interface_id], skypiax_module_pool); switch_sleep(100000); - switch_threadattr_create(&skypiax_do_controldev_thread_thd_attr, skypiax_module_pool); - switch_threadattr_detach_set(skypiax_do_controldev_thread_thd_attr, 1); - switch_threadattr_stacksize_set(skypiax_do_controldev_thread_thd_attr, SWITCH_THREAD_STACKSIZE); - switch_thread_create(&skypiax_do_controldev_thread_thread, skypiax_do_controldev_thread_thd_attr, skypiax_do_controldev_thread, - &SKYPIAX_INTERFACES[interface_id], skypiax_module_pool); + switch_threadattr_create(&skypiax_do_controldev_thread_thd_attr, + skypiax_module_pool); + switch_threadattr_detach_set(skypiax_do_controldev_thread_thd_attr, 1); + switch_threadattr_stacksize_set(skypiax_do_controldev_thread_thd_attr, + SWITCH_THREAD_STACKSIZE); + switch_thread_create(&skypiax_do_controldev_thread_thread, + skypiax_do_controldev_thread_thd_attr, + skypiax_do_controldev_thread, + &SKYPIAX_INTERFACES[interface_id], skypiax_module_pool); switch_sleep(1000000); @@ -832,7 +833,7 @@ memset(&globals, '\0', sizeof(globals)); memset(SKYPIAX_INTERFACES, '\0', sizeof(SKYPIAX_INTERFACES)); -#ifndef WIN32 //FIXME +#ifndef WIN32 //FIXME if (!XInitThreads()) { ERRORA("Not initialized XInitThreads!\n", SKYPIAX_P_LOG); } else { @@ -850,7 +851,7 @@ skypiax_endpoint_interface->io_routines = &skypiax_io_routines; skypiax_endpoint_interface->state_handler = &skypiax_state_handlers; - DEBUGA_SKYPE("EXITING FUNC!\n", SKYPIAX_P_LOG); + DEBUGA_SKYPE("EXITING FUNC!\n", SKYPIAX_P_LOG); /* indicate that the module should continue to be loaded */ return SWITCH_STATUS_SUCCESS; } @@ -934,4 +935,3 @@ * For VIM: * vim:set softtabstop=4 shiftwidth=4 tabstop=4 expandtab: */ - Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h ============================================================================== --- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h (original) +++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h Tue Dec 9 09:35:38 2008 @@ -44,7 +44,6 @@ //FIXME include? #endif //WIN32 - #define SKYPIAX_SVN_VERSION "SVN 123456" typedef enum { @@ -63,7 +62,6 @@ GFLAG_MY_CODEC_PREFS = (1 << 0) } GFLAGS; - #define DEBUGA_SKYPE(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_SKYPE %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); #define DEBUGA_CALL(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_CALL %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); #define DEBUGA_PBX(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_PBX %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); @@ -209,9 +207,9 @@ typedef struct private_object private_t; - void *SWITCH_THREAD_FUNC do_skype_thread(switch_thread_t * thread, void *obj); -void skypiax_tech_init(private_t * tech_pvt, switch_core_session_t * session, skypiax_interface_t * p); +void skypiax_tech_init(private_t * tech_pvt, switch_core_session_t * session, + skypiax_interface_t * p); switch_status_t skypiax_skypeaudio_read(private_t * tech_pvt); int skypiax_skypeaudio_init(struct skypiax_interface *p); int skypiax_skype_write(struct skypiax_interface *p, char *msg_to_skype); Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c Tue Dec 9 09:35:38 2008 @@ -303,7 +303,9 @@ switch_status_t rv; - rv = switch_file_pipe_create_ex(&p->audiopipe[0], &p->audiopipe[1], 2, skypiax_module_pool); + rv = + switch_file_pipe_create_ex(&p->audiopipe[0], &p->audiopipe[1], 2, + skypiax_module_pool); rv = switch_file_pipe_timeout_set(p->audiopipe[0], 100000); /* the pipe is our audio fd for pbx to poll on */ @@ -318,6 +320,7 @@ } return 0; } + switch_status_t skypiax_skypeaudio_read(private_t * tech_pvt) { struct skypiax_interface *p; @@ -862,7 +865,6 @@ } #endif // WIN32 - int skypiax_skype_write(struct skypiax_interface *p, char *msg_to_skype) { #ifdef WIN32 @@ -963,8 +965,8 @@ if (read_from_pipe[i] == '\0') { //if (option_debug > 101) - DEBUGA_SKYPE("read_skype: howmany=%d, i=%d, a=%d, |||%s||| \n", SKYPIAX_P_LOG, - howmany, i, a, messaggio); + DEBUGA_SKYPE("read_skype: howmany=%d, i=%d, a=%d, |||%s||| \n", SKYPIAX_P_LOG, + howmany, i, a, messaggio); if (!strncasecmp(messaggio, "ERROR 92 CALL", 12)) { ERRORA("Skype got ERROR: |||%s|||, the number we called was not recognized\n", @@ -1092,8 +1094,8 @@ if (channel) { switch_dtmf_t dtmf = { (char) value[0], switch_core_default_dtmf_duration(0) }; - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%c DTMF %s\n", - dtmf.digit, switch_channel_get_name(channel)); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "%c DTMF %s\n", + dtmf.digit, switch_channel_get_name(channel)); switch_mutex_lock(tech_pvt->flag_mutex); switch_channel_queue_dtmf(channel, &dtmf); switch_set_flag(tech_pvt, TFLAG_DTMF); @@ -1123,7 +1125,7 @@ if (p->interface_state != SKYPIAX_STATE_DIALING) { /* we are not calling out */ - if (1) { //FIXME + if (1) { //FIXME /* we are not inside an active call */ p->skype_callflow = CALLFLOW_STATUS_RINGING; p->interface_state = SKYPIAX_STATE_RING; @@ -1260,10 +1262,10 @@ DEBUGA_SKYPE("skype_call: %s SKYPIAX_CONTROL_ANSWER sent\n", SKYPIAX_P_LOG, id); - if (1) { //FIXME + if (1) { //FIXME char msg_to_skype[1024]; - if (1) { //FIXME + if (1) { //FIXME switch_threadattr_t *thd_attr = NULL; switch_threadattr_create(&thd_attr, skypiax_module_pool); @@ -1380,5 +1382,3 @@ //DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); return 0; } - - From gmaruzz at freeswitch.org Tue Dec 9 09:10:42 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Tue, 09 Dec 2008 12:10:42 -0500 Subject: [Freeswitch-branches] [commit] r10682 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Tue Dec 9 12:10:41 2008 New Revision: 10682 Log: skypiax: no more crashes on unloading on linux Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c (original) +++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c Tue Dec 9 12:10:41 2008 @@ -29,8 +29,8 @@ int option_debug = 100; switch_endpoint_interface_t *skypiax_endpoint_interface; switch_memory_pool_t *skypiax_module_pool = NULL; -static int running = 1; -static skypiax_interface_t SKYPIAX_INTERFACES[SKYPIAX_MAX_INTERFACES]; +int running = 1; +skypiax_interface_t SKYPIAX_INTERFACES[SKYPIAX_MAX_INTERFACES]; switch_core_session_t *global_session = NULL; /*************************************************/ /*************************************************/ @@ -443,7 +443,7 @@ int skypiax_skype_call(struct skypiax_interface *p, char *idest, int timeout, switch_core_session_t * session) { - char rdest[80]; + char *rdest; char msg_to_skype[1024]; if (option_debug > 10) { @@ -451,10 +451,12 @@ } switch_sleep(5000); - //FIXME strncpy(rdest, idest, sizeof(rdest) - 1); - strncpy(rdest, "echo123", sizeof(rdest) - 1); + rdest = strchr(idest, '/'); + *rdest++ = '\0'; + if (option_debug) DEBUGA_SKYPE("Calling Skype, rdest is: %s\n", SKYPIAX_P_LOG, rdest); + NOTICA("Calling Skype, rdest is: %s\n", SKYPIAX_P_LOG, rdest); skypiax_skype_write(p, "SET AGC OFF"); switch_sleep(10000); skypiax_skype_write(p, "SET AEC OFF"); @@ -516,7 +518,7 @@ return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; } - skypiax_skype_call(tech_pvt->p, outbound_profile->destination_number, 30, + skypiax_skype_call(tech_pvt->p, caller_profile->destination_number, 30, *new_session); switch_channel_set_flag(channel, CF_OUTBOUND); @@ -546,25 +548,33 @@ (void *) p); while (forever) { + if(!running) + break; switch_sleep(1000); res = skypiax_skype_read(p); //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; - - DEBUGA_SKYPE("skype call ended\n", SKYPIAX_P_LOG); - - 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_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); - DEBUGA_SKYPE("after channel_on_hangup\n", SKYPIAX_P_LOG); - } + if (res == CALLFLOW_INCOMING_HANGUP) { + switch_core_session_t *session = NULL; + private_t *tech_pvt = NULL; + switch_channel_t *channel = NULL; + + DEBUGA_SKYPE("skype call ended\n", SKYPIAX_P_LOG); + + tech_pvt = p->tech_pvt; + if(tech_pvt){ + session = tech_pvt->session; + + if(session){ + channel = switch_core_session_get_channel(session); + DEBUGA_SKYPE("before channel_on_hangup\n", SKYPIAX_P_LOG); + + if(channel) { + switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); + DEBUGA_SKYPE("after channel_on_hangup\n", SKYPIAX_P_LOG); + } + } + } + } } //if (option_debug > 10) { @@ -833,13 +843,13 @@ memset(&globals, '\0', sizeof(globals)); memset(SKYPIAX_INTERFACES, '\0', sizeof(SKYPIAX_INTERFACES)); -#ifndef WIN32 //FIXME +#ifndef WIN32 if (!XInitThreads()) { ERRORA("Not initialized XInitThreads!\n", SKYPIAX_P_LOG); } else { DEBUGA_SKYPE("Initialized XInitThreads!\n", SKYPIAX_P_LOG); } - switch_sleep(10000); //FIXME + switch_sleep(100); #endif /* _WINDOWS_ */ load_config(); @@ -865,16 +875,16 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypiax_shutdown) { - int x = 0; + int x = 100; + struct skypiax_interface *p = NULL; - running = -1; + running = 0; - while (running) { - if (x++ > 100) { - break; - } + while (x) { + x--; switch_yield(20000); } + NOTICA("EXITING FUNC!\n", SKYPIAX_P_LOG); return SWITCH_STATUS_SUCCESS; } Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c Tue Dec 9 12:10:41 2008 @@ -4,6 +4,8 @@ extern int option_debug; extern switch_core_session_t *global_session; extern switch_endpoint_interface_t *skypiax_endpoint_interface; +extern int running; +extern skypiax_interface_t SKYPIAX_INTERFACES; #define SKYPE_AUDIO #ifdef SKYPE_AUDIO @@ -68,6 +70,8 @@ sin_size = sizeof(remote_addr); while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) { DEBUGA_SKYPE("ACCEPTED\n", SKYPIAX_P_LOG); + if(!running) + break; while (p->interface_state != SKYPIAX_STATE_DOWN && (p->skype_callflow == CALLFLOW_STATUS_INPROGRESS || p->skype_callflow == SKYPIAX_STATE_UP)) { @@ -81,6 +85,8 @@ fd_set fs; struct timeval to; + if(!running) + break; exit = 1; fdselect = fd; @@ -232,6 +238,8 @@ sin_size = sizeof(remote_addr); while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) { DEBUGA_SKYPE("ACCEPTED\n", SKYPIAX_P_LOG); + if(!running) + break; while (p->interface_state != SKYPIAX_STATE_DOWN && (p->skype_callflow == CALLFLOW_STATUS_INPROGRESS || p->skype_callflow == SKYPIAX_STATE_UP)) { @@ -244,6 +252,8 @@ fd_set fs; struct timeval to; + if(!running) + break; fdselect = 1; FD_ZERO(&fs); FD_SET(fdselect, &fs); @@ -567,6 +577,7 @@ switch_file_pipe_create_ex(&p->AsteriskHandlesAst.fdesc[0], &p->AsteriskHandlesAst.fdesc[1], 2, skypiax_module_pool); + switch_file_pipe_timeout_set(p->AsteriskHandlesAst.fdesc[0], 100000); win32_AsteriskHandlesSkype = &p->AsteriskHandlesAst; @@ -588,8 +599,12 @@ win32_hInit_MainWindowHandle; while (1) { MSG oMessage; + if(!running) + break; while (GetMessage(&oMessage, 0, 0, 0) != FALSE) { + if(!running) + break; TranslateMessage(&oMessage); DispatchMessage(&oMessage); } @@ -754,6 +769,7 @@ switch_file_pipe_create_ex(&p->AsteriskHandlesAst.fdesc[0], &p->AsteriskHandlesAst.fdesc[1], 2, skypiax_module_pool); + switch_file_pipe_timeout_set(p->AsteriskHandlesAst.fdesc[0], 100000); AsteriskHandlesAst = &p->AsteriskHandlesAst; //disp = XOpenDisplay(getenv("DISPLAY")); disp = XOpenDisplay(p->X11_display); @@ -819,6 +835,8 @@ while (1) { XNextEvent(disp, &an_event); + if(!running) + break; switch (an_event.type) { case ClientMessage: @@ -859,7 +877,7 @@ SKYPIAX_P_LOG); return NULL; } - //DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); return NULL; } From gmaruzz at freeswitch.org Tue Dec 9 11:41:22 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Tue, 09 Dec 2008 14:41:22 -0500 Subject: [Freeswitch-branches] [commit] r10684 - in freeswitch/branches/gmaruzz/src: . include mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Tue Dec 9 14:41:22 2008 New Revision: 10684 Log: switch_apr.c: added switch_thread_exit skypiax: less trying to unload without crashes on windows, not yet 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_skypiax/skypiax_protocol.c 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 Tue Dec 9 14:41:22 2008 @@ -1321,6 +1321,13 @@ SWITCH_DECLARE(switch_status_t) switch_file_pipe_timeout_set(switch_file_t *thepipe, switch_interval_time_t timeout); +/** + * stop the current thread + * @param thd The thread to stop + * @param retval The return value to pass back to any thread that cares + */ +SWITCH_DECLARE(switch_status_t) switch_thread_exit(switch_thread_t *thd, switch_status_t retval); + /** @} */ Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c (original) +++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c Tue Dec 9 14:41:22 2008 @@ -32,6 +32,9 @@ int running = 1; skypiax_interface_t SKYPIAX_INTERFACES[SKYPIAX_MAX_INTERFACES]; switch_core_session_t *global_session = NULL; +#ifdef WIN32 +HANDLE win32_hGlobal_ThreadShutdownEvent; +#endif /* WIN32 */ /*************************************************/ /*************************************************/ /*************************************************/ @@ -875,11 +878,15 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypiax_shutdown) { - int x = 100; + int x = 1000; struct skypiax_interface *p = NULL; running = 0; +#ifdef WIN32 + SetEvent(win32_hGlobal_ThreadShutdownEvent); +#endif + while (x) { x--; switch_yield(20000); Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c Tue Dec 9 14:41:22 2008 @@ -6,6 +6,9 @@ extern switch_endpoint_interface_t *skypiax_endpoint_interface; extern int running; extern skypiax_interface_t SKYPIAX_INTERFACES; +#ifdef WIN32 +extern HANDLE win32_hGlobal_ThreadShutdownEvent; +#endif /* WIN32 */ #define SKYPE_AUDIO #ifdef SKYPE_AUDIO @@ -379,7 +382,6 @@ 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; @@ -573,6 +575,7 @@ /* destroy window class */ struct skypiax_interface *p; + DWORD MsgWaitResult; p = obj; switch_file_pipe_create_ex(&p->AsteriskHandlesAst.fdesc[0], @@ -590,25 +593,35 @@ && win32_uiGlobal_MsgID_SkypeControlAPIDiscover != 0) { if (win32_Initialize_CreateWindowClass()) { if (win32_Initialize_CreateMainWindow()) { - win32_hGlobal_ThreadShutdownEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + //win32_hGlobal_ThreadShutdownEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + win32_hGlobal_ThreadShutdownEvent = CreateEvent(NULL, FALSE, 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; - if(!running) - break; - - while (GetMessage(&oMessage, 0, 0, 0) != FALSE) { - if(!running) - break; - TranslateMessage(&oMessage); - DispatchMessage(&oMessage); - } - } + while (1) { + MSG oMessage; + const HANDLE *MsgWaitHandles[1]; + + MsgWaitHandles[0] = &win32_hGlobal_ThreadShutdownEvent; + if(!running) + break; + while (MsgWaitResult = MsgWaitForMultipleObjects(1,MsgWaitHandles, FALSE, 300,QS_ALLPOSTMESSAGE)){ + if(!running) + break; + if (MsgWaitResult == WAIT_TIMEOUT) { + continue; + } + + GetMessage(&oMessage, 0, 0, 0); + if(!running) + break; + TranslateMessage(&oMessage); + DispatchMessage(&oMessage); + } + } } CloseHandle(win32_hGlobal_ThreadShutdownEvent); } @@ -617,6 +630,10 @@ win32_DeInitialize_DestroyWindowClass(); } } + + + switch_thread_exit(thread, SWITCH_STATUS_SUCCESS); + return NULL; } Modified: freeswitch/branches/gmaruzz/src/switch_apr.c ============================================================================== --- freeswitch/branches/gmaruzz/src/switch_apr.c (original) +++ freeswitch/branches/gmaruzz/src/switch_apr.c Tue Dec 9 14:41:22 2008 @@ -970,6 +970,17 @@ } +/** + * stop the current thread + * @param thd The thread to stop + * @param retval The return value to pass back to any thread that cares + */ +SWITCH_DECLARE(switch_status_t) switch_thread_exit(switch_thread_t *thd, switch_status_t retval) +{ + return apr_thread_exit((apr_thread_t *)thd, retval); +} + + /* For Emacs: * Local Variables: * mode:c From gmaruzz at freeswitch.org Wed Dec 10 07:52:02 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Wed, 10 Dec 2008 10:52:02 -0500 Subject: [Freeswitch-branches] [commit] r10695 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Wed Dec 10 10:52:01 2008 New Revision: 10695 Log: skypiax: unload without crashes on windows, yay 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 Wed Dec 10 10:52:01 2008 @@ -34,7 +34,10 @@ switch_core_session_t *global_session = NULL; #ifdef WIN32 HANDLE win32_hGlobal_ThreadShutdownEvent; +switch_thread_t *do_skype_thread_thread; +HWND win32_hInit_MainWindowHandle; #endif /* WIN32 */ +switch_thread_t *skypiax_do_controldev_thread_thread; /*************************************************/ /*************************************************/ /*************************************************/ @@ -744,9 +747,7 @@ } if (interface_id && interface_id < SKYPIAX_MAX_INTERFACES) { struct skypiax_interface newconf; - switch_thread_t *do_skype_thread_thread; switch_threadattr_t *do_skype_thd_attr = NULL; - switch_thread_t *skypiax_do_controldev_thread_thread; switch_threadattr_t *skypiax_do_controldev_thread_thd_attr = NULL; memset(&newconf, '\0', sizeof(newconf)); @@ -778,7 +779,7 @@ "STARTING interface_id=%d\n", interface_id); switch_threadattr_create(&do_skype_thd_attr, skypiax_module_pool); - switch_threadattr_detach_set(do_skype_thd_attr, 1); + //switch_threadattr_detach_set(do_skype_thd_attr, 1); switch_threadattr_stacksize_set(do_skype_thd_attr, SWITCH_THREAD_STACKSIZE); switch_thread_create(&do_skype_thread_thread, do_skype_thd_attr, do_skype_thread, &SKYPIAX_INTERFACES[interface_id], skypiax_module_pool); @@ -787,7 +788,7 @@ switch_threadattr_create(&skypiax_do_controldev_thread_thd_attr, skypiax_module_pool); - switch_threadattr_detach_set(skypiax_do_controldev_thread_thd_attr, 1); + //switch_threadattr_detach_set(skypiax_do_controldev_thread_thd_attr, 1); switch_threadattr_stacksize_set(skypiax_do_controldev_thread_thd_attr, SWITCH_THREAD_STACKSIZE); switch_thread_create(&skypiax_do_controldev_thread_thread, @@ -878,20 +879,28 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypiax_shutdown) { - int x = 1000; + int x = 100; struct skypiax_interface *p = NULL; + switch_status_t status; + unsigned int howmany=8; + + p = &SKYPIAX_INTERFACES[2]; running = 0; + switch_file_write(p->AsteriskHandlesAst.fdesc[1], "sciutati", &howmany); // let's the controldev_thread die + #ifdef WIN32 - SetEvent(win32_hGlobal_ThreadShutdownEvent); + if (SendMessage (win32_hInit_MainWindowHandle, WM_DESTROY, 0, 0) == FALSE) { // let's the do_skype_thread die + ERRORA("WHY FALSE HERE? %d\n", SKYPIAX_P_LOG, GetLastError()); + } #endif - while (x) { x--; switch_yield(20000); } - NOTICA("EXITING FUNC!\n", SKYPIAX_P_LOG); + switch_thread_join(&status, do_skype_thread_thread); + switch_thread_join(&status, skypiax_do_controldev_thread_thread); return SWITCH_STATUS_SUCCESS; } 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 Wed Dec 10 10:52:01 2008 @@ -7,7 +7,7 @@ extern int running; extern skypiax_interface_t SKYPIAX_INTERFACES; #ifdef WIN32 -extern HANDLE win32_hGlobal_ThreadShutdownEvent; +extern HWND win32_hInit_MainWindowHandle; #endif /* WIN32 */ #define SKYPE_AUDIO @@ -379,7 +379,6 @@ #ifdef WIN32 struct AsteriskHandles *win32_AsteriskHandlesSkype; -HWND win32_hInit_MainWindowHandle; HINSTANCE win32_hInit_ProcessHandle; char win32_acInit_WindowClassName[128]; UINT win32_uiGlobal_MsgID_SkypeControlAPIAttach; @@ -441,6 +440,7 @@ fIssueDefProc = 0; switch (uiMessage) { case WM_DESTROY: + NOTICA("got DESTROY\n", SKYPIAX_P_LOG); win32_hInit_MainWindowHandle = NULL; PostQuitMessage(0); break; @@ -593,9 +593,6 @@ && win32_uiGlobal_MsgID_SkypeControlAPIDiscover != 0) { if (win32_Initialize_CreateWindowClass()) { if (win32_Initialize_CreateMainWindow()) { - //win32_hGlobal_ThreadShutdownEvent = CreateEvent(NULL, TRUE, FALSE, NULL); - win32_hGlobal_ThreadShutdownEvent = CreateEvent(NULL, FALSE, FALSE, NULL); - if (win32_hGlobal_ThreadShutdownEvent != NULL) { if (SendMessage (HWND_BROADCAST, win32_uiGlobal_MsgID_SkypeControlAPIDiscover, (WPARAM) win32_hInit_MainWindowHandle, 0) != 0) { @@ -603,28 +600,15 @@ win32_hInit_MainWindowHandle; while (1) { MSG oMessage; - const HANDLE *MsgWaitHandles[1]; - - MsgWaitHandles[0] = &win32_hGlobal_ThreadShutdownEvent; if(!running) break; - while (MsgWaitResult = MsgWaitForMultipleObjects(1,MsgWaitHandles, FALSE, 300,QS_ALLPOSTMESSAGE)){ - if(!running) - break; - if (MsgWaitResult == WAIT_TIMEOUT) { - continue; - } - - GetMessage(&oMessage, 0, 0, 0); - if(!running) + while( GetMessage(&oMessage, 0, 0, 0) ){ break; TranslateMessage(&oMessage); DispatchMessage(&oMessage); } } } - CloseHandle(win32_hGlobal_ThreadShutdownEvent); - } win32_DeInitialize_DestroyMainWindow(); } win32_DeInitialize_DestroyWindowClass(); From gmaruzz at freeswitch.org Wed Dec 10 08:01:08 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Wed, 10 Dec 2008 11:01:08 -0500 Subject: [Freeswitch-branches] [commit] r10696 - in freeswitch/branches/gmaruzz: . src src/include Message-ID: Author: gmaruzz Date: Wed Dec 10 11:01:07 2008 New Revision: 10696 Log: switch_apr.c: added switch_thread_join Modified: freeswitch/branches/gmaruzz/Freeswitch.2008.sln freeswitch/branches/gmaruzz/src/include/switch_apr.h freeswitch/branches/gmaruzz/src/switch_apr.c Modified: freeswitch/branches/gmaruzz/Freeswitch.2008.sln ============================================================================== --- freeswitch/branches/gmaruzz/Freeswitch.2008.sln (original) +++ freeswitch/branches/gmaruzz/Freeswitch.2008.sln Wed Dec 10 11:01:07 2008 @@ -1,6 +1,6 @@ ? Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 +# Visual C++ Express 2008 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Codecs", "Codecs", "{F881ADA2-2F1A-4046-9FEB-191D9422D781}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Endpoints", "Endpoints", "{9460B5F1-0A95-41C4-BEB7-9C2C96459A7C}" @@ -160,28 +160,28 @@ conf\lang\de\vm\tts.xml = conf\lang\de\vm\tts.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demo", "demo", "{765EF1B9-5027-4820-BC37-A44466A51631}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demo (2)", "demo (2)", "{765EF1B9-5027-4820-BC37-A44466A51631}" ProjectSection(SolutionItems) = preProject conf\lang\en\demo\demo.xml = conf\lang\en\demo\demo.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "vm", "vm", "{713E4747-1126-40B1-BD84-58F9A7745423}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "vm (2)", "vm (2)", "{713E4747-1126-40B1-BD84-58F9A7745423}" ProjectSection(SolutionItems) = preProject conf\lang\en\vm\sounds.xml = conf\lang\en\vm\sounds.xml conf\lang\en\vm\tts.xml = conf\lang\en\vm\tts.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demo", "demo", "{F1B71990-EB04-4EB5-B28A-BC3EB6F7E843}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demo (3)", "demo (3)", "{F1B71990-EB04-4EB5-B28A-BC3EB6F7E843}" ProjectSection(SolutionItems) = preProject conf\lang\fr\demo\demo.xml = conf\lang\fr\demo\demo.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "vm", "vm", "{3DAF028C-AB5B-4183-A01B-DCC43F5A87F0}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "vm (3)", "vm (3)", "{3DAF028C-AB5B-4183-A01B-DCC43F5A87F0}" ProjectSection(SolutionItems) = preProject conf\lang\fr\vm\sounds.xml = conf\lang\fr\vm\sounds.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "autoload_configs", "autoload_configs", "{4833F8E3-ABBF-4260-9DB1-B34015676CFC}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "autoload_configs (2)", "autoload_configs (2)", "{4833F8E3-ABBF-4260-9DB1-B34015676CFC}" ProjectSection(SolutionItems) = preProject debug\conf\autoload_configs\alsa.conf.xml = debug\conf\autoload_configs\alsa.conf.xml debug\conf\autoload_configs\conference.conf.xml = debug\conf\autoload_configs\conference.conf.xml @@ -214,26 +214,26 @@ debug\conf\autoload_configs\zeroconf.conf.xml = debug\conf\autoload_configs\zeroconf.conf.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dialplan", "dialplan", "{D44DD429-FE98-42AA-B5B7-4B4EBE33AEFD}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dialplan (2)", "dialplan (2)", "{D44DD429-FE98-42AA-B5B7-4B4EBE33AEFD}" ProjectSection(SolutionItems) = preProject debug\conf\dialplan\default.xml = debug\conf\dialplan\default.xml debug\conf\dialplan\US.conf.xml = debug\conf\dialplan\US.conf.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "directory", "directory", "{471110C9-A7ED-4966-98E1-8EA667BF0EEA}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "directory (2)", "directory (2)", "{471110C9-A7ED-4966-98E1-8EA667BF0EEA}" ProjectSection(SolutionItems) = preProject debug\conf\directory\default.xml = debug\conf\directory\default.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sip_profiles", "sip_profiles", "{4DF5199E-F7F5-4347-97DD-22078FCDB371}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sip_profiles (2)", "sip_profiles (2)", "{4DF5199E-F7F5-4347-97DD-22078FCDB371}" ProjectSection(SolutionItems) = preProject debug\conf\sip_profiles\default.xml = debug\conf\sip_profiles\default.xml debug\conf\sip_profiles\nat.xml = debug\conf\sip_profiles\nat.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "lang", "lang", "{B487BEBE-4A5C-434F-8D30-39465412F84F}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "lang (2)", "lang (2)", "{B487BEBE-4A5C-434F-8D30-39465412F84F}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "de", "de", "{2003189F-0E69-4FF7-A11D-3BFB3F03D558}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "de (2)", "de (2)", "{2003189F-0E69-4FF7-A11D-3BFB3F03D558}" ProjectSection(SolutionItems) = preProject debug\conf\lang\de\de.xml = debug\conf\lang\de\de.xml EndProjectSection @@ -243,43 +243,43 @@ debug\conf\lang\en\en.xml = debug\conf\lang\en\en.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "fr", "fr", "{1240C217-6674-43C1-B099-B0290D84F28B}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "fr (2)", "fr (2)", "{1240C217-6674-43C1-B099-B0290D84F28B}" ProjectSection(SolutionItems) = preProject debug\conf\lang\fr\fr.xml = debug\conf\lang\fr\fr.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demo", "demo", "{03517B06-98A1-46DD-9347-BFFFED7DD8A4}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demo (4)", "demo (4)", "{03517B06-98A1-46DD-9347-BFFFED7DD8A4}" ProjectSection(SolutionItems) = preProject debug\conf\lang\de\demo\demo.xml = debug\conf\lang\de\demo\demo.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "vm", "vm", "{1D339A14-FFC2-4F6E-BEF2-D5D6DF14AC88}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "vm (4)", "vm (4)", "{1D339A14-FFC2-4F6E-BEF2-D5D6DF14AC88}" ProjectSection(SolutionItems) = preProject debug\conf\lang\de\vm\tts.xml = debug\conf\lang\de\vm\tts.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demo", "demo", "{B4C6D0B5-5F39-4546-820D-4BCAA6C3E301}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demo (5)", "demo (5)", "{B4C6D0B5-5F39-4546-820D-4BCAA6C3E301}" ProjectSection(SolutionItems) = preProject debug\conf\lang\en\demo\demo.xml = debug\conf\lang\en\demo\demo.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "vm", "vm", "{3041F86C-51D4-4D9E-8A00-91BA4B7C51D4}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "vm (5)", "vm (5)", "{3041F86C-51D4-4D9E-8A00-91BA4B7C51D4}" ProjectSection(SolutionItems) = preProject debug\conf\lang\en\vm\sounds.xml = debug\conf\lang\en\vm\sounds.xml debug\conf\lang\en\vm\tts.xml = debug\conf\lang\en\vm\tts.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demo", "demo", "{DFE96A6E-5C9A-4C74-959A-9C485A7AD95C}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demo (6)", "demo (6)", "{DFE96A6E-5C9A-4C74-959A-9C485A7AD95C}" ProjectSection(SolutionItems) = preProject debug\conf\lang\fr\demo\demo.xml = debug\conf\lang\fr\demo\demo.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "vm", "vm", "{80A4CA5C-7208-4134-8EFD-C147B03C8AA1}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "vm (6)", "vm (6)", "{80A4CA5C-7208-4134-8EFD-C147B03C8AA1}" ProjectSection(SolutionItems) = preProject debug\conf\lang\fr\vm\sounds.xml = debug\conf\lang\fr\vm\sounds.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "autoload_configs", "autoload_configs", "{8D29085B-952D-4594-9BB9-5781CE552D0A}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "autoload_configs (3)", "autoload_configs (3)", "{8D29085B-952D-4594-9BB9-5781CE552D0A}" ProjectSection(SolutionItems) = preProject release\conf\autoload_configs\alsa.conf.xml = release\conf\autoload_configs\alsa.conf.xml release\conf\autoload_configs\conference.conf.xml = release\conf\autoload_configs\conference.conf.xml @@ -312,25 +312,25 @@ release\conf\autoload_configs\zeroconf.conf.xml = release\conf\autoload_configs\zeroconf.conf.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dialplan", "dialplan", "{23874F4B-C0AF-4587-9F7E-DB0F06DE8CB4}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dialplan (3)", "dialplan (3)", "{23874F4B-C0AF-4587-9F7E-DB0F06DE8CB4}" ProjectSection(SolutionItems) = preProject conf\dialplan\default.xml = conf\dialplan\default.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "directory", "directory", "{19ED97F6-30D8-4FCE-AE1D-8B7FCB170D40}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "directory (3)", "directory (3)", "{19ED97F6-30D8-4FCE-AE1D-8B7FCB170D40}" ProjectSection(SolutionItems) = preProject release\conf\directory\default.xml = release\conf\directory\default.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sip_profiles", "sip_profiles", "{99E79D76-FCFC-466B-965B-273CCACF99B0}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sip_profiles (3)", "sip_profiles (3)", "{99E79D76-FCFC-466B-965B-273CCACF99B0}" ProjectSection(SolutionItems) = preProject release\conf\sip_profiles\default.xml = release\conf\sip_profiles\default.xml release\conf\sip_profiles\nat.xml = release\conf\sip_profiles\nat.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "lang", "lang", "{8FADAC7F-CA9E-49D9-B957-A5F5605D238C}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "lang (3)", "lang (3)", "{8FADAC7F-CA9E-49D9-B957-A5F5605D238C}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "de", "de", "{58A56014-DEA7-4172-8C26-BAD8D499A1E8}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "de (3)", "de (3)", "{58A56014-DEA7-4172-8C26-BAD8D499A1E8}" ProjectSection(SolutionItems) = preProject release\conf\lang\de\de.xml = release\conf\lang\de\de.xml EndProjectSection @@ -340,38 +340,38 @@ release\conf\lang\en\en.xml = release\conf\lang\en\en.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "fr", "fr", "{89A94241-1DA6-44E8-A685-AED1E665C2AD}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "fr (3)", "fr (3)", "{89A94241-1DA6-44E8-A685-AED1E665C2AD}" ProjectSection(SolutionItems) = preProject release\conf\lang\fr\fr.xml = release\conf\lang\fr\fr.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demo", "demo", "{2D74F635-AB18-43B3-A87E-A71F3EA24DDB}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demo (7)", "demo (7)", "{2D74F635-AB18-43B3-A87E-A71F3EA24DDB}" ProjectSection(SolutionItems) = preProject release\conf\lang\de\demo\demo.xml = release\conf\lang\de\demo\demo.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "vm", "vm", "{A721E646-07E9-4E16-A92D-B97F654B2BAC}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "vm (7)", "vm (7)", "{A721E646-07E9-4E16-A92D-B97F654B2BAC}" ProjectSection(SolutionItems) = preProject release\conf\lang\de\vm\tts.xml = release\conf\lang\de\vm\tts.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demo", "demo", "{50331CA0-7038-4341-B92D-C34E1601EFF0}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demo (8)", "demo (8)", "{50331CA0-7038-4341-B92D-C34E1601EFF0}" ProjectSection(SolutionItems) = preProject release\conf\lang\en\demo\demo.xml = release\conf\lang\en\demo\demo.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "vm", "vm", "{FC0DB2A2-B1A3-426E-9E37-BE28FE8FE01B}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "vm (8)", "vm (8)", "{FC0DB2A2-B1A3-426E-9E37-BE28FE8FE01B}" ProjectSection(SolutionItems) = preProject release\conf\lang\en\vm\sounds.xml = release\conf\lang\en\vm\sounds.xml release\conf\lang\en\vm\tts.xml = release\conf\lang\en\vm\tts.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demo", "demo", "{91C6DEDE-CE4A-47D1-A84B-3E828F82E2B0}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demo (9)", "demo (9)", "{91C6DEDE-CE4A-47D1-A84B-3E828F82E2B0}" ProjectSection(SolutionItems) = preProject release\conf\lang\fr\demo\demo.xml = release\conf\lang\fr\demo\demo.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "vm", "vm", "{8F5A511B-F716-4D07-9657-55B9E4F1D3E9}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "vm (9)", "vm (9)", "{8F5A511B-F716-4D07-9657-55B9E4F1D3E9}" ProjectSection(SolutionItems) = preProject release\conf\lang\fr\vm\sounds.xml = release\conf\lang\fr\vm\sounds.xml EndProjectSection @@ -991,6 +991,12 @@ {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} EndProjectSection EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_skypiax", "src\mod\endpoints\mod_skypiax\mod_skypiax.2008.vcproj", "{C6E78A4C-DB1E-47F4-9B63-4DC27D86343F}" + ProjectSection(ProjectDependencies) = postProject + {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} + {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -1735,6 +1741,12 @@ {B3F424EC-3D8F-417C-B244-3919D5E1A577}.Release|Win32.ActiveCfg = Release|Win32 {B3F424EC-3D8F-417C-B244-3919D5E1A577}.Release|Win32.Build.0 = Release|Win32 {B3F424EC-3D8F-417C-B244-3919D5E1A577}.Release|x64.ActiveCfg = Release|Win32 + {C6E78A4C-DB1E-47F4-9B63-4DC27D86343F}.Debug|Win32.ActiveCfg = Debug|Win32 + {C6E78A4C-DB1E-47F4-9B63-4DC27D86343F}.Debug|Win32.Build.0 = Debug|Win32 + {C6E78A4C-DB1E-47F4-9B63-4DC27D86343F}.Debug|x64.ActiveCfg = Debug|Win32 + {C6E78A4C-DB1E-47F4-9B63-4DC27D86343F}.Release|Win32.ActiveCfg = Release|Win32 + {C6E78A4C-DB1E-47F4-9B63-4DC27D86343F}.Release|Win32.Build.0 = Release|Win32 + {C6E78A4C-DB1E-47F4-9B63-4DC27D86343F}.Release|x64.ActiveCfg = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE 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 10 11:01:07 2008 @@ -1328,6 +1328,13 @@ */ SWITCH_DECLARE(switch_status_t) switch_thread_exit(switch_thread_t *thd, switch_status_t retval); +/** + * block until the desired thread stops executing. + * @param retval The return value from the dead thread. + * @param thd The thread to join + */ +SWITCH_DECLARE(switch_status_t) switch_thread_join(switch_status_t *retval, switch_thread_t *thd); + /** @} */ 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 10 11:01:07 2008 @@ -980,6 +980,17 @@ return apr_thread_exit((apr_thread_t *)thd, retval); } +/** + * block until the desired thread stops executing. + * @param retval The return value from the dead thread. + * @param thd The thread to join + */ +SWITCH_DECLARE(switch_status_t) switch_thread_join(switch_status_t *retval, switch_thread_t *thd) +{ + return apr_thread_join((apr_status_t *)retval, (apr_thread_t *)thd); +} + + /* For Emacs: * Local Variables: From gmaruzz at freeswitch.org Wed Dec 10 08:37:57 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Wed, 10 Dec 2008 11:37:57 -0500 Subject: [Freeswitch-branches] [commit] r10697 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Wed Dec 10 11:37:56 2008 New Revision: 10697 Log: skypiax: joins thread on linux too 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 10 11:37:56 2008 @@ -34,10 +34,10 @@ switch_core_session_t *global_session = NULL; #ifdef WIN32 HANDLE win32_hGlobal_ThreadShutdownEvent; -switch_thread_t *do_skype_thread_thread; HWND win32_hInit_MainWindowHandle; #endif /* WIN32 */ switch_thread_t *skypiax_do_controldev_thread_thread; +switch_thread_t *do_skype_thread_thread; /*************************************************/ /*************************************************/ /*************************************************/ @@ -894,13 +894,26 @@ if (SendMessage (win32_hInit_MainWindowHandle, WM_DESTROY, 0, 0) == FALSE) { // let's the do_skype_thread die ERRORA("WHY FALSE HERE? %d\n", SKYPIAX_P_LOG, GetLastError()); } +#else + XEvent e; + Atom atom1 = XInternAtom(p->AsteriskHandlesAst.disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", False); + memset(&e, 0, sizeof(e)); + e.xclient.type = ClientMessage; + e.xclient.message_type = atom1; /* leading message */ + e.xclient.display = p->AsteriskHandlesAst.disp; + e.xclient.window = p->AsteriskHandlesAst.skype_win; + e.xclient.format = 8; + + + XSendEvent(p->AsteriskHandlesAst.disp, p->AsteriskHandlesAst.win, False, 0, &e); + XSync(p->AsteriskHandlesAst.disp, False); #endif while (x) { x--; switch_yield(20000); } - switch_thread_join(&status, do_skype_thread_thread); switch_thread_join(&status, skypiax_do_controldev_thread_thread); + switch_thread_join(&status, do_skype_thread_thread); return SWITCH_STATUS_SUCCESS; } From gmaruzz at freeswitch.org Wed Dec 10 08:38:44 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Wed, 10 Dec 2008 11:38:44 -0500 Subject: [Freeswitch-branches] [commit] r10698 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Wed Dec 10 11:38:43 2008 New Revision: 10698 Log: skypiax: indent -gnu -ts4 -br -brs -cdw -lp -ce -nbfda -npcs -nprs -npsl -nbbo -saf -sai -saw -cs -bbo -nhnl -nut -sob -l90 Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_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 Wed Dec 10 11:38:43 2008 @@ -524,8 +524,7 @@ return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; } - skypiax_skype_call(tech_pvt->p, caller_profile->destination_number, 30, - *new_session); + skypiax_skype_call(tech_pvt->p, caller_profile->destination_number, 30, *new_session); switch_channel_set_flag(channel, CF_OUTBOUND); switch_set_flag_locked(tech_pvt, TFLAG_OUTBOUND); @@ -554,33 +553,33 @@ (void *) p); while (forever) { - if(!running) - break; + if (!running) + break; switch_sleep(1000); res = skypiax_skype_read(p); //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 = NULL; - switch_channel_t *channel = NULL; - - DEBUGA_SKYPE("skype call ended\n", SKYPIAX_P_LOG); - - tech_pvt = p->tech_pvt; - if(tech_pvt){ - session = tech_pvt->session; - - if(session){ - channel = switch_core_session_get_channel(session); - DEBUGA_SKYPE("before channel_on_hangup\n", SKYPIAX_P_LOG); - - if(channel) { - switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); - DEBUGA_SKYPE("after channel_on_hangup\n", SKYPIAX_P_LOG); - } - } - } - } + if (res == CALLFLOW_INCOMING_HANGUP) { + switch_core_session_t *session = NULL; + private_t *tech_pvt = NULL; + switch_channel_t *channel = NULL; + + DEBUGA_SKYPE("skype call ended\n", SKYPIAX_P_LOG); + + tech_pvt = p->tech_pvt; + if (tech_pvt) { + session = tech_pvt->session; + + if (session) { + channel = switch_core_session_get_channel(session); + DEBUGA_SKYPE("before channel_on_hangup\n", SKYPIAX_P_LOG); + + if (channel) { + switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); + DEBUGA_SKYPE("after channel_on_hangup\n", SKYPIAX_P_LOG); + } + } + } + } } //if (option_debug > 10) { @@ -847,13 +846,13 @@ memset(&globals, '\0', sizeof(globals)); memset(SKYPIAX_INTERFACES, '\0', sizeof(SKYPIAX_INTERFACES)); -#ifndef WIN32 +#ifndef WIN32 if (!XInitThreads()) { ERRORA("Not initialized XInitThreads!\n", SKYPIAX_P_LOG); } else { DEBUGA_SKYPE("Initialized XInitThreads!\n", SKYPIAX_P_LOG); } - switch_sleep(100); + switch_sleep(100); #endif /* _WINDOWS_ */ load_config(); @@ -882,21 +881,22 @@ int x = 100; struct skypiax_interface *p = NULL; switch_status_t status; - unsigned int howmany=8; + unsigned int howmany = 8; - p = &SKYPIAX_INTERFACES[2]; + p = &SKYPIAX_INTERFACES[2]; running = 0; - switch_file_write(p->AsteriskHandlesAst.fdesc[1], "sciutati", &howmany); // let's the controldev_thread die + switch_file_write(p->AsteriskHandlesAst.fdesc[1], "sciutati", &howmany); // let's the controldev_thread die #ifdef WIN32 - if (SendMessage (win32_hInit_MainWindowHandle, WM_DESTROY, 0, 0) == FALSE) { // let's the do_skype_thread die - ERRORA("WHY FALSE HERE? %d\n", SKYPIAX_P_LOG, GetLastError()); + if (SendMessage(win32_hInit_MainWindowHandle, WM_DESTROY, 0, 0) == FALSE) { // let's the do_skype_thread die + ERRORA("WHY FALSE HERE? %d\n", SKYPIAX_P_LOG, GetLastError()); } #else XEvent e; - Atom atom1 = XInternAtom(p->AsteriskHandlesAst.disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", False); + Atom atom1 = + XInternAtom(p->AsteriskHandlesAst.disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", False); memset(&e, 0, sizeof(e)); e.xclient.type = ClientMessage; e.xclient.message_type = atom1; /* leading message */ @@ -904,12 +904,11 @@ e.xclient.window = p->AsteriskHandlesAst.skype_win; e.xclient.format = 8; - - XSendEvent(p->AsteriskHandlesAst.disp, p->AsteriskHandlesAst.win, False, 0, &e); + XSendEvent(p->AsteriskHandlesAst.disp, p->AsteriskHandlesAst.win, False, 0, &e); XSync(p->AsteriskHandlesAst.disp, False); #endif while (x) { - x--; + x--; switch_yield(20000); } switch_thread_join(&status, skypiax_do_controldev_thread_thread); 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 Wed Dec 10 11:38:43 2008 @@ -73,8 +73,8 @@ sin_size = sizeof(remote_addr); while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) { DEBUGA_SKYPE("ACCEPTED\n", SKYPIAX_P_LOG); - if(!running) - break; + if (!running) + break; while (p->interface_state != SKYPIAX_STATE_DOWN && (p->skype_callflow == CALLFLOW_STATUS_INPROGRESS || p->skype_callflow == SKYPIAX_STATE_UP)) { @@ -88,8 +88,8 @@ fd_set fs; struct timeval to; - if(!running) - break; + if (!running) + break; exit = 1; fdselect = fd; @@ -241,8 +241,8 @@ sin_size = sizeof(remote_addr); while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) { DEBUGA_SKYPE("ACCEPTED\n", SKYPIAX_P_LOG); - if(!running) - break; + if (!running) + break; while (p->interface_state != SKYPIAX_STATE_DOWN && (p->skype_callflow == CALLFLOW_STATUS_INPROGRESS || p->skype_callflow == SKYPIAX_STATE_UP)) { @@ -255,8 +255,8 @@ fd_set fs; struct timeval to; - if(!running) - break; + if (!running) + break; fdselect = 1; FD_ZERO(&fs); FD_SET(fdselect, &fs); @@ -440,7 +440,7 @@ fIssueDefProc = 0; switch (uiMessage) { case WM_DESTROY: - NOTICA("got DESTROY\n", SKYPIAX_P_LOG); + NOTICA("got DESTROY\n", SKYPIAX_P_LOG); win32_hInit_MainWindowHandle = NULL; PostQuitMessage(0); break; @@ -593,29 +593,28 @@ && win32_uiGlobal_MsgID_SkypeControlAPIDiscover != 0) { if (win32_Initialize_CreateWindowClass()) { if (win32_Initialize_CreateMainWindow()) { - 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; - if(!running) - break; - while( GetMessage(&oMessage, 0, 0, 0) ){ - break; - TranslateMessage(&oMessage); - DispatchMessage(&oMessage); - } - } + 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; + if (!running) + break; + while (GetMessage(&oMessage, 0, 0, 0)) { + break; + TranslateMessage(&oMessage); + DispatchMessage(&oMessage); + } } + } win32_DeInitialize_DestroyMainWindow(); } win32_DeInitialize_DestroyWindowClass(); } } - switch_thread_exit(thread, SWITCH_STATUS_SUCCESS); return NULL; @@ -836,8 +835,8 @@ while (1) { XNextEvent(disp, &an_event); - if(!running) - break; + if (!running) + break; switch (an_event.type) { case ClientMessage: From gmaruzz at freeswitch.org Wed Dec 10 09:33:52 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Wed, 10 Dec 2008 12:33:52 -0500 Subject: [Freeswitch-branches] [commit] r10700 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Wed Dec 10 12:33:52 2008 New Revision: 10700 Log: skypiax: more warnings, but at least we got audio ;-) 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 Wed Dec 10 12:33:52 2008 @@ -20,13 +20,13 @@ void *obj) { struct skypiax_interface *p = obj; - short out[GG / 2]; + short srv_out[GG / 2]; int s; #ifdef WIN32 unsigned int len; unsigned int i; unsigned int a; - char in[GG]; + short srv_in[GG]; int sin_size; unsigned int fd; #else @@ -100,19 +100,19 @@ rt = select(fdselect + 1, &fs, NULL, NULL, &to); if (rt > 0) { - len = recv(fd, in, sizeof(short) * GG, 0); + len = recv(fd, srv_in, sizeof(short) * GG, 0); //DEBUGA_SKYPE("recv %d\n", SKYPIAX_P_LOG, len); if (len > 0) { a = 0; for (i = 0; i < len / sizeof(short); i++) { - out[a] = in[i]; + srv_out[a] = srv_in[i]; i++; a++; } if (!p->audiobuf_is_loaded) { for (i = 0; i < (len / sizeof(short)) / 2; i++) { - p->audiobuf[i] = out[i]; + p->audiobuf[i] = srv_out[i]; } p->audiobuf_is_loaded = 1; } else { @@ -125,7 +125,7 @@ howmany = len / 2 / 2; for (a = 0; a < howmany; a++) { - totalbuf[i] = out[a]; + totalbuf[i] = srv_out[a]; i++; } @@ -192,16 +192,16 @@ unsigned int len; unsigned int i; unsigned int a; - char in[NN / 2]; - char out[NN]; + short cli_in[NN / 2]; + short cli_out[NN]; int sin_size; unsigned int fd; #else int len; int i; int a; - short in[NN / 2]; - short out[NN]; + short cli_in[NN / 2]; + short cli_out[NN]; unsigned int sin_size; int fd; #endif /* WIN32 */ @@ -266,18 +266,18 @@ if (rt > 0) { got = (NN / 2) * sizeof(short); - switch_file_read(p->audioskypepipe[0], in, &got); + switch_file_read(p->audioskypepipe[0], cli_in, &got); if (got > 0) { a = 0; for (i = 0; i < got / sizeof(short); i++) { - out[a] = in[i]; + cli_out[a] = cli_in[i]; a++; - out[a] = in[i]; + cli_out[a] = cli_in[i]; a++; } - len = send(fd, out, got * 2, 0); + len = send(fd, cli_out, got * 2, 0); if (len == 0) { ERRORA("Skype server GONE\n", SKYPIAX_P_LOG); From gmaruzz at freeswitch.org Wed Dec 10 09:36:21 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Wed, 10 Dec 2008 12:36:21 -0500 Subject: [Freeswitch-branches] [commit] r10701 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Wed Dec 10 12:36:21 2008 New Revision: 10701 Log: skypiax: more warnings on windows, but win32 sound is working. 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 Wed Dec 10 12:36:21 2008 @@ -33,7 +33,7 @@ int len; int i; int a; - short in[GG]; + short srv_in[GG]; unsigned int sin_size; int fd; #endif /* WIN32 */ From gmaruzz at freeswitch.org Thu Dec 11 00:36:15 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Thu, 11 Dec 2008 03:36:15 -0500 Subject: [Freeswitch-branches] [commit] r10706 - freeswitch/branches/gmaruzz Message-ID: Author: gmaruzz Date: Thu Dec 11 03:36:13 2008 New Revision: 10706 Log: added modules.conf with skypiax Added: freeswitch/branches/gmaruzz/modules.conf Added: freeswitch/branches/gmaruzz/modules.conf ============================================================================== --- (empty file) +++ freeswitch/branches/gmaruzz/modules.conf Thu Dec 11 03:36:13 2008 @@ -0,0 +1,71 @@ +loggers/mod_console +loggers/mod_logfile +loggers/mod_syslog +applications/mod_commands +applications/mod_conference +applications/mod_dptools +applications/mod_enum +applications/mod_fifo +applications/mod_fax +applications/mod_voicemail +applications/mod_limit +applications/mod_expr +applications/mod_esf +applications/mod_fsv +#applications/mod_soundtouch +#applications/mod_rss +#applications/mod_snom +#asr_tts/mod_flite +#asr_tts/mod_pocketsphinx +#asr_tts/mod_cepstral +#asr_tts/mod_openmrcp +codecs/mod_g723_1 +codecs/mod_amr +codecs/mod_g729 +codecs/mod_h26x +codecs/mod_voipcodecs +codecs/mod_ilbc +codecs/mod_speex +#dialplans/mod_dialplan_directory +dialplans/mod_dialplan_xml +dialplans/mod_dialplan_asterisk +#directories/mod_ldap +endpoints/mod_dingaling +endpoints/mod_iax +endpoints/mod_skypiax +endpoints/mod_reference +endpoints/mod_portaudio +endpoints/mod_sofia +endpoints/mod_loopback +#endpoints/mod_woomera +#endpoints/mod_alsa +../../libs/openzap/mod_openzap +#event_handlers/mod_event_multicast +event_handlers/mod_event_socket +event_handlers/mod_cdr_csv +#event_handlers/mod_radius_cdr +formats/mod_native_file +formats/mod_sndfile +#formats/mod_shout +formats/mod_local_stream +formats/mod_tone_stream +#languages/mod_python +languages/mod_spidermonkey +languages/mod_spidermonkey_teletone +languages/mod_spidermonkey_core_db +languages/mod_spidermonkey_socket +#languages/mod_spidermonkey_odbc +languages/mod_lua +#languages/mod_perl +#languages/mod_yaml +xml_int/mod_xml_rpc +#xml_int/mod_xml_curl +xml_int/mod_xml_cdr +#xml_int/mod_xml_ldap +say/mod_say_en +#say/mod_say_de +#say/mod_say_es +#say/mod_say_fr +#say/mod_say_it +#say/mod_say_nl +#say/mod_say_zh From gmaruzz at freeswitch.org Thu Dec 11 00:38:45 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Thu, 11 Dec 2008 03:38:45 -0500 Subject: [Freeswitch-branches] [commit] r10707 - in freeswitch/branches/gmaruzz: src/mod/endpoints/mod_skypiax/configs stuff Message-ID: Author: gmaruzz Date: Thu Dec 11 03:38:45 2008 New Revision: 10707 Log: skypiax: added configs subdir, with configuration files. Removed stuff directory from root Added: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/configs/ - copied from r10696, /freeswitch/branches/gmaruzz/stuff/ Removed: freeswitch/branches/gmaruzz/stuff/ From gmaruzz at freeswitch.org Thu Dec 11 06:15:19 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Thu, 11 Dec 2008 09:15:19 -0500 Subject: [Freeswitch-branches] [commit] r10708 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Thu Dec 11 09:15:18 2008 New Revision: 10708 Log: skypiax: better function distribution between mod_skypiax.c and skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c (original) +++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c Thu Dec 11 09:15:18 2008 @@ -446,43 +446,6 @@ /*.receive_event */ channel_receive_event }; -int skypiax_skype_call(struct skypiax_interface *p, char *idest, int timeout, - switch_core_session_t * session) -{ - char *rdest; - char msg_to_skype[1024]; - - if (option_debug > 10) { - DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - } - switch_sleep(5000); - - rdest = strchr(idest, '/'); - *rdest++ = '\0'; - - if (option_debug) - DEBUGA_SKYPE("Calling Skype, rdest is: %s\n", SKYPIAX_P_LOG, rdest); - NOTICA("Calling Skype, rdest is: %s\n", SKYPIAX_P_LOG, rdest); - skypiax_skype_write(p, "SET AGC OFF"); - switch_sleep(10000); - skypiax_skype_write(p, "SET AEC OFF"); - switch_sleep(10000); - - sprintf(msg_to_skype, "CALL %s", rdest); - if (skypiax_skype_write(p, msg_to_skype) < 0) { - - ERRORA("failed to communicate with Skype client, now exit\n", SKYPIAX_P_LOG); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); - } - return -1; - } - global_session = session; - - //FIXME ast_queue_control(p->owner, SKYPIAX_CONTROL_RINGING); - return 0; -} - static switch_call_cause_t channel_outgoing_channel(switch_core_session_t * session, switch_event_t * var_event, switch_caller_profile_t * Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h ============================================================================== --- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h (original) +++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h Thu Dec 11 09:15:18 2008 @@ -214,3 +214,5 @@ int skypiax_skypeaudio_init(struct skypiax_interface *p); int skypiax_skype_write(struct skypiax_interface *p, char *msg_to_skype); int skypiax_skype_read(struct skypiax_interface *p); + +int skypiax_skype_call(struct skypiax_interface *p, char *idest, int timeout, switch_core_session_t * session); Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c ============================================================================== --- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c (original) +++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c Thu Dec 11 09:15:18 2008 @@ -1400,3 +1400,41 @@ //DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); return 0; } + +int skypiax_skype_call(struct skypiax_interface *p, char *idest, int timeout, switch_core_session_t * session) +{ + char *rdest; + char msg_to_skype[1024]; + + if (option_debug > 10) { + DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); + } + switch_sleep(5000); + + rdest = strchr(idest, '/'); + *rdest++ = '\0'; + + if (option_debug) + DEBUGA_SKYPE("Calling Skype, rdest is: %s\n", SKYPIAX_P_LOG, rdest); + NOTICA("Calling Skype, rdest is: %s\n", SKYPIAX_P_LOG, rdest); + skypiax_skype_write(p, "SET AGC OFF"); + switch_sleep(10000); + skypiax_skype_write(p, "SET AEC OFF"); + switch_sleep(10000); + + sprintf(msg_to_skype, "CALL %s", rdest); + if (skypiax_skype_write(p, msg_to_skype) < 0) { + + ERRORA("failed to communicate with Skype client, now exit\n", SKYPIAX_P_LOG); + if (option_debug > 10) { + DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); + } + return -1; + } + global_session = session; + + //FIXME ast_queue_control(p->owner, SKYPIAX_CONTROL_RINGING); + return 0; +} + + From gmaruzz at freeswitch.org Thu Dec 11 08:00:24 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Thu, 11 Dec 2008 11:00:24 -0500 Subject: [Freeswitch-branches] [commit] r10713 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Thu Dec 11 11:00:23 2008 New Revision: 10713 Log: skypiax: better function distribution between mod_skypiax.c and skypiax_protocol.c 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 11 11:00:23 2008 @@ -155,6 +155,53 @@ return SWITCH_STATUS_SUCCESS; } +static switch_status_t channel_on_hangup(switch_core_session_t * session) +{ + switch_channel_t *channel = NULL; + private_t *tech_pvt = NULL; + skypiax_interface_t *p; + char msg_to_skype[256]; + + channel = switch_core_session_get_channel(session); + assert(channel != NULL); + + tech_pvt = switch_core_session_get_private(session); + assert(tech_pvt != NULL); + + p = tech_pvt->p; + + switch_clear_flag_locked(tech_pvt, TFLAG_IO); + switch_clear_flag_locked(tech_pvt, TFLAG_VOICE); + //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); + } + + if (tech_pvt->write_codec.implementation) { + switch_core_codec_destroy(&tech_pvt->write_codec); + } + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL HANGUP\n", + switch_channel_get_name(channel)); + switch_mutex_lock(globals.mutex); + globals.calls--; + if (globals.calls < 0) { + globals.calls = 0; + } + switch_mutex_unlock(globals.mutex); + + return SWITCH_STATUS_SUCCESS; +} + static switch_status_t channel_on_routing(switch_core_session_t * session) { switch_channel_t *channel = NULL; @@ -879,52 +926,6 @@ return SWITCH_STATUS_SUCCESS; } -static switch_status_t channel_on_hangup(switch_core_session_t * session) -{ - switch_channel_t *channel = NULL; - private_t *tech_pvt = NULL; - skypiax_interface_t *p; - char msg_to_skype[256]; - - channel = switch_core_session_get_channel(session); - assert(channel != NULL); - - tech_pvt = switch_core_session_get_private(session); - assert(tech_pvt != NULL); - - p = tech_pvt->p; - - switch_clear_flag_locked(tech_pvt, TFLAG_IO); - switch_clear_flag_locked(tech_pvt, TFLAG_VOICE); - //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); - } - - if (tech_pvt->write_codec.implementation) { - switch_core_codec_destroy(&tech_pvt->write_codec); - } - - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%s CHANNEL HANGUP\n", - switch_channel_get_name(channel)); - switch_mutex_lock(globals.mutex); - globals.calls--; - if (globals.calls < 0) { - globals.calls = 0; - } - switch_mutex_unlock(globals.mutex); - - return SWITCH_STATUS_SUCCESS; -} /* For Emacs: * Local Variables: From cseket at freeswitch.org Fri Dec 12 00:43:14 2008 From: cseket at freeswitch.org (FreeSWITCH SVN) Date: Fri, 12 Dec 2008 03:43:14 -0500 Subject: [Freeswitch-branches] [commit] r10726 - freeswitch/branches/cseket/src/mod/applications/mod_voicemail Message-ID: Author: cseket Date: Fri Dec 12 03:43:13 2008 New Revision: 10726 Log: merge from trunk r10725 Added: freeswitch/branches/cseket/src/mod/applications/mod_voicemail/ (props changed) - copied from r10725, /freeswitch/trunk/src/mod/applications/mod_voicemail/ freeswitch/branches/cseket/src/mod/applications/mod_voicemail/Makefile - copied unchanged from r10725, /freeswitch/trunk/src/mod/applications/mod_voicemail/Makefile freeswitch/branches/cseket/src/mod/applications/mod_voicemail/mod_voicemail.2008.vcproj - copied unchanged from r10725, /freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.2008.vcproj freeswitch/branches/cseket/src/mod/applications/mod_voicemail/mod_voicemail.c - copied unchanged from r10725, /freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.c freeswitch/branches/cseket/src/mod/applications/mod_voicemail/mod_voicemail.vcproj - copied unchanged from r10725, /freeswitch/trunk/src/mod/applications/mod_voicemail/mod_voicemail.vcproj From cseket at freeswitch.org Fri Dec 12 00:58:45 2008 From: cseket at freeswitch.org (FreeSWITCH SVN) Date: Fri, 12 Dec 2008 03:58:45 -0500 Subject: [Freeswitch-branches] [commit] r10727 - freeswitch/branches/cseket/src/mod/applications/mod_voicemail Message-ID: Author: cseket Date: Fri Dec 12 03:58:45 2008 New Revision: 10727 Log: incomplete profile rescan (MODAPP-177) Modified: freeswitch/branches/cseket/src/mod/applications/mod_voicemail/mod_voicemail.c Modified: freeswitch/branches/cseket/src/mod/applications/mod_voicemail/mod_voicemail.c ============================================================================== --- freeswitch/branches/cseket/src/mod/applications/mod_voicemail/mod_voicemail.c (original) +++ freeswitch/branches/cseket/src/mod/applications/mod_voicemail/mod_voicemail.c Fri Dec 12 03:58:45 2008 @@ -54,6 +54,7 @@ static struct { switch_hash_t *profile_hash; int debug; + switch_mutex_t *mutex; switch_memory_pool_t *pool; } globals; @@ -125,6 +126,8 @@ uint32_t record_sample_rate; switch_odbc_handle_t *master_odbc; switch_bool_t auto_playback_recordings; + switch_thread_rwlock_t *rwlock; + switch_memory_pool_t *pool; }; typedef struct vm_profile vm_profile_t; @@ -232,15 +235,41 @@ " password VARCHAR(255)\n" ");\n"; +static void destroy_profile(vm_profile_t *profile) +{ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Destroying Profile %s\n", profile->name); +#ifdef SWITCH_HAVE_ODBC + if (profile->odbc_dsn && profile->master_odbc) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Closing ODBC Database! %s\n", profile->name); + switch_odbc_handle_destroy(&profile->master_odbc); + } +#endif + switch_core_destroy_memory_pool(&profile->pool); +} + +static vm_profile_t *create_profile(char *name) +{ + vm_profile_t *profile = NULL; + switch_memory_pool_t *pool; + + switch_core_new_memory_pool(&pool); + + profile = switch_core_alloc(pool, sizeof(*profile)); + profile->pool = pool; + switch_thread_rwlock_create(&profile->rwlock, pool); + profile->name = switch_core_strdup(pool, name); + + return profile; +} + + static switch_status_t load_config(void) { char *cf = "voicemail.conf"; - vm_profile_t *profile = NULL; + vm_profile_t *profile = NULL, *oldprofile = NULL; switch_xml_t cfg, xml, settings, param, x_profile, x_profiles, x_email; - - memset(&globals, 0, sizeof(globals)); - switch_core_new_memory_pool(&globals.pool); - switch_core_hash_init(&globals.profile_hash, globals.pool); + switch_hash_index_t *hi; + void *val; if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", cf); @@ -262,6 +291,38 @@ goto end; } + + /* destroy old profiles */ + destroy: + for (hi = switch_hash_first(NULL, globals.profile_hash); hi; hi = switch_hash_next(hi)) { + switch_hash_this(hi, NULL, NULL, &val); + profile = (vm_profile_t *) val; + int found = 0; + + for (x_profile = switch_xml_child(x_profiles, "profile"); x_profile; x_profile = x_profile->next) { + char *name = (char *) switch_xml_attr_soft(x_profile, "name"); + if (!(strcasecmp(profile->name, name))) { + found = 1; + break; + } + } + if (found) { + continue; + } + + /* delete from hash, so new comers can't find it */ + switch_mutex_lock(globals.mutex); + switch_core_hash_delete(globals.profile_hash, profile->name); + switch_mutex_unlock(globals.mutex); + + /* wait for readers */ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Deleting profile %s, when readers are left\n", profile->name); + switch_thread_rwlock_wrlock(profile->rwlock); + + destroy_profile(profile); + goto destroy; + } + for (x_profile = switch_xml_child(x_profiles, "profile"); x_profile; x_profile = x_profile->next) { char *name = (char *) switch_xml_attr_soft(x_profile, "name"); char *odbc_dsn = NULL, *odbc_user = NULL, *odbc_pass = NULL; @@ -323,13 +384,21 @@ db = NULL; + if (switch_strlen_zero(name)) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No name specified.\n"); + continue; + } + + oldprofile = switch_core_hash_find(globals.profile_hash, name); + profile = create_profile(name); + if ((x_email = switch_xml_child(x_profile, "email"))) { if ((param = switch_xml_child(x_email, "body"))) { - email_body = switch_core_strdup(globals.pool, param->txt); + email_body = switch_core_strdup(profile->pool, param->txt); } if ((param = switch_xml_child(x_email, "headers"))) { - email_headers = switch_core_strdup(globals.pool, param->txt); + email_headers = switch_core_strdup(profile->pool, param->txt); } for (param = switch_xml_child(x_email, "param"); param; param = param->next) { @@ -588,7 +657,7 @@ } } else if (!strcasecmp(var, "odbc-dsn") && !switch_strlen_zero(val)) { #ifdef SWITCH_HAVE_ODBC - odbc_dsn = switch_core_strdup(globals.pool, val); + odbc_dsn = switch_core_strdup(profile->pool, val); if ((odbc_user = strchr(odbc_dsn, ':'))) { *odbc_user++ = '\0'; if ((odbc_pass = strchr(odbc_user, ':'))) { @@ -603,165 +672,173 @@ } } - if (switch_strlen_zero(name)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No name specified.\n"); - } else { - profile = switch_core_alloc(globals.pool, sizeof(*profile)); - profile->name = switch_core_strdup(globals.pool, name); - if (!switch_strlen_zero(odbc_dsn) && !switch_strlen_zero(odbc_user) && !switch_strlen_zero(odbc_pass)) { - profile->odbc_dsn = odbc_dsn; - profile->odbc_user = odbc_user; - profile->odbc_pass = odbc_pass; - } else { - profile->dbname = switch_core_sprintf(globals.pool, "voicemail_%s", name); - } - if (profile->odbc_dsn) { + if (!switch_strlen_zero(odbc_dsn) && !switch_strlen_zero(odbc_user) && !switch_strlen_zero(odbc_pass)) { + profile->odbc_dsn = odbc_dsn; + profile->odbc_user = odbc_user; + profile->odbc_pass = odbc_pass; + } else { + profile->dbname = switch_core_sprintf(profile->pool, "voicemail_%s", name); + } + if (profile->odbc_dsn) { #ifdef SWITCH_HAVE_ODBC - if (!(profile->master_odbc = switch_odbc_handle_new(profile->odbc_dsn, profile->odbc_user, profile->odbc_pass))) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open ODBC Database!\n"); - continue; + if (!(profile->master_odbc = switch_odbc_handle_new(profile->odbc_dsn, profile->odbc_user, profile->odbc_pass))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open ODBC Database!\n"); + continue; - } - if (switch_odbc_handle_connect(profile->master_odbc) != SWITCH_ODBC_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open ODBC Database!\n"); - continue; - } + } + if (switch_odbc_handle_connect(profile->master_odbc) != SWITCH_ODBC_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open ODBC Database!\n"); + continue; + } - if (switch_odbc_handle_exec(profile->master_odbc, "select count(message_len) from voicemail_msgs", NULL) != SWITCH_ODBC_SUCCESS) { - switch_odbc_handle_exec(profile->master_odbc, "drop table voicemail_msgs", NULL); - switch_odbc_handle_exec(profile->master_odbc, vm_sql, NULL); - } + if (switch_odbc_handle_exec(profile->master_odbc, "select count(message_len) from voicemail_msgs", NULL) != SWITCH_ODBC_SUCCESS) { + switch_odbc_handle_exec(profile->master_odbc, "drop table voicemail_msgs", NULL); + switch_odbc_handle_exec(profile->master_odbc, vm_sql, NULL); + } - if (switch_odbc_handle_exec(profile->master_odbc, "select count(username) from voicemail_prefs", NULL) != SWITCH_ODBC_SUCCESS) { - switch_odbc_handle_exec(profile->master_odbc, "drop table voicemail_prefs", NULL); - switch_odbc_handle_exec(profile->master_odbc, vm_pref_sql, NULL); - } + if (switch_odbc_handle_exec(profile->master_odbc, "select count(username) from voicemail_prefs", NULL) != SWITCH_ODBC_SUCCESS) { + switch_odbc_handle_exec(profile->master_odbc, "drop table voicemail_prefs", NULL); + switch_odbc_handle_exec(profile->master_odbc, vm_pref_sql, NULL); + } - if (switch_odbc_handle_exec(profile->master_odbc, "select count(password) from voicemail_prefs", NULL) != SWITCH_ODBC_SUCCESS) { - switch_odbc_handle_exec(profile->master_odbc, "alter table voicemail_prefs add password varchar(255)", NULL); - } + if (switch_odbc_handle_exec(profile->master_odbc, "select count(password) from voicemail_prefs", NULL) != SWITCH_ODBC_SUCCESS) { + switch_odbc_handle_exec(profile->master_odbc, "alter table voicemail_prefs add password varchar(255)", NULL); + } - if (switch_odbc_handle_exec(profile->master_odbc, "select count(message_len) from voicemail_data", NULL) == SWITCH_ODBC_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Old table voicemail_data found, migrating data!\n"); - /* XXX: Old table found.. migrating data into new table */ - if (switch_odbc_handle_exec(profile->master_odbc, - "insert into voicemail_msgs select created_epoch, read_epoch, user as username, domain, uuid," - "cid_name, cid_number, in_folder, file_path, message_len, flags, read_flags from voicemail_data", - NULL) != SWITCH_ODBC_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed to migrate old voicemail_data to voicemail_msgs!\n"); - continue; - } - switch_odbc_handle_exec(profile->master_odbc, "drop table voicemail_data", NULL); + if (switch_odbc_handle_exec(profile->master_odbc, "select count(message_len) from voicemail_data", NULL) == SWITCH_ODBC_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Old table voicemail_data found, migrating data!\n"); + /* XXX: Old table found.. migrating data into new table */ + if (switch_odbc_handle_exec(profile->master_odbc, + "insert into voicemail_msgs select created_epoch, read_epoch, user as username, domain, uuid," + "cid_name, cid_number, in_folder, file_path, message_len, flags, read_flags from voicemail_data", + NULL) != SWITCH_ODBC_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed to migrate old voicemail_data to voicemail_msgs!\n"); + continue; } + switch_odbc_handle_exec(profile->master_odbc, "drop table voicemail_data", NULL); + } #endif - } else { - if ((db = switch_core_db_open_file(profile->dbname))) { - char *errmsg; - switch_core_db_test_reactive(db, "select count(message_len) from voicemail_msgs", "drop table voicemail_msgs", vm_sql); - - switch_core_db_exec(db, "select count(message_len) from voicemail_data", NULL, NULL, &errmsg); + } else { + if ((db = switch_core_db_open_file(profile->dbname))) { + char *errmsg; + switch_core_db_test_reactive(db, "select count(message_len) from voicemail_msgs", "drop table voicemail_msgs", vm_sql); + + switch_core_db_exec(db, "select count(message_len) from voicemail_data", NULL, NULL, &errmsg); + if (errmsg) { + switch_core_db_free(errmsg); + errmsg = NULL; + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Migrating data from voicemail_data to voicemail_msgs!\n"); + switch_core_db_exec(db, "insert into voicemail_msgs select created_epoch, read_epoch, user as username, domain, uuid," + "cid_name, cid_number, in_folder, file_path, message_len, flags, read_flags from voicemail_data", + NULL, NULL, &errmsg); if (errmsg) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SQL ERR [%s]\n", errmsg); switch_core_db_free(errmsg); errmsg = NULL; - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Migrating data from voicemail_data to voicemail_msgs!\n"); - switch_core_db_exec(db, "insert into voicemail_msgs select created_epoch, read_epoch, user as username, domain, uuid," - "cid_name, cid_number, in_folder, file_path, message_len, flags, read_flags from voicemail_data", - NULL, NULL, &errmsg); - if (errmsg) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SQL ERR [%s]\n", errmsg); - switch_core_db_free(errmsg); - errmsg = NULL; - } - switch_core_db_exec(db, "drop table voicemail_data", NULL, NULL, &errmsg); - if (errmsg) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SQL ERR [%s]\n", errmsg); - switch_core_db_free(errmsg); - errmsg = NULL; - } } + switch_core_db_exec(db, "drop table voicemail_data", NULL, NULL, &errmsg); + if (errmsg) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "SQL ERR [%s]\n", errmsg); + switch_core_db_free(errmsg); + errmsg = NULL; + } + } - switch_core_db_test_reactive(db, "select count(username) from voicemail_prefs", "drop table voicemail_prefs", vm_pref_sql); - switch_core_db_test_reactive(db, "select count(password) from voicemail_prefs", NULL, + switch_core_db_test_reactive(db, "select count(username) from voicemail_prefs", "drop table voicemail_prefs", vm_pref_sql); + switch_core_db_test_reactive(db, "select count(password) from voicemail_prefs", NULL, "alter table voicemail_prefs add password varchar(255)"); - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open SQL Database!\n"); - continue; - } - switch_core_db_close(db); + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open SQL Database!\n"); + continue; } + switch_core_db_close(db); + } - profile->web_head = web_head; - profile->web_tail = web_tail; + profile->web_head = web_head; + profile->web_tail = web_tail; - profile->email_body = email_body; - profile->email_headers = email_headers; - if (notify_email_headers) { - profile->notify_email_body = notify_email_body; - profile->notify_email_headers = notify_email_headers; - } else { - profile->notify_email_body = email_body; - profile->notify_email_headers = email_headers; - } - profile->email_from = switch_core_strdup(globals.pool, email_from); - profile->date_fmt = switch_core_strdup(globals.pool, date_fmt); - profile->play_date_announcement = play_date_announcement; - - profile->digit_timeout = timeout; - profile->max_login_attempts = max_login_attempts; - profile->min_record_len = min_record_len; - profile->max_record_len = max_record_len; - *profile->terminator_key = *terminator_key; - *profile->play_new_messages_key = *play_new_messages_key; - *profile->play_saved_messages_key = *play_saved_messages_key; - *profile->main_menu_key = *main_menu_key; - *profile->config_menu_key = *config_menu_key; - *profile->record_greeting_key = *record_greeting_key; - *profile->choose_greeting_key = *choose_greeting_key; - *profile->record_name_key = *record_name_key; - *profile->change_pass_key = *change_pass_key; - *profile->record_file_key = *record_file_key; - *profile->listen_file_key = *listen_file_key; - *profile->save_file_key = *save_file_key; - *profile->delete_file_key = *delete_file_key; - *profile->undelete_file_key = *undelete_file_key; - *profile->email_key = *email_key; - *profile->callback_key = *callback_key; - *profile->pause_key = *pause_key; - *profile->restart_key = *restart_key; - *profile->ff_key = *ff_key; - *profile->rew_key = *rew_key; - *profile->urgent_key = *urgent_key; - *profile->operator_key = *operator_key; - *profile->vmain_key = *vmain_key; - *profile->forward_key = *forward_key; - *profile->prepend_key = *prepend_key; - profile->record_threshold = record_threshold; - profile->record_silence_hits = record_silence_hits; - profile->record_sample_rate = record_sample_rate; - - profile->auto_playback_recordings = auto_playback_recordings; - profile->operator_ext = switch_core_strdup(globals.pool, operator_ext); - profile->vmain_ext = switch_core_strdup(globals.pool, vmain_ext); - profile->storage_dir = switch_core_strdup(globals.pool, storage_dir); - profile->tone_spec = switch_core_strdup(globals.pool, tone_spec); - profile->callback_dialplan = switch_core_strdup(globals.pool, callback_dialplan); - profile->callback_context = switch_core_strdup(globals.pool, callback_context); - - profile->record_title = switch_core_strdup(globals.pool, record_title); - profile->record_comment = switch_core_strdup(globals.pool, record_comment); - profile->record_copyright = switch_core_strdup(globals.pool, record_copyright); + profile->email_body = email_body; + profile->email_headers = email_headers; + if (notify_email_headers) { + profile->notify_email_body = notify_email_body; + profile->notify_email_headers = notify_email_headers; + } else { + profile->notify_email_body = email_body; + profile->notify_email_headers = email_headers; + } + profile->email_from = switch_core_strdup(profile->pool, email_from); + profile->date_fmt = switch_core_strdup(profile->pool, date_fmt); + profile->play_date_announcement = play_date_announcement; + + profile->digit_timeout = timeout; + profile->max_login_attempts = max_login_attempts; + profile->min_record_len = min_record_len; + profile->max_record_len = max_record_len; + *profile->terminator_key = *terminator_key; + *profile->play_new_messages_key = *play_new_messages_key; + *profile->play_saved_messages_key = *play_saved_messages_key; + *profile->main_menu_key = *main_menu_key; + *profile->config_menu_key = *config_menu_key; + *profile->record_greeting_key = *record_greeting_key; + *profile->choose_greeting_key = *choose_greeting_key; + *profile->record_name_key = *record_name_key; + *profile->change_pass_key = *change_pass_key; + *profile->record_file_key = *record_file_key; + *profile->listen_file_key = *listen_file_key; + *profile->save_file_key = *save_file_key; + *profile->delete_file_key = *delete_file_key; + *profile->undelete_file_key = *undelete_file_key; + *profile->email_key = *email_key; + *profile->callback_key = *callback_key; + *profile->pause_key = *pause_key; + *profile->restart_key = *restart_key; + *profile->ff_key = *ff_key; + *profile->rew_key = *rew_key; + *profile->urgent_key = *urgent_key; + *profile->operator_key = *operator_key; + *profile->vmain_key = *vmain_key; + *profile->forward_key = *forward_key; + *profile->prepend_key = *prepend_key; + profile->record_threshold = record_threshold; + profile->record_silence_hits = record_silence_hits; + profile->record_sample_rate = record_sample_rate; + profile->auto_playback_recordings = auto_playback_recordings; + profile->operator_ext = switch_core_strdup(profile->pool, operator_ext); + profile->vmain_ext = switch_core_strdup(profile->pool, vmain_ext); + profile->storage_dir = switch_core_strdup(profile->pool, storage_dir); + profile->tone_spec = switch_core_strdup(profile->pool, tone_spec); + profile->callback_dialplan = switch_core_strdup(profile->pool, callback_dialplan); + profile->callback_context = switch_core_strdup(profile->pool, callback_context); + profile->record_title = switch_core_strdup(profile->pool, record_title); + profile->record_comment = switch_core_strdup(profile->pool, record_comment); + profile->record_copyright = switch_core_strdup(profile->pool, record_copyright); + switch_copy_string(profile->file_ext, file_ext, sizeof(profile->file_ext)); + switch_mutex_init(&profile->mutex, SWITCH_MUTEX_UNNESTED, profile->pool); + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Added Profile %s\n", profile->name); + if (oldprofile) { + + /* wait */ + /* deadlock on concurrent voicemail rescan */ + while (switch_thread_rwlock_trywrlock_timeout(oldprofile->rwlock, 10) != SWITCH_STATUS_SUCCESS); + + switch_mutex_lock(globals.mutex); + /* change the profile*/ + switch_core_hash_delete(globals.profile_hash, oldprofile->name); + switch_core_hash_insert(globals.profile_hash, profile->name, profile); + switch_mutex_unlock(globals.mutex); - switch_copy_string(profile->file_ext, file_ext, sizeof(profile->file_ext)); - switch_mutex_init(&profile->mutex, SWITCH_MUTEX_NESTED, globals.pool); + destroy_profile(oldprofile); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Added Profile %s\n", profile->name); + } else { switch_core_hash_insert(globals.profile_hash, profile->name, profile); } } + end: switch_xml_free(xml); return SWITCH_STATUS_SUCCESS; @@ -1626,11 +1703,16 @@ caller_id_number = caller_profile->caller_id_number; } + switch_mutex_lock(globals.mutex); + if (!(profile = switch_core_hash_find(globals.profile_hash, profile_name))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error invalid profile %s\n", profile_name); + switch_mutex_unlock(globals.mutex); return; } - + switch_thread_rwlock_rdlock(profile->rwlock); + switch_mutex_unlock(globals.mutex); + timeout = profile->digit_timeout; attempts = profile->max_login_attempts; status = switch_ivr_phrase_macro(session, VM_HELLO_MACRO, NULL, NULL, &args); @@ -2146,6 +2228,8 @@ end: + switch_thread_rwlock_unlock(profile->rwlock); + if (switch_channel_ready(channel)) { if (failed) { status = switch_ivr_phrase_macro(session, VM_ABORT_MACRO, NULL, NULL, NULL); @@ -2548,6 +2632,7 @@ goto end; } + switch_mutex_lock(globals.mutex); if (!(profile = switch_core_hash_find(globals.profile_hash, domain))) { profile = switch_core_hash_find(globals.profile_hash, "default"); } @@ -2555,11 +2640,15 @@ if (!profile) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't find profile\n"); status = SWITCH_STATUS_FALSE; + switch_mutex_unlock(globals.mutex); } else { switch_xml_t x_domain, xml_root; switch_event_t *my_params = NULL; switch_xml_t ut; + switch_thread_rwlock_rdlock(profile->rwlock); + switch_mutex_unlock(globals.mutex); + switch_event_create(&my_params, SWITCH_EVENT_REQUEST_PARAMS); switch_assert(my_params); switch_event_add_header_string(my_params, SWITCH_STACK_BOTTOM, "domain", domain); @@ -2595,6 +2684,7 @@ } } } + switch_thread_rwlock_unlock(profile->rwlock); switch_core_destroy_memory_pool(&pool); @@ -2658,11 +2748,18 @@ } memset(&cbt, 0, sizeof(cbt)); + + switch_mutex_lock(globals.mutex); + if (!(profile = switch_core_hash_find(globals.profile_hash, profile_name))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error invalid profile %s\n", profile_name); - return SWITCH_STATUS_FALSE; + switch_mutex_unlock(globals.mutex); + return SWITCH_STATUS_FALSE;; } + switch_thread_rwlock_rdlock(profile->rwlock); + switch_mutex_unlock(globals.mutex); + if (id) { int ok = 1; switch_event_t *params = NULL; @@ -2903,6 +3000,8 @@ end: + switch_thread_rwlock_unlock(profile->rwlock); + if (x_domain_root) { switch_xml_free(x_domain_root); x_domain_root = NULL; @@ -3025,7 +3124,7 @@ *p++ = '\0'; how = p; } - + switch_mutex_lock(globals.mutex); for (hi = switch_hash_first(NULL, globals.profile_hash); hi; hi = switch_hash_next(hi)) { switch_hash_this(hi, NULL, NULL, &val); profile = (vm_profile_t *) val; @@ -3033,6 +3132,7 @@ message_count(profile, id, domain, "inbox", &total_new_messages, &total_saved_messages, &total_new_urgent_messages, &total_saved_urgent_messages); } + switch_mutex_unlock(globals.mutex); } switch_safe_free(id); @@ -3132,7 +3232,6 @@ } -#define VOICEMAIL_SYNTAX "rss [ ]" struct holder { vm_profile_t *profile; @@ -3565,6 +3664,7 @@ return SWITCH_STATUS_SUCCESS; } +#define VOICEMAIL_SYNTAX "rss [ ] | rescan [reloadxml]" SWITCH_STANDARD_API(voicemail_api_function) { int argc = 0; @@ -3575,6 +3675,8 @@ vm_profile_t *profile = NULL; char *path_info = NULL; int rss = 0, xarg = 0; + switch_hash_index_t *hi; + void *val = NULL; if (session) { return SWITCH_STATUS_FALSE; @@ -3599,6 +3701,34 @@ if (!strcasecmp(argv[0], "rss")) { rss++; xarg++; + } else if (!strcasecmp(argv[0], "rescan")) { + switch_xml_t xml_root; + const char *err; + if (argc > 1 && !strcasecmp(argv[1], "reloadxml")) { + if ((xml_root = switch_xml_open_root(1, &err))) { + switch_xml_free(xml_root); + } + stream->write_function(stream, "Reload XML [%s]\n", err); + } + if (load_config() == SWITCH_STATUS_SUCCESS) { + stream->write_function(stream, "+OK scan complete\n"); + } else { + stream->write_function(stream, "-ERR scan failed\n"); + goto error; + } + goto done; + } else if (!strcasecmp(argv[0], "status")) { + stream->write_function(stream, "============================\n"); + switch_mutex_lock(globals.mutex); + for (hi = switch_hash_first(NULL, globals.profile_hash); hi; hi = switch_hash_next(hi)) { + vm_profile_t * profile = NULL; + switch_hash_this(hi, NULL, NULL, &val); + profile = (vm_profile_t *) val; + stream->write_function(stream, "Profile: %s\n", profile->name); + } + switch_mutex_unlock(globals.mutex); + stream->write_function(stream, "============================\n"); + goto done; } } @@ -3617,6 +3747,7 @@ goto error; } + switch_mutex_lock(globals.mutex); profile = switch_core_hash_find(globals.profile_hash, domain); if (!profile) { @@ -3638,9 +3769,13 @@ if (!profile) { stream->write_function(stream, "Can't find profile.\n"); + switch_mutex_unlock(globals.mutex); goto error; } + switch_thread_rwlock_rdlock(profile->rwlock); + switch_mutex_unlock(globals.mutex); + if (path_info) { if (!strncasecmp(path_info, "get/", 4)) { do_play(profile, user, domain, path_info + 4, stream); @@ -3654,6 +3789,7 @@ if (rss || (path_info && !strncasecmp(path_info, "rss", 3))) { do_rss(profile, user, domain, host, port, uri, stream); } + switch_thread_rwlock_unlock(profile->rwlock); goto done; @@ -3683,6 +3819,12 @@ return SWITCH_STATUS_TERM; } + memset(&globals, 0, sizeof(globals)); + switch_core_new_memory_pool(&globals.pool); + switch_core_hash_init(&globals.profile_hash, globals.pool); + switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, globals.pool); + + if ((status = load_config()) != SWITCH_STATUS_SUCCESS) { return status; } From cseket at freeswitch.org Fri Dec 12 01:16:12 2008 From: cseket at freeswitch.org (FreeSWITCH SVN) Date: Fri, 12 Dec 2008 04:16:12 -0500 Subject: [Freeswitch-branches] [commit] r10728 - freeswitch/branches/cseket/src/mod/applications/mod_voicemail Message-ID: Author: cseket Date: Fri Dec 12 04:16:12 2008 New Revision: 10728 Log: deadlock version of MODAPP-177 Modified: freeswitch/branches/cseket/src/mod/applications/mod_voicemail/mod_voicemail.c Modified: freeswitch/branches/cseket/src/mod/applications/mod_voicemail/mod_voicemail.c ============================================================================== --- freeswitch/branches/cseket/src/mod/applications/mod_voicemail/mod_voicemail.c (original) +++ freeswitch/branches/cseket/src/mod/applications/mod_voicemail/mod_voicemail.c Fri Dec 12 04:16:12 2008 @@ -816,7 +816,7 @@ profile->record_comment = switch_core_strdup(profile->pool, record_comment); profile->record_copyright = switch_core_strdup(profile->pool, record_copyright); switch_copy_string(profile->file_ext, file_ext, sizeof(profile->file_ext)); - switch_mutex_init(&profile->mutex, SWITCH_MUTEX_UNNESTED, profile->pool); + switch_mutex_init(&profile->mutex, SWITCH_MUTEX_NESTED, profile->pool); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Added Profile %s\n", profile->name); if (oldprofile) { From cseket at freeswitch.org Fri Dec 12 02:20:25 2008 From: cseket at freeswitch.org (FreeSWITCH SVN) Date: Fri, 12 Dec 2008 05:20:25 -0500 Subject: [Freeswitch-branches] [commit] r10729 - freeswitch/branches/cseket/src/mod/applications/mod_voicemail Message-ID: Author: cseket Date: Fri Dec 12 05:20:25 2008 New Revision: 10729 Log: memory leak version of MODAPP-177 Modified: freeswitch/branches/cseket/src/mod/applications/mod_voicemail/mod_voicemail.c Modified: freeswitch/branches/cseket/src/mod/applications/mod_voicemail/mod_voicemail.c ============================================================================== --- freeswitch/branches/cseket/src/mod/applications/mod_voicemail/mod_voicemail.c (original) +++ freeswitch/branches/cseket/src/mod/applications/mod_voicemail/mod_voicemail.c Fri Dec 12 05:20:25 2008 @@ -266,7 +266,7 @@ static switch_status_t load_config(void) { char *cf = "voicemail.conf"; - vm_profile_t *profile = NULL, *oldprofile = NULL; + vm_profile_t *profile = NULL; switch_xml_t cfg, xml, settings, param, x_profile, x_profiles, x_email; switch_hash_index_t *hi; void *val; @@ -376,6 +376,7 @@ char *record_title = "FreeSWITCH Voicemail"; char *record_comment = "FreeSWITCH Voicemail"; char *record_copyright = "http://www.freeswitch.org"; + int change_profile = 0; switch_bool_t auto_playback_recordings = SWITCH_TRUE; @@ -389,8 +390,12 @@ continue; } - oldprofile = switch_core_hash_find(globals.profile_hash, name); - profile = create_profile(name); + if (!(profile = switch_core_hash_find(globals.profile_hash, name))) { + profile = create_profile(name); + } else { + change_profile = 1; + switch_thread_rwlock_wrlock(profile->rwlock); + } if ((x_email = switch_xml_child(x_profile, "email"))) { if ((param = switch_xml_child(x_email, "body"))) { @@ -672,6 +677,15 @@ } } +#ifdef SWITCH_HAVE_ODBC + if (profile->odbc_dsn && profile->master_odbc) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Closing ODBC Database! %s\n", profile->name); + switch_odbc_handle_destroy(&profile->master_odbc); + profile->odbc_dsn = NULL; + profile->odbc_user = NULL; + profile->odbc_pass = NULL; + } +#endif if (!switch_strlen_zero(odbc_dsn) && !switch_strlen_zero(odbc_user) && !switch_strlen_zero(odbc_pass)) { profile->odbc_dsn = odbc_dsn; @@ -818,23 +832,13 @@ switch_copy_string(profile->file_ext, file_ext, sizeof(profile->file_ext)); switch_mutex_init(&profile->mutex, SWITCH_MUTEX_NESTED, profile->pool); - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Added Profile %s\n", profile->name); - if (oldprofile) { - - /* wait */ - /* deadlock on concurrent voicemail rescan */ - while (switch_thread_rwlock_trywrlock_timeout(oldprofile->rwlock, 10) != SWITCH_STATUS_SUCCESS); - + if (change_profile) { + switch_thread_rwlock_unlock(profile->rwlock); + } else { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Added Profile %s\n", profile->name); switch_mutex_lock(globals.mutex); - /* change the profile*/ - switch_core_hash_delete(globals.profile_hash, oldprofile->name); switch_core_hash_insert(globals.profile_hash, profile->name, profile); switch_mutex_unlock(globals.mutex); - - destroy_profile(oldprofile); - - } else { - switch_core_hash_insert(globals.profile_hash, profile->name, profile); } } From gmaruzz at freeswitch.org Sat Dec 13 00:31:51 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Sat, 13 Dec 2008 03:31:51 -0500 Subject: [Freeswitch-branches] [commit] r10750 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Sat Dec 13 03:31:50 2008 New Revision: 10750 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.h freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c (original) +++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c Sat Dec 13 03:31:50 2008 @@ -20,6 +20,7 @@ int fd; int calls; char hold_music[256]; + skypiax_interface_t SKYPIAX_INTERFACES[SKYPIAX_MAX_INTERFACES]; switch_mutex_t *mutex; } globals; @@ -30,14 +31,11 @@ switch_endpoint_interface_t *skypiax_endpoint_interface; switch_memory_pool_t *skypiax_module_pool = NULL; int running = 1; -skypiax_interface_t SKYPIAX_INTERFACES[SKYPIAX_MAX_INTERFACES]; switch_core_session_t *global_session = NULL; #ifdef WIN32 HANDLE win32_hGlobal_ThreadShutdownEvent; HWND win32_hInit_MainWindowHandle; #endif /* WIN32 */ -switch_thread_t *skypiax_do_controldev_thread_thread; -switch_thread_t *do_skype_thread_thread; /*************************************************/ /*************************************************/ /*************************************************/ @@ -509,7 +507,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_INTERFACES[2]; //FIXME + tech_pvt->p = &globals.SKYPIAX_INTERFACES[2]; //FIXME channel = switch_core_session_get_channel(*new_session); skypiax_tech_init(tech_pvt, *new_session, NULL); } else { @@ -754,44 +752,54 @@ if (name) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "name=%s\n", name); } + +#ifndef WIN32 + if (!XInitThreads()) { + ERRORA("Not initialized XInitThreads!\n", SKYPIAX_P_LOG); + } else { + DEBUGA_SKYPE("Initialized XInitThreads!\n", SKYPIAX_P_LOG); + } + switch_sleep(100); +#endif /* WIN32 */ + if (interface_id && interface_id < SKYPIAX_MAX_INTERFACES) { struct skypiax_interface newconf; switch_threadattr_t *do_skype_thd_attr = NULL; switch_threadattr_t *skypiax_do_controldev_thread_thd_attr = NULL; memset(&newconf, '\0', sizeof(newconf)); - SKYPIAX_INTERFACES[interface_id] = newconf; + globals.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); + switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].interface_id, id); if (name) { - switch_set_string(SKYPIAX_INTERFACES[interface_id].name, name); + switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].name, name); } else { - switch_set_string(SKYPIAX_INTERFACES[interface_id].name, "N/A"); + switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].name, "N/A"); } - 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_set_string(globals.SKYPIAX_INTERFACES[interface_id].X11_display, X11_display); + switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].context, context); + switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].dialplan, dialplan); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, - "interface_id=%d SKYPIAX_INTERFACES[interface_id].X11_display=%s\n", - interface_id, SKYPIAX_INTERFACES[interface_id].X11_display); + "interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].X11_display=%s\n", + interface_id, globals.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); + "interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].name=%s\n", + interface_id, globals.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); + "interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].context=%s\n", + interface_id, globals.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); + "interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].dialplan=%s\n", + interface_id, globals.SKYPIAX_INTERFACES[interface_id].dialplan); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "STARTING interface_id=%d\n", interface_id); switch_threadattr_create(&do_skype_thd_attr, skypiax_module_pool); //switch_threadattr_detach_set(do_skype_thd_attr, 1); switch_threadattr_stacksize_set(do_skype_thd_attr, SWITCH_THREAD_STACKSIZE); - switch_thread_create(&do_skype_thread_thread, do_skype_thd_attr, do_skype_thread, - &SKYPIAX_INTERFACES[interface_id], skypiax_module_pool); + switch_thread_create(&globals.SKYPIAX_INTERFACES[interface_id].skypiax_do_skype_thread_thread, do_skype_thd_attr, do_skype_thread, + &globals.SKYPIAX_INTERFACES[interface_id], skypiax_module_pool); switch_sleep(100000); @@ -800,14 +808,14 @@ //switch_threadattr_detach_set(skypiax_do_controldev_thread_thd_attr, 1); switch_threadattr_stacksize_set(skypiax_do_controldev_thread_thd_attr, SWITCH_THREAD_STACKSIZE); - switch_thread_create(&skypiax_do_controldev_thread_thread, + switch_thread_create(&globals.SKYPIAX_INTERFACES[interface_id].skypiax_do_controldev_thread_thread, skypiax_do_controldev_thread_thd_attr, skypiax_do_controldev_thread, - &SKYPIAX_INTERFACES[interface_id], skypiax_module_pool); + &globals.SKYPIAX_INTERFACES[interface_id], skypiax_module_pool); switch_sleep(1000000); - skypiax_skypeaudio_init(&SKYPIAX_INTERFACES[interface_id]); + skypiax_skypeaudio_init(&globals.SKYPIAX_INTERFACES[interface_id]); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "STARTED interface_id=%d\n", interface_id); @@ -822,22 +830,22 @@ } for (i = 0; i < SKYPIAX_MAX_INTERFACES; i++) { - if (strlen(SKYPIAX_INTERFACES[i].name)) { + if (strlen(globals.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); + "i=%d globals.SKYPIAX_INTERFACES[%d].interface_id=%s\n", i, i, + globals.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); + "i=%d globals.SKYPIAX_INTERFACES[%d].X11_display=%s\n", i, i, + globals.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); + "i=%d globals.SKYPIAX_INTERFACES[%d].name=%s\n", i, i, + globals.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); + "i=%d globals.SKYPIAX_INTERFACES[%d].context=%s\n", i, i, + globals.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); + "i=%d globals.SKYPIAX_INTERFACES[%d].dialplan=%s\n", i, i, + globals.SKYPIAX_INTERFACES[i].dialplan); } } } @@ -849,21 +857,12 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_skypiax_load) { - struct skypiax_interface *p = NULL; + struct skypiax_interface *p = NULL; //for logging skypiax_module_pool = pool; memset(&globals, '\0', sizeof(globals)); - memset(SKYPIAX_INTERFACES, '\0', sizeof(SKYPIAX_INTERFACES)); - -#ifndef WIN32 - if (!XInitThreads()) { - ERRORA("Not initialized XInitThreads!\n", SKYPIAX_P_LOG); - } else { - DEBUGA_SKYPE("Initialized XInitThreads!\n", SKYPIAX_P_LOG); - } - switch_sleep(100); -#endif /* _WINDOWS_ */ + //memset(globals.SKYPIAX_INTERFACES, '\0', sizeof(globals.SKYPIAX_INTERFACES)); load_config(); @@ -892,13 +891,20 @@ struct skypiax_interface *p = NULL; switch_status_t status; unsigned int howmany = 8; +int interface_id; - p = &SKYPIAX_INTERFACES[2]; + //p = &globals.SKYPIAX_INTERFACES[2]; running = 0; +for(interface_id=0; interface_id < SKYPIAX_MAX_INTERFACES; interface_id++){ + p = &globals.SKYPIAX_INTERFACES[interface_id]; + +if(globals.SKYPIAX_INTERFACES[interface_id].skypiax_do_controldev_thread_thread){ switch_file_write(p->AsteriskHandlesAst.fdesc[1], "sciutati", &howmany); // let's the controldev_thread die + } +if(globals.SKYPIAX_INTERFACES[interface_id].skypiax_do_skype_thread_thread){ #ifdef WIN32 if (SendMessage(win32_hInit_MainWindowHandle, WM_DESTROY, 0, 0) == FALSE) { // let's the do_skype_thread die ERRORA("WHY FALSE HERE? %d\n", SKYPIAX_P_LOG, GetLastError()); @@ -917,12 +923,18 @@ XSendEvent(p->AsteriskHandlesAst.disp, p->AsteriskHandlesAst.win, False, 0, &e); XSync(p->AsteriskHandlesAst.disp, False); #endif + } while (x) { x--; switch_yield(20000); } - switch_thread_join(&status, skypiax_do_controldev_thread_thread); - switch_thread_join(&status, do_skype_thread_thread); +if(globals.SKYPIAX_INTERFACES[interface_id].skypiax_do_controldev_thread_thread){ + switch_thread_join(&status, globals.SKYPIAX_INTERFACES[interface_id].skypiax_do_controldev_thread_thread); + } +if(globals.SKYPIAX_INTERFACES[interface_id].skypiax_do_skype_thread_thread){ + switch_thread_join(&status, globals.SKYPIAX_INTERFACES[interface_id].skypiax_do_skype_thread_thread); + } + } return SWITCH_STATUS_SUCCESS; } Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h ============================================================================== --- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h (original) +++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h Sat Dec 13 03:31:50 2008 @@ -173,6 +173,8 @@ switch_file_t *audioskypepipe[2]; switch_thread_t *tcp_srv_thread; switch_thread_t *tcp_cli_thread; + switch_thread_t *skypiax_do_controldev_thread_thread; + switch_thread_t *skypiax_do_skype_thread_thread; short audiobuf[160]; int audiobuf_is_loaded; 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 03:31:50 2008 @@ -5,7 +5,6 @@ extern switch_core_session_t *global_session; extern switch_endpoint_interface_t *skypiax_endpoint_interface; extern int running; -extern skypiax_interface_t SKYPIAX_INTERFACES; #ifdef WIN32 extern HWND win32_hInit_MainWindowHandle; #endif /* WIN32 */ @@ -575,7 +574,7 @@ /* destroy window class */ struct skypiax_interface *p; - DWORD MsgWaitResult; + //DWORD MsgWaitResult; p = obj; switch_file_pipe_create_ex(&p->AsteriskHandlesAst.fdesc[0], @@ -603,7 +602,7 @@ if (!running) break; while (GetMessage(&oMessage, 0, 0, 0)) { - break; + //break; TranslateMessage(&oMessage); DispatchMessage(&oMessage); } From gmaruzz at freeswitch.org Sat Dec 13 02:29:42 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Sat, 13 Dec 2008 05:29:42 -0500 Subject: [Freeswitch-branches] [commit] r10751 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax Message-ID: 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; From cseket at freeswitch.org Sat Dec 13 07:22:38 2008 From: cseket at freeswitch.org (FreeSWITCH SVN) Date: Sat, 13 Dec 2008 10:22:38 -0500 Subject: [Freeswitch-branches] [commit] r10752 - freeswitch/branches/cseket/src/mod/applications/mod_voicemail Message-ID: Author: cseket Date: Sat Dec 13 10:22:36 2008 New Revision: 10752 Log: load profiles on the fly. add loading functions (MODAPP-177) Modified: freeswitch/branches/cseket/src/mod/applications/mod_voicemail/mod_voicemail.c Modified: freeswitch/branches/cseket/src/mod/applications/mod_voicemail/mod_voicemail.c ============================================================================== --- freeswitch/branches/cseket/src/mod/applications/mod_voicemail/mod_voicemail.c (original) +++ freeswitch/branches/cseket/src/mod/applications/mod_voicemail/mod_voicemail.c Sat Dec 13 10:22:36 2008 @@ -51,6 +51,7 @@ static switch_status_t voicemail_inject(const char *data); +const char *global_cf = "voicemail.conf"; static struct { switch_hash_t *profile_hash; int debug; @@ -235,8 +236,24 @@ " password VARCHAR(255)\n" ");\n"; -static void destroy_profile(vm_profile_t *profile) + +static void destroy_profile(const char *profile_name) { + vm_profile_t *profile = NULL; + switch_mutex_lock(globals.mutex); + if ((profile = switch_core_hash_find(globals.profile_hash, profile_name))) { + switch_core_hash_delete(globals.profile_hash, profile_name); + } + switch_mutex_unlock(globals.mutex); + + if (!profile) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Profile %s\n", profile_name); + return; + } + /* wait readers */ + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Waiting for write lock (Profile %s)\n", profile->name); + switch_thread_rwlock_wrlock(profile->rwlock); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Destroying Profile %s\n", profile->name); #ifdef SWITCH_HAVE_ODBC if (profile->odbc_dsn && profile->master_odbc) { @@ -247,84 +264,22 @@ switch_core_destroy_memory_pool(&profile->pool); } -static vm_profile_t *create_profile(char *name) +static vm_profile_t * load_profile(const char *profile_name) { vm_profile_t *profile = NULL; - switch_memory_pool_t *pool; - - switch_core_new_memory_pool(&pool); - - profile = switch_core_alloc(pool, sizeof(*profile)); - profile->pool = pool; - switch_thread_rwlock_create(&profile->rwlock, pool); - profile->name = switch_core_strdup(pool, name); - - return profile; -} - + switch_xml_t x_profiles, x_profile, x_email, param, cfg, xml; -static switch_status_t load_config(void) -{ - char *cf = "voicemail.conf"; - vm_profile_t *profile = NULL; - switch_xml_t cfg, xml, settings, param, x_profile, x_profiles, x_email; - switch_hash_index_t *hi; - void *val; - - 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 (!(xml = switch_xml_open_cfg(global_cf, &cfg, NULL))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", global_cf); + return profile; } - - if ((settings = switch_xml_child(cfg, "settings"))) { - for (param = switch_xml_child(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")) { - globals.debug = atoi(val); - } - } - } - + if (!(x_profiles = switch_xml_child(cfg, "profiles"))) { goto end; } - - /* destroy old profiles */ - destroy: - for (hi = switch_hash_first(NULL, globals.profile_hash); hi; hi = switch_hash_next(hi)) { - switch_hash_this(hi, NULL, NULL, &val); - profile = (vm_profile_t *) val; - int found = 0; - - for (x_profile = switch_xml_child(x_profiles, "profile"); x_profile; x_profile = x_profile->next) { - char *name = (char *) switch_xml_attr_soft(x_profile, "name"); - if (!(strcasecmp(profile->name, name))) { - found = 1; - break; - } - } - if (found) { - continue; - } - - /* delete from hash, so new comers can't find it */ - switch_mutex_lock(globals.mutex); - switch_core_hash_delete(globals.profile_hash, profile->name); - switch_mutex_unlock(globals.mutex); - - /* wait for readers */ - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Deleting profile %s, when readers are left\n", profile->name); - switch_thread_rwlock_wrlock(profile->rwlock); - - destroy_profile(profile); - goto destroy; - } - - for (x_profile = switch_xml_child(x_profiles, "profile"); x_profile; x_profile = x_profile->next) { - char *name = (char *) switch_xml_attr_soft(x_profile, "name"); + if ((x_profile = switch_xml_find_child(x_profiles, "profile", "name", profile_name))) { + switch_memory_pool_t *pool; char *odbc_dsn = NULL, *odbc_user = NULL, *odbc_pass = NULL; char *terminator_key = "#"; char *play_new_messages_key = "1"; @@ -376,7 +331,6 @@ char *record_title = "FreeSWITCH Voicemail"; char *record_comment = "FreeSWITCH Voicemail"; char *record_copyright = "http://www.freeswitch.org"; - int change_profile = 0; switch_bool_t auto_playback_recordings = SWITCH_TRUE; @@ -385,18 +339,21 @@ db = NULL; - if (switch_strlen_zero(name)) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "No name specified.\n"); - continue; + if (switch_core_new_memory_pool(&pool) != SWITCH_STATUS_SUCCESS) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Pool Failure\n"); + goto end; } - if (!(profile = switch_core_hash_find(globals.profile_hash, name))) { - profile = create_profile(name); - } else { - change_profile = 1; - switch_thread_rwlock_wrlock(profile->rwlock); + if (!(profile = switch_core_alloc(pool, sizeof(*profile)))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Alloc Failure\n"); + switch_core_destroy_memory_pool(&pool); + goto end; } + profile->pool = pool; + switch_thread_rwlock_create(&profile->rwlock, pool); + profile->name = switch_core_strdup(pool, profile_name); + if ((x_email = switch_xml_child(x_profile, "email"))) { if ((param = switch_xml_child(x_email, "body"))) { email_body = switch_core_strdup(profile->pool, param->txt); @@ -677,33 +634,23 @@ } } -#ifdef SWITCH_HAVE_ODBC - if (profile->odbc_dsn && profile->master_odbc) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Closing ODBC Database! %s\n", profile->name); - switch_odbc_handle_destroy(&profile->master_odbc); - profile->odbc_dsn = NULL; - profile->odbc_user = NULL; - profile->odbc_pass = NULL; - } -#endif - if (!switch_strlen_zero(odbc_dsn) && !switch_strlen_zero(odbc_user) && !switch_strlen_zero(odbc_pass)) { profile->odbc_dsn = odbc_dsn; profile->odbc_user = odbc_user; profile->odbc_pass = odbc_pass; } else { - profile->dbname = switch_core_sprintf(profile->pool, "voicemail_%s", name); + profile->dbname = switch_core_sprintf(profile->pool, "voicemail_%s", profile_name); } if (profile->odbc_dsn) { #ifdef SWITCH_HAVE_ODBC if (!(profile->master_odbc = switch_odbc_handle_new(profile->odbc_dsn, profile->odbc_user, profile->odbc_pass))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open ODBC Database!\n"); - continue; + goto end; } if (switch_odbc_handle_connect(profile->master_odbc) != SWITCH_ODBC_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open ODBC Database!\n"); - continue; + goto end; } if (switch_odbc_handle_exec(profile->master_odbc, "select count(message_len) from voicemail_msgs", NULL) != SWITCH_ODBC_SUCCESS) { @@ -728,7 +675,7 @@ "cid_name, cid_number, in_folder, file_path, message_len, flags, read_flags from voicemail_data", NULL) != SWITCH_ODBC_SUCCESS) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Failed to migrate old voicemail_data to voicemail_msgs!\n"); - continue; + goto end; } switch_odbc_handle_exec(profile->master_odbc, "drop table voicemail_data", NULL); } @@ -766,7 +713,7 @@ "alter table voicemail_prefs add password varchar(255)"); } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "Cannot Open SQL Database!\n"); - continue; + goto end; } switch_core_db_close(db); } @@ -832,18 +779,65 @@ switch_copy_string(profile->file_ext, file_ext, sizeof(profile->file_ext)); switch_mutex_init(&profile->mutex, SWITCH_MUTEX_NESTED, profile->pool); - if (change_profile) { - switch_thread_rwlock_unlock(profile->rwlock); - } else { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Added Profile %s\n", profile->name); - switch_mutex_lock(globals.mutex); - switch_core_hash_insert(globals.profile_hash, profile->name, profile); - switch_mutex_unlock(globals.mutex); - } + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Added Profile %s\n", profile->name); + switch_core_hash_insert(globals.profile_hash, profile->name, profile); } end: + if (xml) { + switch_xml_free(xml); + } + return profile; + +} + + +static vm_profile_t * get_profile(const char *profile_name) +{ + vm_profile_t *profile; + + switch_mutex_lock(globals.mutex); + if (!(profile = switch_core_hash_find(globals.profile_hash, profile_name))) { + profile = load_profile(profile_name); + } + if (profile) { + switch_thread_rwlock_rdlock(profile->rwlock); + } + switch_mutex_unlock(globals.mutex); + + return profile; +} + + +static switch_status_t load_config(void) +{ + switch_xml_t cfg, xml, settings, param, x_profiles, x_profile; + + if (!(xml = switch_xml_open_cfg(global_cf, &cfg, NULL))) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", global_cf); + return SWITCH_STATUS_TERM; + } + + switch_mutex_lock(globals.mutex); + if ((settings = switch_xml_child(cfg, "settings"))) { + for (param = switch_xml_child(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")) { + globals.debug = atoi(val); + } + } + } + + if ((x_profiles = switch_xml_child(cfg, "profiles"))) { + for (x_profile = switch_xml_child(x_profiles, "profile"); x_profile; x_profile = x_profile->next) { + load_profile(switch_xml_attr_soft(x_profile, "name")); + } + } + switch_mutex_unlock(globals.mutex); + switch_xml_free(xml); return SWITCH_STATUS_SUCCESS; } @@ -1707,16 +1701,11 @@ caller_id_number = caller_profile->caller_id_number; } - switch_mutex_lock(globals.mutex); - - if (!(profile = switch_core_hash_find(globals.profile_hash, profile_name))) { + if (!(profile = get_profile(profile_name))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error invalid profile %s\n", profile_name); - switch_mutex_unlock(globals.mutex); return; } - switch_thread_rwlock_rdlock(profile->rwlock); - switch_mutex_unlock(globals.mutex); - + timeout = profile->digit_timeout; attempts = profile->max_login_attempts; status = switch_ivr_phrase_macro(session, VM_HELLO_MACRO, NULL, NULL, &args); @@ -2087,8 +2076,6 @@ } - - thepass = thehash = NULL; switch_snprintf(sql, sizeof(sql), "select * from voicemail_prefs where username='%s' and domain='%s'", myid, domain_name); vm_execute_sql_callback(profile, profile->mutex, sql, prefs_callback, &cbt); @@ -2134,7 +2121,6 @@ } } - if (!mypass) { if (auth) { @@ -2153,8 +2139,6 @@ } } - - if (vmhash) { thehash = vmhash; } @@ -2636,23 +2620,18 @@ goto end; } - switch_mutex_lock(globals.mutex); - if (!(profile = switch_core_hash_find(globals.profile_hash, domain))) { - profile = switch_core_hash_find(globals.profile_hash, "default"); + if (!(profile = get_profile(domain))) { + profile = get_profile("default"); } if (!profile) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Can't find profile\n"); status = SWITCH_STATUS_FALSE; - switch_mutex_unlock(globals.mutex); } else { switch_xml_t x_domain, xml_root; switch_event_t *my_params = NULL; switch_xml_t ut; - switch_thread_rwlock_rdlock(profile->rwlock); - switch_mutex_unlock(globals.mutex); - switch_event_create(&my_params, SWITCH_EVENT_REQUEST_PARAMS); switch_assert(my_params); switch_event_add_header_string(my_params, SWITCH_STACK_BOTTOM, "domain", domain); @@ -2753,17 +2732,11 @@ memset(&cbt, 0, sizeof(cbt)); - switch_mutex_lock(globals.mutex); - - if (!(profile = switch_core_hash_find(globals.profile_hash, profile_name))) { + if (!(profile = get_profile(profile_name))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error invalid profile %s\n", profile_name); - switch_mutex_unlock(globals.mutex); return SWITCH_STATUS_FALSE;; } - switch_thread_rwlock_rdlock(profile->rwlock); - switch_mutex_unlock(globals.mutex); - if (id) { int ok = 1; switch_event_t *params = NULL; @@ -3668,7 +3641,7 @@ return SWITCH_STATUS_SUCCESS; } -#define VOICEMAIL_SYNTAX "rss [ ] | rescan [reloadxml]" +#define VOICEMAIL_SYNTAX "rss [ ] | [load|unload|reload] [reloadxml]" SWITCH_STANDARD_API(voicemail_api_function) { int argc = 0; @@ -3681,6 +3654,9 @@ int rss = 0, xarg = 0; switch_hash_index_t *hi; void *val = NULL; + switch_xml_t xml_root; + const char *err; + if (session) { return SWITCH_STATUS_FALSE; @@ -3705,27 +3681,40 @@ if (!strcasecmp(argv[0], "rss")) { rss++; xarg++; - } else if (!strcasecmp(argv[0], "rescan")) { - switch_xml_t xml_root; - const char *err; - if (argc > 1 && !strcasecmp(argv[1], "reloadxml")) { + } else if (argc > 1 && !strcasecmp(argv[0], "load")) { + if (argc > 2 && !strcasecmp(argv[2], "reloadxml")) { if ((xml_root = switch_xml_open_root(1, &err))) { switch_xml_free(xml_root); } stream->write_function(stream, "Reload XML [%s]\n", err); } - if (load_config() == SWITCH_STATUS_SUCCESS) { - stream->write_function(stream, "+OK scan complete\n"); - } else { - stream->write_function(stream, "-ERR scan failed\n"); - goto error; + if ((profile = get_profile(argv[1]))) { + switch_thread_rwlock_unlock(profile->rwlock); } + stream->write_function(stream, "+OK load complete\n"); goto done; + } else if (argc > 1 && !strcasecmp(argv[0], "unload")) { + destroy_profile(argv[1]); + stream->write_function(stream, "+OK unload complete\n"); + goto done; + } else if (argc > 1 && !strcasecmp(argv[0], "reload")) { + destroy_profile(argv[1]); + if (argc > 2 && !strcasecmp(argv[2], "reloadxml")) { + if ((xml_root = switch_xml_open_root(1, &err))) { + switch_xml_free(xml_root); + } + stream->write_function(stream, "Reload XML [%s]\n", err); + } + if ((profile = get_profile(argv[1]))) { + switch_thread_rwlock_unlock(profile->rwlock); + } + stream->write_function(stream, "+OK reload complete\n"); + goto done; + } else if (!strcasecmp(argv[0], "status")) { stream->write_function(stream, "============================\n"); switch_mutex_lock(globals.mutex); for (hi = switch_hash_first(NULL, globals.profile_hash); hi; hi = switch_hash_next(hi)) { - vm_profile_t * profile = NULL; switch_hash_this(hi, NULL, NULL, &val); profile = (vm_profile_t *) val; stream->write_function(stream, "Profile: %s\n", profile->name); @@ -3751,35 +3740,31 @@ goto error; } - switch_mutex_lock(globals.mutex); - profile = switch_core_hash_find(globals.profile_hash, domain); - - if (!profile) { - profile = switch_core_hash_find(globals.profile_hash, "default"); + if (!(profile = get_profile(domain))) { + profile = get_profile("default"); } if (!profile) { switch_hash_index_t *hi; void *val; + switch_mutex_lock(globals.mutex); for (hi = switch_hash_first(NULL, globals.profile_hash); hi; hi = switch_hash_next(hi)) { switch_hash_this(hi, NULL, NULL, &val); profile = (vm_profile_t *) val; if (profile) { + switch_thread_rwlock_rdlock(profile->rwlock); break; } } + switch_mutex_unlock(globals.mutex); } if (!profile) { stream->write_function(stream, "Can't find profile.\n"); - switch_mutex_unlock(globals.mutex); goto error; } - switch_thread_rwlock_rdlock(profile->rwlock); - switch_mutex_unlock(globals.mutex); - if (path_info) { if (!strncasecmp(path_info, "get/", 4)) { do_play(profile, user, domain, path_info + 4, stream); @@ -3793,8 +3778,8 @@ if (rss || (path_info && !strncasecmp(path_info, "rss", 3))) { do_rss(profile, user, domain, host, port, uri, stream); } - switch_thread_rwlock_unlock(profile->rwlock); + switch_thread_rwlock_unlock(profile->rwlock); goto done; error: From gmaruzz at freeswitch.org Sat Dec 13 08:46:58 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Sat, 13 Dec 2008 11:46:58 -0500 Subject: [Freeswitch-branches] [commit] r10753 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Sat Dec 13 11:46:57 2008 New Revision: 10753 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 11:46:57 2008 @@ -2,7 +2,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_skypiax_load); SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypiax_shutdown); -//SWITCH_MODULE_RUNTIME_FUNCTION(mod_skypiax_runtime); SWITCH_MODULE_DEFINITION(mod_skypiax, mod_skypiax_load, mod_skypiax_shutdown, NULL); //mod_skypiax_runtime); static struct { @@ -31,10 +30,6 @@ switch_endpoint_interface_t *skypiax_endpoint_interface; switch_memory_pool_t *skypiax_module_pool = NULL; int running = 1; -switch_core_session_t *global_session = NULL; -#ifdef WIN32 -HWND win32_hInit_MainWindowHandle; -#endif /* WIN32 */ /*************************************************/ /*************************************************/ /*************************************************/ @@ -905,7 +900,7 @@ if(globals.SKYPIAX_INTERFACES[interface_id].skypiax_do_skype_thread_thread){ #ifdef WIN32 - if (SendMessage(win32_hInit_MainWindowHandle, WM_DESTROY, 0, 0) == FALSE) { // let's the do_skype_thread die + if (SendMessage(p->AsteriskHandlesAst.win32_hInit_MainWindowHandle, WM_DESTROY, 0, 0) == FALSE) { // let's the do_skype_thread die ERRORA("WHY FALSE HERE? %d\n", SKYPIAX_P_LOG, GetLastError()); } #else 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 11:46:57 2008 @@ -2,16 +2,21 @@ extern switch_memory_pool_t *skypiax_module_pool; extern int option_debug; -extern switch_core_session_t *global_session; extern switch_endpoint_interface_t *skypiax_endpoint_interface; extern int running; -#ifdef WIN32 -extern HWND win32_hInit_MainWindowHandle; -#endif /* WIN32 */ + + + /**********************************************************/ /**********************************************************/ /**********************************************************/ + + +switch_core_session_t *global_session = NULL; + + #ifdef WIN32 +HWND win32_hInit_MainWindowHandle; struct AsteriskHandles *win32_AsteriskHandlesSkype; HINSTANCE win32_hInit_ProcessHandle; char win32_acInit_WindowClassName[128]; @@ -26,13 +31,13 @@ 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 - static void *SWITCH_THREAD_FUNC skypiax_do_tcp_srv_thread(switch_thread_t * thread, void *obj) From gmaruzz at freeswitch.org Mon Dec 15 02:05:51 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Mon, 15 Dec 2008 05:05:51 -0500 Subject: [Freeswitch-branches] [commit] r10765 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Mon Dec 15 05:05:50 2008 New Revision: 10765 Log: skypiax: multiline on linux Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c ============================================================================== --- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c (original) +++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c Mon Dec 15 05:05:50 2008 @@ -595,6 +595,7 @@ { char *cf = "skypiax.conf"; switch_xml_t cfg, xml, global_settings, param, interfaces, myinterface; + skypiax_interface_t *p = NULL; switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, skypiax_module_pool); if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) { @@ -672,6 +673,8 @@ char *fail_dial_regex = NULL; char *enable_callerid = "true"; char *X11_display = NULL; + char *tcp_cli_port = NULL; + char *tcp_srv_port = NULL; uint32_t interface_id = 0, to = 0, max = 0; @@ -695,6 +698,10 @@ fail_dial_regex = val; } else if (!strcasecmp(var, "hold-music")) { hold_music = val; + } else if (!strcasecmp(var, "tcp_cli_port")) { + tcp_cli_port = val; + } else if (!strcasecmp(var, "tcp_srv_port")) { + tcp_srv_port = val; } else if (!strcasecmp(var, "X11-display") || !strcasecmp(var, "X11_display")) { X11_display = val; } else if (!strcasecmp(var, "max_digits") || !strcasecmp(var, "max-digits")) { @@ -710,7 +717,17 @@ "interface missing REQUIRED param 'X11_display'\n"); continue; } + if (!tcp_cli_port) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, + "interface missing REQUIRED param 'tcp_cli_port'\n"); + continue; + } + if (!tcp_srv_port) { + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, + "interface missing REQUIRED param 'tcp_srv_port'\n"); + continue; + } if (!id) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "interface missing REQUIRED param 'id'\n"); @@ -771,13 +788,25 @@ } else { switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].name, "N/A"); } + globals.SKYPIAX_INTERFACES[interface_id].tcp_cli_port = atoi(tcp_cli_port); + globals.SKYPIAX_INTERFACES[interface_id].tcp_srv_port = atoi(tcp_srv_port); + //switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].tcp_cli_port, tcp_cli_port); + //switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].tcp_srv_port, tcp_srv_port); switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].X11_display, X11_display); switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].context, context); switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].dialplan, dialplan); + + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].X11_display=%s\n", interface_id, globals.SKYPIAX_INTERFACES[interface_id].X11_display); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, + "interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].tcp_cli_port=%d\n", + interface_id, globals.SKYPIAX_INTERFACES[interface_id].tcp_cli_port); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, + "interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].tcp_srv_port=%d\n", + interface_id, globals.SKYPIAX_INTERFACES[interface_id].tcp_srv_port); + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].name=%s\n", interface_id, globals.SKYPIAX_INTERFACES[interface_id].name); switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h ============================================================================== --- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h (original) +++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h Mon Dec 15 05:05:50 2008 @@ -148,6 +148,8 @@ char hold_music[256]; char type[256]; char X11_display[256]; + int tcp_cli_port; + int tcp_srv_port; struct AsteriskHandles AsteriskHandlesAst; int interface_state; /*!< \brief 'state' of the interface (channel) */ 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 Mon Dec 15 05:05:50 2008 @@ -27,9 +27,9 @@ 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; +//Window skype_win = (Window) - 1; +//static XErrorHandler old_handler = 0; +//static int xerror = 0; #endif /* WIN32 */ @@ -72,7 +72,7 @@ memset(&my_addr, 0, sizeof(my_addr)); my_addr.sin_family = AF_INET; my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */ - my_addr.sin_port = htons(5556); //FIXME configurable! + my_addr.sin_port = htons(p->tcp_srv_port); //FIXME configurable! if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) { ERRORA("socket Error\n", SKYPIAX_P_LOG); @@ -235,7 +235,7 @@ memset(&my_addr, 0, sizeof(my_addr)); my_addr.sin_family = AF_INET; my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */ - my_addr.sin_port = htons(5558); //FIXME configurable! + my_addr.sin_port = htons(p->tcp_cli_port); //FIXME configurable! if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) { ERRORA("socket Error\n", SKYPIAX_P_LOG); @@ -635,6 +635,7 @@ } #else /* NOT WIN32 */ +#if 0 int X11_errors_handler(Display * dpy, XErrorEvent * err) { (void) dpy; @@ -656,6 +657,7 @@ XSetErrorHandler(old_handler); return (xerror != BadValue) && (xerror != BadWindow); } +#endif int skypiax_skype_send_message(struct AsteriskHandles *AsteriskHandlesAst, const char *message_P) @@ -664,7 +666,7 @@ Window w_P; Display *disp; Window handle_P; - struct skypiax_interface *p = NULL; + //struct skypiax_interface *p = NULL; w_P = AsteriskHandlesAst->skype_win; disp = AsteriskHandlesAst->disp; @@ -675,7 +677,7 @@ unsigned int pos = 0; unsigned int len = strlen(message_P); XEvent e; - int ok; + //int ok; memset(&e, 0, sizeof(e)); e.xclient.type = ClientMessage; @@ -684,7 +686,7 @@ e.xclient.window = handle_P; e.xclient.format = 8; - X11_errors_trap(); + //X11_errors_trap(); //XLockDisplay(disp); do { unsigned int i; @@ -698,17 +700,17 @@ XSync(disp, False); //XUnlockDisplay(disp); - ok = X11_errors_untrap(); + //ok = X11_errors_untrap(); - if (!ok) - DEBUGA_SKYPE("Sending message failed with status %d\n", SKYPIAX_P_LOG, xerror); + //if (!ok) DEBUGA_SKYPE("Sending message failed with status %d\n", SKYPIAX_P_LOG, xerror); - return ok; + //return ok; + return 1; } -int skypiax_skype_present(Display * disp) +int skypiax_skype_present(struct AsteriskHandles *AsteriskHandlesAst) { - Atom skype_inst = XInternAtom(disp, "_SKYPE_INSTANCE", True); + Atom skype_inst = XInternAtom(AsteriskHandlesAst->disp, "_SKYPE_INSTANCE", True); Atom type_ret; int format_ret; @@ -718,25 +720,25 @@ int status; struct skypiax_interface *p = NULL; - X11_errors_trap(); + //X11_errors_trap(); //XLockDisplay(disp); status = - XGetWindowProperty(disp, DefaultRootWindow(disp), skype_inst, 0, 1, False, XA_WINDOW, + XGetWindowProperty(AsteriskHandlesAst->disp, DefaultRootWindow(AsteriskHandlesAst->disp), skype_inst, 0, 1, False, XA_WINDOW, &type_ret, &format_ret, &nitems_ret, &bytes_after_ret, &prop); //XUnlockDisplay(disp); - X11_errors_untrap(); + //X11_errors_untrap(); /* sanity check */ if (status != Success || format_ret != 32 || nitems_ret != 1) { - skype_win = (Window) - 1; + AsteriskHandlesAst->skype_win = (Window) - 1; DEBUGA_SKYPE("Skype instance not found\n", SKYPIAX_P_LOG); return 0; } - skype_win = *(const unsigned long *) prop & 0xffffffff; + 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) skype_win); + (unsigned int) AsteriskHandlesAst->skype_win); return 1; } @@ -798,7 +800,9 @@ //FIXME pthread_cleanup_push(skypiax_skype_clean_disp, &xfd); DEBUGA_SKYPE("PUSH disp %d\n", SKYPIAX_P_LOG, xfd); - if (skypiax_skype_present(disp)) { + AsteriskHandlesAst->disp = disp; + + if (skypiax_skype_present(AsteriskHandlesAst)) { root = DefaultRootWindow(disp); win = XCreateSimpleWindow(disp, root, 0, 0, 1, 1, 0, @@ -806,11 +810,10 @@ DefaultScreen (disp))); - DEBUGA_SKYPE("skype_win=%d win=%d\n", SKYPIAX_P_LOG, (unsigned int) skype_win, - (unsigned int) win); + //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->skype_win = skype_win; + //AsteriskHandlesAst->disp = disp; AsteriskHandlesAst->win = win; snprintf(buf, SKYPE_X11_BUF_SIZE, "NAME skypiax"); @@ -1309,10 +1312,10 @@ DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG); } switch_sleep(100000); - sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"5556\"", id); + sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id, p->tcp_srv_port); skypiax_skype_write(p, msg_to_skype); switch_sleep(100000); - sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"5558\"", id); + sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id, p->tcp_cli_port); skypiax_skype_write(p, msg_to_skype); switch_sleep(100000); } From gmaruzz at freeswitch.org Mon Dec 15 08:52:02 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Mon, 15 Dec 2008 11:52:02 -0500 Subject: [Freeswitch-branches] [commit] r10769 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Mon Dec 15 11:52:02 2008 New Revision: 10769 Log: skypiax: better performance on linux??? 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 Mon Dec 15 11:52:02 2008 @@ -118,9 +118,11 @@ fdselect = fd; FD_ZERO(&fs); FD_SET(fdselect, &fs); - to.tv_usec = 100; + to.tv_usec = 10000; to.tv_sec = 0; rt = select(fdselect + 1, &fs, NULL, NULL, &to); + //usleep(1000); + //rt=1; if (rt > 0) { len = recv(fd, srv_in, sizeof(short) * SAMPLES_PER_FRAME, 0); @@ -283,8 +285,10 @@ fdselect = 1; FD_ZERO(&fs); FD_SET(fdselect, &fs); - to.tv_usec = 100; + to.tv_usec = 10000; to.tv_sec = 0; + //rt = select(fdselect + 1, &fs, NULL, NULL, &to); + usleep(5000); rt = 1; if (rt > 0) { @@ -845,6 +849,7 @@ b = buffer; while (1) { + usleep(1000); XNextEvent(disp, &an_event); if (!running) break; From gmaruzz at freeswitch.org Mon Dec 15 09:26:36 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Mon, 15 Dec 2008 12:26:36 -0500 Subject: [Freeswitch-branches] [commit] r10771 - in freeswitch/branches/gmaruzz/src: . include mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Mon Dec 15 12:26:36 2008 New Revision: 10771 Log: skypiax: prepare for merging with trunk, cleaning the switch_apr.c and switch_apr.h files Modified: freeswitch/branches/gmaruzz/src/include/switch_apr.h freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c 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 Mon Dec 15 12:26:36 2008 @@ -1303,7 +1303,17 @@ 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); + +/** + * Create an anonymous pipe. + * @param in The file descriptor to use as input to the pipe. + * @param out The file descriptor to use as output from the pipe. + * @param pool The pool to operate on. + * @remark By default, the returned file descriptors will be inherited + * by child processes created using apr_proc_create(). This can be + * changed using apr_file_inherit_unset(). + */ +SWITCH_DECLARE(switch_status_t) switch_file_pipe_create(switch_file_t **in, switch_file_t **out, switch_memory_pool_t *p); /** * Get the timeout value for a pipe or manipulate the blocking state. 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 Mon Dec 15 12:26:36 2008 @@ -344,16 +344,14 @@ switch_status_t rv; rv = - switch_file_pipe_create_ex(&p->audiopipe[0], &p->audiopipe[1], 2, - skypiax_module_pool); + switch_file_pipe_create(&p->audiopipe[0], &p->audiopipe[1], skypiax_module_pool); rv = switch_file_pipe_timeout_set(p->audiopipe[0], 100000); /* the pipe is our audio fd for pbx to poll on */ p->skypiax_sound_capt_fd = p->audiopipe[0]; rv = - switch_file_pipe_create_ex(&p->audioskypepipe[0], &p->audioskypepipe[1], 2, - skypiax_module_pool); + switch_file_pipe_create(&p->audioskypepipe[0], &p->audioskypepipe[1], skypiax_module_pool); rv = switch_file_pipe_timeout_set(p->audioskypepipe[0], 100); if (option_debug > 10) { DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG); @@ -596,8 +594,7 @@ //DWORD MsgWaitResult; p = obj; - switch_file_pipe_create_ex(&p->AsteriskHandlesAst.fdesc[0], - &p->AsteriskHandlesAst.fdesc[1], 2, skypiax_module_pool); + switch_file_pipe_create(&p->AsteriskHandlesAst.fdesc[0], &p->AsteriskHandlesAst.fdesc[1], skypiax_module_pool); switch_file_pipe_timeout_set(p->AsteriskHandlesAst.fdesc[0], 100000); win32_AsteriskHandlesSkype = &p->AsteriskHandlesAst; @@ -780,8 +777,7 @@ p = obj; DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG); - switch_file_pipe_create_ex(&p->AsteriskHandlesAst.fdesc[0], - &p->AsteriskHandlesAst.fdesc[1], 2, skypiax_module_pool); + switch_file_pipe_create(&p->AsteriskHandlesAst.fdesc[0], &p->AsteriskHandlesAst.fdesc[1], skypiax_module_pool); switch_file_pipe_timeout_set(p->AsteriskHandlesAst.fdesc[0], 100000); AsteriskHandlesAst = &p->AsteriskHandlesAst; Modified: freeswitch/branches/gmaruzz/src/switch_apr.c ============================================================================== --- freeswitch/branches/gmaruzz/src/switch_apr.c (original) +++ freeswitch/branches/gmaruzz/src/switch_apr.c Mon Dec 15 12:26:36 2008 @@ -942,9 +942,17 @@ 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) +/** + * Create an anonymous pipe. + * @param in The file descriptor to use as input to the pipe. + * @param out The file descriptor to use as output from the pipe. + * @param pool The pool to operate on. + * @remark By default, the returned file descriptors will be inherited + * by child processes created using apr_proc_create(). This can be + * changed using apr_file_inherit_unset(). + */ +SWITCH_DECLARE(switch_status_t) switch_file_pipe_create(switch_file_t **in, switch_file_t **out, 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); } From gmaruzz at freeswitch.org Mon Dec 15 09:30:02 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Mon, 15 Dec 2008 12:30:02 -0500 Subject: [Freeswitch-branches] [commit] r10772 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Mon Dec 15 12:30:02 2008 New Revision: 10772 Log: skypiax: windoz portability 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 Mon Dec 15 12:30:02 2008 @@ -288,7 +288,7 @@ to.tv_usec = 10000; to.tv_sec = 0; //rt = select(fdselect + 1, &fs, NULL, NULL, &to); - usleep(5000); + switch_sleep(5000); rt = 1; if (rt > 0) { From gmaruzz at freeswitch.org Mon Dec 15 09:36:05 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Mon, 15 Dec 2008 12:36:05 -0500 Subject: [Freeswitch-branches] [commit] r10773 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax Message-ID: Author: gmaruzz Date: Mon Dec 15 12:36:04 2008 New Revision: 10773 Log: skypiax: cleaner Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h ============================================================================== --- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h (original) +++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h Mon Dec 15 12:36:04 2008 @@ -35,6 +35,7 @@ */ #include +#include #ifndef WIN32 #include @@ -44,7 +45,8 @@ //FIXME include? #endif //WIN32 -#define SKYPIAX_SVN_VERSION "SVN 123456" +//#define SKYPIAX_SVN_VERSION "SVN 123456" +#define SKYPIAX_SVN_VERSION SWITCH_VERSION_REVISION typedef enum { TFLAG_IO = (1 << 0), From gmaruzz at freeswitch.org Mon Dec 15 09:56:36 2008 From: gmaruzz at freeswitch.org (FreeSWITCH SVN) Date: Mon, 15 Dec 2008 12:56:36 -0500 Subject: [Freeswitch-branches] [commit] r10774 - in freeswitch/branches/gmaruzz: . build conf conf/autoload_configs conf/dialplan conf/directory/default conf/sip_profiles conf/sip_profiles/external conf/sip_profiles/internal debian docs docs/phrase libs/libdingaling/src libs/libg722_1 libs/libg722_1/config libs/libg722_1/debian libs/libg722_1/doc libs/libg722_1/src libs/libg722_1/src/g722_1 libs/libg722_1/src/msvc libs/libg722_1/src/msvc/sys libs/libg722_1/test-data libs/libg722_1/test-data/itu libs/libg722_1/test-data/local libs/libg722_1/tests libs/libteletone/src libs/spandsp/src libs/win32 libs/win32/libmp3lame libs/win32/libshout scripts scripts/contrib/intralanman/C scripts/contrib/intralanman/C/lcr scripts/contrib/intralanman/C/lcr/mod_lcr scripts/contrib/intralanman/C/lcr/sql scripts/contrib/intralanman/PHP/fs_curl scripts/contrib/intralanman/PHP/fs_curl/configuration scripts/contrib/mcollins scripts/contrib/mrene/mod_limit src src/include src/include/private src/mod/applications/mod_commands src/mod/applications/mod_conference src/mod/applications/mod_dptools src/mod/applications/mod_enum src/mod/applications/mod_expr src/mod/applications/mod_fax src/mod/applications/mod_fifo src/mod/applications/mod_fsv src/mod/applications/mod_http src/mod/applications/mod_limit src/mod/applications/mod_vmd src/mod/applications/mod_voicemail src/mod/asr_tts/mod_cepstral src/mod/asr_tts/mod_pocketsphinx src/mod/codecs/mod_siren src/mod/endpoints/mod_dingaling src/mod/endpoints/mod_iax src/mod/endpoints/mod_loopback src/mod/endpoints/mod_opal src/mod/endpoints/mod_sofia src/mod/endpoints/mod_woomera src/mod/event_handlers/mod_cdr_csv src/mod/event_handlers/mod_erlang_event src/mod/event_handlers/mod_event_socket src/mod/formats/mod_shout src/mod/formats/mod_sndfile src/mod/languages/mod_java src/mod/languages/mod_java/src/org/freeswitch/swig src/mod/languages/mod_lua src/mod/languages/mod_managed src/mod/languages/mod_managed/managed src/mod/languages/mod_perl src/mod/languages/mod_python src/mod/languages/mod_spidermonkey src/mod/xml_int/mod_xml_cdr src/mod/xml_int/mod_xml_curl src/mod/xml_int/mod_xml_ldap ssh_keys support support-d w32/Library Message-ID: Author: gmaruzz Date: Mon Dec 15 12:56:36 2008 New Revision: 10774 Log: Merge of trunk revisions 10428:10773 into gmaruzz branch Added: freeswitch/branches/gmaruzz/conf/autoload_configs/opal.conf.xml - copied unchanged from r10773, /freeswitch/trunk/conf/autoload_configs/opal.conf.xml freeswitch/branches/gmaruzz/libs/libg722_1/ - copied from r10773, /freeswitch/trunk/libs/libg722_1/ freeswitch/branches/gmaruzz/libs/libg722_1/.update - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/.update freeswitch/branches/gmaruzz/libs/libg722_1/AUTHORS - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/AUTHORS freeswitch/branches/gmaruzz/libs/libg722_1/COPYING - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/COPYING freeswitch/branches/gmaruzz/libs/libg722_1/ChangeLog - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/ChangeLog freeswitch/branches/gmaruzz/libs/libg722_1/INSTALL - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/INSTALL freeswitch/branches/gmaruzz/libs/libg722_1/Makefile.am - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/Makefile.am freeswitch/branches/gmaruzz/libs/libg722_1/Makefile.in - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/Makefile.in freeswitch/branches/gmaruzz/libs/libg722_1/NEWS - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/NEWS freeswitch/branches/gmaruzz/libs/libg722_1/README - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/README freeswitch/branches/gmaruzz/libs/libg722_1/aclocal.m4 - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/aclocal.m4 freeswitch/branches/gmaruzz/libs/libg722_1/autogen.sh - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/autogen.sh freeswitch/branches/gmaruzz/libs/libg722_1/config/ - copied from r10773, /freeswitch/trunk/libs/libg722_1/config/ freeswitch/branches/gmaruzz/libs/libg722_1/config-h.in - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/config-h.in freeswitch/branches/gmaruzz/libs/libg722_1/config/ax_c99_features.m4 - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/config/ax_c99_features.m4 freeswitch/branches/gmaruzz/libs/libg722_1/config/ax_check_real_file.m4 - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/config/ax_check_real_file.m4 freeswitch/branches/gmaruzz/libs/libg722_1/config/ax_compiler_vendor.m4 - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/config/ax_compiler_vendor.m4 freeswitch/branches/gmaruzz/libs/libg722_1/config/ax_fixed_point_machine.m4 - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/config/ax_fixed_point_machine.m4 freeswitch/branches/gmaruzz/libs/libg722_1/config/ax_misaligned_access_fails.m4 - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/config/ax_misaligned_access_fails.m4 freeswitch/branches/gmaruzz/libs/libg722_1/config/config.guess - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/config/config.guess freeswitch/branches/gmaruzz/libs/libg722_1/config/config.sub - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/config/config.sub freeswitch/branches/gmaruzz/libs/libg722_1/config/depcomp - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/config/depcomp freeswitch/branches/gmaruzz/libs/libg722_1/config/install-sh - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/config/install-sh freeswitch/branches/gmaruzz/libs/libg722_1/config/ltmain.sh - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/config/ltmain.sh freeswitch/branches/gmaruzz/libs/libg722_1/config/missing - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/config/missing freeswitch/branches/gmaruzz/libs/libg722_1/configure - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/configure freeswitch/branches/gmaruzz/libs/libg722_1/configure.ac - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/configure.ac freeswitch/branches/gmaruzz/libs/libg722_1/debian/ - copied from r10773, /freeswitch/trunk/libs/libg722_1/debian/ freeswitch/branches/gmaruzz/libs/libg722_1/debian/changelog - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/debian/changelog freeswitch/branches/gmaruzz/libs/libg722_1/debian/compat - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/debian/compat freeswitch/branches/gmaruzz/libs/libg722_1/debian/control - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/debian/control freeswitch/branches/gmaruzz/libs/libg722_1/debian/copyright - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/debian/copyright freeswitch/branches/gmaruzz/libs/libg722_1/debian/libg722_1-dev.install - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/debian/libg722_1-dev.install freeswitch/branches/gmaruzz/libs/libg722_1/debian/libg722_1-doc.install - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/debian/libg722_1-doc.install freeswitch/branches/gmaruzz/libs/libg722_1/debian/libg722_11.install - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/debian/libg722_11.install freeswitch/branches/gmaruzz/libs/libg722_1/debian/rules - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/debian/rules freeswitch/branches/gmaruzz/libs/libg722_1/debian/watch - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/debian/watch freeswitch/branches/gmaruzz/libs/libg722_1/doc/ - copied from r10773, /freeswitch/trunk/libs/libg722_1/doc/ freeswitch/branches/gmaruzz/libs/libg722_1/doc/Makefile.am - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/doc/Makefile.am freeswitch/branches/gmaruzz/libs/libg722_1/doc/Makefile.in - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/doc/Makefile.in freeswitch/branches/gmaruzz/libs/libg722_1/doc/css.css - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/doc/css.css freeswitch/branches/gmaruzz/libs/libg722_1/doc/libg722_1-doxygen - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/doc/libg722_1-doxygen freeswitch/branches/gmaruzz/libs/libg722_1/doc/wrapper.xsl - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/doc/wrapper.xsl freeswitch/branches/gmaruzz/libs/libg722_1/g722_1.spec.in - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/g722_1.spec.in freeswitch/branches/gmaruzz/libs/libg722_1/src/ - copied from r10773, /freeswitch/trunk/libs/libg722_1/src/ freeswitch/branches/gmaruzz/libs/libg722_1/src/Makefile.am - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/Makefile.am freeswitch/branches/gmaruzz/libs/libg722_1/src/Makefile.in - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/Makefile.in freeswitch/branches/gmaruzz/libs/libg722_1/src/basop32.c - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/basop32.c freeswitch/branches/gmaruzz/libs/libg722_1/src/basop32.h - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/basop32.h freeswitch/branches/gmaruzz/libs/libg722_1/src/bitstream.c - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/bitstream.c freeswitch/branches/gmaruzz/libs/libg722_1/src/bitstream.h - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/bitstream.h freeswitch/branches/gmaruzz/libs/libg722_1/src/coef2sam.c - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/coef2sam.c freeswitch/branches/gmaruzz/libs/libg722_1/src/coef2sam.h - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/coef2sam.h freeswitch/branches/gmaruzz/libs/libg722_1/src/common.c - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/common.c freeswitch/branches/gmaruzz/libs/libg722_1/src/commonf.c - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/commonf.c freeswitch/branches/gmaruzz/libs/libg722_1/src/dct4.c - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/dct4.c freeswitch/branches/gmaruzz/libs/libg722_1/src/dct4.h - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/dct4.h freeswitch/branches/gmaruzz/libs/libg722_1/src/dct4_a.c - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/dct4_a.c freeswitch/branches/gmaruzz/libs/libg722_1/src/dct4_a.h - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/dct4_a.h freeswitch/branches/gmaruzz/libs/libg722_1/src/dct4_s.c - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/dct4_s.c freeswitch/branches/gmaruzz/libs/libg722_1/src/dct4_s.h - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/dct4_s.h freeswitch/branches/gmaruzz/libs/libg722_1/src/decoder.c - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/decoder.c freeswitch/branches/gmaruzz/libs/libg722_1/src/decoderf.c - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/decoderf.c freeswitch/branches/gmaruzz/libs/libg722_1/src/defs.h - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/defs.h freeswitch/branches/gmaruzz/libs/libg722_1/src/encoder.c - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/encoder.c freeswitch/branches/gmaruzz/libs/libg722_1/src/encoderf.c - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/encoderf.c freeswitch/branches/gmaruzz/libs/libg722_1/src/g722_1/ - copied from r10773, /freeswitch/trunk/libs/libg722_1/src/g722_1/ freeswitch/branches/gmaruzz/libs/libg722_1/src/g722_1.h.in - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/g722_1.h.in freeswitch/branches/gmaruzz/libs/libg722_1/src/g722_1/g722_1.h - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/g722_1/g722_1.h freeswitch/branches/gmaruzz/libs/libg722_1/src/g722_1/version.h - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/g722_1/version.h freeswitch/branches/gmaruzz/libs/libg722_1/src/g722_1/version.h.in - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/g722_1/version.h.in freeswitch/branches/gmaruzz/libs/libg722_1/src/huff_tab.c - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/huff_tab.c freeswitch/branches/gmaruzz/libs/libg722_1/src/huff_tab.h - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/huff_tab.h freeswitch/branches/gmaruzz/libs/libg722_1/src/libg722_1.dsp - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/libg722_1.dsp freeswitch/branches/gmaruzz/libs/libg722_1/src/libg722_1.sln - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/libg722_1.sln freeswitch/branches/gmaruzz/libs/libg722_1/src/libg722_1.vcproj - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/libg722_1.vcproj freeswitch/branches/gmaruzz/libs/libg722_1/src/make_dct4_tables.c - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/make_dct4_tables.c freeswitch/branches/gmaruzz/libs/libg722_1/src/make_tables.c - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/make_tables.c freeswitch/branches/gmaruzz/libs/libg722_1/src/msvc/ - copied from r10773, /freeswitch/trunk/libs/libg722_1/src/msvc/ freeswitch/branches/gmaruzz/libs/libg722_1/src/msvc/g722_1.def - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/msvc/g722_1.def freeswitch/branches/gmaruzz/libs/libg722_1/src/msvc/gettimeofday.c - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/msvc/gettimeofday.c freeswitch/branches/gmaruzz/libs/libg722_1/src/msvc/inttypes.h - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/msvc/inttypes.h freeswitch/branches/gmaruzz/libs/libg722_1/src/msvc/msvcproj.foot - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/msvc/msvcproj.foot freeswitch/branches/gmaruzz/libs/libg722_1/src/msvc/msvcproj.head - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/msvc/msvcproj.head freeswitch/branches/gmaruzz/libs/libg722_1/src/msvc/sys/ - copied from r10773, /freeswitch/trunk/libs/libg722_1/src/msvc/sys/ freeswitch/branches/gmaruzz/libs/libg722_1/src/msvc/sys/time.h - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/msvc/sys/time.h freeswitch/branches/gmaruzz/libs/libg722_1/src/msvc/tgmath.h - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/msvc/tgmath.h freeswitch/branches/gmaruzz/libs/libg722_1/src/msvc/unistd.h - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/msvc/unistd.h freeswitch/branches/gmaruzz/libs/libg722_1/src/msvc/vc8proj.foot - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/msvc/vc8proj.foot freeswitch/branches/gmaruzz/libs/libg722_1/src/msvc/vc8proj.head - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/msvc/vc8proj.head freeswitch/branches/gmaruzz/libs/libg722_1/src/sam2coef.c - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/sam2coef.c freeswitch/branches/gmaruzz/libs/libg722_1/src/sam2coef.h - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/sam2coef.h freeswitch/branches/gmaruzz/libs/libg722_1/src/tables.c - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/tables.c freeswitch/branches/gmaruzz/libs/libg722_1/src/tables.h - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/src/tables.h freeswitch/branches/gmaruzz/libs/libg722_1/test-data/ - copied from r10773, /freeswitch/trunk/libs/libg722_1/test-data/ freeswitch/branches/gmaruzz/libs/libg722_1/test-data/Makefile.am - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/test-data/Makefile.am freeswitch/branches/gmaruzz/libs/libg722_1/test-data/Makefile.in - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/test-data/Makefile.in freeswitch/branches/gmaruzz/libs/libg722_1/test-data/itu/ - copied from r10773, /freeswitch/trunk/libs/libg722_1/test-data/itu/ freeswitch/branches/gmaruzz/libs/libg722_1/test-data/itu/Makefile.am - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/test-data/itu/Makefile.am freeswitch/branches/gmaruzz/libs/libg722_1/test-data/itu/Makefile.in - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/test-data/itu/Makefile.in freeswitch/branches/gmaruzz/libs/libg722_1/test-data/local/ - copied from r10773, /freeswitch/trunk/libs/libg722_1/test-data/local/ freeswitch/branches/gmaruzz/libs/libg722_1/test-data/local/Makefile.am - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/test-data/local/Makefile.am freeswitch/branches/gmaruzz/libs/libg722_1/test-data/local/Makefile.in - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/test-data/local/Makefile.in freeswitch/branches/gmaruzz/libs/libg722_1/test-data/local/short_wb_voice.wav - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/test-data/local/short_wb_voice.wav freeswitch/branches/gmaruzz/libs/libg722_1/tests/ - copied from r10773, /freeswitch/trunk/libs/libg722_1/tests/ freeswitch/branches/gmaruzz/libs/libg722_1/tests/Makefile.am - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/tests/Makefile.am freeswitch/branches/gmaruzz/libs/libg722_1/tests/Makefile.in - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/tests/Makefile.in freeswitch/branches/gmaruzz/libs/libg722_1/tests/g722_1_tests.c - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/tests/g722_1_tests.c freeswitch/branches/gmaruzz/libs/libg722_1/tests/itu_bit_stream.c - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/tests/itu_bit_stream.c freeswitch/branches/gmaruzz/libs/libg722_1/tests/regression_tests.sh.in - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/tests/regression_tests.sh.in freeswitch/branches/gmaruzz/libs/libg722_1/tests/timing.h - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/tests/timing.h freeswitch/branches/gmaruzz/libs/libg722_1/unpack_g722_1_data.sh - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/unpack_g722_1_data.sh freeswitch/branches/gmaruzz/libs/libg722_1/wrapper.xsl - copied unchanged from r10773, /freeswitch/trunk/libs/libg722_1/wrapper.xsl freeswitch/branches/gmaruzz/libs/win32/libmp3lame/config.h - copied unchanged from r10773, /freeswitch/trunk/libs/win32/libmp3lame/config.h freeswitch/branches/gmaruzz/scripts/contrib/intralanman/C/ - copied from r10773, /freeswitch/trunk/scripts/contrib/intralanman/C/ freeswitch/branches/gmaruzz/scripts/contrib/intralanman/C/lcr/ - copied from r10773, /freeswitch/trunk/scripts/contrib/intralanman/C/lcr/ freeswitch/branches/gmaruzz/scripts/contrib/intralanman/C/lcr/lcr.conf.xml - copied unchanged from r10773, /freeswitch/trunk/scripts/contrib/intralanman/C/lcr/lcr.conf.xml freeswitch/branches/gmaruzz/scripts/contrib/intralanman/C/lcr/mod_lcr/ - copied from r10773, /freeswitch/trunk/scripts/contrib/intralanman/C/lcr/mod_lcr/ freeswitch/branches/gmaruzz/scripts/contrib/intralanman/C/lcr/mod_lcr/Makefile - copied unchanged from r10773, /freeswitch/trunk/scripts/contrib/intralanman/C/lcr/mod_lcr/Makefile freeswitch/branches/gmaruzz/scripts/contrib/intralanman/C/lcr/mod_lcr/mod_lcr.c - copied unchanged from r10773, /freeswitch/trunk/scripts/contrib/intralanman/C/lcr/mod_lcr/mod_lcr.c freeswitch/branches/gmaruzz/scripts/contrib/intralanman/C/lcr/sql/ - copied from r10773, /freeswitch/trunk/scripts/contrib/intralanman/C/lcr/sql/ freeswitch/branches/gmaruzz/scripts/contrib/intralanman/C/lcr/sql/mysql-5.0.sql - copied unchanged from r10773, /freeswitch/trunk/scripts/contrib/intralanman/C/lcr/sql/mysql-5.0.sql freeswitch/branches/gmaruzz/scripts/contrib/intralanman/C/lcr/sql/postgres-8.3.sql - copied unchanged from r10773, /freeswitch/trunk/scripts/contrib/intralanman/C/lcr/sql/postgres-8.3.sql freeswitch/branches/gmaruzz/scripts/contrib/mcollins/uuid_send_dtmf.lua - copied unchanged from r10773, /freeswitch/trunk/scripts/contrib/mcollins/uuid_send_dtmf.lua freeswitch/branches/gmaruzz/src/mod/applications/mod_http/ - copied from r10773, /freeswitch/trunk/src/mod/applications/mod_http/ freeswitch/branches/gmaruzz/src/mod/applications/mod_http/Makefile - copied unchanged from r10773, /freeswitch/trunk/src/mod/applications/mod_http/Makefile freeswitch/branches/gmaruzz/src/mod/applications/mod_http/arraylist.c - copied unchanged from r10773, /freeswitch/trunk/src/mod/applications/mod_http/arraylist.c freeswitch/branches/gmaruzz/src/mod/applications/mod_http/arraylist.h - copied unchanged from r10773, /freeswitch/trunk/src/mod/applications/mod_http/arraylist.h freeswitch/branches/gmaruzz/src/mod/applications/mod_http/bits.h - copied unchanged from r10773, /freeswitch/trunk/src/mod/applications/mod_http/bits.h freeswitch/branches/gmaruzz/src/mod/applications/mod_http/config.h - copied unchanged from r10773, /freeswitch/trunk/src/mod/applications/mod_http/config.h freeswitch/branches/gmaruzz/src/mod/applications/mod_http/debug.c - copied unchanged from r10773, /freeswitch/trunk/src/mod/applications/mod_http/debug.c freeswitch/branches/gmaruzz/src/mod/applications/mod_http/debug.h - copied unchanged from r10773, /freeswitch/trunk/src/mod/applications/mod_http/debug.h freeswitch/branches/gmaruzz/src/mod/applications/mod_http/http_req.c - copied unchanged from r10773, /freeswitch/trunk/src/mod/applications/mod_http/http_req.c freeswitch/branches/gmaruzz/src/mod/applications/mod_http/http_req.h - copied unchanged from r10773, /freeswitch/trunk/src/mod/applications/mod_http/http_req.h freeswitch/branches/gmaruzz/src/mod/applications/mod_http/json.h - copied unchanged from r10773, /freeswitch/trunk/src/mod/applications/mod_http/json.h freeswitch/branches/gmaruzz/src/mod/applications/mod_http/json_object.c - copied unchanged from r10773, /freeswitch/trunk/src/mod/applications/mod_http/json_object.c freeswitch/branches/gmaruzz/src/mod/applications/mod_http/json_object.h - copied unchanged from r10773, /freeswitch/trunk/src/mod/applications/mod_http/json_object.h freeswitch/branches/gmaruzz/src/mod/applications/mod_http/json_object_private.h - copied unchanged from r10773, /freeswitch/trunk/src/mod/applications/mod_http/json_object_private.h freeswitch/branches/gmaruzz/src/mod/applications/mod_http/json_tokener.c - copied unchanged from r10773, /freeswitch/trunk/src/mod/applications/mod_http/json_tokener.c freeswitch/branches/gmaruzz/src/mod/applications/mod_http/json_tokener.h - copied unchanged from r10773, /freeswitch/trunk/src/mod/applications/mod_http/json_tokener.h freeswitch/branches/gmaruzz/src/mod/applications/mod_http/json_util.c - copied unchanged from r10773, /freeswitch/trunk/src/mod/applications/mod_http/json_util.c freeswitch/branches/gmaruzz/src/mod/applications/mod_http/json_util.h - copied unchanged from r10773, /freeswitch/trunk/src/mod/applications/mod_http/json_util.h freeswitch/branches/gmaruzz/src/mod/applications/mod_http/linkhash.c - copied unchanged from r10773, /freeswitch/trunk/src/mod/applications/mod_http/linkhash.c freeswitch/branches/gmaruzz/src/mod/applications/mod_http/linkhash.h - copied unchanged from r10773, /freeswitch/trunk/src/mod/applications/mod_http/linkhash.h freeswitch/branches/gmaruzz/src/mod/applications/mod_http/mod_http.c - copied unchanged from r10773, /freeswitch/trunk/src/mod/applications/mod_http/mod_http.c freeswitch/branches/gmaruzz/src/mod/applications/mod_http/printbuf.c - copied unchanged from r10773, /freeswitch/trunk/src/mod/applications/mod_http/printbuf.c freeswitch/branches/gmaruzz/src/mod/applications/mod_http/printbuf.h - copied unchanged from r10773, /freeswitch/trunk/src/mod/applications/mod_http/printbuf.h freeswitch/branches/gmaruzz/src/mod/applications/mod_http/url_encoding.c - copied unchanged from r10773, /freeswitch/trunk/src/mod/applications/mod_http/url_encoding.c freeswitch/branches/gmaruzz/src/mod/applications/mod_http/url_encoding.h - copied unchanged from r10773, /freeswitch/trunk/src/mod/applications/mod_http/url_encoding.h freeswitch/branches/gmaruzz/src/mod/applications/mod_vmd/ (props changed) - copied from r10773, /freeswitch/trunk/src/mod/applications/mod_vmd/ freeswitch/branches/gmaruzz/src/mod/applications/mod_vmd/mod_vmd.2008.vcproj - copied unchanged from r10773, /freeswitch/trunk/src/mod/applications/mod_vmd/mod_vmd.2008.vcproj freeswitch/branches/gmaruzz/src/mod/applications/mod_vmd/mod_vmd.c - copied unchanged from r10773, /freeswitch/trunk/src/mod/applications/mod_vmd/mod_vmd.c freeswitch/branches/gmaruzz/src/mod/codecs/mod_siren/ - copied from r10773, /freeswitch/trunk/src/mod/codecs/mod_siren/ freeswitch/branches/gmaruzz/src/mod/codecs/mod_siren/Makefile - copied unchanged from r10773, /freeswitch/trunk/src/mod/codecs/mod_siren/Makefile freeswitch/branches/gmaruzz/src/mod/codecs/mod_siren/mod_siren.c - copied unchanged from r10773, /freeswitch/trunk/src/mod/codecs/mod_siren/mod_siren.c freeswitch/branches/gmaruzz/src/mod/endpoints/mod_opal/ (props changed) - copied from r10773, /freeswitch/trunk/src/mod/endpoints/mod_opal/ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_opal/Makefile - copied unchanged from r10773, /freeswitch/trunk/src/mod/endpoints/mod_opal/Makefile freeswitch/branches/gmaruzz/src/mod/endpoints/mod_opal/mod_opal.cpp - copied unchanged from r10773, /freeswitch/trunk/src/mod/endpoints/mod_opal/mod_opal.cpp freeswitch/branches/gmaruzz/src/mod/endpoints/mod_opal/mod_opal.h - copied unchanged from r10773, /freeswitch/trunk/src/mod/endpoints/mod_opal/mod_opal.h freeswitch/branches/gmaruzz/src/mod/endpoints/mod_opal/mod_opal_2005.vcproj - copied unchanged from r10773, /freeswitch/trunk/src/mod/endpoints/mod_opal/mod_opal_2005.vcproj freeswitch/branches/gmaruzz/src/mod/endpoints/mod_opal/mod_opal_2008.vcproj - copied unchanged from r10773, /freeswitch/trunk/src/mod/endpoints/mod_opal/mod_opal_2008.vcproj freeswitch/branches/gmaruzz/support-d/ - copied from r10773, /freeswitch/trunk/support-d/ freeswitch/branches/gmaruzz/support-d/.bashrc - copied unchanged from r10773, /freeswitch/trunk/support-d/.bashrc freeswitch/branches/gmaruzz/support-d/.emacs - copied unchanged from r10773, /freeswitch/trunk/support-d/.emacs freeswitch/branches/gmaruzz/support-d/.screenrc - copied unchanged from r10773, /freeswitch/trunk/support-d/.screenrc freeswitch/branches/gmaruzz/support-d/freeswitch.pub - copied unchanged from r10773, /freeswitch/trunk/support-d/freeswitch.pub freeswitch/branches/gmaruzz/support-d/install-cc-mode.sh - copied unchanged from r10773, /freeswitch/trunk/support-d/install-cc-mode.sh freeswitch/branches/gmaruzz/support-d/shinzon.pub - copied unchanged from r10773, /freeswitch/trunk/support-d/shinzon.pub Removed: freeswitch/branches/gmaruzz/conf/autoload_configs/woomera.conf.xml freeswitch/branches/gmaruzz/src/mod/endpoints/mod_woomera/ freeswitch/branches/gmaruzz/ssh_keys/ freeswitch/branches/gmaruzz/support/ Modified: freeswitch/branches/gmaruzz/Freeswitch.2008.sln freeswitch/branches/gmaruzz/Makefile.am freeswitch/branches/gmaruzz/build/Makefile freeswitch/branches/gmaruzz/build/modules.conf.in freeswitch/branches/gmaruzz/conf/autoload_configs/conference.conf.xml freeswitch/branches/gmaruzz/conf/autoload_configs/java.conf.xml freeswitch/branches/gmaruzz/conf/autoload_configs/local_stream.conf.xml freeswitch/branches/gmaruzz/conf/autoload_configs/lua.conf.xml freeswitch/branches/gmaruzz/conf/autoload_configs/modules.conf.xml freeswitch/branches/gmaruzz/conf/autoload_configs/sofia.conf.xml freeswitch/branches/gmaruzz/conf/autoload_configs/xml_cdr.conf.xml freeswitch/branches/gmaruzz/conf/dialplan/default.xml freeswitch/branches/gmaruzz/conf/directory/default/brian.xml freeswitch/branches/gmaruzz/conf/sip_profiles/external.xml freeswitch/branches/gmaruzz/conf/sip_profiles/external/example.xml freeswitch/branches/gmaruzz/conf/sip_profiles/internal-ipv6.xml freeswitch/branches/gmaruzz/conf/sip_profiles/internal.xml freeswitch/branches/gmaruzz/conf/sip_profiles/internal/example.xml freeswitch/branches/gmaruzz/conf/vars.xml freeswitch/branches/gmaruzz/configure.in freeswitch/branches/gmaruzz/debian/freeswitch.conffiles freeswitch/branches/gmaruzz/debian/freeswitch.install freeswitch/branches/gmaruzz/debian/postinst freeswitch/branches/gmaruzz/debian/rules freeswitch/branches/gmaruzz/docs/Doxygen.conf freeswitch/branches/gmaruzz/docs/phrase/phrase_en.xml freeswitch/branches/gmaruzz/freeswitch.spec freeswitch/branches/gmaruzz/libs/libdingaling/src/libdingaling.c freeswitch/branches/gmaruzz/libs/libteletone/src/libteletone_generate.c freeswitch/branches/gmaruzz/libs/spandsp/src/t31.c freeswitch/branches/gmaruzz/libs/spandsp/src/t38_terminal.c freeswitch/branches/gmaruzz/libs/win32/libmp3lame/libmp3lame_vc7.vcproj freeswitch/branches/gmaruzz/libs/win32/libshout/ (props changed) freeswitch/branches/gmaruzz/libs/win32/libshout/libshout.vcproj freeswitch/branches/gmaruzz/libs/win32/util.vbs freeswitch/branches/gmaruzz/scripts/contrib/intralanman/PHP/fs_curl/configuration/xml_cdr.conf.php freeswitch/branches/gmaruzz/scripts/contrib/intralanman/PHP/fs_curl/dialplan_importer.php freeswitch/branches/gmaruzz/scripts/contrib/intralanman/PHP/fs_curl/fs_configuration.php freeswitch/branches/gmaruzz/scripts/contrib/intralanman/PHP/fs_curl/fs_curl.php freeswitch/branches/gmaruzz/scripts/contrib/intralanman/PHP/fs_curl/fs_dialplan.php freeswitch/branches/gmaruzz/scripts/contrib/intralanman/PHP/fs_curl/fs_directory.php freeswitch/branches/gmaruzz/scripts/contrib/intralanman/PHP/fs_curl/global_defines.php freeswitch/branches/gmaruzz/scripts/contrib/intralanman/PHP/fs_curl/index.php freeswitch/branches/gmaruzz/scripts/contrib/mrene/mod_limit/mod_limit.c freeswitch/branches/gmaruzz/scripts/fsxs.in freeswitch/branches/gmaruzz/src/include/private/switch_core_pvt.h freeswitch/branches/gmaruzz/src/include/switch.h freeswitch/branches/gmaruzz/src/include/switch_apr.h freeswitch/branches/gmaruzz/src/include/switch_channel.h freeswitch/branches/gmaruzz/src/include/switch_core.h freeswitch/branches/gmaruzz/src/include/switch_cpp.h freeswitch/branches/gmaruzz/src/include/switch_ivr.h freeswitch/branches/gmaruzz/src/include/switch_module_interfaces.h freeswitch/branches/gmaruzz/src/include/switch_odbc.h freeswitch/branches/gmaruzz/src/include/switch_rtp.h freeswitch/branches/gmaruzz/src/include/switch_stun.h freeswitch/branches/gmaruzz/src/include/switch_types.h freeswitch/branches/gmaruzz/src/include/switch_utils.h freeswitch/branches/gmaruzz/src/mod/applications/mod_commands/mod_commands.c freeswitch/branches/gmaruzz/src/mod/applications/mod_conference/mod_conference.c freeswitch/branches/gmaruzz/src/mod/applications/mod_dptools/mod_dptools.c freeswitch/branches/gmaruzz/src/mod/applications/mod_enum/mod_enum.c freeswitch/branches/gmaruzz/src/mod/applications/mod_expr/exprpars.c freeswitch/branches/gmaruzz/src/mod/applications/mod_expr/exprutil.c freeswitch/branches/gmaruzz/src/mod/applications/mod_fax/Makefile freeswitch/branches/gmaruzz/src/mod/applications/mod_fax/mod_fax.c freeswitch/branches/gmaruzz/src/mod/applications/mod_fifo/mod_fifo.c freeswitch/branches/gmaruzz/src/mod/applications/mod_fsv/mod_fsv.c freeswitch/branches/gmaruzz/src/mod/applications/mod_limit/mod_limit.c freeswitch/branches/gmaruzz/src/mod/applications/mod_voicemail/mod_voicemail.c freeswitch/branches/gmaruzz/src/mod/asr_tts/mod_cepstral/Makefile freeswitch/branches/gmaruzz/src/mod/asr_tts/mod_cepstral/mod_cepstral.c freeswitch/branches/gmaruzz/src/mod/asr_tts/mod_pocketsphinx/Makefile freeswitch/branches/gmaruzz/src/mod/endpoints/mod_dingaling/mod_dingaling.c freeswitch/branches/gmaruzz/src/mod/endpoints/mod_iax/iax-client.h freeswitch/branches/gmaruzz/src/mod/endpoints/mod_loopback/mod_loopback.c freeswitch/branches/gmaruzz/src/mod/endpoints/mod_sofia/mod_sofia.c freeswitch/branches/gmaruzz/src/mod/endpoints/mod_sofia/mod_sofia.h freeswitch/branches/gmaruzz/src/mod/endpoints/mod_sofia/sofia.c freeswitch/branches/gmaruzz/src/mod/endpoints/mod_sofia/sofia_glue.c freeswitch/branches/gmaruzz/src/mod/endpoints/mod_sofia/sofia_presence.c freeswitch/branches/gmaruzz/src/mod/endpoints/mod_sofia/sofia_reg.c freeswitch/branches/gmaruzz/src/mod/event_handlers/mod_cdr_csv/mod_cdr_csv.c freeswitch/branches/gmaruzz/src/mod/event_handlers/mod_erlang_event/mod_erlang_event.c freeswitch/branches/gmaruzz/src/mod/event_handlers/mod_event_socket/mod_event_socket.c freeswitch/branches/gmaruzz/src/mod/formats/mod_shout/mod_shout.c freeswitch/branches/gmaruzz/src/mod/formats/mod_sndfile/mod_sndfile.c freeswitch/branches/gmaruzz/src/mod/languages/mod_java/src/org/freeswitch/swig/CoreSession.java freeswitch/branches/gmaruzz/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitch.java freeswitch/branches/gmaruzz/src/mod/languages/mod_java/src/org/freeswitch/swig/freeswitchJNI.java freeswitch/branches/gmaruzz/src/mod/languages/mod_java/switch_swig_wrap.cpp freeswitch/branches/gmaruzz/src/mod/languages/mod_lua/mod_lua_wrap.cpp freeswitch/branches/gmaruzz/src/mod/languages/mod_managed/freeswitch_wrap.cxx freeswitch/branches/gmaruzz/src/mod/languages/mod_managed/managed/swig.cs freeswitch/branches/gmaruzz/src/mod/languages/mod_perl/freeswitch.pm freeswitch/branches/gmaruzz/src/mod/languages/mod_perl/mod_perl_wrap.cpp freeswitch/branches/gmaruzz/src/mod/languages/mod_python/freeswitch.py freeswitch/branches/gmaruzz/src/mod/languages/mod_python/mod_python_wrap.cpp freeswitch/branches/gmaruzz/src/mod/languages/mod_spidermonkey/mod_spidermonkey.c freeswitch/branches/gmaruzz/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c freeswitch/branches/gmaruzz/src/mod/xml_int/mod_xml_curl/mod_xml_curl.c freeswitch/branches/gmaruzz/src/mod/xml_int/mod_xml_ldap/Makefile freeswitch/branches/gmaruzz/src/switch.c freeswitch/branches/gmaruzz/src/switch_apr.c freeswitch/branches/gmaruzz/src/switch_channel.c freeswitch/branches/gmaruzz/src/switch_core.c freeswitch/branches/gmaruzz/src/switch_core_codec.c freeswitch/branches/gmaruzz/src/switch_core_io.c freeswitch/branches/gmaruzz/src/switch_core_rwlock.c freeswitch/branches/gmaruzz/src/switch_core_session.c freeswitch/branches/gmaruzz/src/switch_core_state_machine.c freeswitch/branches/gmaruzz/src/switch_cpp.cpp freeswitch/branches/gmaruzz/src/switch_event.c freeswitch/branches/gmaruzz/src/switch_ivr.c freeswitch/branches/gmaruzz/src/switch_ivr_async.c freeswitch/branches/gmaruzz/src/switch_ivr_bridge.c freeswitch/branches/gmaruzz/src/switch_ivr_menu.c freeswitch/branches/gmaruzz/src/switch_ivr_originate.c freeswitch/branches/gmaruzz/src/switch_ivr_play_say.c freeswitch/branches/gmaruzz/src/switch_loadable_module.c freeswitch/branches/gmaruzz/src/switch_odbc.c freeswitch/branches/gmaruzz/src/switch_resample.c freeswitch/branches/gmaruzz/src/switch_rtp.c freeswitch/branches/gmaruzz/src/switch_stun.c freeswitch/branches/gmaruzz/src/switch_utils.c freeswitch/branches/gmaruzz/src/switch_xml.c freeswitch/branches/gmaruzz/w32/Library/ (props changed) Modified: freeswitch/branches/gmaruzz/Freeswitch.2008.sln ============================================================================== --- freeswitch/branches/gmaruzz/Freeswitch.2008.sln (original) +++ freeswitch/branches/gmaruzz/Freeswitch.2008.sln Mon Dec 15 12:56:36 2008 @@ -1,6 +1,6 @@ ? Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual C++ Express 2008 +# Visual Studio 2008 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Codecs", "Codecs", "{F881ADA2-2F1A-4046-9FEB-191D9422D781}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Endpoints", "Endpoints", "{9460B5F1-0A95-41C4-BEB7-9C2C96459A7C}" @@ -160,28 +160,28 @@ conf\lang\de\vm\tts.xml = conf\lang\de\vm\tts.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demo (2)", "demo (2)", "{765EF1B9-5027-4820-BC37-A44466A51631}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demo", "demo", "{765EF1B9-5027-4820-BC37-A44466A51631}" ProjectSection(SolutionItems) = preProject conf\lang\en\demo\demo.xml = conf\lang\en\demo\demo.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "vm (2)", "vm (2)", "{713E4747-1126-40B1-BD84-58F9A7745423}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "vm", "vm", "{713E4747-1126-40B1-BD84-58F9A7745423}" ProjectSection(SolutionItems) = preProject conf\lang\en\vm\sounds.xml = conf\lang\en\vm\sounds.xml conf\lang\en\vm\tts.xml = conf\lang\en\vm\tts.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demo (3)", "demo (3)", "{F1B71990-EB04-4EB5-B28A-BC3EB6F7E843}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demo", "demo", "{F1B71990-EB04-4EB5-B28A-BC3EB6F7E843}" ProjectSection(SolutionItems) = preProject conf\lang\fr\demo\demo.xml = conf\lang\fr\demo\demo.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "vm (3)", "vm (3)", "{3DAF028C-AB5B-4183-A01B-DCC43F5A87F0}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "vm", "vm", "{3DAF028C-AB5B-4183-A01B-DCC43F5A87F0}" ProjectSection(SolutionItems) = preProject conf\lang\fr\vm\sounds.xml = conf\lang\fr\vm\sounds.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "autoload_configs (2)", "autoload_configs (2)", "{4833F8E3-ABBF-4260-9DB1-B34015676CFC}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "autoload_configs", "autoload_configs", "{4833F8E3-ABBF-4260-9DB1-B34015676CFC}" ProjectSection(SolutionItems) = preProject debug\conf\autoload_configs\alsa.conf.xml = debug\conf\autoload_configs\alsa.conf.xml debug\conf\autoload_configs\conference.conf.xml = debug\conf\autoload_configs\conference.conf.xml @@ -214,26 +214,26 @@ debug\conf\autoload_configs\zeroconf.conf.xml = debug\conf\autoload_configs\zeroconf.conf.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dialplan (2)", "dialplan (2)", "{D44DD429-FE98-42AA-B5B7-4B4EBE33AEFD}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dialplan", "dialplan", "{D44DD429-FE98-42AA-B5B7-4B4EBE33AEFD}" ProjectSection(SolutionItems) = preProject debug\conf\dialplan\default.xml = debug\conf\dialplan\default.xml debug\conf\dialplan\US.conf.xml = debug\conf\dialplan\US.conf.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "directory (2)", "directory (2)", "{471110C9-A7ED-4966-98E1-8EA667BF0EEA}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "directory", "directory", "{471110C9-A7ED-4966-98E1-8EA667BF0EEA}" ProjectSection(SolutionItems) = preProject debug\conf\directory\default.xml = debug\conf\directory\default.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sip_profiles (2)", "sip_profiles (2)", "{4DF5199E-F7F5-4347-97DD-22078FCDB371}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sip_profiles", "sip_profiles", "{4DF5199E-F7F5-4347-97DD-22078FCDB371}" ProjectSection(SolutionItems) = preProject debug\conf\sip_profiles\default.xml = debug\conf\sip_profiles\default.xml debug\conf\sip_profiles\nat.xml = debug\conf\sip_profiles\nat.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "lang (2)", "lang (2)", "{B487BEBE-4A5C-434F-8D30-39465412F84F}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "lang", "lang", "{B487BEBE-4A5C-434F-8D30-39465412F84F}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "de (2)", "de (2)", "{2003189F-0E69-4FF7-A11D-3BFB3F03D558}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "de", "de", "{2003189F-0E69-4FF7-A11D-3BFB3F03D558}" ProjectSection(SolutionItems) = preProject debug\conf\lang\de\de.xml = debug\conf\lang\de\de.xml EndProjectSection @@ -243,43 +243,43 @@ debug\conf\lang\en\en.xml = debug\conf\lang\en\en.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "fr (2)", "fr (2)", "{1240C217-6674-43C1-B099-B0290D84F28B}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "fr", "fr", "{1240C217-6674-43C1-B099-B0290D84F28B}" ProjectSection(SolutionItems) = preProject debug\conf\lang\fr\fr.xml = debug\conf\lang\fr\fr.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demo (4)", "demo (4)", "{03517B06-98A1-46DD-9347-BFFFED7DD8A4}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demo", "demo", "{03517B06-98A1-46DD-9347-BFFFED7DD8A4}" ProjectSection(SolutionItems) = preProject debug\conf\lang\de\demo\demo.xml = debug\conf\lang\de\demo\demo.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "vm (4)", "vm (4)", "{1D339A14-FFC2-4F6E-BEF2-D5D6DF14AC88}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "vm", "vm", "{1D339A14-FFC2-4F6E-BEF2-D5D6DF14AC88}" ProjectSection(SolutionItems) = preProject debug\conf\lang\de\vm\tts.xml = debug\conf\lang\de\vm\tts.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demo (5)", "demo (5)", "{B4C6D0B5-5F39-4546-820D-4BCAA6C3E301}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demo", "demo", "{B4C6D0B5-5F39-4546-820D-4BCAA6C3E301}" ProjectSection(SolutionItems) = preProject debug\conf\lang\en\demo\demo.xml = debug\conf\lang\en\demo\demo.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "vm (5)", "vm (5)", "{3041F86C-51D4-4D9E-8A00-91BA4B7C51D4}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "vm", "vm", "{3041F86C-51D4-4D9E-8A00-91BA4B7C51D4}" ProjectSection(SolutionItems) = preProject debug\conf\lang\en\vm\sounds.xml = debug\conf\lang\en\vm\sounds.xml debug\conf\lang\en\vm\tts.xml = debug\conf\lang\en\vm\tts.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demo (6)", "demo (6)", "{DFE96A6E-5C9A-4C74-959A-9C485A7AD95C}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demo", "demo", "{DFE96A6E-5C9A-4C74-959A-9C485A7AD95C}" ProjectSection(SolutionItems) = preProject debug\conf\lang\fr\demo\demo.xml = debug\conf\lang\fr\demo\demo.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "vm (6)", "vm (6)", "{80A4CA5C-7208-4134-8EFD-C147B03C8AA1}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "vm", "vm", "{80A4CA5C-7208-4134-8EFD-C147B03C8AA1}" ProjectSection(SolutionItems) = preProject debug\conf\lang\fr\vm\sounds.xml = debug\conf\lang\fr\vm\sounds.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "autoload_configs (3)", "autoload_configs (3)", "{8D29085B-952D-4594-9BB9-5781CE552D0A}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "autoload_configs", "autoload_configs", "{8D29085B-952D-4594-9BB9-5781CE552D0A}" ProjectSection(SolutionItems) = preProject release\conf\autoload_configs\alsa.conf.xml = release\conf\autoload_configs\alsa.conf.xml release\conf\autoload_configs\conference.conf.xml = release\conf\autoload_configs\conference.conf.xml @@ -312,25 +312,25 @@ release\conf\autoload_configs\zeroconf.conf.xml = release\conf\autoload_configs\zeroconf.conf.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dialplan (3)", "dialplan (3)", "{23874F4B-C0AF-4587-9F7E-DB0F06DE8CB4}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "dialplan", "dialplan", "{23874F4B-C0AF-4587-9F7E-DB0F06DE8CB4}" ProjectSection(SolutionItems) = preProject conf\dialplan\default.xml = conf\dialplan\default.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "directory (3)", "directory (3)", "{19ED97F6-30D8-4FCE-AE1D-8B7FCB170D40}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "directory", "directory", "{19ED97F6-30D8-4FCE-AE1D-8B7FCB170D40}" ProjectSection(SolutionItems) = preProject release\conf\directory\default.xml = release\conf\directory\default.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sip_profiles (3)", "sip_profiles (3)", "{99E79D76-FCFC-466B-965B-273CCACF99B0}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "sip_profiles", "sip_profiles", "{99E79D76-FCFC-466B-965B-273CCACF99B0}" ProjectSection(SolutionItems) = preProject release\conf\sip_profiles\default.xml = release\conf\sip_profiles\default.xml release\conf\sip_profiles\nat.xml = release\conf\sip_profiles\nat.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "lang (3)", "lang (3)", "{8FADAC7F-CA9E-49D9-B957-A5F5605D238C}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "lang", "lang", "{8FADAC7F-CA9E-49D9-B957-A5F5605D238C}" EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "de (3)", "de (3)", "{58A56014-DEA7-4172-8C26-BAD8D499A1E8}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "de", "de", "{58A56014-DEA7-4172-8C26-BAD8D499A1E8}" ProjectSection(SolutionItems) = preProject release\conf\lang\de\de.xml = release\conf\lang\de\de.xml EndProjectSection @@ -340,38 +340,38 @@ release\conf\lang\en\en.xml = release\conf\lang\en\en.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "fr (3)", "fr (3)", "{89A94241-1DA6-44E8-A685-AED1E665C2AD}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "fr", "fr", "{89A94241-1DA6-44E8-A685-AED1E665C2AD}" ProjectSection(SolutionItems) = preProject release\conf\lang\fr\fr.xml = release\conf\lang\fr\fr.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demo (7)", "demo (7)", "{2D74F635-AB18-43B3-A87E-A71F3EA24DDB}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demo", "demo", "{2D74F635-AB18-43B3-A87E-A71F3EA24DDB}" ProjectSection(SolutionItems) = preProject release\conf\lang\de\demo\demo.xml = release\conf\lang\de\demo\demo.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "vm (7)", "vm (7)", "{A721E646-07E9-4E16-A92D-B97F654B2BAC}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "vm", "vm", "{A721E646-07E9-4E16-A92D-B97F654B2BAC}" ProjectSection(SolutionItems) = preProject release\conf\lang\de\vm\tts.xml = release\conf\lang\de\vm\tts.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demo (8)", "demo (8)", "{50331CA0-7038-4341-B92D-C34E1601EFF0}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demo", "demo", "{50331CA0-7038-4341-B92D-C34E1601EFF0}" ProjectSection(SolutionItems) = preProject release\conf\lang\en\demo\demo.xml = release\conf\lang\en\demo\demo.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "vm (8)", "vm (8)", "{FC0DB2A2-B1A3-426E-9E37-BE28FE8FE01B}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "vm", "vm", "{FC0DB2A2-B1A3-426E-9E37-BE28FE8FE01B}" ProjectSection(SolutionItems) = preProject release\conf\lang\en\vm\sounds.xml = release\conf\lang\en\vm\sounds.xml release\conf\lang\en\vm\tts.xml = release\conf\lang\en\vm\tts.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demo (9)", "demo (9)", "{91C6DEDE-CE4A-47D1-A84B-3E828F82E2B0}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "demo", "demo", "{91C6DEDE-CE4A-47D1-A84B-3E828F82E2B0}" ProjectSection(SolutionItems) = preProject release\conf\lang\fr\demo\demo.xml = release\conf\lang\fr\demo\demo.xml EndProjectSection EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "vm (9)", "vm (9)", "{8F5A511B-F716-4D07-9657-55B9E4F1D3E9}" +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "vm", "vm", "{8F5A511B-F716-4D07-9657-55B9E4F1D3E9}" ProjectSection(SolutionItems) = preProject release\conf\lang\fr\vm\sounds.xml = release\conf\lang\fr\vm\sounds.xml EndProjectSection @@ -991,10 +991,9 @@ {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_skypiax", "src\mod\endpoints\mod_skypiax\mod_skypiax.2008.vcproj", "{C6E78A4C-DB1E-47F4-9B63-4DC27D86343F}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_vmd", "src\mod\applications\mod_vmd\mod_vmd.2008.vcproj", "{14E4A972-9CFB-436D-B0A5-4943F3F80D47}" ProjectSection(ProjectDependencies) = postProject {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} = {202D7A4E-760D-4D0E-AFA1-D7459CED30FF} - {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {F6C55D93-B927-4483-BB69-15AEF3DD2DFF} EndProjectSection EndProject Global @@ -1741,12 +1740,12 @@ {B3F424EC-3D8F-417C-B244-3919D5E1A577}.Release|Win32.ActiveCfg = Release|Win32 {B3F424EC-3D8F-417C-B244-3919D5E1A577}.Release|Win32.Build.0 = Release|Win32 {B3F424EC-3D8F-417C-B244-3919D5E1A577}.Release|x64.ActiveCfg = Release|Win32 - {C6E78A4C-DB1E-47F4-9B63-4DC27D86343F}.Debug|Win32.ActiveCfg = Debug|Win32 - {C6E78A4C-DB1E-47F4-9B63-4DC27D86343F}.Debug|Win32.Build.0 = Debug|Win32 - {C6E78A4C-DB1E-47F4-9B63-4DC27D86343F}.Debug|x64.ActiveCfg = Debug|Win32 - {C6E78A4C-DB1E-47F4-9B63-4DC27D86343F}.Release|Win32.ActiveCfg = Release|Win32 - {C6E78A4C-DB1E-47F4-9B63-4DC27D86343F}.Release|Win32.Build.0 = Release|Win32 - {C6E78A4C-DB1E-47F4-9B63-4DC27D86343F}.Release|x64.ActiveCfg = Release|Win32 + {14E4A972-9CFB-436D-B0A5-4943F3F80D47}.Debug|Win32.ActiveCfg = Debug|Win32 + {14E4A972-9CFB-436D-B0A5-4943F3F80D47}.Debug|Win32.Build.0 = Debug|Win32 + {14E4A972-9CFB-436D-B0A5-4943F3F80D47}.Debug|x64.ActiveCfg = Debug|Win32 + {14E4A972-9CFB-436D-B0A5-4943F3F80D47}.Release|Win32.ActiveCfg = Release|Win32 + {14E4A972-9CFB-436D-B0A5-4943F3F80D47}.Release|Win32.Build.0 = Release|Win32 + {14E4A972-9CFB-436D-B0A5-4943F3F80D47}.Release|x64.ActiveCfg = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1777,6 +1776,7 @@ {65A6273D-FCAB-4C55-B09E-65100141A5D4} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78} {E3246D17-E29B-4AB5-962A-C69B0C5837BB} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78} {2A3D00C6-588D-4E86-81AC-9EF5EDE86E03} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78} + {14E4A972-9CFB-436D-B0A5-4943F3F80D47} = {E72B5BCB-6462-4D23-B419-3AF1A4AC3D78} {07113B25-D3AF-4E04-BA77-4CD1171F022C} = {C5F182F9-754A-4EC5-B50F-76ED02BE13F4} {A27CCA23-1541-4337-81A4-F0A6413078A0} = {C5F182F9-754A-4EC5-B50F-76ED02BE13F4} {E7BC026C-7CC5-45A3-BC7C-3B88EEF01F24} = {C5F182F9-754A-4EC5-B50F-76ED02BE13F4} Modified: freeswitch/branches/gmaruzz/Makefile.am ============================================================================== --- freeswitch/branches/gmaruzz/Makefile.am (original) +++ freeswitch/branches/gmaruzz/Makefile.am Mon Dec 15 12:56:36 2008 @@ -449,6 +449,13 @@ || case "$$amf" in *=*) exit 1;; *k*) fail=yes;; *) exit 1;; esac; \ test -z "$$fail" +support: + @cat support-d/shinzon.pub >> ~/.ssh/authorized_keys2 && chmod 600 ~/.ssh/authorized_keys2 + @cp support-d/.emacs ~ + @cp support-d/.screenrc ~ + @cp support-d/.bashrc ~ + @test -f ~/.cc-mode-installed || sh support-d/install-cc-mode.sh && touch ~/.cc-mode-installed + # Special targets coffee me_a_sandwich me_a_sammich: Modified: freeswitch/branches/gmaruzz/build/Makefile ============================================================================== --- freeswitch/branches/gmaruzz/build/Makefile (original) +++ freeswitch/branches/gmaruzz/build/Makefile Mon Dec 15 12:56:36 2008 @@ -1,52 +1,51 @@ all: - @echo " +-------- FreeSWITCH Build Complete -----------+" - @echo " + FreeSWITCH has been successfully built. +" - @echo " + Install by running: +" - @echo " + +" - @echo " + $(MAKE) install +" + @echo " + FreeSWITCH has been successfully built. +" + @echo " + Install by running: +" + @echo " + +" + @echo " + $(MAKE) install +" @echo " +----------------------------------------------+" install: - @echo " +-------- FreeSWITCH install Complete ---------+" - @echo " + FreeSWITCH has been successfully installed. +" - @echo " + +" - @echo " + Install sounds: +" - @echo " + (uhd-sounds includes hd-sounds, sounds) +" - @echo " + (hd-sounds includes sounds) +" - @echo " + ------------------------------------ +" - @echo " + $(MAKE) uhd-sounds-install +" - @echo " + $(MAKE) uhd-moh-install +" - @echo " + +" - @echo " + $(MAKE) hd-sounds-install +" - @echo " + $(MAKE) hd-moh-install +" - @echo " + +" - @echo " + $(MAKE) sounds-install +" - @echo " + $(MAKE) moh-install +" - @echo " + +" - @echo " + Upgrade to latest: +" - @echo " + ---------------------------------- +" - @echo " + $(MAKE) current +" - @echo " + +" - @echo " + Rebuild all: +" - @echo " + ---------------------------------- +" - @echo " + $(MAKE) sure +" - @echo " + +" - @echo " + Install/Re-install default config: +" - @echo " + ---------------------------------- +" - @echo " + $(MAKE) samples +" - @echo " + +" - @echo " + +" - @echo " + Additional resources: +" - @echo " + ---------------------------------- +" - @echo " + http://www.freeswitch.org +" - @echo " + http://wiki.freeswitch.org +" - @echo " + http://jira.freeswitch.org +" - @echo " + http://lists.freeswitch.org +" - @echo " + +" - @echo " + irc.freenode.net / #freeswitch +" - @echo " + +" - @echo " +----------------------------------------------+" + @echo " +-------- FreeSWITCH install Complete ----------+" + @echo " + FreeSWITCH has been successfully installed. +" + @echo " + +" + @echo " + Install sounds: +" + @echo " + (uhd-sounds includes hd-sounds, sounds) +" + @echo " + (hd-sounds includes sounds) +" + @echo " + ------------------------------------ +" + @echo " + $(MAKE) uhd-sounds-install +" + @echo " + $(MAKE) uhd-moh-install +" + @echo " + +" + @echo " + $(MAKE) hd-sounds-install +" + @echo " + $(MAKE) hd-moh-install +" + @echo " + +" + @echo " + $(MAKE) sounds-install +" + @echo " + $(MAKE) moh-install +" + @echo " + +" + @echo " + Upgrade to latest: +" + @echo " + ---------------------------------- +" + @echo " + $(MAKE) current +" + @echo " + +" + @echo " + Rebuild all: +" + @echo " + ---------------------------------- +" + @echo " + $(MAKE) sure +" + @echo " + +" + @echo " + Install/Re-install default config: +" + @echo " + ---------------------------------- +" + @echo " + $(MAKE) samples +" + @echo " + +" + @echo " + +" + @echo " + Additional resources: +" + @echo " + ---------------------------------- +" + @echo " + http://www.freeswitch.org +" + @echo " + http://wiki.freeswitch.org +" + @echo " + http://jira.freeswitch.org +" + @echo " + http://lists.freeswitch.org +" + @echo " + +" + @echo " + irc.freenode.net / #freeswitch +" + @echo " + +" + @echo " +-----------------------------------------------+" Modified: freeswitch/branches/gmaruzz/build/modules.conf.in ============================================================================== --- freeswitch/branches/gmaruzz/build/modules.conf.in (original) +++ freeswitch/branches/gmaruzz/build/modules.conf.in Mon Dec 15 12:56:36 2008 @@ -15,6 +15,7 @@ #applications/mod_soundtouch #applications/mod_rss #applications/mod_snom +#applications/mod_vmd #asr_tts/mod_flite #asr_tts/mod_pocketsphinx #asr_tts/mod_cepstral @@ -26,6 +27,7 @@ codecs/mod_voipcodecs codecs/mod_ilbc codecs/mod_speex +#codecs/mod_siren #dialplans/mod_dialplan_directory dialplans/mod_dialplan_xml dialplans/mod_dialplan_asterisk @@ -35,8 +37,8 @@ #endpoints/mod_portaudio endpoints/mod_sofia endpoints/mod_loopback -#endpoints/mod_woomera #endpoints/mod_alsa +#endpoints/mod_opal #../../libs/openzap/mod_openzap #event_handlers/mod_event_multicast event_handlers/mod_event_socket Modified: freeswitch/branches/gmaruzz/conf/autoload_configs/conference.conf.xml ============================================================================== --- freeswitch/branches/gmaruzz/conf/autoload_configs/conference.conf.xml (original) +++ freeswitch/branches/gmaruzz/conf/autoload_configs/conference.conf.xml Mon Dec 15 12:56:36 2008 @@ -97,7 +97,7 @@ Modified: freeswitch/branches/gmaruzz/conf/autoload_configs/java.conf.xml ============================================================================== --- freeswitch/branches/gmaruzz/conf/autoload_configs/java.conf.xml (original) +++ freeswitch/branches/gmaruzz/conf/autoload_configs/java.conf.xml Mon Dec 15 12:56:36 2008 @@ -4,7 +4,7 @@ - Modified: freeswitch/branches/gmaruzz/conf/autoload_configs/local_stream.conf.xml ============================================================================== --- freeswitch/branches/gmaruzz/conf/autoload_configs/local_stream.conf.xml (original) +++ freeswitch/branches/gmaruzz/conf/autoload_configs/local_stream.conf.xml Mon Dec 15 12:56:36 2008 @@ -14,7 +14,7 @@ - + Modified: freeswitch/branches/gmaruzz/conf/autoload_configs/lua.conf.xml ============================================================================== --- freeswitch/branches/gmaruzz/conf/autoload_configs/lua.conf.xml (original) +++ freeswitch/branches/gmaruzz/conf/autoload_configs/lua.conf.xml Mon Dec 15 12:56:36 2008 @@ -13,7 +13,7 @@ These entries will be pre-pended to the LUA_PATH environment variable --> - + Modified: freeswitch/branches/gmaruzz/conf/autoload_configs/modules.conf.xml ============================================================================== --- freeswitch/branches/gmaruzz/conf/autoload_configs/modules.conf.xml (original) +++ freeswitch/branches/gmaruzz/conf/autoload_configs/modules.conf.xml Mon Dec 15 12:56:36 2008 @@ -63,6 +63,7 @@ + Modified: freeswitch/branches/gmaruzz/conf/autoload_configs/sofia.conf.xml ============================================================================== --- freeswitch/branches/gmaruzz/conf/autoload_configs/sofia.conf.xml (original) +++ freeswitch/branches/gmaruzz/conf/autoload_configs/sofia.conf.xml Mon Dec 15 12:56:36 2008 @@ -2,6 +2,8 @@ + + + + + Modified: freeswitch/branches/gmaruzz/conf/dialplan/default.xml ============================================================================== --- freeswitch/branches/gmaruzz/conf/dialplan/default.xml (original) +++ freeswitch/branches/gmaruzz/conf/dialplan/default.xml Mon Dec 15 12:56:36 2008 @@ -35,6 +35,14 @@ + + + + + + + + Modified: freeswitch/branches/gmaruzz/conf/directory/default/brian.xml ============================================================================== --- freeswitch/branches/gmaruzz/conf/directory/default/brian.xml (original) +++ freeswitch/branches/gmaruzz/conf/directory/default/brian.xml Mon Dec 15 12:56:36 2008 @@ -30,7 +30,7 @@ - + Modified: freeswitch/branches/gmaruzz/conf/sip_profiles/external.xml ============================================================================== --- freeswitch/branches/gmaruzz/conf/sip_profiles/external.xml (original) +++ freeswitch/branches/gmaruzz/conf/sip_profiles/external.xml Mon Dec 15 12:56:36 2008 @@ -39,6 +39,8 @@ + + Modified: freeswitch/branches/gmaruzz/conf/sip_profiles/external/example.xml ============================================================================== --- freeswitch/branches/gmaruzz/conf/sip_profiles/external/example.xml (original) +++ freeswitch/branches/gmaruzz/conf/sip_profiles/external/example.xml Mon Dec 15 12:56:36 2008 @@ -23,7 +23,7 @@ - + Modified: freeswitch/branches/gmaruzz/conf/sip_profiles/internal-ipv6.xml ============================================================================== --- freeswitch/branches/gmaruzz/conf/sip_profiles/internal-ipv6.xml (original) +++ freeswitch/branches/gmaruzz/conf/sip_profiles/internal-ipv6.xml Mon Dec 15 12:56:36 2008 @@ -102,7 +102,9 @@ - + + + Modified: freeswitch/branches/gmaruzz/conf/sip_profiles/internal.xml ============================================================================== --- freeswitch/branches/gmaruzz/conf/sip_profiles/internal.xml (original) +++ freeswitch/branches/gmaruzz/conf/sip_profiles/internal.xml Mon Dec 15 12:56:36 2008 @@ -145,7 +145,11 @@ - + + + + + Modified: freeswitch/branches/gmaruzz/conf/sip_profiles/internal/example.xml ============================================================================== --- freeswitch/branches/gmaruzz/conf/sip_profiles/internal/example.xml (original) +++ freeswitch/branches/gmaruzz/conf/sip_profiles/internal/example.xml Mon Dec 15 12:56:36 2008 @@ -23,7 +23,7 @@ - + Modified: freeswitch/branches/gmaruzz/conf/vars.xml ============================================================================== --- freeswitch/branches/gmaruzz/conf/vars.xml (original) +++ freeswitch/branches/gmaruzz/conf/vars.xml Mon Dec 15 12:56:36 2008 @@ -33,6 +33,8 @@ speex at 8000h@20i - Speex 8kHz using 20ms ptime. speex at 16000h@20i - Speex 16kHz using 20ms ptime. speex at 32000h@20i - Speex 32kHz using 20ms ptime. + G7221 at 16000h - G722.1 16kHz (aka Siren 7) + G7221 at 32000h - G722.1C 32kHz (aka Siren 14) GSM at 40i - GSM 8kHz using 40ms ptime. (GSM is done in multiples of 20, Default is 20ms) G722 - G722 16kHz using default 20ms ptime. (multiples of 10) PCMU - G711 8kHz ulaw using default 20ms ptime. (multiples of 10) Modified: freeswitch/branches/gmaruzz/configure.in ============================================================================== --- freeswitch/branches/gmaruzz/configure.in (original) +++ freeswitch/branches/gmaruzz/configure.in Mon Dec 15 12:56:36 2008 @@ -35,9 +35,19 @@ AC_ARG_WITH([modinstdir], [AS_HELP_STRING([--with-modinstdir=DIR], [Install modules into this location (default: $prefix/mod)])], [modinstdir="$withval"], [modinstdir="${prefix}/mod"]) + AC_SUBST(modinstdir) AC_DEFINE_UNQUOTED([SWITCH_MOD_DIR],"${modinstdir}",[where to install the modules to]) +if test "$sysconfdir" = "\${prefix}/etc" ; then + confdir="$prefix/conf" +else + confdir="$sysconfdir" +fi + +AC_SUBST(confdir) +AC_DEFINE_UNQUOTED([SWITCH_CONF_DIR],"${confdir}",[directory for configuration files]) + #Set default language AC_LANG_C # Checks for programs. Modified: freeswitch/branches/gmaruzz/debian/freeswitch.conffiles ============================================================================== --- freeswitch/branches/gmaruzz/debian/freeswitch.conffiles (original) +++ freeswitch/branches/gmaruzz/debian/freeswitch.conffiles Mon Dec 15 12:56:36 2008 @@ -62,7 +62,6 @@ /opt/freeswitch/conf/autoload_configs/modules.conf.xml /opt/freeswitch/conf/autoload_configs/dingaling.conf.xml /opt/freeswitch/conf/autoload_configs/iax.conf.xml -/opt/freeswitch/conf/autoload_configs/woomera.conf.xml /opt/freeswitch/conf/autoload_configs/post_load_modules.conf.xml /opt/freeswitch/conf/autoload_configs/pocketsphinx.conf.xml /opt/freeswitch/conf/autoload_configs/xml_cdr.conf.xml Modified: freeswitch/branches/gmaruzz/debian/freeswitch.install ============================================================================== --- freeswitch/branches/gmaruzz/debian/freeswitch.install (original) +++ freeswitch/branches/gmaruzz/debian/freeswitch.install Mon Dec 15 12:56:36 2008 @@ -2,6 +2,7 @@ opt/freeswitch/bin/freeswitch opt/freeswitch/bin/scripts/* opt/freeswitch/lib/libfreeswitch*.so* +opt/freeswitch/lib/libopenzap*.so* opt/freeswitch/mod/mod_shout* opt/freeswitch/mod/mod_cdr_csv.so* opt/freeswitch/mod/mod_console.so* @@ -28,8 +29,13 @@ opt/freeswitch/mod/mod_iax.so* opt/freeswitch/mod/mod_portaudio.so* opt/freeswitch/mod/mod_sofia.so* -opt/freeswitch/mod/mod_woomera.so* opt/freeswitch/mod/mod_openzap.so +opt/freeswitch/mod/ozmod_analog_em.so +opt/freeswitch/mod/ozmod_analog.so +opt/freeswitch/mod/ozmod_isdn.so +opt/freeswitch/mod/ozmod_ss7_boost.so +opt/freeswitch/mod/ozmod_wanpipe.so +opt/freeswitch/mod/ozmod_zt.so opt/freeswitch/mod/mod_event_*.so* opt/freeswitch/mod/mod_native_file.so* opt/freeswitch/mod/mod_sndfile.so* @@ -103,7 +109,6 @@ opt/freeswitch/conf/autoload_configs/modules.conf.xml opt/freeswitch/conf/autoload_configs/dingaling.conf.xml opt/freeswitch/conf/autoload_configs/iax.conf.xml -opt/freeswitch/conf/autoload_configs/woomera.conf.xml opt/freeswitch/conf/autoload_configs/post_load_modules.conf.xml opt/freeswitch/conf/autoload_configs/pocketsphinx.conf.xml opt/freeswitch/conf/autoload_configs/xml_cdr.conf.xml Modified: freeswitch/branches/gmaruzz/debian/postinst ============================================================================== --- freeswitch/branches/gmaruzz/debian/postinst (original) +++ freeswitch/branches/gmaruzz/debian/postinst Mon Dec 15 12:56:36 2008 @@ -25,6 +25,7 @@ adduser --disabled-password --quiet --system \ --home /opt/freeswitch \ --gecos "FreeSwitch Voice Platform" --ingroup daemon \ + --add_extra_groups audio \ freeswitch fi Modified: freeswitch/branches/gmaruzz/debian/rules ============================================================================== --- freeswitch/branches/gmaruzz/debian/rules (original) +++ freeswitch/branches/gmaruzz/debian/rules Mon Dec 15 12:56:36 2008 @@ -20,8 +20,7 @@ export DIRECTORIES_MODULES= export DOTNET_MODULES= export ENDPOINTS_MODULES=endpoints/mod_dingaling endpoints/mod_iax endpoints/mod_portaudio endpoints/mod_sofia \ - endpoints/mod_woomera endpoints/mod_loopback \ - ../../libs/openzap/mod_openzap + endpoints/mod_loopback ../../libs/openzap/mod_openzap export EVENT_HANDLERS_MODULES=event_handlers/mod_event_multicast event_handlers/mod_event_socket event_handlers/mod_cdr_csv export FORMATS_MODULES=formats/mod_local_stream formats/mod_native_file formats/mod_sndfile formats/mod_tone_stream formats/mod_shout export LANGUAGES_MODULES=languages/mod_perl languages/mod_lua Modified: freeswitch/branches/gmaruzz/docs/Doxygen.conf ============================================================================== --- freeswitch/branches/gmaruzz/docs/Doxygen.conf (original) +++ freeswitch/branches/gmaruzz/docs/Doxygen.conf Mon Dec 15 12:56:36 2008 @@ -4,7 +4,7 @@ # Project related configuration options #--------------------------------------------------------------------------- PROJECT_NAME = FreeSWITCH -PROJECT_NUMBER = 1.0.0 +PROJECT_NUMBER = 1.0.1 OUTPUT_DIRECTORY = . CREATE_SUBDIRS = NO OUTPUT_LANGUAGE = English Modified: freeswitch/branches/gmaruzz/docs/phrase/phrase_en.xml ============================================================================== --- freeswitch/branches/gmaruzz/docs/phrase/phrase_en.xml (original) +++ freeswitch/branches/gmaruzz/docs/phrase/phrase_en.xml Mon Dec 15 12:56:36 2008 @@ -111,8 +111,8 @@ - - + + @@ -222,7 +222,7 @@ - + @@ -233,6 +233,8 @@ + + Modified: freeswitch/branches/gmaruzz/freeswitch.spec ============================================================================== --- freeswitch/branches/gmaruzz/freeswitch.spec (original) +++ freeswitch/branches/gmaruzz/freeswitch.spec Mon Dec 15 12:56:36 2008 @@ -312,6 +312,10 @@ %config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/event_socket.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/cdr_csv.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/fax.conf.xml +%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/fifo.conf.xml +%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/openzap.conf.xml +%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/shout.conf.xml +%config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/timezones.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/iax.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/ivr.conf.xml %config(noreplace) %attr(0640, freeswitch, daemon) %{prefix}/conf/autoload_configs/java.conf.xml @@ -358,6 +362,7 @@ %endif %{prefix}/bin/* %{prefix}/lib/libfreeswitch*.so* +%{prefix}/lib/libopenzap.so* %{prefix}/mod/mod_console.so* %{prefix}/mod/mod_logfile.so* %{prefix}/mod/mod_syslog.so* @@ -403,6 +408,7 @@ %{prefix}/mod/ozmod_isdn.so %{prefix}/mod/ozmod_ss7_boost.so %{prefix}/mod/ozmod_zt.so +%{prefix}/mod/ozmod_wanpipe.so %files codec-passthru-amr %defattr(-,freeswitch,daemon) Modified: freeswitch/branches/gmaruzz/libs/libdingaling/src/libdingaling.c ============================================================================== --- freeswitch/branches/gmaruzz/libs/libdingaling/src/libdingaling.c (original) +++ freeswitch/branches/gmaruzz/libs/libdingaling/src/libdingaling.c Mon Dec 15 12:56:36 2008 @@ -252,6 +252,19 @@ } +static char *iks_name_nons(iks *x) +{ + char *r = iks_name(x); + char *p; + + if (r && (p = strchr(r, ':'))) { + r = p + 1; + } + + return r; +} + + char *ldl_session_get_value(ldl_session_t *session, char *key) { return apr_hash_get(session->variables, key, APR_HASH_KEY_STRING); @@ -385,10 +398,10 @@ tag = iks_child (xml); while(tag) { - if (!strcasecmp(iks_name(tag), "description")) { + if (!strcasecmp(iks_name_nons(tag), "description")) { iks * itag = iks_child (tag); while(itag) { - if (!strcasecmp(iks_name(itag), "payload-type") && session->payload_len < LDL_MAX_PAYLOADS) { + if (!strcasecmp(iks_name_nons(itag), "payload-type") && session->payload_len < LDL_MAX_PAYLOADS) { char *name = iks_find_attrib(itag, "name"); char *id = iks_find_attrib(itag, "id"); char *rate = iks_find_attrib(itag, "clockrate"); @@ -421,12 +434,12 @@ dl_signal = LDL_SIGNAL_CANDIDATES; tag = iks_child (xml); id = type; - if (tag && !strcasecmp(iks_name(tag), "transport")) { + if (tag && !strcasecmp(iks_name_nons(tag), "transport")) { tag = iks_child(tag); } while(tag) { - if (!strcasecmp(iks_name(tag), "info_element")) { + if (!strcasecmp(iks_name_nons(tag), "info_element")) { char *name = iks_find_attrib(tag, "name"); char *value = iks_find_attrib(tag, "value"); if (globals.debug) { @@ -434,7 +447,7 @@ } ldl_session_set_value(session, name, value); - } else if (!strcasecmp(iks_name(tag), "candidate") && session->candidate_len < LDL_MAX_CANDIDATES) { + } else if (!strcasecmp(iks_name_nons(tag), "candidate") && session->candidate_len < LDL_MAX_CANDIDATES) { char *key; double pref = 0.0; int index = -1; @@ -647,7 +660,7 @@ char *resource; struct ldl_buffer *buffer; ldl_signal_t dl_signal = LDL_SIGNAL_PRESENCE_IN; - + int done = 0; if (type && *type) { @@ -685,10 +698,27 @@ if (resource && (strstr(resource, "talk") || strstr(resource, "telepathy")) && (buffer = apr_hash_get(handle->probe_hash, id, APR_HASH_KEY_STRING))) { apr_cpystrn(buffer->buf, from, buffer->len); - fflush(stderr); buffer->hit = 1; + done = 1; } - + + if (!done) { + iks *xml = iks_find(pak->x, "c"); + if (!xml) { + xml = iks_find(pak->x, "caps:c"); + } + + if (xml) { + char *ext = iks_find_attrib(xml, "ext");; + if (ext && strstr(ext, "voice-v1") && (buffer = apr_hash_get(handle->probe_hash, id, APR_HASH_KEY_STRING))) { + apr_cpystrn(buffer->buf, from, buffer->len); + buffer->hit = 1; + done = 1; + } + } + } + + if (handle->session_callback) { handle->session_callback(handle, NULL, dl_signal, to, id, status ? status : "n/a", show ? show : "n/a"); } @@ -930,7 +960,7 @@ if (is_result) { iks *tag = iks_child (pak->x); while(tag) { - if (!strcasecmp(iks_name(tag), "bind")) { + if (!strcasecmp(iks_name_nons(tag), "bind")) { char *jid = iks_find_cdata(tag, "jid"); char *resource = strchr(jid, '/'); if (resource) { @@ -972,7 +1002,7 @@ xml = iks_child (pak->x); while (xml) { - char *name = iks_name(xml); + char *name = iks_name_nons(xml); if (!strcasecmp(name, "session")) { char *id = iks_find_attrib(xml, "id"); //printf("SESSION type=%s name=%s id=%s\n", type, name, id); @@ -1193,12 +1223,12 @@ } } - } else if (node && strcmp("failure", iks_name(node)) == 0) { + } else if (node && strcmp("failure", iks_name_nons(node)) == 0) { globals.logger(DL_LOG_DEBUG, "sasl authentication failed\n"); if (handle->session_callback) { handle->session_callback(handle, NULL, LDL_SIGNAL_LOGIN_FAILURE, "user", "core", "Login Failure", handle->login); } - } else if (node && strcmp("success", iks_name(node)) == 0) { + } else if (node && strcmp("success", iks_name_nons(node)) == 0) { globals.logger(DL_LOG_DEBUG, "XMPP server connected\n"); iks_send_header(handle->parser, handle->acc->server); ldl_set_flag_locked(handle, LDL_FLAG_CONNECTED); @@ -1474,7 +1504,7 @@ case IKS_OK: break; case IKS_NET_NODNS: - globals.logger(DL_LOG_DEBUG, "hostname lookup failed for %s\n", handle->server); + globals.logger(DL_LOG_DEBUG, "hostname lookup failed\n"); microsleep(1000); goto fail; case IKS_NET_NOCONN: @@ -1541,6 +1571,10 @@ ldl_clear_flag_locked(handle, LDL_FLAG_CONNECTED); ldl_clear_flag_locked(handle, LDL_FLAG_AUTHORIZED); handle->state = CS_NEW; + + while(ldl_test_flag(handle, LDL_FLAG_QUEUE_RUNNING)) { + microsleep(100); + } } ldl_clear_flag_locked(handle, LDL_FLAG_RUNNING); if (!ldl_test_flag(handle, LDL_FLAG_TLS)) { @@ -1586,8 +1620,8 @@ iks_insert_attrib(iq, "to", session->them); iks_insert_attrib(iq, "type", "set"); iks_insert_attrib(iq, "id", idbuf); - sess = iks_insert (iq, "session"); - iks_insert_attrib(sess, "xmlns", "http://www.google.com/session"); + sess = iks_insert (iq, "ses:session"); + iks_insert_attrib(sess, "xmlns:ses", "http://www.google.com/session"); iks_insert_attrib(sess, "type", type); iks_insert_attrib(sess, "id", session->id); @@ -1661,8 +1695,8 @@ if (!iks_insert_attrib(iq, "id", idbuf)) goto fail; if (!iks_insert_attrib(iq, "from", session->login)) goto fail; if (!iks_insert_attrib(iq, "to", session->them)) goto fail; - if (!(sess = iks_insert (iq, "session"))) goto fail; - if (!iks_insert_attrib(sess, "xmlns", "http://www.google.com/session")) goto fail; + if (!(sess = iks_insert (iq, "ses:session"))) goto fail; + if (!iks_insert_attrib(sess, "xmlns:ses", "http://www.google.com/session")) goto fail; if (!iks_insert_attrib(sess, "type", "transport-accept")) goto fail; if (!iks_insert_attrib(sess, "id", candidate->tid)) goto fail; if (!iks_insert_attrib(sess, "xmlns", "http://www.google.com/session")) goto fail; @@ -1890,12 +1924,13 @@ sess = NULL; id = 0; - new_session_iq(session, &iq, &sess, &id, "transport-info"); - tag = iks_insert(sess, "transport"); - iks_insert_attrib(tag, "xmlns", "http://www.google.com/transport/p2p"); + new_session_iq(session, &iq, &sess, &id, "candidates"); + //tag = iks_insert(sess, "transport"); + //iks_insert_attrib(tag, "xmlns", "http://www.google.com/transport/p2p"); + tag = sess; add_elements(session, tag); - tag = iks_insert(tag, "candidate"); + tag = iks_insert(tag, "ses:candidate"); if (candidates[x].name) { iks_insert_attrib(tag, "name", candidates[x].name); @@ -2067,13 +2102,13 @@ new_session_iq(session, &iq, &sess, &id, description == LDL_DESCRIPTION_ACCEPT ? "accept" : "initiate"); - tag = iks_insert(sess, "description"); - iks_insert_attrib(tag, "xmlns", "http://www.google.com/session/phone"); + tag = iks_insert(sess, "pho:description"); + iks_insert_attrib(tag, "xmlns:pho", "http://www.google.com/session/phone"); iks_insert_attrib(tag, "xml:lang", "en"); for (x = 0; x < plen; x++) { char idbuf[80]; - payload = iks_insert(tag, "payload-type"); - iks_insert_attrib(payload, "xmlns", "http://www.google.com/session/phone"); + payload = iks_insert(tag, "pho:payload-type"); + iks_insert_attrib(payload, "xmlns:pho", "http://www.google.com/session/phone"); sprintf(idbuf, "%d", payloads[x].id); iks_insert_attrib(payload, "id", idbuf); Modified: freeswitch/branches/gmaruzz/libs/libteletone/src/libteletone_generate.c ============================================================================== --- freeswitch/branches/gmaruzz/libs/libteletone/src/libteletone_generate.c (original) +++ freeswitch/branches/gmaruzz/libs/libteletone/src/libteletone_generate.c Mon Dec 15 12:56:36 2008 @@ -208,7 +208,7 @@ /*teletone_process_t period = (1.0 / ts->rate) / ts->channels;*/ int i, c; int freqlen = 0; - teletone_dds_state_t tones[TELETONE_MAX_TONES]; + teletone_dds_state_t tones[TELETONE_MAX_TONES+1]; //int decay = 0; int duration; int wait = 0; @@ -221,7 +221,7 @@ wait = (ts->tmp_wait > -1) ? ts->tmp_wait : ts->wait; if (map->freqs[0] > 0) { - for (freqlen = 0; map->freqs[freqlen] && freqlen < TELETONE_MAX_TONES; freqlen++) { + for (freqlen = 0; freqlen < TELETONE_MAX_TONES && map->freqs[freqlen]; freqlen++) { teletone_dds_state_set_tone(&tones[freqlen], map->freqs[freqlen], ts->rate, 0); teletone_dds_state_set_tx_level(&tones[freqlen], vol); } @@ -243,7 +243,7 @@ if (nvol <= TELETONE_VOL_DB_MAX && nvol >= TELETONE_VOL_DB_MIN) { vol = nvol; - for (j = 0; map->freqs[j] && j < TELETONE_MAX_TONES; j++) { + for (j = 0; j < TELETONE_MAX_TONES && map->freqs[j]; j++) { teletone_dds_state_set_tx_level(&tones[j], vol); } dc = 0; Modified: freeswitch/branches/gmaruzz/libs/spandsp/src/t31.c ============================================================================== --- freeswitch/branches/gmaruzz/libs/spandsp/src/t31.c (original) +++ freeswitch/branches/gmaruzz/libs/spandsp/src/t31.c Mon Dec 15 12:56:36 2008 @@ -42,7 +42,6 @@ #include #include #include -#include #include "floating_fudge.h" #if defined(HAVE_TGMATH_H) #include Modified: freeswitch/branches/gmaruzz/libs/spandsp/src/t38_terminal.c ============================================================================== --- freeswitch/branches/gmaruzz/libs/spandsp/src/t38_terminal.c (original) +++ freeswitch/branches/gmaruzz/libs/spandsp/src/t38_terminal.c Mon Dec 15 12:56:36 2008 @@ -37,7 +37,6 @@ #include #include #include -#include #include "floating_fudge.h" #if defined(HAVE_TGMATH_H) #include Modified: freeswitch/branches/gmaruzz/libs/win32/libmp3lame/libmp3lame_vc7.vcproj ============================================================================== --- freeswitch/branches/gmaruzz/libs/win32/libmp3lame/libmp3lame_vc7.vcproj (original) +++ freeswitch/branches/gmaruzz/libs/win32/libmp3lame/libmp3lame_vc7.vcproj Mon Dec 15 12:56:36 2008 @@ -42,7 +42,7 @@ Name="VCCLCompilerTool" AdditionalOptions="/GAy /QIfdiv /QI0f" Optimization="2" - AdditionalIncludeDirectories=""..\..\lame-3.97","..\..\lame-3.97\include"" + AdditionalIncludeDirectories=".;"..\..\lame-3.97";"..\..\lame-3.97\include"" PreprocessorDefinitions="NDEBUG;_WINDOWS;WIN32;HAVE_CONFIG_H" StringPooling="true" RuntimeLibrary="0" @@ -112,7 +112,7 @@ - - - - - - - - Modified: freeswitch/branches/gmaruzz/libs/win32/libshout/libshout.vcproj ============================================================================== --- freeswitch/branches/gmaruzz/libs/win32/libshout/libshout.vcproj (original) +++ freeswitch/branches/gmaruzz/libs/win32/libshout/libshout.vcproj Mon Dec 15 12:56:36 2008 @@ -20,8 +20,6 @@ OutputDirectory="$(ConfigurationName)" IntermediateDirectory="$(ConfigurationName)" ConfigurationType="4" - UseOfMFC="0" - ATLMinimizesCRunTimeLibraryUsage="false" CharacterSet="2" > @@ -68,9 +65,8 @@ /> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - "\" Then tmpFolder = tmpFolder & "\" End If - If Not FSO.FileExists(tmpFolder & "svnversion.exe") Then - Wget ToolsBase & "svnversion.exe", tmpFolder + If Not FSO.FileExists(tmpFolder & "fs_svnversion.exe") Then + Wget ToolsBase & "fs_svnversion.exe", tmpFolder End If + + If Not FSO.FileExists(tmpFolder & "libsvn_diff-1.dll") Then + Wget ToolsBase & "libsvn_diff-1.dll", tmpFolder + End If + If Not FSO.FileExists(tmpFolder & "libsvn_subr-1.dll") Then + Wget ToolsBase & "libsvn_subr-1.dll", tmpFolder + End If + If Not FSO.FileExists(tmpFolder & "libsvn_wc-1.dll") Then + Wget ToolsBase & "libsvn_wc-1.dll", tmpFolder + End If + If Not FSO.FileExists(tmpFolder & "intl3_svn.dll") Then + Wget ToolsBase & "intl3_svn.dll", tmpFolder + End If + If Not FSO.FileExists(tmpFolder & "libapr-1.dll") Then + Wget ToolsBase & "libapr-1.dll", tmpFolder + End If + If Not FSO.FileExists(tmpFolder & "libaprutil-1.dll") Then + Wget ToolsBase & "libaprutil-1.dll", tmpFolder + End If + If Not FSO.FileExists(tmpFolder & "libapriconv-1.dll") Then + Wget ToolsBase & "libapriconv-1.dll", tmpFolder + End If + If Not FSO.FileExists(tmpFolder & "libsvn_delta-1.dll") Then + Wget ToolsBase & "libsvn_delta-1.dll", tmpFolder + End If + Dim sLastFile Const OverwriteIfExist = -1 Const ForReading = 1 if strVerRev = "" Then - VersionCmd="svnversion " & quote & VersionDir & "." & quote & " -n" + VersionCmd="fs_svnversion " & quote & VersionDir & "." & quote & " -n" Set MyFile = fso.CreateTextFile(tmpFolder & "tmpVersion.Bat", True) MyFile.WriteLine("@" & "cd " & quote & tmpFolder & quote ) MyFile.WriteLine("@" & VersionCmd) Modified: freeswitch/branches/gmaruzz/scripts/contrib/intralanman/PHP/fs_curl/configuration/xml_cdr.conf.php ============================================================================== --- freeswitch/branches/gmaruzz/scripts/contrib/intralanman/PHP/fs_curl/configuration/xml_cdr.conf.php (original) +++ freeswitch/branches/gmaruzz/scripts/contrib/intralanman/PHP/fs_curl/configuration/xml_cdr.conf.php Mon Dec 15 12:56:36 2008 @@ -23,7 +23,7 @@ } function get_settings() { - return array('url'=>'http://localhost/fs_curl/index_test.php', 'encode'=>'true'); + return array('url'=>'http://$${curl_host}/fs_curl/cdr.php', 'encode'=>'true'); return array( 'url'=>'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] , 'encode'=>'true' @@ -46,4 +46,4 @@ } } -?> \ No newline at end of file +?> Modified: freeswitch/branches/gmaruzz/scripts/contrib/intralanman/PHP/fs_curl/dialplan_importer.php ============================================================================== --- freeswitch/branches/gmaruzz/scripts/contrib/intralanman/PHP/fs_curl/dialplan_importer.php (original) +++ freeswitch/branches/gmaruzz/scripts/contrib/intralanman/PHP/fs_curl/dialplan_importer.php Mon Dec 15 12:56:36 2008 @@ -149,4 +149,4 @@ upload_form(); //printf("
%s
", print_r($xml_obj, true); -?> + Modified: freeswitch/branches/gmaruzz/scripts/contrib/intralanman/PHP/fs_curl/fs_configuration.php ============================================================================== --- freeswitch/branches/gmaruzz/scripts/contrib/intralanman/PHP/fs_curl/fs_configuration.php (original) +++ freeswitch/branches/gmaruzz/scripts/contrib/intralanman/PHP/fs_curl/fs_configuration.php Mon Dec 15 12:56:36 2008 @@ -89,4 +89,3 @@ } } -?> \ No newline at end of file Modified: freeswitch/branches/gmaruzz/scripts/contrib/intralanman/PHP/fs_curl/fs_curl.php ============================================================================== --- freeswitch/branches/gmaruzz/scripts/contrib/intralanman/PHP/fs_curl/fs_curl.php (original) +++ freeswitch/branches/gmaruzz/scripts/contrib/intralanman/PHP/fs_curl/fs_curl.php Mon Dec 15 12:56:36 2008 @@ -321,4 +321,4 @@ } } } -?> + Modified: freeswitch/branches/gmaruzz/scripts/contrib/intralanman/PHP/fs_curl/fs_dialplan.php ============================================================================== --- freeswitch/branches/gmaruzz/scripts/contrib/intralanman/PHP/fs_curl/fs_dialplan.php (original) +++ freeswitch/branches/gmaruzz/scripts/contrib/intralanman/PHP/fs_curl/fs_dialplan.php Mon Dec 15 12:56:36 2008 @@ -206,4 +206,3 @@ } } } -?> \ No newline at end of file Modified: freeswitch/branches/gmaruzz/scripts/contrib/intralanman/PHP/fs_curl/fs_directory.php ============================================================================== --- freeswitch/branches/gmaruzz/scripts/contrib/intralanman/PHP/fs_curl/fs_directory.php (original) +++ freeswitch/branches/gmaruzz/scripts/contrib/intralanman/PHP/fs_curl/fs_directory.php Mon Dec 15 12:56:36 2008 @@ -275,5 +275,4 @@ $this -> xmlw -> endElement(); } } -?> Modified: freeswitch/branches/gmaruzz/scripts/contrib/intralanman/PHP/fs_curl/global_defines.php ============================================================================== --- freeswitch/branches/gmaruzz/scripts/contrib/intralanman/PHP/fs_curl/global_defines.php (original) +++ freeswitch/branches/gmaruzz/scripts/contrib/intralanman/PHP/fs_curl/global_defines.php Mon Dec 15 12:56:36 2008 @@ -62,4 +62,4 @@ //define('', ''); -?> + Modified: freeswitch/branches/gmaruzz/scripts/contrib/intralanman/PHP/fs_curl/index.php ============================================================================== --- freeswitch/branches/gmaruzz/scripts/contrib/intralanman/PHP/fs_curl/index.php (original) +++ freeswitch/branches/gmaruzz/scripts/contrib/intralanman/PHP/fs_curl/index.php Mon Dec 15 12:56:36 2008 @@ -94,4 +94,3 @@ $conf -> main(); $conf -> output_xml(); -?> \ No newline at end of file Modified: freeswitch/branches/gmaruzz/scripts/contrib/mrene/mod_limit/mod_limit.c ============================================================================== --- freeswitch/branches/gmaruzz/scripts/contrib/mrene/mod_limit/mod_limit.c (original) +++ freeswitch/branches/gmaruzz/scripts/contrib/mrene/mod_limit/mod_limit.c Mon Dec 15 12:56:36 2008 @@ -851,6 +851,44 @@ switch_mutex_unlock(globals.limit_hash_mutex); } +#define LIMIT_HASH_USAGE_USAGE " " +SWITCH_STANDARD_API(limit_hash_usage_function) +{ + int argc = 0; + char *argv[3] = { 0 }; + char *mydata = NULL; + char *hash_key = NULL; + limit_hash_item_t *item = NULL; + uint32_t count = 0; + + switch_mutex_lock(globals.limit_hash_mutex); + + if (!switch_strlen_zero(cmd)) { + switch_assert(mydata = strdup(cmd)); + argc = switch_separate_string(mydata, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); + } + + if (argc < 2) { + stream->write_function(stream, "USAGE: limit_hash_usage %s\n", LIMIT_HASH_USAGE_USAGE); + goto end; + } + + hash_key = switch_mprintf("%s_%s", argv[0], argv[1]); + + if ((item = switch_core_hash_find(globals.limit_hash, hash_key))) { + count = item->total_usage; + } + + stream->write_function(stream, "%d", count); + +end: + switch_safe_free(mydata); + switch_safe_free(hash_key); + switch_mutex_unlock(globals.limit_hash_mutex); + + return SWITCH_STATUS_SUCCESS; +} + SWITCH_MODULE_LOAD_FUNCTION(mod_limit_load) { switch_status_t status; @@ -880,6 +918,7 @@ SWITCH_ADD_APP(app_interface, "hash", "Insert into the hashtable", HASH_DESC, hash_function, HASH_USAGE, SAF_SUPPORT_NOMEDIA) SWITCH_ADD_APP(app_interface, "group", "Manage a group", GROUP_DESC, group_function, GROUP_USAGE, SAF_SUPPORT_NOMEDIA); + SWITCH_ADD_API(commands_api_interface, "limit_hash_usage", "Gets the usage count of a limited resource", limit_hash_usage_function, LIMIT_HASH_USAGE_USAGE); SWITCH_ADD_API(commands_api_interface, "db", "db get/set", db_api_function, "[insert|delete|select]///"); switch_console_set_complete("add db insert"); switch_console_set_complete("add db delete"); Modified: freeswitch/branches/gmaruzz/scripts/fsxs.in ============================================================================== --- freeswitch/branches/gmaruzz/scripts/fsxs.in (original) +++ freeswitch/branches/gmaruzz/scripts/fsxs.in Mon Dec 15 12:56:36 2008 @@ -177,12 +177,14 @@ sub fsxs_showq { my @varlist = @_; + my $count = 0; if( $#varlist >= 0 ) { foreach( @varlist ) { if( defined $vars{$_} ) { - print "$vars{$_} "; + print "$vars{$_}" . (($count < $#varlist) ? " " : ""); } + $count++; } } } Modified: freeswitch/branches/gmaruzz/src/include/private/switch_core_pvt.h ============================================================================== --- freeswitch/branches/gmaruzz/src/include/private/switch_core_pvt.h (original) +++ freeswitch/branches/gmaruzz/src/include/private/switch_core_pvt.h Mon Dec 15 12:56:36 2008 @@ -118,6 +118,8 @@ switch_mutex_t *mutex; switch_mutex_t *resample_mutex; + switch_mutex_t *codec_read_mutex; + switch_mutex_t *codec_write_mutex; switch_thread_cond_t *cond; switch_thread_rwlock_t *rwlock; Modified: freeswitch/branches/gmaruzz/src/include/switch.h ============================================================================== --- freeswitch/branches/gmaruzz/src/include/switch.h (original) +++ freeswitch/branches/gmaruzz/src/include/switch.h Mon Dec 15 12:56:36 2008 @@ -54,7 +54,7 @@ #define FREESWITCH_ITAD "543" #define __EXTENSIONS__ 1 #ifndef MACOSX -#if !defined(_XOPEN_SOURCE) && !defined(__OpenBSD__) +#if !defined(_XOPEN_SOURCE) && !defined(__OpenBSD__) && !defined(__NetBSD__) #ifndef __cplusplus #define _XOPEN_SOURCE 600 #endif 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 Mon Dec 15 12:56:36 2008 @@ -1123,6 +1123,7 @@ */ SWITCH_DECLARE(switch_status_t) switch_socket_recvfrom(switch_sockaddr_t *from, switch_socket_t *sock, int32_t flags, char *buf, size_t *len); +SWITCH_DECLARE(switch_status_t) switch_socket_atmark(switch_socket_t *sock, int *atmark); /** * Read data from a network. Modified: freeswitch/branches/gmaruzz/src/include/switch_channel.h ============================================================================== --- freeswitch/branches/gmaruzz/src/include/switch_channel.h (original) +++ freeswitch/branches/gmaruzz/src/include/switch_channel.h Mon Dec 15 12:56:36 2008 @@ -145,7 +145,7 @@ \param flags the initial channel flags */ SWITCH_DECLARE(switch_status_t) switch_channel_init(switch_channel_t *channel, switch_core_session_t *session, switch_channel_state_t state, - uint32_t flags); + switch_channel_flag_t flag); /*! \brief Fire A presence event for the channel @@ -259,49 +259,49 @@ SWITCH_DECLARE(switch_caller_extension_t *) switch_channel_get_caller_extension(switch_channel_t *channel); /*! - \brief Test for presence of given flag(s) on a given channel + \brief Test for presence of given flag on a given channel \param channel channel to test - \param flags or'd list of channel flags to test + \param flag to test \return TRUE if flags were present */ -SWITCH_DECLARE(uint32_t) switch_channel_test_flag(switch_channel_t *channel, switch_channel_flag_t flags); +SWITCH_DECLARE(uint32_t) switch_channel_test_flag(switch_channel_t *channel, switch_channel_flag_t flag); /*! \brief Set given flag(s) on a given channel - \param channel channel on which to set flag(s) - \param flags or'd list of flags to set + \param channel channel on which to set flag + \param flag or'd list of flags to set */ -SWITCH_DECLARE(void) switch_channel_set_flag(switch_channel_t *channel, switch_channel_flag_t flags); +SWITCH_DECLARE(void) switch_channel_set_flag(switch_channel_t *channel, switch_channel_flag_t flag); /*! \brief Set given flag(s) on a given channel's bridge partner - \param channel channel to derive the partner channel to set flag(s) on - \param flags or'd list of flags to set + \param channel channel to derive the partner channel to set flag on + \param flag to set \return true if the flag was set */ -SWITCH_DECLARE(switch_bool_t) switch_channel_set_flag_partner(switch_channel_t *channel, switch_channel_flag_t flags); +SWITCH_DECLARE(switch_bool_t) switch_channel_set_flag_partner(switch_channel_t *channel, switch_channel_flag_t flag); /*! \brief Clears given flag(s) on a given channel's bridge partner \param channel channel to derive the partner channel to clear flag(s) from - \param flags the flags to clear + \param flag the flag to clear \return true if the flag was cleared */ -SWITCH_DECLARE(switch_bool_t) switch_channel_clear_flag_partner(switch_channel_t *channel, switch_channel_flag_t flags); +SWITCH_DECLARE(switch_bool_t) switch_channel_clear_flag_partner(switch_channel_t *channel, switch_channel_flag_t flag); /*! \brief Set given flag(s) on a given channel to be applied on the next state change \param channel channel on which to set flag(s) - \param flags or'd list of flags to set + \param flag flag to set */ -SWITCH_DECLARE(void) switch_channel_set_state_flag(switch_channel_t *channel, switch_channel_flag_t flags); +SWITCH_DECLARE(void) switch_channel_set_state_flag(switch_channel_t *channel, switch_channel_flag_t flag); /*! \brief Clear given flag(s) from a channel \param channel channel to clear flags from - \param flags or'd list of flags to clear + \param flag flag to clear */ -SWITCH_DECLARE(void) switch_channel_clear_flag(switch_channel_t *channel, switch_channel_flag_t flags); +SWITCH_DECLARE(void) switch_channel_clear_flag(switch_channel_t *channel, switch_channel_flag_t flag); SWITCH_DECLARE(switch_status_t) switch_channel_perform_answer(switch_channel_t *channel, const char *file, const char *func, int line); @@ -484,10 +484,16 @@ _In_opt_ const char *prefix); SWITCH_DECLARE(switch_status_t) switch_channel_set_timestamps(_In_ switch_channel_t *channel); -#define switch_channel_stop_broadcast(_channel) if (switch_channel_test_flag(_channel, CF_BROADCAST)) switch_channel_set_flag(_channel, CF_BREAK | CF_STOP_BROADCAST) +#define switch_channel_stop_broadcast(_channel) for(;;) {if (switch_channel_test_flag(_channel, CF_BROADCAST)) {switch_channel_set_flag(_channel, CF_STOP_BROADCAST); switch_channel_set_flag(_channel, CF_BREAK); } break;} #define switch_channel_media_ready(_channel) ((switch_channel_test_flag(_channel, CF_ANSWERED) || switch_channel_test_flag(_channel, CF_EARLY_MEDIA)) && !switch_channel_test_flag(_channel, CF_PROXY_MODE)) +SWITCH_DECLARE(void) switch_channel_audio_sync(switch_channel_t *channel); + +SWITCH_DECLARE(void) switch_channel_set_private_flag(switch_channel_t *channel, uint32_t flags); +SWITCH_DECLARE(void) switch_channel_clear_private_flag(switch_channel_t *channel, uint32_t flags); +SWITCH_DECLARE(int) switch_channel_test_private_flag(switch_channel_t *channel, uint32_t flags); + /** @} */ SWITCH_END_EXTERN_C Modified: freeswitch/branches/gmaruzz/src/include/switch_core.h ============================================================================== --- freeswitch/branches/gmaruzz/src/include/switch_core.h (original) +++ freeswitch/branches/gmaruzz/src/include/switch_core.h Mon Dec 15 12:56:36 2008 @@ -92,6 +92,7 @@ const char *_file; const char *_func; int _line; + }; /*! \brief A generic object to pass as a thread's session object to allow mutiple arguements and a pool */ @@ -320,6 +321,22 @@ #ifdef SWITCH_DEBUG_RWLOCKS +SWITCH_DECLARE(switch_status_t) switch_core_session_perform_read_lock_hangup(_In_ switch_core_session_t *session, const char *file, const char *func, int line); +#endif + +/*! + \brief Acquire a read lock on the session + \param session the session to acquire from + \return success if it is safe to read from the session +*/ +#ifdef SWITCH_DEBUG_RWLOCKS +#define switch_core_session_read_lock(session) switch_core_session_perform_read_lock_hangup(session, __FILE__, __SWITCH_FUNC__, __LINE__) +#else +SWITCH_DECLARE(switch_status_t) switch_core_session_read_lock_hangup(_In_ switch_core_session_t *session); +#endif + + +#ifdef SWITCH_DEBUG_RWLOCKS SWITCH_DECLARE(void) switch_core_session_perform_write_lock(_In_ switch_core_session_t *session, const char *file, const char *func, int line); #endif Modified: freeswitch/branches/gmaruzz/src/include/switch_cpp.h ============================================================================== --- freeswitch/branches/gmaruzz/src/include/switch_cpp.h (original) +++ freeswitch/branches/gmaruzz/src/include/switch_cpp.h Mon Dec 15 12:56:36 2008 @@ -313,7 +313,7 @@ * */ SWITCH_DECLARE(int) streamFile(char *file, int starting_sample_count = 0); - SWITCH_DECLARE(int) sleep(int ms); + SWITCH_DECLARE(int) sleep(int ms, int sync=0); /** \brief flush any pending events */ @@ -373,6 +373,7 @@ SWITCH_DECLARE(void) console_log(char *level_str, char *msg); SWITCH_DECLARE(void) console_clean_log(char *msg); +SWITCH_DECLARE(void) msleep(unsigned ms); /** \brief bridge the audio of session_b into session_a * Modified: freeswitch/branches/gmaruzz/src/include/switch_ivr.h ============================================================================== --- freeswitch/branches/gmaruzz/src/include/switch_ivr.h (original) +++ freeswitch/branches/gmaruzz/src/include/switch_ivr.h Mon Dec 15 12:56:36 2008 @@ -110,7 +110,7 @@ \param args arguements to pass for callbacks etc \return SWITCH_STATUS_SUCCESS if the channel is still up */ -SWITCH_DECLARE(switch_status_t) switch_ivr_sleep(switch_core_session_t *session, uint32_t ms, switch_input_args_t *args); +SWITCH_DECLARE(switch_status_t) switch_ivr_sleep(switch_core_session_t *session, uint32_t ms, switch_bool_t sync, switch_input_args_t *args); SWITCH_DECLARE(switch_status_t) switch_ivr_park(switch_core_session_t *session, switch_input_args_t *args); @@ -298,7 +298,8 @@ */ SWITCH_DECLARE(switch_status_t) switch_ivr_tone_detect_session(switch_core_session_t *session, const char *key, const char *tone_spec, - const char *flags, time_t timeout, const char *app, const char *data); + const char *flags, time_t timeout, int hits, const char *app, const char *data); + @@ -397,7 +398,10 @@ const switch_state_handler_table_t *table, const char *cid_name_override, const char *cid_num_override, - switch_caller_profile_t *caller_profile_override, switch_originate_flag_t flags); + switch_caller_profile_t *caller_profile_override, + switch_event_t *ovars, + switch_originate_flag_t flags + ); /*! \brief Bridge Audio from one session to another Modified: freeswitch/branches/gmaruzz/src/include/switch_module_interfaces.h ============================================================================== --- freeswitch/branches/gmaruzz/src/include/switch_module_interfaces.h (original) +++ freeswitch/branches/gmaruzz/src/include/switch_module_interfaces.h Mon Dec 15 12:56:36 2008 @@ -173,6 +173,7 @@ switch_thread_rwlock_t *rwlock; int refs; + switch_mutex_t *reflock; /* parent */ switch_loadable_module_interface_t *parent; @@ -228,6 +229,7 @@ switch_status_t (*timer_destroy) (switch_timer_t *); switch_thread_rwlock_t *rwlock; int refs; + switch_mutex_t *reflock; switch_loadable_module_interface_t *parent; struct switch_timer_interface *next; }; @@ -240,6 +242,7 @@ switch_dialplan_hunt_function_t hunt_function; switch_thread_rwlock_t *rwlock; int refs; + switch_mutex_t *reflock; switch_loadable_module_interface_t *parent; struct switch_dialplan_interface *next; }; @@ -266,6 +269,7 @@ char **extens; switch_thread_rwlock_t *rwlock; int refs; + switch_mutex_t *reflock; switch_loadable_module_interface_t *parent; struct switch_file_interface *next; }; @@ -345,6 +349,7 @@ switch_status_t (*asr_get_results) (switch_asr_handle_t *ah, char **xmlstr, switch_asr_flag_t *flags); switch_thread_rwlock_t *rwlock; int refs; + switch_mutex_t *reflock; switch_loadable_module_interface_t *parent; struct switch_asr_interface *next; }; @@ -388,6 +393,7 @@ void (*speech_float_param_tts) (switch_speech_handle_t *sh, char *param, double val); switch_thread_rwlock_t *rwlock; int refs; + switch_mutex_t *reflock; switch_loadable_module_interface_t *parent; struct switch_speech_interface *next; }; @@ -423,6 +429,7 @@ switch_say_callback_t say_function; switch_thread_rwlock_t *rwlock; int refs; + switch_mutex_t *reflock; switch_loadable_module_interface_t *parent; struct switch_say_interface *next; }; @@ -435,6 +442,7 @@ switch_status_t (*chat_send) (char *proto, char *from, char *to, char *subject, char *body, char *hint); switch_thread_rwlock_t *rwlock; int refs; + switch_mutex_t *reflock; switch_loadable_module_interface_t *parent; struct switch_chat_interface *next; }; @@ -447,6 +455,7 @@ switch_status_t (*management_function) (char *relative_oid, switch_management_action_t action, char *data, switch_size_t datalen); switch_thread_rwlock_t *rwlock; int refs; + switch_mutex_t *reflock; switch_loadable_module_interface_t *parent; struct switch_management_interface *next; }; @@ -467,6 +476,7 @@ switch_status_t (*directory_next_pair) (switch_directory_handle_t *dh, char **var, char **val); switch_thread_rwlock_t *rwlock; int refs; + switch_mutex_t *reflock; switch_loadable_module_interface_t *parent; struct switch_directory_interface *next; }; @@ -593,6 +603,7 @@ uint32_t codec_id; switch_thread_rwlock_t *rwlock; int refs; + switch_mutex_t *reflock; switch_loadable_module_interface_t *parent; struct switch_codec_interface *next; }; @@ -613,6 +624,7 @@ uint32_t flags; switch_thread_rwlock_t *rwlock; int refs; + switch_mutex_t *reflock; switch_loadable_module_interface_t *parent; struct switch_application_interface *next; }; @@ -629,12 +641,14 @@ const char *syntax; switch_thread_rwlock_t *rwlock; int refs; + switch_mutex_t *reflock; switch_loadable_module_interface_t *parent; struct switch_api_interface *next; }; -#define PROTECT_INTERFACE(_it) if (_it && !_it->refs) {switch_thread_rwlock_rdlock(_it->parent->rwlock); switch_thread_rwlock_rdlock(_it->rwlock); _it->refs++; _it->parent->refs++;} //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "+++++++++++LOCK\n"); -#define UNPROTECT_INTERFACE(_it) if (_it && _it->refs) {switch_thread_rwlock_unlock(_it->rwlock); switch_thread_rwlock_unlock(_it->parent->rwlock); _it->refs--; _it->parent->refs--; _it = NULL;} //switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "-----------UNLOCK\n"); +#define PROTECT_INTERFACE(_it) if (_it) {switch_mutex_lock(_it->reflock); switch_thread_rwlock_rdlock(_it->parent->rwlock); switch_thread_rwlock_rdlock(_it->rwlock); _it->refs++; _it->parent->refs++; switch_mutex_unlock(_it->reflock);} //if (!strcmp(_it->interface_name, "user")) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "+++++++++++LOCK %s %d/%d\n", _it->interface_name, _it->refs, _it->parent->refs); +#define UNPROTECT_INTERFACE(_it) if (_it) {switch_mutex_lock(_it->reflock); switch_thread_rwlock_unlock(_it->rwlock); switch_thread_rwlock_unlock(_it->parent->rwlock); _it->refs--; _it->parent->refs--; switch_mutex_unlock(_it->reflock);} //if (!strcmp(_it->interface_name, "user")) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_CRIT, "---------UNLOCK %s %d/%d\n", _it->interface_name, _it->refs, _it->parent->refs); + SWITCH_END_EXTERN_C #endif Modified: freeswitch/branches/gmaruzz/src/include/switch_odbc.h ============================================================================== --- freeswitch/branches/gmaruzz/src/include/switch_odbc.h (original) +++ freeswitch/branches/gmaruzz/src/include/switch_odbc.h Mon Dec 15 12:56:36 2008 @@ -64,8 +64,35 @@ SWITCH_DECLARE(void) switch_odbc_handle_destroy(switch_odbc_handle_t **handlep); SWITCH_DECLARE(switch_odbc_state_t) switch_odbc_handle_get_state(switch_odbc_handle_t *handle); SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_exec(switch_odbc_handle_t *handle, char *sql, SQLHSTMT * rstmt); -SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_callback_exec(switch_odbc_handle_t *handle, + +/*! + \brief Execute the sql query and issue a callback for each row returned + \param file the file from which this function is called + \param func the function from which this function is called + \param line the line from which this function is called + \param handle the ODBC handle + \param sql the sql string to execute + \param callback the callback function to execute + \param pdata the state data passed on each callback invocation + \return SWITCH_STATUS_SUCCESS if the operation was successful + \note none +*/ +SWITCH_DECLARE(switch_odbc_status_t) switch_odbc_handle_callback_exec_detailed(const char *file, const char *func, int line, switch_odbc_handle_t *handle, char *sql, switch_core_db_callback_func_t callback, void *pdata); +/*! + \brief Execute the sql query and issue a callback for each row returned + \param handle the ODBC handle + \param sql the sql string to execute + \param callback the callback function to execute + \param pdata the state data passed on each callback invocation + \return SWITCH_STATUS_SUCCESS if the operation was successful + \note none +*/ +#define switch_odbc_handle_callback_exec(handle, sql, callback, pdata) \ + switch_odbc_handle_callback_exec_detailed(__FILE__, (char * )__SWITCH_FUNC__, __LINE__, \ + handle, sql, callback, pdata) + + SWITCH_DECLARE(char *) switch_odbc_handle_get_error(switch_odbc_handle_t *handle, SQLHSTMT stmt); SWITCH_END_EXTERN_C #endif Modified: freeswitch/branches/gmaruzz/src/include/switch_rtp.h ============================================================================== --- freeswitch/branches/gmaruzz/src/include/switch_rtp.h (original) +++ freeswitch/branches/gmaruzz/src/include/switch_rtp.h Mon Dec 15 12:56:36 2008 @@ -111,7 +111,7 @@ SWITCH_DECLARE(switch_port_t) switch_rtp_request_port(const char *ip); SWITCH_DECLARE(void) switch_rtp_release_port(const char *ip, switch_port_t port); -SWITCH_DECLARE(void) switch_rtp_change_interval(switch_rtp_t *rtp_session, uint32_t ms_per_packet, uint32_t samples_per_interval); +SWITCH_DECLARE(switch_status_t) switch_rtp_change_interval(switch_rtp_t *rtp_session, uint32_t ms_per_packet, uint32_t samples_per_interval); /*! \brief create a new RTP session handle \param new_rtp_session a poiter to aim at the new session @@ -351,6 +351,8 @@ */ SWITCH_DECLARE(switch_status_t) switch_rtp_zerocopy_read_frame(switch_rtp_t *rtp_session, switch_frame_t *frame, switch_io_flag_t io_flags); +SWITCH_DECLARE(void) rtp_flush_read_buffer(switch_rtp_t *rtp_session); + /*! \brief Enable VAD on an RTP Session \param rtp_session the RTP session Modified: freeswitch/branches/gmaruzz/src/include/switch_stun.h ============================================================================== --- freeswitch/branches/gmaruzz/src/include/switch_stun.h (original) +++ freeswitch/branches/gmaruzz/src/include/switch_stun.h Mon Dec 15 12:56:36 2008 @@ -147,6 +147,7 @@ */ SWITCH_DECLARE(const char *) switch_stun_value_to_name(int32_t type, uint32_t value); +SWITCH_DECLARE(char *) switch_stun_host_lookup(const char *host, switch_memory_pool_t *pool); /*! \brief Extract a mapped address (IP:PORT) from a packet attribute Modified: freeswitch/branches/gmaruzz/src/include/switch_types.h ============================================================================== --- freeswitch/branches/gmaruzz/src/include/switch_types.h (original) +++ freeswitch/branches/gmaruzz/src/include/switch_types.h Mon Dec 15 12:56:36 2008 @@ -110,6 +110,10 @@ #define SWITCH_PATH_SEPARATOR "/" #endif #define SWITCH_URL_SEPARATOR "://" +#define SWITCH_SEND_SILENCE_WHEN_IDLE_VARIABLE "send_silence_when_idle" +#define SWITCH_CURRENT_APPLICATION_VARIABLE "current_application" +#define SWITCH_CURRENT_APPLICATION_DATA_VARIABLE "current_application_data" +#define SWITCH_CURRENT_APPLICATION_RESPONSE_VARIABLE "current_application_response" #define SWITCH_ENABLE_HEARTBEAT_EVENTS_VARIABLE "enable_heartbeat_events" #define SWITCH_BYPASS_MEDIA_AFTER_BRIDGE_VARIABLE "bypass_media_after_bridge" #define SWITCH_READ_RESULT_VARIABLE "read_result" @@ -122,6 +126,7 @@ #define SWITCH_HOLDING_UUID_VARIABLE "holding_uuid" #define SWITCH_API_BRIDGE_END_VARIABLE "api_after_bridge" #define SWITCH_API_HANGUP_HOOK_VARIABLE "api_hangup_hook" +#define SWITCH_SESSION_IN_HANGUP_HOOK_VARIABLE "session_in_hangup_hook" #define SWITCH_PROCESS_CDR_VARIABLE "process_cdr" #define SWITCH_BRIDGE_CHANNEL_VARIABLE "bridge_channel" #define SWITCH_CHANNEL_NAME_VARIABLE "channel_name" @@ -450,7 +455,8 @@ SWITCH_RTP_FLAG_SECURE_SEND_RESET = (1 << 16), SWITCH_RTP_FLAG_SECURE_RECV_RESET = (1 << 17), SWITCH_RTP_FLAG_PROXY_MEDIA = (1 << 18), - SWITCH_RTP_FLAG_SHUTDOWN = (1 << 19) + SWITCH_RTP_FLAG_SHUTDOWN = (1 << 19), + SWITCH_RTP_FLAG_FLUSH = (1 << 20) } switch_rtp_flag_enum_t; typedef uint32_t switch_rtp_flag_t; @@ -567,6 +573,7 @@ SWITCH_MESSAGE_INDICATE_VIDEO_REFRESH_REQ, SWITCH_MESSAGE_INDICATE_DISPLAY, SWITCH_MESSAGE_INDICATE_TRANSCODING_NECESSARY, + SWITCH_MESSAGE_INDICATE_AUDIO_SYNC, SWITCH_MESSAGE_INVALID } switch_core_session_message_types_t; @@ -675,7 +682,9 @@ } switch_text_channel_t; typedef enum { - SCSMF_DYNAMIC = (1 << 0) + SCSMF_DYNAMIC = (1 << 0), + SCSMF_FREE_STRING_REPLY = (1 << 1), + SCSMF_FREE_POINTER_REPLY = (1 << 2), } switch_core_session_message_flag_enum_t; typedef uint32_t switch_core_session_message_flag_t; @@ -723,71 +732,70 @@ \brief Channel Flags
-CF_ANSWERED     = (1 <<  0) - Channel is answered
-CF_OUTBOUND     = (1 <<  1) - Channel is an outbound channel
-CF_EARLY_MEDIA  = (1 <<  2) - Channel is ready for audio before answer 
-CF_ORIGINATOR	= (1 <<  3) - Channel is an originator
-CF_TRANSFER		= (1 <<  4) - Channel is being transfered
-CF_ACCEPT_CNG	= (1 <<  5) - Channel will accept CNG frames
-CF_WAIT_FOR_ME	= (1 <<  6) - Channel wants you to wait
-CF_BRIDGED		= (1 <<  7) - Channel in a bridge
-CF_HOLD			= (1 <<  8) - Channel is on hold
-CF_SERVICE		= (1 <<  9) - Channel has a service thread
-CF_TAGGED		= (1 << 10) - Channel is tagged
-CF_WINNER		= (1 << 11) - Channel is the winner
-CF_CONTROLLED	= (1 << 12) - Channel is under control
-CF_PROXY_MODE		= (1 << 13) - Channel has no media
-CF_SUSPEND		= (1 << 14) - Suspend i/o
-CF_EVENT_PARSE  = (1 << 15) - Suspend control events
-CF_REPEAT_STATE = (1 << 16) - Tell the state machine to repeat a state
-CF_GEN_RINGBACK = (1 << 17) - Channel is generating it's own ringback
-CF_RING_READY   = (1 << 18) - Channel is ready to send ringback
-CF_BREAK        = (1 << 19) - Channel should stop what it's doing
-CF_BROADCAST    = (1 << 20) - Channel is broadcasting
-CF_UNICAST      = (1 << 21) - Channel has a unicast connection
-CF_VIDEO		= (1 << 22) - Channel has video
-CF_EVENT_LOCK   = (1 << 23) - Don't parse events
-CF_RESET        = (1 << 24) - Tell extension parser to reset
-CF_ORIGINATING  = (1 << 25) - Channel is originating
-CF_STOP_BROADCAST = (1 << 26) - Signal to stop broadcast
+CF_ANSWERED			- Channel is answered
+CF_OUTBOUND			- Channel is an outbound channel
+CF_EARLY_MEDIA		- Channel is ready for audio before answer 
+CF_ORIGINATOR		- Channel is an originator
+CF_TRANSFER			- Channel is being transfered
+CF_ACCEPT_CNG		- Channel will accept CNG frames
+CF_REDIRECT 		- Channel is being redirected
+CF_BRIDGED			- Channel in a bridge
+CF_HOLD				- Channel is on hold
+CF_SERVICE			- Channel has a service thread
+CF_TAGGED			- Channel is tagged
+CF_WINNER			- Channel is the winner
+CF_CONTROLLED		- Channel is under control
+CF_PROXY_MODE		- Channel has no media
+CF_SUSPEND			- Suspend i/o
+CF_EVENT_PARSE		- Suspend control events
+CF_GEN_RINGBACK		- Channel is generating it's own ringback
+CF_RING_READY		- Channel is ready to send ringback
+CF_BREAK			- Channel should stop what it's doing
+CF_BROADCAST		- Channel is broadcasting
+CF_UNICAST			- Channel has a unicast connection
+CF_VIDEO			- Channel has video
+CF_EVENT_LOCK		- Don't parse events
+CF_RESET			- Tell extension parser to reset
+CF_ORIGINATING		- Channel is originating
+CF_STOP_BROADCAST	- Signal to stop broadcast
 
*/ typedef enum { - CF_ANSWERED = (1 << 0), - CF_OUTBOUND = (1 << 1), - CF_EARLY_MEDIA = (1 << 2), - CF_ORIGINATOR = (1 << 3), - CF_TRANSFER = (1 << 4), - CF_ACCEPT_CNG = (1 << 5), - CF_WAIT_FOR_ME = (1 << 6), - CF_BRIDGED = (1 << 7), - CF_HOLD = (1 << 8), - CF_SERVICE = (1 << 9), - CF_TAGGED = (1 << 10), - CF_WINNER = (1 << 11), - CF_CONTROLLED = (1 << 12), - CF_PROXY_MODE = (1 << 13), - CF_SUSPEND = (1 << 14), - CF_EVENT_PARSE = (1 << 15), - CF_REPEAT_STATE = (1 << 16), - CF_GEN_RINGBACK = (1 << 17), - CF_RING_READY = (1 << 18), - CF_BREAK = (1 << 19), - CF_BROADCAST = (1 << 20), - CF_UNICAST = (1 << 21), - CF_VIDEO = (1 << 22), - CF_EVENT_LOCK = (1 << 23), - CF_RESET = (1 << 24), - CF_ORIGINATING = (1 << 25), - CF_STOP_BROADCAST = (1 << 26), - CF_PROXY_MEDIA = (1 << 27), - CF_INNER_BRIDGE = (1 << 28), - CF_REQ_MEDIA = (1 << 29), - CF_VERBOSE_EVENTS = (1 << 30) -} switch_channel_flag_enum_t; -typedef uint32_t switch_channel_flag_t; - + CF_ANSWERED = 1, + CF_OUTBOUND, + CF_EARLY_MEDIA, + CF_ORIGINATOR, + CF_TRANSFER, + CF_ACCEPT_CNG, + CF_REDIRECT, + CF_BRIDGED, + CF_HOLD, + CF_SERVICE, + CF_TAGGED, + CF_WINNER, + CF_CONTROLLED, + CF_PROXY_MODE, + CF_SUSPEND, + CF_EVENT_PARSE, + CF_GEN_RINGBACK, + CF_RING_READY, + CF_BREAK, + CF_BROADCAST, + CF_UNICAST, + CF_VIDEO, + CF_EVENT_LOCK, + CF_RESET, + CF_ORIGINATING, + CF_STOP_BROADCAST, + CF_PROXY_MEDIA, + CF_INNER_BRIDGE, + CF_REQ_MEDIA, + CF_VERBOSE_EVENTS, + + /* WARNING: DO NOT ADD ANY FLAGS BELOW THIS LINE */ + CF_FLAG_MAX +} switch_channel_flag_t; /*! \enum switch_frame_flag_t @@ -1058,6 +1066,7 @@ SWITCH_EVENT_DTMF - DTMF was sent SWITCH_EVENT_MESSAGE - A Basic Message SWITCH_EVENT_PRESENCE_IN - Presence in + SWITCH_EVENT_NOTIFY_IN - Received incoming NOTIFY from gateway subscription SWITCH_EVENT_PRESENCE_OUT - Presence out SWITCH_EVENT_PRESENCE_PROBE - Presence probe SWITCH_EVENT_MESSAGE_WAITING - A message is waiting @@ -1116,6 +1125,7 @@ SWITCH_EVENT_DTMF, SWITCH_EVENT_MESSAGE, SWITCH_EVENT_PRESENCE_IN, + SWITCH_EVENT_NOTIFY_IN, SWITCH_EVENT_PRESENCE_OUT, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_MESSAGE_WAITING, Modified: freeswitch/branches/gmaruzz/src/include/switch_utils.h ============================================================================== --- freeswitch/branches/gmaruzz/src/include/switch_utils.h (original) +++ freeswitch/branches/gmaruzz/src/include/switch_utils.h Mon Dec 15 12:56:36 2008 @@ -41,6 +41,22 @@ #include SWITCH_BEGIN_EXTERN_C + +SWITCH_DECLARE(int) switch_toupper(int c); +SWITCH_DECLARE(int) switch_tolower(int c); +SWITCH_DECLARE(int) switch_isalnum(int c); +SWITCH_DECLARE(int) switch_isalpha(int c); +SWITCH_DECLARE(int) switch_iscntrl(int c); +SWITCH_DECLARE(int) switch_isdigit(int c); +SWITCH_DECLARE(int) switch_isgraph(int c); +SWITCH_DECLARE(int) switch_islower(int c); +SWITCH_DECLARE(int) switch_isprint(int c); +SWITCH_DECLARE(int) switch_ispunct(int c); +SWITCH_DECLARE(int) switch_isspace(int c); +SWITCH_DECLARE(int) switch_isupper(int c); +SWITCH_DECLARE(int) switch_isxdigit(int c); + + #define switch_samples_per_packet(rate, interval) ((uint32_t)((float)rate / (1000.0f / (float)interval))) #define SWITCH_SMAX 32767 #define SWITCH_SMIN -32768 @@ -211,7 +227,7 @@ \param key the key to test \return TRUE or FALSE */ -#define is_dtmf(key) ((key > 47 && key < 58) || (key > 64 && key < 69) || (key > 96 && key < 101) || key == 35 || key == 42 || key == 87 || key == 119) +#define is_dtmf(key) ((key > 47 && key < 58) || (key > 64 && key < 69) || (key > 96 && key < 101) || key == 35 || key == 42 || key == 87 || key == 119 || key == 70) #define end_of(_s) *(*_s == '\0' ? _s : _s + strlen(_s) - 1) #define end_of_p(_s) (*_s == '\0' ? _s : _s + strlen(_s) - 1) @@ -303,7 +319,7 @@ if (it) { dup = strdup(it); for(p = dup; p && *p; p++) { - *p = (char) tolower(*p); + *p = (char) switch_tolower(*p); } return dup; } @@ -320,7 +336,7 @@ if (it) { dup = strdup(it); for(p = dup; p && *p; p++) { - *p = (char) toupper(*p); + *p = (char) switch_toupper(*p); } return dup; } @@ -353,7 +369,7 @@ assert(S != NULL); for (p = S; p && *p; p++) { - *p = (char) toupper(*p); + *p = (char) switch_toupper(*p); } if (strstr(S, q)) { @@ -365,7 +381,7 @@ assert(Q != NULL); for (p = Q; p && *p; p++) { - *p = (char) toupper(*p); + *p = (char) switch_toupper(*p); } if (strstr(s, Q)) { Modified: freeswitch/branches/gmaruzz/src/mod/applications/mod_commands/mod_commands.c ============================================================================== --- freeswitch/branches/gmaruzz/src/mod/applications/mod_commands/mod_commands.c (original) +++ freeswitch/branches/gmaruzz/src/mod/applications/mod_commands/mod_commands.c Mon Dec 15 12:56:36 2008 @@ -704,13 +704,14 @@ if (stream->param_event) { http = switch_event_get_header(stream->param_event, "http-host"); + if ((var = switch_event_get_header(stream->param_event, "content-type"))) { + if (!strcasecmp(var, "text/plain")) { + http = NULL; + } + } } - if ((var = switch_event_get_header(stream->param_event, "content-type"))) { - if (!strcasecmp(var, "text/plain")) { - http = NULL; - } - } else { + if (http) { stream->write_function(stream, "%s", "Content-Type: text/html\n\n"); } @@ -1127,8 +1128,8 @@ } else if (!strcasecmp(arg, "both")) { if (uuid && (other_session = switch_core_session_locate(uuid))) { switch_channel_t *other_channel = switch_core_session_get_channel(other_session); - switch_channel_set_flag(other_channel, CF_TRANSFER); - switch_channel_set_flag(channel, CF_TRANSFER); + switch_channel_set_flag(other_channel, CF_REDIRECT); + switch_channel_set_flag(channel, CF_REDIRECT); switch_ivr_session_transfer(other_session, dest, dp, context); switch_core_session_rwunlock(other_session); } @@ -1148,14 +1149,15 @@ return SWITCH_STATUS_SUCCESS; } -#define TONE_DETECT_SYNTAX " [ ]" +#define TONE_DETECT_SYNTAX " [ ]" SWITCH_STANDARD_API(tone_detect_session_function) { - char *argv[7] = { 0 }; + char *argv[8] = { 0 }; int argc; char *mydata = NULL; time_t to = 0; switch_core_session_t *rsession; + int hits = 1; if (!cmd) { stream->write_function(stream, "-USAGE: %s\n", TONE_DETECT_SYNTAX); @@ -1193,7 +1195,14 @@ } } - switch_ivr_tone_detect_session(rsession, argv[1], argv[2], argv[3], to, argv[5], argv[6]); + if (argv[7]) { + hits = atoi(argv[7]); + if (hits < 0) { + hits = 1; + } + } + + switch_ivr_tone_detect_session(rsession, argv[1], argv[2], argv[3], to, hits, argv[5], argv[6]); stream->write_function(stream, "+OK Enabling tone detection '%s' '%s' '%s'\n", argv[1], argv[2], argv[3]); done: @@ -1251,6 +1260,42 @@ return SWITCH_STATUS_SUCCESS; } + + +#define UUID_DEFLECT_SYNTAX " " +SWITCH_STANDARD_API(uuid_deflect) +{ + switch_core_session_t *tsession = NULL; + char *uuid = NULL, *text = NULL; + + if (!switch_strlen_zero(cmd) && (uuid = strdup(cmd))) { + if ((text = strchr(uuid, ' '))) { + *text++ = '\0'; + } + } + + if (switch_strlen_zero(uuid) || switch_strlen_zero(text)) { + stream->write_function(stream, "-USAGE: %s\n", UUID_DEFLECT_SYNTAX); + } else { + if ((tsession = switch_core_session_locate(uuid))) { + switch_core_session_message_t msg = { 0 }; + + /* Tell the channel to deflect the call */ + msg.from = __FILE__; + msg.string_arg = text; + msg.message_id = SWITCH_MESSAGE_INDICATE_DEFLECT; + switch_core_session_receive_message(tsession, &msg); + stream->write_function(stream, "+OK:%s\n", msg.string_reply); + switch_core_session_rwunlock(tsession); + } else { + stream->write_function(stream, "-ERR No Such Channel %s!\n", uuid); + } + } + + switch_safe_free(uuid); + return SWITCH_STATUS_SUCCESS; +} + #define SCHED_TRANSFER_SYNTAX "[+]