[Freeswitch-svn] [commit] r11517 - freeswitch/branches/gmaruzz/mod_skypiax

FreeSWITCH SVN gmaruzz at freeswitch.org
Tue Jan 27 13:59:01 PST 2009


Author: gmaruzz
Date: Tue Jan 27 15:59:00 2009
New Revision: 11517

Log:
skypiax: moving switch specific things out of skypiax_protocol.c

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

Modified: freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c
==============================================================================
--- freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c	(original)
+++ freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c	Tue Jan 27 15:59:00 2009
@@ -293,7 +293,7 @@
   tech_pvt->read_frame.flags = SFF_NONE;
   *frame = NULL;
 
-  if (skypiax_skypeaudio_read(tech_pvt) != SWITCH_STATUS_SUCCESS) {
+  if (!skypiax_skypeaudio_read(tech_pvt)) {
 
     ERRORA("skypiax_skypeaudio_read ERROR\n", SKYPIAX_P_LOG);
 
@@ -861,7 +861,7 @@
                                         SWITCH_THREAD_STACKSIZE);
         switch_thread_create(&globals.SKYPIAX_INTERFACES[interface_id].
                              skypiax_skypeapi_thread, skypiax_skypeapi_thread_attr,
-                             skypiax_skypeapi_thread_func,
+                             skypiax_do_skypeapi_thread,
                              &globals.SKYPIAX_INTERFACES[interface_id],
                              skypiax_module_pool);
 
@@ -1013,6 +1013,23 @@
   return SWITCH_STATUS_SUCCESS;
 }
 
+void *SWITCH_THREAD_FUNC skypiax_do_tcp_srv_thread(switch_thread_t * thread,
+                                                          void *obj)
+{
+	return skypiax_do_tcp_srv_thread_func(obj);
+}
+void *SWITCH_THREAD_FUNC skypiax_do_tcp_cli_thread(switch_thread_t * thread,
+                                                          void *obj)
+{
+	return skypiax_do_tcp_cli_thread_func(obj);
+}
+void *SWITCH_THREAD_FUNC skypiax_do_skypeapi_thread(switch_thread_t * thread,
+                                                          void *obj)
+{
+	return skypiax_do_skypeapi_thread_func(obj);
+}
+
+
 /* For Emacs:
  * Local Variables:
  * mode:c

Modified: freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h
==============================================================================
--- freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h	(original)
+++ freeswitch/branches/gmaruzz/mod_skypiax/skypiax.h	Tue Jan 27 15:59:00 2009
@@ -237,7 +237,7 @@
 void *SWITCH_THREAD_FUNC skypiax_skypeapi_thread_func(switch_thread_t * thread,
                                                       void *obj);
 void skypiax_tech_init(private_t * tech_pvt, switch_core_session_t * session);
-switch_status_t skypiax_skypeaudio_read(private_t * tech_pvt);
+int skypiax_skypeaudio_read(private_t * tech_pvt);
 int skypiax_skypeaudio_init(private_t * tech_pvt);
 int skypiax_skype_write(private_t * tech_pvt, char *msg_to_skype);
 int skypiax_skype_read(private_t * tech_pvt);
@@ -245,3 +245,13 @@
 int skypiax_skype_call(private_t * tech_pvt, char *idest, int timeout,
                        switch_core_session_t * session);
 int skypiax_skype_senddigit(private_t * tech_pvt, char digit);
+
+#define skypiax_sleep switch_sleep
+void * skypiax_do_tcp_srv_thread_func(void *obj);
+void *SWITCH_THREAD_FUNC skypiax_do_tcp_srv_thread(switch_thread_t * thread, void *obj);
+
+void * skypiax_do_tcp_cli_thread_func(void *obj);
+void *SWITCH_THREAD_FUNC skypiax_do_tcp_cli_thread(switch_thread_t * thread, void *obj);
+
+void * skypiax_do_skypeapi_thread_func(void *obj);
+void *SWITCH_THREAD_FUNC skypiax_do_skypeapi_thread(switch_thread_t * thread, void *obj);

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	Tue Jan 27 15:59:00 2009
@@ -12,8 +12,7 @@
 #endif /* WIN32 */
 /*************************************/
 
-static void *SWITCH_THREAD_FUNC skypiax_do_tcp_srv_thread(switch_thread_t * thread,
-                                                          void *obj)
+void * skypiax_do_tcp_srv_thread_func(void *obj)
 {
   private_t *tech_pvt = obj;
   int s;
@@ -155,7 +154,7 @@
 
           } else if (len == 0) {
             DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG);
-            switch_sleep(1000);
+            skypiax_sleep(1000);
           } else {
             ERRORA("len=%d\n", SKYPIAX_P_LOG, len);
             exit = 1;
@@ -205,7 +204,7 @@
 
           } else if (len == 0) {
             DEBUGA_SKYPE("Skype client GONE\n", SKYPIAX_P_LOG);
-            switch_sleep(1000);
+            skypiax_sleep(1000);
           } else {
             ERRORA("SRV len=%d\n", SKYPIAX_P_LOG, len);
             exit = 1;
@@ -218,7 +217,7 @@
       } else {
         if (rt)
           ERRORA("SRV rt=%d\n", SKYPIAX_P_LOG, rt);
-        switch_sleep(10000);
+        skypiax_sleep(10000);
       }
     }
 #ifdef WIN32
@@ -263,8 +262,7 @@
   }
   return NULL;
 }
-static void *SWITCH_THREAD_FUNC skypiax_do_tcp_cli_thread(switch_thread_t * thread,
-                                                          void *obj)
+void * skypiax_do_tcp_cli_thread_func(void *obj)
 {
   private_t *tech_pvt = obj;
   int s;
@@ -383,7 +381,7 @@
               break;
             }
           } else {
-            switch_sleep(1000);
+            skypiax_sleep(1000);
             ERRORA("CLI PIPE give us: %u\n", SKYPIAX_P_LOG, got);
           }
         } else if (SAMPLERATE_SKYPIAX == 16000) {
@@ -412,13 +410,13 @@
               break;
             }
           } else {
-            switch_sleep(1000);
+            skypiax_sleep(1000);
             ERRORA("CLI PIPE give us: %u\n", SKYPIAX_P_LOG, got);
           }
         }
 
       } else {
-        switch_sleep(1000);
+        skypiax_sleep(1000);
         if (rt)
           ERRORA("select give us: %u\n", SKYPIAX_P_LOG, rt);
       }
@@ -473,7 +471,7 @@
   return 0;
 }
 
-switch_status_t skypiax_skypeaudio_read(private_t * tech_pvt)
+int skypiax_skypeaudio_read(private_t * tech_pvt)
 {
   //private_t *p;
   unsigned int samples;
@@ -508,7 +506,7 @@
       //if (samples)
       //ERRORA("SRV PIPE READ=====> NOT GOOD samples=%u expected=%lu\n", SKYPIAX_P_LOG, samples, SAMPLES_PER_FRAME * sizeof(short));
       assert(samples == SAMPLES_PER_FRAME * sizeof(short)); //do a crash, please
-      //do nothing
+      return 0;
     } else {
       /* A real frame */
       tech_pvt->read_frame.datalen = samples;
@@ -516,8 +514,9 @@
   } else {
     if (rt)
       DEBUGA_SKYPE("select returned %d\n", SKYPIAX_P_LOG, rt);
+    //do nothing
   }
-  return SWITCH_STATUS_SUCCESS;
+  return 1;
 }
 
 #ifdef WIN32
@@ -619,7 +618,7 @@
           DEBUGA_SKYPE
             ("\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);
+          skypiax_sleep(5000);
           if (!tech_pvt->SkypiaxHandles.api_connected) {
             SendMessage(HWND_BROADCAST,
                         tech_pvt->SkypiaxHandles.
@@ -636,7 +635,7 @@
           break;
         case SKYPECONTROLAPI_ATTACH_API_AVAILABLE:
           DEBUGA_SKYPE("Skype API available\n", SKYPIAX_P_LOG);
-          switch_sleep(5000);
+          skypiax_sleep(5000);
           if (!tech_pvt->SkypiaxHandles.api_connected) {
             SendMessage(HWND_BROADCAST,
                         tech_pvt->SkypiaxHandles.
@@ -731,7 +730,7 @@
 
 DWORD win32_dwThreadId;
 
-void *SWITCH_THREAD_FUNC skypiax_skypeapi_thread_func(switch_thread_t * thread, void *obj)
+void * skypiax_do_skypeapi_thread_func(void *obj)
 {
   /*  create window class */
   /*    create dummy/hidden window for processing messages */
@@ -751,7 +750,7 @@
   tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover =
     RegisterWindowMessage("SkypeControlAPIDiscover");
 
-  switch_sleep(2000000);
+  skypiax_sleep(2000000);
 
   if (tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIAttach != 0
       && tech_pvt->SkypiaxHandles.win32_uiGlobal_MsgID_SkypeControlAPIDiscover != 0) {
@@ -909,10 +908,10 @@
     DEBUGA_SKYPE("NOT destroyed disp\n", SKYPIAX_P_LOG);
   }
   DEBUGA_SKYPE("OUT destroyed disp\n", SKYPIAX_P_LOG);
-  switch_sleep(1000);
+  skypiax_sleep(1000);
 }
 
-void *SWITCH_THREAD_FUNC skypiax_skypeapi_thread_func(switch_thread_t * thread, void *obj)
+void * skypiax_do_skypeapi_thread_func(void *obj)
 {
 
   private_t *tech_pvt = obj;
@@ -1156,9 +1155,9 @@
             DEBUGA_SKYPE
               ("If I don't connect immediately, please give the Skype client authorization to be connected by Skypiax (and to not ask you again)\n",
                SKYPIAX_P_LOG);
-            switch_sleep(1000000);
+            skypiax_sleep(1000000);
             skypiax_skype_write(tech_pvt, "PROTOCOL 6");
-            switch_sleep(10000);
+            skypiax_sleep(10000);
             return 0;
           }
 
@@ -1400,15 +1399,15 @@
                     tech_pvt->interface_state = SKYPIAX_STATE_RING;
                     /* no owner, no active call, let's answer */
                     skypiax_skype_write(tech_pvt, "SET AGC OFF");
-                    switch_sleep(10000);
+                    skypiax_sleep(10000);
                     skypiax_skype_write(tech_pvt, "SET AEC OFF");
-                    switch_sleep(10000);
+                    skypiax_sleep(10000);
                     sprintf(msg_to_skype, "GET CALL %s PARTNER_DISPNAME", id);
                     skypiax_skype_write(tech_pvt, msg_to_skype);
-                    switch_sleep(10000);
+                    skypiax_sleep(10000);
                     sprintf(msg_to_skype, "GET CALL %s PARTNER_HANDLE", id);
                     skypiax_skype_write(tech_pvt, msg_to_skype);
-                    switch_sleep(10000);
+                    skypiax_sleep(10000);
                     sprintf(msg_to_skype, "ALTER CALL %s ANSWER", id);
                     skypiax_skype_write(tech_pvt, msg_to_skype);
                     if (option_debug)
@@ -1420,7 +1419,7 @@
                     /* we're owned, we're in a call, let's refuse */
                     sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", id);
                     skypiax_skype_write(tech_pvt, msg_to_skype);
-                    switch_sleep(10000);
+                    skypiax_sleep(10000);
                     DEBUGA_SKYPE
                       ("We have NOT answered a Skype RING on skype_call %s, because we are already in a skypiax call\n",
                        SKYPIAX_P_LOG, id);
@@ -1552,15 +1551,15 @@
                                        skypiax_do_tcp_cli_thread, tech_pvt,
                                        skypiax_module_pool);
                   DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
-                  switch_sleep(100000);
+                  skypiax_sleep(100000);
                   sprintf(msg_to_skype, "ALTER CALL %s SET_OUTPUT PORT=\"%d\"", id,
                           tech_pvt->tcp_srv_port);
                   skypiax_skype_write(tech_pvt, msg_to_skype);
-                  switch_sleep(100000);
+                  skypiax_sleep(100000);
                   sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id,
                           tech_pvt->tcp_cli_port);
                   skypiax_skype_write(tech_pvt, msg_to_skype);
-                  switch_sleep(100000);
+                  skypiax_sleep(100000);
                 }
 
                 tech_pvt->skype_callflow = SKYPIAX_STATE_UP;
@@ -1698,16 +1697,16 @@
   if (option_debug > 10) {
     DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
   }
-  switch_sleep(5000);
+  skypiax_sleep(5000);
 
   rdest = strchr(idest, '/');
   *rdest++ = '\0';
 
   DEBUGA_SKYPE("Calling Skype, rdest is: %s\n", SKYPIAX_P_LOG, rdest);
   skypiax_skype_write(tech_pvt, "SET AGC OFF");
-  switch_sleep(10000);
+  skypiax_sleep(10000);
   skypiax_skype_write(tech_pvt, "SET AEC OFF");
-  switch_sleep(10000);
+  skypiax_sleep(10000);
 
   sprintf(msg_to_skype, "CALL %s", rdest);
   if (skypiax_skype_write(tech_pvt, msg_to_skype) < 0) {



More information about the Freeswitch-svn mailing list