CERROR(call, NULL, "Linked call structure has no link to us.\n");
call->bridge_call->bridge_call = NULL;
}
+ if (call->trans)
+ ast_translator_free_path(call->trans);
+ if (call->dsp)
+ ast_dsp_free(call->dsp);
CDEBUG(call, NULL, "Call instance freed.\n");
free(call);
return;
{
union parameter newparam;
char string[1024], *p = string, *opt, *key;
- int gain, i, newmode = 0;
+ int gain, i;
if (!data[0])
return; // no opts
break;
}
CDEBUG(call, call->ast, "Option 'h' (HDLC).\n");
- if (!call->hdlc) {
+ if (!call->hdlc)
call->hdlc = 1;
- newmode = 1;
- }
break;
case 't':
if (opt[1] != '\0') {
break;
}
CDEBUG(call, call->ast, "Option 't' (no dsp).\n");
- if (!call->nodsp) {
+ if (!call->nodsp)
call->nodsp = 1;
- newmode = 1;
- }
break;
case 'e':
if (opt[1] == '\0') {
if (call->bchannel)
bchannel_pipeline(call->bchannel, call->pipeline);
break;
+ case 'f':
+ if (opt[1] == '\0') {
+ CERROR(call, call->ast, "Option 'f' (faxdetect) expects parameter.\n", opt);
+ break;
+ }
+ call->faxdetect=atoi(opt+1);
+ if (!call->dsp)
+ call->dsp=ast_dsp_new();
+ if (call->dsp) {
+ ast_dsp_set_features(call->dsp, DSP_FEATURE_DTMF_DETECT| DSP_FEATURE_FAX_DETECT);
+ if (!call->trans)
+ call->trans=ast_translator_build_path(AST_FORMAT_SLINEAR, (options.law=='a')?AST_FORMAT_ALAW:AST_FORMAT_ULAW);
+ }
+ CDEBUG(call, call->ast, "Option 'f' (faxdetect) with config '%s'.\n", call->faxdetect);
+ break;
case 'r':
if (opt[1] != '\0') {
CERROR(call, call->ast, "Option 'r' (re-buffer 160 bytes) expects no parameter.\n", opt);
}
CDEBUG(call, call->ast, "Option 'r' (re-buffer 160 bytes)");
call->rebuffer = 1;
+ call->framepos = 0;
break;
case 's':
if (opt[1] != '\0') {
/* re-open, if bchannel is created */
if (call->bchannel && call->bchannel->b_sock > -1) {
bchannel_destroy(call->bchannel);
- if (bchannel_create(call->bchannel, ((call->nodsp)?1:0) + ((call->hdlc)?2:0)))
+ if (bchannel_create(call->bchannel, ((call->nodsp || call->faxdetect > 0)?1:0) + ((call->hdlc)?2:0)))
bchannel_activate(call->bchannel, 1);
}
}
bchannel_join(bchannel, call->bridge_id);
}
/* create only, if call exists, othewhise it bchannel is freed below... */
- if (bchannel_create(bchannel, ((call->nodsp)?1:0) + ((call->hdlc)?2:0)))
+ if (bchannel_create(bchannel, ((call->nodsp || call->faxdetect > 0)?1:0) + ((call->hdlc)?2:0)))
bchannel_activate(bchannel, 1);
}
/* acknowledge */
return -1;
}
if (call->bchannel && f->samples)
- bchannel_transmit(call->bchannel, f->data, f->samples);
+ bchannel_transmit(call->bchannel, (unsigned char *)f->data, f->samples);
ast_mutex_unlock(&chan_lock);
return 0;
}
}
if (call->pipe[0] > -1) {
if (call->rebuffer && !call->hdlc) {
- len = read(call->pipe[0], call->read_buff, 160);
+ /* Make sure we have a complete 20ms (160byte) frame */
+ len=read(call->pipe[0],call->read_buff + call->framepos, 160 - call->framepos);
+ if (len > 0) {
+ call->framepos += len;
+ }
} else {
len = read(call->pipe[0], call->read_buff, sizeof(call->read_buff));
}
call->pipe[0] = -1;
ast_mutex_unlock(&chan_lock);
return NULL;
+ } else if (call->rebuffer && call->framepos < 160) {
+ /* Not a complete frame, so we send a null-frame */
+ ast_mutex_unlock(&chan_lock);
+ return &ast_null_frame;
}
}
call->read_fr.frametype = AST_FRAME_VOICE;
call->read_fr.subclass = ast->nativeformats;
- call->read_fr.datalen = len;
- call->read_fr.samples = len;
+ if (call->rebuffer) {
+ call->read_fr.datalen = call->framepos;
+ call->read_fr.samples = call->framepos;
+ call->framepos = 0;
+ } else {
+ call->read_fr.datalen = len;
+ call->read_fr.samples = len;
+ }
call->read_fr.delivery = ast_tv(0,0);
- call->read_fr.data = call->read_buff;
+ *((unsigned char **)&(call->read_fr.data)) = call->read_buff;
ast_mutex_unlock(&chan_lock);
return &call->read_fr;
return AST_BRIDGE_COMPLETE;
}
- /* join, if both call instances uses dsp */
+ /* join, if both call instances uses dsp
+ ignore the case of fax detection here it may be benificial for ISDN fax machines or pass through.
+ */
if (!call1->nodsp && !call2->nodsp) {
CDEBUG(NULL, NULL, "Both calls use DSP, bridging via DSP.\n");
" n - Don't detect dtmf tones on called channel.\n"
" h - Force data call (HDLC).\n"
" t - Disable mISDN_dsp features (required for fax application).\n"
+ " f - Adding fax detection. It it timeouts, mISDN_dsp is used.\n"
+ " Use time to detect for optarg.\n"
" c - Make crypted outgoing call, optarg is keyindex.\n"
" e - Perform echo cancelation on this channel.\n"
" Takes mISDN pipeline option as optarg.\n"
" s - Send Non Inband DTMF as inband.\n"
+ " r - re-buffer packets (160 bytes). Required for some SIP-phones and fax applications.\n"
" vr - rxgain control\n"
" vt - txgain control\n"
" Volume changes at factor 2 ^ optarg.\n"