<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[Freeswitch-trunk][14533] </title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<div id="header">FreeSWITCH Subversion</div>
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://fisheye.freeswitch.org/changelog/FreeSWITCH?cs=14533">14533</a></dd>
<dt>Author</dt> <dd>gmaruzz</dd>
<dt>Date</dt> <dd>2009-08-15 10:37:44 -0500 (Sat, 15 Aug 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre>skypiax: more stability, no dangling channels, <a href="http://jira.freeswitch.org/browse/MODSKYPIAX-42">MODSKYPIAX-42</a>, added 'sk list' statistics (thanks Seven Du) <a href="http://jira.freeswitch.org/browse/MODENDP-236">MODENDP-236</a></pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunksrcmodendpointsmod_skypiaxmod_skypiaxc">freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_skypiaxskypiaxh">freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax.h</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_skypiaxskypiax_protocolc">freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunksrcmodendpointsmod_skypiaxmod_skypiaxc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c (14532 => 14533)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c        2009-08-15 14:32:33 UTC (rev 14532)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c        2009-08-15 15:37:44 UTC (rev 14533)
</span><span class="lines">@@ -96,6 +96,51 @@
</span><span class="cx"> #define SOFT_RELOAD 1
</span><span class="cx"> /* END: Changes heres */
</span><span class="cx"> 
</span><ins>+char *interface_status[] = {  /* should match SKYPIAX_STATE_xxx in skypiax.h */
+        &quot;IDLE&quot;,
+        &quot;DOWN&quot;,
+        &quot;RING&quot;,
+        &quot;DIALING&quot;,
+        &quot;BUSY&quot;,
+        &quot;UP&quot;,
+        &quot;RINGING&quot;,
+        &quot;PRERING&quot;,
+        &quot;DOUBLE&quot;,
+        &quot;SELECTD&quot;,
+        &quot;HANG_RQ&quot;,
+        &quot;PREANSW&quot;
+};
+char *skype_callflow[] = {  /* should match CALLFLOW_XXX in skypiax.h */
+&quot;CALL_IDLE&quot;,
+&quot;CALL_DOWN&quot;,
+&quot;INCOMING_RNG&quot;,
+&quot;CALL_DIALING&quot;,
+&quot;CALL_LINEBUSY&quot;,
+&quot;CALL_ACTIVE&quot;,
+&quot;INCOMING_HNG&quot;,
+&quot;CALL_RLEASD&quot;,
+&quot;CALL_NOCARR&quot;,
+&quot;CALL_INFLUX&quot;,
+&quot;CALL_INCOMING&quot;,
+&quot;CALL_FAILED&quot;,
+&quot;CALL_NOSRVC&quot;,
+&quot;CALL_OUTRESTR&quot;,
+&quot;CALL_SECFAIL&quot;,
+&quot;CALL_NOANSWER&quot;,
+&quot;STATUS_FNSHED&quot;,
+&quot;STATUS_CANCLED&quot;,
+&quot;STATUS_FAILED&quot;,
+&quot;STATUS_REFUSED&quot;,
+&quot;STATUS_RINGING&quot;,
+&quot;STATUS_INPROGRS&quot;,
+&quot;STATUS_UNPLACD&quot;,
+&quot;STATUS_ROUTING&quot;,
+&quot;STATUS_EARLYMD&quot;,
+&quot;INCOMING_CLID&quot;,
+&quot;STATUS_RMTEHOLD&quot;
+};
+
+
</ins><span class="cx"> static struct {
</span><span class="cx">         int debug;
</span><span class="cx">         char *ip;
</span><span class="lines">@@ -140,6 +185,7 @@
</span><span class="cx"> static switch_status_t channel_on_destroy(switch_core_session_t *session);
</span><span class="cx"> static switch_status_t channel_on_routing(switch_core_session_t *session);
</span><span class="cx"> static switch_status_t channel_on_exchange_media(switch_core_session_t *session);
</span><ins>+static switch_status_t channel_on_consume_media(switch_core_session_t *session);
</ins><span class="cx"> static switch_status_t channel_on_soft_execute(switch_core_session_t *session);
</span><span class="cx"> static switch_call_cause_t channel_outgoing_channel(switch_core_session_t *session,
</span><span class="cx">                                                                                                         switch_event_t *var_event,
</span><span class="lines">@@ -375,7 +421,7 @@
</span><span class="cx"> 
</span><span class="cx">         channel = switch_core_session_get_channel(session);
</span><span class="cx">         switch_assert(channel != NULL);
</span><del>-        DEBUGA_SKYPE(&quot;%s CHANNEL INIT\n&quot;, SKYPIAX_P_LOG, switch_channel_get_name(channel));
</del><ins>+        //ERRORA(&quot;%s CHANNEL INIT\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;name);
</ins><span class="cx">         switch_set_flag(tech_pvt, TFLAG_IO);
</span><span class="cx"> 
</span><span class="cx">         /* Move channel's state machine to ROUTING. This means the call is trying
</span><span class="lines">@@ -387,6 +433,7 @@
</span><span class="cx">         globals.calls++;
</span><span class="cx"> 
</span><span class="cx">         switch_mutex_unlock(globals.mutex);
</span><ins>+                DEBUGA_SKYPE(&quot;%s CHANNEL INIT %s\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;name, switch_core_session_get_uuid(session));
</ins><span class="cx"> 
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="lines">@@ -397,7 +444,10 @@
</span><span class="cx"> 
</span><span class="cx">         tech_pvt = switch_core_session_get_private(session);
</span><span class="cx"> 
</span><ins>+
</ins><span class="cx">         if (tech_pvt) {
</span><ins>+                DEBUGA_SKYPE(&quot;%s CHANNEL DESTROY %s\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;name, switch_core_session_get_uuid(session));
+
</ins><span class="cx">                 if (switch_core_codec_ready(&amp;tech_pvt-&gt;read_codec)) {
</span><span class="cx">                         switch_core_codec_destroy(&amp;tech_pvt-&gt;read_codec);
</span><span class="cx">                 }
</span><span class="lines">@@ -406,7 +456,13 @@
</span><span class="cx">                         switch_core_codec_destroy(&amp;tech_pvt-&gt;write_codec);
</span><span class="cx">                 }
</span><span class="cx">                 *tech_pvt-&gt;session_uuid_str = '\0';
</span><ins>+                tech_pvt-&gt;interface_state = SKYPIAX_STATE_IDLE;
+                if(tech_pvt-&gt;skype_callflow == CALLFLOW_STATUS_FINISHED){
+                        tech_pvt-&gt;skype_callflow = CALLFLOW_CALL_IDLE;
+                }
</ins><span class="cx">                 switch_core_session_set_private(session, NULL);
</span><ins>+        } else {
+                DEBUGA_SKYPE(&quot;!!!!!!NO tech_pvt!!!! CHANNEL DESTROY %s\n&quot;, SKYPIAX_P_LOG, switch_core_session_get_uuid(session));
</ins><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -425,6 +481,14 @@
</span><span class="cx">         tech_pvt = switch_core_session_get_private(session);
</span><span class="cx">         switch_assert(tech_pvt != NULL);
</span><span class="cx"> 
</span><ins>+         if (!switch_channel_test_flag(channel, CF_ANSWERED)) {
+                 if (switch_channel_direction(channel) == SWITCH_CALL_DIRECTION_OUTBOUND) {
+                         tech_pvt-&gt;ob_failed_calls++;
+                 } else {
+                         tech_pvt-&gt;ib_failed_calls++;
+                 }
+         }
+
</ins><span class="cx">         switch_clear_flag(tech_pvt, TFLAG_IO);
</span><span class="cx">         switch_clear_flag(tech_pvt, TFLAG_VOICE);
</span><span class="cx">         //switch_set_flag(tech_pvt, TFLAG_HANGUP);
</span><span class="lines">@@ -437,12 +501,17 @@
</span><span class="cx">         }
</span><span class="cx">         //memset(tech_pvt-&gt;session_uuid_str, '\0', sizeof(tech_pvt-&gt;session_uuid_str));
</span><span class="cx">         //*tech_pvt-&gt;session_uuid_str = '\0';
</span><del>-        DEBUGA_SKYPE(&quot;%s CHANNEL HANGUP\n&quot;, SKYPIAX_P_LOG, switch_channel_get_name(channel));
</del><ins>+        DEBUGA_SKYPE(&quot;%s CHANNEL HANGUP\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;name);
</ins><span class="cx">         switch_mutex_lock(globals.mutex);
</span><span class="cx">         globals.calls--;
</span><span class="cx">         if (globals.calls &lt; 0) {
</span><span class="cx">                 globals.calls = 0;
</span><span class="cx">         }
</span><ins>+
+                tech_pvt-&gt;interface_state = SKYPIAX_STATE_IDLE;
+                if(tech_pvt-&gt;skype_callflow == CALLFLOW_STATUS_FINISHED){
+                        tech_pvt-&gt;skype_callflow = CALLFLOW_CALL_IDLE;
+                }
</ins><span class="cx">         switch_mutex_unlock(globals.mutex);
</span><span class="cx"> 
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="lines">@@ -459,7 +528,7 @@
</span><span class="cx">         tech_pvt = switch_core_session_get_private(session);
</span><span class="cx">         switch_assert(tech_pvt != NULL);
</span><span class="cx"> 
</span><del>-        DEBUGA_SKYPE(&quot;%s CHANNEL ROUTING\n&quot;, SKYPIAX_P_LOG, switch_channel_get_name(channel));
</del><ins>+        DEBUGA_SKYPE(&quot;%s CHANNEL ROUTING\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;name);
</ins><span class="cx"> 
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="lines">@@ -476,7 +545,7 @@
</span><span class="cx">         tech_pvt = switch_core_session_get_private(session);
</span><span class="cx">         switch_assert(tech_pvt != NULL);
</span><span class="cx"> 
</span><del>-        DEBUGA_SKYPE(&quot;%s CHANNEL EXECUTE\n&quot;, SKYPIAX_P_LOG, switch_channel_get_name(channel));
</del><ins>+        DEBUGA_SKYPE(&quot;%s CHANNEL EXECUTE\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;name);
</ins><span class="cx"> 
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="lines">@@ -492,6 +561,7 @@
</span><span class="cx">         tech_pvt = switch_core_session_get_private(session);
</span><span class="cx">         switch_assert(tech_pvt != NULL);
</span><span class="cx"> 
</span><ins>+        DEBUGA_SKYPE(&quot;%s CHANNEL KILL_CHANNEL\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;name);
</ins><span class="cx">         switch (sig) {
</span><span class="cx">         case SWITCH_SIG_KILL:
</span><span class="cx">                 DEBUGA_SKYPE(&quot;%s CHANNEL got SWITCH_SIG_KILL\n&quot;, SKYPIAX_P_LOG, switch_channel_get_name(channel));
</span><span class="lines">@@ -514,18 +584,30 @@
</span><span class="cx"> 
</span><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><ins>+static switch_status_t channel_on_consume_media(switch_core_session_t *session)
+{
+        private_t *tech_pvt = NULL;
</ins><span class="cx"> 
</span><ins>+        tech_pvt = switch_core_session_get_private(session);
+
+        DEBUGA_SKYPE(&quot;%s CHANNEL CONSUME_MEDIA\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;name);
+        return SWITCH_STATUS_SUCCESS;
+}
+
+
</ins><span class="cx"> static switch_status_t channel_on_exchange_media(switch_core_session_t *session)
</span><span class="cx"> {
</span><span class="cx">         private_t *tech_pvt = NULL;
</span><del>-        DEBUGA_SKYPE(&quot;CHANNEL LOOPBACK\n&quot;, SKYPIAX_P_LOG);
</del><ins>+        tech_pvt = switch_core_session_get_private(session);
+        DEBUGA_SKYPE(&quot;%s CHANNEL EXCHANGE_MEDIA\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;name);
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> static switch_status_t channel_on_soft_execute(switch_core_session_t *session)
</span><span class="cx"> {
</span><span class="cx">         private_t *tech_pvt = NULL;
</span><del>-        DEBUGA_SKYPE(&quot;CHANNEL TRANSMIT\n&quot;, SKYPIAX_P_LOG);
</del><ins>+        tech_pvt = switch_core_session_get_private(session);
+        DEBUGA_SKYPE(&quot;%s CHANNEL SOFT_EXECUTE\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;name);
</ins><span class="cx">         return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -534,6 +616,7 @@
</span><span class="cx">         private_t *tech_pvt = switch_core_session_get_private(session);
</span><span class="cx">         switch_assert(tech_pvt != NULL);
</span><span class="cx"> 
</span><ins>+        DEBUGA_SKYPE(&quot;%s CHANNEL SEND_DTMF\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;name);
</ins><span class="cx">         DEBUGA_SKYPE(&quot;DTMF: %c\n&quot;, SKYPIAX_P_LOG, dtmf-&gt;digit);
</span><span class="cx"> 
</span><span class="cx">         skypiax_senddigit(tech_pvt, dtmf-&gt;digit);
</span><span class="lines">@@ -718,7 +801,7 @@
</span><span class="cx">         /*.on_hangup */ channel_on_hangup,
</span><span class="cx">         /*.on_exchange_media */ channel_on_exchange_media,
</span><span class="cx">         /*.on_soft_execute */ channel_on_soft_execute,
</span><del>-        /*.on_consume_media */ NULL,
</del><ins>+        /*.on_consume_media */ channel_on_consume_media,
</ins><span class="cx">         /*.on_hibernate */ NULL,
</span><span class="cx">         /*.on_reset */ NULL,
</span><span class="cx">         /*.on_park */ NULL,
</span><span class="lines">@@ -749,6 +832,7 @@
</span><span class="cx">                 int found = 0;
</span><span class="cx">                 char interface_name[256];
</span><span class="cx"> 
</span><ins>+                DEBUGA_SKYPE(&quot;1 SESSION_REQUEST %s\n&quot;, SKYPIAX_P_LOG, switch_core_session_get_uuid(*new_session));
</ins><span class="cx">                 switch_core_session_add_stream(*new_session, NULL);
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -783,6 +867,7 @@
</span><span class="cx">                                                 DEBUGA_SKYPE
</span><span class="cx">                                                         (&quot;globals.SKYPIAX_INTERFACES[%d].name=|||%s||| session_uuid_str=|||%s||| is BUSY\n&quot;,
</span><span class="cx">                                                          SKYPIAX_P_LOG, i, globals.SKYPIAX_INTERFACES[i].name, globals.SKYPIAX_INTERFACES[i].session_uuid_str);
</span><ins>+                                                DEBUGA_SKYPE(&quot;1 SESSION_DESTROY %s\n&quot;, SKYPIAX_P_LOG, switch_core_session_get_uuid(*new_session));
</ins><span class="cx">                                                 switch_core_session_destroy(new_session);
</span><span class="cx">                                                 switch_mutex_unlock(globals.mutex);
</span><span class="cx">                                                 return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
</span><span class="lines">@@ -804,6 +889,7 @@
</span><span class="cx"> 
</span><span class="cx">                 if (!found) {
</span><span class="cx">                         DEBUGA_SKYPE(&quot;Doh! no available interface for |||%s|||?\n&quot;, SKYPIAX_P_LOG, interface_name);
</span><ins>+                        DEBUGA_SKYPE(&quot;2 SESSION_DESTROY %s\n&quot;, SKYPIAX_P_LOG, switch_core_session_get_uuid(*new_session));
</ins><span class="cx">                         switch_core_session_destroy(new_session);
</span><span class="cx">                         switch_mutex_unlock(globals.mutex);
</span><span class="cx">                         //return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
</span><span class="lines">@@ -840,6 +926,8 @@
</span><span class="cx">                         switch_mutex_unlock(globals.mutex);
</span><span class="cx">                         return SWITCH_CAUSE_DESTINATION_OUT_OF_ORDER;
</span><span class="cx">                 }
</span><ins>+    
+        tech_pvt-&gt;ob_calls++;
</ins><span class="cx"> 
</span><span class="cx">                 rdest = strchr(caller_profile-&gt;destination_number, '/');
</span><span class="cx">                 *rdest++ = '\0';
</span><span class="lines">@@ -904,14 +992,21 @@
</span><span class="cx">                                 } else {
</span><span class="cx">                                         DEBUGA_SKYPE(&quot;no session\n&quot;, SKYPIAX_P_LOG);
</span><span class="cx">                                 }
</span><ins>+        switch_mutex_lock(globals.mutex);
</ins><span class="cx">                                 tech_pvt-&gt;interface_state = SKYPIAX_STATE_DOWN;
</span><span class="cx">                                 *tech_pvt-&gt;session_uuid_str = '\0';
</span><span class="cx">                                 *tech_pvt-&gt;skype_call_id = '\0';
</span><ins>+        switch_mutex_unlock(globals.mutex);
</ins><span class="cx"> 
</span><span class="cx">                                 //ERRORA(&quot;LET'S WAIT\n&quot;, SKYPIAX_P_LOG);
</span><span class="cx">                                 switch_sleep(300000);        //0.3 sec
</span><span class="cx">                                 //ERRORA(&quot;WAIT'S OVER\n&quot;, SKYPIAX_P_LOG);
</span><del>-                                tech_pvt-&gt;skype_callflow = CALLFLOW_STATUS_FINISHED;
</del><ins>+                                //tech_pvt-&gt;skype_callflow = CALLFLOW_STATUS_FINISHED;
+                                //usleep(30000);        //0.03 sec
+        switch_mutex_lock(globals.mutex);
+                                tech_pvt-&gt;skype_callflow = CALLFLOW_CALL_IDLE;
+                                tech_pvt-&gt;interface_state = SKYPIAX_STATE_IDLE;
+        switch_mutex_unlock(globals.mutex);
</ins><span class="cx">                         } else {
</span><span class="cx">                                 ERRORA(&quot;no tech_pvt?\n&quot;, SKYPIAX_P_LOG);
</span><span class="cx">                         }
</span><span class="lines">@@ -1461,6 +1556,7 @@
</span><span class="cx">         switch_channel_t *channel = NULL;
</span><span class="cx"> 
</span><span class="cx">         if ((session = switch_core_session_request(skypiax_endpoint_interface, SWITCH_CALL_DIRECTION_INBOUND, NULL)) != 0) {
</span><ins>+                DEBUGA_SKYPE(&quot;2 SESSION_REQUEST %s\n&quot;, SKYPIAX_P_LOG, switch_core_session_get_uuid(session));
</ins><span class="cx">                 switch_core_session_add_stream(session, NULL);
</span><span class="cx">                 channel = switch_core_session_get_channel(session);
</span><span class="cx">                 if (!channel) {
</span><span class="lines">@@ -1668,20 +1764,27 @@
</span><span class="cx">                 int i;
</span><span class="cx">                 char next_flag_char = ' ';
</span><span class="cx"> 
</span><ins>+        stream-&gt;write_function(stream, &quot;F ID\t    Name    \tIB (F/T)    OB (F/T)\tState\tCallFlw\t\tUUID\n&quot;);
+        stream-&gt;write_function(stream, &quot;= ====\t  ========  \t=======     =======\t======\t============\t======\n&quot;);
+
</ins><span class="cx">                 for (i = 0; i &lt; SKYPIAX_MAX_INTERFACES; i++) {
</span><span class="cx">                         next_flag_char = i == globals.next_interface ? '*' : ' ';
</span><span class="cx"> 
</span><span class="cx">                         if (strlen(globals.SKYPIAX_INTERFACES[i].name)) {
</span><del>-                                if (strlen(globals.SKYPIAX_INTERFACES[i].session_uuid_str)) {
-                                        stream-&gt;write_function(stream,
-                                                                                   &quot;%c\t%d\t[%s]\tBUSY, session_uuid_str=|||%s|||\n&quot;,
-                                                                                   next_flag_char, i, globals.SKYPIAX_INTERFACES[i].name, globals.SKYPIAX_INTERFACES[i].session_uuid_str);
-                                } else {
-                                        stream-&gt;write_function(stream, &quot;%c\t%d\t[%s]\tIDLE\n&quot;, next_flag_char, i, globals.SKYPIAX_INTERFACES[i].name);
-                                }
-                        } else if (argc &gt; 1 &amp;&amp; !strcasecmp(argv[1], &quot;full&quot;)) {
</del><ins>+                                stream-&gt;write_function(stream,
+                                               &quot;%c %d\t[%s]\t%3ld/%ld\t%6ld/%ld\t%s\t%s\t%s\n&quot;,
+                                               next_flag_char,
+                                               i, globals.SKYPIAX_INTERFACES[i].name,
+                                               globals.SKYPIAX_INTERFACES[i].ib_failed_calls,
+                                               globals.SKYPIAX_INTERFACES[i].ib_calls,
+                                               globals.SKYPIAX_INTERFACES[i].ob_failed_calls,
+                                               globals.SKYPIAX_INTERFACES[i].ob_calls,
+                                               interface_status[globals.SKYPIAX_INTERFACES[i].interface_state],
+                                               skype_callflow[globals.SKYPIAX_INTERFACES[i].skype_callflow],
+                                               globals.SKYPIAX_INTERFACES[i].session_uuid_str);
+                        } else if(argc &gt; 1 &amp;&amp; !strcasecmp(argv[1], &quot;full&quot;)) {
</ins><span class="cx">                                 stream-&gt;write_function(stream, &quot;%c\t%d\n&quot;, next_flag_char, i);
</span><del>-                        }
</del><ins>+                        }                                                                      
</ins><span class="cx"> 
</span><span class="cx">                 }
</span><span class="cx">                 stream-&gt;write_function(stream, &quot;\nTotal: %d\n&quot;, globals.real_interfaces - 1);
</span><span class="lines">@@ -1847,9 +1950,12 @@
</span><span class="cx">         if (tech_pvt &amp;&amp; tech_pvt-&gt;skype_call_id &amp;&amp; !strlen(tech_pvt-&gt;skype_call_id)) {
</span><span class="cx">                 /* we are not inside an active call */
</span><span class="cx"> 
</span><ins>+                tech_pvt-&gt;ib_calls++;
+
</ins><span class="cx">                 sprintf(msg_to_skype, &quot;GET CALL %s PARTNER_DISPNAME&quot;, id);
</span><span class="cx">                 skypiax_signaling_write(tech_pvt, msg_to_skype);
</span><span class="cx">                 switch_sleep(10000);
</span><ins>+                tech_pvt-&gt;interface_state = SKYPIAX_STATE_PREANSWER;
</ins><span class="cx">                 sprintf(msg_to_skype, &quot;ALTER CALL %s ANSWER&quot;, id);
</span><span class="cx">                 skypiax_signaling_write(tech_pvt, msg_to_skype);
</span><span class="cx">                 DEBUGA_SKYPE(&quot;We answered a Skype RING on skype_call %s\n&quot;, SKYPIAX_P_LOG, id);
</span><span class="lines">@@ -1912,7 +2018,7 @@
</span><span class="cx"> 
</span><span class="cx">         if (!tech_pvt || !tech_pvt-&gt;skype_call_id || !strlen(tech_pvt-&gt;skype_call_id)) {
</span><span class="cx">                 /* we are not inside an active call */
</span><del>-                ERRORA(&quot;We're NO MORE in a call now %s\n&quot;, SKYPIAX_P_LOG, (tech_pvt &amp;&amp; tech_pvt-&gt;skype_call_id) ? tech_pvt-&gt;skype_call_id : &quot;&quot;);
</del><ins>+                DEBUGA_SKYPE(&quot;We're NO MORE in a call now %s\n&quot;, SKYPIAX_P_LOG, (tech_pvt &amp;&amp; tech_pvt-&gt;skype_call_id) ? tech_pvt-&gt;skype_call_id : &quot;&quot;);
</ins><span class="cx">                 switch_mutex_unlock(globals.mutex);
</span><span class="cx"> 
</span><span class="cx">         } else {
</span><span class="lines">@@ -1966,8 +2072,15 @@
</span><span class="cx">                         DEBUGA_SKYPE
</span><span class="cx">                                 (&quot;Let's transfer the skype_call %s to %s interface (with skype_user: %s), because we are already in a skypiax call(%s)\n&quot;,
</span><span class="cx">                                  SKYPIAX_P_LOG, tech_pvt-&gt;skype_call_id, available_skypiax_interface-&gt;name, available_skypiax_interface-&gt;skype_user, id);
</span><ins>+
+                        //FIXME why this? the inbound call will come, eventually, on that other interface
+                        //available_skypiax_interface-&gt;ib_calls++;
+
</ins><span class="cx">                         sprintf(msg_to_skype, &quot;ALTER CALL %s TRANSFER %s&quot;, id, available_skypiax_interface-&gt;skype_user);
</span><span class="cx">                         skypiax_signaling_write(tech_pvt, msg_to_skype);
</span><ins>+                        if(tech_pvt-&gt;interface_state == SKYPIAX_STATE_SELECTED) {
+                                tech_pvt-&gt;interface_state = SKYPIAX_STATE_IDLE; //we marked it SKYPIAX_STATE_SELECTED just in case it has to make an outbound call
+                        }
</ins><span class="cx">                 } else {
</span><span class="cx">                         /* no skypiax interfaces idle, do nothing */
</span><span class="cx">                         DEBUGA_SKYPE
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_skypiaxskypiaxh"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax.h (14532 => 14533)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax.h        2009-08-15 14:32:33 UTC (rev 14532)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax.h        2009-08-15 15:37:44 UTC (rev 14533)
</span><span class="lines">@@ -91,45 +91,47 @@
</span><span class="cx"> #define SKYPIAX_CONTROL_ANSWER                2
</span><span class="cx"> 
</span><span class="cx"> /*********************************/
</span><del>-#define                SKYPIAX_STATE_DOWN                1
-#define                SKYPIAX_STATE_RING                2
-#define                SKYPIAX_STATE_DIALING        3
-#define                SKYPIAX_STATE_BUSY                4
-#define                SKYPIAX_STATE_UP                5
-#define                SKYPIAX_STATE_RINGING        6
-#define                SKYPIAX_STATE_PRERING        7
-#define                SKYPIAX_STATE_ERROR_DOUBLE_CALL        8
-#define                SKYPIAX_STATE_SELECTED        9
</del><ins>+#define                SKYPIAX_STATE_IDLE                                        0
+#define                SKYPIAX_STATE_DOWN                                        1
+#define                SKYPIAX_STATE_RING                                        2
+#define                SKYPIAX_STATE_DIALING                                3
+#define                SKYPIAX_STATE_BUSY                                        4
+#define                SKYPIAX_STATE_UP                                        5
+#define                SKYPIAX_STATE_RINGING                                6
+#define                SKYPIAX_STATE_PRERING                                7
+#define                SKYPIAX_STATE_ERROR_DOUBLE_CALL                8
+#define                SKYPIAX_STATE_SELECTED                                9
+#define         SKYPIAX_STATE_HANGUP_REQUESTED                10
+#define                SKYPIAX_STATE_PREANSWER                                11
</ins><span class="cx"> /*********************************/
</span><span class="cx"> /* call flow from the device */
</span><del>-#define         CALLFLOW_CALL_IDLE  SKYPIAX_STATE_DOWN
-#define         CALLFLOW_INCOMING_RING  SKYPIAX_STATE_RING
-#define         CALLFLOW_CALL_DIALING   SKYPIAX_STATE_DIALING
-#define         CALLFLOW_CALL_LINEBUSY   SKYPIAX_STATE_BUSY
-#define         CALLFLOW_CALL_ACTIVE   300
-#define         CALLFLOW_INCOMING_HANGUP   100
-#define         CALLFLOW_CALL_RELEASED   101
-#define         CALLFLOW_CALL_NOCARRIER   102
-#define         CALLFLOW_CALL_INFLUX   103
-#define         CALLFLOW_CALL_INCOMING   104
-#define         CALLFLOW_CALL_FAILED   105
-#define         CALLFLOW_CALL_NOSERVICE   106
-#define         CALLFLOW_CALL_OUTGOINGRESTRICTED   107
-#define         CALLFLOW_CALL_SECURITYFAIL   108
-#define         CALLFLOW_CALL_NOANSWER   109
-#define         CALLFLOW_STATUS_FINISHED   110
-#define         CALLFLOW_STATUS_CANCELLED   111
-#define         CALLFLOW_STATUS_FAILED   112
-#define         CALLFLOW_STATUS_REFUSED   113
-#define         CALLFLOW_STATUS_RINGING   114
-#define         CALLFLOW_STATUS_INPROGRESS   115
-#define         CALLFLOW_STATUS_UNPLACED   116
-#define         CALLFLOW_STATUS_ROUTING   117
-#define         CALLFLOW_STATUS_EARLYMEDIA   118
-#define         SKYPIAX_STATE_HANGUP_REQUESTED   200
-  //FIXME CALLFLOW_INCOMING_CALLID to be removed
-#define         CALLFLOW_INCOMING_CALLID   1019
-#define         CALLFLOW_STATUS_REMOTEHOLD   201
</del><ins>+#define         CALLFLOW_CALL_IDLE                                        0
+#define         CALLFLOW_CALL_DOWN                                        1
+#define         CALLFLOW_INCOMING_RING                                2
+#define         CALLFLOW_CALL_DIALING                                3
+#define         CALLFLOW_CALL_LINEBUSY                                4
+#define         CALLFLOW_CALL_ACTIVE                                5
+#define         CALLFLOW_INCOMING_HANGUP                        6                
+#define         CALLFLOW_CALL_RELEASED                                7
+#define         CALLFLOW_CALL_NOCARRIER                                8
+#define         CALLFLOW_CALL_INFLUX                                9
+#define         CALLFLOW_CALL_INCOMING                                10
+#define         CALLFLOW_CALL_FAILED                                11
+#define         CALLFLOW_CALL_NOSERVICE                                12
+#define         CALLFLOW_CALL_OUTGOINGRESTRICTED        13
+#define         CALLFLOW_CALL_SECURITYFAIL                        14
+#define         CALLFLOW_CALL_NOANSWER                                15
+#define         CALLFLOW_STATUS_FINISHED                        16
+#define         CALLFLOW_STATUS_CANCELLED                        17
+#define         CALLFLOW_STATUS_FAILED                                18
+#define         CALLFLOW_STATUS_REFUSED                                19
+#define         CALLFLOW_STATUS_RINGING                                20
+#define         CALLFLOW_STATUS_INPROGRESS                        21
+#define         CALLFLOW_STATUS_UNPLACED                        22
+#define         CALLFLOW_STATUS_ROUTING                                23
+#define         CALLFLOW_STATUS_EARLYMEDIA                        24
+#define         CALLFLOW_INCOMING_CALLID                        25
+#define         CALLFLOW_STATUS_REMOTEHOLD                        26
</ins><span class="cx"> 
</span><span class="cx"> /*********************************/
</span><span class="cx"> 
</span><span class="lines">@@ -241,6 +243,10 @@
</span><span class="cx">         char transfer_callid_number[50];
</span><span class="cx">         char skype_transfer_call_id[512];
</span><span class="cx">         int running;
</span><ins>+  unsigned long ib_calls;
+  unsigned long ob_calls;     
+  unsigned long ib_failed_calls;
+  unsigned long ob_failed_calls;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> typedef struct private_object private_t;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_skypiaxskypiax_protocolc"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c (14532 => 14533)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c        2009-08-15 14:32:33 UTC (rev 14532)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c        2009-08-15 15:37:44 UTC (rev 14533)
</span><span class="lines">@@ -62,7 +62,6 @@
</span><span class="cx">                                    tech_pvt-&gt;tcp_cli_port, tech_pvt-&gt;tcp_srv_port);
</span><span class="cx">                         return -1;
</span><span class="cx">                 }
</span><del>-                //usleep(100);
</del><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         DEBUGA_SKYPE(&quot;SUCCESS! *which_port=%d, tech_pvt-&gt;tcp_cli_port=%d, tech_pvt-&gt;tcp_srv_port=%d\n&quot;, SKYPIAX_P_LOG, *which_port, tech_pvt-&gt;tcp_cli_port,
</span><span class="lines">@@ -231,7 +230,7 @@
</span><span class="cx">                                 //SKYPIAX_P_LOG, message, obj, id, prop, value, where ? where : &quot;NULL&quot;);
</span><span class="cx"> 
</span><span class="cx">                                 if (!strcasecmp(prop, &quot;PARTNER_HANDLE&quot;)) {
</span><del>-                                        if (!strlen(tech_pvt-&gt;skype_call_id) || !strlen(tech_pvt-&gt;session_uuid_str)) {
</del><ins>+                                        if (tech_pvt-&gt;interface_state != SKYPIAX_STATE_SELECTED &amp;&amp; (!strlen(tech_pvt-&gt;skype_call_id) || !strlen(tech_pvt-&gt;session_uuid_str)) ) {
</ins><span class="cx">                                                 //if (!strlen(tech_pvt-&gt;skype_call_id)) {
</span><span class="cx">                                                 /* we are NOT inside an active call */
</span><span class="cx">                                                 DEBUGA_SKYPE(&quot;Call %s TRY ANSWER\n&quot;, SKYPIAX_P_LOG, id);
</span><span class="lines">@@ -256,13 +255,13 @@
</span><span class="cx">                                 }
</span><span class="cx">                                 if (!strcasecmp(prop, &quot;CONF_ID&quot;) &amp;&amp; !strcasecmp(value, &quot;0&quot;)) {
</span><span class="cx">                                         //DEBUGA_SKYPE(&quot;the skype_call %s is NOT a conference call\n&quot;, SKYPIAX_P_LOG, id);
</span><del>-                                        if (tech_pvt-&gt;interface_state == SKYPIAX_STATE_DOWN)
-                                                tech_pvt-&gt;interface_state = SKYPIAX_STATE_PRERING;
</del><ins>+                                        //if (tech_pvt-&gt;interface_state == SKYPIAX_STATE_DOWN)
+                                                //tech_pvt-&gt;interface_state = SKYPIAX_STATE_PRERING;
</ins><span class="cx">                                 }
</span><span class="cx">                                 if (!strcasecmp(prop, &quot;CONF_ID&quot;) &amp;&amp; strcasecmp(value, &quot;0&quot;)) {
</span><span class="cx">                                         DEBUGA_SKYPE(&quot;the skype_call %s is a conference call\n&quot;, SKYPIAX_P_LOG, id);
</span><del>-                                        if (tech_pvt-&gt;interface_state == SKYPIAX_STATE_DOWN)
-                                                tech_pvt-&gt;interface_state = SKYPIAX_STATE_PRERING;
</del><ins>+                                        //if (tech_pvt-&gt;interface_state == SKYPIAX_STATE_DOWN)
+                                                //tech_pvt-&gt;interface_state = SKYPIAX_STATE_PRERING;
</ins><span class="cx">                                 }
</span><span class="cx">                                 if (!strcasecmp(prop, &quot;DTMF&quot;)) {
</span><span class="cx">                                         DEBUGA_SKYPE(&quot;Call %s received a DTMF: %s\n&quot;, SKYPIAX_P_LOG, id, value);
</span><span class="lines">@@ -338,7 +337,6 @@
</span><span class="cx">                                                 DEBUGA_SKYPE(&quot;We missed skype_call %s\n&quot;, SKYPIAX_P_LOG, id);
</span><span class="cx">                                         } else if (!strcasecmp(value, &quot;FINISHED&quot;)) {
</span><span class="cx">                                                 //DEBUGA_SKYPE(&quot;skype_call %s now is DOWN\n&quot;, SKYPIAX_P_LOG, id);
</span><del>-                                                //usleep(150000);//150msec, let's give the TCP sockets time to timeout
</del><span class="cx">                                                 if (!strcasecmp(tech_pvt-&gt;skype_call_id, id)) {
</span><span class="cx">                                                         //tech_pvt-&gt;skype_callflow = CALLFLOW_STATUS_FINISHED;
</span><span class="cx">                                                         DEBUGA_SKYPE(&quot;skype_call %s is MY call, now I'm going DOWN\n&quot;, SKYPIAX_P_LOG, id);
</span><span class="lines">@@ -429,7 +427,7 @@
</span><span class="cx">                                                                         DEBUGA_SKYPE(&quot;New Inbound Channel!\n\n\n\n&quot;, SKYPIAX_P_LOG);
</span><span class="cx">                                                                         new_inbound_channel(tech_pvt);
</span><span class="cx">                                                                 } else {
</span><del>-                                                                        DEBUGA_SKYPE(&quot;Outbound Channel Answered!\n&quot;, SKYPIAX_P_LOG);
</del><ins>+                                                                        DEBUGA_SKYPE(&quot;Outbound Channel Answered! session_uuid_str=%s\n&quot;, SKYPIAX_P_LOG, tech_pvt-&gt;session_uuid_str);
</ins><span class="cx">                                                                         outbound_channel_answered(tech_pvt);
</span><span class="cx">                                                                 }
</span><span class="cx">                                                         } else {
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>

</body>
</html>