<!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][15227] </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=15227">15227</a></dd>
<dt>Author</dt> <dd>bottleman</dd>
<dt>Date</dt> <dd>2009-10-26 11:40:11 -0500 (Mon, 26 Oct 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre>bugfix and improvements.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#freeswitchtrunksrcmodendpointsmod_h323Makefile">freeswitch/trunk/src/mod/endpoints/mod_h323/Makefile</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_h323changestxt">freeswitch/trunk/src/mod/endpoints/mod_h323/changes.txt</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_h323h323confxml">freeswitch/trunk/src/mod/endpoints/mod_h323/h323.conf.xml</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_h323mod_h323cpp">freeswitch/trunk/src/mod/endpoints/mod_h323/mod_h323.cpp</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_h323mod_h323h">freeswitch/trunk/src/mod/endpoints/mod_h323/mod_h323.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunksrcmodendpointsmod_h323Makefile"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_h323/Makefile (15226 => 15227)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_h323/Makefile        2009-10-26 14:50:12 UTC (rev 15226)
+++ freeswitch/trunk/src/mod/endpoints/mod_h323/Makefile        2009-10-26 16:40:11 UTC (rev 15227)
</span><span class="lines">@@ -1,5 +1,7 @@
</span><span class="cx"> BASE=../../../..
</span><del>-LOCAL_CFLAGS+=-g -I/usr/include/ptlib -I/usr/local/src/h323plus/include  -I. -DPTRACING=1 -D_REENTRANT -fno-exceptions
-LOCAL_LDFLAGS= -L/usr/local/src/h323plus/lib -lh323_linux_x86_ -lpt -lrt 
</del><ins>+LOCAL_CFLAGS+=-g -ggdb  -I/usr/include/ptlib -I/usr/include/openh323  -I. -DPTRACING=1 -D_REENTRANT -fno-exceptions
+LOCAL_LDFLAGS= -lopenh323 -lpt -lrt 
</ins><span class="cx"> 
</span><span class="cx"> include $(BASE)/build/modmake.rules
</span><ins>+
+
</ins></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_h323changestxt"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_h323/changes.txt (15226 => 15227)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_h323/changes.txt        2009-10-26 14:50:12 UTC (rev 15226)
+++ freeswitch/trunk/src/mod/endpoints/mod_h323/changes.txt        2009-10-26 16:40:11 UTC (rev 15227)
</span><span class="lines">@@ -1,4 +1,10 @@
</span><span class="cx"> 
</span><ins>+implement jitter-size value option.
+implement gk register retry timer.
+implement h245insetup enable/disable option.
+implement h245tunneling enable/disable option.
+implement faststart enable/disable option.
+fix release handling from h323 leg.
</ins><span class="cx"> fix misstype in codec conversion.
</span><span class="cx"> fix rtp issue causes choppy sound.
</span><span class="cx"> fix progress ind handling on outbound calls.
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_h323h323confxml"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_h323/h323.conf.xml (15226 => 15227)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_h323/h323.conf.xml        2009-10-26 14:50:12 UTC (rev 15226)
+++ freeswitch/trunk/src/mod/endpoints/mod_h323/h323.conf.xml        2009-10-26 16:40:11 UTC (rev 15227)
</span><span class="lines">@@ -7,6 +7,11 @@
</span><span class="cx">     &lt;param name=&quot;gk-address&quot; value=&quot;&quot;/&gt;    &lt;!-- empty to disable, &quot;*&quot; to search LAN --&gt;
</span><span class="cx">     &lt;param name=&quot;gk-identifer&quot; value=&quot;&quot;/&gt;  &lt;!-- optional name of gk --&gt;
</span><span class="cx">     &lt;param name=&quot;gk-interface&quot; value=&quot;&quot;/&gt;  &lt;!-- optional listener interface name --&gt;
</span><ins>+    &lt;param name=&quot;gk-retry&quot; value=&quot;30&quot;/&gt;  &lt;!-- optional GK register retry timer --&gt;
+    &lt;param name=&quot;faststart&quot; value=&quot;true&quot;/&gt;  &lt;!-- optional --&gt;
+    &lt;param name=&quot;h245tunneling&quot; value=&quot;true&quot;/&gt;  &lt;!-- optional --&gt;
+    &lt;param name=&quot;h245insetup&quot; value=&quot;true&quot;/&gt;  &lt;!-- optional --&gt;
+    &lt;param name=&quot;jitter-size&quot; value=&quot;60&quot;/&gt;  &lt;!-- optional --&gt;
</ins><span class="cx">   &lt;/settings&gt;
</span><span class="cx">   &lt;listeners&gt;
</span><span class="cx">     &lt;listener name=&quot;default&quot;&gt;
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_h323mod_h323cpp"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_h323/mod_h323.cpp (15226 => 15227)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_h323/mod_h323.cpp        2009-10-26 14:50:12 UTC (rev 15226)
+++ freeswitch/trunk/src/mod/endpoints/mod_h323/mod_h323.cpp        2009-10-26 16:40:11 UTC (rev 15227)
</span><span class="lines">@@ -1,5 +1,7 @@
</span><ins>+/*
+        Version 0.0.8
+*/
</ins><span class="cx"> 
</span><del>-
</del><span class="cx"> #include &quot;mod_h323.h&quot;
</span><span class="cx"> 
</span><span class="cx"> SWITCH_DECLARE_GLOBAL_STRING_FUNC(set_global_codec_string, mod_h323_globals.codec_string);
</span><span class="lines">@@ -239,36 +241,41 @@
</span><span class="cx"> 
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-PString GetH245CodecName(const H245_AudioCapability &amp;cap){
-        switch (cap.GetTag()) {
-        case H245_AudioCapability::e_g711Alaw64k:
-        case H245_AudioCapability::e_g711Alaw56k:
-                return &quot;PCMA&quot;;
-        case H245_AudioCapability::e_g711Ulaw64k:
-        case H245_AudioCapability::e_g711Ulaw56k:
-                return &quot;PCMU&quot;;
-        case H245_AudioCapability::e_g722_64k:
-        case H245_AudioCapability::e_g722_56k:
-        case H245_AudioCapability::e_g722_48k:
-                return &quot;G722&quot;;
-        case H245_AudioCapability::e_g728:
-                return &quot;G728&quot;;
-        case H245_AudioCapability::e_g729:
-        case H245_AudioCapability::e_g729AnnexA:
-        case H245_AudioCapability::e_g729wAnnexB:
-        case H245_AudioCapability::e_g729AnnexAwAnnexB:
-                return &quot;G729&quot;;
-        case H245_AudioCapability::e_g7231:
-        case H245_AudioCapability::e_g7231AnnexCCapability:
-                return &quot;G723&quot;;
-        case H245_AudioCapability::e_gsmFullRate:
-        case H245_AudioCapability::e_gsmHalfRate:
-        case H245_AudioCapability::e_gsmEnhancedFullRate:
-                return &quot;GSM&quot;;
</del><ins>+PString GetH245CodecName(const H323Capability* cap){
+        
+        switch (cap-&gt;GetSubType()) {
+                case H245_AudioCapability::e_g711Alaw64k:
+                case H245_AudioCapability::e_g711Alaw56k:
+                        return &quot;PCMA&quot;;
+                case H245_AudioCapability::e_g711Ulaw64k:
+                case H245_AudioCapability::e_g711Ulaw56k:
+                        return &quot;PCMU&quot;;
+                case H245_AudioCapability::e_g722_64k:
+                case H245_AudioCapability::e_g722_56k:
+                case H245_AudioCapability::e_g722_48k:
+                        return &quot;G722&quot;;
+                case H245_AudioCapability::e_g728:
+                        return &quot;G728&quot;;
+                case H245_AudioCapability::e_g729:
+                case H245_AudioCapability::e_g729AnnexA:
+                case H245_AudioCapability::e_g729wAnnexB:
+                case H245_AudioCapability::e_g729AnnexAwAnnexB:
+                        return &quot;G729&quot;;
+                case H245_AudioCapability::e_g7231:
+                case H245_AudioCapability::e_g7231AnnexCCapability:
+                        return &quot;G723&quot;;
+                case H245_AudioCapability::e_gsmFullRate:
+                case H245_AudioCapability::e_gsmHalfRate:
+                case H245_AudioCapability::e_gsmEnhancedFullRate:
+                        return &quot;GSM&quot;;
+                case H245_AudioCapability::e_nonStandard:{
+                        if (cap-&gt;GetFormatName().Find(&quot;726-40&quot;)) return &quot;G726-40&quot;;
+                }        
</ins><span class="cx">         }
</span><span class="cx">         return &quot;Unknown&quot;;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+
</ins><span class="cx"> FSProcess::FSProcess()
</span><span class="cx">   : PLibraryProcess(&quot;Test&quot;, &quot;mod_h323&quot;, 1, 0, AlphaCode, 1)
</span><span class="cx">   , m_h323endpoint(NULL){
</span><span class="lines">@@ -302,6 +309,8 @@
</span><span class="cx">                         
</span><span class="cx">         PString codec = ((const char *)mod_h323_globals.codec_string);
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Config capabilliti %s \n&quot;,(const char *)codec);
</span><ins>+        
+
</ins><span class="cx">         if (!codec.IsEmpty()) {                
</span><span class="cx">                 const char** f = h323_formats;
</span><span class="cx">                 for (; *f; f += 2) {                        
</span><span class="lines">@@ -329,10 +338,16 @@
</span><span class="cx">                 }
</span><span class="cx">         }
</span><span class="cx"> 
</span><ins>+//        AddAllCapabilities(0, 0, &quot;*&quot;); 
</ins><span class="cx"> 
</span><span class="cx">                 
</span><span class="cx">     AddAllUserInputCapabilities(0,1);
</span><del>-         PTRACE(1, &quot;OpenPhone\tCapability Table:\n&quot; &lt;&lt; setprecision(4) &lt;&lt; capabilities);
</del><ins>+        PTRACE(1, &quot;OpenPhone\tCapability Table:\n&quot; &lt;&lt; setprecision(4) &lt;&lt; capabilities);
+        
+        DisableFastStart(!m_faststart);
+    DisableH245Tunneling(!m_h245tunneling);
+    DisableH245inSetup(!m_h245insetup);        
+         
</ins><span class="cx">     if (m_listeners.empty()) {
</span><span class="cx">         StartListener(&quot;&quot;);
</span><span class="cx">     } else {
</span><span class="lines">@@ -353,7 +368,11 @@
</span><span class="cx">     }
</span><span class="cx"> */
</span><span class="cx"> 
</span><del>-    if (!m_gkAddress.IsEmpty()) {
</del><ins>+    if (!m_gkAddress.IsEmpty() &amp;&amp; !m_gkIdentifer.IsEmpty() &amp;&amp; !m_gkInterface.IsEmpty()) {
+                m_thread = new FSGkRegThread(this,&amp;m_gkAddress,&amp;m_gkIdentifer,&amp;m_gkInterface,m_gkretry);
+                m_thread-&gt;SetAutoDelete();
+                m_thread-&gt;Resume();
+        /*
</ins><span class="cx">       if (UseGatekeeper(m_gkAddress, m_gkIdentifer, m_gkInterface))
</span><span class="cx">         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;Started gatekeeper: %s\n&quot;,
</span><span class="cx">                           (const char *)GetGatekeeper()-&gt;GetName());
</span><span class="lines">@@ -363,8 +382,9 @@
</span><span class="cx">                           (const char *)m_gkAddress,
</span><span class="cx">                           (const char *)m_gkIdentifer,
</span><span class="cx">                           (const char *)m_gkInterface);
</span><ins>+        */
</ins><span class="cx">     }
</span><del>-
</del><ins>+        
</ins><span class="cx">     return TRUE;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -422,6 +442,12 @@
</span><span class="cx">                                         switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, &quot;Set zero Jitter buffer\n&quot;);
</span><span class="cx">                                         SetAudioJitterDelay(0, 0);
</span><span class="cx">                                 }
</span><ins>+                        } else if (!strcasecmp(var, &quot;faststart&quot;)) {
+                                m_faststart = switch_true(val);
+                        } else if (!strcasecmp(var, &quot;h245tunneling&quot;)) {
+                                m_h245tunneling = switch_true(val);
+                        } else if (!strcasecmp(var, &quot;h245insetup&quot;)) {
+                                m_h245insetup = switch_true(val);
</ins><span class="cx">             } else if (!strcasecmp(var, &quot;gk-address&quot;)) {
</span><span class="cx">                 m_gkAddress = val;
</span><span class="cx">             } else if (!strcasecmp(var, &quot;gk-identifer&quot;)) {
</span><span class="lines">@@ -430,7 +456,10 @@
</span><span class="cx">                 m_gkInterface = val;
</span><span class="cx">             } else if (!strcasecmp(var, &quot;gk-prefix&quot;)) {
</span><span class="cx">                                 m_gkPrefixes.AppendString(val);
</span><del>-                        }
</del><ins>+                        } else if (!strcasecmp(var, &quot;gk-retry&quot;)) {
+                                m_gkretry = atoi(val);
+                        } 
+                        
</ins><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="lines">@@ -471,11 +500,20 @@
</span><span class="cx">     return status;
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-FSH323EndPoint::FSH323EndPoint(){
-        PTRACE(4, &quot;mod_h323\t======&gt;FSH323EndPoint::FSH323EndPoint &quot; &lt;&lt; *this);
</del><ins>+FSH323EndPoint::FSH323EndPoint()
+        :m_faststart(true)
+        ,m_h245tunneling(true)
+        ,m_h245insetup(true)
+{
+        PTRACE(4, &quot;mod_h323\t======&gt;FSH323EndPoint::FSH323EndPoint [&quot; &lt;&lt; *this&lt;&lt;&quot;]&quot;);
</ins><span class="cx">         terminalType = e_GatewayOnly;
</span><span class="cx"> }        
</span><span class="cx"> 
</span><ins>+FSH323EndPoint::~FSH323EndPoint(){
+        PTRACE(4, &quot;mod_h323\t======&gt;FSH323EndPoint::~FSH323EndPoint [&quot; &lt;&lt; *this&lt;&lt;&quot;]&quot;);
+        StopGkClient();
+}
+
</ins><span class="cx"> H323Connection  *FSH323EndPoint::CreateConnection(
</span><span class="cx">         unsigned callReference,
</span><span class="cx">         void* userData,
</span><span class="lines">@@ -516,14 +554,43 @@
</span><span class="cx">         return false;
</span><span class="cx"> }
</span><span class="cx"> 
</span><ins>+void FSH323EndPoint::StartGkClient(int retry, PString* gkAddress,PString* gkIdentifer,PString* gkInterface){
+        PTRACE(4, &quot;mod_h323\t======&gt;FSH323EndPoint::StartGkClient [&quot; &lt;&lt; *this&lt;&lt;&quot;]&quot;);
+        while(!UseGatekeeper(m_gkAddress, m_gkIdentifer, m_gkInterface) &amp;&amp; retry &gt; 0 ){
+                        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR,
+                          &quot;Could not start gatekeeper: addr=\&quot;%s\&quot;, id=\&quot;%s\&quot;, if=\&quot;%s\&quot;\n&quot;,
+                          (const char *)m_gkAddress,
+                          (const char *)m_gkIdentifer,
+                          (const char *)m_gkInterface);
+                        switch_yield(retry*1000);
+        }
+        switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;Started gatekeeper: %s\n&quot;,
+                                                        (const char *)GetGatekeeper()-&gt;GetName());        
+        m_thread = 0;        
+}
+
+void FSH323EndPoint::StopGkClient(){
+        PTRACE(4, &quot;mod_h323\t======&gt; FSH323EndPoint::StopGkClient [&quot; &lt;&lt; *this&lt;&lt;&quot;]&quot;);
+        if (m_thread) {
+                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, &quot;Started gatekeeper thread\n&quot;);
+                RemoveGatekeeper();
+                m_thread-&gt;Terminate();
+                m_thread = 0;
+    }
+}
+
</ins><span class="cx"> FSH323Connection::FSH323Connection(FSH323EndPoint&amp; endpoint, H323Transport* transport, unsigned callReference,  switch_caller_profile_t *outbound_profile, switch_core_session_t *fsSession, switch_channel_t *fsChannel)
</span><span class="cx">         : H323Connection(endpoint,callReference)
</span><span class="cx">         , m_endpoint(&amp;endpoint)
</span><span class="cx">         , m_fsSession(fsSession)
</span><span class="cx">     , m_fsChannel(fsChannel)
</span><span class="cx">         , m_callOnPreAnswer(false)
</span><del>-        , m_startRTP(false){
-        PTRACE(4, &quot;mod_h323\t======&gt;FSH323Connection::FSH323Connection &quot; &lt;&lt; *this);
</del><ins>+        , m_startRTP(false)
+        , m_rxChennel(false)
+        , m_txChennel(false)
+        , m_ChennelAnswer(false)
+        , m_ChennelProgress(false){
+        PTRACE(4, &quot;mod_h323\t======&gt;FSH323Connection::FSH323Connection [&quot; &lt;&lt; *this&lt;&lt;&quot;]&quot;);
</ins><span class="cx"> 
</span><span class="cx">     h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_alloc(m_fsSession, sizeof(*tech_pvt));
</span><span class="cx">     tech_pvt-&gt;me = this;
</span><span class="lines">@@ -720,7 +787,7 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> H323Channel* FSH323Connection::CreateRealTimeLogicalChannel(const H323Capability&amp; capability,H323Channel::Directions dir,unsigned sessionID,const H245_H2250LogicalChannelParameters* param, RTP_QOS * rtpqos){
</span><del>-        PTRACE(4, &quot;mod_h323\t======&gt;FSH323Connection::CreateRealTimeLogicalChannel &quot; &lt;&lt; *this);
</del><ins>+        PTRACE(4, &quot;mod_h323\t======&gt;FSH323Connection::CreateRealTimeLogicalChannel [&quot; &lt;&lt; *this&lt;&lt;&quot;]&quot;);
</ins><span class="cx">         
</span><span class="cx">         H323TransportAddress m_h323transportadd = GetSignallingChannel()-&gt;GetLocalAddress();
</span><span class="cx">         m_h323transportadd.GetIpAddress(m_RTPlocalIP);
</span><span class="lines">@@ -729,14 +796,14 @@
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> PBoolean FSH323Connection::OnStartLogicalChannel(H323Channel &amp; channel){
</span><del>-    PTRACE(4, &quot;mod_h323\t======&gt;FSH323Connection::OnStartLogicalChannel chennel = &quot;&lt;&lt;&amp;channel&lt;&lt;&quot;, &quot;&lt;&lt;*this);
</del><ins>+    PTRACE(4, &quot;mod_h323\t======&gt;FSH323Connection::OnStartLogicalChannel chennel = &quot;&lt;&lt;&amp;channel&lt;&lt;&quot; [&quot;&lt;&lt;*this&lt;&lt;&quot;]&quot;);
</ins><span class="cx">     
</span><span class="cx"> //    return  H323Connection::OnStartLogicalChannel(channel);
</span><span class="cx">         return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> PBoolean FSH323Connection::OnCreateLogicalChannel(const H323Capability&amp; capability, H323Channel::Directions dir, unsigned&amp; errorCode){
</span><del>-    PTRACE(4, &quot;mod_h323\t======&gt;FSH323Connection::OnCreateLogicalChannel ('&quot;&lt;&lt; (const char *)capability.GetFormatName()&lt;&lt;&quot;',&quot;&lt;&lt;dir&lt;&lt;&quot;) &quot;&lt;&lt;*this);
</del><ins>+    PTRACE(4, &quot;mod_h323\t======&gt;FSH323Connection::OnCreateLogicalChannel ('&quot;&lt;&lt; (const char *)capability.GetFormatName()&lt;&lt;&quot;',&quot;&lt;&lt;dir&lt;&lt;&quot;) [&quot;&lt;&lt;*this&lt;&lt;&quot;]&quot;);
</ins><span class="cx">     
</span><span class="cx">         return H323Connection::OnCreateLogicalChannel(capability,dir,errorCode);
</span><span class="cx"> }
</span><span class="lines">@@ -753,9 +820,12 @@
</span><span class="cx"> 
</span><span class="cx"> bool FSH323Connection::OnReceivedProgress(const H323SignalPDU &amp;pdu)
</span><span class="cx"> {
</span><del>-        PTRACE(4, &quot;mod_h323\t======&gt;FSH323Connection::OnReceivedProgress&quot;);
-        m_txAudioOpened.Wait();
-        switch_channel_mark_pre_answered(m_fsChannel);
</del><ins>+        PTRACE(4, &quot;mod_h323\t======&gt;FSH323Connection::OnReceivedProgress [&quot;&lt;&lt;*this&lt;&lt;&quot;]&quot;);
+        if ((m_rxChennel &amp;&amp; m_txChennel) || (m_ChennelProgress &amp;&amp; m_rxChennel))
+                switch_channel_mark_pre_answered(m_fsChannel);
+        else{
+                m_ChennelProgress = true;
+        }
</ins><span class="cx">         return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -810,8 +880,9 @@
</span><span class="cx"> void FSH323Connection::OnEstablished(){
</span><span class="cx"> 
</span><span class="cx">         PTRACE(4, &quot;mod_h323\t======&gt;PFSH323Connection::OnEstablished [&quot;&lt;&lt;*this&lt;&lt;&quot;]&quot;);
</span><del>-        
-        switch_channel_mark_answered(m_fsChannel);
</del><ins>+        if(m_startRTP)                
+                switch_channel_mark_answered(m_fsChannel);
+        else m_ChennelAnswer = true;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -819,26 +890,26 @@
</span><span class="cx"> void FSH323Connection::setRemoteAddress(const char* remoteIP, WORD remotePort){
</span><span class="cx">         PTRACE(4, &quot;mod_h323\t======&gt;PFSH323Connection::setRemoteAddress remoteIP =&quot;&lt;&lt;remoteIP&lt;&lt;&quot;, remotePort = &quot;&lt;&lt;remotePort&lt;&lt;&quot; &quot;&lt;&lt;*this);
</span><span class="cx">     if (!m_remotePort) {
</span><del>-        PTRACE(4, &quot;mod_h323\tGot remote RTP address &quot;&lt;&lt;remoteIP&lt;&lt;&quot;:&quot;&lt;&lt;remotePort&lt;&lt;&quot; &quot;&lt;&lt;*this);
</del><ins>+        PTRACE(4, &quot;mod_h323\tGot remote RTP address &quot;&lt;&lt;remoteIP&lt;&lt;&quot;:&quot;&lt;&lt;remotePort&lt;&lt;&quot; [&quot;&lt;&lt;*this&lt;&lt;&quot;]&quot;);
</ins><span class="cx">         m_remotePort = remotePort;
</span><span class="cx">         m_remoteAddr = remoteIP;
</span><span class="cx">     }
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> switch_status_t FSH323Connection::on_execute(){
</span><del>-        PTRACE(4, &quot;mod_h323\t======&gt;FSH323Connection::on_execute &quot; &lt;&lt; *this);
</del><ins>+        PTRACE(4, &quot;mod_h323\t======&gt;FSH323Connection::on_execute [&quot; &lt;&lt; *this&lt;&lt;&quot;]&quot;);
</ins><span class="cx">     
</span><span class="cx">     return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> switch_status_t FSH323Connection::on_routing(){
</span><del>-        PTRACE(4, &quot;mod_h323\t======&gt;FSH323Connection::on_routing &quot; &lt;&lt; *this);
</del><ins>+        PTRACE(4, &quot;mod_h323\t======&gt;FSH323Connection::on_routing [&quot;&lt;&lt; *this&lt;&lt;&quot;]&quot;);
</ins><span class="cx">    
</span><span class="cx">     return SWITCH_STATUS_SUCCESS;
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> switch_status_t FSH323Connection::kill_channel(int sig){
</span><del>-        PTRACE(4, &quot;mod_h323\t======&gt;FSH323Connection::kill_channel &quot; &lt;&lt; *this);
</del><ins>+        PTRACE(4, &quot;mod_h323\t======&gt;FSH323Connection::kill_channel [&quot;&lt;&lt; *this&lt;&lt;&quot;]&quot;);
</ins><span class="cx">     PTRACE(3, &quot;mod_h323\tKill &quot; &lt;&lt; sig &lt;&lt; &quot; on connection &quot; &lt;&lt; *this);
</span><span class="cx">         h323_private_t *tech_pvt = (h323_private_t *) switch_core_session_get_private(m_fsSession);
</span><span class="cx">         
</span><span class="lines">@@ -1004,13 +1075,12 @@
</span><span class="cx">     } else {            
</span><span class="cx">         switch_core_timer_next(&amp;tech_pvt-&gt;read_timer);
</span><span class="cx">     }
</span><del>-*/
</del><ins>+*/        
</ins><span class="cx">         switch_set_flag_locked(tech_pvt, TFLAG_READING);
</span><del>-        
</del><span class="cx">     if (!switch_channel_ready(m_fsChannel)) {
</span><span class="cx">                 PTRACE(4, &quot;mod_h323\t---------&gt; RETURN&quot;);
</span><del>-                switch_clear_flag_locked(tech_pvt, TFLAG_READING);
-        return SWITCH_STATUS_FALSE;
</del><ins>+                switch_clear_flag_locked(tech_pvt, TFLAG_READING);                
+            return SWITCH_STATUS_FALSE;
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (!switch_core_codec_ready(&amp;tech_pvt-&gt;read_codec )) {
</span><span class="lines">@@ -1019,7 +1089,6 @@
</span><span class="cx">         return SWITCH_STATUS_FALSE;
</span><span class="cx">     }
</span><span class="cx"> 
</span><del>-    //switch_core_timer_step(&amp;m_switchTimer);
</del><span class="cx"> 
</span><span class="cx">         
</span><span class="cx">         switch_status_t status = switch_rtp_zerocopy_read_frame(tech_pvt-&gt;rtp_session, &amp;tech_pvt-&gt;read_frame, flags);
</span><span class="lines">@@ -1043,11 +1112,10 @@
</span><span class="cx">         tech_pvt-&gt;read_frame.codec = &amp;tech_pvt-&gt;read_codec ;
</span><span class="cx">     }
</span><span class="cx">         switch_clear_flag_locked(tech_pvt, TFLAG_READING);
</span><ins>+        
</ins><span class="cx">     *frame = &amp;tech_pvt-&gt;read_frame;
</span><span class="cx"> 
</span><span class="cx">     return SWITCH_STATUS_SUCCESS;
</span><del>-        
-
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> switch_status_t FSH323Connection::write_audio_frame(switch_frame_t *frame, switch_io_flag_t flags, int stream_id){
</span><span class="lines">@@ -1184,7 +1252,7 @@
</span><span class="cx">         PTRACE(4, &quot;mod_h323\t-------------------&gt;m_capability-&gt;GetTxFramesInPacket() return =  &quot;&lt;&lt;m_capability-&gt;GetTxFramesInPacket());
</span><span class="cx">         PTRACE(4, &quot;mod_h323\t-------------------&gt;m_capability-&gt;GetFormatName() return =  &quot;&lt;&lt;m_capability-&gt;GetFormatName());
</span><span class="cx">         
</span><del>-        PTRACE(4, &quot;mod_h323\t-------------------&gt;GetH245CodecName() return =  &quot;&lt;&lt;GetH245CodecName(m_capability-&gt;GetSubType()));
</del><ins>+        PTRACE(4, &quot;mod_h323\t-------------------&gt;GetH245CodecName() return =  &quot;&lt;&lt;GetH245CodecName(m_capability));
</ins><span class="cx">         
</span><span class="cx">         
</span><span class="cx">         
</span><span class="lines">@@ -1193,8 +1261,10 @@
</span><span class="cx">         if (GetDirection() == IsReceiver){
</span><span class="cx">                 m_switchCodec = isAudio ? &amp;tech_pvt-&gt;read_codec : &amp;tech_pvt-&gt;vid_read_codec;
</span><span class="cx">         m_switchTimer = isAudio ? &amp;tech_pvt-&gt;read_timer : &amp;tech_pvt-&gt;vid_read_timer;
</span><ins>+                m_conn-&gt;m_rxChennel = true;
</ins><span class="cx">         }else{
</span><span class="cx">                 m_switchCodec = isAudio ? &amp;tech_pvt-&gt;write_codec : &amp;tech_pvt-&gt;vid_write_codec;
</span><ins>+                m_conn-&gt;m_txChennel = true;
</ins><span class="cx">         }
</span><span class="cx">         
</span><span class="cx">         if (m_conn-&gt;m_callOnPreAnswer &amp;&amp; !(GetDirection() == IsReceiver)){
</span><span class="lines">@@ -1202,14 +1272,12 @@
</span><span class="cx">         m_switchTimer = isAudio ? &amp;tech_pvt-&gt;read_timer : &amp;tech_pvt-&gt;vid_read_timer;
</span><span class="cx">         }
</span><span class="cx">         
</span><del>-        
-        
-        if (switch_core_codec_init(m_switchCodec, GetH245CodecName(m_capability-&gt;GetSubType()), NULL, // FMTP
</del><ins>+        if (switch_core_codec_init(m_switchCodec, GetH245CodecName(m_capability), NULL, // FMTP
</ins><span class="cx">                                8000, m_capability-&gt;GetTxFramesInPacket(), 1,  // Channels
</span><span class="cx">                                SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,   // Settings
</span><span class="cx">                                switch_core_session_get_pool(m_fsSession)) != SWITCH_STATUS_SUCCESS) {
</span><span class="cx">         
</span><del>-        if (switch_core_codec_init(m_switchCodec, GetH245CodecName(m_capability-&gt;GetSubType()), NULL, // FMTP
</del><ins>+        if (switch_core_codec_init(m_switchCodec, GetH245CodecName(m_capability), NULL, // FMTP
</ins><span class="cx">                                    8000, 0, 1,  // Channels
</span><span class="cx">                                    SWITCH_CODEC_FLAG_ENCODE | SWITCH_CODEC_FLAG_DECODE, NULL,   // Settings
</span><span class="cx">                                    switch_core_session_get_pool(m_fsSession)) != SWITCH_STATUS_SUCCESS) {
</span><span class="lines">@@ -1271,6 +1339,12 @@
</span><span class="cx">                 }        
</span><span class="cx">         }
</span><span class="cx">         
</span><ins>+        if (m_conn-&gt;m_ChennelProgress &amp;&amp; (GetDirection() == IsReceiver)){
+                if (isAudio) {
+            switch_core_session_set_write_codec(m_fsSession, m_switchCodec);
+        }
+        }
+        
</ins><span class="cx">     PTRACE(3, &quot;mod_h323\tSet &quot; &lt;&lt; ((GetDirection() == IsReceiver)? &quot; read&quot; : &quot; write&quot;) &lt;&lt; ' '
</span><span class="cx">            &lt;&lt; m_capability-&gt;GetMainType() &lt;&lt; &quot; codec to &lt;&lt; &quot; &lt;&lt; m_capability &lt;&lt; &quot; for connection &quot; &lt;&lt; *this);
</span><span class="cx"> 
</span><span class="lines">@@ -1314,7 +1388,12 @@
</span><span class="cx">         else m_conn-&gt;m_txAudioOpened.Signal();
</span><span class="cx">     PTRACE(4, &quot;mod_h323\t-------------&gt;External RTP address &quot;&lt;&lt;m_RTPremoteIP&lt;&lt;&quot;:&quot;&lt;&lt;m_RTPremotePort);
</span><span class="cx">         switch_mutex_unlock(tech_pvt-&gt;h323_mutex);
</span><del>-        
</del><ins>+        if ( m_conn-&gt;m_ChennelAnswer &amp;&amp; m_conn-&gt;m_rxChennel &amp;&amp;  m_conn-&gt;m_txChennel)
+                switch_channel_mark_answered(m_fsChannel);
+                
+        if (m_conn-&gt;m_ChennelProgress &amp;&amp; m_conn-&gt;m_rxChennel)
+                switch_channel_mark_pre_answered(m_fsChannel);
+                
</ins><span class="cx">         return true;
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_h323mod_h323h"></a>
<div class="modfile"><h4>Modified: freeswitch/trunk/src/mod/endpoints/mod_h323/mod_h323.h (15226 => 15227)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_h323/mod_h323.h        2009-10-26 14:50:12 UTC (rev 15226)
+++ freeswitch/trunk/src/mod/endpoints/mod_h323/mod_h323.h        2009-10-26 16:40:11 UTC (rev 15227)
</span><span class="lines">@@ -125,12 +125,13 @@
</span><span class="cx">     PString localUserName;
</span><span class="cx">     PString gatekeeper;
</span><span class="cx"> };
</span><del>-
</del><ins>+class FSGkRegThread;
</ins><span class="cx"> class FSH323EndPoint:public H323EndPoint {
</span><span class="cx"> 
</span><span class="cx">     PCLASSINFO(FSH323EndPoint, H323EndPoint);
</span><span class="cx">         public:
</span><span class="cx">                 FSH323EndPoint();
</span><ins>+                ~FSH323EndPoint();
</ins><span class="cx">                 
</span><span class="cx">                 
</span><span class="cx">          /**Create a connection that uses the specified call.
</span><span class="lines">@@ -147,6 +148,9 @@
</span><span class="cx">         
</span><span class="cx">     switch_status_t ReadConfig(int reload);
</span><span class="cx">         
</span><ins>+        void StartGkClient(int retry, PString* gkAddress,PString* gkIdentifer,PString* gkInterface);
+        void StopGkClient();
+        
</ins><span class="cx">         switch_endpoint_interface_t *GetSwitchInterface() const {
</span><span class="cx">         return m_freeswitch;
</span><span class="cx">     }
</span><span class="lines">@@ -159,9 +163,33 @@
</span><span class="cx">                 PString m_gkAddress;
</span><span class="cx">                 PString m_gkIdentifer;
</span><span class="cx">                 PString m_gkInterface;
</span><ins>+                bool m_faststart;
+                bool m_h245tunneling;
+                bool m_h245insetup;
+                int m_gkretry;
+                FSGkRegThread* m_thread;
</ins><span class="cx">                 
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+
+class FSGkRegThread : public PThread
+{
+    PCLASSINFO(FSGkRegThread, PThread);
+public:
+    FSGkRegThread(FSH323EndPoint* endpoint, PString* gkAddress, PString* gkIdentifer, PString* gkInterface, int retry = 0)
+        : PThread(10000), m_ep(endpoint), m_retry(retry), m_gkAddress(gkAddress),m_gkIdentifer(gkIdentifer),m_gkInterface(gkInterface)
+        { }
+    void Main()
+        { m_ep-&gt;StartGkClient(m_retry,m_gkAddress,m_gkIdentifer,m_gkInterface); }
+protected:
+    FSH323EndPoint* m_ep;
+    int m_retry;
+    PString* m_gkAddress;
+        PString* m_gkIdentifer;
+        PString* m_gkInterface;
+};
+
+
</ins><span class="cx"> class FSH323Connection:public H323Connection {
</span><span class="cx">     PCLASSINFO(FSH323Connection, H323Connection)
</span><span class="cx"> 
</span><span class="lines">@@ -225,6 +253,10 @@
</span><span class="cx">         
</span><span class="cx">         bool m_callOnPreAnswer;
</span><span class="cx">         bool m_startRTP;
</span><ins>+        bool m_rxChennel;
+        bool m_txChennel;
+        bool m_ChennelAnswer;
+        bool m_ChennelProgress;
</ins><span class="cx">         PSyncPoint m_rxAudioOpened;
</span><span class="cx">     PSyncPoint m_txAudioOpened;
</span><span class="cx">   protected:
</span><span class="lines">@@ -238,6 +270,7 @@
</span><span class="cx">         unsigned char m_buf[SWITCH_RECOMMENDED_BUFFER_SIZE];
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+
</ins><span class="cx"> class FSH323_ExternalRTPChannel : public H323_ExternalRTPChannel{
</span><span class="cx">     PCLASSINFO(FSH323_ExternalRTPChannel, H323_ExternalRTPChannel);
</span><span class="cx"> public:
</span><span class="lines">@@ -409,7 +442,71 @@
</span><span class="cx">         unsigned m_type;
</span><span class="cx"> };
</span><span class="cx"> 
</span><ins>+class BaseG726Cap : public H323AudioCapability
+{
+        PCLASSINFO(BaseG726Cap, H323AudioCapability);
</ins><span class="cx"> 
</span><ins>+public:
+        
+        BaseG726Cap(const char* fname, unsigned type = H245_AudioCapability::e_nonStandard)
+        : H323AudioCapability(24,2), m_name(fname), m_type(type),m_comfortNoise(0),m_scrambled(0)
+        { }
+        
+        virtual PObject * Clone() const{
+                return new BaseG726Cap(*this);
+        }
+
+        virtual H323Codec* CreateCodec(H323Codec::Direction direction) const{
+                return 0;
+        }
+
+        virtual unsigned GetSubType() const{
+                PTRACE(2, &quot;mod_h323\t==============&gt;BaseG726Cap::GetSubType&quot;);
+                return H245_AudioCapability::e_nonStandard;
+        }
+
+        virtual PString GetFormatName() const{
+                PTRACE(2, &quot;mod_h323\t==============&gt;BaseG726Cap::GetFormatName&quot;);
+                return m_name;
+        }
+
+        virtual bool OnSendingPDU(H245_AudioCapability &amp; pdu, unsigned packetSize) const{
+                PTRACE(2, &quot;mod_h323\t==============&gt;BaseG726Cap::OnSendingPDU&quot;);
+                pdu.SetTag(H245_AudioCapability::e_nonStandard);
+                return true;
+        }
+        
+        virtual bool OnReceivedPDU(const H245_AudioCapability &amp; pdu, unsigned &amp; packetSize){
+                PTRACE(2, &quot;mod_h323\t==============&gt;BaseG726Cap::OnReceivedPDU&quot;);
+                return true;
+        }
+
+protected:
+        const char* m_name;
+        int m_comfortNoise;
+        int m_scrambled;
+        unsigned m_type;
+};
+
+
+
+
+#define OPAL_G726_40 &quot;G.726-40k&quot;
+
+char OpalG726_40[] = OPAL_G726_40;
+
+OPAL_MEDIA_FORMAT_DECLARE(OpalG726Format,
+          OpalG726_40,
+          OpalMediaFormat::DefaultAudioSessionID,
+          RTP_DataFrame::G726,
+          TRUE, // Needs jitter
+          8000, // bits/sec
+          5,   // bytes
+          80,   // 10 milliseconds
+          OpalMediaFormat::AudioTimeUnits,
+          0)
+
+
</ins><span class="cx"> #define DEFINE_H323_CAPAB(cls,base,param,name) \
</span><span class="cx"> class cls : public base { \
</span><span class="cx">   public: \
</span><span class="lines">@@ -427,5 +524,6 @@
</span><span class="cx"> DEFINE_H323_CAPAB(FS_G729B,BaseG729Capab,H245_AudioCapability::e_g729wAnnexB,OPAL_G729B&quot;{sw}&quot;)
</span><span class="cx"> DEFINE_H323_CAPAB(FS_G729AB,BaseG729Capab,H245_AudioCapability::e_g729AnnexAwAnnexB,OPAL_G729AB&quot;{sw}&quot;)
</span><span class="cx"> DEFINE_H323_CAPAB(FS_GSM,BaseGSM0610Cap,H245_AudioCapability::e_gsmFullRate,OPAL_GSM0610&quot;{sw}&quot;)
</span><ins>+DEFINE_H323_CAPAB(FS_G726_40,BaseG726Cap,H245_AudioCapability::e_nonStandard,OPAL_G726_40&quot;{sw}&quot;)
</ins><span class="cx"> 
</span><span class="cx"> static FSProcess *h323_process = NULL;
</span></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>

</body>
</html>