[Freeswitch-trunk] [commit] r12831 - freeswitch/trunk/src/mod/endpoints/mod_skypiax

FreeSWITCH SVN gmaruzz at freeswitch.org
Sun Mar 29 02:17:59 PDT 2009


Author: gmaruzz
Date: Sun Mar 29 04:17:58 2009
New Revision: 12831

Log:
skypiax: FARMING modifications

Modified:
   freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c

Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c	Sun Mar 29 04:17:58 2009
@@ -1,5 +1,7 @@
 #include "skypiax.h"
 
+#define FARMING
+
 #ifdef ASTERISK
 #define skypiax_sleep usleep
 #define skypiax_strncpy strncpy
@@ -216,6 +218,7 @@
                 tech_pvt->skype_callflow = CALLFLOW_STATUS_RINGING;
                 tech_pvt->interface_state = SKYPIAX_STATE_RING;
                 /* no owner, no active call, let's answer */
+#ifndef FARMING
                 skypiax_signaling_write(tech_pvt, "SET AGC OFF");
                 skypiax_sleep(10000);
                 skypiax_signaling_write(tech_pvt, "SET AEC OFF");
@@ -226,6 +229,7 @@
                 sprintf(msg_to_skype, "GET CALL %s PARTNER_HANDLE", id);
                 skypiax_signaling_write(tech_pvt, msg_to_skype);
                 skypiax_sleep(10000);
+#endif //FARMING
                 sprintf(msg_to_skype, "ALTER CALL %s ANSWER", id);
                 skypiax_signaling_write(tech_pvt, msg_to_skype);
                 DEBUGA_SKYPE("We answered a Skype RING on skype_call %s\n", SKYPIAX_P_LOG,
@@ -278,11 +282,12 @@
             tech_pvt->interface_state = SKYPIAX_STATE_DIALING;
             NOTICA("Our remote party in skype_call %s is EARLYMEDIA\n", SKYPIAX_P_LOG,
                    id);
+                start_audio_threads(tech_pvt);
+          	skypiax_sleep(1000);
             sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id,
                     tech_pvt->tcp_cli_port);
             skypiax_signaling_write(tech_pvt, msg_to_skype);
-            start_audio_threads(tech_pvt);
-            sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id,
+                sprintf(msg_to_skype, "#output ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id,
                     tech_pvt->tcp_srv_port);
             skypiax_signaling_write(tech_pvt, msg_to_skype);
 
@@ -365,11 +370,12 @@
               if (tech_pvt->skype_callflow != CALLFLOW_STATUS_EARLYMEDIA) {
                 tech_pvt->skype_callflow = CALLFLOW_STATUS_INPROGRESS;
                 tech_pvt->interface_state = SKYPIAX_STATE_UP;
+                start_audio_threads(tech_pvt);
+          	skypiax_sleep(1000);
                 sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id,
                         tech_pvt->tcp_cli_port);
                 skypiax_signaling_write(tech_pvt, msg_to_skype);
-                start_audio_threads(tech_pvt);
-                sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id,
+                sprintf(msg_to_skype, "#output ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id,
                         tech_pvt->tcp_srv_port);
                 skypiax_signaling_write(tech_pvt, msg_to_skype);
               }
@@ -440,7 +446,11 @@
 
   memset(&my_addr, 0, sizeof(my_addr));
   my_addr.sin_family = AF_INET;
+#ifdef FARMING
+  //my_addr.sin_addr.s_addr = htonl(0x7f000001);  /* default on all addresses  */
+#else // FARMING
   my_addr.sin_addr.s_addr = htonl(0x7f000001);  /* use the localhost */
+#endif // FARMING
   my_addr.sin_port = htons(tech_pvt->tcp_srv_port);
 
   if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
@@ -458,7 +468,7 @@
 
   sin_size = sizeof(remote_addr);
   while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) {
-    DEBUGA_SKYPE("ACCEPTED\n", SKYPIAX_P_LOG);
+    DEBUGA_SKYPE("ACCEPTED here I send you %d\n", SKYPIAX_P_LOG, tech_pvt->tcp_srv_port);
     if (!running)
       break;
     while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN
@@ -484,6 +494,9 @@
       rt = select(fdselect + 1, &fs, NULL, NULL, &to);
       if (rt > 0) {
 
+#ifdef FARMING
+	switch_sleep(500); //seems that reconnecting through a proxy leads to half the packet size, bizarrely, 158-162, never 160 :-)
+#endif // FARMING
         len = recv(fd, (char *) srv_in, 320, 0);    //seems that Skype only sends 320 bytes at time
 
         if (len == 320) {
@@ -535,9 +548,7 @@
         } else if (len == 0) {
           skypiax_sleep(1000);
         } else {
-          ERRORA("len=%d\n", SKYPIAX_P_LOG, len);
-          exit = 1;
-          break;
+          ERRORA("len=%d, expected 320\n", SKYPIAX_P_LOG, len);
         }
 
       } else {
@@ -591,7 +602,11 @@
 
   memset(&my_addr, 0, sizeof(my_addr));
   my_addr.sin_family = AF_INET;
+#ifdef FARMING
+  //my_addr.sin_addr.s_addr = htonl(0x7f000001);  /* default on all addresses */
+#else // FARMING
   my_addr.sin_addr.s_addr = htonl(0x7f000001);  /* use the localhost */
+#endif // FARMING
   my_addr.sin_port = htons(tech_pvt->tcp_cli_port);
 
   if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
@@ -610,7 +625,7 @@
 
   sin_size = sizeof(remote_addr);
   while ((fd = accept(s, (struct sockaddr *) &remote_addr, &sin_size)) > 0) {
-    DEBUGA_SKYPE("ACCEPTED\n", SKYPIAX_P_LOG);
+    DEBUGA_SKYPE("ACCEPTED here you send me %d\n", SKYPIAX_P_LOG, tech_pvt->tcp_cli_port);
     if (!running)
       break;
     while (tech_pvt->interface_state != SKYPIAX_STATE_DOWN
@@ -1165,6 +1180,14 @@
   return (xerror != BadValue) && (xerror != BadWindow);
 }
 
+#ifdef FARMING
+int skypiax_send_message(struct SkypiaxHandles *SkypiaxHandles, const char *message_P)
+{
+        printf("%s\n", message_P);
+        fflush(stdout);
+  return 1;
+}
+#else// FARMING
 int skypiax_send_message(struct SkypiaxHandles *SkypiaxHandles, const char *message_P)
 {
 
@@ -1212,6 +1235,8 @@
 
   return 1;
 }
+
+#endif// FARMING
 int skypiax_signaling_write(private_t * tech_pvt, char *msg_to_skype)
 {
   struct SkypiaxHandles *SkypiaxHandles;
@@ -1289,6 +1314,48 @@
   skypiax_sleep(1000);
 }
 
+#ifdef FARMING
+void *skypiax_do_skypeapi_thread_func(void *obj)
+{
+
+  private_t *tech_pvt = obj;
+  struct SkypiaxHandles *SkypiaxHandles;
+
+  if (!strlen(tech_pvt->X11_display))
+    strcpy(tech_pvt->X11_display, getenv("DISPLAY"));
+
+  if (!tech_pvt->tcp_srv_port)
+    tech_pvt->tcp_srv_port = 10160;
+
+  if (!tech_pvt->tcp_cli_port)
+    tech_pvt->tcp_cli_port = 10161;
+
+  if (pipe(tech_pvt->SkypiaxHandles.fdesc)) {
+    fcntl(tech_pvt->SkypiaxHandles.fdesc[0], F_SETFL, O_NONBLOCK);
+    fcntl(tech_pvt->SkypiaxHandles.fdesc[1], F_SETFL, O_NONBLOCK);
+  }
+  SkypiaxHandles = &tech_pvt->SkypiaxHandles;
+
+
+  SkypiaxHandles->api_connected = 1;
+
+    char *b;
+          unsigned int howmany;
+
+    while (1) {
+      char s[17000];
+
+      memset(s, '\0', 17000);
+      b=fgets(s, sizeof(s) - 1, stdin);
+      s[strlen(s) - 1] = '\0';
+          howmany = strlen(s) + 1;
+
+          howmany = write(SkypiaxHandles->fdesc[1], &s, howmany);
+
+    }
+}
+
+#else //FARMING
 void *skypiax_do_skypeapi_thread_func(void *obj)
 {
 
@@ -1409,4 +1476,5 @@
   return NULL;
 
 }
+#endif //FARMING
 #endif // WIN32



More information about the Freeswitch-trunk mailing list