⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 srldevice.cpp

📁 Conferencing code using Dialogic hardware
💻 CPP
📖 第 1 页 / 共 3 页
字号:
// Returns:	
//    true = success
//*****************************************************************************
bool CSrlDevice::StopDx(){
int rc;

  // play it
  rc = dx_stopch(m_dx_srl_handle, EV_ASYNC);

      LOG( RC(rc), GetName(),
           "%d = dx_stopch(hndl=0x%x,  EV_ASYNC)",
           rc, m_dx_srl_handle);

      if ( rc == AT_FAILURE){
           process_dx_error(m_dx_srl_handle, GetName());
           return false;                             
      }

    return true;
} // End of StopDx()

//*****************************************************************************
// Purpose	: 
//    Get reason for terminating voice operation
// Parameters:	
//    none
// Returns:	
//    true = success
//*****************************************************************************
bool CSrlDevice::GetTermReason(){

  // play it
  int termno = ATDX_TERMMSK(m_dx_srl_handle);
  const char *termname = dx_get_termination(termno);  

  LOG( LOG_API, GetName(),
       "%d = ATDX_TERMMSK(hndl=0x%x) [%s])",
       termno, m_dx_srl_handle, termname);

 return true;
} // End of GetTermReason()

//*****************************************************************************
// Purpose	: 
//    Clear FW Digit buffer
// Parameters:	
//    none
// Returns:	
//    true = success
//*****************************************************************************
bool CSrlDevice::ClearDigits(){
bool brc = true;
int rc = dx_clrdigbuf(m_dx_srl_handle);
  LOG( RC(rc), GetName(),
       "%d = dx_clrdigbuf(hndl=0x%x)",
       rc, m_dx_srl_handle);

  if (rc == AT_FAILURE){
      process_dx_error(m_dx_srl_handle, GetName());
      brc = false;
  }

  return brc;
} // End of GetTermReason()

//*****************************************************************************
// Purpose	: 
//    Close voice file handle (if any)
// Parameters:	
//    none
// Returns:	
//    true = success
//*****************************************************************************
bool CSrlDevice::CloseVoiceFile(){
     if (m_iott.io_fhandle != INV_FILE_HANDLE) {
         int rc = dx_fileclose(m_iott.io_fhandle);
         LOG(LOG_DBG, GetName(), "%d = dx_fileclose(0x%x)",rc, m_iott.io_fhandle);
         m_iott.io_fhandle = INV_FILE_HANDLE;
     }
  return true;
} // End of CloseVoiceFile()

//*****************************************************************************
// Purpose	: 
//    Voice device listen to gc/ntwk(3PCC mode) device and vice versa
// Parameters:	
//    none
// Returns:	
//    bool (true = success)
//*****************************************************************************
bool CSrlDevice::RouteVoice(){
int rc;
long ntwk_xmit;

    SC_TSINFO ts_info;
    ts_info.sc_numts = 1;
    ts_info.sc_tsarrayp = &ntwk_xmit;

    //-------------------
    // Voice listen to gc/ ntwk

    // Get gc xmit slot
    if (Is3PCCMode()){
        rc =  ipm_GetXmitSlot(m_ntwk_srl_handle, &ts_info, EV_SYNC);
        LOG(  RCFATAL(rc), GetName(),
              "%d = ipm_GetXmitSlot(ipm hndl = 0x%x, &tc_info, EV_SYNC)",
              rc, m_ntwk_srl_handle);
   
        if ( rc != GC_SUCCESS) {
             SetSrlState ( SRLSTATE_FAILED_FATAL );
             process_ipml_error(m_ntwk_srl_handle, GetName());
             return false;
        }
    }else {
        rc =  gc_GetXmitSlot(m_srl_handle, &ts_info);
        LOG(  RCFATAL(rc), GetName(),
              "%d = gc_GetXmitSlot(gc hndl = 0x%x, &tc_info)",
              rc, m_srl_handle);
   
        if ( rc != GC_SUCCESS) {
             SetSrlState ( SRLSTATE_FAILED_FATAL );
             process_gc_error();
             return false;
        }
    }
    gc_dump(&ts_info);
    // voice listen to gc
    rc = dx_listen(m_dx_srl_handle, &ts_info);
    LOG( RCFATAL(rc), GetName(),
         "%d = dx_listen(dx hndl = 0x%x, &tc_info)",
         rc, m_dx_srl_handle);

    if ( rc != EDX_NOERROR) {
         SetSrlState ( SRLSTATE_FAILED_FATAL );
         process_dx_error(m_dx_srl_handle, m_dx_name);
         return false;
    }

    //-------------------
    // gc listen to voice

    // get voice xmit slot
    long voice_xmit;
    ts_info.sc_numts = 1;
    ts_info.sc_tsarrayp = &voice_xmit;

    rc = dx_getxmitslot(m_dx_srl_handle, &ts_info);
    LOG( RCFATAL(rc) , GetName(),
         "%d = dx_getxmitslot(dx hndl=0x%x, &ts_info)",
         rc, m_dx_srl_handle);

    if ( rc == AT_FAILURE) {
         SetSrlState ( SRLSTATE_FAILED_FATAL );
         process_dx_error(m_dx_srl_handle, m_dx_name);
         return false;
    }

    gc_dump(&ts_info);

    int handle;
    const char *name;
    if ( Is3PCCMode() ) {
        handle = m_ntwk_srl_handle;
        name = "ipml";
    }else {
        handle = m_srl_handle;
        name = "gc";
    }

    if (Is3PCCMode() ){
    // ipm listen to voice
        rc = ipm_Listen(m_ntwk_srl_handle, &ts_info, EV_SYNC);
        LOG( RCFATAL(rc), GetName(),
             "%d = ipm_Listen(ntwk hndl = 0x%x, &ts_info, EV_SYNC)",
             rc, m_ntwk_srl_handle);
        PutEvent(USREV_IPML_LISTEN, GetName());

        if ( rc != GC_SUCCESS) {
             SetSrlState ( SRLSTATE_FAILED_FATAL );
             process_ipml_error(m_ntwk_srl_handle, GetName());
             return false;
        }
    }else {
    // gc listen to voice
        rc = gc_Listen(m_srl_handle, &ts_info, EV_ASYNC);
        LOG( RCFATAL(rc), GetName(),
             "%d = gc_Listen(gc hndl = 0x%x, &ts_info, EV_ASYNC)",
             rc, m_srl_handle);

        if ( rc != GC_SUCCESS) {
             SetSrlState ( SRLSTATE_FAILED_FATAL );
             process_gc_error();
             return false;
        }
    }

 return true;
} // End of RouteVoice()

// Undo RouteVoice
bool CSrlDevice::UnListen(){
int rc;

    //-------------------------
    // Voice  gc/ ntwk unlisten

    if (Is3PCCMode()){
        rc =  ipm_UnListen(m_ntwk_srl_handle, EV_ASYNC);
        LOG(  RCFATAL(rc), GetName(),
              "%d = ipm_UnListen(ipm hndl = 0x%x, EV_ASYNC)",
              rc, m_ntwk_srl_handle);
   
        if ( rc != GC_SUCCESS) {
             SetSrlState ( SRLSTATE_FAILED_FATAL );
             process_ipml_error(m_ntwk_srl_handle, GetName());
             return false;
        }
    }else {
        rc =  gc_UnListen(m_srl_handle, EV_ASYNC);
        LOG(  RCFATAL(rc), GetName(),
              "%d = gc_UnListen(gc hndl = 0x%x, EV_ASYNC)",
              rc, m_srl_handle);
   
        if ( rc != GC_SUCCESS) {
             SetSrlState ( SRLSTATE_FAILED_FATAL );
             process_gc_error();
             return false;
        }
    }
 return true;
} // End of RouteVoice()

//*****************************************************************************
// Purpose	: 
//    dev_Connect cnf party to other device
// Parameters:	
//    [in] device type (DEV_DX_PARTY or DEV_NTWK_PARTY)
// Returns:	
//    true = success
//*****************************************************************************
bool CSrlDevice::DevConnect(DEV_PARTY party){
SRL_DEVICE_HANDLE hndl;
const char *devname;
   switch ( party) {
       case DEV_DX_PARTY:
            hndl = m_dx_srl_handle;
            devname = "dx handle";
            break;
       case DEV_NTWK_PARTY:
            hndl = m_ntwk_srl_handle;
            devname = "ntwk handle";
            break;
       case DEV_CNF_PARTY:
       default:
            LOG(LOG_ASSERT, GetName(), "DevDisconnect:: Invalid parameter %d", party);
            return false;
   } // switch(party)
   int rc = dev_Connect(hndl, m_cnf_party_srl_handle, DM_FULLDUP, EV_ASYNC); 
   bool brc = true;
   LOG( RC(rc), GetName(), 
        "%d = dev_Connect(%s=0x%x, cnf_party=0x%x, DM_FULLDUP, EV_ASYNC)",
        rc, devname, hndl, m_cnf_party_srl_handle);
   
   if (rc == BRD_FAILURE){
      process_dev_error( );
      brc = false;
   }
   return brc;
}// End of DevConnect()


//*****************************************************************************
// Purpose	: 
//    dev_Disconnect party 
// Parameters:	
//    [in] device type (DEV_DX_PARTY,  DEV_NTWK_PARTY or DEV_CNF_PARTY )
// Returns:	
//    true = success
//*****************************************************************************
bool CSrlDevice::DevDisconnect(DEV_PARTY party){
SRL_DEVICE_HANDLE hndl;
const char *devname;
   switch ( party) {
       case DEV_CNF_PARTY:
            hndl = m_cnf_party_srl_handle;
            devname = "cnf party handle";
            break; 
       case DEV_DX_PARTY:
            hndl = m_dx_srl_handle;
            devname = "dx handle";
            break;
       case DEV_NTWK_PARTY:
            hndl = m_ntwk_srl_handle;
            devname = "ntwk handle";
            break;
       default:
            LOG( LOG_ASSERT, GetName(),
                 "DevDisconnect:: Invalid parameter %d", party);
            return false;
   }// switch(party)

   int rc = dev_Disconnect(hndl, EV_ASYNC); 
   bool brc = true;

   LOG( RC(rc), GetName(), 
        "%d = dev_Disconnect(%s = 0x%x, EV_ASYNC)",
        rc, devname, hndl);
   
   if ( rc == BRD_FAILURE){
        process_dev_error();
        brc = false;
   }
   return brc;
}// End of DevDisconnect()

//*****************************************************************************
// Purpose	: 
//    Find conference party 
// Parameters:	
//    none
// Returns:	
//    true = success
//*****************************************************************************
bool CSrlDevice::OpenParty(){
  CNF_ASSERT(m_pCnfBoard, "Missing m_pCnfBoard object");

  int srl_handle = m_pCnfBoard->OpenParty(this);
  if ( CNF_ERROR != srl_handle ){
       m_cnf_party_srl_handle = srl_handle;
  } 
  
  LOG(LOG_DBG, GetName(), "0x%x = OpenParty()", srl_handle);
  
 return true;
}// End of OpenParty()

//*****************************************************************************
// Purpose	: 
//    Release conference party
// Parameters:	
//    none
// Returns:	
//    true = success
//*****************************************************************************
bool CSrlDevice::CloseParty(){
  CNF_ASSERT(m_pCnfBoard, "Missing m_pCnfBoard object");

  bool brc = m_pCnfBoard->CloseParty(m_cnf_party_srl_handle);

  LOG(LOG_DBG, GetName(), "%s = CloseParty(0x%x)",brc?"true":"false", m_cnf_party_srl_handle);
  if ( brc ){
       m_cnf_party_srl_handle = INV_SRL_HANDLE;
  }
 
 return brc;
}// End of CloseParty()

//*****************************************************************************
// Purpose	: 
//    Set conference attributes according to configuration parameters
// Parameters:	
//    none
// Returns:	
//    true = success
//*****************************************************************************
bool CSrlDevice::SetPartyAttributes(ECNF_ATTR_STATE clamping){
    CNF_ATTR CnfAttr[2];
    CNF_ATTR_INFO CnfAttrInfo;
    int inx = 0;
      CnfAttrInfo.unVersion = CNF_ATTR_INFO_VERSION_0; ///< Structure version
      CnfAttrInfo.pAttrList = CnfAttr;                 ///< Pointer to attribute structure list
        
      CnfAttr[inx].unVersion   = CNF_ATTR_VERSION_0 ;           ///< Structure version
      CnfAttr[inx].unAttribute = ECNF_PARTY_ATTR_TONE_CLAMPING; ///< Attribute type
      CnfAttr[inx].unValue     = clamping;                      ///< Disable tone clamping
        
      CnfAttrInfo.unAttrCount = inx+1;                 ///< Number of attribute structures in list

      bool brc = false;
      int rc;

      rc = cnf_SetAttributes(m_cnf_party_srl_handle, &CnfAttrInfo, this);

      cnf_dump(&CnfAttrInfo);
      LOG( RC(rc), GetName(),
           "%d = cnf_SetAttributes(0x%x,attr,0x%x(this))",
           rc, m_cnf_party_srl_handle, this);

 
        if (rc == CNF_ERROR) {
            process_cnf_error();
        }else {
            brc = true;
        }

   return brc;
} // End of SetAttributes()

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -