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

FreeSWITCH SVN gmaruzz at freeswitch.org
Thu Dec 4 03:46:58 PST 2008


Author: gmaruzz
Date: Thu Dec  4 06:46:57 2008
New Revision: 10591

Log:
skypiax: now compiles and kind of works in win32, let see if works in linux

Modified:
   freeswitch/branches/gmaruzz/src/mod/endpoints/mod_skypiax/mod_skypiax.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  4 06:46:57 2008
@@ -34,8 +34,8 @@
  *
  */
 
-#undef WIN32_SKYPIAX
-#undef __CYGWIN__
+#define WIN32_SKYPIAX
+#define __CYGWIN__
 #define MOD_SKYPIAX
 #ifdef MOD_SKYPIAX
 
@@ -137,7 +137,7 @@
 struct AsteriskHandles {
   HWND win32_hInit_MainWindowHandle;
   HWND win32_hGlobal_SkypeAPIWindowHandle;
-  int fdesc[2];
+  switch_file_t *fdesc[2];
 };
 
 #endif //WIN32_SKYPIAX
@@ -349,11 +349,22 @@
     break;
   case WM_COPYDATA:
     if (win32_hGlobal_SkypeAPIWindowHandle == (HWND) uiParam) {
+        unsigned int howmany;
+        char msg_from_skype[2048];
+
 
       PCOPYDATASTRUCT poCopyData = (PCOPYDATASTRUCT) ulParam;
-      write(win32_AsteriskHandlesSkype->fdesc[1], (const char *) poCopyData->lpData,
-            strlen((const char *) poCopyData->lpData));
-      write(win32_AsteriskHandlesSkype->fdesc[1], "\0", 1);
+
+        memset(msg_from_skype, '\0', sizeof(msg_from_skype));
+      strncpy(msg_from_skype, (const char *) poCopyData->lpData, sizeof(msg_from_skype) -2);
+
+      //howmany = strlen((const char *) poCopyData->lpData);
+      howmany = strlen(msg_from_skype) + 1;
+      //switch_file_write(win32_AsteriskHandlesSkype->fdesc[1], (const char *) poCopyData->lpData, &howmany);
+      switch_file_write(win32_AsteriskHandlesSkype->fdesc[1], msg_from_skype, &howmany);
+        NOTICA("From Skype API: %s\n", SKYPIAX_P_LOG, (const char *) poCopyData->lpData);
+      //howmany=1;
+      //switch_file_write(win32_AsteriskHandlesSkype->fdesc[1], "\0", &howmany);
       lReturnCode = 1;
     }
     break;
@@ -480,7 +491,12 @@
   }
 #endif //0
 
-  win32_AsteriskHandlesSkype = (struct AsteriskHandles *) obj;
+  struct skypiax_interface *p;
+  p = obj;
+
+    switch_file_pipe_create_ex(&p->AsteriskHandlesAst.fdesc[0], &p->AsteriskHandlesAst.fdesc[1], 2, module_pool);
+
+  win32_AsteriskHandlesSkype = &p->AsteriskHandlesAst;
 
   win32_uiGlobal_MsgID_SkypeControlAPIAttach =
     RegisterWindowMessage("SkypeControlAPIAttach");
@@ -742,10 +758,22 @@
           p->audiobuf_is_loaded = 1;
         } else {
 			unsigned int howmany;
+            short totalbuf[320];
+
 			howmany = len/2;
-          switch_file_write(p->audiopipe[1], p->audiobuf, &howmany);
-			howmany = len/2;
-          switch_file_write(p->audiopipe[1], out, &howmany);
+            for(i=0; i<howmany; i++)
+                totalbuf[i] = p->audiobuf[i];
+
+            for(a=0; a<howmany; a++){
+                totalbuf[i] = out[a];
+                i++;
+            }
+
+            howmany = len;
+
+          switch_file_write(p->audiopipe[1], totalbuf, &howmany);
+			//howmany = len/2;
+          //switch_file_write(p->audiopipe[1], out, &howmany);
           p->audiobuf_is_loaded = 0;
           //DEBUGA_SOUND("read=====> req=%d recv=%d to sent=%d sent=%d\n", SKYPIAX_P_LOG, sizeof(short)*GG, len, (len*sizeof(short))/2, sent);
         }
@@ -761,13 +789,19 @@
   }
     }
     DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG);
+    //switch_sleep(1000000);
+
+#ifndef WIN32_SKYPIAX
     close(fd);
+#endif
     if (exit)
       break;
   }
 
   DEBUGA_SKYPE("server (I am it) GONE\n", SKYPIAX_P_LOG);
+#ifndef WIN32_SKYPIAX
   close(s);
+#endif
   if (option_debug > 10) {
     DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
   }
@@ -810,7 +844,9 @@
     if (option_debug > 10) {
       DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
     }
+#ifndef WIN32_SKYPIAX
   close(s);
+#endif
     return NULL;
   }
   DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
@@ -871,13 +907,17 @@
 
     }
     DEBUGA_SKYPE("Skype server GONE\n", SKYPIAX_P_LOG);
+#ifndef WIN32_SKYPIAX
     close(fd);
+#endif
     if (exit)
       break;
   }
 
   DEBUGA_SKYPE("client (I am it) GONE\n", SKYPIAX_P_LOG);
+#ifndef WIN32_SKYPIAX
   close(s);
+#endif
   if (option_debug > 10) {
     DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
   }
@@ -979,9 +1019,9 @@
 	  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 != 320) {
+  if (samples != SAMPLES_PER_FRAME * sizeof(short)) {
     DEBUGA_SKYPE("read=====> NOT GOOD samples=%d expected=%d\n", SKYPIAX_P_LOG, samples,
-                 320);
+                 SAMPLES_PER_FRAME * sizeof(short));
     switch_sleep(1000);
     //do nothing
   } else {
@@ -2084,6 +2124,8 @@
     DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
   }
     DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
+//switch_sleep(1000000);
+
   memset(read_from_pipe, 0, 4096);
   memset(messaggio, 0, 4096);
   memset(messaggio_2, 0, 4096);



More information about the Freeswitch-branches mailing list