From 8c5efce33e707928afb27f89292e0428be1d32a0 Mon Sep 17 00:00:00 2001 From: Andrey Volk Date: Sat, 24 Aug 2024 13:16:30 +0300 Subject: [PATCH] [mod_skypopen] Remove from tree. --- debian/bootstrap.sh | 1 - src/mod/.gitignore | 3 - src/mod/Makefile.am | 1 - src/mod/endpoints/mod_skypopen/Makefile.am | 19 - src/mod/endpoints/mod_skypopen/README | 8 - .../endpoints/mod_skypopen/configs/client.c | 298 -- .../configs/old-stuff/README.skypopen_auth | 57 - .../mod_skypopen/configs/old-stuff/copy | 39 - .../mod_skypopen/configs/old-stuff/create | 40 - .../README | 4 - .../multi.sh | 152 - .../skypopen.conf.xml | 31 - .../configs/old-stuff/skypopen_auth.c | 219 -- .../configs/old-stuff/startskype.sh | 143 - .../skypeclient00/shared.lck | 0 .../skypeclient00/shared.xml | 99 - .../skypeclient00/skypenameA/config.lck | 0 .../skypeclient00/skypenameA/config.xml | 74 - .../skypenameA/httpfe/cookies.dat | 1 - .../skypeclient00/skypenameA/index2.dat | Bin 208 -> 0 bytes .../skypeclient00/skypenameA/main.lock | 0 .../skypeclient00/skypenameB/config.lck | 0 .../skypeclient00/skypenameB/config.xml | 74 - .../skypenameB/httpfe/cookies.dat | 1 - .../skypeclient00/skypenameB/index2.dat | Bin 208 -> 0 bytes .../skypeclient00/skypenameB/main.lock | 0 .../skypeclient01/shared.lck | 0 .../skypeclient01/shared.xml | 99 - .../skypeclient01/skypenameA/config.lck | 0 .../skypeclient01/skypenameA/config.xml | 74 - .../skypenameA/httpfe/cookies.dat | 1 - .../skypeclient01/skypenameA/index2.dat | Bin 208 -> 0 bytes .../skypeclient01/skypenameA/main.lock | 0 .../skypeclient01/skypenameB/config.lck | 0 .../skypeclient01/skypenameB/config.xml | 74 - .../skypenameB/httpfe/cookies.dat | 1 - .../skypeclient01/skypenameB/index2.dat | Bin 208 -> 0 bytes .../skypeclient01/skypenameB/main.lock | 0 .../skypeclient01/skypenameC/config.lck | 0 .../skypeclient01/skypenameC/config.xml | 74 - .../skypenameC/httpfe/cookies.dat | 1 - .../skypeclient01/skypenameC/index2.dat | Bin 208 -> 0 bytes .../skypeclient01/skypenameC/main.lock | 0 .../mod_skypopen/configs/skypopen.conf.xml | 34 - .../mod_skypopen/configs/startskype.bat | 52 - .../endpoints/mod_skypopen/configs/wait.bat | 4 - .../configs/windows-service/startskype.cmd | 61 - .../configs/windows-service/wait.cmd | 4 - .../endpoints/mod_skypopen/install/install.pl | 365 -- .../mod_skypopen/mod_skypopen.2015.vcxproj | 173 - src/mod/endpoints/mod_skypopen/mod_skypopen.c | 3403 ---------------- .../mod_skypopen/old-stuff/asterisk/Makefile | 93 - .../mod_skypopen/old-stuff/asterisk/README | 1 - .../old-stuff/asterisk/chan_skypiax.c | 2315 ----------- .../old-stuff/asterisk/cyg_no_pthread_kill.c | 17 - .../old-stuff/asterisk/skypiax.conf | 207 - .../mod_skypopen/old-stuff/asterisk/skypiax.h | 427 -- .../endpoints/mod_skypopen/old-stuff/dummy.c | 821 ---- .../mod_skypopen/old-stuff/pcm_lib.c | 2182 ---------- .../mod_skypopen/old-stuff/pcm_native.c | 3493 ----------------- src/mod/endpoints/mod_skypopen/oss/Makefile | 43 - src/mod/endpoints/mod_skypopen/oss/main.c | 502 --- src/mod/endpoints/mod_skypopen/oss/skypopen.h | 79 - src/mod/endpoints/mod_skypopen/skypopen.h | 405 -- .../mod_skypopen/skypopen_protocol.c | 2197 ----------- 65 files changed, 18466 deletions(-) delete mode 100644 src/mod/endpoints/mod_skypopen/Makefile.am delete mode 100644 src/mod/endpoints/mod_skypopen/README delete mode 100644 src/mod/endpoints/mod_skypopen/configs/client.c delete mode 100644 src/mod/endpoints/mod_skypopen/configs/old-stuff/README.skypopen_auth delete mode 100644 src/mod/endpoints/mod_skypopen/configs/old-stuff/copy delete mode 100644 src/mod/endpoints/mod_skypopen/configs/old-stuff/create delete mode 100644 src/mod/endpoints/mod_skypopen/configs/old-stuff/multiple-instance-same-skype-username/README delete mode 100755 src/mod/endpoints/mod_skypopen/configs/old-stuff/multiple-instance-same-skype-username/multi.sh delete mode 100644 src/mod/endpoints/mod_skypopen/configs/old-stuff/multiple-instance-same-skype-username/skypopen.conf.xml delete mode 100644 src/mod/endpoints/mod_skypopen/configs/old-stuff/skypopen_auth.c delete mode 100755 src/mod/endpoints/mod_skypopen/configs/old-stuff/startskype.sh delete mode 100644 src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/shared.lck delete mode 100644 src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/shared.xml delete mode 100644 src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/skypenameA/config.lck delete mode 100644 src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/skypenameA/config.xml delete mode 100644 src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/skypenameA/httpfe/cookies.dat delete mode 100644 src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/skypenameA/index2.dat delete mode 100644 src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/skypenameA/main.lock delete mode 100644 src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/skypenameB/config.lck delete mode 100644 src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/skypenameB/config.xml delete mode 100644 src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/skypenameB/httpfe/cookies.dat delete mode 100644 src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/skypenameB/index2.dat delete mode 100644 src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/skypenameB/main.lock delete mode 100644 src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/shared.lck delete mode 100644 src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/shared.xml delete mode 100644 src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameA/config.lck delete mode 100644 src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameA/config.xml delete mode 100644 src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameA/httpfe/cookies.dat delete mode 100644 src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameA/index2.dat delete mode 100644 src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameA/main.lock delete mode 100644 src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameB/config.lck delete mode 100644 src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameB/config.xml delete mode 100644 src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameB/httpfe/cookies.dat delete mode 100644 src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameB/index2.dat delete mode 100644 src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameB/main.lock delete mode 100644 src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameC/config.lck delete mode 100644 src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameC/config.xml delete mode 100644 src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameC/httpfe/cookies.dat delete mode 100644 src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameC/index2.dat delete mode 100644 src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameC/main.lock delete mode 100644 src/mod/endpoints/mod_skypopen/configs/skypopen.conf.xml delete mode 100644 src/mod/endpoints/mod_skypopen/configs/startskype.bat delete mode 100644 src/mod/endpoints/mod_skypopen/configs/wait.bat delete mode 100644 src/mod/endpoints/mod_skypopen/configs/windows-service/startskype.cmd delete mode 100644 src/mod/endpoints/mod_skypopen/configs/windows-service/wait.cmd delete mode 100755 src/mod/endpoints/mod_skypopen/install/install.pl delete mode 100644 src/mod/endpoints/mod_skypopen/mod_skypopen.2015.vcxproj delete mode 100644 src/mod/endpoints/mod_skypopen/mod_skypopen.c delete mode 100644 src/mod/endpoints/mod_skypopen/old-stuff/asterisk/Makefile delete mode 100644 src/mod/endpoints/mod_skypopen/old-stuff/asterisk/README delete mode 100644 src/mod/endpoints/mod_skypopen/old-stuff/asterisk/chan_skypiax.c delete mode 100644 src/mod/endpoints/mod_skypopen/old-stuff/asterisk/cyg_no_pthread_kill.c delete mode 100644 src/mod/endpoints/mod_skypopen/old-stuff/asterisk/skypiax.conf delete mode 100644 src/mod/endpoints/mod_skypopen/old-stuff/asterisk/skypiax.h delete mode 100644 src/mod/endpoints/mod_skypopen/old-stuff/dummy.c delete mode 100644 src/mod/endpoints/mod_skypopen/old-stuff/pcm_lib.c delete mode 100644 src/mod/endpoints/mod_skypopen/old-stuff/pcm_native.c delete mode 100644 src/mod/endpoints/mod_skypopen/oss/Makefile delete mode 100644 src/mod/endpoints/mod_skypopen/oss/main.c delete mode 100644 src/mod/endpoints/mod_skypopen/oss/skypopen.h delete mode 100644 src/mod/endpoints/mod_skypopen/skypopen.h delete mode 100644 src/mod/endpoints/mod_skypopen/skypopen_protocol.c diff --git a/debian/bootstrap.sh b/debian/bootstrap.sh index fa40702938..da2f303d49 100755 --- a/debian/bootstrap.sh +++ b/debian/bootstrap.sh @@ -53,7 +53,6 @@ avoid_mods=( endpoints/mod_khomp endpoints/mod_opal endpoints/mod_reference - endpoints/mod_skypopen endpoints/mod_unicall event_handlers/mod_smpp event_handlers/mod_event_zmq diff --git a/src/mod/.gitignore b/src/mod/.gitignore index 8dd8c44d4c..7284fb6176 100644 --- a/src/mod/.gitignore +++ b/src/mod/.gitignore @@ -39,9 +39,6 @@ /endpoints/mod_skinny/Makefile /endpoints/mod_skinny/Makefile.in /endpoints/mod_skinny/mod_skinny.log -/endpoints/mod_skypopen/Makefile -/endpoints/mod_skypopen/Makefile.in -/endpoints/mod_skypopen/mod_skypopen.log /endpoints/mod_sofia/Makefile /endpoints/mod_sofia/Makefile.in /endpoints/mod_sofia/mod_sofia.log diff --git a/src/mod/Makefile.am b/src/mod/Makefile.am index 02ecb52ddd..54064d49f3 100644 --- a/src/mod/Makefile.am +++ b/src/mod/Makefile.am @@ -7,7 +7,6 @@ uninstall: $(OUR_UNINSTALL_MODULES) $(OUR_DISABLED_UNINSTALL_MODULES) print_tests: $(OUR_TEST_MODULES) check: $(OUR_CHECK_MODULES) -mod_skypopen-all: mod_gsmopen-all mod_gsmopen-all: mod_spandsp-all $(OUR_MODULES) $(OUR_CLEAN_MODULES) $(OUR_INSTALL_MODULES) $(OUR_UNINSTALL_MODULES) $(OUR_DISABLED_MODULES) $(OUR_DISABLED_CLEAN_MODULES) $(OUR_DISABLED_INSTALL_MODULES) $(OUR_DISABLED_UNINSTALL_MODULES) $(OUR_TEST_MODULES) $(OUR_CHECK_MODULES): diff --git a/src/mod/endpoints/mod_skypopen/Makefile.am b/src/mod/endpoints/mod_skypopen/Makefile.am deleted file mode 100644 index 3e1c8ec7ef..0000000000 --- a/src/mod/endpoints/mod_skypopen/Makefile.am +++ /dev/null @@ -1,19 +0,0 @@ -include $(top_srcdir)/build/modmake.rulesam -MODNAME=mod_skypopen - -SPANDSP_DIR=$(switch_srcdir)/libs/spandsp -SPANDSP_BUILDDIR=$(switch_builddir)/libs/spandsp -SPANDSP_LA=$(SPANDSP_BUILDDIR)/src/libspandsp.la - -mod_LTLIBRARIES = mod_skypopen.la -mod_skypopen_la_SOURCES = mod_skypopen.c skypopen_protocol.c -mod_skypopen_la_CFLAGS = $(AM_CFLAGS) -mod_skypopen_la_CPPFLAGS = -I$(SPANDSP_DIR)/src -I$(SPANDSP_BUILDDIR)/src -I. -mod_skypopen_la_LIBADD = $(switch_builddir)/libfreeswitch.la $(SPANDSP_LA) -mod_skypopen_la_LDFLAGS = -avoid-version -module -no-undefined -shared -lX11 - -BUILT_SOURCES = $(SPANDSP_LA) - -$(SPANDSP_LA): $(SPANDSP_DIR) $(SPANDSP_DIR)/.update - cd $(SPANDSP_BUILDDIR) && $(MAKE) CFLAGS="$(CFLAGS)" CPPFLAGS="$(CPPFLAGS)" - $(TOUCH_TARGET) diff --git a/src/mod/endpoints/mod_skypopen/README b/src/mod/endpoints/mod_skypopen/README deleted file mode 100644 index c84b9993cd..0000000000 --- a/src/mod/endpoints/mod_skypopen/README +++ /dev/null @@ -1,8 +0,0 @@ -Skypopen, Skype Endpoint and Trunk - -All documentation on compiling, using, configuring, -tricks and tweaks, possible problems at: - -http://wiki.freeswitch.org/wiki/Mod_skypopen_Skype_Endpoint_and_Trunk - -mail to: < gmaruzz at gmail dot com > diff --git a/src/mod/endpoints/mod_skypopen/configs/client.c b/src/mod/endpoints/mod_skypopen/configs/client.c deleted file mode 100644 index f437ccce86..0000000000 --- a/src/mod/endpoints/mod_skypopen/configs/client.c +++ /dev/null @@ -1,298 +0,0 @@ -//gcc -Wall -ggdb client.c -o client -lX11 -lpthread -/* - - Interactive client for the Skype API - -USAGE: client [Xserver instance] - -# ./client :103 - -*/ - -#include -#include -#include -#include -#include -#include - -Display *disp = NULL; - -struct SkypopenHandles { - Window skype_win; - Display *disp; - Window win; - int api_connected; - int fdesc[2]; -}; - -XErrorHandler old_handler = 0; -int xerror = 0; -char *dispname; - -int X11_errors_handler(Display * dpy, XErrorEvent * err) -{ - (void) dpy; - - xerror = err->error_code; - printf("\n\nReceived error code %d from X Server on display '%s'\n\n", xerror, dispname); - 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 skypopen_send_message(struct SkypopenHandles *SkypopenHandles, const char *message_P) -{ - - Window w_P; - Display *disp; - Window handle_P; - int ok; - - w_P = SkypopenHandles->skype_win; - disp = SkypopenHandles->disp; - handle_P = SkypopenHandles->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; - - 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(); - 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); - - //giovanni XSync(disp, False); - XFlush(disp); - ok = X11_errors_untrap(); - - if (!ok) - printf("Sending message failed with status %d\n", xerror); - - return 1; -} - -int skypopen_present(struct SkypopenHandles *SkypopenHandles) -{ - Atom skype_inst = XInternAtom(SkypopenHandles->disp, "_SKYPE_INSTANCE", True); - - Atom type_ret; - int format_ret; - unsigned long nitems_ret; - unsigned long bytes_after_ret; - unsigned char *prop; - int status; - - X11_errors_trap(); - status = - XGetWindowProperty(SkypopenHandles->disp, DefaultRootWindow(SkypopenHandles->disp), - skype_inst, 0, 1, False, XA_WINDOW, &type_ret, &format_ret, &nitems_ret, &bytes_after_ret, &prop); - - X11_errors_untrap(); - /* sanity check */ - if (status != Success || format_ret != 32 || nitems_ret != 1) { - SkypopenHandles->skype_win = (Window) - 1; - printf("Skype instance not found on display '%s'\n", dispname); - return 0; - } - - SkypopenHandles->skype_win = *(const unsigned long *) prop & 0xffffffff; - //printf("Skype instance found on display '%s', with id #%d\n", dispname, (unsigned int) SkypopenHandles->skype_win); - return 1; -} - -void skypopen_clean_disp(void *data) -{ - - int *dispptr; - int disp; - - dispptr = data; - disp = *dispptr; - - if (disp) { - close(disp); - } else { - } - usleep(1000); -} - -typedef struct { - int value; - char string[128]; -} thread_parm_t; - -void *threadfunc(void *parm) -{ //child - thread_parm_t *p = (thread_parm_t *) parm; - //printf("%s, parm = %d\n", p->string, p->value); - free(p); - - /* 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'; - - strcat(buffer, buf); - - if (i < 20) { /* last fragment */ - unsigned int howmany; - - howmany = strlen(b) + 1; - - //printf("\tRECEIVED\t==>\t%s\n", b); - printf("%s\n", b); - fflush(stdout); - memset(buffer, '\0', 17000); - } - - break; - default: - break; - } - - } - return NULL; -} - -int main(int argc, char *argv[]) -{ - - struct SkypopenHandles SkypopenHandles; - char buf[512]; - //Display *disp = NULL; - Window root = -1; - Window win = -1; - - if (argc == 2) - dispname = argv[1]; - else - dispname = ":0.0"; - - - if (!XInitThreads()) { - printf("Not initialized XInitThreads!\n"); - } else { - printf("Initialized XInitThreads!\n"); - } - - - - - - disp = XOpenDisplay(dispname); - if (!disp) { - printf("Cannot open X Display '%s', exiting\n", dispname); - return -1; - } - - int xfd; - xfd = XConnectionNumber(disp); - - SkypopenHandles.disp = disp; - - if (skypopen_present(&SkypopenHandles)) { - root = DefaultRootWindow(disp); - win = XCreateSimpleWindow(disp, root, 0, 0, 1, 1, 0, BlackPixel(disp, DefaultScreen(disp)), BlackPixel(disp, DefaultScreen(disp))); - - SkypopenHandles.win = win; - - snprintf(buf, 512, "NAME skypopen"); - - if (!skypopen_send_message(&SkypopenHandles, buf)) { - printf("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch skypopen_auth again\n"); - return -1; - } - - snprintf(buf, 512, "PROTOCOL 7"); - if (!skypopen_send_message(&SkypopenHandles, buf)) { - printf("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch skypopen_auth again\n"); - return -1; - } - - snprintf(buf, 512, "#ciapalino PING"); - if (!skypopen_send_message(&SkypopenHandles, buf)) { - printf("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch skypopen_auth again\n"); - return -1; - } - - pthread_t thread; - int rc = 0; - pthread_attr_t pta; - thread_parm_t *parm = NULL; - - rc = pthread_attr_init(&pta); - - parm = malloc(sizeof(thread_parm_t)); - parm->value = 5; - rc = pthread_create(&thread, NULL, threadfunc, (void *) parm); - - while (1) { - char s[512]; - - memset(s, '\0', 512); - fgets(s, sizeof(s) - 1, stdin); - s[strlen(s) - 1] = '\0'; - - //printf("\tSENT\t\t==>\t%s\n", s); - - if (!strncmp(s, "#output", 7)) { - - system("/bin/nc -l -p 15557 0/tmp/back2 &"); - system("/bin/nc -l -p 15556 0/tmp/back1 &"); - } - if (!skypopen_send_message(&SkypopenHandles, s)) { - printf("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch skypopen_auth again\n"); - return -1; - } - } - } else { - printf("Skype client not found on display '%s'. Please run/restart Skype manually and launch skypopen_auth again\n\n\n", dispname); - return -1; - } - return 0; - -} diff --git a/src/mod/endpoints/mod_skypopen/configs/old-stuff/README.skypopen_auth b/src/mod/endpoints/mod_skypopen/configs/old-stuff/README.skypopen_auth deleted file mode 100644 index c59122e952..0000000000 --- a/src/mod/endpoints/mod_skypopen/configs/old-stuff/README.skypopen_auth +++ /dev/null @@ -1,57 +0,0 @@ -####################################### -HOW TO USE SKYPOPEN_AUTH -####################################### - -You will use skypopen_auth only at the setup moment, to force the Skype client to ask you to authorize "skypopen" to connect to it. - -Then you copy the .Skype configuration directory of the user that has launched Skype (eg: /home/maruzz/.Skype if you are maruzz) on the home directory of the user that will start Skype on the server (eg: root). - -Compile skypopen_auth: -$ gcc -Wall -ggdb skypopen_auth.c -o skypopen_auth -lX11 - -Then: - -1) on a Linux desktop machine, rmmod all the snd* modules -2) on the desktop machine, modprobe snd-dummy -3) on the desktop machine, logout from your autologin username if any, launch the Skype client and login as the username you'll use on server -4) on the desktop machine, set the desktop client to use the "hw:dummy" audio device, to not update, to not make "events", etc etc... Make and receive a couple of test calls. Please note that you (and the remote party) will hear nothing (you're using the snd-dummy "fake" audio driver), that's ok. -3) on the desktop machine, when satisfied of the Skype client setup, use skypopen_auth (that simulates FS-skypopen connecting to the Skype client). The Skype client will ask you to be authorized to let "skypopen" connect. -4) Give the authorization and check the "not ask me again" option. -5) Close (Quit) the Skype client from the tray icon, so it saves its config. -6) Then, relaunch the Skype client and use skypopen_auth again, just to be sure it now succeed. -7) Close (Quit) the Skype client from the tray icon, so it saves its config. - -*** Do the steps 1-7 for all Skype usernames you will want to use on the server (eg: one Skype username per channel) - -When finished with all the Skype usernames: -Copy or targzip the .Skype directory and all its content on the home directory of the server user that will launch the Skype client(s). - -############################ -first time you use skypopen_auth -############################ -$ ./skypopen_auth -Skype instance found with id #27263062 -RECEIVED==> ERROR 68 -RECEIVED==> OK - -############################ -Give the auth to the Skype client, and tell him not to ask again -Then Ctrl-C to exit from skypopen_auth -############################ - - -Close (Quit) the Skype client from the tray icon, so it saves its config. -Then, relaunch the Skype client - -############################ -you use skypopen_auth again -############################ -$ ./skypopen_auth -Skype instance found with id #27263062 -RECEIVED==> OK -RECEIVED==> PROTOCOL 6 -RECEIVED==> CONNSTATUS ONLINE -RECEIVED==> CURRENTUSERHANDLE gmaruzz3 -RECEIVED==> USERSTATUS INVISIBLE - - diff --git a/src/mod/endpoints/mod_skypopen/configs/old-stuff/copy b/src/mod/endpoints/mod_skypopen/configs/old-stuff/copy deleted file mode 100644 index 59400bf1ff..0000000000 --- a/src/mod/endpoints/mod_skypopen/configs/old-stuff/copy +++ /dev/null @@ -1,39 +0,0 @@ -cp -a skypopen101/* skypopen102/ -cp -a skypopen101/* skypopen103/ -cp -a skypopen101/* skypopen104/ -cp -a skypopen101/* skypopen105/ -cp -a skypopen101/* skypopen106/ -cp -a skypopen101/* skypopen107/ -cp -a skypopen101/* skypopen108/ -cp -a skypopen101/* skypopen109/ -cp -a skypopen101/* skypopen110/ -cp -a skypopen101/* skypopen111/ -cp -a skypopen101/* skypopen112/ -cp -a skypopen101/* skypopen113/ -cp -a skypopen101/* skypopen114/ -cp -a skypopen101/* skypopen115/ -cp -a skypopen101/* skypopen116/ -cp -a skypopen101/* skypopen117/ -cp -a skypopen101/* skypopen118/ -cp -a skypopen101/* skypopen119/ -cp -a skypopen101/* skypopen120/ -cp -a skypopen101/* skypopen121/ -cp -a skypopen101/* skypopen122/ -cp -a skypopen101/* skypopen123/ -cp -a skypopen101/* skypopen124/ -cp -a skypopen101/* skypopen125/ -cp -a skypopen101/* skypopen126/ -cp -a skypopen101/* skypopen127/ -cp -a skypopen101/* skypopen128/ -cp -a skypopen101/* skypopen129/ -cp -a skypopen101/* skypopen130/ -cp -a skypopen101/* skypopen131/ -cp -a skypopen101/* skypopen132/ -cp -a skypopen101/* skypopen133/ -cp -a skypopen101/* skypopen134/ -cp -a skypopen101/* skypopen135/ -cp -a skypopen101/* skypopen136/ -cp -a skypopen101/* skypopen137/ -cp -a skypopen101/* skypopen138/ -cp -a skypopen101/* skypopen139/ -cp -a skypopen101/* skypopen140/ diff --git a/src/mod/endpoints/mod_skypopen/configs/old-stuff/create b/src/mod/endpoints/mod_skypopen/configs/old-stuff/create deleted file mode 100644 index fd2c9e0229..0000000000 --- a/src/mod/endpoints/mod_skypopen/configs/old-stuff/create +++ /dev/null @@ -1,40 +0,0 @@ -mkdir skypopen101 -mkdir skypopen102 -mkdir skypopen103 -mkdir skypopen104 -mkdir skypopen105 -mkdir skypopen106 -mkdir skypopen107 -mkdir skypopen108 -mkdir skypopen109 -mkdir skypopen110 -mkdir skypopen111 -mkdir skypopen112 -mkdir skypopen113 -mkdir skypopen114 -mkdir skypopen115 -mkdir skypopen116 -mkdir skypopen117 -mkdir skypopen118 -mkdir skypopen119 -mkdir skypopen120 -mkdir skypopen121 -mkdir skypopen122 -mkdir skypopen123 -mkdir skypopen124 -mkdir skypopen125 -mkdir skypopen126 -mkdir skypopen127 -mkdir skypopen128 -mkdir skypopen129 -mkdir skypopen130 -mkdir skypopen131 -mkdir skypopen132 -mkdir skypopen133 -mkdir skypopen134 -mkdir skypopen135 -mkdir skypopen136 -mkdir skypopen137 -mkdir skypopen138 -mkdir skypopen139 -mkdir skypopen140 diff --git a/src/mod/endpoints/mod_skypopen/configs/old-stuff/multiple-instance-same-skype-username/README b/src/mod/endpoints/mod_skypopen/configs/old-stuff/multiple-instance-same-skype-username/README deleted file mode 100644 index 3de4125e12..0000000000 --- a/src/mod/endpoints/mod_skypopen/configs/old-stuff/multiple-instance-same-skype-username/README +++ /dev/null @@ -1,4 +0,0 @@ -# just execute the file - -sh ./multi.sh - diff --git a/src/mod/endpoints/mod_skypopen/configs/old-stuff/multiple-instance-same-skype-username/multi.sh b/src/mod/endpoints/mod_skypopen/configs/old-stuff/multiple-instance-same-skype-username/multi.sh deleted file mode 100755 index 792e330a44..0000000000 --- a/src/mod/endpoints/mod_skypopen/configs/old-stuff/multiple-instance-same-skype-username/multi.sh +++ /dev/null @@ -1,152 +0,0 @@ -#!/bin/bash -# remember to add here the removing of all the installed snd-* modules, so you're sure only the snd-dummy driver will be around -rmmod snd_hda_intel -rmmod snd-dummy # enable=1,1,1 - -# you need three dummy soundcard for 20 Skype client instances, because each dummy soundcard can handle a max of 8 Skype instances -# the enable= module parameter tells how many cards to start. For each additional card, add a comma and a 1 -# manually configure the first 8 Skype client instances to use the hw:Dummy_0, the next 8 instances to use hw:Dummy_1, etc for all three devices (Play, Capture, Ring) -modprobe snd-dummy -#modprobe snd-aloop enable=1,1,1 -sleep 3 - -#start the fake X server on a given port - /usr/bin/Xvfb :101 -screen 0 800x600x16 -nolisten tcp -ac & -sleep 3 - -# start a Skype client instance that will connect to the X server above, and will login to the Skype network using the 'username password' you send to it on stdin. Here passwd5 would be the password and user5 the username -su root -c "/bin/echo 'user5 passwd5'| DISPLAY=:101 /usr/bin/skype --dbpath=/root/multi/skypopen101 --pipelogin &" - - -sleep 7 - - - /usr/bin/Xvfb :102 -screen 0 800x600x16 -nolisten tcp -ac & -sleep 3 - -su root -c "/bin/echo 'user5 passwd5'| DISPLAY=:102 /usr/bin/skype --dbpath=/root/multi/skypopen102 --pipelogin &" - -sleep 7 - -exit 0 - -################################################################# -# Following X server and Skype client instances are commented out -################################################################# - /usr/bin/Xvfb :103 -screen 0 800x600x16 -nolisten tcp -ac & -sleep 3 - -su root -c "/bin/echo 'user5 passwd5'| DISPLAY=:103 /usr/bin/skype --dbpath=/root/multi/skypopen103 --pipelogin &" - -sleep 7 - /usr/bin/Xvfb :104 -screen 0 800x600x16 -nolisten tcp -ac & -sleep 3 - -su root -c "/bin/echo 'user5 passwd5'| DISPLAY=:104 /usr/bin/skype --dbpath=/root/multi/skypopen104 --pipelogin &" - -sleep 7 - /usr/bin/Xvfb :105 -screen 0 800x600x16 -nolisten tcp -ac & -sleep 3 - -su root -c "/bin/echo 'user5 passwd5'| DISPLAY=:105 /usr/bin/skype --dbpath=/root/multi/skypopen105 --pipelogin &" - -sleep 7 - /usr/bin/Xvfb :106 -screen 0 800x600x16 -nolisten tcp -ac & -sleep 3 - -su root -c "/bin/echo 'user5 passwd5'| DISPLAY=:106 /usr/bin/skype --dbpath=/root/multi/skypopen106 --pipelogin &" - - -sleep 7 - /usr/bin/Xvfb :107 -screen 0 800x600x16 -nolisten tcp -ac & -sleep 3 - -su root -c "/bin/echo 'user5 passwd5'| DISPLAY=:107 /usr/bin/skype --dbpath=/root/multi/skypopen107 --pipelogin &" - -sleep 7 - /usr/bin/Xvfb :108 -screen 0 800x600x16 -nolisten tcp -ac & -sleep 3 - -su root -c "/bin/echo 'user5 passwd5'| DISPLAY=:108 /usr/bin/skype --dbpath=/root/multi/skypopen108 --pipelogin &" - -sleep 7 - - - /usr/bin/Xvfb :109 -screen 0 800x600x16 -nolisten tcp -ac & -sleep 3 - -su root -c "/bin/echo 'user5 passwd5'| DISPLAY=:109 /usr/bin/skype --dbpath=/root/multi/skypopen109 --pipelogin &" - -sleep 7 - /usr/bin/Xvfb :110 -screen 0 800x600x16 -nolisten tcp -ac & -sleep 3 - -su root -c "/bin/echo 'user5 passwd5'| DISPLAY=:110 /usr/bin/skype --dbpath=/root/multi/skypopen110 --pipelogin &" - -sleep 7 - - - /usr/bin/Xvfb :111 -screen 0 800x600x16 -nolisten tcp -ac & -sleep 3 - -su root -c "/bin/echo 'user5 passwd5'| DISPLAY=:111 /usr/bin/skype --dbpath=/root/multi/skypopen111 --pipelogin &" - -sleep 7 - /usr/bin/Xvfb :112 -screen 0 800x600x16 -nolisten tcp -ac & -sleep 3 - -su root -c "/bin/echo 'user5 passwd5'| DISPLAY=:112 /usr/bin/skype --dbpath=/root/multi/skypopen112 --pipelogin &" - -sleep 7 - /usr/bin/Xvfb :113 -screen 0 800x600x16 -nolisten tcp -ac & -sleep 3 - -su root -c "/bin/echo 'user5 passwd5'| DISPLAY=:113 /usr/bin/skype --dbpath=/root/multi/skypopen113 --pipelogin &" - -sleep 7 - /usr/bin/Xvfb :114 -screen 0 800x600x16 -nolisten tcp -ac & -sleep 3 - -su root -c "/bin/echo 'user5 passwd5'| DISPLAY=:114 /usr/bin/skype --dbpath=/root/multi/skypopen114 --pipelogin &" - -sleep 7 - /usr/bin/Xvfb :115 -screen 0 800x600x16 -nolisten tcp -ac & -sleep 3 - -su root -c "/bin/echo 'user5 passwd5'| DISPLAY=:115 /usr/bin/skype --dbpath=/root/multi/skypopen115 --pipelogin &" - -sleep 7 - /usr/bin/Xvfb :116 -screen 0 800x600x16 -nolisten tcp -ac & -sleep 3 - -su root -c "/bin/echo 'user5 passwd5'| DISPLAY=:116 /usr/bin/skype --dbpath=/root/multi/skypopen116 --pipelogin &" - -sleep 7 - - - /usr/bin/Xvfb :117 -screen 0 800x600x16 -nolisten tcp -ac & -sleep 3 - -su root -c "/bin/echo 'user5 passwd5'| DISPLAY=:117 /usr/bin/skype --dbpath=/root/multi/skypopen117 --pipelogin &" - -sleep 7 - /usr/bin/Xvfb :118 -screen 0 800x600x16 -nolisten tcp -ac & -sleep 3 - -su root -c "/bin/echo 'user5 passwd5'| DISPLAY=:118 /usr/bin/skype --dbpath=/root/multi/skypopen118 --pipelogin &" - -sleep 7 - /usr/bin/Xvfb :119 -screen 0 800x600x16 -nolisten tcp -ac & -sleep 3 - -su root -c "/bin/echo 'user5 passwd5'| DISPLAY=:119 /usr/bin/skype --dbpath=/root/multi/skypopen119 --pipelogin &" - -sleep 7 - /usr/bin/Xvfb :120 -screen 0 800x600x16 -nolisten tcp -ac & -sleep 3 - -su root -c "/bin/echo 'user5 passwd5'| DISPLAY=:120 /usr/bin/skype --dbpath=/root/multi/skypopen120 --pipelogin &" - -sleep 7 - -exit 0 diff --git a/src/mod/endpoints/mod_skypopen/configs/old-stuff/multiple-instance-same-skype-username/skypopen.conf.xml b/src/mod/endpoints/mod_skypopen/configs/old-stuff/multiple-instance-same-skype-username/skypopen.conf.xml deleted file mode 100644 index 037a26255b..0000000000 --- a/src/mod/endpoints/mod_skypopen/configs/old-stuff/multiple-instance-same-skype-username/skypopen.conf.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/mod/endpoints/mod_skypopen/configs/old-stuff/skypopen_auth.c b/src/mod/endpoints/mod_skypopen/configs/old-stuff/skypopen_auth.c deleted file mode 100644 index f886834fe0..0000000000 --- a/src/mod/endpoints/mod_skypopen/configs/old-stuff/skypopen_auth.c +++ /dev/null @@ -1,219 +0,0 @@ -//gcc -Wall -ggdb skypopen_auth.c -o skypopen_auth -lX11 -#include -#include -#include -#include -#include - -struct SkypopenHandles { - Window skype_win; - Display *disp; - Window win; - int api_connected; - int fdesc[2]; -}; - -XErrorHandler old_handler = 0; -int xerror = 0; -char *dispname; - -int X11_errors_handler(Display * dpy, XErrorEvent * err) -{ - (void) dpy; - - xerror = err->error_code; - printf("\n\nReceived error code %d from X Server on display '%s'\n\n", xerror, dispname); - 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 skypopen_send_message(struct SkypopenHandles *SkypopenHandles, const char *message_P) -{ - - Window w_P; - Display *disp; - Window handle_P; - int ok; - - w_P = SkypopenHandles->skype_win; - disp = SkypopenHandles->disp; - handle_P = SkypopenHandles->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; - - 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(); - 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); - ok = X11_errors_untrap(); - - if (!ok) - printf("Sending message failed with status %d\n", xerror); - - return 1; -} - -int skypopen_present(struct SkypopenHandles *SkypopenHandles) -{ - Atom skype_inst = XInternAtom(SkypopenHandles->disp, "_SKYPE_INSTANCE", True); - - Atom type_ret; - int format_ret; - unsigned long nitems_ret; - unsigned long bytes_after_ret; - unsigned char *prop; - int status; - - X11_errors_trap(); - status = - XGetWindowProperty(SkypopenHandles->disp, DefaultRootWindow(SkypopenHandles->disp), - skype_inst, 0, 1, False, XA_WINDOW, &type_ret, &format_ret, &nitems_ret, &bytes_after_ret, &prop); - - X11_errors_untrap(); - /* sanity check */ - if (status != Success || format_ret != 32 || nitems_ret != 1) { - SkypopenHandles->skype_win = (Window) - 1; - printf("Skype instance not found on display '%s'\n", dispname); - return 0; - } - - SkypopenHandles->skype_win = *(const unsigned long *) prop & 0xffffffff; - printf("Skype instance found on display '%s', with id #%d\n", dispname, (unsigned int) SkypopenHandles->skype_win); - return 1; -} - -void skypopen_clean_disp(void *data) -{ - - int *dispptr; - int disp; - - dispptr = data; - disp = *dispptr; - - if (disp) { - close(disp); - } else { - } - usleep(1000); -} - -int main(int argc, char *argv[]) -{ - - struct SkypopenHandles SkypopenHandles; - char buf[512]; - Display *disp = NULL; - Window root = -1; - Window win = -1; - - if (argc == 2) - dispname = argv[1]; - else - dispname = ":0.0"; - - disp = XOpenDisplay(dispname); - if (!disp) { - printf("Cannot open X Display '%s', exiting\n", dispname); - return -1; - } - - int xfd; - xfd = XConnectionNumber(disp); - - SkypopenHandles.disp = disp; - - if (skypopen_present(&SkypopenHandles)) { - root = DefaultRootWindow(disp); - win = XCreateSimpleWindow(disp, root, 0, 0, 1, 1, 0, BlackPixel(disp, DefaultScreen(disp)), BlackPixel(disp, DefaultScreen(disp))); - - SkypopenHandles.win = win; - - snprintf(buf, 512, "NAME skypopen"); - - if (!skypopen_send_message(&SkypopenHandles, buf)) { - printf("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch skypopen_auth again\n"); - return -1; - } - - snprintf(buf, 512, "PROTOCOL 6"); - if (!skypopen_send_message(&SkypopenHandles, buf)) { - printf("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch skypopen_auth again\n"); - return -1; - } - - /* 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'; - - strcat(buffer, buf); - - if (i < 20) { /* last fragment */ - unsigned int howmany; - - howmany = strlen(b) + 1; - - printf("RECEIVED==> %s\n", b); - memset(buffer, '\0', 17000); - } - - break; - default: - break; - } - } - } else { - printf("Skype client not found on display '%s'. Please run/restart Skype manually and launch skypopen_auth again\n\n\n", dispname); - return -1; - } - return 0; - -} diff --git a/src/mod/endpoints/mod_skypopen/configs/old-stuff/startskype.sh b/src/mod/endpoints/mod_skypopen/configs/old-stuff/startskype.sh deleted file mode 100755 index 8e030ec2f3..0000000000 --- a/src/mod/endpoints/mod_skypopen/configs/old-stuff/startskype.sh +++ /dev/null @@ -1,143 +0,0 @@ -# remember to add here the removing of all the installed snd-* modules, so you're sure only the snd-dummy driver will be around -rmmod snd_hda_intel -rmmod snd-dummy - -# if you DO NOT USE the custom ALSA device we provide, you need three "standard" dummy soundcard for 20 Skype client instances, because each "standard" dummy soundcard can handle a max of 8 Skype instances -# the enable= module parameter tells how many cards to start. For each additional card, add a comma and a 1 -# manually configure the first 8 Skype client instances to use the hw:Dummy_0, the next 8 instances to use hw:Dummy_1, etc for all three devices (Play, Capture, Ring) -modprobe snd-dummy # enable=1,1,1 -sleep 3 - -#start the fake X server on a given port - /usr/bin/Xvfb :101 -ac & -sleep 3 - -# start a Skype client instance that will connect to the X server above, and will login to the Skype network using the 'username password' you send to it on stdin. Here xxxx would be the password and user1 the username -su root -c "/bin/echo 'user1 xxxx'| DISPLAY=:101 /usr/bin/skype --pipelogin &" - - -sleep 7 - - - /usr/bin/Xvfb :102 -ac & -sleep 3 - -su root -c "/bin/echo 'user2 xxxx'| DISPLAY=:102 /usr/bin/skype --pipelogin &" - -sleep 7 - -exit 0 - -################################################################################## -# Following X server and Skype client instances are NOT LAUNCHED (see line before) -################################################################################## - - /usr/bin/Xvfb :103 -ac & -sleep 3 - -su root -c "/bin/echo 'user3 xxxx'| DISPLAY=:103 /usr/bin/skype --pipelogin &" - -sleep 7 - /usr/bin/Xvfb :104 -ac & -sleep 3 - -su root -c "/bin/echo 'user4 xxxx'| DISPLAY=:104 /usr/bin/skype --pipelogin &" - -sleep 7 - /usr/bin/Xvfb :105 -ac & -sleep 3 - -su root -c "/bin/echo 'user5 xxxx'| DISPLAY=:105 /usr/bin/skype --pipelogin &" - -sleep 7 - /usr/bin/Xvfb :106 -ac & -sleep 3 - -su root -c "/bin/echo 'user6 xxxx'| DISPLAY=:106 /usr/bin/skype --pipelogin &" - -sleep 7 - /usr/bin/Xvfb :107 -ac & -sleep 3 - -su root -c "/bin/echo 'user7 xxxx'| DISPLAY=:107 /usr/bin/skype --pipelogin &" - -sleep 7 - /usr/bin/Xvfb :108 -ac & -sleep 3 - -su root -c "/bin/echo 'user8 xxxx'| DISPLAY=:108 /usr/bin/skype --pipelogin &" - -sleep 7 - /usr/bin/Xvfb :109 -ac & -sleep 3 - -su root -c "/bin/echo 'user9 xxxx'| DISPLAY=:109 /usr/bin/skype --pipelogin &" - -sleep 7 - /usr/bin/Xvfb :110 -ac & -sleep 3 - -su root -c "/bin/echo 'user10 xxxx'| DISPLAY=:110 /usr/bin/skype --pipelogin &" - -sleep 7 - /usr/bin/Xvfb :111 -ac & -sleep 3 - -su root -c "/bin/echo 'user11 xxxx'| DISPLAY=:111 /usr/bin/skype --pipelogin &" - -sleep 7 - /usr/bin/Xvfb :112 -ac & -sleep 3 - -su root -c "/bin/echo 'user12 xxxx'| DISPLAY=:112 /usr/bin/skype --pipelogin &" - -sleep 7 - /usr/bin/Xvfb :113 -ac & -sleep 3 - -su root -c "/bin/echo 'user13 xxxx'| DISPLAY=:113 /usr/bin/skype --pipelogin &" - -sleep 7 - /usr/bin/Xvfb :114 -ac & -sleep 3 - -su root -c "/bin/echo 'user14 xxxx'| DISPLAY=:114 /usr/bin/skype --pipelogin &" - -sleep 7 - /usr/bin/Xvfb :115 -ac & -sleep 3 - -su root -c "/bin/echo 'user15 xxxx'| DISPLAY=:115 /usr/bin/skype --pipelogin &" - -sleep 7 - /usr/bin/Xvfb :116 -ac & -sleep 3 - -su root -c "/bin/echo 'user16 xxxx'| DISPLAY=:116 /usr/bin/skype --pipelogin &" - -sleep 7 - /usr/bin/Xvfb :117 -ac & -sleep 3 - -su root -c "/bin/echo 'user17 xxxx'| DISPLAY=:117 /usr/bin/skype --pipelogin &" - -sleep 7 - /usr/bin/Xvfb :118 -ac & -sleep 3 - -su root -c "/bin/echo 'user18 xxxx'| DISPLAY=:118 /usr/bin/skype --pipelogin &" - -sleep 7 - /usr/bin/Xvfb :119 -ac & -sleep 3 - -su root -c "/bin/echo 'user19 xxxx'| DISPLAY=:119 /usr/bin/skype --pipelogin &" - -sleep 7 - /usr/bin/Xvfb :120 -ac & -sleep 3 - -su root -c "/bin/echo 'user20 xxxx'| DISPLAY=:120 /usr/bin/skype --pipelogin &" - -sleep 7 - diff --git a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/shared.lck b/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/shared.lck deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/shared.xml b/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/shared.xml deleted file mode 100644 index 4b72e67eb5..0000000000 --- a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/shared.xml +++ /dev/null @@ -1,99 +0,0 @@ - - - - - <_2>00001000A563932E7DE5A581942041A820F8437512A079C7ACB1B73281F191D109521E265BCD38C4133596B834AD9AA1D6BB5E1AC3D59E8675785321F722D39FBFAFB9A24E6482FA3030FFA3692D2C4A53BBCE9DC63F25D10207A20FA969982FEDC1DCC2A7C599071F4735E52AB2E06E34CA232C08B3AA2FB88A0C4A5763E0CD23C3AA37D1D2A7D6EED691EE99BA08BE294F68C24F9AE777DAF294F0AEB8346325A978DC6CF7C210AD11EF3F38111F6D98F388CF41CCBA40ABE9F0D6CBBD3118BA0588344953DF3C5E88B2CCAEDE2E692F320D20EBF16D7DB36156E617C0CC9FB2855D7FDB4C7F8638CC9830E7448D5EAE301A2810277062989841EE679E00E4E277615FEC038DE3A0A20DD7C6A2A00DFBC6A2A00DA6E2B6F404FDC6A2A00DFEC6A2A00DF7FBBB990CF2C6A2A00D8EB4FE8A0C8FB4FE8A0C95C7A6E00CF5FBBB990CD6C7A6E00CD0F896950CCCE2B6F40485CCA2A00DA1D8EEA50DFDFBBB990CA7C7A6E00CA8C7A6E00CA9C7A6E00C97C7A6E00C90B4FE8A0CFE90D59308C290D59308D1E2B6F404C5E2B6F404C6AAF18705C7AAF18705C8AAF18705BBD8EEA50DBCD8EEA50DBDD8EEA50D93CCA2A00D94CCA2A00DEFE2B6F40491B4FE8A0CE2FBBB990CE3FBBB990CBED8EEA50DA0CCA2A00DA1CCA2A00DA6B4FE8A0CA7B4FE8A0CCED8EEA50DA3CCA2A00DA4CCA2A00D84E698AD0DB8C7A6E00CD9E2B6F404E0E2B6F40486E698AD0DFDF896950C0013A60400173D0018DE0200190300AB01F40300449875044518C15F9A278109D4BBAC4E8109D408A6238109D5A63304810904460CC15F9A26303ED408A624303E0047B054004801004980A305004A80E90F004BE0A801004C80A305004D01005CAC02045E5A50FC55465BA050FC55475BA050FC55485BA0C32EFDEE5BA0C32EFDEF5BA0C2A5BC4A5BA0C2A5BC4B5BA0D4BBAC055BA0D4BBAC145BA0D4BBAC215BA0D408A3575BA0D408A37D5BA0D408A37E5BA08275487E5BA0827548425BA00060B817046506CC09A3D6303E04AE018C0125F8D500021A25F9D500011A162102200301220125FFD50025FAD5000C03E4000D2580D6000F060125F8D5000302172105050103080D06010501011C210302060125FCD50025F9D5000A25FDD50025FED5000A0D06020502050119211305020380808080100C05010D0380808080100B25FDD5000C01080005000380808080100D060307010503220101220104AC01BF012597CE002597CE002590CE0019152590CE002597CE000B033C1815210220030122012593CE0014212E2594CE002103030B220125A5CE00030F172103030B22012596CE00142103030B22012597CE00142103030B22012599CE00142103030A220125A5CE00030A1A2590CE002592CE000B031E1B15142103030A220125A4CE000380201D14210303092201259BCE0014210A2594CE002103030B2201259DCE00142103030822012593CE002103012201259ECE001421030306220103022201006800006901006A01006C987504740CC2A5BC4C303ED408A34C303E007828047912CC09A3D3303E82754864303E4E8DB16F303E047DBF010203020800050003020D0B0601030308000500020501030508000500021A03060800050003041A16030508000500021D160C0A0C060203D00F251205020A03020D0A050103D00F0C0A0603010800050003FFFFFFFF0F18030208000500021D141506042512020800050003030D05040C10030205040B0C06050306050505020A0C060603040800050003050800050003E400180C0607050703E400250A0B250A011C0C0A0314100608050303C03E0F03B8171005060388270F03DC0B100508047E5E0380010304080005000B03040D250403E4000F03140D0A2503250203030D0A0B0110060101080005000380020D0302080005000380020D172103010601250A03E4001B210D0501030A03E400250A210303DF002002250A0B0D0F0601050100800180EA49008101E003036F3139352E34362E3235332E3235333A313233353000038201706F6F6C313D2A2E6C6976657461622E736B7970653B706F6F6C323D7765622E6578747261732E736B7970653B706F6F6C333D6578747261732E646F776E6C6F6164732E736B7970653B706F6F6C343D2A2E736B79706566696E642E736B7970653B706F6F6C353D2A2E7072656D69756D2E736B7970653B706F6F6C363D2A2E6D756C74696D656469612E736B7970653B706F6F6C373D2A2E6D756C74696D656469612E6D657461636166653B706F6F6C383D2A2E6D756C74696D656469612E6461696C796D6F74696F6E3B706F6F6C393D2A2E6D756C74696D656469612E6D6574616F6D6E69747572653B706F6F6C31303D77686174736E65772E736B7970653B706F6F6C31313D7061792E736B7970653B706F6F6C31323D7365637572652E7061792E736B7970653B706F6F6C31333D2A2E70696373746F72653B706F6F6C31343D2A2E6D796163636F756E742E736B7970653B706F6F6C31353D2A2E62696269743B706F6F6C31363D2A2E70726F6363796265723B706F6F6C31373D747261636B696E672E6F6D6E69747572653B706F6F6C31383D676F2E736B7970653B706F6F6C31393D747261636B2E736B7970657C706F6F6C313D3139342E3139322E3139392E3235313A31323335303B706F6F6C323D3139342E3139322E3139392E3235323A31323335303B706F6F6C333D3139342E3139322E3139392E3235323A31323335303B706F6F6C343D3139342E3136352E3138382E3130313A31323335303B706F6F6C353D3139332E39352E3135342E31353A31323335313B706F6F6C363D3139342E3136352E3138382E3130303A31323335303B706F6F6C373D3139342E3136352E3138382E3130303A31323335303B706F6F6C383D3139342E3136352E3138382E3130303A31323335303B706F6F6C393D3139342E3136352E3138382E3130303A31323335303B706F6F6C31303D3230342E392E3136332E3134313A31323335303B706F6F6C31313D3139352E34362E3235332E3234353A31323335303B706F6F6C31323D3139352E34362E3235332E3234353A31323335303B706F6F6C31333D3139332E39352E3135342E31343A31323335313B706F6F6C31343D3139332E39352E3135342E31343A31323335313B706F6F6C31353D3139332E39352E3135342E31343A31323335313B706F6F6C31363D3139332E39352E3135342E31343A31323335313B706F6F6C31373D3139342E3136352E3138382E3130303A31323335303B706F6F6C31383D3139342E3136352E3138382E3130303A31323335303B706F6F6C31393D3139332E39352E3135342E31343A31323335310003B101706F6F6C313D2A2E6C6976657461622E736B7970653B706F6F6C323D7765622E6578747261732E736B797065206578747261732E646F776E6C6F6164732E736B7970653B706F6F6C333D2A2E687773746F72652E736B7970653B706F6F6C343D2A2E736B79706566696E642E736B797065202A2E6469726563746F72792E736B7970653B706F6F6C353D2A2E70696373746F7265202A2E6D796163636F756E742E736B797065202A2E6269626974202A2E70726F63637962657220747261636B2E736B79706520617070732E736B7970656173736574733B706F6F6C363D2A2E6D756C74696D656469612E736B797065202A2E6D756C74696D656469612E6D65746163616665202A2E6D756C74696D656469612E6461696C796D6F74696F6E202A2E6D756C74696D656469612E6D6574616F6D6E6974757265207777772E736B7970652077686174736E65772E736B7970653B706F6F6C373D7061792E736B797065207365637572652E7061792E736B7970653B706F6F6C383D6170692E736B7970653B706F6F6C393D63616C6C70686F6E65732E736B7970652063616C6C72617465732E736B7970653B706F6F6C31303D2A2E7072656D69756D2E736B7970653B706F6F6C31323D6C6F67732E736B7970653B706F6F6C31333D617661746172736572766963652E736B79706520636F6E74616374696D706F72742E736B7970653B706F6F6C31343D676F2E736B7970653B706F6F6C31353D747261636B696E672E6F6D6E69747572657C706F6F6C313D3139342E3139322E3139392E3235312C31323335302C312C4E4C2C77652C35302C313B706F6F6C323D3139342E3139322E3139392E3235322C31323335302C312C444B2C77652C35302C313B706F6F6C333D3139332E39352E3135342E31372C31323335312C312C49452C77652C35302C31203231322E3138372E3137322E36322C31323335312C312C49452C77652C35302C31203139352E34362E3235332E3232372C31323335312C312C4C552C77652C35302C31203231322E382E3136362E33332C31323335312C312C4C552C77652C35302C313B706F6F6C343D3139342E3136352E3138382E3130312C31323335302C312C49452C77652C35302C313B706F6F6C353D3139332E39352E3135342E31342C31323335312C312C49452C77652C35302C31203139352E34362E3235332E3230352C31323335312C312C4C552C77652C35302C31203231322E3138372E3137322E35392C31323335312C312C49452C77652C35302C31203231322E382E3136362E31392C31323335312C312C4C552C77652C35302C313B706F6F6C363D3139342E3136352E3138382E3130302C31323335302C312C49452C77652C35302C31203230342E392E3136332E3134302C31323335302C312C43412C6E612C35302C313B706F6F6C373D3139352E34362E3235332E3234352C31323335302C312C4C552C77652C35302C31203139332E39352E3135342E31362C31323335312C312C49452C77652C35302C31203231322E3138372E3137322E36312C31323335312C312C49452C77652C35302C31203231322E382E3136362E32302C31323335302C312C4C552C77652C35302C313B706F6F6C383D3230342E392E3136332E3138342C31323335302C312C43412C6E612C35302C312037382E3134312E3137372E38392C31323335302C312C4C552C77652C35302C313B706F6F6C393D3139342E3136352E3138382E3131352C31323335302C312C49452C77652C35302C31203230342E392E3136332E3134312C31323335302C312C43412C6E612C35302C313B706F6F6C31303D3139332E39352E3135342E31352C31323335312C312C49452C77652C35302C31203231322E3138372E3137322E36302C31323335312C312C49452C77652C35302C31203139352E34362E3235332E3232362C31323335312C312C4C552C77652C35302C31203231322E382E3136362E33322C31323335312C312C4C552C77652C35302C313B706F6F6C31323D37382E3134312E3137372E37362C31323335302C312C4C552C77652C35302C313B706F6F6C31333D3230342E392E3136332E3136372C31323335302C312C43412C6E612C35302C312037382E3134312E3137372E38312C31323335302C312C4C552C77652C35302C313B706F6F6C31343D3230342E392E3136332E3136382C31323335302C312C43412C6E612C35302C31203139342E3136352E3138382E3130302C31323335302C312C49452C77652C35302C313B706F6F6C31353D3230342E392E3136332E3136392C31323335302C312C43412C6E612C35302C31203139342E3136352E3138382E3130302C31323335302C312C49452C77652C35302C3100039701736B79706566696E642E736B7970653D31372C362C382C2D33392C3139206469726563746F72792E736B7970653D31372C362C382C2D33392C31390003A60138302E3235322E38352E37302C32333435362C312C6E6C2C77652C35302C312038302E3235322E38352E37312C32333435362C312C6E6C2C77652C35302C312038302E3235322E38352E37322C32333435362C312C6E6C2C77652C35302C31203139352E34362E3235332E3233382C32333435362C322C6C752C77652C35302C31203139352E34362E3235332E3233392C32333435362C322C6C752C77652C35302C31203139342E3136352E3138382E37342C32333435362C332C69652C77652C35302C31203139342E3136352E3138382E37352C32333435362C332C69652C77652C35302C31203231322E3138372E3137322E352C32333435362C342C69652C77652C35302C31203231322E3138372E3137322E32302C32333435362C342C69652C77652C35302C31203231322E3138372E3137322E33332C32333435362C342C69652C77652C35302C31203231322E382E3136332E38372C32333435362C362C6C752C77652C35302C31203231322E382E3136332E3132352C32333435362C362C6C752C77652C35302C31203231322E382E3136332E3132362C32333435362C362C6C752C77652C35302C31203133302E3131372E37322E3132362C32333435362C372C6E6C2C77652C35302C31203133302E3131372E37322E36362C32333435362C372C6E6C2C77652C35302C310004B2010B03A09C0125B3EA010B220104A5012A24A39C012102220025A19C010401F3C2011A142103030A220125B0EA0103051A2103030B2201030522010384012B39393030303131313A37382E3134312E3137372E39363A3233343536000086010C008701880E039101000493010CC2A5BC5C2774C32EFDD927740496010CD592BC1034504E8DB5F2345006C20105F801F901FA01FB01FC010395016272617465303D31206272617465313D31206272617465323D31206272617465333D31206272617465343D31206272617465353D31206272617465363D31206272617465373D31206272617465383D31207372617465303D31207372617465313D31207372617465323D31207372617465333D31207372617465343D31207372617465353D31207372617465363D31207372617465373D31207372617465383D310003B4013139342E3136352E3138382E37373A3132333530203231322E382E3136332E3130333A31323335300000C0010100C1010103CB012E6163636573732E736B7970652E6E65740000E1010F00F0010100F101A982CA950303D50137382E3134312E3137372E33383A3132333530203230342E392E3136332E3135313A31323335300003CF0137382E3134312E3137372E36393A3132333530203230342E392E3136332E3134393A31323335300000D6010103E4013139342E3136352E3138382E38303A3132333530203231322E382E3136362E353A31323335300003E5010000F8016403F7015B574845453A204F4646203130302C20563120302C20563220305D205B496E70757445513A204F46462035302C2056312035305D205B4945513A204F46462031362C2056312031322C2056322031322C2056332031322C2056342031322C2056352031322C2056362031322C2056372031325D205B53453A204453203130302C2057494F20305D205B5345323A2044532039302C2057494F2031305D205B414D504D3A204F4C442035302C20444147432035305D205B4B54523A204F46462035302C204F4E2035305D205B49414D323A204F46462039392C204D3120312C204D3220305D0003FA0152434F4E3D350003F901302F342E322E2A2E2A2C33322C3320302F352E302E2A2E2A2C31342C3320302F352E312E2A2E3130342C342C330003A80168747470733A2F2F7777775C2E70617970616C5C2E2E3F2E3F2E3F247C68747470733A2F2F696D616765735C2E70617970616C5C2E636F6D247C68747470733A2F2F7777775C2E70617970616C6F626A656374735C2E636F6D247C68747470733F3A2F2F2E2B5C2E666263646E5C2E6E6574247C68747470733F3A2F2F2E2B5C2E66616365626F6F6B5C2E636F6D247C68747470733F3A2F2F6368616E6E656C5C2E736B7970655C2E636F6D247C68747470733A2F2F617070735C2E736B7970655C2E636F6D247C68747470733F3A2F2F7161617070735C2E736B7970655C2E6E6574247C68747470733F3A2F2F636F6E6E6563745C2E66616365626F6F6B5C2E6E6574247C68747470733A2F2F2E2A5C2E736B7970656173736574735C2E636F6D247C68747470733A2F2F61645C2E646F75626C65636C69636B5C2E6E6574247C68747470733A2F2F61642D656D65615C2E646F75626C65636C69636B5C2E6E6574247C68747470733A2F2F61642D617061635C2E646F75626C65636C69636B5C2E6E6574247C68747470733A2F2F737461746963323F5C2E736B7970655C2E636F6D247C68747470733A2F2F7161737461746963323F5C2E736B7970655C2E6E6574247C68747470733A2F2F7072657374617469635C2E736B7970655C2E6E6574240003FF013078313030303230343030393136333231372D642D723230342E392E3136332E3231373A38313932203078313030303230343030393136333231392D642D723230342E392E3136332E3231393A38313932203078313030303230343030393136333232312D642D723230342E392E3136332E3232313A38313932203078313030303230343030393136333232332D642D723230342E392E3136332E3232333A38313932203078313030303230343030393136333232352D642D723230342E392E3136332E3232353A38313932203078313030303230343030393136333232372D642D723230342E392E3136332E3232373A38313932203078313030303230383038383138363030352D642D723230382E38382E3138362E353A38313932203078313030303230383038383138363030372D642D723230382E38382E3138362E373A38313932203078313030303230383038383138363030392D642D723230382E38382E3138362E393A38313932203078313030303230383038383138363031312D642D723230382E38382E3138362E31313A38313932203078313030303230383038383138363031332D642D723230382E38382E3138362E31333A38313932203078313030303230383038383138363031352D642D723230382E38382E3138362E31353A38313932203078313030303230383038383138363031372D642D723230382E38382E3138362E31373A38313932203078313030303230383038383138363031392D642D723230382E38382E3138362E31393A38313932203078313030303230383038383138363032312D642D723230382E38382E3138362E32313A38313932203078313030303230383038383138363032332D642D723230382E38382E3138362E32333A38313932203078313030303230383038383138363032352D642D723230382E38382E3138362E32353A38313932203078313030303230383038383138363032372D642D723230382E38382E3138362E32373A38313932203078313030303230383038383138363032392D642D723230382E38382E3138362E32393A38313932203078313030303230383038383138363033312D642D723230382E38382E3138362E33313A38313932203078313030303230383038383138363033332D642D723230382E38382E3138362E33333A38313932203078313030303230383038383138363033352D642D723230382E38382E3138362E33353A38313932203078313030303230383038383138363033372D642D723230382E38382E3138362E33373A38313932203078313030303230383038383138363033392D642D723230382E38382E3138362E33393A38313932203078313030303230383038383138363034372D642D723230382E38382E3138362E34373A38313932203078313030303230383038383138363034392D642D723230382E38382E3138362E34393A38313932203078313030303230383038383138363035312D642D723230382E38382E3138362E35313A38313932203078313030303230383038383138363035332D642D723230382E38382E3138362E35333A38313932203078313030303230383038383138363035352D642D723230382E38382E3138362E35353A38313932203078313030303230383038383138363035372D642D723230382E38382E3138362E35373A38313932203078313030303230383038383138363035392D642D723230382E38382E3138362E35393A38313932203078313030303230383038383138363036312D642D723230382E38382E3138362E36313A38313932203078313030303230383038383138363036332D642D723230382E38382E3138362E36333A38313932203078313030303230383038383138363035392D642D723230382E38382E3138362E36353A38313932203078313030303230383038383138363036312D642D723230382E38382E3138362E36373A38313932203078313030303230383038383138363036332D642D723230382E38382E3138362E36393A38313932203078313030303230383038383138363037312D642D723230382E38382E3138362E37313A38313932203078313030303230383038383138363037332D642D723230382E38382E3138362E37333A38313932203078313030303230383038383138363037352D642D723230382E38382E3138362E37353A38313932203078313030303230383038383138363037372D642D723230382E38382E3138362E37373A38313932203078313030303230383038383138363037392D642D723230382E38382E3138362E37393A38313932203078313030303230383038383138363038312D642D723230382E38382E3138362E38313A38313932203078313030303230383038383138363038332D642D723230382E38382E3138362E38333A38313932203078313030303230383038383138363038352D642D723230382E38382E3138362E38353A38313932203078313030303230383038383138363038372D642D723230382E38382E3138362E38373A38313932203078313030303230383038383138363038392D642D723230382E38382E3138362E38393A38313932203078313030303230383038383138363039312D642D723230382E38382E3138362E39313A38313932203078313030303230383038383138363039332D642D723230382E38382E3138362E39333A38313932203078313030303230383038383138363039352D642D723230382E38382E3138362E39353A38313932203078313030303230383038383138363039372D642D723230382E38382E3138362E39373A38313932203078313030303230383038383138363039392D642D723230382E38382E3138362E39393A38313932203078313030303230383038383138363130312D642D723230382E38382E3138362E3130313A38313932203078313030303230383038383138363130332D642D723230382E38382E3138362E3130333A38313932203078313030303230383038383138363130352D642D723230382E38382E3138362E3130353A38313932203078313030303230383038383138363130372D642D723230382E38382E3138362E3130373A38313932203078313030303230383038383138363130392D642D723230382E38382E3138362E3130393A38313932203078313030303230383038383138363131312D642D723230382E38382E3138362E3131313A38313932203078313030303230383038383138363131332D642D723230382E38382E3138362E3131333A38313932203078313030303230383038383138363131352D642D723230382E38382E3138362E3131353A38313932203078313030303230383038383138363131372D642D723230382E38382E3138362E3131373A38313932203078323030303134393030353034353031312D642D723134392E352E34352E31313A38313932203078323030303134393030353034353031332D642D723134392E352E34352E31333A38313932203078323030303134393030353034353031352D642D723134392E352E34352E31353A38313932203078323030303134393030353034353031372D642D723134392E352E34352E31373A38313932203078323030303134393030353034353031392D642D723134392E352E34352E31393A38313932203078323030303134393030353034353032312D642D723134392E352E34352E32313A38313932203078323030303134393030353034353032332D642D723134392E352E34352E32333A38313932203078323030303134393030353034353032352D642D723134392E352E34352E32353A38313932203078323030303134393030353034353032372D642D723134392E352E34352E32373A38313932203078323030303134393030353034353032392D642D723134392E352E34352E32393A38313932203078323030303134393030353034353033312D642D723134392E352E34352E33313A38313932203078323030303134393030353034353033332D642D723134392E352E34352E33333A38313932203078323030303134393030353034353033352D642D723134392E352E34352E33353A38313932203078323030303134393030353034353033372D642D723134392E352E34352E33373A38313932203078323030303134393030353034353033392D642D723134392E352E34352E33393A38313932203078323030303134393030353034353034312D642D723134392E352E34352E34313A38313932203078323030303134393030353034353034332D642D723134392E352E34352E34333A38313932203078323030303134393030353034353034352D642D723134392E352E34352E34353A38313932203078323030303134393030353034353034372D642D723134392E352E34352E34373A38313932203078323030303134393030353034353034392D642D723134392E352E34352E34393A38313932203078323030303134393030353034353035312D642D723134392E352E34352E35313A38313932203078323030303134393030353034353035332D642D723134392E352E34352E35333A38313932203078323030303134393030353034353035352D642D723134392E352E34352E35353A38313932203078323030303134393030353034353035372D642D723134392E352E34352E35373A38313932203078323030303134393030353034353035392D642D723134392E352E34352E35393A38313932203078323030303134393030353034353036312D642D723134392E352E34352E36313A38313932203078323030303134393030353034353036332D642D723134392E352E34352E36333A38313932203078323030303134393030353034353036352D642D723134392E352E34352E36353A38313932203078323030303134393030353034353036372D642D723134392E352E34352E36373A38313932203078323030303134393030353034353036392D642D723134392E352E34352E36393A38313932203078323030303134393030353034353037312D642D723134392E352E34352E37313A38313932203078323030303134393030353034353037332D642D723134392E352E34352E37333A38313932203078323030303134393030353034353037352D642D723134392E352E34352E37353A38313932203078323030303134393030353034353037372D642D723134392E352E34352E37373A38313932203078323030303134393030353034353037392D642D723134392E352E34352E37393A38313932203078323030303134393030353034353038312D642D723134392E352E34352E38313A38313932203078323030303134393030353034353038332D642D723134392E352E34352E38333A38313932203078323030303134393030353034353038352D642D723134392E352E34352E38353A38313932203078323030303134393030353034353038372D642D723134392E352E34352E38373A38313932203078323030303134393030353034353038392D642D723134392E352E34352E38393A38313932203078323030303134393030353034353039312D642D723134392E352E34352E39313A38313932203078323030303134393030353034353039332D642D723134392E352E34352E39333A38313932203078323030303134393030353034353039352D642D723134392E352E34352E39353A38313932203078323030303134393030353034353039372D642D723134392E352E34352E39373A38313932203078323030303134393030353034353039392D642D723134392E352E34352E39393A38313932203078323030303134393030353034353130312D642D723134392E352E34352E3130313A38313932203078323030303134393030353034353130332D642D723134392E352E34352E3130333A38313932203078323030303134393030353034353130352D642D723134392E352E34352E3130353A38313932203078323030303134393030353034353130372D642D723134392E352E34352E3130373A38313932203078323030303134393030353034353130392D642D723134392E352E34352E3130393A38313932203078323030303134393030353034353131312D642D723134392E352E34352E3131313A38313932203078323030303134393030353034353131332D642D723134392E352E34352E3131333A38313932203078323030303134393030353034353131352D642D723134392E352E34352E3131353A38313932203078323030303134393030353034353131372D642D723134392E352E34352E3131373A38313932203078323030303134393030353034353131392D642D723134392E352E34352E3131393A38313932203078323030303134393030353034353132312D642D723134392E352E34352E3132313A38313932203078323030303134393030353034353132332D642D723134392E352E34352E3132333A38313932203078323030303134393030353034353132352D642D723134392E352E34352E3132353A38313932203078323030303134393030353034353132372D642D723134392E352E34352E3132373A38313932203078323030303134393030353034353132392D642D723134392E352E34352E3132393A38313932000089020A062E19AEBFD5A40B80D4B6B30280D2AFF205808CFD910B80DEB9F1048FA486F4049CA486F404D5A486F404ACC686F404C2C686F404878F87F404CEB887F404ADC487F404BCC687F404D4D087F404F9EA87F4049CF587F404C8F487F404C9F487F404CAF487F404EACCBB9C05F7CCBB9C05E694D7BB058E96D7BB05A896D7BB050094023C0095021400930201039902536B79706520546563686E6F6C6F6769657320534100008E0200008F0280BAB70300910280A30503F2013231332E3134362E3138392E3230313A3132333530203231332E3134362E3138392E3230323A3132333530203231332E3134362E3138392E3230333A3132333530203231332E3134362E3138392E3230343A3132333530203231332E3134362E3138392E3230353A3132333530203231332E3134362E3138392E3230363A3132333530203231322E3136312E382E31303A3132333530203231322E3136312E382E323A3132333530203231322E3136312E382E333A3132333530203231322E3136312E382E343A3132333530203231322E3136312E382E353A3132333530203231322E3136312E382E363A31323335300000FC010106FD0106011E64AC02A403E807009002C20103C301687474703A2F2F37392E3132352E36332E3732247C68747470733F3A2F2F2E2B5C2E66616365626F6F6B5C2E636F6D240000DE0148 - <_256>000010011AC0AA3BA66DF7FB48228AE35F9BB4A032FE4A6A898DA7A1A5AE37DC59FB3D09607F1CACD46A5DBC008DABF8F09C797DF5A8903307D04C318825CEA7C481303C655A9EEE099E9A0AF1158373B458BB8FDACB336A6EC63C043E6782688E2350B417DDDDFF96B474DAEA7D1DF3742303B79111FC752BFB5D6887A5B822F945CC761FAF6E80DE5EC60868768CB8A9F9C876137806DCEA0DD1300181558ABFDBA26592078F5F84195C526D8C7F339EF82700FD93F8FB71ADA5ED3E977D27FA52D1F489EF5DA0A9E00B146BADCBDEBFB0DFEBCD61E5B8352A49893357E0DC3A736743929DA975782EA4D8184605FD064641986C47706D264281C876F926BF58003E9E - <_3>0000100498ECF8A7A4585F76C930739A1EAE590DE96D9EF3AA9B231E67965F3F08ECFC493E1DA23ECDE17A85C94CBE034E88F9414E9BBC82F32AAFCFFB2C09F6F57A478238BAEC9EEF2BB9C67F71257722E6786D88D6400F6B7D81450FB3B6CCCC3986E3782D2387E354EBA9099331AEF510D479C6601D2383D866E2B5B525DF0BA975D58C120EFAE88C89EE365FC696CC891B77F67CFA18FDE8E95DDAC25A7C7D70FA7A1414BAE593856A658888C622836006C1C131B4B2E805554DCFA52F3EFD34C1B759BF8A302E491835DCE701E84D37ED150C8ADD699AD3DCA9F515123C5B5AD94E253E173BA3465E64A0079D5EF4E6075E66D0F5FBC3D9BC25C4E80C4CB2FE9B87040003000004D00F0005D00F050041040400B80125C20003141B14230025D50003031B14230024E100142300250003191714230025EA0003141714230025EA00011724EA00140A14230025E400030F1C14230025FC00011A24FF000A14230025FF00011A142300258001011A14230025E10025E10003A006100A0309031725000325180C0A25C20003140B0C03040D0A03882725C3000C0A03E43225C4000C0A0602050228038407DC08FA1E0601050102050203FA1E1C0603250028061D1E1F202122060105010205010503050141060300636F756E74206279207175616C697479000001CC080002040003000004010005010501410603006261647175616C69747920636F756E742062792076657273696F6E000001D6080002070003000004010005010501410603006261647175616C6974792073756D2062792076657273696F6E000001E0080002070003000004010005010500410304005424E400142300250003191714230025EA0003141714230025EA00011724EA00140A14230025FC00011A24FF000A14230025FF00011A142300258001011A14230025E40025E40028043CB401D804901C060105010205014106030073756D206F66206C61737463616C6C206475726174696F6E73000001B009000201000300000480A3050005B054050141060300636F756E74206279206C61737463616C6C206475726174696F6E000001BA090002050003000004010005010500410204005025EB00011C142300250003191714230025EA0003141714230025EA00011724EA00140A14230025FC00011A24FF000A14230025FF00011A142300258001011A14230025EB0028031E32D0000601050102050141060300636F756E742062792073797374656D20637075207573616765000001940A0002040003000004010005010500410204004F25EC00011C142300250003191714230025EA0003141714230025EA00011724EA00140A14230025FC00011A24FF000A14230025FF00011A142300258001011A14230025EC0028030F1E320601050102050141060300636F756E742062792070726F63657373206370752075736167650000019E0A0002040003000004010005010500410304006824C20014230024E60014230025E600011A14230025EC00011C142300250003191714230025EA0003141714230025EA00011724EA00140A14230025FC00011A24FF000A14230025FF00011A142300258001011A14230025EC0028030F1E320601050102050125C2000501410603006A6974746572636F756E742062792070726F6365737320637075207573616765000001F80A0002040003000004010005010501410603006A69747465722062792070726F6365737320637075207573616765000001820B0002040003000004D00F0005D00F0500410304004424E700142300250003191714230025EA0003141714230025EA00011724EA00140A14230025FC00011A24FF000A14230025FF00011A142300258001011A1423000225E700050141060300706F74656E7469616C207463702066616C6C6261636B73000001DC0B00020100030000040100050105014106030061637475616C207463702066616C6C6261636B73000001E60B00020100030000040100050105004103040056240C142300250C030A1814230025EA0003141714230025EA00011724EA00140A14230024E70014230025E700011A14230024E50014230025E500011C0602250C29050306070809280401020405060105010205010502050141060300636F756E74206279206E617474797065000001C00C0002050003000004010005010501410603007564706661696C75726573206279206E617474797065000001CA0C0002050003000004010005010500410204001B25D90014230025D90025DA000B0602050228030102040601050102050141060300636F756E74206279206E726F666D756C74696368617473000001A40D0002040003000004010005010500410304001425F700011C14230025000319171423000225F90005014106030075736572732077686F206861766520636F6D706C65746564204943000001880E0002010003000004010005010501410603006C617374204943207969656C6420676C6F62616C73756D000001920E0002010003000004E8070005500500410304001224F60014230025000319171423000225F60005014106030075736572732077686F206861766520494320737570706F7274000001EC0E0002010003000004010005010501410603004943207374617274757020636F756E7420676C6F62616C73756D000001F60E00020100030000046400051405004102040025240C142300250C030A18142300250C011C142300250C280802030405060708090601050102050141060300636F756E74206279206E617474797065000001D00F0002090003000004010005010500410404001A250003191714230025E20025E30025FC00280201020601050102050141060300766964656F2073656E642063617061626C650000019811000201000300000401000501050141060300766964656F20706172616C6C656C2063616C6C730000019911000201000300000414000502050141060300636F756E7420627920766964656F2063616C6C73206D616465000001A2110002030003000004010005010500410204003A250003191714230025EA0003141714230025EA00011724EA00140A14230024E50014230025E50003031914230025E50028030102030601050102050141060300636F756E742062792073747265616D7472616E73706F7274000001FC11000204000300000401000501050041090400E00125C20003141B25E400030F1C1514230024E100142300250003191714230025EA0003141725EA0001171514230025FF002580010A011A14230025E60003031A25E50003031A1514230024F5001423002412142300249F0114230025C30025E10025E10003A006100A03A0060B0309031725000325180C0A25C20003140B0C03040D0A2512030A0C251025F5001703CC080C0A1C160602020502250003231B241D150603050305020503150503251D03808080808080808080011D14150603050305020503150503251D038080808080808080C0011D1415060305030502050315050141060300706F74656E7469616C2052555F756E65787065637465645F62616471000001E01200020100030000040100050105014106030061637475616C2052555F756E65787065637465645F62616471000001EA1200020100030000040100050105014106030042435020706F74656E7469616C2052555F756E65787065637465645F62616471000001F4120002010003000004010005010501410603004243502061637475616C2052555F756E65787065637465645F62616471000001FE12000201000300000401000501050141060300424350203220706F74656E7469616C2052555F756E65787065637465645F62616471000001881300020100030000040100050105014106030042435020322061637475616C2052555F756E65787065637465645F626164710000019213000201000300000401000501050141060300424350203420706F74656E7469616C2052555F756E65787065637465645F626164710000019C130002010003000004010005010501410603004243502031362061637475616C2052555F756E65787065637465645F62616471000001A6130002010003000004010005010500410304000825B801011C25B701050141060300757365727320696E207075626C6963206368617473000001C4130002010003000004010005010501410603007075626C69632063686174206D6573736167657320696E206C617374206D696E757465000001CE1300020100030000046400050A0500410404005F248E0114230024D5001423002500032B1B1423002500032B1C250D03021C16250E03FFFFFFFF0F1D03B4E2C8F10217250E0380808080100D03B4E2C8F10217151614230025D500280219C80106010501020501258E010501258E0103880E1C050141060300636F756E742062792062756464696573000001A814000203000300000401000501050141060300617661696C6162696C697479206167652062792062756464696573000001B2140002030003000004C0FC150005A099020501410603006C6F6E6720617661696C6162696C697479206167652062792062756464696573000001BC140002030003000004010005010500410204003324C000142300250003191714230025F301290300E5C68583B7AEDE36F2CAB9A3A7AE983806020502280202030601050125C00005014106030073696D756C74616E656F75732063616C6C7320706572206E616D6573706163650000018C15000203000300000419000519050041020400C50125C00006020502142300250006030503031917142300050303231B06040504210302200225A1010605050421030502200225A2010606030606070505021A050503021A160506021A15210305072002010607050203021B050603021B152103050720020206070502021A050603021B15210305072002030206070502021A050503041A15210305072002030306070502021A050503031A15210305072002030406070502021A050503051A152103050720020305060705072806010203040506060105010205014106030063616C6C6572733A207332735F313120636F6E665F686F737420636F6E665F636C69656E7420736B7970656F757420736B797065696E20766F6963656D61696C20756E6B6E6F776E000001F015000207000300000401000501 - <_4>000010052A0B6759B71FBC1EF05BE97DFEA4EE6C1E15AF19ED70DEC1130B14C13CE41246D302B9662592907E3CA508A57702B5C00C2A05170857FA22012E0F235B425B4D919B23A541D3AD6E948FC634DE71A29493634884DFD5E9D89C5D951CBCD71B9B3ABFD3C4E2779BB1817D76E7C223CA36BD75A6A05B730AF138057E4048B2FFDD522BB588EC0B9D3E014BF9E354EB608150BC613C739D9E8C7465F05F047FAF7AFA3EE89B9B58BF0FC35F07B55CF3E4B59A7C4ED48B1C0C7F0305E6AC2E80AAEAD6064EB6ACDC1806FCE0B5CB66F0840DA7F0FE7B228E3898E3E42A9AFEFE13DDF019EF8D8F02A631AF2615BBC6E1EDB65C89A775F642C88109E6247EC4B463DC302E2A2E323000050541020006020307322E302E2A2E3100050541030006020307322E302E2A2E3200000AE4ED8009050541030006020307322E302E2A2E33000009B3E6CC990B050541040006020307322E302E2A2E3400000AE4ED8009000BA00B050541030006020308322E302E2A2E35000307322E302E2A2E3900050541040006020308322E302E2A2E39000307322E302E2A2E313100000AE4ED8009050541040006020308322E302E2A2E3131000307322E302E2A2E3135000009E6CC99B306050541050006020308322E302E2A2E3135000307322E302E2A2E323000000AE4ED8009000BA00B050041050303557067726164655465737433000301332E302E302E3130300003044E6963654272616E6400050541040006020307332E302E302E2A0003074E6963654272616E6400000AE4ED8009050541040006020307322E302E302E2A0003074E6963654272616E6400000AE4ED80090500410E0303557067726164655465737433000301332E302E302E31303000050541040006020307332E302E302E39390003074F746865724272616E6400000AE4ED8009050541040006020307322E302E302E39390003074F746865724272616E6400000AE4ED8009050541040006020307332E302E302E39380003074F746865724272616E64000009B3E6CC990B050541040006020307322E302E302E39380003074F746865724272616E64000009B3E6CC990B050541050006020307332E302E302E39370003074F746865724272616E6400000AE4ED8009000BA00B050541050006020307322E302E302E39370003074F746865724272616E6400000AE4ED8009000BA00B050541030006020307332E302E302E393900000AE4ED8009050541030006020307322E302E302E393900000AE4ED8009050541030006020307332E302E302E3938000009B3E6CC990B050541030006020307322E302E302E3938000009B3E6CC990B050541040006020307332E302E302E393700000AE4ED8009000BA00B050541040006020307322E302E302E393700000AE4ED8009000BA00B0500410303033130303031000301302E302E302E313000050541020006020307302E302E302E3900 - <_5>00001006739CA527EF827847E16F23CD52458C3EBA3460A42935EC6948BEFA626B49E3BDF279FC62486E2DDBCA19609ED23D31F4E5175920F282AD74A74A997C3909E67B622480C68A058E886C7D5F3C40954880D7798CD61CEA0FBAFB389BE5B2B8A887348F7AADB4DF642B194B814047CDA0E698EDDE61DFA731DCA5883A76F913D8C94066718054E85ADA7AE009F2B2A9AF762FDCB9B6CAF64C156911E3AB172CFD795F66FB6E8E15048A54E4AB17979D6C447DEBADE75CC6F606050D980061112AFF9AE7C7BF8065D711949E41FA4C8B6CBF0916BB395B3E186A7D617D353C6BFFC687FE79475DFA095D113D70B828FB597BC3665B7C9C3669CA9CBE5D308D3FC23803044E45544745415200050541020006040307302E392E302E2A000500410503033130303033000301312E302E302E3137000304534D4300050541020006040307302E392E302E313200050541020006020307302E392E302E3230000500410503033130303033000301312E312E302E313000030442454C4B494E00050541020006040307302E392E302E313200050541020006020307302E392E302E3230000500410503033130303033000301312E302E302E3137000304454447452D434F524500050541020006040307302E392E302E313200050541020006020307302E392E302E3230000500410503033130303033000301312E302E302E31330003044C4F474954454300050541020006040307302E392E302E313200050541020006020307302E392E302E3230000500410503033130303035000301312E342E38382E31333636000304544F50434F4D00050541020006040307312E342E38382E3133353600050541020006020307312E342E38382E31333635000500410503033130303035000301312E342E38382E313336360003045043484F4D4500050541020006040307312E342E38382E3133353600050541020006020307312E342E38382E31333635000500410403033130303036000301302E302E302E313000050541020006040307302E302E302E3500050541020006020307302E302E302E39000500410503033130303037000301312E302E312E330003045445434F00050541020006040307312E302E302E3800050541020006020307312E302E312E31000500410503033130303038000301302E392E332E3339370003044C494E4B53595300050541020006040307302E382E332E2A00050541020006020307302E392E332E333932000500410503033130303038000301302E392E332E3339370003044E45544745415200050541020006040307302E382E332E2A00050541020006020307302E392E332E333932000500410503033130303038000301302E392E332E3339370003045048494C49505300050541020006040307302E382E332E2A00050541020006020307302E392E332E333932000500410403033130303130000301302E392E302E31310003044C494E4B53595300050541020006040307302E392E302E3130000500410403033130303130000301302E392E302E313100030442554646414C4F00050541020006040307302E392E302E3130000500410503033130303132000301312E302E302E310003044353544E00050541020006040307302E302E302E3500050541020006020307302E302E302E39000500410503033130303133000301302E302E332E3234000304414B00050541020006040307302E302E312E323400050541020006020307302E302E322E3234000500410303033130303134000301312E372E34332E33382E3200050541020006040307312E372E32332E32372E34000500410503033130303135000301312E322E31372E30000304415A5445434800050541020006040307312E322E31312E3000050541020006020307312E322E31352E30000500410303033130303230000301312E302E302E343700050541030006020308312E302E302E3233000307312E302E302E3233000500410403033130303234000301332E322E302E323800050541030006040308332E302E302E35000307332E302E302E3500050541030006020308332E312E302E31000307332E322E302E38000500410503033130303232000301302E302E302E3900030450414E41534F4E494300050541020006040307302E302E302E3100050541020006020307302E302E302E38000500410503033130303232000301302E302E302E3900030450414E41534F4E4943434F4E53554D455200050541020006040307302E302E302E3100050541020006020307302E302E302E3800 - - 1 - - 400 - - - - 8118 - 39,64,8184 - 37,50,13164 - - 1 - - 1 - - - -1431699456 - -1431699456 - 1610612735 - - 41C801050041050200D9AF0D45D9E900010400028788BCED0400038788BCED04000400050041050200BB0AB3FDD1A40001040002B7DCBCED040003B7DCBCED040004000500410502005C3766C2DA6B00010400029FB2BCED0400039FB2BCED04000400050041050200D9F8DC20CA33000104000296DAAAED04000396DAAAED0400040005004105020063847B3765900001040002D794BDED040003D794BDED040004000500410502004E80142FD3C70001040002CF86BDED040003CF86BDED04000400050041050200C3B213EA24A50001040002BF89BBED040003BF89BBED040004000500410502006FFEF1BA804C0001040002CF86BDED040003CF86BDED0400040005004105020052ED923CB3A700010400028788BCED0400038788BCED040004000500410502005243330D305B000104000283FFB2ED04000383FFB2ED040004000500410502006FF9438E9E5D0001040002CF86BDED040003CF86BDED04000400050041050200585515F19D77000104000283FFB2ED04000383FFB2ED04000400050041050200729EE3A8DD460001040002CF86BDED040003CF86BDED040004000500410502004572795D3BB300010400029FB2BCED0400039FB2BCED040004000500410502009F94D72CABA40001040002CF86BDED040003CF86BDED0400040005004105020095052D9C81090001040002B7DCBCED040003B7DCBCED040004000500410502005859A15FD7FC0001040002DC8FB5ED040003DC8FB5ED0400040005004105020059D7AB3EBBFB0001020002F8FABCED040003CF86BDED04000400050041050200BB2481B9390E0001040002CF86BDED040003CF86BDED0400040005004105020059D7F395A7BA0001040002B7DCBCED040003B7DCBCED040004000500410502006DC4BEF5D52E0001040002B0DFBAED040003B0DFBAED040004000500410502004B6E709CF4290001040002B7DCBCED040003B7DCBCED040004000500410502007A7D5CEC2B8D0001040002CF86BDED040003CF86BDED040004000500410502006FFFA8AFB19D0001040002B7DCBCED040003B7DCBCED040004000500410502003E4475A07A6F0001040002B7DCBCED040003B7DCBCED040004000500410502003EDD8384A4F90001040002BF89BBED040003BF89BBED04000400050041050200560FBFA4E4900001040002B7DCBCED040003B7DCBCED04000400050041050200C24FAEEE43F10001040002B3CEB5ED040003B3CEB5ED040004000500410502004F378778C6F30001040002CF86BDED040003CF86BDED04000400050041050200C94418BB0EDF0001040002B7DCBCED040003B7DCBCED040004000500410502003B75A58BECB30001040002CF86BDED040003CF86BDED04000400050041050200772A7A0908890001040002CF86BDED040003CF86BDED0400040005004105020048BB63586DE100010400029088BCED0400039088BCED040004000500410502005544F881BEDA000104000283FFB2ED04000383FFB2ED040004000500410502005B4C1468EDF80001040002B7DCBCED040003B7DCBCED04000400050041050200538BAF3F934F0001040002B3CEB5ED040003B3CEB5ED0400040005004105020055D6F93A4FD70001040002D7B3BBED040003D7B3BBED04000400050041050200D5D64561E55F00010400028788BCED0400038788BCED0400040005004105020046ADF229B8570001040002CF86BDED040003CF86BDED04000400050041050200D5151C19FFD600010200029FB2BCED040003B7DCBCED04000400050041050200973CA35DB82400010400029FB2BCED0400039FB2BCED04000400050041050200C249E5B953700001040002CF86BDED040003CF86BDED04000400050041050200722C69D8C4F500010400029FB2BCED0400039FB2BCED0400040005004105020058CBB311F2400001040002DC8FB5ED040003DC8FB5ED040004000500410502004BB7A090766E0001040002CF86BDED040003CF86BDED040004000500410502007DEF80FBEBD90001040002EFDDBBED040003EFDDBBED0400040005004105020076A03698F87A0001040002CF86BDED040003CF86BDED0400040005004105020050E5DFDD0C700001040002CF86BDED040003CF86BDED040004000500410502004D4C85E0CEC80001040002CF86BDED040003CF86BDED040004000500410502006FEA6BCD92A10001020002F8FABCED040003CF86BDED0400040005004105020043BAA930F28600010400029FB2BCED0400039FB2BCED04000400050041050200722DB82DDB780001040002CF86BDED040003CF86BDED0400040005004105020052E995118B9F0001040002CF86BDED040003CF86BDED040004000500410502005403013B36D20001040002EFDDBBED040003EFDDBBED04000400050041050200B27C0C920B260001040002B7DCBCED040003B7DCBCED04000400050041050200D9AF0997A7450001040002BCD9AAED040003BCD9AAED04000400050041050200BC00130BB5F60001040002CF86BDED040003CF86BDED04000400050041050200591FF23B53830001040002CF86BDED040003CF86BDED04000400050041050200557EB01367590001040002CF86BDED040003CF86BDED04000400050041050200505F157093A2000102000297A4BCED04000397A4BCED040004000500410502003A036C495C670001040002CF86BDED040003CF86BDED0400040005004105020050D8CF0B7D480001040002B7DCBCED040003B7DCBCED040004000500410502004E34E4D0FF250001040002B7DCBCED040003B7DCBCED040004000500410502007A1E50A46E770001040002CF86BDED040003CF86BDED040004000500410502005F18C666CBB80001040002EFDDBBED040003EFDDBBED04000400050041050200C19335603A9E0001040002DC8FB5ED040003DC8FB5ED0400040005004105020097142BD7DF890001040002AFDFBAED040003AFDFBAED0400040005004105020052F3355FFED400010400029FB2BCED0400039FB2BCED04000400050041050200BCBA857EECDF0001040002D7B3BBED040003D7B3BBED04000400050041050200729259D605EF0001040002CF86BDED040003CF86BDED04000400050041050200BEC2F57655B300010400029FB2BCED0400039FB2BCED040004000500410502005BD905C8304B0001020002A8EEBBED0400038788BCED0400040005004105020055F2C0360F360001040002EFDDBBED040003EFDDBBED0400040005004105020082C01DB9605D00010400028788BCED0400038788BCED04000400050041050200BC73B8FB30360001040002CF86BDED040003CF86BDED0400040005004105020050390E32DF8B0001040002B0DFBAED040003B0DFBAED040004000500410502005BCE8A2D7B8000010400028788BCED0400038788BCED0400040005004105020042292BB45D2D0001040002CF86BDED040003CF86BDED040004000500410502004F1A354DCA9A00010400029FB2BCED0400039FB2BCED04000400050041050200591C1D7F0EC900010400028788BCED0400038788BCED04000400050041050200722E9D2CCB030001040002CF86BDED040003CF86BDED04000400050041050200443AB71D3F8A0001040002CF86BDED040003CF86BDED0400040005004105020018DEF34EB70600010400028788BCED0400038788BCED0400040005004105020097215860080F00010400029FB2BCED0400039FB2BCED040004000500410502007229C156A49E0001040002B7DCBCED040003B7DCBCED040004000500410502003A72EDECB0250001040002B3F7B4ED040003B3F7B4ED04000400050041050200D52F8CD18F640001040002E285B0ED040003E285B0ED040004000500410502006B0325208B4C0001040002EFDDBBED040003EFDDBBED040004000500410502005164424285660001040002938AB5ED040003938AB5ED04000400050041050200D4E9D6AB12F80001040002AFDFBAED040003AFDFBAED0400040005004105020059B3090F459C0001040002FCDDAAED040003FCDDAAED04000400050041050200BC10C41E7AAB0001040002CF86BDED040003CF86BDED040004000500410502009F9532B560C100010400028788BCED0400038788BCED0400040005004105020050EA7B4A63750001040002CF86BDED040003CF86BDED0400040005004105020045A658245E790001040002CF86BDED040003CF86BDED0400040005004105020047E3059299620001040002CF86BDED040003CF86BDED0400040005004105020081164AFC3B450001040002CF86BDED040003CF86BDED040004000500410502005703C3FC60FF00010400028788BCED0400038788BCED0400040005004105020063FAEB02F39300010400028788BCED0400038788BCED040004000500410502005714F2D9F6650001020002AFDFBAED040003ECE7BAED04000400050041050200505F1B22B00D0001040002CF86BDED040003CF86BDED0400040005004105020062C2F2A80C7900010400029FB2BCED0400039FB2BCED04000400050041050200425CA6CCD1FF0001040002CF86BDED040003CF86BDED0400040005004105020084C778D4AB110001040002CF86BDED040003CF86BDED040004000500410502005106437CD3B60001040002CF86BDED040003CF86BDED0400040005004105020058506B2B47D40001040002D7B3BBED040003D7B3BBED04000400050041050200DD70204563390001040002B7DCBCED040003B7DCBCED040004000500410502005CFFA5BE4A0000010200028888BCED040003F8FABCED0400040005004105020089BD8692E0400001040002B7DCBCED040003B7DCBCED040004000500410502004AC12BB2AB8D0001040002B7DCBCED040003B7DCBCED04000400050041050200DB555CBAEE6B0001040002CF86BDED040003CF86BDED0400040005004105020095052D8F81090001020002A7FDBCED040003CF86BDED04000400050041050200473AA0E1C9110001020002A7FDBCED040003CF86BDED040004000500410502004EFA971D2E4C0001040002B7DCBCED040003B7DCBCED04000400050041050200BCE6C5A829D900010400029E90B5ED0400039E90B5ED0400040005004105020051699F18DC540001040002D7B3BBED040003D7B3BBED040004000500410502005CFB85D7E6460001040002B3CEB5ED040003B3CEB5ED0400040005004105020052D17CE5A9840001040002BF89BBED040003BF89BBED0400040005004105020054DD54C818F20001040002CF86BDED040003CF86BDED040004000500410502005C3555EBDC670001040002B7DCBCED040003B7DCBCED0400040005004105020051D92EE554370001040002BF89BBED040003BF89BBED0400040005004105020095549556182D0001040002CF86BDED040003CF86BDED040004000500410502005419C1F7F52A0001040002B3CEB5ED040003B3CEB5ED040004000500410502008C7259638E1D0001040002B7DCBCED040003B7DCBCED04000400050041050200516745231C2200010400029FB2BCED0400039FB2BCED0400040005004105020055FB3DEAE2380001040002B7DCBCED040003B7DCBCED040004000500410502005D5470BCB83A00010400028788BCED0400038788BCED0400040005004105020054C6D511E6810001040002CF86BDED040003CF86BDED0400040005004105020062A7FAC0119000010200028788BCED0400038888BCED040004000500410502007225A1DCFB1A00010200028788BCED0400038888BCED04000400050041050200708B358CF15C00010400028788BCED0400038788BCED04000400050041050200D9A293C3FE550001040002AFDFBAED040003AFDFBAED04000400050041050200722119BAFCB600010400029FB2BCED0400039FB2BCED0400040005004105020054369C95EAC60001040002CF86BDED040003CF86BDED04000400050041050200AE74419813810001040002B7DCBCED040003B7DCBCED0400040005004105020048C613BC68510001040002EFDDBBED040003EFDDBBED04000400050041050200516E168D638B0001040002EFDDBBED040003EFDDBBED040004000500410502001819CFB484D20001040002CF86BDED040003CF86BDED04000400050041050200ADE013B3E9F10001040002CF86BDED040003CF86BDED040004000500410502005C708ABFAC890001040002B3CEB5ED040003B3CEB5ED04000400050041050200BC81882E891C0001040002B7DCBCED040003B7DCBCED0400040005004105020057785543EB480001040002CF86BDED040003CF86BDED040004000500410502006FF0CE6CB4500001040002CF86BDED040003CF86BDED040004000500410502005CE13B7199D4000102000283ADE7E304000383ADE7E30400040005004105020063F610137D170001040002B7DCBCED040003B7DCBCED04000400050041050200DC887BC89E210001040002CF86BDED040003CF86BDED040004000500410502005D9324151E7F0001020002A7FDBCED040003CF86BDED04000400050041050200BC02D363924D00010400029FB2BCED0400039FB2BCED040004000500410502004F28848E1AC50001040002CF86BDED040003CF86BDED0400040005004105020054C606DD0D260001040002D984B5ED040003D984B5ED04000400050041050200D5F586558C850001040002BF89BBED040003BF89BBED0400040005004105020082582B0468CF00010400028788BCED0400038788BCED040004000500410502005CE21BB9BD7C00010400029FB2BCED0400039FB2BCED0400040005004105020059A9ACE3BC02000104000296DAAAED04000396DAAAED040004000500410502005557DB28EDA300010400028788BCED0400038788BCED0400040005004105020076ABA00FF52C0001040002CF86BDED040003CF86BDED0400040005004105020052185C5CB8440001040002B7DCBCED040003B7DCBCED04000400050041050200441402A770A800010200028788BCED0400038888BCED04000400050041050200516623CC99760001040002CF86BDED040003CF86BDED040004000500410502005A3D6D867C2A0001040002BF89BBED040003BF89BBED04000400050041050200BC70864FCE530001040002B3F7B4ED040003B3F7B4ED040004000500410502005E9C9B4E7A740001040002CF86BDED040003CF86BDED0400040005004105020058ABF63F0EA70001040002FCDDAAED040003FCDDAAED040004000500410502005556BDBE86AC000104000286FFB2ED04000386FFB2ED0400040005004105020059D0D49C9B8000010400028788BCED0400038788BCED0400040005004105020059A934952E920001040002B3F7B4ED040003B3F7B4ED040004000500410502007220ABEC82C80001040002B7DCBCED040003B7DCBCED04000400050041050200807AB45544310001040002BF89BBED040003BF89BBED04000400050041050200187A8DFCCDCF0001040002BF89BBED040003BF89BBED04000400050041050200616B5C35801000010400028788BCED0400038788BCED040004000500410502005ABCE5EAE3790001040002938AB5ED040003938AB5ED0400040005004105020048DF5F3311D10001020002F8FABCED040003CF86BDED04000400050041050200D3146B24D6340001040002CF86BDED040003CF86BDED0400040005004105020059037023AC7D00010400029FB2BCED0400039FB2BCED040004000500410502003EDD92C929340001040002BF89BBED040003BF89BBED040004000500410502004C4EB0C1270D0001040002CF86BDED040003CF86BDED04000400050041050200BCA300CD17370001040002CF86BDED040003CF86BDED040004000500410502005BC42D9E789A0001040002D7B3BBED040003D7B3BBED04000400050041050200589755D3E75F0001020002D884B5ED040003B3CEB5ED040004000500410502007A7CC86B21530001040002CF86BDED040003CF86BDED040004000500410502005352A2DA24D300010400028788BCED0400038788BCED0400040005004105020058C9F9B6A86F0001040002B7DCBCED040003B7DCBCED040004000500410502005706A79DEAE60001020002AFDFBAED040003ECE7BAED0400040005004105020082D1B28F7A3A0001040002CF86BDED040003CF86BDED0400040005004105020052217343E79C0001040002CF86BDED040003CF86BDED0400040005004105020082CEA3A289FE000104000296DAAAED04000396DAAAED04000400050041050200D9E0FF79D1180001040002B7DCBCED040003B7DCBCED0400040005004105020052FD31513EE90001040002938AB5ED040003938AB5ED0400040005004105020052128CCDBA7C00010400029FB2BCED0400039FB2BCED040004000500410502006FB83DA167580001040002CF86BDED040003CF86BDED040004000500410502002E14B9387F540001020002B7DCBCED040003CF86BDED040004000500410502004F7E6F098A990001040002CF86BDED040003CF86BDED040004000500410502005D98B7099E1F0001040002B7DCBCED040003B7DCBCED04000400050041050200722A7476317600010400029FB2BCED0400039FB2BCED04000400050041050200BC18CE5EBDA10001020002AFDFBAED040003ECE7BAED040004000500410502005CF890CF3E270001040002B7DCBCED040003B7DCBCED040004000500410502008D72AE6DBEE30001040002CF86BDED040003CF86BDED0400040005004105020076A6D8E9EAAB0001040002CF86BDED040003CF86BDED04000400050041050200721B63925A140001040002CF86BDED040003CF86BDED040004000500410502007608B348A53A0001040002CF86BDED040003CF86BDED04000400 - - 0 - - -645574544 - 0 - 47500 - - 1 - - - 217.133.80.112:1076 217.133.80.112:47500 217.133.80.112:1083 217.133.80.112:1083 217.133.80.112:49734 - 7 - - <_1303289856>6C81442204F3D9855070B98CAE5879A505F3D9855070B98C4D4320134B66D9855070B98C5F4E60ED0D34D98550700434 - <_1303293952>4287274ED659D9855070B98C4287274ED74BD9855070B98C4287274EC15CD9855070B98C4287274ECE92D9855070B98C4287274EA75BD9855070B98C4287274E4B98D9855070B98C4287274EAA2DD9855070B98C4287274EA175D9855070B98C4287274ED735D9855070B98C4287274EAE25D9855070B98C4287274E1A2BD9855070B98C3D7D44372576D9855070B98CCF86DF304366D9855070B98C3D2E02A2259CD9855070B98C4287274EB98CD9855070B98C - <_1303298048>2E3363049108D9855070B98C2E3795FA3202D9855070B98C2E2F6F42E86DD9855070B98CB4B0620AA528D9855070B98C - <_1303306240>5F1894D8122BD9855070B98C2E40484969A3D9855070B98CD592A70A5566D9855070B98C2E26119F8DBED9855070B98C2E3754264E48D9855070B98C - <_1303314432>4D2BFFCAEC6CD9855070043B54BAD08D05E0D9855070B98C9D9D4DA11995D9855070B98C59584CCBB5CED9855070B98C972AC71733DDD9855070B98C - <_1303322624>5F3B0DCEB535D9855070043BD5150C1746D3D9855070B98C4D4B8646EF29D9855070B98CD5152F4D12BBD9855070B98C - <_1303326720>59D0D11D89DCD9855070C2462E755D8E1E97D9855070B98C2E492F875789D9855070B98C2E378784E9C6D9855070B98C2E2F6F6B48FCD9855070B98C - - - <_1303289856>9A4A56D31C619325C6601C71B23E13FDFAF5CA49F15C34A4E33F239B524D6BBC226021F010D2270A3B48DFA2E8CDB6FD37531B1118DB2D471CB980D0 - <_1303293952>D5A2186D0B45088ADDFA7B626C0904CED47E3DF13172672AED483E1EAD69DB781ABEC0D8812B1B5EFF91BC28C67FB5A3404D875A - <_1303298048>DB0EC5161D10171C7C6A4C7109DD - <_1303302144>5379BD98 - <_1303306240>88B19442A48D863ED54D712EEC36D53127BCE36653FE - <_1303310336>1908404B0F7BA3BE952CB1C533456D3CDA410BCB774AF93880FB8BD8C110 - <_1303314432>4B015AD444DD027FD3F61B2A51A53BA0 - <_1303322624>878BAF81A9F053B39E35081485E24B4EDA5F79D37E176C409B6E237A336451F42CFA7CEC013C98A18B51 - <_1303326720>CFB137906F6CCE77246BD5B6B434875570B1F9B9140C85D5114EE6953110B04F3557C0D1686D46A9F69106521979AE49E19F8622F93A - <_1303330816>BA4B81F735FDCDA4E4EF57ACF8A37051C66401E41CA4E562A5A49ACC2E246CCE - - - - 1 - - - 1 - - - 0 - - - 1 - - - - 9BF92EA4B417A7F6 - - - 4102030E322F322E302E302E37322F31373400000FF6EB9ADC04 - - - 0 - - - - 2 - en - - 357 - 258 - 0 - 0 - - 0 - - diff --git a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/skypenameA/config.lck b/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/skypenameA/config.lck deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/skypenameA/config.xml b/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/skypenameA/config.xml deleted file mode 100644 index f7af8873ad..0000000000 --- a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/skypenameA/config.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - - - 300 - 1800 - 63 - - - 41010300676D6172757A7A3400 - 1268962216 - - - 0 - 0 - 1303202372 - 0 - -

- 35716ecf:2 - 98e6c103:0 -

- -
-
- - 1 - 3 - 65535 - 1266110339 - - - 1 - - - 1 - - - 1000000166 - 1303166852 - 1303209779 - - - 1267114269 - - 2 - - 4109008620EBA4DDDB0400FA0100009E2001009420FB09008520B1A58BDD04008120CCD9E6E3040093209B0A00F501820200F801A3B608 - - - 1267114267 - 11 - 4263C0064DD5ACF9A03594DAB928D2B81510 - - - - <_59908281a5de1c9c602d40fe1f815199a1601558ebea75accdfae8b723bb342e>1303296179 23160:21600:1303209779 9589:7200:1303209779 8707:21600:1303209779 - -
- - - skypopen - - - 0 - 2 - 2 - 2 - -
diff --git a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/skypenameA/httpfe/cookies.dat b/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/skypenameA/httpfe/cookies.dat deleted file mode 100644 index fc7f2b1150..0000000000 --- a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/skypenameA/httpfe/cookies.dat +++ /dev/null @@ -1 +0,0 @@ -B \ No newline at end of file diff --git a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/skypenameA/index2.dat b/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/skypenameA/index2.dat deleted file mode 100644 index b8b96d84318e540df1ace348fe21db2b6bc5db1c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 208 zcmXwuNdbT`5X8FNmjYy9pe~S#BNQM2CZ)5VNwV*L#B-llsu$ko2Zk2aTXAXCJ2}n& hUQDwOVw!yv)9jO&W}n40`y!^<5k^1s4DS diff --git a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/skypenameA/main.lock b/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/skypenameA/main.lock deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/skypenameB/config.lck b/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/skypenameB/config.lck deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/skypenameB/config.xml b/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/skypenameB/config.xml deleted file mode 100644 index f7af8873ad..0000000000 --- a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/skypenameB/config.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - - - 300 - 1800 - 63 - - - 41010300676D6172757A7A3400 - 1268962216 - - - 0 - 0 - 1303202372 - 0 - -

- 35716ecf:2 - 98e6c103:0 -

- -
-
- - 1 - 3 - 65535 - 1266110339 - - - 1 - - - 1 - - - 1000000166 - 1303166852 - 1303209779 - - - 1267114269 - - 2 - - 4109008620EBA4DDDB0400FA0100009E2001009420FB09008520B1A58BDD04008120CCD9E6E3040093209B0A00F501820200F801A3B608 - - - 1267114267 - 11 - 4263C0064DD5ACF9A03594DAB928D2B81510 - - - - <_59908281a5de1c9c602d40fe1f815199a1601558ebea75accdfae8b723bb342e>1303296179 23160:21600:1303209779 9589:7200:1303209779 8707:21600:1303209779 - -
- - - skypopen - - - 0 - 2 - 2 - 2 - -
diff --git a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/skypenameB/httpfe/cookies.dat b/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/skypenameB/httpfe/cookies.dat deleted file mode 100644 index fc7f2b1150..0000000000 --- a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/skypenameB/httpfe/cookies.dat +++ /dev/null @@ -1 +0,0 @@ -B \ No newline at end of file diff --git a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/skypenameB/index2.dat b/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/skypenameB/index2.dat deleted file mode 100644 index b8b96d84318e540df1ace348fe21db2b6bc5db1c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 208 zcmXwuNdbT`5X8FNmjYy9pe~S#BNQM2CZ)5VNwV*L#B-llsu$ko2Zk2aTXAXCJ2}n& hUQDwOVw!yv)9jO&W}n40`y!^<5k^1s4DS diff --git a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/skypenameB/main.lock b/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient00/skypenameB/main.lock deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/shared.lck b/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/shared.lck deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/shared.xml b/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/shared.xml deleted file mode 100644 index 4b72e67eb5..0000000000 --- a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/shared.xml +++ /dev/null @@ -1,99 +0,0 @@ - - - - - <_2>00001000A563932E7DE5A581942041A820F8437512A079C7ACB1B73281F191D109521E265BCD38C4133596B834AD9AA1D6BB5E1AC3D59E8675785321F722D39FBFAFB9A24E6482FA3030FFA3692D2C4A53BBCE9DC63F25D10207A20FA969982FEDC1DCC2A7C599071F4735E52AB2E06E34CA232C08B3AA2FB88A0C4A5763E0CD23C3AA37D1D2A7D6EED691EE99BA08BE294F68C24F9AE777DAF294F0AEB8346325A978DC6CF7C210AD11EF3F38111F6D98F388CF41CCBA40ABE9F0D6CBBD3118BA0588344953DF3C5E88B2CCAEDE2E692F320D20EBF16D7DB36156E617C0CC9FB2855D7FDB4C7F8638CC9830E7448D5EAE301A2810277062989841EE679E00E4E277615FEC038DE3A0A20DD7C6A2A00DFBC6A2A00DA6E2B6F404FDC6A2A00DFEC6A2A00DF7FBBB990CF2C6A2A00D8EB4FE8A0C8FB4FE8A0C95C7A6E00CF5FBBB990CD6C7A6E00CD0F896950CCCE2B6F40485CCA2A00DA1D8EEA50DFDFBBB990CA7C7A6E00CA8C7A6E00CA9C7A6E00C97C7A6E00C90B4FE8A0CFE90D59308C290D59308D1E2B6F404C5E2B6F404C6AAF18705C7AAF18705C8AAF18705BBD8EEA50DBCD8EEA50DBDD8EEA50D93CCA2A00D94CCA2A00DEFE2B6F40491B4FE8A0CE2FBBB990CE3FBBB990CBED8EEA50DA0CCA2A00DA1CCA2A00DA6B4FE8A0CA7B4FE8A0CCED8EEA50DA3CCA2A00DA4CCA2A00D84E698AD0DB8C7A6E00CD9E2B6F404E0E2B6F40486E698AD0DFDF896950C0013A60400173D0018DE0200190300AB01F40300449875044518C15F9A278109D4BBAC4E8109D408A6238109D5A63304810904460CC15F9A26303ED408A624303E0047B054004801004980A305004A80E90F004BE0A801004C80A305004D01005CAC02045E5A50FC55465BA050FC55475BA050FC55485BA0C32EFDEE5BA0C32EFDEF5BA0C2A5BC4A5BA0C2A5BC4B5BA0D4BBAC055BA0D4BBAC145BA0D4BBAC215BA0D408A3575BA0D408A37D5BA0D408A37E5BA08275487E5BA0827548425BA00060B817046506CC09A3D6303E04AE018C0125F8D500021A25F9D500011A162102200301220125FFD50025FAD5000C03E4000D2580D6000F060125F8D5000302172105050103080D06010501011C210302060125FCD50025F9D5000A25FDD50025FED5000A0D06020502050119211305020380808080100C05010D0380808080100B25FDD5000C01080005000380808080100D060307010503220101220104AC01BF012597CE002597CE002590CE0019152590CE002597CE000B033C1815210220030122012593CE0014212E2594CE002103030B220125A5CE00030F172103030B22012596CE00142103030B22012597CE00142103030B22012599CE00142103030A220125A5CE00030A1A2590CE002592CE000B031E1B15142103030A220125A4CE000380201D14210303092201259BCE0014210A2594CE002103030B2201259DCE00142103030822012593CE002103012201259ECE001421030306220103022201006800006901006A01006C987504740CC2A5BC4C303ED408A34C303E007828047912CC09A3D3303E82754864303E4E8DB16F303E047DBF010203020800050003020D0B0601030308000500020501030508000500021A03060800050003041A16030508000500021D160C0A0C060203D00F251205020A03020D0A050103D00F0C0A0603010800050003FFFFFFFF0F18030208000500021D141506042512020800050003030D05040C10030205040B0C06050306050505020A0C060603040800050003050800050003E400180C0607050703E400250A0B250A011C0C0A0314100608050303C03E0F03B8171005060388270F03DC0B100508047E5E0380010304080005000B03040D250403E4000F03140D0A2503250203030D0A0B0110060101080005000380020D0302080005000380020D172103010601250A03E4001B210D0501030A03E400250A210303DF002002250A0B0D0F0601050100800180EA49008101E003036F3139352E34362E3235332E3235333A313233353000038201706F6F6C313D2A2E6C6976657461622E736B7970653B706F6F6C323D7765622E6578747261732E736B7970653B706F6F6C333D6578747261732E646F776E6C6F6164732E736B7970653B706F6F6C343D2A2E736B79706566696E642E736B7970653B706F6F6C353D2A2E7072656D69756D2E736B7970653B706F6F6C363D2A2E6D756C74696D656469612E736B7970653B706F6F6C373D2A2E6D756C74696D656469612E6D657461636166653B706F6F6C383D2A2E6D756C74696D656469612E6461696C796D6F74696F6E3B706F6F6C393D2A2E6D756C74696D656469612E6D6574616F6D6E69747572653B706F6F6C31303D77686174736E65772E736B7970653B706F6F6C31313D7061792E736B7970653B706F6F6C31323D7365637572652E7061792E736B7970653B706F6F6C31333D2A2E70696373746F72653B706F6F6C31343D2A2E6D796163636F756E742E736B7970653B706F6F6C31353D2A2E62696269743B706F6F6C31363D2A2E70726F6363796265723B706F6F6C31373D747261636B696E672E6F6D6E69747572653B706F6F6C31383D676F2E736B7970653B706F6F6C31393D747261636B2E736B7970657C706F6F6C313D3139342E3139322E3139392E3235313A31323335303B706F6F6C323D3139342E3139322E3139392E3235323A31323335303B706F6F6C333D3139342E3139322E3139392E3235323A31323335303B706F6F6C343D3139342E3136352E3138382E3130313A31323335303B706F6F6C353D3139332E39352E3135342E31353A31323335313B706F6F6C363D3139342E3136352E3138382E3130303A31323335303B706F6F6C373D3139342E3136352E3138382E3130303A31323335303B706F6F6C383D3139342E3136352E3138382E3130303A31323335303B706F6F6C393D3139342E3136352E3138382E3130303A31323335303B706F6F6C31303D3230342E392E3136332E3134313A31323335303B706F6F6C31313D3139352E34362E3235332E3234353A31323335303B706F6F6C31323D3139352E34362E3235332E3234353A31323335303B706F6F6C31333D3139332E39352E3135342E31343A31323335313B706F6F6C31343D3139332E39352E3135342E31343A31323335313B706F6F6C31353D3139332E39352E3135342E31343A31323335313B706F6F6C31363D3139332E39352E3135342E31343A31323335313B706F6F6C31373D3139342E3136352E3138382E3130303A31323335303B706F6F6C31383D3139342E3136352E3138382E3130303A31323335303B706F6F6C31393D3139332E39352E3135342E31343A31323335310003B101706F6F6C313D2A2E6C6976657461622E736B7970653B706F6F6C323D7765622E6578747261732E736B797065206578747261732E646F776E6C6F6164732E736B7970653B706F6F6C333D2A2E687773746F72652E736B7970653B706F6F6C343D2A2E736B79706566696E642E736B797065202A2E6469726563746F72792E736B7970653B706F6F6C353D2A2E70696373746F7265202A2E6D796163636F756E742E736B797065202A2E6269626974202A2E70726F63637962657220747261636B2E736B79706520617070732E736B7970656173736574733B706F6F6C363D2A2E6D756C74696D656469612E736B797065202A2E6D756C74696D656469612E6D65746163616665202A2E6D756C74696D656469612E6461696C796D6F74696F6E202A2E6D756C74696D656469612E6D6574616F6D6E6974757265207777772E736B7970652077686174736E65772E736B7970653B706F6F6C373D7061792E736B797065207365637572652E7061792E736B7970653B706F6F6C383D6170692E736B7970653B706F6F6C393D63616C6C70686F6E65732E736B7970652063616C6C72617465732E736B7970653B706F6F6C31303D2A2E7072656D69756D2E736B7970653B706F6F6C31323D6C6F67732E736B7970653B706F6F6C31333D617661746172736572766963652E736B79706520636F6E74616374696D706F72742E736B7970653B706F6F6C31343D676F2E736B7970653B706F6F6C31353D747261636B696E672E6F6D6E69747572657C706F6F6C313D3139342E3139322E3139392E3235312C31323335302C312C4E4C2C77652C35302C313B706F6F6C323D3139342E3139322E3139392E3235322C31323335302C312C444B2C77652C35302C313B706F6F6C333D3139332E39352E3135342E31372C31323335312C312C49452C77652C35302C31203231322E3138372E3137322E36322C31323335312C312C49452C77652C35302C31203139352E34362E3235332E3232372C31323335312C312C4C552C77652C35302C31203231322E382E3136362E33332C31323335312C312C4C552C77652C35302C313B706F6F6C343D3139342E3136352E3138382E3130312C31323335302C312C49452C77652C35302C313B706F6F6C353D3139332E39352E3135342E31342C31323335312C312C49452C77652C35302C31203139352E34362E3235332E3230352C31323335312C312C4C552C77652C35302C31203231322E3138372E3137322E35392C31323335312C312C49452C77652C35302C31203231322E382E3136362E31392C31323335312C312C4C552C77652C35302C313B706F6F6C363D3139342E3136352E3138382E3130302C31323335302C312C49452C77652C35302C31203230342E392E3136332E3134302C31323335302C312C43412C6E612C35302C313B706F6F6C373D3139352E34362E3235332E3234352C31323335302C312C4C552C77652C35302C31203139332E39352E3135342E31362C31323335312C312C49452C77652C35302C31203231322E3138372E3137322E36312C31323335312C312C49452C77652C35302C31203231322E382E3136362E32302C31323335302C312C4C552C77652C35302C313B706F6F6C383D3230342E392E3136332E3138342C31323335302C312C43412C6E612C35302C312037382E3134312E3137372E38392C31323335302C312C4C552C77652C35302C313B706F6F6C393D3139342E3136352E3138382E3131352C31323335302C312C49452C77652C35302C31203230342E392E3136332E3134312C31323335302C312C43412C6E612C35302C313B706F6F6C31303D3139332E39352E3135342E31352C31323335312C312C49452C77652C35302C31203231322E3138372E3137322E36302C31323335312C312C49452C77652C35302C31203139352E34362E3235332E3232362C31323335312C312C4C552C77652C35302C31203231322E382E3136362E33322C31323335312C312C4C552C77652C35302C313B706F6F6C31323D37382E3134312E3137372E37362C31323335302C312C4C552C77652C35302C313B706F6F6C31333D3230342E392E3136332E3136372C31323335302C312C43412C6E612C35302C312037382E3134312E3137372E38312C31323335302C312C4C552C77652C35302C313B706F6F6C31343D3230342E392E3136332E3136382C31323335302C312C43412C6E612C35302C31203139342E3136352E3138382E3130302C31323335302C312C49452C77652C35302C313B706F6F6C31353D3230342E392E3136332E3136392C31323335302C312C43412C6E612C35302C31203139342E3136352E3138382E3130302C31323335302C312C49452C77652C35302C3100039701736B79706566696E642E736B7970653D31372C362C382C2D33392C3139206469726563746F72792E736B7970653D31372C362C382C2D33392C31390003A60138302E3235322E38352E37302C32333435362C312C6E6C2C77652C35302C312038302E3235322E38352E37312C32333435362C312C6E6C2C77652C35302C312038302E3235322E38352E37322C32333435362C312C6E6C2C77652C35302C31203139352E34362E3235332E3233382C32333435362C322C6C752C77652C35302C31203139352E34362E3235332E3233392C32333435362C322C6C752C77652C35302C31203139342E3136352E3138382E37342C32333435362C332C69652C77652C35302C31203139342E3136352E3138382E37352C32333435362C332C69652C77652C35302C31203231322E3138372E3137322E352C32333435362C342C69652C77652C35302C31203231322E3138372E3137322E32302C32333435362C342C69652C77652C35302C31203231322E3138372E3137322E33332C32333435362C342C69652C77652C35302C31203231322E382E3136332E38372C32333435362C362C6C752C77652C35302C31203231322E382E3136332E3132352C32333435362C362C6C752C77652C35302C31203231322E382E3136332E3132362C32333435362C362C6C752C77652C35302C31203133302E3131372E37322E3132362C32333435362C372C6E6C2C77652C35302C31203133302E3131372E37322E36362C32333435362C372C6E6C2C77652C35302C310004B2010B03A09C0125B3EA010B220104A5012A24A39C012102220025A19C010401F3C2011A142103030A220125B0EA0103051A2103030B2201030522010384012B39393030303131313A37382E3134312E3137372E39363A3233343536000086010C008701880E039101000493010CC2A5BC5C2774C32EFDD927740496010CD592BC1034504E8DB5F2345006C20105F801F901FA01FB01FC010395016272617465303D31206272617465313D31206272617465323D31206272617465333D31206272617465343D31206272617465353D31206272617465363D31206272617465373D31206272617465383D31207372617465303D31207372617465313D31207372617465323D31207372617465333D31207372617465343D31207372617465353D31207372617465363D31207372617465373D31207372617465383D310003B4013139342E3136352E3138382E37373A3132333530203231322E382E3136332E3130333A31323335300000C0010100C1010103CB012E6163636573732E736B7970652E6E65740000E1010F00F0010100F101A982CA950303D50137382E3134312E3137372E33383A3132333530203230342E392E3136332E3135313A31323335300003CF0137382E3134312E3137372E36393A3132333530203230342E392E3136332E3134393A31323335300000D6010103E4013139342E3136352E3138382E38303A3132333530203231322E382E3136362E353A31323335300003E5010000F8016403F7015B574845453A204F4646203130302C20563120302C20563220305D205B496E70757445513A204F46462035302C2056312035305D205B4945513A204F46462031362C2056312031322C2056322031322C2056332031322C2056342031322C2056352031322C2056362031322C2056372031325D205B53453A204453203130302C2057494F20305D205B5345323A2044532039302C2057494F2031305D205B414D504D3A204F4C442035302C20444147432035305D205B4B54523A204F46462035302C204F4E2035305D205B49414D323A204F46462039392C204D3120312C204D3220305D0003FA0152434F4E3D350003F901302F342E322E2A2E2A2C33322C3320302F352E302E2A2E2A2C31342C3320302F352E312E2A2E3130342C342C330003A80168747470733A2F2F7777775C2E70617970616C5C2E2E3F2E3F2E3F247C68747470733A2F2F696D616765735C2E70617970616C5C2E636F6D247C68747470733A2F2F7777775C2E70617970616C6F626A656374735C2E636F6D247C68747470733F3A2F2F2E2B5C2E666263646E5C2E6E6574247C68747470733F3A2F2F2E2B5C2E66616365626F6F6B5C2E636F6D247C68747470733F3A2F2F6368616E6E656C5C2E736B7970655C2E636F6D247C68747470733A2F2F617070735C2E736B7970655C2E636F6D247C68747470733F3A2F2F7161617070735C2E736B7970655C2E6E6574247C68747470733F3A2F2F636F6E6E6563745C2E66616365626F6F6B5C2E6E6574247C68747470733A2F2F2E2A5C2E736B7970656173736574735C2E636F6D247C68747470733A2F2F61645C2E646F75626C65636C69636B5C2E6E6574247C68747470733A2F2F61642D656D65615C2E646F75626C65636C69636B5C2E6E6574247C68747470733A2F2F61642D617061635C2E646F75626C65636C69636B5C2E6E6574247C68747470733A2F2F737461746963323F5C2E736B7970655C2E636F6D247C68747470733A2F2F7161737461746963323F5C2E736B7970655C2E6E6574247C68747470733A2F2F7072657374617469635C2E736B7970655C2E6E6574240003FF013078313030303230343030393136333231372D642D723230342E392E3136332E3231373A38313932203078313030303230343030393136333231392D642D723230342E392E3136332E3231393A38313932203078313030303230343030393136333232312D642D723230342E392E3136332E3232313A38313932203078313030303230343030393136333232332D642D723230342E392E3136332E3232333A38313932203078313030303230343030393136333232352D642D723230342E392E3136332E3232353A38313932203078313030303230343030393136333232372D642D723230342E392E3136332E3232373A38313932203078313030303230383038383138363030352D642D723230382E38382E3138362E353A38313932203078313030303230383038383138363030372D642D723230382E38382E3138362E373A38313932203078313030303230383038383138363030392D642D723230382E38382E3138362E393A38313932203078313030303230383038383138363031312D642D723230382E38382E3138362E31313A38313932203078313030303230383038383138363031332D642D723230382E38382E3138362E31333A38313932203078313030303230383038383138363031352D642D723230382E38382E3138362E31353A38313932203078313030303230383038383138363031372D642D723230382E38382E3138362E31373A38313932203078313030303230383038383138363031392D642D723230382E38382E3138362E31393A38313932203078313030303230383038383138363032312D642D723230382E38382E3138362E32313A38313932203078313030303230383038383138363032332D642D723230382E38382E3138362E32333A38313932203078313030303230383038383138363032352D642D723230382E38382E3138362E32353A38313932203078313030303230383038383138363032372D642D723230382E38382E3138362E32373A38313932203078313030303230383038383138363032392D642D723230382E38382E3138362E32393A38313932203078313030303230383038383138363033312D642D723230382E38382E3138362E33313A38313932203078313030303230383038383138363033332D642D723230382E38382E3138362E33333A38313932203078313030303230383038383138363033352D642D723230382E38382E3138362E33353A38313932203078313030303230383038383138363033372D642D723230382E38382E3138362E33373A38313932203078313030303230383038383138363033392D642D723230382E38382E3138362E33393A38313932203078313030303230383038383138363034372D642D723230382E38382E3138362E34373A38313932203078313030303230383038383138363034392D642D723230382E38382E3138362E34393A38313932203078313030303230383038383138363035312D642D723230382E38382E3138362E35313A38313932203078313030303230383038383138363035332D642D723230382E38382E3138362E35333A38313932203078313030303230383038383138363035352D642D723230382E38382E3138362E35353A38313932203078313030303230383038383138363035372D642D723230382E38382E3138362E35373A38313932203078313030303230383038383138363035392D642D723230382E38382E3138362E35393A38313932203078313030303230383038383138363036312D642D723230382E38382E3138362E36313A38313932203078313030303230383038383138363036332D642D723230382E38382E3138362E36333A38313932203078313030303230383038383138363035392D642D723230382E38382E3138362E36353A38313932203078313030303230383038383138363036312D642D723230382E38382E3138362E36373A38313932203078313030303230383038383138363036332D642D723230382E38382E3138362E36393A38313932203078313030303230383038383138363037312D642D723230382E38382E3138362E37313A38313932203078313030303230383038383138363037332D642D723230382E38382E3138362E37333A38313932203078313030303230383038383138363037352D642D723230382E38382E3138362E37353A38313932203078313030303230383038383138363037372D642D723230382E38382E3138362E37373A38313932203078313030303230383038383138363037392D642D723230382E38382E3138362E37393A38313932203078313030303230383038383138363038312D642D723230382E38382E3138362E38313A38313932203078313030303230383038383138363038332D642D723230382E38382E3138362E38333A38313932203078313030303230383038383138363038352D642D723230382E38382E3138362E38353A38313932203078313030303230383038383138363038372D642D723230382E38382E3138362E38373A38313932203078313030303230383038383138363038392D642D723230382E38382E3138362E38393A38313932203078313030303230383038383138363039312D642D723230382E38382E3138362E39313A38313932203078313030303230383038383138363039332D642D723230382E38382E3138362E39333A38313932203078313030303230383038383138363039352D642D723230382E38382E3138362E39353A38313932203078313030303230383038383138363039372D642D723230382E38382E3138362E39373A38313932203078313030303230383038383138363039392D642D723230382E38382E3138362E39393A38313932203078313030303230383038383138363130312D642D723230382E38382E3138362E3130313A38313932203078313030303230383038383138363130332D642D723230382E38382E3138362E3130333A38313932203078313030303230383038383138363130352D642D723230382E38382E3138362E3130353A38313932203078313030303230383038383138363130372D642D723230382E38382E3138362E3130373A38313932203078313030303230383038383138363130392D642D723230382E38382E3138362E3130393A38313932203078313030303230383038383138363131312D642D723230382E38382E3138362E3131313A38313932203078313030303230383038383138363131332D642D723230382E38382E3138362E3131333A38313932203078313030303230383038383138363131352D642D723230382E38382E3138362E3131353A38313932203078313030303230383038383138363131372D642D723230382E38382E3138362E3131373A38313932203078323030303134393030353034353031312D642D723134392E352E34352E31313A38313932203078323030303134393030353034353031332D642D723134392E352E34352E31333A38313932203078323030303134393030353034353031352D642D723134392E352E34352E31353A38313932203078323030303134393030353034353031372D642D723134392E352E34352E31373A38313932203078323030303134393030353034353031392D642D723134392E352E34352E31393A38313932203078323030303134393030353034353032312D642D723134392E352E34352E32313A38313932203078323030303134393030353034353032332D642D723134392E352E34352E32333A38313932203078323030303134393030353034353032352D642D723134392E352E34352E32353A38313932203078323030303134393030353034353032372D642D723134392E352E34352E32373A38313932203078323030303134393030353034353032392D642D723134392E352E34352E32393A38313932203078323030303134393030353034353033312D642D723134392E352E34352E33313A38313932203078323030303134393030353034353033332D642D723134392E352E34352E33333A38313932203078323030303134393030353034353033352D642D723134392E352E34352E33353A38313932203078323030303134393030353034353033372D642D723134392E352E34352E33373A38313932203078323030303134393030353034353033392D642D723134392E352E34352E33393A38313932203078323030303134393030353034353034312D642D723134392E352E34352E34313A38313932203078323030303134393030353034353034332D642D723134392E352E34352E34333A38313932203078323030303134393030353034353034352D642D723134392E352E34352E34353A38313932203078323030303134393030353034353034372D642D723134392E352E34352E34373A38313932203078323030303134393030353034353034392D642D723134392E352E34352E34393A38313932203078323030303134393030353034353035312D642D723134392E352E34352E35313A38313932203078323030303134393030353034353035332D642D723134392E352E34352E35333A38313932203078323030303134393030353034353035352D642D723134392E352E34352E35353A38313932203078323030303134393030353034353035372D642D723134392E352E34352E35373A38313932203078323030303134393030353034353035392D642D723134392E352E34352E35393A38313932203078323030303134393030353034353036312D642D723134392E352E34352E36313A38313932203078323030303134393030353034353036332D642D723134392E352E34352E36333A38313932203078323030303134393030353034353036352D642D723134392E352E34352E36353A38313932203078323030303134393030353034353036372D642D723134392E352E34352E36373A38313932203078323030303134393030353034353036392D642D723134392E352E34352E36393A38313932203078323030303134393030353034353037312D642D723134392E352E34352E37313A38313932203078323030303134393030353034353037332D642D723134392E352E34352E37333A38313932203078323030303134393030353034353037352D642D723134392E352E34352E37353A38313932203078323030303134393030353034353037372D642D723134392E352E34352E37373A38313932203078323030303134393030353034353037392D642D723134392E352E34352E37393A38313932203078323030303134393030353034353038312D642D723134392E352E34352E38313A38313932203078323030303134393030353034353038332D642D723134392E352E34352E38333A38313932203078323030303134393030353034353038352D642D723134392E352E34352E38353A38313932203078323030303134393030353034353038372D642D723134392E352E34352E38373A38313932203078323030303134393030353034353038392D642D723134392E352E34352E38393A38313932203078323030303134393030353034353039312D642D723134392E352E34352E39313A38313932203078323030303134393030353034353039332D642D723134392E352E34352E39333A38313932203078323030303134393030353034353039352D642D723134392E352E34352E39353A38313932203078323030303134393030353034353039372D642D723134392E352E34352E39373A38313932203078323030303134393030353034353039392D642D723134392E352E34352E39393A38313932203078323030303134393030353034353130312D642D723134392E352E34352E3130313A38313932203078323030303134393030353034353130332D642D723134392E352E34352E3130333A38313932203078323030303134393030353034353130352D642D723134392E352E34352E3130353A38313932203078323030303134393030353034353130372D642D723134392E352E34352E3130373A38313932203078323030303134393030353034353130392D642D723134392E352E34352E3130393A38313932203078323030303134393030353034353131312D642D723134392E352E34352E3131313A38313932203078323030303134393030353034353131332D642D723134392E352E34352E3131333A38313932203078323030303134393030353034353131352D642D723134392E352E34352E3131353A38313932203078323030303134393030353034353131372D642D723134392E352E34352E3131373A38313932203078323030303134393030353034353131392D642D723134392E352E34352E3131393A38313932203078323030303134393030353034353132312D642D723134392E352E34352E3132313A38313932203078323030303134393030353034353132332D642D723134392E352E34352E3132333A38313932203078323030303134393030353034353132352D642D723134392E352E34352E3132353A38313932203078323030303134393030353034353132372D642D723134392E352E34352E3132373A38313932203078323030303134393030353034353132392D642D723134392E352E34352E3132393A38313932000089020A062E19AEBFD5A40B80D4B6B30280D2AFF205808CFD910B80DEB9F1048FA486F4049CA486F404D5A486F404ACC686F404C2C686F404878F87F404CEB887F404ADC487F404BCC687F404D4D087F404F9EA87F4049CF587F404C8F487F404C9F487F404CAF487F404EACCBB9C05F7CCBB9C05E694D7BB058E96D7BB05A896D7BB050094023C0095021400930201039902536B79706520546563686E6F6C6F6769657320534100008E0200008F0280BAB70300910280A30503F2013231332E3134362E3138392E3230313A3132333530203231332E3134362E3138392E3230323A3132333530203231332E3134362E3138392E3230333A3132333530203231332E3134362E3138392E3230343A3132333530203231332E3134362E3138392E3230353A3132333530203231332E3134362E3138392E3230363A3132333530203231322E3136312E382E31303A3132333530203231322E3136312E382E323A3132333530203231322E3136312E382E333A3132333530203231322E3136312E382E343A3132333530203231322E3136312E382E353A3132333530203231322E3136312E382E363A31323335300000FC010106FD0106011E64AC02A403E807009002C20103C301687474703A2F2F37392E3132352E36332E3732247C68747470733F3A2F2F2E2B5C2E66616365626F6F6B5C2E636F6D240000DE0148 - <_256>000010011AC0AA3BA66DF7FB48228AE35F9BB4A032FE4A6A898DA7A1A5AE37DC59FB3D09607F1CACD46A5DBC008DABF8F09C797DF5A8903307D04C318825CEA7C481303C655A9EEE099E9A0AF1158373B458BB8FDACB336A6EC63C043E6782688E2350B417DDDDFF96B474DAEA7D1DF3742303B79111FC752BFB5D6887A5B822F945CC761FAF6E80DE5EC60868768CB8A9F9C876137806DCEA0DD1300181558ABFDBA26592078F5F84195C526D8C7F339EF82700FD93F8FB71ADA5ED3E977D27FA52D1F489EF5DA0A9E00B146BADCBDEBFB0DFEBCD61E5B8352A49893357E0DC3A736743929DA975782EA4D8184605FD064641986C47706D264281C876F926BF58003E9E - <_3>0000100498ECF8A7A4585F76C930739A1EAE590DE96D9EF3AA9B231E67965F3F08ECFC493E1DA23ECDE17A85C94CBE034E88F9414E9BBC82F32AAFCFFB2C09F6F57A478238BAEC9EEF2BB9C67F71257722E6786D88D6400F6B7D81450FB3B6CCCC3986E3782D2387E354EBA9099331AEF510D479C6601D2383D866E2B5B525DF0BA975D58C120EFAE88C89EE365FC696CC891B77F67CFA18FDE8E95DDAC25A7C7D70FA7A1414BAE593856A658888C622836006C1C131B4B2E805554DCFA52F3EFD34C1B759BF8A302E491835DCE701E84D37ED150C8ADD699AD3DCA9F515123C5B5AD94E253E173BA3465E64A0079D5EF4E6075E66D0F5FBC3D9BC25C4E80C4CB2FE9B87040003000004D00F0005D00F050041040400B80125C20003141B14230025D50003031B14230024E100142300250003191714230025EA0003141714230025EA00011724EA00140A14230025E400030F1C14230025FC00011A24FF000A14230025FF00011A142300258001011A14230025E10025E10003A006100A0309031725000325180C0A25C20003140B0C03040D0A03882725C3000C0A03E43225C4000C0A0602050228038407DC08FA1E0601050102050203FA1E1C0603250028061D1E1F202122060105010205010503050141060300636F756E74206279207175616C697479000001CC080002040003000004010005010501410603006261647175616C69747920636F756E742062792076657273696F6E000001D6080002070003000004010005010501410603006261647175616C6974792073756D2062792076657273696F6E000001E0080002070003000004010005010500410304005424E400142300250003191714230025EA0003141714230025EA00011724EA00140A14230025FC00011A24FF000A14230025FF00011A142300258001011A14230025E40025E40028043CB401D804901C060105010205014106030073756D206F66206C61737463616C6C206475726174696F6E73000001B009000201000300000480A3050005B054050141060300636F756E74206279206C61737463616C6C206475726174696F6E000001BA090002050003000004010005010500410204005025EB00011C142300250003191714230025EA0003141714230025EA00011724EA00140A14230025FC00011A24FF000A14230025FF00011A142300258001011A14230025EB0028031E32D0000601050102050141060300636F756E742062792073797374656D20637075207573616765000001940A0002040003000004010005010500410204004F25EC00011C142300250003191714230025EA0003141714230025EA00011724EA00140A14230025FC00011A24FF000A14230025FF00011A142300258001011A14230025EC0028030F1E320601050102050141060300636F756E742062792070726F63657373206370752075736167650000019E0A0002040003000004010005010500410304006824C20014230024E60014230025E600011A14230025EC00011C142300250003191714230025EA0003141714230025EA00011724EA00140A14230025FC00011A24FF000A14230025FF00011A142300258001011A14230025EC0028030F1E320601050102050125C2000501410603006A6974746572636F756E742062792070726F6365737320637075207573616765000001F80A0002040003000004010005010501410603006A69747465722062792070726F6365737320637075207573616765000001820B0002040003000004D00F0005D00F0500410304004424E700142300250003191714230025EA0003141714230025EA00011724EA00140A14230025FC00011A24FF000A14230025FF00011A142300258001011A1423000225E700050141060300706F74656E7469616C207463702066616C6C6261636B73000001DC0B00020100030000040100050105014106030061637475616C207463702066616C6C6261636B73000001E60B00020100030000040100050105004103040056240C142300250C030A1814230025EA0003141714230025EA00011724EA00140A14230024E70014230025E700011A14230024E50014230025E500011C0602250C29050306070809280401020405060105010205010502050141060300636F756E74206279206E617474797065000001C00C0002050003000004010005010501410603007564706661696C75726573206279206E617474797065000001CA0C0002050003000004010005010500410204001B25D90014230025D90025DA000B0602050228030102040601050102050141060300636F756E74206279206E726F666D756C74696368617473000001A40D0002040003000004010005010500410304001425F700011C14230025000319171423000225F90005014106030075736572732077686F206861766520636F6D706C65746564204943000001880E0002010003000004010005010501410603006C617374204943207969656C6420676C6F62616C73756D000001920E0002010003000004E8070005500500410304001224F60014230025000319171423000225F60005014106030075736572732077686F206861766520494320737570706F7274000001EC0E0002010003000004010005010501410603004943207374617274757020636F756E7420676C6F62616C73756D000001F60E00020100030000046400051405004102040025240C142300250C030A18142300250C011C142300250C280802030405060708090601050102050141060300636F756E74206279206E617474797065000001D00F0002090003000004010005010500410404001A250003191714230025E20025E30025FC00280201020601050102050141060300766964656F2073656E642063617061626C650000019811000201000300000401000501050141060300766964656F20706172616C6C656C2063616C6C730000019911000201000300000414000502050141060300636F756E7420627920766964656F2063616C6C73206D616465000001A2110002030003000004010005010500410204003A250003191714230025EA0003141714230025EA00011724EA00140A14230024E50014230025E50003031914230025E50028030102030601050102050141060300636F756E742062792073747265616D7472616E73706F7274000001FC11000204000300000401000501050041090400E00125C20003141B25E400030F1C1514230024E100142300250003191714230025EA0003141725EA0001171514230025FF002580010A011A14230025E60003031A25E50003031A1514230024F5001423002412142300249F0114230025C30025E10025E10003A006100A03A0060B0309031725000325180C0A25C20003140B0C03040D0A2512030A0C251025F5001703CC080C0A1C160602020502250003231B241D150603050305020503150503251D03808080808080808080011D14150603050305020503150503251D038080808080808080C0011D1415060305030502050315050141060300706F74656E7469616C2052555F756E65787065637465645F62616471000001E01200020100030000040100050105014106030061637475616C2052555F756E65787065637465645F62616471000001EA1200020100030000040100050105014106030042435020706F74656E7469616C2052555F756E65787065637465645F62616471000001F4120002010003000004010005010501410603004243502061637475616C2052555F756E65787065637465645F62616471000001FE12000201000300000401000501050141060300424350203220706F74656E7469616C2052555F756E65787065637465645F62616471000001881300020100030000040100050105014106030042435020322061637475616C2052555F756E65787065637465645F626164710000019213000201000300000401000501050141060300424350203420706F74656E7469616C2052555F756E65787065637465645F626164710000019C130002010003000004010005010501410603004243502031362061637475616C2052555F756E65787065637465645F62616471000001A6130002010003000004010005010500410304000825B801011C25B701050141060300757365727320696E207075626C6963206368617473000001C4130002010003000004010005010501410603007075626C69632063686174206D6573736167657320696E206C617374206D696E757465000001CE1300020100030000046400050A0500410404005F248E0114230024D5001423002500032B1B1423002500032B1C250D03021C16250E03FFFFFFFF0F1D03B4E2C8F10217250E0380808080100D03B4E2C8F10217151614230025D500280219C80106010501020501258E010501258E0103880E1C050141060300636F756E742062792062756464696573000001A814000203000300000401000501050141060300617661696C6162696C697479206167652062792062756464696573000001B2140002030003000004C0FC150005A099020501410603006C6F6E6720617661696C6162696C697479206167652062792062756464696573000001BC140002030003000004010005010500410204003324C000142300250003191714230025F301290300E5C68583B7AEDE36F2CAB9A3A7AE983806020502280202030601050125C00005014106030073696D756C74616E656F75732063616C6C7320706572206E616D6573706163650000018C15000203000300000419000519050041020400C50125C00006020502142300250006030503031917142300050303231B06040504210302200225A1010605050421030502200225A2010606030606070505021A050503021A160506021A15210305072002010607050203021B050603021B152103050720020206070502021A050603021B15210305072002030206070502021A050503041A15210305072002030306070502021A050503031A15210305072002030406070502021A050503051A152103050720020305060705072806010203040506060105010205014106030063616C6C6572733A207332735F313120636F6E665F686F737420636F6E665F636C69656E7420736B7970656F757420736B797065696E20766F6963656D61696C20756E6B6E6F776E000001F015000207000300000401000501 - <_4>000010052A0B6759B71FBC1EF05BE97DFEA4EE6C1E15AF19ED70DEC1130B14C13CE41246D302B9662592907E3CA508A57702B5C00C2A05170857FA22012E0F235B425B4D919B23A541D3AD6E948FC634DE71A29493634884DFD5E9D89C5D951CBCD71B9B3ABFD3C4E2779BB1817D76E7C223CA36BD75A6A05B730AF138057E4048B2FFDD522BB588EC0B9D3E014BF9E354EB608150BC613C739D9E8C7465F05F047FAF7AFA3EE89B9B58BF0FC35F07B55CF3E4B59A7C4ED48B1C0C7F0305E6AC2E80AAEAD6064EB6ACDC1806FCE0B5CB66F0840DA7F0FE7B228E3898E3E42A9AFEFE13DDF019EF8D8F02A631AF2615BBC6E1EDB65C89A775F642C88109E6247EC4B463DC302E2A2E323000050541020006020307322E302E2A2E3100050541030006020307322E302E2A2E3200000AE4ED8009050541030006020307322E302E2A2E33000009B3E6CC990B050541040006020307322E302E2A2E3400000AE4ED8009000BA00B050541030006020308322E302E2A2E35000307322E302E2A2E3900050541040006020308322E302E2A2E39000307322E302E2A2E313100000AE4ED8009050541040006020308322E302E2A2E3131000307322E302E2A2E3135000009E6CC99B306050541050006020308322E302E2A2E3135000307322E302E2A2E323000000AE4ED8009000BA00B050041050303557067726164655465737433000301332E302E302E3130300003044E6963654272616E6400050541040006020307332E302E302E2A0003074E6963654272616E6400000AE4ED8009050541040006020307322E302E302E2A0003074E6963654272616E6400000AE4ED80090500410E0303557067726164655465737433000301332E302E302E31303000050541040006020307332E302E302E39390003074F746865724272616E6400000AE4ED8009050541040006020307322E302E302E39390003074F746865724272616E6400000AE4ED8009050541040006020307332E302E302E39380003074F746865724272616E64000009B3E6CC990B050541040006020307322E302E302E39380003074F746865724272616E64000009B3E6CC990B050541050006020307332E302E302E39370003074F746865724272616E6400000AE4ED8009000BA00B050541050006020307322E302E302E39370003074F746865724272616E6400000AE4ED8009000BA00B050541030006020307332E302E302E393900000AE4ED8009050541030006020307322E302E302E393900000AE4ED8009050541030006020307332E302E302E3938000009B3E6CC990B050541030006020307322E302E302E3938000009B3E6CC990B050541040006020307332E302E302E393700000AE4ED8009000BA00B050541040006020307322E302E302E393700000AE4ED8009000BA00B0500410303033130303031000301302E302E302E313000050541020006020307302E302E302E3900 - <_5>00001006739CA527EF827847E16F23CD52458C3EBA3460A42935EC6948BEFA626B49E3BDF279FC62486E2DDBCA19609ED23D31F4E5175920F282AD74A74A997C3909E67B622480C68A058E886C7D5F3C40954880D7798CD61CEA0FBAFB389BE5B2B8A887348F7AADB4DF642B194B814047CDA0E698EDDE61DFA731DCA5883A76F913D8C94066718054E85ADA7AE009F2B2A9AF762FDCB9B6CAF64C156911E3AB172CFD795F66FB6E8E15048A54E4AB17979D6C447DEBADE75CC6F606050D980061112AFF9AE7C7BF8065D711949E41FA4C8B6CBF0916BB395B3E186A7D617D353C6BFFC687FE79475DFA095D113D70B828FB597BC3665B7C9C3669CA9CBE5D308D3FC23803044E45544745415200050541020006040307302E392E302E2A000500410503033130303033000301312E302E302E3137000304534D4300050541020006040307302E392E302E313200050541020006020307302E392E302E3230000500410503033130303033000301312E312E302E313000030442454C4B494E00050541020006040307302E392E302E313200050541020006020307302E392E302E3230000500410503033130303033000301312E302E302E3137000304454447452D434F524500050541020006040307302E392E302E313200050541020006020307302E392E302E3230000500410503033130303033000301312E302E302E31330003044C4F474954454300050541020006040307302E392E302E313200050541020006020307302E392E302E3230000500410503033130303035000301312E342E38382E31333636000304544F50434F4D00050541020006040307312E342E38382E3133353600050541020006020307312E342E38382E31333635000500410503033130303035000301312E342E38382E313336360003045043484F4D4500050541020006040307312E342E38382E3133353600050541020006020307312E342E38382E31333635000500410403033130303036000301302E302E302E313000050541020006040307302E302E302E3500050541020006020307302E302E302E39000500410503033130303037000301312E302E312E330003045445434F00050541020006040307312E302E302E3800050541020006020307312E302E312E31000500410503033130303038000301302E392E332E3339370003044C494E4B53595300050541020006040307302E382E332E2A00050541020006020307302E392E332E333932000500410503033130303038000301302E392E332E3339370003044E45544745415200050541020006040307302E382E332E2A00050541020006020307302E392E332E333932000500410503033130303038000301302E392E332E3339370003045048494C49505300050541020006040307302E382E332E2A00050541020006020307302E392E332E333932000500410403033130303130000301302E392E302E31310003044C494E4B53595300050541020006040307302E392E302E3130000500410403033130303130000301302E392E302E313100030442554646414C4F00050541020006040307302E392E302E3130000500410503033130303132000301312E302E302E310003044353544E00050541020006040307302E302E302E3500050541020006020307302E302E302E39000500410503033130303133000301302E302E332E3234000304414B00050541020006040307302E302E312E323400050541020006020307302E302E322E3234000500410303033130303134000301312E372E34332E33382E3200050541020006040307312E372E32332E32372E34000500410503033130303135000301312E322E31372E30000304415A5445434800050541020006040307312E322E31312E3000050541020006020307312E322E31352E30000500410303033130303230000301312E302E302E343700050541030006020308312E302E302E3233000307312E302E302E3233000500410403033130303234000301332E322E302E323800050541030006040308332E302E302E35000307332E302E302E3500050541030006020308332E312E302E31000307332E322E302E38000500410503033130303232000301302E302E302E3900030450414E41534F4E494300050541020006040307302E302E302E3100050541020006020307302E302E302E38000500410503033130303232000301302E302E302E3900030450414E41534F4E4943434F4E53554D455200050541020006040307302E302E302E3100050541020006020307302E302E302E3800 - - 1 - - 400 - - - - 8118 - 39,64,8184 - 37,50,13164 - - 1 - - 1 - - - -1431699456 - -1431699456 - 1610612735 - - 41C801050041050200D9AF0D45D9E900010400028788BCED0400038788BCED04000400050041050200BB0AB3FDD1A40001040002B7DCBCED040003B7DCBCED040004000500410502005C3766C2DA6B00010400029FB2BCED0400039FB2BCED04000400050041050200D9F8DC20CA33000104000296DAAAED04000396DAAAED0400040005004105020063847B3765900001040002D794BDED040003D794BDED040004000500410502004E80142FD3C70001040002CF86BDED040003CF86BDED04000400050041050200C3B213EA24A50001040002BF89BBED040003BF89BBED040004000500410502006FFEF1BA804C0001040002CF86BDED040003CF86BDED0400040005004105020052ED923CB3A700010400028788BCED0400038788BCED040004000500410502005243330D305B000104000283FFB2ED04000383FFB2ED040004000500410502006FF9438E9E5D0001040002CF86BDED040003CF86BDED04000400050041050200585515F19D77000104000283FFB2ED04000383FFB2ED04000400050041050200729EE3A8DD460001040002CF86BDED040003CF86BDED040004000500410502004572795D3BB300010400029FB2BCED0400039FB2BCED040004000500410502009F94D72CABA40001040002CF86BDED040003CF86BDED0400040005004105020095052D9C81090001040002B7DCBCED040003B7DCBCED040004000500410502005859A15FD7FC0001040002DC8FB5ED040003DC8FB5ED0400040005004105020059D7AB3EBBFB0001020002F8FABCED040003CF86BDED04000400050041050200BB2481B9390E0001040002CF86BDED040003CF86BDED0400040005004105020059D7F395A7BA0001040002B7DCBCED040003B7DCBCED040004000500410502006DC4BEF5D52E0001040002B0DFBAED040003B0DFBAED040004000500410502004B6E709CF4290001040002B7DCBCED040003B7DCBCED040004000500410502007A7D5CEC2B8D0001040002CF86BDED040003CF86BDED040004000500410502006FFFA8AFB19D0001040002B7DCBCED040003B7DCBCED040004000500410502003E4475A07A6F0001040002B7DCBCED040003B7DCBCED040004000500410502003EDD8384A4F90001040002BF89BBED040003BF89BBED04000400050041050200560FBFA4E4900001040002B7DCBCED040003B7DCBCED04000400050041050200C24FAEEE43F10001040002B3CEB5ED040003B3CEB5ED040004000500410502004F378778C6F30001040002CF86BDED040003CF86BDED04000400050041050200C94418BB0EDF0001040002B7DCBCED040003B7DCBCED040004000500410502003B75A58BECB30001040002CF86BDED040003CF86BDED04000400050041050200772A7A0908890001040002CF86BDED040003CF86BDED0400040005004105020048BB63586DE100010400029088BCED0400039088BCED040004000500410502005544F881BEDA000104000283FFB2ED04000383FFB2ED040004000500410502005B4C1468EDF80001040002B7DCBCED040003B7DCBCED04000400050041050200538BAF3F934F0001040002B3CEB5ED040003B3CEB5ED0400040005004105020055D6F93A4FD70001040002D7B3BBED040003D7B3BBED04000400050041050200D5D64561E55F00010400028788BCED0400038788BCED0400040005004105020046ADF229B8570001040002CF86BDED040003CF86BDED04000400050041050200D5151C19FFD600010200029FB2BCED040003B7DCBCED04000400050041050200973CA35DB82400010400029FB2BCED0400039FB2BCED04000400050041050200C249E5B953700001040002CF86BDED040003CF86BDED04000400050041050200722C69D8C4F500010400029FB2BCED0400039FB2BCED0400040005004105020058CBB311F2400001040002DC8FB5ED040003DC8FB5ED040004000500410502004BB7A090766E0001040002CF86BDED040003CF86BDED040004000500410502007DEF80FBEBD90001040002EFDDBBED040003EFDDBBED0400040005004105020076A03698F87A0001040002CF86BDED040003CF86BDED0400040005004105020050E5DFDD0C700001040002CF86BDED040003CF86BDED040004000500410502004D4C85E0CEC80001040002CF86BDED040003CF86BDED040004000500410502006FEA6BCD92A10001020002F8FABCED040003CF86BDED0400040005004105020043BAA930F28600010400029FB2BCED0400039FB2BCED04000400050041050200722DB82DDB780001040002CF86BDED040003CF86BDED0400040005004105020052E995118B9F0001040002CF86BDED040003CF86BDED040004000500410502005403013B36D20001040002EFDDBBED040003EFDDBBED04000400050041050200B27C0C920B260001040002B7DCBCED040003B7DCBCED04000400050041050200D9AF0997A7450001040002BCD9AAED040003BCD9AAED04000400050041050200BC00130BB5F60001040002CF86BDED040003CF86BDED04000400050041050200591FF23B53830001040002CF86BDED040003CF86BDED04000400050041050200557EB01367590001040002CF86BDED040003CF86BDED04000400050041050200505F157093A2000102000297A4BCED04000397A4BCED040004000500410502003A036C495C670001040002CF86BDED040003CF86BDED0400040005004105020050D8CF0B7D480001040002B7DCBCED040003B7DCBCED040004000500410502004E34E4D0FF250001040002B7DCBCED040003B7DCBCED040004000500410502007A1E50A46E770001040002CF86BDED040003CF86BDED040004000500410502005F18C666CBB80001040002EFDDBBED040003EFDDBBED04000400050041050200C19335603A9E0001040002DC8FB5ED040003DC8FB5ED0400040005004105020097142BD7DF890001040002AFDFBAED040003AFDFBAED0400040005004105020052F3355FFED400010400029FB2BCED0400039FB2BCED04000400050041050200BCBA857EECDF0001040002D7B3BBED040003D7B3BBED04000400050041050200729259D605EF0001040002CF86BDED040003CF86BDED04000400050041050200BEC2F57655B300010400029FB2BCED0400039FB2BCED040004000500410502005BD905C8304B0001020002A8EEBBED0400038788BCED0400040005004105020055F2C0360F360001040002EFDDBBED040003EFDDBBED0400040005004105020082C01DB9605D00010400028788BCED0400038788BCED04000400050041050200BC73B8FB30360001040002CF86BDED040003CF86BDED0400040005004105020050390E32DF8B0001040002B0DFBAED040003B0DFBAED040004000500410502005BCE8A2D7B8000010400028788BCED0400038788BCED0400040005004105020042292BB45D2D0001040002CF86BDED040003CF86BDED040004000500410502004F1A354DCA9A00010400029FB2BCED0400039FB2BCED04000400050041050200591C1D7F0EC900010400028788BCED0400038788BCED04000400050041050200722E9D2CCB030001040002CF86BDED040003CF86BDED04000400050041050200443AB71D3F8A0001040002CF86BDED040003CF86BDED0400040005004105020018DEF34EB70600010400028788BCED0400038788BCED0400040005004105020097215860080F00010400029FB2BCED0400039FB2BCED040004000500410502007229C156A49E0001040002B7DCBCED040003B7DCBCED040004000500410502003A72EDECB0250001040002B3F7B4ED040003B3F7B4ED04000400050041050200D52F8CD18F640001040002E285B0ED040003E285B0ED040004000500410502006B0325208B4C0001040002EFDDBBED040003EFDDBBED040004000500410502005164424285660001040002938AB5ED040003938AB5ED04000400050041050200D4E9D6AB12F80001040002AFDFBAED040003AFDFBAED0400040005004105020059B3090F459C0001040002FCDDAAED040003FCDDAAED04000400050041050200BC10C41E7AAB0001040002CF86BDED040003CF86BDED040004000500410502009F9532B560C100010400028788BCED0400038788BCED0400040005004105020050EA7B4A63750001040002CF86BDED040003CF86BDED0400040005004105020045A658245E790001040002CF86BDED040003CF86BDED0400040005004105020047E3059299620001040002CF86BDED040003CF86BDED0400040005004105020081164AFC3B450001040002CF86BDED040003CF86BDED040004000500410502005703C3FC60FF00010400028788BCED0400038788BCED0400040005004105020063FAEB02F39300010400028788BCED0400038788BCED040004000500410502005714F2D9F6650001020002AFDFBAED040003ECE7BAED04000400050041050200505F1B22B00D0001040002CF86BDED040003CF86BDED0400040005004105020062C2F2A80C7900010400029FB2BCED0400039FB2BCED04000400050041050200425CA6CCD1FF0001040002CF86BDED040003CF86BDED0400040005004105020084C778D4AB110001040002CF86BDED040003CF86BDED040004000500410502005106437CD3B60001040002CF86BDED040003CF86BDED0400040005004105020058506B2B47D40001040002D7B3BBED040003D7B3BBED04000400050041050200DD70204563390001040002B7DCBCED040003B7DCBCED040004000500410502005CFFA5BE4A0000010200028888BCED040003F8FABCED0400040005004105020089BD8692E0400001040002B7DCBCED040003B7DCBCED040004000500410502004AC12BB2AB8D0001040002B7DCBCED040003B7DCBCED04000400050041050200DB555CBAEE6B0001040002CF86BDED040003CF86BDED0400040005004105020095052D8F81090001020002A7FDBCED040003CF86BDED04000400050041050200473AA0E1C9110001020002A7FDBCED040003CF86BDED040004000500410502004EFA971D2E4C0001040002B7DCBCED040003B7DCBCED04000400050041050200BCE6C5A829D900010400029E90B5ED0400039E90B5ED0400040005004105020051699F18DC540001040002D7B3BBED040003D7B3BBED040004000500410502005CFB85D7E6460001040002B3CEB5ED040003B3CEB5ED0400040005004105020052D17CE5A9840001040002BF89BBED040003BF89BBED0400040005004105020054DD54C818F20001040002CF86BDED040003CF86BDED040004000500410502005C3555EBDC670001040002B7DCBCED040003B7DCBCED0400040005004105020051D92EE554370001040002BF89BBED040003BF89BBED0400040005004105020095549556182D0001040002CF86BDED040003CF86BDED040004000500410502005419C1F7F52A0001040002B3CEB5ED040003B3CEB5ED040004000500410502008C7259638E1D0001040002B7DCBCED040003B7DCBCED04000400050041050200516745231C2200010400029FB2BCED0400039FB2BCED0400040005004105020055FB3DEAE2380001040002B7DCBCED040003B7DCBCED040004000500410502005D5470BCB83A00010400028788BCED0400038788BCED0400040005004105020054C6D511E6810001040002CF86BDED040003CF86BDED0400040005004105020062A7FAC0119000010200028788BCED0400038888BCED040004000500410502007225A1DCFB1A00010200028788BCED0400038888BCED04000400050041050200708B358CF15C00010400028788BCED0400038788BCED04000400050041050200D9A293C3FE550001040002AFDFBAED040003AFDFBAED04000400050041050200722119BAFCB600010400029FB2BCED0400039FB2BCED0400040005004105020054369C95EAC60001040002CF86BDED040003CF86BDED04000400050041050200AE74419813810001040002B7DCBCED040003B7DCBCED0400040005004105020048C613BC68510001040002EFDDBBED040003EFDDBBED04000400050041050200516E168D638B0001040002EFDDBBED040003EFDDBBED040004000500410502001819CFB484D20001040002CF86BDED040003CF86BDED04000400050041050200ADE013B3E9F10001040002CF86BDED040003CF86BDED040004000500410502005C708ABFAC890001040002B3CEB5ED040003B3CEB5ED04000400050041050200BC81882E891C0001040002B7DCBCED040003B7DCBCED0400040005004105020057785543EB480001040002CF86BDED040003CF86BDED040004000500410502006FF0CE6CB4500001040002CF86BDED040003CF86BDED040004000500410502005CE13B7199D4000102000283ADE7E304000383ADE7E30400040005004105020063F610137D170001040002B7DCBCED040003B7DCBCED04000400050041050200DC887BC89E210001040002CF86BDED040003CF86BDED040004000500410502005D9324151E7F0001020002A7FDBCED040003CF86BDED04000400050041050200BC02D363924D00010400029FB2BCED0400039FB2BCED040004000500410502004F28848E1AC50001040002CF86BDED040003CF86BDED0400040005004105020054C606DD0D260001040002D984B5ED040003D984B5ED04000400050041050200D5F586558C850001040002BF89BBED040003BF89BBED0400040005004105020082582B0468CF00010400028788BCED0400038788BCED040004000500410502005CE21BB9BD7C00010400029FB2BCED0400039FB2BCED0400040005004105020059A9ACE3BC02000104000296DAAAED04000396DAAAED040004000500410502005557DB28EDA300010400028788BCED0400038788BCED0400040005004105020076ABA00FF52C0001040002CF86BDED040003CF86BDED0400040005004105020052185C5CB8440001040002B7DCBCED040003B7DCBCED04000400050041050200441402A770A800010200028788BCED0400038888BCED04000400050041050200516623CC99760001040002CF86BDED040003CF86BDED040004000500410502005A3D6D867C2A0001040002BF89BBED040003BF89BBED04000400050041050200BC70864FCE530001040002B3F7B4ED040003B3F7B4ED040004000500410502005E9C9B4E7A740001040002CF86BDED040003CF86BDED0400040005004105020058ABF63F0EA70001040002FCDDAAED040003FCDDAAED040004000500410502005556BDBE86AC000104000286FFB2ED04000386FFB2ED0400040005004105020059D0D49C9B8000010400028788BCED0400038788BCED0400040005004105020059A934952E920001040002B3F7B4ED040003B3F7B4ED040004000500410502007220ABEC82C80001040002B7DCBCED040003B7DCBCED04000400050041050200807AB45544310001040002BF89BBED040003BF89BBED04000400050041050200187A8DFCCDCF0001040002BF89BBED040003BF89BBED04000400050041050200616B5C35801000010400028788BCED0400038788BCED040004000500410502005ABCE5EAE3790001040002938AB5ED040003938AB5ED0400040005004105020048DF5F3311D10001020002F8FABCED040003CF86BDED04000400050041050200D3146B24D6340001040002CF86BDED040003CF86BDED0400040005004105020059037023AC7D00010400029FB2BCED0400039FB2BCED040004000500410502003EDD92C929340001040002BF89BBED040003BF89BBED040004000500410502004C4EB0C1270D0001040002CF86BDED040003CF86BDED04000400050041050200BCA300CD17370001040002CF86BDED040003CF86BDED040004000500410502005BC42D9E789A0001040002D7B3BBED040003D7B3BBED04000400050041050200589755D3E75F0001020002D884B5ED040003B3CEB5ED040004000500410502007A7CC86B21530001040002CF86BDED040003CF86BDED040004000500410502005352A2DA24D300010400028788BCED0400038788BCED0400040005004105020058C9F9B6A86F0001040002B7DCBCED040003B7DCBCED040004000500410502005706A79DEAE60001020002AFDFBAED040003ECE7BAED0400040005004105020082D1B28F7A3A0001040002CF86BDED040003CF86BDED0400040005004105020052217343E79C0001040002CF86BDED040003CF86BDED0400040005004105020082CEA3A289FE000104000296DAAAED04000396DAAAED04000400050041050200D9E0FF79D1180001040002B7DCBCED040003B7DCBCED0400040005004105020052FD31513EE90001040002938AB5ED040003938AB5ED0400040005004105020052128CCDBA7C00010400029FB2BCED0400039FB2BCED040004000500410502006FB83DA167580001040002CF86BDED040003CF86BDED040004000500410502002E14B9387F540001020002B7DCBCED040003CF86BDED040004000500410502004F7E6F098A990001040002CF86BDED040003CF86BDED040004000500410502005D98B7099E1F0001040002B7DCBCED040003B7DCBCED04000400050041050200722A7476317600010400029FB2BCED0400039FB2BCED04000400050041050200BC18CE5EBDA10001020002AFDFBAED040003ECE7BAED040004000500410502005CF890CF3E270001040002B7DCBCED040003B7DCBCED040004000500410502008D72AE6DBEE30001040002CF86BDED040003CF86BDED0400040005004105020076A6D8E9EAAB0001040002CF86BDED040003CF86BDED04000400050041050200721B63925A140001040002CF86BDED040003CF86BDED040004000500410502007608B348A53A0001040002CF86BDED040003CF86BDED04000400 - - 0 - - -645574544 - 0 - 47500 - - 1 - - - 217.133.80.112:1076 217.133.80.112:47500 217.133.80.112:1083 217.133.80.112:1083 217.133.80.112:49734 - 7 - - <_1303289856>6C81442204F3D9855070B98CAE5879A505F3D9855070B98C4D4320134B66D9855070B98C5F4E60ED0D34D98550700434 - <_1303293952>4287274ED659D9855070B98C4287274ED74BD9855070B98C4287274EC15CD9855070B98C4287274ECE92D9855070B98C4287274EA75BD9855070B98C4287274E4B98D9855070B98C4287274EAA2DD9855070B98C4287274EA175D9855070B98C4287274ED735D9855070B98C4287274EAE25D9855070B98C4287274E1A2BD9855070B98C3D7D44372576D9855070B98CCF86DF304366D9855070B98C3D2E02A2259CD9855070B98C4287274EB98CD9855070B98C - <_1303298048>2E3363049108D9855070B98C2E3795FA3202D9855070B98C2E2F6F42E86DD9855070B98CB4B0620AA528D9855070B98C - <_1303306240>5F1894D8122BD9855070B98C2E40484969A3D9855070B98CD592A70A5566D9855070B98C2E26119F8DBED9855070B98C2E3754264E48D9855070B98C - <_1303314432>4D2BFFCAEC6CD9855070043B54BAD08D05E0D9855070B98C9D9D4DA11995D9855070B98C59584CCBB5CED9855070B98C972AC71733DDD9855070B98C - <_1303322624>5F3B0DCEB535D9855070043BD5150C1746D3D9855070B98C4D4B8646EF29D9855070B98CD5152F4D12BBD9855070B98C - <_1303326720>59D0D11D89DCD9855070C2462E755D8E1E97D9855070B98C2E492F875789D9855070B98C2E378784E9C6D9855070B98C2E2F6F6B48FCD9855070B98C - - - <_1303289856>9A4A56D31C619325C6601C71B23E13FDFAF5CA49F15C34A4E33F239B524D6BBC226021F010D2270A3B48DFA2E8CDB6FD37531B1118DB2D471CB980D0 - <_1303293952>D5A2186D0B45088ADDFA7B626C0904CED47E3DF13172672AED483E1EAD69DB781ABEC0D8812B1B5EFF91BC28C67FB5A3404D875A - <_1303298048>DB0EC5161D10171C7C6A4C7109DD - <_1303302144>5379BD98 - <_1303306240>88B19442A48D863ED54D712EEC36D53127BCE36653FE - <_1303310336>1908404B0F7BA3BE952CB1C533456D3CDA410BCB774AF93880FB8BD8C110 - <_1303314432>4B015AD444DD027FD3F61B2A51A53BA0 - <_1303322624>878BAF81A9F053B39E35081485E24B4EDA5F79D37E176C409B6E237A336451F42CFA7CEC013C98A18B51 - <_1303326720>CFB137906F6CCE77246BD5B6B434875570B1F9B9140C85D5114EE6953110B04F3557C0D1686D46A9F69106521979AE49E19F8622F93A - <_1303330816>BA4B81F735FDCDA4E4EF57ACF8A37051C66401E41CA4E562A5A49ACC2E246CCE - - - - 1 - - - 1 - - - 0 - - - 1 - - - - 9BF92EA4B417A7F6 - - - 4102030E322F322E302E302E37322F31373400000FF6EB9ADC04 - - - 0 - - - - 2 - en - - 357 - 258 - 0 - 0 - - 0 - - diff --git a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameA/config.lck b/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameA/config.lck deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameA/config.xml b/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameA/config.xml deleted file mode 100644 index f7af8873ad..0000000000 --- a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameA/config.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - - - 300 - 1800 - 63 - - - 41010300676D6172757A7A3400 - 1268962216 - - - 0 - 0 - 1303202372 - 0 - -

- 35716ecf:2 - 98e6c103:0 -

- -
-
- - 1 - 3 - 65535 - 1266110339 - - - 1 - - - 1 - - - 1000000166 - 1303166852 - 1303209779 - - - 1267114269 - - 2 - - 4109008620EBA4DDDB0400FA0100009E2001009420FB09008520B1A58BDD04008120CCD9E6E3040093209B0A00F501820200F801A3B608 - - - 1267114267 - 11 - 4263C0064DD5ACF9A03594DAB928D2B81510 - - - - <_59908281a5de1c9c602d40fe1f815199a1601558ebea75accdfae8b723bb342e>1303296179 23160:21600:1303209779 9589:7200:1303209779 8707:21600:1303209779 - -
- - - skypopen - - - 0 - 2 - 2 - 2 - -
diff --git a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameA/httpfe/cookies.dat b/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameA/httpfe/cookies.dat deleted file mode 100644 index fc7f2b1150..0000000000 --- a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameA/httpfe/cookies.dat +++ /dev/null @@ -1 +0,0 @@ -B \ No newline at end of file diff --git a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameA/index2.dat b/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameA/index2.dat deleted file mode 100644 index b8b96d84318e540df1ace348fe21db2b6bc5db1c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 208 zcmXwuNdbT`5X8FNmjYy9pe~S#BNQM2CZ)5VNwV*L#B-llsu$ko2Zk2aTXAXCJ2}n& hUQDwOVw!yv)9jO&W}n40`y!^<5k^1s4DS diff --git a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameA/main.lock b/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameA/main.lock deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameB/config.lck b/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameB/config.lck deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameB/config.xml b/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameB/config.xml deleted file mode 100644 index f7af8873ad..0000000000 --- a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameB/config.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - - - 300 - 1800 - 63 - - - 41010300676D6172757A7A3400 - 1268962216 - - - 0 - 0 - 1303202372 - 0 - -

- 35716ecf:2 - 98e6c103:0 -

- -
-
- - 1 - 3 - 65535 - 1266110339 - - - 1 - - - 1 - - - 1000000166 - 1303166852 - 1303209779 - - - 1267114269 - - 2 - - 4109008620EBA4DDDB0400FA0100009E2001009420FB09008520B1A58BDD04008120CCD9E6E3040093209B0A00F501820200F801A3B608 - - - 1267114267 - 11 - 4263C0064DD5ACF9A03594DAB928D2B81510 - - - - <_59908281a5de1c9c602d40fe1f815199a1601558ebea75accdfae8b723bb342e>1303296179 23160:21600:1303209779 9589:7200:1303209779 8707:21600:1303209779 - -
- - - skypopen - - - 0 - 2 - 2 - 2 - -
diff --git a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameB/httpfe/cookies.dat b/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameB/httpfe/cookies.dat deleted file mode 100644 index fc7f2b1150..0000000000 --- a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameB/httpfe/cookies.dat +++ /dev/null @@ -1 +0,0 @@ -B \ No newline at end of file diff --git a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameB/index2.dat b/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameB/index2.dat deleted file mode 100644 index b8b96d84318e540df1ace348fe21db2b6bc5db1c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 208 zcmXwuNdbT`5X8FNmjYy9pe~S#BNQM2CZ)5VNwV*L#B-llsu$ko2Zk2aTXAXCJ2}n& hUQDwOVw!yv)9jO&W}n40`y!^<5k^1s4DS diff --git a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameB/main.lock b/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameB/main.lock deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameC/config.lck b/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameC/config.lck deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameC/config.xml b/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameC/config.xml deleted file mode 100644 index f7af8873ad..0000000000 --- a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameC/config.xml +++ /dev/null @@ -1,74 +0,0 @@ - - - - - 300 - 1800 - 63 - - - 41010300676D6172757A7A3400 - 1268962216 - - - 0 - 0 - 1303202372 - 0 - -

- 35716ecf:2 - 98e6c103:0 -

- -
-
- - 1 - 3 - 65535 - 1266110339 - - - 1 - - - 1 - - - 1000000166 - 1303166852 - 1303209779 - - - 1267114269 - - 2 - - 4109008620EBA4DDDB0400FA0100009E2001009420FB09008520B1A58BDD04008120CCD9E6E3040093209B0A00F501820200F801A3B608 - - - 1267114267 - 11 - 4263C0064DD5ACF9A03594DAB928D2B81510 - - - - <_59908281a5de1c9c602d40fe1f815199a1601558ebea75accdfae8b723bb342e>1303296179 23160:21600:1303209779 9589:7200:1303209779 8707:21600:1303209779 - -
- - - skypopen - - - 0 - 2 - 2 - 2 - -
diff --git a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameC/httpfe/cookies.dat b/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameC/httpfe/cookies.dat deleted file mode 100644 index fc7f2b1150..0000000000 --- a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameC/httpfe/cookies.dat +++ /dev/null @@ -1 +0,0 @@ -B \ No newline at end of file diff --git a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameC/index2.dat b/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameC/index2.dat deleted file mode 100644 index b8b96d84318e540df1ace348fe21db2b6bc5db1c..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 208 zcmXwuNdbT`5X8FNmjYy9pe~S#BNQM2CZ)5VNwV*L#B-llsu$ko2Zk2aTXAXCJ2}n& hUQDwOVw!yv)9jO&W}n40`y!^<5k^1s4DS diff --git a/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameC/main.lock b/src/mod/endpoints/mod_skypopen/configs/skype-client-configuration-dir-template/skypeclient01/skypenameC/main.lock deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/src/mod/endpoints/mod_skypopen/configs/skypopen.conf.xml b/src/mod/endpoints/mod_skypopen/configs/skypopen.conf.xml deleted file mode 100644 index c03fd718e0..0000000000 --- a/src/mod/endpoints/mod_skypopen/configs/skypopen.conf.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/src/mod/endpoints/mod_skypopen/configs/startskype.bat b/src/mod/endpoints/mod_skypopen/configs/startskype.bat deleted file mode 100644 index 5624b02af4..0000000000 --- a/src/mod/endpoints/mod_skypopen/configs/startskype.bat +++ /dev/null @@ -1,52 +0,0 @@ -echo off -REM -REM you MUST use the new Skype (4.x) for Windows, older versions (3.x) cannot be started this way -REM -REM you have to adjust PATH to where the Skype executable is -set PATH=%PATH%;C:\Program Files\Skype\Phone\ - -echo %PATH% - -REM start a Skype client instance that will login to the Skype network using the "username password" you give to it. Here xxx would be the password and user1 the username -start Skype.exe /secondary /username:user1 /password:xxx -call wait 7 -start Skype.exe /secondary /username:user2 /password:xxx -call wait 7 -REM -REM Following Skype client instances are commented out -REM -REM start Skype.exe /secondary /username:user3 /password:xxx -REM call wait 7 -REM start Skype.exe /secondary /username:user4 /password:xxx -REM call wait 7 -REM start Skype.exe /secondary /username:user5 /password:xxx -REM call wait 7 -REM start Skype.exe /secondary /username:user6 /password:xxx -REM call wait 7 -REM start Skype.exe /secondary /username:user7 /password:xxx -REM call wait 7 -REM start Skype.exe /secondary /username:user8 /password:xxx -REM call wait 7 -REM start Skype.exe /secondary /username:user9 /password:xxx -REM call wait 7 -REM start Skype.exe /secondary /username:user10 /password:xxx -REM call wait 7 -REM start Skype.exe /secondary /username:user11 /password:xxx -REM call wait 7 -REM start Skype.exe /secondary /username:user12 /password:xxx -REM call wait 7 -REM start Skype.exe /secondary /username:user13 /password:xxx -REM call wait 7 -REM start Skype.exe /secondary /username:user14 /password:xxx -REM call wait 7 -REM start Skype.exe /secondary /username:user15 /password:xxx -REM call wait 7 -REM start Skype.exe /secondary /username:user16 /password:xxx -REM call wait 7 -REM start Skype.exe /secondary /username:user17 /password:xxx -REM call wait 7 -REM start Skype.exe /secondary /username:user18 /password:xxx -REM call wait 7 -REM start Skype.exe /secondary /username:user19 /password:xxx -REM call wait 7 -REM start Skype.exe /secondary /username:user20 /password:xxx diff --git a/src/mod/endpoints/mod_skypopen/configs/wait.bat b/src/mod/endpoints/mod_skypopen/configs/wait.bat deleted file mode 100644 index 8381230f47..0000000000 --- a/src/mod/endpoints/mod_skypopen/configs/wait.bat +++ /dev/null @@ -1,4 +0,0 @@ -REM would you believe there is no sleep() in standard windows batchfiles? -@ping 127.0.0.1 -n 2 -w 1000 > nul -@ping 127.0.0.1 -n %1% -w 1000> nul - diff --git a/src/mod/endpoints/mod_skypopen/configs/windows-service/startskype.cmd b/src/mod/endpoints/mod_skypopen/configs/windows-service/startskype.cmd deleted file mode 100644 index 505a36c4b5..0000000000 --- a/src/mod/endpoints/mod_skypopen/configs/windows-service/startskype.cmd +++ /dev/null @@ -1,61 +0,0 @@ -echo off - -REM -REM you MUST use the new Skype (4.x) for Windows, older versions (3.x) cannot be started this way -REM -REM you have to adjust PATH to where the Skype executable is -set PATH=%PATH%;C:\Program Files\Skype\Phone\ - -REM echo %PATH% - -REM start a Skype client instance that will login to the Skype network using the "username password" you give to it. -REM Here xxxx would be the password and user20 the username - -start Skype.exe /secondary /username:user20 /password:xxxx -call C:\wait.cmd 20 - -start Skype.exe /secondary /username:user19 /password:xxxx -call C:\wait.cmd 5 - -REM -REM Following Skype client instances are commented out -REM - -REM start Skype.exe /secondary /username:user18 /password:xxxx -REM call C:\wait.cmd 5 -REM start Skype.exe /secondary /username:user17 /password:xxxx -REM call C:\wait.cmd 5 -REM start Skype.exe /secondary /username:user16 /password:xxxx -REM call C:\wait.cmd 5 -REM start Skype.exe /secondary /username:user15 /password:xxxx -REM call C:\wait.cmd 5 -REM start Skype.exe /secondary /username:user14 /password:xxxx -REM call C:\wait.cmd 5 -REM start Skype.exe /secondary /username:user13 /password:xxxx -REM call C:\wait.cmd 5 -REM start Skype.exe /secondary /username:user12 /password:xxxx -REM call C:\wait.cmd 5 -REM start Skype.exe /secondary /username:user11 /password:xxxx -REM call C:\wait.cmd 5 -REM start Skype.exe /secondary /username:user10 /password:xxxx -REM call C:\wait.cmd 5 -REM start Skype.exe /secondary /username:user9 /password:xxxx -REM call C:\wait.cmd 5 -REM start Skype.exe /secondary /username:user8 /password:xxxx -REM call C:\wait.cmd 5 -REM start Skype.exe /secondary /username:user7 /password:xxxx -REM call C:\wait.cmd 5 -REM start Skype.exe /secondary /username:user6 /password:xxxx -REM call C:\wait.cmd 5 -REM start Skype.exe /secondary /username:user5 /password:xxxx -REM call C:\wait.cmd 5 -REM start Skype.exe /secondary /username:user4 /password:xxxx -REM call C:\wait.cmd 5 -REM start Skype.exe /secondary /username:user3 /password:xxxx -REM call C:\wait.cmd 5 -REM start Skype.exe /secondary /username:user2 /password:xxxx -REM call C:\wait.cmd 5 -REM start Skype.exe /secondary /username:user1 /password:xxxx -call C:\wait.cmd 120 -NET start AICCU2 -pause diff --git a/src/mod/endpoints/mod_skypopen/configs/windows-service/wait.cmd b/src/mod/endpoints/mod_skypopen/configs/windows-service/wait.cmd deleted file mode 100644 index 8381230f47..0000000000 --- a/src/mod/endpoints/mod_skypopen/configs/windows-service/wait.cmd +++ /dev/null @@ -1,4 +0,0 @@ -REM would you believe there is no sleep() in standard windows batchfiles? -@ping 127.0.0.1 -n 2 -w 1000 > nul -@ping 127.0.0.1 -n %1% -w 1000> nul - diff --git a/src/mod/endpoints/mod_skypopen/install/install.pl b/src/mod/endpoints/mod_skypopen/install/install.pl deleted file mode 100755 index e449f0ad2e..0000000000 --- a/src/mod/endpoints/mod_skypopen/install/install.pl +++ /dev/null @@ -1,365 +0,0 @@ -#!/usr/bin/perl - -my $myname ; -my $skype_download_url = "http://download.skype.com/linux/skype-4.3.0.37.tar.bz2"; -my $skype_download_pkg = "skype-4.3.0.37.tar.bz2"; -my $skype_binary_dir = "/usr/local/freeswitch/skypopen/skype-clients-symlinks-dir"; -my $skype_download_dir = "/tmp/skype_download"; -my $skype_unpacked_dir = "skype-4.3.0.37"; -my $skype_share_dir = "/usr/share/skype"; -my $freeswitch_modules_config_dir = "/usr/local/freeswitch/conf/autoload_configs"; -my $skypopen_sound_driver_dir = "/usr/local/freeswitch/skypopen/skypopen-sound-driver-dir"; -my $skype_config_dir = "/usr/local/freeswitch/skypopen/skype-clients-configuration-dir"; -my $skype_startup_dir = "/usr/local/freeswitch/skypopen/skype-clients-startup-dir"; -my $skype_symlinks_dir = "/usr/local/freeswitch/skypopen/skype-clients-symlinks-dir"; -my $skype_clients_to_be_launched = "5"; -my $skype_clients_starting_number = "100"; -my $multi_skypeusername = "one"; -my $skype_username = "your_own_skype_username"; -my $skype_password = "your_own_skype_password"; -my @skype_username_array; -my @skype_password_array; -my $sure = "nope"; - -### PRESENTATION ### -system("clear"); -printf("\n"); -printf("This is the interactive installation helper for Skypopen\n"); -printf("(http://wiki.freeswitch.org/wiki/Mod_skypopen_Skype_Endpoint_and_Trunk)\n"); -printf("\n"); -printf("Especially designed for FreeSWITCH\n"); -printf("by Giovanni Maruzzelli\n"); -printf("\n"); -printf("Please direct all questions or issues to the FreeSWITCH mailing list or Jira\n"); -printf("(http://lists.freeswitch.org/mailman/listinfo or https://freeswitch.org/jira)\n"); -printf("\n"); -printf("\n"); -printf("I'll ask you questions, giving default answers in square brackets [] if any\n"); -printf("To accept the default, just press Enter\n"); -printf("You'll be prompted to confirm your answer at each step\n"); -printf("At the end of questions, before I do anything, I'll let you review it all\n"); -printf("To abort, press Ctrl-C\n"); -printf("\n"); -printf("\n"); -printf("Let's start asking your name, so you see how the question/answer works\n"); -printf("To accept the default, just press Enter\n"); -$myname = &promptUser("Enter your name ", "Giovanni"); -system("clear"); -printf("\n"); -printf("OK %s, GREAT! Let's start real questions! (At any time, Ctrl-C to abort)\n", $myname); -printf("\n"); -printf("At the end of questions, before I do anything, I'll let you review all your answers, don't worry! :)\n"); -printf("\n"); -printf("\n"); - -### ASKING QUESTIONS ### - -printf("I'm about to download the Skype client for Linux version 2.0.0.72 for OSS\n"); -printf("nicely repackaged by Arch Linux with official Skype permission.\n"); -printf("I need to create a directory to download and unpack the Skype client\n"); -printf("To accept the default, just press Enter\n"); -$skype_download_dir = &promptUser("Enter the full path of the Skype download directory ", "$skype_download_dir"); -system("clear"); -printf("\n"); -printf("I'm about to install the Skype client\n"); -printf("I would put the binary in $skype_binary_dir and the associated files in $skype_share_dir\n"); -printf("Location of associated files is mandatory ($skype_share_dir)\n"); -printf("Location of binary is recommended ($skype_binary_dir)\n"); -printf("To accept the default, just press Enter\n"); -$skype_binary_dir = &promptUser("Enter the directory full path for Skype client binary ", "$skype_binary_dir"); -system("clear"); -printf("\n"); -printf("I'm about to create the FreeSWITCH configuration file for mod_skypopen (skypopen.conf.xml)\n"); -printf("I need to know where to put it, eg: where is the FreeSWITCH modules' config dir\n"); -printf("To accept the default, just press Enter\n"); -$freeswitch_modules_config_dir = &promptUser("Enter the directory full path for FreeSWITCH modules' config files ", "$freeswitch_modules_config_dir"); -system("clear"); -printf("\n"); -printf("I'm about to create the directory where to put our fake sound driver\n"); -printf("Location of fake sound driver directory is where you like it more :)\n"); -printf("To accept the default, just press Enter\n"); -$skypopen_sound_driver_dir = &promptUser("Enter the directory full path for fake sound driver ", "$skypopen_sound_driver_dir"); -system("clear"); -printf("\n"); -printf("I'm about to create the configuration directory needed by the Skype clients\n"); -printf("Location of Skype clients configuration directory is where you like it more :)\n"); -printf("To accept the default, just press Enter\n"); -$skype_config_dir = &promptUser("Enter the directory full path for Skype clients config ", "$skype_config_dir"); -system("clear"); -printf("\n"); -printf("I'm about to create a directory where I'll put the Skype clients startup script\n"); -printf("Location of Skype clients startup script directory is where you like it more :)\n"); -printf("To accept the default, just press Enter\n"); -$skype_startup_dir = &promptUser("Enter the directory full path for Skype clients startup script ", "$skype_startup_dir"); -system("clear"); -printf("\n"); -printf("I'm about to create the directory for symlinks needed by the Skype clients startup script\n"); -printf("Location of symlinks directory is where you like it more :)\n"); -printf("To accept the default, just press Enter\n"); -$skype_symlinks_dir = &promptUser("Enter the directory full path for Skype clients symlinks ", "$skype_symlinks_dir"); -system("clear"); -printf("\n"); -printf("How many Skype clients (channels) do you want to launch?\n"); -printf("Each Skype client will be one channel to FreeSWITCH and use approx 70MB of ram\n"); -printf("A quad core CPU can very easily support 20 or more Skype clients\n"); -printf("Each Skype client allows one concurrent call\n"); -printf("Eg: if you plan to have a max of 10 concurrent (outbound and/or inbound) Skype calls then enter 10\n"); -printf("To accept the default, just press Enter\n"); -$skype_clients_to_be_launched = &promptUser("Enter how many Skype clients will be launched ", "$skype_clients_to_be_launched"); -system("clear"); -printf("\n"); - - -while(1){ - printf("You want all of the Skype clients to use the same Skype login (skypeusername)?\n"); - printf("eg: you want all of your skypopen channels to be Bob on the Skype network, or you want channel skype01 to be Bob, channel skype02 to be Alice, etc?\n"); - printf("Please answer 'one' for all channels using the same Skype login (you'll be asked just one time for Skype login and password) or 'multi' for being asked for each channel\n"); - printf("\n"); - $multi_skypeusername = &promptUser("Enter 'one' or 'multi' ", "$multi_skypeusername"); - system("clear"); - printf("\n"); - if($multi_skypeusername eq "one" or $multi_skypeusername eq "multi"){ - last; - } -} - - -if($multi_skypeusername eq "one"){ - printf("I need the Skype username which will be used by ALL the Skype clients to be launched\n"); - printf("(That's the one-word you registered as login to the Skype network)\n"); - printf("This installer will create the needed files to launch concurrently many (or one) instances of it\n"); - printf("\n"); - printf("NB: DON'T ACCEPT the DEFAULT, write YOUR OWN\n"); - $skype_username = &promptUser("Enter the Skype clients username ", "$skype_username"); - for($count=1; $count <= $skype_clients_to_be_launched ; $count++){ - $skype_username_array[$count] = $skype_username; - } - system("clear"); - printf("\n"); - printf("I need the Skype password which will be used by ALL the Skype clients to be launched\n"); - printf("(That's the one-word you registered as password to the Skype network)\n"); - printf("\n"); - printf("NB: DON'T ACCEPT the DEFAULT, write YOUR OWN\n"); - $skype_password = &promptUser("Enter the Skype clients password ", "$skype_password"); - for($count=1; $count <= $skype_clients_to_be_launched ; $count++){ - $skype_password_array[$count] = $skype_password; - } - system("clear"); -} else { - for($count=1; $count <= $skype_clients_to_be_launched ; $count++){ - $skype_client_extension = $skype_clients_starting_number + $count ; - printf("I need the Skype username which will be used by the Skype client for channel 'skype$skype_client_extension'\n"); - printf("(That's the one-word you registered as login to the Skype network)\n"); - printf("\n"); - printf("NB: DON'T ACCEPT the DEFAULT, write YOUR OWN\n"); - $skype_username = &promptUser("Enter the Skype username for channel 'skype$skype_client_extension'", "$skype_username"); - $skype_username_array[$count] = $skype_username; - system("clear"); - printf("\n"); - printf("I need the Skype password which will be used by the Skype client 'skype$skype_client_extension'\n"); - printf("(That's the one-word you registered as password to the Skype network)\n"); - printf("\n"); - printf("NB: DON'T ACCEPT the DEFAULT, write YOUR OWN\n"); - $skype_password = &promptUser("Enter the Skype password for '$skype_username'", "$skype_password"); - $skype_password_array[$count] = $skype_password; - system("clear"); - } - -} - -### GETTING FINAL APPROVAL ### -printf("\n"); -printf("Please check the following values:\n"); -printf("\n"); -printf("directory for downloading and unpacking Skype client:\n'$skype_download_dir'\n"); -printf("directory for Skype client binary:\n'$skype_binary_dir'\n"); -printf("directory for FreeSWITCH modules' configs:\n'$freeswitch_modules_config_dir'\n"); -printf("directory for fake sound driver:\n'$skypopen_sound_driver_dir'\n"); -printf("directory for Skype clients configs:\n'$skype_config_dir'\n"); -printf("directory for Skype clients startup script:\n'$skype_startup_dir'\n"); -printf("directory for Skype clients symlinks:\n'$skype_symlinks_dir'\n"); -printf("how many Skype clients to launch: '$skype_clients_to_be_launched'\n"); -if($multi_skypeusername eq "one"){ - printf("Skype login: '$skype_username'\n"); - printf("Skype password: '$skype_password'\n"); -}else { - for($count=1; $count <= $skype_clients_to_be_launched ; $count++){ - $skype_client_extension = $skype_clients_starting_number + $count ; - printf("channel='skype$skype_client_extension' Skype login='$skype_username_array[$count]' Skype password='$skype_password_array[$count]'\n"); - } -} - -$sure = &promptUser("Are you sure you like the values? Write 'sure' for yes ", "$sure"); -if($sure ne "sure"){ - printf("No problem, please relaunch the installer and begin again\n"); - exit 0; -} -system("clear"); - -printf("\n"); -printf("GREAT! Please stand back, I'm working...\n"); -printf("\n"); - -#### EXECUTION ### - -system("mkdir -p $skype_download_dir"); -system("cd $skype_download_dir ; wget -c $skype_download_url"); -system("cd $skype_download_dir ; tar -xjf $skype_download_pkg"); - -system("mkdir -p $skype_binary_dir"); -system("cd $skype_download_dir/$skype_unpacked_dir ; cp skype $skype_binary_dir/"); - -system("mkdir -p $skype_share_dir"); -system("cd $skype_download_dir/$skype_unpacked_dir ; cp -a avatars $skype_share_dir/"); -system("cd $skype_download_dir/$skype_unpacked_dir ; cp -a sounds $skype_share_dir/"); -system("cd $skype_download_dir/$skype_unpacked_dir ; cp -a lang $skype_share_dir/"); -system("cd $skype_download_dir/$skype_unpacked_dir ; cp -a icons $skype_share_dir/"); - - -system("mkdir -p $skype_config_dir"); -system("mkdir -p $skype_startup_dir"); -system("mkdir -p $skype_symlinks_dir"); - -system("echo \"\" > $freeswitch_modules_config_dir/skypopen.conf.xml"); -system("echo \"\" >> $freeswitch_modules_config_dir/skypopen.conf.xml"); -system("echo \" \" >> $freeswitch_modules_config_dir/skypopen.conf.xml"); -system("echo \" \" >> $freeswitch_modules_config_dir/skypopen.conf.xml"); -system("echo \" \" >> $freeswitch_modules_config_dir/skypopen.conf.xml"); -system("echo \" \" >> $freeswitch_modules_config_dir/skypopen.conf.xml"); -system("echo \" \" >> $freeswitch_modules_config_dir/skypopen.conf.xml"); -system("echo \" \" >> $freeswitch_modules_config_dir/skypopen.conf.xml"); -system("echo \" \" >> $freeswitch_modules_config_dir/skypopen.conf.xml"); -system("echo \"\" >> $freeswitch_modules_config_dir/skypopen.conf.xml"); -system("echo \"\" >> $freeswitch_modules_config_dir/skypopen.conf.xml"); -system("echo \"\" >> $freeswitch_modules_config_dir/skypopen.conf.xml"); - - -system("echo \"#!/bin/sh\" > $skype_startup_dir/start_skype_clients.sh"); -system("echo >> $skype_startup_dir/start_skype_clients.sh"); -system("echo >> $skype_startup_dir/start_skype_clients.sh"); - - -for ($count = 1; $count <= $skype_clients_to_be_launched; $count++) { - $skype_client_extension = $skype_clients_starting_number + $count ; - $skype_login=$skype_username_array[$count]; - $skype_passwd=$skype_password_array[$count]; - system("ln -s $skype_binary_dir/skype $skype_symlinks_dir/skype$skype_client_extension"); - system("mkdir -p $skype_config_dir/skype$skype_client_extension"); - system("cp -a ../configs/skype-client-configuration-dir-template/skypeclient01/shared.* $skype_config_dir/skype$skype_client_extension"); - system("cp -a ../configs/skype-client-configuration-dir-template/skypeclient01/skypenameA $skype_config_dir/skype$skype_client_extension/$skype_login"); - - system("echo \" \" >> $freeswitch_modules_config_dir/skypopen.conf.xml"); - if($multi_skypeusername ne "one"){ - system("echo \" \" >> $freeswitch_modules_config_dir/skypopen.conf.xml"); - } - system("echo \" \" >> $freeswitch_modules_config_dir/skypopen.conf.xml"); - system("echo \" \" >> $freeswitch_modules_config_dir/skypopen.conf.xml"); - - system("echo \"#start the fake X server on the given port\" >> $skype_startup_dir/start_skype_clients.sh"); - system("echo \"/usr/bin/Xvfb :$skype_client_extension -ac -nolisten tcp -screen 0 640x480x8 &\" >> $skype_startup_dir/start_skype_clients.sh"); - system("echo \"sleep 3\" >> $skype_startup_dir/start_skype_clients.sh"); - system("echo \"# start a Skype client instance that will connect to the X server above, and will login to the Skype network using the 'username password' you send to it on stdin.\" >> $skype_startup_dir/start_skype_clients.sh"); - system("echo \"su root -c \\\"/bin/echo '$skype_login $skype_passwd'| DISPLAY=:$skype_client_extension $skype_symlinks_dir/skype$skype_client_extension --dbpath=$skype_config_dir/skype$skype_client_extension --pipelogin &\\\"\" >> $skype_startup_dir/start_skype_clients.sh"); - system("echo \"sleep 7\" >> $skype_startup_dir/start_skype_clients.sh"); - system("echo >> $skype_startup_dir/start_skype_clients.sh"); -} - -system("echo \"\" >> $freeswitch_modules_config_dir/skypopen.conf.xml"); -system("echo \"\" >> $freeswitch_modules_config_dir/skypopen.conf.xml"); - -system("echo \"exit 0\" >> $skype_startup_dir/start_skype_clients.sh"); - - -printf("\n"); -printf("SUCCESS!!!\n"); -printf("\n"); - - -#=========================================================================# - - -#-------------------------------------------------------------------------# -# promptUser, a Perl subroutine to prompt a user for input. -# Copyright 2010 Alvin Alexander, devdaily.com. -# This code is shared here under the -# Creative Commons Attribution-ShareAlike Unported 3.0 license. -# See http://creativecommons.org/licenses/by-sa/3.0/ for more information. -#-------------------------------------------------------------------------# - -# Original at: http://www.devdaily.com/perl/edu/articles/pl010005 -# Modified to get confirmations by Giovanni Maruzzelli - -#----------------------------( promptUser )-----------------------------# -# # -# FUNCTION: promptUser # -# # -# PURPOSE: Prompt the user for some type of input, and return the # -# input back to the calling program. # -# # -# ARGS: $promptString - what you want to prompt the user with # -# $defaultValue - (optional) a default value for the prompt # -# # -#-------------------------------------------------------------------------# - -sub promptUser { - -#-------------------------------------------------------------------# -# two possible input arguments - $promptString, and $defaultValue # -# make the input arguments local variables. # -#-------------------------------------------------------------------# - - local($promptString,$defaultValue) = @_; - local $input; - local $confirm; - local $gave; - -#-------------------------------------------------------------------# -# if there is a default value, use the first print statement; if # -# no default is provided, print the second string. # -#-------------------------------------------------------------------# - - while(1){ - printf("\n"); - if ($defaultValue) { - print $promptString, "\n[", $defaultValue, "]: "; - } else { - print $promptString, ": "; - } - - $| = 1; # force a flush after our print - $input = ; # get the input from STDIN (presumably the keyboard) - - -#------------------------------------------------------------------# -# remove the newline character from the end of the input the user # -# gave us. # -#------------------------------------------------------------------# - - chomp($input); - - $gave = $input ? $input : $defaultValue; - print("You gave: '$gave'\nIt's OK? Please answer 'Y' for yes or 'N' for not [N]: "); - $| = 1; # force a flush after our print - $confirm = ; - chomp($confirm); - if($confirm eq "Y" or $confirm eq "y"){ - last; - } - } -#-----------------------------------------------------------------# -# if we had a $default value, and the user gave us input, then # -# return the input; if we had a default, and they gave us no # -# no input, return the $defaultValue. # -# # -# if we did not have a default value, then just return whatever # -# the user gave us. if they just hit the key, # -# the calling routine will have to deal with that. # -#-----------------------------------------------------------------# - - if ("$defaultValue") { - return $input ? $input : $defaultValue; # return $_ if it has a value - } else { - return $input; - } -} - diff --git a/src/mod/endpoints/mod_skypopen/mod_skypopen.2015.vcxproj b/src/mod/endpoints/mod_skypopen/mod_skypopen.2015.vcxproj deleted file mode 100644 index bb8fd5eda9..0000000000 --- a/src/mod/endpoints/mod_skypopen/mod_skypopen.2015.vcxproj +++ /dev/null @@ -1,173 +0,0 @@ - - - - - Debug - Win32 - - - Debug - x64 - - - Release - Win32 - - - Release - x64 - - - - mod_skypopen - {C6E78A4C-DB1E-47F4-9B63-4DC27D86343F} - mod_skypopen - Win32Proj - - - - DynamicLibrary - MultiByte - v140 - - - DynamicLibrary - MultiByte - v140 - - - DynamicLibrary - MultiByte - v140 - - - DynamicLibrary - MultiByte - v140 - - - - - - - - - - - - - - - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - - - - %(RootDir)%(Directory)..\..\..\..\libs\spandsp\src\msvc;%(RootDir)%(Directory)..\..\..\..\libs\spandsp\src;%(RootDir)%(Directory)..\..\..\..\libs\jpeg-8d;%(AdditionalIncludeDirectories) - - - Level4 - false - 28252;28253;4456;6031;4324;6340;6246;6011;6387;%(DisableSpecificWarnings) - - - rpcrt4.lib "..\..\..\..\libs\spandsp\src\Win32\Debug\libtiff.lib" "..\..\..\..\Win32\Debug\libspandsp.lib" %(AdditionalOptions) - false - - - - - - - %(RootDir)%(Directory)..\..\..\..\libs\spandsp\src\msvc;%(RootDir)%(Directory)..\..\..\..\libs\spandsp\src;%(RootDir)%(Directory)..\..\..\..\libs\jpeg-8d;%(AdditionalIncludeDirectories) - - - Level4 - false - 28183;28252;28253;4456;6031;4324;6340;6246;6011;6387;%(DisableSpecificWarnings) - - - rpcrt4.lib "..\..\..\..\libs\spandsp\src\x64\Debug\libtiff.lib" "..\..\..\..\x64\Debug\libspandsp.lib" %(AdditionalOptions) - false - - - - - - - %(RootDir)%(Directory)..\..\..\..\libs\spandsp\src\msvc;%(RootDir)%(Directory)..\..\..\..\libs\spandsp\src;%(RootDir)%(Directory)..\..\..\..\libs\jpeg-8d;%(AdditionalIncludeDirectories) - - - 28252;28253;4456;6031;4324;6340;6246;6011;6387;%(DisableSpecificWarnings) - - - rpcrt4.lib "..\..\..\..\libs\spandsp\src\Win32\Release\libtiff.lib" "..\..\..\..\Win32\Release\libspandsp.lib" %(AdditionalOptions) - false - - - - - - - %(RootDir)%(Directory)..\..\..\..\libs\spandsp\src\msvc;%(RootDir)%(Directory)..\..\..\..\libs\spandsp\src;%(RootDir)%(Directory)..\..\..\..\libs\jpeg-8d;%(AdditionalIncludeDirectories) - - - 28252;28253;4456;6031;4324;6340;6246;6011;6387;%(DisableSpecificWarnings) - - - rpcrt4.lib "..\..\..\..\libs\spandsp\src\x64\Release\libtiff.lib" "..\..\..\..\x64\Release\libspandsp.lib" %(AdditionalOptions) - false - - - - - - - - - - - - - - - - - 4305;4306;28193;4244;4267;4324;6340;6246;6011;6387;%(DisableSpecificWarnings) - 4305;4306;28193;4244;4267;4324;6340;6246;6011;6387;%(DisableSpecificWarnings) - 4305;4306;28193;4244;4267;4324;6340;6246;6011;6387;%(DisableSpecificWarnings) - 4305;4306;28193;4244;4267;4324;6340;6246;6011;6387;%(DisableSpecificWarnings) - - - - - - - - - - - - - - - - {202d7a4e-760d-4d0e-afa1-d7459ced30ff} - false - - - - - - \ No newline at end of file diff --git a/src/mod/endpoints/mod_skypopen/mod_skypopen.c b/src/mod/endpoints/mod_skypopen/mod_skypopen.c deleted file mode 100644 index ccfcc0d567..0000000000 --- a/src/mod/endpoints/mod_skypopen/mod_skypopen.c +++ /dev/null @@ -1,3403 +0,0 @@ -/* - * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2011, 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_gsmopen) has been contributed by: - * - * Giovanni Maruzzelli - * - * Maintainer: Giovanni Maruzzelli - * - * mod_skypopen.c -- Skype compatible Endpoint Module - * - */ - - -#include "skypopen.h" -#define SKYPE_CHAT_PROTO "skype" - -#ifdef WIN32 -/***************/ -// from http://www.openasthra.com/c-tidbits/gettimeofday-function-for-windows/ - -#include - -#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS) -#define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64 -#else /* */ -#define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL -#endif /* */ -struct sk_timezone { - int tz_minuteswest; /* minutes W of Greenwich */ - int tz_dsttime; /* type of dst correction */ -}; -int gettimeofday(struct timeval *tv, struct sk_timezone *tz) -{ - FILETIME ft; - unsigned __int64 tmpres = 0; - static int tzflag; - if (NULL != tv) { - GetSystemTimeAsFileTime(&ft); - tmpres |= ft.dwHighDateTime; - tmpres <<= 32; - tmpres |= ft.dwLowDateTime; - - /*converting file time to unix epoch */ - tmpres /= 10; /*convert into microseconds */ - tmpres -= DELTA_EPOCH_IN_MICROSECS; - tv->tv_sec = (long) (tmpres / 1000000UL); - tv->tv_usec = (long) (tmpres % 1000000UL); - } - if (NULL != tz) { - if (!tzflag) { - _tzset(); - tzflag++; - } - tz->tz_minuteswest = _timezone / 60; - tz->tz_dsttime = _daylight; - } - return 0; -} - -/***************/ -#endif /* WIN32 */ -SWITCH_MODULE_LOAD_FUNCTION(mod_skypopen_load); -SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypopen_shutdown); -SWITCH_MODULE_DEFINITION(mod_skypopen, mod_skypopen_load, mod_skypopen_shutdown, NULL); -SWITCH_STANDARD_API(sk_function); -/* BEGIN: Changes here */ -#define SK_SYNTAX "list [full] || console || skype_API_msg || remove < skypeusername | #interface_name | #interface_id > || reload" -/* END: Changes heres */ -SWITCH_STANDARD_API(skypopen_function); -#define SKYPOPEN_SYNTAX "interface_name skype_API_msg" - -SWITCH_STANDARD_API(skypopen_chat_function); -#define SKYPOPEN_CHAT_SYNTAX "interface_name remote_skypename TEXT" -#define FULL_RELOAD 0 -#define SOFT_RELOAD 1 - -char *interface_status[] = { /* should match SKYPOPEN_STATE_xxx in skypopen.h */ - "IDLE", - "DOWN", - "RING", - "DIALING", - "BUSY", - "UP", - "RINGING", - "PRERING", - "DOUBLE", - "SELECTD", - "HANG_RQ", - "PREANSW", - "DEAD" -}; - -char *skype_callflow[] = { /* should match CALLFLOW_XXX in skypopen.h */ - "IDLE", - "DOWN", - "INC_RNG", - "CALL_DIALING", - "CALL_LINEBUSY", - "CALL_ACTIVE", - "INC_HNG", - "CALL_RLEASD", - "CALL_NOCARR", - "CALL_INFLUX", - "CALL_INCOMING", - "CALL_FAILED", - "CALL_NOSRVC", - "CALL_OUTRESTR", - "CALL_SECFAIL", - "CALL_NOANSWER", - "FNSHED", - "CANCLED", - "FAILED", - "REFUSED", - "RINGING", - "INPROGRS", - "UNPLACD", - "ROUTING", - "EARLYMD", - "INC_CLID", - "RMTEHOLD" -}; - - -static struct { - int debug; - char *context; - char *dialplan; - char *destination; - char *skype_user; - char *report_incoming_chatmessages; - char *silent_mode; - char *write_silence_when_idle; - char *setsockopt; - int calls; - int real_interfaces; - int next_interface; - private_t SKYPOPEN_INTERFACES[SKYPOPEN_MAX_INTERFACES]; - switch_mutex_t *mutex; - private_t *sk_console; - int start_port; - - // CLOUDTREE (THomas Hazel) - switch_mutex_t *list_mutex; - -} globals; - -switch_endpoint_interface_t *skypopen_endpoint_interface; -switch_memory_pool_t *skypopen_module_pool = NULL; -int running = 0; - -// CLOUDTREE (THomas Hazel) -#ifndef WIN32 -struct SkypopenList global_handles_list; -extern int xio_error_handler(Display * dpy); -extern int X11_errors_handler(Display * dpy, XErrorEvent * err); -extern int xio_error_handler2(Display * dpy, XErrorEvent * err); -#endif - -SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_context, globals.context); -SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_dialplan, globals.dialplan); -SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_destination, globals.destination); -SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_skype_user, globals.skype_user); -SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_report_incoming_chatmessages, globals.report_incoming_chatmessages); -SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_silent_mode, globals.silent_mode); -SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_write_silence_when_idle, globals.write_silence_when_idle); -SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_setsockopt, globals.setsockopt); - -static switch_status_t interface_exists(char *the_interface); -/* CLOUDTREE (Thomas Hazel) static*/ switch_status_t remove_interface(char *the_interface, /* CLOUDTREE (Thomas Hazel */ switch_bool_t force); - -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_reset(switch_core_session_t *session); -static switch_status_t channel_on_destroy(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_consume_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, - switch_call_cause_t *cancel_cause); -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 skypopen_tech_init(private_t *tech_pvt, switch_core_session_t *session); - -static switch_status_t skypopen_codec(private_t *tech_pvt, int sample_rate, int codec_ms) -{ - switch_core_session_t *session = NULL; - - if (switch_core_codec_init - (&tech_pvt->read_codec, "L16", NULL, NULL, sample_rate, codec_ms, 1, - SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, NULL) != SWITCH_STATUS_SUCCESS) { - ERRORA("skypopen_codec: Can't load codec?\n", SKYPOPEN_P_LOG); - return SWITCH_STATUS_FALSE; - } - - if (switch_core_codec_init - (&tech_pvt->write_codec, "L16", NULL, NULL, sample_rate, codec_ms, 1, - SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL, NULL) != SWITCH_STATUS_SUCCESS) { - ERRORA("skypopen_codec: Can't load codec?\n", SKYPOPEN_P_LOG); - 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; - - session = switch_core_session_locate(tech_pvt->session_uuid_str); - - if (session) { - switch_core_session_set_read_codec(session, &tech_pvt->read_codec); - switch_core_session_set_write_codec(session, &tech_pvt->write_codec); - switch_core_session_rwunlock(session); - } else { - ERRORA("skypopen_codec: no session\n", SKYPOPEN_P_LOG); - return SWITCH_STATUS_FALSE; - } - - DEBUGA_SKYPE("codecs UP\n", SKYPOPEN_P_LOG); - return SWITCH_STATUS_SUCCESS; - -} - -switch_status_t skypopen_tech_init(private_t *tech_pvt, switch_core_session_t *session) -{ - - switch_assert(tech_pvt != NULL); - switch_assert(session != NULL); - 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); - switch_copy_string(tech_pvt->session_uuid_str, switch_core_session_get_uuid(session), sizeof(tech_pvt->session_uuid_str)); - if (!strlen(tech_pvt->session_uuid_str)) { - ERRORA("skypopen_tech_init: no tech_pvt->session_uuid_str\n", SKYPOPEN_P_LOG); - return SWITCH_STATUS_FALSE; - } - if (skypopen_codec(tech_pvt, SAMPLERATE_SKYPOPEN, MS_SKYPOPEN) != SWITCH_STATUS_SUCCESS) { - ERRORA("skypopen_tech_init: skypopen_codec FAILED\n", SKYPOPEN_P_LOG); - return SWITCH_STATUS_FALSE; - } - - dtmf_rx_init(&tech_pvt->dtmf_state, NULL, NULL); - dtmf_rx_parms(&tech_pvt->dtmf_state, 0, 10, 10, -99); - - - DEBUGA_SKYPE("skypopen_tech_init SUCCESS\n", SKYPOPEN_P_LOG); - return SWITCH_STATUS_SUCCESS; -} - -static switch_status_t interface_exists(char *the_interface) -{ - int i; - int interface_id; - - if (*the_interface == '#') { /* look by interface id or interface name */ - the_interface++; - switch_assert(the_interface); - interface_id = atoi(the_interface); - - /* take a number as interface id */ - if (interface_id > 0 || (interface_id == 0 && strcmp(the_interface, "0") == 0)) { - if (strlen(globals.SKYPOPEN_INTERFACES[interface_id].name)) { - return SWITCH_STATUS_SUCCESS; - } - } else { - /* interface name */ - for (interface_id = 0; interface_id < SKYPOPEN_MAX_INTERFACES; interface_id++) { - if (strcmp(globals.SKYPOPEN_INTERFACES[interface_id].name, the_interface) == 0) { - return SWITCH_STATUS_SUCCESS; - break; - } - } - } - } else { /* look by skype_user */ - - - for (i = 0; i < SKYPOPEN_MAX_INTERFACES; i++) { - if (strlen(globals.SKYPOPEN_INTERFACES[i].skype_user)) { - if (strcmp(globals.SKYPOPEN_INTERFACES[i].skype_user, the_interface) == 0) { - return SWITCH_STATUS_SUCCESS; - } - } - } - } - return SWITCH_STATUS_FALSE; -} - -/* CLOUDTREE (Thomas Hazel) static */ switch_status_t remove_interface(char *the_interface, /* CLOUDTREE (Thomas Hazel) */ switch_bool_t force) -{ - int x = 10; - switch_size_t howmany = 8; - int interface_id = -1; - private_t *tech_pvt = NULL; - switch_status_t status; - - - if (*the_interface == '#') { /* remove by interface id or interface name */ - the_interface++; - switch_assert(the_interface); - interface_id = atoi(the_interface); - - if (interface_id > 0 || (interface_id == 0 && strcmp(the_interface, "0") == 0)) { - /* take a number as interface id */ - tech_pvt = &globals.SKYPOPEN_INTERFACES[interface_id]; - } else { - - for (interface_id = 0; interface_id < SKYPOPEN_MAX_INTERFACES; interface_id++) { - if (strcmp(globals.SKYPOPEN_INTERFACES[interface_id].name, the_interface) == 0) { - tech_pvt = &globals.SKYPOPEN_INTERFACES[interface_id]; - break; - } - } - } - } else { /* remove by skype_user */ - for (interface_id = 0; interface_id < SKYPOPEN_MAX_INTERFACES; interface_id++) { - if (strcmp(globals.SKYPOPEN_INTERFACES[interface_id].skype_user, the_interface) == 0) { - tech_pvt = &globals.SKYPOPEN_INTERFACES[interface_id]; - break; - } - } - } - - if (!tech_pvt) { - DEBUGA_SKYPE("interface '%s' does not exist\n", SKYPOPEN_P_LOG, the_interface); - goto end; - } - - if ( /* CLOUDTREE (Thomas Hazel) */ (force == FALSE) && strlen(globals.SKYPOPEN_INTERFACES[interface_id].session_uuid_str)) { - DEBUGA_SKYPE("interface '%s' is busy\n", SKYPOPEN_P_LOG, the_interface); - goto end; - } - - globals.SKYPOPEN_INTERFACES[interface_id].running = 0; - - tech_pvt->interface_state = SKYPOPEN_STATE_DEAD; - - if (globals.SKYPOPEN_INTERFACES[interface_id].skypopen_signaling_thread) { -#ifdef WIN32 - skypopen_signaling_write(tech_pvt, "DIE"); - switch_sleep(20000); - switch_file_write(tech_pvt->SkypopenHandles.fdesc[1], "sciutati", &howmany); // let's the controldev_thread die -#else /* WIN32 */ - howmany = write(tech_pvt->SkypopenHandles.fdesc[1], "sciutati", howmany); -#endif /* WIN32 */ - } - - if (globals.SKYPOPEN_INTERFACES[interface_id].skypopen_api_thread) { -#ifdef WIN32 - if (SendMessage(tech_pvt->SkypopenHandles.win32_hInit_MainWindowHandle, WM_DESTROY, 0, 0) == FALSE) { // let's the skypopen_api_thread_func die - DEBUGA_SKYPE("got FALSE here, thread probably was already dead. GetLastError returned: %d\n", SKYPOPEN_P_LOG, GetLastError()); - globals.SKYPOPEN_INTERFACES[interface_id].skypopen_api_thread = NULL; - } -#else - if (tech_pvt->running && tech_pvt->SkypopenHandles.disp) { - XEvent e; - Atom atom1 = XInternAtom(tech_pvt->SkypopenHandles.disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", False); - switch_sleep(20000); - XFlush(tech_pvt->SkypopenHandles.disp); - memset(&e, 0, sizeof(e)); - e.xclient.type = ClientMessage; - e.xclient.message_type = atom1; /* leading message */ - e.xclient.display = tech_pvt->SkypopenHandles.disp; - e.xclient.window = tech_pvt->SkypopenHandles.skype_win; - e.xclient.format = 8; - - XSendEvent(tech_pvt->SkypopenHandles.disp, tech_pvt->SkypopenHandles.win, False, 0, &e); - XFlush(tech_pvt->SkypopenHandles.disp); - } -#endif - } - - while (x) { - x--; - switch_yield(50000); - } - -#ifndef WIN32 - if (tech_pvt->SkypopenHandles.disp) { - } -#endif - - if (globals.SKYPOPEN_INTERFACES[interface_id].skypopen_signaling_thread) { - switch_thread_join(&status, globals.SKYPOPEN_INTERFACES[interface_id].skypopen_signaling_thread); - } - - if (globals.SKYPOPEN_INTERFACES[interface_id].skypopen_api_thread) { - switch_thread_join(&status, globals.SKYPOPEN_INTERFACES[interface_id].skypopen_api_thread); - } - - switch_mutex_lock(globals.mutex); - if (globals.sk_console == &globals.SKYPOPEN_INTERFACES[interface_id]) { - DEBUGA_SKYPE("interface '%s' no more console\n", SKYPOPEN_P_LOG, the_interface); - globals.sk_console = NULL; - } else { - DEBUGA_SKYPE("interface '%s' STILL console\n", SKYPOPEN_P_LOG, the_interface); - } - if (strlen(tech_pvt->session_uuid_str)) { - - } else { - memset(&globals.SKYPOPEN_INTERFACES[interface_id], '\0', sizeof(private_t)); - } - globals.real_interfaces--; - switch_mutex_unlock(globals.mutex); - - DEBUGA_SKYPE("interface '%s' deleted successfully\n", SKYPOPEN_P_LOG, the_interface); - globals.SKYPOPEN_INTERFACES[interface_id].running = 1; - end: - return SWITCH_STATUS_SUCCESS; -} - - -/* - 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) -{ - switch_channel_t *channel; - private_t *tech_pvt = NULL; - - tech_pvt = switch_core_session_get_private(session); - switch_assert(tech_pvt != NULL); - - channel = switch_core_session_get_channel(session); - switch_assert(channel != NULL); - memset(tech_pvt->skype_voicemail_id, '\0', sizeof(tech_pvt->skype_voicemail_id)); - memset(tech_pvt->skype_voicemail_id_greeting, '\0', sizeof(tech_pvt->skype_voicemail_id_greeting)); - switch_channel_set_variable(channel, "skype_user", tech_pvt->skype_user); - switch_mutex_lock(tech_pvt->flag_mutex); - switch_set_flag(tech_pvt, TFLAG_IO); - switch_mutex_unlock(tech_pvt->flag_mutex); - - DEBUGA_SKYPE("%s CHANNEL INIT %s\n", SKYPOPEN_P_LOG, tech_pvt->name, switch_core_session_get_uuid(session)); - switch_copy_string(tech_pvt->session_uuid_str, switch_core_session_get_uuid(session), sizeof(tech_pvt->session_uuid_str)); - - return SWITCH_STATUS_SUCCESS; -} - -static switch_status_t channel_on_destroy(switch_core_session_t *session) -{ - private_t *tech_pvt = NULL; - switch_status_t status; - int conta; - - tech_pvt = switch_core_session_get_private(session); - - - if (tech_pvt) { - DEBUGA_SKYPE("%s CHANNEL DESTROY %s\n", SKYPOPEN_P_LOG, tech_pvt->name, switch_core_session_get_uuid(session)); - - if (tech_pvt->interface_state != SKYPOPEN_STATE_DEAD) { - tech_pvt->interface_state = SKYPOPEN_STATE_DOWN; - } - - switch_mutex_lock(tech_pvt->flag_mutex); - switch_clear_flag(tech_pvt, TFLAG_IO); - switch_clear_flag(tech_pvt, TFLAG_VOICE); - if (switch_test_flag(tech_pvt, TFLAG_PROGRESS)) { - switch_clear_flag(tech_pvt, TFLAG_PROGRESS); - } - switch_mutex_unlock(tech_pvt->flag_mutex); - - DEBUGA_SKYPE("audio tcp threads to DIE\n", SKYPOPEN_P_LOG); - conta = 0; - while (tech_pvt->tcp_srv_thread) { - switch_sleep(50000); - conta++; - if (conta == 20) { - ERRORA("tcp_srv_thread is NOT dead, this can LEAK MEMORY\n", SKYPOPEN_P_LOG); - break; - } - } - DEBUGA_SKYPE("audio tcp srv thread DEAD %d\n", SKYPOPEN_P_LOG, conta); - conta = 0; - while (tech_pvt->tcp_cli_thread) { - switch_sleep(50000); - conta++; - if (conta == 20) { - ERRORA("tcp_cli_thread is NOT dead, this can LEAK MEMORY\n", SKYPOPEN_P_LOG); - break; - } - } - DEBUGA_SKYPE("audio tcp cli thread DEAD %d\n", SKYPOPEN_P_LOG, conta); - - - if (switch_core_codec_ready(&tech_pvt->read_codec)) { - switch_core_codec_destroy(&tech_pvt->read_codec); - } - - if (switch_core_codec_ready(&tech_pvt->write_codec)) { - switch_core_codec_destroy(&tech_pvt->write_codec); - } - - DEBUGA_SKYPE("codecs DOWN\n", SKYPOPEN_P_LOG); - if (tech_pvt->timer_read.timer_interface && tech_pvt->timer_read.timer_interface->timer_next) { - switch_core_timer_destroy(&tech_pvt->timer_read); - } - - if (tech_pvt->timer_read_srv.timer_interface && tech_pvt->timer_read_srv.timer_interface->timer_next) { - switch_core_timer_destroy(&tech_pvt->timer_read_srv); - } - - if (tech_pvt->timer_write.timer_interface && tech_pvt->timer_write.timer_interface->timer_next) { - switch_core_timer_destroy(&tech_pvt->timer_write); - } - - if (tech_pvt->read_buffer) { - switch_buffer_destroy(&tech_pvt->read_buffer); - } - if (tech_pvt->write_buffer) { - switch_buffer_destroy(&tech_pvt->write_buffer); - } - //DEBUGA_SKYPE("debugging_hangup 13\n", SKYPOPEN_P_LOG); - switch_mutex_lock(tech_pvt->mutex_thread_audio_cli); - //DEBUGA_SKYPE("debugging_hangup cli lock\n", SKYPOPEN_P_LOG); - if (tech_pvt->tcp_cli_thread) { - //DEBUGA_SKYPE("debugging_hangup 14\n", SKYPOPEN_P_LOG); - switch_thread_join(&status, tech_pvt->tcp_cli_thread); - tech_pvt->tcp_cli_thread = NULL; - //DEBUGA_SKYPE("debugging_hangup 15\n", SKYPOPEN_P_LOG); - } - switch_mutex_unlock(tech_pvt->mutex_thread_audio_cli); - //DEBUGA_SKYPE("debugging_hangup cli unlock\n", SKYPOPEN_P_LOG); - switch_mutex_lock(tech_pvt->mutex_thread_audio_srv); - //DEBUGA_SKYPE("debugging_hangup srv lock\n", SKYPOPEN_P_LOG); - if (tech_pvt->tcp_srv_thread) { - //DEBUGA_SKYPE("debugging_hangup 16\n", SKYPOPEN_P_LOG); - switch_thread_join(&status, tech_pvt->tcp_srv_thread); - tech_pvt->tcp_srv_thread = NULL; - //DEBUGA_SKYPE("debugging_hangup 17\n", SKYPOPEN_P_LOG); - } - switch_mutex_unlock(tech_pvt->mutex_thread_audio_srv); - //DEBUGA_SKYPE("debugging_hangup srv unlock\n", SKYPOPEN_P_LOG); - //DEBUGA_SKYPE("debugging_hangup 18\n", SKYPOPEN_P_LOG); - - *tech_pvt->session_uuid_str = '\0'; - - if (tech_pvt->interface_state != SKYPOPEN_STATE_DEAD) { - tech_pvt->interface_state = SKYPOPEN_STATE_IDLE; - tech_pvt->skype_callflow = CALLFLOW_CALL_IDLE; - } else { - memset(tech_pvt, '\0', sizeof(private_t)); - } - switch_core_session_set_private(session, NULL); - } else { - DEBUGA_SKYPE("!!!!!!NO tech_pvt!!!! CHANNEL DESTROY %s\n", SKYPOPEN_P_LOG, switch_core_session_get_uuid(session)); - } - - DEBUGA_SKYPE("CHANNEL DESTROYED %s\n", SKYPOPEN_P_LOG, switch_core_session_get_uuid(session)); - 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; - char msg_to_skype[256]; - //switch_status_t status; - - - channel = switch_core_session_get_channel(session); - switch_assert(channel != NULL); - - tech_pvt = switch_core_session_get_private(session); - - //DEBUGA_SKYPE("debugging_hangup 1\n", SKYPOPEN_P_LOG); - - if (tech_pvt) { - if (tech_pvt->interface_state == SKYPOPEN_STATE_DEAD) { - return SWITCH_STATUS_SUCCESS; - } - if (!switch_channel_test_flag(channel, CF_ANSWERED)) { - if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) { - tech_pvt->ob_failed_calls++; - } else { - tech_pvt->ib_failed_calls++; - } - } - - tech_pvt->interface_state = SKYPOPEN_STATE_HANGUP_REQUESTED; - switch_mutex_lock(tech_pvt->flag_mutex); - switch_clear_flag(tech_pvt, TFLAG_IO); - switch_clear_flag(tech_pvt, TFLAG_VOICE); - if (switch_test_flag(tech_pvt, TFLAG_PROGRESS)) { - switch_clear_flag(tech_pvt, TFLAG_PROGRESS); - } - switch_mutex_unlock(tech_pvt->flag_mutex); - - - //DEBUGA_SKYPE("debugging_hangup 2\n", SKYPOPEN_P_LOG); - - if (strlen(tech_pvt->skype_call_id)) { - DEBUGA_SKYPE("hanging up skype call: %s\n", SKYPOPEN_P_LOG, tech_pvt->skype_call_id); - if(strlen(tech_pvt->skype_voicemail_id_greeting)){ - sprintf(msg_to_skype, "ALTER VOICEMAIL %s STOPPLAYBACK", tech_pvt->skype_voicemail_id_greeting); - skypopen_signaling_write(tech_pvt, msg_to_skype); - switch_sleep(MS_SKYPOPEN * 1000 * 100);//XXX FIXME 2000 millisecs, 2 seconds, so it will record at least 1 second - } - - if(strlen(tech_pvt->skype_voicemail_id_greeting)){ - sprintf(msg_to_skype, "ALTER VOICEMAIL %s DELETE", tech_pvt->skype_voicemail_id_greeting); - skypopen_signaling_write(tech_pvt, msg_to_skype); - switch_sleep(MS_SKYPOPEN * 1000 * 10);//XXX FIXME 200 millisecs - } - if(strlen(tech_pvt->skype_voicemail_id)){ - sprintf(msg_to_skype, "ALTER VOICEMAIL %s STOPRECORDING", tech_pvt->skype_voicemail_id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - switch_sleep(MS_SKYPOPEN * 1000 * 10);//XXX FIXME 200 millisecs - } - sprintf(msg_to_skype, "ALTER CALL %s HANGUP", tech_pvt->skype_call_id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", tech_pvt->skype_call_id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - } - DEBUGA_SKYPE("%s CHANNEL HANGUP\n", SKYPOPEN_P_LOG, tech_pvt->name); - switch_mutex_lock(globals.mutex); - globals.calls--; - if (globals.calls < 0) { - globals.calls = 0; - } - //DEBUGA_SKYPE("debugging_hangup 9\n", SKYPOPEN_P_LOG); - tech_pvt->interface_state = SKYPOPEN_STATE_DOWN; - if (tech_pvt->skype_callflow == CALLFLOW_STATUS_FINISHED) { - tech_pvt->skype_callflow = CALLFLOW_CALL_IDLE; - } - //DEBUGA_SKYPE("debugging_hangup 10\n", SKYPOPEN_P_LOG); - switch_mutex_unlock(globals.mutex); - } else { - WARNINGA("FYI %s CHANNEL has no tech_pvt in his private\n", SKYPOPEN_P_LOG, switch_channel_get_name(channel)); - //DEBUGA_SKYPE("debugging_hangup 11\n", SKYPOPEN_P_LOG); - } - //DEBUGA_SKYPE("debugging_hangup 12\n", SKYPOPEN_P_LOG); - - //switch_channel_set_state(channel, CS_DESTROY); - - return SWITCH_STATUS_SUCCESS; -} - -static switch_status_t channel_on_routing(switch_core_session_t *session) -{ - //switch_channel_t *channel = NULL; - private_t *tech_pvt = NULL; - - //channel = switch_core_session_get_channel(session); - //switch_assert(channel != NULL); - - tech_pvt = switch_core_session_get_private(session); - switch_assert(tech_pvt != NULL); - - DEBUGA_SKYPE("%s CHANNEL ROUTING\n", SKYPOPEN_P_LOG, tech_pvt->name); - - return SWITCH_STATUS_SUCCESS; -} - -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); - switch_assert(channel != NULL); - - tech_pvt = switch_core_session_get_private(session); - switch_assert(tech_pvt != NULL); - - DEBUGA_SKYPE("%s CHANNEL EXECUTE\n", SKYPOPEN_P_LOG, tech_pvt->name); - - return SWITCH_STATUS_SUCCESS; -} - -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); - switch_assert(channel != NULL); - - tech_pvt = switch_core_session_get_private(session); - - //DEBUGA_SKYPE("%s CHANNEL KILL_CHANNEL\n", SKYPOPEN_P_LOG, tech_pvt->name); - if (tech_pvt) { - switch (sig) { - case SWITCH_SIG_KILL: - DEBUGA_SKYPE("%s CHANNEL got SWITCH_SIG_KILL\n", SKYPOPEN_P_LOG, switch_channel_get_name(channel)); - if (tech_pvt->interface_state == SKYPOPEN_STATE_DEAD) { - switch_channel_set_state(channel, CS_HANGUP); - return SWITCH_STATUS_SUCCESS; - } - tech_pvt->interface_state = SKYPOPEN_STATE_HANGUP_REQUESTED; - if (tech_pvt->skype_callflow == CALLFLOW_STATUS_REMOTEHOLD) { - DEBUGA_SKYPE("FYI %s CHANNEL in CALLFLOW_STATUS_REMOTEHOLD got SWITCH_SIG_KILL\n", SKYPOPEN_P_LOG, switch_channel_get_name(channel)); - } - if (switch_channel_get_state(channel) == CS_NEW) { - WARNINGA("FYI %s CHANNEL in CS_NEW state got SWITCH_SIG_KILL\n", SKYPOPEN_P_LOG, switch_channel_get_name(channel)); - } - if (switch_channel_get_state(channel) != CS_NEW && switch_channel_get_state(channel) < CS_EXECUTE) { - WARNINGA("FYI %s CHANNEL in %d state got SWITCH_SIG_KILL\n", SKYPOPEN_P_LOG, switch_channel_get_name(channel), - switch_channel_get_state(channel)); - } - - switch_mutex_lock(tech_pvt->flag_mutex); - switch_clear_flag(tech_pvt, TFLAG_IO); - switch_clear_flag(tech_pvt, TFLAG_VOICE); - switch_set_flag(tech_pvt, TFLAG_HANGUP); - if (switch_test_flag(tech_pvt, TFLAG_PROGRESS)) { - switch_clear_flag(tech_pvt, TFLAG_PROGRESS); - } - switch_mutex_unlock(tech_pvt->flag_mutex); - break; - case SWITCH_SIG_BREAK: - DEBUGA_SKYPE("%s CHANNEL got SWITCH_SIG_BREAK\n", SKYPOPEN_P_LOG, switch_channel_get_name(channel)); - switch_mutex_lock(tech_pvt->flag_mutex); - switch_set_flag(tech_pvt, TFLAG_BREAK); - switch_mutex_unlock(tech_pvt->flag_mutex); - break; - default: - break; - } - } else { - WARNINGA("FYI %s CHANNEL has no tech_pvt in his private\n", SKYPOPEN_P_LOG, switch_channel_get_name(channel)); - } - - return SWITCH_STATUS_SUCCESS; -} - -static switch_status_t channel_on_consume_media(switch_core_session_t *session) -{ - private_t *tech_pvt = NULL; - - tech_pvt = switch_core_session_get_private(session); - - DEBUGA_SKYPE("%s CHANNEL CONSUME_MEDIA\n", SKYPOPEN_P_LOG, tech_pvt->name); - return SWITCH_STATUS_SUCCESS; -} - - -static switch_status_t channel_on_exchange_media(switch_core_session_t *session) -{ - private_t *tech_pvt = NULL; - tech_pvt = switch_core_session_get_private(session); - DEBUGA_SKYPE("%s CHANNEL EXCHANGE_MEDIA\n", SKYPOPEN_P_LOG, tech_pvt->name); - return SWITCH_STATUS_SUCCESS; -} - -static switch_status_t channel_on_soft_execute(switch_core_session_t *session) -{ - private_t *tech_pvt = NULL; - tech_pvt = switch_core_session_get_private(session); - DEBUGA_SKYPE("%s CHANNEL SOFT_EXECUTE\n", SKYPOPEN_P_LOG, tech_pvt->name); - return SWITCH_STATUS_SUCCESS; -} - -#if 0 -static switch_status_t channel_on_reset(switch_core_session_t *session) -{ - private_t *tech_pvt = NULL; - switch_channel_t *channel = NULL; - tech_pvt = switch_core_session_get_private(session); - DEBUGA_SKYPE("%s CHANNEL RESET\n", SKYPOPEN_P_LOG, tech_pvt->name); - - - if (session) { - channel = switch_core_session_get_channel(session); - } else { - ERRORA("No session???\n", SKYPOPEN_P_LOG); - } - if (channel) { - switch_channel_set_state(channel, CS_HANGUP); - } else { - ERRORA("No channel???\n", SKYPOPEN_P_LOG); - } - - - return SWITCH_STATUS_SUCCESS; -} -#endif //0 - - -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); - - DEBUGA_SKYPE("%s CHANNEL SEND_DTMF\n", SKYPOPEN_P_LOG, tech_pvt->name); - DEBUGA_SKYPE("DTMF: %c\n", SKYPOPEN_P_LOG, dtmf->digit); - - skypopen_senddigit(tech_pvt, dtmf->digit); - - 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_byte_t *data; - char digit_str[256]; - short *frame_16_khz; - short frame_8_khz[160]; - unsigned int i; - unsigned int a; - size_t bytes_read = 0; - int try = 0; - - - *frame = NULL; - - channel = switch_core_session_get_channel(session); - switch_assert(channel != NULL); - - tech_pvt = switch_core_session_get_private(session); - switch_assert(tech_pvt != NULL); - - tech_pvt->read_frame.flags = SFF_NONE; - - if (!switch_test_flag(tech_pvt, TFLAG_IO)) { - switch_sleep(MS_SKYPOPEN * 1000); - return SWITCH_STATUS_FALSE; - } - if (!switch_channel_ready(channel)) { - ERRORA("channel not ready \n", SKYPOPEN_P_LOG); - switch_sleep(MS_SKYPOPEN * 1000); - return SWITCH_STATUS_FALSE; - } - - if (switch_test_flag(tech_pvt, TFLAG_PROGRESS)) { - //DEBUGA_SKYPE("CHANNEL READ FRAME in TFLAG_PROGRESS goto CNG\n", SKYPOPEN_P_LOG); - //switch_sleep(MS_SKYPOPEN * 1000); - goto cng; - } - - if (!tech_pvt->read_buffer) { - int32_t max_len = BYTES_PER_FRAME * 10; - - switch_buffer_create(skypopen_module_pool, &tech_pvt->read_buffer, max_len); - switch_assert(tech_pvt->read_buffer); - switch_buffer_zero(tech_pvt->read_buffer); - tech_pvt->begin_to_read = 1; - } - - - - if (tech_pvt->timer_read.timer_interface && tech_pvt->timer_read.timer_interface->timer_next) { - switch_core_timer_next(&tech_pvt->timer_read); - } - - try = 0; - read: - - - if (tech_pvt && tech_pvt->interface_state != SKYPOPEN_STATE_DOWN - && (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS - || tech_pvt->skype_callflow == CALLFLOW_STATUS_EARLYMEDIA - || tech_pvt->skype_callflow == CALLFLOW_STATUS_REMOTEHOLD || tech_pvt->skype_callflow == SKYPOPEN_STATE_UP)) { - switch_mutex_lock(tech_pvt->mutex_audio_srv); - if (tech_pvt->read_buffer && switch_buffer_inuse(tech_pvt->read_buffer)) { - bytes_read = switch_buffer_read(tech_pvt->read_buffer, tech_pvt->read_frame.data, BYTES_PER_FRAME); - tech_pvt->read_frame.datalen = (uint32_t)bytes_read; - } - switch_mutex_unlock(tech_pvt->mutex_audio_srv); - - if (!bytes_read) { - switch_sleep(1000); //XXX don't like this - try++; - if (try < 5) { - //DEBUGA_SKYPE("skypopen_audio_read going back to read\n", SKYPOPEN_P_LOG); - goto read; - } - - if (!strlen(tech_pvt->skype_voicemail_id)) { - DEBUGA_SKYPE("READ BUFFER EMPTY, skypopen_audio_read Silence\n", SKYPOPEN_P_LOG); - } - memset(tech_pvt->read_frame.data, 255, BYTES_PER_FRAME); - tech_pvt->read_frame.datalen = BYTES_PER_FRAME; - - } - } else { - memset(tech_pvt->read_frame.data, 255, BYTES_PER_FRAME); - tech_pvt->read_frame.datalen = BYTES_PER_FRAME; - } - - switch_mutex_lock(tech_pvt->flag_mutex); - switch_set_flag(tech_pvt, TFLAG_VOICE); - switch_mutex_unlock(tech_pvt->flag_mutex); - - while (switch_test_flag(tech_pvt, TFLAG_IO)) { - if (switch_test_flag(tech_pvt, TFLAG_BREAK)) { - switch_mutex_lock(tech_pvt->flag_mutex); - switch_clear_flag(tech_pvt, TFLAG_BREAK); - switch_mutex_unlock(tech_pvt->flag_mutex); - DEBUGA_SKYPE("CHANNEL READ FRAME goto CNG\n", SKYPOPEN_P_LOG); - goto cng; - } - - if (!switch_test_flag(tech_pvt, TFLAG_IO)) { - DEBUGA_SKYPE("CHANNEL READ FRAME not IO\n", SKYPOPEN_P_LOG); - return SWITCH_STATUS_FALSE; - } - - if (switch_test_flag(tech_pvt, TFLAG_IO) && switch_test_flag(tech_pvt, TFLAG_VOICE)) { - switch_mutex_lock(tech_pvt->flag_mutex); - switch_clear_flag(tech_pvt, TFLAG_VOICE); - switch_mutex_unlock(tech_pvt->flag_mutex); - if (!tech_pvt->read_frame.datalen) { - DEBUGA_SKYPE("CHANNEL READ CONTINUE\n", SKYPOPEN_P_LOG); - continue; - } - *frame = &tech_pvt->read_frame; - - - if (switch_true(switch_channel_get_variable(channel, "skype_get_inband_dtmf"))) { - - frame_16_khz = tech_pvt->read_frame.data; - - a = 0; - for (i = 0; i < tech_pvt->read_frame.datalen / sizeof(short); i++) { - frame_8_khz[a] = frame_16_khz[i]; - i++; - a++; - } - - memset(digit_str, 0, sizeof(digit_str)); - dtmf_rx(&tech_pvt->dtmf_state, (int16_t *) frame_8_khz, 160); - dtmf_rx_get(&tech_pvt->dtmf_state, digit_str, sizeof(digit_str)); - - - if (digit_str[0]) { - switch_time_t new_dtmf_timestamp = switch_time_now(); - if ((new_dtmf_timestamp - tech_pvt->old_dtmf_timestamp) > 350000) { - char *p = digit_str; - switch_channel_t *channel = switch_core_session_get_channel(session); - - if (channel) { - - while (p && *p) { - switch_dtmf_t dtmf = { 0 }; - dtmf.digit = *p; - dtmf.duration = SWITCH_DEFAULT_DTMF_DURATION; - switch_channel_queue_dtmf(channel, &dtmf); - p++; - } - NOTICA("DTMF DETECTED: [%s] new_dtmf_timestamp: %u, delta_t: %u\n", SKYPOPEN_P_LOG, digit_str, - (unsigned int) new_dtmf_timestamp, (unsigned int) (new_dtmf_timestamp - tech_pvt->old_dtmf_timestamp)); - tech_pvt->old_dtmf_timestamp = new_dtmf_timestamp; - } else { - WARNINGA("NO CHANNEL ?\n", SKYPOPEN_P_LOG); - } - } - } - } -#if SWITCH_BYTE_ORDER == __BIG_ENDIAN - if (switch_test_flag(tech_pvt, TFLAG_LINEAR)) { - switch_swap_linear((*frame)->data, (int) (*frame)->datalen / 2); - } -#endif - return SWITCH_STATUS_SUCCESS; - } - DEBUGA_SKYPE("CHANNEL READ no TFLAG_IO\n", SKYPOPEN_P_LOG); - return SWITCH_STATUS_FALSE; - } - - DEBUGA_SKYPE("CHANNEL READ FALSE\n", SKYPOPEN_P_LOG); - 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; - -} - -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; - int no_space = 0; - - channel = switch_core_session_get_channel(session); - switch_assert(channel != NULL); - - tech_pvt = switch_core_session_get_private(session); - switch_assert(tech_pvt != NULL); - - if (switch_test_flag(tech_pvt, TFLAG_PROGRESS)) { - //DEBUGA_SKYPE("CHANNEL in TFLAG_PROGRESS\n", SKYPOPEN_P_LOG); - return SWITCH_STATUS_SUCCESS; - } - - if (!switch_channel_ready(channel)) { - ERRORA("channel not ready \n", SKYPOPEN_P_LOG); - return SWITCH_STATUS_FALSE; - } - if (!switch_test_flag(tech_pvt, TFLAG_IO)) { - DEBUGA_SKYPE("channel not in TFLAG_IO \n", SKYPOPEN_P_LOG); - return SWITCH_STATUS_FALSE; - } -#if SWITCH_BYTE_ORDER == __BIG_ENDIAN - if (switch_test_flag(tech_pvt, TFLAG_LINEAR)) { - switch_swap_linear(frame->data, (int) frame->datalen / 2); - } -#endif - if (!tech_pvt->write_buffer) { - int32_t max_len = BYTES_PER_FRAME * 4; - - switch_buffer_create(skypopen_module_pool, &tech_pvt->write_buffer, max_len); - switch_assert(tech_pvt->write_buffer); - } - - switch_mutex_lock(tech_pvt->mutex_audio_cli); - if (switch_buffer_freespace(tech_pvt->write_buffer) < frame->datalen) { - switch_buffer_zero(tech_pvt->write_buffer); - no_space = 1; - } - switch_buffer_write(tech_pvt->write_buffer, frame->data, frame->datalen); - switch_mutex_unlock(tech_pvt->mutex_audio_cli); - if (no_space && !strlen(tech_pvt->skype_voicemail_id)) { - //switch_sleep(MS_SKYPOPEN * 1000); - DEBUGA_SKYPE("NO SPACE in WRITE BUFFER: there was no space for %d\n", SKYPOPEN_P_LOG, frame->datalen); - } - tech_pvt->begin_to_write = 1; - - return SWITCH_STATUS_SUCCESS; -} - -static switch_status_t channel_answer_channel(switch_core_session_t *session) -{ - private_t *tech_pvt; - switch_channel_t *channel = NULL; - int conta = 0; - - channel = switch_core_session_get_channel(session); - switch_assert(channel != NULL); - - tech_pvt = switch_core_session_get_private(session); - switch_assert(tech_pvt != NULL); - - switch_mutex_lock(tech_pvt->flag_mutex); - switch_clear_flag(tech_pvt, TFLAG_IO); - switch_mutex_unlock(tech_pvt->flag_mutex); - skypopen_answer(tech_pvt); - - while (!switch_test_flag(tech_pvt, TFLAG_IO)) { - if (switch_channel_get_state(channel) == CS_RESET) { - return SWITCH_STATUS_FALSE; - } - switch_sleep(50000); - conta++; - if (conta == 10) { //0.5 seconds - return SWITCH_STATUS_FALSE; - } - } - switch_mutex_lock(globals.mutex); - globals.calls++; - - switch_mutex_unlock(globals.mutex); - DEBUGA_SKYPE("%s CHANNEL ANSWER %s\n", SKYPOPEN_P_LOG, tech_pvt->name, switch_core_session_get_uuid(session)); - - - - - DEBUGA_SKYPE("ANSWERED! \n", SKYPOPEN_P_LOG); - - return SWITCH_STATUS_SUCCESS; -} - -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; - char msg_to_skype[256]; - - channel = switch_core_session_get_channel(session); - switch_assert(channel != NULL); - - tech_pvt = (private_t *) switch_core_session_get_private(session); - switch_assert(tech_pvt != NULL); - - switch (msg->message_id) { - case SWITCH_MESSAGE_INDICATE_PROGRESS: - { - DEBUGA_SKYPE("%s CHANNEL got SWITCH_MESSAGE_INDICATE_PROGRESS\n", SKYPOPEN_P_LOG, switch_channel_get_name(channel)); - switch_mutex_lock(tech_pvt->flag_mutex); - switch_set_flag(tech_pvt, TFLAG_PROGRESS); - switch_mutex_unlock(tech_pvt->flag_mutex); - } - break; - case SWITCH_MESSAGE_INDICATE_CLEAR_PROGRESS: - { - DEBUGA_SKYPE("%s CHANNEL got SWITCH_MESSAGE_INDICATE_CLEAR_PROGRESS\n", SKYPOPEN_P_LOG, switch_channel_get_name(channel)); - if (switch_test_flag(tech_pvt, TFLAG_PROGRESS)) { - sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", tech_pvt->ring_id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - sprintf(msg_to_skype, "ALTER CALL %s HANGUP", tech_pvt->ring_id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", tech_pvt->skype_call_id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - sprintf(msg_to_skype, "ALTER CALL %s HANGUP", tech_pvt->skype_call_id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - switch_mutex_lock(tech_pvt->flag_mutex); - switch_clear_flag(tech_pvt, TFLAG_PROGRESS); - switch_mutex_unlock(tech_pvt->flag_mutex); - } - } - break; - - case SWITCH_MESSAGE_INDICATE_ANSWER: - { - DEBUGA_SKYPE("%s CHANNEL got SWITCH_MESSAGE_INDICATE_ANSWER\n", SKYPOPEN_P_LOG, switch_channel_get_name(channel)); - - channel_answer_channel(session); - switch_mutex_lock(tech_pvt->flag_mutex); - switch_clear_flag(tech_pvt, TFLAG_PROGRESS); - switch_mutex_unlock(tech_pvt->flag_mutex); - - if (tech_pvt->read_buffer) { - switch_mutex_lock(tech_pvt->mutex_audio_srv); - switch_buffer_zero(tech_pvt->read_buffer); - if (tech_pvt->timer_read.timer_interface && tech_pvt->timer_read.timer_interface->timer_next) { - switch_core_timer_sync(&tech_pvt->timer_read); - } - if (tech_pvt->timer_read_srv.timer_interface && tech_pvt->timer_read_srv.timer_interface->timer_next) { - switch_core_timer_sync(&tech_pvt->timer_read_srv); - } - switch_mutex_unlock(tech_pvt->mutex_audio_srv); - } - - if (tech_pvt->write_buffer) { - switch_mutex_lock(tech_pvt->mutex_audio_cli); - switch_buffer_zero(tech_pvt->write_buffer); - if (tech_pvt->timer_write.timer_interface && tech_pvt->timer_write.timer_interface->timer_next) { - switch_core_timer_sync(&tech_pvt->timer_write); - } - switch_mutex_unlock(tech_pvt->mutex_audio_cli); - } - DEBUGA_SKYPE("Synching audio\n", SKYPOPEN_P_LOG); - - } - break; - case SWITCH_MESSAGE_INDICATE_AUDIO_SYNC: - - DEBUGA_SKYPE("%s CHANNEL got SWITCH_MESSAGE_INDICATE_AUDIO_SYNC\n", SKYPOPEN_P_LOG, switch_channel_get_name(channel)); - - if (tech_pvt->read_buffer) { - switch_mutex_lock(tech_pvt->mutex_audio_srv); - switch_buffer_zero(tech_pvt->read_buffer); - if (tech_pvt->timer_read.timer_interface && tech_pvt->timer_read.timer_interface->timer_next) { - switch_core_timer_sync(&tech_pvt->timer_read); - } - if (tech_pvt->timer_read_srv.timer_interface && tech_pvt->timer_read_srv.timer_interface->timer_next) { - switch_core_timer_sync(&tech_pvt->timer_read_srv); - } - switch_mutex_unlock(tech_pvt->mutex_audio_srv); - } - - if (tech_pvt->write_buffer) { - switch_mutex_lock(tech_pvt->mutex_audio_cli); - switch_buffer_zero(tech_pvt->write_buffer); - if (tech_pvt->timer_write.timer_interface && tech_pvt->timer_write.timer_interface->timer_next) { - switch_core_timer_sync(&tech_pvt->timer_write); - } - switch_mutex_unlock(tech_pvt->mutex_audio_cli); - } - DEBUGA_SKYPE("Synching audio\n", SKYPOPEN_P_LOG); - break; - case SWITCH_MESSAGE_INDICATE_BRIDGE: - DEBUGA_SKYPE("%s CHANNEL got SWITCH_MESSAGE_INDICATE_BRIDGE\n", SKYPOPEN_P_LOG, switch_channel_get_name(channel)); - - if (tech_pvt->read_buffer) { - switch_mutex_lock(tech_pvt->mutex_audio_srv); - switch_buffer_zero(tech_pvt->read_buffer); - if (tech_pvt->timer_read.timer_interface && tech_pvt->timer_read.timer_interface->timer_next) { - switch_core_timer_sync(&tech_pvt->timer_read); - } - if (tech_pvt->timer_read_srv.timer_interface && tech_pvt->timer_read_srv.timer_interface->timer_next) { - switch_core_timer_sync(&tech_pvt->timer_read_srv); - } - switch_mutex_unlock(tech_pvt->mutex_audio_srv); - } - - if (tech_pvt->write_buffer) { - switch_mutex_lock(tech_pvt->mutex_audio_cli); - switch_buffer_zero(tech_pvt->write_buffer); - if (tech_pvt->timer_write.timer_interface && tech_pvt->timer_write.timer_interface->timer_next) { - switch_core_timer_sync(&tech_pvt->timer_write); - } - switch_mutex_unlock(tech_pvt->mutex_audio_cli); - } - DEBUGA_SKYPE("Synching audio\n", SKYPOPEN_P_LOG); - break; - - default: - { - - DEBUGA_SKYPE("MSG_ID=%d\n", SKYPOPEN_P_LOG, msg->message_id); - } - break; - } - - return SWITCH_STATUS_SUCCESS; -} - -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); - - if (!body) { - body = ""; - } - - WARNINGA("event: |||%s|||\n", SKYPOPEN_P_LOG, body); - - return SWITCH_STATUS_SUCCESS; -} - -switch_state_handler_table_t skypopen_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_consume_media */ channel_on_consume_media, - /*.on_hibernate */ NULL, - /*.on_reset */ NULL, - /*.on_park */ NULL, - /*.on_reporting */ NULL, - /*.on_destroy */ channel_on_destroy -}; - -switch_io_routines_t skypopen_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 -}; - -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, - switch_call_cause_t *cancel_cause) -{ - private_t *tech_pvt = NULL; - if ((*new_session = switch_core_session_request_uuid(skypopen_endpoint_interface, SWITCH_CALL_DIRECTION_OUTBOUND, flags, pool, switch_event_get_header(var_event, "origination_uuid"))) != 0) { - switch_channel_t *channel = NULL; - switch_caller_profile_t *caller_profile; - char *rdest; - int found = 0; - char interface_name[256]; - - DEBUGA_SKYPE("1 SESSION_REQUEST %s\n", SKYPOPEN_P_LOG, switch_core_session_get_uuid(*new_session)); - switch_core_session_add_stream(*new_session, NULL); - - - if (!zstr(outbound_profile->destination_number)) { - int i; - char *slash; - - switch_copy_string(interface_name, outbound_profile->destination_number, 255); - slash = strrchr(interface_name, '/'); - if(slash != NULL){ - *slash = '\0'; - } - - switch_mutex_lock(globals.mutex); - if (strncmp("ANY", interface_name, strlen(interface_name)) == 0 || strncmp("RR", interface_name, strlen(interface_name)) == 0) { - /* Find the first idle interface using Round Robin */ - DEBUGA_SKYPE("Finding one available skype interface RR\n", SKYPOPEN_P_LOG); - tech_pvt = find_available_skypopen_interface_rr(NULL); - if (tech_pvt) - found = 1; - } - - for (i = 0; !found && i < SKYPOPEN_MAX_INTERFACES; i++) { - /* we've been asked for a normal interface name, or we have not found idle interfaces to serve as the "ANY" interface */ - if (strlen(globals.SKYPOPEN_INTERFACES[i].name) - && (strncmp(globals.SKYPOPEN_INTERFACES[i].name, interface_name, strlen(interface_name)) == 0)) { - if (strlen(globals.SKYPOPEN_INTERFACES[i].session_uuid_str)) { - DEBUGA_SKYPE - ("globals.SKYPOPEN_INTERFACES[%d].name=|||%s||| session_uuid_str=|||%s||| is BUSY\n", - SKYPOPEN_P_LOG, i, globals.SKYPOPEN_INTERFACES[i].name, globals.SKYPOPEN_INTERFACES[i].session_uuid_str); - DEBUGA_SKYPE("1 SESSION_DESTROY %s\n", SKYPOPEN_P_LOG, switch_core_session_get_uuid(*new_session)); - switch_core_session_destroy(new_session); - switch_mutex_unlock(globals.mutex); - return SWITCH_CAUSE_NORMAL_CIRCUIT_CONGESTION; - } - - DEBUGA_SKYPE("globals.SKYPOPEN_INTERFACES[%d].name=|||%s|||?\n", SKYPOPEN_P_LOG, i, globals.SKYPOPEN_INTERFACES[i].name); - tech_pvt = &globals.SKYPOPEN_INTERFACES[i]; - found = 1; - break; - } - - } - - } else { - ERRORA("Doh! no destination number?\n", SKYPOPEN_P_LOG); - switch_core_session_destroy(new_session); - return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; - } - - if (!found) { - DEBUGA_SKYPE("Doh! no available interface for |||%s|||?\n", SKYPOPEN_P_LOG, interface_name); - DEBUGA_SKYPE("2 SESSION_DESTROY %s\n", SKYPOPEN_P_LOG, switch_core_session_get_uuid(*new_session)); - switch_core_session_destroy(new_session); - switch_mutex_unlock(globals.mutex); - return SWITCH_CAUSE_NORMAL_CIRCUIT_CONGESTION; - } - - channel = switch_core_session_get_channel(*new_session); - if (!channel) { - ERRORA("Doh! no channel?\n", SKYPOPEN_P_LOG); - switch_core_session_destroy(new_session); - switch_mutex_unlock(globals.mutex); - return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; - } - switch_channel_set_variable(channel, "waste", "false"); - if (skypopen_tech_init(tech_pvt, *new_session) != SWITCH_STATUS_SUCCESS) { - ERRORA("Doh! no tech_init?\n", SKYPOPEN_P_LOG); - switch_core_session_destroy(new_session); - switch_mutex_unlock(globals.mutex); - return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; - } - - - if (outbound_profile) { - char name[128]; - - if (strncmp("ANY", outbound_profile->destination_number, 3) == 0) { - snprintf(name, sizeof(name), "skypopen/%s%s", tech_pvt->name, outbound_profile->destination_number + 3); - } else if (strncmp("RR", outbound_profile->destination_number, 2) == 0) { - snprintf(name, sizeof(name), "skypopen/%s%s", tech_pvt->name, outbound_profile->destination_number + 2); - } else { - snprintf(name, sizeof(name), "skypopen/%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 { - ERRORA("Doh! no caller profile\n", SKYPOPEN_P_LOG); - switch_core_session_destroy(new_session); - switch_mutex_unlock(globals.mutex); - return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; - } - - - rdest = strchr(caller_profile->destination_number, '/'); - *rdest++ = '\0'; - - switch_copy_string(tech_pvt->session_uuid_str, switch_core_session_get_uuid(*new_session), sizeof(tech_pvt->session_uuid_str)); - caller_profile = tech_pvt->caller_profile; - caller_profile->destination_number = rdest; - - switch_mutex_lock(tech_pvt->flag_mutex); - tech_pvt->ob_calls++; - switch_set_flag(tech_pvt, TFLAG_OUTBOUND); - switch_mutex_unlock(tech_pvt->flag_mutex); - switch_channel_set_state(channel, CS_INIT); - skypopen_call(tech_pvt, rdest, 30); - switch_mutex_unlock(globals.mutex); - return SWITCH_CAUSE_SUCCESS; - } - - ERRORA("Doh! no new_session\n", SKYPOPEN_P_LOG); - return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER; -} - -/*! - * \brief This thread runs during a call, and monitor the interface for signaling, like hangup, caller id, etc most of signaling is handled inside the skypopen_signaling_read function - * - */ -static void *SWITCH_THREAD_FUNC skypopen_signaling_thread_func(switch_thread_t *thread, void *obj) -{ - private_t *tech_pvt = obj; - int res; - int forever = 1; - switch_event_t *event; - - if (!tech_pvt) - return NULL; - - DEBUGA_SKYPE("In skypopen_signaling_thread_func: started, p=%p\n", SKYPOPEN_P_LOG, (void *) tech_pvt); - - while (forever) { - if (!(running && tech_pvt->running)) - break; - res = skypopen_signaling_read(tech_pvt); - - if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, MY_EVENT_INCOMING_RAW) == SWITCH_STATUS_SUCCESS) { - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "X-Skype-Response-Code", "%d", res); - switch_event_add_header(event, SWITCH_STACK_BOTTOM, "X-Skype-Interface", "%s", tech_pvt->interface_id); - switch_event_add_body(event, "%s", tech_pvt->message); - switch_event_fire(&event); - } - - if (res == CALLFLOW_INCOMING_HANGUP || tech_pvt->skype_callflow == CALLFLOW_INCOMING_HANGUP) { - switch_core_session_t *session = NULL; - switch_channel_t *channel = NULL; - int conta; - - DEBUGA_SKYPE("skype call ended\n", SKYPOPEN_P_LOG); - - if (tech_pvt) { - if (tech_pvt->interface_state == SKYPOPEN_STATE_DEAD) { - break; - } - session = switch_core_session_locate(tech_pvt->session_uuid_str); - if (session) { - channel = switch_core_session_get_channel(session); - if (channel) { - switch_channel_state_t state = switch_channel_get_state(channel); - if (state < CS_EXECUTE) { - switch_sleep(20000); //20 msec, let the state evolve from CS_NEW - } - switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING); - } else { - ERRORA("no channel?\n", SKYPOPEN_P_LOG); - } - switch_core_session_rwunlock(session); - } else { - DEBUGA_SKYPE("no session\n", SKYPOPEN_P_LOG); - - tech_pvt->interface_state = SKYPOPEN_STATE_DOWN; - DEBUGA_SKYPE("audio tcp threads to DIE\n", SKYPOPEN_P_LOG); - conta = 0; - while (tech_pvt->tcp_srv_thread) { - switch_sleep(50000); - conta++; - if (conta == 20) { - ERRORA("tcp_srv_thread is NOT dead, this can LEAK MEMORY\n", SKYPOPEN_P_LOG); - break; - } - } - DEBUGA_SKYPE("audio tcp srv thread DEAD %d\n", SKYPOPEN_P_LOG, conta); - conta = 0; - while (tech_pvt->tcp_cli_thread) { - switch_sleep(50000); - conta++; - if (conta == 20) { - ERRORA("tcp_cli_thread is NOT dead, this can LEAK MEMORY\n", SKYPOPEN_P_LOG); - break; - } - } - DEBUGA_SKYPE("audio tcp cli thread DEAD %d\n", SKYPOPEN_P_LOG, conta); - } - switch_mutex_lock(globals.mutex); - tech_pvt->ringing_state = SKYPOPEN_RINGING_INIT; - *tech_pvt->session_uuid_str = '\0'; - *tech_pvt->initial_skype_user = '\0'; - *tech_pvt->answer_id = '\0'; - *tech_pvt->answer_value = '\0'; - *tech_pvt->ring_id = '\0'; - *tech_pvt->ring_value = '\0'; - *tech_pvt->callid_number = '\0'; - *tech_pvt->callid_name = '\0'; - - tech_pvt->skype_callflow = CALLFLOW_CALL_IDLE; - tech_pvt->interface_state = SKYPOPEN_STATE_IDLE; - switch_mutex_unlock(globals.mutex); - } else { - ERRORA("no tech_pvt?\n", SKYPOPEN_P_LOG); - } - } - } - tech_pvt->skypopen_signaling_thread = NULL; - DEBUGA_SKYPE("EXITING\n", SKYPOPEN_P_LOG); - return NULL; -} - -static switch_status_t load_config(int reload_type) -{ - char *cf = "skypopen.conf"; - switch_xml_t cfg, xml, global_settings, param, interfaces, myinterface; - private_t *tech_pvt = NULL; - - // CLOUDTREE (Thomas Hazel) - always try to load configuration - running = 1; - - switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, skypopen_module_pool); - if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) { - ERRORA("open of %s failed\n", SKYPOPEN_P_LOG, cf); - running = 0; - switch_xml_free(xml); - return SWITCH_STATUS_TERM; - } - - switch_mutex_lock(globals.mutex); - 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")) { - globals.debug = atoi(val); - DEBUGA_SKYPE("globals.debug=%d\n", SKYPOPEN_P_LOG, globals.debug); - - } else if (!strcmp(var, "context")) { - set_global_context(val); - DEBUGA_SKYPE("globals.context=%s\n", SKYPOPEN_P_LOG, globals.context); - } else if (!strcmp(var, "dialplan")) { - set_global_dialplan(val); - DEBUGA_SKYPE("globals.dialplan=%s\n", SKYPOPEN_P_LOG, globals.dialplan); - } else if (!strcmp(var, "destination")) { - set_global_destination(val); - DEBUGA_SKYPE("globals.destination=%s\n", SKYPOPEN_P_LOG, globals.destination); - } else if (!strcmp(var, "skype_user")) { - set_global_skype_user(val); - DEBUGA_SKYPE("globals.skype_user=%s\n", SKYPOPEN_P_LOG, globals.skype_user); - } else if (!strcmp(var, "report_incoming_chatmessages")) { - set_global_report_incoming_chatmessages(val); - DEBUGA_SKYPE("globals.report_incoming_chatmessages=%s\n", SKYPOPEN_P_LOG, globals.report_incoming_chatmessages); - } else if (!strcmp(var, "silent_mode")) { - set_global_silent_mode(val); - DEBUGA_SKYPE("globals.silent_mode=%s\n", SKYPOPEN_P_LOG, globals.silent_mode); - } else if (!strcmp(var, "write_silence_when_idle")) { - set_global_write_silence_when_idle(val); - DEBUGA_SKYPE("globals.write_silence_when_idle=%s\n", SKYPOPEN_P_LOG, globals.write_silence_when_idle); - } else if (!strcmp(var, "setsockopt")) { - set_global_setsockopt(val); - DEBUGA_SKYPE("globals.setsockopt=%s\n", SKYPOPEN_P_LOG, globals.setsockopt); - } - - } - } - - globals.start_port = 32769; - 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 *destination = "5000"; - char *X11_display = NULL; - char *skype_user = NULL; - char *report_incoming_chatmessages = "true"; - char *silent_mode = "false"; - char *write_silence_when_idle = "true"; - char *setsockopt = "false"; - uint32_t interface_id = 0; - - if (globals.context) - context = globals.context; - if (globals.dialplan) - dialplan = globals.dialplan; - if (globals.destination) - destination = globals.destination; - if (globals.skype_user) - skype_user = globals.skype_user; - if (globals.report_incoming_chatmessages) - report_incoming_chatmessages = globals.report_incoming_chatmessages; - if (globals.silent_mode) - silent_mode = globals.silent_mode; - if (globals.write_silence_when_idle) - write_silence_when_idle = globals.write_silence_when_idle; - if (globals.setsockopt) - setsockopt = globals.setsockopt; - - tech_pvt = NULL; - - 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, "context")) { - context = val; - } else if (!strcasecmp(var, "dialplan")) { - dialplan = val; - } else if (!strcasecmp(var, "destination")) { - destination = val; - } else if (!strcasecmp(var, "skype_user")) { - skype_user = val; - } else if (!strcasecmp(var, "report_incoming_chatmessages")) { - report_incoming_chatmessages = val; - } else if (!strcasecmp(var, "silent_mode")) { - silent_mode = val; - } else if (!strcasecmp(var, "write_silence_when_idle")) { - write_silence_when_idle = val; - } else if (!strcasecmp(var, "setsockopt")) { - setsockopt = val; - } else if (!strcasecmp(var, "X11-display") || !strcasecmp(var, "X11_display")) { - X11_display = val; - } - - } - if (!skype_user) { - ERRORA("interface missing REQUIRED param 'skype_user'\n", SKYPOPEN_P_LOG); - continue; - } - - if (reload_type == SOFT_RELOAD) { - char the_interface[256]; - sprintf(the_interface, "#%s", name); - - if (interface_exists(the_interface) == SWITCH_STATUS_SUCCESS) { - continue; - } - } -#ifndef WIN32 - if (!X11_display) { - ERRORA("interface missing REQUIRED param 'X11_display'\n", SKYPOPEN_P_LOG); - continue; - } -#endif - if (!id) { - ERRORA("interface missing REQUIRED param 'id'\n", SKYPOPEN_P_LOG); - continue; - } - if (switch_is_number(id)) { - interface_id = atoi(id); - DEBUGA_SKYPE("interface_id=%d\n", SKYPOPEN_P_LOG, interface_id); - } else { - ERRORA("interface param 'id' MUST be a number, now id='%s'\n", SKYPOPEN_P_LOG, id); - continue; - } - - if (!name) { - WARNINGA("interface missing param 'name', not nice, but works\n", SKYPOPEN_P_LOG); - } - - if (name) { - DEBUGA_SKYPE("name=%s\n", SKYPOPEN_P_LOG, name); - } -#ifndef WIN32 - if (!XInitThreads()) { - ERRORA("Not initialized XInitThreads!\n", SKYPOPEN_P_LOG); - } else { - DEBUGA_SKYPE("Initialized XInitThreads!\n", SKYPOPEN_P_LOG); - } - switch_sleep(20000); -#endif /* WIN32 */ - - if (interface_id && interface_id < SKYPOPEN_MAX_INTERFACES) { - private_t newconf; - switch_threadattr_t *skypopen_api_thread_attr = NULL; - switch_threadattr_t *skypopen_signaling_thread_attr = NULL; - - memset(&newconf, '\0', sizeof(newconf)); - globals.SKYPOPEN_INTERFACES[interface_id] = newconf; - globals.SKYPOPEN_INTERFACES[interface_id].running = 1; - - - tech_pvt = &globals.SKYPOPEN_INTERFACES[interface_id]; - - switch_set_string(globals.SKYPOPEN_INTERFACES[interface_id].interface_id, id); - if (name) { - switch_set_string(globals.SKYPOPEN_INTERFACES[interface_id].name, name); - } else { - switch_set_string(globals.SKYPOPEN_INTERFACES[interface_id].name, "N/A"); - } - DEBUGA_SKYPE("CONFIGURING interface_id=%d\n", SKYPOPEN_P_LOG, interface_id); - - switch_set_string(globals.SKYPOPEN_INTERFACES[interface_id].context, context); - switch_set_string(globals.SKYPOPEN_INTERFACES[interface_id].dialplan, dialplan); - switch_set_string(globals.SKYPOPEN_INTERFACES[interface_id].destination, destination); - switch_set_string(globals.SKYPOPEN_INTERFACES[interface_id].X11_display, X11_display); - switch_set_string(globals.SKYPOPEN_INTERFACES[interface_id].skype_user, skype_user); - - if (!strcmp(report_incoming_chatmessages, "true") || !strcmp(report_incoming_chatmessages, "1")) { - globals.SKYPOPEN_INTERFACES[interface_id].report_incoming_chatmessages = 1; - } else { - globals.SKYPOPEN_INTERFACES[interface_id].report_incoming_chatmessages = 0; //redundant, just in case - - } - - if (!strcmp(silent_mode, "true") || !strcmp(silent_mode, "1")) { - globals.SKYPOPEN_INTERFACES[interface_id].silent_mode = 1; - } else { - globals.SKYPOPEN_INTERFACES[interface_id].silent_mode = 0; //redundant, just in case - - } - - if (!strcmp(write_silence_when_idle, "true") || !strcmp(write_silence_when_idle, "1")) { - globals.SKYPOPEN_INTERFACES[interface_id].write_silence_when_idle = 1; - } else { - globals.SKYPOPEN_INTERFACES[interface_id].write_silence_when_idle = 0; //redundant, just in case - - } - - if (!strcmp(setsockopt, "true") || !strcmp(setsockopt, "1")) { - globals.SKYPOPEN_INTERFACES[interface_id].setsockopt = 1; - } else { - globals.SKYPOPEN_INTERFACES[interface_id].setsockopt = 0; //redundant, just in case - - } - - DEBUGA_SKYPE("interface_id=%d globals.SKYPOPEN_INTERFACES[interface_id].name=%s\n", - SKYPOPEN_P_LOG, interface_id, globals.SKYPOPEN_INTERFACES[interface_id].name); - DEBUGA_SKYPE - ("interface_id=%d globals.SKYPOPEN_INTERFACES[interface_id].context=%s\n", - SKYPOPEN_P_LOG, interface_id, globals.SKYPOPEN_INTERFACES[interface_id].context); - DEBUGA_SKYPE - ("interface_id=%d globals.SKYPOPEN_INTERFACES[interface_id].dialplan=%s\n", - SKYPOPEN_P_LOG, interface_id, globals.SKYPOPEN_INTERFACES[interface_id].dialplan); - DEBUGA_SKYPE - ("interface_id=%d globals.SKYPOPEN_INTERFACES[interface_id].destination=%s\n", - SKYPOPEN_P_LOG, interface_id, globals.SKYPOPEN_INTERFACES[interface_id].destination); - DEBUGA_SKYPE - ("interface_id=%d globals.SKYPOPEN_INTERFACES[interface_id].X11_display=%s\n", - SKYPOPEN_P_LOG, interface_id, globals.SKYPOPEN_INTERFACES[interface_id].X11_display); - DEBUGA_SKYPE - ("interface_id=%d globals.SKYPOPEN_INTERFACES[interface_id].skype_user=%s\n", - SKYPOPEN_P_LOG, interface_id, globals.SKYPOPEN_INTERFACES[interface_id].skype_user); - DEBUGA_SKYPE - ("interface_id=%d globals.SKYPOPEN_INTERFACES[interface_id].report_incoming_chatmessages=%d\n", - SKYPOPEN_P_LOG, interface_id, globals.SKYPOPEN_INTERFACES[interface_id].report_incoming_chatmessages); - DEBUGA_SKYPE - ("interface_id=%d globals.SKYPOPEN_INTERFACES[interface_id].silent_mode=%d\n", - SKYPOPEN_P_LOG, interface_id, globals.SKYPOPEN_INTERFACES[interface_id].silent_mode); - DEBUGA_SKYPE - ("interface_id=%d globals.SKYPOPEN_INTERFACES[interface_id].write_silence_when_idle=%d\n", - SKYPOPEN_P_LOG, interface_id, globals.SKYPOPEN_INTERFACES[interface_id].write_silence_when_idle); - DEBUGA_SKYPE - ("interface_id=%d globals.SKYPOPEN_INTERFACES[interface_id].setsockopt=%d\n", - SKYPOPEN_P_LOG, interface_id, globals.SKYPOPEN_INTERFACES[interface_id].setsockopt); - - WARNINGA("STARTING interface_id=%d\n", SKYPOPEN_P_LOG, interface_id); - - switch_threadattr_create(&skypopen_api_thread_attr, skypopen_module_pool); - switch_threadattr_detach_set(skypopen_api_thread_attr, 0); - switch_threadattr_stacksize_set(skypopen_api_thread_attr, SWITCH_THREAD_STACKSIZE); - - switch_thread_create(&globals.SKYPOPEN_INTERFACES[interface_id].skypopen_api_thread, - skypopen_api_thread_attr, skypopen_do_skypeapi_thread, &globals.SKYPOPEN_INTERFACES[interface_id], - skypopen_module_pool); - - switch_sleep(100000); - - switch_threadattr_create(&skypopen_signaling_thread_attr, skypopen_module_pool); - switch_threadattr_detach_set(skypopen_signaling_thread_attr, 0); - switch_threadattr_stacksize_set(skypopen_signaling_thread_attr, SWITCH_THREAD_STACKSIZE); - - switch_thread_create(&globals.SKYPOPEN_INTERFACES[interface_id].skypopen_signaling_thread, skypopen_signaling_thread_attr, - skypopen_signaling_thread_func, &globals.SKYPOPEN_INTERFACES[interface_id], skypopen_module_pool); - - switch_sleep(100000); - - skypopen_audio_init(&globals.SKYPOPEN_INTERFACES[interface_id]); - switch_mutex_init(&globals.SKYPOPEN_INTERFACES[interface_id].mutex_audio_srv, SWITCH_MUTEX_NESTED, skypopen_module_pool); - switch_mutex_init(&globals.SKYPOPEN_INTERFACES[interface_id].mutex_audio_cli, SWITCH_MUTEX_NESTED, skypopen_module_pool); - switch_mutex_init(&globals.SKYPOPEN_INTERFACES[interface_id].mutex_thread_audio_srv, SWITCH_MUTEX_NESTED, skypopen_module_pool); - switch_mutex_init(&globals.SKYPOPEN_INTERFACES[interface_id].mutex_thread_audio_cli, SWITCH_MUTEX_NESTED, skypopen_module_pool); - - NOTICA - ("WAITING roughly 10 seconds to find a running Skype client and connect to its SKYPE API for interface_id=%d\n", - SKYPOPEN_P_LOG, interface_id); - i = 0; - while (globals.SKYPOPEN_INTERFACES[interface_id].SkypopenHandles.api_connected == 0 && running && i < 200) { // 10 seconds! thanks Jeff Lenk - switch_sleep(50000); - i++; - } - if (globals.SKYPOPEN_INTERFACES[interface_id].SkypopenHandles.api_connected) { - NOTICA - ("Found a running Skype client, connected to its SKYPE API for interface_id=%d, waiting 60 seconds for CURRENTUSERHANDLE==%s\n", - SKYPOPEN_P_LOG, interface_id, globals.SKYPOPEN_INTERFACES[interface_id].skype_user); - } else { - ERRORA - ("Failed to connect to a SKYPE API for interface_id=%d, no SKYPE client running, please (re)start Skype client. Skypopen exiting\n", - SKYPOPEN_P_LOG, interface_id); - running = 0; - switch_mutex_unlock(globals.mutex); - switch_xml_free(xml); - return SWITCH_STATUS_FALSE; - } - - i = 0; - while (globals.SKYPOPEN_INTERFACES[interface_id].SkypopenHandles.currentuserhandle == 0 && running && i < 1200) { // 60 seconds! thanks Jeff Lenk - switch_sleep(50000); - i++; - } - if (globals.SKYPOPEN_INTERFACES[interface_id].SkypopenHandles.currentuserhandle) { - WARNINGA - ("Interface_id=%d is now STARTED, the Skype client to which we are connected gave us the correct CURRENTUSERHANDLE (%s)\n", - SKYPOPEN_P_LOG, interface_id, globals.SKYPOPEN_INTERFACES[interface_id].skype_user); - - skypopen_signaling_write(&globals.SKYPOPEN_INTERFACES[interface_id], "PROTOCOL 999"); - switch_sleep(20000); - skypopen_signaling_write(&globals.SKYPOPEN_INTERFACES[interface_id], "SET AUTOAWAY OFF"); - switch_sleep(20000); - skypopen_signaling_write(&globals.SKYPOPEN_INTERFACES[interface_id], "SET WINDOWSTATE HIDDEN"); - switch_sleep(20000); - skypopen_signaling_write(&globals.SKYPOPEN_INTERFACES[interface_id], "SET USERSTATUS ONLINE"); - switch_sleep(20000); - if (globals.SKYPOPEN_INTERFACES[interface_id].silent_mode) { - skypopen_signaling_write(&globals.SKYPOPEN_INTERFACES[interface_id], "SET SILENT_MODE ON"); - switch_sleep(20000); - skypopen_signaling_write(&globals.SKYPOPEN_INTERFACES[interface_id], "SET SILENT_MODE OFF"); - switch_sleep(20000); - skypopen_signaling_write(&globals.SKYPOPEN_INTERFACES[interface_id], "SET SILENT_MODE ON"); - switch_sleep(20000); - } - } else { - ERRORA - ("The Skype client to which we are connected FAILED to gave us CURRENTUSERHANDLE=%s, interface_id=%d FAILED to start. No Skype client logged in as '%s' has been found. Please (re)launch a Skype client logged in as '%s'. Skypopen exiting now\n", - SKYPOPEN_P_LOG, globals.SKYPOPEN_INTERFACES[interface_id].skype_user, - interface_id, globals.SKYPOPEN_INTERFACES[interface_id].skype_user, globals.SKYPOPEN_INTERFACES[interface_id].skype_user); - running = 0; - switch_mutex_unlock(globals.mutex); - switch_xml_free(xml); - return SWITCH_STATUS_FALSE; - } - - } else { - ERRORA("interface id %d is higher than SKYPOPEN_MAX_INTERFACES (%d)\n", SKYPOPEN_P_LOG, interface_id, SKYPOPEN_MAX_INTERFACES); - continue; - } - - } - - for (i = 0; i < SKYPOPEN_MAX_INTERFACES; i++) { - if (strlen(globals.SKYPOPEN_INTERFACES[i].name)) { - /* How many real intterfaces */ - globals.real_interfaces = i + 1; - - tech_pvt = &globals.SKYPOPEN_INTERFACES[i]; - - DEBUGA_SKYPE("i=%d globals.SKYPOPEN_INTERFACES[%d].interface_id=%s\n", SKYPOPEN_P_LOG, i, i, globals.SKYPOPEN_INTERFACES[i].interface_id); - DEBUGA_SKYPE("i=%d globals.SKYPOPEN_INTERFACES[%d].name=%s\n", SKYPOPEN_P_LOG, i, i, globals.SKYPOPEN_INTERFACES[i].name); - DEBUGA_SKYPE("i=%d globals.SKYPOPEN_INTERFACES[%d].context=%s\n", SKYPOPEN_P_LOG, i, i, globals.SKYPOPEN_INTERFACES[i].context); - DEBUGA_SKYPE("i=%d globals.SKYPOPEN_INTERFACES[%d].dialplan=%s\n", SKYPOPEN_P_LOG, i, i, globals.SKYPOPEN_INTERFACES[i].dialplan); - DEBUGA_SKYPE("i=%d globals.SKYPOPEN_INTERFACES[%d].destination=%s\n", SKYPOPEN_P_LOG, i, i, globals.SKYPOPEN_INTERFACES[i].destination); - DEBUGA_SKYPE("i=%d globals.SKYPOPEN_INTERFACES[%d].X11_display=%s\n", SKYPOPEN_P_LOG, i, i, globals.SKYPOPEN_INTERFACES[i].X11_display); - DEBUGA_SKYPE("i=%d globals.SKYPOPEN_INTERFACES[%d].skype_user=%s\n", SKYPOPEN_P_LOG, i, i, globals.SKYPOPEN_INTERFACES[i].skype_user); - DEBUGA_SKYPE("i=%d globals.SKYPOPEN_INTERFACES[%d].report_incoming_chatmessages=%d\n", SKYPOPEN_P_LOG, i, i, - globals.SKYPOPEN_INTERFACES[i].report_incoming_chatmessages); - DEBUGA_SKYPE("i=%d globals.SKYPOPEN_INTERFACES[%d].silent_mode=%d\n", SKYPOPEN_P_LOG, i, i, globals.SKYPOPEN_INTERFACES[i].silent_mode); - DEBUGA_SKYPE("i=%d globals.SKYPOPEN_INTERFACES[%d].write_silence_when_idle=%d\n", SKYPOPEN_P_LOG, i, i, - globals.SKYPOPEN_INTERFACES[i].write_silence_when_idle); - DEBUGA_SKYPE("i=%d globals.SKYPOPEN_INTERFACES[%d].setsockopt=%d\n", SKYPOPEN_P_LOG, i, i, globals.SKYPOPEN_INTERFACES[i].setsockopt); - } - } - } - - switch_mutex_unlock(globals.mutex); - switch_xml_free(xml); - - return SWITCH_STATUS_SUCCESS; -} - -static switch_status_t chat_send(switch_event_t *message_event) -{ - char *user = NULL, *host, *f_user = NULL, *f_host = NULL, *f_resource = NULL; - private_t *tech_pvt = NULL; - int i = 0, found = 0, tried = 0; - char skype_msg[1024]; - - const char *proto; - const char *from; - const char *to; - const char *subject; - const char *body; - //const char *type; - const char *hint; - - proto = switch_event_get_header(message_event, "proto"); - from = switch_event_get_header(message_event, "from"); - to = switch_event_get_header(message_event, "to"); - subject = switch_event_get_header(message_event, "subject"); - body = switch_event_get_body(message_event); - //type = switch_event_get_header(message_event, "type"); - hint = switch_event_get_header(message_event, "hint"); - - switch_assert(proto != NULL); - - //DEBUGA_SKYPE("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=%s, hint=%s)\n", SKYPOPEN_P_LOG, proto, from, to, subject, body, type, - // hint ? hint : "NULL"); - DEBUGA_SKYPE("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, hint=%s)\n", SKYPOPEN_P_LOG, proto, from, to, subject, body, - hint ? hint : "NULL"); - - if (!to || !strlen(to)) { - ERRORA("Missing To: header.\n", SKYPOPEN_P_LOG); - return SWITCH_STATUS_SUCCESS; - } - - if ((!from && !hint) || (!strlen(from) && !strlen(hint))) { - ERRORA("Missing From: AND Hint: headers.\n", SKYPOPEN_P_LOG); - return SWITCH_STATUS_SUCCESS; - } - - if (from && (f_user = strdup(from))) { - if ((f_host = strchr(f_user, '@'))) { - *f_host++ = '\0'; - if ((f_resource = strchr(f_host, '/'))) { - *f_resource++ = '\0'; - } - } - } - - if (to && (user = strdup(to))) { - if ((host = strchr(user, '@'))) { - *host++ = '\0'; - } - //DEBUGA_SKYPE("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=%s, hint=%s)\n", SKYPOPEN_P_LOG, proto, from, to, subject, body, type, - // hint ? hint : "NULL"); - DEBUGA_SKYPE("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, hint=%s)\n", SKYPOPEN_P_LOG, proto, from, to, subject, body, - hint ? hint : "NULL"); - if (hint && strlen(hint)) { - //in hint we receive the interface name to use - for (i = 0; !found && i < SKYPOPEN_MAX_INTERFACES; i++) { - if (strlen(globals.SKYPOPEN_INTERFACES[i].name) - && (strncmp(globals.SKYPOPEN_INTERFACES[i].name, hint, strlen(hint)) == 0)) { - tech_pvt = &globals.SKYPOPEN_INTERFACES[i]; - DEBUGA_SKYPE("Using interface: globals.SKYPOPEN_INTERFACES[%d].name=|||%s|||\n", SKYPOPEN_P_LOG, i, - globals.SKYPOPEN_INTERFACES[i].name); - found = 1; - break; - } - } - } else { - //we have no a predefined interface name to use (hint is NULL), so let's choose an interface from the username (from) - for (i = 0; !found && i < SKYPOPEN_MAX_INTERFACES; i++) { - if (strlen(globals.SKYPOPEN_INTERFACES[i].name) - && (strncmp(globals.SKYPOPEN_INTERFACES[i].skype_user, from, strlen(from)) == 0)) { - tech_pvt = &globals.SKYPOPEN_INTERFACES[i]; - DEBUGA_SKYPE("Using interface: globals.SKYPOPEN_INTERFACES[%d].name=|||%s|||\n", SKYPOPEN_P_LOG, i, - globals.SKYPOPEN_INTERFACES[i].name); - found = 1; - break; - } - } - } - if (!found) { - ERRORA("ERROR: A Skypopen interface with name='%s' or one with skypeuser='%s' was not found\n", SKYPOPEN_P_LOG, hint ? hint : "NULL", - from ? from : "NULL"); - goto end; - } else { - - snprintf(skype_msg, sizeof(skype_msg), "CHAT CREATE %s", to); - skypopen_signaling_write(tech_pvt, skype_msg); - switch_sleep(20000); - } - - found = 0; - - while (!found) { - for (i = 0; i < MAX_CHATS; i++) { - //DEBUGA_SKYPE("tech_pvt->chats[i].dialog_partner='%s' to='%s'\n", SKYPOPEN_P_LOG, tech_pvt->chats[i].dialog_partner, to); - if (!strcmp(tech_pvt->chats[i].dialog_partner, to)) { - snprintf(skype_msg, sizeof(skype_msg), "CHATMESSAGE %s %s", tech_pvt->chats[i].chatname, body); - skypopen_signaling_write(tech_pvt, skype_msg); - found = 1; - break; - } - } - if (found) { - break; - } - tried++; - if (tried > 20) { - ERRORA - ("No chat with dialog_partner='%s' was found. (If you're using mod_sms this is a bug of mod_skypopen when using mod_sms, from next incoming message it will probably work...)\n", - SKYPOPEN_P_LOG, to); - break; - } - switch_sleep(50000); - } - - } - end: - switch_safe_free(user); - switch_safe_free(f_user); - return SWITCH_STATUS_SUCCESS; -} - - -SWITCH_MODULE_LOAD_FUNCTION(mod_skypopen_load) -{ - switch_api_interface_t *commands_api_interface; - switch_chat_interface_t *chat_interface; - - skypopen_module_pool = pool; - memset(&globals, '\0', sizeof(globals)); - - // CLOUDTREE (Thomas Hazel) -#ifndef WIN32 - // XXX: these assumes no one will override - //XSetErrorHandler(X11_errors_handler); - //XXX giovanni: seems that if Xserver is up, but skype client is crashed, the error is non fatal. Let's use Thomas handler in this case too - XSetErrorHandler(xio_error_handler2); - XSetIOErrorHandler(xio_error_handler); - - memset(&global_handles_list, 0, sizeof(global_handles_list)); - switch_mutex_init(&globals.list_mutex, SWITCH_MUTEX_NESTED, skypopen_module_pool); -#endif - - running = 1; - - if (load_config(FULL_RELOAD) == SWITCH_STATUS_SUCCESS) { - - *module_interface = switch_loadable_module_create_module_interface(pool, modname); - skypopen_endpoint_interface = switch_loadable_module_create_interface(*module_interface, SWITCH_ENDPOINT_INTERFACE); - skypopen_endpoint_interface->interface_name = "skypopen"; - skypopen_endpoint_interface->io_routines = &skypopen_io_routines; - skypopen_endpoint_interface->state_handler = &skypopen_state_handlers; - - if (running) { - - SWITCH_ADD_API(commands_api_interface, "sk", "Skypopen console commands", sk_function, SK_SYNTAX); - SWITCH_ADD_API(commands_api_interface, "skypopen", "Skypopen interface commands", skypopen_function, SKYPOPEN_SYNTAX); - SWITCH_ADD_API(commands_api_interface, "skypopen_chat", "Skypopen_chat interface remote_skypename TEXT", skypopen_chat_function, - SKYPOPEN_CHAT_SYNTAX); - SWITCH_ADD_CHAT(chat_interface, SKYPE_CHAT_PROTO, chat_send); - - if (switch_event_reserve_subclass(MY_EVENT_INCOMING_CHATMESSAGE) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass!\n"); - return SWITCH_STATUS_FALSE; - } - - if (switch_event_reserve_subclass(MY_EVENT_INCOMING_RAW) != SWITCH_STATUS_SUCCESS) { - switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldn't register subclass!\n"); - return SWITCH_STATUS_FALSE; - } - - /* indicate that the module should continue to be loaded */ - return SWITCH_STATUS_SUCCESS; - } - } else { - running = 0; - switch_sleep(1000000); //1 full second - return SWITCH_STATUS_FALSE; - } - return SWITCH_STATUS_FALSE; -} - -SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypopen_shutdown) -{ - int x; - private_t *tech_pvt = NULL; - switch_status_t status = SWITCH_STATUS_SUCCESS; - switch_size_t howmany = 8; - int interface_id; - - running = 0; - - for (interface_id = 0; interface_id < SKYPOPEN_MAX_INTERFACES; interface_id++) { - tech_pvt = &globals.SKYPOPEN_INTERFACES[interface_id]; - - - if (strlen(globals.SKYPOPEN_INTERFACES[interface_id].name)) { - if (globals.SKYPOPEN_INTERFACES[interface_id].skypopen_signaling_thread) { -#ifdef WIN32 - skypopen_signaling_write(tech_pvt, "DIE"); - switch_sleep(20000); - switch_file_write(tech_pvt->SkypopenHandles.fdesc[1], "sciutati", &howmany); // let's the controldev_thread die - -#else /* WIN32 */ - skypopen_signaling_write(tech_pvt, "DIE"); - switch_sleep(20000); - howmany = write(tech_pvt->SkypopenHandles.fdesc[1], "sciutati", howmany); -#endif /* WIN32 */ - } - - if (globals.SKYPOPEN_INTERFACES[interface_id].skypopen_api_thread) { -#ifdef WIN32 - if (SendMessage(tech_pvt->SkypopenHandles.win32_hInit_MainWindowHandle, WM_DESTROY, 0, 0) == FALSE) { // let's the skypopen_api_thread_func die - DEBUGA_SKYPE("got FALSE here, thread probably was already dead. GetLastError returned: %d\n", SKYPOPEN_P_LOG, GetLastError()); - tech_pvt->skypopen_api_thread = NULL; - } -#else - if (tech_pvt->SkypopenHandles.disp) { - XEvent e; - Atom atom1 = XInternAtom(tech_pvt->SkypopenHandles.disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", - False); - switch_sleep(20000); - XFlush(tech_pvt->SkypopenHandles.disp); - memset(&e, 0, sizeof(e)); - e.xclient.type = ClientMessage; - e.xclient.message_type = atom1; /* leading message */ - e.xclient.display = tech_pvt->SkypopenHandles.disp; - e.xclient.window = tech_pvt->SkypopenHandles.skype_win; - e.xclient.format = 8; - - XSendEvent(tech_pvt->SkypopenHandles.disp, tech_pvt->SkypopenHandles.win, False, 0, &e); - XFlush(tech_pvt->SkypopenHandles.disp); - } -#endif - } - x = 10; - while (x) { - x--; - switch_yield(50000); - } -#ifndef WIN32 - if (tech_pvt->SkypopenHandles.disp) { - DEBUGA_SKYPE("CLOSIN X\n", SKYPOPEN_P_LOG); - XCloseDisplay(tech_pvt->SkypopenHandles.disp); - DEBUGA_SKYPE("CLOSIN X END\n", SKYPOPEN_P_LOG); - } -#endif - if (globals.SKYPOPEN_INTERFACES[interface_id].skypopen_signaling_thread) { - switch_thread_join(&status, globals.SKYPOPEN_INTERFACES[interface_id].skypopen_signaling_thread); - } - if (status != SWITCH_STATUS_SUCCESS) - DEBUGA_SKYPE("got FALSE here, thread was not joined\n", SKYPOPEN_P_LOG); - if (globals.SKYPOPEN_INTERFACES[interface_id].skypopen_api_thread) { - switch_thread_join(&status, globals.SKYPOPEN_INTERFACES[interface_id].skypopen_api_thread); - } - if (status != SWITCH_STATUS_SUCCESS) - DEBUGA_SKYPE("got FALSE here, thread was not joined\n", SKYPOPEN_P_LOG); -#ifndef WIN32 - WARNINGA("SHUTDOWN interface_id=%d\n", SKYPOPEN_P_LOG, interface_id); - shutdown(tech_pvt->audiopipe_cli[0], 2); - close(tech_pvt->audiopipe_cli[0]); - shutdown(tech_pvt->audiopipe_cli[1], 2); - close(tech_pvt->audiopipe_cli[1]); - shutdown(tech_pvt->audiopipe_srv[0], 2); - close(tech_pvt->audiopipe_srv[0]); - shutdown(tech_pvt->audiopipe_srv[1], 2); - close(tech_pvt->audiopipe_srv[1]); - shutdown(tech_pvt->SkypopenHandles.fdesc[0], 2); - close(tech_pvt->SkypopenHandles.fdesc[0]); - shutdown(tech_pvt->SkypopenHandles.fdesc[1], 2); - close(tech_pvt->SkypopenHandles.fdesc[1]); -#endif /* WIN32 */ - } - - } - switch_event_free_subclass(MY_EVENT_INCOMING_CHATMESSAGE); - switch_event_free_subclass(MY_EVENT_INCOMING_RAW); - - switch_safe_free(globals.context); - switch_safe_free(globals.dialplan); - switch_safe_free(globals.destination); - switch_safe_free(globals.skype_user); - switch_safe_free(globals.report_incoming_chatmessages); - switch_safe_free(globals.silent_mode); - switch_safe_free(globals.write_silence_when_idle); - switch_safe_free(globals.setsockopt); - - return SWITCH_STATUS_SUCCESS; -} - -void *SWITCH_THREAD_FUNC skypopen_do_tcp_srv_thread(switch_thread_t *thread, void *obj) -{ - return skypopen_do_tcp_srv_thread_func(obj); -} - -void *SWITCH_THREAD_FUNC skypopen_do_tcp_cli_thread(switch_thread_t *thread, void *obj) -{ - return skypopen_do_tcp_cli_thread_func(obj); -} - -void *SWITCH_THREAD_FUNC skypopen_do_skypeapi_thread(switch_thread_t *thread, void *obj) -{ - return skypopen_do_skypeapi_thread_func(obj); -} - -int dtmf_received(private_t *tech_pvt, char *value) -{ - switch_core_session_t *session = NULL; - switch_channel_t *channel = NULL; - - session = switch_core_session_locate(tech_pvt->session_uuid_str); - if (session) { - channel = switch_core_session_get_channel(session); - - if (channel) { - - if (switch_channel_test_flag(channel, CF_BRIDGED) - && !switch_true(switch_channel_get_variable(channel, "skype_add_outband_dtmf_also_when_bridged"))) { - - - NOTICA - ("received DTMF '%c' on channel %s, but we're BRIDGED, so we DO NOT relay it out of band. If you DO want to relay it out of band when bridged too, on top of audio DTMF, set the channel variable 'skype_add_outband_dtmf_also_when_bridged=true' \n", - SKYPOPEN_P_LOG, value[0], switch_channel_get_name(channel)); - - } else { - - - - switch_dtmf_t dtmf = { (char) value[0], switch_core_default_dtmf_duration(0) }; - DEBUGA_SKYPE("received DTMF %c on channel %s\n", SKYPOPEN_P_LOG, 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); - } - } else { - WARNINGA("received %c DTMF, but no channel?\n", SKYPOPEN_P_LOG, value[0]); - } - switch_core_session_rwunlock(session); - } else { - WARNINGA("received %c DTMF, but no session?\n", SKYPOPEN_P_LOG, value[0]); - } - - return 0; -} - -void *SWITCH_THREAD_FUNC skypopen_do_mod_sms_thread(switch_thread_t *thread, void *obj) -{ - switch_event_t *event; - - - event = obj; - switch_core_chat_send("GLOBAL", event); /* mod_sms */ - - return event; - -} - - - -int start_mod_sms_thread(private_t *tech_pvt, switch_event_t *event) -{ - switch_threadattr_t *mod_sms_thread_thd_attr = NULL; - switch_thread_t *mod_sms_thread; - - - switch_threadattr_create(&mod_sms_thread_thd_attr, skypopen_module_pool); - switch_threadattr_detach_set(mod_sms_thread_thd_attr, 0); - switch_threadattr_stacksize_set(mod_sms_thread_thd_attr, SWITCH_THREAD_STACKSIZE); - if (switch_thread_create(&mod_sms_thread, mod_sms_thread_thd_attr, skypopen_do_mod_sms_thread, event, skypopen_module_pool) == SWITCH_STATUS_SUCCESS) { - DEBUGA_SKYPE("started mod_sms_thread thread.\n", SKYPOPEN_P_LOG); - } else { - ERRORA("failed to start mod_sms_thread thread.\n", SKYPOPEN_P_LOG); - return -1; - } - if (mod_sms_thread == NULL) { - WARNINGA("mod_sms_thread exited\n", SKYPOPEN_P_LOG); - return -1; - } - - return 0; -} - - -int start_audio_threads(private_t *tech_pvt) -{ - switch_threadattr_t *tcp_srv_thread_thd_attr = NULL; - switch_threadattr_t *tcp_cli_thread_thd_attr = NULL; - - tech_pvt->begin_to_write = 0; - tech_pvt->begin_to_read = 0; - - if (switch_core_timer_init(&tech_pvt->timer_read, "soft", MS_SKYPOPEN, SAMPLES_PER_FRAME, skypopen_module_pool) != SWITCH_STATUS_SUCCESS) { - ERRORA("setup timer failed\n", SKYPOPEN_P_LOG); - return SWITCH_STATUS_FALSE; - } - - switch_core_timer_sync(&tech_pvt->timer_read); - - if (switch_core_timer_init(&tech_pvt->timer_read_srv, "soft", MS_SKYPOPEN, SAMPLES_PER_FRAME, skypopen_module_pool) != SWITCH_STATUS_SUCCESS) { - ERRORA("setup timer failed\n", SKYPOPEN_P_LOG); - return SWITCH_STATUS_FALSE; - } - - switch_core_timer_sync(&tech_pvt->timer_read_srv); - - if (switch_core_timer_init(&tech_pvt->timer_write, "soft", MS_SKYPOPEN, SAMPLES_PER_FRAME, skypopen_module_pool) != SWITCH_STATUS_SUCCESS) { - ERRORA("setup timer failed\n", SKYPOPEN_P_LOG); - return SWITCH_STATUS_FALSE; - } - - switch_core_timer_sync(&tech_pvt->timer_write); - - switch_threadattr_create(&tcp_srv_thread_thd_attr, skypopen_module_pool); - switch_threadattr_detach_set(tcp_srv_thread_thd_attr, 0); - switch_threadattr_stacksize_set(tcp_srv_thread_thd_attr, SWITCH_THREAD_STACKSIZE); - switch_threadattr_priority_set(tcp_srv_thread_thd_attr, SWITCH_PRI_REALTIME); - switch_mutex_lock(tech_pvt->mutex_thread_audio_srv); - //DEBUGA_SKYPE("debugging_hangup srv lock\n", SKYPOPEN_P_LOG); - if (switch_thread_create(&tech_pvt->tcp_srv_thread, tcp_srv_thread_thd_attr, skypopen_do_tcp_srv_thread, tech_pvt, skypopen_module_pool) == - SWITCH_STATUS_SUCCESS) { - DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPOPEN_P_LOG); - } else { - ERRORA("failed to start tcp_srv_thread thread.\n", SKYPOPEN_P_LOG); - switch_mutex_unlock(tech_pvt->mutex_thread_audio_srv); - //DEBUGA_SKYPE("debugging_hangup srv unlock\n", SKYPOPEN_P_LOG); - return -1; - } - switch_mutex_unlock(tech_pvt->mutex_thread_audio_srv); - //DEBUGA_SKYPE("debugging_hangup srv unlock\n", SKYPOPEN_P_LOG); - - switch_threadattr_create(&tcp_cli_thread_thd_attr, skypopen_module_pool); - switch_threadattr_detach_set(tcp_cli_thread_thd_attr, 0); - switch_threadattr_stacksize_set(tcp_cli_thread_thd_attr, SWITCH_THREAD_STACKSIZE); - switch_threadattr_priority_set(tcp_cli_thread_thd_attr, SWITCH_PRI_REALTIME); - switch_mutex_lock(tech_pvt->mutex_thread_audio_cli); - //DEBUGA_SKYPE("debugging_hangup cli lock\n", SKYPOPEN_P_LOG); - if (switch_thread_create(&tech_pvt->tcp_cli_thread, tcp_cli_thread_thd_attr, skypopen_do_tcp_cli_thread, tech_pvt, skypopen_module_pool) == - SWITCH_STATUS_SUCCESS) { - DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPOPEN_P_LOG); - } else { - ERRORA("failed to start tcp_cli_thread thread.\n", SKYPOPEN_P_LOG); - switch_mutex_unlock(tech_pvt->mutex_thread_audio_cli); - //DEBUGA_SKYPE("debugging_hangup cli unlock\n", SKYPOPEN_P_LOG); - return -1; - } - switch_mutex_unlock(tech_pvt->mutex_thread_audio_cli); - //DEBUGA_SKYPE("debugging_hangup cli unlock\n", SKYPOPEN_P_LOG); - switch_sleep(100000); - - if (tech_pvt->tcp_cli_thread == NULL || tech_pvt->tcp_srv_thread == NULL) { - WARNINGA("tcp_cli_thread or tcp_srv_thread exited\n", SKYPOPEN_P_LOG); - return -1; - } - - return 0; -} - -int new_inbound_channel(private_t *tech_pvt) -{ - switch_core_session_t *session = NULL; - switch_channel_t *channel = NULL; - - if ((session = switch_core_session_request(skypopen_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, SOF_NONE, NULL)) != 0) { - DEBUGA_SKYPE("2 SESSION_REQUEST %s\n", SKYPOPEN_P_LOG, switch_core_session_get_uuid(session)); - switch_core_session_add_stream(session, NULL); - channel = switch_core_session_get_channel(session); - if (!channel) { - ERRORA("Doh! no channel?\n", SKYPOPEN_P_LOG); - switch_core_session_destroy(&session); - return 0; - } - switch_channel_set_variable(channel, "waste", "false"); - if (skypopen_tech_init(tech_pvt, session) != SWITCH_STATUS_SUCCESS) { - ERRORA("Doh! no tech_init?\n", SKYPOPEN_P_LOG); - switch_core_session_destroy(&session); - return 0; - } - - if ((tech_pvt->caller_profile = - switch_caller_profile_new(switch_core_session_get_pool(session), "skypopen", - tech_pvt->dialplan, tech_pvt->callid_name, - tech_pvt->callid_number, NULL, NULL, NULL, NULL, "mod_skypopen", tech_pvt->context, tech_pvt->destination)) != 0) { - char name[128]; - switch_snprintf(name, sizeof(name), "skypopen/%s", tech_pvt->name); - 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) { - ERRORA("Error spawning thread\n", SKYPOPEN_P_LOG); - switch_core_session_destroy(&session); - return 0; - } - } - if (channel) { - switch_channel_set_variable(channel, "skype_user", tech_pvt->skype_user); - switch_channel_set_variable(channel, "initial_skype_user", tech_pvt->initial_skype_user); - } - - DEBUGA_SKYPE("new_inbound_channel\n", SKYPOPEN_P_LOG); - - return 0; -} - -int remote_party_is_ringing(private_t *tech_pvt) -{ - switch_core_session_t *session = NULL; - switch_channel_t *channel = NULL; - - if (!zstr(tech_pvt->session_uuid_str)) { - session = switch_core_session_locate(tech_pvt->session_uuid_str); - } else { - ERRORA("No session_uuid_str???\n", SKYPOPEN_P_LOG); - return SWITCH_STATUS_FALSE; - } - if (session) { - channel = switch_core_session_get_channel(session); - } else { - ERRORA("No session???\n", SKYPOPEN_P_LOG); - return SWITCH_STATUS_FALSE; - } - if (channel) { - switch_channel_mark_ring_ready(channel); - DEBUGA_SKYPE("skype_call: REMOTE PARTY RINGING\n", SKYPOPEN_P_LOG); - } else { - ERRORA("No channel???\n", SKYPOPEN_P_LOG); - } - - switch_core_session_rwunlock(session); - - return SWITCH_STATUS_SUCCESS; -} - -int remote_party_is_early_media(private_t *tech_pvt) -{ - switch_core_session_t *session = NULL; - switch_channel_t *channel = NULL; - - if (!zstr(tech_pvt->session_uuid_str)) { - session = switch_core_session_locate(tech_pvt->session_uuid_str); - } else { - ERRORA("No session_uuid_str???\n\n\n", SKYPOPEN_P_LOG); - goto done; - } - if (session) { - channel = switch_core_session_get_channel(session); - switch_core_session_add_stream(session, NULL); - } else { - ERRORA("No session???\n", SKYPOPEN_P_LOG); - goto done; - } - if (channel) { - switch_channel_mark_pre_answered(channel); - DEBUGA_SKYPE("skype_call: REMOTE PARTY EARLY MEDIA\n", SKYPOPEN_P_LOG); - } else { - ERRORA("No channel???\n", SKYPOPEN_P_LOG); - } - - switch_core_session_rwunlock(session); - - done: - return 0; -} - -int outbound_channel_answered(private_t *tech_pvt) -{ - switch_core_session_t *session = NULL; - switch_channel_t *channel = NULL; - - if (!zstr(tech_pvt->session_uuid_str)) { - session = switch_core_session_locate(tech_pvt->session_uuid_str); - } else { - ERRORA("No session???\n", SKYPOPEN_P_LOG); - goto done; - } - if (session) { - channel = switch_core_session_get_channel(session); - } else { - ERRORA("No channel???\n", SKYPOPEN_P_LOG); - goto done; - } - if (channel) { - switch_channel_mark_answered(channel); - } else { - ERRORA("No channel???\n", SKYPOPEN_P_LOG); - } - - switch_core_session_rwunlock(session); - - done: - DEBUGA_SKYPE("outbound_channel_answered!\n", SKYPOPEN_P_LOG); - - return 0; -} - -private_t *find_available_skypopen_interface_rr(private_t *tech_pvt_calling) -{ - private_t *tech_pvt = NULL; - int i; - - switch_mutex_lock(globals.mutex); - - /* Fact is the real interface start from 1 */ - //XXX no, is just a convention, but you can have it start from 0. I do not, for aestetic reasons :-) - - for (i = 0; i < SKYPOPEN_MAX_INTERFACES; i++) { - int interface_id; - - interface_id = globals.next_interface; - globals.next_interface = interface_id + 1 < SKYPOPEN_MAX_INTERFACES ? interface_id + 1 : 0; - - if (strlen(globals.SKYPOPEN_INTERFACES[interface_id].name)) { - int skype_state = 0; - - tech_pvt = &globals.SKYPOPEN_INTERFACES[interface_id]; - skype_state = tech_pvt->interface_state; - if ((tech_pvt_calling ? strcmp(tech_pvt->skype_user, tech_pvt_calling->skype_user) : 1) - && (SKYPOPEN_STATE_IDLE == skype_state)) { - DEBUGA_SKYPE("returning as available skype interface name: %s, state: %d callflow: %d\n", SKYPOPEN_P_LOG, tech_pvt->name, skype_state, - tech_pvt->skype_callflow); - if (tech_pvt_calling == NULL) { - tech_pvt->interface_state = SKYPOPEN_STATE_SELECTED; - } - - switch_mutex_unlock(globals.mutex); - return tech_pvt; - } - } - } - - switch_mutex_unlock(globals.mutex); - return NULL; -} - -SWITCH_STANDARD_API(sk_function) -{ - char *mycmd = NULL, *argv[10] = { 0 }; - int argc = 0; - int tmp_i = 0; - char tmp_message[4096]; - - if (globals.sk_console) - stream->write_function(stream, "sk console is: |||%s|||\n", globals.sk_console->name); - else - stream->write_function(stream, "sk console is NOT yet assigned\n"); - - if (!zstr(cmd) && (mycmd = strdup(cmd))) { - argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); - } - - if (!argc || !argv[0]) { - stream->write_function(stream, "%s", SK_SYNTAX); - goto end; - } - - - if (!strcasecmp(argv[0], "balances")) { - stream->write_function(stream, " Name \tBalance\tCurrency\n"); - stream->write_function(stream, " ==== \t=======\t========\n"); - - for (tmp_i = 0; tmp_i < SKYPOPEN_MAX_INTERFACES; tmp_i++) { - if (strlen(globals.SKYPOPEN_INTERFACES[tmp_i].name)) { - skypopen_signaling_write(&globals.SKYPOPEN_INTERFACES[tmp_i], "GET PROFILE PSTN_BALANCE"); - switch_sleep(20000); - - strncpy(tmp_message, globals.SKYPOPEN_INTERFACES[tmp_i].message, sizeof(globals.SKYPOPEN_INTERFACES[tmp_i].message)); - - skypopen_signaling_write(&globals.SKYPOPEN_INTERFACES[tmp_i], "GET PROFILE PSTN_BALANCE_CURRENCY"); - switch_sleep(20000); - if (strlen(tmp_message) > 21 && strlen(globals.SKYPOPEN_INTERFACES[tmp_i].message) > 30) - stream->write_function(stream, " %s \t%s\t%s\n", globals.SKYPOPEN_INTERFACES[tmp_i].name, tmp_message + 21, - globals.SKYPOPEN_INTERFACES[tmp_i].message + 30); - } - } - } else if (!strcasecmp(argv[0], "list")) { - int i; - unsigned int ib = 0; - unsigned int ib_failed = 0; - unsigned int ob = 0; - unsigned int ob_failed = 0; - char next_flag_char = ' '; - - stream->write_function(stream, "F ID\t Name \tIB (F/T) OB (F/T)\tState\tCallFlw\t\tUUID\n"); - stream->write_function(stream, "= ====\t ======== \t======= =======\t======\t============\t======\n"); - - for (i = 0; i < SKYPOPEN_MAX_INTERFACES; i++) { - if (strlen(globals.SKYPOPEN_INTERFACES[i].name)) { - next_flag_char = i == globals.next_interface ? '*' : ' '; - ib += globals.SKYPOPEN_INTERFACES[i].ib_calls; - ib_failed += globals.SKYPOPEN_INTERFACES[i].ib_failed_calls; - ob += globals.SKYPOPEN_INTERFACES[i].ob_calls; - ob_failed += globals.SKYPOPEN_INTERFACES[i].ob_failed_calls; - - stream->write_function(stream, - "%c %d\t[%6s]\t%3u/%u\t%6u/%u\t%s\t%s\t%s\n", - next_flag_char, - i, globals.SKYPOPEN_INTERFACES[i].name, - globals.SKYPOPEN_INTERFACES[i].ib_failed_calls, - globals.SKYPOPEN_INTERFACES[i].ib_calls, - globals.SKYPOPEN_INTERFACES[i].ob_failed_calls, - globals.SKYPOPEN_INTERFACES[i].ob_calls, - interface_status[globals.SKYPOPEN_INTERFACES[i].interface_state], - skype_callflow[globals.SKYPOPEN_INTERFACES[i].skype_callflow], globals.SKYPOPEN_INTERFACES[i].session_uuid_str); - } else if (argc > 1 && !strcasecmp(argv[1], "full")) { - stream->write_function(stream, "%c %d\n", next_flag_char, i); - } - - } - stream->write_function(stream, "\nTotal Interfaces: %d IB Calls(Failed/Total): %u/%u OB Calls(Failed/Total): %u/%u\n", - globals.real_interfaces > 0 ? globals.real_interfaces - 1 : 0, ib_failed, ib, ob_failed, ob); - - } else if (!strcasecmp(argv[0], "console")) { - int i; - int found = 0; - - if (argc == 2) { - for (i = 0; !found && i < SKYPOPEN_MAX_INTERFACES; i++) { - /* we've been asked for a normal interface name, or we have not found idle interfaces to serve as the "ANY" interface */ - if (strlen(globals.SKYPOPEN_INTERFACES[i].name) - && (strncmp(globals.SKYPOPEN_INTERFACES[i].name, argv[1], strlen(argv[1])) == 0)) { - globals.sk_console = &globals.SKYPOPEN_INTERFACES[i]; - stream->write_function(stream, - "sk console is now: globals.SKYPOPEN_INTERFACES[%d].name=|||%s|||\n", i, globals.SKYPOPEN_INTERFACES[i].name); - stream->write_function(stream, "sk console is: |||%s|||\n", globals.sk_console->name); - found = 1; - break; - } - - } - if (!found) - stream->write_function(stream, "ERROR: A Skypopen interface with name='%s' was not found\n", argv[1]); - } else { - - stream->write_function(stream, "-ERR Usage: sk console interface_name\n"); - goto end; - } - - } else if (!strcasecmp(argv[0], "reload")) { - if (load_config(SOFT_RELOAD) != SWITCH_STATUS_SUCCESS) { - stream->write_function(stream, "sk reload failed\n"); - } else { - stream->write_function(stream, "sk reload success\n"); - } - } else if (!strcasecmp(argv[0], "remove")) { - if (argc == 2) { - if (remove_interface(argv[1], FALSE) == SWITCH_STATUS_SUCCESS) { - if (interface_exists(argv[1]) == SWITCH_STATUS_SUCCESS) { - stream->write_function(stream, "sk remove '%s' failed\n", argv[1]); - } else { - stream->write_function(stream, "sk remove '%s' success\n", argv[1]); - } - } - } else { - stream->write_function(stream, "-ERR Usage: sk remove interface_name\n"); - goto end; - } - - } else { - if (globals.sk_console) - skypopen_signaling_write(globals.sk_console, (char *) cmd); - else - stream->write_function(stream, "sk console is NOT yet assigned\n"); - } - end: - switch_safe_free(mycmd); - - return SWITCH_STATUS_SUCCESS; -} - -SWITCH_STANDARD_API(skypopen_function) -{ - char *mycmd = NULL, *argv[10] = { 0 }; - int argc = 0; - private_t *tech_pvt = NULL; - - if (!zstr(cmd) && (mycmd = strdup(cmd))) { - argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); - } - - if (!argc) { - stream->write_function(stream, "ERROR, usage: %s", SKYPOPEN_SYNTAX); - goto end; - } - - if (argc < 2) { - stream->write_function(stream, "ERROR, usage: %s", SKYPOPEN_SYNTAX); - goto end; - } - - if (argv[0]) { - int i; - int found = 0; - - for (i = 0; !found && i < SKYPOPEN_MAX_INTERFACES; i++) { - /* we've been asked for a normal interface name, or we have not found idle interfaces to serve as the "ANY" interface */ - if (strlen(globals.SKYPOPEN_INTERFACES[i].name) - && (strncmp(globals.SKYPOPEN_INTERFACES[i].name, argv[0], strlen(argv[0])) == 0)) { - tech_pvt = &globals.SKYPOPEN_INTERFACES[i]; - stream->write_function(stream, "Using interface: globals.SKYPOPEN_INTERFACES[%d].name=|||%s|||\n", i, globals.SKYPOPEN_INTERFACES[i].name); - found = 1; - break; - } - - } - if (!found) { - stream->write_function(stream, "ERROR: A Skypopen interface with name='%s' was not found\n", argv[0]); - switch_safe_free(mycmd); - - return SWITCH_STATUS_SUCCESS; - } else { - skypopen_signaling_write(tech_pvt, (char *) &cmd[strlen(argv[0]) + 1]); - } - } else { - stream->write_function(stream, "ERROR, usage: %s", SKYPOPEN_SYNTAX); - } - end: - switch_safe_free(mycmd); - - return SWITCH_STATUS_SUCCESS; -} - - -int skypopen_partner_handle_ring(private_t *tech_pvt) -{ - char msg_to_skype[1024]; - int i; - int found = 0; - private_t *giovatech; - struct timeval timenow; - char *id = tech_pvt->ring_id; - char *value = tech_pvt->ring_value; - switch_core_session_t *session = NULL; - - switch_mutex_lock(globals.mutex); - - gettimeofday(&timenow, NULL); - for (i = 0; !found && i < SKYPOPEN_MAX_INTERFACES; i++) { - if (strlen(globals.SKYPOPEN_INTERFACES[i].name)) { - - giovatech = &globals.SKYPOPEN_INTERFACES[i]; - if ((giovatech->interface_state != SKYPOPEN_STATE_DEAD) && (giovatech->interface_state != SKYPOPEN_STATE_DOWN) && (giovatech->interface_state != SKYPOPEN_STATE_IDLE) && (strcmp(giovatech->name, tech_pvt->name)) && (!strcmp(giovatech->skype_user, tech_pvt->skype_user)) && (!strcmp(giovatech->ring_value, value)) && ((((timenow.tv_sec - giovatech->ring_time.tv_sec) * 1000000) + (timenow.tv_usec - giovatech->ring_time.tv_usec)) < 1000000)) { //XXX 1.0sec - can have a max of 1 call coming from the same skypename to the same skypename each 1.0 seconds - found = 1; - DEBUGA_SKYPE - ("FOUND (name=%s, giovatech->interface_state=%d != SKYPOPEN_STATE_DOWN) && (giovatech->skype_user=%s == tech_pvt->skype_user=%s) && (giovatech->callid_number=%s == value=%s)\n", - SKYPOPEN_P_LOG, giovatech->name, giovatech->interface_state, giovatech->skype_user, tech_pvt->skype_user, giovatech->callid_number, - value); - if (tech_pvt->interface_state == SKYPOPEN_STATE_PRERING) { - tech_pvt->interface_state = SKYPOPEN_STATE_DOWN; - } else if (tech_pvt->interface_state != 0 && tech_pvt->interface_state != SKYPOPEN_STATE_DOWN) { - WARNINGA("Why an interface_state %d HERE?\n", SKYPOPEN_P_LOG, tech_pvt->interface_state); - tech_pvt->interface_state = SKYPOPEN_STATE_DOWN; - } - - *tech_pvt->answer_id = '\0'; - *tech_pvt->answer_value = '\0'; - *tech_pvt->ring_id = '\0'; - *tech_pvt->ring_value = '\0'; - break; - } - } - } - - if (found) { - switch_mutex_unlock(globals.mutex); - return 0; - } - DEBUGA_SKYPE("NOT FOUND\n", SKYPOPEN_P_LOG); - - // CLOUDTREE (Thomas Hazel) - if (tech_pvt && tech_pvt->ringing_state == SKYPOPEN_RINGING_INIT) { - /* we are not inside an active call */ - - switch_channel_t *channel = NULL; - - tech_pvt->interface_state = SKYPOPEN_STATE_PRERING; - gettimeofday(&tech_pvt->ring_time, NULL); - switch_copy_string(tech_pvt->callid_number, value, sizeof(tech_pvt->callid_number) - 1); - - session = switch_core_session_locate(tech_pvt->session_uuid_str); - if (session) { - switch_core_session_rwunlock(session); - return 0; - } - - new_inbound_channel(tech_pvt); - - switch_sleep(10000); - - session = switch_core_session_locate(tech_pvt->session_uuid_str); - if (session) { - channel = switch_core_session_get_channel(session); - switch_core_session_queue_indication(session, SWITCH_MESSAGE_INDICATE_RINGING); - if (channel) { - switch_channel_mark_ring_ready(channel); - DEBUGA_SKYPE("switch_channel_mark_ring_ready(channel);\n", SKYPOPEN_P_LOG); - } else { - ERRORA("no channel\n", SKYPOPEN_P_LOG); - } - switch_core_session_rwunlock(session); - } else { - ERRORA("no session\n", SKYPOPEN_P_LOG); - } - } else if (!tech_pvt || !tech_pvt->skype_call_id[0]) { - ERRORA("No Call ID?\n", SKYPOPEN_P_LOG); - } else { - DEBUGA_SKYPE("We're in a call now (%s), let's refuse this one (%s)\n", SKYPOPEN_P_LOG, tech_pvt->skype_call_id, id); - sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - sprintf(msg_to_skype, "ALTER CALL %s HANGUP", id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - } - - switch_mutex_unlock(globals.mutex); - return 0; -} - -int skypopen_answer(private_t *tech_pvt) -{ - char msg_to_skype[1024]; - int i; - int found = 0; - private_t *giovatech; - struct timeval timenow; - char *id = tech_pvt->answer_id; - char *value = tech_pvt->answer_value; - switch_core_session_t *session = NULL; - switch_channel_t *channel = NULL; - - switch_mutex_lock(globals.mutex); - - gettimeofday(&timenow, NULL); - for (i = 0; !found && i < SKYPOPEN_MAX_INTERFACES; i++) { - if (strlen(globals.SKYPOPEN_INTERFACES[i].name)) { - - giovatech = &globals.SKYPOPEN_INTERFACES[i]; - if (strlen(giovatech->skype_call_id) && (giovatech->interface_state != SKYPOPEN_STATE_DEAD) && (giovatech->interface_state != SKYPOPEN_STATE_DOWN) && (giovatech->interface_state != SKYPOPEN_STATE_IDLE) && (strcmp(giovatech->name, tech_pvt->name)) && (!strcmp(giovatech->skype_user, tech_pvt->skype_user)) && (!strcmp(giovatech->callid_number, value)) && ((((timenow.tv_sec - giovatech->answer_time.tv_sec) * 1000000) + (timenow.tv_usec - giovatech->answer_time.tv_usec)) < 1000000)) { //XXX 1.0sec - can have a max of 1 call coming from the same skypename to the same skypename each 1.0 seconds - found = 1; - DEBUGA_SKYPE - ("FOUND (name=%s, giovatech->interface_state=%d != SKYPOPEN_STATE_DOWN) && (giovatech->skype_user=%s == tech_pvt->skype_user=%s) && (giovatech->callid_number=%s == value=%s)\n", - SKYPOPEN_P_LOG, giovatech->name, giovatech->interface_state, giovatech->skype_user, tech_pvt->skype_user, giovatech->callid_number, - value); - if (tech_pvt->interface_state == SKYPOPEN_STATE_PRERING) { - tech_pvt->interface_state = SKYPOPEN_STATE_DOWN; - } else if (tech_pvt->interface_state != 0 && tech_pvt->interface_state != SKYPOPEN_STATE_DOWN) { - WARNINGA("Why an interface_state %d HERE?\n", SKYPOPEN_P_LOG, tech_pvt->interface_state); - tech_pvt->interface_state = SKYPOPEN_STATE_DOWN; - } - - - if (!zstr(tech_pvt->session_uuid_str)) { - session = switch_core_session_locate(tech_pvt->session_uuid_str); - } else { - ERRORA("No session_uuid_str???\n", SKYPOPEN_P_LOG); - break; - } - if (session) { - channel = switch_core_session_get_channel(session); - } else { - ERRORA("No session???\n", SKYPOPEN_P_LOG); - switch_core_session_rwunlock(session); - break; - } - if (channel) { - switch_channel_set_state(channel, CS_RESET); - } else { - ERRORA("No channel???\n", SKYPOPEN_P_LOG); - switch_core_session_rwunlock(session); - break; - } - - switch_core_session_rwunlock(session); - - break; - } - } - } - - if (found) { - switch_mutex_unlock(globals.mutex); - return 0; - } - DEBUGA_SKYPE("NOT FOUND\n", SKYPOPEN_P_LOG); - - // CLOUDTREE (Thomas Hazel) - if (tech_pvt && tech_pvt->ringing_state == SKYPOPEN_RINGING_INIT) { - /* we are not inside an active call */ - - tech_pvt->ib_calls++; - - tech_pvt->interface_state = SKYPOPEN_STATE_PREANSWER; - sprintf(msg_to_skype, "ALTER CALL %s ANSWER", id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - DEBUGA_SKYPE("We answered a Skype RING on skype_call %s\n", SKYPOPEN_P_LOG, id); - gettimeofday(&tech_pvt->answer_time, NULL); - switch_copy_string(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); - - switch_copy_string(tech_pvt->callid_number, value, sizeof(tech_pvt->callid_number) - 1); - - DEBUGA_SKYPE - ("NEW! name: %s, state: %d, value=%s, tech_pvt->callid_number=%s, tech_pvt->skype_user=%s\n", - SKYPOPEN_P_LOG, tech_pvt->name, tech_pvt->interface_state, value, tech_pvt->callid_number, tech_pvt->skype_user); - } else if (!tech_pvt || !tech_pvt->skype_call_id[0]) { - ERRORA("No Call ID?\n", SKYPOPEN_P_LOG); - } else { - DEBUGA_SKYPE("We're in a call now (%s), let's refuse this one (%s)\n", SKYPOPEN_P_LOG, tech_pvt->skype_call_id, id); - sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - sprintf(msg_to_skype, "ALTER CALL %s HANGUP", id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - } - - switch_mutex_unlock(globals.mutex); - return 0; -} - -int skypopen_transfer(private_t *tech_pvt) -{ - char msg_to_skype[1024]; - int i; - int found = 0; - private_t *giovatech; - struct timeval timenow; - char *id = tech_pvt->ring_id; - char *value = tech_pvt->ring_value; - - switch_mutex_lock(globals.mutex); - - gettimeofday(&timenow, NULL); - for (i = 0; !found && i < SKYPOPEN_MAX_INTERFACES; i++) { - if (strlen(globals.SKYPOPEN_INTERFACES[i].name)) { - - giovatech = &globals.SKYPOPEN_INTERFACES[i]; - /* let's look for a RINGING one */ - if ((giovatech->interface_state != SKYPOPEN_STATE_DEAD) && (giovatech->interface_state != SKYPOPEN_STATE_DOWN) && (giovatech->interface_state != SKYPOPEN_STATE_IDLE) && (strcmp(giovatech->name, tech_pvt->name)) && (!strcmp(giovatech->skype_user, tech_pvt->skype_user)) && (!strcmp(giovatech->ring_value, value)) && ((((timenow.tv_sec - giovatech->ring_time.tv_sec) * 1000000) + (timenow.tv_usec - giovatech->ring_time.tv_usec)) < 1000000)) { //XXX 1.0sec - can have a max of 1 call coming from the same skypename to the same skypename each 1.0 seconds - found = 1; - DEBUGA_SKYPE - ("FOUND (name=%s, giovatech->interface_state=%d != SKYPOPEN_STATE_DOWN) && (giovatech->skype_user=%s == tech_pvt->skype_user=%s) && (giovatech->callid_number=%s == value=%s)\n", - SKYPOPEN_P_LOG, giovatech->name, giovatech->interface_state, giovatech->skype_user, tech_pvt->skype_user, giovatech->callid_number, - value); - if (tech_pvt->interface_state == SKYPOPEN_STATE_PRERING) { - tech_pvt->interface_state = SKYPOPEN_STATE_DOWN; - } - break; - } - } - } - - for (i = 0; !found && i < SKYPOPEN_MAX_INTERFACES; i++) { - if (strlen(globals.SKYPOPEN_INTERFACES[i].name)) { - - giovatech = &globals.SKYPOPEN_INTERFACES[i]; - /* let's look for a IDLE one */ - if ((giovatech->interface_state == SKYPOPEN_STATE_IDLE) && (!strcmp(giovatech->skype_user, tech_pvt->skype_user))) { - found = 1; - DEBUGA_SKYPE - ("FOUND (name=%s, giovatech->interface_state=%d == SKYPOPEN_STATE_DOWN) && (giovatech->skype_user=%s == tech_pvt->skype_user=%s) && (giovatech->callid_number=%s == value=%s)\n", - SKYPOPEN_P_LOG, giovatech->name, giovatech->interface_state, giovatech->skype_user, tech_pvt->skype_user, giovatech->callid_number, - value); - if (tech_pvt->interface_state == SKYPOPEN_STATE_PRERING) { - tech_pvt->interface_state = SKYPOPEN_STATE_DOWN; - } - break; - } - } - } - - - if (found) { - switch_mutex_unlock(globals.mutex); - return 0; - } - DEBUGA_SKYPE("NOT FOUND\n", SKYPOPEN_P_LOG); - - if (!tech_pvt || !tech_pvt->skype_call_id[0]) { - /* we are not inside an active call */ - DEBUGA_SKYPE("We're NO MORE in a call now %s\n", SKYPOPEN_P_LOG, tech_pvt ? tech_pvt->skype_call_id : ""); - switch_mutex_unlock(globals.mutex); - - } else { - - /* we're in a call, let's try to transfer */ - /************************** TODO - Checking here if it is possible to transfer this call to Test2 - -> GET CALL 288 CAN_TRANSFER Test2 - <- CALL 288 CAN_TRANSFER test2 TRUE - **********************************/ - - private_t *available_skypopen_interface = NULL; - - gettimeofday(&timenow, NULL); - for (i = 0; !found && i < SKYPOPEN_MAX_INTERFACES; i++) { - if (strlen(globals.SKYPOPEN_INTERFACES[i].name)) { - - giovatech = &globals.SKYPOPEN_INTERFACES[i]; - if (strlen(giovatech->skype_transfer_call_id) && (giovatech->interface_state != SKYPOPEN_STATE_DOWN) && (giovatech->interface_state != SKYPOPEN_STATE_DEAD) && (!strcmp(giovatech->skype_user, tech_pvt->skype_user)) && (!strcmp(giovatech->transfer_callid_number, value)) && ((((timenow.tv_sec - giovatech->transfer_time.tv_sec) * 1000000) + (timenow.tv_usec - giovatech->transfer_time.tv_usec)) < 1000000)) { //1.0 sec - found = 1; - DEBUGA_SKYPE - ("FOUND (name=%s, giovatech->interface_state=%d != SKYPOPEN_STATE_DOWN) && (giovatech->skype_user=%s == tech_pvt->skype_user=%s) && (giovatech->transfer_callid_number=%s == value=%s)\n", - SKYPOPEN_P_LOG, giovatech->name, giovatech->interface_state, - giovatech->skype_user, tech_pvt->skype_user, giovatech->transfer_callid_number, value) - break; - } - } - } - - if (found) { - switch_mutex_unlock(globals.mutex); - return 0; - } - DEBUGA_SKYPE("NOT FOUND\n", SKYPOPEN_P_LOG); - - available_skypopen_interface = find_available_skypopen_interface_rr(tech_pvt); - if (available_skypopen_interface) { - /* there is a skypopen interface idle, let's transfer the call to it */ - - switch_copy_string(available_skypopen_interface->initial_skype_user, tech_pvt->skype_user, sizeof(tech_pvt->skype_user) - 1); - - gettimeofday(&tech_pvt->transfer_time, NULL); - switch_copy_string(tech_pvt->skype_transfer_call_id, id, sizeof(tech_pvt->skype_transfer_call_id) - 1); - - switch_copy_string(tech_pvt->transfer_callid_number, value, sizeof(tech_pvt->transfer_callid_number) - 1); - - DEBUGA_SKYPE - ("Let's transfer the skype_call %s to %s interface (with skype_user: %s), because we are already in a skypopen call(%s)\n", - SKYPOPEN_P_LOG, tech_pvt->skype_call_id, available_skypopen_interface->name, available_skypopen_interface->skype_user, id); - - - sprintf(msg_to_skype, "ALTER CALL %s TRANSFER %s", id, available_skypopen_interface->skype_user); - skypopen_signaling_write(tech_pvt, msg_to_skype); - } else { - /* no skypopen interfaces idle, do hangup */ - DEBUGA_SKYPE - ("Not answering the skype_call %s, because we are already in a skypopen call(%s) and not transferring, because no other skypopen interfaces are available\n", - SKYPOPEN_P_LOG, id, tech_pvt->skype_call_id); - sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - sprintf(msg_to_skype, "ALTER CALL %s HANGUP", id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - } - switch_sleep(20000); - DEBUGA_SKYPE - ("We have NOT answered a Skype RING from skype_call %s, because we are already in a skypopen call (%s)\n", - SKYPOPEN_P_LOG, id, tech_pvt->skype_call_id); - - switch_mutex_unlock(globals.mutex); - } - return 0; -} - -int incoming_chatmessage(private_t *tech_pvt, int which) -{ - switch_event_t *event; - switch_core_session_t *session = NULL; - int event_sent_to_esl = 0; - - DEBUGA_SKYPE("received CHATMESSAGE on interface %s\n", SKYPOPEN_P_LOG, tech_pvt->name); - - if (!tech_pvt->report_incoming_chatmessages) { - DEBUGA_SKYPE("I will not generate an Event, report_incoming_chatmessages is %d\n", SKYPOPEN_P_LOG, tech_pvt->report_incoming_chatmessages); - return 0; - } - - if (!zstr(tech_pvt->session_uuid_str)) { - session = switch_core_session_locate(tech_pvt->session_uuid_str); - } - if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", SKYPE_CHAT_PROTO); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", tech_pvt->name); - //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "hint", tech_pvt->chatmessages[which].from_dispname); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", tech_pvt->chatmessages[which].from_handle); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "subject", "SIMPLE MESSAGE"); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "chatname", tech_pvt->chatmessages[which].chatname); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "id", tech_pvt->chatmessages[which].id); -/* mod_sms begin */ - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to", tech_pvt->skype_user); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "hint", tech_pvt->name); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_proto", SKYPE_CHAT_PROTO); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_user", tech_pvt->chatmessages[which].from_handle); - //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_host", "from_host"); - //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_full", "from_full"); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_user", tech_pvt->name); - //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_host", "to_host"); -/* mod_sms end */ - - switch_event_add_body(event, "%s", tech_pvt->chatmessages[which].body); - - if (session) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "during-call", "true"); - if (switch_core_session_queue_event(session, &event) != SWITCH_STATUS_SUCCESS) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "delivery-failure", "true"); - switch_event_fire(&event); - } - } else { //no session - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "during-call", "false"); - switch_event_fire(&event); - event_sent_to_esl = 1; - } - - } else { - ERRORA("cannot create event on interface %s. WHY?????\n", SKYPOPEN_P_LOG, tech_pvt->name); - } - - if (!event_sent_to_esl) { - - if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", SKYPE_CHAT_PROTO); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", tech_pvt->name); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "hint", tech_pvt->chatmessages[which].from_dispname); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", tech_pvt->chatmessages[which].from_handle); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "subject", "SIMPLE MESSAGE"); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "chatname", tech_pvt->chatmessages[which].chatname); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "id", tech_pvt->chatmessages[which].id); - switch_event_add_body(event, "%s", tech_pvt->chatmessages[which].body); - if (session) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "during-call", "true"); - } else { //no session - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "during-call", "false"); - } - switch_event_fire(&event); - } else { - ERRORA("cannot create event on interface %s. WHY?????\n", SKYPOPEN_P_LOG, tech_pvt->name); - } - } - - if (session) { - switch_core_session_rwunlock(session); - } - - - if (switch_event_create(&event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) { - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", SKYPE_CHAT_PROTO); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", tech_pvt->name); - //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "hint", tech_pvt->chatmessages[which].from_dispname); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", tech_pvt->chatmessages[which].from_handle); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "subject", "SIMPLE MESSAGE"); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "chatname", tech_pvt->chatmessages[which].chatname); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "id", tech_pvt->chatmessages[which].id); -/* mod_sms begin */ - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to", tech_pvt->skype_user); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "hint", tech_pvt->name); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_proto", SKYPE_CHAT_PROTO); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_user", tech_pvt->chatmessages[which].from_handle); - //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_host", "from_host"); - //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from_full", "from_full"); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_user", tech_pvt->name); - //switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "to_host", "to_host"); - switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "context", tech_pvt->context); -/* mod_sms end */ - - switch_event_add_body(event, "%s", tech_pvt->chatmessages[which].body); - //switch_core_chat_send("GLOBAL", event); /* mod_sms */ - start_mod_sms_thread(tech_pvt, event); - //usleep(20000); - - } else { - ERRORA("cannot create event on interface %s. WHY?????\n", SKYPOPEN_P_LOG, tech_pvt->name); - } - - return 0; -} - -static switch_status_t compat_chat_send(const char *proto, const char *from, const char *to, - const char *subject, const char *body, const char *type, const char *hint) -{ - switch_event_t *message_event; - switch_status_t status; - - if (switch_event_create(&message_event, SWITCH_EVENT_MESSAGE) == SWITCH_STATUS_SUCCESS) { - switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "proto", proto); - switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "from", from); - switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "to", to); - switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "subject", subject); - switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "type", type); - switch_event_add_header_string(message_event, SWITCH_STACK_BOTTOM, "hint", hint); - - if (body) { - switch_event_add_body(message_event, "%s", body); - } - } else { - abort(); - } - - status = chat_send(message_event); - switch_event_destroy(&message_event); - - return status; - -} - -SWITCH_STANDARD_API(skypopen_chat_function) -{ - char *mycmd = NULL, *argv[10] = { 0 }; - int argc = 0; - private_t *tech_pvt = NULL; - int i; - int found = 0; - - if (!zstr(cmd) && (mycmd = strdup(cmd))) { - argc = switch_separate_string(mycmd, ' ', argv, (sizeof(argv) / sizeof(argv[0]))); - } - - if (!argc) { - stream->write_function(stream, "ERROR, usage: %s", SKYPOPEN_CHAT_SYNTAX); - goto end; - } - - if (argc < 3) { - stream->write_function(stream, "ERROR, usage: %s", SKYPOPEN_CHAT_SYNTAX); - goto end; - } - - if (argv[0]) { - for (i = 0; !found && i < SKYPOPEN_MAX_INTERFACES; i++) { - /* we've been asked for a normal interface name, or we have not found idle interfaces to serve as the "ANY" interface */ - if (strlen(globals.SKYPOPEN_INTERFACES[i].name) - && (strncmp(globals.SKYPOPEN_INTERFACES[i].name, argv[0], strlen(argv[0])) == 0)) { - tech_pvt = &globals.SKYPOPEN_INTERFACES[i]; - stream->write_function(stream, "Using interface: globals.SKYPOPEN_INTERFACES[%d].name=|||%s|||\n", i, globals.SKYPOPEN_INTERFACES[i].name); - found = 1; - break; - } - - } - if (!found) { - stream->write_function(stream, "ERROR: A Skypopen interface with name='%s' was not found\n", argv[0]); - goto end; - } else { - - NOTICA("chat_send(proto=%s, from=%s, to=%s, subject=%s, body=%s, type=NULL, hint=%s)\n", SKYPOPEN_P_LOG, SKYPE_CHAT_PROTO, - tech_pvt->skype_user, argv[1], "SIMPLE MESSAGE", switch_str_nil((char *) &cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1]), - tech_pvt->name); - - compat_chat_send(SKYPE_CHAT_PROTO, tech_pvt->skype_user, argv[1], "SIMPLE MESSAGE", - switch_str_nil((char *) &cmd[strlen(argv[0]) + 1 + strlen(argv[1]) + 1]), NULL, tech_pvt->name); - - } - } else { - stream->write_function(stream, "ERROR, usage: %s", SKYPOPEN_CHAT_SYNTAX); - goto end; - } - - end: - switch_safe_free(mycmd); - - return SWITCH_STATUS_SUCCESS; -} - -int next_port(void) -{ - switch_mutex_lock(globals.mutex); - globals.start_port++; - if (globals.start_port == 65000) - globals.start_port = 32769; - switch_mutex_unlock(globals.mutex); - return (globals.start_port - 1); -} - -#ifndef WIN32 -// CLOUDTREE (THomas Hazel) - is there a capable freeswitch list? -struct SkypopenHandles *skypopen_list_add(struct SkypopenList *list, struct SkypopenHandles *handle) -{ - switch_mutex_lock(globals.list_mutex); - - if (handle->managed == SWITCH_TRUE) { - // already added - switch_mutex_unlock(globals.list_mutex); - return 0; - } - - if (list->head == 0) { - list->head = handle; - handle->prev = 0; - - } else { - ((struct SkypopenHandles *) list->tail)->next = handle; - ((struct SkypopenHandles *) handle)->prev = list->tail; - } - - list->tail = handle; - handle->next = 0; - - handle->managed = SWITCH_TRUE; - - list->entries++; - - switch_mutex_unlock(globals.list_mutex); - - return handle; -} - -// CLOUDTREE (THomas Hazel) - is there a capable freeswitch list? -struct SkypopenHandles *skypopen_list_remove_by_value(struct SkypopenList *list, Display * display) -{ - struct SkypopenHandles *iter; - struct SkypopenHandles *handle = 0; - - switch_mutex_lock(globals.list_mutex); - - iter = (struct SkypopenHandles *) list->head; - while (iter != 0) { - if (iter->disp == display) { - handle = iter; - break; - } - - iter = (struct SkypopenHandles *) iter->next; - } - - if ((handle != 0) && (handle->managed == SWITCH_TRUE)) { - if (handle->prev == 0) { - list->head = ((struct SkypopenHandles *) handle)->next; - - } else { - ((struct SkypopenHandles *) handle->prev)->next = ((struct SkypopenHandles *) handle)->next; - } - - if (handle->next == 0) { - list->tail = ((struct SkypopenHandles *) handle)->prev; - - } else { - ((struct SkypopenHandles *) handle->next)->prev = ((struct SkypopenHandles *) handle)->prev; - } - - handle->managed = SWITCH_FALSE; - handle->next = 0; - handle->prev = 0; - - list->entries--; - } - - switch_mutex_unlock(globals.list_mutex); - - return handle; -} - -// CLOUDTREE (THomas Hazel) - is there a capable freeswitch list? -struct SkypopenHandles *skypopen_list_remove_by_reference(struct SkypopenList *list, struct SkypopenHandles *handle) -{ - private_t *tech_pvt = NULL; - - switch_mutex_lock(globals.list_mutex); - - DEBUGA_SKYPE("BEGIN REMOVE\n", SKYPOPEN_P_LOG); - if (handle->managed == SWITCH_FALSE) { - // already removed - switch_mutex_unlock(globals.list_mutex); - DEBUGA_SKYPE("EXIT REMOVE\n", SKYPOPEN_P_LOG); - return 0; - } - - if (handle->prev == 0) { - list->head = ((struct SkypopenHandles *) handle)->next; - - } else { - ((struct SkypopenHandles *) handle->prev)->next = ((struct SkypopenHandles *) handle)->next; - } - - if (handle->next == 0) { - list->tail = ((struct SkypopenHandles *) handle)->prev; - - } else { - ((struct SkypopenHandles *) handle->next)->prev = ((struct SkypopenHandles *) handle)->prev; - } - - handle->managed = SWITCH_FALSE; - handle->next = 0; - handle->prev = 0; - - list->entries--; - - switch_mutex_unlock(globals.list_mutex); - DEBUGA_SKYPE("EXIT REMOVE\n", SKYPOPEN_P_LOG); - - return handle; -} - -// CLOUDTREE (THomas Hazel) - is there a capable freeswitch list? -#ifdef XIO_ERROR_BY_UCONTEXT -struct SkypopenHandles *skypopen_list_find(struct SkypopenList *list, struct SkypopenHandles *find) -{ - struct SkypopenHandles *iter; - struct SkypopenHandles *handle = NULL; - - switch_mutex_lock(globals.list_mutex); - - iter = (struct SkypopenHandles *) list->head; - while (iter != NULL) { - if (iter == find) { - handle = iter; - break; - } - - iter = (struct SkypopenHandles *) iter->next; - } - - switch_mutex_unlock(globals.list_mutex); - - return handle; -} -#endif - -// CLOUDTREE (THomas Hazel) - is there a capable freeswitch list? -int skypopen_list_size(struct SkypopenList *list) -{ - return list->entries; -} -#endif /* NOT WIN32 */ - -/* For Emacs: - * Local Variables: - * mode:c - * indent-tabs-mode:t - * tab-width:4 - * c-basic-offset:4 - * End: - * For VIM: - * vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet: - */ diff --git a/src/mod/endpoints/mod_skypopen/old-stuff/asterisk/Makefile b/src/mod/endpoints/mod_skypopen/old-stuff/asterisk/Makefile deleted file mode 100644 index 86aab9175e..0000000000 --- a/src/mod/endpoints/mod_skypopen/old-stuff/asterisk/Makefile +++ /dev/null @@ -1,93 +0,0 @@ -# -# Asterisk -- A telephony toolkit for Linux. -# -# Makefile for channel drivers -# -# Copyright (C) 1999-2005, Mark Spencer -# -# Mark Spencer -# -# Edited By Belgarath <> Aug 28 2004 -# Added bare bones ultrasparc-linux support. -# -# This program is free software, distributed under the terms of -# the GNU General Public License -# - -#ASTERISK INCLUDE FILES -#The directory that contains the Asterisk include files (eg: /usr/include or /usr/include/asterisk or /usr/src/asterisk/include or ...) -#AST_INCLUDE_DIR=/usr/src/asterisk/include -#AST_INCLUDE_DIR=/home/maruzz/devel/svn_asterisk_trunk/include -#AST_INCLUDE_DIR=/home/maruzz/devel/svn_asterisk_branches_160/include -#AST_INCLUDE_DIR=/home/maruzz/devel/svn_asterisk_branches_12/include -#AST_INCLUDE_DIR=/home/maruzz/devel/svn_asterisk_branches_14/include -#AST_INCLUDE_DIR=/home/maruzz/devel/svn_celliax_trunk/asterisk-1.2.rev137401/include -AST_INCLUDE_DIR=/home/user/devel/asterisk-1.4.23.1/include - -#ASTERISK -CFLAGS+=-DASTERISK - -#ASTERISK VERSION -#Uncomment one of the following lines to match your Asterisk series -CFLAGS+=-DASTERISK_VERSION_1_4 -#CFLAGS+=-DASTERISK_VERSION_1_6 -#CFLAGS+=-DASTERISK_VERSION_1_2 - -#LINUX SKYPE SUPPORT (Celliax for Cygwin always supports Skype) -SKYPE_LIB=-L/usr/X11R6/lib -lX11 - -CFLAGS+=-pipe -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -CFLAGS+=-g3 - - - -CFLAGS+=-I$(AST_INCLUDE_DIR) -I. -CFLAGS+=-D_REENTRANT -D_GNU_SOURCE -#CFLAGS+=-O6 -CFLAGS+=-march=i686 -CFLAGS+=-fomit-frame-pointer -ifeq ($(shell uname -m),x86_64) -CFLAGS+=-fPIC -endif - -SVNDEF := -D'SKYPIAX_SVN_VERSION="$(shell svnversion -n ..)"' -CFLAGS += $(SVNDEF) - - -SOLINK=-shared -Xlinker -x -CHANNEL_LIBS=chan_skypiax.so -CC=gcc - -OSARCH=$(shell uname -s) - -ifeq ($(findstring CYGWIN,$(OSARCH)),CYGWIN) -# definition of pthread_kill as a printf (or as a noop) is required for Asterisk (and skypiax) to run on Cygwin -# without it, each time (often) pthread_kill is called (by any thread, with any signal, URG included), bad things happen -CC=gcc -D pthread_kill=cyg_no_pthreadkill -AST_DLL_DIR=/home/maruzz/devel/svn_asterisk_branches_12 -CYGSOLINK=-Wl,--out-implib=lib$@.a -Wl,--export-all-symbols cyg_no_pthread_kill.o -CYGSOLIB=-L/usr/lib/w32api -lrpcrt4 -L/lib/mingw -lwinmm -L$(AST_DLL_DIR) -lasterisk.dll -L$(AST_DLL_DIR)/res -lres_features.so -SKYPE_LIB= -CHANNEL_LIBS=cyg_no_pthread_kill.o chan_skypiax.so -endif - -all: $(CHANNEL_LIBS) - -clean: - rm -f *.so *.o *.so.a - - -#chan_skypiax section begins - -#to debug threads and lock on 1.4 uncomment the following -#CFLAGS+=-include /usr/src/asterisk/include/asterisk/autoconfig.h - - -cyg_no_pthread_kill.o: cyg_no_pthread_kill.c - $(CC) $(CFLAGS) -c -o cyg_no_pthread_kill.o cyg_no_pthread_kill.c -chan_skypiax.o: chan_skypiax.c - $(CC) $(CFLAGS) -c -o chan_skypiax.o chan_skypiax.c -chan_skypiax.so: chan_skypiax.o skypiax_protocol.o - $(CC) $(SOLINK) -o $@ ${CYGSOLINK} chan_skypiax.o skypiax_protocol.o -lm -ldl $(SKYPE_LIB) ${CYGSOLIB} -#chan_skypiax section ends - diff --git a/src/mod/endpoints/mod_skypopen/old-stuff/asterisk/README b/src/mod/endpoints/mod_skypopen/old-stuff/asterisk/README deleted file mode 100644 index a3d352e0c6..0000000000 --- a/src/mod/endpoints/mod_skypopen/old-stuff/asterisk/README +++ /dev/null @@ -1 +0,0 @@ -Skypopen for asterisk does not work yet. diff --git a/src/mod/endpoints/mod_skypopen/old-stuff/asterisk/chan_skypiax.c b/src/mod/endpoints/mod_skypopen/old-stuff/asterisk/chan_skypiax.c deleted file mode 100644 index 52101f171b..0000000000 --- a/src/mod/endpoints/mod_skypopen/old-stuff/asterisk/chan_skypiax.c +++ /dev/null @@ -1,2315 +0,0 @@ -//indent -gnu -ts4 -br -brs -cdw -lp -ce -nbfda -npcs -nprs -npsl -nbbo -saf -sai -saw -cs -bbo -nhnl -nut -sob -l90 -#include "skypiax.h" - -/* LOCKS */ -/*! \brief Protect the skypiax_usecnt */ -AST_MUTEX_DEFINE_STATIC(skypiax_usecnt_lock); -/*! \brief Protect the monitoring thread, so only one process can kill or start it, and not - * when it's doing something critical. */ -AST_MUTEX_DEFINE_STATIC(skypiax_monlock); -/*! \brief Protect the interfaces list */ -AST_MUTEX_DEFINE_STATIC(skypiax_iflock); - -/* GLOBAL VARIABLES */ -int running = 1; -int skypiax_dir_entry_extension = 1; //FIXME one var for each interface! -char skypiax_console_active_array[50] = ""; -char *skypiax_console_active = skypiax_console_active_array; -/*! \brief Count of active channels for this module */ -int skypiax_usecnt = 0; -int skypiax_debug = 0; -/*! \brief This is the thread for the monitor which checks for input on the channels - * which are not currently in use. */ -pthread_t skypiax_monitor_thread = AST_PTHREADT_NULL; -pthread_t skypiax_monitor_audio_thread = AST_PTHREADT_NULL; - -/* CONSTANTS */ -/*! \brief Textual description for this module */ -const char skypiax_desc[] = "Skypiax, Skype Driver"; -/*! \brief Textual type for this module */ -const char skypiax_type[] = "Skypiax"; -/*! \brief Name of configuration file for this module */ -const char skypiax_config[] = "skypiax.conf"; - -char skypiax_console_skypiax_usage[] = - " \n" "chan_skypiax commands info\n" " \n" - " chan_skypiax adds to Asterisk the following CLI commands:\n" " \n" - " CLI COMMANDS:\n" " skypiax_hangup\n" " skypiax_dial\n" - " skypiax_console\n" " skypiax_playback_boost\n" - " skypiax_capture_boost\n" " skypiax_skype\n" - " skypiax_dir_import\n" "\n" " You can type 'help [command]' to obtain more specific info on usage.\n" " \n"; -char skypiax_console_hangup_usage[] = - "Usage: skypiax_hangup\n" - " Hangs up any call currently placed on the \"current\" skypiax_console (Skypiax) channel.\n" - " Enter 'help skypiax_console' on how to change the \"current\" skypiax_console\n"; -char skypiax_console_playback_boost_usage[] = - "Usage: skypiax_playback_boost [value]\n" - " Shows or set the value of boost applied to the outgoing sound (voice). Possible values are: 0 (no boost applied), -40 to 40 (negative to positive range, in db). Without specifying a value, it just shows the current value. The value is for the \"current\" skypiax_console (Skypiax) channel.\n" - " Enter 'help skypiax_console' on how to change the \"current\" skypiax_console\n"; -char skypiax_console_capture_boost_usage[] = - "Usage: skypiax_capture_boost [value]\n" - " Shows or set the value of boost applied to the incoming sound (voice). Possible values are: 0 (no boost applied), -40 to 40 (negative to positive range, in db). Without specifying a value, it just shows the current value. The value is for the \"current\" skypiax_console (Skypiax) channel.\n" - " Enter 'help skypiax_console' on how to change the \"current\" skypiax_console\n"; - -char skypiax_console_dial_usage[] = - "Usage: skypiax_dial [DTMFs]\n" - " Dials a given DTMF string in the call currently placed on the\n" - " \"current\" skypiax_console (Skypiax) channel.\n" " Enter 'help skypiax_console' on how to change the \"current\" skypiax_console\n"; - -char skypiax_console_skypiax_console_usage[] = - "Usage: skypiax_console [interface] | [show]\n" - " If used without a parameter, displays which interface is the \"current\"\n" - " skypiax_console. If a device is specified, the \"current\" skypiax_console is changed to\n" - " the interface specified.\n" " If the parameter is \"show\", the available interfaces are listed\n"; - -char skypiax_console_skype_usage[] = - "Usage: skypiax_skype [command string]\n" - " Send the 'command string' skype_msg to the Skype client connected to the \"current\" skypiax_console (Skypiax) channel.\n" - " Enter 'help skypiax_console' on how to change the \"current\" skypiax_console\n"; - -char skypiax_console_skypiax_dir_import_usage[] = - "Usage: skypiax_dir_import [add | replace]\n" - " Write in the directoriax.conf config file all the entries found in 'Contacts' list of the Skype client connected to the \"current\" skypiax_console.\n" - " You can choose between 'add' to the end of the directoriax.conf file, or 'replace' the whole file with this new content.\n" - " Enter 'help skypiax_console' on how to change the \"current\" skypiax_console\n"; - -/*! \brief Definition of this channel for PBX channel registration */ -const struct ast_channel_tech skypiax_tech = { - .type = skypiax_type, - .description = skypiax_desc, - .capabilities = AST_FORMAT_SLINEAR, - .requester = skypiax_request, - .hangup = skypiax_hangup, - .answer = skypiax_answer, - .read = skypiax_read, - .call = skypiax_originate_call, - .write = skypiax_write, - .indicate = skypiax_indicate, - .fixup = skypiax_fixup, - .devicestate = skypiax_devicestate, -#ifdef ASTERISK_VERSION_1_4 - .send_digit_begin = skypiax_digitsend_begin, - .send_digit_end = skypiax_digitsend_end, -#else /* ASTERISK_VERSION_1_4 */ - .send_digit = skypiax_digitsend, -#endif /* ASTERISK_VERSION_1_4 */ -}; - -/*! \brief fake skypiax_pvt structure values, - * just for logging purposes */ -struct skypiax_pvt skypiax_log_struct = { - .name = "none", -}; - -/*! \brief Default skypiax_pvt structure values, - * used by skypiax_mkif to initialize the interfaces */ -struct skypiax_pvt skypiax_default = { - .interface_state = SKYPIAX_STATE_DOWN, - .skype_callflow = 0, - .context = "default", - .language = "en", - .exten = "s", - .next = NULL, - .owner = NULL, - .controldev_thread = AST_PTHREADT_NULL, - .skypiax_sound_rate = 8000, - .skypiax_sound_capt_fd = -1, - .capture_boost = 0, - .playback_boost = 0, - .stripmsd = 0, - .skype = 0, - .skypiax_dir_entry_extension_prefix = 6, -}; - -/*! - * \brief PVT structure for a skypiax interface (channel), created by skypiax_mkif - */ -struct skypiax_pvt *skypiax_iflist = NULL; - -#ifdef ASTERISK_VERSION_1_6 -struct ast_cli_entry myclis[] = { -/* - * CLI do not works since some time on 1.6, they changed the CLI mechanism - */ -#if 0 - AST_CLI_DEFINE(skypiax_console_hangup, "Hangup a call on the console"), - AST_CLI_DEFINE(skypiax_console_dial, "Dial an extension on the console"), - AST_CLI_DEFINE(skypiax_console_playback_boost, "Sets/displays spk boost in dB"), - AST_CLI_DEFINE(skypiax_console_capture_boost, "Sets/displays mic boost in dB"), - AST_CLI_DEFINE(skypiax_console_set_active, "Sets/displays active console"), - AST_CLI_DEFINE(skypiax_console_skype, "Sends a Skype command"), - AST_CLI_DEFINE(skypiax_console_skypiax_dir_import, "imports entries from cellphone"), - AST_CLI_DEFINE(skypiax_console_skypiax, "all things skypiax"), -#endif -}; -#else -struct ast_cli_entry myclis[] = { - {{"skypiax_hangup", NULL}, skypiax_console_hangup, - "Hangup a call on the skypiax_console", - skypiax_console_hangup_usage}, - {{"skypiax_playback_boost", NULL}, skypiax_console_playback_boost, "playback boost", - skypiax_console_playback_boost_usage}, - {{"skypiax_capture_boost", NULL}, skypiax_console_capture_boost, "capture boost", - skypiax_console_capture_boost_usage}, - {{"skypiax_usage", NULL}, skypiax_console_skypiax, "chan_skypiax commands info", - skypiax_console_skypiax_usage}, - {{"skypiax_skype", NULL}, skypiax_console_skype, "Skype msg", - skypiax_console_skype_usage}, - {{"skypiax_dial", NULL}, skypiax_console_dial, - "Dial an extension on the skypiax_console", - skypiax_console_dial_usage}, - {{"skypiax_console", NULL}, skypiax_console_set_active, - "Sets/displays active skypiax_console", - skypiax_console_skypiax_console_usage}, - {{"skypiax_dir_import", NULL}, skypiax_console_skypiax_dir_import, - "Write the directoriax.conf file, used by directoriax app", - skypiax_console_skypiax_dir_import_usage}, -}; -#endif - -/* IMPLEMENTATION */ - -void skypiax_unlocka_log(void *x) -{ - ast_mutex_t *y; - y = x; - int i; - - for (i = 0; i < 5; i++) { //let's be generous - - ast_log(LOG_DEBUG, - SKYPIAX_SVN_VERSION - "[%-7lx] I'm a dying thread, and I'm to go unlocking mutex %p for the %dth time\n", (unsigned long int) pthread_self(), y, i); - - ast_mutex_unlock(y); - } - ast_log(LOG_DEBUG, SKYPIAX_SVN_VERSION "[%-7lx] I'm a dying thread, I've finished unlocking mutex %p\n", (unsigned long int) pthread_self(), y); -} - -int skypiax_queue_control(struct ast_channel *c, int control) -{ - struct skypiax_pvt *p = c->tech_pvt; - -/* queue the frame */ - if (p) - p->control_to_send = control; - else { - return 0; - } - DEBUGA_PBX("Queued CONTROL FRAME %d\n", SKYPIAX_P_LOG, control); - -/* wait for the frame to be sent */ - while (p->control_to_send) - usleep(1); - - return 0; -} - -int skypiax_devicestate(void *data) -{ - struct skypiax_pvt *p = NULL; - char *name = data; - int res = AST_DEVICE_INVALID; - - if (!data) { - ERRORA("Devicestate requested with no data\n", SKYPIAX_P_LOG); - return res; - } - - /* lock the interfaces' list */ - LOKKA(&skypiax_iflock); - /* make a pointer to the first interface in the interfaces list */ - p = skypiax_iflist; - /* Search for the requested interface and verify if is unowned */ - while (p) { - size_t length = strlen(p->name); - /* is this the requested interface? */ - if (strncmp(name, p->name, length) == 0) { - /* is this interface unowned? */ - if (!p->owner) { - res = AST_DEVICE_NOT_INUSE; - DEBUGA_PBX("Interface is NOT OWNED by a channel\n", SKYPIAX_P_LOG); - } else { - /* interface owned by a channel */ - res = AST_DEVICE_INUSE; - DEBUGA_PBX("Interface is OWNED by a channel\n", SKYPIAX_P_LOG); - } - - /* we found the requested interface, bail out from the while loop */ - break; - } - /* not yet found, next please */ - p = p->next; - } - /* unlock the interfaces' list */ - UNLOCKA(&skypiax_iflock); - - if (res == AST_DEVICE_INVALID) { - ERRORA("Checking device state for interface [%s] returning AST_DEVICE_INVALID\n", SKYPIAX_P_LOG, name); - } - return res; -} - -#ifndef ASTERISK_VERSION_1_4 -int skypiax_indicate(struct ast_channel *c, int cond) -#else -int skypiax_indicate(struct ast_channel *c, int cond, const void *data, size_t datalen) -#endif -{ - struct skypiax_pvt *p = c->tech_pvt; - int res = 0; - - NOTICA("Let's INDICATE %d\n", SKYPIAX_P_LOG, cond); - - switch (cond) { - case AST_CONTROL_BUSY: - case AST_CONTROL_CONGESTION: - case AST_CONTROL_RINGING: - case -1: - res = -1; /* Ask for inband indications */ - break; - case AST_CONTROL_PROGRESS: - case AST_CONTROL_PROCEEDING: - case AST_CONTROL_VIDUPDATE: - case AST_CONTROL_HOLD: - case AST_CONTROL_UNHOLD: -#ifdef ASTERISK_VERSION_1_4 - case AST_CONTROL_SRCUPDATE: -#endif /* ASTERISK_VERSION_1_4 */ - break; - default: - WARNINGA("Don't know how to display condition %d on %s\n", SKYPIAX_P_LOG, cond, c->name); - /* The core will play inband indications for us if appropriate */ - res = -1; - } - - return res; -} - -/*! \brief PBX interface function -build skypiax pvt structure - * skypiax calls initiated by the PBX arrive here */ -struct ast_channel *skypiax_request(const char *type, int format, void *data, int *cause) -{ - struct skypiax_pvt *p = NULL; - struct ast_channel *tmp = NULL; - char *name = data; - int found = 0; - - DEBUGA_PBX("Try to request type: %s, name: %s, cause: %d," " format: %d\n", SKYPIAX_P_LOG, type, name, *cause, format); - - if (!data) { - ERRORA("Channel requested with no data\n", SKYPIAX_P_LOG); - return NULL; - } - - char interface[256]; - int i; - memset(interface, '\0', sizeof(interface)); - - for (i = 0; i < sizeof(interface); i++) { - if (name[i] == '/') - break; - interface[i] = name[i]; - } - /* lock the interfaces' list */ - LOKKA(&skypiax_iflock); - /* make a pointer to the first interface in the interfaces list */ - p = skypiax_iflist; - - if (strcmp("ANY", interface) == 0) { - /* we've been asked for the "ANY" interface, let's find the first idle interface */ - DEBUGA_SKYPE("Finding one available skype interface\n", SKYPIAX_P_LOG); - p = find_available_skypiax_interface(); - if (p) { - found = 1; - - /* create a new channel owning this interface */ - tmp = skypiax_new(p, SKYPIAX_STATE_DOWN, p->context); - if (!tmp) { - /* the channel was not created, probable memory allocation error */ - *cause = AST_CAUSE_SWITCH_CONGESTION; - } - - } - - } - - /* Search for the requested interface and verify if is unowned and format compatible */ - while (p && !found) { - //size_t length = strlen(p->name); - /* is this the requested interface? */ - if (strcmp(interface, p->name) == 0) { - /* is the requested format supported by this interface? */ - if ((format & AST_FORMAT_SLINEAR) != 0) { - /* is this interface unowned? */ - if (!p->owner) { - DEBUGA_PBX("Requesting: %s, name: %s, format: %d\n", SKYPIAX_P_LOG, type, name, format); - /* create a new channel owning this interface */ - tmp = skypiax_new(p, SKYPIAX_STATE_DOWN, p->context); - if (!tmp) { - /* the channel was not created, probable memory allocation error */ - *cause = AST_CAUSE_SWITCH_CONGESTION; - } - } else { - /* interface owned by another channel */ - WARNINGA("owned by another channel\n", SKYPIAX_P_LOG); - *cause = AST_CAUSE_REQUESTED_CHAN_UNAVAIL; - } - } else { - /* requested format not supported */ - WARNINGA("format %d not supported\n", SKYPIAX_P_LOG, format); - *cause = AST_CAUSE_BEARERCAPABILITY_NOTAVAIL; - } - /* we found the requested interface, bail out from the while loop */ - break; - } - /* not yet found, next please */ - p = p->next; - } - /* unlock the interfaces' list */ - UNLOCKA(&skypiax_iflock); - /* restart the monitor so it will watch only the remaining unowned interfaces */ - skypiax_restart_monitor(); - if (tmp == NULL) { - /* new channel was not created */ - WARNINGA("Unable to create new Skypiax channel %s\n", SKYPIAX_P_LOG, name); - } - /* return the newly created channel */ - return tmp; -} - -/*! \brief Hangup skypiax call - * Part of PBX interface, called from ast_hangup */ - -int skypiax_hangup(struct ast_channel *c) -{ - struct skypiax_pvt *p; - - /* get our skypiax pvt interface from channel */ - p = c->tech_pvt; - /* if there is not skypiax pvt why we are here ? */ - if (!p) { - ERRORA("Asked to hangup channel not connected\n", SKYPIAX_P_LOG); - return 0; - } - - if (p->skype && p->interface_state != SKYPIAX_STATE_DOWN) { - char msg_to_skype[1024]; - p->interface_state = SKYPIAX_STATE_HANGUP_REQUESTED; - DEBUGA_SKYPE("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_signaling_write(p, msg_to_skype); - } - - while (p->interface_state != SKYPIAX_STATE_DOWN) { - usleep(10000); - } - DEBUGA_SKYPE("Now is really DOWN\n", SKYPIAX_P_LOG); - /* shutdown the serial monitoring thread */ - if (p->controldev_thread && (p->controldev_thread != AST_PTHREADT_NULL) - && (p->controldev_thread != AST_PTHREADT_STOP)) { - if (pthread_cancel(p->controldev_thread)) { - ERRORA("controldev_thread pthread_cancel failed, maybe he killed himself?\n", SKYPIAX_P_LOG); - } - /* push it, maybe is stuck in a select or so */ - if (pthread_kill(p->controldev_thread, SIGURG)) { - DEBUGA_SERIAL("controldev_thread pthread_kill failed, no problem\n", SKYPIAX_P_LOG); - } -#ifndef __CYGWIN__ /* under cygwin, this seems to be not reliable, get stuck at times */ - /* wait for it to die */ - if (pthread_join(p->controldev_thread, NULL)) { - ERRORA("controldev_thread pthread_join failed, BAD\n", SKYPIAX_P_LOG); - } -#else /* __CYGWIN__ */ -/* allow the serial thread to die */ - usleep(300000); //300msecs -#endif /* __CYGWIN__ */ - } - p->controldev_thread = AST_PTHREADT_NULL; - - p->interface_state = SKYPIAX_STATE_DOWN; - p->skype_callflow = CALLFLOW_CALL_IDLE; - - DEBUGA_PBX("I'll send AST_CONTROL_HANGUP\n", SKYPIAX_P_LOG); - ast_queue_control(p->owner, AST_CONTROL_HANGUP); - DEBUGA_PBX("I've sent AST_CONTROL_HANGUP\n", SKYPIAX_P_LOG); - - /* subtract one to the usage count of Skypiax-type channels */ - LOKKA(&skypiax_usecnt_lock); - skypiax_usecnt--; - if (skypiax_usecnt < 0) - ERRORA("Usecnt < 0???\n", SKYPIAX_P_LOG); - UNLOCKA(&skypiax_usecnt_lock); - ast_update_use_count(); - - /* our skypiax pvt interface is no more part of a channel */ - p->owner = NULL; - /* our channel has no more this skypiax pvt interface to manage */ - c->tech_pvt = NULL; - /* set the channel state to DOWN, eg. available, not in active use */ - if (ast_setstate(c, SKYPIAX_STATE_DOWN)) { - ERRORA("ast_setstate failed, BAD\n", SKYPIAX_P_LOG); - return -1; - } - - /* restart the monitor thread, so it can recheck which interfaces it have to watch during its loop (the interfaces that are not owned by channels) */ - if (skypiax_restart_monitor()) { - ERRORA("skypiax_restart_monitor failed, BAD\n", SKYPIAX_P_LOG); - return -1; - } - - return 0; -} - -/*! \brief Answer incoming call, - * Part of PBX interface */ -int skypiax_answer(struct ast_channel *c) -{ - struct skypiax_pvt *p = c->tech_pvt; - int res; - - /* whle ringing, we just wait, the skype thread will answer */ - while (p->interface_state == SKYPIAX_STATE_RING) { - usleep(10000); //10msec - } - if (p->interface_state != SKYPIAX_STATE_UP) { - ERRORA("call answering failed, we want it to be into interface_state=%d, got %d\n", SKYPIAX_P_LOG, SKYPIAX_STATE_UP, p->interface_state); - res = -1; - } else { - DEBUGA_PBX("call answered\n", SKYPIAX_P_LOG); - res = 0; - } - return res; -} - -#ifdef ASTERISK_VERSION_1_4 -int skypiax_digitsend_begin(struct ast_channel *c, char digit) -{ - struct skypiax_pvt *p = c->tech_pvt; - - DEBUGA_PBX("DIGIT BEGIN received: %c\n", SKYPIAX_P_LOG, digit); - - return 0; -} - -int skypiax_digitsend_end(struct ast_channel *c, char digit, unsigned int duration) -{ - struct skypiax_pvt *p = c->tech_pvt; - char msg_to_skype[1024]; - - NOTICA("DIGIT END received: %c %d\n", SKYPIAX_P_LOG, digit, duration); - - sprintf(msg_to_skype, "SET CALL %s DTMF %c", p->skype_call_id, digit); - - skypiax_signaling_write(p, msg_to_skype); - - return 0; -} -#else /* ASTERISK_VERSION_1_4 */ -int skypiax_digitsend(struct ast_channel *c, char digit) -{ - struct skypiax_pvt *p = c->tech_pvt; - char msg_to_skype[1024]; - - NOTICA("DIGIT received: %c\n", SKYPIAX_P_LOG, digit); - - sprintf(msg_to_skype, "SET CALL %s DTMF %c", p->skype_call_id, digit); - - skypiax_signaling_write(p, msg_to_skype); - - return 0; -} - -#endif /* ASTERISK_VERSION_1_4 */ -//struct ast_frame *skypiax_audio_read(struct skypiax_pvt *p) -//#define SAMPLES_PER_FRAME 160 -/*! \brief Read audio frames from channel */ -struct ast_frame *skypiax_read(struct ast_channel *c) -{ - struct skypiax_pvt *p = c->tech_pvt; - static struct ast_frame f; - static short __buf[SKYPIAX_FRAME_SIZE + AST_FRIENDLY_OFFSET / 2]; - short *buf; - int samples; - -/* if there are control frames queued to be sent by skypiax_queue_control, send it the first */ -//TODO maybe better a real queue? - if (p && p->owner && p->control_to_send) { - ast_queue_control(p->owner, p->control_to_send); - DEBUGA_PBX("Sent CONTROL FRAME %d\n", SKYPIAX_P_LOG, p->control_to_send); - p->control_to_send = 0; - } - - memset(__buf, '\0', (SKYPIAX_FRAME_SIZE + AST_FRIENDLY_OFFSET / 2)); - - buf = __buf + AST_FRIENDLY_OFFSET / 2; - - f.frametype = AST_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 the call is not active (ie: answered), do not send audio frames, they would pile up in a lag queue */ - if (p->owner && p->owner->_state != SKYPIAX_STATE_UP) { - return &f; - } - - 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); - //do nothing - } else { - //DEBUGA_SOUND("read=====> GOOD samples=%d\n", SKYPIAX_P_LOG, samples); - /* A real frame */ - f.frametype = AST_FRAME_VOICE; - f.subclass = AST_FORMAT_SLINEAR; - f.samples = SKYPIAX_FRAME_SIZE; - f.datalen = SKYPIAX_FRAME_SIZE * 2; - f.data = buf; - f.offset = AST_FRIENDLY_OFFSET; - f.src = skypiax_type; - f.mallocd = 0; - - if (p->capture_boost) - skypiax_sound_boost(&f, p->capture_boost); - } - - return &f; -} - -/*! \brief Initiate skypiax call from PBX - * used from the dial() application - */ -int skypiax_originate_call(struct ast_channel *c, char *idest, int timeout) -{ - struct skypiax_pvt *p = NULL; - p = c->tech_pvt; - char rdest[80], *where, dstr[100] = ""; - char *stringp = NULL; - int status; - - if ((c->_state != SKYPIAX_STATE_DOWN) - && (c->_state != SKYPIAX_STATE_RESERVED)) { - ERRORA("skypiax_originate_call called on %s, neither down nor reserved\n", SKYPIAX_P_LOG, c->name); - return -1; - } - - DEBUGA_PBX("skypiax_originate_call to call idest: %s, timeout: %d!\n", SKYPIAX_P_LOG, idest, timeout); - - strncpy(rdest, idest, sizeof(rdest) - 1); - stringp = rdest; - strsep(&stringp, "/"); - where = strsep(&stringp, "/"); - if (!where) { - ERRORA("Destination %s requires an actual destination (Skypiax/device/destination)\n", SKYPIAX_P_LOG, idest); - return -1; - } - - strncpy(dstr, where + p->stripmsd, sizeof(dstr) - 1); - DEBUGA_PBX("skypiax_originate_call dialing idest: %s, timeout: %d, dstr: %s!\n", SKYPIAX_P_LOG, idest, timeout, dstr); - - strcpy(p->session_uuid_str, "dialing"); - status = skypiax_call(p, dstr, timeout); - if (status) { - WARNINGA("skypiax_originate_call dialing failed: %d!\n", SKYPIAX_P_LOG, status); - return -1; - } - - DEBUGA_PBX("skypiax_originate_call dialed idest: %s, timeout: %d, dstr: %s!\n", SKYPIAX_P_LOG, idest, timeout, dstr); - - ast_setstate(p->owner, SKYPIAX_STATE_DIALING); - return 0; -} - -int skypiax_sound_boost(struct ast_frame *f, double boost) -{ -/* LUIGI RIZZO's magic */ - if (boost != 0) { /* scale and clip values */ - int i, x; - int16_t *ptr = (int16_t *) f->data; - for (i = 0; i < f->samples; i++) { - x = (ptr[i] * boost) / BOOST_SCALE; - if (x > 32767) { - x = 32767; - } else if (x < -32768) { - x = -32768; - } - ptr[i] = x; - } - } - return 0; -} - -/*! \brief Send audio frame to channel */ -int skypiax_write(struct ast_channel *c, struct ast_frame *f) -{ - struct skypiax_pvt *p = c->tech_pvt; - int sent; - - if (p->owner && p->owner->_state != SKYPIAX_STATE_UP) { - return 0; - } - if (p->playback_boost) - skypiax_sound_boost(f, p->playback_boost); - - sent = write(p->audioskypepipe[1], (short *) f->data, f->datalen); - //skypiax_sound_write(p, f); - - return 0; -} - -/*! \brief Fix up a channel: If a channel is consumed, this is called. - * Basically update any ->owner links */ -int skypiax_fixup(struct ast_channel *oldchan, struct ast_channel *newchan) -{ - struct skypiax_pvt *p = newchan->tech_pvt; - - if (!p) { - ERRORA("No pvt after masquerade. Strange things may happen\n", SKYPIAX_P_LOG); - return -1; - } - - if (p->owner != oldchan) { - ERRORA("old channel wasn't %p but was %p\n", SKYPIAX_P_LOG, oldchan, p->owner); - return -1; - } - - p->owner = newchan; - return 0; -} - -struct ast_channel *skypiax_new(struct skypiax_pvt *p, int state, char *context) -{ - struct ast_channel *tmp; - - /* alloc a generic channel struct */ -#ifndef ASTERISK_VERSION_1_4 - tmp = ast_channel_alloc(1); -#else - //tmp = ast_channel_alloc(1, state, 0, 0, "", p->exten, p->context, 0, ""); - //tmp = ast_channel_alloc(1, state, i->cid_num, i->cid_name, i->accountcode, i->exten, i->context, i->amaflags, "Skypiax/%s", p->name); - tmp = ast_channel_alloc(1, state, 0, 0, "", p->exten, p->context, 0, "Skypiax/%s", p->name); - -#endif /* ASTERISK_VERSION_1_4 */ - if (tmp) { - - /* give a name to the newly created channel */ -#ifndef ASTERISK_VERSION_1_4 - snprintf(tmp->name, sizeof(tmp->name), "Skypiax/%s", p->name); - tmp->type = skypiax_type; -#else /* ASTERISK_VERSION_1_4 */ - ast_string_field_build(tmp, name, "Skypiax/%s", p->name); -#endif /* ASTERISK_VERSION_1_4 */ - - DEBUGA_PBX("new channel: name=%s requested_state=%d\n", SKYPIAX_P_LOG, tmp->name, state); - - /* fd for the channel to poll for incoming audio */ - tmp->fds[0] = p->skypiax_sound_capt_fd; - - /* audio formats managed */ - tmp->nativeformats = AST_FORMAT_SLINEAR; - tmp->readformat = AST_FORMAT_SLINEAR; - tmp->writeformat = AST_FORMAT_SLINEAR; - /* the technology description (eg. the interface type) of the newly created channel is the Skypiax's one */ - tmp->tech = &skypiax_tech; - /* the technology pvt (eg. the interface) of the newly created channel is this interface pvt */ - tmp->tech_pvt = p; - - /* copy this interface default context, extension, language to the newly created channel */ - if (strlen(p->context)) - strncpy(tmp->context, p->context, sizeof(tmp->context) - 1); - if (strlen(p->exten)) - strncpy(tmp->exten, p->exten, sizeof(tmp->exten) - 1); -#ifndef ASTERISK_VERSION_1_4 - if (strlen(p->language)) - strncpy(tmp->language, p->language, sizeof(tmp->language) - 1); -#else - if (strlen(p->language)) - ast_string_field_set(tmp, language, p->language); -#endif /* ASTERISK_VERSION_1_4 */ - /* copy the requested context (not necessarily the interface default) to the newly created channel */ - if (strlen(context)) - strncpy(tmp->context, context, sizeof(tmp->context) - 1); - - /* copy this interface default callerid in the newly created channel */ - ast_set_callerid(tmp, !ast_strlen_zero(p->callid_number) ? p->callid_number : NULL, - !ast_strlen_zero(p->callid_name) ? p->callid_name : NULL, !ast_strlen_zero(p->callid_number) ? p->callid_number : NULL); - - DEBUGA_PBX("callid_number=%s, callid_name=%s\n", SKYPIAX_P_LOG, p->callid_number, p->callid_name); - - /* the owner of this interface pvt is the newly created channel */ - p->owner = tmp; - /* set the newly created channel state to the requested state */ - if (ast_setstate(tmp, state)) { - ERRORA("ast_setstate failed, BAD\n", SKYPIAX_P_LOG); - //ast_dsp_free(p->dsp); - ast_channel_free(tmp); - return NULL; - } - /* if the requested state is different from DOWN, let the pbx manage this interface (now part of the newly created channel) */ - if (state != SKYPIAX_STATE_DOWN) { - DEBUGA_PBX("Try to start PBX on %s, state=%d\n", SKYPIAX_P_LOG, tmp->name, state); - if (ast_pbx_start(tmp)) { - ERRORA("Unable to start PBX on %s\n", SKYPIAX_P_LOG, tmp->name); - ast_channel_free(tmp); - return NULL; - } - } - /* let's start the serial monitoring thread too, so we can have serial signaling */ - if (ast_pthread_create(&p->controldev_thread, NULL, skypiax_do_controldev_thread, p) < 0) { - ERRORA("Unable to start controldev thread.\n", SKYPIAX_P_LOG); - ast_channel_free(tmp); - tmp = NULL; - } - DEBUGA_SERIAL("STARTED controldev_thread=%lu STOP=%lu NULL=%lu\n", SKYPIAX_P_LOG, - (unsigned long) p->controldev_thread, (unsigned long) AST_PTHREADT_STOP, (unsigned long) AST_PTHREADT_NULL); - - /* add one to the usage count of Skypiax-type channels */ - LOKKA(&skypiax_usecnt_lock); - skypiax_usecnt++; - UNLOCKA(&skypiax_usecnt_lock); - ast_update_use_count(); - - /* return the newly created channel */ - return tmp; - } - ERRORA("failed memory allocation for Skypiax channel\n", SKYPIAX_P_LOG); - return NULL; -} - -/*! - * \brief Load the module into Asterisk and start its threads - * - * This function register the module into Asterisk, - * create the interfaces for the channels, - * start the auxiliary threads for the interfaces, - * then start a monitor thread. The monitor thread - * will signal Asterisk when an interface receive a call. - * - * - * \return zero on success, -1 on error. - */ -int load_module(void) -{ - int i; - struct ast_config *cfg; - struct skypiax_pvt *tmp; - struct skypiax_pvt *p = NULL; - struct skypiax_pvt *p2 = NULL; -#ifdef ASTERISK_VERSION_1_6 - struct ast_flags config_flags = { 0 }; -#endif /* ASTERISK_VERSION_1_6 */ - -#if defined(WANT_SKYPE_X11) || defined(__CYGWIN__) -#ifndef __CYGWIN__ - if (!XInitThreads()) - ast_log(LOG_ERROR, "Not initialized XInitThreads!\n"); -#endif /* __CYGWIN__ */ -#if 0 - ast_register_atexit(skypiax_disconnect); - ast_register_application(skype2skypiaxapp, skype2skypiax, skype2skypiaxsynopsis, skype2skypiaxdescrip); - ast_register_application(skypiax2skypeapp, skypiax2skype, skypiax2skypesynopsis, skypiax2skypedescrip); -#endif -#endif /* defined(WANT_SKYPE_X11) || defined(__CYGWIN__) */ - - /* make sure we can register our channel type with Asterisk */ - i = ast_channel_register(&skypiax_tech); - if (i < 0) { - ERRORA("Unable to register channel type '%s'\n", SKYPIAX_P_LOG, skypiax_type); - return -1; - } - /* load skypiax.conf config file */ -#ifdef ASTERISK_VERSION_1_6 - cfg = ast_config_load(skypiax_config, config_flags); -#else - cfg = ast_config_load(skypiax_config); -#endif /* ASTERISK_VERSION_1_6 */ - if (cfg != NULL) { - char *ctg = NULL; - int is_first_category = 1; - while ((ctg = ast_category_browse(cfg, ctg)) != NULL) { - /* create one interface for each category in skypiax.conf config file, first one set the defaults */ - tmp = skypiax_mkif(cfg, ctg, is_first_category); - if (tmp) { - DEBUGA_PBX("Created channel Skypiax: skypiax.conf category '[%s]', channel name '%s'" "\n", SKYPIAX_P_LOG, ctg, tmp->name); - /* add interface to skypiax_iflist */ - tmp->next = skypiax_iflist; - skypiax_iflist = tmp; - /* next one will not be the first ;) */ - if (is_first_category == 1) { - is_first_category = 0; - skypiax_console_active = tmp->name; - } - } else { - ERRORA("Unable to create channel Skypiax from skypiax.conf category '[%s]'\n", SKYPIAX_P_LOG, ctg); - /* if error, unload config from memory and return */ - ast_config_destroy(cfg); - ast_channel_unregister(&skypiax_tech); - return -1; - } - /* do it for each category described in config */ - } - - /* we finished, unload config from memory */ - ast_config_destroy(cfg); - } else { - ERRORA("Unable to load skypiax_config skypiax.conf\n", SKYPIAX_P_LOG); - ast_channel_unregister(&skypiax_tech); - return -1; - } -#ifndef ASTERISK_VERSION_1_6 - ast_cli_register_multiple(myclis, sizeof(myclis) / sizeof(struct ast_cli_entry)); -#endif /* ASTERISK_VERSION_1_6 */ - /* start to monitor the interfaces (skypiax_iflist) for the first time */ - if (skypiax_restart_monitor()) { - ERRORA("skypiax_restart_monitor failed, BAD\n", SKYPIAX_P_LOG); - return -1; - } - /* go through the interfaces list (skypiax_iflist) WITHOUT locking */ - p = skypiax_iflist; - while (p) { - int i; - /* for each interface in list */ - p2 = p->next; - NOTICA("STARTING interface %s, please be patient\n", SKYPIAX_P_LOG, p->name); - i = 0; - while (p->SkypiaxHandles.api_connected == 0 && running && i < 60000) { // 60sec FIXME - usleep(1000); - i++; - } - if (p->SkypiaxHandles.api_connected) { - NOTICA("STARTED interface %s\n", SKYPIAX_P_LOG, p->name); - } else { - ERRORA("Interface %s FAILED to start\n", SKYPIAX_P_LOG, p->name); - running = 0; - return -1; - } - /* next one, please */ - p = p2; - } - return 0; -} - -/*! - * \brief Unload the module from Asterisk and shutdown its threads - * - * This function unregister the module from Asterisk, - * destroy the interfaces for the channels, - * shutdown the auxiliary threads for the interfaces, - * then shutdown its monitor thread. - * - * \return zero on success, -1 on error. - */ -int unload_module(void) -{ - struct skypiax_pvt *p = NULL, *p2 = NULL; - int res; - - /* unregister our channel type with Asterisk */ - ast_channel_unregister(&skypiax_tech); - ast_cli_unregister_multiple(myclis, sizeof(myclis) / sizeof(struct ast_cli_entry)); - -#if defined(WANT_SKYPE_X11) || defined(__CYGWIN__) -#ifndef __CYGWIN__ - //FIXME what to do? if (!XInitThreads()) - //FIXME what to do? ast_log(LOG_ERROR, "Not initialized XInitThreads!\n"); -#endif /* __CYGWIN__ */ -#if 0 - ast_unregister_atexit(skypiax_disconnect); - ast_unregister_application(skype2skypiaxapp); - ast_unregister_application(skypiax2skypeapp); -#endif -#endif /* defined(WANT_SKYPE_X11) || defined(__CYGWIN__) */ - - /* lock the skypiax_monlock, kill the monitor thread, unlock the skypiax_monlock */ - LOKKA(&skypiax_monlock); - if (skypiax_monitor_thread && (skypiax_monitor_thread != AST_PTHREADT_NULL) - && (skypiax_monitor_thread != AST_PTHREADT_STOP)) { - if (pthread_cancel(skypiax_monitor_thread)) { - ERRORA("pthread_cancel failed, BAD\n", SKYPIAX_P_LOG); - return -1; - } - if (pthread_kill(skypiax_monitor_thread, SIGURG)) { - DEBUGA_PBX("pthread_kill failed\n", SKYPIAX_P_LOG); //maybe it just died - } -#ifndef __CYGWIN__ /* under cygwin, this seems to be not reliable, get stuck at times */ - if (pthread_join(skypiax_monitor_thread, NULL)) { - ERRORA("pthread_join failed, BAD\n", SKYPIAX_P_LOG); - return -1; - } -#endif /* __CYGWIN__ */ - } - skypiax_monitor_thread = AST_PTHREADT_STOP; - UNLOCKA(&skypiax_monlock); - - if (skypiax_monitor_audio_thread && (skypiax_monitor_audio_thread != AST_PTHREADT_NULL) - && (skypiax_monitor_audio_thread != AST_PTHREADT_STOP)) { - - if (pthread_cancel(skypiax_monitor_audio_thread)) { - ERRORA("pthread_cancel skypiax_monitor_audio_thread failed, BAD\n", SKYPIAX_P_LOG); - } - if (pthread_kill(skypiax_monitor_audio_thread, SIGURG)) { - DEBUGA_PBX("pthread_kill skypiax_monitor_audio_thread failed, no problem\n", SKYPIAX_P_LOG); //maybe it just died - } - - if (pthread_join(skypiax_monitor_audio_thread, NULL)) { - ERRORA("pthread_join failed, BAD\n", SKYPIAX_P_LOG); - } - } - /* lock the skypiax_iflock, and go through the interfaces list (skypiax_iflist) */ - LOKKA(&skypiax_iflock); - p = skypiax_iflist; - while (p) { - /* for each interface in list */ - p2 = p->next; - /* shutdown the sound system, close sound fds, and if exist shutdown the sound managing threads */ - DEBUGA_SOUND("shutting down sound\n", SKYPIAX_P_LOG); - res = skypiax_sound_shutdown(p); - if (res == -1) { - ERRORA("Failed to shutdown sound\n", SKYPIAX_P_LOG); - } -#if 0 - /* if a dsp struct has been allocated, free it */ - if (p->dsp) { - ast_dsp_free(p->dsp); - p->dsp = NULL; - } -#endif - DEBUGA_PBX("freeing PVT\n", SKYPIAX_P_LOG); - /* free the pvt allocated memory */ - free(p); - /* next one, please */ - p = p2; - } - /* finished with the interfaces list, unlock the skypiax_iflock */ - UNLOCKA(&skypiax_iflock); - -#ifdef __CYGWIN__ - NOTICA("Sleping 5 secs, please wait...\n", SKYPIAX_P_LOG); - sleep(5); /* without this pause, for some unknown (to me) reason it crashes on cygwin */ -#endif /* __CYGWIN__ */ - NOTICA("Unloaded Skypiax Module\n", SKYPIAX_P_LOG); - return 0; -} - -/*! - * \brief Return the count of active channels for this module - * - * \return the count of active channels for this module - */ -int usecount() -{ - int res; - static struct skypiax_pvt *p = &skypiax_log_struct; -/* lock the skypiax_usecnt lock */ - LOKKA(&skypiax_usecnt_lock); - /* retrieve the skypiax_usecnt */ - res = skypiax_usecnt; -/* unlock the skypiax_usecnt lock */ - UNLOCKA(&skypiax_usecnt_lock); - /* return the skypiax_usecnt */ - return res; -} - -/*! - * \brief Return the textual description of the module - * - * \return the textual description of the module - */ -char *description() -{ - return (char *) skypiax_desc; -} - -/*! - * \brief Return the ASTERISK_GPL_KEY - * - * \return the ASTERISK_GPL_KEY - */ -char *key() -{ - struct skypiax_pvt *p = NULL; - - NOTICA("Returning Key\n", SKYPIAX_P_LOG); - - return ASTERISK_GPL_KEY; -} - -/*! - * \brief Create and initialize one interface for the module - * \param cfg pointer to configuration data from skypiax.conf - * \param ctg pointer to a category name to be found in cfg - * \param is_first_category is this the first category in cfg - * - * This function create and initialize one interface for the module - * - * \return a pointer to the PVT structure of interface on success, NULL on error. - */ -struct skypiax_pvt *skypiax_mkif(struct ast_config *cfg, char *ctg, int is_first_category) -{ - struct skypiax_pvt *tmp; - struct ast_variable *v; - int res; - - int debug_all = 0; - int debug_at = 0; - int debug_fbus2 = 0; - int debug_serial = 0; - int debug_sound = 0; - int debug_pbx = 0; - int debug_skype = 0; - int debug_call = 0; - int debug_locks = 0; - int debug_monitorlocks = 0; - - ast_log(LOG_DEBUG, "ENTERING FUNC\n"); - /* alloc memory for PVT */ - tmp = malloc(sizeof(struct skypiax_pvt)); - if (tmp == NULL) { /* fail */ - return NULL; - } - /* clear memory for PVT */ - memset(tmp, 0, sizeof(struct skypiax_pvt)); - - /* if we are reading the "first" category of the config file, take SELECTED values as defaults, overriding the values in skypiax_default */ - if (is_first_category == 1) { - /* for each variable in category, copy it in the skypiax_default struct */ - for (v = ast_variable_browse(cfg, ctg); v; v = v->next) { - M_START(v->name, v->value); - - M_STR("context", skypiax_default.context) - M_STR("language", skypiax_default.language) - M_STR("extension", skypiax_default.exten) - M_F("playback_boost", skypiax_store_boost(v->value, &skypiax_default.playback_boost)) - M_F("capture_boost", skypiax_store_boost(v->value, &skypiax_default.capture_boost)) - M_UINT("skypiax_dir_entry_extension_prefix", skypiax_default.skypiax_dir_entry_extension_prefix) - M_END(; - ); - } - } - - /* initialize the newly created PVT from the skypiax_default values */ - *tmp = skypiax_default; - - /* the category name becomes the interface name */ - tmp->name = strdup(ctg); - - /* for each category in config file, "first" included, read in ALL the values */ - for (v = ast_variable_browse(cfg, ctg); v; v = v->next) { - M_START(v->name, v->value); - - M_BOOL("debug_all", debug_all) - M_BOOL("debug_at", debug_at) - M_BOOL("debug_fbus2", debug_fbus2) - M_BOOL("debug_serial", debug_serial) - M_BOOL("debug_sound", debug_sound) - M_BOOL("debug_pbx", debug_pbx) - M_BOOL("debug_skype", debug_skype) - M_BOOL("debug_call", debug_call) - M_BOOL("debug_locks", debug_locks) - M_BOOL("debug_monitorlocks", debug_monitorlocks) - M_BOOL("skype", tmp->skype) - M_STR("context", tmp->context) - M_STR("language", tmp->language) - M_STR("extension", tmp->exten) - M_STR("X11_display", tmp->X11_display) - M_UINT("tcp_cli_port", tmp->tcp_cli_port) - M_UINT("tcp_srv_port", tmp->tcp_srv_port) - M_F("playback_boost", skypiax_store_boost(v->value, &tmp->playback_boost)) - M_F("capture_boost", skypiax_store_boost(v->value, &tmp->capture_boost)) - M_STR("skype_user", tmp->skype_user) - M_UINT("skypiax_dir_entry_extension_prefix", tmp->skypiax_dir_entry_extension_prefix) - M_END(; - ); - } - - if (debug_all) { - skypiax_debug = skypiax_debug | DEBUG_ALL; - if (!option_debug) { - WARNINGA - ("DEBUG_ALL activated, but option_debug is 0. You have to set debug level higher than zero to see some debugging output. Please use the command \"set debug 10\" or start Asterisk with \"-dddddddddd\" option for full DEBUG_ALL debugging output.\n", - SKYPIAX_TMP_LOG); - } else { - NOTICA("DEBUG_ALL activated. \n", SKYPIAX_TMP_LOG); - } - } - - if (debug_fbus2) { - skypiax_debug = skypiax_debug | DEBUG_FBUS2; - if (!option_debug) { - WARNINGA - ("DEBUG_FBUS2 activated, but option_debug is 0. You have to set debug level higher than zero to see some debugging output. Please use the command \"set debug 10\" or start Asterisk with \"-dddddddddd\" option for full DEBUG_FBUS2 debugging output.\n", - SKYPIAX_TMP_LOG); - } else { - NOTICA("DEBUG_FBUS2 activated. \n", SKYPIAX_TMP_LOG); - } - } - - if (debug_serial) { - skypiax_debug = skypiax_debug | DEBUG_SERIAL; - if (!option_debug) { - WARNINGA - ("DEBUG_SERIAL activated, but option_debug is 0. You have to set debug level higher than zero to see some debugging output. Please use the command \"set debug 10\" or start Asterisk with \"-dddddddddd\" option for full DEBUG_SERIAL debugging output.\n", - SKYPIAX_TMP_LOG); - } else { - NOTICA("DEBUG_SERIAL activated. \n", SKYPIAX_TMP_LOG); - } - } - - if (debug_sound) { - skypiax_debug = skypiax_debug | DEBUG_SOUND; - if (!option_debug) { - WARNINGA - ("DEBUG_SOUND activated, but option_debug is 0. You have to set debug level higher than zero to see some debugging output. Please use the command \"set debug 10\" or start Asterisk with \"-dddddddddd\" option for full DEBUG_SOUND debugging output.\n", - SKYPIAX_TMP_LOG); - } else { - NOTICA("DEBUG_SOUND activated. \n", SKYPIAX_TMP_LOG); - } - } - - if (debug_pbx) { - skypiax_debug = skypiax_debug | DEBUG_PBX; - if (!option_debug) { - WARNINGA - ("DEBUG_PBX activated, but option_debug is 0. You have to set debug level higher than zero to see some debugging output. Please use the command \"set debug 10\" or start Asterisk with \"-dddddddddd\" option for full DEBUG_PBX debugging output.\n", - SKYPIAX_TMP_LOG); - } else { - NOTICA("DEBUG_PBX activated. \n", SKYPIAX_TMP_LOG); - } - } - - if (debug_skype) { - skypiax_debug = skypiax_debug | DEBUG_SKYPE; - if (!option_debug) { - WARNINGA - ("DEBUG_SKYPE activated, but option_debug is 0. You have to set debug level higher than zero to see some debugging output. Please use the command \"set debug 10\" or start Asterisk with \"-dddddddddd\" option for full DEBUG_SKYPE debugging output.\n", - SKYPIAX_TMP_LOG); - } else { - NOTICA("DEBUG_SKYPE activated. \n", SKYPIAX_TMP_LOG); - } - } - - if (debug_call) { - skypiax_debug = skypiax_debug | DEBUG_CALL; - if (!option_debug) { - WARNINGA - ("DEBUG_CALL activated, but option_debug is 0. You have to set debug level higher than zero to see some debugging output. Please use the command \"set debug 10\" or start Asterisk with \"-dddddddddd\" option for full DEBUG_CALL debugging output.\n", - SKYPIAX_TMP_LOG); - } else { - NOTICA("DEBUG_CALL activated. \n", SKYPIAX_TMP_LOG); - } - } - - if (debug_locks) { - skypiax_debug = skypiax_debug | DEBUG_LOCKS; - if (!option_debug) { - WARNINGA - ("DEBUG_LOCKS activated, but option_debug is 0. You have to set debug level higher than zero to see some debugging output. Please use the command \"set debug 10\" or start Asterisk with \"-dddddddddd\" option for full DEBUG_LOCKS debugging output.\n", - SKYPIAX_TMP_LOG); - } else { - NOTICA("DEBUG_LOCKS activated. \n", SKYPIAX_TMP_LOG); - } - } - - if (debug_monitorlocks) { - skypiax_debug = skypiax_debug | DEBUG_MONITORLOCKS; - if (!option_debug) { - WARNINGA - ("DEBUG_MONITORLOCKS activated, but option_debug is 0. You have to set debug level higher than zero to see some debugging output. Please use the command \"set debug 10\" or start Asterisk with \"-dddddddddd\" option for full DEBUG_MONITORLOCKS debugging output.\n", - SKYPIAX_TMP_LOG); - } else { - NOTICA("DEBUG_MONITORLOCKS activated. \n", SKYPIAX_TMP_LOG); - } - } - - if (option_debug > 1) { - DEBUGA_SOUND("playback_boost is %f\n", SKYPIAX_TMP_LOG, tmp->playback_boost); - DEBUGA_SOUND("capture_boost is %f\n", SKYPIAX_TMP_LOG, tmp->capture_boost); - } -/* initialize the soundcard channels (input and output) used by this interface (a multichannel soundcard can be used by multiple interfaces), optionally starting the sound managing threads */ - res = skypiax_sound_init(tmp); - if (res == -1) { - ERRORA("Failed initializing sound device\n", SKYPIAX_TMP_LOG); - /* we failed, free the PVT */ - free(tmp); - return NULL; - } - /* - res = pipe(tmp->SkypiaxHandles.fdesc); - if (res) { - ast_log(LOG_ERROR, "Unable to create skype pipe\n"); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG); - } - free(tmp); - return NULL; - } - fcntl(tmp->SkypiaxHandles.fdesc[0], F_SETFL, O_NONBLOCK); - fcntl(tmp->SkypiaxHandles.fdesc[1], F_SETFL, O_NONBLOCK); - */ - tmp->skype_thread = AST_PTHREADT_NULL; - - if (tmp->skype) { - ast_log(LOG_DEBUG, "TO BE started skype_thread=%lu STOP=%lu NULL=%lu\n", - (unsigned long) tmp->skype_thread, (unsigned long) AST_PTHREADT_STOP, (unsigned long) AST_PTHREADT_NULL); -#ifdef __CYGWIN__ - if (ast_pthread_create(&tmp->skype_thread, NULL, do_skypeapi_thread, tmp) < 0) { - ast_log(LOG_ERROR, "Unable to start skype_main thread.\n"); - free(tmp); - return NULL; - } -#else /* __CYGWIN__ */ -#ifdef WANT_SKYPE_X11 - ast_log(LOG_DEBUG, "AsteriskHandlesfd: %d\n", tmp->SkypiaxHandles.fdesc[1]); - if (ast_pthread_create(&tmp->skype_thread, NULL, do_skypeapi_thread, tmp) < 0) { - ast_log(LOG_ERROR, "Unable to start skype_main thread.\n"); - free(tmp); - return NULL; - } -#endif /* WANT_SKYPE_X11 */ -#endif /* __CYGWIN__ */ - usleep(100000); //0.1 sec - if (tmp->skype_thread == AST_PTHREADT_NULL) { - ast_log(LOG_ERROR, "Unable to start skype_main thread.\n"); - free(tmp); - return NULL; - } - ast_log(LOG_DEBUG, "STARTED skype_thread=%lu STOP=%lu NULL=%lu\n", - (unsigned long) tmp->skype_thread, (unsigned long) AST_PTHREADT_STOP, (unsigned long) AST_PTHREADT_NULL); - } -#if 0 - if (tmp->skype) { -#if 0 - if (option_debug > 1) - ast_log(LOG_DEBUG, "TO BE started skype_thread=%lu STOP=%lu NULL=%lu\n", - (unsigned long) tmp->skype_thread, (unsigned long) AST_PTHREADT_STOP, (unsigned long) AST_PTHREADT_NULL); -#endif -#ifdef __CYGWIN__ - if (ast_pthread_create(&tmp->skype_thread, NULL, do_skypeapi_thread, &tmp->SkypiaxHandles) < 0) { - ast_log(LOG_ERROR, "Unable to start skype_main thread.\n"); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG); - } - free(tmp); - return NULL; - } -#else /* __CYGWIN__ */ -#ifdef WANT_SKYPE_X11 - if (ast_pthread_create(&tmp->signaling_thread, NULL, do_signaling_thread_fnc, tmp) < 0) { - ast_log(LOG_ERROR, "Unable to start skype_main thread.\n"); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG); - } - free(tmp); - return NULL; - } -#endif /* WANT_SKYPE_X11 */ -#endif /* __CYGWIN__ */ - usleep(100000); //0.1 sec - if (tmp->skype_thread == AST_PTHREADT_NULL) { - ast_log(LOG_ERROR, "Unable to start skype_main thread.\n"); - if (option_debug > 10) { - DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG); - } - free(tmp); - return NULL; - } - if (option_debug > 1) - ast_log(LOG_DEBUG, "STARTED signaling_thread=%lu STOP=%lu NULL=%lu\n", - (unsigned long) tmp->signaling_thread, (unsigned long) AST_PTHREADT_STOP, (unsigned long) AST_PTHREADT_NULL); - } -#endif - - /* return the newly created skypiax_pvt */ - return tmp; -} - -/*! \brief (Re)Start the module main monitor thread, watching for incoming calls on the interfaces */ -int skypiax_restart_monitor(void) -{ - static struct skypiax_pvt *p = &skypiax_log_struct; - - /* If we're supposed to be stopped -- stay stopped */ - if (skypiax_monitor_thread == AST_PTHREADT_STOP) { - return 0; - } - LOKKA(&skypiax_monlock); - /* Do not seems possible to me that this function can be called by the very same monitor thread, but let's be paranoid */ - if (skypiax_monitor_thread == pthread_self()) { - UNLOCKA(&skypiax_monlock); - ERRORA("Cannot kill myself\n", SKYPIAX_P_LOG); - return -1; - } - /* if the monitor thread exists */ - if (skypiax_monitor_thread != AST_PTHREADT_NULL) { - /* Wake up the thread, it can be stuck waiting in a select or so */ - pthread_kill(skypiax_monitor_thread, SIGURG); - } else { - /* the monitor thread does not exists, start a new monitor */ - if (ast_pthread_create(&skypiax_monitor_thread, NULL, skypiax_do_monitor, NULL) < 0) { - UNLOCKA(&skypiax_monlock); - ERRORA("Unable to start monitor thread.\n", SKYPIAX_P_LOG); - return -1; - } - } - UNLOCKA(&skypiax_monlock); - return 0; -} - -/*! \brief The skypiax monitoring thread - * \note This thread monitors all the skypiax interfaces that are not in a call - * (and thus do not have a separate thread) indefinitely - * */ -void *skypiax_do_monitor(void *data) -{ - fd_set rfds; - int res; - struct skypiax_pvt *p = NULL; - int max = -1; - struct timeval to; - time_t now_timestamp; - - if (pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL)) { - ERRORA("Unable to set cancel type to deferred\n", SKYPIAX_P_LOG); - return NULL; - } - - for (;;) { - pthread_testcancel(); - /* Don't let anybody kill us right away. Nobody should lock the interface list - and wait for the monitor list, but the other way around is okay. */ - PUSHA_UNLOCKA(&skypiax_monlock); - MONITORLOKKA(&skypiax_monlock); - /* Lock the interface list */ - PUSHA_UNLOCKA(&skypiax_iflock); - MONITORLOKKA(&skypiax_iflock); - /* Build the stuff we're going to select on, that is the skypiax_serial_fd of every - skypiax_pvt that does not have an associated owner channel. In the case of FBUS2 3310 - and in the case of PROTOCOL_NO_SERIAL we add the audio_fd as well, because there is not serial signaling of incoming calls */ - FD_ZERO(&rfds); - - time(&now_timestamp); - p = skypiax_iflist; - while (p) { - if (!p->owner) { - /* This interface needs to be watched, as it lacks an owner */ - - if (p->skype) { - if (FD_ISSET(p->SkypiaxHandles.fdesc[0], &rfds)) - ERRORA("Descriptor %d (SkypiaxHandles.fdesc[0]) appears twice ?\n", SKYPIAX_P_LOG, p->SkypiaxHandles.fdesc[0]); - - if (p->SkypiaxHandles.fdesc[0] > 0) { - FD_SET(p->SkypiaxHandles.fdesc[0], &rfds); - if (p->SkypiaxHandles.fdesc[0] > max) - max = p->SkypiaxHandles.fdesc[0]; - - } - } - - } - /* next interface, please */ - p = p->next; - } - /* Okay, now that we know what to do, release the interface lock */ - MONITORUNLOCKA(&skypiax_iflock); - POPPA_UNLOCKA(&skypiax_iflock); - /* And from now on, we're okay to be killed, so release the monitor lock as well */ - MONITORUNLOCKA(&skypiax_monlock); - POPPA_UNLOCKA(&skypiax_monlock); - - /* you want me to die? */ - pthread_testcancel(); - - /* Wait for something to happen */ - to.tv_sec = 0; - to.tv_usec = 500000; /* we select with this timeout because under cygwin we avoid the signal usage, so there is no way to end the thread if it is stuck waiting for select */ - res = ast_select(max + 1, &rfds, NULL, NULL, &to); - - /* you want me to die? */ - pthread_testcancel(); - - /* Okay, select has finished. Let's see what happened. */ - - /* If there are errors... */ - if (res < 0) { - if (errno == EINTR) /* EINTR is just the select - being interrupted by a SIGURG, or so */ - continue; - else { - ERRORA("select returned %d: %s\n", SKYPIAX_P_LOG, res, strerror(errno)); - return NULL; - } - } - - /* must not be killed while skypiax_iflist is locked */ - PUSHA_UNLOCKA(&skypiax_monlock); - MONITORLOKKA(&skypiax_monlock); - /* Alright, lock the interface list again, and let's look and see what has - happened */ - PUSHA_UNLOCKA(&skypiax_iflock); - MONITORLOKKA(&skypiax_iflock); - - p = skypiax_iflist; - for (; p; p = p->next) { - - if (p->skype) { - if (FD_ISSET(p->SkypiaxHandles.fdesc[0], &rfds)) { - res = skypiax_signaling_read(p); - if (res == CALLFLOW_INCOMING_CALLID || res == CALLFLOW_INCOMING_RING) { - //ast_log(LOG_NOTICE, "CALLFLOW_INCOMING_RING SKYPE\n"); - DEBUGA_SKYPE("CALLFLOW_INCOMING_RING\n", SKYPIAX_P_LOG); - skypiax_new(p, SKYPIAX_STATE_RING, p->context /* p->context */ ); - } - } - } - - } - MONITORUNLOCKA(&skypiax_iflock); - POPPA_UNLOCKA(&skypiax_iflock); - MONITORUNLOCKA(&skypiax_monlock); - POPPA_UNLOCKA(&skypiax_monlock); - pthread_testcancel(); - } -/* Never reached */ - return NULL; - -} - -/*! - * \brief Initialize the soundcard channels (input and output) used by one interface (a multichannel soundcard can be used by multiple interfaces) - * \param p the skypiax_pvt of the interface - * - * This function initialize the soundcard channels (input and output) used by one interface (a multichannel soundcard can be used by multiple interfaces). It simply pass its parameters to the right function for the sound system for which has been compiled, eg. alsa_init for ALSA, oss_init for OSS, winmm_init for Windows Multimedia, etc and return the result - * - * \return zero on success, -1 on error. - */ - -int skypiax_sound_init(struct skypiax_pvt *p) -{ - return skypiax_audio_init(p); -} - -/*! - * \brief Shutdown the soundcard channels (input and output) used by one interface (a multichannel soundcard can be used by multiple interfaces) - * \param p the skypiax_pvt of the interface - * - * This function shutdown the soundcard channels (input and output) used by one interface (a multichannel soundcard can be used by multiple interfaces). It simply pass its parameters to the right function for the sound system for which has been compiled, eg. alsa_shutdown for ALSA, oss_shutdown for OSS, winmm_shutdown for Windows Multimedia, etc and return the result - * - * \return zero on success, -1 on error. - */ - -int skypiax_sound_shutdown(struct skypiax_pvt *p) -{ - - //return skypiax_portaudio_shutdown(p); - - return -1; -} - -/*! \brief Read audio frames from interface */ -struct ast_frame *skypiax_sound_read(struct skypiax_pvt *p) -{ - struct ast_frame *f = NULL; - int res; - - res = skypiax_audio_read(p); - f = &p->read_frame; - return f; -} - -/*! \brief Send audio frame to interface */ -int skypiax_sound_write(struct skypiax_pvt *p, struct ast_frame *f) -{ - int ret = -1; - - ret = skypiax_audio_write(p, f); - return ret; -} - -/*! - * \brief This thread runs during a call, and monitor the interface serial port for signaling, like hangup, caller id, etc - * - */ -void *skypiax_do_controldev_thread(void *data) -{ - struct skypiax_pvt *p = data; - int res; - - DEBUGA_SERIAL("In skypiax_do_controldev_thread: started, p=%p\n", SKYPIAX_P_LOG, p); - - if (pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL)) { - ERRORA("Unable to set cancel type to deferred\n", SKYPIAX_P_LOG); - return NULL; - } - - while (1) { - usleep(1000); - pthread_testcancel(); - if (p->skype) { - res = skypiax_signaling_read(p); - if (res == CALLFLOW_INCOMING_HANGUP) { - DEBUGA_SKYPE("skype call ended\n", SKYPIAX_P_LOG); - if (p->owner) { - pthread_testcancel(); - ast_queue_control(p->owner, AST_CONTROL_HANGUP); - } - } - } - } - - return NULL; - -} - -/************************************************/ - -/* LUIGI RIZZO's magic */ -/* - * store the boost factor - */ -#ifdef ASTERISK_VERSION_1_6 -void skypiax_store_boost(const char *s, double *boost) -#else -void skypiax_store_boost(char *s, double *boost) -#endif /* ASTERISK_VERSION_1_6 */ -{ - struct skypiax_pvt *p = NULL; - - if (sscanf(s, "%lf", boost) != 1) { - ERRORA("invalid boost <%s>\n", SKYPIAX_P_LOG, s); - return; - } - if (*boost < -BOOST_MAX) { - WARNINGA("boost %s too small, using %d\n", SKYPIAX_P_LOG, s, -BOOST_MAX); - *boost = -BOOST_MAX; - } else if (*boost > BOOST_MAX) { - WARNINGA("boost %s too large, using %d\n", SKYPIAX_P_LOG, s, BOOST_MAX); - *boost = BOOST_MAX; - } - *boost = exp(log(10) * *boost / 20) * BOOST_SCALE; - DEBUGA_SOUND("setting boost %s to %f\n", SKYPIAX_P_LOG, s, *boost); -} - -/* - * returns a pointer to the descriptor with the given name - */ -struct skypiax_pvt *skypiax_console_find_desc(char *dev) -{ - struct skypiax_pvt *p = NULL; - - for (p = skypiax_iflist; p && strcmp(p->name, dev) != 0; p = p->next); - if (p == NULL) - WARNINGA("could not find <%s>\n", SKYPIAX_P_LOG, dev); - - return p; -} -int skypiax_console_playback_boost(int fd, int argc, char *argv[]) -{ - struct skypiax_pvt *p = skypiax_console_find_desc(skypiax_console_active); - - if (argc > 2) { - return RESULT_SHOWUSAGE; - } - if (!p) { - ast_cli(fd, "No \"current\" skypiax_console for playback_boost, please enter 'help skypiax_console'\n"); - return RESULT_SUCCESS; - } - - if (argc == 1) { - ast_cli(fd, "playback_boost on the active skypiax_console, that is [%s], is: %5.1f\n", - skypiax_console_active, 20 * log10(((double) p->playback_boost / (double) BOOST_SCALE))); - } else if (argc == 2) { - skypiax_store_boost(argv[1], &p->playback_boost); - - ast_cli(fd, - "playback_boost on the active skypiax_console, that is [%s], is now: %5.1f\n", - skypiax_console_active, 20 * log10(((double) p->playback_boost / (double) BOOST_SCALE))); - } - - return RESULT_SUCCESS; -} -int skypiax_console_capture_boost(int fd, int argc, char *argv[]) -{ - struct skypiax_pvt *p = skypiax_console_find_desc(skypiax_console_active); - - if (argc > 2) { - return RESULT_SHOWUSAGE; - } - if (!p) { - ast_cli(fd, "No \"current\" skypiax_console for capture_boost, please enter 'help skypiax_console'\n"); - return RESULT_SUCCESS; - } - - if (argc == 1) { - ast_cli(fd, "capture_boost on the active skypiax_console, that is [%s], is: %5.1f\n", - skypiax_console_active, 20 * log10(((double) p->capture_boost / (double) BOOST_SCALE))); - } else if (argc == 2) { - skypiax_store_boost(argv[1], &p->capture_boost); - - ast_cli(fd, - "capture_boost on the active skypiax_console, that is [%s], is now: %5.1f\n", - skypiax_console_active, 20 * log10(((double) p->capture_boost / (double) BOOST_SCALE))); - } - - return RESULT_SUCCESS; -} - -int skypiax_console_hangup(int fd, int argc, char *argv[]) -{ - struct skypiax_pvt *p = skypiax_console_find_desc(skypiax_console_active); - - if (argc != 1) { - return RESULT_SHOWUSAGE; - } - if (!p) { - ast_cli(fd, "No \"current\" skypiax_console for hanging up, please enter 'help skypiax_console'\n"); - return RESULT_SUCCESS; - } - if (!p->owner) { - ast_cli(fd, "No call to hangup on the active skypiax_console, that is [%s]\n", skypiax_console_active); - return RESULT_FAILURE; - } - if (p->owner) - ast_queue_hangup(p->owner); - return RESULT_SUCCESS; -} - -int skypiax_console_dial(int fd, int argc, char *argv[]) -{ - char *s = NULL; - struct skypiax_pvt *p = skypiax_console_find_desc(skypiax_console_active); - - if (argc != 2) { - return RESULT_SHOWUSAGE; - } - if (!p) { - ast_cli(fd, "No \"current\" skypiax_console for dialing, please enter 'help skypiax_console'\n"); - return RESULT_SUCCESS; - } - - if (p->owner) { /* already in a call */ - int i; - struct ast_frame f = { AST_FRAME_DTMF, 0 }; - - s = argv[1]; - /* send the string one char at a time */ - for (i = 0; i < strlen(s); i++) { - f.subclass = s[i]; - ast_queue_frame(p->owner, &f); - } - return RESULT_SUCCESS; - } else - ast_cli(fd, "No call in which to dial on the \"current\" skypiax_console, that is [%s]\n", skypiax_console_active); - if (s) - free(s); - return RESULT_SUCCESS; -} -int skypiax_console_set_active(int fd, int argc, char *argv[]) -{ - if (argc == 1) - ast_cli(fd, - "\"current\" skypiax_console is [%s]\n Enter 'skypiax_console show' to see the available interfaces.\n Enter 'skypiax_console interfacename' to change the \"current\" skypiax_console.\n", - skypiax_console_active); - else if (argc != 2) { - return RESULT_SHOWUSAGE; - } else { - struct skypiax_pvt *p; - if (strcmp(argv[1], "show") == 0) { - ast_cli(fd, "Available interfaces:\n"); - for (p = skypiax_iflist; p; p = p->next) - ast_cli(fd, " [%s]\n", p->name); - return RESULT_SUCCESS; - } - p = skypiax_console_find_desc(argv[1]); - if (p == NULL) - ast_cli(fd, "Interface [%s] do not exists!\n", argv[1]); - else { - skypiax_console_active = p->name; - ast_cli(fd, "\"current\" skypiax_console is now: [%s]\n", argv[1]); - } - } - return RESULT_SUCCESS; -} - -int skypiax_console_skypiax(int fd, int argc, char *argv[]) -{ - return RESULT_SHOWUSAGE; -} - -void *do_skypeapi_thread(void *obj) -{ - return skypiax_do_skypeapi_thread_func(obj); -} - -int dtmf_received(private_t * p, char *value) -{ - - struct ast_frame f2 = { AST_FRAME_DTMF, value[0], }; - DEBUGA_SKYPE("Received DTMF: %s\n", SKYPIAX_P_LOG, value); - ast_queue_frame(p->owner, &f2); - - return 0; - -} - -int start_audio_threads(private_t * p) -{ - //if (!p->tcp_srv_thread) { - 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); - return -1; - } else { - DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG); - } - //} - //if (!p->tcp_cli_thread) { - if (ast_pthread_create(&p->tcp_cli_thread, NULL, skypiax_do_tcp_cli_thread, p) < 0) { - ERRORA("Unable to start tcp_cli_thread thread.\n", SKYPIAX_P_LOG); - return -1; - } else { - DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG); - } - //} - -#ifdef NOTDEF - 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(&tech_pvt->tcp_srv_thread, thd_attr, skypiax_do_tcp_srv_thread, tech_pvt, 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(&tech_pvt->tcp_cli_thread, thd_attr, skypiax_do_tcp_cli_thread, tech_pvt, skypiax_module_pool); - DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG); - switch_sleep(100000); - -#endif - - return 0; -} - -int new_inbound_channel(private_t * p) -{ - -#ifdef NOTDEF - switch_core_session_t *session = NULL; - switch_channel_t *channel = NULL; - - if ((session = switch_core_session_request(skypiax_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, SOF_NONE, NULL)) != 0) { - switch_core_session_add_stream(session, NULL); - channel = switch_core_session_get_channel(session); - skypiax_tech_init(tech_pvt, session); - - if ((tech_pvt->caller_profile = - switch_caller_profile_new(switch_core_session_get_pool(session), "skypiax", - tech_pvt->dialplan, tech_pvt->callid_name, - tech_pvt->callid_number, NULL, NULL, NULL, NULL, "mod_skypiax", tech_pvt->context, tech_pvt->destination)) != 0) { - char name[128]; - //switch_snprintf(name, sizeof(name), "skypiax/%s/%s", tech_pvt->name, tech_pvt->caller_profile->destination_number); - switch_snprintf(name, sizeof(name), "skypiax/%s", tech_pvt->name); - 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) { - ERRORA("Error spawning thread\n", SKYPIAX_P_LOG); - switch_core_session_destroy(&session); - } - } - switch_channel_mark_answered(channel); - -#endif - return 0; -} - -int remote_party_is_ringing(private_t * p) -{ - if (p->owner) { - ast_queue_control(p->owner, AST_CONTROL_RINGING); - } - - return 0; -} - -int remote_party_is_early_media(private_t * p) -{ - if (p->owner) { - ast_queue_control(p->owner, AST_CONTROL_RINGING); - } - - return 0; -} - -int outbound_channel_answered(private_t * p) -{ - - if (p->owner) { - ast_queue_control(p->owner, AST_CONTROL_ANSWER); - } - - return 0; -} -void *skypiax_do_tcp_srv_thread(void *obj) -{ - return skypiax_do_tcp_srv_thread_func(obj); -} -void *skypiax_do_tcp_cli_thread(void *obj) -{ - return skypiax_do_tcp_cli_thread_func(obj); -} - -int skypiax_audio_write(struct skypiax_pvt *p, struct ast_frame *f) -{ - int sent; - - sent = write(p->audioskypepipe[1], (short *) f->data, f->datalen); - - return 0; -} -int skypiax_console_skype(int fd, int argc, char *argv[]) -{ - struct skypiax_pvt *p = skypiax_console_find_desc(skypiax_console_active); - char skype_msg[1024]; - int i, a, c; - - if (argc == 1) { - return RESULT_SHOWUSAGE; - } - if (!p) { - ast_cli(fd, "No \"current\" console for skypiax_, please enter 'help console'\n"); - return RESULT_SUCCESS; - } - if (!p->skype) { - ast_cli(fd, "The \"current\" console is not connected to a Skype client'\n"); - return RESULT_SUCCESS; - } - - memset(skype_msg, 0, sizeof(skype_msg)); - c = 0; - for (i = 1; i < argc; i++) { - for (a = 0; a < strlen(argv[i]); a++) { - skype_msg[c] = argv[i][a]; - c++; - if (c == 1022) - break; - } - if (i != argc - 1) { - skype_msg[c] = ' '; - c++; - } - if (c == 1023) - break; - } - skypiax_signaling_write(p, skype_msg); - return RESULT_SUCCESS; -} - -int skypiax_console_skypiax_dir_import(int fd, int argc, char *argv[]) -{ - //int res; - struct skypiax_pvt *p = skypiax_console_find_desc(skypiax_console_active); - //char list_command[64]; - char fn[256]; - char date[256] = ""; - time_t t; - char *configfile = SKYPIAX_DIR_CONFIG; - int add_to_skypiax_dir_conf = 1; - //int fromskype = 0; - //int fromcell = 0; - -#if 0 - if (directoriax_entry_extension) { - skypiax_dir_entry_extension = directoriax_entry_extension; - } else { - ast_cli(fd, "No 'directoriax_entry_extension', you MUST have loaded directoriax.so\n"); - return RESULT_SUCCESS; - } -#endif - - if (argc != 2) - return RESULT_SHOWUSAGE; - if (!p) { - ast_cli(fd, "No \"current\" console ???, please enter 'help skypiax_console'\n"); - return RESULT_SUCCESS; - } - - if (!strcasecmp(argv[1], "add")) - add_to_skypiax_dir_conf = 1; - else if (!strcasecmp(argv[1], "replace")) - add_to_skypiax_dir_conf = 0; - else { - ast_cli(fd, "\n\nYou have neither specified 'add' nor 'replace'\n\n"); - return RESULT_SHOWUSAGE; - } - -#if 0 - if (!strcasecmp(argv[2], "fromskype")) - fromskype = 1; - else if (!strcasecmp(argv[2], "fromcell")) - fromcell = 1; - else { - ast_cli(fd, "\n\nYou have neither specified 'fromskype' nor 'fromcell'\n\n"); - return RESULT_SHOWUSAGE; - } - - if (fromcell) { - ast_cli(fd, "Importing from cellphone is currently supported only on \"AT\" cellphones :( !\n"); - //fclose(p->phonebook_writing_fp); - //skypiax_dir_create_extensions(); - return RESULT_SUCCESS; - } - - if (fromskype) - if (!p->skype) { - ast_cli(fd, "Importing from skype is supported by skypiax_dir on chan_skypiax!\n"); - //fclose(p->phonebook_writing_fp); - //skypiax_dir_create_extensions(); - return RESULT_SUCCESS; - } - - if (fromcell || fromskype) - if (argc != 3) { - ast_cli(fd, "\n\nYou don't have to specify a filename with 'fromcell' or with 'fromskype'\n\n"); - return RESULT_SHOWUSAGE; - } -#endif - - /*******************************************************************************************/ - - if (configfile[0] == '/') { - ast_copy_string(fn, configfile, sizeof(fn)); - } else { - snprintf(fn, sizeof(fn), "%s/%s", ast_config_AST_CONFIG_DIR, configfile); - } - NOTICA("Opening '%s'\n", SKYPIAX_P_LOG, fn); - time(&t); - ast_copy_string(date, ctime(&t), sizeof(date)); - - if (add_to_skypiax_dir_conf) - p->phonebook_writing_fp = fopen(fn, "a+"); - else - p->phonebook_writing_fp = fopen(fn, "w+"); - - if (p->phonebook_writing_fp) { - if (add_to_skypiax_dir_conf) { - NOTICA("Opened '%s' for appending \n", SKYPIAX_P_LOG, fn); - fprintf(p->phonebook_writing_fp, ";!\n"); - fprintf(p->phonebook_writing_fp, ";! Update Date: %s", date); - fprintf(p->phonebook_writing_fp, ";! Updated by: %s, %d\n", __FILE__, __LINE__); - fprintf(p->phonebook_writing_fp, ";!\n"); - } else { - NOTICA("Opened '%s' for writing \n", SKYPIAX_P_LOG, fn); - fprintf(p->phonebook_writing_fp, ";!\n"); - fprintf(p->phonebook_writing_fp, ";! Automatically generated configuration file\n"); - fprintf(p->phonebook_writing_fp, ";! Filename: %s (%s)\n", configfile, fn); - fprintf(p->phonebook_writing_fp, ";! Creation Date: %s", date); - fprintf(p->phonebook_writing_fp, ";! Generated by: %s, %d\n", __FILE__, __LINE__); - fprintf(p->phonebook_writing_fp, ";!\n"); - fprintf(p->phonebook_writing_fp, "[general]\n\n"); - fprintf(p->phonebook_writing_fp, "[default]\n"); - } - - /*******************************************************************************************/ - //if (fromskype) { - if (p->skype) { - WARNINGA("About to querying the Skype client 'Contacts', it may take some moments... Don't worry.\n", SKYPIAX_P_LOG); - if (p->skype_thread != AST_PTHREADT_NULL) { - char msg_to_skype[1024]; - - p->skype_friends[0] = '\0'; - sprintf(msg_to_skype, "#333 SEARCH FRIENDS"); - if (skypiax_signaling_write(p, msg_to_skype) < 0) { - return -1; - } - - int friends_count = 0; - while (p->skype_friends[0] == '\0') { - /* FIXME needs a timeout, can't wait forever! - * eg. when skype is running but not connected! */ - usleep(100); - friends_count++; - if (friends_count > 20000) { - return -1; /* FIXME */ - } - } - - } - - if (p->skype_thread != AST_PTHREADT_NULL) { - char msg_to_skype[1024]; - - if (p->skype_friends[0] != '\0') { - char *buf, *where; - char **stringp; - int skype_dir_file_written = 0; - - buf = p->skype_friends; - stringp = &buf; - where = strsep(stringp, ", "); - while (where) { - if (where[0] != '\0') { - /* - * So, we have the Skype username (the HANDLE, I think is called). - * But we want to call the names we see in the Skype contact list - * So, let's check the DISPLAYNAME (the end user modified contact name) - * Then, we check the FULLNAME (that appears as it was the DISPLAYNAME - * if the end user has not modify it) - * If we still have neither DISPLAYNAME nor FULLNAME, we'll use the - * Skipe username (the HANDLE) - */ - - p->skype_displayname[0] = '\0'; - sprintf(msg_to_skype, "#765 GET USER %s DISPLAYNAME", where); - skypiax_signaling_write(p, msg_to_skype); - int displayname_count = 0; - while (p->skype_displayname[0] == '\0') { - /* FIXME needs a timeout, can't wait forever! - * eg. when skype is running but not connected! */ - usleep(100); - displayname_count++; - if (displayname_count > 20000) - return -1; /* FIXME */ - } - if (p->skype_displayname[0] != '\0') { - char *where2; - char sanitized[300]; - - sanitized[0] = '\0'; - - where2 = strstr(p->skype_displayname, "DISPLAYNAME "); - if (where2) { - - /* there can be some *smart* that makes a displayname - * that is different than firstlast, */ - /* maybe initials, simbols, slashes, - * something smartish... let's check */ - - if (where2[12] != '\0') { - int i = 12; - int x = 0; - int spaces = 0; - int last_char_was_space = 0; - - for (i = 12; i < strlen(where2) && x < 299; i++) { - if (!isalnum(where2[i])) { - if (!isblank(where2[i])) { - /* bad char */ - continue; - } - /* is a space */ - if (last_char_was_space == 1) /* do not write 2 consecutive spaces */ - continue; - last_char_was_space = 1; - sanitized[x] = ' '; - x++; - continue; - } - /* is alphanum */ - last_char_was_space = 0; - sanitized[x] = where2[i]; - x++; - continue; - } - - sanitized[x] = '\0'; - if (spaces == 0) { - } - DEBUGA_SKYPE("sanitized=|%s|, where=|%s|, where2=|%s|\n", SKYPIAX_P_LOG, sanitized, where, &where2[12]); - } - - if (where2[12] != '\0') { - skypiax_dir_entry_extension++; - if (where[0] == '+' || isdigit(where[0])) { /* is a skypeout number */ - fprintf(p->phonebook_writing_fp, - "%s => ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n", - where, sanitized, "no", - p->skypiax_dir_entry_extension_prefix, "2", skypiax_dir_entry_extension, "yes", "not_specified"); - } else { /* is a skype name */ - fprintf(p->phonebook_writing_fp, - "%s => ,%sSKY,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n", - where, sanitized, "no", - p->skypiax_dir_entry_extension_prefix, "1", skypiax_dir_entry_extension, "yes", "not_specified"); - } - skype_dir_file_written = 1; - - } - } - } - p->skype_displayname[0] = '\0'; - - p->skype_fullname[0] = '\0'; - sprintf(msg_to_skype, "#222 GET USER %s FULLNAME", where); - skypiax_signaling_write(p, msg_to_skype); - int fullname_count = 0; - while (p->skype_fullname[0] == '\0') { - /* FIXME needs a timeout, can't wait forever! - * eg. when skype is running but not connected! */ - usleep(100); - fullname_count++; - if (fullname_count > 20000) - return -1; /* FIXME */ - } - if (p->skype_fullname[0] != '\0') { - char *where2; - char sanitized[300]; - - where2 = strstr(p->skype_fullname, "FULLNAME "); - if (where2) { - - /* there can be some *smart* that makes a fullname - * that is different than firstlast, */ - /* maybe initials, simbols, slashes, - * something smartish... let's check */ - - if (where2[9] != '\0') { - int i = 9; - int x = 0; - int spaces = 0; - int last_char_was_space = 0; - - for (i = 9; i < strlen(where2) && x < 299; i++) { - if (!isalnum(where2[i])) { - if (!isblank(where2[i])) { - /* bad char */ - continue; - } - /* is a space */ - if (last_char_was_space == 1) /* do not write 2 consecutive spaces */ - continue; - last_char_was_space = 1; - sanitized[x] = ' '; - x++; - continue; - } - /* alphanum */ - last_char_was_space = 0; - sanitized[x] = where2[i]; - x++; - continue; - } - - sanitized[x] = '\0'; - if (spaces == 0) { - } - DEBUGA_SKYPE("sanitized=|%s|, where=|%s|, where2=|%s|\n", SKYPIAX_P_LOG, sanitized, where, &where2[9]); - } - - if (skype_dir_file_written == 0) { - skypiax_dir_entry_extension++; - if (where2[9] != '\0') { - if (where[0] == '+' || isdigit(where[0])) { /* is a skypeout number */ - fprintf(p->phonebook_writing_fp, - "%s => ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n", - where, sanitized, "no", - p->skypiax_dir_entry_extension_prefix, "2", skypiax_dir_entry_extension, "yes", "not_specified"); - } else { /* is a skype name */ - fprintf(p->phonebook_writing_fp, - "%s => ,%sSKY,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n", - where, sanitized, "no", - p->skypiax_dir_entry_extension_prefix, "1", skypiax_dir_entry_extension, "yes", "not_specified"); - - } - - } else { - if (where[0] == '+' || isdigit(where[0])) { /* is a skypeout number */ - fprintf(p->phonebook_writing_fp, - "%s => ,%sSKO,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n", - where, where, "no", p->skypiax_dir_entry_extension_prefix, - "2", skypiax_dir_entry_extension, "yes", "not_specified"); - } else { /* is a skype name */ - fprintf(p->phonebook_writing_fp, - "%s => ,%sSKY,,,hidefromdir=%s|phonebook_direct_calling_ext=%d%s%.4d|phonebook_entry_fromskype=%s|phonebook_entry_owner=%s\n", - where, where, "no", p->skypiax_dir_entry_extension_prefix, - "1", skypiax_dir_entry_extension, "yes", "not_specified"); - - } - } - } - - skype_dir_file_written = 0; - - } - - } - p->skype_fullname[0] = '\0'; - - } - where = strsep(stringp, ", "); - } - - p->skype_friends[0] = '\0'; - } - } - } else { - - ast_cli(fd, "Skype not configured on the 'current' console, not importing from Skype client!\n"); - } - //} - /*******************************************************************************************/ - /*******************************************************************************************/ - } else { - ast_cli(fd, "\n\nfailed to open the skypiax_dir.conf configuration file: %s\n", fn); - ERRORA("failed to open the skypiax_dir.conf configuration file: %s\n", SKYPIAX_P_LOG, fn); - return RESULT_FAILURE; - } - - fclose(p->phonebook_writing_fp); - //skypiax_dir_create_extensions(); - - return RESULT_SUCCESS; -} - -private_t *find_available_skypiax_interface(void) -{ - private_t *p; - int found = 0; - - /* lock the interfaces' list */ - LOKKA(&skypiax_iflock); - /* make a pointer to the first interface in the interfaces list */ - p = skypiax_iflist; - /* Search for the requested interface and verify if is unowned */ - while (p) { - if (!p->owner) { - DEBUGA_PBX("Interface is NOT OWNED by a channel\n", SKYPIAX_P_LOG); - found = 1; - /* we found the requested interface, bail out from the while loop */ - break; - } else { - /* interface owned by a channel */ - DEBUGA_PBX("Interface is OWNED by a channel\n", SKYPIAX_P_LOG); - } - /* not yet found, next please */ - p = p->next; - } - - /* lock the interfaces' list */ - UNLOCKA(&skypiax_iflock); - - if (found) - return p; - else - return NULL; -} - -/************************************************/ -#ifdef ASTERISK_VERSION_1_4 -#ifndef AST_MODULE -#define AST_MODULE "chan_skypiax" -#endif -AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Skypiax, Audio-Serial Driver"); -#endif /* ASTERISK_VERSION_1_4 */ - -/* rewriting end */ -/*******************************************************************************/ diff --git a/src/mod/endpoints/mod_skypopen/old-stuff/asterisk/cyg_no_pthread_kill.c b/src/mod/endpoints/mod_skypopen/old-stuff/asterisk/cyg_no_pthread_kill.c deleted file mode 100644 index df2da1868a..0000000000 --- a/src/mod/endpoints/mod_skypopen/old-stuff/asterisk/cyg_no_pthread_kill.c +++ /dev/null @@ -1,17 +0,0 @@ -#include -#define PRINTMSGCYG - -extern int option_debug; -int cyg_no_pthreadkill(int thread, int sig); - -int cyg_no_pthreadkill(int thread, int sig) -{ -#ifdef PRINTMSGCYG - if (option_debug) { - printf - ("\n\nHere there would have been a pthread_kill() on thread [%-7lx], with sig=%d, but it has been substituted by this printf in file cyg_no_pthread_kill.c because CYGWIN does not support sending a signal to a one only thread :-(\n\n", - (unsigned long int) thread, sig); - } -#endif // PRINTMSGCYG - return 0; -} diff --git a/src/mod/endpoints/mod_skypopen/old-stuff/asterisk/skypiax.conf b/src/mod/endpoints/mod_skypopen/old-stuff/asterisk/skypiax.conf deleted file mode 100644 index 445c65536a..0000000000 --- a/src/mod/endpoints/mod_skypopen/old-stuff/asterisk/skypiax.conf +++ /dev/null @@ -1,207 +0,0 @@ -;;;;;;;; -;;;;;;;; -;;;;;;; Skypiax Asterisk Driver -;;;;;;; -;;;;;;; Configuration file -;;;;;;; lines beginning with semicolon (" are ignored (commented out) -;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;; -;;;;;;; The first interface (named skypeclient) -;;;;;;[skypeclient] -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;; general settings, valid on all platforms -;;;;;;; -;;;;;;; -;;;;;;; Default language -;;;;;;; -;;;;;;language=en -;;;;;;; -;;;;;;; Default context (in extensions.conf, can be overridden with @context syntax) -;;;;;;; -;;;;;;context=default -;;;;;;; -;;;;;;; Default extension (in extensions.conf) where incoming calls land -;;;;;;; -;;;;;;extension=s -;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;; Debugging settings, valid globally for all interfaces on all platforms -;;;;;;; -;;;;;;; the debug values are global for all the interfaces. -;;;;;;; -;;;;;;; default is no skypiax debugging output, you **have** to activate debugging here to obtain debugging from skypiax -;;;;;;; -;;;;;;; To see the debugging output you have to "set debug 100" from the Asterisk CLI or launch -;;;;;;; Asterisk with -ddddddddddd option, and have the logger.conf file activating debug info for console and messages -;;;;;;; -;;;;;;; You can activate each of the following separately, but you can't disactivate. Eg: debug_at=no does not subtract debug_at from debug_all -;;;;;;; debug_all activate all possible debugging info -;;;;;;; -;;;;;;;debug_all=yes -;;;;;;debug_skype=yes -;;;;;;debug_pbx=yes -;;;;;;;debug_sound=yes -;;;;;;;debug_locks=yes -;;;;;;;debug_monitorlocks=yes -;;;;;; -;;;;;;skype=yes ; legacy setting, leave it to yes -;;;;;;X11_display=:101 -;;;;;;tcp_cli_port=11234 -;;;;;;tcp_srv_port=11235 -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;;;;;; audio boost settings, valid for all platforms, to compensate for different input/output audio signal levels -;;;;;;; tweak it if you get horrible (or not hearable) sound -;;;;;;; -;;;;;;;boost can be positive or negative (-40 to +40) in db -;;;;;;;experiment to find which values are best for your computer -;;;;;;playback_boost=0 ; -;;;;;;capture_boost=0 ; -;;;;;; -;;; [skypiax1] -;;; language=en -;;; context=default -;;; extension=s -;;; debug_skype=yes -;;; debug_pbx=yes -;;; skype=yes ; legacy setting, leave it to yes -;;; playback_boost=0 ; -;;; capture_boost=0 ; -;;; X11_display=:101 -;;; tcp_cli_port=15576 -;;; tcp_srv_port=15577 -;;; skype_user=skypiax1 -;;; -;;; [skypiax2] -;;; language=en -;;; context=default -;;; extension=s -;;; debug_skype=yes -;;; debug_pbx=yes -;;; skype=yes ; legacy setting, leave it to yes -;;; playback_boost=0 ; -;;; capture_boost=0 ; -;;; X11_display=:102 -;;; tcp_cli_port=15578 -;;; tcp_srv_port=15579 -;;; skype_user=skypiax2 -;;; -;;; [skypiax3] -;;; language=en -;;; context=default -;;; extension=s -;;; debug_skype=yes -;;; debug_pbx=yes -;;; skype=yes ; legacy setting, leave it to yes -;;; playback_boost=0 ; -;;; capture_boost=0 ; -;;; X11_display=:103 -;;; tcp_cli_port=15580 -;;; tcp_srv_port=15581 -;;; skype_user=skypiax3 -;;; -[skypiax4] -language=en -context=default -extension=s -debug_skype=yes -debug_pbx=yes -skype=yes ; legacy setting, leave it to yes -playback_boost=0 ; -capture_boost=0 ; -X11_display=:104 -tcp_cli_port=15582 -tcp_srv_port=15583 -skype_user=skypiax4 - -[skypiax5] -language=en -context=default -extension=s -debug_skype=yes -debug_pbx=yes -skype=yes ; legacy setting, leave it to yes -playback_boost=0 ; -capture_boost=0 ; -X11_display=:105 -tcp_cli_port=15584 -tcp_srv_port=15585 -skype_user=skypiax5 - -[skypiax6] -language=en -context=default -extension=s -debug_skype=yes -debug_pbx=yes -skype=yes ; legacy setting, leave it to yes -playback_boost=0 ; -capture_boost=0 ; -X11_display=:106 -tcp_cli_port=15586 -tcp_srv_port=16586 -skype_user=skypiax6 - -;;; [skypiax17] -;;; language=en -;;; context=default -;;; extension=s -;;; debug_skype=yes -;;; debug_pbx=yes -;;; skype=yes ; legacy setting, leave it to yes -;;; playback_boost=0 ; -;;; capture_boost=0 ; -;;; X11_display=:117 -;;; tcp_cli_port=15587 -;;; tcp_srv_port=15588 -;;; skype_user=skypiax17 -;;; -;;; [skypiax18] -;;; language=en -;;; context=default -;;; extension=s -;;; debug_skype=yes -;;; debug_pbx=yes -;;; skype=yes ; legacy setting, leave it to yes -;;; playback_boost=0 ; -;;; capture_boost=0 ; -;;; X11_display=:118 -;;; tcp_cli_port=15589 -;;; tcp_srv_port=15590 -;;; skype_user=skypiax18 -;;; -;;; [skypiax19] -;;; language=en -;;; context=default -;;; extension=s -;;; debug_skype=yes -;;; debug_pbx=yes -;;; skype=yes ; legacy setting, leave it to yes -;;; playback_boost=0 ; -;;; capture_boost=0 ; -;;; X11_display=:119 -;;; tcp_cli_port=15591 -;;; tcp_srv_port=15592 -;;; skype_user=skypiax19 -;;; -;;; [skypiax20] -;;; language=en -;;; context=default -;;; extension=s -;;; debug_skype=yes -;;; debug_pbx=yes -;;; skype=yes ; legacy setting, leave it to yes -;;; playback_boost=0 ; -;;; capture_boost=0 ; -;;; X11_display=:120 -;;; tcp_cli_port=15593 -;;; tcp_srv_port=15594 -;;; skype_user=skypiax20 -;;; -;;; -;;; diff --git a/src/mod/endpoints/mod_skypopen/old-stuff/asterisk/skypiax.h b/src/mod/endpoints/mod_skypopen/old-stuff/asterisk/skypiax.h deleted file mode 100644 index d960f80a07..0000000000 --- a/src/mod/endpoints/mod_skypopen/old-stuff/asterisk/skypiax.h +++ /dev/null @@ -1,427 +0,0 @@ -//indent -gnu -ts4 -br -brs -cdw -lp -ce -nbfda -npcs -nprs -npsl -nbbo -saf -sai -saw -cs -bbo -nhnl -nut -sob -l90 -#ifndef _SKYPIAX_H_ -#define _SKYPIAX_H_ - -#ifndef SKYPIAX_SVN_VERSION -#define SKYPIAX_SVN_VERSION "????NO_REVISION???" -#endif - -#include /* needed here for conditional compilation on version.h */ - /* the following #defs are for LINUX */ -#ifndef __CYGWIN__ -#ifndef ASTERISK_VERSION_1_6 -#ifndef ASTERISK_VERSION_1_4 -#ifndef ASTERISK_VERSION_1_2 -#define ASTERISK_VERSION_1_4 -#if(ASTERISK_VERSION_NUM == 999999) -#undef ASTERISK_VERSION_1_4 -#elif(ASTERISK_VERSION_NUM < 10400) -#undef ASTERISK_VERSION_1_4 -#endif /* ASTERISK_VERSION_NUM == 999999 || ASTERISK_VERSION_NUM < 10400 */ -#endif /* ASTERISK_VERSION_1_2 */ -#endif /* ASTERISK_VERSION_1_4 */ -#endif /* ASTERISK_VERSION_1_6 */ -#ifdef ASTERISK_VERSION_1_2 -#undef ASTERISK_VERSION_1_4 -#endif /* ASTERISK_VERSION_1_2 */ -#ifdef ASTERISK_VERSION_1_6 -#define ASTERISK_VERSION_1_4 -#endif /* ASTERISK_VERSION_1_6 */ -#define SKYPIAX_SKYPE -#define WANT_SKYPE_X11 -#endif /* NOT __CYGWIN__ */ - /* the following #defs are for WINDOWS */ -#ifdef __CYGWIN__ -#undef ASTERISK_VERSION_1_4 -#undef ASTERISK_VERSION_1_6 -#define SKYPIAX_SKYPE -#undef WANT_SKYPE_X11 -#endif /* __CYGWIN__ */ - -/* INCLUDES */ -#ifdef ASTERISK_VERSION_1_6 -#include /* some asterisk-devel package do not contains asterisk.h, but seems that is needed for the 1.6 series, at least from trunk */ -#endif /* ASTERISK_VERSION_1_6 */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef ASTERISK_VERSION_1_4 -#include -#include -#endif /* ASTERISK_VERSION_1_4 */ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifdef ASTERISK_VERSION_1_6 -#include -#include -#endif /* ASTERISK_VERSION_1_6 */ -#ifdef ASTERISK_VERSION_1_4 -#include -#include -#include -#include -#endif /* ASTERISK_VERSION_1_4 */ -#ifdef ASTERISK_VERSION_1_2 -#include -#include -#endif /* ASTERISK_VERSION_1_2 */ -#ifdef HAVE_CONFIG_H -#include -#endif -//#include "skypiax_spandsp.h" -#ifdef __CYGWIN__ -#include -#endif /* __CYGWIN__ */ -#ifdef WANT_SKYPE_X11 -#include -#include -#include -#endif /* WANT_SKYPE_X11 */ -#ifndef AST_DIGIT_ANYDIG -#define AST_DIGIT_ANYDIG "0123456789*#" -#else -#warning Please review Skypiax AST_DIGIT_ANYDIG -#endif -#ifndef _ASTERISK_H -#define AST_CONFIG_MAX_PATH 255 /* defined in asterisk.h, but some asterisk-devel package do not contains asterisk.h */ -extern char ast_config_AST_CONFIG_DIR[AST_CONFIG_MAX_PATH]; -int ast_register_atexit(void (*func) (void)); /* in asterisk.h, but some asterisk-devel package do not contains asterisk.h */ -void ast_unregister_atexit(void (*func) (void)); /* in asterisk.h, but some asterisk-devel package do not contains asterisk.h */ -#endif - -/* DEFINITIONS */ -#define SAMPLERATE_SKYPIAX 8000 -#define SAMPLES_PER_FRAME SAMPLERATE_SKYPIAX/50 -#define SKYPIAX_DIR_CONFIG "directoriax.conf" - -/* LUIGI RIZZO's magic */ -/* boost support. BOOST_SCALE * 10 ^(BOOST_MAX/20) must - * be representable in 16 bits to avoid overflows. - */ -#define BOOST_SCALE (1<<9) -#define BOOST_MAX 40 /* slightly less than 7 bits */ -/* call flow from the device */ -#define CALLFLOW_CALL_IDLE AST_STATE_DOWN -#define CALLFLOW_INCOMING_RING AST_STATE_RING -#define CALLFLOW_CALL_DIALING AST_STATE_DIALING -#define CALLFLOW_CALL_LINEBUSY AST_STATE_BUSY -#define CALLFLOW_CALL_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 AST_STATE_HANGUP_REQUESTED 200 - //FIXME CALLFLOW_INCOMING_CALLID to be removed -#define CALLFLOW_INCOMING_CALLID 1019 -/* debugging bitmask */ -#define DEBUG_SOUND 1 -#define DEBUG_SERIAL 2 -#define DEBUG_SKYPE 4 -#define DEBUG_AT 8 -#define DEBUG_FBUS2 16 -#define DEBUG_CALL 32 -#define DEBUG_LOCKS 64 -#define DEBUG_PBX 128 -#define DEBUG_MONITORLOCKS 256 -#define DEBUG_ALL DEBUG_SOUND|DEBUG_SERIAL|DEBUG_SKYPE|DEBUG_AT|DEBUG_FBUS2|DEBUG_CALL|DEBUG_PBX|DEBUG_LOCKS|DEBUG_MONITORLOCKS -/* wrappers for ast_log */ -#define DEBUGA_SOUND(...) if (skypiax_debug & DEBUG_SOUND) ast_log(LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_SOUND %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); -#define DEBUGA_SERIAL(...) if (skypiax_debug & DEBUG_SERIAL) ast_log(LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_SERIAL %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); -#define DEBUGA_SKYPE(...) if (skypiax_debug & DEBUG_SKYPE) ast_log(LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_SKYPE %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); -#define DEBUGA_AT(...) if (skypiax_debug & DEBUG_AT) ast_log(LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_AT %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); -#define DEBUGA_FBUS2(...) if (skypiax_debug & DEBUG_FBUS2) ast_log(LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_FBUS2 %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); -#define DEBUGA_CALL(...) if (skypiax_debug & DEBUG_CALL) ast_log(LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_CALL %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); -#define DEBUGA_PBX(...) if (skypiax_debug & DEBUG_PBX) ast_log(LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_PBX %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); -#define ERRORA(...) ast_log(LOG_ERROR, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][ERROR %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); -#define NOTICA(...) ast_log(LOG_NOTICE, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][NOTICE %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); -#define WARNINGA(...) ast_log(LOG_WARNING, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][WARNING %-5d][%-10s][%2d,%2d,%2d] " __VA_ARGS__ ); -/* macros for logging */ -#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_TMP_LOG tmp ? tmp->owner : NULL, (unsigned long)pthread_self(), __LINE__, tmp ? tmp->name ? tmp->name : "none" : "none", tmp ? tmp->owner ? tmp->owner->_state : -1 : -1, tmp ? tmp->interface_state : -1, tmp ? tmp->skype_callflow : -1 -/* logging wrappers for ast_mutex_lock and ast_mutex_unlock */ -#define LOKKA(x) if (skypiax_debug & DEBUG_LOCKS) ast_log(LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_LOCKS %-5d][%-10s][%2d,%2d,%2d] going to lock %p (%s)\n", SKYPIAX_P_LOG, x, x == &skypiax_monlock ? "MONLOCK" : x == &skypiax_iflock ? "IFLOCK" : x == &skypiax_usecnt_lock ? "USECNT_LOCK" : "?????"); if (ast_mutex_lock(x)) ast_log(LOG_ERROR, "ast_mutex_lock failed, BAD\n"); if (skypiax_debug & DEBUG_LOCKS) ast_log(LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_LOCKS %-5d][%-10s][%2d,%2d,%2d] locked %p (%s)\n", SKYPIAX_P_LOG, x, x == &skypiax_monlock ? "MONLOCK" : x == &skypiax_iflock ? "IFLOCK" : x == &skypiax_usecnt_lock ? "USECNT_LOCK" : "?????"); -#define UNLOCKA(x) if (skypiax_debug & DEBUG_LOCKS) ast_log(LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_LOCKS %-5d][%-10s][%2d,%2d,%2d] going to unlock %p (%s)\n", SKYPIAX_P_LOG, x, x == &skypiax_monlock ? "MONLOCK" : x == &skypiax_iflock ? "IFLOCK" : x == &skypiax_usecnt_lock ? "USECNT_LOCK" : "?????"); if (ast_mutex_unlock(x)) ast_log(LOG_ERROR, "ast_mutex_lock failed, BAD\n"); if (skypiax_debug & DEBUG_LOCKS) ast_log(LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_LOCKS %-5d][%-10s][%2d,%2d,%2d] unlocked %p (%s)\n", SKYPIAX_P_LOG, x, x == &skypiax_monlock ? "MONLOCK" : x == &skypiax_iflock ? "IFLOCK" : x == &skypiax_usecnt_lock ? "USECNT_LOCK" : "?????"); -#define PUSHA_UNLOCKA(x) pthread_cleanup_push(skypiax_unlocka_log, (void *) x); -#define POPPA_UNLOCKA(x) pthread_cleanup_pop(0); -#define MONITORLOKKA(x) if (skypiax_debug & DEBUG_MONITORLOCKS) ast_log(LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_MONITORLOCKS %-5d][%-10s][%2d,%2d,%2d] going to lock %p (%s)\n", SKYPIAX_P_LOG, x, x == &skypiax_monlock ? "MONLOCK" : x == &skypiax_iflock ? "IFLOCK" : x == &skypiax_usecnt_lock ? "USECNT_LOCK" : "?????"); if (ast_mutex_lock(x)) ast_log(LOG_ERROR, "ast_mutex_lock failed, BAD\n"); if (skypiax_debug & DEBUG_MONITORLOCKS) ast_log(LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_MONITORLOCKS %-5d][%-10s][%2d,%2d,%2d] locked %p (%s)\n", SKYPIAX_P_LOG, x, x == &skypiax_monlock ? "MONLOCK" : x == &skypiax_iflock ? "IFLOCK" : x == &skypiax_usecnt_lock ? "USECNT_LOCK" : "?????"); -#define MONITORUNLOCKA(x) if (skypiax_debug & DEBUG_MONITORLOCKS) ast_log(LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_MONITORLOCKS %-5d][%-10s][%2d,%2d,%2d] going to unlock %p (%s)\n", SKYPIAX_P_LOG, x, x == &skypiax_monlock ? "MONLOCK" : x == &skypiax_iflock ? "IFLOCK" : x == &skypiax_usecnt_lock ? "USECNT_LOCK" : "?????"); if (ast_mutex_unlock(x)) ast_log(LOG_ERROR, "ast_mutex_lock failed, BAD\n"); if (skypiax_debug & DEBUG_MONITORLOCKS) ast_log(LOG_DEBUG, "rev "SKYPIAX_SVN_VERSION "[%p|%-7lx][DEBUG_MONITORLOCKS %-5d][%-10s][%2d,%2d,%2d] unlocked %p (%s)\n", SKYPIAX_P_LOG, x, x == &skypiax_monlock ? "MONLOCK" : x == &skypiax_iflock ? "IFLOCK" : x == &skypiax_usecnt_lock ? "USECNT_LOCK" : "?????"); -/* macros used for config file parsing (luigi rizzo)*/ -#define M_BOOL(tag, dst) M_F(tag, (dst) = ast_true(__val) ) -#define M_END(x) x; -#define M_F(tag, f) if (!strcasecmp((__s), tag)) { f; } else -#ifdef ASTERISK_VERSION_1_6 -#define M_START(var, val) const char *__s = var; const char *__val = val; -#else -#define M_START(var, val) char *__s = var; char *__val = val; -#endif /* ASTERISK_VERSION_1_6 */ -#define M_STR(tag, dst) M_F(tag, ast_copy_string(dst, __val, sizeof(dst))) -#define M_UINT(tag, dst) M_F(tag, (dst) = strtoul(__val, NULL, 0) ) - -#define SKYPIAX_FRAME_SIZE 160 - -/* SKYPIAX INTERNAL STRUCTS */ -/*! - * \brief structure for exchanging messages with the skype client - */ -#ifdef WANT_SKYPE_X11 -struct AsteriskHandles { - Window skype_win; - Display *disp; - Window win; - int fdesc[2]; -}; -#else /* WANT_SKYPE_X11 */ -struct AsteriskHandles { - HWND win32_hInit_MainWindowHandle; - HWND win32_hGlobal_SkypeAPIWindowHandle; - int fdesc[2]; -}; -#endif /* WANT_SKYPE_X11 */ - -#ifndef WIN32 -struct SkypiaxHandles { - Window skype_win; - Display *disp; - Window win; - int api_connected; - int fdesc[2]; -}; -#else //WIN32 - -struct SkypiaxHandles { - HWND win32_hInit_MainWindowHandle; - HWND win32_hGlobal_SkypeAPIWindowHandle; - HINSTANCE win32_hInit_ProcessHandle; - char win32_acInit_WindowClassName[128]; - UINT win32_uiGlobal_MsgID_SkypeControlAPIAttach; - UINT win32_uiGlobal_MsgID_SkypeControlAPIDiscover; - int api_connected; - int fdesc[2]; -}; - -#endif //WIN32 - -/*! - * \brief PVT structure for a skypiax interface (channel), created by skypiax_mkif - */ -struct skypiax_pvt { - char *name; /*!< \brief 'name' of the interface (channel) */ - int interface_state; /*!< \brief 'state' of the interface (channel) */ - struct ast_channel *owner; /*!< \brief channel we belong to, possibly NULL */ - struct skypiax_pvt *next; /*!< \brief Next interface (channel) in list */ - char context[AST_MAX_EXTENSION]; /*!< \brief default Asterisk dialplan context for this interface */ - char language[MAX_LANGUAGE]; /*!< \brief default Asterisk dialplan language for this interface */ - char exten[AST_MAX_EXTENSION]; /*!< \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 */ - char callid_name[50]; - char callid_number[50]; - pthread_t controldev_thread; /*!< \brief serial control thread for this interface, running during the call */ - double playback_boost; - double capture_boost; - int stripmsd; - pthread_t skype_thread; - struct AsteriskHandles AsteriskHandlesAst; - struct SkypiaxHandles SkypiaxHandles; - 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; - int audiopipe[2]; - int audioskypepipe[2]; - pthread_t tcp_srv_thread; - pthread_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; -#ifdef WIN32 - unsigned short tcp_cli_port; - unsigned short tcp_srv_port; -#else - int tcp_cli_port; - int tcp_srv_port; -#endif - char X11_display[256]; - - struct ast_frame read_frame; - - char skype_user[256]; - char skype_password[256]; - char destination[256]; - char session_uuid_str[512 + 1]; - pthread_t signaling_thread; -}; - -typedef struct skypiax_pvt private_t; -/* FUNCTIONS */ - -/* module helpers functions */ -int load_module(void); -int unload_module(void); -int usecount(void); -char *description(void); -char *key(void); - -/* chan_skypiax internal functions */ -void skypiax_unlocka_log(void *x); - -void *do_skypeapi_thread(void *data); -//int skypiax2skype(struct ast_channel *c, void *data); -//int skype2skypiax(struct ast_channel *c, void *data); -//void skypiax_disconnect(void); -int skypiax_signaling_write(struct skypiax_pvt *p, char *msg_to_skype); -int skypiax_signaling_read(struct skypiax_pvt *p); -int skypiax_console_skype(int fd, int argc, char *argv[]); -#ifdef WANT_SKYPE_X11 -int X11_errors_handler(Display * dpy, XErrorEvent * err); -int skypiax_send_message(struct SkypiaxHandles *SkypiaxHandles, const char *message_P); -int skypiax_present(struct SkypiaxHandles *SkypiaxHandles); -void skypiax_clean_disp(void *data); -#endif /* WANT_SKYPE_X11 */ -#ifdef __CYGWIN__ - -int win32_Initialize_CreateWindowClass(private_t * tech_pvt); -void win32_DeInitialize_DestroyWindowClass(private_t * tech_pvt); -int win32_Initialize_CreateMainWindow(private_t * tech_pvt); -void win32_DeInitialize_DestroyMainWindow(private_t * tech_pvt); -#endif /* __CYGWIN__ */ - -/* CHAN_SKYPIAX.C */ -int skypiax_queue_control(struct ast_channel *chan, int control); -struct skypiax_pvt *skypiax_console_find_desc(char *dev); -int skypiax_serial_call(struct skypiax_pvt *p, char *dstr); - -/* FUNCTIONS */ -/* PBX interface functions */ -struct ast_channel *skypiax_request(const char *type, int format, void *data, int *cause); -int skypiax_answer(struct ast_channel *c); -int skypiax_hangup(struct ast_channel *c); -int skypiax_originate_call(struct ast_channel *c, char *idest, int timeout); -struct ast_frame *skypiax_read(struct ast_channel *chan); -int skypiax_write(struct ast_channel *c, struct ast_frame *f); -int skypiax_fixup(struct ast_channel *oldchan, struct ast_channel *newchan); -#ifndef ASTERISK_VERSION_1_4 -int skypiax_indicate(struct ast_channel *c, int cond); -#else -int skypiax_indicate(struct ast_channel *c, int cond, const void *data, size_t datalen); -#endif -int skypiax_devicestate(void *data); -#ifdef ASTERISK_VERSION_1_4 -int skypiax_digitsend_begin(struct ast_channel *ast, char digit); -int skypiax_digitsend_end(struct ast_channel *ast, char digit, unsigned int duration); -#else /* ASTERISK_VERSION_1_4 */ -int skypiax_digitsend(struct ast_channel *ast, char digit); -#endif /* ASTERISK_VERSION_1_4 */ - -/* chan_skypiax internal functions */ - -struct skypiax_pvt *skypiax_mkif(struct ast_config *cfg, char *ctg, int is_first_category); -struct ast_channel *skypiax_new(struct skypiax_pvt *p, int state, char *context); -int skypiax_restart_monitor(void); -void *skypiax_do_monitor(void *data); -int skypiax_sound_boost(struct ast_frame *f, double boost); -int skypiax_sound_init(struct skypiax_pvt *p); -int skypiax_sound_shutdown(struct skypiax_pvt *p); -struct ast_frame *skypiax_sound_read(struct skypiax_pvt *p); -int skypiax_sound_write(struct skypiax_pvt *p, struct ast_frame *f); -void *skypiax_do_controldev_thread(void *data); -#ifdef ASTERISK_VERSION_1_6 -void skypiax_store_boost(const char *s, double *boost); -#else -void skypiax_store_boost(char *s, double *boost); -#endif /* ASTERISK_VERSION_1_6 */ -int skypiax_console_set_active(int fd, int argc, char *argv[]); -int skypiax_console_hangup(int fd, int argc, char *argv[]); -int skypiax_console_playback_boost(int fd, int argc, char *argv[]); -int skypiax_console_capture_boost(int fd, int argc, char *argv[]); -int skypiax_console_skypiax(int fd, int argc, char *argv[]); -int skypiax_console_dial(int fd, int argc, char *argv[]); -int skypiax_audio_init(struct skypiax_pvt *p); -//struct ast_frame *skypiax_audio_read(struct skypiax_pvt *p); -int skypiax_audio_read(struct skypiax_pvt *p); -void *skypiax_do_tcp_srv_thread(void *data); -int skypiax_audio_write(struct skypiax_pvt *p, struct ast_frame *f); -void *skypiax_do_tcp_cli_thread(void *data); -int skypiax_call(struct skypiax_pvt *p, char *idest, int timeout); -int skypiax_console_skypiax_dir_import(int fd, int argc, char *argv[]); - -void *skypiax_do_tcp_srv_thread_func(void *obj); -void *skypiax_do_tcp_cli_thread_func(void *obj); -void *skypiax_do_skypeapi_thread_func(void *obj); -int dtmf_received(private_t * tech_pvt, char *value); -int start_audio_threads(private_t * tech_pvt); -int new_inbound_channel(private_t * tech_pvt); -int outbound_channel_answered(private_t * tech_pvt); -int skypiax_senddigit(struct skypiax_pvt *p, char digit); -int skypiax_signaling_write(private_t * tech_pvt, char *msg_to_skype); -#if defined(WIN32) && !defined(__CYGWIN__) -int skypiax_pipe_read(switch_file_t * pipe, short *buf, int howmany); -int skypiax_pipe_write(switch_file_t * pipe, short *buf, int howmany); -/* Visual C do not have strsep ? */ -char *strsep(char **stringp, const char *delim); -#else -int skypiax_pipe_read(int pipe, short *buf, int howmany); -int skypiax_pipe_write(int pipe, short *buf, int howmany); -#endif /* WIN32 */ -int skypiax_close_socket(unsigned int fd); -private_t *find_available_skypiax_interface(void); -int remote_party_is_ringing(private_t * tech_pvt); -int remote_party_is_early_media(private_t * tech_pvt); -#define SKYPIAX_STATE_DOWN AST_STATE_DOWN -#define SKYPIAX_STATE_RING AST_STATE_RING -#define SKYPIAX_STATE_DIALING AST_STATE_DIALING -#define SKYPIAX_STATE_BUSY AST_STATE_BUSY -#define SKYPIAX_STATE_UP AST_STATE_UP -#define SKYPIAX_STATE_RINGING AST_STATE_RINGING -#define SKYPIAX_STATE_PRERING AST_STATE_PRERING -#define SKYPIAX_STATE_RESERVED AST_STATE_RESERVED -#define SKYPIAX_STATE_HANGUP_REQUESTED 200 -#endif /* _SKYPIAX_H_ */ diff --git a/src/mod/endpoints/mod_skypopen/old-stuff/dummy.c b/src/mod/endpoints/mod_skypopen/old-stuff/dummy.c deleted file mode 100644 index 1a369dcc4f..0000000000 --- a/src/mod/endpoints/mod_skypopen/old-stuff/dummy.c +++ /dev/null @@ -1,821 +0,0 @@ -/* - * Dummy soundcard - * Copyright (c) by Jaroslav Kysela - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - -MODULE_AUTHOR("Jaroslav Kysela "); -MODULE_DESCRIPTION("Dummy soundcard (/dev/null)"); -MODULE_LICENSE("GPL"); -MODULE_SUPPORTED_DEVICE("{{ALSA,Dummy soundcard}}"); - -#define MAX_PCM_DEVICES 4 -#define MAX_PCM_SUBSTREAMS 128 -#define MAX_MIDI_DEVICES 2 - - -/* defaults */ -#ifndef MAX_BUFFER_SIZE -#define MAX_BUFFER_SIZE (64*1024) -#endif -#ifndef MAX_PERIOD_SIZE -#define MAX_PERIOD_SIZE MAX_BUFFER_SIZE -#endif -#ifndef USE_FORMATS -#define USE_FORMATS (SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE) -#endif -#ifndef USE_RATE -#define USE_RATE SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000 -#define USE_RATE_MIN 5500 -#define USE_RATE_MAX 48000 -#endif -#ifndef USE_CHANNELS_MIN -#define USE_CHANNELS_MIN 1 -#endif -#ifndef USE_CHANNELS_MAX -#define USE_CHANNELS_MAX 2 -#endif -#ifndef USE_PERIODS_MIN -#define USE_PERIODS_MIN 10 -#endif -#ifndef USE_PERIODS_MAX -#define USE_PERIODS_MAX 1024 -#endif -#ifndef add_playback_constraints -#define add_playback_constraints(x) 0 -#endif -#ifndef add_capture_constraints -#define add_capture_constraints(x) 0 -#endif - -static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ -static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ -static int enable[SNDRV_CARDS] = { 1,[1 ... (SNDRV_CARDS - 1)] = 0 }; -static int pcm_devs[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1 }; -static int pcm_substreams[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 128 }; - - -module_param_array(index, int, NULL, 0444); -MODULE_PARM_DESC(index, "Index value for dummy soundcard."); -module_param_array(id, charp, NULL, 0444); -MODULE_PARM_DESC(id, "ID string for dummy soundcard."); -module_param_array(enable, bool, NULL, 0444); -MODULE_PARM_DESC(enable, "Enable this dummy soundcard."); -module_param_array(pcm_devs, int, NULL, 0444); -MODULE_PARM_DESC(pcm_devs, "PCM devices # (0-4) for dummy driver."); -module_param_array(pcm_substreams, int, NULL, 0444); -MODULE_PARM_DESC(pcm_substreams, "PCM substreams # (1-64) for dummy driver."); - -static struct platform_device *devices[SNDRV_CARDS]; -static struct timer_list dummytimer; -static int dummystarted = 0; -static int dummyindex = 0; -static spinlock_t dummylock; -struct dummydpcm { - struct snd_pcm_substream *substream; - struct snd_dummy_pcm *dpcm; - int started; - int elapsed; -}; -static struct dummydpcm dummydpcms[MAX_PCM_SUBSTREAMS]; - -#define MIXER_ADDR_MASTER 0 -#define MIXER_ADDR_LINE 1 -#define MIXER_ADDR_MIC 2 -#define MIXER_ADDR_SYNTH 3 -#define MIXER_ADDR_CD 4 -#define MIXER_ADDR_LAST 4 - -static void snd_card_dummy_pcm_timer_function(unsigned long data); -struct snd_dummy { - struct snd_card *card; - struct snd_pcm *pcm; - spinlock_t mixer_lock; - int mixer_volume[MIXER_ADDR_LAST + 1][2]; - int capture_source[MIXER_ADDR_LAST + 1][2]; -}; - -struct snd_dummy_pcm { - struct snd_dummy *dummy; - //spinlock_t lock; - //struct timer_list timer; - unsigned int pcm_buffer_size; - unsigned int pcm_period_size; - unsigned int pcm_bps; /* bytes per second */ - unsigned int pcm_hz; /* HZ */ - unsigned int pcm_irq_pos; /* IRQ position */ - unsigned int pcm_buf_pos; /* position in buffer */ - struct snd_pcm_substream *substream; -}; - - -static inline void snd_card_dummy_pcm_timer_start(struct snd_dummy_pcm *dpcm) -{ - int i; - int found = 0; - - for (i = 0; i < dummyindex + 1; i++) { - //if (i > MAX_PCM_SUBSTREAMS || dummyindex > MAX_PCM_SUBSTREAMS) { - //printk("dummy, %s:%d, i=%d, dummyindex=%d dpcm=%p\n", __FILE__, __LINE__, i, dummyindex, dpcm); - //} - - if (dummydpcms[i].dpcm == dpcm) { - dummydpcms[i].started = 1; - found = 1; - } - } - //if (!found) { - //printk("skypopen: start, NOT found?\n"); - //} -} - -static inline void snd_card_dummy_pcm_timer_stop(struct snd_dummy_pcm *dpcm) -{ - int i; - int found = 0; - - for (i = 0; i < dummyindex + 1; i++) { - - //if (i > MAX_PCM_SUBSTREAMS || dummyindex > MAX_PCM_SUBSTREAMS) { - //printk("dummy, %s:%d, i=%d, dummyindex=%d dpcm=%p\n", __FILE__, __LINE__, i, dummyindex, dpcm); - //} - if (dummydpcms[i].dpcm == dpcm) { - dummydpcms[i].started = 0; - dummydpcms[i].elapsed = 0; - found = 1; - } - } - if (!found) { - } else { - } -} - -static int snd_card_dummy_pcm_trigger(struct snd_pcm_substream *substream, int cmd) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct snd_dummy_pcm *dpcm = runtime->private_data; - int err = 0; - - spin_lock_bh(&dummylock); - switch (cmd) { - case SNDRV_PCM_TRIGGER_START: - case SNDRV_PCM_TRIGGER_RESUME: - snd_card_dummy_pcm_timer_start(dpcm); - break; - case SNDRV_PCM_TRIGGER_STOP: - case SNDRV_PCM_TRIGGER_SUSPEND: - snd_card_dummy_pcm_timer_stop(dpcm); - break; - default: - err = -EINVAL; - break; - } - spin_unlock_bh(&dummylock); - return 0; -} - -static int snd_card_dummy_pcm_prepare(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct snd_dummy_pcm *dpcm = runtime->private_data; - int bps; - - bps = snd_pcm_format_width(runtime->format) * runtime->rate * runtime->channels / 8; - - if (bps <= 0) - return -EINVAL; - - dpcm->pcm_bps = bps; - dpcm->pcm_hz = HZ; - dpcm->pcm_buffer_size = snd_pcm_lib_buffer_bytes(substream); - dpcm->pcm_period_size = snd_pcm_lib_period_bytes(substream); - dpcm->pcm_irq_pos = 0; - dpcm->pcm_buf_pos = 0; - snd_pcm_format_set_silence(runtime->format, runtime->dma_area, bytes_to_samples(runtime, runtime->dma_bytes)); - - return 0; -} - -static void snd_card_dummy_pcm_timer_function(unsigned long data) -{ - struct snd_dummy_pcm *dpcm = NULL; - int i; - - - dummytimer.expires = 1 + jiffies; - add_timer(&dummytimer); - - //spin_lock_bh(&dummylock); - for (i = 0; i < dummyindex + 1; i++) { - -#if 0 - if (i > MAX_PCM_SUBSTREAMS || dummyindex > MAX_PCM_SUBSTREAMS) { - printk("dummy, %s:%d, i=%d, dummyindex=%d dpcm=%p\n", __FILE__, __LINE__, i, dummyindex, dpcm); - } -#endif - if (dummydpcms[i].started != 1) - continue; - dpcm = dummydpcms[i].dpcm; -#if 0 - if (dpcm == NULL) { - printk("dummy: timer_func %d %d NULL: continue\n", __LINE__, i); - continue; - } -#endif - //spin_lock_bh(&dpcm->lock); - dpcm->pcm_irq_pos += dpcm->pcm_bps * 1; - dpcm->pcm_buf_pos += dpcm->pcm_bps * 1; - dpcm->pcm_buf_pos %= dpcm->pcm_buffer_size * dpcm->pcm_hz; - if (dpcm->pcm_irq_pos >= dpcm->pcm_period_size * dpcm->pcm_hz) { - dpcm->pcm_irq_pos %= dpcm->pcm_period_size * dpcm->pcm_hz; - //spin_unlock_bh(&dpcm->lock); - //snd_pcm_period_elapsed(dpcm->substream); - dummydpcms[i].elapsed = 1; - } else { - //spin_unlock_bh(&dpcm->lock); - } - } - //spin_unlock_bh(&dummylock); - for (i = 0; i < dummyindex + 1; i++) { - -#if 0 - if (i > MAX_PCM_SUBSTREAMS || dummyindex > MAX_PCM_SUBSTREAMS) { - printk("dummy, %s:%d, i=%d, dummyindex=%d dpcm=%p\n", __FILE__, __LINE__, i, dummyindex, dpcm); - } -#endif - if (dummydpcms[i].started != 1) - continue; - dpcm = dummydpcms[i].dpcm; -#if 0 - if (dpcm == NULL) { - printk("dummy: timer_func %d %d NULL: continue\n", __LINE__, i); - continue; - } -#endif - if (dummydpcms[i].elapsed){ - snd_pcm_period_elapsed(dpcm->substream); - dummydpcms[i].elapsed = 0; - } - } - -} - -static snd_pcm_uframes_t snd_card_dummy_pcm_pointer(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct snd_dummy_pcm *dpcm = runtime->private_data; - - //return bytes_to_frames(runtime, dpcm->pcm_buf_pos / dpcm->pcm_hz); - return (dpcm->pcm_buf_pos / dpcm->pcm_hz) / 2; -} - -static struct snd_pcm_hardware snd_card_dummy_playback = { - .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID), - //.info = (SNDRV_PCM_INFO_INTERLEAVED), - .formats = USE_FORMATS, - .rates = USE_RATE, - .rate_min = USE_RATE_MIN, - .rate_max = USE_RATE_MAX, - .channels_min = USE_CHANNELS_MIN, - .channels_max = USE_CHANNELS_MAX, - .buffer_bytes_max = MAX_BUFFER_SIZE, - //.period_bytes_min = 256, - .period_bytes_min = 2048, - .period_bytes_max = MAX_PERIOD_SIZE, - .periods_min = USE_PERIODS_MIN, - .periods_max = USE_PERIODS_MAX, - .fifo_size = 0, -}; - -static struct snd_pcm_hardware snd_card_dummy_capture = { - .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID), - //.info = (SNDRV_PCM_INFO_INTERLEAVED), - .formats = USE_FORMATS, - .rates = USE_RATE, - .rate_min = USE_RATE_MIN, - .rate_max = USE_RATE_MAX, - .channels_min = USE_CHANNELS_MIN, - .channels_max = USE_CHANNELS_MAX, - .buffer_bytes_max = MAX_BUFFER_SIZE, - //.period_bytes_min = 256, - .period_bytes_min = 2048, - .period_bytes_max = MAX_PERIOD_SIZE, - .periods_min = USE_PERIODS_MIN, - .periods_max = USE_PERIODS_MAX, - .fifo_size = 0, -}; - -static void snd_card_dummy_runtime_free(struct snd_pcm_runtime *runtime) -{ - int i; - - spin_lock_bh(&dummylock); - - for (i = 0; i < dummyindex; i++) { - - if (i > MAX_PCM_SUBSTREAMS || dummyindex > MAX_PCM_SUBSTREAMS) { - printk("dummy, %s:%d, i=%d, dummyindex=%d \n", __FILE__, __LINE__, i, dummyindex); - } - if ((dummydpcms[i].dpcm == runtime->private_data)) { - dummydpcms[i].started = 0; - dummydpcms[i].elapsed = 0; - } else { - } - } - - spin_unlock_bh(&dummylock); - kfree(runtime->private_data); -} - -static int snd_card_dummy_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *hw_params) -{ - return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params)); -} - -static int snd_card_dummy_hw_free(struct snd_pcm_substream *substream) -{ - return snd_pcm_lib_free_pages(substream); -} - -static struct snd_dummy_pcm *new_pcm_stream(struct snd_pcm_substream *substream) -{ - struct snd_dummy_pcm *dpcm; - int i; - int found = 0; - - dpcm = kzalloc(sizeof(*dpcm), GFP_KERNEL); - if (!dpcm) { - printk("dummy, %s:%d, dummyindex=%d NO MEMORY!!!!\n", __FILE__, __LINE__, dummyindex); - return dpcm; - } - //init_timer(&dpcm->timer); - //spin_lock_init(&dpcm->lock); - dpcm->substream = substream; - - spin_lock_bh(&dummylock); - for (i = 0; i < dummyindex; i++) { - - //if (i > MAX_PCM_SUBSTREAMS || dummyindex > MAX_PCM_SUBSTREAMS) { - //printk("dummy, %s:%d, i=%d, dummyindex=%d dpcm=%p\n", __FILE__, __LINE__, i, dummyindex, dpcm); - //} - if ((dummydpcms[i].substream == substream)) { - found = 1; - break; - } - - } - - if (!found) { - - dummydpcms[dummyindex].substream = substream; - dummyindex++; - } - - - - found = 0; - for (i = 0; i < dummyindex; i++) { - - //if (i > MAX_PCM_SUBSTREAMS || dummyindex > MAX_PCM_SUBSTREAMS) { - //printk("dummy, %s:%d, i=%d, dummyindex=%d dpcm=%p\n", __FILE__, __LINE__, i, dummyindex, dpcm); - //} - if (dummydpcms[i].substream == substream) { - dummydpcms[i].dpcm = dpcm; - dummydpcms[i].started = 0; - dummydpcms[i].elapsed = 0; - found = 1; - break; - } - - } - - spin_unlock_bh(&dummylock); - //if (!found) { - //printk("skypopen dummyindex=%d NOT found????\n", dummyindex); - //} - return dpcm; -} - -static int snd_card_dummy_playback_open(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct snd_dummy_pcm *dpcm; - int err; - - if ((dpcm = new_pcm_stream(substream)) == NULL) - return -ENOMEM; - runtime->private_data = dpcm; - /* makes the infrastructure responsible for freeing dpcm */ - runtime->private_free = snd_card_dummy_runtime_free; - runtime->hw = snd_card_dummy_playback; - if (substream->pcm->device & 1) { - runtime->hw.info &= ~SNDRV_PCM_INFO_INTERLEAVED; - runtime->hw.info |= SNDRV_PCM_INFO_NONINTERLEAVED; - } - if (substream->pcm->device & 2) - runtime->hw.info &= ~(SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID); - err = add_playback_constraints(runtime); - if (err < 0) - return err; - - return 0; -} - -static int snd_card_dummy_capture_open(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct snd_dummy_pcm *dpcm; - int err; - - if ((dpcm = new_pcm_stream(substream)) == NULL) - return -ENOMEM; - runtime->private_data = dpcm; - /* makes the infrastructure responsible for freeing dpcm */ - runtime->private_free = snd_card_dummy_runtime_free; - runtime->hw = snd_card_dummy_capture; - if (substream->pcm->device == 1) { - runtime->hw.info &= ~SNDRV_PCM_INFO_INTERLEAVED; - runtime->hw.info |= SNDRV_PCM_INFO_NONINTERLEAVED; - } - if (substream->pcm->device & 2) - runtime->hw.info &= ~(SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_MMAP_VALID); - err = add_capture_constraints(runtime); - if (err < 0) - return err; - - return 0; -} - -static int snd_card_dummy_playback_close(struct snd_pcm_substream *substream) -{ - snd_card_dummy_pcm_timer_stop(substream->private_data); - return 0; -} - -static int snd_card_dummy_capture_close(struct snd_pcm_substream *substream) -{ - snd_card_dummy_pcm_timer_stop(substream->private_data); - return 0; -} - -static struct snd_pcm_ops snd_card_dummy_playback_ops = { - .open = snd_card_dummy_playback_open, - .close = snd_card_dummy_playback_close, - .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_card_dummy_hw_params, - .hw_free = snd_card_dummy_hw_free, - .prepare = snd_card_dummy_pcm_prepare, - .trigger = snd_card_dummy_pcm_trigger, - .pointer = snd_card_dummy_pcm_pointer, -}; - -static struct snd_pcm_ops snd_card_dummy_capture_ops = { - .open = snd_card_dummy_capture_open, - .close = snd_card_dummy_capture_close, - .ioctl = snd_pcm_lib_ioctl, - .hw_params = snd_card_dummy_hw_params, - .hw_free = snd_card_dummy_hw_free, - .prepare = snd_card_dummy_pcm_prepare, - .trigger = snd_card_dummy_pcm_trigger, - .pointer = snd_card_dummy_pcm_pointer, -}; - -static int __devinit snd_card_dummy_pcm(struct snd_dummy *dummy, int device, int substreams) -{ - struct snd_pcm *pcm; - int err; - - err = snd_pcm_new(dummy->card, "Dummy PCM", device, substreams, substreams, &pcm); - if (err < 0) - return err; - dummy->pcm = pcm; - snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &snd_card_dummy_playback_ops); - snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &snd_card_dummy_capture_ops); - pcm->private_data = dummy; - pcm->info_flags = 0; - strcpy(pcm->name, "Dummy PCM"); - snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS, snd_dma_continuous_data(GFP_KERNEL), 128 * 1024, 1024 * 1024); - - return 0; -} - -#define DUMMY_VOLUME(xname, xindex, addr) \ -{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \ - .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ, \ - .name = xname, .index = xindex, \ - .info = snd_dummy_volume_info, \ - .get = snd_dummy_volume_get, .put = snd_dummy_volume_put, \ - .private_value = addr, \ - .tlv = { .p = db_scale_dummy } } - -static int snd_dummy_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *uinfo) -{ - uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; - uinfo->count = 2; - uinfo->value.integer.min = -50; - uinfo->value.integer.max = 100; - return 0; -} - -static int snd_dummy_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) -{ - struct snd_dummy *dummy = snd_kcontrol_chip(kcontrol); - int addr = kcontrol->private_value; - - if (in_irq()) - printk("dummy: line %d we are in HARDWARE IRQ\n", __LINE__); - spin_lock_bh(&dummy->mixer_lock); - ucontrol->value.integer.value[0] = dummy->mixer_volume[addr][0]; - ucontrol->value.integer.value[1] = dummy->mixer_volume[addr][1]; - spin_unlock_bh(&dummy->mixer_lock); - return 0; -} - -static int snd_dummy_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) -{ - struct snd_dummy *dummy = snd_kcontrol_chip(kcontrol); - int change, addr = kcontrol->private_value; - int left, right; - - if (in_irq()) - printk("dummy: line %d we are in HARDWARE IRQ\n", __LINE__); - left = ucontrol->value.integer.value[0]; - if (left < -50) - left = -50; - if (left > 100) - left = 100; - right = ucontrol->value.integer.value[1]; - if (right < -50) - right = -50; - if (right > 100) - right = 100; - spin_lock_bh(&dummy->mixer_lock); - change = dummy->mixer_volume[addr][0] != left || dummy->mixer_volume[addr][1] != right; - dummy->mixer_volume[addr][0] = left; - dummy->mixer_volume[addr][1] = right; - spin_unlock_bh(&dummy->mixer_lock); - return change; -} - -static const DECLARE_TLV_DB_SCALE(db_scale_dummy, -4500, 30, 0); - -#define DUMMY_CAPSRC(xname, xindex, addr) \ -{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \ - .info = snd_dummy_capsrc_info, \ - .get = snd_dummy_capsrc_get, .put = snd_dummy_capsrc_put, \ - .private_value = addr } - -#define snd_dummy_capsrc_info snd_ctl_boolean_stereo_info - -static int snd_dummy_capsrc_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) -{ - struct snd_dummy *dummy = snd_kcontrol_chip(kcontrol); - int addr = kcontrol->private_value; - - if (in_irq()) - printk("dummy: line %d we are in HARDWARE IRQ\n", __LINE__); - spin_lock_bh(&dummy->mixer_lock); - ucontrol->value.integer.value[0] = dummy->capture_source[addr][0]; - ucontrol->value.integer.value[1] = dummy->capture_source[addr][1]; - spin_unlock_bh(&dummy->mixer_lock); - return 0; -} - -static int snd_dummy_capsrc_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol) -{ - struct snd_dummy *dummy = snd_kcontrol_chip(kcontrol); - int change, addr = kcontrol->private_value; - int left, right; - - if (in_irq()) - printk("dummy: line %d we are in HARDWARE IRQ\n", __LINE__); - left = ucontrol->value.integer.value[0] & 1; - right = ucontrol->value.integer.value[1] & 1; - spin_lock_bh(&dummy->mixer_lock); - change = dummy->capture_source[addr][0] != left && dummy->capture_source[addr][1] != right; - dummy->capture_source[addr][0] = left; - dummy->capture_source[addr][1] = right; - spin_unlock_bh(&dummy->mixer_lock); - return change; -} - -static struct snd_kcontrol_new snd_dummy_controls[] = { - DUMMY_VOLUME("Master Volume", 0, MIXER_ADDR_MASTER), - DUMMY_CAPSRC("Master Capture Switch", 0, MIXER_ADDR_MASTER), - DUMMY_VOLUME("Synth Volume", 0, MIXER_ADDR_SYNTH), - DUMMY_CAPSRC("Synth Capture Switch", 0, MIXER_ADDR_SYNTH), - DUMMY_VOLUME("Line Volume", 0, MIXER_ADDR_LINE), - DUMMY_CAPSRC("Line Capture Switch", 0, MIXER_ADDR_LINE), - DUMMY_VOLUME("Mic Volume", 0, MIXER_ADDR_MIC), - DUMMY_CAPSRC("Mic Capture Switch", 0, MIXER_ADDR_MIC), - DUMMY_VOLUME("CD Volume", 0, MIXER_ADDR_CD), - DUMMY_CAPSRC("CD Capture Switch", 0, MIXER_ADDR_CD) -}; - -static int __devinit snd_card_dummy_new_mixer(struct snd_dummy *dummy) -{ - struct snd_card *card = dummy->card; - unsigned int idx; - int err; - - return 0; //XXX no mixer - spin_lock_init(&dummy->mixer_lock); - strcpy(card->mixername, "Dummy Mixer"); - - for (idx = 0; idx < ARRAY_SIZE(snd_dummy_controls); idx++) { - err = snd_ctl_add(card, snd_ctl_new1(&snd_dummy_controls[idx], dummy)); - if (err < 0) - return err; - } - return 0; -} - -static int __devinit snd_dummy_probe(struct platform_device *devptr) -{ - struct snd_card *card; - struct snd_dummy *dummy; - int idx, err; - int dev = devptr->id; - - err = snd_card_create(index[dev], id[dev], THIS_MODULE, - sizeof(struct snd_dummy), &card); - if (err < 0) - return err; - - dummy = card->private_data; - dummy->card = card; - for (idx = 0; idx < MAX_PCM_DEVICES && idx < pcm_devs[dev]; idx++) { - if (pcm_substreams[dev] < 1) - pcm_substreams[dev] = 1; - if (pcm_substreams[dev] > MAX_PCM_SUBSTREAMS) - pcm_substreams[dev] = MAX_PCM_SUBSTREAMS; - err = snd_card_dummy_pcm(dummy, idx, pcm_substreams[dev]); - if (err < 0) - goto __nodev; - } - //err = snd_card_dummy_new_mixer(dummy); - //if (err < 0) - //goto __nodev; - strcpy(card->driver, "Dummy"); - strcpy(card->shortname, "Dummy"); - sprintf(card->longname, "Dummy %i", dev + 1); - - snd_card_set_dev(card, &devptr->dev); - - err = snd_card_register(card); - if (err == 0) { - platform_set_drvdata(devptr, card); - return 0; - } - __nodev: - snd_card_free(card); - return err; -} - -static int __devexit snd_dummy_remove(struct platform_device *devptr) -{ - - del_timer(&dummytimer); - snd_card_free(platform_get_drvdata(devptr)); - platform_set_drvdata(devptr, NULL); - return 0; -} - -#ifdef CONFIG_PM -static int snd_dummy_suspend(struct platform_device *pdev, pm_message_t state) -{ - struct snd_card *card = platform_get_drvdata(pdev); - struct snd_dummy *dummy = card->private_data; - - snd_power_change_state(card, SNDRV_CTL_POWER_D3hot); - snd_pcm_suspend_all(dummy->pcm); - return 0; -} - -static int snd_dummy_resume(struct platform_device *pdev) -{ - struct snd_card *card = platform_get_drvdata(pdev); - - snd_power_change_state(card, SNDRV_CTL_POWER_D0); - return 0; -} -#endif - -#define SND_DUMMY_DRIVER "snd_dummy" - -static struct platform_driver snd_dummy_driver = { - .probe = snd_dummy_probe, - .remove = __devexit_p(snd_dummy_remove), -#ifdef CONFIG_PM - .suspend = snd_dummy_suspend, - .resume = snd_dummy_resume, -#endif - .driver = { - .name = SND_DUMMY_DRIVER}, -}; - -static void snd_dummy_unregister_all(void) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(devices); ++i) - platform_device_unregister(devices[i]); - platform_driver_unregister(&snd_dummy_driver); -} - -static int __init alsa_card_dummy_init(void) -{ - int i, cards, err; - - err = platform_driver_register(&snd_dummy_driver); - if (err < 0) - return err; - - if (!dummystarted) { - dummystarted = 1; - spin_lock_init(&dummylock); - - spin_lock_bh(&dummylock); - for (i = 0; i < MAX_PCM_SUBSTREAMS; i++) { - - //if (i > MAX_PCM_SUBSTREAMS || dummyindex > MAX_PCM_SUBSTREAMS) { - //printk("dummy, %s:%d, i=%d, dummyindex=%d \n", __FILE__, __LINE__, i, dummyindex); - //} - dummydpcms[i].substream = NULL; - dummydpcms[i].dpcm = NULL; - dummydpcms[i].started = 0; - dummydpcms[i].elapsed = 0; - } - init_timer(&dummytimer); - dummytimer.data = (unsigned long) &dummydpcms; - dummytimer.function = snd_card_dummy_pcm_timer_function; - dummytimer.expires = 1 + jiffies; - add_timer(&dummytimer); - printk("snd-dummy skypopen driver version: 9, %s:%d working on a machine with %dHZ kernel\n", __FILE__, __LINE__, HZ); - spin_unlock_bh(&dummylock); - } - - - cards = 0; - for (i = 0; i < SNDRV_CARDS; i++) { - struct platform_device *device; - if (!enable[i]) - continue; - device = platform_device_register_simple(SND_DUMMY_DRIVER, i, NULL, 0); - if (IS_ERR(device)) - continue; - if (!platform_get_drvdata(device)) { - platform_device_unregister(device); - continue; - } - devices[i] = device; - cards++; - } - if (!cards) { -#ifdef MODULE - printk(KERN_ERR "Dummy soundcard not found or device busy\n"); -#endif - snd_dummy_unregister_all(); - return -ENODEV; - } - return 0; -} - -static void __exit alsa_card_dummy_exit(void) -{ - del_timer(&dummytimer); - snd_dummy_unregister_all(); -} - -module_init(alsa_card_dummy_init) - module_exit(alsa_card_dummy_exit) diff --git a/src/mod/endpoints/mod_skypopen/old-stuff/pcm_lib.c b/src/mod/endpoints/mod_skypopen/old-stuff/pcm_lib.c deleted file mode 100644 index 3155bf05e9..0000000000 --- a/src/mod/endpoints/mod_skypopen/old-stuff/pcm_lib.c +++ /dev/null @@ -1,2182 +0,0 @@ -/* - * Digital Audio (PCM) abstract layer - * Copyright (c) by Jaroslav Kysela - * Abramo Bagnara - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * fill ring buffer with silence - * runtime->silence_start: starting pointer to silence area - * runtime->silence_filled: size filled with silence - * runtime->silence_threshold: threshold from application - * runtime->silence_size: maximal size from application - * - * when runtime->silence_size >= runtime->boundary - fill processed area with silence immediately - */ -void snd_pcm_playback_silence(struct snd_pcm_substream *substream, snd_pcm_uframes_t new_hw_ptr) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - snd_pcm_uframes_t frames, ofs, transfer; - - if (runtime->silence_size < runtime->boundary) { - snd_pcm_sframes_t noise_dist, n; - if (runtime->silence_start != runtime->control->appl_ptr) { - n = runtime->control->appl_ptr - runtime->silence_start; - if (n < 0) - n += runtime->boundary; - if ((snd_pcm_uframes_t)n < runtime->silence_filled) - runtime->silence_filled -= n; - else - runtime->silence_filled = 0; - runtime->silence_start = runtime->control->appl_ptr; - } - if (runtime->silence_filled >= runtime->buffer_size) - return; - noise_dist = snd_pcm_playback_hw_avail(runtime) + runtime->silence_filled; - if (noise_dist >= (snd_pcm_sframes_t) runtime->silence_threshold) - return; - frames = runtime->silence_threshold - noise_dist; - if (frames > runtime->silence_size) - frames = runtime->silence_size; - } else { - if (new_hw_ptr == ULONG_MAX) { /* initialization */ - snd_pcm_sframes_t avail = snd_pcm_playback_hw_avail(runtime); - runtime->silence_filled = avail > 0 ? avail : 0; - runtime->silence_start = (runtime->status->hw_ptr + - runtime->silence_filled) % - runtime->boundary; - } else { - ofs = runtime->status->hw_ptr; - frames = new_hw_ptr - ofs; - if ((snd_pcm_sframes_t)frames < 0) - frames += runtime->boundary; - runtime->silence_filled -= frames; - if ((snd_pcm_sframes_t)runtime->silence_filled < 0) { - runtime->silence_filled = 0; - runtime->silence_start = new_hw_ptr; - } else { - runtime->silence_start = ofs; - } - } - frames = runtime->buffer_size - runtime->silence_filled; - } - if (snd_BUG_ON(frames > runtime->buffer_size)) - return; - if (frames == 0) - return; - ofs = runtime->silence_start % runtime->buffer_size; - while (frames > 0) { - transfer = ofs + frames > runtime->buffer_size ? runtime->buffer_size - ofs : frames; - if (runtime->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED || - runtime->access == SNDRV_PCM_ACCESS_MMAP_INTERLEAVED) { - if (substream->ops->silence) { - int err; - err = substream->ops->silence(substream, -1, ofs, transfer); - snd_BUG_ON(err < 0); - } else { - char *hwbuf = runtime->dma_area + frames_to_bytes(runtime, ofs); - snd_pcm_format_set_silence(runtime->format, hwbuf, transfer * runtime->channels); - } - } else { - unsigned int c; - unsigned int channels = runtime->channels; - if (substream->ops->silence) { - for (c = 0; c < channels; ++c) { - int err; - err = substream->ops->silence(substream, c, ofs, transfer); - snd_BUG_ON(err < 0); - } - } else { - size_t dma_csize = runtime->dma_bytes / channels; - for (c = 0; c < channels; ++c) { - char *hwbuf = runtime->dma_area + (c * dma_csize) + samples_to_bytes(runtime, ofs); - snd_pcm_format_set_silence(runtime->format, hwbuf, transfer); - } - } - } - runtime->silence_filled += transfer; - frames -= transfer; - ofs = 0; - } -} - -static void pcm_debug_name(struct snd_pcm_substream *substream, - char *name, size_t len) -{ - snprintf(name, len, "pcmC%dD%d%c:%d", - substream->pcm->card->number, - substream->pcm->device, - substream->stream ? 'c' : 'p', - substream->number); -} - -#define XRUN_DEBUG_BASIC (1<<0) -#define XRUN_DEBUG_STACK (1<<1) /* dump also stack */ -#define XRUN_DEBUG_JIFFIESCHECK (1<<2) /* do jiffies check */ -#define XRUN_DEBUG_PERIODUPDATE (1<<3) /* full period update info */ -#define XRUN_DEBUG_HWPTRUPDATE (1<<4) /* full hwptr update info */ -#define XRUN_DEBUG_LOG (1<<5) /* show last 10 positions on err */ -#define XRUN_DEBUG_LOGONCE (1<<6) /* do above only once */ - -#ifdef CONFIG_SND_PCM_XRUN_DEBUG - -#define xrun_debug(substream, mask) \ - ((substream)->pstr->xrun_debug & (mask)) -#else -#define xrun_debug(substream, mask) 0 -#endif - -#define dump_stack_on_xrun(substream) do { \ - if (xrun_debug(substream, XRUN_DEBUG_STACK)) \ - dump_stack(); \ - } while (0) - -static void xrun(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - - if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) - snd_pcm_gettime(runtime, (struct timespec *)&runtime->status->tstamp); - snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN); - if (xrun_debug(substream, XRUN_DEBUG_BASIC)) { - char name[16]; - pcm_debug_name(substream, name, sizeof(name)); - snd_printd(KERN_DEBUG "XRUN: %s\n", name); - dump_stack_on_xrun(substream); - } -} - -#ifdef CONFIG_SND_PCM_XRUN_DEBUG -#define hw_ptr_error(substream, fmt, args...) \ - do { \ - if (xrun_debug(substream, XRUN_DEBUG_BASIC)) { \ - xrun_log_show(substream); \ - if (printk_ratelimit()) { \ - snd_printd("PCM: " fmt, ##args); \ - } \ - dump_stack_on_xrun(substream); \ - } \ - } while (0) - -#define XRUN_LOG_CNT 10 - -struct hwptr_log_entry { - unsigned long jiffies; - snd_pcm_uframes_t pos; - snd_pcm_uframes_t period_size; - snd_pcm_uframes_t buffer_size; - snd_pcm_uframes_t old_hw_ptr; - snd_pcm_uframes_t hw_ptr_base; -}; - -struct snd_pcm_hwptr_log { - unsigned int idx; - unsigned int hit: 1; - struct hwptr_log_entry entries[XRUN_LOG_CNT]; -}; - -static void xrun_log(struct snd_pcm_substream *substream, - snd_pcm_uframes_t pos) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct snd_pcm_hwptr_log *log = runtime->hwptr_log; - struct hwptr_log_entry *entry; - - if (log == NULL) { - log = kzalloc(sizeof(*log), GFP_ATOMIC); - if (log == NULL) - return; - runtime->hwptr_log = log; - } else { - if (xrun_debug(substream, XRUN_DEBUG_LOGONCE) && log->hit) - return; - } - entry = &log->entries[log->idx]; - entry->jiffies = jiffies; - entry->pos = pos; - entry->period_size = runtime->period_size; - entry->buffer_size = runtime->buffer_size;; - entry->old_hw_ptr = runtime->status->hw_ptr; - entry->hw_ptr_base = runtime->hw_ptr_base; - log->idx = (log->idx + 1) % XRUN_LOG_CNT; -} - -static void xrun_log_show(struct snd_pcm_substream *substream) -{ - struct snd_pcm_hwptr_log *log = substream->runtime->hwptr_log; - struct hwptr_log_entry *entry; - char name[16]; - unsigned int idx; - int cnt; - - if (log == NULL) - return; - if (xrun_debug(substream, XRUN_DEBUG_LOGONCE) && log->hit) - return; - pcm_debug_name(substream, name, sizeof(name)); - for (cnt = 0, idx = log->idx; cnt < XRUN_LOG_CNT; cnt++) { - entry = &log->entries[idx]; - if (entry->period_size == 0) - break; - snd_printd("hwptr log: %s: j=%lu, pos=%ld/%ld/%ld, " - "hwptr=%ld/%ld\n", - name, entry->jiffies, (unsigned long)entry->pos, - (unsigned long)entry->period_size, - (unsigned long)entry->buffer_size, - (unsigned long)entry->old_hw_ptr, - (unsigned long)entry->hw_ptr_base); - idx++; - idx %= XRUN_LOG_CNT; - } - log->hit = 1; -} - -#else /* ! CONFIG_SND_PCM_XRUN_DEBUG */ - -#define hw_ptr_error(substream, fmt, args...) do { } while (0) -#define xrun_log(substream, pos) do { } while (0) -#define xrun_log_show(substream) do { } while (0) - -#endif - -int snd_pcm_update_state(struct snd_pcm_substream *substream, - struct snd_pcm_runtime *runtime) -{ - snd_pcm_uframes_t avail; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - avail = snd_pcm_playback_avail(runtime); - else - avail = snd_pcm_capture_avail(runtime); - if (avail > runtime->avail_max) - runtime->avail_max = avail; - if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) { - if (avail >= runtime->buffer_size) { - snd_pcm_drain_done(substream); - return -EPIPE; - } - } else { - if (avail >= runtime->stop_threshold) { - xrun(substream); - return -EPIPE; - } - } - if (avail >= runtime->control->avail_min) - wake_up(runtime->twake ? &runtime->tsleep : &runtime->sleep); - return 0; -} - -static int snd_pcm_update_hw_ptr0(struct snd_pcm_substream *substream, - unsigned int in_interrupt) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - snd_pcm_uframes_t pos; - snd_pcm_uframes_t old_hw_ptr, new_hw_ptr, hw_base; - snd_pcm_sframes_t hdelta, delta; - unsigned long jdelta; - - old_hw_ptr = runtime->status->hw_ptr; - pos = substream->ops->pointer(substream); - if (pos == SNDRV_PCM_POS_XRUN) { - xrun(substream); - return -EPIPE; - } - if (pos >= runtime->buffer_size) { - if (printk_ratelimit()) { - char name[16]; - pcm_debug_name(substream, name, sizeof(name)); - xrun_log_show(substream); - snd_printd(KERN_ERR "BUG: %s, pos = %ld, " - "buffer size = %ld, period size = %ld\n", - name, pos, runtime->buffer_size, - runtime->period_size); - } - pos = 0; - } - pos -= pos % runtime->min_align; - if (xrun_debug(substream, XRUN_DEBUG_LOG)) - xrun_log(substream, pos); - hw_base = runtime->hw_ptr_base; - new_hw_ptr = hw_base + pos; - if (in_interrupt) { - /* we know that one period was processed */ - /* delta = "expected next hw_ptr" for in_interrupt != 0 */ - delta = runtime->hw_ptr_interrupt + runtime->period_size; - if (delta > new_hw_ptr) { - hw_base += runtime->buffer_size; - if (hw_base >= runtime->boundary) - hw_base = 0; - new_hw_ptr = hw_base + pos; - goto __delta; - } - } - /* new_hw_ptr might be lower than old_hw_ptr in case when */ - /* pointer crosses the end of the ring buffer */ - if (new_hw_ptr < old_hw_ptr) { - hw_base += runtime->buffer_size; - if (hw_base >= runtime->boundary) - hw_base = 0; - new_hw_ptr = hw_base + pos; - } - __delta: - delta = (new_hw_ptr - old_hw_ptr) % runtime->boundary; - if (xrun_debug(substream, in_interrupt ? - XRUN_DEBUG_PERIODUPDATE : XRUN_DEBUG_HWPTRUPDATE)) { - char name[16]; - pcm_debug_name(substream, name, sizeof(name)); - snd_printd("%s_update: %s: pos=%u/%u/%u, " - "hwptr=%ld/%ld/%ld/%ld\n", - in_interrupt ? "period" : "hwptr", - name, - (unsigned int)pos, - (unsigned int)runtime->period_size, - (unsigned int)runtime->buffer_size, - (unsigned long)delta, - (unsigned long)old_hw_ptr, - (unsigned long)new_hw_ptr, - (unsigned long)runtime->hw_ptr_base); - } - /* something must be really wrong */ - if (delta >= runtime->buffer_size + runtime->period_size) { - hw_ptr_error(substream, - "Unexpected hw_pointer value %s" - "(stream=%i, pos=%ld, new_hw_ptr=%ld, " - "old_hw_ptr=%ld)\n", - in_interrupt ? "[Q] " : "[P]", - substream->stream, (long)pos, - (long)new_hw_ptr, (long)old_hw_ptr); - return 0; - } - - /* Do jiffies check only in xrun_debug mode */ - if (!xrun_debug(substream, XRUN_DEBUG_JIFFIESCHECK)) - goto no_jiffies_check; - - /* Skip the jiffies check for hardwares with BATCH flag. - * Such hardware usually just increases the position at each IRQ, - * thus it can't give any strange position. - */ - if (runtime->hw.info & SNDRV_PCM_INFO_BATCH) - goto no_jiffies_check; - hdelta = delta; - if (hdelta < runtime->delay) - goto no_jiffies_check; - hdelta -= runtime->delay; - jdelta = jiffies - runtime->hw_ptr_jiffies; - if (((hdelta * HZ) / runtime->rate) > jdelta + HZ/100) { - delta = jdelta / - (((runtime->period_size * HZ) / runtime->rate) - + HZ/100); - /* move new_hw_ptr according jiffies not pos variable */ - new_hw_ptr = old_hw_ptr; - hw_base = delta; - /* use loop to avoid checks for delta overflows */ - /* the delta value is small or zero in most cases */ - while (delta > 0) { - new_hw_ptr += runtime->period_size; - if (new_hw_ptr >= runtime->boundary) - new_hw_ptr -= runtime->boundary; - delta--; - } - /* align hw_base to buffer_size */ - hw_ptr_error(substream, - "hw_ptr skipping! %s" - "(pos=%ld, delta=%ld, period=%ld, " - "jdelta=%lu/%lu/%lu, hw_ptr=%ld/%ld)\n", - in_interrupt ? "[Q] " : "", - (long)pos, (long)hdelta, - (long)runtime->period_size, jdelta, - ((hdelta * HZ) / runtime->rate), hw_base, - (unsigned long)old_hw_ptr, - (unsigned long)new_hw_ptr); - /* reset values to proper state */ - delta = 0; - hw_base = new_hw_ptr - (new_hw_ptr % runtime->buffer_size); - } - no_jiffies_check: - if (delta > runtime->period_size + runtime->period_size / 2) { - hw_ptr_error(substream, - "Lost interrupts? %s" - "(stream=%i, delta=%ld, new_hw_ptr=%ld, " - "old_hw_ptr=%ld)\n", - in_interrupt ? "[Q] " : "", - substream->stream, (long)delta, - (long)new_hw_ptr, - (long)old_hw_ptr); - } - - if (runtime->status->hw_ptr == new_hw_ptr) - return 0; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && - runtime->silence_size > 0) - snd_pcm_playback_silence(substream, new_hw_ptr); - - if (in_interrupt) { - runtime->hw_ptr_interrupt = new_hw_ptr - - (new_hw_ptr % runtime->period_size); - } - runtime->hw_ptr_base = hw_base; - runtime->status->hw_ptr = new_hw_ptr; - runtime->hw_ptr_jiffies = jiffies; - if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) - snd_pcm_gettime(runtime, (struct timespec *)&runtime->status->tstamp); - - return snd_pcm_update_state(substream, runtime); -} - -/* CAUTION: call it with irq disabled */ -int snd_pcm_update_hw_ptr(struct snd_pcm_substream *substream) -{ - return snd_pcm_update_hw_ptr0(substream, 0); -} - -/** - * snd_pcm_set_ops - set the PCM operators - * @pcm: the pcm instance - * @direction: stream direction, SNDRV_PCM_STREAM_XXX - * @ops: the operator table - * - * Sets the given PCM operators to the pcm instance. - */ -void snd_pcm_set_ops(struct snd_pcm *pcm, int direction, struct snd_pcm_ops *ops) -{ - struct snd_pcm_str *stream = &pcm->streams[direction]; - struct snd_pcm_substream *substream; - - for (substream = stream->substream; substream != NULL; substream = substream->next) - substream->ops = ops; -} - -EXPORT_SYMBOL(snd_pcm_set_ops); - -/** - * snd_pcm_sync - set the PCM sync id - * @substream: the pcm substream - * - * Sets the PCM sync identifier for the card. - */ -void snd_pcm_set_sync(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - - runtime->sync.id32[0] = substream->pcm->card->number; - runtime->sync.id32[1] = -1; - runtime->sync.id32[2] = -1; - runtime->sync.id32[3] = -1; -} - -EXPORT_SYMBOL(snd_pcm_set_sync); - -/* - * Standard ioctl routine - */ - -static inline unsigned int div32(unsigned int a, unsigned int b, - unsigned int *r) -{ - if (b == 0) { - *r = 0; - return UINT_MAX; - } - *r = a % b; - return a / b; -} - -static inline unsigned int div_down(unsigned int a, unsigned int b) -{ - if (b == 0) - return UINT_MAX; - return a / b; -} - -static inline unsigned int div_up(unsigned int a, unsigned int b) -{ - unsigned int r; - unsigned int q; - if (b == 0) - return UINT_MAX; - q = div32(a, b, &r); - if (r) - ++q; - return q; -} - -static inline unsigned int mul(unsigned int a, unsigned int b) -{ - if (a == 0) - return 0; - if (div_down(UINT_MAX, a) < b) - return UINT_MAX; - return a * b; -} - -static inline unsigned int muldiv32(unsigned int a, unsigned int b, - unsigned int c, unsigned int *r) -{ - uint64_t n = (u_int64_t) a * b; - if (c == 0) { - snd_BUG_ON(!n); - *r = 0; - return UINT_MAX; - } - n = div_u64_rem(n, c, r); - if (n >= UINT_MAX) { - *r = 0; - return UINT_MAX; - } - return n; -} - -/** - * snd_interval_refine - refine the interval value of configurator - * @i: the interval value to refine - * @v: the interval value to refer to - * - * Refines the interval value with the reference value. - * The interval is changed to the range satisfying both intervals. - * The interval status (min, max, integer, etc.) are evaluated. - * - * Returns non-zero if the value is changed, zero if not changed. - */ -int snd_interval_refine(struct snd_interval *i, const struct snd_interval *v) -{ - int changed = 0; - if (snd_BUG_ON(snd_interval_empty(i))) - return -EINVAL; - if (i->min < v->min) { - i->min = v->min; - i->openmin = v->openmin; - changed = 1; - } else if (i->min == v->min && !i->openmin && v->openmin) { - i->openmin = 1; - changed = 1; - } - if (i->max > v->max) { - i->max = v->max; - i->openmax = v->openmax; - changed = 1; - } else if (i->max == v->max && !i->openmax && v->openmax) { - i->openmax = 1; - changed = 1; - } - if (!i->integer && v->integer) { - i->integer = 1; - changed = 1; - } - if (i->integer) { - if (i->openmin) { - i->min++; - i->openmin = 0; - } - if (i->openmax) { - i->max--; - i->openmax = 0; - } - } else if (!i->openmin && !i->openmax && i->min == i->max) - i->integer = 1; - if (snd_interval_checkempty(i)) { - snd_interval_none(i); - return -EINVAL; - } - return changed; -} - -EXPORT_SYMBOL(snd_interval_refine); - -static int snd_interval_refine_first(struct snd_interval *i) -{ - if (snd_BUG_ON(snd_interval_empty(i))) - return -EINVAL; - if (snd_interval_single(i)) - return 0; - i->max = i->min; - i->openmax = i->openmin; - if (i->openmax) - i->max++; - return 1; -} - -static int snd_interval_refine_last(struct snd_interval *i) -{ - if (snd_BUG_ON(snd_interval_empty(i))) - return -EINVAL; - if (snd_interval_single(i)) - return 0; - i->min = i->max; - i->openmin = i->openmax; - if (i->openmin) - i->min--; - return 1; -} - -void snd_interval_mul(const struct snd_interval *a, const struct snd_interval *b, struct snd_interval *c) -{ - if (a->empty || b->empty) { - snd_interval_none(c); - return; - } - c->empty = 0; - c->min = mul(a->min, b->min); - c->openmin = (a->openmin || b->openmin); - c->max = mul(a->max, b->max); - c->openmax = (a->openmax || b->openmax); - c->integer = (a->integer && b->integer); -} - -/** - * snd_interval_div - refine the interval value with division - * @a: dividend - * @b: divisor - * @c: quotient - * - * c = a / b - * - * Returns non-zero if the value is changed, zero if not changed. - */ -void snd_interval_div(const struct snd_interval *a, const struct snd_interval *b, struct snd_interval *c) -{ - unsigned int r; - if (a->empty || b->empty) { - snd_interval_none(c); - return; - } - c->empty = 0; - c->min = div32(a->min, b->max, &r); - c->openmin = (r || a->openmin || b->openmax); - if (b->min > 0) { - c->max = div32(a->max, b->min, &r); - if (r) { - c->max++; - c->openmax = 1; - } else - c->openmax = (a->openmax || b->openmin); - } else { - c->max = UINT_MAX; - c->openmax = 0; - } - c->integer = 0; -} - -/** - * snd_interval_muldivk - refine the interval value - * @a: dividend 1 - * @b: dividend 2 - * @k: divisor (as integer) - * @c: result - * - * c = a * b / k - * - * Returns non-zero if the value is changed, zero if not changed. - */ -void snd_interval_muldivk(const struct snd_interval *a, const struct snd_interval *b, - unsigned int k, struct snd_interval *c) -{ - unsigned int r; - if (a->empty || b->empty) { - snd_interval_none(c); - return; - } - c->empty = 0; - c->min = muldiv32(a->min, b->min, k, &r); - c->openmin = (r || a->openmin || b->openmin); - c->max = muldiv32(a->max, b->max, k, &r); - if (r) { - c->max++; - c->openmax = 1; - } else - c->openmax = (a->openmax || b->openmax); - c->integer = 0; -} - -/** - * snd_interval_mulkdiv - refine the interval value - * @a: dividend 1 - * @k: dividend 2 (as integer) - * @b: divisor - * @c: result - * - * c = a * k / b - * - * Returns non-zero if the value is changed, zero if not changed. - */ -void snd_interval_mulkdiv(const struct snd_interval *a, unsigned int k, - const struct snd_interval *b, struct snd_interval *c) -{ - unsigned int r; - if (a->empty || b->empty) { - snd_interval_none(c); - return; - } - c->empty = 0; - c->min = muldiv32(a->min, k, b->max, &r); - c->openmin = (r || a->openmin || b->openmax); - if (b->min > 0) { - c->max = muldiv32(a->max, k, b->min, &r); - if (r) { - c->max++; - c->openmax = 1; - } else - c->openmax = (a->openmax || b->openmin); - } else { - c->max = UINT_MAX; - c->openmax = 0; - } - c->integer = 0; -} - -/* ---- */ - - -/** - * snd_interval_ratnum - refine the interval value - * @i: interval to refine - * @rats_count: number of ratnum_t - * @rats: ratnum_t array - * @nump: pointer to store the resultant numerator - * @denp: pointer to store the resultant denominator - * - * Returns non-zero if the value is changed, zero if not changed. - */ -int snd_interval_ratnum(struct snd_interval *i, - unsigned int rats_count, struct snd_ratnum *rats, - unsigned int *nump, unsigned int *denp) -{ - unsigned int best_num, best_den; - int best_diff; - unsigned int k; - struct snd_interval t; - int err; - unsigned int result_num, result_den; - int result_diff; - - best_num = best_den = best_diff = 0; - for (k = 0; k < rats_count; ++k) { - unsigned int num = rats[k].num; - unsigned int den; - unsigned int q = i->min; - int diff; - if (q == 0) - q = 1; - den = div_up(num, q); - if (den < rats[k].den_min) - continue; - if (den > rats[k].den_max) - den = rats[k].den_max; - else { - unsigned int r; - r = (den - rats[k].den_min) % rats[k].den_step; - if (r != 0) - den -= r; - } - diff = num - q * den; - if (diff < 0) - diff = -diff; - if (best_num == 0 || - diff * best_den < best_diff * den) { - best_diff = diff; - best_den = den; - best_num = num; - } - } - if (best_den == 0) { - i->empty = 1; - return -EINVAL; - } - t.min = div_down(best_num, best_den); - t.openmin = !!(best_num % best_den); - - result_num = best_num; - result_diff = best_diff; - result_den = best_den; - best_num = best_den = best_diff = 0; - for (k = 0; k < rats_count; ++k) { - unsigned int num = rats[k].num; - unsigned int den; - unsigned int q = i->max; - int diff; - if (q == 0) { - i->empty = 1; - return -EINVAL; - } - den = div_down(num, q); - if (den > rats[k].den_max) - continue; - if (den < rats[k].den_min) - den = rats[k].den_min; - else { - unsigned int r; - r = (den - rats[k].den_min) % rats[k].den_step; - if (r != 0) - den += rats[k].den_step - r; - } - diff = q * den - num; - if (diff < 0) - diff = -diff; - if (best_num == 0 || - diff * best_den < best_diff * den) { - best_diff = diff; - best_den = den; - best_num = num; - } - } - if (best_den == 0) { - i->empty = 1; - return -EINVAL; - } - t.max = div_up(best_num, best_den); - t.openmax = !!(best_num % best_den); - t.integer = 0; - err = snd_interval_refine(i, &t); - if (err < 0) - return err; - - if (snd_interval_single(i)) { - if (best_diff * result_den < result_diff * best_den) { - result_num = best_num; - result_den = best_den; - } - if (nump) - *nump = result_num; - if (denp) - *denp = result_den; - } - return err; -} - -EXPORT_SYMBOL(snd_interval_ratnum); - -/** - * snd_interval_ratden - refine the interval value - * @i: interval to refine - * @rats_count: number of struct ratden - * @rats: struct ratden array - * @nump: pointer to store the resultant numerator - * @denp: pointer to store the resultant denominator - * - * Returns non-zero if the value is changed, zero if not changed. - */ -static int snd_interval_ratden(struct snd_interval *i, - unsigned int rats_count, struct snd_ratden *rats, - unsigned int *nump, unsigned int *denp) -{ - unsigned int best_num, best_diff, best_den; - unsigned int k; - struct snd_interval t; - int err; - - best_num = best_den = best_diff = 0; - for (k = 0; k < rats_count; ++k) { - unsigned int num; - unsigned int den = rats[k].den; - unsigned int q = i->min; - int diff; - num = mul(q, den); - if (num > rats[k].num_max) - continue; - if (num < rats[k].num_min) - num = rats[k].num_max; - else { - unsigned int r; - r = (num - rats[k].num_min) % rats[k].num_step; - if (r != 0) - num += rats[k].num_step - r; - } - diff = num - q * den; - if (best_num == 0 || - diff * best_den < best_diff * den) { - best_diff = diff; - best_den = den; - best_num = num; - } - } - if (best_den == 0) { - i->empty = 1; - return -EINVAL; - } - t.min = div_down(best_num, best_den); - t.openmin = !!(best_num % best_den); - - best_num = best_den = best_diff = 0; - for (k = 0; k < rats_count; ++k) { - unsigned int num; - unsigned int den = rats[k].den; - unsigned int q = i->max; - int diff; - num = mul(q, den); - if (num < rats[k].num_min) - continue; - if (num > rats[k].num_max) - num = rats[k].num_max; - else { - unsigned int r; - r = (num - rats[k].num_min) % rats[k].num_step; - if (r != 0) - num -= r; - } - diff = q * den - num; - if (best_num == 0 || - diff * best_den < best_diff * den) { - best_diff = diff; - best_den = den; - best_num = num; - } - } - if (best_den == 0) { - i->empty = 1; - return -EINVAL; - } - t.max = div_up(best_num, best_den); - t.openmax = !!(best_num % best_den); - t.integer = 0; - err = snd_interval_refine(i, &t); - if (err < 0) - return err; - - if (snd_interval_single(i)) { - if (nump) - *nump = best_num; - if (denp) - *denp = best_den; - } - return err; -} - -/** - * snd_interval_list - refine the interval value from the list - * @i: the interval value to refine - * @count: the number of elements in the list - * @list: the value list - * @mask: the bit-mask to evaluate - * - * Refines the interval value from the list. - * When mask is non-zero, only the elements corresponding to bit 1 are - * evaluated. - * - * Returns non-zero if the value is changed, zero if not changed. - */ -int snd_interval_list(struct snd_interval *i, unsigned int count, unsigned int *list, unsigned int mask) -{ - unsigned int k; - struct snd_interval list_range; - - if (!count) { - i->empty = 1; - return -EINVAL; - } - snd_interval_any(&list_range); - list_range.min = UINT_MAX; - list_range.max = 0; - for (k = 0; k < count; k++) { - if (mask && !(mask & (1 << k))) - continue; - if (!snd_interval_test(i, list[k])) - continue; - list_range.min = min(list_range.min, list[k]); - list_range.max = max(list_range.max, list[k]); - } - return snd_interval_refine(i, &list_range); -} - -EXPORT_SYMBOL(snd_interval_list); - -static int snd_interval_step(struct snd_interval *i, unsigned int min, unsigned int step) -{ - unsigned int n; - int changed = 0; - n = (i->min - min) % step; - if (n != 0 || i->openmin) { - i->min += step - n; - changed = 1; - } - n = (i->max - min) % step; - if (n != 0 || i->openmax) { - i->max -= n; - changed = 1; - } - if (snd_interval_checkempty(i)) { - i->empty = 1; - return -EINVAL; - } - return changed; -} - -/* Info constraints helpers */ - -/** - * snd_pcm_hw_rule_add - add the hw-constraint rule - * @runtime: the pcm runtime instance - * @cond: condition bits - * @var: the variable to evaluate - * @func: the evaluation function - * @private: the private data pointer passed to function - * @dep: the dependent variables - * - * Returns zero if successful, or a negative error code on failure. - */ -int snd_pcm_hw_rule_add(struct snd_pcm_runtime *runtime, unsigned int cond, - int var, - snd_pcm_hw_rule_func_t func, void *private, - int dep, ...) -{ - struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; - struct snd_pcm_hw_rule *c; - unsigned int k; - va_list args; - va_start(args, dep); - if (constrs->rules_num >= constrs->rules_all) { - struct snd_pcm_hw_rule *new; - unsigned int new_rules = constrs->rules_all + 16; - new = kcalloc(new_rules, sizeof(*c), GFP_KERNEL); - if (!new) - return -ENOMEM; - if (constrs->rules) { - memcpy(new, constrs->rules, - constrs->rules_num * sizeof(*c)); - kfree(constrs->rules); - } - constrs->rules = new; - constrs->rules_all = new_rules; - } - c = &constrs->rules[constrs->rules_num]; - c->cond = cond; - c->func = func; - c->var = var; - c->private = private; - k = 0; - while (1) { - if (snd_BUG_ON(k >= ARRAY_SIZE(c->deps))) - return -EINVAL; - c->deps[k++] = dep; - if (dep < 0) - break; - dep = va_arg(args, int); - } - constrs->rules_num++; - va_end(args); - return 0; -} - -EXPORT_SYMBOL(snd_pcm_hw_rule_add); - -/** - * snd_pcm_hw_constraint_mask - apply the given bitmap mask constraint - * @runtime: PCM runtime instance - * @var: hw_params variable to apply the mask - * @mask: the bitmap mask - * - * Apply the constraint of the given bitmap mask to a 32-bit mask parameter. - */ -int snd_pcm_hw_constraint_mask(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var, - uint32_t mask) -{ - struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; - struct snd_mask *maskp = constrs_mask(constrs, var); - *maskp->bits &= mask; - memset(maskp->bits + 1, 0, (SNDRV_MASK_MAX-32) / 8); /* clear rest */ - if (*maskp->bits == 0) - return -EINVAL; - return 0; -} - -/** - * snd_pcm_hw_constraint_mask64 - apply the given bitmap mask constraint - * @runtime: PCM runtime instance - * @var: hw_params variable to apply the mask - * @mask: the 64bit bitmap mask - * - * Apply the constraint of the given bitmap mask to a 64-bit mask parameter. - */ -int snd_pcm_hw_constraint_mask64(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var, - uint64_t mask) -{ - struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; - struct snd_mask *maskp = constrs_mask(constrs, var); - maskp->bits[0] &= (uint32_t)mask; - maskp->bits[1] &= (uint32_t)(mask >> 32); - memset(maskp->bits + 2, 0, (SNDRV_MASK_MAX-64) / 8); /* clear rest */ - if (! maskp->bits[0] && ! maskp->bits[1]) - return -EINVAL; - return 0; -} - -/** - * snd_pcm_hw_constraint_integer - apply an integer constraint to an interval - * @runtime: PCM runtime instance - * @var: hw_params variable to apply the integer constraint - * - * Apply the constraint of integer to an interval parameter. - */ -int snd_pcm_hw_constraint_integer(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var) -{ - struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; - return snd_interval_setinteger(constrs_interval(constrs, var)); -} - -EXPORT_SYMBOL(snd_pcm_hw_constraint_integer); - -/** - * snd_pcm_hw_constraint_minmax - apply a min/max range constraint to an interval - * @runtime: PCM runtime instance - * @var: hw_params variable to apply the range - * @min: the minimal value - * @max: the maximal value - * - * Apply the min/max range constraint to an interval parameter. - */ -int snd_pcm_hw_constraint_minmax(struct snd_pcm_runtime *runtime, snd_pcm_hw_param_t var, - unsigned int min, unsigned int max) -{ - struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; - struct snd_interval t; - t.min = min; - t.max = max; - t.openmin = t.openmax = 0; - t.integer = 0; - return snd_interval_refine(constrs_interval(constrs, var), &t); -} - -EXPORT_SYMBOL(snd_pcm_hw_constraint_minmax); - -static int snd_pcm_hw_rule_list(struct snd_pcm_hw_params *params, - struct snd_pcm_hw_rule *rule) -{ - struct snd_pcm_hw_constraint_list *list = rule->private; - return snd_interval_list(hw_param_interval(params, rule->var), list->count, list->list, list->mask); -} - - -/** - * snd_pcm_hw_constraint_list - apply a list of constraints to a parameter - * @runtime: PCM runtime instance - * @cond: condition bits - * @var: hw_params variable to apply the list constraint - * @l: list - * - * Apply the list of constraints to an interval parameter. - */ -int snd_pcm_hw_constraint_list(struct snd_pcm_runtime *runtime, - unsigned int cond, - snd_pcm_hw_param_t var, - struct snd_pcm_hw_constraint_list *l) -{ - return snd_pcm_hw_rule_add(runtime, cond, var, - snd_pcm_hw_rule_list, l, - var, -1); -} - -EXPORT_SYMBOL(snd_pcm_hw_constraint_list); - -static int snd_pcm_hw_rule_ratnums(struct snd_pcm_hw_params *params, - struct snd_pcm_hw_rule *rule) -{ - struct snd_pcm_hw_constraint_ratnums *r = rule->private; - unsigned int num = 0, den = 0; - int err; - err = snd_interval_ratnum(hw_param_interval(params, rule->var), - r->nrats, r->rats, &num, &den); - if (err >= 0 && den && rule->var == SNDRV_PCM_HW_PARAM_RATE) { - params->rate_num = num; - params->rate_den = den; - } - return err; -} - -/** - * snd_pcm_hw_constraint_ratnums - apply ratnums constraint to a parameter - * @runtime: PCM runtime instance - * @cond: condition bits - * @var: hw_params variable to apply the ratnums constraint - * @r: struct snd_ratnums constriants - */ -int snd_pcm_hw_constraint_ratnums(struct snd_pcm_runtime *runtime, - unsigned int cond, - snd_pcm_hw_param_t var, - struct snd_pcm_hw_constraint_ratnums *r) -{ - return snd_pcm_hw_rule_add(runtime, cond, var, - snd_pcm_hw_rule_ratnums, r, - var, -1); -} - -EXPORT_SYMBOL(snd_pcm_hw_constraint_ratnums); - -static int snd_pcm_hw_rule_ratdens(struct snd_pcm_hw_params *params, - struct snd_pcm_hw_rule *rule) -{ - struct snd_pcm_hw_constraint_ratdens *r = rule->private; - unsigned int num = 0, den = 0; - int err = snd_interval_ratden(hw_param_interval(params, rule->var), - r->nrats, r->rats, &num, &den); - if (err >= 0 && den && rule->var == SNDRV_PCM_HW_PARAM_RATE) { - params->rate_num = num; - params->rate_den = den; - } - return err; -} - -/** - * snd_pcm_hw_constraint_ratdens - apply ratdens constraint to a parameter - * @runtime: PCM runtime instance - * @cond: condition bits - * @var: hw_params variable to apply the ratdens constraint - * @r: struct snd_ratdens constriants - */ -int snd_pcm_hw_constraint_ratdens(struct snd_pcm_runtime *runtime, - unsigned int cond, - snd_pcm_hw_param_t var, - struct snd_pcm_hw_constraint_ratdens *r) -{ - return snd_pcm_hw_rule_add(runtime, cond, var, - snd_pcm_hw_rule_ratdens, r, - var, -1); -} - -EXPORT_SYMBOL(snd_pcm_hw_constraint_ratdens); - -static int snd_pcm_hw_rule_msbits(struct snd_pcm_hw_params *params, - struct snd_pcm_hw_rule *rule) -{ - unsigned int l = (unsigned long) rule->private; - int width = l & 0xffff; - unsigned int msbits = l >> 16; - struct snd_interval *i = hw_param_interval(params, SNDRV_PCM_HW_PARAM_SAMPLE_BITS); - if (snd_interval_single(i) && snd_interval_value(i) == width) - params->msbits = msbits; - return 0; -} - -/** - * snd_pcm_hw_constraint_msbits - add a hw constraint msbits rule - * @runtime: PCM runtime instance - * @cond: condition bits - * @width: sample bits width - * @msbits: msbits width - */ -int snd_pcm_hw_constraint_msbits(struct snd_pcm_runtime *runtime, - unsigned int cond, - unsigned int width, - unsigned int msbits) -{ - unsigned long l = (msbits << 16) | width; - return snd_pcm_hw_rule_add(runtime, cond, -1, - snd_pcm_hw_rule_msbits, - (void*) l, - SNDRV_PCM_HW_PARAM_SAMPLE_BITS, -1); -} - -EXPORT_SYMBOL(snd_pcm_hw_constraint_msbits); - -static int snd_pcm_hw_rule_step(struct snd_pcm_hw_params *params, - struct snd_pcm_hw_rule *rule) -{ - unsigned long step = (unsigned long) rule->private; - return snd_interval_step(hw_param_interval(params, rule->var), 0, step); -} - -/** - * snd_pcm_hw_constraint_step - add a hw constraint step rule - * @runtime: PCM runtime instance - * @cond: condition bits - * @var: hw_params variable to apply the step constraint - * @step: step size - */ -int snd_pcm_hw_constraint_step(struct snd_pcm_runtime *runtime, - unsigned int cond, - snd_pcm_hw_param_t var, - unsigned long step) -{ - return snd_pcm_hw_rule_add(runtime, cond, var, - snd_pcm_hw_rule_step, (void *) step, - var, -1); -} - -EXPORT_SYMBOL(snd_pcm_hw_constraint_step); - -static int snd_pcm_hw_rule_pow2(struct snd_pcm_hw_params *params, struct snd_pcm_hw_rule *rule) -{ - static unsigned int pow2_sizes[] = { - 1<<0, 1<<1, 1<<2, 1<<3, 1<<4, 1<<5, 1<<6, 1<<7, - 1<<8, 1<<9, 1<<10, 1<<11, 1<<12, 1<<13, 1<<14, 1<<15, - 1<<16, 1<<17, 1<<18, 1<<19, 1<<20, 1<<21, 1<<22, 1<<23, - 1<<24, 1<<25, 1<<26, 1<<27, 1<<28, 1<<29, 1<<30 - }; - return snd_interval_list(hw_param_interval(params, rule->var), - ARRAY_SIZE(pow2_sizes), pow2_sizes, 0); -} - -/** - * snd_pcm_hw_constraint_pow2 - add a hw constraint power-of-2 rule - * @runtime: PCM runtime instance - * @cond: condition bits - * @var: hw_params variable to apply the power-of-2 constraint - */ -int snd_pcm_hw_constraint_pow2(struct snd_pcm_runtime *runtime, - unsigned int cond, - snd_pcm_hw_param_t var) -{ - return snd_pcm_hw_rule_add(runtime, cond, var, - snd_pcm_hw_rule_pow2, NULL, - var, -1); -} - -EXPORT_SYMBOL(snd_pcm_hw_constraint_pow2); - -static void _snd_pcm_hw_param_any(struct snd_pcm_hw_params *params, - snd_pcm_hw_param_t var) -{ - if (hw_is_mask(var)) { - snd_mask_any(hw_param_mask(params, var)); - params->cmask |= 1 << var; - params->rmask |= 1 << var; - return; - } - if (hw_is_interval(var)) { - snd_interval_any(hw_param_interval(params, var)); - params->cmask |= 1 << var; - params->rmask |= 1 << var; - return; - } - snd_BUG(); -} - -void _snd_pcm_hw_params_any(struct snd_pcm_hw_params *params) -{ - unsigned int k; - memset(params, 0, sizeof(*params)); - for (k = SNDRV_PCM_HW_PARAM_FIRST_MASK; k <= SNDRV_PCM_HW_PARAM_LAST_MASK; k++) - _snd_pcm_hw_param_any(params, k); - for (k = SNDRV_PCM_HW_PARAM_FIRST_INTERVAL; k <= SNDRV_PCM_HW_PARAM_LAST_INTERVAL; k++) - _snd_pcm_hw_param_any(params, k); - params->info = ~0U; -} - -EXPORT_SYMBOL(_snd_pcm_hw_params_any); - -/** - * snd_pcm_hw_param_value - return @params field @var value - * @params: the hw_params instance - * @var: parameter to retrieve - * @dir: pointer to the direction (-1,0,1) or %NULL - * - * Return the value for field @var if it's fixed in configuration space - * defined by @params. Return -%EINVAL otherwise. - */ -int snd_pcm_hw_param_value(const struct snd_pcm_hw_params *params, - snd_pcm_hw_param_t var, int *dir) -{ - if (hw_is_mask(var)) { - const struct snd_mask *mask = hw_param_mask_c(params, var); - if (!snd_mask_single(mask)) - return -EINVAL; - if (dir) - *dir = 0; - return snd_mask_value(mask); - } - if (hw_is_interval(var)) { - const struct snd_interval *i = hw_param_interval_c(params, var); - if (!snd_interval_single(i)) - return -EINVAL; - if (dir) - *dir = i->openmin; - return snd_interval_value(i); - } - return -EINVAL; -} - -EXPORT_SYMBOL(snd_pcm_hw_param_value); - -void _snd_pcm_hw_param_setempty(struct snd_pcm_hw_params *params, - snd_pcm_hw_param_t var) -{ - if (hw_is_mask(var)) { - snd_mask_none(hw_param_mask(params, var)); - params->cmask |= 1 << var; - params->rmask |= 1 << var; - } else if (hw_is_interval(var)) { - snd_interval_none(hw_param_interval(params, var)); - params->cmask |= 1 << var; - params->rmask |= 1 << var; - } else { - snd_BUG(); - } -} - -EXPORT_SYMBOL(_snd_pcm_hw_param_setempty); - -static int _snd_pcm_hw_param_first(struct snd_pcm_hw_params *params, - snd_pcm_hw_param_t var) -{ - int changed; - if (hw_is_mask(var)) - changed = snd_mask_refine_first(hw_param_mask(params, var)); - else if (hw_is_interval(var)) - changed = snd_interval_refine_first(hw_param_interval(params, var)); - else - return -EINVAL; - if (changed) { - params->cmask |= 1 << var; - params->rmask |= 1 << var; - } - return changed; -} - - -/** - * snd_pcm_hw_param_first - refine config space and return minimum value - * @pcm: PCM instance - * @params: the hw_params instance - * @var: parameter to retrieve - * @dir: pointer to the direction (-1,0,1) or %NULL - * - * Inside configuration space defined by @params remove from @var all - * values > minimum. Reduce configuration space accordingly. - * Return the minimum. - */ -int snd_pcm_hw_param_first(struct snd_pcm_substream *pcm, - struct snd_pcm_hw_params *params, - snd_pcm_hw_param_t var, int *dir) -{ - int changed = _snd_pcm_hw_param_first(params, var); - if (changed < 0) - return changed; - if (params->rmask) { - int err = snd_pcm_hw_refine(pcm, params); - if (snd_BUG_ON(err < 0)) - return err; - } - return snd_pcm_hw_param_value(params, var, dir); -} - -EXPORT_SYMBOL(snd_pcm_hw_param_first); - -static int _snd_pcm_hw_param_last(struct snd_pcm_hw_params *params, - snd_pcm_hw_param_t var) -{ - int changed; - if (hw_is_mask(var)) - changed = snd_mask_refine_last(hw_param_mask(params, var)); - else if (hw_is_interval(var)) - changed = snd_interval_refine_last(hw_param_interval(params, var)); - else - return -EINVAL; - if (changed) { - params->cmask |= 1 << var; - params->rmask |= 1 << var; - } - return changed; -} - - -/** - * snd_pcm_hw_param_last - refine config space and return maximum value - * @pcm: PCM instance - * @params: the hw_params instance - * @var: parameter to retrieve - * @dir: pointer to the direction (-1,0,1) or %NULL - * - * Inside configuration space defined by @params remove from @var all - * values < maximum. Reduce configuration space accordingly. - * Return the maximum. - */ -int snd_pcm_hw_param_last(struct snd_pcm_substream *pcm, - struct snd_pcm_hw_params *params, - snd_pcm_hw_param_t var, int *dir) -{ - int changed = _snd_pcm_hw_param_last(params, var); - if (changed < 0) - return changed; - if (params->rmask) { - int err = snd_pcm_hw_refine(pcm, params); - if (snd_BUG_ON(err < 0)) - return err; - } - return snd_pcm_hw_param_value(params, var, dir); -} - -EXPORT_SYMBOL(snd_pcm_hw_param_last); - -/** - * snd_pcm_hw_param_choose - choose a configuration defined by @params - * @pcm: PCM instance - * @params: the hw_params instance - * - * Choose one configuration from configuration space defined by @params. - * The configuration chosen is that obtained fixing in this order: - * first access, first format, first subformat, min channels, - * min rate, min period time, max buffer size, min tick time - */ -int snd_pcm_hw_params_choose(struct snd_pcm_substream *pcm, - struct snd_pcm_hw_params *params) -{ - static int vars[] = { - SNDRV_PCM_HW_PARAM_ACCESS, - SNDRV_PCM_HW_PARAM_FORMAT, - SNDRV_PCM_HW_PARAM_SUBFORMAT, - SNDRV_PCM_HW_PARAM_CHANNELS, - SNDRV_PCM_HW_PARAM_RATE, - SNDRV_PCM_HW_PARAM_PERIOD_TIME, - SNDRV_PCM_HW_PARAM_BUFFER_SIZE, - SNDRV_PCM_HW_PARAM_TICK_TIME, - -1 - }; - int err, *v; - - for (v = vars; *v != -1; v++) { - if (*v != SNDRV_PCM_HW_PARAM_BUFFER_SIZE) - err = snd_pcm_hw_param_first(pcm, params, *v, NULL); - else - err = snd_pcm_hw_param_last(pcm, params, *v, NULL); - if (snd_BUG_ON(err < 0)) - return err; - } - return 0; -} - -static int snd_pcm_lib_ioctl_reset(struct snd_pcm_substream *substream, - void *arg) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - unsigned long flags; - snd_pcm_stream_lock_irqsave(substream, flags); - if (snd_pcm_running(substream) && - snd_pcm_update_hw_ptr(substream) >= 0) - runtime->status->hw_ptr %= runtime->buffer_size; - else - runtime->status->hw_ptr = 0; - snd_pcm_stream_unlock_irqrestore(substream, flags); - return 0; -} - -static int snd_pcm_lib_ioctl_channel_info(struct snd_pcm_substream *substream, - void *arg) -{ - struct snd_pcm_channel_info *info = arg; - struct snd_pcm_runtime *runtime = substream->runtime; - int width; - if (!(runtime->info & SNDRV_PCM_INFO_MMAP)) { - info->offset = -1; - return 0; - } - width = snd_pcm_format_physical_width(runtime->format); - if (width < 0) - return width; - info->offset = 0; - switch (runtime->access) { - case SNDRV_PCM_ACCESS_MMAP_INTERLEAVED: - case SNDRV_PCM_ACCESS_RW_INTERLEAVED: - info->first = info->channel * width; - info->step = runtime->channels * width; - break; - case SNDRV_PCM_ACCESS_MMAP_NONINTERLEAVED: - case SNDRV_PCM_ACCESS_RW_NONINTERLEAVED: - { - size_t size = runtime->dma_bytes / runtime->channels; - info->first = info->channel * size * 8; - info->step = width; - break; - } - default: - snd_BUG(); - break; - } - return 0; -} - -static int snd_pcm_lib_ioctl_fifo_size(struct snd_pcm_substream *substream, - void *arg) -{ - struct snd_pcm_hw_params *params = arg; - snd_pcm_format_t format; - int channels, width; - - params->fifo_size = substream->runtime->hw.fifo_size; - if (!(substream->runtime->hw.info & SNDRV_PCM_INFO_FIFO_IN_FRAMES)) { - format = params_format(params); - channels = params_channels(params); - width = snd_pcm_format_physical_width(format); - params->fifo_size /= width * channels; - } - return 0; -} - -/** - * snd_pcm_lib_ioctl - a generic PCM ioctl callback - * @substream: the pcm substream instance - * @cmd: ioctl command - * @arg: ioctl argument - * - * Processes the generic ioctl commands for PCM. - * Can be passed as the ioctl callback for PCM ops. - * - * Returns zero if successful, or a negative error code on failure. - */ -int snd_pcm_lib_ioctl(struct snd_pcm_substream *substream, - unsigned int cmd, void *arg) -{ - switch (cmd) { - case SNDRV_PCM_IOCTL1_INFO: - return 0; - case SNDRV_PCM_IOCTL1_RESET: - return snd_pcm_lib_ioctl_reset(substream, arg); - case SNDRV_PCM_IOCTL1_CHANNEL_INFO: - return snd_pcm_lib_ioctl_channel_info(substream, arg); - case SNDRV_PCM_IOCTL1_FIFO_SIZE: - return snd_pcm_lib_ioctl_fifo_size(substream, arg); - } - return -ENXIO; -} - -EXPORT_SYMBOL(snd_pcm_lib_ioctl); - -/** - * snd_pcm_period_elapsed - update the pcm status for the next period - * @substream: the pcm substream instance - * - * This function is called from the interrupt handler when the - * PCM has processed the period size. It will update the current - * pointer, wake up sleepers, etc. - * - * Even if more than one periods have elapsed since the last call, you - * have to call this only once. - */ -void snd_pcm_period_elapsed(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime; - unsigned long flags; - - if (PCM_RUNTIME_CHECK(substream)) - return; - runtime = substream->runtime; - - if (runtime->transfer_ack_begin) - runtime->transfer_ack_begin(substream); - - //giovanni snd_pcm_stream_lock_irqsave(substream, flags); //giovanni - if (!snd_pcm_running(substream) || - snd_pcm_update_hw_ptr0(substream, 1) < 0) - goto _end; - - if (substream->timer_running) - snd_timer_interrupt(substream->timer, 1); - _end: - //giovanni snd_pcm_stream_unlock_irqrestore(substream, flags); //giovanni - if (runtime->transfer_ack_end) - runtime->transfer_ack_end(substream); - kill_fasync(&runtime->fasync, SIGIO, POLL_IN); -} - -EXPORT_SYMBOL(snd_pcm_period_elapsed); - -/* - * Wait until avail_min data becomes available - * Returns a negative error code if any error occurs during operation. - * The available space is stored on availp. When err = 0 and avail = 0 - * on the capture stream, it indicates the stream is in DRAINING state. - */ -static int wait_for_avail_min(struct snd_pcm_substream *substream, - snd_pcm_uframes_t *availp) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - int is_playback = substream->stream == SNDRV_PCM_STREAM_PLAYBACK; - wait_queue_t wait; - int err = 0; - snd_pcm_uframes_t avail = 0; - long tout; - - init_waitqueue_entry(&wait, current); - add_wait_queue(&runtime->tsleep, &wait); - for (;;) { - if (signal_pending(current)) { - err = -ERESTARTSYS; - break; - } - set_current_state(TASK_INTERRUPTIBLE); - //giovanni snd_pcm_stream_unlock_irq(substream); - tout = schedule_timeout(msecs_to_jiffies(10000)); - //giovanni snd_pcm_stream_lock_irq(substream); - switch (runtime->status->state) { - case SNDRV_PCM_STATE_SUSPENDED: - err = -ESTRPIPE; - goto _endloop; - case SNDRV_PCM_STATE_XRUN: - err = -EPIPE; - goto _endloop; - case SNDRV_PCM_STATE_DRAINING: - if (is_playback) - err = -EPIPE; - else - avail = 0; /* indicate draining */ - goto _endloop; - case SNDRV_PCM_STATE_OPEN: - case SNDRV_PCM_STATE_SETUP: - case SNDRV_PCM_STATE_DISCONNECTED: - err = -EBADFD; - goto _endloop; - } - if (!tout) { - snd_printd("%s write error (DMA or IRQ trouble?)\n", - is_playback ? "playback" : "capture"); - err = -EIO; - break; - } - if (is_playback) - avail = snd_pcm_playback_avail(runtime); - else - avail = snd_pcm_capture_avail(runtime); - if (avail >= runtime->control->avail_min) - break; - } - _endloop: - remove_wait_queue(&runtime->tsleep, &wait); - *availp = avail; - return err; -} - -static int snd_pcm_lib_write_transfer(struct snd_pcm_substream *substream, - unsigned int hwoff, - unsigned long data, unsigned int off, - snd_pcm_uframes_t frames) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - int err; - char __user *buf = (char __user *) data + frames_to_bytes(runtime, off); - if (substream->ops->copy) { - if ((err = substream->ops->copy(substream, -1, hwoff, buf, frames)) < 0) - return err; - } else { - char *hwbuf = runtime->dma_area + frames_to_bytes(runtime, hwoff); - if (copy_from_user(hwbuf, buf, frames_to_bytes(runtime, frames))) - return -EFAULT; - } - return 0; -} - -typedef int (*transfer_f)(struct snd_pcm_substream *substream, unsigned int hwoff, - unsigned long data, unsigned int off, - snd_pcm_uframes_t size); - -static snd_pcm_sframes_t snd_pcm_lib_write1(struct snd_pcm_substream *substream, - unsigned long data, - snd_pcm_uframes_t size, - int nonblock, - transfer_f transfer) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - snd_pcm_uframes_t xfer = 0; - snd_pcm_uframes_t offset = 0; - int err = 0; - - if (size == 0) - return 0; - - //giovanni snd_pcm_stream_lock_irq(substream); - switch (runtime->status->state) { - case SNDRV_PCM_STATE_PREPARED: - case SNDRV_PCM_STATE_RUNNING: - case SNDRV_PCM_STATE_PAUSED: - break; - case SNDRV_PCM_STATE_XRUN: - err = -EPIPE; - goto _end_unlock; - case SNDRV_PCM_STATE_SUSPENDED: - err = -ESTRPIPE; - goto _end_unlock; - default: - err = -EBADFD; - goto _end_unlock; - } - - runtime->twake = 1; - while (size > 0) { - snd_pcm_uframes_t frames, appl_ptr, appl_ofs; - snd_pcm_uframes_t avail; - snd_pcm_uframes_t cont; - if (runtime->status->state == SNDRV_PCM_STATE_RUNNING) - snd_pcm_update_hw_ptr(substream); - avail = snd_pcm_playback_avail(runtime); - if (!avail) { - if (nonblock) { - err = -EAGAIN; - goto _end_unlock; - } - err = wait_for_avail_min(substream, &avail); - if (err < 0) - goto _end_unlock; - } - frames = size > avail ? avail : size; - cont = runtime->buffer_size - runtime->control->appl_ptr % runtime->buffer_size; - if (frames > cont) - frames = cont; - if (snd_BUG_ON(!frames)) { - runtime->twake = 0; - //giovanni snd_pcm_stream_unlock_irq(substream); - return -EINVAL; - } - appl_ptr = runtime->control->appl_ptr; - appl_ofs = appl_ptr % runtime->buffer_size; - //giovanni snd_pcm_stream_unlock_irq(substream); - err = transfer(substream, appl_ofs, data, offset, frames); - //giovanni snd_pcm_stream_lock_irq(substream); - if (err < 0) - goto _end_unlock; - switch (runtime->status->state) { - case SNDRV_PCM_STATE_XRUN: - err = -EPIPE; - goto _end_unlock; - case SNDRV_PCM_STATE_SUSPENDED: - err = -ESTRPIPE; - goto _end_unlock; - default: - break; - } - appl_ptr += frames; - if (appl_ptr >= runtime->boundary) - appl_ptr -= runtime->boundary; - runtime->control->appl_ptr = appl_ptr; - if (substream->ops->ack) - substream->ops->ack(substream); - - offset += frames; - size -= frames; - xfer += frames; - if (runtime->status->state == SNDRV_PCM_STATE_PREPARED && - snd_pcm_playback_hw_avail(runtime) >= (snd_pcm_sframes_t)runtime->start_threshold) { - err = snd_pcm_start(substream); - if (err < 0) - goto _end_unlock; - } - } - _end_unlock: - runtime->twake = 0; - if (xfer > 0 && err >= 0) - snd_pcm_update_state(substream, runtime); - //giovanni snd_pcm_stream_unlock_irq(substream); - return xfer > 0 ? (snd_pcm_sframes_t)xfer : err; -} - -/* sanity-check for read/write methods */ -static int pcm_sanity_check(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime; - if (PCM_RUNTIME_CHECK(substream)) - return -ENXIO; - runtime = substream->runtime; - if (snd_BUG_ON(!substream->ops->copy && !runtime->dma_area)) - return -EINVAL; - if (runtime->status->state == SNDRV_PCM_STATE_OPEN) - return -EBADFD; - return 0; -} - -snd_pcm_sframes_t snd_pcm_lib_write(struct snd_pcm_substream *substream, const void __user *buf, snd_pcm_uframes_t size) -{ - struct snd_pcm_runtime *runtime; - int nonblock; - int err; - - err = pcm_sanity_check(substream); - if (err < 0) - return err; - runtime = substream->runtime; - nonblock = !!(substream->f_flags & O_NONBLOCK); - - if (runtime->access != SNDRV_PCM_ACCESS_RW_INTERLEAVED && - runtime->channels > 1) - return -EINVAL; - return snd_pcm_lib_write1(substream, (unsigned long)buf, size, nonblock, - snd_pcm_lib_write_transfer); -} - -EXPORT_SYMBOL(snd_pcm_lib_write); - -static int snd_pcm_lib_writev_transfer(struct snd_pcm_substream *substream, - unsigned int hwoff, - unsigned long data, unsigned int off, - snd_pcm_uframes_t frames) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - int err; - void __user **bufs = (void __user **)data; - int channels = runtime->channels; - int c; - if (substream->ops->copy) { - if (snd_BUG_ON(!substream->ops->silence)) - return -EINVAL; - for (c = 0; c < channels; ++c, ++bufs) { - if (*bufs == NULL) { - if ((err = substream->ops->silence(substream, c, hwoff, frames)) < 0) - return err; - } else { - char __user *buf = *bufs + samples_to_bytes(runtime, off); - if ((err = substream->ops->copy(substream, c, hwoff, buf, frames)) < 0) - return err; - } - } - } else { - /* default transfer behaviour */ - size_t dma_csize = runtime->dma_bytes / channels; - for (c = 0; c < channels; ++c, ++bufs) { - char *hwbuf = runtime->dma_area + (c * dma_csize) + samples_to_bytes(runtime, hwoff); - if (*bufs == NULL) { - snd_pcm_format_set_silence(runtime->format, hwbuf, frames); - } else { - char __user *buf = *bufs + samples_to_bytes(runtime, off); - if (copy_from_user(hwbuf, buf, samples_to_bytes(runtime, frames))) - return -EFAULT; - } - } - } - return 0; -} - -snd_pcm_sframes_t snd_pcm_lib_writev(struct snd_pcm_substream *substream, - void __user **bufs, - snd_pcm_uframes_t frames) -{ - struct snd_pcm_runtime *runtime; - int nonblock; - int err; - - err = pcm_sanity_check(substream); - if (err < 0) - return err; - runtime = substream->runtime; - nonblock = !!(substream->f_flags & O_NONBLOCK); - - if (runtime->access != SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) - return -EINVAL; - return snd_pcm_lib_write1(substream, (unsigned long)bufs, frames, - nonblock, snd_pcm_lib_writev_transfer); -} - -EXPORT_SYMBOL(snd_pcm_lib_writev); - -static int snd_pcm_lib_read_transfer(struct snd_pcm_substream *substream, - unsigned int hwoff, - unsigned long data, unsigned int off, - snd_pcm_uframes_t frames) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - int err; - char __user *buf = (char __user *) data + frames_to_bytes(runtime, off); - if (substream->ops->copy) { - if ((err = substream->ops->copy(substream, -1, hwoff, buf, frames)) < 0) - return err; - } else { - char *hwbuf = runtime->dma_area + frames_to_bytes(runtime, hwoff); - if (copy_to_user(buf, hwbuf, frames_to_bytes(runtime, frames))) - return -EFAULT; - } - return 0; -} - -static snd_pcm_sframes_t snd_pcm_lib_read1(struct snd_pcm_substream *substream, - unsigned long data, - snd_pcm_uframes_t size, - int nonblock, - transfer_f transfer) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - snd_pcm_uframes_t xfer = 0; - snd_pcm_uframes_t offset = 0; - int err = 0; - - if (size == 0) - return 0; - - //giovanni snd_pcm_stream_lock_irq(substream); - switch (runtime->status->state) { - case SNDRV_PCM_STATE_PREPARED: - if (size >= runtime->start_threshold) { - err = snd_pcm_start(substream); - if (err < 0) - goto _end_unlock; - } - break; - case SNDRV_PCM_STATE_DRAINING: - case SNDRV_PCM_STATE_RUNNING: - case SNDRV_PCM_STATE_PAUSED: - break; - case SNDRV_PCM_STATE_XRUN: - err = -EPIPE; - goto _end_unlock; - case SNDRV_PCM_STATE_SUSPENDED: - err = -ESTRPIPE; - goto _end_unlock; - default: - err = -EBADFD; - goto _end_unlock; - } - - runtime->twake = 1; - while (size > 0) { - snd_pcm_uframes_t frames, appl_ptr, appl_ofs; - snd_pcm_uframes_t avail; - snd_pcm_uframes_t cont; - if (runtime->status->state == SNDRV_PCM_STATE_RUNNING) - snd_pcm_update_hw_ptr(substream); - avail = snd_pcm_capture_avail(runtime); - if (!avail) { - if (runtime->status->state == - SNDRV_PCM_STATE_DRAINING) { - snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); - goto _end_unlock; - } - if (nonblock) { - err = -EAGAIN; - goto _end_unlock; - } - err = wait_for_avail_min(substream, &avail); - if (err < 0) - goto _end_unlock; - if (!avail) - continue; /* draining */ - } - frames = size > avail ? avail : size; - cont = runtime->buffer_size - runtime->control->appl_ptr % runtime->buffer_size; - if (frames > cont) - frames = cont; - if (snd_BUG_ON(!frames)) { - runtime->twake = 0; - //giovanni snd_pcm_stream_unlock_irq(substream); - return -EINVAL; - } - appl_ptr = runtime->control->appl_ptr; - appl_ofs = appl_ptr % runtime->buffer_size; - //giovanni snd_pcm_stream_unlock_irq(substream); - err = transfer(substream, appl_ofs, data, offset, frames); - //giovanni snd_pcm_stream_lock_irq(substream); - if (err < 0) - goto _end_unlock; - switch (runtime->status->state) { - case SNDRV_PCM_STATE_XRUN: - err = -EPIPE; - goto _end_unlock; - case SNDRV_PCM_STATE_SUSPENDED: - err = -ESTRPIPE; - goto _end_unlock; - default: - break; - } - appl_ptr += frames; - if (appl_ptr >= runtime->boundary) - appl_ptr -= runtime->boundary; - runtime->control->appl_ptr = appl_ptr; - if (substream->ops->ack) - substream->ops->ack(substream); - - offset += frames; - size -= frames; - xfer += frames; - } - _end_unlock: - runtime->twake = 0; - if (xfer > 0 && err >= 0) - snd_pcm_update_state(substream, runtime); - //giovanni snd_pcm_stream_unlock_irq(substream); - return xfer > 0 ? (snd_pcm_sframes_t)xfer : err; -} - -snd_pcm_sframes_t snd_pcm_lib_read(struct snd_pcm_substream *substream, void __user *buf, snd_pcm_uframes_t size) -{ - struct snd_pcm_runtime *runtime; - int nonblock; - int err; - - err = pcm_sanity_check(substream); - if (err < 0) - return err; - runtime = substream->runtime; - nonblock = !!(substream->f_flags & O_NONBLOCK); - if (runtime->access != SNDRV_PCM_ACCESS_RW_INTERLEAVED) - return -EINVAL; - return snd_pcm_lib_read1(substream, (unsigned long)buf, size, nonblock, snd_pcm_lib_read_transfer); -} - -EXPORT_SYMBOL(snd_pcm_lib_read); - -static int snd_pcm_lib_readv_transfer(struct snd_pcm_substream *substream, - unsigned int hwoff, - unsigned long data, unsigned int off, - snd_pcm_uframes_t frames) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - int err; - void __user **bufs = (void __user **)data; - int channels = runtime->channels; - int c; - if (substream->ops->copy) { - for (c = 0; c < channels; ++c, ++bufs) { - char __user *buf; - if (*bufs == NULL) - continue; - buf = *bufs + samples_to_bytes(runtime, off); - if ((err = substream->ops->copy(substream, c, hwoff, buf, frames)) < 0) - return err; - } - } else { - snd_pcm_uframes_t dma_csize = runtime->dma_bytes / channels; - for (c = 0; c < channels; ++c, ++bufs) { - char *hwbuf; - char __user *buf; - if (*bufs == NULL) - continue; - - hwbuf = runtime->dma_area + (c * dma_csize) + samples_to_bytes(runtime, hwoff); - buf = *bufs + samples_to_bytes(runtime, off); - if (copy_to_user(buf, hwbuf, samples_to_bytes(runtime, frames))) - return -EFAULT; - } - } - return 0; -} - -snd_pcm_sframes_t snd_pcm_lib_readv(struct snd_pcm_substream *substream, - void __user **bufs, - snd_pcm_uframes_t frames) -{ - struct snd_pcm_runtime *runtime; - int nonblock; - int err; - - err = pcm_sanity_check(substream); - if (err < 0) - return err; - runtime = substream->runtime; - if (runtime->status->state == SNDRV_PCM_STATE_OPEN) - return -EBADFD; - - nonblock = !!(substream->f_flags & O_NONBLOCK); - if (runtime->access != SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) - return -EINVAL; - return snd_pcm_lib_read1(substream, (unsigned long)bufs, frames, nonblock, snd_pcm_lib_readv_transfer); -} - -EXPORT_SYMBOL(snd_pcm_lib_readv); diff --git a/src/mod/endpoints/mod_skypopen/old-stuff/pcm_native.c b/src/mod/endpoints/mod_skypopen/old-stuff/pcm_native.c deleted file mode 100644 index 36ee1efba4..0000000000 --- a/src/mod/endpoints/mod_skypopen/old-stuff/pcm_native.c +++ /dev/null @@ -1,3493 +0,0 @@ -/* - * Digital Audio (PCM) abstract layer - * Copyright (c) by Jaroslav Kysela - * - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - * - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * Compatibility - */ - -struct snd_pcm_hw_params_old { - unsigned int flags; - unsigned int masks[SNDRV_PCM_HW_PARAM_SUBFORMAT - - SNDRV_PCM_HW_PARAM_ACCESS + 1]; - struct snd_interval intervals[SNDRV_PCM_HW_PARAM_TICK_TIME - - SNDRV_PCM_HW_PARAM_SAMPLE_BITS + 1]; - unsigned int rmask; - unsigned int cmask; - unsigned int info; - unsigned int msbits; - unsigned int rate_num; - unsigned int rate_den; - snd_pcm_uframes_t fifo_size; - unsigned char reserved[64]; -}; - -#ifdef CONFIG_SND_SUPPORT_OLD_API -#define SNDRV_PCM_IOCTL_HW_REFINE_OLD _IOWR('A', 0x10, struct snd_pcm_hw_params_old) -#define SNDRV_PCM_IOCTL_HW_PARAMS_OLD _IOWR('A', 0x11, struct snd_pcm_hw_params_old) - -static int snd_pcm_hw_refine_old_user(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params_old __user * _oparams); -static int snd_pcm_hw_params_old_user(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params_old __user * _oparams); -#endif -static int snd_pcm_open(struct file *file, struct snd_pcm *pcm, int stream); - -/* - * - */ - -DEFINE_RWLOCK(snd_pcm_link_rwlock); -EXPORT_SYMBOL(snd_pcm_link_rwlock); - -static DECLARE_RWSEM(snd_pcm_link_rwsem); - -static inline mm_segment_t snd_enter_user(void) -{ - mm_segment_t fs = get_fs(); - set_fs(get_ds()); - return fs; -} - -static inline void snd_leave_user(mm_segment_t fs) -{ - set_fs(fs); -} - - - -int snd_pcm_info(struct snd_pcm_substream *substream, struct snd_pcm_info *info) -{ - struct snd_pcm_runtime *runtime; - struct snd_pcm *pcm = substream->pcm; - struct snd_pcm_str *pstr = substream->pstr; - - memset(info, 0, sizeof(*info)); - info->card = pcm->card->number; - info->device = pcm->device; - info->stream = substream->stream; - info->subdevice = substream->number; - strlcpy(info->id, pcm->id, sizeof(info->id)); - strlcpy(info->name, pcm->name, sizeof(info->name)); - info->dev_class = pcm->dev_class; - info->dev_subclass = pcm->dev_subclass; - info->subdevices_count = pstr->substream_count; - info->subdevices_avail = pstr->substream_count - pstr->substream_opened; - strlcpy(info->subname, substream->name, sizeof(info->subname)); - runtime = substream->runtime; - /* AB: FIXME!!! This is definitely nonsense */ - if (runtime) { - info->sync = runtime->sync; - substream->ops->ioctl(substream, SNDRV_PCM_IOCTL1_INFO, info); - } - return 0; -} - -int snd_pcm_info_user(struct snd_pcm_substream *substream, - struct snd_pcm_info __user * _info) -{ - struct snd_pcm_info *info; - int err; - - info = kmalloc(sizeof(*info), GFP_KERNEL); - if (! info) - return -ENOMEM; - err = snd_pcm_info(substream, info); - if (err >= 0) { - if (copy_to_user(_info, info, sizeof(*info))) - err = -EFAULT; - } - kfree(info); - return err; -} - -#undef RULES_DEBUG - -#ifdef RULES_DEBUG -#define HW_PARAM(v) [SNDRV_PCM_HW_PARAM_##v] = #v -char *snd_pcm_hw_param_names[] = { - HW_PARAM(ACCESS), - HW_PARAM(FORMAT), - HW_PARAM(SUBFORMAT), - HW_PARAM(SAMPLE_BITS), - HW_PARAM(FRAME_BITS), - HW_PARAM(CHANNELS), - HW_PARAM(RATE), - HW_PARAM(PERIOD_TIME), - HW_PARAM(PERIOD_SIZE), - HW_PARAM(PERIOD_BYTES), - HW_PARAM(PERIODS), - HW_PARAM(BUFFER_TIME), - HW_PARAM(BUFFER_SIZE), - HW_PARAM(BUFFER_BYTES), - HW_PARAM(TICK_TIME), -}; -#endif - -int snd_pcm_hw_refine(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - unsigned int k; - struct snd_pcm_hardware *hw; - struct snd_interval *i = NULL; - struct snd_mask *m = NULL; - struct snd_pcm_hw_constraints *constrs = &substream->runtime->hw_constraints; - unsigned int rstamps[constrs->rules_num]; - unsigned int vstamps[SNDRV_PCM_HW_PARAM_LAST_INTERVAL + 1]; - unsigned int stamp = 2; - int changed, again; - - params->info = 0; - params->fifo_size = 0; - if (params->rmask & (1 << SNDRV_PCM_HW_PARAM_SAMPLE_BITS)) - params->msbits = 0; - if (params->rmask & (1 << SNDRV_PCM_HW_PARAM_RATE)) { - params->rate_num = 0; - params->rate_den = 0; - } - - for (k = SNDRV_PCM_HW_PARAM_FIRST_MASK; k <= SNDRV_PCM_HW_PARAM_LAST_MASK; k++) { - m = hw_param_mask(params, k); - if (snd_mask_empty(m)) - return -EINVAL; - if (!(params->rmask & (1 << k))) - continue; -#ifdef RULES_DEBUG - printk(KERN_DEBUG "%s = ", snd_pcm_hw_param_names[k]); - printk("%04x%04x%04x%04x -> ", m->bits[3], m->bits[2], m->bits[1], m->bits[0]); -#endif - changed = snd_mask_refine(m, constrs_mask(constrs, k)); -#ifdef RULES_DEBUG - printk("%04x%04x%04x%04x\n", m->bits[3], m->bits[2], m->bits[1], m->bits[0]); -#endif - if (changed) - params->cmask |= 1 << k; - if (changed < 0) - return changed; - } - - for (k = SNDRV_PCM_HW_PARAM_FIRST_INTERVAL; k <= SNDRV_PCM_HW_PARAM_LAST_INTERVAL; k++) { - i = hw_param_interval(params, k); - if (snd_interval_empty(i)) - return -EINVAL; - if (!(params->rmask & (1 << k))) - continue; -#ifdef RULES_DEBUG - printk(KERN_DEBUG "%s = ", snd_pcm_hw_param_names[k]); - if (i->empty) - printk("empty"); - else - printk("%c%u %u%c", - i->openmin ? '(' : '[', i->min, - i->max, i->openmax ? ')' : ']'); - printk(" -> "); -#endif - changed = snd_interval_refine(i, constrs_interval(constrs, k)); -#ifdef RULES_DEBUG - if (i->empty) - printk("empty\n"); - else - printk("%c%u %u%c\n", - i->openmin ? '(' : '[', i->min, - i->max, i->openmax ? ')' : ']'); -#endif - if (changed) - params->cmask |= 1 << k; - if (changed < 0) - return changed; - } - - for (k = 0; k < constrs->rules_num; k++) - rstamps[k] = 0; - for (k = 0; k <= SNDRV_PCM_HW_PARAM_LAST_INTERVAL; k++) - vstamps[k] = (params->rmask & (1 << k)) ? 1 : 0; - do { - again = 0; - for (k = 0; k < constrs->rules_num; k++) { - struct snd_pcm_hw_rule *r = &constrs->rules[k]; - unsigned int d; - int doit = 0; - if (r->cond && !(r->cond & params->flags)) - continue; - for (d = 0; r->deps[d] >= 0; d++) { - if (vstamps[r->deps[d]] > rstamps[k]) { - doit = 1; - break; - } - } - if (!doit) - continue; -#ifdef RULES_DEBUG - printk(KERN_DEBUG "Rule %d [%p]: ", k, r->func); - if (r->var >= 0) { - printk("%s = ", snd_pcm_hw_param_names[r->var]); - if (hw_is_mask(r->var)) { - m = hw_param_mask(params, r->var); - printk("%x", *m->bits); - } else { - i = hw_param_interval(params, r->var); - if (i->empty) - printk("empty"); - else - printk("%c%u %u%c", - i->openmin ? '(' : '[', i->min, - i->max, i->openmax ? ')' : ']'); - } - } -#endif - changed = r->func(params, r); -#ifdef RULES_DEBUG - if (r->var >= 0) { - printk(" -> "); - if (hw_is_mask(r->var)) - printk("%x", *m->bits); - else { - if (i->empty) - printk("empty"); - else - printk("%c%u %u%c", - i->openmin ? '(' : '[', i->min, - i->max, i->openmax ? ')' : ']'); - } - } - printk("\n"); -#endif - rstamps[k] = stamp; - if (changed && r->var >= 0) { - params->cmask |= (1 << r->var); - vstamps[r->var] = stamp; - again = 1; - } - if (changed < 0) - return changed; - stamp++; - } - } while (again); - if (!params->msbits) { - i = hw_param_interval(params, SNDRV_PCM_HW_PARAM_SAMPLE_BITS); - if (snd_interval_single(i)) - params->msbits = snd_interval_value(i); - } - - if (!params->rate_den) { - i = hw_param_interval(params, SNDRV_PCM_HW_PARAM_RATE); - if (snd_interval_single(i)) { - params->rate_num = snd_interval_value(i); - params->rate_den = 1; - } - } - - hw = &substream->runtime->hw; - if (!params->info) - params->info = hw->info & ~SNDRV_PCM_INFO_FIFO_IN_FRAMES; - if (!params->fifo_size) { - m = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); - i = hw_param_interval(params, SNDRV_PCM_HW_PARAM_CHANNELS); - if (snd_mask_min(m) == snd_mask_max(m) && - snd_interval_min(i) == snd_interval_max(i)) { - changed = substream->ops->ioctl(substream, - SNDRV_PCM_IOCTL1_FIFO_SIZE, params); - if (changed < 0) - return changed; - } - } - params->rmask = 0; - return 0; -} - -EXPORT_SYMBOL(snd_pcm_hw_refine); - -static int snd_pcm_hw_refine_user(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params __user * _params) -{ - struct snd_pcm_hw_params *params; - int err; - - params = memdup_user(_params, sizeof(*params)); - if (IS_ERR(params)) - return PTR_ERR(params); - - err = snd_pcm_hw_refine(substream, params); - if (copy_to_user(_params, params, sizeof(*params))) { - if (!err) - err = -EFAULT; - } - - kfree(params); - return err; -} - -static int period_to_usecs(struct snd_pcm_runtime *runtime) -{ - int usecs; - - if (! runtime->rate) - return -1; /* invalid */ - - /* take 75% of period time as the deadline */ - usecs = (750000 / runtime->rate) * runtime->period_size; - usecs += ((750000 % runtime->rate) * runtime->period_size) / - runtime->rate; - - return usecs; -} - -static int calc_boundary(struct snd_pcm_runtime *runtime) -{ - uint64_t boundary; - - boundary = (uint64_t)runtime->buffer_size * - (uint64_t)runtime->period_size; -#if BITS_PER_LONG < 64 - /* try to find lowest common multiple for buffer and period */ - if (boundary > LONG_MAX - runtime->buffer_size) { - uint32_t remainder = -1; - uint32_t divident = runtime->buffer_size; - uint32_t divisor = runtime->period_size; - while (remainder) { - remainder = divident % divisor; - if (remainder) { - divident = divisor; - divisor = remainder; - } - } - boundary = div_u64(boundary, divisor); - if (boundary > LONG_MAX - runtime->buffer_size) - return -ERANGE; - } -#endif - if (boundary == 0) - return -ERANGE; - runtime->boundary = boundary; - while (runtime->boundary * 2 <= LONG_MAX - runtime->buffer_size) - runtime->boundary *= 2; - return 0; -} - -static int snd_pcm_hw_params(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params *params) -{ - struct snd_pcm_runtime *runtime; - int err, usecs; - unsigned int bits; - snd_pcm_uframes_t frames; - - if (PCM_RUNTIME_CHECK(substream)) - return -ENXIO; - runtime = substream->runtime; - snd_pcm_stream_lock_irq(substream); - switch (runtime->status->state) { - case SNDRV_PCM_STATE_OPEN: - case SNDRV_PCM_STATE_SETUP: - case SNDRV_PCM_STATE_PREPARED: - break; - default: - snd_pcm_stream_unlock_irq(substream); - return -EBADFD; - } - snd_pcm_stream_unlock_irq(substream); -#if defined(CONFIG_SND_PCM_OSS) || defined(CONFIG_SND_PCM_OSS_MODULE) - if (!substream->oss.oss) -#endif - if (atomic_read(&substream->mmap_count)) - return -EBADFD; - - params->rmask = ~0U; - err = snd_pcm_hw_refine(substream, params); - if (err < 0) - goto _error; - - err = snd_pcm_hw_params_choose(substream, params); - if (err < 0) - goto _error; - - if (substream->ops->hw_params != NULL) { - err = substream->ops->hw_params(substream, params); - if (err < 0) - goto _error; - } - - runtime->access = params_access(params); - runtime->format = params_format(params); - runtime->subformat = params_subformat(params); - runtime->channels = params_channels(params); - runtime->rate = params_rate(params); - runtime->period_size = params_period_size(params); - runtime->periods = params_periods(params); - runtime->buffer_size = params_buffer_size(params); - runtime->info = params->info; - runtime->rate_num = params->rate_num; - runtime->rate_den = params->rate_den; - - bits = snd_pcm_format_physical_width(runtime->format); - runtime->sample_bits = bits; - bits *= runtime->channels; - runtime->frame_bits = bits; - frames = 1; - while (bits % 8 != 0) { - bits *= 2; - frames *= 2; - } - runtime->byte_align = bits / 8; - runtime->min_align = frames; - - /* Default sw params */ - runtime->tstamp_mode = SNDRV_PCM_TSTAMP_NONE; - runtime->period_step = 1; - runtime->control->avail_min = runtime->period_size; - runtime->start_threshold = 1; - runtime->stop_threshold = runtime->buffer_size; - runtime->silence_threshold = 0; - runtime->silence_size = 0; - err = calc_boundary(runtime); - if (err < 0) - goto _error; - - snd_pcm_timer_resolution_change(substream); - runtime->status->state = SNDRV_PCM_STATE_SETUP; - - pm_qos_remove_requirement(PM_QOS_CPU_DMA_LATENCY, - substream->latency_id); - if ((usecs = period_to_usecs(runtime)) >= 0) - pm_qos_add_requirement(PM_QOS_CPU_DMA_LATENCY, - substream->latency_id, usecs); - return 0; - _error: - /* hardware might be unuseable from this time, - so we force application to retry to set - the correct hardware parameter settings */ - runtime->status->state = SNDRV_PCM_STATE_OPEN; - if (substream->ops->hw_free != NULL) - substream->ops->hw_free(substream); - return err; -} - -static int snd_pcm_hw_params_user(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params __user * _params) -{ - struct snd_pcm_hw_params *params; - int err; - - params = memdup_user(_params, sizeof(*params)); - if (IS_ERR(params)) - return PTR_ERR(params); - - err = snd_pcm_hw_params(substream, params); - if (copy_to_user(_params, params, sizeof(*params))) { - if (!err) - err = -EFAULT; - } - - kfree(params); - return err; -} - -static int snd_pcm_hw_free(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime; - int result = 0; - - if (PCM_RUNTIME_CHECK(substream)) - return -ENXIO; - runtime = substream->runtime; - snd_pcm_stream_lock_irq(substream); - switch (runtime->status->state) { - case SNDRV_PCM_STATE_SETUP: - case SNDRV_PCM_STATE_PREPARED: - break; - default: - snd_pcm_stream_unlock_irq(substream); - return -EBADFD; - } - snd_pcm_stream_unlock_irq(substream); - if (atomic_read(&substream->mmap_count)) - return -EBADFD; - if (substream->ops->hw_free) - result = substream->ops->hw_free(substream); - runtime->status->state = SNDRV_PCM_STATE_OPEN; - pm_qos_remove_requirement(PM_QOS_CPU_DMA_LATENCY, - substream->latency_id); - return result; -} - -static int snd_pcm_sw_params(struct snd_pcm_substream *substream, - struct snd_pcm_sw_params *params) -{ - struct snd_pcm_runtime *runtime; - int err; - - if (PCM_RUNTIME_CHECK(substream)) - return -ENXIO; - runtime = substream->runtime; - snd_pcm_stream_lock_irq(substream); - if (runtime->status->state == SNDRV_PCM_STATE_OPEN) { - snd_pcm_stream_unlock_irq(substream); - return -EBADFD; - } - snd_pcm_stream_unlock_irq(substream); - - if (params->tstamp_mode > SNDRV_PCM_TSTAMP_LAST) - return -EINVAL; - if (params->avail_min == 0) - return -EINVAL; - if (params->silence_size >= runtime->boundary) { - if (params->silence_threshold != 0) - return -EINVAL; - } else { - if (params->silence_size > params->silence_threshold) - return -EINVAL; - if (params->silence_threshold > runtime->buffer_size) - return -EINVAL; - } - err = 0; - snd_pcm_stream_lock_irq(substream); - runtime->tstamp_mode = params->tstamp_mode; - runtime->period_step = params->period_step; - runtime->control->avail_min = params->avail_min; - runtime->start_threshold = params->start_threshold; - runtime->stop_threshold = params->stop_threshold; - runtime->silence_threshold = params->silence_threshold; - runtime->silence_size = params->silence_size; - params->boundary = runtime->boundary; - if (snd_pcm_running(substream)) { - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && - runtime->silence_size > 0) - snd_pcm_playback_silence(substream, ULONG_MAX); - err = snd_pcm_update_state(substream, runtime); - } - snd_pcm_stream_unlock_irq(substream); - return err; -} - -static int snd_pcm_sw_params_user(struct snd_pcm_substream *substream, - struct snd_pcm_sw_params __user * _params) -{ - struct snd_pcm_sw_params params; - int err; - if (copy_from_user(¶ms, _params, sizeof(params))) - return -EFAULT; - err = snd_pcm_sw_params(substream, ¶ms); - if (copy_to_user(_params, ¶ms, sizeof(params))) - return -EFAULT; - return err; -} - -int snd_pcm_status(struct snd_pcm_substream *substream, - struct snd_pcm_status *status) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - - //giovanni snd_pcm_stream_lock_irq(substream); - status->state = runtime->status->state; - status->suspended_state = runtime->status->suspended_state; - if (status->state == SNDRV_PCM_STATE_OPEN) - goto _end; - status->trigger_tstamp = runtime->trigger_tstamp; - if (snd_pcm_running(substream)) { - snd_pcm_update_hw_ptr(substream); - if (runtime->tstamp_mode == SNDRV_PCM_TSTAMP_ENABLE) { - status->tstamp = runtime->status->tstamp; - goto _tstamp_end; - } - } - snd_pcm_gettime(runtime, &status->tstamp); - _tstamp_end: - status->appl_ptr = runtime->control->appl_ptr; - status->hw_ptr = runtime->status->hw_ptr; - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - status->avail = snd_pcm_playback_avail(runtime); - if (runtime->status->state == SNDRV_PCM_STATE_RUNNING || - runtime->status->state == SNDRV_PCM_STATE_DRAINING) { - status->delay = runtime->buffer_size - status->avail; - status->delay += runtime->delay; - } else - status->delay = 0; - } else { - status->avail = snd_pcm_capture_avail(runtime); - if (runtime->status->state == SNDRV_PCM_STATE_RUNNING) - status->delay = status->avail + runtime->delay; - else - status->delay = 0; - } - status->avail_max = runtime->avail_max; - status->overrange = runtime->overrange; - runtime->avail_max = 0; - runtime->overrange = 0; - _end: - //giovanni snd_pcm_stream_unlock_irq(substream); - return 0; -} - -static int snd_pcm_status_user(struct snd_pcm_substream *substream, - struct snd_pcm_status __user * _status) -{ - struct snd_pcm_status status; - int res; - - memset(&status, 0, sizeof(status)); - res = snd_pcm_status(substream, &status); - if (res < 0) - return res; - if (copy_to_user(_status, &status, sizeof(status))) - return -EFAULT; - return 0; -} - -static int snd_pcm_channel_info(struct snd_pcm_substream *substream, - struct snd_pcm_channel_info * info) -{ - struct snd_pcm_runtime *runtime; - unsigned int channel; - - channel = info->channel; - runtime = substream->runtime; - //giovanni snd_pcm_stream_lock_irq(substream); - if (runtime->status->state == SNDRV_PCM_STATE_OPEN) { - //giovanni snd_pcm_stream_unlock_irq(substream); - return -EBADFD; - } - //giovanni snd_pcm_stream_unlock_irq(substream); - if (channel >= runtime->channels) - return -EINVAL; - memset(info, 0, sizeof(*info)); - info->channel = channel; - return substream->ops->ioctl(substream, SNDRV_PCM_IOCTL1_CHANNEL_INFO, info); -} - -static int snd_pcm_channel_info_user(struct snd_pcm_substream *substream, - struct snd_pcm_channel_info __user * _info) -{ - struct snd_pcm_channel_info info; - int res; - - if (copy_from_user(&info, _info, sizeof(info))) - return -EFAULT; - res = snd_pcm_channel_info(substream, &info); - if (res < 0) - return res; - if (copy_to_user(_info, &info, sizeof(info))) - return -EFAULT; - return 0; -} - -static void snd_pcm_trigger_tstamp(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - if (runtime->trigger_master == NULL) - return; - if (runtime->trigger_master == substream) { - snd_pcm_gettime(runtime, &runtime->trigger_tstamp); - } else { - snd_pcm_trigger_tstamp(runtime->trigger_master); - runtime->trigger_tstamp = runtime->trigger_master->runtime->trigger_tstamp; - } - runtime->trigger_master = NULL; -} - -struct action_ops { - int (*pre_action)(struct snd_pcm_substream *substream, int state); - int (*do_action)(struct snd_pcm_substream *substream, int state); - void (*undo_action)(struct snd_pcm_substream *substream, int state); - void (*post_action)(struct snd_pcm_substream *substream, int state); -}; - -/* - * this functions is core for handling of linked stream - * Note: the stream state might be changed also on failure - * Note2: call with calling stream lock + link lock - */ -static int snd_pcm_action_group(struct action_ops *ops, - struct snd_pcm_substream *substream, - int state, int do_lock) -{ - struct snd_pcm_substream *s = NULL; - struct snd_pcm_substream *s1; - int res = 0; - - snd_pcm_group_for_each_entry(s, substream) { - if (do_lock && s != substream) - spin_lock_nested(&s->self_group.lock, - SINGLE_DEPTH_NESTING); - res = ops->pre_action(s, state); - if (res < 0) - goto _unlock; - } - snd_pcm_group_for_each_entry(s, substream) { - res = ops->do_action(s, state); - if (res < 0) { - if (ops->undo_action) { - snd_pcm_group_for_each_entry(s1, substream) { - if (s1 == s) /* failed stream */ - break; - ops->undo_action(s1, state); - } - } - s = NULL; /* unlock all */ - goto _unlock; - } - } - snd_pcm_group_for_each_entry(s, substream) { - ops->post_action(s, state); - } - _unlock: - if (do_lock) { - /* unlock streams */ - snd_pcm_group_for_each_entry(s1, substream) { - if (s1 != substream) - spin_unlock(&s1->self_group.lock); - if (s1 == s) /* end */ - break; - } - } - return res; -} - -/* - * Note: call with stream lock - */ -static int snd_pcm_action_single(struct action_ops *ops, - struct snd_pcm_substream *substream, - int state) -{ - int res; - - res = ops->pre_action(substream, state); - if (res < 0) - return res; - res = ops->do_action(substream, state); - if (res == 0) - ops->post_action(substream, state); - else if (ops->undo_action) - ops->undo_action(substream, state); - return res; -} - -/* - * Note: call with stream lock - */ -static int snd_pcm_action(struct action_ops *ops, - struct snd_pcm_substream *substream, - int state) -{ - int res; - - if (snd_pcm_stream_linked(substream)) { - if (!spin_trylock(&substream->group->lock)) { - spin_unlock(&substream->self_group.lock); - spin_lock(&substream->group->lock); - spin_lock(&substream->self_group.lock); - } - res = snd_pcm_action_group(ops, substream, state, 1); - spin_unlock(&substream->group->lock); - } else { - res = snd_pcm_action_single(ops, substream, state); - } - return res; -} - -/* - * Note: don't use any locks before - */ -static int snd_pcm_action_lock_irq(struct action_ops *ops, - struct snd_pcm_substream *substream, - int state) -{ - int res; - - read_lock_irq(&snd_pcm_link_rwlock); - if (snd_pcm_stream_linked(substream)) { - spin_lock(&substream->group->lock); - spin_lock(&substream->self_group.lock); - res = snd_pcm_action_group(ops, substream, state, 1); - spin_unlock(&substream->self_group.lock); - spin_unlock(&substream->group->lock); - } else { - spin_lock(&substream->self_group.lock); - res = snd_pcm_action_single(ops, substream, state); - spin_unlock(&substream->self_group.lock); - } - read_unlock_irq(&snd_pcm_link_rwlock); - return res; -} - -/* - */ -static int snd_pcm_action_nonatomic(struct action_ops *ops, - struct snd_pcm_substream *substream, - int state) -{ - int res; - - down_read(&snd_pcm_link_rwsem); - if (snd_pcm_stream_linked(substream)) - res = snd_pcm_action_group(ops, substream, state, 0); - else - res = snd_pcm_action_single(ops, substream, state); - up_read(&snd_pcm_link_rwsem); - return res; -} - -/* - * start callbacks - */ -static int snd_pcm_pre_start(struct snd_pcm_substream *substream, int state) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - if (runtime->status->state != SNDRV_PCM_STATE_PREPARED) - return -EBADFD; - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && - !snd_pcm_playback_data(substream)) - return -EPIPE; - runtime->trigger_master = substream; - return 0; -} - -static int snd_pcm_do_start(struct snd_pcm_substream *substream, int state) -{ - if (substream->runtime->trigger_master != substream) - return 0; - return substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_START); -} - -static void snd_pcm_undo_start(struct snd_pcm_substream *substream, int state) -{ - if (substream->runtime->trigger_master == substream) - substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_STOP); -} - -static void snd_pcm_post_start(struct snd_pcm_substream *substream, int state) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - snd_pcm_trigger_tstamp(substream); - runtime->hw_ptr_jiffies = jiffies; - runtime->status->state = state; - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && - runtime->silence_size > 0) - snd_pcm_playback_silence(substream, ULONG_MAX); - if (substream->timer) - snd_timer_notify(substream->timer, SNDRV_TIMER_EVENT_MSTART, - &runtime->trigger_tstamp); -} - -static struct action_ops snd_pcm_action_start = { - .pre_action = snd_pcm_pre_start, - .do_action = snd_pcm_do_start, - .undo_action = snd_pcm_undo_start, - .post_action = snd_pcm_post_start -}; - -/** - * snd_pcm_start - start all linked streams - * @substream: the PCM substream instance - */ -int snd_pcm_start(struct snd_pcm_substream *substream) -{ - return snd_pcm_action(&snd_pcm_action_start, substream, - SNDRV_PCM_STATE_RUNNING); -} - -/* - * stop callbacks - */ -static int snd_pcm_pre_stop(struct snd_pcm_substream *substream, int state) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - if (runtime->status->state == SNDRV_PCM_STATE_OPEN) - return -EBADFD; - runtime->trigger_master = substream; - return 0; -} - -static int snd_pcm_do_stop(struct snd_pcm_substream *substream, int state) -{ - if (substream->runtime->trigger_master == substream && - snd_pcm_running(substream)) - substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_STOP); - return 0; /* unconditonally stop all substreams */ -} - -static void snd_pcm_post_stop(struct snd_pcm_substream *substream, int state) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - if (runtime->status->state != state) { - snd_pcm_trigger_tstamp(substream); - if (substream->timer) - snd_timer_notify(substream->timer, SNDRV_TIMER_EVENT_MSTOP, - &runtime->trigger_tstamp); - runtime->status->state = state; - } - wake_up(&runtime->sleep); - wake_up(&runtime->tsleep); -} - -static struct action_ops snd_pcm_action_stop = { - .pre_action = snd_pcm_pre_stop, - .do_action = snd_pcm_do_stop, - .post_action = snd_pcm_post_stop -}; - -/** - * snd_pcm_stop - try to stop all running streams in the substream group - * @substream: the PCM substream instance - * @state: PCM state after stopping the stream - * - * The state of each stream is then changed to the given state unconditionally. - */ -int snd_pcm_stop(struct snd_pcm_substream *substream, int state) -{ - return snd_pcm_action(&snd_pcm_action_stop, substream, state); -} - -EXPORT_SYMBOL(snd_pcm_stop); - -/** - * snd_pcm_drain_done - stop the DMA only when the given stream is playback - * @substream: the PCM substream - * - * After stopping, the state is changed to SETUP. - * Unlike snd_pcm_stop(), this affects only the given stream. - */ -int snd_pcm_drain_done(struct snd_pcm_substream *substream) -{ - return snd_pcm_action_single(&snd_pcm_action_stop, substream, - SNDRV_PCM_STATE_SETUP); -} - -/* - * pause callbacks - */ -static int snd_pcm_pre_pause(struct snd_pcm_substream *substream, int push) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - if (!(runtime->info & SNDRV_PCM_INFO_PAUSE)) - return -ENOSYS; - if (push) { - if (runtime->status->state != SNDRV_PCM_STATE_RUNNING) - return -EBADFD; - } else if (runtime->status->state != SNDRV_PCM_STATE_PAUSED) - return -EBADFD; - runtime->trigger_master = substream; - return 0; -} - -static int snd_pcm_do_pause(struct snd_pcm_substream *substream, int push) -{ - if (substream->runtime->trigger_master != substream) - return 0; - /* The jiffies check in snd_pcm_update_hw_ptr*() is done by - * a delta betwen the current jiffies, this gives a large enough - * delta, effectively to skip the check once. - */ - substream->runtime->hw_ptr_jiffies = jiffies - HZ * 1000; - return substream->ops->trigger(substream, - push ? SNDRV_PCM_TRIGGER_PAUSE_PUSH : - SNDRV_PCM_TRIGGER_PAUSE_RELEASE); -} - -static void snd_pcm_undo_pause(struct snd_pcm_substream *substream, int push) -{ - if (substream->runtime->trigger_master == substream) - substream->ops->trigger(substream, - push ? SNDRV_PCM_TRIGGER_PAUSE_RELEASE : - SNDRV_PCM_TRIGGER_PAUSE_PUSH); -} - -static void snd_pcm_post_pause(struct snd_pcm_substream *substream, int push) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - snd_pcm_trigger_tstamp(substream); - if (push) { - runtime->status->state = SNDRV_PCM_STATE_PAUSED; - if (substream->timer) - snd_timer_notify(substream->timer, - SNDRV_TIMER_EVENT_MPAUSE, - &runtime->trigger_tstamp); - wake_up(&runtime->sleep); - wake_up(&runtime->tsleep); - } else { - runtime->status->state = SNDRV_PCM_STATE_RUNNING; - if (substream->timer) - snd_timer_notify(substream->timer, - SNDRV_TIMER_EVENT_MCONTINUE, - &runtime->trigger_tstamp); - } -} - -static struct action_ops snd_pcm_action_pause = { - .pre_action = snd_pcm_pre_pause, - .do_action = snd_pcm_do_pause, - .undo_action = snd_pcm_undo_pause, - .post_action = snd_pcm_post_pause -}; - -/* - * Push/release the pause for all linked streams. - */ -static int snd_pcm_pause(struct snd_pcm_substream *substream, int push) -{ - return snd_pcm_action(&snd_pcm_action_pause, substream, push); -} - -#ifdef CONFIG_PM -/* suspend */ - -static int snd_pcm_pre_suspend(struct snd_pcm_substream *substream, int state) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - if (runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) - return -EBUSY; - runtime->trigger_master = substream; - return 0; -} - -static int snd_pcm_do_suspend(struct snd_pcm_substream *substream, int state) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - if (runtime->trigger_master != substream) - return 0; - if (! snd_pcm_running(substream)) - return 0; - substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_SUSPEND); - return 0; /* suspend unconditionally */ -} - -static void snd_pcm_post_suspend(struct snd_pcm_substream *substream, int state) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - snd_pcm_trigger_tstamp(substream); - if (substream->timer) - snd_timer_notify(substream->timer, SNDRV_TIMER_EVENT_MSUSPEND, - &runtime->trigger_tstamp); - runtime->status->suspended_state = runtime->status->state; - runtime->status->state = SNDRV_PCM_STATE_SUSPENDED; - wake_up(&runtime->sleep); - wake_up(&runtime->tsleep); -} - -static struct action_ops snd_pcm_action_suspend = { - .pre_action = snd_pcm_pre_suspend, - .do_action = snd_pcm_do_suspend, - .post_action = snd_pcm_post_suspend -}; - -/** - * snd_pcm_suspend - trigger SUSPEND to all linked streams - * @substream: the PCM substream - * - * After this call, all streams are changed to SUSPENDED state. - */ -int snd_pcm_suspend(struct snd_pcm_substream *substream) -{ - int err; - unsigned long flags; - - if (! substream) - return 0; - - snd_pcm_stream_lock_irqsave(substream, flags); - err = snd_pcm_action(&snd_pcm_action_suspend, substream, 0); - snd_pcm_stream_unlock_irqrestore(substream, flags); - return err; -} - -EXPORT_SYMBOL(snd_pcm_suspend); - -/** - * snd_pcm_suspend_all - trigger SUSPEND to all substreams in the given pcm - * @pcm: the PCM instance - * - * After this call, all streams are changed to SUSPENDED state. - */ -int snd_pcm_suspend_all(struct snd_pcm *pcm) -{ - struct snd_pcm_substream *substream; - int stream, err = 0; - - if (! pcm) - return 0; - - for (stream = 0; stream < 2; stream++) { - for (substream = pcm->streams[stream].substream; - substream; substream = substream->next) { - /* FIXME: the open/close code should lock this as well */ - if (substream->runtime == NULL) - continue; - err = snd_pcm_suspend(substream); - if (err < 0 && err != -EBUSY) - return err; - } - } - return 0; -} - -EXPORT_SYMBOL(snd_pcm_suspend_all); - -/* resume */ - -static int snd_pcm_pre_resume(struct snd_pcm_substream *substream, int state) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - if (!(runtime->info & SNDRV_PCM_INFO_RESUME)) - return -ENOSYS; - runtime->trigger_master = substream; - return 0; -} - -static int snd_pcm_do_resume(struct snd_pcm_substream *substream, int state) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - if (runtime->trigger_master != substream) - return 0; - /* DMA not running previously? */ - if (runtime->status->suspended_state != SNDRV_PCM_STATE_RUNNING && - (runtime->status->suspended_state != SNDRV_PCM_STATE_DRAINING || - substream->stream != SNDRV_PCM_STREAM_PLAYBACK)) - return 0; - return substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_RESUME); -} - -static void snd_pcm_undo_resume(struct snd_pcm_substream *substream, int state) -{ - if (substream->runtime->trigger_master == substream && - snd_pcm_running(substream)) - substream->ops->trigger(substream, SNDRV_PCM_TRIGGER_SUSPEND); -} - -static void snd_pcm_post_resume(struct snd_pcm_substream *substream, int state) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - snd_pcm_trigger_tstamp(substream); - if (substream->timer) - snd_timer_notify(substream->timer, SNDRV_TIMER_EVENT_MRESUME, - &runtime->trigger_tstamp); - runtime->status->state = runtime->status->suspended_state; -} - -static struct action_ops snd_pcm_action_resume = { - .pre_action = snd_pcm_pre_resume, - .do_action = snd_pcm_do_resume, - .undo_action = snd_pcm_undo_resume, - .post_action = snd_pcm_post_resume -}; - -static int snd_pcm_resume(struct snd_pcm_substream *substream) -{ - struct snd_card *card = substream->pcm->card; - int res; - - snd_power_lock(card); - if ((res = snd_power_wait(card, SNDRV_CTL_POWER_D0)) >= 0) - res = snd_pcm_action_lock_irq(&snd_pcm_action_resume, substream, 0); - snd_power_unlock(card); - return res; -} - -#else - -static int snd_pcm_resume(struct snd_pcm_substream *substream) -{ - return -ENOSYS; -} - -#endif /* CONFIG_PM */ - -/* - * xrun ioctl - * - * Change the RUNNING stream(s) to XRUN state. - */ -static int snd_pcm_xrun(struct snd_pcm_substream *substream) -{ - struct snd_card *card = substream->pcm->card; - struct snd_pcm_runtime *runtime = substream->runtime; - int result; - - snd_power_lock(card); - if (runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) { - result = snd_power_wait(card, SNDRV_CTL_POWER_D0); - if (result < 0) - goto _unlock; - } - - snd_pcm_stream_lock_irq(substream); - switch (runtime->status->state) { - case SNDRV_PCM_STATE_XRUN: - result = 0; /* already there */ - break; - case SNDRV_PCM_STATE_RUNNING: - result = snd_pcm_stop(substream, SNDRV_PCM_STATE_XRUN); - break; - default: - result = -EBADFD; - } - snd_pcm_stream_unlock_irq(substream); - _unlock: - snd_power_unlock(card); - return result; -} - -/* - * reset ioctl - */ -static int snd_pcm_pre_reset(struct snd_pcm_substream *substream, int state) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - switch (runtime->status->state) { - case SNDRV_PCM_STATE_RUNNING: - case SNDRV_PCM_STATE_PREPARED: - case SNDRV_PCM_STATE_PAUSED: - case SNDRV_PCM_STATE_SUSPENDED: - return 0; - default: - return -EBADFD; - } -} - -static int snd_pcm_do_reset(struct snd_pcm_substream *substream, int state) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - int err = substream->ops->ioctl(substream, SNDRV_PCM_IOCTL1_RESET, NULL); - if (err < 0) - return err; - runtime->hw_ptr_base = 0; - runtime->hw_ptr_interrupt = runtime->status->hw_ptr - - runtime->status->hw_ptr % runtime->period_size; - runtime->silence_start = runtime->status->hw_ptr; - runtime->silence_filled = 0; - return 0; -} - -static void snd_pcm_post_reset(struct snd_pcm_substream *substream, int state) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - runtime->control->appl_ptr = runtime->status->hw_ptr; - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK && - runtime->silence_size > 0) - snd_pcm_playback_silence(substream, ULONG_MAX); -} - -static struct action_ops snd_pcm_action_reset = { - .pre_action = snd_pcm_pre_reset, - .do_action = snd_pcm_do_reset, - .post_action = snd_pcm_post_reset -}; - -static int snd_pcm_reset(struct snd_pcm_substream *substream) -{ - return snd_pcm_action_nonatomic(&snd_pcm_action_reset, substream, 0); -} - -/* - * prepare ioctl - */ -/* we use the second argument for updating f_flags */ -static int snd_pcm_pre_prepare(struct snd_pcm_substream *substream, - int f_flags) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - if (runtime->status->state == SNDRV_PCM_STATE_OPEN || - runtime->status->state == SNDRV_PCM_STATE_DISCONNECTED) - return -EBADFD; - if (snd_pcm_running(substream)) - return -EBUSY; - substream->f_flags = f_flags; - return 0; -} - -static int snd_pcm_do_prepare(struct snd_pcm_substream *substream, int state) -{ - int err; - err = substream->ops->prepare(substream); - if (err < 0) - return err; - return snd_pcm_do_reset(substream, 0); -} - -static void snd_pcm_post_prepare(struct snd_pcm_substream *substream, int state) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - runtime->control->appl_ptr = runtime->status->hw_ptr; - runtime->status->state = SNDRV_PCM_STATE_PREPARED; -} - -static struct action_ops snd_pcm_action_prepare = { - .pre_action = snd_pcm_pre_prepare, - .do_action = snd_pcm_do_prepare, - .post_action = snd_pcm_post_prepare -}; - -/** - * snd_pcm_prepare - prepare the PCM substream to be triggerable - * @substream: the PCM substream instance - * @file: file to refer f_flags - */ -static int snd_pcm_prepare(struct snd_pcm_substream *substream, - struct file *file) -{ - int res; - struct snd_card *card = substream->pcm->card; - int f_flags; - - if (file) - f_flags = file->f_flags; - else - f_flags = substream->f_flags; - - snd_power_lock(card); - if ((res = snd_power_wait(card, SNDRV_CTL_POWER_D0)) >= 0) - res = snd_pcm_action_nonatomic(&snd_pcm_action_prepare, - substream, f_flags); - snd_power_unlock(card); - return res; -} - -/* - * drain ioctl - */ - -static int snd_pcm_pre_drain_init(struct snd_pcm_substream *substream, int state) -{ - substream->runtime->trigger_master = substream; - return 0; -} - -static int snd_pcm_do_drain_init(struct snd_pcm_substream *substream, int state) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - switch (runtime->status->state) { - case SNDRV_PCM_STATE_PREPARED: - /* start playback stream if possible */ - if (! snd_pcm_playback_empty(substream)) { - snd_pcm_do_start(substream, SNDRV_PCM_STATE_DRAINING); - snd_pcm_post_start(substream, SNDRV_PCM_STATE_DRAINING); - } - break; - case SNDRV_PCM_STATE_RUNNING: - runtime->status->state = SNDRV_PCM_STATE_DRAINING; - break; - default: - break; - } - } else { - /* stop running stream */ - if (runtime->status->state == SNDRV_PCM_STATE_RUNNING) { - int new_state = snd_pcm_capture_avail(runtime) > 0 ? - SNDRV_PCM_STATE_DRAINING : SNDRV_PCM_STATE_SETUP; - snd_pcm_do_stop(substream, new_state); - snd_pcm_post_stop(substream, new_state); - } - } - return 0; -} - -static void snd_pcm_post_drain_init(struct snd_pcm_substream *substream, int state) -{ -} - -static struct action_ops snd_pcm_action_drain_init = { - .pre_action = snd_pcm_pre_drain_init, - .do_action = snd_pcm_do_drain_init, - .post_action = snd_pcm_post_drain_init -}; - -static int snd_pcm_drop(struct snd_pcm_substream *substream); - -/* - * Drain the stream(s). - * When the substream is linked, sync until the draining of all playback streams - * is finished. - * After this call, all streams are supposed to be either SETUP or DRAINING - * (capture only) state. - */ -static int snd_pcm_drain(struct snd_pcm_substream *substream, - struct file *file) -{ - struct snd_card *card; - struct snd_pcm_runtime *runtime; - struct snd_pcm_substream *s; - wait_queue_t wait; - int result = 0; - int nonblock = 0; - - card = substream->pcm->card; - runtime = substream->runtime; - - if (runtime->status->state == SNDRV_PCM_STATE_OPEN) - return -EBADFD; - - snd_power_lock(card); - if (runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) { - result = snd_power_wait(card, SNDRV_CTL_POWER_D0); - if (result < 0) { - snd_power_unlock(card); - return result; - } - } - - if (file) { - if (file->f_flags & O_NONBLOCK) - nonblock = 1; - } else if (substream->f_flags & O_NONBLOCK) - nonblock = 1; - - down_read(&snd_pcm_link_rwsem); - snd_pcm_stream_lock_irq(substream); - /* resume pause */ - if (runtime->status->state == SNDRV_PCM_STATE_PAUSED) - snd_pcm_pause(substream, 0); - - /* pre-start/stop - all running streams are changed to DRAINING state */ - result = snd_pcm_action(&snd_pcm_action_drain_init, substream, 0); - if (result < 0) - goto unlock; - /* in non-blocking, we don't wait in ioctl but let caller poll */ - if (nonblock) { - result = -EAGAIN; - goto unlock; - } - - for (;;) { - long tout; - struct snd_pcm_runtime *to_check; - if (signal_pending(current)) { - result = -ERESTARTSYS; - break; - } - /* find a substream to drain */ - to_check = NULL; - snd_pcm_group_for_each_entry(s, substream) { - if (s->stream != SNDRV_PCM_STREAM_PLAYBACK) - continue; - runtime = s->runtime; - if (runtime->status->state == SNDRV_PCM_STATE_DRAINING) { - to_check = runtime; - break; - } - } - if (!to_check) - break; /* all drained */ - init_waitqueue_entry(&wait, current); - add_wait_queue(&to_check->sleep, &wait); - set_current_state(TASK_INTERRUPTIBLE); - snd_pcm_stream_unlock_irq(substream); - up_read(&snd_pcm_link_rwsem); - snd_power_unlock(card); - tout = schedule_timeout(10 * HZ); - snd_power_lock(card); - down_read(&snd_pcm_link_rwsem); - snd_pcm_stream_lock_irq(substream); - remove_wait_queue(&to_check->sleep, &wait); - if (tout == 0) { - if (substream->runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) - result = -ESTRPIPE; - else { - snd_printd("playback drain error (DMA or IRQ trouble?)\n"); - snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); - result = -EIO; - } - break; - } - } - - unlock: - snd_pcm_stream_unlock_irq(substream); - up_read(&snd_pcm_link_rwsem); - snd_power_unlock(card); - - return result; -} - -/* - * drop ioctl - * - * Immediately put all linked substreams into SETUP state. - */ -static int snd_pcm_drop(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime; - struct snd_card *card; - int result = 0; - - if (PCM_RUNTIME_CHECK(substream)) - return -ENXIO; - runtime = substream->runtime; - card = substream->pcm->card; - - if (runtime->status->state == SNDRV_PCM_STATE_OPEN || - runtime->status->state == SNDRV_PCM_STATE_DISCONNECTED || - runtime->status->state == SNDRV_PCM_STATE_SUSPENDED) - return -EBADFD; - - snd_pcm_stream_lock_irq(substream); - /* resume pause */ - if (runtime->status->state == SNDRV_PCM_STATE_PAUSED) - snd_pcm_pause(substream, 0); - - snd_pcm_stop(substream, SNDRV_PCM_STATE_SETUP); - /* runtime->control->appl_ptr = runtime->status->hw_ptr; */ - snd_pcm_stream_unlock_irq(substream); - - return result; -} - - -/* WARNING: Don't forget to fput back the file */ -static struct file *snd_pcm_file_fd(int fd) -{ - struct file *file; - struct inode *inode; - unsigned int minor; - - file = fget(fd); - if (!file) - return NULL; - inode = file->f_path.dentry->d_inode; - if (!S_ISCHR(inode->i_mode) || - imajor(inode) != snd_major) { - fput(file); - return NULL; - } - minor = iminor(inode); - if (!snd_lookup_minor_data(minor, SNDRV_DEVICE_TYPE_PCM_PLAYBACK) && - !snd_lookup_minor_data(minor, SNDRV_DEVICE_TYPE_PCM_CAPTURE)) { - fput(file); - return NULL; - } - return file; -} - -/* - * PCM link handling - */ -static int snd_pcm_link(struct snd_pcm_substream *substream, int fd) -{ - int res = 0; - struct file *file; - struct snd_pcm_file *pcm_file; - struct snd_pcm_substream *substream1; - - file = snd_pcm_file_fd(fd); - if (!file) - return -EBADFD; - pcm_file = file->private_data; - substream1 = pcm_file->substream; - down_write(&snd_pcm_link_rwsem); - write_lock_irq(&snd_pcm_link_rwlock); - if (substream->runtime->status->state == SNDRV_PCM_STATE_OPEN || - substream->runtime->status->state != substream1->runtime->status->state) { - res = -EBADFD; - goto _end; - } - if (snd_pcm_stream_linked(substream1)) { - res = -EALREADY; - goto _end; - } - if (!snd_pcm_stream_linked(substream)) { - substream->group = kmalloc(sizeof(struct snd_pcm_group), GFP_ATOMIC); - if (substream->group == NULL) { - res = -ENOMEM; - goto _end; - } - spin_lock_init(&substream->group->lock); - INIT_LIST_HEAD(&substream->group->substreams); - list_add_tail(&substream->link_list, &substream->group->substreams); - substream->group->count = 1; - } - list_add_tail(&substream1->link_list, &substream->group->substreams); - substream->group->count++; - substream1->group = substream->group; - _end: - write_unlock_irq(&snd_pcm_link_rwlock); - up_write(&snd_pcm_link_rwsem); - fput(file); - return res; -} - -static void relink_to_local(struct snd_pcm_substream *substream) -{ - substream->group = &substream->self_group; - INIT_LIST_HEAD(&substream->self_group.substreams); - list_add_tail(&substream->link_list, &substream->self_group.substreams); -} - -static int snd_pcm_unlink(struct snd_pcm_substream *substream) -{ - struct snd_pcm_substream *s; - int res = 0; - - down_write(&snd_pcm_link_rwsem); - write_lock_irq(&snd_pcm_link_rwlock); - if (!snd_pcm_stream_linked(substream)) { - res = -EALREADY; - goto _end; - } - list_del(&substream->link_list); - substream->group->count--; - if (substream->group->count == 1) { /* detach the last stream, too */ - snd_pcm_group_for_each_entry(s, substream) { - relink_to_local(s); - break; - } - kfree(substream->group); - } - relink_to_local(substream); - _end: - write_unlock_irq(&snd_pcm_link_rwlock); - up_write(&snd_pcm_link_rwsem); - return res; -} - -/* - * hw configurator - */ -static int snd_pcm_hw_rule_mul(struct snd_pcm_hw_params *params, - struct snd_pcm_hw_rule *rule) -{ - struct snd_interval t; - snd_interval_mul(hw_param_interval_c(params, rule->deps[0]), - hw_param_interval_c(params, rule->deps[1]), &t); - return snd_interval_refine(hw_param_interval(params, rule->var), &t); -} - -static int snd_pcm_hw_rule_div(struct snd_pcm_hw_params *params, - struct snd_pcm_hw_rule *rule) -{ - struct snd_interval t; - snd_interval_div(hw_param_interval_c(params, rule->deps[0]), - hw_param_interval_c(params, rule->deps[1]), &t); - return snd_interval_refine(hw_param_interval(params, rule->var), &t); -} - -static int snd_pcm_hw_rule_muldivk(struct snd_pcm_hw_params *params, - struct snd_pcm_hw_rule *rule) -{ - struct snd_interval t; - snd_interval_muldivk(hw_param_interval_c(params, rule->deps[0]), - hw_param_interval_c(params, rule->deps[1]), - (unsigned long) rule->private, &t); - return snd_interval_refine(hw_param_interval(params, rule->var), &t); -} - -static int snd_pcm_hw_rule_mulkdiv(struct snd_pcm_hw_params *params, - struct snd_pcm_hw_rule *rule) -{ - struct snd_interval t; - snd_interval_mulkdiv(hw_param_interval_c(params, rule->deps[0]), - (unsigned long) rule->private, - hw_param_interval_c(params, rule->deps[1]), &t); - return snd_interval_refine(hw_param_interval(params, rule->var), &t); -} - -static int snd_pcm_hw_rule_format(struct snd_pcm_hw_params *params, - struct snd_pcm_hw_rule *rule) -{ - unsigned int k; - struct snd_interval *i = hw_param_interval(params, rule->deps[0]); - struct snd_mask m; - struct snd_mask *mask = hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT); - snd_mask_any(&m); - for (k = 0; k <= SNDRV_PCM_FORMAT_LAST; ++k) { - int bits; - if (! snd_mask_test(mask, k)) - continue; - bits = snd_pcm_format_physical_width(k); - if (bits <= 0) - continue; /* ignore invalid formats */ - if ((unsigned)bits < i->min || (unsigned)bits > i->max) - snd_mask_reset(&m, k); - } - return snd_mask_refine(mask, &m); -} - -static int snd_pcm_hw_rule_sample_bits(struct snd_pcm_hw_params *params, - struct snd_pcm_hw_rule *rule) -{ - struct snd_interval t; - unsigned int k; - t.min = UINT_MAX; - t.max = 0; - t.openmin = 0; - t.openmax = 0; - for (k = 0; k <= SNDRV_PCM_FORMAT_LAST; ++k) { - int bits; - if (! snd_mask_test(hw_param_mask(params, SNDRV_PCM_HW_PARAM_FORMAT), k)) - continue; - bits = snd_pcm_format_physical_width(k); - if (bits <= 0) - continue; /* ignore invalid formats */ - if (t.min > (unsigned)bits) - t.min = bits; - if (t.max < (unsigned)bits) - t.max = bits; - } - t.integer = 1; - return snd_interval_refine(hw_param_interval(params, rule->var), &t); -} - -#if SNDRV_PCM_RATE_5512 != 1 << 0 || SNDRV_PCM_RATE_192000 != 1 << 12 -#error "Change this table" -#endif - -static unsigned int rates[] = { 5512, 8000, 11025, 16000, 22050, 32000, 44100, - 48000, 64000, 88200, 96000, 176400, 192000 }; - -const struct snd_pcm_hw_constraint_list snd_pcm_known_rates = { - .count = ARRAY_SIZE(rates), - .list = rates, -}; - -static int snd_pcm_hw_rule_rate(struct snd_pcm_hw_params *params, - struct snd_pcm_hw_rule *rule) -{ - struct snd_pcm_hardware *hw = rule->private; - return snd_interval_list(hw_param_interval(params, rule->var), - snd_pcm_known_rates.count, - snd_pcm_known_rates.list, hw->rates); -} - -static int snd_pcm_hw_rule_buffer_bytes_max(struct snd_pcm_hw_params *params, - struct snd_pcm_hw_rule *rule) -{ - struct snd_interval t; - struct snd_pcm_substream *substream = rule->private; - t.min = 0; - t.max = substream->buffer_bytes_max; - t.openmin = 0; - t.openmax = 0; - t.integer = 1; - return snd_interval_refine(hw_param_interval(params, rule->var), &t); -} - -int snd_pcm_hw_constraints_init(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct snd_pcm_hw_constraints *constrs = &runtime->hw_constraints; - int k, err; - - for (k = SNDRV_PCM_HW_PARAM_FIRST_MASK; k <= SNDRV_PCM_HW_PARAM_LAST_MASK; k++) { - snd_mask_any(constrs_mask(constrs, k)); - } - - for (k = SNDRV_PCM_HW_PARAM_FIRST_INTERVAL; k <= SNDRV_PCM_HW_PARAM_LAST_INTERVAL; k++) { - snd_interval_any(constrs_interval(constrs, k)); - } - - snd_interval_setinteger(constrs_interval(constrs, SNDRV_PCM_HW_PARAM_CHANNELS)); - snd_interval_setinteger(constrs_interval(constrs, SNDRV_PCM_HW_PARAM_BUFFER_SIZE)); - snd_interval_setinteger(constrs_interval(constrs, SNDRV_PCM_HW_PARAM_BUFFER_BYTES)); - snd_interval_setinteger(constrs_interval(constrs, SNDRV_PCM_HW_PARAM_SAMPLE_BITS)); - snd_interval_setinteger(constrs_interval(constrs, SNDRV_PCM_HW_PARAM_FRAME_BITS)); - - err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FORMAT, - snd_pcm_hw_rule_format, NULL, - SNDRV_PCM_HW_PARAM_SAMPLE_BITS, -1); - if (err < 0) - return err; - err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_SAMPLE_BITS, - snd_pcm_hw_rule_sample_bits, NULL, - SNDRV_PCM_HW_PARAM_FORMAT, - SNDRV_PCM_HW_PARAM_SAMPLE_BITS, -1); - if (err < 0) - return err; - err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_SAMPLE_BITS, - snd_pcm_hw_rule_div, NULL, - SNDRV_PCM_HW_PARAM_FRAME_BITS, SNDRV_PCM_HW_PARAM_CHANNELS, -1); - if (err < 0) - return err; - err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FRAME_BITS, - snd_pcm_hw_rule_mul, NULL, - SNDRV_PCM_HW_PARAM_SAMPLE_BITS, SNDRV_PCM_HW_PARAM_CHANNELS, -1); - if (err < 0) - return err; - err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FRAME_BITS, - snd_pcm_hw_rule_mulkdiv, (void*) 8, - SNDRV_PCM_HW_PARAM_PERIOD_BYTES, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, -1); - if (err < 0) - return err; - err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_FRAME_BITS, - snd_pcm_hw_rule_mulkdiv, (void*) 8, - SNDRV_PCM_HW_PARAM_BUFFER_BYTES, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, -1); - if (err < 0) - return err; - err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_CHANNELS, - snd_pcm_hw_rule_div, NULL, - SNDRV_PCM_HW_PARAM_FRAME_BITS, SNDRV_PCM_HW_PARAM_SAMPLE_BITS, -1); - if (err < 0) - return err; - err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, - snd_pcm_hw_rule_mulkdiv, (void*) 1000000, - SNDRV_PCM_HW_PARAM_PERIOD_SIZE, SNDRV_PCM_HW_PARAM_PERIOD_TIME, -1); - if (err < 0) - return err; - err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, - snd_pcm_hw_rule_mulkdiv, (void*) 1000000, - SNDRV_PCM_HW_PARAM_BUFFER_SIZE, SNDRV_PCM_HW_PARAM_BUFFER_TIME, -1); - if (err < 0) - return err; - err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIODS, - snd_pcm_hw_rule_div, NULL, - SNDRV_PCM_HW_PARAM_BUFFER_SIZE, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, -1); - if (err < 0) - return err; - err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, - snd_pcm_hw_rule_div, NULL, - SNDRV_PCM_HW_PARAM_BUFFER_SIZE, SNDRV_PCM_HW_PARAM_PERIODS, -1); - if (err < 0) - return err; - err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, - snd_pcm_hw_rule_mulkdiv, (void*) 8, - SNDRV_PCM_HW_PARAM_PERIOD_BYTES, SNDRV_PCM_HW_PARAM_FRAME_BITS, -1); - if (err < 0) - return err; - err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_SIZE, - snd_pcm_hw_rule_muldivk, (void*) 1000000, - SNDRV_PCM_HW_PARAM_PERIOD_TIME, SNDRV_PCM_HW_PARAM_RATE, -1); - if (err < 0) - return err; - err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, - snd_pcm_hw_rule_mul, NULL, - SNDRV_PCM_HW_PARAM_PERIOD_SIZE, SNDRV_PCM_HW_PARAM_PERIODS, -1); - if (err < 0) - return err; - err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, - snd_pcm_hw_rule_mulkdiv, (void*) 8, - SNDRV_PCM_HW_PARAM_BUFFER_BYTES, SNDRV_PCM_HW_PARAM_FRAME_BITS, -1); - if (err < 0) - return err; - err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_SIZE, - snd_pcm_hw_rule_muldivk, (void*) 1000000, - SNDRV_PCM_HW_PARAM_BUFFER_TIME, SNDRV_PCM_HW_PARAM_RATE, -1); - if (err < 0) - return err; - err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, - snd_pcm_hw_rule_muldivk, (void*) 8, - SNDRV_PCM_HW_PARAM_PERIOD_SIZE, SNDRV_PCM_HW_PARAM_FRAME_BITS, -1); - if (err < 0) - return err; - err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, - snd_pcm_hw_rule_muldivk, (void*) 8, - SNDRV_PCM_HW_PARAM_BUFFER_SIZE, SNDRV_PCM_HW_PARAM_FRAME_BITS, -1); - if (err < 0) - return err; - err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_PERIOD_TIME, - snd_pcm_hw_rule_mulkdiv, (void*) 1000000, - SNDRV_PCM_HW_PARAM_PERIOD_SIZE, SNDRV_PCM_HW_PARAM_RATE, -1); - if (err < 0) - return err; - err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_TIME, - snd_pcm_hw_rule_mulkdiv, (void*) 1000000, - SNDRV_PCM_HW_PARAM_BUFFER_SIZE, SNDRV_PCM_HW_PARAM_RATE, -1); - if (err < 0) - return err; - return 0; -} - -int snd_pcm_hw_constraints_complete(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct snd_pcm_hardware *hw = &runtime->hw; - int err; - unsigned int mask = 0; - - if (hw->info & SNDRV_PCM_INFO_INTERLEAVED) - mask |= 1 << SNDRV_PCM_ACCESS_RW_INTERLEAVED; - if (hw->info & SNDRV_PCM_INFO_NONINTERLEAVED) - mask |= 1 << SNDRV_PCM_ACCESS_RW_NONINTERLEAVED; - if (hw->info & SNDRV_PCM_INFO_MMAP) { - if (hw->info & SNDRV_PCM_INFO_INTERLEAVED) - mask |= 1 << SNDRV_PCM_ACCESS_MMAP_INTERLEAVED; - if (hw->info & SNDRV_PCM_INFO_NONINTERLEAVED) - mask |= 1 << SNDRV_PCM_ACCESS_MMAP_NONINTERLEAVED; - if (hw->info & SNDRV_PCM_INFO_COMPLEX) - mask |= 1 << SNDRV_PCM_ACCESS_MMAP_COMPLEX; - } - err = snd_pcm_hw_constraint_mask(runtime, SNDRV_PCM_HW_PARAM_ACCESS, mask); - if (err < 0) - return err; - - err = snd_pcm_hw_constraint_mask64(runtime, SNDRV_PCM_HW_PARAM_FORMAT, hw->formats); - if (err < 0) - return err; - - err = snd_pcm_hw_constraint_mask(runtime, SNDRV_PCM_HW_PARAM_SUBFORMAT, 1 << SNDRV_PCM_SUBFORMAT_STD); - if (err < 0) - return err; - - err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_CHANNELS, - hw->channels_min, hw->channels_max); - if (err < 0) - return err; - - err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_RATE, - hw->rate_min, hw->rate_max); - if (err < 0) - return err; - - err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIOD_BYTES, - hw->period_bytes_min, hw->period_bytes_max); - if (err < 0) - return err; - - err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_PERIODS, - hw->periods_min, hw->periods_max); - if (err < 0) - return err; - - err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, - hw->period_bytes_min, hw->buffer_bytes_max); - if (err < 0) - return err; - - err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, - snd_pcm_hw_rule_buffer_bytes_max, substream, - SNDRV_PCM_HW_PARAM_BUFFER_BYTES, -1); - if (err < 0) - return err; - - /* FIXME: remove */ - if (runtime->dma_bytes) { - err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 0, runtime->dma_bytes); - if (err < 0) - return -EINVAL; - } - - if (!(hw->rates & (SNDRV_PCM_RATE_KNOT | SNDRV_PCM_RATE_CONTINUOUS))) { - err = snd_pcm_hw_rule_add(runtime, 0, SNDRV_PCM_HW_PARAM_RATE, - snd_pcm_hw_rule_rate, hw, - SNDRV_PCM_HW_PARAM_RATE, -1); - if (err < 0) - return err; - } - - /* FIXME: this belong to lowlevel */ - snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIOD_SIZE); - - return 0; -} - -static void pcm_release_private(struct snd_pcm_substream *substream) -{ - snd_pcm_unlink(substream); -} - -void snd_pcm_release_substream(struct snd_pcm_substream *substream) -{ - substream->ref_count--; - if (substream->ref_count > 0) - return; - - snd_pcm_drop(substream); - if (substream->hw_opened) { - if (substream->ops->hw_free != NULL) - substream->ops->hw_free(substream); - substream->ops->close(substream); - substream->hw_opened = 0; - } - if (substream->pcm_release) { - substream->pcm_release(substream); - substream->pcm_release = NULL; - } - snd_pcm_detach_substream(substream); -} - -EXPORT_SYMBOL(snd_pcm_release_substream); - -int snd_pcm_open_substream(struct snd_pcm *pcm, int stream, - struct file *file, - struct snd_pcm_substream **rsubstream) -{ - struct snd_pcm_substream *substream; - int err; - - err = snd_pcm_attach_substream(pcm, stream, file, &substream); - if (err < 0) - return err; - if (substream->ref_count > 1) { - *rsubstream = substream; - return 0; - } - - err = snd_pcm_hw_constraints_init(substream); - if (err < 0) { - snd_printd("snd_pcm_hw_constraints_init failed\n"); - goto error; - } - - if ((err = substream->ops->open(substream)) < 0) - goto error; - - substream->hw_opened = 1; - - err = snd_pcm_hw_constraints_complete(substream); - if (err < 0) { - snd_printd("snd_pcm_hw_constraints_complete failed\n"); - goto error; - } - - *rsubstream = substream; - return 0; - - error: - snd_pcm_release_substream(substream); - return err; -} - -EXPORT_SYMBOL(snd_pcm_open_substream); - -static int snd_pcm_open_file(struct file *file, - struct snd_pcm *pcm, - int stream, - struct snd_pcm_file **rpcm_file) -{ - struct snd_pcm_file *pcm_file; - struct snd_pcm_substream *substream; - struct snd_pcm_str *str; - int err; - - if (rpcm_file) - *rpcm_file = NULL; - - err = snd_pcm_open_substream(pcm, stream, file, &substream); - if (err < 0) - return err; - - pcm_file = kzalloc(sizeof(*pcm_file), GFP_KERNEL); - if (pcm_file == NULL) { - snd_pcm_release_substream(substream); - return -ENOMEM; - } - pcm_file->substream = substream; - if (substream->ref_count == 1) { - str = substream->pstr; - substream->file = pcm_file; - substream->pcm_release = pcm_release_private; - } - file->private_data = pcm_file; - if (rpcm_file) - *rpcm_file = pcm_file; - return 0; -} - -static int snd_pcm_playback_open(struct inode *inode, struct file *file) -{ - struct snd_pcm *pcm; - int err = nonseekable_open(inode, file); - if (err < 0) - return err; - pcm = snd_lookup_minor_data(iminor(inode), - SNDRV_DEVICE_TYPE_PCM_PLAYBACK); - return snd_pcm_open(file, pcm, SNDRV_PCM_STREAM_PLAYBACK); -} - -static int snd_pcm_capture_open(struct inode *inode, struct file *file) -{ - struct snd_pcm *pcm; - int err = nonseekable_open(inode, file); - if (err < 0) - return err; - pcm = snd_lookup_minor_data(iminor(inode), - SNDRV_DEVICE_TYPE_PCM_CAPTURE); - return snd_pcm_open(file, pcm, SNDRV_PCM_STREAM_CAPTURE); -} - -static int snd_pcm_open(struct file *file, struct snd_pcm *pcm, int stream) -{ - int err; - struct snd_pcm_file *pcm_file; - wait_queue_t wait; - - if (pcm == NULL) { - err = -ENODEV; - goto __error1; - } - err = snd_card_file_add(pcm->card, file); - if (err < 0) - goto __error1; - if (!try_module_get(pcm->card->module)) { - err = -EFAULT; - goto __error2; - } - init_waitqueue_entry(&wait, current); - add_wait_queue(&pcm->open_wait, &wait); - mutex_lock(&pcm->open_mutex); - while (1) { - err = snd_pcm_open_file(file, pcm, stream, &pcm_file); - if (err >= 0) - break; - if (err == -EAGAIN) { - if (file->f_flags & O_NONBLOCK) { - err = -EBUSY; - break; - } - } else - break; - set_current_state(TASK_INTERRUPTIBLE); - mutex_unlock(&pcm->open_mutex); - schedule(); - mutex_lock(&pcm->open_mutex); - if (signal_pending(current)) { - err = -ERESTARTSYS; - break; - } - } - remove_wait_queue(&pcm->open_wait, &wait); - mutex_unlock(&pcm->open_mutex); - if (err < 0) - goto __error; - return err; - - __error: - module_put(pcm->card->module); - __error2: - snd_card_file_remove(pcm->card, file); - __error1: - return err; -} - -static int snd_pcm_release(struct inode *inode, struct file *file) -{ - struct snd_pcm *pcm; - struct snd_pcm_substream *substream; - struct snd_pcm_file *pcm_file; - - pcm_file = file->private_data; - substream = pcm_file->substream; - if (snd_BUG_ON(!substream)) - return -ENXIO; - pcm = substream->pcm; - mutex_lock(&pcm->open_mutex); - snd_pcm_release_substream(substream); - kfree(pcm_file); - mutex_unlock(&pcm->open_mutex); - wake_up(&pcm->open_wait); - module_put(pcm->card->module); - snd_card_file_remove(pcm->card, file); - return 0; -} - -static snd_pcm_sframes_t snd_pcm_playback_rewind(struct snd_pcm_substream *substream, - snd_pcm_uframes_t frames) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - snd_pcm_sframes_t appl_ptr; - snd_pcm_sframes_t ret; - snd_pcm_sframes_t hw_avail; - - if (frames == 0) - return 0; - - snd_pcm_stream_lock_irq(substream); - switch (runtime->status->state) { - case SNDRV_PCM_STATE_PREPARED: - break; - case SNDRV_PCM_STATE_DRAINING: - case SNDRV_PCM_STATE_RUNNING: - if (snd_pcm_update_hw_ptr(substream) >= 0) - break; - /* Fall through */ - case SNDRV_PCM_STATE_XRUN: - ret = -EPIPE; - goto __end; - case SNDRV_PCM_STATE_SUSPENDED: - ret = -ESTRPIPE; - goto __end; - default: - ret = -EBADFD; - goto __end; - } - - hw_avail = snd_pcm_playback_hw_avail(runtime); - if (hw_avail <= 0) { - ret = 0; - goto __end; - } - if (frames > (snd_pcm_uframes_t)hw_avail) - frames = hw_avail; - appl_ptr = runtime->control->appl_ptr - frames; - if (appl_ptr < 0) - appl_ptr += runtime->boundary; - runtime->control->appl_ptr = appl_ptr; - ret = frames; - __end: - snd_pcm_stream_unlock_irq(substream); - return ret; -} - -static snd_pcm_sframes_t snd_pcm_capture_rewind(struct snd_pcm_substream *substream, - snd_pcm_uframes_t frames) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - snd_pcm_sframes_t appl_ptr; - snd_pcm_sframes_t ret; - snd_pcm_sframes_t hw_avail; - - if (frames == 0) - return 0; - - snd_pcm_stream_lock_irq(substream); - switch (runtime->status->state) { - case SNDRV_PCM_STATE_PREPARED: - case SNDRV_PCM_STATE_DRAINING: - break; - case SNDRV_PCM_STATE_RUNNING: - if (snd_pcm_update_hw_ptr(substream) >= 0) - break; - /* Fall through */ - case SNDRV_PCM_STATE_XRUN: - ret = -EPIPE; - goto __end; - case SNDRV_PCM_STATE_SUSPENDED: - ret = -ESTRPIPE; - goto __end; - default: - ret = -EBADFD; - goto __end; - } - - hw_avail = snd_pcm_capture_hw_avail(runtime); - if (hw_avail <= 0) { - ret = 0; - goto __end; - } - if (frames > (snd_pcm_uframes_t)hw_avail) - frames = hw_avail; - appl_ptr = runtime->control->appl_ptr - frames; - if (appl_ptr < 0) - appl_ptr += runtime->boundary; - runtime->control->appl_ptr = appl_ptr; - ret = frames; - __end: - snd_pcm_stream_unlock_irq(substream); - return ret; -} - -static snd_pcm_sframes_t snd_pcm_playback_forward(struct snd_pcm_substream *substream, - snd_pcm_uframes_t frames) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - snd_pcm_sframes_t appl_ptr; - snd_pcm_sframes_t ret; - snd_pcm_sframes_t avail; - - if (frames == 0) - return 0; - - snd_pcm_stream_lock_irq(substream); - switch (runtime->status->state) { - case SNDRV_PCM_STATE_PREPARED: - case SNDRV_PCM_STATE_PAUSED: - break; - case SNDRV_PCM_STATE_DRAINING: - case SNDRV_PCM_STATE_RUNNING: - if (snd_pcm_update_hw_ptr(substream) >= 0) - break; - /* Fall through */ - case SNDRV_PCM_STATE_XRUN: - ret = -EPIPE; - goto __end; - case SNDRV_PCM_STATE_SUSPENDED: - ret = -ESTRPIPE; - goto __end; - default: - ret = -EBADFD; - goto __end; - } - - avail = snd_pcm_playback_avail(runtime); - if (avail <= 0) { - ret = 0; - goto __end; - } - if (frames > (snd_pcm_uframes_t)avail) - frames = avail; - appl_ptr = runtime->control->appl_ptr + frames; - if (appl_ptr >= (snd_pcm_sframes_t)runtime->boundary) - appl_ptr -= runtime->boundary; - runtime->control->appl_ptr = appl_ptr; - ret = frames; - __end: - snd_pcm_stream_unlock_irq(substream); - return ret; -} - -static snd_pcm_sframes_t snd_pcm_capture_forward(struct snd_pcm_substream *substream, - snd_pcm_uframes_t frames) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - snd_pcm_sframes_t appl_ptr; - snd_pcm_sframes_t ret; - snd_pcm_sframes_t avail; - - if (frames == 0) - return 0; - - snd_pcm_stream_lock_irq(substream); - switch (runtime->status->state) { - case SNDRV_PCM_STATE_PREPARED: - case SNDRV_PCM_STATE_DRAINING: - case SNDRV_PCM_STATE_PAUSED: - break; - case SNDRV_PCM_STATE_RUNNING: - if (snd_pcm_update_hw_ptr(substream) >= 0) - break; - /* Fall through */ - case SNDRV_PCM_STATE_XRUN: - ret = -EPIPE; - goto __end; - case SNDRV_PCM_STATE_SUSPENDED: - ret = -ESTRPIPE; - goto __end; - default: - ret = -EBADFD; - goto __end; - } - - avail = snd_pcm_capture_avail(runtime); - if (avail <= 0) { - ret = 0; - goto __end; - } - if (frames > (snd_pcm_uframes_t)avail) - frames = avail; - appl_ptr = runtime->control->appl_ptr + frames; - if (appl_ptr >= (snd_pcm_sframes_t)runtime->boundary) - appl_ptr -= runtime->boundary; - runtime->control->appl_ptr = appl_ptr; - ret = frames; - __end: - snd_pcm_stream_unlock_irq(substream); - return ret; -} - -static int snd_pcm_hwsync(struct snd_pcm_substream *substream) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - int err; - - snd_pcm_stream_lock_irq(substream); - switch (runtime->status->state) { - case SNDRV_PCM_STATE_DRAINING: - if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - goto __badfd; - case SNDRV_PCM_STATE_RUNNING: - if ((err = snd_pcm_update_hw_ptr(substream)) < 0) - break; - /* Fall through */ - case SNDRV_PCM_STATE_PREPARED: - case SNDRV_PCM_STATE_SUSPENDED: - err = 0; - break; - case SNDRV_PCM_STATE_XRUN: - err = -EPIPE; - break; - default: - __badfd: - err = -EBADFD; - break; - } - snd_pcm_stream_unlock_irq(substream); - return err; -} - -static int snd_pcm_delay(struct snd_pcm_substream *substream, - snd_pcm_sframes_t __user *res) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - int err; - snd_pcm_sframes_t n = 0; - - //giovanni snd_pcm_stream_lock_irq(substream); - switch (runtime->status->state) { - case SNDRV_PCM_STATE_DRAINING: - if (substream->stream == SNDRV_PCM_STREAM_CAPTURE) - goto __badfd; - case SNDRV_PCM_STATE_RUNNING: - if ((err = snd_pcm_update_hw_ptr(substream)) < 0) - break; - /* Fall through */ - case SNDRV_PCM_STATE_PREPARED: - case SNDRV_PCM_STATE_SUSPENDED: - err = 0; - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) - n = snd_pcm_playback_hw_avail(runtime); - else - n = snd_pcm_capture_avail(runtime); - n += runtime->delay; - break; - case SNDRV_PCM_STATE_XRUN: - err = -EPIPE; - break; - default: - __badfd: - err = -EBADFD; - break; - } - //giovanni snd_pcm_stream_unlock_irq(substream); - if (!err) - if (put_user(n, res)) - err = -EFAULT; - return err; -} - -static int snd_pcm_sync_ptr(struct snd_pcm_substream *substream, - struct snd_pcm_sync_ptr __user *_sync_ptr) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - struct snd_pcm_sync_ptr sync_ptr; - volatile struct snd_pcm_mmap_status *status; - volatile struct snd_pcm_mmap_control *control; - int err; - - memset(&sync_ptr, 0, sizeof(sync_ptr)); - if (get_user(sync_ptr.flags, (unsigned __user *)&(_sync_ptr->flags))) - return -EFAULT; - if (copy_from_user(&sync_ptr.c.control, &(_sync_ptr->c.control), sizeof(struct snd_pcm_mmap_control))) - return -EFAULT; - status = runtime->status; - control = runtime->control; - if (sync_ptr.flags & SNDRV_PCM_SYNC_PTR_HWSYNC) { - err = snd_pcm_hwsync(substream); - if (err < 0) - return err; - } - //giovanni snd_pcm_stream_lock_irq(substream); - if (!(sync_ptr.flags & SNDRV_PCM_SYNC_PTR_APPL)) - control->appl_ptr = sync_ptr.c.control.appl_ptr; - else - sync_ptr.c.control.appl_ptr = control->appl_ptr; - if (!(sync_ptr.flags & SNDRV_PCM_SYNC_PTR_AVAIL_MIN)) - control->avail_min = sync_ptr.c.control.avail_min; - else - sync_ptr.c.control.avail_min = control->avail_min; - sync_ptr.s.status.state = status->state; - sync_ptr.s.status.hw_ptr = status->hw_ptr; - sync_ptr.s.status.tstamp = status->tstamp; - sync_ptr.s.status.suspended_state = status->suspended_state; - //giovanni snd_pcm_stream_unlock_irq(substream); - if (copy_to_user(_sync_ptr, &sync_ptr, sizeof(sync_ptr))) - return -EFAULT; - return 0; -} - -static int snd_pcm_tstamp(struct snd_pcm_substream *substream, int __user *_arg) -{ - struct snd_pcm_runtime *runtime = substream->runtime; - int arg; - - if (get_user(arg, _arg)) - return -EFAULT; - if (arg < 0 || arg > SNDRV_PCM_TSTAMP_TYPE_LAST) - return -EINVAL; - runtime->tstamp_type = SNDRV_PCM_TSTAMP_TYPE_GETTIMEOFDAY; - if (arg == SNDRV_PCM_TSTAMP_TYPE_MONOTONIC) - runtime->tstamp_type = SNDRV_PCM_TSTAMP_TYPE_MONOTONIC; - return 0; -} - -static int snd_pcm_common_ioctl1(struct file *file, - struct snd_pcm_substream *substream, - unsigned int cmd, void __user *arg) -{ - switch (cmd) { - case SNDRV_PCM_IOCTL_PVERSION: - return put_user(SNDRV_PCM_VERSION, (int __user *)arg) ? -EFAULT : 0; - case SNDRV_PCM_IOCTL_INFO: - return snd_pcm_info_user(substream, arg); - case SNDRV_PCM_IOCTL_TSTAMP: /* just for compatibility */ - return 0; - case SNDRV_PCM_IOCTL_TTSTAMP: - return snd_pcm_tstamp(substream, arg); - case SNDRV_PCM_IOCTL_HW_REFINE: - return snd_pcm_hw_refine_user(substream, arg); - case SNDRV_PCM_IOCTL_HW_PARAMS: - return snd_pcm_hw_params_user(substream, arg); - case SNDRV_PCM_IOCTL_HW_FREE: - return snd_pcm_hw_free(substream); - case SNDRV_PCM_IOCTL_SW_PARAMS: - return snd_pcm_sw_params_user(substream, arg); - case SNDRV_PCM_IOCTL_STATUS: - return snd_pcm_status_user(substream, arg); - case SNDRV_PCM_IOCTL_CHANNEL_INFO: - return snd_pcm_channel_info_user(substream, arg); - case SNDRV_PCM_IOCTL_PREPARE: - return snd_pcm_prepare(substream, file); - case SNDRV_PCM_IOCTL_RESET: - return snd_pcm_reset(substream); - case SNDRV_PCM_IOCTL_START: - return snd_pcm_action_lock_irq(&snd_pcm_action_start, substream, SNDRV_PCM_STATE_RUNNING); - case SNDRV_PCM_IOCTL_LINK: - return snd_pcm_link(substream, (int)(unsigned long) arg); - case SNDRV_PCM_IOCTL_UNLINK: - return snd_pcm_unlink(substream); - case SNDRV_PCM_IOCTL_RESUME: - return snd_pcm_resume(substream); - case SNDRV_PCM_IOCTL_XRUN: - return snd_pcm_xrun(substream); - case SNDRV_PCM_IOCTL_HWSYNC: - return snd_pcm_hwsync(substream); - case SNDRV_PCM_IOCTL_DELAY: - return snd_pcm_delay(substream, arg); - case SNDRV_PCM_IOCTL_SYNC_PTR: - return snd_pcm_sync_ptr(substream, arg); -#ifdef CONFIG_SND_SUPPORT_OLD_API - case SNDRV_PCM_IOCTL_HW_REFINE_OLD: - return snd_pcm_hw_refine_old_user(substream, arg); - case SNDRV_PCM_IOCTL_HW_PARAMS_OLD: - return snd_pcm_hw_params_old_user(substream, arg); -#endif - case SNDRV_PCM_IOCTL_DRAIN: - return snd_pcm_drain(substream, file); - case SNDRV_PCM_IOCTL_DROP: - return snd_pcm_drop(substream); - case SNDRV_PCM_IOCTL_PAUSE: - { - int res; - snd_pcm_stream_lock_irq(substream); - res = snd_pcm_pause(substream, (int)(unsigned long)arg); - snd_pcm_stream_unlock_irq(substream); - return res; - } - } - snd_printd("unknown ioctl = 0x%x\n", cmd); - return -ENOTTY; -} - -static int snd_pcm_playback_ioctl1(struct file *file, - struct snd_pcm_substream *substream, - unsigned int cmd, void __user *arg) -{ - if (snd_BUG_ON(!substream)) - return -ENXIO; - if (snd_BUG_ON(substream->stream != SNDRV_PCM_STREAM_PLAYBACK)) - return -EINVAL; - switch (cmd) { - case SNDRV_PCM_IOCTL_WRITEI_FRAMES: - { - struct snd_xferi xferi; - struct snd_xferi __user *_xferi = arg; - struct snd_pcm_runtime *runtime = substream->runtime; - snd_pcm_sframes_t result; - if (runtime->status->state == SNDRV_PCM_STATE_OPEN) - return -EBADFD; - if (put_user(0, &_xferi->result)) - return -EFAULT; - if (copy_from_user(&xferi, _xferi, sizeof(xferi))) - return -EFAULT; - result = snd_pcm_lib_write(substream, xferi.buf, xferi.frames); - __put_user(result, &_xferi->result); - return result < 0 ? result : 0; - } - case SNDRV_PCM_IOCTL_WRITEN_FRAMES: - { - struct snd_xfern xfern; - struct snd_xfern __user *_xfern = arg; - struct snd_pcm_runtime *runtime = substream->runtime; - void __user **bufs; - snd_pcm_sframes_t result; - if (runtime->status->state == SNDRV_PCM_STATE_OPEN) - return -EBADFD; - if (runtime->channels > 128) - return -EINVAL; - if (put_user(0, &_xfern->result)) - return -EFAULT; - if (copy_from_user(&xfern, _xfern, sizeof(xfern))) - return -EFAULT; - - bufs = memdup_user(xfern.bufs, - sizeof(void *) * runtime->channels); - if (IS_ERR(bufs)) - return PTR_ERR(bufs); - result = snd_pcm_lib_writev(substream, bufs, xfern.frames); - kfree(bufs); - __put_user(result, &_xfern->result); - return result < 0 ? result : 0; - } - case SNDRV_PCM_IOCTL_REWIND: - { - snd_pcm_uframes_t frames; - snd_pcm_uframes_t __user *_frames = arg; - snd_pcm_sframes_t result; - if (get_user(frames, _frames)) - return -EFAULT; - if (put_user(0, _frames)) - return -EFAULT; - result = snd_pcm_playback_rewind(substream, frames); - __put_user(result, _frames); - return result < 0 ? result : 0; - } - case SNDRV_PCM_IOCTL_FORWARD: - { - snd_pcm_uframes_t frames; - snd_pcm_uframes_t __user *_frames = arg; - snd_pcm_sframes_t result; - if (get_user(frames, _frames)) - return -EFAULT; - if (put_user(0, _frames)) - return -EFAULT; - result = snd_pcm_playback_forward(substream, frames); - __put_user(result, _frames); - return result < 0 ? result : 0; - } - } - return snd_pcm_common_ioctl1(file, substream, cmd, arg); -} - -static int snd_pcm_capture_ioctl1(struct file *file, - struct snd_pcm_substream *substream, - unsigned int cmd, void __user *arg) -{ - if (snd_BUG_ON(!substream)) - return -ENXIO; - if (snd_BUG_ON(substream->stream != SNDRV_PCM_STREAM_CAPTURE)) - return -EINVAL; - switch (cmd) { - case SNDRV_PCM_IOCTL_READI_FRAMES: - { - struct snd_xferi xferi; - struct snd_xferi __user *_xferi = arg; - struct snd_pcm_runtime *runtime = substream->runtime; - snd_pcm_sframes_t result; - if (runtime->status->state == SNDRV_PCM_STATE_OPEN) - return -EBADFD; - if (put_user(0, &_xferi->result)) - return -EFAULT; - if (copy_from_user(&xferi, _xferi, sizeof(xferi))) - return -EFAULT; - result = snd_pcm_lib_read(substream, xferi.buf, xferi.frames); - __put_user(result, &_xferi->result); - return result < 0 ? result : 0; - } - case SNDRV_PCM_IOCTL_READN_FRAMES: - { - struct snd_xfern xfern; - struct snd_xfern __user *_xfern = arg; - struct snd_pcm_runtime *runtime = substream->runtime; - void *bufs; - snd_pcm_sframes_t result; - if (runtime->status->state == SNDRV_PCM_STATE_OPEN) - return -EBADFD; - if (runtime->channels > 128) - return -EINVAL; - if (put_user(0, &_xfern->result)) - return -EFAULT; - if (copy_from_user(&xfern, _xfern, sizeof(xfern))) - return -EFAULT; - - bufs = memdup_user(xfern.bufs, - sizeof(void *) * runtime->channels); - if (IS_ERR(bufs)) - return PTR_ERR(bufs); - result = snd_pcm_lib_readv(substream, bufs, xfern.frames); - kfree(bufs); - __put_user(result, &_xfern->result); - return result < 0 ? result : 0; - } - case SNDRV_PCM_IOCTL_REWIND: - { - snd_pcm_uframes_t frames; - snd_pcm_uframes_t __user *_frames = arg; - snd_pcm_sframes_t result; - if (get_user(frames, _frames)) - return -EFAULT; - if (put_user(0, _frames)) - return -EFAULT; - result = snd_pcm_capture_rewind(substream, frames); - __put_user(result, _frames); - return result < 0 ? result : 0; - } - case SNDRV_PCM_IOCTL_FORWARD: - { - snd_pcm_uframes_t frames; - snd_pcm_uframes_t __user *_frames = arg; - snd_pcm_sframes_t result; - if (get_user(frames, _frames)) - return -EFAULT; - if (put_user(0, _frames)) - return -EFAULT; - result = snd_pcm_capture_forward(substream, frames); - __put_user(result, _frames); - return result < 0 ? result : 0; - } - } - return snd_pcm_common_ioctl1(file, substream, cmd, arg); -} - -static long snd_pcm_playback_ioctl(struct file *file, unsigned int cmd, - unsigned long arg) -{ - struct snd_pcm_file *pcm_file; - - pcm_file = file->private_data; - - if (((cmd >> 8) & 0xff) != 'A') - return -ENOTTY; - - return snd_pcm_playback_ioctl1(file, pcm_file->substream, cmd, - (void __user *)arg); -} - -static long snd_pcm_capture_ioctl(struct file *file, unsigned int cmd, - unsigned long arg) -{ - struct snd_pcm_file *pcm_file; - - pcm_file = file->private_data; - - if (((cmd >> 8) & 0xff) != 'A') - return -ENOTTY; - - return snd_pcm_capture_ioctl1(file, pcm_file->substream, cmd, - (void __user *)arg); -} - -int snd_pcm_kernel_ioctl(struct snd_pcm_substream *substream, - unsigned int cmd, void *arg) -{ - mm_segment_t fs; - int result; - - fs = snd_enter_user(); - switch (substream->stream) { - case SNDRV_PCM_STREAM_PLAYBACK: - result = snd_pcm_playback_ioctl1(NULL, substream, cmd, - (void __user *)arg); - break; - case SNDRV_PCM_STREAM_CAPTURE: - result = snd_pcm_capture_ioctl1(NULL, substream, cmd, - (void __user *)arg); - break; - default: - result = -EINVAL; - break; - } - snd_leave_user(fs); - return result; -} - -EXPORT_SYMBOL(snd_pcm_kernel_ioctl); - -static ssize_t snd_pcm_read(struct file *file, char __user *buf, size_t count, - loff_t * offset) -{ - struct snd_pcm_file *pcm_file; - struct snd_pcm_substream *substream; - struct snd_pcm_runtime *runtime; - snd_pcm_sframes_t result; - - pcm_file = file->private_data; - substream = pcm_file->substream; - if (PCM_RUNTIME_CHECK(substream)) - return -ENXIO; - runtime = substream->runtime; - if (runtime->status->state == SNDRV_PCM_STATE_OPEN) - return -EBADFD; - if (!frame_aligned(runtime, count)) - return -EINVAL; - count = bytes_to_frames(runtime, count); - result = snd_pcm_lib_read(substream, buf, count); - if (result > 0) - result = frames_to_bytes(runtime, result); - return result; -} - -static ssize_t snd_pcm_write(struct file *file, const char __user *buf, - size_t count, loff_t * offset) -{ - struct snd_pcm_file *pcm_file; - struct snd_pcm_substream *substream; - struct snd_pcm_runtime *runtime; - snd_pcm_sframes_t result; - - pcm_file = file->private_data; - substream = pcm_file->substream; - if (PCM_RUNTIME_CHECK(substream)) - return -ENXIO; - runtime = substream->runtime; - if (runtime->status->state == SNDRV_PCM_STATE_OPEN) - return -EBADFD; - if (!frame_aligned(runtime, count)) - return -EINVAL; - count = bytes_to_frames(runtime, count); - result = snd_pcm_lib_write(substream, buf, count); - if (result > 0) - result = frames_to_bytes(runtime, result); - return result; -} - -static ssize_t snd_pcm_aio_read(struct kiocb *iocb, const struct iovec *iov, - unsigned long nr_segs, loff_t pos) - -{ - struct snd_pcm_file *pcm_file; - struct snd_pcm_substream *substream; - struct snd_pcm_runtime *runtime; - snd_pcm_sframes_t result; - unsigned long i; - void __user **bufs; - snd_pcm_uframes_t frames; - - pcm_file = iocb->ki_filp->private_data; - substream = pcm_file->substream; - if (PCM_RUNTIME_CHECK(substream)) - return -ENXIO; - runtime = substream->runtime; - if (runtime->status->state == SNDRV_PCM_STATE_OPEN) - return -EBADFD; - if (nr_segs > 1024 || nr_segs != runtime->channels) - return -EINVAL; - if (!frame_aligned(runtime, iov->iov_len)) - return -EINVAL; - frames = bytes_to_samples(runtime, iov->iov_len); - bufs = kmalloc(sizeof(void *) * nr_segs, GFP_KERNEL); - if (bufs == NULL) - return -ENOMEM; - for (i = 0; i < nr_segs; ++i) - bufs[i] = iov[i].iov_base; - result = snd_pcm_lib_readv(substream, bufs, frames); - if (result > 0) - result = frames_to_bytes(runtime, result); - kfree(bufs); - return result; -} - -static ssize_t snd_pcm_aio_write(struct kiocb *iocb, const struct iovec *iov, - unsigned long nr_segs, loff_t pos) -{ - struct snd_pcm_file *pcm_file; - struct snd_pcm_substream *substream; - struct snd_pcm_runtime *runtime; - snd_pcm_sframes_t result; - unsigned long i; - void __user **bufs; - snd_pcm_uframes_t frames; - - pcm_file = iocb->ki_filp->private_data; - substream = pcm_file->substream; - if (PCM_RUNTIME_CHECK(substream)) - return -ENXIO; - runtime = substream->runtime; - if (runtime->status->state == SNDRV_PCM_STATE_OPEN) - return -EBADFD; - if (nr_segs > 128 || nr_segs != runtime->channels || - !frame_aligned(runtime, iov->iov_len)) - return -EINVAL; - frames = bytes_to_samples(runtime, iov->iov_len); - bufs = kmalloc(sizeof(void *) * nr_segs, GFP_KERNEL); - if (bufs == NULL) - return -ENOMEM; - for (i = 0; i < nr_segs; ++i) - bufs[i] = iov[i].iov_base; - result = snd_pcm_lib_writev(substream, bufs, frames); - if (result > 0) - result = frames_to_bytes(runtime, result); - kfree(bufs); - return result; -} - -static unsigned int snd_pcm_playback_poll(struct file *file, poll_table * wait) -{ - struct snd_pcm_file *pcm_file; - struct snd_pcm_substream *substream; - struct snd_pcm_runtime *runtime; - unsigned int mask; - snd_pcm_uframes_t avail; - - pcm_file = file->private_data; - - substream = pcm_file->substream; - if (PCM_RUNTIME_CHECK(substream)) - return -ENXIO; - runtime = substream->runtime; - - poll_wait(file, &runtime->sleep, wait); - - //giovanni snd_pcm_stream_lock_irq(substream); - avail = snd_pcm_playback_avail(runtime); - switch (runtime->status->state) { - case SNDRV_PCM_STATE_RUNNING: - case SNDRV_PCM_STATE_PREPARED: - case SNDRV_PCM_STATE_PAUSED: - if (avail >= runtime->control->avail_min) { - mask = POLLOUT | POLLWRNORM; - break; - } - /* Fall through */ - case SNDRV_PCM_STATE_DRAINING: - mask = 0; - break; - default: - mask = POLLOUT | POLLWRNORM | POLLERR; - break; - } - //giovanni snd_pcm_stream_unlock_irq(substream); - return mask; -} - -static unsigned int snd_pcm_capture_poll(struct file *file, poll_table * wait) -{ - struct snd_pcm_file *pcm_file; - struct snd_pcm_substream *substream; - struct snd_pcm_runtime *runtime; - unsigned int mask; - snd_pcm_uframes_t avail; - - pcm_file = file->private_data; - - substream = pcm_file->substream; - if (PCM_RUNTIME_CHECK(substream)) - return -ENXIO; - runtime = substream->runtime; - - poll_wait(file, &runtime->sleep, wait); - - //giovanni snd_pcm_stream_lock_irq(substream); - avail = snd_pcm_capture_avail(runtime); - switch (runtime->status->state) { - case SNDRV_PCM_STATE_RUNNING: - case SNDRV_PCM_STATE_PREPARED: - case SNDRV_PCM_STATE_PAUSED: - if (avail >= runtime->control->avail_min) { - mask = POLLIN | POLLRDNORM; - break; - } - mask = 0; - break; - case SNDRV_PCM_STATE_DRAINING: - if (avail > 0) { - mask = POLLIN | POLLRDNORM; - break; - } - /* Fall through */ - default: - mask = POLLIN | POLLRDNORM | POLLERR; - break; - } - //giovanni snd_pcm_stream_unlock_irq(substream); - return mask; -} - -/* - * mmap support - */ - -/* - * Only on coherent architectures, we can mmap the status and the control records - * for effcient data transfer. On others, we have to use HWSYNC ioctl... - */ -#if defined(CONFIG_X86) || defined(CONFIG_PPC) || defined(CONFIG_ALPHA) -/* - * mmap status record - */ -static int snd_pcm_mmap_status_fault(struct vm_area_struct *area, - struct vm_fault *vmf) -{ - struct snd_pcm_substream *substream = area->vm_private_data; - struct snd_pcm_runtime *runtime; - - if (substream == NULL) - return VM_FAULT_SIGBUS; - runtime = substream->runtime; - vmf->page = virt_to_page(runtime->status); - get_page(vmf->page); - return 0; -} - -static const struct vm_operations_struct snd_pcm_vm_ops_status = -{ - .fault = snd_pcm_mmap_status_fault, -}; - -static int snd_pcm_mmap_status(struct snd_pcm_substream *substream, struct file *file, - struct vm_area_struct *area) -{ - struct snd_pcm_runtime *runtime; - long size; - if (!(area->vm_flags & VM_READ)) - return -EINVAL; - runtime = substream->runtime; - size = area->vm_end - area->vm_start; - if (size != PAGE_ALIGN(sizeof(struct snd_pcm_mmap_status))) - return -EINVAL; - area->vm_ops = &snd_pcm_vm_ops_status; - area->vm_private_data = substream; - area->vm_flags |= VM_RESERVED; - return 0; -} - -/* - * mmap control record - */ -static int snd_pcm_mmap_control_fault(struct vm_area_struct *area, - struct vm_fault *vmf) -{ - struct snd_pcm_substream *substream = area->vm_private_data; - struct snd_pcm_runtime *runtime; - - if (substream == NULL) - return VM_FAULT_SIGBUS; - runtime = substream->runtime; - vmf->page = virt_to_page(runtime->control); - get_page(vmf->page); - return 0; -} - -static const struct vm_operations_struct snd_pcm_vm_ops_control = -{ - .fault = snd_pcm_mmap_control_fault, -}; - -static int snd_pcm_mmap_control(struct snd_pcm_substream *substream, struct file *file, - struct vm_area_struct *area) -{ - struct snd_pcm_runtime *runtime; - long size; - if (!(area->vm_flags & VM_READ)) - return -EINVAL; - runtime = substream->runtime; - size = area->vm_end - area->vm_start; - if (size != PAGE_ALIGN(sizeof(struct snd_pcm_mmap_control))) - return -EINVAL; - area->vm_ops = &snd_pcm_vm_ops_control; - area->vm_private_data = substream; - area->vm_flags |= VM_RESERVED; - return 0; -} -#else /* ! coherent mmap */ -/* - * don't support mmap for status and control records. - */ -static int snd_pcm_mmap_status(struct snd_pcm_substream *substream, struct file *file, - struct vm_area_struct *area) -{ - return -ENXIO; -} -static int snd_pcm_mmap_control(struct snd_pcm_substream *substream, struct file *file, - struct vm_area_struct *area) -{ - return -ENXIO; -} -#endif /* coherent mmap */ - -static inline struct page * -snd_pcm_default_page_ops(struct snd_pcm_substream *substream, unsigned long ofs) -{ - void *vaddr = substream->runtime->dma_area + ofs; -#if defined(CONFIG_MIPS) && defined(CONFIG_DMA_NONCOHERENT) - if (substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV) - return virt_to_page(CAC_ADDR(vaddr)); -#endif -#if defined(CONFIG_PPC32) && defined(CONFIG_NOT_COHERENT_CACHE) - if (substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV) { - dma_addr_t addr = substream->runtime->dma_addr + ofs; - addr -= get_dma_offset(substream->dma_buffer.dev.dev); - /* assume dma_handle set via pfn_to_phys() in - * mm/dma-noncoherent.c - */ - return pfn_to_page(addr >> PAGE_SHIFT); - } -#endif - return virt_to_page(vaddr); -} - -/* - * fault callback for mmapping a RAM page - */ -static int snd_pcm_mmap_data_fault(struct vm_area_struct *area, - struct vm_fault *vmf) -{ - struct snd_pcm_substream *substream = area->vm_private_data; - struct snd_pcm_runtime *runtime; - unsigned long offset; - struct page * page; - size_t dma_bytes; - - if (substream == NULL) - return VM_FAULT_SIGBUS; - runtime = substream->runtime; - offset = vmf->pgoff << PAGE_SHIFT; - dma_bytes = PAGE_ALIGN(runtime->dma_bytes); - if (offset > dma_bytes - PAGE_SIZE) - return VM_FAULT_SIGBUS; - if (substream->ops->page) - page = substream->ops->page(substream, offset); - else - page = snd_pcm_default_page_ops(substream, offset); - if (!page) - return VM_FAULT_SIGBUS; - get_page(page); - vmf->page = page; - return 0; -} - -static const struct vm_operations_struct snd_pcm_vm_ops_data = { - .open = snd_pcm_mmap_data_open, - .close = snd_pcm_mmap_data_close, -}; - -static const struct vm_operations_struct snd_pcm_vm_ops_data_fault = { - .open = snd_pcm_mmap_data_open, - .close = snd_pcm_mmap_data_close, - .fault = snd_pcm_mmap_data_fault, -}; - -#ifndef ARCH_HAS_DMA_MMAP_COHERENT -/* This should be defined / handled globally! */ -#ifdef CONFIG_ARM -#define ARCH_HAS_DMA_MMAP_COHERENT -#endif -#endif - -/* - * mmap the DMA buffer on RAM - */ -static int snd_pcm_default_mmap(struct snd_pcm_substream *substream, - struct vm_area_struct *area) -{ - area->vm_flags |= VM_RESERVED; -#ifdef ARCH_HAS_DMA_MMAP_COHERENT - if (!substream->ops->page && - substream->dma_buffer.dev.type == SNDRV_DMA_TYPE_DEV) - return dma_mmap_coherent(substream->dma_buffer.dev.dev, - area, - substream->runtime->dma_area, - substream->runtime->dma_addr, - area->vm_end - area->vm_start); -#endif /* ARCH_HAS_DMA_MMAP_COHERENT */ - /* mmap with fault handler */ - area->vm_ops = &snd_pcm_vm_ops_data_fault; - return 0; -} - -/* - * mmap the DMA buffer on I/O memory area - */ -#if SNDRV_PCM_INFO_MMAP_IOMEM -int snd_pcm_lib_mmap_iomem(struct snd_pcm_substream *substream, - struct vm_area_struct *area) -{ - long size; - unsigned long offset; - - area->vm_page_prot = pgprot_noncached(area->vm_page_prot); - area->vm_flags |= VM_IO; - size = area->vm_end - area->vm_start; - offset = area->vm_pgoff << PAGE_SHIFT; - if (io_remap_pfn_range(area, area->vm_start, - (substream->runtime->dma_addr + offset) >> PAGE_SHIFT, - size, area->vm_page_prot)) - return -EAGAIN; - return 0; -} - -EXPORT_SYMBOL(snd_pcm_lib_mmap_iomem); -#endif /* SNDRV_PCM_INFO_MMAP */ - -/* mmap callback with pgprot_noncached */ -int snd_pcm_lib_mmap_noncached(struct snd_pcm_substream *substream, - struct vm_area_struct *area) -{ - area->vm_page_prot = pgprot_noncached(area->vm_page_prot); - return snd_pcm_default_mmap(substream, area); -} -EXPORT_SYMBOL(snd_pcm_lib_mmap_noncached); - -/* - * mmap DMA buffer - */ -int snd_pcm_mmap_data(struct snd_pcm_substream *substream, struct file *file, - struct vm_area_struct *area) -{ - struct snd_pcm_runtime *runtime; - long size; - unsigned long offset; - size_t dma_bytes; - int err; - - if (substream->stream == SNDRV_PCM_STREAM_PLAYBACK) { - if (!(area->vm_flags & (VM_WRITE|VM_READ))) - return -EINVAL; - } else { - if (!(area->vm_flags & VM_READ)) - return -EINVAL; - } - runtime = substream->runtime; - if (runtime->status->state == SNDRV_PCM_STATE_OPEN) - return -EBADFD; - if (!(runtime->info & SNDRV_PCM_INFO_MMAP)) - return -ENXIO; - if (runtime->access == SNDRV_PCM_ACCESS_RW_INTERLEAVED || - runtime->access == SNDRV_PCM_ACCESS_RW_NONINTERLEAVED) - return -EINVAL; - size = area->vm_end - area->vm_start; - offset = area->vm_pgoff << PAGE_SHIFT; - dma_bytes = PAGE_ALIGN(runtime->dma_bytes); - if ((size_t)size > dma_bytes) - return -EINVAL; - if (offset > dma_bytes - size) - return -EINVAL; - - area->vm_ops = &snd_pcm_vm_ops_data; - area->vm_private_data = substream; - if (substream->ops->mmap) - err = substream->ops->mmap(substream, area); - else - err = snd_pcm_default_mmap(substream, area); - if (!err) - atomic_inc(&substream->mmap_count); - return err; -} - -EXPORT_SYMBOL(snd_pcm_mmap_data); - -static int snd_pcm_mmap(struct file *file, struct vm_area_struct *area) -{ - struct snd_pcm_file * pcm_file; - struct snd_pcm_substream *substream; - unsigned long offset; - - pcm_file = file->private_data; - substream = pcm_file->substream; - if (PCM_RUNTIME_CHECK(substream)) - return -ENXIO; - - offset = area->vm_pgoff << PAGE_SHIFT; - switch (offset) { - case SNDRV_PCM_MMAP_OFFSET_STATUS: - if (pcm_file->no_compat_mmap) - return -ENXIO; - return snd_pcm_mmap_status(substream, file, area); - case SNDRV_PCM_MMAP_OFFSET_CONTROL: - if (pcm_file->no_compat_mmap) - return -ENXIO; - return snd_pcm_mmap_control(substream, file, area); - default: - return snd_pcm_mmap_data(substream, file, area); - } - return 0; -} - -static int snd_pcm_fasync(int fd, struct file * file, int on) -{ - struct snd_pcm_file * pcm_file; - struct snd_pcm_substream *substream; - struct snd_pcm_runtime *runtime; - - pcm_file = file->private_data; - substream = pcm_file->substream; - if (PCM_RUNTIME_CHECK(substream)) - return -ENXIO; - runtime = substream->runtime; - return fasync_helper(fd, file, on, &runtime->fasync); -} - -/* - * ioctl32 compat - */ -#ifdef CONFIG_COMPAT -#include "pcm_compat.c" -#else -#define snd_pcm_ioctl_compat NULL -#endif - -/* - * To be removed helpers to keep binary compatibility - */ - -#ifdef CONFIG_SND_SUPPORT_OLD_API -#define __OLD_TO_NEW_MASK(x) ((x&7)|((x&0x07fffff8)<<5)) -#define __NEW_TO_OLD_MASK(x) ((x&7)|((x&0xffffff00)>>5)) - -static void snd_pcm_hw_convert_from_old_params(struct snd_pcm_hw_params *params, - struct snd_pcm_hw_params_old *oparams) -{ - unsigned int i; - - memset(params, 0, sizeof(*params)); - params->flags = oparams->flags; - for (i = 0; i < ARRAY_SIZE(oparams->masks); i++) - params->masks[i].bits[0] = oparams->masks[i]; - memcpy(params->intervals, oparams->intervals, sizeof(oparams->intervals)); - params->rmask = __OLD_TO_NEW_MASK(oparams->rmask); - params->cmask = __OLD_TO_NEW_MASK(oparams->cmask); - params->info = oparams->info; - params->msbits = oparams->msbits; - params->rate_num = oparams->rate_num; - params->rate_den = oparams->rate_den; - params->fifo_size = oparams->fifo_size; -} - -static void snd_pcm_hw_convert_to_old_params(struct snd_pcm_hw_params_old *oparams, - struct snd_pcm_hw_params *params) -{ - unsigned int i; - - memset(oparams, 0, sizeof(*oparams)); - oparams->flags = params->flags; - for (i = 0; i < ARRAY_SIZE(oparams->masks); i++) - oparams->masks[i] = params->masks[i].bits[0]; - memcpy(oparams->intervals, params->intervals, sizeof(oparams->intervals)); - oparams->rmask = __NEW_TO_OLD_MASK(params->rmask); - oparams->cmask = __NEW_TO_OLD_MASK(params->cmask); - oparams->info = params->info; - oparams->msbits = params->msbits; - oparams->rate_num = params->rate_num; - oparams->rate_den = params->rate_den; - oparams->fifo_size = params->fifo_size; -} - -static int snd_pcm_hw_refine_old_user(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params_old __user * _oparams) -{ - struct snd_pcm_hw_params *params; - struct snd_pcm_hw_params_old *oparams = NULL; - int err; - - params = kmalloc(sizeof(*params), GFP_KERNEL); - if (!params) - return -ENOMEM; - - oparams = memdup_user(_oparams, sizeof(*oparams)); - if (IS_ERR(oparams)) { - err = PTR_ERR(oparams); - goto out; - } - snd_pcm_hw_convert_from_old_params(params, oparams); - err = snd_pcm_hw_refine(substream, params); - snd_pcm_hw_convert_to_old_params(oparams, params); - if (copy_to_user(_oparams, oparams, sizeof(*oparams))) { - if (!err) - err = -EFAULT; - } - - kfree(oparams); -out: - kfree(params); - return err; -} - -static int snd_pcm_hw_params_old_user(struct snd_pcm_substream *substream, - struct snd_pcm_hw_params_old __user * _oparams) -{ - struct snd_pcm_hw_params *params; - struct snd_pcm_hw_params_old *oparams = NULL; - int err; - - params = kmalloc(sizeof(*params), GFP_KERNEL); - if (!params) - return -ENOMEM; - - oparams = memdup_user(_oparams, sizeof(*oparams)); - if (IS_ERR(oparams)) { - err = PTR_ERR(oparams); - goto out; - } - snd_pcm_hw_convert_from_old_params(params, oparams); - err = snd_pcm_hw_params(substream, params); - snd_pcm_hw_convert_to_old_params(oparams, params); - if (copy_to_user(_oparams, oparams, sizeof(*oparams))) { - if (!err) - err = -EFAULT; - } - - kfree(oparams); -out: - kfree(params); - return err; -} -#endif /* CONFIG_SND_SUPPORT_OLD_API */ - -#ifndef CONFIG_MMU -static unsigned long snd_pcm_get_unmapped_area(struct file *file, - unsigned long addr, - unsigned long len, - unsigned long pgoff, - unsigned long flags) -{ - struct snd_pcm_file *pcm_file = file->private_data; - struct snd_pcm_substream *substream = pcm_file->substream; - struct snd_pcm_runtime *runtime = substream->runtime; - unsigned long offset = pgoff << PAGE_SHIFT; - - switch (offset) { - case SNDRV_PCM_MMAP_OFFSET_STATUS: - return (unsigned long)runtime->status; - case SNDRV_PCM_MMAP_OFFSET_CONTROL: - return (unsigned long)runtime->control; - default: - return (unsigned long)runtime->dma_area + offset; - } -} -#else -# define snd_pcm_get_unmapped_area NULL -#endif - -/* - * Register section - */ - -const struct file_operations snd_pcm_f_ops[2] = { - { - .owner = THIS_MODULE, - .write = snd_pcm_write, - .aio_write = snd_pcm_aio_write, - .open = snd_pcm_playback_open, - .release = snd_pcm_release, - .llseek = no_llseek, - .poll = snd_pcm_playback_poll, - .unlocked_ioctl = snd_pcm_playback_ioctl, - .compat_ioctl = snd_pcm_ioctl_compat, - .mmap = snd_pcm_mmap, - .fasync = snd_pcm_fasync, - .get_unmapped_area = snd_pcm_get_unmapped_area, - }, - { - .owner = THIS_MODULE, - .read = snd_pcm_read, - .aio_read = snd_pcm_aio_read, - .open = snd_pcm_capture_open, - .release = snd_pcm_release, - .llseek = no_llseek, - .poll = snd_pcm_capture_poll, - .unlocked_ioctl = snd_pcm_capture_ioctl, - .compat_ioctl = snd_pcm_ioctl_compat, - .mmap = snd_pcm_mmap, - .fasync = snd_pcm_fasync, - .get_unmapped_area = snd_pcm_get_unmapped_area, - } -}; diff --git a/src/mod/endpoints/mod_skypopen/oss/Makefile b/src/mod/endpoints/mod_skypopen/oss/Makefile deleted file mode 100644 index 40b25f0e25..0000000000 --- a/src/mod/endpoints/mod_skypopen/oss/Makefile +++ /dev/null @@ -1,43 +0,0 @@ -# Comment/uncomment the following line to disable/enable debugging -#DEBUG = y -#LDDINC= - -# Add your debugging flag (or not) to CFLAGS -ifeq ($(DEBUG),y) - DEBFLAGS = -O -g -DSKYPOPEN_DEBUG # "-O" is needed to expand inlines -else - DEBFLAGS = -O2 -Wall -endif - -EXTRA_CFLAGS += $(DEBFLAGS) -EXTRA_CFLAGS += -I$(LDDINC) - -ifneq ($(KERNELRELEASE),) -# call from kernel build system - -skypopen-objs := main.o - -obj-m := skypopen.o - -else - -KERNELDIR ?= /lib/modules/$(shell uname -r)/build -PWD := $(shell pwd) - -modules: - $(MAKE) -C $(KERNELDIR) M=$(PWD) LDDINC=$(PWD)/../include modules - -endif - - - -clean: - rm -rf *.o *~ core .depend .*.cmd *.ko *.mod.c .tmp_versions - -depend .depend dep: - $(CC) $(EXTRA_CFLAGS) -M *.c > .depend - - -ifeq (.depend,$(wildcard .depend)) -include .depend -endif diff --git a/src/mod/endpoints/mod_skypopen/oss/main.c b/src/mod/endpoints/mod_skypopen/oss/main.c deleted file mode 100644 index 32acb46790..0000000000 --- a/src/mod/endpoints/mod_skypopen/oss/main.c +++ /dev/null @@ -1,502 +0,0 @@ -/* - * main.c -- the bare skypopen char module - * - * Copyright (C) 2010 Giovanni Maruzzelli - * Copyright (C) 2001 Alessandro Rubini and Jonathan Corbet - * Copyright (C) 2001 O'Reilly & Associates - * - * The source code in this file can be freely used, adapted, - * and redistributed in source or binary form, so long as an - * acknowledgment appears in derived source files. The citation - * should list that the code comes from the book "Linux Device - * Drivers" by Alessandro Rubini and Jonathan Corbet, published - * by O'Reilly & Associates. No warranty is attached; - * we cannot take responsibility for errors or fitness for use. - * - */ - -#include -#include -#include - -#include /* printk() */ -#include /* kmalloc() */ -#include /* everything... */ -#include /* error codes */ -#include /* size_t */ -#include -#include /* O_ACCMODE */ -#include -#include - -#include /* copy_*_user */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "skypopen.h" /* local definitions */ - - -/* - * Our parameters which can be set at load time. - */ - -int skypopen_major = SKYPOPEN_MAJOR; -int skypopen_minor = SKYPOPEN_MINOR; -int skypopen_nr_devs = SKYPOPEN_NR_DEVS; /* number of bare skypopen devices */ - -module_param(skypopen_major, int, S_IRUGO); -module_param(skypopen_minor, int, S_IRUGO); -module_param(skypopen_nr_devs, int, S_IRUGO); - -MODULE_AUTHOR("Original: Alessandro Rubini, Jonathan Corbet. Modified by: Giovanni Maruzzelli for FreeSWITCH skypopen"); -MODULE_LICENSE("Dual BSD/GPL"); - -static struct skypopen_dev *skypopen_devices; /* allocated in skypopen_init_module */ - -static int unload = 0; - -#ifndef WANT_HRTIMER -void my_timer_callback_inq( unsigned long data ) -{ - struct skypopen_dev *dev = (void *)data; - - wake_up_interruptible(&dev->inq); - mod_timer( &dev->timer_inq, jiffies + msecs_to_jiffies(SKYPOPEN_SLEEP) ); - -} - -void my_timer_callback_outq( unsigned long data ) -{ - struct skypopen_dev *dev = (void *)data; - - wake_up_interruptible(&dev->outq); - mod_timer( &dev->timer_outq, jiffies + msecs_to_jiffies(SKYPOPEN_SLEEP) ); -} -#else// WANT_HRTIMER - -#ifndef CENTOS_5 -static enum hrtimer_restart my_hrtimer_callback_inq( struct hrtimer *timer_inq ) -{ - struct skypopen_dev *dev = container_of(timer_inq, struct skypopen_dev, timer_inq); - - if(unload) - return HRTIMER_NORESTART; - - hrtimer_forward(&dev->timer_inq, timer_inq->_softexpires, ktime_set(0, SKYPOPEN_SLEEP * 1000000)); - wake_up_interruptible(&dev->inq); - - return HRTIMER_RESTART; -} -static enum hrtimer_restart my_hrtimer_callback_outq( struct hrtimer *timer_outq ) -{ - struct skypopen_dev *dev = container_of(timer_outq, struct skypopen_dev, timer_outq); - - if(unload) - return HRTIMER_NORESTART; - - hrtimer_forward(&dev->timer_outq, timer_outq->_softexpires, ktime_set(0, SKYPOPEN_SLEEP * 1000000)); - wake_up_interruptible(&dev->outq); - - return HRTIMER_RESTART; -} -#else// CENTOS_5 -static int my_hrtimer_callback_inq( struct hrtimer *timer_inq ) -{ - struct skypopen_dev *dev = container_of(timer_inq, struct skypopen_dev, timer_inq); - - if(unload) - return HRTIMER_NORESTART; - - hrtimer_forward(&dev->timer_inq, timer_inq->expires, ktime_set(0, SKYPOPEN_SLEEP * 1000000)); - wake_up_interruptible(&dev->inq); - - return HRTIMER_RESTART; -} -static int my_hrtimer_callback_outq( struct hrtimer *timer_outq ) -{ - struct skypopen_dev *dev = container_of(timer_outq, struct skypopen_dev, timer_outq); - - if(unload) - return HRTIMER_NORESTART; - - hrtimer_forward(&dev->timer_outq, timer_outq->expires, ktime_set(0, SKYPOPEN_SLEEP * 1000000)); - wake_up_interruptible(&dev->outq); - - return HRTIMER_RESTART; -} -#endif// CENTOS_5 -#endif// WANT_HRTIMER - -/* The clone-specific data structure includes a key field */ - -struct skypopen_listitem { - struct skypopen_dev device; - dev_t key; - struct list_head list; - -}; - -/* The list of devices, and a lock to protect it */ -static LIST_HEAD(skypopen_c_list); -#ifdef WANT_DEFINE_SPINLOCK -static DEFINE_SPINLOCK(skypopen_c_lock); -#else // WANT_DEFINE_SPINLOCK -static spinlock_t skypopen_c_lock = SPIN_LOCK_UNLOCKED; -#endif // WANT_DEFINE_SPINLOCK - -/* Look for a device or create one if missing */ -static struct skypopen_dev *skypopen_c_lookfor_device(dev_t key) -{ - struct skypopen_listitem *lptr; -#ifdef WANT_HRTIMER -#endif// WANT_HRTIMER - - list_for_each_entry(lptr, &skypopen_c_list, list) { - if (lptr->key == key) - return &(lptr->device); - } - - /* not found */ - lptr = kmalloc(sizeof(struct skypopen_listitem), GFP_KERNEL); - if (!lptr) - return NULL; - - /* initialize the device */ - memset(lptr, 0, sizeof(struct skypopen_listitem)); - lptr->key = key; - - init_waitqueue_head(&lptr->device.inq); - init_waitqueue_head(&lptr->device.outq); - -#ifndef WANT_HRTIMER - setup_timer( &lptr->device.timer_inq, my_timer_callback_inq, (long int)lptr ); - setup_timer( &lptr->device.timer_outq, my_timer_callback_outq, (long int)lptr ); - printk( "Starting skypopen OSS driver read timer (%dms) skype client:(%d)\n", SKYPOPEN_SLEEP, current->tgid ); - mod_timer( &lptr->device.timer_inq, jiffies + msecs_to_jiffies(SKYPOPEN_SLEEP) ); - printk( "Starting skypopen OSS driver write timer (%dms) skype client:(%d)\n", SKYPOPEN_SLEEP, current->tgid ); - mod_timer( &lptr->device.timer_outq, jiffies + msecs_to_jiffies(SKYPOPEN_SLEEP) ); -#endif// WANT_HRTIMER - - /* place it in the list */ - list_add(&lptr->list, &skypopen_c_list); - - return &(lptr->device); -} - -/* - * Open and close - */ -static int skypopen_c_open(struct inode *inode, struct file *filp) -{ - struct skypopen_dev *dev; - dev_t key; - - key = current->tgid; - - /* look for a skypopenc device in the list */ - spin_lock(&skypopen_c_lock); - dev = skypopen_c_lookfor_device(key); - if (dev){ - dev->opened++; - } - spin_unlock(&skypopen_c_lock); - - if (!dev) - return -ENOMEM; - - /* then, everything else is copied from the bare skypopen device */ - filp->private_data = dev; - return 0; /* success */ -} - -static int skypopen_c_release(struct inode *inode, struct file *filp) -{ - dev_t key; - struct skypopen_dev *dev = filp->private_data; - int ret; - - key = current->tgid; - - spin_lock(&skypopen_c_lock); - dev->opened--; - spin_unlock(&skypopen_c_lock); - - if(!dev->opened){ -#ifdef WANT_HRTIMER - if(dev->timer_inq_started){ - ret = hrtimer_cancel( &dev->timer_inq ); - //printk( "Stopped skypopen OSS driver read HRtimer skype client:(%d) ret=%d\n", key, ret); - dev->timer_inq_started=0; - } - if(dev->timer_outq_started){ - ret = hrtimer_cancel( &dev->timer_outq ); - //printk( "Stopped skypopen OSS driver write HRtimer skype client:(%d) ret=%d\n", key, ret); - dev->timer_outq_started=0; - } -#endif// WANT_HRTIMER - } - return 0; -} - - - -/*************************************************************/ - -static ssize_t skypopen_read(struct file *filp, char __user *buf, size_t count, - loff_t *f_pos) -{ - DEFINE_WAIT(wait); - struct skypopen_dev *dev = filp->private_data; - dev_t key; - - key = current->tgid; - - if(unload) - return -1; - -#ifdef WANT_HRTIMER - if(dev->timer_inq_started == 0){ - ktime_t ktime_inq; - - ktime_inq = ktime_set( 0, SKYPOPEN_SLEEP * 1000000); - hrtimer_init( &dev->timer_inq, CLOCK_MONOTONIC, HRTIMER_MODE_REL ); - dev->timer_inq.function = &my_hrtimer_callback_inq; - hrtimer_start( &dev->timer_inq, ktime_inq, HRTIMER_MODE_REL ); - dev->timer_inq_started = 1; - //printk( "Started skypopen OSS driver read HRtimer skype client:(%d) \n", key); - } -#endif// WANT_HRTIMER - - //printk("READ\n"); - prepare_to_wait(&dev->inq, &wait, TASK_INTERRUPTIBLE); - schedule(); - finish_wait(&dev->inq, &wait); - return count; -} - -static ssize_t skypopen_write(struct file *filp, const char __user *buf, size_t count, - loff_t *f_pos) -{ - DEFINE_WAIT(wait); - struct skypopen_dev *dev = filp->private_data; - dev_t key; - - key = current->tgid; - - if(unload) - return -1; - -#ifdef WANT_HRTIMER - if(dev->timer_outq_started == 0){ - ktime_t ktime_outq; - - ktime_outq = ktime_set( 0, SKYPOPEN_SLEEP * 1000000); - hrtimer_init( &dev->timer_outq, CLOCK_MONOTONIC, HRTIMER_MODE_REL ); - dev->timer_outq.function = &my_hrtimer_callback_outq; - hrtimer_start( &dev->timer_outq, ktime_outq, HRTIMER_MODE_REL ); - dev->timer_outq_started = 1; - //printk( "Started skypopen OSS driver write HRtimer skype client:(%d) \n", key); - } -#endif// WANT_HRTIMER - - //printk("WRITE\n"); - prepare_to_wait(&dev->outq, &wait, TASK_INTERRUPTIBLE); - schedule(); - finish_wait(&dev->outq, &wait); - return count; - -} -/* - * The ioctl() implementation - */ - -#ifndef HAVE_UNLOCKED_IOCTL -static int skypopen_ioctl(struct inode *inode, struct file *filp, - unsigned int cmd, unsigned long arg) -{ - void __user *argp = (void __user *)arg; - int __user *p = argp; - - switch (cmd) { - case OSS_GETVERSION: - return put_user(SOUND_VERSION, p); - case SNDCTL_DSP_GETBLKSIZE: - return put_user(SKYPOPEN_BLK, p); - case SNDCTL_DSP_GETFMTS: - return put_user(28731, p); - - default: - return 0; - } - -} -#else// HAVE_UNLOCKED_IOCTL -static long skypopen_unlocked_ioctl(struct file *filp, - unsigned int cmd, unsigned long arg) -{ - void __user *argp = (void __user *)arg; - int __user *p = argp; - - switch (cmd) { - case OSS_GETVERSION: - return put_user(SOUND_VERSION, p); - case SNDCTL_DSP_GETBLKSIZE: - return put_user(SKYPOPEN_BLK, p); - case SNDCTL_DSP_GETFMTS: - return put_user(28731, p); - - default: - return 0; - } - -} -#endif// HAVE_UNLOCKED_IOCTL - -struct file_operations skypopen_fops = { - .owner = THIS_MODULE, - .llseek = no_llseek, - .read = skypopen_read, - .write = skypopen_write, -#ifndef HAVE_UNLOCKED_IOCTL - .ioctl = skypopen_ioctl, -#else// HAVE_UNLOCKED_IOCTL - .unlocked_ioctl = skypopen_unlocked_ioctl, -#endif// HAVE_UNLOCKED_IOCTL - .open = skypopen_c_open, - .release = skypopen_c_release, -}; - -/* - * Finally, the module stuff - */ - -/* - * The cleanup function is used to handle initialization failures as well. - * Thefore, it must be careful to work correctly even if some of the items - * have not been initialized - */ - -void skypopen_cleanup_module(void) -{ - int i; - int ret; - struct skypopen_listitem *lptr, *next; - dev_t devno = MKDEV(skypopen_major, skypopen_minor); - - - unload = 1; - - msleep(100); - - /* Get rid of our char dev entries */ - if (skypopen_devices) { - for (i = 0; i < skypopen_nr_devs; i++) { - cdev_del(&skypopen_devices[i].cdev); - } - kfree(skypopen_devices); - } - - /* And all the cloned devices */ - list_for_each_entry_safe(lptr, next, &skypopen_c_list, list) { -#ifndef WANT_HRTIMER - ret= del_timer( &lptr->device.timer_inq ); - printk( "Stopped skypopen OSS driver read timer\n"); - ret= del_timer( &lptr->device.timer_outq ); - printk( "Stopped skypopen OSS driver write timer\n"); -#else// WANT_HRTIMER - if(lptr->device.timer_inq_started){ - ret = hrtimer_cancel( &lptr->device.timer_inq ); - printk( "Stopped skypopen OSS driver read HRtimer\n"); - } - if(lptr->device.timer_outq_started){ - ret = hrtimer_cancel( &lptr->device.timer_outq ); - printk( "Stopped skypopen OSS driver write HRtimer\n"); - } - -#endif// WANT_HRTIMER - list_del(&lptr->list); - kfree(lptr); - } - /* cleanup_module is never called if registering failed */ - unregister_chrdev_region(devno, skypopen_nr_devs); - printk("skypopen OSS driver unloaded\n"); - -} - - -/* - * Set up the char_dev structure for this device. - */ -static void skypopen_setup_cdev(struct skypopen_dev *dev, int index) -{ - int err, devno = MKDEV(skypopen_major, skypopen_minor + index); - - cdev_init(&dev->cdev, &skypopen_fops); - dev->cdev.owner = THIS_MODULE; - dev->cdev.ops = &skypopen_fops; - err = cdev_add (&dev->cdev, devno, 1); - /* Fail gracefully if need be */ - if (err) - printk(KERN_NOTICE "Error %d adding skypopen%d", err, index); -} - - - -int skypopen_init_module(void) -{ - int result, i; - dev_t dev = 0; - - printk("skypopen OSS driver loading (www.freeswitch.org)\n"); - - /* - * Get a range of minor numbers to work with, asking for a dynamic - * major unless directed otherwise at load time. - */ - if (skypopen_major) { - dev = MKDEV(skypopen_major, skypopen_minor); - result = register_chrdev_region(dev, skypopen_nr_devs, "dsp"); - } else { - result = alloc_chrdev_region(&dev, skypopen_minor, skypopen_nr_devs, - "dsp"); - skypopen_major = MAJOR(dev); - } - if (result < 0) { - printk(KERN_WARNING "skypopen OSS driver: can't get major %d\n", skypopen_major); - return result; - } - - /* - * allocate the devices -- we can't have them static, as the number - * can be specified at load time - */ - skypopen_devices = kmalloc(skypopen_nr_devs * sizeof(struct skypopen_dev), GFP_KERNEL); - if (!skypopen_devices) { - result = -ENOMEM; - goto fail; /* Make this more graceful */ - } - memset(skypopen_devices, 0, skypopen_nr_devs * sizeof(struct skypopen_dev)); - - /* Initialize each device. */ - for (i = 0; i < skypopen_nr_devs; i++) { - skypopen_setup_cdev(&skypopen_devices[i], i); - } - - /* At this point call the init function for any friend device */ - dev = MKDEV(skypopen_major, skypopen_minor + skypopen_nr_devs); - return 0; /* succeed */ - -fail: - skypopen_cleanup_module(); - return result; -} - -module_init(skypopen_init_module); -module_exit(skypopen_cleanup_module); diff --git a/src/mod/endpoints/mod_skypopen/oss/skypopen.h b/src/mod/endpoints/mod_skypopen/oss/skypopen.h deleted file mode 100644 index 3486bccdd1..0000000000 --- a/src/mod/endpoints/mod_skypopen/oss/skypopen.h +++ /dev/null @@ -1,79 +0,0 @@ -/* - * skypopen.h -- definitions for the char module - * - * Copyright (C) 2010 Giovanni Maruzzelli - * Copyright (C) 2001 Alessandro Rubini and Jonathan Corbet - * Copyright (C) 2001 O'Reilly & Associates - * - * The source code in this file can be freely used, adapted, - * and redistributed in source or binary form, so long as an - * acknowledgment appears in derived source files. The citation - * should list that the code comes from the book "Linux Device - * Drivers" by Alessandro Rubini and Jonathan Corbet, published - * by O'Reilly & Associates. No warranty is attached; - * we cannot take responsibility for errors or fitness for use. - * - * $Id: skypopen.h,v 1.15 2004/11/04 17:51:18 rubini Exp $ - */ - -#ifndef _SKYPOPEN_H_ -#define _SKYPOPEN_H_ - -#include -#include /* needed for the _IOW etc stuff used later */ -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0) -#include /* cli(), *_flags */ -#else -#include /* cli(), *_flags */ -#endif //LINUX_VERSION_CODE >= KERNEL_VERSION(3, 4, 0) - - -#if LINUX_VERSION_CODE == KERNEL_VERSION(2, 6, 18) -#define CENTOS_5 -#define WANT_HRTIMER /* undef this only if you don't want to use High Resolution Timers (why?) */ -#endif /* CentOS 5.x */ - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 24) -#define WANT_HRTIMER -#endif /* HRTIMER */ - -#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 0, 0) -#define WANT_DEFINE_SPINLOCK -#endif /* DEFINE_SPINLOCK */ - -#define SKYPOPEN_BLK 1920 -#define SKYPOPEN_SLEEP 20 - - -#define SKYPOPEN_MAJOR 14 /* dynamic major by default */ -#define SKYPOPEN_MINOR 3 /* dynamic major by default */ -#define SKYPOPEN_NR_DEVS 1 /* not useful, I'm too lazy to remove it */ - -#ifdef CENTOS_5 -#define HRTIMER_MODE_REL HRTIMER_REL -#endif// CENTOS_5 - -struct skypopen_dev { - struct cdev cdev; /* Char device structure */ - wait_queue_head_t inq; /* read and write queues */ - wait_queue_head_t outq; /* read and write queues */ -#ifndef WANT_HRTIMER - struct timer_list timer_inq; - struct timer_list timer_outq; -#else// WANT_HRTIMER - struct hrtimer timer_inq; - struct hrtimer timer_outq; -#endif// WANT_HRTIMER - int timer_inq_started; - int timer_outq_started; - int opened; -}; - - -/* - * The different configurable parameters - */ -extern int skypopen_major; /* main.c */ -extern int skypopen_nr_devs; - -#endif /* _SKYPOPEN_H_ */ diff --git a/src/mod/endpoints/mod_skypopen/skypopen.h b/src/mod/endpoints/mod_skypopen/skypopen.h deleted file mode 100644 index a38a42c915..0000000000 --- a/src/mod/endpoints/mod_skypopen/skypopen.h +++ /dev/null @@ -1,405 +0,0 @@ -/* - * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2011, 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_gsmopen) has been contributed by: - * - * Giovanni Maruzzelli - * - * Maintainer: Giovanni Maruzzelli - * - * mod_skypopen.c -- Skype compatible Endpoint Module - * - */ - - -#include - -#ifndef WIN32 -#include -#include -#include -#include - -// CLOUDTREE (Thomas Hazel) -#define XIO_ERROR_BY_SETJMP -//#define XIO_ERROR_BY_UCONTEXT - -// CLOUDTREE (Thomas Hazel) -#ifdef XIO_ERROR_BY_SETJMP -#include "setjmp.h" -#endif -// CLOUDTREE (Thomas Hazel) -#ifdef XIO_ERROR_BY_UCONTEXT -#include "ucontext.h" -#endif - -#endif //WIN32 - -#define SPANDSP_EXPOSE_INTERNAL_STRUCTURES -#include -#include - -#ifndef WIN32 -#include -#endif - -#ifdef _MSC_VER -//Windows macro for FD_SET includes a warning C4127: conditional expression is constant -#pragma warning(push) -#pragma warning(disable:4127) -#endif - -#define MY_EVENT_INCOMING_CHATMESSAGE "skypopen::incoming_chatmessage" -#define MY_EVENT_INCOMING_RAW "skypopen::incoming_raw" - -#define SAMPLERATE_SKYPOPEN 16000 -#define MS_SKYPOPEN 20 -#define SAMPLES_PER_FRAME (SAMPLERATE_SKYPOPEN/(1000/MS_SKYPOPEN)) -#define BYTES_PER_FRAME (SAMPLES_PER_FRAME * sizeof(short)) - -#ifndef SKYPOPEN_SVN_VERSION -#define SKYPOPEN_SVN_VERSION switch_version_full() -#endif /* SKYPOPEN_SVN_VERSION */ - -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_PROGRESS = (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, "%-*s [%s ] [DEBUG_SKYPE %-5d][%-15s][%s,%s] " __VA_ARGS__ ); -#define DEBUGA_CALL(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%-*s [%s ] [DEBUG_CALL %-5d][%-15s][%s,%s] " __VA_ARGS__ ); -#define DEBUGA_PBX(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "%-*s [%s ] [DEBUG_PBX %-5d][%-15s][%s,%s] " __VA_ARGS__ ); -#define ERRORA(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "%-*s [%s ] [ERRORA %-5d][%-15s][%s,%s] " __VA_ARGS__ ); -#define WARNINGA(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "%-*s[%s ] [WARNINGA %-5d][%-15s][%s,%s] " __VA_ARGS__ ); -#define NOTICA(...) switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "%-*s [%s ] [NOTICA %-5d][%-15s][%s,%s] " __VA_ARGS__ ); - -#define SKYPOPEN_P_LOG (int)((20 - (strlen(__FILE__))) + ((__LINE__ - 1000) < 0) + ((__LINE__ - 100) < 0)), " ", SKYPOPEN_SVN_VERSION, __LINE__, tech_pvt ? tech_pvt->name ? tech_pvt->name : "none" : "none", tech_pvt ? interface_status[tech_pvt->interface_state] : "N/A", tech_pvt ? skype_callflow[tech_pvt->skype_callflow] : "N/A" - -/*********************************/ -#define SKYPOPEN_CAUSE_NORMAL 1 -/*********************************/ -#define SKYPOPEN_FRAME_DTMF 1 -/*********************************/ -#define SKYPOPEN_CONTROL_RINGING 1 -#define SKYPOPEN_CONTROL_ANSWER 2 - -/*********************************/ -// CLOUDTREE (Thomas Hazel) -#define SKYPOPEN_RINGING_INIT 0 -#define SKYPOPEN_RINGING_PRE 1 - -/*********************************/ -#define SKYPOPEN_STATE_IDLE 0 -#define SKYPOPEN_STATE_DOWN 1 -#define SKYPOPEN_STATE_RING 2 -#define SKYPOPEN_STATE_DIALING 3 -#define SKYPOPEN_STATE_BUSY 4 -#define SKYPOPEN_STATE_UP 5 -#define SKYPOPEN_STATE_RINGING 6 -#define SKYPOPEN_STATE_PRERING 7 -#define SKYPOPEN_STATE_ERROR_DOUBLE_CALL 8 -#define SKYPOPEN_STATE_SELECTED 9 -#define SKYPOPEN_STATE_HANGUP_REQUESTED 10 -#define SKYPOPEN_STATE_PREANSWER 11 -#define SKYPOPEN_STATE_DEAD 12 -/*********************************/ -/* call flow from the device */ -#define CALLFLOW_CALL_IDLE 0 -#define CALLFLOW_CALL_DOWN 1 -#define CALLFLOW_INCOMING_RING 2 -#define CALLFLOW_CALL_DIALING 3 -#define CALLFLOW_CALL_LINEBUSY 4 -#define CALLFLOW_CALL_ACTIVE 5 -#define CALLFLOW_INCOMING_HANGUP 6 -#define CALLFLOW_CALL_RELEASED 7 -#define CALLFLOW_CALL_NOCARRIER 8 -#define CALLFLOW_CALL_INFLUX 9 -#define CALLFLOW_CALL_INCOMING 10 -#define CALLFLOW_CALL_FAILED 11 -#define CALLFLOW_CALL_NOSERVICE 12 -#define CALLFLOW_CALL_OUTGOINGRESTRICTED 13 -#define CALLFLOW_CALL_SECURITYFAIL 14 -#define CALLFLOW_CALL_NOANSWER 15 -#define CALLFLOW_STATUS_FINISHED 16 -#define CALLFLOW_STATUS_CANCELLED 17 -#define CALLFLOW_STATUS_FAILED 18 -#define CALLFLOW_STATUS_REFUSED 19 -#define CALLFLOW_STATUS_RINGING 20 -#define CALLFLOW_STATUS_INPROGRESS 21 -#define CALLFLOW_STATUS_UNPLACED 22 -#define CALLFLOW_STATUS_ROUTING 23 -#define CALLFLOW_STATUS_EARLYMEDIA 24 -#define CALLFLOW_INCOMING_CALLID 25 -#define CALLFLOW_STATUS_REMOTEHOLD 26 - -/*********************************/ - -#define SKYPOPEN_MAX_INTERFACES 64 - -#ifndef WIN32 -struct SkypopenHandles { - Window skype_win; - Display *disp; - Window win; - int currentuserhandle; - int api_connected; - int fdesc[2]; - - // CLOUDTREE (Thomas Hazel) -#ifdef XIO_ERROR_BY_SETJMP - jmp_buf ioerror_context; -#endif -#ifdef XIO_ERROR_BY_UCONTEXT - ucontext_t ioerror_context; -#endif - - // CLOUDTREE (Thomas Hazel) - is there a capable freeswitch list? - switch_bool_t managed; - void *prev; - void *next; -}; - -// CLOUDTREE (Thomas Hazel) - is there a capable freeswitch list? -struct SkypopenList { - int entries; - void *head; - void *tail; -}; - -// CLOUDTREE (Thomas Hazel) - is there a capable freeswitch list? -struct SkypopenHandles *skypopen_list_add(struct SkypopenList *list, struct SkypopenHandles *x); -struct SkypopenHandles *skypopen_list_find(struct SkypopenList *list, struct SkypopenHandles *x); -struct SkypopenHandles *skypopen_list_remove_by_value(struct SkypopenList *list, Display * display); -struct SkypopenHandles *skypopen_list_remove_by_reference(struct SkypopenList *list, struct SkypopenHandles *x); -int skypopen_list_size(struct SkypopenList *list); - -#else //WIN32 - -struct SkypopenHandles { - HWND win32_hInit_MainWindowHandle; - HWND win32_hGlobal_SkypeAPIWindowHandle; - HINSTANCE win32_hInit_ProcessHandle; - char win32_acInit_WindowClassName[128]; - UINT win32_uiGlobal_MsgID_SkypeControlAPIAttach; - UINT win32_uiGlobal_MsgID_SkypeControlAPIDiscover; - int currentuserhandle; - int api_connected; - switch_file_t *fdesc[2]; -}; -#endif //WIN32 - -#define MAX_CHATS 10 - -struct chat { - char chatname[256]; - char dialog_partner[256]; -}; -typedef struct chat chat_t; - -#define MAX_CHATMESSAGES 10 - -struct chatmessage { - char id[256]; - char type[256]; - char chatname[256]; - char from_handle[256]; - char from_dispname[256]; - char body[512]; -}; -typedef struct chatmessage chatmessage_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]; - char session_uuid_str[SWITCH_UUID_FORMATTED_LENGTH + 1]; - switch_caller_profile_t *caller_profile; - switch_mutex_t *mutex; - switch_mutex_t *flag_mutex; - - 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]; -#ifdef WIN32 - unsigned short tcp_cli_port; - unsigned short tcp_srv_port; -#else - int tcp_cli_port; - int tcp_srv_port; -#endif - struct SkypopenHandles SkypopenHandles; - - // CLOUDTREE (Thomas Hazel) - char ringing_state; - - int interface_state; - char language[80]; - char exten[80]; - int skypopen_sound_rate; - char callid_name[50]; - char callid_number[50]; - double playback_boost; - double capture_boost; - int stripmsd; - char skype_call_id[512]; - int skype_call_ongoing; - char skype_friends[4096]; - char skype_fullname[512]; - char skype_displayname[512]; - int skype_callflow; - int skype; - int control_to_send; -#ifdef WIN32 - switch_file_t *audiopipe_srv[2]; - switch_file_t *audiopipe_cli[2]; - switch_file_t *skypopen_sound_capt_fd; -#else /* WIN32 */ - int audiopipe_srv[2]; - int audiopipe_cli[2]; - int skypopen_sound_capt_fd; -#endif /* WIN32 */ - switch_thread_t *tcp_srv_thread; - switch_thread_t *tcp_cli_thread; - switch_thread_t *skypopen_signaling_thread; - switch_thread_t *skypopen_api_thread; - short audiobuf[SAMPLES_PER_FRAME]; - int audiobuf_is_loaded; - short audiobuf_cli[SAMPLES_PER_FRAME]; - switch_mutex_t *mutex_audio_cli; - int flag_audio_cli; - short audiobuf_srv[SAMPLES_PER_FRAME]; - switch_mutex_t *mutex_audio_srv; - int flag_audio_srv; - switch_mutex_t *mutex_thread_audio_cli; - switch_mutex_t *mutex_thread_audio_srv; - - FILE *phonebook_writing_fp; - int skypopen_dir_entry_extension_prefix; - char skype_user[256]; - char initial_skype_user[256]; - char skype_password[256]; - char destination[256]; - struct timeval answer_time; - struct timeval ring_time; - - struct timeval transfer_time; - char transfer_callid_number[50]; - char skype_transfer_call_id[512]; - int running; - uint32_t ib_calls; - uint32_t ob_calls; - uint32_t ib_failed_calls; - uint32_t ob_failed_calls; - - chatmessage_t chatmessages[MAX_CHATMESSAGES]; - chat_t chats[MAX_CHATS]; - uint32_t report_incoming_chatmessages; - switch_timer_t timer_read; - switch_timer_t timer_read_srv; - switch_timer_t timer_write; - int begin_to_write; - int begin_to_read; - dtmf_rx_state_t dtmf_state; - switch_time_t old_dtmf_timestamp; - switch_buffer_t *write_buffer; - switch_buffer_t *read_buffer; - int silent_mode; - int write_silence_when_idle; - int setsockopt; - char answer_id[256]; - char answer_value[256]; - char ring_id[256]; - char ring_value[256]; - - char message[4096]; - char skype_voicemail_id[512]; - char skype_voicemail_id_greeting[512]; -}; - -typedef struct private_object private_t; - -void *SWITCH_THREAD_FUNC skypopen_api_thread_func(switch_thread_t *thread, void *obj); -int skypopen_audio_read(private_t *tech_pvt); -int skypopen_audio_init(private_t *tech_pvt); -int skypopen_signaling_write(private_t *tech_pvt, char *msg_to_skype); -int skypopen_signaling_read(private_t *tech_pvt); - -int skypopen_call(private_t *tech_pvt, char *idest, int timeout); -int skypopen_senddigit(private_t *tech_pvt, char digit); - -void *skypopen_do_tcp_srv_thread_func(void *obj); -void *SWITCH_THREAD_FUNC skypopen_do_tcp_srv_thread(switch_thread_t *thread, void *obj); - -void *skypopen_do_tcp_cli_thread_func(void *obj); -void *SWITCH_THREAD_FUNC skypopen_do_tcp_cli_thread(switch_thread_t *thread, void *obj); - -void *skypopen_do_skypeapi_thread_func(void *obj); -void *SWITCH_THREAD_FUNC skypopen_do_skypeapi_thread(switch_thread_t *thread, void *obj); -int dtmf_received(private_t *tech_pvt, char *value); -int start_audio_threads(private_t *tech_pvt); -int new_inbound_channel(private_t *tech_pvt); -int outbound_channel_answered(private_t *tech_pvt); -int skypopen_signaling_write(private_t *tech_pvt, char *msg_to_skype); -#if defined(WIN32) && !defined(__CYGWIN__) -int skypopen_pipe_read(switch_file_t *pipe, short *buf, int howmany); -int skypopen_pipe_write(switch_file_t *pipe, short *buf, int howmany); -/* Visual C do not have strsep ? */ -char *strsep(char **stringp, const char *delim); -#else -int skypopen_pipe_read(int pipe, short *buf, int howmany); -int skypopen_pipe_write(int pipe, short *buf, int howmany); -#endif /* WIN32 */ -int skypopen_close_socket(unsigned int fd); -private_t *find_available_skypopen_interface_rr(private_t *tech_pvt_calling); -int remote_party_is_ringing(private_t *tech_pvt); -int remote_party_is_early_media(private_t *tech_pvt); -int skypopen_answer(private_t *tech_pvt); -int skypopen_transfer(private_t *tech_pvt); -#ifndef WIN32 -int skypopen_socket_create_and_bind(private_t *tech_pvt, int *which_port); -#else -int skypopen_socket_create_and_bind(private_t *tech_pvt, unsigned short *which_port); -#endif //WIN32 -int incoming_chatmessage(private_t *tech_pvt, int which); -int next_port(void); -int skypopen_partner_handle_ring(private_t *tech_pvt); -int skypopen_answered(private_t *tech_pvt); -int inbound_channel_answered(private_t *tech_pvt); diff --git a/src/mod/endpoints/mod_skypopen/skypopen_protocol.c b/src/mod/endpoints/mod_skypopen/skypopen_protocol.c deleted file mode 100644 index d001af16ab..0000000000 --- a/src/mod/endpoints/mod_skypopen/skypopen_protocol.c +++ /dev/null @@ -1,2197 +0,0 @@ -/* - * FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application - * Copyright (C) 2005-2011, 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_gsmopen) has been contributed by: - * - * Giovanni Maruzzelli - * - * Maintainer: Giovanni Maruzzelli - * - * skypopen_protocol.c -- Low Level Interface for mod_skypopen - * - */ - - -#include "skypopen.h" - -#ifdef ASTERISK -#define skypopen_sleep usleep -#define skypopen_strncpy strncpy -#define tech_pvt p -extern int skypopen_debug; -extern char *skypopen_console_active; -#else /* FREESWITCH */ -#define skypopen_sleep switch_sleep -#define skypopen_strncpy switch_copy_string -extern switch_memory_pool_t *skypopen_module_pool; -extern switch_endpoint_interface_t *skypopen_endpoint_interface; -#endif /* ASTERISK */ -int samplerate_skypopen = SAMPLERATE_SKYPOPEN; - -extern int running; -extern char *interface_status[]; -extern char *skype_callflow[]; - -/*************************************/ -/* suspicious globals FIXME */ -#ifdef WIN32 -DWORD win32_dwThreadId; -#else - -// CLOUDTREE (Thomas Hazel) -static int global_x_error = Success; -extern struct SkypopenList global_handles_list; -extern switch_status_t remove_interface(char *the_interface, switch_bool_t force); - -#endif /* WIN32 */ -/*************************************/ -#ifndef WIN32 -int skypopen_socket_create_and_bind(private_t *tech_pvt, int *which_port) -#else -int skypopen_socket_create_and_bind(private_t *tech_pvt, unsigned short *which_port) -#endif //WIN32 -{ - int s = -1; - struct sockaddr_in my_addr; -#ifndef WIN32 - int start_port = 6001; - unsigned int size = sizeof(int); -#else - unsigned short start_port = 6001; - int size = sizeof(int); -#endif //WIN32 - int sockbufsize = 0; - int flag = 0; - - - memset(&my_addr, 0, sizeof(my_addr)); - my_addr.sin_family = AF_INET; - my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */ - - if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) { - ERRORA("socket Error\n", SKYPOPEN_P_LOG); - return -1; - } - - if (*which_port != 0) - start_port = *which_port; -#ifdef WIN32 - start_port = (unsigned short) next_port(); -#else - start_port = (unsigned short) next_port(); -#endif - my_addr.sin_port = htons(start_port); - *which_port = start_port; - while (bind(s, (struct sockaddr *) &my_addr, sizeof(struct sockaddr)) < 0) { - DEBUGA_SKYPE("*which_port=%d, tech_pvt->tcp_cli_port=%d, tech_pvt->tcp_srv_port=%d\n", SKYPOPEN_P_LOG, *which_port, tech_pvt->tcp_cli_port, - tech_pvt->tcp_srv_port); - DEBUGA_SKYPE("bind errno=%d, error: %s\n", SKYPOPEN_P_LOG, errno, strerror(errno)); - start_port++; - my_addr.sin_port = htons(start_port); - *which_port = start_port; - DEBUGA_SKYPE("*which_port=%d, tech_pvt->tcp_cli_port=%d, tech_pvt->tcp_srv_port=%d\n", SKYPOPEN_P_LOG, *which_port, tech_pvt->tcp_cli_port, - tech_pvt->tcp_srv_port); - - if (start_port > 65000) { - ERRORA("NO MORE PORTS! *which_port=%d, tech_pvt->tcp_cli_port=%d, tech_pvt->tcp_srv_port=%d\n", SKYPOPEN_P_LOG, *which_port, - tech_pvt->tcp_cli_port, tech_pvt->tcp_srv_port); - return -1; - } - } - - DEBUGA_SKYPE("Binded! *which_port=%d, tech_pvt->tcp_cli_port=%d, tech_pvt->tcp_srv_port=%d\n", SKYPOPEN_P_LOG, *which_port, tech_pvt->tcp_cli_port, - tech_pvt->tcp_srv_port); - - sockbufsize = 0; - size = sizeof(int); - getsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *) &sockbufsize, &size); - DEBUGA_SKYPE("1 SO_RCVBUF is %d, size is %d\n", SKYPOPEN_P_LOG, sockbufsize, size); - sockbufsize = 0; - size = sizeof(int); - getsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *) &sockbufsize, &size); - DEBUGA_SKYPE("1 SO_SNDBUF is %d, size is %d\n", SKYPOPEN_P_LOG, sockbufsize, size); - - - -#ifdef WIN32 - sockbufsize = SAMPLES_PER_FRAME * 8; -#else - sockbufsize = SAMPLES_PER_FRAME * 8; -#endif //WIN32 - size = sizeof(int); - if (tech_pvt->setsockopt) { - setsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *) &sockbufsize, size); - } - - sockbufsize = 0; - size = sizeof(int); - getsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *) &sockbufsize, &size); - DEBUGA_SKYPE("2 SO_RCVBUF is %d, size is %d\n", SKYPOPEN_P_LOG, sockbufsize, size); - -#ifdef WIN32 - sockbufsize = SAMPLES_PER_FRAME * 8; -#else - sockbufsize = SAMPLES_PER_FRAME * 8; -#endif //WIN32 - size = sizeof(int); - if (tech_pvt->setsockopt) { - setsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *) &sockbufsize, size); - } - - sockbufsize = 0; - size = sizeof(int); - getsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *) &sockbufsize, &size); - DEBUGA_SKYPE("2 SO_SNDBUF is %d, size is %d\n", SKYPOPEN_P_LOG, sockbufsize, size); - - flag = 0; - getsockopt(s, IPPROTO_TCP, TCP_NODELAY, (char *) &flag, &size); - DEBUGA_SKYPE("TCP_NODELAY is %d\n", SKYPOPEN_P_LOG, flag); - flag = 1; - if (tech_pvt->setsockopt) { - setsockopt(s, IPPROTO_TCP, TCP_NODELAY, (char *) &flag, size); - } - flag = 0; - getsockopt(s, IPPROTO_TCP, TCP_NODELAY, (char *) &flag, &size); - DEBUGA_SKYPE("TCP_NODELAY is %d\n", SKYPOPEN_P_LOG, flag); - - - - - return s; -} - -int skypopen_signaling_read(private_t *tech_pvt) -{ - char read_from_pipe[4096]; - char message[4096]; - char message_2[4096]; - char *buf, obj[512] = "", id[512] = "", prop[512] = "", value[512] = "", *where; - char **stringp = NULL; - int a; - unsigned int howmany; - unsigned int i; - - memset(read_from_pipe, 0, 4096); - memset(message, 0, 4096); - memset(message_2, 0, 4096); - - howmany = skypopen_pipe_read(tech_pvt->SkypopenHandles.fdesc[0], (short *) read_from_pipe, sizeof(read_from_pipe)); - - a = 0; - for (i = 0; i < howmany; i++) { - message[a] = read_from_pipe[i]; - a++; - - if (read_from_pipe[i] == '\0') { - //if (!strstr(message, "DURATION")) { - DEBUGA_SKYPE("READING: |||%s||| \n", SKYPOPEN_P_LOG, message); - strncpy(tech_pvt->message, message, sizeof(tech_pvt->message)); - //} - if (!strcasecmp(message, "SILENT_MODE OFF")) { - if (tech_pvt->silent_mode) { - DEBUGA_SKYPE("Resetting SILENT_MODE on skype_call: %s.\n", SKYPOPEN_P_LOG, id); - skypopen_signaling_write(tech_pvt, "SET SILENT_MODE ON"); - //switch_sleep(1000); - } - } - if (!strcasecmp(message, "ERROR 68")) { - DEBUGA_SKYPE - ("If I don't connect immediately, please give the Skype client authorization to be connected by Skypopen (and to not ask you again)\n", - SKYPOPEN_P_LOG); - skypopen_sleep(1000000); - skypopen_signaling_write(tech_pvt, "PROTOCOL 999"); - skypopen_sleep(20000); - return 0; - } - if (!strncasecmp(message, "ERROR 92 CALL", 12)) { - ERRORA("Skype got ERROR: |||%s|||, the (skypeout) number we called was not recognized as valid\n", SKYPOPEN_P_LOG, message); - tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED; - DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPOPEN_P_LOG); - tech_pvt->skype_call_id[0] = '\0'; - - if (tech_pvt->interface_state != SKYPOPEN_STATE_HANGUP_REQUESTED) { - tech_pvt->interface_state = SKYPOPEN_STATE_DOWN; - return CALLFLOW_INCOMING_HANGUP; - } else { - tech_pvt->interface_state = SKYPOPEN_STATE_DOWN; - } - } - - if (!strncasecmp(message, "ERROR", 4)) { - if (!strncasecmp(message, "ERROR 96 CALL", 12)) { - DEBUGA_SKYPE - ("Skype got ERROR: |||%s|||, we are trying to use this interface to make or receive a call, but another call is half-active on this interface. Let's the previous one to continue.\n", - SKYPOPEN_P_LOG, message); - } else if (!strncasecmp(message, "ERROR 99 CALL", 12)) { - DEBUGA_SKYPE("Skype got ERROR: |||%s|||, another call is active on this interface\n\n\n", SKYPOPEN_P_LOG, message); - tech_pvt->interface_state = SKYPOPEN_STATE_ERROR_DOUBLE_CALL; - } else if (!strncasecmp(message, "ERROR 531 VOICEMAIL", 18)) { - NOTICA("Skype got ERROR about VOICEMAIL, no problem: |||%s|||\n", SKYPOPEN_P_LOG, message); - } else if (!strncasecmp(message, "ERROR 529 VOICEMAIL", 18)) { - NOTICA("Skype got ERROR about VOICEMAIL, no problem: |||%s|||\n", SKYPOPEN_P_LOG, message); - } else if (!strncasecmp(message, "ERROR 592 ALTER CALL", 19)) { - NOTICA("Skype got ERROR about TRANSFERRING, no problem: |||%s|||\n", SKYPOPEN_P_LOG, message); - } else if (!strncasecmp(message, "ERROR 559 CALL", 13) | !strncasecmp(message, "ERROR 556 CALL", 13)) { - if (tech_pvt->interface_state == SKYPOPEN_STATE_PREANSWER) { - DEBUGA_SKYPE("Skype got ERROR about a failed action (probably TRYING to ANSWER A CALL), let's go down: |||%s|||\n", SKYPOPEN_P_LOG, - message); - tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED; - DEBUGA_SKYPE("skype_call now is DOWN\n", SKYPOPEN_P_LOG); - tech_pvt->skype_call_id[0] = '\0'; - tech_pvt->interface_state = SKYPOPEN_STATE_DOWN; - return CALLFLOW_INCOMING_HANGUP; - - } else { - DEBUGA_SKYPE("Skype got ERROR about a failed action (probably TRYING to HANGUP A CALL), no problem: |||%s|||\n", SKYPOPEN_P_LOG, - message); - } - } else if (!strncasecmp(message, "ERROR 36 Not online", 18)) { - char msg_to_skype[256]; - ERRORA("Skype client is not online, eg: not connected to Skype network, probably got a temporary net outage: |||%s|||\n", - SKYPOPEN_P_LOG, message); - if (strlen(tech_pvt->skype_call_id)) { - sprintf(msg_to_skype, "ALTER CALL %s HANGUP", tech_pvt->skype_call_id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - } - if (strlen(tech_pvt->ring_id)) { - sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", tech_pvt->ring_id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - } - tech_pvt->interface_state = SKYPOPEN_STATE_DOWN; - return CALLFLOW_INCOMING_HANGUP; - } else if (!strncasecmp(message, "ERROR 589 ALTER CALL", 19)) { - char msg_to_skype[256]; - DEBUGA_SKYPE("Skype client was not able to correctly manage tcp audio sockets, probably got a local or remote hangup: |||%s|||\n", - SKYPOPEN_P_LOG, message); - if (strlen(tech_pvt->skype_call_id)) { - sprintf(msg_to_skype, "ALTER CALL %s HANGUP", tech_pvt->skype_call_id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - } - if (strlen(tech_pvt->ring_id)) { - sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", tech_pvt->ring_id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - } - tech_pvt->interface_state = SKYPOPEN_STATE_DOWN; - return CALLFLOW_INCOMING_HANGUP; - } else { - ERRORA("Skype got ERROR: |||%s|||\n", SKYPOPEN_P_LOG, message); - tech_pvt->skype_callflow = CALLFLOW_STATUS_FINISHED; - ERRORA("skype_call now is DOWN\n", SKYPOPEN_P_LOG); - tech_pvt->skype_call_id[0] = '\0'; - - if (tech_pvt->interface_state != SKYPOPEN_STATE_HANGUP_REQUESTED) { - tech_pvt->interface_state = SKYPOPEN_STATE_DOWN; - return CALLFLOW_INCOMING_HANGUP; - } else { - tech_pvt->interface_state = SKYPOPEN_STATE_DOWN; - } - } - } - - skypopen_strncpy(message_2, message, sizeof(message) - 1); - buf = message; - stringp = &buf; - where = strsep(stringp, " "); - if (!where) { - WARNINGA("Skype MSG without spaces: %s\n", SKYPOPEN_P_LOG, message); - } - - if (!strcasecmp(message, "CURRENTUSERHANDLE")) { - skypopen_strncpy(obj, where, sizeof(obj) - 1); - where = strsep(stringp, " "); - skypopen_strncpy(id, where, sizeof(id) - 1); - if (!strcasecmp(id, tech_pvt->skype_user)) { - tech_pvt->SkypopenHandles.currentuserhandle = 1; - DEBUGA_SKYPE - ("Skype MSG: message: %s, currentuserhandle: %s, cuh: %s, skype_user: %s!\n", - SKYPOPEN_P_LOG, message, obj, id, tech_pvt->skype_user); - } - } - if (!strcasecmp(message, "USER")) { - skypopen_strncpy(obj, where, sizeof(obj) - 1); - where = strsep(stringp, " "); - skypopen_strncpy(id, where, sizeof(id) - 1); - where = strsep(stringp, " "); - skypopen_strncpy(prop, where, sizeof(prop) - 1); - if (!strcasecmp(prop, "RECEIVEDAUTHREQUEST")) { - char msg_to_skype[256]; - DEBUGA_SKYPE("Skype MSG: message: %s, obj: %s, id: %s, prop: %s!\n", SKYPOPEN_P_LOG, message, obj, id, prop); - sprintf(msg_to_skype, "SET USER %s ISAUTHORIZED TRUE", id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - } - } - if (!strcasecmp(message, "MESSAGE")) { - skypopen_strncpy(obj, where, sizeof(obj) - 1); - where = strsep(stringp, " "); - skypopen_strncpy(id, where, sizeof(id) - 1); - where = strsep(stringp, " "); - skypopen_strncpy(prop, where, sizeof(prop) - 1); - if (!strcasecmp(prop, "STATUS")) { - where = strsep(stringp, " "); - skypopen_strncpy(value, where, sizeof(value) - 1); - if (!strcasecmp(value, "RECEIVED")) { - char msg_to_skype[256]; - DEBUGA_SKYPE("Skype MSG: message: %s, obj: %s, id: %s, prop: %s value: %s!\n", SKYPOPEN_P_LOG, message, obj, id, prop, value); - //TODO: authomatically flag messages as read based on config param - sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - } - } else if (!strcasecmp(prop, "BODY")) { - char msg_to_skype[256]; - DEBUGA_SKYPE("Skype MSG: message: %s, obj: %s, id: %s, prop: %s!\n", SKYPOPEN_P_LOG, message, obj, id, prop); - //TODO: authomatically flag messages as read based on config param - sprintf(msg_to_skype, "SET MESSAGE %s SEEN", id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - } - } - if (!strcasecmp(message, "CHAT")) { - char msg_to_skype[256]; - int i; - int found; - - skypopen_strncpy(obj, where, sizeof(obj) - 1); - where = strsep(stringp, " "); - skypopen_strncpy(id, where, sizeof(id) - 1); - where = strsep(stringp, " "); - skypopen_strncpy(prop, where, sizeof(prop) - 1); - skypopen_strncpy(value, *stringp, sizeof(value) - 1); - - if (!strcasecmp(prop, "STATUS") && !strcasecmp(value, "DIALOG")) { - DEBUGA_SKYPE("CHAT %s is DIALOG\n", SKYPOPEN_P_LOG, id); - sprintf(msg_to_skype, "GET CHAT %s DIALOG_PARTNER", id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - } - - if (!strcasecmp(prop, "DIALOG_PARTNER")) { - DEBUGA_SKYPE("CHAT %s has DIALOG_PARTNER %s\n", SKYPOPEN_P_LOG, id, value); - found = 0; - for (i = 0; i < MAX_CHATS; i++) { - if (strlen(tech_pvt->chats[i].chatname) == 0 || !strcmp(tech_pvt->chats[i].chatname, id)) { - strncpy(tech_pvt->chats[i].chatname, id, sizeof(tech_pvt->chats[i].chatname)); - strncpy(tech_pvt->chats[i].dialog_partner, value, sizeof(tech_pvt->chats[i].dialog_partner)); - found = 1; - break; - } - } - if (!found) { - ERRORA("why we do not have a chats slot free? we have more than %d chats in parallel?\n", SKYPOPEN_P_LOG, MAX_CHATS); - } - - DEBUGA_SKYPE("CHAT %s is in position %d in the chats array, chatname=%s, dialog_partner=%s\n", SKYPOPEN_P_LOG, id, i, - tech_pvt->chats[i].chatname, tech_pvt->chats[i].dialog_partner); - } - - } - - - if (!strcasecmp(message, "CHATMESSAGE")) { - char msg_to_skype[256]; - int i; - int found; - - skypopen_strncpy(obj, where, sizeof(obj) - 1); - where = strsep(stringp, " "); - skypopen_strncpy(id, where, sizeof(id) - 1); - where = strsep(stringp, " "); - skypopen_strncpy(prop, where, sizeof(prop) - 1); - skypopen_strncpy(value, *stringp, sizeof(value) - 1); - - if (!tech_pvt->report_incoming_chatmessages) { - if (!strcasecmp(prop, "STATUS") && !strcasecmp(value, "RECEIVED")) { - sprintf(msg_to_skype, "SET CHATMESSAGE %s SEEN", id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - } - } else { - if (!strcasecmp(prop, "STATUS") && !strcasecmp(value, "RECEIVED")) { - DEBUGA_SKYPE("RECEIVED CHATMESSAGE %s, let's see which type it is\n", SKYPOPEN_P_LOG, id); - sprintf(msg_to_skype, "GET CHATMESSAGE %s TYPE", id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - } - - if (!strcasecmp(prop, "TYPE") && !strcasecmp(value, "SAID")) { - DEBUGA_SKYPE("CHATMESSAGE %s is of type SAID, let's get the other infos\n", SKYPOPEN_P_LOG, id); - found = 0; - for (i = 0; i < MAX_CHATMESSAGES; i++) { - if (strlen(tech_pvt->chatmessages[i].id) == 0) { - strncpy(tech_pvt->chatmessages[i].id, id, sizeof(tech_pvt->chatmessages[i].id)); - strncpy(tech_pvt->chatmessages[i].type, value, sizeof(tech_pvt->chatmessages[i].type)); - found = 1; - break; - } - } - if (!found) { - ERRORA("why we do not have a chatmessages slot free? we have more than %d chatmessages in parallel?\n", SKYPOPEN_P_LOG, - MAX_CHATMESSAGES); - } else { - DEBUGA_SKYPE("CHATMESSAGE %s is in position %d in the chatmessages array, type=%s, id=%s\n", SKYPOPEN_P_LOG, id, i, - tech_pvt->chatmessages[i].type, tech_pvt->chatmessages[i].id); - sprintf(msg_to_skype, "GET CHATMESSAGE %s CHATNAME", id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - //skypopen_sleep(1000); - sprintf(msg_to_skype, "GET CHATMESSAGE %s FROM_HANDLE", id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - //skypopen_sleep(1000); - sprintf(msg_to_skype, "GET CHATMESSAGE %s FROM_DISPNAME", id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - //skypopen_sleep(1000); - sprintf(msg_to_skype, "GET CHATMESSAGE %s BODY", id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - } - } - - if (!strcasecmp(prop, "CHATNAME")) { - DEBUGA_SKYPE("CHATMESSAGE %s belongs to the CHAT %s\n", SKYPOPEN_P_LOG, id, value); - found = 0; - for (i = 0; i < MAX_CHATMESSAGES; i++) { - if (!strcmp(tech_pvt->chatmessages[i].id, id)) { - strncpy(tech_pvt->chatmessages[i].chatname, value, sizeof(tech_pvt->chatmessages[i].chatname)); - found = 1; - break; - } - } - if (!found) { - DEBUGA_SKYPE("why chatmessage %s was not found in the chatmessages array??\n", SKYPOPEN_P_LOG, id); - } - } - if (!strcasecmp(prop, "FROM_HANDLE")) { - DEBUGA_SKYPE("CHATMESSAGE %s was sent by FROM_HANDLE %s\n", SKYPOPEN_P_LOG, id, value); - found = 0; - for (i = 0; i < MAX_CHATMESSAGES; i++) { - if (!strcmp(tech_pvt->chatmessages[i].id, id)) { - strncpy(tech_pvt->chatmessages[i].from_handle, value, sizeof(tech_pvt->chatmessages[i].from_handle)); - found = 1; - break; - } - } - if (!found) { - DEBUGA_SKYPE("why chatmessage %s was not found in the chatmessages array??\n", SKYPOPEN_P_LOG, id); - } - - } - if (!strcasecmp(prop, "FROM_DISPNAME")) { - DEBUGA_SKYPE("CHATMESSAGE %s was sent by FROM_DISPNAME %s\n", SKYPOPEN_P_LOG, id, value); - found = 0; - for (i = 0; i < MAX_CHATMESSAGES; i++) { - if (!strcmp(tech_pvt->chatmessages[i].id, id)) { - strncpy(tech_pvt->chatmessages[i].from_dispname, value, sizeof(tech_pvt->chatmessages[i].from_dispname)); - found = 1; - break; - } - } - if (!found) { - DEBUGA_SKYPE("why chatmessage %s was not found in the chatmessages array??\n", SKYPOPEN_P_LOG, id); - } - - } - if (!strcasecmp(prop, "BODY")) { - DEBUGA_SKYPE("CHATMESSAGE %s has BODY %s\n", SKYPOPEN_P_LOG, id, value); - found = 0; - for (i = 0; i < MAX_CHATMESSAGES; i++) { - if (!strcmp(tech_pvt->chatmessages[i].id, id)) { - strncpy(tech_pvt->chatmessages[i].body, value, sizeof(tech_pvt->chatmessages[i].body)); - found = 1; - break; - } - } - if (!found) { - DEBUGA_SKYPE("why chatmessage %s was not found in the chatmessages array??\n", SKYPOPEN_P_LOG, id); - } else { - DEBUGA_SKYPE - ("CHATMESSAGE %s is in position %d in the chatmessages array, type=%s, id=%s, chatname=%s, from_handle=%s, from_dispname=%s, body=%s\n", - SKYPOPEN_P_LOG, id, i, tech_pvt->chatmessages[i].type, tech_pvt->chatmessages[i].id, tech_pvt->chatmessages[i].chatname, - tech_pvt->chatmessages[i].from_handle, tech_pvt->chatmessages[i].from_dispname, tech_pvt->chatmessages[i].body); - if (strcmp(tech_pvt->chatmessages[i].from_handle, tech_pvt->skype_user)) { //if the message was not sent by myself - incoming_chatmessage(tech_pvt, i); - memset(&tech_pvt->chatmessages[i], '\0', sizeof(tech_pvt->chatmessages[i])); - - sprintf(msg_to_skype, "SET CHATMESSAGE %s SEEN", id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - } else { - DEBUGA_SKYPE - ("CHATMESSAGE %s is in position %d in the chatmessages array, type=%s, id=%s, chatname=%s, from_handle=%s, from_dispname=%s, body=%s NOT DELETED\n", - SKYPOPEN_P_LOG, id, i, tech_pvt->chatmessages[i].type, tech_pvt->chatmessages[i].id, tech_pvt->chatmessages[i].chatname, - tech_pvt->chatmessages[i].from_handle, tech_pvt->chatmessages[i].from_dispname, tech_pvt->chatmessages[i].body); - memset(&tech_pvt->chatmessages[i], '\0', sizeof(tech_pvt->chatmessages[i])); - DEBUGA_SKYPE("chatmessage %s HAS BEEN DELETED\n", SKYPOPEN_P_LOG, id); - } - - } - - } - } - - } - - - if (!strcasecmp(message, "VOICEMAIL")) { - char msg_to_skype[1024]; - - skypopen_strncpy(obj, where, sizeof(obj) - 1); - where = strsep(stringp, " "); - skypopen_strncpy(id, where, sizeof(id) - 1); - where = strsep(stringp, " "); - skypopen_strncpy(prop, where, sizeof(prop) - 1); - where = strsep(stringp, " "); - skypopen_strncpy(value, where, sizeof(value) - 1); - where = strsep(stringp, " "); - - //DEBUGA_SKYPE - //("Skype MSG: message: %s, obj: %s, id: %s, prop: %s, value: %s,where: %s!\n", - //SKYPOPEN_P_LOG, message, obj, id, prop, value, where ? where : "NULL"); - - if (!strcasecmp(prop, "STATUS") && !strcasecmp(value, "RECORDING") ) { - DEBUGA_SKYPE("VOICEMAIL %s INPUT\n", SKYPOPEN_P_LOG, id); - sprintf(msg_to_skype, "ALTER VOICEMAIL %s SET_INPUT PORT=\"%d\"", id, tech_pvt->tcp_cli_port); - skypopen_signaling_write(tech_pvt, msg_to_skype); - } else if (!strcasecmp(prop, "STATUS") && !strcasecmp(value, "PLAYING") ) { - DEBUGA_SKYPE("VOICEMAIL %s OUTPUT\n", SKYPOPEN_P_LOG, id); - sprintf(msg_to_skype, "ALTER VOICEMAIL %s SET_OUTPUT PORT=\"%d\"", id, tech_pvt->tcp_srv_port); - skypopen_signaling_write(tech_pvt, msg_to_skype); - sprintf(tech_pvt->skype_voicemail_id_greeting, "%s", id); - - } else if (!strcasecmp(prop, "TYPE") && !strcasecmp(value, "OUTGOING") ) { - DEBUGA_SKYPE("VOICEMAIL OUTGOING id is %s\n", SKYPOPEN_P_LOG, id); - sprintf(tech_pvt->skype_voicemail_id, "%s", id); - } else if (!strcasecmp(prop, "STATUS") && !strcasecmp(value, "PLAYED") ) { - //switch_ivr_broadcast( tech_pvt->session_uuid_str, "gentones::%(500,0,800)",SMF_ECHO_ALEG|SMF_ECHO_BLEG); - switch_ivr_broadcast( tech_pvt->session_uuid_str, "gentones::%(500,0,800)",SMF_ECHO_BLEG); - memset(tech_pvt->skype_voicemail_id_greeting, '\0', sizeof(tech_pvt->skype_voicemail_id_greeting)); - - } - } - - if (!strcasecmp(message, "CALL")) { - skypopen_strncpy(obj, where, sizeof(obj) - 1); - where = strsep(stringp, " "); - skypopen_strncpy(id, where, sizeof(id) - 1); - where = strsep(stringp, " "); - skypopen_strncpy(prop, where, sizeof(prop) - 1); - where = strsep(stringp, " "); - skypopen_strncpy(value, where, sizeof(value) - 1); - where = strsep(stringp, " "); - - //DEBUGA_SKYPE - //("Skype MSG: message: %s, obj: %s, id: %s, prop: %s, value: %s,where: %s!\n", - //SKYPOPEN_P_LOG, message, obj, id, prop, value, where ? where : "NULL"); - - if (!strcasecmp(prop, "PARTNER_HANDLE")) { - if (tech_pvt->interface_state == SKYPOPEN_STATE_IDLE) { - /* we are NOT inside an active call */ - DEBUGA_SKYPE("Call %s go to skypopen_partner_handle_ring\n", SKYPOPEN_P_LOG, id); - skypopen_strncpy(tech_pvt->ring_id, id, sizeof(tech_pvt->ring_id)); - skypopen_strncpy(tech_pvt->ring_value, value, sizeof(tech_pvt->ring_value)); - skypopen_strncpy(tech_pvt->answer_id, id, sizeof(tech_pvt->answer_id)); - skypopen_strncpy(tech_pvt->answer_value, value, sizeof(tech_pvt->answer_value)); - skypopen_partner_handle_ring(tech_pvt); - } else { - /* we are inside an active call */ - if (!strcasecmp(tech_pvt->skype_call_id, id)) { - /* this is the call in which we are calling out */ - DEBUGA_SKYPE("Call %s DO NOTHING\n", SKYPOPEN_P_LOG, id); - } else { - DEBUGA_SKYPE("Call %s TRY TRANSFER\n", SKYPOPEN_P_LOG, id); - skypopen_strncpy(tech_pvt->ring_id, id, sizeof(tech_pvt->ring_id)); - skypopen_strncpy(tech_pvt->ring_value, value, sizeof(tech_pvt->ring_value)); - skypopen_strncpy(tech_pvt->answer_id, id, sizeof(tech_pvt->answer_id)); - skypopen_strncpy(tech_pvt->answer_value, value, sizeof(tech_pvt->answer_value)); - skypopen_transfer(tech_pvt); - } - } - } - if (!strcasecmp(prop, "PARTNER_DISPNAME")) { - snprintf(tech_pvt->callid_name, sizeof(tech_pvt->callid_name) - 1, "%s%s%s", value, where ? " " : "", where ? where : ""); - } - if (!strcasecmp(prop, "CONF_ID") && !strcasecmp(value, "0")) { - } - if (!strcasecmp(prop, "CONF_ID") && strcasecmp(value, "0")) { - DEBUGA_SKYPE("the skype_call %s is a conference call\n", SKYPOPEN_P_LOG, id); - } - if (!strcasecmp(prop, "DTMF")) { - DEBUGA_SKYPE("Call %s received a DTMF: %s\n", SKYPOPEN_P_LOG, id, value); - dtmf_received(tech_pvt, value); - } - if (!strcasecmp(prop, "FAILUREREASON")) { - DEBUGA_SKYPE("Skype FAILED on skype_call %s. Let's wait for the FAILED message.\n", SKYPOPEN_P_LOG, id); - } -#if 0 -#ifndef WIN32 - if (!strcasecmp(prop, "DURATION")) { /* each 20 seconds, we zero the buffers and sync the timers */ - if (!((atoi(value) % 20))) { - if (tech_pvt->read_buffer) { - switch_mutex_lock(tech_pvt->mutex_audio_srv); - switch_buffer_zero(tech_pvt->read_buffer); - if (tech_pvt->timer_read.timer_interface && tech_pvt->timer_read.timer_interface->timer_next) { - switch_core_timer_sync(&tech_pvt->timer_read); - } - if (tech_pvt->timer_read_srv.timer_interface && tech_pvt->timer_read_srv.timer_interface->timer_next) { - switch_core_timer_sync(&tech_pvt->timer_read_srv); - } - switch_mutex_unlock(tech_pvt->mutex_audio_srv); - } - - if (tech_pvt->write_buffer) { - switch_mutex_lock(tech_pvt->mutex_audio_cli); - switch_buffer_zero(tech_pvt->write_buffer); - if (tech_pvt->timer_write.timer_interface && tech_pvt->timer_write.timer_interface->timer_next) { - switch_core_timer_sync(&tech_pvt->timer_write); - } - switch_mutex_unlock(tech_pvt->mutex_audio_cli); - } - DEBUGA_SKYPE("Synching audio on skype_call: %s.\n", SKYPOPEN_P_LOG, id); - } - } -#endif //WIN32 -#endif //0 - if (!strcasecmp(prop, "DURATION") && (!strcasecmp(value, "1"))) { - if (strcasecmp(id, tech_pvt->skype_call_id)) { - skypopen_strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); - DEBUGA_SKYPE("We called a Skype contact and he answered us on skype_call: %s.\n", SKYPOPEN_P_LOG, id); - } - } - - if (!strcasecmp(prop, "DURATION") && (tech_pvt->interface_state == SKYPOPEN_STATE_ERROR_DOUBLE_CALL)) { - char msg_to_skype[1024]; - skypopen_strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); - WARNINGA("We are in a double call situation, trying to get out hanging up call id: %s.\n", SKYPOPEN_P_LOG, id); - sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - sprintf(msg_to_skype, "ALTER CALL %s HANGUP", id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - //skypopen_sleep(10000); - } - - - if (!strcasecmp(prop, "VM_DURATION") && (!strcasecmp(value, "0"))) { - char msg_to_skype[1024]; - - NOTICA("We called a Skype contact and he started Skype voicemail on our skype_call: %s.\n", SKYPOPEN_P_LOG, id); - - if (!strlen(tech_pvt->session_uuid_str)) { - DEBUGA_SKYPE("no tech_pvt->session_uuid_str\n", SKYPOPEN_P_LOG); - } - if (tech_pvt->skype_callflow != CALLFLOW_STATUS_REMOTEHOLD) { - if (!strlen(tech_pvt->session_uuid_str) || !strlen(tech_pvt->skype_call_id) - || !strcasecmp(tech_pvt->skype_call_id, id)) { - skypopen_strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); - DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPOPEN_P_LOG, id); - - if (tech_pvt->skype_callflow != CALLFLOW_STATUS_EARLYMEDIA) { - tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS; - tech_pvt->interface_state = SKYPOPEN_STATE_UP; - - if (tech_pvt->tcp_cli_thread == NULL) { - DEBUGA_SKYPE("START start_audio_threads\n", SKYPOPEN_P_LOG); - if (start_audio_threads(tech_pvt)) { - WARNINGA("start_audio_threads FAILED\n", SKYPOPEN_P_LOG); - return CALLFLOW_INCOMING_HANGUP; - } - } - } - tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS; - if (skypopen_answered(tech_pvt) != SWITCH_STATUS_SUCCESS) { - sprintf(msg_to_skype, "ALTER CALL %s HANGUP", id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - } - } else { - DEBUGA_SKYPE("I'm on %s, skype_call %s is NOT MY call, ignoring\n", SKYPOPEN_P_LOG, tech_pvt->skype_call_id, id); - } - } else { - tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS; - DEBUGA_SKYPE("Back from REMOTEHOLD!\n", SKYPOPEN_P_LOG); - } - } - - if (!strcasecmp(prop, "STATUS")) { - - if (!strcasecmp(value, "RINGING")) { - char msg_to_skype[1024]; - if (tech_pvt->interface_state == SKYPOPEN_STATE_IDLE) { - // CLOUDTREE (Thomas Hazel) - skypopen_strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); - - /* we are NOT inside an active call */ - DEBUGA_SKYPE("NO ACTIVE calls in this moment, skype_call %s is RINGING, to ask PARTNER_DISPNAME and PARTNER_HANDLE\n", - SKYPOPEN_P_LOG, id); - sprintf(msg_to_skype, "GET CALL %s PARTNER_DISPNAME", id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - //skypopen_sleep(100); - sprintf(msg_to_skype, "GET CALL %s PARTNER_HANDLE", id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - //skypopen_sleep(10000); - } else { - /* we are inside an active call */ - if (!strcasecmp(tech_pvt->skype_call_id, id)) { - // CLOUDTREE (Thomas Hazel) - tech_pvt->ringing_state = SKYPOPEN_RINGING_PRE; - - /* this is the call in which we are calling out */ - tech_pvt->skype_callflow = CALLFLOW_STATUS_RINGING; - tech_pvt->interface_state = SKYPOPEN_STATE_RINGING; - skypopen_strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); - DEBUGA_SKYPE("Our remote party in skype_call %s is RINGING\n", SKYPOPEN_P_LOG, id); - if (remote_party_is_ringing(tech_pvt) != SWITCH_STATUS_SUCCESS) { - DEBUGA_SKYPE - ("We are getting the RINGING from a call we probably canceled, trying to get out hanging up call id: %s.\n", - SKYPOPEN_P_LOG, id); - sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - sprintf(msg_to_skype, "ALTER CALL %s HANGUP", id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - tech_pvt->skype_call_id[0] = '\0'; - // CLOUDTREE (Thomas Hazel) - tech_pvt->ringing_state = SKYPOPEN_RINGING_INIT; - tech_pvt->skype_callflow = CALLFLOW_CALL_IDLE; - tech_pvt->interface_state = SKYPOPEN_STATE_DOWN; - DEBUGA_SKYPE("we're now DOWN\n", SKYPOPEN_P_LOG); - return CALLFLOW_INCOMING_HANGUP; - - } - } else { - DEBUGA_SKYPE - ("We are in another call, but skype_call %s is RINGING on us, let's ask PARTNER_HANDLE, so maybe we'll TRANSFER\n", - SKYPOPEN_P_LOG, id); - sprintf(msg_to_skype, "GET CALL %s PARTNER_HANDLE", id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - //skypopen_sleep(10000); - } - } - } else if (!strcasecmp(value, "EARLYMEDIA")) { - char msg_to_skype[1024]; - tech_pvt->skype_callflow = CALLFLOW_STATUS_EARLYMEDIA; - tech_pvt->interface_state = SKYPOPEN_STATE_DIALING; - DEBUGA_SKYPE("Our remote party in skype_call %s is EARLYMEDIA\n", SKYPOPEN_P_LOG, id); - if (tech_pvt->tcp_cli_thread == NULL) { - DEBUGA_SKYPE("START start_audio_threads\n", SKYPOPEN_P_LOG); - if (start_audio_threads(tech_pvt)) { - ERRORA("start_audio_threads FAILED\n", SKYPOPEN_P_LOG); - return CALLFLOW_INCOMING_HANGUP; - } - } - //skypopen_sleep(1000); - sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id, tech_pvt->tcp_cli_port); - skypopen_signaling_write(tech_pvt, msg_to_skype); - //skypopen_sleep(1000); - sprintf(msg_to_skype, "#output ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id, tech_pvt->tcp_srv_port); - skypopen_signaling_write(tech_pvt, msg_to_skype); - - remote_party_is_early_media(tech_pvt); - } else if (!strcasecmp(value, "MISSED") || !strcasecmp(value, "FINISHED")) { - if (!strcasecmp(tech_pvt->skype_call_id, id)) { - DEBUGA_SKYPE("skype_call %s is MY call, now I'm going DOWN\n", SKYPOPEN_P_LOG, id); - if (tech_pvt->interface_state != SKYPOPEN_STATE_HANGUP_REQUESTED) { - return CALLFLOW_INCOMING_HANGUP; - } else { - tech_pvt->interface_state = SKYPOPEN_STATE_DOWN; - } - } else { - DEBUGA_SKYPE("skype_call %s is NOT MY call, ignoring\n", SKYPOPEN_P_LOG, id); - } - - } else if (!strcasecmp(value, "CANCELLED")) { - tech_pvt->skype_callflow = CALLFLOW_STATUS_CANCELLED; - DEBUGA_SKYPE("we tried to call Skype on skype_call %s and Skype has now CANCELLED\n", SKYPOPEN_P_LOG, id); - tech_pvt->skype_call_id[0] = '\0'; - if (tech_pvt->interface_state != SKYPOPEN_STATE_HANGUP_REQUESTED) { - tech_pvt->interface_state = SKYPOPEN_STATE_DOWN; - return CALLFLOW_INCOMING_HANGUP; - } else { - tech_pvt->interface_state = SKYPOPEN_STATE_DOWN; - } - } else if (!strcasecmp(value, "FAILED")) { - tech_pvt->skype_callflow = CALLFLOW_STATUS_FAILED; - DEBUGA_SKYPE("we tried to call Skype on skype_call %s and Skype has now FAILED\n", SKYPOPEN_P_LOG, id); - tech_pvt->skype_call_id[0] = '\0'; - skypopen_strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); - tech_pvt->interface_state = SKYPOPEN_STATE_DOWN; - return CALLFLOW_INCOMING_HANGUP; - } else if (!strcasecmp(value, "REFUSED")) { - if (!strcasecmp(id, tech_pvt->skype_call_id)) { - /* this is the id of the call we are in, probably we generated it */ - tech_pvt->skype_callflow = CALLFLOW_STATUS_REFUSED; - DEBUGA_SKYPE("we tried to call Skype on skype_call %s and Skype has now REFUSED\n", SKYPOPEN_P_LOG, id); - skypopen_strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); - tech_pvt->interface_state = SKYPOPEN_STATE_DOWN; - tech_pvt->skype_call_id[0] = '\0'; - return CALLFLOW_INCOMING_HANGUP; - } else { - /* we're here because were us that refused an incoming call */ - DEBUGA_SKYPE("we REFUSED skype_call %s\n", SKYPOPEN_P_LOG, id); - } - } else if (!strcasecmp(value, "TRANSFERRING")) { - DEBUGA_SKYPE("skype_call %s is transferring\n", SKYPOPEN_P_LOG, id); - } else if (!strcasecmp(value, "TRANSFERRED")) { - DEBUGA_SKYPE("skype_call %s has been transferred\n", SKYPOPEN_P_LOG, id); - } else if (!strcasecmp(value, "ROUTING")) { - tech_pvt->skype_callflow = CALLFLOW_STATUS_ROUTING; - tech_pvt->interface_state = SKYPOPEN_STATE_DIALING; - skypopen_strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); - DEBUGA_SKYPE("skype_call: %s is now ROUTING\n", SKYPOPEN_P_LOG, id); - } else if (!strcasecmp(value, "UNPLACED")) { - tech_pvt->skype_callflow = CALLFLOW_STATUS_UNPLACED; - tech_pvt->interface_state = SKYPOPEN_STATE_DIALING; - skypopen_strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); - DEBUGA_SKYPE("skype_call: %s is now UNPLACED\n", SKYPOPEN_P_LOG, id); - } else if (!strcasecmp(value, "INPROGRESS")) { - char msg_to_skype[1024]; - - if (!strlen(tech_pvt->session_uuid_str)) { - DEBUGA_SKYPE("no tech_pvt->session_uuid_str\n", SKYPOPEN_P_LOG); - } - if (tech_pvt->skype_callflow != CALLFLOW_STATUS_REMOTEHOLD) { - if (!strlen(tech_pvt->session_uuid_str) || !strlen(tech_pvt->skype_call_id) - || !strcasecmp(tech_pvt->skype_call_id, id)) { - skypopen_strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); - DEBUGA_SKYPE("skype_call: %s is now active\n", SKYPOPEN_P_LOG, id); - - if (tech_pvt->skype_callflow != CALLFLOW_STATUS_EARLYMEDIA) { - tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS; - tech_pvt->interface_state = SKYPOPEN_STATE_UP; - - if (tech_pvt->tcp_cli_thread == NULL) { - DEBUGA_SKYPE("START start_audio_threads\n", SKYPOPEN_P_LOG); - if (start_audio_threads(tech_pvt)) { - WARNINGA("start_audio_threads FAILED\n", SKYPOPEN_P_LOG); - return CALLFLOW_INCOMING_HANGUP; - } - } - //skypopen_sleep(1000); - sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id, tech_pvt->tcp_cli_port); - skypopen_signaling_write(tech_pvt, msg_to_skype); - //skypopen_sleep(1000); - sprintf(msg_to_skype, "#output ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id, tech_pvt->tcp_srv_port); - skypopen_signaling_write(tech_pvt, msg_to_skype); - } - tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS; - if (skypopen_answered(tech_pvt) != SWITCH_STATUS_SUCCESS) { - sprintf(msg_to_skype, "ALTER CALL %s HANGUP", id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - } - } else { - DEBUGA_SKYPE("I'm on %s, skype_call %s is NOT MY call, ignoring\n", SKYPOPEN_P_LOG, tech_pvt->skype_call_id, id); - } - } else { - tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS; - DEBUGA_SKYPE("Back from REMOTEHOLD!\n", SKYPOPEN_P_LOG); - } - - } else if (!strcasecmp(value, "LOCALHOLD")) { - char msg_to_skype[256]; - DEBUGA_SKYPE("skype_call: %s is now LOCALHOLD, let's hangup\n", SKYPOPEN_P_LOG, id); - sprintf(msg_to_skype, "ALTER CALL %s HANGUP", id); - skypopen_signaling_write(tech_pvt, msg_to_skype); - } else if (!strcasecmp(value, "REMOTEHOLD")) { - tech_pvt->skype_callflow = CALLFLOW_STATUS_REMOTEHOLD; - DEBUGA_SKYPE("skype_call: %s is now REMOTEHOLD\n", SKYPOPEN_P_LOG, id); - - } else if (!strcasecmp(value, "BUSY")) { - tech_pvt->skype_callflow = CALLFLOW_STATUS_FAILED; - DEBUGA_SKYPE - ("we tried to call Skype on skype_call %s and remote party (destination) was BUSY. Our outbound call has failed\n", - SKYPOPEN_P_LOG, id); - skypopen_strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); - tech_pvt->interface_state = SKYPOPEN_STATE_DOWN; - tech_pvt->skype_call_id[0] = '\0'; - //skypopen_sleep(1000); - return CALLFLOW_INCOMING_HANGUP; - } else if (!strcasecmp(value, "WAITING_REDIAL_COMMAND")) { - tech_pvt->skype_callflow = CALLFLOW_STATUS_FAILED; - DEBUGA_SKYPE - ("we tried to call Skype on skype_call %s and remote party (destination) has rejected us (WAITING_REDIAL_COMMAND). Our outbound call has failed\n", - SKYPOPEN_P_LOG, id); - skypopen_strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1); - tech_pvt->interface_state = SKYPOPEN_STATE_DOWN; - tech_pvt->skype_call_id[0] = '\0'; - //skypopen_sleep(1000); - return CALLFLOW_INCOMING_HANGUP; - } else if (!strncmp(value, "VM_", 2)) { - DEBUGA_SKYPE ("Our skype_call %s is in Skype voicemail: %s\n", SKYPOPEN_P_LOG, id, value); - } else { - WARNINGA("skype_call: %s, STATUS: %s is not recognized\n", SKYPOPEN_P_LOG, id, value); - } - } //STATUS - } //CALL - /* the "numbered" messages that follows are used by the directory application, not yet ported */ - if (!strcasecmp(message, "#333")) { - memset(tech_pvt->skype_friends, 0, 4096); - skypopen_strncpy(tech_pvt->skype_friends, &message_2[11], 4095); - } - if (!strcasecmp(message, "#222")) { - memset(tech_pvt->skype_fullname, 0, 512); - skypopen_strncpy(tech_pvt->skype_fullname, &message_2[10], 511); - } - if (!strcasecmp(message, "#765")) { - memset(tech_pvt->skype_displayname, 0, 512); - skypopen_strncpy(tech_pvt->skype_displayname, &message_2[10], 511); - } - a = 0; - } //message end - } //read_from_pipe - return 0; -} - -void *skypopen_do_tcp_srv_thread_func(void *obj) -{ - private_t *tech_pvt = obj; - int s; - unsigned int len; -#if defined(WIN32) && !defined(__CYGWIN__) - int sin_size; - int size = sizeof(int); -#else /* WIN32 */ - unsigned int sin_size; - unsigned int size = sizeof(int); -#endif /* WIN32 */ - unsigned int fd; - short srv_in[SAMPLES_PER_FRAME * 10]; - struct sockaddr_in remote_addr; - int sockbufsize = 0; - - s = skypopen_socket_create_and_bind(tech_pvt, &tech_pvt->tcp_srv_port); - if (s < 0) { - ERRORA("skypopen_socket_create_and_bind error!\n", SKYPOPEN_P_LOG); - return NULL; - } - DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPOPEN_P_LOG); - - listen(s, 6); - - sin_size = sizeof(remote_addr); - - while (tech_pvt && tech_pvt->interface_state != SKYPOPEN_STATE_DOWN - && (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS - || tech_pvt->skype_callflow == CALLFLOW_STATUS_EARLYMEDIA - || tech_pvt->skype_callflow == CALLFLOW_STATUS_REMOTEHOLD || tech_pvt->skype_callflow == SKYPOPEN_STATE_UP)) { - - unsigned int fdselectgio; - int rtgio; - fd_set fsgio; - struct timeval togio; - - if (!(running && tech_pvt->running)) - break; - FD_ZERO(&fsgio); - togio.tv_usec = MS_SKYPOPEN * 1000; - togio.tv_sec = 0; - fdselectgio = s; - FD_SET(fdselectgio, &fsgio); - - rtgio = select(fdselectgio + 1, &fsgio, NULL, NULL, &togio); - - if (rtgio) { - - while (s > 0 && (fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) { - DEBUGA_SKYPE("ACCEPTED here I send you %d\n", SKYPOPEN_P_LOG, tech_pvt->tcp_srv_port); - - sockbufsize = 0; - size = sizeof(int); - getsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *) &sockbufsize, &size); - DEBUGA_SKYPE("3 SO_RCVBUF is %d, size is %d\n", SKYPOPEN_P_LOG, sockbufsize, size); - sockbufsize = 0; - size = sizeof(int); - getsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *) &sockbufsize, &size); - DEBUGA_SKYPE("3 SO_SNDBUF is %d, size is %d\n", SKYPOPEN_P_LOG, sockbufsize, size); - - - if (!(running && tech_pvt->running)) - break; - while (tech_pvt && tech_pvt->interface_state != SKYPOPEN_STATE_DOWN - && tech_pvt->interface_state != SKYPOPEN_STATE_IDLE - && tech_pvt->interface_state != SKYPOPEN_STATE_HANGUP_REQUESTED - && (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS - || tech_pvt->skype_callflow == CALLFLOW_STATUS_EARLYMEDIA - || tech_pvt->skype_callflow == CALLFLOW_STATUS_REMOTEHOLD || tech_pvt->skype_callflow == SKYPOPEN_STATE_UP)) { - - unsigned int fdselect; - int rt = 1; - fd_set fs; - struct timeval to; - int nospace; - - if (!(running && tech_pvt->running)) - break; -#if 1 - fdselect = fd; - FD_ZERO(&fs); - FD_SET(fdselect, &fs); - to.tv_usec = MS_SKYPOPEN * 1000 * 3; - to.tv_sec = 0; -#endif //0 - - if (tech_pvt->timer_read_srv.timer_interface && tech_pvt->timer_read_srv.timer_interface->timer_next) { - switch_core_timer_next(&tech_pvt->timer_read_srv); - } else { - skypopen_sleep(20000); - - } - rt = select(fdselect + 1, &fs, NULL, NULL, &to); - if (rt > 0) { - - if (tech_pvt->skype_callflow != CALLFLOW_STATUS_REMOTEHOLD) { - len = recv(fd, (char *) srv_in, BYTES_PER_FRAME * 2, 0); - } else { - //skypopen_sleep(10000); - continue; - } - if (tech_pvt->begin_to_read == 0) { - DEBUGA_SKYPE("len=%d\n", SKYPOPEN_P_LOG, len); - //skypopen_sleep(10000); - continue; - } - - if (len == -1) { - DEBUGA_SKYPE("len=%d, error: %s\n", SKYPOPEN_P_LOG, len, strerror(errno)); - break; - } - nospace = 0; - if (len > 0) { - switch_mutex_lock(tech_pvt->mutex_audio_srv); - if (tech_pvt->read_buffer) { - if (switch_buffer_freespace(tech_pvt->read_buffer) < len) { - switch_buffer_zero(tech_pvt->read_buffer); - switch_buffer_write(tech_pvt->read_buffer, srv_in, len); - nospace = 1; - } else { - switch_buffer_write(tech_pvt->read_buffer, srv_in, len); - } - } - switch_mutex_unlock(tech_pvt->mutex_audio_srv); - if (nospace) { - DEBUGA_SKYPE("NO SPACE in READ BUFFER: there was no space for: %d\n", SKYPOPEN_P_LOG, len); - } - } else if (len == 0) { - DEBUGA_SKYPE("CLOSED\n", SKYPOPEN_P_LOG); - break; - } else { - DEBUGA_SKYPE("len=%d\n", SKYPOPEN_P_LOG, len); - } - - } else if (rt == 0) { - continue; - } else { - DEBUGA_SKYPE("SRV rt=%d\n", SKYPOPEN_P_LOG, rt); - break; - } - - } - - DEBUGA_SKYPE("Skype incoming audio GONE\n", SKYPOPEN_P_LOG); - tech_pvt->skype_callflow = CALLFLOW_INCOMING_HANGUP; - skypopen_close_socket(fd); - break; - } - break; - } - } - - DEBUGA_SKYPE("incoming audio (read) server (I am it) EXITING\n", SKYPOPEN_P_LOG); - skypopen_close_socket(s); - s = -1; - //DEBUGA_SKYPE("debugging_hangup PRE srv lock\n", SKYPOPEN_P_LOG); - switch_mutex_lock(tech_pvt->mutex_thread_audio_srv); - //DEBUGA_SKYPE("debugging_hangup srv lock\n", SKYPOPEN_P_LOG); - tech_pvt->tcp_srv_thread = NULL; - switch_mutex_unlock(tech_pvt->mutex_thread_audio_srv); - //DEBUGA_SKYPE("debugging_hangup srv unlock\n", SKYPOPEN_P_LOG); - return NULL; -} - -void *skypopen_do_tcp_cli_thread_func(void *obj) -{ - private_t *tech_pvt = obj; - int s; - struct sockaddr_in remote_addr; - unsigned int len; - unsigned int fd; - short cli_out[SAMPLES_PER_FRAME * 2 * 10]; -#ifdef WIN32 - int sin_size; - int size = sizeof(int); -#else - unsigned int sin_size; - unsigned int size = sizeof(int); -#endif /* WIN32 */ - int sockbufsize = 0; - - s = skypopen_socket_create_and_bind(tech_pvt, &tech_pvt->tcp_cli_port); - if (s < 0) { - ERRORA("skypopen_socket_create_and_bind error!\n", SKYPOPEN_P_LOG); - return NULL; - } - - - - DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPOPEN_P_LOG); - - listen(s, 6); - - sin_size = sizeof(remote_addr); - - while (tech_pvt && tech_pvt->interface_state != SKYPOPEN_STATE_DOWN - && (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS - || tech_pvt->skype_callflow == CALLFLOW_STATUS_EARLYMEDIA - || tech_pvt->skype_callflow == CALLFLOW_STATUS_REMOTEHOLD || tech_pvt->skype_callflow == SKYPOPEN_STATE_UP)) { - - unsigned int fdselectgio; - int rtgio; - fd_set fsgio; - struct timeval togio; - - if (!(running && tech_pvt->running)) - break; - FD_ZERO(&fsgio); - togio.tv_usec = MS_SKYPOPEN * 1000 * 3; - togio.tv_sec = 0; - fdselectgio = s; - FD_SET(fdselectgio, &fsgio); - - rtgio = select(fdselectgio + 1, &fsgio, NULL, NULL, &togio); - - if (rtgio) { - - while (s > 0 && (fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) { - DEBUGA_SKYPE("ACCEPTED here you send me %d\n", SKYPOPEN_P_LOG, tech_pvt->tcp_cli_port); - - sockbufsize = 0; - size = sizeof(int); - getsockopt(s, SOL_SOCKET, SO_RCVBUF, (char *) &sockbufsize, &size); - DEBUGA_SKYPE("4 SO_RCVBUF is %d, size is %d\n", SKYPOPEN_P_LOG, sockbufsize, size); - sockbufsize = 0; - size = sizeof(int); - getsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *) &sockbufsize, &size); - DEBUGA_SKYPE("4 SO_SNDBUF is %d, size is %d\n", SKYPOPEN_P_LOG, sockbufsize, size); - - - - if (!(running && tech_pvt->running)) - break; - while (tech_pvt && tech_pvt->interface_state != SKYPOPEN_STATE_DOWN - && tech_pvt->interface_state != SKYPOPEN_STATE_IDLE - && tech_pvt->interface_state != SKYPOPEN_STATE_HANGUP_REQUESTED - && (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS - || tech_pvt->skype_callflow == CALLFLOW_STATUS_EARLYMEDIA - || tech_pvt->skype_callflow == CALLFLOW_STATUS_REMOTEHOLD || tech_pvt->skype_callflow == SKYPOPEN_STATE_UP)) { - size_t bytes_to_write; - - if (!(running && tech_pvt->running)) - break; - - if (tech_pvt->timer_write.timer_interface && tech_pvt->timer_write.timer_interface->timer_next - && tech_pvt->interface_state != SKYPOPEN_STATE_HANGUP_REQUESTED) { - switch_core_timer_next(&tech_pvt->timer_write); - } else { - skypopen_sleep(20000); - } - - if (tech_pvt->begin_to_write == 0) { - memset(cli_out, 255, sizeof(cli_out)); - bytes_to_write = BYTES_PER_FRAME; - len = send(fd, (char *) cli_out, bytes_to_write, 0); - if (len == -1) { - DEBUGA_SKYPE("len=%d, error: %s\n", SKYPOPEN_P_LOG, len, strerror(errno)); - break; - } - //skypopen_sleep(10000); - continue; - } else { - - bytes_to_write = 0; - - if (tech_pvt->skype_callflow == CALLFLOW_INCOMING_HANGUP) { - break; - } - switch_mutex_lock(tech_pvt->mutex_audio_cli); - if (tech_pvt->write_buffer && switch_buffer_inuse(tech_pvt->write_buffer)) { - bytes_to_write = switch_buffer_read(tech_pvt->write_buffer, cli_out, BYTES_PER_FRAME); - } - switch_mutex_unlock(tech_pvt->mutex_audio_cli); - - if (!bytes_to_write) { - if (tech_pvt->write_silence_when_idle) { - memset(cli_out, 255, sizeof(cli_out)); - bytes_to_write = BYTES_PER_FRAME; - //DEBUGA_SKYPE("WRITE Silence!\n", SKYPOPEN_P_LOG); - } else { - continue; - } - } - /* send the 16khz frame to the Skype client waiting for incoming audio to be sent to the remote party */ - if (tech_pvt->skype_callflow != CALLFLOW_STATUS_REMOTEHOLD) { - len = send(fd, (char *) cli_out, bytes_to_write, 0); - if (len == -1) { - DEBUGA_SKYPE("len=%d, error: %s\n", SKYPOPEN_P_LOG, len, strerror(errno)); - break; - } - if (len != bytes_to_write) { - DEBUGA_SKYPE("len=%d\n", SKYPOPEN_P_LOG, len); - } - } - } - - } - DEBUGA_SKYPE("Skype outbound audio GONE\n", SKYPOPEN_P_LOG); - tech_pvt->skype_callflow = CALLFLOW_INCOMING_HANGUP; - skypopen_close_socket(fd); - break; - } - break; - } - } - - DEBUGA_SKYPE("outbound audio server (I am it) EXITING\n", SKYPOPEN_P_LOG); - skypopen_close_socket(s); - s = -1; - //DEBUGA_SKYPE("debugging_hangup PRE cli lock\n", SKYPOPEN_P_LOG); - switch_mutex_lock(tech_pvt->mutex_thread_audio_cli); - //DEBUGA_SKYPE("debugging_hangup cli lock\n", SKYPOPEN_P_LOG); - tech_pvt->tcp_cli_thread = NULL; - switch_mutex_unlock(tech_pvt->mutex_thread_audio_cli); - //DEBUGA_SKYPE("debugging_hangup cli unlock\n", SKYPOPEN_P_LOG); - return NULL; -} - -int skypopen_senddigit(private_t *tech_pvt, char digit) -{ - char msg_to_skype[1024]; - - DEBUGA_SKYPE("DIGIT received: %c\n", SKYPOPEN_P_LOG, digit); - if (digit != 'a' && digit != 'A' && digit != 'b' && digit != 'B' && digit != 'c' && digit != 'C' && digit != 'd' && digit != 'D') { - sprintf(msg_to_skype, "SET CALL %s DTMF %c", tech_pvt->skype_call_id, digit); - skypopen_signaling_write(tech_pvt, msg_to_skype); - } else { - WARNINGA("Received DTMF DIGIT \"%c\", but not relayed to Skype client because Skype client accepts only 0-9*#\n", SKYPOPEN_P_LOG, digit); - } - - return 0; -} - -int skypopen_call(private_t *tech_pvt, char *rdest, int timeout) -{ - char msg_to_skype[1024]; - - DEBUGA_SKYPE("Calling Skype, rdest is: %s\n", SKYPOPEN_P_LOG, rdest); - - sprintf(msg_to_skype, "CALL %s", rdest); - if (skypopen_signaling_write(tech_pvt, msg_to_skype) < 0) { - ERRORA("failed to communicate with Skype client, now exit\n", SKYPOPEN_P_LOG); - return -1; - } - return 0; -} - -/***************************/ -/* PLATFORM SPECIFIC */ -/***************************/ -#if defined(WIN32) && !defined(__CYGWIN__) -int skypopen_pipe_read(switch_file_t *pipe, short *buf, int howmany) -{ - switch_size_t quantity; - - quantity = howmany; - - switch_file_read(pipe, buf, &quantity); - - howmany = (int)quantity; - - return howmany; -} - -int skypopen_pipe_write(switch_file_t *pipe, short *buf, int howmany) -{ - switch_size_t quantity; - - quantity = howmany; - - switch_file_write(pipe, buf, &quantity); - - howmany = (int)quantity; - - return howmany; -} - -int skypopen_close_socket(unsigned int fd) -{ - int res; - - res = closesocket(fd); - - return res; -} - -int skypopen_audio_init(private_t *tech_pvt) -{ - switch_status_t rv; - rv = switch_file_pipe_create(&tech_pvt->audiopipe_srv[0], &tech_pvt->audiopipe_srv[1], skypopen_module_pool); - rv = switch_file_pipe_create(&tech_pvt->audiopipe_cli[0], &tech_pvt->audiopipe_cli[1], skypopen_module_pool); - return 0; -} -#else /* WIN32 */ -int skypopen_pipe_read(int pipe, short *buf, int howmany) -{ - howmany = read(pipe, buf, howmany); - return howmany; -} - -int skypopen_pipe_write(int pipe, short *buf, int howmany) -{ - if (buf) { - howmany = write(pipe, buf, howmany); - return howmany; - } else { - return 0; - } -} - -int skypopen_close_socket(unsigned int fd) -{ - int res; - - res = close(fd); - - return res; -} - -int skypopen_audio_init(private_t *tech_pvt) -{ - if (pipe(tech_pvt->audiopipe_srv)) { - fcntl(tech_pvt->audiopipe_srv[0], F_SETFL, O_NONBLOCK); - fcntl(tech_pvt->audiopipe_srv[1], F_SETFL, O_NONBLOCK); - } - if (pipe(tech_pvt->audiopipe_cli)) { - fcntl(tech_pvt->audiopipe_cli[0], F_SETFL, O_NONBLOCK); - fcntl(tech_pvt->audiopipe_cli[1], F_SETFL, O_NONBLOCK); - } - -/* this pipe is the audio fd for asterisk to poll on during a call. FS do not use it */ - tech_pvt->skypopen_sound_capt_fd = tech_pvt->audiopipe_srv[0]; - - return 0; -} -#endif /* WIN32 */ - -#ifdef WIN32 - -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 -}; - -/* Visual C do not have strsep? */ -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; -} - -int skypopen_signaling_write(private_t *tech_pvt, char *msg_to_skype) -{ - static char acInputRow[1024]; - COPYDATASTRUCT oCopyData; - - DEBUGA_SKYPE("SENDING: |||%s||||\n", SKYPOPEN_P_LOG, msg_to_skype); - - sprintf(acInputRow, "%s", msg_to_skype); - /* send command to skype */ - oCopyData.dwData = 0; - oCopyData.lpData = acInputRow; - oCopyData.cbData = strlen(acInputRow) + 1; - if (oCopyData.cbData != 1) { - if (SendMessage - (tech_pvt->SkypopenHandles.win32_hGlobal_SkypeAPIWindowHandle, WM_COPYDATA, - (WPARAM) tech_pvt->SkypopenHandles.win32_hInit_MainWindowHandle, (LPARAM) & oCopyData) == FALSE) { - ERRORA("Sending message failed - probably Skype crashed.\n\nPlease shutdown Skypopen, then launch Skypopen and try again.\n", SKYPOPEN_P_LOG); - return -1; - } - } - - return 0; - -} - -LRESULT APIENTRY skypopen_present(HWND hWindow, UINT uiMessage, WPARAM uiParam, LPARAM ulParam) -{ - LRESULT lReturnCode; - int fIssueDefProc; - private_t *tech_pvt = NULL; - - lReturnCode = 0; - fIssueDefProc = 0; - tech_pvt = (private_t *)(intptr_t) GetWindowLong(hWindow, GWLP_USERDATA); - - if (!running) { - DEBUGA_SKYPE("let's DIE!\n", SKYPOPEN_P_LOG); - tech_pvt->SkypopenHandles.win32_hInit_MainWindowHandle = NULL; - PostQuitMessage(0); - return lReturnCode; - } - switch (uiMessage) { - case WM_CREATE: - tech_pvt = (private_t *) ((LPCREATESTRUCT) ulParam)->lpCreateParams; - SetWindowLong(hWindow, GWLP_USERDATA, (LONG) (intptr_t)tech_pvt); - DEBUGA_SKYPE("got CREATE\n", SKYPOPEN_P_LOG); - break; - case WM_DESTROY: - DEBUGA_SKYPE("got DESTROY\n", SKYPOPEN_P_LOG); - tech_pvt->SkypopenHandles.win32_hInit_MainWindowHandle = NULL; - PostQuitMessage(0); - break; - case WM_COPYDATA: - if (tech_pvt->SkypopenHandles.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)); - skypopen_strncpy(msg_from_skype, (const char *) poCopyData->lpData, sizeof(msg_from_skype) - 2); - - howmany = strlen(msg_from_skype) + 1; - howmany = skypopen_pipe_write(tech_pvt->SkypopenHandles.fdesc[1], (short *) msg_from_skype, howmany); - lReturnCode = 1; - } - break; - default: - if (tech_pvt && tech_pvt->SkypopenHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach) { - if (uiMessage == tech_pvt->SkypopenHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach) { - switch (ulParam) { - case SKYPECONTROLAPI_ATTACH_SUCCESS: - if (!tech_pvt->SkypopenHandles.currentuserhandle) { - //DEBUGA_SKYPE("\n\n\tConnected to Skype API!\n", SKYPOPEN_P_LOG); - tech_pvt->SkypopenHandles.api_connected = 1; - tech_pvt->SkypopenHandles.win32_hGlobal_SkypeAPIWindowHandle = (HWND) uiParam; - tech_pvt->SkypopenHandles.win32_hGlobal_SkypeAPIWindowHandle = tech_pvt->SkypopenHandles.win32_hGlobal_SkypeAPIWindowHandle; - } - break; - case SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION: - skypopen_sleep(20000); - break; - case SKYPECONTROLAPI_ATTACH_REFUSED: - ERRORA("Skype client refused to be connected by Skypopen!\n", SKYPOPEN_P_LOG); - break; - case SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE: - ERRORA("Skype API not (yet?) available\n", SKYPOPEN_P_LOG); - break; - case SKYPECONTROLAPI_ATTACH_API_AVAILABLE: - DEBUGA_SKYPE("Skype API available\n", SKYPOPEN_P_LOG); - skypopen_sleep(20000); - break; - default: - WARNINGA("GOT AN UNKNOWN SKYPE WINDOWS MSG\n", SKYPOPEN_P_LOG); - } - lReturnCode = 1; - break; - } - } - fIssueDefProc = 1; - break; - } - if (fIssueDefProc) - lReturnCode = DefWindowProc(hWindow, uiMessage, uiParam, ulParam); - return (lReturnCode); -} - -int win32_Initialize_CreateWindowClass(private_t *tech_pvt) -{ - unsigned char *paucUUIDString; - RPC_STATUS lUUIDResult; - int fReturnStatus; - UUID oUUID; - - fReturnStatus = 0; - lUUIDResult = UuidCreate(&oUUID); - tech_pvt->SkypopenHandles.win32_hInit_ProcessHandle = (HINSTANCE) OpenProcess(PROCESS_DUP_HANDLE, FALSE, GetCurrentProcessId()); - if (tech_pvt->SkypopenHandles.win32_hInit_ProcessHandle != NULL && (lUUIDResult == RPC_S_OK || lUUIDResult == RPC_S_UUID_LOCAL_ONLY)) { - if (UuidToString(&oUUID, &paucUUIDString) == RPC_S_OK) { - WNDCLASS oWindowClass; - - strcpy(tech_pvt->SkypopenHandles.win32_acInit_WindowClassName, "Skype-API-Skypopen-"); - strcat(tech_pvt->SkypopenHandles.win32_acInit_WindowClassName, (char *) paucUUIDString); - - oWindowClass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS; - oWindowClass.lpfnWndProc = (WNDPROC) & skypopen_present; - oWindowClass.cbClsExtra = 0; - oWindowClass.cbWndExtra = 0; - oWindowClass.hInstance = tech_pvt->SkypopenHandles.win32_hInit_ProcessHandle; - oWindowClass.hIcon = NULL; - oWindowClass.hCursor = NULL; - oWindowClass.hbrBackground = NULL; - oWindowClass.lpszMenuName = NULL; - oWindowClass.lpszClassName = tech_pvt->SkypopenHandles.win32_acInit_WindowClassName; - - if (RegisterClass(&oWindowClass) != 0) - fReturnStatus = 1; - - RpcStringFree(&paucUUIDString); - } - } - if (fReturnStatus == 0) - CloseHandle(tech_pvt->SkypopenHandles.win32_hInit_ProcessHandle); - tech_pvt->SkypopenHandles.win32_hInit_ProcessHandle = NULL; - return (fReturnStatus); -} - -void win32_DeInitialize_DestroyWindowClass(private_t *tech_pvt) -{ - UnregisterClass(tech_pvt->SkypopenHandles.win32_acInit_WindowClassName, tech_pvt->SkypopenHandles.win32_hInit_ProcessHandle); - CloseHandle(tech_pvt->SkypopenHandles.win32_hInit_ProcessHandle); - tech_pvt->SkypopenHandles.win32_hInit_ProcessHandle = NULL; -} - -int win32_Initialize_CreateMainWindow(private_t *tech_pvt) -{ - tech_pvt->SkypopenHandles.win32_hInit_MainWindowHandle = - CreateWindowEx(WS_EX_APPWINDOW | WS_EX_WINDOWEDGE, - tech_pvt->SkypopenHandles.win32_acInit_WindowClassName, "", - WS_BORDER | WS_SYSMENU | WS_MINIMIZEBOX, CW_USEDEFAULT, CW_USEDEFAULT, - 128, 128, NULL, 0, tech_pvt->SkypopenHandles.win32_hInit_ProcessHandle, tech_pvt); - return (tech_pvt->SkypopenHandles.win32_hInit_MainWindowHandle != NULL ? 1 : 0); -} - -void win32_DeInitialize_DestroyMainWindow(private_t *tech_pvt) -{ - if (tech_pvt->SkypopenHandles.win32_hInit_MainWindowHandle != NULL) - DestroyWindow(tech_pvt->SkypopenHandles.win32_hInit_MainWindowHandle), tech_pvt->SkypopenHandles.win32_hInit_MainWindowHandle = NULL; -} - -void *skypopen_do_skypeapi_thread_func(void *obj) -{ - private_t *tech_pvt = obj; -#if defined(WIN32) && !defined(__CYGWIN__) - switch_status_t rv; - - switch_file_pipe_create(&tech_pvt->SkypopenHandles.fdesc[0], &tech_pvt->SkypopenHandles.fdesc[1], skypopen_module_pool); - rv = switch_file_pipe_create(&tech_pvt->SkypopenHandles.fdesc[0], &tech_pvt->SkypopenHandles.fdesc[1], skypopen_module_pool); -#else /* WIN32 */ - if (pipe(tech_pvt->SkypopenHandles.fdesc)) { - fcntl(tech_pvt->SkypopenHandles.fdesc[0], F_SETFL, O_NONBLOCK); - fcntl(tech_pvt->SkypopenHandles.fdesc[1], F_SETFL, O_NONBLOCK); - } -#endif /* WIN32 */ - - tech_pvt->SkypopenHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach = RegisterWindowMessage("SkypeControlAPIAttach"); - tech_pvt->SkypopenHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover = RegisterWindowMessage("SkypeControlAPIDiscover"); - - skypopen_sleep(200000); //0,2 sec - - if (tech_pvt->SkypopenHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach != 0 - && tech_pvt->SkypopenHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover != 0) { - if (win32_Initialize_CreateWindowClass(tech_pvt)) { - if (win32_Initialize_CreateMainWindow(tech_pvt)) { - if (SendMessage - (HWND_BROADCAST, - tech_pvt->SkypopenHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover, - (WPARAM) tech_pvt->SkypopenHandles.win32_hInit_MainWindowHandle, 0) != 0) { - tech_pvt->SkypopenHandles.win32_hInit_MainWindowHandle = tech_pvt->SkypopenHandles.win32_hInit_MainWindowHandle; - while (running && tech_pvt->running) { - MSG oMessage; - if (!(running && tech_pvt->running)) - break; - while (GetMessage(&oMessage, 0, 0, 0)) { - TranslateMessage(&oMessage); - DispatchMessage(&oMessage); - } - } - } - win32_DeInitialize_DestroyMainWindow(tech_pvt); - } - win32_DeInitialize_DestroyWindowClass(tech_pvt); - } - } - tech_pvt->skypopen_api_thread = NULL; - DEBUGA_SKYPE("EXITING\n", SKYPOPEN_P_LOG); - return NULL; -} - -#else /* NOT WIN32 */ - -// CLOUDTREE (Thomas Hazel) -int xio_error_handler(Display * dpy) -{ - private_t *tech_pvt = NULL; - struct SkypopenHandles *handle; - - ERRORA("Fatal display error for %d, %s\n", SKYPOPEN_P_LOG, skypopen_list_size(&global_handles_list), dpy->display_name); - - handle = skypopen_list_remove_by_value(&global_handles_list, dpy); - if (handle != NULL) { -#ifdef XIO_ERROR_BY_SETJMP - siglongjmp(handle->ioerror_context, 1); -#endif -#ifdef XIO_ERROR_BY_UCONTEXT - setcontext(&handle->ioerror_context); -#endif - } - - ERRORA("Fatal display error for %p, %s - failed to siglongjmp\n", SKYPOPEN_P_LOG, (void *) handle, dpy->display_name); - - return 0; -} - -int xio_error_handler2(Display * dpy, XErrorEvent * err) -{ - private_t *tech_pvt = NULL; - struct SkypopenHandles *handle; - global_x_error = err->error_code; - - ERRORA("Received error code %d from X Server\n\n", SKYPOPEN_P_LOG, global_x_error); - ERRORA("Display error for %d, %s\n", SKYPOPEN_P_LOG, skypopen_list_size(&global_handles_list), dpy->display_name); - - handle = skypopen_list_remove_by_value(&global_handles_list, dpy); - if (handle != NULL) { -#ifdef XIO_ERROR_BY_SETJMP - siglongjmp(handle->ioerror_context, 1); -#endif -#ifdef XIO_ERROR_BY_UCONTEXT - setcontext(&handle->ioerror_context); -#endif - } - - ERRORA("Fatal display error for %p, %s - failed to siglongjmp\n", SKYPOPEN_P_LOG, (void *) handle, dpy->display_name); - - return 0; -} - - -int X11_errors_handler(Display * dpy, XErrorEvent * err) -{ - private_t *tech_pvt = NULL; - (void) dpy; - - global_x_error = err->error_code; - ERRORA("Received error code %d from X Server\n\n", SKYPOPEN_P_LOG, global_x_error); - return 0; /* ignore the error */ -} - -int skypopen_send_message(private_t *tech_pvt, const char *message_P) -{ - struct SkypopenHandles *SkypopenHandles = &tech_pvt->SkypopenHandles; - Window w_P = SkypopenHandles->skype_win; - Display *disp = SkypopenHandles->disp; - Window handle_P = SkypopenHandles->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; - - //skypopen_sleep(1000); - //XFlush(disp); - - 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; - - // CLOUDTREE (Thomas Hazel) - global_x_error = Success; - - 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); - - XFlush(disp); - - // CLOUDTREE (Thomas Hazel) - if (global_x_error != Success) { - ERRORA("Sending message failed with status %d\n", SKYPOPEN_P_LOG, global_x_error); - tech_pvt->running = 0; - return 0; - } - - return 1; -} - -int skypopen_signaling_write(private_t *tech_pvt, char *msg_to_skype) -{ - - DEBUGA_SKYPE("SENDING: |||%s||||\n", SKYPOPEN_P_LOG, msg_to_skype); - - - if (!skypopen_send_message(tech_pvt, msg_to_skype)) { - ERRORA - ("Sending message failed - probably Skype crashed.\n\nPlease shutdown Skypopen, then restart Skype, then launch Skypopen and try again.\n", - SKYPOPEN_P_LOG); - return -1; - } - - return 0; - -} - -int skypopen_present(struct SkypopenHandles *SkypopenHandles) -{ - Atom skype_inst = XInternAtom(SkypopenHandles->disp, "_SKYPE_INSTANCE", True); - - Atom type_ret; - int format_ret; - unsigned long nitems_ret; - unsigned long bytes_after_ret; - unsigned char *prop; - int status; - private_t *tech_pvt = NULL; - - status = - XGetWindowProperty(SkypopenHandles->disp, DefaultRootWindow(SkypopenHandles->disp), - skype_inst, 0, 1, False, XA_WINDOW, &type_ret, &format_ret, &nitems_ret, &bytes_after_ret, &prop); - - /* sanity check */ - if (status != Success || format_ret != 32 || nitems_ret != 1) { - SkypopenHandles->skype_win = (Window) - 1; - DEBUGA_SKYPE("Skype instance not found\n", SKYPOPEN_P_LOG); - running = 0; - SkypopenHandles->api_connected = 0; - return 0; - } - - SkypopenHandles->skype_win = *(const unsigned long *) prop & 0xffffffff; - DEBUGA_SKYPE("Skype instance found with id #%d\n", SKYPOPEN_P_LOG, (unsigned int) SkypopenHandles->skype_win); - SkypopenHandles->api_connected = 1; - return 1; -} - -void skypopen_clean_disp(void *data) -{ - - int *dispptr; - int disp; - private_t *tech_pvt = NULL; - - dispptr = data; - disp = *dispptr; - - if (disp) { - DEBUGA_SKYPE("to be destroyed disp %d\n", SKYPOPEN_P_LOG, disp); - close(disp); - DEBUGA_SKYPE("destroyed disp\n", SKYPOPEN_P_LOG); - } else { - DEBUGA_SKYPE("NOT destroyed disp\n", SKYPOPEN_P_LOG); - } - DEBUGA_SKYPE("OUT destroyed disp\n", SKYPOPEN_P_LOG); - skypopen_sleep(20000); -} - -void *skypopen_do_skypeapi_thread_func(void *obj) -{ - - private_t *tech_pvt = obj; - struct SkypopenHandles *SkypopenHandles; - char buf[512]; - Display *disp = NULL; - Window root = -1; - Window win = -1; - int xfd; - fd_set xfds; - - if (!strlen(tech_pvt->X11_display)) - strcpy(tech_pvt->X11_display, getenv("DISPLAY")); - - if (!tech_pvt->tcp_srv_port) - tech_pvt->tcp_srv_port = 10160; - - if (!tech_pvt->tcp_cli_port) - tech_pvt->tcp_cli_port = 10161; - - if (pipe(tech_pvt->SkypopenHandles.fdesc)) { - fcntl(tech_pvt->SkypopenHandles.fdesc[0], F_SETFL, O_NONBLOCK); - fcntl(tech_pvt->SkypopenHandles.fdesc[1], F_SETFL, O_NONBLOCK); - } - SkypopenHandles = &tech_pvt->SkypopenHandles; - disp = XOpenDisplay(tech_pvt->X11_display); - if (!disp) { - ERRORA("Cannot open X Display '%s', exiting skype thread\n", SKYPOPEN_P_LOG, tech_pvt->X11_display); - running = 0; - - // CLOUDTREE (Thomas Hazel) - tech_pvt->skypopen_api_thread = NULL; - remove_interface(tech_pvt->skype_user, FALSE); - return NULL; - } else { - DEBUGA_SKYPE("X Display '%s' opened\n", SKYPOPEN_P_LOG, tech_pvt->X11_display); - } - - // CLOUDTREE (Thomas Hazel) -#ifndef WIN32 - { - char interfacename[256]; - - skypopen_list_add(&global_handles_list, SkypopenHandles); - sprintf(interfacename, "#%s", tech_pvt->name); - -#ifdef XIO_ERROR_BY_SETJMP - if (sigsetjmp(SkypopenHandles->ioerror_context, 1) != 0) { - switch_core_session_t *session = NULL; - tech_pvt->interface_state = SKYPOPEN_STATE_DEAD; - ERRORA("Fatal display error for %s - successed to jump\n", SKYPOPEN_P_LOG, tech_pvt->X11_display); - - session = switch_core_session_locate(tech_pvt->session_uuid_str); - if (session) { - switch_channel_t *channel = switch_core_session_get_channel(session); - - if (channel) { - - switch_mutex_lock(tech_pvt->flag_mutex); - switch_clear_flag(tech_pvt, TFLAG_IO); - switch_clear_flag(tech_pvt, TFLAG_VOICE); - if (switch_test_flag(tech_pvt, TFLAG_PROGRESS)) { - switch_clear_flag(tech_pvt, TFLAG_PROGRESS); - } - switch_mutex_unlock(tech_pvt->flag_mutex); - - - switch_core_session_rwunlock(session); - WARNINGA("Closing session for %s\n", SKYPOPEN_P_LOG, interfacename); - switch_channel_hangup(channel, SWITCH_CAUSE_CRASH); - } else { - WARNINGA("NO CHANNEL ?\n", SKYPOPEN_P_LOG); - switch_core_session_rwunlock(session); - } - } - - WARNINGA("Removing skype interface %s\n", SKYPOPEN_P_LOG, interfacename); - remove_interface(interfacename, TRUE); - return NULL; - } -#endif -#ifdef XIO_ERROR_BY_UCONTEXT - getcontext(&SkypopenHandles->ioerror_context); - - if (skypopen_list_find(&global_handles_list, SkypopenHandles) == NULL) { - switch_core_session_t *session = NULL; - tech_pvt->interface_state = SKYPOPEN_STATE_DEAD; - ERRORA("Fatal display error for %s - successed to jump\n", SKYPOPEN_P_LOG, tech_pvt->X11_display); - - session = switch_core_session_locate(tech_pvt->session_uuid_str); - if (session) { - switch_channel_t *channel = switch_core_session_get_channel(session); - - - if (channel) { - switch_mutex_lock(tech_pvt->flag_mutex); - switch_clear_flag(tech_pvt, TFLAG_IO); - switch_clear_flag(tech_pvt, TFLAG_VOICE); - if (switch_test_flag(tech_pvt, TFLAG_PROGRESS)) { - switch_clear_flag(tech_pvt, TFLAG_PROGRESS); - } - switch_mutex_unlock(tech_pvt->flag_mutex); - - - switch_core_session_rwunlock(session); - WARNINGA("Closing session for %s\n", SKYPOPEN_P_LOG, interfacename); - switch_channel_hangup(channel, SWITCH_CAUSE_CRASH); - - } else { - WARNINGA("NO CHANNEL ?\n", SKYPOPEN_P_LOG); - } - //skypopen_sleep(500000); - } - - WARNINGA("Removing skype interface %s\n", SKYPOPEN_P_LOG, interfacename); - //tech_pvt->skypopen_api_thread = NULL; - remove_interface(interfacename, TRUE); - //XCloseDisplay(disp); - return NULL; - } -#endif - } -#endif /* NOT WIN32 */ - - xfd = XConnectionNumber(disp); - fcntl(xfd, F_SETFD, FD_CLOEXEC); - - SkypopenHandles->disp = disp; - - if (skypopen_present(SkypopenHandles)) { - root = DefaultRootWindow(disp); - win = XCreateSimpleWindow(disp, root, 0, 0, 1, 1, 0, BlackPixel(disp, DefaultScreen(disp)), BlackPixel(disp, DefaultScreen(disp))); - - SkypopenHandles->win = win; - - snprintf(buf, 512, "NAME skypopen"); - - if (!skypopen_send_message(tech_pvt, buf)) { - ERRORA("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypopen again\n", SKYPOPEN_P_LOG); - - // CLOUDTREE (Thomas Hazel) -#ifndef WIN32 - skypopen_list_remove_by_reference(&global_handles_list, SkypopenHandles); -#endif - - XCloseDisplay(disp); - running = 0; - return NULL; - } - - snprintf(buf, 512, "PROTOCOL 999"); - if (!skypopen_send_message(tech_pvt, buf)) { - ERRORA("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch Skypopen again\n", SKYPOPEN_P_LOG); - - // CLOUDTREE (Thomas Hazel) -#ifndef WIN32 - skypopen_list_remove_by_reference(&global_handles_list, SkypopenHandles); -#endif - - XCloseDisplay(disp); - running = 0; - return NULL; - } - - { - /* perform an events loop */ - XEvent an_event; - char buf[21]; /* can't be longer */ - char buffer[17000]; - char continuebuffer[17000]; - char *b; - int i; - int continue_is_broken = 0; - int there_were_continues = 0; - struct timeval tv; - Atom atom_begin = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", False); - Atom atom_continue = XInternAtom(disp, "SKYPECONTROLAPI_MESSAGE", False); - - memset(buffer, '\0', 17000); - memset(continuebuffer, '\0', 17000); - b = buffer; - - while (running && tech_pvt->running) { - - - FD_ZERO(&xfds); - FD_SET(xfd, &xfds); - - tv.tv_usec = 100000; - tv.tv_sec = 0; - - - - if (select(xfd + 1, &xfds, 0, 0, &tv)) { - - while (XPending(disp)) { - - - - XNextEvent(disp, &an_event); - if (!(running && tech_pvt->running)) - break; - switch (an_event.type) { - case ClientMessage: - - if (an_event.xclient.format != 8) { - //skypopen_sleep(1000); //0.1 msec - 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'; - - if (an_event.xclient.message_type == atom_begin) { - if (strlen(buffer)) { - unsigned int howmany; - howmany = strlen(b) + 1; - howmany = write(SkypopenHandles->fdesc[1], b, howmany); - WARNINGA - ("A begin atom while the previous message is not closed???? value of previous message (between vertical bars) is=|||%s|||, will be lost\n", - SKYPOPEN_P_LOG, buffer); - memset(buffer, '\0', 17000); - } - if (continue_is_broken) { - continue_is_broken = 0; - there_were_continues = 1; - } - } - if (an_event.xclient.message_type == atom_continue) { - if (!strlen(buffer)) { - WARNINGA - ("Got a 'continue' XAtom without a previous 'begin'. It's value (between vertical bars) is=|||%s|||, let's store it and hope next 'begin' will be the good one\n", - SKYPOPEN_P_LOG, buf); - strcat(continuebuffer, buf); - continue_is_broken = 1; - if (!strncmp(buf, "ognised identity", 15)) { - WARNINGA - ("Got a 'continue' XAtom without a previous 'begin'. It's value (between vertical bars) is=|||%s|||. Let's introduce a 1 second delay.\n", - SKYPOPEN_P_LOG, buf); - skypopen_sleep(1000000); //1 sec - } - skypopen_sleep(20000); //20 msec - break; - } - } - if (continue_is_broken) { - XFlush(disp); - skypopen_sleep(20000); //20 msec - WARNINGA("continue_is_broken\n", SKYPOPEN_P_LOG); - continue; - } - strcat(buffer, buf); - strcat(buffer, continuebuffer); - memset(continuebuffer, '\0', 17000); - - if (i < 20 || there_were_continues) { /* last fragment */ - unsigned int howmany; - - howmany = strlen(b) + 1; - howmany = write(SkypopenHandles->fdesc[1], b, howmany); - memset(buffer, '\0', 17000); - //XFlush(disp); - there_were_continues = 0; - } - //skypopen_sleep(1000); //0.1 msec - break; - default: - //skypopen_sleep(1000); //0.1 msec - break; - } //switch event.type - } //while XPending - XFlush(disp); - - } // if select - } //while running - - - - - - } - } else { - ERRORA("Skype is not running, maybe crashed. Please run/restart Skype and relaunch Skypopen\n", SKYPOPEN_P_LOG); - running = 0; - } - - DEBUGA_SKYPE("EXITING\n", SKYPOPEN_P_LOG); - - // CLOUDTREE (Thomas Hazel) -#ifndef WIN32 - skypopen_list_remove_by_reference(&global_handles_list, SkypopenHandles); -#endif - - tech_pvt->skypopen_api_thread = NULL; - return NULL; - -} -#endif // WIN32 - -int inbound_channel_answered(private_t *tech_pvt) -{ - int res = 0; - switch_core_session_t *session = NULL; - switch_channel_t *channel = NULL; - - session = switch_core_session_locate(tech_pvt->session_uuid_str); - if (session) { - channel = switch_core_session_get_channel(session); - - if (channel) { - switch_mutex_lock(tech_pvt->flag_mutex); - switch_set_flag(tech_pvt, TFLAG_IO); - switch_mutex_unlock(tech_pvt->flag_mutex); - } else { - ERRORA("no channel\n", SKYPOPEN_P_LOG); - } - switch_core_session_rwunlock(session); - } else { - ERRORA("no session\n", SKYPOPEN_P_LOG); - - } - return res; -} - - -int skypopen_answered(private_t *tech_pvt) -{ - - int res = SWITCH_STATUS_SUCCESS; - switch_core_session_t *session = NULL; - switch_channel_t *channel = NULL; - - if (strlen(tech_pvt->session_uuid_str)) { - session = switch_core_session_locate(tech_pvt->session_uuid_str); - if (session) { - channel = switch_core_session_get_channel(session); - - if (channel) { - if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) { - tech_pvt->interface_state = SKYPOPEN_STATE_UP; - DEBUGA_SKYPE("Outbound Channel Answered! session_uuid_str=%s\n", SKYPOPEN_P_LOG, tech_pvt->session_uuid_str); - outbound_channel_answered(tech_pvt); - } else { - DEBUGA_SKYPE("answered Inbound Channel!\n\n\n\n", SKYPOPEN_P_LOG); - inbound_channel_answered(tech_pvt); - } - - } else { - ERRORA("no channel after INPROGRESS?\n", SKYPOPEN_P_LOG); - return SWITCH_STATUS_FALSE; - } - switch_core_session_rwunlock(session); - } else { - WARNINGA("no session after INPROGRESS, let's hangup\n", SKYPOPEN_P_LOG); - return SWITCH_STATUS_FALSE; - } - } else { - WARNINGA("no tech_pvt->session_uuid_str after INPROGRESS, let's hangup\n", SKYPOPEN_P_LOG); - return SWITCH_STATUS_FALSE; - } - return res; -}