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

FreeSWITCH SVN gmaruzz at freeswitch.org
Thu Feb 12 01:01:03 PST 2009


Author: gmaruzz
Date: Thu Feb 12 03:01:03 2009
New Revision: 11916

Log:
skypiax: cleaning...

Modified:
   freeswitch/branches/gmaruzz/mod_skypiax/mod_skypiax.c
   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	Thu Feb 12 03:01:03 2009
@@ -492,29 +492,15 @@
         *slash = '\0';
 
 	if (strncmp("ANY", interface_name,  strlen(interface_name)) == 0) {
+		/* we've been asked for the "ANY" interface, let's find the first idle interface */
 		DEBUGA_SKYPE("Finding one available skype interface\n",
 				SKYPIAX_P_LOG);
-		//find an available one, allowing call like originate skypiax/ANY/another_skypename
-
-		for (i = 0; !found && i < SKYPIAX_MAX_INTERFACES; i++) {
-			if (strlen(globals.SKYPIAX_INTERFACES[i].name)) {
-				int skype_state = 0;
-
-				tech_pvt = &globals.SKYPIAX_INTERFACES[i];
-				skype_state = tech_pvt->interface_state;
-				DEBUGA_SKYPE("skype interface: %d, name: %s, state: %d\n",
-						SKYPIAX_P_LOG,
-						i, globals.SKYPIAX_INTERFACES[i].name, skype_state);
-				if (SKYPIAX_STATE_DOWN == skype_state || 0 == skype_state) {
-					found=1;
-					break;
-				}
-			}
-		}
+		tech_pvt = find_available_skypiax_interface();
+		if(tech_pvt)
+			found=1;
 	}
-
-
         for (i = 0; !found && i < SKYPIAX_MAX_INTERFACES; i++) {
+		/* we've been asked for a normal interface name, or we have not found idle interfaces to serve as the "ANY" interface */
           if (strlen(globals.SKYPIAX_INTERFACES[i].name)
               &&
               (strncmp
@@ -528,7 +514,7 @@
 
             DEBUGA_SKYPE("globals.SKYPIAX_INTERFACES[%d].name=|||%s|||?\n", SKYPIAX_P_LOG,
                          i, globals.SKYPIAX_INTERFACES[i].name);
-            tech_pvt = &globals.SKYPIAX_INTERFACES[i];  //FIXME
+            tech_pvt = &globals.SKYPIAX_INTERFACES[i];  
             found = 1;
             break;
           }
@@ -895,7 +881,7 @@
         DEBUGA_SKYPE
           ("interface_id=%d globals.SKYPIAX_INTERFACES[interface_id].context=%s\n",
            SKYPIAX_P_LOG, interface_id, globals.SKYPIAX_INTERFACES[interface_id].context);
-        NOTICA("Trying to START interface_id=%d\n", SKYPIAX_P_LOG, interface_id);
+        NOTICA("STARTING interface_id=%d\n", SKYPIAX_P_LOG, interface_id);
 
         switch_threadattr_create(&skypiax_skypeapi_thread_attr, skypiax_module_pool);
         switch_threadattr_stacksize_set(skypiax_skypeapi_thread_attr,
@@ -917,7 +903,7 @@
                              &globals.SKYPIAX_INTERFACES[interface_id],
                              skypiax_module_pool);
 
-        switch_sleep(1000000);
+        switch_sleep(100000);
 
         skypiax_skypeaudio_init(&globals.SKYPIAX_INTERFACES[interface_id]);
 
@@ -1080,7 +1066,7 @@
               if (channel) {
                 switch_dtmf_t dtmf =
                   { (char) value[0], switch_core_default_dtmf_duration(0) };
-                NOTICA("received DTMF %c on channel %s\n", SKYPIAX_P_LOG, dtmf.digit,
+                DEBUGA_SKYPE("received DTMF %c on channel %s\n", SKYPIAX_P_LOG, dtmf.digit,
                              switch_channel_get_name(channel));
                 switch_mutex_lock(tech_pvt->flag_mutex);
 		//FIXME: why sometimes DTMFs from here do not seems to be get by FS?
@@ -1198,7 +1184,7 @@
 
 			tech_pvt = &globals.SKYPIAX_INTERFACES[i];
 			skype_state = tech_pvt->interface_state;
-			NOTICA("skype interface: %d, name: %s, state: %d\n",
+			DEBUGA_SKYPE("skype interface: %d, name: %s, state: %d\n",
 					SKYPIAX_P_LOG,
 					i, globals.SKYPIAX_INTERFACES[i].name, skype_state);
 			if (SKYPIAX_STATE_DOWN == skype_state || 0 == skype_state) {

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	Thu Feb 12 03:01:03 2009
@@ -185,7 +185,7 @@
             tech_pvt->interface_state = SKYPIAX_STATE_PRERING;
         }
         if (!strcasecmp(prop, "DTMF")) {
-          NOTICA("Call %s received a DTMF: %s\n", SKYPIAX_P_LOG, id, value);
+          DEBUGA_SKYPE("Call %s received a DTMF: %s\n", SKYPIAX_P_LOG, id, value);
           dtmf_received(tech_pvt, value);
         }
         if (!strcasecmp(prop, "FAILUREREASON")) {
@@ -224,7 +224,7 @@
                 skypiax_sleep(10000);
                 sprintf(msg_to_skype, "ALTER CALL %s ANSWER", id);
                 skypiax_skype_write(tech_pvt, msg_to_skype);
-                NOTICA("We answered a Skype RING on skype_call %s\n", SKYPIAX_P_LOG,
+                DEBUGA_SKYPE("We answered a Skype RING on skype_call %s\n", SKYPIAX_P_LOG,
                              id);
                 strncpy(tech_pvt->skype_call_id, id, sizeof(tech_pvt->skype_call_id) - 1);
               } else {
@@ -240,16 +240,16 @@
 		available_skypiax_interface = find_available_skypiax_interface();
 		if(available_skypiax_interface){
 			/* there is a skypiax interface idle, let's transfer the call to it */
-                NOTICA ("Let's transfer the skype_call %s to %s interface, because we are already in a skypiax call(%s)\n", SKYPIAX_P_LOG, tech_pvt->skype_call_id, available_skypiax_interface->name, id);
+                DEBUGA_SKYPE ("Let's transfer the skype_call %s to %s interface, because we are already in a skypiax call(%s)\n", SKYPIAX_P_LOG, tech_pvt->skype_call_id, available_skypiax_interface->name, id);
                 sprintf(msg_to_skype, "ALTER CALL %s TRANSFER %s", id, available_skypiax_interface->name);
 		} else{
 			/* no skypiax interfaces idle, let's refuse the call */
-                NOTICA ("Let's refuse the skype_call %s, because we are already in a skypiax call(%s) and no other skypiax interfaces are available\n", SKYPIAX_P_LOG, tech_pvt->skype_call_id, id);
+                DEBUGA_SKYPE ("Let's refuse the skype_call %s, because we are already in a skypiax call(%s) and no other skypiax interfaces are available\n", SKYPIAX_P_LOG, tech_pvt->skype_call_id, id);
                 sprintf(msg_to_skype, "ALTER CALL %s END HANGUP", id);
 		}
                 skypiax_skype_write(tech_pvt, msg_to_skype);
                 skypiax_sleep(10000);
-                NOTICA
+                DEBUGA_SKYPE
                   ("We (%s) have NOT answered a Skype RING on skype_call %s, because we are already in a skypiax call\n",
                    SKYPIAX_P_LOG, tech_pvt->skype_call_id, id);
               }
@@ -271,7 +271,7 @@
 	  } else if (!strcasecmp(value, "FINISHED")) {
 		  DEBUGA_SKYPE("skype_call %s now is DOWN\n", SKYPIAX_P_LOG, id);
 		  if(!strcasecmp(tech_pvt->skype_call_id, id)){
-			  NOTICA("skype_call %s is MY call, now I'm going DOWN\n", SKYPIAX_P_LOG, id);
+			  DEBUGA_SKYPE("skype_call %s is MY call, now I'm going DOWN\n", SKYPIAX_P_LOG, id);
 			  tech_pvt->skype_call_id[0] = '\0';
 			  if (tech_pvt->interface_state != SKYPIAX_STATE_HANGUP_REQUESTED) {
 				  //tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
@@ -280,7 +280,7 @@
 				  tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
 			  }	    
 		  }else {
-			  NOTICA("skype_call %s is NOT MY call, ignoring\n", SKYPIAX_P_LOG, id);
+			  DEBUGA_SKYPE("skype_call %s is NOT MY call, ignoring\n", SKYPIAX_P_LOG, id);
 		  }
 
 	  } else if (!strcasecmp(value, "CANCELLED")) {
@@ -353,7 +353,7 @@
 				  outbound_channel_answered(tech_pvt);
 			  }
 		  }else {
-			  NOTICA("I'm on %s, skype_call %s is NOT MY call, ignoring\n", SKYPIAX_P_LOG, tech_pvt->skype_call_id, id);
+			  DEBUGA_SKYPE("I'm on %s, skype_call %s is NOT MY call, ignoring\n", SKYPIAX_P_LOG, tech_pvt->skype_call_id, id);
 		  }
 	  } else {
             WARNINGA("skype_call: %s, STATUS: %s is not recognized\n", SKYPIAX_P_LOG, id,
@@ -905,7 +905,7 @@
     DEBUGA_SKYPE("got CREATE\n", SKYPIAX_P_LOG);
     break;
   case WM_DESTROY:
-    NOTICA("got DESTROY\n", SKYPIAX_P_LOG);
+    DEBUGA_SKYPE("got DESTROY\n", SKYPIAX_P_LOG);
     tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle = NULL;
     PostQuitMessage(0);
     break;
@@ -924,7 +924,7 @@
       howmany =
         skypiax_pipe_write(tech_pvt->SkypiaxHandles.fdesc[1], (short *) msg_from_skype,
                            howmany);
-      //NOTICA("From Skype API: %s\n", SKYPIAX_P_LOG, msg_from_skype);
+      //DEBUGA_SKYPE("From Skype API: %s\n", SKYPIAX_P_LOG, msg_from_skype);
       lReturnCode = 1;
     }
     break;



More information about the Freeswitch-svn mailing list