[Freeswitch-branches] [commit] r10574 - in freeswitch/branches/gmaruzz/src: . include mod/endpoints/mod_skypiax mod/endpoints/mod_woomera
FreeSWITCH SVN
gmaruzz at freeswitch.org
Wed Dec 3 09:19:43 PST 2008
Author: gmaruzz
Date: Wed Dec 3 12:19:42 2008
New Revision: 10574
Log:
freeswitch_core_lib: added switch_file_pipe_create to switch_apr.c and switch_apr.h. skypiax: added stuff to compile on visual C. Almost there
Modified:
freeswitch/branches/gmaruzz/src/include/switch_apr.h
freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c
freeswitch/branches/gmaruzz/src/mod/endpoints/mod_woomera/mod_woomera.2008.vcproj
freeswitch/branches/gmaruzz/src/switch_apr.c
Modified: freeswitch/branches/gmaruzz/src/include/switch_apr.h
==============================================================================
--- freeswitch/branches/gmaruzz/src/include/switch_apr.h (original)
+++ freeswitch/branches/gmaruzz/src/include/switch_apr.h Wed Dec 3 12:19:42 2008
@@ -1303,6 +1303,7 @@
SWITCH_DECLARE(switch_status_t) switch_match_glob(const char *pattern, switch_array_header_t **result, switch_memory_pool_t *p);
SWITCH_DECLARE(switch_status_t) switch_socket_addr_get(switch_sockaddr_t **sa, switch_bool_t remote, switch_socket_t *sock);
+SWITCH_DECLARE(switch_status_t) switch_file_pipe_create_ex(switch_file_t **in, switch_file_t **out, int32_t blocking, switch_memory_pool_t *p);
/** @} */
Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c
==============================================================================
--- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c (original)
+++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c Wed Dec 3 12:19:42 2008
@@ -34,12 +34,19 @@
*
*/
+#define WIN32_SKYPIAX
+#define __CYGWIN__
#define MOD_SKYPIAX
#ifdef MOD_SKYPIAX
+#ifndef WIN32_SKYPIAX
#include <X11/Xlib.h>
#include <X11/Xlibint.h>
#include <X11/Xatom.h>
+#else //WIN32_SKYPIAX
+//FIXME include?
+#endif //WIN32_SKYPIAX
+
#include <switch.h>
#define SKYPIAX_SVN_VERSION "SVN 123456"
@@ -118,12 +125,22 @@
static switch_memory_pool_t *module_pool = NULL;
static int running = 1;
+#ifndef WIN32_SKYPIAX
struct AsteriskHandles {
Window skype_win;
Display *disp;
Window win;
int fdesc[2];
};
+#else //WIN32_SKYPIAX
+
+struct AsteriskHandles {
+ HWND win32_hInit_MainWindowHandle;
+ HWND win32_hGlobal_SkypeAPIWindowHandle;
+ int fdesc[2];
+};
+
+#endif //WIN32_SKYPIAX
typedef enum {
@@ -183,7 +200,7 @@
double playback_boost;
double capture_boost;
int stripmsd;
- pthread_t skype_thread;
+ switch_thread_t *skype_thread;
char skype_call_id[512];
int skype_call_ongoing;
char skype_friends[4096];
@@ -258,6 +275,232 @@
int option_debug = 100;
switch_core_session_t *global_session = NULL;
+#ifdef WIN32_SKYPIAX
+#ifdef __CYGWIN__
+struct AsteriskHandles *win32_AsteriskHandlesSkype;
+HWND win32_hInit_MainWindowHandle;
+HINSTANCE win32_hInit_ProcessHandle;
+char win32_acInit_WindowClassName[128];
+HANDLE win32_hGlobal_ThreadShutdownEvent;
+UINT win32_uiGlobal_MsgID_SkypeControlAPIAttach;
+UINT win32_uiGlobal_MsgID_SkypeControlAPIDiscover;
+HWND win32_hGlobal_SkypeAPIWindowHandle = NULL;
+DWORD win32_ulGlobal_PromptConsoleMode = 0;
+HANDLE volatile win32_hGlobal_PromptConsoleHandle = NULL;
+
+enum {
+ SKYPECONTROLAPI_ATTACH_SUCCESS = 0, /* Client is successfully
+ attached and API window handle can be found
+ in wParam parameter */
+ SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION = 1, /* Skype has acknowledged
+ connection request and is waiting
+ for confirmation from the user. */
+ /* The client is not yet attached
+ * and should wait for SKYPECONTROLAPI_ATTACH_SUCCESS message */
+ SKYPECONTROLAPI_ATTACH_REFUSED = 2, /* User has explicitly
+ denied access to client */
+ SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE = 3, /* API is not available
+ at the moment.
+ For example, this happens when no user
+ is currently logged in. */
+ /* Client should wait for
+ * SKYPECONTROLAPI_ATTACH_API_AVAILABLE
+ * broadcast before making any further */
+ /* connection attempts. */
+ SKYPECONTROLAPI_ATTACH_API_AVAILABLE = 0x8001
+};
+
+LRESULT APIENTRY skypiax_skype_present(HWND hWindow, UINT uiMessage, WPARAM uiParam,
+ LPARAM ulParam)
+{
+ LRESULT lReturnCode;
+ int fIssueDefProc;
+ struct skypiax_interface *p = NULL;
+
+ lReturnCode = 0;
+ fIssueDefProc = 0;
+ switch (uiMessage) {
+ case WM_DESTROY:
+ win32_hInit_MainWindowHandle = NULL;
+ PostQuitMessage(0);
+ break;
+ case WM_COPYDATA:
+ if (win32_hGlobal_SkypeAPIWindowHandle == (HWND) uiParam) {
+
+ PCOPYDATASTRUCT poCopyData = (PCOPYDATASTRUCT) ulParam;
+ write(win32_AsteriskHandlesSkype->fdesc[1], (const char *) poCopyData->lpData,
+ strlen((const char *) poCopyData->lpData));
+ write(win32_AsteriskHandlesSkype->fdesc[1], "\0", 1);
+ lReturnCode = 1;
+ }
+ break;
+ default:
+ if (uiMessage == win32_uiGlobal_MsgID_SkypeControlAPIAttach) {
+ switch (ulParam) {
+ case SKYPECONTROLAPI_ATTACH_SUCCESS:
+ NOTICA("\n\n\tConnected to Skype API!\n", SKYPIAX_P_LOG);
+ win32_hGlobal_SkypeAPIWindowHandle = (HWND) uiParam;
+ switch_sleep(5000);
+ win32_AsteriskHandlesSkype->win32_hGlobal_SkypeAPIWindowHandle =
+ win32_hGlobal_SkypeAPIWindowHandle;
+ break;
+ case SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION:
+ WARNINGA
+ ("\n\n\tIf I do not immediately connect to Skype API,\n\tplease give the Skype client authorization to be connected \n\tby Asterisk and to not ask you again.\n\n",
+ SKYPIAX_P_LOG);
+ break;
+ case SKYPECONTROLAPI_ATTACH_REFUSED:
+ ERRORA("Skype client refused to be connected by Skypiax!\n", SKYPIAX_P_LOG);
+ break;
+ case SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE:
+ ERRORA("Skype API not available\n", SKYPIAX_P_LOG);
+ break;
+ case SKYPECONTROLAPI_ATTACH_API_AVAILABLE:
+ DEBUGA_SKYPE("Skype API available\n", SKYPIAX_P_LOG);
+ break;
+ default:
+ WARNINGA("GOT AN UNKNOWN SKYPE WINDOWS MSG\n", SKYPIAX_P_LOG);
+ }
+ lReturnCode = 1;
+ break;
+ }
+ fIssueDefProc = 1;
+ break;
+ }
+ if (fIssueDefProc)
+ lReturnCode = DefWindowProc(hWindow, uiMessage, uiParam, ulParam);
+ return (lReturnCode);
+}
+
+int win32_Initialize_CreateWindowClass(void)
+{
+ unsigned char *paucUUIDString;
+ RPC_STATUS lUUIDResult;
+ int fReturnStatus;
+ UUID oUUID;
+
+ fReturnStatus = 0;
+ lUUIDResult = UuidCreate(&oUUID);
+ win32_hInit_ProcessHandle =
+ (HINSTANCE) OpenProcess(PROCESS_DUP_HANDLE, FALSE, GetCurrentProcessId());
+ if (win32_hInit_ProcessHandle != NULL
+ && (lUUIDResult == RPC_S_OK || lUUIDResult == RPC_S_UUID_LOCAL_ONLY)) {
+ if (UuidToString(&oUUID, &paucUUIDString) == RPC_S_OK) {
+ WNDCLASS oWindowClass;
+
+ strcpy(win32_acInit_WindowClassName, "Skype-API-Skypiax-");
+ strcat(win32_acInit_WindowClassName, (char *) paucUUIDString);
+
+ oWindowClass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
+ oWindowClass.lpfnWndProc = (WNDPROC) & skypiax_skype_present;
+ oWindowClass.cbClsExtra = 0;
+ oWindowClass.cbWndExtra = 0;
+ oWindowClass.hInstance = win32_hInit_ProcessHandle;
+ oWindowClass.hIcon = NULL;
+ oWindowClass.hCursor = NULL;
+ oWindowClass.hbrBackground = NULL;
+ oWindowClass.lpszMenuName = NULL;
+ oWindowClass.lpszClassName = win32_acInit_WindowClassName;
+
+ if (RegisterClass(&oWindowClass) != 0)
+ fReturnStatus = 1;
+
+ RpcStringFree(&paucUUIDString);
+ }
+ }
+ if (fReturnStatus == 0)
+ CloseHandle(win32_hInit_ProcessHandle), win32_hInit_ProcessHandle = NULL;
+ return (fReturnStatus);
+}
+
+void win32_DeInitialize_DestroyWindowClass(void)
+{
+ UnregisterClass(win32_acInit_WindowClassName, win32_hInit_ProcessHandle);
+ CloseHandle(win32_hInit_ProcessHandle), win32_hInit_ProcessHandle = NULL;
+}
+
+int win32_Initialize_CreateMainWindow(void)
+{
+ win32_hInit_MainWindowHandle =
+ CreateWindowEx(WS_EX_APPWINDOW | WS_EX_WINDOWEDGE, win32_acInit_WindowClassName, "",
+ WS_BORDER | WS_SYSMENU | WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT,
+ 128, 128, NULL, 0, win32_hInit_ProcessHandle, 0);
+ return (win32_hInit_MainWindowHandle != NULL ? 1 : 0);
+}
+
+void win32_DeInitialize_DestroyMainWindow(void)
+{
+ if (win32_hInit_MainWindowHandle != NULL)
+ DestroyWindow(win32_hInit_MainWindowHandle), win32_hInit_MainWindowHandle = NULL;
+}
+
+DWORD win32_dwThreadId;
+
+//void *do_skype_thread(void *data)
+static void *SWITCH_THREAD_FUNC do_skype_thread(switch_thread_t *thread, void *obj)
+{
+ /* create window class */
+ /* create dummy/hidden window for processing messages */
+ /* run message loop thread */
+ /* do application control until exit */
+ /* exit: send QUIT message to our own window */
+ /* wait until thred terminates */
+ /* destroy main window */
+ /* destroy window class */
+
+#if 0
+ res = pipe(p->AsteriskHandlesAst.fdesc);
+ if (res) {
+ ERRORA("Unable to create skype pipe, exiting skype thread\n", SKYPIAX_P_LOG);
+ DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
+ return NULL;
+ }
+#endif //0
+
+ win32_AsteriskHandlesSkype = (struct AsteriskHandles *) obj;
+
+ win32_uiGlobal_MsgID_SkypeControlAPIAttach =
+ RegisterWindowMessage("SkypeControlAPIAttach");
+ win32_uiGlobal_MsgID_SkypeControlAPIDiscover =
+ RegisterWindowMessage("SkypeControlAPIDiscover");
+
+ if (win32_uiGlobal_MsgID_SkypeControlAPIAttach != 0
+ && win32_uiGlobal_MsgID_SkypeControlAPIDiscover != 0) {
+ if (win32_Initialize_CreateWindowClass()) {
+ if (win32_Initialize_CreateMainWindow()) {
+ win32_hGlobal_ThreadShutdownEvent = CreateEvent(NULL, TRUE, FALSE, NULL);
+ if (win32_hGlobal_ThreadShutdownEvent != NULL) {
+ if (SendMessage
+ (HWND_BROADCAST, win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
+ (WPARAM) win32_hInit_MainWindowHandle, 0) != 0) {
+ win32_AsteriskHandlesSkype->win32_hInit_MainWindowHandle =
+ win32_hInit_MainWindowHandle;
+ while (1) {
+ MSG oMessage;
+
+ while (GetMessage(&oMessage, 0, 0, 0) != FALSE) {
+ TranslateMessage(&oMessage);
+ DispatchMessage(&oMessage);
+ }
+ }
+ }
+ CloseHandle(win32_hGlobal_ThreadShutdownEvent);
+ }
+ win32_DeInitialize_DestroyMainWindow();
+ }
+ win32_DeInitialize_DestroyWindowClass();
+ }
+ }
+ return NULL;
+}
+
+#endif /* __CYGWIN__ */
+
+
+
+#endif //WIN32_SKYPIAX
+
+
static switch_status_t skypiax_codec(private_t *tech_pvt, int sample_rate, int codec_ms)
{
if (switch_core_codec_init(&tech_pvt->read_codec,
@@ -592,7 +835,7 @@
break;
}
} else {
- usleep(1000);
+ switch_sleep(1000);
}
}
@@ -648,8 +891,10 @@
}
return -1;
}
+#ifndef WIN32_SKYPIAX
fcntl(p->audioskypepipe[0], F_SETFL, O_NONBLOCK);
fcntl(p->audioskypepipe[1], F_SETFL, O_NONBLOCK);
+#endif// WIN32_SKYPIAX
if (option_debug > 10) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
@@ -686,7 +931,7 @@
if ((samples = read(p->audiopipe[0], tech_pvt->read_frame.data, SAMPLES_PER_FRAME * sizeof(short))) != 320) {
DEBUGA_SKYPE("read=====> NOT GOOD samples=%d expected=%d\n", SKYPIAX_P_LOG, samples,
320);
- usleep(1000);
+ switch_sleep(1000);
//do nothing
} else {
tech_pvt->read_frame.datalen=samples;
@@ -734,7 +979,7 @@
if ((samples = read(p->audiopipe[0], buf, SAMPLES_PER_FRAME * sizeof(short))) != 320) {
DEBUGA_SOUND("read=====> NOT GOOD samples=%d expected=%d\n", SKYPIAX_P_LOG, samples,
SAMPLES_PER_FRAME * sizeof(short));
- usleep(100);
+ switch_sleep(100);
//do nothing
} else {
//DEBUGA_SOUND("read=====> GOOD samples=%d\n", SKYPIAX_P_LOG, samples);
@@ -942,7 +1187,7 @@
if ((samples = read(p->audiopipe[0], buf, SAMPLES_PER_FRAME * sizeof(short))) != 320) {
DEBUGA_SOUND("read=====> NOT GOOD samples=%d expected=%d\n", SKYPIAX_P_LOG, samples,
SAMPLES_PER_FRAME * sizeof(short));
- usleep(100);
+ switch_sleep(100);
//do nothing
} else {
//DEBUGA_SOUND("read=====> GOOD samples=%d\n", SKYPIAX_P_LOG, samples);
@@ -1033,6 +1278,230 @@
}
+#if 1
+switch_file_t *readp = NULL;
+switch_file_t *writep = NULL;
+
+void create_pipe(void *data)
+{
+ switch_status_t rv;
+
+ //rv = switch_file_pipe_create_ex(&readp, &writep, APR_FULL_NONBLOCK, module_pool);
+ rv = switch_file_pipe_create_ex(&readp, &writep, 2, module_pool);
+ //rv = switch_file_pipe_create(&readp, &writep, module_pool);
+}
+#if 0
+//testpipe.c
+
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdlib.h>
+
+#include "testutil.h"
+#include "apr_file_io.h"
+#include "apr_errno.h"
+#include "apr_general.h"
+#include "apr_lib.h"
+#include "apr_thread_proc.h"
+#include "apr_strings.h"
+
+static apr_file_t *readp = NULL;
+static apr_file_t *writep = NULL;
+
+static void create_pipe(abts_case *tc, void *data)
+{
+ apr_status_t rv;
+
+ rv = apr_file_pipe_create(&readp, &writep, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ ABTS_PTR_NOTNULL(tc, readp);
+ ABTS_PTR_NOTNULL(tc, writep);
+}
+
+static void close_pipe(abts_case *tc, void *data)
+{
+ apr_status_t rv;
+ apr_size_t nbytes = 256;
+ char buf[256];
+
+ rv = apr_file_close(readp);
+ rv = apr_file_close(writep);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_file_read(readp, buf, &nbytes);
+ ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_EBADF(rv));
+}
+
+static void set_timeout(abts_case *tc, void *data)
+{
+ apr_status_t rv;
+ apr_interval_time_t timeout;
+
+ rv = apr_file_pipe_create_ex(&readp, &writep, APR_WRITE_BLOCK, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ ABTS_PTR_NOTNULL(tc, readp);
+ ABTS_PTR_NOTNULL(tc, writep);
+
+ rv = apr_file_pipe_timeout_get(writep, &timeout);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ ABTS_ASSERT(tc, "Timeout mismatch, expected -1", timeout == -1);
+
+ rv = apr_file_pipe_timeout_set(readp, apr_time_from_sec(1));
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_file_pipe_timeout_get(readp, &timeout);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ ABTS_ASSERT(tc, "Timeout mismatch, expected 1 second",
+ timeout == apr_time_from_sec(1));
+}
+
+static void read_write(abts_case *tc, void *data)
+{
+ apr_status_t rv;
+ char *buf;
+ apr_size_t nbytes;
+
+ nbytes = strlen("this is a test");
+ buf = (char *)apr_palloc(p, nbytes + 1);
+
+ rv = apr_file_pipe_create_ex(&readp, &writep, APR_WRITE_BLOCK, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ ABTS_PTR_NOTNULL(tc, readp);
+ ABTS_PTR_NOTNULL(tc, writep);
+
+ rv = apr_file_pipe_timeout_set(readp, apr_time_from_sec(1));
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ if (!rv) {
+ rv = apr_file_read(readp, buf, &nbytes);
+ ABTS_INT_EQUAL(tc, 1, APR_STATUS_IS_TIMEUP(rv));
+ ABTS_SIZE_EQUAL(tc, 0, nbytes);
+ }
+}
+
+static void read_write_notimeout(abts_case *tc, void *data)
+{
+ apr_status_t rv;
+ char *buf = "this is a test";
+ char *input;
+ apr_size_t nbytes;
+
+ nbytes = strlen("this is a test");
+
+ rv = apr_file_pipe_create(&readp, &writep, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ ABTS_PTR_NOTNULL(tc, readp);
+ ABTS_PTR_NOTNULL(tc, writep);
+
+ rv = apr_file_write(writep, buf, &nbytes);
+ ABTS_SIZE_EQUAL(tc, strlen("this is a test"), nbytes);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ nbytes = 256;
+ input = apr_pcalloc(p, nbytes + 1);
+ rv = apr_file_read(readp, input, &nbytes);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ ABTS_SIZE_EQUAL(tc, strlen("this is a test"), nbytes);
+ ABTS_STR_EQUAL(tc, "this is a test", input);
+}
+
+static void test_pipe_writefull(abts_case *tc, void *data)
+{
+ int iterations = 1000;
+ int i;
+ int bytes_per_iteration = 8000;
+ char *buf = (char *)malloc(bytes_per_iteration);
+ char responsebuf[128];
+ apr_size_t nbytes;
+ int bytes_processed;
+ apr_proc_t proc = {0};
+ apr_procattr_t *procattr;
+ const char *args[2];
+ apr_status_t rv;
+ apr_exit_why_e why;
+
+ rv = apr_procattr_create(&procattr, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_procattr_io_set(procattr, APR_CHILD_BLOCK, APR_CHILD_BLOCK,
+ APR_CHILD_BLOCK);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_procattr_error_check_set(procattr, 1);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ args[0] = "readchild" EXTENSION;
+ args[1] = NULL;
+ rv = apr_proc_create(&proc, TESTBINPATH "readchild" EXTENSION, args, NULL, procattr, p);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_file_pipe_timeout_set(proc.in, apr_time_from_sec(10));
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ rv = apr_file_pipe_timeout_set(proc.out, apr_time_from_sec(10));
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ i = iterations;
+ do {
+ rv = apr_file_write_full(proc.in, buf, bytes_per_iteration, NULL);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ } while (--i);
+
+ free(buf);
+
+ rv = apr_file_close(proc.in);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+
+ nbytes = sizeof(responsebuf);
+ rv = apr_file_read(proc.out, responsebuf, &nbytes);
+ ABTS_INT_EQUAL(tc, APR_SUCCESS, rv);
+ bytes_processed = (int)apr_strtoi64(responsebuf, NULL, 10);
+ ABTS_INT_EQUAL(tc, iterations * bytes_per_iteration, bytes_processed);
+
+ ABTS_ASSERT(tc, "wait for child process",
+ apr_proc_wait(&proc, NULL, &why, APR_WAIT) == APR_CHILD_DONE);
+
+ ABTS_ASSERT(tc, "child terminated normally", why == APR_PROC_EXIT);
+}
+
+abts_suite *testpipe(abts_suite *suite)
+{
+ suite = ADD_SUITE(suite)
+
+ abts_run_test(suite, create_pipe, NULL);
+ abts_run_test(suite, close_pipe, NULL);
+ abts_run_test(suite, set_timeout, NULL);
+ abts_run_test(suite, close_pipe, NULL);
+ abts_run_test(suite, read_write, NULL);
+ abts_run_test(suite, close_pipe, NULL);
+ abts_run_test(suite, read_write_notimeout, NULL);
+ abts_run_test(suite, test_pipe_writefull, NULL);
+ abts_run_test(suite, close_pipe, NULL);
+
+ return suite;
+}
+
+
+
+
+#endif
+
+
+#endif
static switch_status_t channel_answer_channel(switch_core_session_t *session)
{
private_t *tech_pvt;
@@ -1173,7 +1642,9 @@
/*.receive_event */ channel_receive_event
};
#define SKYPE_THREAD
+#ifndef WIN32_SKYPIAX
#ifdef SKYPE_THREAD
+
#define SKYPE_X11_BUF_SIZE 512
Window skype_win = (Window) - 1;
static XErrorHandler old_handler = 0;
@@ -1302,7 +1773,7 @@
DEBUGA_SKYPE("NOT destroyed disp\n", SKYPIAX_P_LOG);
}
DEBUGA_SKYPE("OUT destroyed disp\n", SKYPIAX_P_LOG);
- usleep(1000);
+ switch_sleep(1000);
}
static void *SWITCH_THREAD_FUNC do_skype_thread(switch_thread_t *thread, void *obj)
@@ -1427,7 +1898,7 @@
write(AsteriskHandlesAst->fdesc[1], b, strlen(b) + 1);
//write(AsteriskHandlesAst->fdesc[1], "\0", 1);
//FIXME DEBUGA_SKYPE("SKYPE pipewrite: |||%s|||len=%d serial=%ld\n\n\n", SKYPIAX_P_LOG, b, strlen(b) + 1, an_event.xclient.serial);
- //usleep(1000);
+ //switch_sleep(1000);
memset(buffer, '\0', 17000);
}
@@ -1454,6 +1925,11 @@
#endif /* SKYPE_THREAD */
+#else // WIN32_SKYPIAX
+
+
+
+#endif // WIN32_SKYPIAX
#define CONTROLDEV_THREAD
#ifdef CONTROLDEV_THREAD
@@ -1485,7 +1961,8 @@
("Sending message failed - probably Skype crashed.\n\nPlease shutdown Skypiax (Asterisk), then restart Skype from the menu, then launch Skypiax and try again.\n",
SKYPIAX_P_LOG);
p->skype = 0;
- p->skype_thread = SKYPIAX_PTHREADT_NULL;
+ //FIXME p->skype_thread = SKYPIAX_PTHREADT_NULL;
+ p->skype_thread = NULL;
if (option_debug > 100) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
@@ -1578,7 +2055,7 @@
SKYPIAX_P_LOG);
sleep(1);
skypiax_skype_write(p, "PROTOCOL 6");
- usleep(10000);
+ switch_sleep(10000);
}
#endif
@@ -1758,15 +2235,15 @@
p->interface_state = SKYPIAX_STATE_RING;
/* no owner, no active call, let's answer */
skypiax_skype_write(p, "SET AGC OFF");
- usleep(10000);
+ switch_sleep(10000);
skypiax_skype_write(p, "SET AEC OFF");
- usleep(10000);
+ switch_sleep(10000);
sprintf(msg_to_skype, "GET CALL %s PARTNER_DISPNAME", id);
skypiax_skype_write(p, msg_to_skype);
- usleep(10000);
+ switch_sleep(10000);
sprintf(msg_to_skype, "GET CALL %s PARTNER_HANDLE", id);
skypiax_skype_write(p, msg_to_skype);
- usleep(10000);
+ switch_sleep(10000);
sprintf(msg_to_skype, "ALTER CALL %s ANSWER", id);
skypiax_skype_write(p, msg_to_skype);
if (option_debug)
@@ -1777,7 +2254,7 @@
/* we're owned, we're in a call, let's refuse */
sprintf(msg_to_skype, "SET CALL %s STATUS FINISHED", id);
skypiax_skype_write(p, msg_to_skype);
- usleep(10000);
+ switch_sleep(10000);
DEBUGA_SKYPE
("We have NOT answered a Skype RING on skype_call %s, because we are already in a skypiax call\n",
SKYPIAX_P_LOG, id);
@@ -1952,13 +2429,13 @@
}
#endif
- usleep(100000);
+ switch_sleep(100000);
sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"5556\"", id);
skypiax_skype_write(p, msg_to_skype);
- usleep(100000);
+ switch_sleep(100000);
sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"5558\"", id);
skypiax_skype_write(p, msg_to_skype);
- usleep(100000);
+ switch_sleep(100000);
}
p->skype_callflow = SKYPIAX_STATE_UP;
@@ -2077,30 +2554,30 @@
int skypiax_skype_call(struct skypiax_interface *p, char *idest, int timeout, switch_core_session_t *session)
{
char rdest[80];
+ char msg_to_skype[1024];
if (option_debug > 10) {
DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
}
-usleep(5000);
+switch_sleep(5000);
//FIXME strncpy(rdest, idest, sizeof(rdest) - 1);
strncpy(rdest, "echo123", sizeof(rdest) - 1);
if (option_debug)
DEBUGA_SKYPE("Calling Skype, rdest is: %s\n", SKYPIAX_P_LOG, rdest);
//skypiax_skype_write(p, "GET AGC");
- //usleep(10000);
+ //switch_sleep(10000);
skypiax_skype_write(p, "SET AGC OFF");
- usleep(10000);
+ switch_sleep(10000);
//skypiax_skype_write(p, "GET AGC");
- //usleep(10000);
+ //switch_sleep(10000);
//skypiax_skype_write(p, "GET AEC");
- //usleep(10000);
+ //switch_sleep(10000);
skypiax_skype_write(p, "SET AEC OFF");
- usleep(10000);
+ switch_sleep(10000);
//skypiax_skype_write(p, "GET AEC");
- //usleep(300000);
+ //switch_sleep(300000);
- char msg_to_skype[1024];
sprintf(msg_to_skype, "CALL %s", rdest);
if (skypiax_skype_write(p, msg_to_skype) < 0) {
@@ -2184,7 +2661,7 @@
while (1) {
- usleep(1000);
+ switch_sleep(1000);
res = skypiax_skype_read(p);
#if 1
//if (res == CALLFLOW_INCOMING_HANGUP && p->interface_state != SKYPIAX_STATE_DOWN)
@@ -2393,7 +2870,7 @@
switch_thread_create(&thread, thd_attr, do_skype_thread, &SKYPIAX_INTERFACES[interface_id], module_pool);
}
-usleep(100000);
+switch_sleep(100000);
if(1)
{
switch_thread_t *thread;
@@ -2406,7 +2883,7 @@
}
-usleep(1000000);
+switch_sleep(1000000);
skypiax_skypeaudio_init(&SKYPIAX_INTERFACES[interface_id]);
@@ -2451,7 +2928,7 @@
} else {
DEBUGA_SKYPE("Initialized XInitThreads!\n", SKYPIAX_P_LOG);
}
-usleep(10000); //FIXME
+switch_sleep(10000); //FIXME
#endif /* _WINDOWS_ */
Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_woomera/mod_woomera.2008.vcproj
==============================================================================
--- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_woomera/mod_woomera.2008.vcproj (original)
+++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_woomera/mod_woomera.2008.vcproj Wed Dec 3 12:19:42 2008
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
- Version="9.00"
- Name="mod_woomera"
+ Version="9,00"
+ Name="mod_skypiax"
ProjectGUID="{FE3540C5-3303-46E0-A69E-D92F775687F1}"
RootNamespace="mod_woomera"
Keyword="Win32Proj"
@@ -40,6 +40,8 @@
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
+ WarningLevel="4"
+ WarnAsError="false"
/>
<Tool
Name="VCManagedResourceCompilerTool"
@@ -52,6 +54,7 @@
/>
<Tool
Name="VCLinkerTool"
+ AdditionalOptions="rpcrt4.lib"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
/>
@@ -143,7 +146,7 @@
</References>
<Files>
<File
- RelativePath=".\mod_woomera.c"
+ RelativePath="..\mod_skypiax\mod_skypiax.c"
>
</File>
</Files>
Modified: freeswitch/branches/gmaruzz/src/switch_apr.c
==============================================================================
--- freeswitch/branches/gmaruzz/src/switch_apr.c (original)
+++ freeswitch/branches/gmaruzz/src/switch_apr.c Wed Dec 3 12:19:42 2008
@@ -942,6 +942,12 @@
return apr_match_glob(pattern, (apr_array_header_t **) result, p);
}
+SWITCH_DECLARE(switch_status_t) switch_file_pipe_create_ex(switch_file_t **in, switch_file_t **out, int32_t blocking, switch_memory_pool_t *p)
+{
+ //return apr_file_pipe_create_ex ((apr_file_t **) in, (apr_file_t **) out, blocking, p);
+ return apr_file_pipe_create ((apr_file_t **) in, (apr_file_t **) out, p);
+}
+
/* For Emacs:
* Local Variables:
* mode:c
More information about the Freeswitch-branches
mailing list