SMdestroyVMP
Previous Topic  Next Topic 

Synopsis:

       SMdestryVMP(vmp_chan)


Arguments:

       vmp_chan                 The VMP channel handle (as returned from SMcreateVMP())


Description:   This function releases the VMP end-point specified by vmp_chan and frees the handle.    It is up to the programmer to decide whether VMP channels are allocated once upon start-up or whether they are allocated dynamically as and when required (e.g. when an inbound IP call is detected).


The following example shows a VMP being created dynamically when an inbound call is received on an IP channel after which it is destroyed with SMdestroyVMP():


$include "aculab.inc"

main

   int port,chan,vox_chan,module_id,x,state;

      port=0;  

      chan=1;

      vox_chan=1;

      module_id=0;


      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


      // make full duplex connection between VMP and a voice channel datafeeds

      SMfeedlisten(vmp_chan,TYPE_VMP,vox_chan,TYPE_VOX);

      SMfeedlisten(vox_chan,TYPE_VOX,vmp_chan,TYPE_VMP);


      // play a prompt

      SMplay(vox_chan,"TEST.VOX");


      // Stop the full duplex listen to datafeeds

      SMfeedunlisten(vmp_chan,TYPE_VMP);

      SMfeedunlisten(vox_chan,TYPE_VOX);

      // release the VMP

      SMdestroyVMP(vmp_chan);


      // Clear down the call

      CChangup(port,chan);

      while(CCstate(port,chan)!=CS_IDLE)

          sleep(1);

      endwhile

      CCrelease(port,chan);


      // restart program to wait for next call..

      restart;

endmain

          


          

    


Returns:   0 upon success or a negative error code.