Dear Pavel,
On 01/30/2014 06:55 AM, Pavel Troller wrote:
I probably found what causes random segfaults during fax detection with
spandsp... Many thanks for your contributions and brainstorming about this,
it helped a lot. If you have such issue, please test this possible fix and
let me know...
At res_fax.c, somewhere around line 3070, you'll find (at least for
Asterisk 11)
case AST_FORMAT_ALAW:
case AST_FORMAT_ULAW:
Comment out these two lines, recompile, reload and test.
As I understand the code, by commenting out these lines, we'll just abandon
the frame hook for A/ULAW samples, so we'll never gateway them then... Yes,
it will probabaly stop segfaulting, but as a side-effect, it will stop
gatewaying as well :-). Of course I may be wrong, I just had a little look
there...
I tested this fix before posting to the list, and T38 gatewaying is
working with it, at least in my setup (between DAHDI and SIP). I tested
both ways (SIP->DAHDI, DAHDI->SIP) and fax receipt was successful.
Gateway is enabled in sip.conf, in peer section:
setvar=FAXOPT(t38gateway)=yes,20
However, it seems that there is really a bug in the hook.
- On line 3130, we are attempting to translate the frames before we write
them to the faxing engine (on line 3141). It's OK.
- BUT: On line 3122, we are calling fax_gateway_detect_v21() with
UNTRANSLATED frames, which is FATAL - this detection can handle only linear
format similarly as real faxing, so we have to translate non-linear formats
(A/ULAW) for it as well! By not doing this, we probably
1) prevent successful detection of V.21, so it doesn't work either
2) In rare cases, crash the whole thing, because the detection code always
tries to read 320 bytes from 160byte buffer (as Michal pointed out below).
Once again, I may be wrong, but I think it's in accordance with all the
symptoms we have already collected.
.... it seems that you really don't like my quick fix :o)) OK, then
forget it, and try this instead:
# diff res/res_fax.c.orig res/res_fax.c
2963a2964
> struct ast_frame *tmpframe = &ast_null_frame;
3117a3119,3131
>
> if (f->subclass.format.id != AST_FORMAT_SLINEAR) {
>
> if (ast_channel_readtrans(active) && (tmpframe
= ast_translate(ast_channel_readtrans(active), f, 0)) == NULL) {
> ast_debug(5, "frame translation to
slinear failed, v21 detection skipped\n");
> return f; // translation unsuccessful,
dont start v21 detection
> }
> ast_debug(5, "frame translated to slinear for
v21 detection\n");
> fax_gateway_detect_v21(gateway, chan, peer,
active, tmpframe);
> ast_frfree(tmpframe);
> return f;
> }
>
This code will translate non-slinear frames to slinear, just before they
are sent to libspandsp for v21detection. With this patch applied, v21
detection is done also for RTP (SIP) alaw/ulaw frames, so maybe SIP/G711
<-> SIP/T38 gateway will work too. I tested DAHDI <-> SIP/T38, gateway
works both ways, voice calls too. Is it better now? :o)
--
Michal Rybarik
--
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --
asterisk-dev mailing list
To UNSUBSCRIBE or update options visit:
http://lists.digium.com/mailman/listinfo/asterisk-dev