提交 8c697d4c authored 作者: Brian West's avatar Brian West

Move Skypiax into svn Trunk



git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12167 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 f0e6d610
MODNAME=mod_skypiax
SVNDEF := -D'SKYPIAX_SVN_VERSION="$(shell svnversion -n .)"'
LOCAL_CFLAGS += $(SVNDEF)
LOCAL_LDFLAGS=-lX11
LOCAL_OBJS=skypiax_protocol.o
include ../../../../build/modmake.rules
差异被折叠。
#
# Asterisk -- A telephony toolkit for Linux.
#
# Makefile for channel drivers
#
# Copyright (C) 1999-2005, Mark Spencer
#
# Mark Spencer <markster@digium.com>
#
# 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
#include <stdio.h>
#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;
}
;;;;;;;;
;;;;;;;;
;;;;;;; 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
;;;
;;;
;;;
../skypiax_protocol.c
\ No newline at end of file
#######################################
HOW TO USE SKYPIAX_AUTH
#######################################
You will use skypiax_auth only at the setup moment, to force the Skype client to ask you to authorize "skypiax" 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 skypiax_auth:
$ gcc -Wall -ggdb skypiax_auth.c -o skypiax_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 skypiax_auth (that simulates FS-skypiax connecting to the Skype client). The Skype client will ask you to be authorized to let "skypiax" 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 skypiax_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 skypiax_auth
############################
$ ./skypiax_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 skypiax_auth
############################
Close (Quit) the Skype client from the tray icon, so it saves its config.
Then, relaunch the Skype client
############################
you use skypiax_auth again
############################
$ ./skypiax_auth
Skype instance found with id #27263062
RECEIVED==> OK
RECEIVED==> PROTOCOL 6
RECEIVED==> CONNSTATUS ONLINE
RECEIVED==> CURRENTUSERHANDLE gmaruzz3
RECEIVED==> USERSTATUS INVISIBLE
<configuration name="skypiax.conf" description="Skypiax Configuration">
<global_settings>
<param name="debug" value="8"/>
<param name="codec-master" value="us"/>
<param name="dialplan" value="XML"/>
<param name="context" value="default"/>
<param name="codec-prefs" value="gsm,ulaw"/>
<param name="codec-rates" value="8000,16000"/>
<param name="hold-music" value="$${moh_uri}"/>
<param name="destination" value="5000"/>
</global_settings>
<!-- one entry here per skypiax interface -->
<per_interface_settings>
<interface id="1" name="skypiax1">
<param name="hold-music" value="$${moh_uri}"/>
<param name="dialplan" value="XML"/>
<param name="context" value="default"/>
<param name="X11-display" value=":101"/>
<param name="tcp_cli_port" value="15556"/>
<param name="tcp_srv_port" value="15557"/>
<param name="skype_user" value="skypiax1"/>
<param name="destination" value="3101"/>
</interface>
<interface id="2" name="skypiax2">
<param name="hold-music" value="$${moh_uri}"/>
<param name="dialplan" value="XML"/>
<param name="context" value="default"/>
<param name="X11-display" value=":102"/>
<param name="tcp_cli_port" value="15558"/>
<param name="tcp_srv_port" value="15559"/>
<param name="skype_user" value="skypiax2"/>
<param name="destination" value="5000"/>
</interface>
<!-- following interfaces are commented out!
<interface id="3" name="skypiax3">
<param name="hold-music" value="$${moh_uri}"/>
<param name="dialplan" value="XML"/>
<param name="context" value="default"/>
<param name="X11-display" value=":103"/>
<param name="tcp_cli_port" value="15560"/>
<param name="tcp_srv_port" value="15561"/>
<param name="skype_user" value="skypiax3"/>
</interface>
<interface id="4" name="skypiax4">
<param name="hold-music" value="$${moh_uri}"/>
<param name="dialplan" value="XML"/>
<param name="context" value="default"/>
<param name="X11-display" value=":104"/>
<param name="tcp_cli_port" value="15562"/>
<param name="tcp_srv_port" value="15563"/>
<param name="skype_user" value="skypiax4"/>
</interface>
<interface id="5" name="skypiax5">
<param name="hold-music" value="$${moh_uri}"/>
<param name="dialplan" value="XML"/>
<param name="context" value="default"/>
<param name="X11-display" value=":105"/>
<param name="tcp_cli_port" value="15564"/>
<param name="tcp_srv_port" value="15565"/>
<param name="skype_user" value="skypiax5"/>
</interface>
<interface id="6" name="skypiax6">
<param name="hold-music" value="$${moh_uri}"/>
<param name="dialplan" value="XML"/>
<param name="context" value="default"/>
<param name="X11-display" value=":106"/>
<param name="tcp_cli_port" value="15566"/>
<param name="tcp_srv_port" value="15567"/>
<param name="skype_user" value="skypiax6"/>
</interface>
<interface id="7" name="skypiax7">
<param name="hold-music" value="$${moh_uri}"/>
<param name="dialplan" value="XML"/>
<param name="context" value="default"/>
<param name="X11-display" value=":107"/>
<param name="tcp_cli_port" value="15568"/>
<param name="tcp_srv_port" value="15569"/>
<param name="skype_user" value="skypiax7"/>
</interface>
<interface id="8" name="skypiax8">
<param name="hold-music" value="$${moh_uri}"/>
<param name="dialplan" value="XML"/>
<param name="context" value="default"/>
<param name="X11-display" value=":108"/>
<param name="tcp_cli_port" value="15570"/>
<param name="tcp_srv_port" value="15571"/>
<param name="skype_user" value="skypiax8"/>
</interface>
<interface id="9" name="skypiax9">
<param name="hold-music" value="$${moh_uri}"/>
<param name="dialplan" value="XML"/>
<param name="context" value="default"/>
<param name="X11-display" value=":109"/>
<param name="tcp_cli_port" value="15572"/>
<param name="tcp_srv_port" value="15573"/>
<param name="skype_user" value="skypiax9"/>
</interface>
<interface id="10" name="skypiax10">
<param name="hold-music" value="$${moh_uri}"/>
<param name="dialplan" value="XML"/>
<param name="context" value="default"/>
<param name="X11-display" value=":110"/>
<param name="tcp_cli_port" value="15574"/>
<param name="tcp_srv_port" value="15575"/>
<param name="skype_user" value="skypiax10"/>
</interface>
<interface id="11" name="skypiax11">
<param name="hold-music" value="$${moh_uri}"/>
<param name="dialplan" value="XML"/>
<param name="context" value="default"/>
<param name="X11-display" value=":111"/>
<param name="tcp_cli_port" value="15576"/>
<param name="tcp_srv_port" value="15577"/>
<param name="skype_user" value="skypiax11"/>
</interface>
<interface id="12" name="skypiax12">
<param name="hold-music" value="$${moh_uri}"/>
<param name="dialplan" value="XML"/>
<param name="context" value="default"/>
<param name="X11-display" value=":112"/>
<param name="tcp_cli_port" value="15578"/>
<param name="tcp_srv_port" value="15579"/>
<param name="skype_user" value="skypiax12"/>
</interface>
<interface id="13" name="skypiax13">
<param name="hold-music" value="$${moh_uri}"/>
<param name="dialplan" value="XML"/>
<param name="context" value="default"/>
<param name="X11-display" value=":113"/>
<param name="tcp_cli_port" value="15580"/>
<param name="tcp_srv_port" value="15581"/>
<param name="skype_user" value="skypiax13"/>
</interface>
<interface id="14" name="skypiax14">
<param name="hold-music" value="$${moh_uri}"/>
<param name="dialplan" value="XML"/>
<param name="context" value="default"/>
<param name="X11-display" value=":114"/>
<param name="tcp_cli_port" value="15582"/>
<param name="tcp_srv_port" value="15583"/>
<param name="skype_user" value="skypiax14"/>
</interface>
<interface id="15" name="skypiax15">
<param name="hold-music" value="$${moh_uri}"/>
<param name="dialplan" value="XML"/>
<param name="context" value="default"/>
<param name="X11-display" value=":115"/>
<param name="tcp_cli_port" value="15584"/>
<param name="tcp_srv_port" value="15585"/>
<param name="skype_user" value="skypiax15"/>
</interface>
<interface id="16" name="skypiax16">
<param name="hold-music" value="$${moh_uri}"/>
<param name="dialplan" value="XML"/>
<param name="context" value="default"/>
<param name="X11-display" value=":116"/>
<param name="tcp_cli_port" value="15586"/>
<param name="tcp_srv_port" value="15587"/>
<param name="skype_user" value="skypiax16"/>
</interface>
<interface id="17" name="skypiax17">
<param name="hold-music" value="$${moh_uri}"/>
<param name="dialplan" value="XML"/>
<param name="context" value="default"/>
<param name="X11-display" value=":117"/>
<param name="tcp_cli_port" value="15588"/>
<param name="tcp_srv_port" value="15589"/>
<param name="skype_user" value="skypiax17"/>
</interface>
<interface id="18" name="skypiax18">
<param name="hold-music" value="$${moh_uri}"/>
<param name="dialplan" value="XML"/>
<param name="context" value="default"/>
<param name="X11-display" value=":118"/>
<param name="tcp_cli_port" value="15590"/>
<param name="tcp_srv_port" value="15591"/>
<param name="skype_user" value="skypiax18"/>
</interface>
<interface id="19" name="skypiax19">
<param name="hold-music" value="$${moh_uri}"/>
<param name="dialplan" value="XML"/>
<param name="context" value="default"/>
<param name="X11-display" value=":119"/>
<param name="tcp_cli_port" value="15592"/>
<param name="tcp_srv_port" value="15593"/>
<param name="skype_user" value="skypiax19"/>
</interface>
<interface id="20" name="skypiax20">
<param name="hold-music" value="$${moh_uri}"/>
<param name="dialplan" value="XML"/>
<param name="context" value="default"/>
<param name="X11-display" value=":120"/>
<param name="tcp_cli_port" value="15594"/>
<param name="tcp_srv_port" value="15595"/>
<param name="skype_user" value="skypiax20"/>
</interface>
-->
</per_interface_settings>
</configuration>
//gcc -Wall -ggdb skypiax_auth.c -o skypiax_auth -lX11
#include <stdio.h>
#include <unistd.h>
#include <X11/Xlib.h>
#include <X11/Xlibint.h>
#include <X11/Xatom.h>
struct SkypiaxHandles {
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 skypiax_send_message(struct SkypiaxHandles *SkypiaxHandles, const char *message_P)
{
Window w_P;
Display *disp;
Window handle_P;
int ok;
w_P = SkypiaxHandles->skype_win;
disp = SkypiaxHandles->disp;
handle_P = SkypiaxHandles->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 skypiax_present(struct SkypiaxHandles *SkypiaxHandles)
{
Atom skype_inst = XInternAtom(SkypiaxHandles->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(SkypiaxHandles->disp, DefaultRootWindow(SkypiaxHandles->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) {
SkypiaxHandles->skype_win = (Window) - 1;
printf("Skype instance not found on display '%s'\n", dispname);
return 0;
}
SkypiaxHandles->skype_win = *(const unsigned long *) prop & 0xffffffff;
printf("Skype instance found on display '%s', with id #%d\n", dispname,
(unsigned int) SkypiaxHandles->skype_win);
return 1;
}
void skypiax_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 SkypiaxHandles SkypiaxHandles;
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);
SkypiaxHandles.disp = disp;
if (skypiax_present(&SkypiaxHandles)) {
root = DefaultRootWindow(disp);
win =
XCreateSimpleWindow(disp, root, 0, 0, 1, 1, 0,
BlackPixel(disp, DefaultScreen(disp)), BlackPixel(disp,
DefaultScreen
(disp)));
SkypiaxHandles.win = win;
snprintf(buf, 512, "NAME skypiax");
if (!skypiax_send_message(&SkypiaxHandles, buf)) {
printf
("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch skypiax_auth again\n");
return -1;
}
snprintf(buf, 512, "PROTOCOL 6");
if (!skypiax_send_message(&SkypiaxHandles, buf)) {
printf
("Sending message failed - probably Skype crashed. Please run/restart Skype manually and launch skypiax_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 skypiax_auth again\n\n\n",
dispname);
return -1;
}
return 0;
}
echo off
REM
REM you MUST use the new Skype BETA (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 skypiax1 the username
start Skype.exe /secondary /username:skypiax1 /password:xxx
call wait 7
start Skype.exe /secondary /username:skypiax2 /password:xxx
call wait 7
REM
REM Following Skype client instances are commented out
REM
REM start Skype.exe /secondary /username:skypiax3 /password:xxx
REM call wait 7
REM start Skype.exe /secondary /username:skypiax4 /password:xxx
REM call wait 7
REM start Skype.exe /secondary /username:skypiax5 /password:xxx
REM call wait 7
REM start Skype.exe /secondary /username:skypiax6 /password:xxx
REM call wait 7
REM start Skype.exe /secondary /username:skypiax7 /password:xxx
REM call wait 7
REM start Skype.exe /secondary /username:skypiax8 /password:xxx
REM call wait 7
REM start Skype.exe /secondary /username:skypiax9 /password:xxx
REM call wait 7
REM start Skype.exe /secondary /username:skypiax10 /password:xxx
REM call wait 7
REM start Skype.exe /secondary /username:skypiax11 /password:xxx
REM call wait 7
REM start Skype.exe /secondary /username:skypiax12 /password:xxx
REM call wait 7
REM start Skype.exe /secondary /username:skypiax13 /password:xxx
REM call wait 7
REM start Skype.exe /secondary /username:skypiax14 /password:xxx
REM call wait 7
REM start Skype.exe /secondary /username:skypiax15 /password:xxx
REM call wait 7
REM start Skype.exe /secondary /username:skypiax16 /password:xxx
REM call wait 7
REM start Skype.exe /secondary /username:skypiax17 /password:xxx
REM call wait 7
REM start Skype.exe /secondary /username:skypiax18 /password:xxx
REM call wait 7
REM start Skype.exe /secondary /username:skypiax19 /password:xxx
REM call wait 7
REM start Skype.exe /secondary /username:skypiax20 /password:xxx
# 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
# 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 enable=1,1,1
sleep 3
#start the fake X server on a given port
/usr/bin/Xvfb :101 -auth /usr/local/freeswitch/conf/autoload_configs/skypiax.X.conf &
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 xxx would be the password and skypiax1 the username
echo "skypiax1 xxx"| DISPLAY=:101 /usr/bin/skype --pipelogin &
sleep 7
/usr/bin/Xvfb :102 -auth /usr/local/freeswitch/conf/autoload_configs/skypiax.X.conf &
sleep 3
echo "skypiax2 xxx"| DISPLAY=:102 /usr/bin/skype --pipelogin &
sleep 7
#################################################################
# Following X server Skype client instances are commented out
#################################################################
###/usr/bin/Xvfb :103 -auth /usr/local/freeswitch/conf/autoload_configs/skypiax.X.conf &
###sleep 3
###
###echo "skypiax3 xxx"| DISPLAY=:103 /usr/bin/skype --pipelogin &
###
###sleep 7
###/usr/bin/Xvfb :104 -auth /usr/local/freeswitch/conf/autoload_configs/skypiax.X.conf &
###sleep 3
###
###echo "skypiax4 xxx"| DISPLAY=:104 /usr/bin/skype --pipelogin &
###
###sleep 7
###/usr/bin/Xvfb :105 -auth /usr/local/freeswitch/conf/autoload_configs/skypiax.X.conf &
###sleep 3
###
###echo "skypiax5 xxx"| DISPLAY=:105 /usr/bin/skype --pipelogin &
###
###sleep 7
###/usr/bin/Xvfb :106 -auth /usr/local/freeswitch/conf/autoload_configs/skypiax.X.conf &
###sleep 3
###
###echo "skypiax6 xxx"| DISPLAY=:106 /usr/bin/skype --pipelogin &
###
###sleep 7
###/usr/bin/Xvfb :107 -auth /usr/local/freeswitch/conf/autoload_configs/skypiax.X.conf &
###sleep 3
###
###echo "skypiax7 xxx"| DISPLAY=:107 /usr/bin/skype --pipelogin &
###
###sleep 7
###/usr/bin/Xvfb :108 -auth /usr/local/freeswitch/conf/autoload_configs/skypiax.X.conf &
###sleep 3
###
###echo "skypiax8 xxx"| DISPLAY=:108 /usr/bin/skype --pipelogin &
###
###sleep 7
###/usr/bin/Xvfb :109 -auth /usr/local/freeswitch/conf/autoload_configs/skypiax.X.conf &
###sleep 3
###
###echo "skypiax9 xxx"| DISPLAY=:109 /usr/bin/skype --pipelogin &
###
###sleep 7
###/usr/bin/Xvfb :110 -auth /usr/local/freeswitch/conf/autoload_configs/skypiax.X.conf &
###sleep 3
###
###echo "skypiax10 xxx"| DISPLAY=:110 /usr/bin/skype --pipelogin &
###
###sleep 7
###/usr/bin/Xvfb :111 -auth /usr/local/freeswitch/conf/autoload_configs/skypiax.X.conf &
###sleep 3
###
###echo "skypiax11 xxx"| DISPLAY=:111 /usr/bin/skype --pipelogin &
###
###sleep 7
###/usr/bin/Xvfb :112 -auth /usr/local/freeswitch/conf/autoload_configs/skypiax.X.conf &
###sleep 3
###
###echo "skypiax12 xxx"| DISPLAY=:112 /usr/bin/skype --pipelogin &
###
###sleep 7
###/usr/bin/Xvfb :113 -auth /usr/local/freeswitch/conf/autoload_configs/skypiax.X.conf &
###sleep 3
###
###echo "skypiax13 xxx"| DISPLAY=:113 /usr/bin/skype --pipelogin &
###
###sleep 7
###/usr/bin/Xvfb :114 -auth /usr/local/freeswitch/conf/autoload_configs/skypiax.X.conf &
###sleep 3
###
###echo "skypiax14 xxx"| DISPLAY=:114 /usr/bin/skype --pipelogin &
###
###sleep 7
###/usr/bin/Xvfb :115 -auth /usr/local/freeswitch/conf/autoload_configs/skypiax.X.conf &
###sleep 3
###
###echo "skypiax15 xxx"| DISPLAY=:115 /usr/bin/skype --pipelogin &
###
###sleep 7
###/usr/bin/Xvfb :116 -auth /usr/local/freeswitch/conf/autoload_configs/skypiax.X.conf &
###sleep 3
###
###echo "skypiax16 xxx"| DISPLAY=:116 /usr/bin/skype --pipelogin &
###
###sleep 7
###/usr/bin/Xvfb :117 -auth /usr/local/freeswitch/conf/autoload_configs/skypiax.X.conf &
###sleep 3
###
###echo "skypiax17 xxx"| DISPLAY=:117 /usr/bin/skype --pipelogin &
###
###sleep 7
###/usr/bin/Xvfb :118 -auth /usr/local/freeswitch/conf/autoload_configs/skypiax.X.conf &
###sleep 3
###
###echo "skypiax18 xxx"| DISPLAY=:118 /usr/bin/skype --pipelogin &
###
###sleep 7
###/usr/bin/Xvfb :119 -auth /usr/local/freeswitch/conf/autoload_configs/skypiax.X.conf &
###sleep 3
###
###echo "skypiax19 xxx"| DISPLAY=:119 /usr/bin/skype --pipelogin &
###
###sleep 7
###/usr/bin/Xvfb :120 -auth /usr/local/freeswitch/conf/autoload_configs/skypiax.X.conf &
###sleep 3
###
###echo "skypiax20 xxx"| DISPLAY=:120 /usr/bin/skype --pipelogin &
###
###sleep 7
###
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
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Name="mod_skypiax"
ProjectGUID="{C6E78A4C-DB1E-47F4-9B63-4DC27D86343F}"
RootNamespace="mod_skypiax"
Keyword="Win32Proj"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
ConfigurationType="2"
InheritedPropertySheets="..\..\..\..\w32\module_debug.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
WarningLevel="4"
WarnAsError="false"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalOptions="rpcrt4.lib &quot;..\..\..\..\libs\win32\pthread\pthreadvc2.lib&quot; &quot;..\..\..\..\libs\win32\apr\debug\libapr-1.lib&quot; &quot;..\..\..\..\w32\library\debug\freeswitchcore.lib&quot;"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
ConfigurationType="2"
InheritedPropertySheets="..\..\..\..\w32\module_release.vsprops"
CharacterSet="2"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
UsePrecompiledHeader="0"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<File
RelativePath="..\mod_skypiax\mod_skypiax.c"
>
</File>
<File
RelativePath=".\skypiax.h"
>
</File>
<File
RelativePath=".\skypiax_protocol.c"
>
</File>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
差异被折叠。
差异被折叠。
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论