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

FreeSWITCH SVN gmaruzz at freeswitch.org
Thu Dec 18 07:00:05 PST 2008


Author: gmaruzz
Date: Thu Dec 18 10:00:03 2008
New Revision: 10867

Log:
skypiax: seems to read/write audio native on windows, but there are still problems...

Modified:
   freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.c
   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	Thu Dec 18 10:00:03 2008
@@ -392,7 +392,7 @@
 
   sent = frame->datalen;
   switch_file_write(p->audioskypepipe[1], (short *) frame->data, &sent);
-  DEBUGA_SKYPE("CLI PIPE write %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_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	Thu Dec 18 10:00:03 2008
@@ -63,7 +63,7 @@
   struct sockaddr_in remote_addr;
   int exit = 0;
   unsigned int kill_cli_size;
-  short kill_cli_buff[SAMPLES_PER_FRAME * sizeof(short)];
+  short kill_cli_buff[SAMPLES_PER_FRAME];
 
   if (option_debug > 10) {
     WARNINGA("ENTERING FUNC\n", SKYPIAX_P_LOG);
@@ -117,57 +117,119 @@
       fdselect = fd;
       FD_ZERO(&fs);
       FD_SET(fdselect, &fs);
-      to.tv_usec = 10000;
+      to.tv_usec = 100000;
       to.tv_sec = 0;
       rt = select(fdselect + 1, &fs, NULL, NULL, &to);
-	  //usleep(1000);
 	  //rt=1;
       if (rt > 0) {
 
-        len = recv(fd, srv_in, sizeof(short) * SAMPLES_PER_FRAME, 0);
-        //DEBUGA_SKYPE("recv %d\n", SKYPIAX_P_LOG, len);
-        if (len > 0) {
-          a = 0;
-          for (i = 0; i < len / sizeof(short); i++) {
-            srv_out[a] = srv_in[i];
-            i++;
-            a++;
-          }
+	      len = recv(fd, srv_in, sizeof(short) * SAMPLES_PER_FRAME, 0);
+	      //DEBUGA_SKYPE("recv %d\n", SKYPIAX_P_LOG, len);
 
-          if (!p->audiobuf_is_loaded) {
-            for (i = 0; i < (len / sizeof(short)) / 2; i++) {
-              p->audiobuf[i] = srv_out[i];
-            }
-            p->audiobuf_is_loaded = 1;
-          } else {
-            unsigned int howmany;
-            short totalbuf[SAMPLES_PER_FRAME];
+	      if(SAMPLERATE == 8000) {
 
-            howmany = len / 2 / 2;
-            for (i = 0; i < howmany; i++)
-              totalbuf[i] = p->audiobuf[i];
-
-            howmany = len / 2 / 2;
-            for (a = 0; a < howmany; a++) {
-              totalbuf[i] = srv_out[a];
-              i++;
-            }
+		      /****************************************************************/
+		      if (len > 0) {
+			      a = 0;
+			      for (i = 0; i < len / sizeof(short); i++) {
+				      srv_out[a] = srv_in[i];
+				      i++;
+				      a++;
+			      }
+
+			      if (!p->audiobuf_is_loaded) {
+				      for (i = 0; i < (len / sizeof(short)) / 2; i++) {
+					      p->audiobuf[i] = srv_out[i];
+				      }
+				      p->audiobuf_is_loaded = 1;
+			      } else {
+				      unsigned int howmany;
+				      short totalbuf[SAMPLES_PER_FRAME];
+
+				      howmany = len / 2 / 2;
+				      for (i = 0; i < howmany; i++)
+					      totalbuf[i] = p->audiobuf[i];
+
+				      howmany = len / 2 / 2;
+				      for (a = 0; a < howmany; a++) {
+					      totalbuf[i] = srv_out[a];
+					      i++;
+				      }
+
+				      howmany = len;
+
+				      switch_file_write(p->audiopipe[1], totalbuf, &howmany);
+				      p->audiobuf_is_loaded = 0;
+				      //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);
+			      }
+
+		      } else if (len == 0) {
+			      DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG);
+			      break;
+		      } else {
+			      ERRORA("len=%d\n", SKYPIAX_P_LOG, len);
+			      exit = 1;
+			      break;
+		      }
+		      /****************************************************************/
+	      } else if (SAMPLERATE == 16000) {
+
+
+		      /****************************************************************/
+		      if (len > 0) {
+			      if (len == SAMPLES_PER_FRAME * sizeof(short)) {
+				      unsigned int howmany;
+				      DEBUGA_SKYPE("SRV recv %d\n", SKYPIAX_P_LOG, len);
+				      howmany = len;
+
+				      switch_file_write(p->audiopipe[1], srv_in, &howmany);
+				      p->audiobuf_is_loaded = 0;
+				      DEBUGA_SKYPE("SRV PIPE WRITE=====> req=%d recv=%d to sent=%d sent=%d\n", SKYPIAX_P_LOG, sizeof(short)*SAMPLES_PER_FRAME, len, len, howmany);
+			      }else if (len == SAMPLES_PER_FRAME * sizeof(short) / 2) {
+				      unsigned int howmany;
+				      DEBUGA_SKYPE("SRV recv %d\n", SKYPIAX_P_LOG, len);
+				      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 = SAMPLES_PER_FRAME * sizeof(short);
+					      short totalbuf[SAMPLES_PER_FRAME];
+
+					      for (i = 0; i < (len / sizeof(short)); i++)
+						      totalbuf[i] = p->audiobuf[i];
+					      for (a = 0; a < (len / sizeof(short)); a++) {
+						      totalbuf[i] = srv_in[a];
+						      i++;
+					      }
+
+					      switch_file_write(p->audiopipe[1], totalbuf, &howmany);
+					      p->audiobuf_is_loaded = 0;
+					      DEBUGA_SKYPE("SRV PIPE WRITE=====> req=%d recv=%d to sent=%d sent=%d\n", SKYPIAX_P_LOG, SAMPLES_PER_FRAME * sizeof(short), len, SAMPLES_PER_FRAME * sizeof(short), howmany);
+				      }
+			      } else {
+
+			      ERRORA("len=%d\n", SKYPIAX_P_LOG, len);
+
+				}
+
+		      } else if (len == 0) {
+			      DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG);
+			      break;
+		      } else {
+			      ERRORA("len=%d\n", SKYPIAX_P_LOG, len);
+			      exit = 1;
+			      break;
+		      }
+		      /****************************************************************/
 
-            howmany = len;
 
-            switch_file_write(p->audiopipe[1], totalbuf, &howmany);
-            p->audiobuf_is_loaded = 0;
-            //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);
-          }
 
-        } else if (len == 0) {
-          DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG);
-          break;
-        } else {
-          ERRORA("len=%d\n", SKYPIAX_P_LOG, len);
-          exit = 1;
-          break;
-        }
+	      } else {
+
+		      ERRORA("SAMPLERATE can only be 8000 or 16000\n", SKYPIAX_P_LOG);
+	      }
       }
     }
 
@@ -286,9 +348,8 @@
       FD_SET(fdselect, &fs);
       to.tv_usec = 10000;
       to.tv_sec = 0;
-      //rt = select(fdselect + 1, &fs, NULL, NULL, &to);
-	  //switch_sleep(5000);
-      rt = 1;
+      rt = select(fdselect + 1, &fs, NULL, NULL, &to);
+      //rt = 1;
 	  if (rt > 0) {
 			  /*********************************************/
 		  if (SAMPLERATE == 8000) {
@@ -322,11 +383,11 @@
 			  switch_file_read(p->audioskypepipe[0], cli_in, &got);
 
 			  if (got > 0) {
-				  DEBUGA_SKYPE("CLI PIPE read %d\n", SKYPIAX_P_LOG, got);
+				  //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);
+				  //DEBUGA_SKYPE("CLI PIPE send %d\n", SKYPIAX_P_LOG, len);
 
 				  if (len == 0) {
 					  ERRORA("Skype server GONE\n", SKYPIAX_P_LOG);
@@ -404,7 +465,7 @@
 
     if (samples != SAMPLES_PER_FRAME * sizeof(short)) {
       if (samples)
-        DEBUGA_SKYPE("read=====> NOT GOOD samples=%d expected=%d\n", SKYPIAX_P_LOG,
+        DEBUGA_SKYPE("SRV PIPE READ=====> NOT GOOD samples=%d expected=%d\n", SKYPIAX_P_LOG,
                      samples, SAMPLES_PER_FRAME * sizeof(short));
       //do nothing
     } else {



More information about the Freeswitch-branches mailing list