[Freeswitch-branches] [commit] r10853 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax
FreeSWITCH SVN
gmaruzz at freeswitch.org
Wed Dec 17 09:21:26 PST 2008
Author: gmaruzz
Date: Wed Dec 17 12:21:26 2008
New Revision: 10853
Log:
re-beginning native rate
Modified:
freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c
freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h
freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c
Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c
==============================================================================
--- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c (original)
+++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c Wed Dec 17 12:21:26 2008
@@ -107,7 +107,7 @@
p->tech_pvt = tech_pvt;
}
- if (skypiax_codec(tech_pvt, 16000, 20) != SWITCH_STATUS_SUCCESS) {
+ if (skypiax_codec(tech_pvt, SAMPLERATE, 20) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "skypiax_docec FAILED\n");
} else {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "skypiax_codec SUCCESS\n");
@@ -390,10 +390,9 @@
}
#endif
- sent = frame->datalen/sizeof(short);
- //ERRORA("CLI to be sent %d\n", SKYPIAX_P_LOG, sent);
+ sent = frame->datalen;
switch_file_write(p->audioskypepipe[1], (short *) frame->data, &sent);
- //ERRORA("CLI sent %d\n", SKYPIAX_P_LOG, sent);
+ //ERRORA("sent %d\n", SKYPIAX_P_LOG, sent);
return SWITCH_STATUS_SUCCESS;
Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h
==============================================================================
--- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h (original)
+++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax.h Wed Dec 17 12:21:26 2008
@@ -45,6 +45,8 @@
//FIXME include?
#endif //WIN32
+#define SAMPLES_PER_FRAME 160
+#define SAMPLERATE 8000
//#define SKYPIAX_SVN_VERSION "SVN 123456"
#define SKYPIAX_SVN_VERSION SWITCH_VERSION_REVISION
@@ -179,7 +181,7 @@
switch_thread_t *tcp_cli_thread;
switch_thread_t *skypiax_do_controldev_thread_thread;
switch_thread_t *skypiax_do_skype_thread_thread;
- short audiobuf[160];
+ short audiobuf[SAMPLES_PER_FRAME];
int audiobuf_is_loaded;
//int phonebook_listing;
Modified: freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c
==============================================================================
--- freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c (original)
+++ freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/skypiax_protocol.c Wed Dec 17 12:21:26 2008
@@ -37,13 +37,12 @@
/**********************************************************/
/**********************************************************/
/**********************************************************/
-#define SAMPLES_PER_FRAME 320
static void *SWITCH_THREAD_FUNC skypiax_do_tcp_srv_thread(switch_thread_t * thread,
void *obj)
{
struct skypiax_interface *p = obj;
- //short srv_out[SAMPLES_PER_FRAME / 2];
+ short srv_out[SAMPLES_PER_FRAME / 2];
int s;
#ifdef WIN32
unsigned int len;
@@ -53,10 +52,10 @@
int sin_size;
unsigned int fd;
#else
- int len = 0;
- //int i;
- //int a;
- short srv_in[SAMPLES_PER_FRAME * 2];
+ int len;
+ int i;
+ int a;
+ short srv_in[SAMPLES_PER_FRAME];
unsigned int sin_size;
int fd;
#endif /* WIN32 */
@@ -64,9 +63,7 @@
struct sockaddr_in remote_addr;
int exit = 0;
unsigned int kill_cli_size;
- short kill_cli_buff[320];
- //int i;
- //int a;
+ short kill_cli_buff[SAMPLES_PER_FRAME * sizeof(short)];
if (option_debug > 10) {
WARNINGA("ENTERING FUNC\n", SKYPIAX_P_LOG);
@@ -120,61 +117,16 @@
fdselect = fd;
FD_ZERO(&fs);
FD_SET(fdselect, &fs);
- to.tv_usec = 100000;
+ to.tv_usec = 10000;
to.tv_sec = 0;
rt = select(fdselect + 1, &fs, NULL, NULL, &to);
- //switch_sleep(10000);
+ //usleep(1000);
//rt=1;
if (rt > 0) {
- len = recv(fd, srv_in, SAMPLES_PER_FRAME * sizeof(short), 0);
+ len = recv(fd, srv_in, sizeof(short) * SAMPLES_PER_FRAME, 0);
//DEBUGA_SKYPE("recv %d\n", SKYPIAX_P_LOG, len);
if (len > 0) {
- if(len == SAMPLES_PER_FRAME * sizeof(short)) {
- unsigned int howmany;
-
- howmany = len / sizeof(short);
- switch_file_write(p->audiopipe[1], srv_in, &howmany);
- if(howmany == 320){
- NOTICA("SRV=====> req=%d recv=%d to sent=%d sent=%d\n", SKYPIAX_P_LOG, SAMPLES_PER_FRAME * sizeof(short), len, len / sizeof(short), howmany);
- } else {
- ERRORA("SRV=====> req=%d recv=%d to sent=%d sent=%d\n", SKYPIAX_P_LOG, SAMPLES_PER_FRAME * sizeof(short), len, len / sizeof(short), howmany);
- switch_sleep(1000);
- }
- } else {
-
- if (!p->audiobuf_is_loaded) {
- for (i = 0; i < (len / sizeof(short)); i++) {
- p->audiobuf[i] = srv_in[i];
- }
- p->audiobuf_is_loaded = 1;
- } else {
- unsigned int howmany;
- short totalbuf[SAMPLES_PER_FRAME];
-
- howmany = len / 2 ;
- for (i = 0; i < howmany; i++)
- totalbuf[i] = p->audiobuf[i];
-
- howmany = len / 2 ;
- for (a = 0; a < howmany; a++) {
- totalbuf[i] = srv_in[a];
- i++;
- }
-
- howmany = SAMPLES_PER_FRAME;
-
- switch_file_write(p->audiopipe[1], totalbuf, &howmany);
- p->audiobuf_is_loaded = 0;
- DEBUGA_SKYPE("SRV=====> req=%d recv=%d to sent=%d sent=%d\n", SKYPIAX_P_LOG, sizeof(short)*SAMPLES_PER_FRAME, len, SAMPLES_PER_FRAME, howmany);
- }
-
-
-
-
- }
-
-#if 0
a = 0;
for (i = 0; i < len / sizeof(short); i++) {
srv_out[a] = srv_in[i];
@@ -208,7 +160,6 @@
//DEBUGA_SKYPE("read=====> req=%d recv=%d to sent=%d sent=%d\n", SKYPIAX_P_LOG, sizeof(short)*SAMPLES_PER_FRAME, len, (len*sizeof(short))/2, howmany);
}
-#endif
} else if (len == 0) {
DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG);
break;
@@ -220,14 +171,14 @@
}
}
- kill_cli_size = 320;
+ kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
switch_file_write(p->audiopipe[1], kill_cli_buff, &kill_cli_size);
- kill_cli_size = 320;
+ kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
switch_file_write(p->audioskypepipe[1], kill_cli_buff, &kill_cli_size);
p->interface_state = SKYPIAX_STATE_DOWN;
- kill_cli_size = 320;
+ kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
switch_file_write(p->audiopipe[1], kill_cli_buff, &kill_cli_size);
- kill_cli_size = 320;
+ kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
switch_file_write(p->audioskypepipe[1], kill_cli_buff, &kill_cli_size);
DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG);
@@ -271,9 +222,9 @@
unsigned int fd;
#else
int len;
- //int i;
- //int a;
- //short cli_in[SAMPLES_PER_FRAME / 2];
+ int i;
+ int a;
+ short cli_in[SAMPLES_PER_FRAME / 2];
short cli_out[SAMPLES_PER_FRAME];
unsigned int sin_size;
int fd;
@@ -336,17 +287,9 @@
to.tv_usec = 10000;
to.tv_sec = 0;
//rt = select(fdselect + 1, &fs, NULL, NULL, &to);
- switch_sleep(1000);
+ switch_sleep(5000);
rt = 1;
if (rt > 0) {
- //got = (SAMPLES_PER_FRAME / 2) * sizeof(short);
- got = SAMPLES_PER_FRAME;
- switch_file_read(p->audioskypepipe[0], cli_out, &got);
- if (got > 0) {
- len = send(fd, cli_out, got * sizeof(short), 0);
- NOTICA("CLI=====> req=%d recv=%d to sent=%d sent=%d\n", SKYPIAX_P_LOG, SAMPLES_PER_FRAME, got, got*sizeof(short), len);
- }
-#if 0
got = (SAMPLES_PER_FRAME / 2) * sizeof(short);
switch_file_read(p->audioskypepipe[0], cli_in, &got);
@@ -370,7 +313,6 @@
switch_sleep(1000);
//ERRORA("Audio skype pipe give us: %u\n", SKYPIAX_P_LOG, got);
}
-#endif
}
}
@@ -409,7 +351,7 @@
rv =
switch_file_pipe_create(&p->audioskypepipe[0], &p->audioskypepipe[1], skypiax_module_pool);
- rv = switch_file_pipe_timeout_set(p->audioskypepipe[0], 100000);
+ rv = switch_file_pipe_timeout_set(p->audioskypepipe[0], 100);
if (option_debug > 10) {
DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
}
@@ -419,7 +361,6 @@
switch_status_t skypiax_skypeaudio_read(private_t * tech_pvt)
{
struct skypiax_interface *p;
- short buf[640];
unsigned int samples;
int rt;
@@ -427,26 +368,22 @@
//DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
- memset(buf, '\0', sizeof(buf));
- //switch_sleep(10000);
rt = 1;
if (rt > 0) {
- samples = SAMPLES_PER_FRAME;
+ samples = SAMPLES_PER_FRAME * sizeof(short);
switch_file_read(p->audiopipe[0], tech_pvt->read_frame.data, &samples);
- //if ((samples = read(p->audiopipe[0], buf, SAMPLES_PER_FRAME * sizeof(short))) != 320)
- if (samples != SAMPLES_PER_FRAME) {
- if (samples){
- DEBUGA_SKYPE("SRV=====> NOT GOOD samples=%d expected=%d\n", SKYPIAX_P_LOG, samples, SAMPLES_PER_FRAME);
- //tech_pvt->read_frame.datalen = 0;
+ if (samples != SAMPLES_PER_FRAME * sizeof(short)) {
+ if (samples)
+ DEBUGA_SKYPE("read=====> NOT GOOD samples=%d expected=%d\n", SKYPIAX_P_LOG,
+ samples, SAMPLES_PER_FRAME * sizeof(short));
//do nothing
- }
} else {
- tech_pvt->read_frame.datalen = samples * sizeof(short);
- NOTICA("SRV=====> GOOD samples=%d\n", SKYPIAX_P_LOG, samples);
+ tech_pvt->read_frame.datalen = samples;
+ //DEBUGA_SKYPE("read=====> GOOD samples=%d\n", SKYPIAX_P_LOG, samples);
/* A real frame */
}
} else {
More information about the Freeswitch-branches
mailing list