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

FreeSWITCH SVN gmaruzz at freeswitch.org
Sat Dec 27 01:43:44 PST 2008


Author: gmaruzz
Date: Sat Dec 27 04:43:44 2008
New Revision: 10967

Log:
skypiax: windows, no more warnings

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	Sat Dec 27 04:43:44 2008
@@ -576,11 +576,11 @@
 
         if (session) {
           channel = switch_core_session_get_channel(session);
-          DEBUGA_SKYPE("before channel_on_hangup\n", SKYPIAX_P_LOG);
+          //DEBUGA_SKYPE("before channel_on_hangup\n", SKYPIAX_P_LOG);
 
           if (channel) {
             switch_channel_hangup(channel, SWITCH_CAUSE_NORMAL_CLEARING);
-            DEBUGA_SKYPE("after channel_on_hangup\n", SKYPIAX_P_LOG);
+            //DEBUGA_SKYPE("after channel_on_hangup\n", SKYPIAX_P_LOG);
           }
         }
       }
@@ -604,7 +604,7 @@
 
   switch_mutex_init(&globals.mutex, SWITCH_MUTEX_NESTED, skypiax_module_pool);
   if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
-    switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
+    ERRORA("open of %s failed\n", SKYPIAX_P_LOG, cf);
     return SWITCH_STATUS_TERM;
   }
 
@@ -809,8 +809,13 @@
         } else {
           switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].name, "N/A");
         }
+#ifdef WIN32
+		globals.SKYPIAX_INTERFACES[interface_id].tcp_cli_port = (unsigned short)atoi(tcp_cli_port);
+		globals.SKYPIAX_INTERFACES[interface_id].tcp_srv_port = (unsigned short)atoi(tcp_srv_port);
+#else /* WIN32 */
 		globals.SKYPIAX_INTERFACES[interface_id].tcp_cli_port = atoi(tcp_cli_port);
 		globals.SKYPIAX_INTERFACES[interface_id].tcp_srv_port = atoi(tcp_srv_port);
+#endif /* WIN32 */
         //switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].tcp_cli_port, tcp_cli_port);
         //switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].tcp_srv_port, tcp_srv_port);
         switch_set_string(globals.SKYPIAX_INTERFACES[interface_id].X11_display, X11_display);

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	Sat Dec 27 04:43:44 2008
@@ -45,8 +45,14 @@
 //FIXME include?
 #endif //WIN32
 
-#define SAMPLES_PER_FRAME 320
+#ifdef _MSC_VER
+//Windows macro  for FD_SET includes a warning C4127: conditional expression is constant
+#pragma warning(push)
+#pragma warning(disable:4127)
+#endif
+
 #define SAMPLERATE_SKYPIAX 16000
+#define SAMPLES_PER_FRAME SAMPLERATE_SKYPIAX/50
 //#define SKYPIAX_SVN_VERSION "SVN 123456"
 #define SKYPIAX_SVN_VERSION SWITCH_VERSION_REVISION
 
@@ -157,8 +163,13 @@
   char hold_music[256];
   char type[256];
   char X11_display[256];
+#ifdef WIN32
+  unsigned short tcp_cli_port;
+  unsigned short tcp_srv_port;
+#else
   int tcp_cli_port;
   int tcp_srv_port;
+#endif
   struct AsteriskHandles AsteriskHandlesAst;
 
   int interface_state;          /*!< \brief 'state' of the interface (channel) */

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	Sat Dec 27 04:43:44 2008
@@ -30,7 +30,6 @@
                                                           void *obj)
 {
   struct skypiax_interface *p = obj;
-  short srv_out[SAMPLES_PER_FRAME / 2];
   int s;
 #ifdef WIN32
   unsigned int len;
@@ -38,14 +37,17 @@
   unsigned int a;
   int sin_size;
   unsigned int fd;
+  short srv_in[SAMPLES_PER_FRAME];
+  short srv_out[SAMPLES_PER_FRAME / 2];
 #else
   int len;
   int i;
   int a;
   unsigned int sin_size;
   int fd;
-#endif /* WIN32 */
   short srv_in[SAMPLES_PER_FRAME];
+  short srv_out[SAMPLES_PER_FRAME / 2];
+#endif /* WIN32 */
   struct sockaddr_in my_addr;
   struct sockaddr_in remote_addr;
   int exit = 0;
@@ -58,7 +60,7 @@
   memset(&my_addr, 0, sizeof(my_addr));
   my_addr.sin_family = AF_INET;
   my_addr.sin_addr.s_addr = htonl(0x7f000001);  /* use the localhost */
-  my_addr.sin_port = htons(p->tcp_srv_port);   //FIXME configurable!
+  my_addr.sin_port = htons(p->tcp_srv_port);   
 
   if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
     ERRORA("socket Error\n", SKYPIAX_P_LOG);
@@ -76,6 +78,7 @@
     return NULL;
   }
   DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG);
+    ERRORA("sizeof(short)=%d, sizeof(char)=%d\n", SKYPIAX_P_LOG, sizeof(short), sizeof(char));
 
   listen(s, 6);
 
@@ -111,8 +114,11 @@
 	  //rt=0;
       if (rt > 0) {
 
-	      //len = recv(fd, srv_in, sizeof(short) * SAMPLES_PER_FRAME, 0);
-	      len = recv(fd, srv_in, 320, 0); //seems that Skype only sends 320 bytes at time
+#ifdef WIN32
+	      len = recv(fd, (char *)srv_in, 320, 0); //seems that Skype only sends 320 bytes at time
+#else /* WIN32 */
+	      len = recv(fd, (char *)srv_in, 320, 0); //seems that Skype only sends 320 bytes at time
+#endif /* WIN32 */
 
 		  if ((SAMPLERATE_SKYPIAX - 8000) == 0) {
 
@@ -254,7 +260,7 @@
       break;
   }
 
-  WARNINGA("server (I am it) GONE\n", SKYPIAX_P_LOG);
+  DEBUGA_SKYPE("server (I am it) GONE\n", SKYPIAX_P_LOG);
 #ifndef WIN32
   close(s);
 #else
@@ -274,20 +280,22 @@
   struct sockaddr_in my_addr;
   struct sockaddr_in remote_addr;
   unsigned int got;
-  short cli_in[SAMPLES_PER_FRAME];
-  short cli_out[SAMPLES_PER_FRAME * 2];
 #ifdef WIN32
   unsigned int len;
   unsigned int i;
   unsigned int a;
   int sin_size;
   unsigned int fd;
+  short cli_out[SAMPLES_PER_FRAME * 2];
+  short cli_in[SAMPLES_PER_FRAME];
 #else
   int len;
   int i;
   int a;
   unsigned int sin_size;
   int fd;
+  short cli_out[SAMPLES_PER_FRAME * 2];
+  short cli_in[SAMPLES_PER_FRAME];
 #endif /* WIN32 */
 
   if (option_debug > 10) {
@@ -357,7 +365,7 @@
 			  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);
 				  a = 0;
 				  for (i = 0; i < got / sizeof(short); i++) {
 					  cli_out[a] = cli_in[i];
@@ -366,8 +374,12 @@
 					  a++;
 				  }
 
+#ifdef WIN32
+				  len = send(fd, (char *)cli_out, got * 2, 0);
+#else /* WIN32 */
 				  len = send(fd, cli_out, got * 2, 0);
-				  DEBUGA_SKYPE("CLI PIPE send %d\n", SKYPIAX_P_LOG, len);
+#endif /* WIN32 */
+				  //DEBUGA_SKYPE("CLI PIPE send %d\n", SKYPIAX_P_LOG, len);
 
 				  if (len == 0) {
 					  ERRORA("Skype server GONE\n", SKYPIAX_P_LOG);
@@ -389,7 +401,11 @@
 				  if(got != SAMPLES_PER_FRAME * sizeof(short) )
 					ERRORA("CLI PIPE read %d\n", SKYPIAX_P_LOG, got);
 
+#ifdef WIN32
+				  len = send(fd, (char *)cli_in, got, 0);
+#else /* WIN32 */
 				  len = send(fd, cli_in, got, 0);
+#endif /* WIN32 */
 
 				  if(len != got )
 					ERRORA("CLI PIPE send %d\n", SKYPIAX_P_LOG, len);
@@ -408,7 +424,7 @@
 	  }
 
     }
-    ERRORA("Skype server GONE\n", SKYPIAX_P_LOG);
+    DEBUGA_SKYPE("Skype server GONE\n", SKYPIAX_P_LOG);
 #ifndef WIN32
     close(fd);
 #else
@@ -417,7 +433,7 @@
     break;
   }
 
-  WARNINGA("client (I am it) GONE\n", SKYPIAX_P_LOG);
+  DEBUGA_SKYPE("client (I am it) GONE\n", SKYPIAX_P_LOG);
 #ifndef WIN32
   close(s);
 #else
@@ -575,10 +591,9 @@
 	  p = ( struct skypiax_interface *)GetWindowLong(hWindow, GWL_USERDATA);
   switch (uiMessage) {
   case WM_CREATE:
-    NOTICA("got CREATE\n", SKYPIAX_P_LOG);
 	  p=( struct skypiax_interface *)((LPCREATESTRUCT)ulParam)->lpCreateParams;
 	  SetWindowLong(hWindow, GWL_USERDATA, (LONG)p);
-    NOTICA("got CREATE\n", SKYPIAX_P_LOG);
+    DEBUGA_SKYPE("got CREATE\n", SKYPIAX_P_LOG);
     break;
   case WM_DESTROY:
     NOTICA("got DESTROY\n", SKYPIAX_P_LOG);
@@ -598,7 +613,7 @@
 
       howmany = strlen(msg_from_skype) + 1;
       switch_file_write(p->AsteriskHandlesAst.fdesc[1], msg_from_skype, &howmany);
-      NOTICA("From Skype API: %s\n", SKYPIAX_P_LOG, (const char *) poCopyData->lpData);
+      //NOTICA("From Skype API: %s\n", SKYPIAX_P_LOG, (const char *) poCopyData->lpData);
       lReturnCode = 1;
     }
     break;
@@ -610,25 +625,31 @@
 	if(!p->AsteriskHandlesAst.api_connected){
         NOTICA("\n\n\tConnected to Skype API!\n", SKYPIAX_P_LOG);
         p->AsteriskHandlesAst.win32_hGlobal_SkypeAPIWindowHandle = (HWND) uiParam;
-        switch_sleep(5000);
+        //switch_sleep(5000);
         p->AsteriskHandlesAst.win32_hGlobal_SkypeAPIWindowHandle =
           p->AsteriskHandlesAst.win32_hGlobal_SkypeAPIWindowHandle;
 	}
         break;
       case SKYPECONTROLAPI_ATTACH_PENDING_AUTHORIZATION:
         WARNINGA
-          ("\n\n\tIf I do not immediately connect to Skype API,\n\tplease give the Skype client authorization to be connected \n\tby Asterisk and to not ask you again.\n\n",
+          ("\n\n\tIf I do not (almost) immediately connect to Skype API,\n\tplease give the Skype client authorization to be connected \n\tby Asterisk and to not ask you again.\n\n",
            SKYPIAX_P_LOG);
+        switch_sleep(5000);
+	if(!p->AsteriskHandlesAst.api_connected){
+        SendMessage
+            (HWND_BROADCAST, p->AsteriskHandlesAst.win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
+             (WPARAM) p->AsteriskHandlesAst.win32_hInit_MainWindowHandle, 0);
+	}
         break;
       case SKYPECONTROLAPI_ATTACH_REFUSED:
         ERRORA("Skype client refused to be connected by Skypiax!\n", SKYPIAX_P_LOG);
         break;
       case SKYPECONTROLAPI_ATTACH_NOT_AVAILABLE:
-        ERRORA("Skype API not available\n", SKYPIAX_P_LOG);
+        ERRORA("Skype API not (yet?) available\n", SKYPIAX_P_LOG);
         break;
       case SKYPECONTROLAPI_ATTACH_API_AVAILABLE:
         DEBUGA_SKYPE("Skype API available\n", SKYPIAX_P_LOG);
-
+        switch_sleep(5000);
 	if(!p->AsteriskHandlesAst.api_connected){
         SendMessage
             (HWND_BROADCAST, p->AsteriskHandlesAst.win32_uiGlobal_MsgID_SkypeControlAPIDiscover,
@@ -741,7 +762,7 @@
     RegisterWindowMessage("SkypeControlAPIDiscover");
 
   LaunchSkype(p);
-	switch_sleep(1000000);
+	switch_sleep(2000000);
 
   if (p->AsteriskHandlesAst.win32_uiGlobal_MsgID_SkypeControlAPIAttach != 0
       && p->AsteriskHandlesAst.win32_uiGlobal_MsgID_SkypeControlAPIDiscover != 0) {
@@ -1044,6 +1065,13 @@
 #ifdef WIN32
   static char acInputRow[1024];
   COPYDATASTRUCT oCopyData;
+#else /* WIN32 */
+  struct AsteriskHandles *AsteriskHandlesAst;
+#endif /* WIN32 */
+
+    DEBUGA_SKYPE("SENDING: |||%s||||\n", SKYPIAX_P_LOG, msg_to_skype);
+
+#ifdef WIN32
 
   if (option_debug > 100) {
     DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
@@ -1073,16 +1101,12 @@
     }
   }
 #else /* WIN32 */
-  struct AsteriskHandles *AsteriskHandlesAst;
 
   if (option_debug > 100) {
     DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
   }
   AsteriskHandlesAst = &p->AsteriskHandlesAst;
 
-  if (option_debug > 101) {
-    DEBUGA_SKYPE("SENDING: |||%s||||\n", SKYPIAX_P_LOG, msg_to_skype);
-  }
 
   if (!skypiax_skype_send_message(AsteriskHandlesAst, msg_to_skype)) {
     ERRORA
@@ -1216,7 +1240,7 @@
 
           if (!strcasecmp(id, p->skype_user)) {
 		  p->AsteriskHandlesAst.api_connected = 1;
-            DEBUGA_SKYPE ("Skype MSG: messaggio: %s, currentuserhandle: %s, cuh: %s, skype_user: %s!\n", SKYPIAX_P_LOG, messaggio, obj, id, p->skype_user);
+            //DEBUGA_SKYPE ("Skype MSG: messaggio: %s, currentuserhandle: %s, cuh: %s, skype_user: %s!\n", SKYPIAX_P_LOG, messaggio, obj, id, p->skype_user);
           }
           }
 



More information about the Freeswitch-svn mailing list