<div dir="ltr">Hello everyone, this is me again. I keep pushing ppl to followup on their stuff so I will put my money where my mouth is.<div><br></div><div style>I&#39;ve made big progress and I will respond to my own questions. Look inline.</div>
<div style><br></div><div style>I am still working on putting the pieces together because there are more scenarios than the ones I anticipated when it comes to t38_gateway. It turns out that FaxA can send a fax to FaxB even tho FaxB was the calling party and therefore, T38 negotiation will be initiated by FSB instead of the expected FSA since it is FaxB emitting CED/Preamble.</div>
<div style><br></div><div style>Anyhow, stay tuned and more will come (probably more questions than answers tho).</div><div style><br></div><div style>Regards,</div><div class="gmail_extra"><div>Joćo Mesquita<br></div>
<br><br><div class="gmail_quote">On Thu, Jan 17, 2013 at 12:05 PM, Joćo Mesquita <span dir="ltr">&lt;<a href="mailto:jmesquita@freeswitch.org" target="_blank">jmesquita@freeswitch.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>Hello everyone!</div><div><br></div><div>I have been playing around with mod_spandsp&#39;s capabilities lately and most certainly because I am new to the all old faxing stuff (pretty funny, right?), I have been making a bit of a mess in my head about how a T30-&gt;T38 gateway should work.</div>

<div><br></div><div>I&#39;ve set up a testing environment here as follows:</div><div><br></div><div><b>Components:</b></div><div><b><br></b></div><div>2 analog fax machines (call is FaxA and FaxB)</div><div>2 FXS cards</div>

<div>2 FreeSWITCH machines (call FSA and FSB)</div><div><br></div><div><b>Connection scheme:</b></div><div><b><br></b></div><div><i>FaxA &lt;-&gt; FSA and FaxB &lt;-&gt; FSB</i></div><div><br></div><div>Both of these connections are using the respective FXS cards</div>

<div><br></div><div><i>FSA &lt;-SIP-&gt; FSB</i></div><div><i><br></i></div><div>Both FreeSWITCHes are connected using SIP, of course.</div><div><br></div><div><b>Call scenarios:</b></div><div><br></div><div><ol><li><b>FaxA sending a fax to FSB (using rxfax on FSB) - OK</b><br>

Dialplan on FSA is:<br>&lt;action application=&quot;set&quot; data=&quot;sip_execute_on_image=&quot;t38_gateway peer nocng&quot; /&gt;<br>&lt;action application=&quot;bridge&quot; data=&quot;{fax_t38_enable=true}sofia/internal/FSB&quot; /&gt;<br>

Dialplan on FSB:<br>&lt;action applcation=&quot;answer&quot;/&gt;<br>&lt;action applcation=&quot;set&quot; data=&quot;fax_t38_enable=true&quot; /&gt;<br>&lt;action applcation=&quot;set&quot; data=&quot;fax_t38_request=true&quot; /&gt;<br>

&lt;action applcation=&quot;rxfax&quot; data=&quot;/tmp/fax.tif&quot; /&gt;<br><br></li><li><b>FSB sending a a fax to FaxA - OK</b><br><span style="font-weight:normal">Dialplan on FSA is:</span><br style="font-weight:normal">

<span style="font-weight:normal">&lt;action application=&quot;set&quot; data=&quot;sip_execute_on_image=&quot;t38_gateway self nocng&quot; /&gt;</span><br style="font-weight:normal"><span style="font-weight:normal">&lt;action application=&quot;bridge&quot; data=&quot;{fax_t38_enable=true}sofia/internal/FSB&quot; /&gt;</span><br style="font-weight:normal">

Originate line on FSB:<br><div style="line-height:13px;font-size:11px;background-color:rgb(240,240,240);font-family:monospace;margin:0px 1em 1em;border:1px dashed;padding:0px"><div style="margin:0px;padding:5px;overflow:auto">

<pre style="margin-top:0px;margin-bottom:0px;padding:0px;font-size:13px;line-height:1.3em;max-height:30em;overflow:auto;word-wrap:normal">originate {fax_enable_t38_request=<span style="background-color:inherit;color:rgb(0,0,145)">true</span>,fax_enable_t38=<span style="background-color:inherit;color:rgb(0,0,145)">true</span>}sofia/internal/FSB &#39;set:ignore_early_media=<span style="background-color:inherit;color:rgb(0,0,145)">true</span>,txfax:/root/fax.tiff&#39; inline</pre>

</div></div><br></li><li><b>FaxA sending a fax to FaxB in manual mode</b></li><li><b>FaxA sending a fax to FaxB in automatic mode</b></li><li><b>FaxA receiving a fax from FaxB in manual mode</b></li><li><b>FaxA receiving a fax from FaxB in automatic mode</b><br>

Here comes the problem. It is not clear to me how this should work from the dialplan perspective and from the theory as well. Now, as I understand, t38_gateway works by detecting CED tones as specified on the code by the line:<br>

<i><font face="courier new, monospace">spandsp_fax_detect_session(session, &quot;rw&quot;, timeout, MODEM_CONNECT_TONES_FAX_CED_OR_PREAMBLE, 1, direction, NULL, t38_gateway_start);</font></i></li></ol><div><br></div><b>Questions:</b><br>

<br></div><div>If this is true and looking at the T.30 standard, some of the cases mentioned above make the CED tone optional, is this correct?<br></div></blockquote><div><br></div><div style>I am still not sure if there are cases where CED is optional but V.21 Preamble is not and SpanDSP detects both of them. A question remains... I&#39;ve read that CED (also called ASN in docs) is the same 2100Hz tone emitted by answering machines. Does that mean we also start fax when there is an answering machine on the other end?</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div></div><div><br></div><div>By talking to Steve Underwood yesterday on IRC, he mentioned that (and I quote):</div>

<div>&quot;the emitting gateway should detect the signal from the answering FAX machine and initiate the change to T.38&quot;. My understanding is that on 3 for example, FSA needs to detect CED being sent from FaxB, correct?</div>
</blockquote><div><br></div><div style>That is correct. The reason why it was not working for me is because I&#39;ve found a bug on latest stable that has been resolved on HEAD (I am doing a bisect tomorrow) that removes the media bug installed by spandsp before it has a chance to detect CED.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div><br></div><div>Looking at the T.38 standard Annex D to understand who should initiate a T.38 re-invite at what instance, I found this phrase:</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">

&quot;The receiving gateway should only use the ITU-T V.21 preamble generated by the answering FAX endpoint as the trigger for detection, and it should generate the INVITE request no more than 200 milliseconds after the ITU-T V.21 preamble begins, in order to allow the maximum amount of time for the session to transition into ITU-T T.38 mode before the answering FAX endpoint begins transmitting NSF, CSI or DIS.&quot;</blockquote>

<div>Googling, I found that the ITU-T V.21 preamble is not CNG or CED tone, but rather something else...  I assume that the _OR_PREAMBLE is exactly that, correct?</div></blockquote><div><br></div><div style>That is also correct.</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><br></div><div>I greatly appreciate any help as the Wiki is not very specific on the analog fax stuff. My intent is to wikify all that and help the folks out there as well. Fax seems to be mistic for more than myself.</div>

<div><br></div><div>Regards,</div><div>Joćo Mesquita<br></div>
</blockquote></div><br></div></div>