skypiax: restored a previous wrong commit
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@16633 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
f4a09d2c4e
commit
08c331ee72
|
@ -36,12 +36,7 @@
|
||||||
|
|
||||||
#include "skypiax.h"
|
#include "skypiax.h"
|
||||||
#define MDL_CHAT_PROTO "skype"
|
#define MDL_CHAT_PROTO "skype"
|
||||||
#define TIMERS_ON
|
|
||||||
#ifdef TIMERS_ON
|
|
||||||
#define TIMER_WRITE
|
#define TIMER_WRITE
|
||||||
#else
|
|
||||||
#undef TIMER_WRITE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
/***************/
|
/***************/
|
||||||
|
@ -263,7 +258,6 @@ switch_status_t skypiax_tech_init(private_t * tech_pvt, switch_core_session_t *s
|
||||||
return SWITCH_STATUS_FALSE;
|
return SWITCH_STATUS_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TIMERS_ON
|
|
||||||
if (switch_core_timer_init(&tech_pvt->timer_read, "soft", 20, tech_pvt->read_codec.implementation->samples_per_packet, skypiax_module_pool) !=
|
if (switch_core_timer_init(&tech_pvt->timer_read, "soft", 20, tech_pvt->read_codec.implementation->samples_per_packet, skypiax_module_pool) !=
|
||||||
SWITCH_STATUS_SUCCESS) {
|
SWITCH_STATUS_SUCCESS) {
|
||||||
ERRORA("setup timer failed\n", SKYPIAX_P_LOG);
|
ERRORA("setup timer failed\n", SKYPIAX_P_LOG);
|
||||||
|
@ -271,7 +265,6 @@ switch_status_t skypiax_tech_init(private_t * tech_pvt, switch_core_session_t *s
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_core_timer_sync(&tech_pvt->timer_read);
|
switch_core_timer_sync(&tech_pvt->timer_read);
|
||||||
#endif// TIMERS_ON
|
|
||||||
|
|
||||||
#ifdef TIMER_WRITE
|
#ifdef TIMER_WRITE
|
||||||
if (switch_core_timer_init(&tech_pvt->timer_write, "soft", 20, tech_pvt->write_codec.implementation->samples_per_packet, skypiax_module_pool) !=
|
if (switch_core_timer_init(&tech_pvt->timer_write, "soft", 20, tech_pvt->write_codec.implementation->samples_per_packet, skypiax_module_pool) !=
|
||||||
|
@ -489,9 +482,7 @@ static switch_status_t channel_on_destroy(switch_core_session_t *session)
|
||||||
switch_core_codec_destroy(&tech_pvt->write_codec);
|
switch_core_codec_destroy(&tech_pvt->write_codec);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TIMERS_ON
|
|
||||||
switch_core_timer_destroy(&tech_pvt->timer_read);
|
switch_core_timer_destroy(&tech_pvt->timer_read);
|
||||||
#endif// TIMERS_ON
|
|
||||||
#ifdef TIMER_WRITE
|
#ifdef TIMER_WRITE
|
||||||
|
|
||||||
switch_core_timer_destroy(&tech_pvt->timer_write);
|
switch_core_timer_destroy(&tech_pvt->timer_write);
|
||||||
|
@ -684,7 +675,6 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
||||||
switch_channel_t *channel = NULL;
|
switch_channel_t *channel = NULL;
|
||||||
private_t *tech_pvt = NULL;
|
private_t *tech_pvt = NULL;
|
||||||
switch_byte_t *data;
|
switch_byte_t *data;
|
||||||
//unsigned int len;
|
|
||||||
|
|
||||||
channel = switch_core_session_get_channel(session);
|
channel = switch_core_session_get_channel(session);
|
||||||
switch_assert(channel != NULL);
|
switch_assert(channel != NULL);
|
||||||
|
@ -703,14 +693,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
||||||
|
|
||||||
//switch_core_timer_next(&tech_pvt->timer_read);
|
//switch_core_timer_next(&tech_pvt->timer_read);
|
||||||
|
|
||||||
if (tech_pvt->skype_callflow != CALLFLOW_STATUS_REMOTEHOLD) {
|
if (!skypiax_audio_read(tech_pvt)) {
|
||||||
tech_pvt->read_frame.datalen = recv(tech_pvt->readfd, (char *) tech_pvt->read_frame.data, 320, 0); //seems that Skype only sends 320 bytes at time
|
|
||||||
} else {
|
|
||||||
tech_pvt->read_frame.datalen = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
//if (!skypiax_audio_read(tech_pvt)) {
|
|
||||||
if (!tech_pvt->read_frame.datalen) {
|
|
||||||
|
|
||||||
ERRORA("skypiax_audio_read ERROR\n", SKYPIAX_P_LOG);
|
ERRORA("skypiax_audio_read ERROR\n", SKYPIAX_P_LOG);
|
||||||
|
|
||||||
|
@ -736,9 +719,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
|
||||||
DEBUGA_SKYPE("CHANNEL READ CONTINUE\n", SKYPIAX_P_LOG);
|
DEBUGA_SKYPE("CHANNEL READ CONTINUE\n", SKYPIAX_P_LOG);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
#ifdef TIMERS_ON
|
|
||||||
switch_core_timer_check(&tech_pvt->timer_read, SWITCH_TRUE);
|
switch_core_timer_check(&tech_pvt->timer_read, SWITCH_TRUE);
|
||||||
#endif// TIMERS_ON
|
|
||||||
*frame = &tech_pvt->read_frame;
|
*frame = &tech_pvt->read_frame;
|
||||||
#if SWITCH_BYTE_ORDER == __BIG_ENDIAN
|
#if SWITCH_BYTE_ORDER == __BIG_ENDIAN
|
||||||
if (switch_test_flag(tech_pvt, TFLAG_LINEAR)) {
|
if (switch_test_flag(tech_pvt, TFLAG_LINEAR)) {
|
||||||
|
@ -771,7 +752,7 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
|
||||||
{
|
{
|
||||||
switch_channel_t *channel = NULL;
|
switch_channel_t *channel = NULL;
|
||||||
private_t *tech_pvt = NULL;
|
private_t *tech_pvt = NULL;
|
||||||
unsigned int sent=0;
|
unsigned int sent;
|
||||||
|
|
||||||
channel = switch_core_session_get_channel(session);
|
channel = switch_core_session_get_channel(session);
|
||||||
switch_assert(channel != NULL);
|
switch_assert(channel != NULL);
|
||||||
|
@ -790,50 +771,25 @@ static switch_status_t channel_write_frame(switch_core_session_t *session, switc
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if 0
|
|
||||||
sent = frame->datalen;
|
sent = frame->datalen;
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
//switch_file_write(tech_pvt->audiopipe_cli[1], frame->data, &sent);
|
//switch_file_write(tech_pvt->audiopipe_cli[1], frame->data, &sent);
|
||||||
#else /* WIN32 */
|
#else /* WIN32 */
|
||||||
//sent = write(tech_pvt->audiopipe_cli[1], frame->data, sent);
|
//sent = write(tech_pvt->audiopipe_cli[1], frame->data, sent);
|
||||||
#endif /* WIN32 */
|
#endif /* WIN32 */
|
||||||
//if (tech_pvt->flag_audio_cli == 0) {
|
if (tech_pvt->flag_audio_cli == 1) {
|
||||||
|
switch_sleep(1000); //1 millisec
|
||||||
|
}
|
||||||
|
if (tech_pvt->flag_audio_cli == 0) {
|
||||||
#ifdef TIMER_WRITE
|
#ifdef TIMER_WRITE
|
||||||
switch_core_timer_next(&tech_pvt->timer_write);
|
switch_core_timer_next(&tech_pvt->timer_write);
|
||||||
#endif // TIMER_WRITE
|
#endif // TIMER_WRITE
|
||||||
|
|
||||||
//while (tech_pvt->flag_audio_cli == 1) {
|
|
||||||
//switch_sleep(1000); //10 millisec
|
|
||||||
//WARNINGA("write now is 1\n", SKYPIAX_P_LOG);
|
|
||||||
//}
|
|
||||||
switch_mutex_lock(tech_pvt->flag_audio_cli_mutex);
|
|
||||||
memcpy(tech_pvt->audiobuf_cli, frame->data, frame->datalen);
|
memcpy(tech_pvt->audiobuf_cli, frame->data, frame->datalen);
|
||||||
tech_pvt->flag_audio_cli = 1;
|
tech_pvt->flag_audio_cli = 1;
|
||||||
switch_mutex_unlock(tech_pvt->flag_audio_cli_mutex);
|
}
|
||||||
//}
|
|
||||||
//NOTICA("write \n", SKYPIAX_P_LOG);
|
//NOTICA("write \n", SKYPIAX_P_LOG);
|
||||||
#endif //0
|
|
||||||
|
|
||||||
#ifdef TIMER_WRITE
|
|
||||||
/* NONBLOCKING ? */
|
|
||||||
switch_core_timer_next(&tech_pvt->timer_write);
|
|
||||||
//switch_core_timer_check(&tech_pvt->timer_write, SWITCH_TRUE);
|
|
||||||
#endif // TIMER_WRITE
|
|
||||||
/* 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) {
|
|
||||||
sent = send(tech_pvt->writefd, (char *) frame->data, frame->datalen, 0);
|
|
||||||
if (sent == -1) {
|
|
||||||
ERRORA("EXIT? sent=%d\n", SKYPIAX_P_LOG, sent);
|
|
||||||
} else if (sent != frame->datalen) {
|
|
||||||
ERRORA("sent=%d\n", SKYPIAX_P_LOG, sent);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef TIMER_WRITE
|
|
||||||
/* BLOCKING ? */
|
|
||||||
//switch_core_timer_check(&tech_pvt->timer_write, SWITCH_TRUE);
|
|
||||||
#endif // TIMER_WRITE
|
|
||||||
if (sent != frame->datalen && sent != -1) {
|
if (sent != frame->datalen && sent != -1) {
|
||||||
DEBUGA_SKYPE("CLI PIPE write %d\n", SKYPIAX_P_LOG, sent);
|
DEBUGA_SKYPE("CLI PIPE write %d\n", SKYPIAX_P_LOG, sent);
|
||||||
}
|
}
|
||||||
|
@ -874,9 +830,7 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
|
||||||
{
|
{
|
||||||
DEBUGA_SKYPE("MSG_ID=%d, TO BE ANSWERED!\n", SKYPIAX_P_LOG, msg->message_id);
|
DEBUGA_SKYPE("MSG_ID=%d, TO BE ANSWERED!\n", SKYPIAX_P_LOG, msg->message_id);
|
||||||
|
|
||||||
#ifdef TIMERS_ON
|
|
||||||
switch_core_timer_sync(&tech_pvt->timer_read);
|
switch_core_timer_sync(&tech_pvt->timer_read);
|
||||||
#endif// TIMERS_ON
|
|
||||||
#ifdef TIMER_WRITE
|
#ifdef TIMER_WRITE
|
||||||
switch_core_timer_sync(&tech_pvt->timer_write);
|
switch_core_timer_sync(&tech_pvt->timer_write);
|
||||||
#endif // TIMER_WRITE
|
#endif // TIMER_WRITE
|
||||||
|
@ -887,9 +841,7 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
|
||||||
|
|
||||||
DEBUGA_SKYPE("%s CHANNEL got SWITCH_MESSAGE_INDICATE_AUDIO_SYNC\n", SKYPIAX_P_LOG, switch_channel_get_name(channel));
|
DEBUGA_SKYPE("%s CHANNEL got SWITCH_MESSAGE_INDICATE_AUDIO_SYNC\n", SKYPIAX_P_LOG, switch_channel_get_name(channel));
|
||||||
|
|
||||||
#ifdef TIMERS_ON
|
|
||||||
switch_core_timer_sync(&tech_pvt->timer_read);
|
switch_core_timer_sync(&tech_pvt->timer_read);
|
||||||
#endif// TIMERS_ON
|
|
||||||
#ifdef TIMER_WRITE
|
#ifdef TIMER_WRITE
|
||||||
switch_core_timer_sync(&tech_pvt->timer_write);
|
switch_core_timer_sync(&tech_pvt->timer_write);
|
||||||
#endif // TIMER_WRITE
|
#endif // TIMER_WRITE
|
||||||
|
@ -897,9 +849,7 @@ static switch_status_t channel_receive_message(switch_core_session_t *session, s
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
|
|
||||||
#ifdef TIMERS_ON
|
|
||||||
switch_core_timer_sync(&tech_pvt->timer_read);
|
switch_core_timer_sync(&tech_pvt->timer_read);
|
||||||
#endif// TIMERS_ON
|
|
||||||
#ifdef TIMER_WRITE
|
#ifdef TIMER_WRITE
|
||||||
|
|
||||||
switch_core_timer_sync(&tech_pvt->timer_write);
|
switch_core_timer_sync(&tech_pvt->timer_write);
|
||||||
|
@ -1444,8 +1394,6 @@ static switch_status_t load_config(int reload_type)
|
||||||
|
|
||||||
skypiax_audio_init(&globals.SKYPIAX_INTERFACES[interface_id]);
|
skypiax_audio_init(&globals.SKYPIAX_INTERFACES[interface_id]);
|
||||||
|
|
||||||
switch_mutex_init(&globals.SKYPIAX_INTERFACES[interface_id].flag_audio_srv_mutex, SWITCH_MUTEX_NESTED, skypiax_module_pool);
|
|
||||||
switch_mutex_init(&globals.SKYPIAX_INTERFACES[interface_id].flag_audio_cli_mutex, SWITCH_MUTEX_NESTED, skypiax_module_pool);
|
|
||||||
NOTICA
|
NOTICA
|
||||||
("WAITING roughly 10 seconds to find a running Skype client and connect to its SKYPE API for interface_id=%d\n",
|
("WAITING roughly 10 seconds to find a running Skype client and connect to its SKYPE API for interface_id=%d\n",
|
||||||
SKYPIAX_P_LOG, interface_id);
|
SKYPIAX_P_LOG, interface_id);
|
||||||
|
|
|
@ -29,7 +29,6 @@
|
||||||
* Further Contributors:
|
* Further Contributors:
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
*
|
|
||||||
* mod_skypiax.c -- Skype compatible Endpoint Module
|
* mod_skypiax.c -- Skype compatible Endpoint Module
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -192,8 +191,6 @@ struct private_object {
|
||||||
switch_caller_profile_t *caller_profile;
|
switch_caller_profile_t *caller_profile;
|
||||||
switch_mutex_t *mutex;
|
switch_mutex_t *mutex;
|
||||||
switch_mutex_t *flag_mutex;
|
switch_mutex_t *flag_mutex;
|
||||||
switch_mutex_t *flag_audio_cli_mutex;
|
|
||||||
switch_mutex_t *flag_audio_srv_mutex;
|
|
||||||
|
|
||||||
char interface_id[80];
|
char interface_id[80];
|
||||||
char name[80];
|
char name[80];
|
||||||
|
@ -281,8 +278,6 @@ struct private_object {
|
||||||
uint32_t report_incoming_chatmessages;
|
uint32_t report_incoming_chatmessages;
|
||||||
switch_timer_t timer_read;
|
switch_timer_t timer_read;
|
||||||
switch_timer_t timer_write;
|
switch_timer_t timer_write;
|
||||||
unsigned int writefd;
|
|
||||||
unsigned int readfd;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct private_object private_t;
|
typedef struct private_object private_t;
|
||||||
|
|
|
@ -55,9 +55,8 @@ int skypiax_socket_create_and_bind(private_t * tech_pvt, unsigned short *which_p
|
||||||
start_port = *which_port;
|
start_port = *which_port;
|
||||||
|
|
||||||
my_addr.sin_port = htons(start_port);
|
my_addr.sin_port = htons(start_port);
|
||||||
/* NONBLOCKING ? */
|
|
||||||
//fcntl(s, F_SETFL, O_NONBLOCK);
|
//fcntl(s, F_SETFL, O_NONBLOCK);
|
||||||
|
//tech_pvt->tcp_cli_port = start_port;
|
||||||
*which_port = start_port;
|
*which_port = start_port;
|
||||||
while (bind(s, (struct sockaddr *) &my_addr, sizeof(struct sockaddr)) < 0) {
|
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", SKYPIAX_P_LOG, *which_port, tech_pvt->tcp_cli_port,
|
DEBUGA_SKYPE("*which_port=%d, tech_pvt->tcp_cli_port=%d, tech_pvt->tcp_srv_port=%d\n", SKYPIAX_P_LOG, *which_port, tech_pvt->tcp_cli_port,
|
||||||
|
@ -119,7 +118,6 @@ int skypiax_socket_create_and_bind(private_t * tech_pvt, unsigned short *which_p
|
||||||
size = sizeof(int);
|
size = sizeof(int);
|
||||||
setsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *) &sockbufsize, size);
|
setsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *) &sockbufsize, size);
|
||||||
|
|
||||||
|
|
||||||
sockbufsize = 0;
|
sockbufsize = 0;
|
||||||
size = sizeof(int);
|
size = sizeof(int);
|
||||||
getsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *) &sockbufsize, &size);
|
getsockopt(s, SOL_SOCKET, SO_SNDBUF, (char *) &sockbufsize, &size);
|
||||||
|
@ -724,22 +722,22 @@ void *skypiax_do_tcp_srv_thread_func(void *obj)
|
||||||
private_t *tech_pvt = obj;
|
private_t *tech_pvt = obj;
|
||||||
int s;
|
int s;
|
||||||
unsigned int len;
|
unsigned int len;
|
||||||
//unsigned int i;
|
unsigned int i;
|
||||||
//unsigned int a;
|
unsigned int a;
|
||||||
#if defined(WIN32) && !defined(__CYGWIN__)
|
#if defined(WIN32) && !defined(__CYGWIN__)
|
||||||
int sin_size;
|
int sin_size;
|
||||||
#else /* WIN32 */
|
#else /* WIN32 */
|
||||||
unsigned int sin_size;
|
unsigned int sin_size;
|
||||||
#endif /* WIN32 */
|
#endif /* WIN32 */
|
||||||
unsigned int fd;
|
unsigned int fd;
|
||||||
//short srv_in[SAMPLES_PER_FRAME];
|
short srv_in[SAMPLES_PER_FRAME];
|
||||||
//short srv_out[SAMPLES_PER_FRAME / 2];
|
short srv_out[SAMPLES_PER_FRAME / 2];
|
||||||
//struct sockaddr_in my_addr;
|
//struct sockaddr_in my_addr;
|
||||||
struct sockaddr_in remote_addr;
|
struct sockaddr_in remote_addr;
|
||||||
//int exit = 0;
|
//int exit = 0;
|
||||||
unsigned int kill_cli_size;
|
unsigned int kill_cli_size;
|
||||||
short kill_cli_buff[SAMPLES_PER_FRAME];
|
short kill_cli_buff[SAMPLES_PER_FRAME];
|
||||||
//short totalbuf[SAMPLES_PER_FRAME];
|
short totalbuf[SAMPLES_PER_FRAME];
|
||||||
int sockbufsize = 0;
|
int sockbufsize = 0;
|
||||||
unsigned int size = sizeof(int);
|
unsigned int size = sizeof(int);
|
||||||
|
|
||||||
|
@ -799,13 +797,6 @@ void *skypiax_do_tcp_srv_thread_func(void *obj)
|
||||||
|| tech_pvt->skype_callflow == CALLFLOW_STATUS_EARLYMEDIA
|
|| tech_pvt->skype_callflow == CALLFLOW_STATUS_EARLYMEDIA
|
||||||
|| tech_pvt->skype_callflow == CALLFLOW_STATUS_REMOTEHOLD || tech_pvt->skype_callflow == SKYPIAX_STATE_UP)) {
|
|| tech_pvt->skype_callflow == CALLFLOW_STATUS_REMOTEHOLD || tech_pvt->skype_callflow == SKYPIAX_STATE_UP)) {
|
||||||
|
|
||||||
tech_pvt->readfd = fd;
|
|
||||||
//WARNINGA("read HERE\n", SKYPIAX_P_LOG);
|
|
||||||
skypiax_sleep(100000);
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef NOLOOP
|
|
||||||
|
|
||||||
unsigned int fdselect;
|
unsigned int fdselect;
|
||||||
int rt;
|
int rt;
|
||||||
fd_set fs;
|
fd_set fs;
|
||||||
|
@ -875,16 +866,13 @@ void *skypiax_do_tcp_srv_thread_func(void *obj)
|
||||||
|
|
||||||
|
|
||||||
howmany = SAMPLES_PER_FRAME * sizeof(short);
|
howmany = SAMPLES_PER_FRAME * sizeof(short);
|
||||||
//while (tech_pvt->flag_audio_srv == 1) {
|
if (tech_pvt->flag_audio_srv == 1) {
|
||||||
//switch_sleep(1000); //10 millisec
|
switch_sleep(1000); //1 millisec
|
||||||
//WARNINGA("read now is 1\n", SKYPIAX_P_LOG);
|
}
|
||||||
//}
|
if (tech_pvt->flag_audio_srv == 0) {
|
||||||
//if (tech_pvt->flag_audio_srv == 0) {
|
|
||||||
//switch_mutex_lock(tech_pvt->flag_audio_srv_mutex);
|
|
||||||
memcpy(tech_pvt->audiobuf_srv, totalbuf, SAMPLES_PER_FRAME * sizeof(short));
|
memcpy(tech_pvt->audiobuf_srv, totalbuf, SAMPLES_PER_FRAME * sizeof(short));
|
||||||
tech_pvt->flag_audio_srv = 1;
|
tech_pvt->flag_audio_srv = 1;
|
||||||
//switch_mutex_unlock(tech_pvt->flag_audio_srv_mutex);
|
}
|
||||||
//}
|
|
||||||
//NOTICA("read \n", SKYPIAX_P_LOG);
|
//NOTICA("read \n", SKYPIAX_P_LOG);
|
||||||
if (howmany != SAMPLES_PER_FRAME * sizeof(short)) {
|
if (howmany != SAMPLES_PER_FRAME * sizeof(short)) {
|
||||||
ERRORA("howmany is %d, but was expected to be %d\n", SKYPIAX_P_LOG,
|
ERRORA("howmany is %d, but was expected to be %d\n", SKYPIAX_P_LOG,
|
||||||
|
@ -906,7 +894,6 @@ void *skypiax_do_tcp_srv_thread_func(void *obj)
|
||||||
skypiax_sleep(10000);
|
skypiax_sleep(10000);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif// NOLOOP
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* let's send some frame in the pipes, so both tcp_cli and tcp_srv will have an occasion to die */
|
/* let's send some frame in the pipes, so both tcp_cli and tcp_srv will have an occasion to die */
|
||||||
|
@ -931,7 +918,6 @@ void *skypiax_do_tcp_srv_thread_func(void *obj)
|
||||||
skypiax_sleep(2000);
|
skypiax_sleep(2000);
|
||||||
DEBUGA_SKYPE("Skype incoming audio GONE\n", SKYPIAX_P_LOG);
|
DEBUGA_SKYPE("Skype incoming audio GONE\n", SKYPIAX_P_LOG);
|
||||||
skypiax_close_socket(fd);
|
skypiax_close_socket(fd);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -948,15 +934,13 @@ void *skypiax_do_tcp_cli_thread_func(void *obj)
|
||||||
int s;
|
int s;
|
||||||
//struct sockaddr_in my_addr;
|
//struct sockaddr_in my_addr;
|
||||||
struct sockaddr_in remote_addr;
|
struct sockaddr_in remote_addr;
|
||||||
#ifdef NOVARS
|
|
||||||
unsigned int got;
|
unsigned int got;
|
||||||
unsigned int len;
|
unsigned int len;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
unsigned int a;
|
unsigned int a;
|
||||||
|
unsigned int fd;
|
||||||
short cli_out[SAMPLES_PER_FRAME * 2];
|
short cli_out[SAMPLES_PER_FRAME * 2];
|
||||||
short cli_in[SAMPLES_PER_FRAME];
|
short cli_in[SAMPLES_PER_FRAME];
|
||||||
#endif// NOVARS
|
|
||||||
unsigned int fd;
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
int sin_size;
|
int sin_size;
|
||||||
#else
|
#else
|
||||||
|
@ -1025,19 +1009,10 @@ void *skypiax_do_tcp_cli_thread_func(void *obj)
|
||||||
|
|
||||||
if (!(running && tech_pvt->running))
|
if (!(running && tech_pvt->running))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN
|
while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN
|
||||||
&& (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS
|
&& (tech_pvt->skype_callflow == CALLFLOW_STATUS_INPROGRESS
|
||||||
|| tech_pvt->skype_callflow == CALLFLOW_STATUS_EARLYMEDIA
|
|| tech_pvt->skype_callflow == CALLFLOW_STATUS_EARLYMEDIA
|
||||||
|| tech_pvt->skype_callflow == CALLFLOW_STATUS_REMOTEHOLD || tech_pvt->skype_callflow == SKYPIAX_STATE_UP)) {
|
|| tech_pvt->skype_callflow == CALLFLOW_STATUS_REMOTEHOLD || tech_pvt->skype_callflow == SKYPIAX_STATE_UP)) {
|
||||||
tech_pvt->writefd = fd;
|
|
||||||
//NOTICA("write HERE\n", SKYPIAX_P_LOG);
|
|
||||||
skypiax_sleep(100000);
|
|
||||||
#if 0
|
|
||||||
#ifdef NOVARS
|
|
||||||
unsigned int fdselect;
|
unsigned int fdselect;
|
||||||
int rt;
|
int rt;
|
||||||
fd_set fs;
|
fd_set fs;
|
||||||
|
@ -1064,46 +1039,32 @@ void *skypiax_do_tcp_cli_thread_func(void *obj)
|
||||||
fdselect = fd;
|
fdselect = fd;
|
||||||
FD_SET(fdselect, &fs);
|
FD_SET(fdselect, &fs);
|
||||||
|
|
||||||
#endif// NOVARS
|
//FIXME rt = select(fdselect + 1, NULL, &fs, NULL, &to);
|
||||||
#if 0
|
|
||||||
rt = select(fdselect + 1, NULL, &fs, NULL, NULL);
|
|
||||||
while (tech_pvt->flag_audio_cli == 0) {
|
while (tech_pvt->flag_audio_cli == 0) {
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
skypiax_sleep(100); //0.1 millisec
|
skypiax_sleep(100); //0.1 millisec
|
||||||
#else
|
#else
|
||||||
skypiax_sleep(1000); //10 millisec
|
skypiax_sleep(1000); //1 millisec
|
||||||
#endif //WIN32
|
#endif //WIN32
|
||||||
NOTICA("write now is 0\n", SKYPIAX_P_LOG);
|
//WARNINGA("write now is 0\n", SKYPIAX_P_LOG);
|
||||||
}
|
}
|
||||||
//ERRORA("write is now 1\n", SKYPIAX_P_LOG);
|
//ERRORA("write is now 1\n", SKYPIAX_P_LOG);
|
||||||
|
|
||||||
rt = 1;
|
rt = 1;
|
||||||
#endif //0
|
|
||||||
//rt = select(fdselect + 1, NULL, &fs, NULL, NULL);
|
|
||||||
|
|
||||||
#ifdef NOLOOP
|
|
||||||
if (rt > 0) {
|
if (rt > 0) {
|
||||||
int counter;
|
int counter;
|
||||||
#if 0
|
|
||||||
while (tech_pvt->flag_audio_cli == 0) {
|
|
||||||
#ifdef WIN32
|
|
||||||
skypiax_sleep(100); //0.1 millisec
|
|
||||||
#else
|
|
||||||
skypiax_sleep(10000); //10 millisec
|
|
||||||
#endif //WIN32
|
|
||||||
WARNINGA("write now is 0\n", SKYPIAX_P_LOG);
|
|
||||||
}
|
|
||||||
#endif //0
|
|
||||||
|
|
||||||
/* until we drained the pipe to empty */
|
/* until we drained the pipe to empty */
|
||||||
|
//for (counter = 0; counter < 10; counter++) {
|
||||||
for (counter = 0; counter < 1; counter++) {
|
for (counter = 0; counter < 1; counter++) {
|
||||||
/* read from the pipe the audio frame we are supposed to send out */
|
/* read from the pipe the audio frame we are supposed to send out */
|
||||||
//got = skypiax_pipe_read(tech_pvt->audiopipe_cli[0], cli_in, SAMPLES_PER_FRAME * sizeof(short));
|
//got = skypiax_pipe_read(tech_pvt->audiopipe_cli[0], cli_in, SAMPLES_PER_FRAME * sizeof(short));
|
||||||
|
|
||||||
|
|
||||||
got = SAMPLES_PER_FRAME * sizeof(short);
|
got = SAMPLES_PER_FRAME * sizeof(short);
|
||||||
switch_mutex_lock(tech_pvt->flag_audio_cli_mutex);
|
|
||||||
memcpy(cli_in, tech_pvt->audiobuf_cli, SAMPLES_PER_FRAME * sizeof(short));
|
memcpy(cli_in, tech_pvt->audiobuf_cli, SAMPLES_PER_FRAME * sizeof(short));
|
||||||
|
tech_pvt->flag_audio_cli = 0;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1139,7 +1100,6 @@ void *skypiax_do_tcp_cli_thread_func(void *obj)
|
||||||
/* send the 16khz frame to the Skype client waiting for incoming audio to be sent to the remote party */
|
/* 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) {
|
if (tech_pvt->skype_callflow != CALLFLOW_STATUS_REMOTEHOLD) {
|
||||||
len = send(fd, (char *) cli_out, got, 0);
|
len = send(fd, (char *) cli_out, got, 0);
|
||||||
tech_pvt->flag_audio_cli = 0;
|
|
||||||
//skypiax_sleep(5000); //5 msec
|
//skypiax_sleep(5000); //5 msec
|
||||||
|
|
||||||
if (len == -1) {
|
if (len == -1) {
|
||||||
|
@ -1151,7 +1111,6 @@ void *skypiax_do_tcp_cli_thread_func(void *obj)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_mutex_unlock(tech_pvt->flag_audio_cli_mutex);
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
WARNINGA("got is %d, but was expected to be %d\n", SKYPIAX_P_LOG, got, (int) (SAMPLES_PER_FRAME * sizeof(short)));
|
WARNINGA("got is %d, but was expected to be %d\n", SKYPIAX_P_LOG, got, (int) (SAMPLES_PER_FRAME * sizeof(short)));
|
||||||
|
@ -1174,12 +1133,9 @@ void *skypiax_do_tcp_cli_thread_func(void *obj)
|
||||||
skypiax_sleep(1000);
|
skypiax_sleep(1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif// NOLOOP
|
|
||||||
#endif// 0
|
|
||||||
}
|
}
|
||||||
DEBUGA_SKYPE("Skype outbound audio GONE\n", SKYPIAX_P_LOG);
|
DEBUGA_SKYPE("Skype outbound audio GONE\n", SKYPIAX_P_LOG);
|
||||||
skypiax_close_socket(fd);
|
skypiax_close_socket(fd);
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1194,24 +1150,20 @@ int skypiax_audio_read(private_t * tech_pvt)
|
||||||
{
|
{
|
||||||
unsigned int samples;
|
unsigned int samples;
|
||||||
|
|
||||||
#if 0
|
|
||||||
while (tech_pvt->flag_audio_srv == 0) {
|
while (tech_pvt->flag_audio_srv == 0) {
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
skypiax_sleep(100); //0.1 millisec
|
skypiax_sleep(100); //0.1 millisec
|
||||||
#else
|
#else
|
||||||
skypiax_sleep(1000); //10 millisec
|
skypiax_sleep(1000); //1 millisec
|
||||||
#endif //WIN32
|
#endif //WIN32
|
||||||
|
|
||||||
WARNINGA("read now is 0\n", SKYPIAX_P_LOG);
|
//WARNINGA("read now is 0\n", SKYPIAX_P_LOG);
|
||||||
}
|
}
|
||||||
#endif //0
|
|
||||||
//ERRORA("read is now 1\n", SKYPIAX_P_LOG);
|
//ERRORA("read is now 1\n", SKYPIAX_P_LOG);
|
||||||
//samples = skypiax_pipe_read(tech_pvt->audiopipe_srv[0], tech_pvt->read_frame.data, SAMPLES_PER_FRAME * sizeof(short));
|
//samples = skypiax_pipe_read(tech_pvt->audiopipe_srv[0], tech_pvt->read_frame.data, SAMPLES_PER_FRAME * sizeof(short));
|
||||||
samples = SAMPLES_PER_FRAME * sizeof(short);
|
samples = SAMPLES_PER_FRAME * sizeof(short);
|
||||||
//switch_mutex_lock(tech_pvt->flag_audio_srv_mutex);
|
|
||||||
memcpy(tech_pvt->read_frame.data, tech_pvt->audiobuf_srv, SAMPLES_PER_FRAME * sizeof(short));
|
memcpy(tech_pvt->read_frame.data, tech_pvt->audiobuf_srv, SAMPLES_PER_FRAME * sizeof(short));
|
||||||
tech_pvt->flag_audio_srv = 0;
|
tech_pvt->flag_audio_srv = 0;
|
||||||
//switch_mutex_unlock(tech_pvt->flag_audio_srv_mutex);
|
|
||||||
|
|
||||||
if (samples != SAMPLES_PER_FRAME * sizeof(short)) {
|
if (samples != SAMPLES_PER_FRAME * sizeof(short)) {
|
||||||
if (samples)
|
if (samples)
|
||||||
|
|
Loading…
Reference in New Issue