skypiax: FARMING modifications
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12831 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
7fd9f69f26
commit
ab565bba44
|
@ -1,5 +1,7 @@
|
||||||
#include "skypiax.h"
|
#include "skypiax.h"
|
||||||
|
|
||||||
|
#define FARMING
|
||||||
|
|
||||||
#ifdef ASTERISK
|
#ifdef ASTERISK
|
||||||
#define skypiax_sleep usleep
|
#define skypiax_sleep usleep
|
||||||
#define skypiax_strncpy strncpy
|
#define skypiax_strncpy strncpy
|
||||||
|
@ -216,6 +218,7 @@ int skypiax_signaling_read(private_t * tech_pvt)
|
||||||
tech_pvt->skype_callflow = CALLFLOW_STATUS_RINGING;
|
tech_pvt->skype_callflow = CALLFLOW_STATUS_RINGING;
|
||||||
tech_pvt->interface_state = SKYPIAX_STATE_RING;
|
tech_pvt->interface_state = SKYPIAX_STATE_RING;
|
||||||
/* no owner, no active call, let's answer */
|
/* no owner, no active call, let's answer */
|
||||||
|
#ifndef FARMING
|
||||||
skypiax_signaling_write(tech_pvt, "SET AGC OFF");
|
skypiax_signaling_write(tech_pvt, "SET AGC OFF");
|
||||||
skypiax_sleep(10000);
|
skypiax_sleep(10000);
|
||||||
skypiax_signaling_write(tech_pvt, "SET AEC OFF");
|
skypiax_signaling_write(tech_pvt, "SET AEC OFF");
|
||||||
|
@ -226,6 +229,7 @@ int skypiax_signaling_read(private_t * tech_pvt)
|
||||||
sprintf(msg_to_skype, "GET CALL %s PARTNER_HANDLE", id);
|
sprintf(msg_to_skype, "GET CALL %s PARTNER_HANDLE", id);
|
||||||
skypiax_signaling_write(tech_pvt, msg_to_skype);
|
skypiax_signaling_write(tech_pvt, msg_to_skype);
|
||||||
skypiax_sleep(10000);
|
skypiax_sleep(10000);
|
||||||
|
#endif //FARMING
|
||||||
sprintf(msg_to_skype, "ALTER CALL %s ANSWER", id);
|
sprintf(msg_to_skype, "ALTER CALL %s ANSWER", id);
|
||||||
skypiax_signaling_write(tech_pvt, msg_to_skype);
|
skypiax_signaling_write(tech_pvt, msg_to_skype);
|
||||||
DEBUGA_SKYPE("We answered a Skype RING on skype_call %s\n", SKYPIAX_P_LOG,
|
DEBUGA_SKYPE("We answered a Skype RING on skype_call %s\n", SKYPIAX_P_LOG,
|
||||||
|
@ -278,11 +282,12 @@ int skypiax_signaling_read(private_t * tech_pvt)
|
||||||
tech_pvt->interface_state = SKYPIAX_STATE_DIALING;
|
tech_pvt->interface_state = SKYPIAX_STATE_DIALING;
|
||||||
NOTICA("Our remote party in skype_call %s is EARLYMEDIA\n", SKYPIAX_P_LOG,
|
NOTICA("Our remote party in skype_call %s is EARLYMEDIA\n", SKYPIAX_P_LOG,
|
||||||
id);
|
id);
|
||||||
|
start_audio_threads(tech_pvt);
|
||||||
|
skypiax_sleep(1000);
|
||||||
sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id,
|
sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id,
|
||||||
tech_pvt->tcp_cli_port);
|
tech_pvt->tcp_cli_port);
|
||||||
skypiax_signaling_write(tech_pvt, msg_to_skype);
|
skypiax_signaling_write(tech_pvt, msg_to_skype);
|
||||||
start_audio_threads(tech_pvt);
|
sprintf(msg_to_skype, "#output ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id,
|
||||||
sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id,
|
|
||||||
tech_pvt->tcp_srv_port);
|
tech_pvt->tcp_srv_port);
|
||||||
skypiax_signaling_write(tech_pvt, msg_to_skype);
|
skypiax_signaling_write(tech_pvt, msg_to_skype);
|
||||||
|
|
||||||
|
@ -365,11 +370,12 @@ int skypiax_signaling_read(private_t * tech_pvt)
|
||||||
if (tech_pvt->skype_callflow != CALLFLOW_STATUS_EARLYMEDIA) {
|
if (tech_pvt->skype_callflow != CALLFLOW_STATUS_EARLYMEDIA) {
|
||||||
tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS;
|
tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS;
|
||||||
tech_pvt->interface_state = SKYPIAX_STATE_UP;
|
tech_pvt->interface_state = SKYPIAX_STATE_UP;
|
||||||
|
start_audio_threads(tech_pvt);
|
||||||
|
skypiax_sleep(1000);
|
||||||
sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id,
|
sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id,
|
||||||
tech_pvt->tcp_cli_port);
|
tech_pvt->tcp_cli_port);
|
||||||
skypiax_signaling_write(tech_pvt, msg_to_skype);
|
skypiax_signaling_write(tech_pvt, msg_to_skype);
|
||||||
start_audio_threads(tech_pvt);
|
sprintf(msg_to_skype, "#output ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id,
|
||||||
sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id,
|
|
||||||
tech_pvt->tcp_srv_port);
|
tech_pvt->tcp_srv_port);
|
||||||
skypiax_signaling_write(tech_pvt, msg_to_skype);
|
skypiax_signaling_write(tech_pvt, msg_to_skype);
|
||||||
}
|
}
|
||||||
|
@ -440,7 +446,11 @@ void *skypiax_do_tcp_srv_thread_func(void *obj)
|
||||||
|
|
||||||
memset(&my_addr, 0, sizeof(my_addr));
|
memset(&my_addr, 0, sizeof(my_addr));
|
||||||
my_addr.sin_family = AF_INET;
|
my_addr.sin_family = AF_INET;
|
||||||
|
#ifdef FARMING
|
||||||
|
//my_addr.sin_addr.s_addr = htonl(0x7f000001); /* default on all addresses */
|
||||||
|
#else // FARMING
|
||||||
my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */
|
my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */
|
||||||
|
#endif // FARMING
|
||||||
my_addr.sin_port = htons(tech_pvt->tcp_srv_port);
|
my_addr.sin_port = htons(tech_pvt->tcp_srv_port);
|
||||||
|
|
||||||
if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
|
if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
|
||||||
|
@ -458,7 +468,7 @@ void *skypiax_do_tcp_srv_thread_func(void *obj)
|
||||||
|
|
||||||
sin_size = sizeof(remote_addr);
|
sin_size = sizeof(remote_addr);
|
||||||
while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) {
|
while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) {
|
||||||
DEBUGA_SKYPE("ACCEPTED\n", SKYPIAX_P_LOG);
|
DEBUGA_SKYPE("ACCEPTED here I send you %d\n", SKYPIAX_P_LOG, tech_pvt->tcp_srv_port);
|
||||||
if (!running)
|
if (!running)
|
||||||
break;
|
break;
|
||||||
while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN
|
while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN
|
||||||
|
@ -484,6 +494,9 @@ void *skypiax_do_tcp_srv_thread_func(void *obj)
|
||||||
rt = select(fdselect + 1, &fs, NULL, NULL, &to);
|
rt = select(fdselect + 1, &fs, NULL, NULL, &to);
|
||||||
if (rt > 0) {
|
if (rt > 0) {
|
||||||
|
|
||||||
|
#ifdef FARMING
|
||||||
|
switch_sleep(500); //seems that reconnecting through a proxy leads to half the packet size, bizarrely, 158-162, never 160 :-)
|
||||||
|
#endif // FARMING
|
||||||
len = recv(fd, (char *) srv_in, 320, 0); //seems that Skype only sends 320 bytes at time
|
len = recv(fd, (char *) srv_in, 320, 0); //seems that Skype only sends 320 bytes at time
|
||||||
|
|
||||||
if (len == 320) {
|
if (len == 320) {
|
||||||
|
@ -535,9 +548,7 @@ void *skypiax_do_tcp_srv_thread_func(void *obj)
|
||||||
} else if (len == 0) {
|
} else if (len == 0) {
|
||||||
skypiax_sleep(1000);
|
skypiax_sleep(1000);
|
||||||
} else {
|
} else {
|
||||||
ERRORA("len=%d\n", SKYPIAX_P_LOG, len);
|
ERRORA("len=%d, expected 320\n", SKYPIAX_P_LOG, len);
|
||||||
exit = 1;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -591,7 +602,11 @@ void *skypiax_do_tcp_cli_thread_func(void *obj)
|
||||||
|
|
||||||
memset(&my_addr, 0, sizeof(my_addr));
|
memset(&my_addr, 0, sizeof(my_addr));
|
||||||
my_addr.sin_family = AF_INET;
|
my_addr.sin_family = AF_INET;
|
||||||
|
#ifdef FARMING
|
||||||
|
//my_addr.sin_addr.s_addr = htonl(0x7f000001); /* default on all addresses */
|
||||||
|
#else // FARMING
|
||||||
my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */
|
my_addr.sin_addr.s_addr = htonl(0x7f000001); /* use the localhost */
|
||||||
|
#endif // FARMING
|
||||||
my_addr.sin_port = htons(tech_pvt->tcp_cli_port);
|
my_addr.sin_port = htons(tech_pvt->tcp_cli_port);
|
||||||
|
|
||||||
if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
|
if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
|
||||||
|
@ -610,7 +625,7 @@ void *skypiax_do_tcp_cli_thread_func(void *obj)
|
||||||
|
|
||||||
sin_size = sizeof(remote_addr);
|
sin_size = sizeof(remote_addr);
|
||||||
while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) {
|
while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) {
|
||||||
DEBUGA_SKYPE("ACCEPTED\n", SKYPIAX_P_LOG);
|
DEBUGA_SKYPE("ACCEPTED here you send me %d\n", SKYPIAX_P_LOG, tech_pvt->tcp_cli_port);
|
||||||
if (!running)
|
if (!running)
|
||||||
break;
|
break;
|
||||||
while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN
|
while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN
|
||||||
|
@ -1165,6 +1180,14 @@ static int X11_errors_untrap(void)
|
||||||
return (xerror != BadValue) && (xerror != BadWindow);
|
return (xerror != BadValue) && (xerror != BadWindow);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef FARMING
|
||||||
|
int skypiax_send_message(struct SkypiaxHandles *SkypiaxHandles, const char *message_P)
|
||||||
|
{
|
||||||
|
printf("%s\n", message_P);
|
||||||
|
fflush(stdout);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#else// FARMING
|
||||||
int skypiax_send_message(struct SkypiaxHandles *SkypiaxHandles, const char *message_P)
|
int skypiax_send_message(struct SkypiaxHandles *SkypiaxHandles, const char *message_P)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -1212,6 +1235,8 @@ int skypiax_send_message(struct SkypiaxHandles *SkypiaxHandles, const char *mess
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif// FARMING
|
||||||
int skypiax_signaling_write(private_t * tech_pvt, char *msg_to_skype)
|
int skypiax_signaling_write(private_t * tech_pvt, char *msg_to_skype)
|
||||||
{
|
{
|
||||||
struct SkypiaxHandles *SkypiaxHandles;
|
struct SkypiaxHandles *SkypiaxHandles;
|
||||||
|
@ -1289,6 +1314,48 @@ void skypiax_clean_disp(void *data)
|
||||||
skypiax_sleep(1000);
|
skypiax_sleep(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef FARMING
|
||||||
|
void *skypiax_do_skypeapi_thread_func(void *obj)
|
||||||
|
{
|
||||||
|
|
||||||
|
private_t *tech_pvt = obj;
|
||||||
|
struct SkypiaxHandles *SkypiaxHandles;
|
||||||
|
|
||||||
|
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->SkypiaxHandles.fdesc)) {
|
||||||
|
fcntl(tech_pvt->SkypiaxHandles.fdesc[0], F_SETFL, O_NONBLOCK);
|
||||||
|
fcntl(tech_pvt->SkypiaxHandles.fdesc[1], F_SETFL, O_NONBLOCK);
|
||||||
|
}
|
||||||
|
SkypiaxHandles = &tech_pvt->SkypiaxHandles;
|
||||||
|
|
||||||
|
|
||||||
|
SkypiaxHandles->api_connected = 1;
|
||||||
|
|
||||||
|
char *b;
|
||||||
|
unsigned int howmany;
|
||||||
|
|
||||||
|
while (1) {
|
||||||
|
char s[17000];
|
||||||
|
|
||||||
|
memset(s, '\0', 17000);
|
||||||
|
b=fgets(s, sizeof(s) - 1, stdin);
|
||||||
|
s[strlen(s) - 1] = '\0';
|
||||||
|
howmany = strlen(s) + 1;
|
||||||
|
|
||||||
|
howmany = write(SkypiaxHandles->fdesc[1], &s, howmany);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#else //FARMING
|
||||||
void *skypiax_do_skypeapi_thread_func(void *obj)
|
void *skypiax_do_skypeapi_thread_func(void *obj)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -1409,4 +1476,5 @@ void *skypiax_do_skypeapi_thread_func(void *obj)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#endif //FARMING
|
||||||
#endif // WIN32
|
#endif // WIN32
|
||||||
|
|
Loading…
Reference in New Issue