[Freeswitch-svn] [commit] r10855 - freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax

FreeSWITCH SVN gmaruzz at freeswitch.org
Wed Dec 17 10:37:18 PST 2008


Author: gmaruzz
Date: Wed Dec 17 13:37:17 2008
New Revision: 10855

Log:
send audio to remote skype client at native rate on linux

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 13:37:17 2008
@@ -392,7 +392,7 @@
 
   sent = frame->datalen;
   switch_file_write(p->audioskypepipe[1], (short *) frame->data, &sent);
-  //ERRORA("sent %d\n", SKYPIAX_P_LOG, sent);
+  DEBUGA_SKYPE("CLI PIPE write %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 13:37:17 2008
@@ -45,8 +45,8 @@
 //FIXME include?
 #endif //WIN32
 
-#define SAMPLES_PER_FRAME 160
-#define SAMPLERATE 8000
+#define SAMPLES_PER_FRAME 320
+#define SAMPLERATE 16000
 //#define SKYPIAX_SVN_VERSION "SVN 123456"
 #define SKYPIAX_SVN_VERSION SWITCH_VERSION_REVISION
 

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 13:37:17 2008
@@ -216,7 +216,7 @@
   unsigned int len;
   unsigned int i;
   unsigned int a;
-  short cli_in[SAMPLES_PER_FRAME / 2];
+  short cli_in[SAMPLES_PER_FRAME];
   short cli_out[SAMPLES_PER_FRAME];
   int sin_size;
   unsigned int fd;
@@ -224,7 +224,7 @@
   int len;
   int i;
   int a;
-  short cli_in[SAMPLES_PER_FRAME / 2];
+  short cli_in[SAMPLES_PER_FRAME];
   short cli_out[SAMPLES_PER_FRAME];
   unsigned int sin_size;
   int fd;
@@ -287,33 +287,59 @@
       to.tv_usec = 10000;
       to.tv_sec = 0;
       //rt = select(fdselect + 1, &fs, NULL, NULL, &to);
-	  switch_sleep(5000);
+	  //switch_sleep(5000);
       rt = 1;
-      if (rt > 0) {
+	  if (rt > 0) {
+			  /*********************************************/
+		  if (SAMPLERATE == 8000) {
+			  got = (SAMPLES_PER_FRAME / 2) * sizeof(short);
+			  switch_file_read(p->audioskypepipe[0], cli_in, &got);
+
+			  if (got > 0) {
+				  a = 0;
+				  for (i = 0; i < got / sizeof(short); i++) {
+					  cli_out[a] = cli_in[i];
+					  a++;
+					  cli_out[a] = cli_in[i];
+					  a++;
+				  }
+
+				  len = send(fd, cli_out, got * 2, 0);
+
+				  if (len == 0) {
+					  ERRORA("Skype server GONE\n", SKYPIAX_P_LOG);
+					  break;
+				  }
+			  } else {
+				  switch_sleep(1000);
+				  //ERRORA("Audio skype pipe give us: %u\n", SKYPIAX_P_LOG, got);
+			  }
+		  }
+		  /*********************************************/
+			  /*********************************************/
+		  else if (SAMPLERATE == 16000) {
+			  got = SAMPLES_PER_FRAME * sizeof(short);
+			  switch_file_read(p->audioskypepipe[0], cli_in, &got);
+
+			  if (got > 0) {
+				  DEBUGA_SKYPE("CLI PIPE read %d\n", SKYPIAX_P_LOG, got);
+
+				  len = send(fd, cli_in, got, 0);
+
+				  DEBUGA_SKYPE("CLI PIPE send %d\n", SKYPIAX_P_LOG, len);
+
+				  if (len == 0) {
+					  ERRORA("Skype server GONE\n", SKYPIAX_P_LOG);
+					  break;
+				  }
+			  } else {
+				  switch_sleep(1000);
+				  ERRORA("CLI PIPE give us: %u\n", SKYPIAX_P_LOG, got);
+			  }
+		  }
+		  /*********************************************/
 
-        got = (SAMPLES_PER_FRAME / 2) * sizeof(short);
-        switch_file_read(p->audioskypepipe[0], cli_in, &got);
-
-        if (got > 0) {
-          a = 0;
-          for (i = 0; i < got / sizeof(short); i++) {
-            cli_out[a] = cli_in[i];
-            a++;
-            cli_out[a] = cli_in[i];
-            a++;
-          }
-
-          len = send(fd, cli_out, got * 2, 0);
-
-          if (len == 0) {
-            ERRORA("Skype server GONE\n", SKYPIAX_P_LOG);
-            break;
-          }
-        } else {
-          switch_sleep(1000);
-          //ERRORA("Audio skype pipe give us: %u\n", SKYPIAX_P_LOG, got);
-        }
-      }
+	  }
 
     }
     ERRORA("Skype server GONE\n", SKYPIAX_P_LOG);
@@ -351,7 +377,7 @@
 
   rv =
     switch_file_pipe_create(&p->audioskypepipe[0], &p->audioskypepipe[1], skypiax_module_pool);
-  rv = switch_file_pipe_timeout_set(p->audioskypepipe[0], 100);
+  rv = switch_file_pipe_timeout_set(p->audioskypepipe[0], 100000);
   if (option_debug > 10) {
     DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
   }



More information about the Freeswitch-svn mailing list