Synopsis:
SMfeedlisten(chan1_id,chan1_type,chan2_id,chan2_type)
Arguments:
chan1_id – The channel into which the feed will be fed
chan1_type - The channel type (TYPE_VOX, TYPE_VMP, TYPE_TDM)
chan2_id - The channel whose feed to listen to
chan2_type - The channel type (TYPE_VOX, TYPE_VMP, TYPE_TDM)
Description: This function makes the channel specified by the arguments chan1_id and chan1_type 'listen' to the datafeeds provided by the channel specified by the arguments chan2_id and chan2_type.
The specified channels can be one of the following types as defined in aculab.inc:
const TYPE_VOX=0;
const TYPE_VMP=1;
const TYPE_TDM=2;
Channel types TYPE_VMP and TYPE_TDM must be have been previously created using the appropriate functions (SMcreateVMP() or SMcreateTMD()), whereas TYPE_VOX channels are allocated at startup.
The first time a TYPE_VOX, TYPE_VMP, or TYPE_TDM channel is used as a feed (i.e as chan2_id and chan2_type arguments) then the datafeed for that channel is created and stored in the internal structure associated with that channel.
For example, if you make a VMP channel listen to a VOX channel datafeed then any prompts or tones played on that VOX channel will be output by the VMP channel. For Example:
int vox_chan, port, chan, vmp_chan, module_id;
vox_chan=1;
module_id=0;
port=0;
chan=1;
vmp_chan=SMcreateVMP(module_id);
// The vmp_chan will now listen to the vox_chan datafeed
SMfeedlisten(vmp_chan,TYPE_VMP,vox_chan,TYPE_VOX);
// Wait for an inbound call (using the newly created VMP when we accept)
CCenablein(port,chan);
while(1)
x=CCwait(port,chan,WAIT_FOREVER,&state);
if(state eq CS_INCOMING_CALL_DET)
CCalerting(port,chan); // send INCOMING_RINGING event
else if(state eq CS_WAIT_FOR_ACCEPT)
vmp_chan=SMcreateVMP(module_id);
// specify a codec on the vmp channel
SMsetcodec(vmp_chan,0,G711_ALAW);
CCclrparms(port,chan,PARM_TYPE_ACCEPT);
CCsetparm(port,chan,PARM_TYPE_ACCEPT,CP_IPTEL_VMPRXID,vmp_chan);
CCsetparm(port,chan,PARM_TYPE_ACCEPT,CP_IPTEL_VMPTXID,vmp_chan);
CCsetparm(port,chan,PARM_TYPE_ACCEPT,CP_IPTEL_CODECS,vmp_chan);
CCaccept(port,chan);
endif endif
endwhile
// play a prompt which because of the above SMfeedlisten() will be heard by the caller..
SMplay(vox_chan,"TEST.VOX");
... etc
To make a full duplex connection then make each channel listen to the other:
// The vmp_chan will now listen to the vox_chan datafeed
SMfeedlisten(vmp_chan,TYPE_VMP,vox_chan,TYPE_VOX);
// The vox_chan will now listen to the vmp_chan datafeed
SMfeedlisten(vox_chan,TYPE_VMP,vox_chan,TYPE_VMP);
For IP to TDM calls then the datafeeds from the VMP and the TDM can be connected as follows:
int vox_chan, port, chan, vmp_chan, module_id;
vox_chan=1;
module_id=0;
e1port=0;
e1chan=1;
ipport=8;
ipchan=1;
tdm_chan=CCcreateTDM(e1port,e1chan); // Get a TDM endpoint for an E1 channel
vmp_chan=SMcreateVMP(module_id); // Create a VMP channel
// specify a codec on the vmp channel
SMsetcodec(vmp_chan,0,G711_ALAW);
// Wait for an inbound call on IP channel(using the newly created VMP when we accept)
CCenablein(ipport,ipchan);
while(1)
x=CCwait(ipport,ipchan,WAIT_FOREVER,&state);
if(state eq CS_INCOMING_CALL_DET)
CCalerting(ipport,ipchan); // send INCOMING_RINGING event
else if(state eq CS_WAIT_FOR_ACCEPT)
// specify a codec on the vmp channel
SMsetcodec(vmp_chan,0,G711_ALAW);
CCclrparms(ipport,ipchan,PARM_TYPE_ACCEPT);
CCsetparm(ipport,ipchan,PARM_TYPE_ACCEPT,CP_IPTEL_VMPRXID,vmp_chan);
CCsetparm(ipport,ipchan,PARM_TYPE_ACCEPT,CP_IPTEL_VMPTXID,vmp_chan);
CCsetparm(ipport,ipchan,PARM_TYPE_ACCEPT,CP_IPTEL_CODECS,vmp_chan);
CCaccept(ipport,ipchan);
endif endif
endwhile
// Now make outbound call on E1 port/channel
x=CCmkcall(e1port,e1chan,"123456"."987654");
while(1)
x=CCwait(e1port,e1chan,WAIT_FOREVER,&state);
if(state eq CS_OUTGOING_RINGING)
applog("Outgoing ringing") // send INCOMING_RINGING event
else if(state eq CS_CALL_CONNECTED)
break;
else if(state eq CS_CALL_DISCONNECTED)
// clear down the calls here and restart..
cleardown_calls();
restart;
endif endif
endwhile
// ** Now connect the feeds from the VMP and TDM endpoint to make
// ** a full duplex connection to connect the conversations from the IP to E1 calls
// The vmp_chan will now listen to the tdm_chan datafeed
SMfeedlisten(vmp_chan,TYPE_VMP,tdm_chan,TYPE_TDM);
// The tdm_chan will now listen to the vpm_chan datafeed
SMfeedlisten(tdm_chan,TYPE_TDM,vpm_chan,TYPE_VPM);
// The conversations are now connected..
etc
Returns: Upon success it returns 0, otherwise a negative error code.