[Freeswitch-branches] [commit] r11688 - freeswitch/branches/gmaruzz/mod_skypiax

FreeSWITCH SVN gmaruzz at freeswitch.org
Sun Feb 8 05:49:11 PST 2009


Author: gmaruzz
Date: Sun Feb  8 07:49:11 2009
New Revision: 11688

Log:
skypiax: cleaning skypiax_protocol.c

Modified:
   freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c

Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c
==============================================================================
--- freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c	(original)
+++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax_protocol.c	Sun Feb  8 07:49:11 2009
@@ -116,10 +116,99 @@
       to.tv_sec = 0;
 
       rt = select(fdselect + 1, &fs, NULL, NULL, &to);
+#ifndef NOTDEF
       if (rt > 0) {
 
         len = recv(fd, (char *) srv_in, 320, 0);    //seems that Skype only sends 320 bytes at time
 
+          if (len == 320) {
+
+        if (SAMPLERATE_SKYPIAX == 8000) {
+
+            a = 0;
+            for (i = 0; i < len / sizeof(short); i++) {
+              srv_out[a] = srv_in[i];
+              i++;
+              a++;
+            }
+
+            if (!tech_pvt->audiobuf_is_loaded) {
+              for (i = 0; i < (len / sizeof(short)) / 2; i++) {
+                tech_pvt->audiobuf[i] = srv_out[i];
+              }
+              tech_pvt->audiobuf_is_loaded = 1;
+            } else {
+              unsigned int howmany;
+
+              howmany = len / 2 / 2;
+              for (i = 0; i < howmany; i++)
+                totalbuf[i] = tech_pvt->audiobuf[i];
+
+              howmany = len / 2 / 2;
+              for (a = 0; a < howmany; a++) {
+                totalbuf[i] = srv_out[a];
+                i++;
+              }
+
+              howmany = len;
+
+              howmany = skypiax_file_write(tech_pvt->audiopipe[1], totalbuf, howmany);
+              tech_pvt->audiobuf_is_loaded = 0;
+            }
+
+	} else if (SAMPLERATE_SKYPIAX == 16000) {
+
+              if (!tech_pvt->audiobuf_is_loaded) {
+                for (i = 0; i < (len / sizeof(short)); i++) {
+                  tech_pvt->audiobuf[i] = srv_in[i];
+                }
+                tech_pvt->audiobuf_is_loaded = 1;
+              } else {
+                unsigned int howmany = SAMPLES_PER_FRAME * sizeof(short);
+
+                for (i = 0; i < (len / sizeof(short)); i++)
+                  totalbuf[i] = tech_pvt->audiobuf[i];
+                for (a = 0; a < (len / sizeof(short)); a++) {
+                  totalbuf[i] = srv_in[a];
+                  i++;
+                }
+
+                howmany = skypiax_file_write(tech_pvt->audiopipe[1], totalbuf, howmany);
+                tech_pvt->audiobuf_is_loaded = 0;
+              }
+
+        } else {
+          ERRORA("SAMPLERATE_SKYPIAX can only be 8000 or 16000\n", SKYPIAX_P_LOG);
+        }
+
+          } else if (len == 0) {
+            DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG);
+            skypiax_sleep(1000);
+          } else {
+            ERRORA("len=%d\n", SKYPIAX_P_LOG, len);
+            exit = 1;
+            break;
+          }
+
+
+
+
+
+
+
+      } else {
+        if (rt)
+          ERRORA("SRV rt=%d\n", SKYPIAX_P_LOG, rt);
+        skypiax_sleep(10000);
+      }
+#endif // NOTDEF
+
+#ifdef NOTDEF
+      if (rt > 0) {
+
+        len = recv(fd, (char *) srv_in, 320, 0);    //seems that Skype only sends 320 bytes at time
+
+
         if (SAMPLERATE_SKYPIAX == 8000) {
 
           if (len == 320) {
@@ -200,30 +289,8 @@
           ERRORA("SRV rt=%d\n", SKYPIAX_P_LOG, rt);
         skypiax_sleep(10000);
       }
+#endif // NOTDEF
     }
-#if 0
-#if defined(WIN32) && !defined(__CYGWIN__) 
-    kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
-    skypiax_file_write(tech_pvt->audiopipe[1], kill_cli_buff, &kill_cli_size);
-    kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
-    skypiax_file_write(tech_pvt->audioskypepipe[1], kill_cli_buff, &kill_cli_size);
-    tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
-    kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
-    skypiax_file_write(tech_pvt->audiopipe[1], kill_cli_buff, &kill_cli_size);
-    kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
-    skypiax_file_write(tech_pvt->audioskypepipe[1], kill_cli_buff, &kill_cli_size);
-#else /* WIN32 */
-    kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
-    len = write(tech_pvt->audiopipe[1], kill_cli_buff, kill_cli_size);
-    kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
-    len = write(tech_pvt->audioskypepipe[1], kill_cli_buff, kill_cli_size);
-    tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
-    kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
-    len = write(tech_pvt->audiopipe[1], kill_cli_buff, kill_cli_size);
-    kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
-    len = write(tech_pvt->audioskypepipe[1], kill_cli_buff, kill_cli_size);
-#endif /* WIN32 */
-#endif
 
     kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
     len = skypiax_file_write(tech_pvt->audiopipe[1], kill_cli_buff, kill_cli_size);
@@ -235,8 +302,6 @@
     kill_cli_size = SAMPLES_PER_FRAME * sizeof(short);
     len = skypiax_file_write(tech_pvt->audioskypepipe[1], kill_cli_buff, kill_cli_size);
 
-
-
     DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG);
 #if defined(WIN32) && !defined(__CYGWIN__) 
     closesocket(fd);



More information about the Freeswitch-branches mailing list