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

📄 cnfboard.cpp

📁 Conferencing code using Dialogic hardware
💻 CPP
📖 第 1 页 / 共 2 页
字号:
       pConf->SetCnfBoard(0);
   } 

 // Close Board
    Close();
 return;
}  // End of Destructor()

//*****************************************************************************
// Purpose	: 
//    Find conference by pass code
// Parameters:	
//    [in]  pass code
//    [out] Holder to return conference
// Returns:	
//    true = found
//    false = not found
//*****************************************************************************
bool CnfBoard::FindConferenceByPassCode(const char *pass_code, PCnfConference *ppConf){
   list<PSrlDevice>::iterator pos;
   PCnfConference pConf;
   for ( pos = begin(); pos != end(); ++pos) {
       pConf = static_cast<PCnfConference>(*pos);
       if ( pConf->IsPassCode(pass_code) ){
           LOG(LOG_DBG, GetName(), "CheckConference: passCode=%s, Cnf=%s, passed", pass_code, pConf->GetName());
           *ppConf = pConf; 
           return true;
       }
       LOG(LOG_DBG, GetName(), "CheckConference: passCode=%s, Cnf=%s, failed", pass_code, pConf->GetName());
   } 
  return false;
} // End of FindConferenceByPassCode()

//*****************************************************************************
// Purpose	: 
//    Find conference by Id
// Parameters:	
//    [in] id
//    [out] Holder to return conference
// Returns:	
//    true = found
//    false = not found
//*****************************************************************************
bool CnfBoard::FindConferenceById(int id, PCnfConference *ppConf){
   list<PSrlDevice>::iterator pos;
   PCnfConference pConf;
   for ( pos = begin(); pos != end(); ++pos) {
       pConf = static_cast<PCnfConference>(*pos);
       if ( pConf->IsId(id) ){
           *ppConf = pConf; 
           return true;
       }
   } 
  return false;
} // End of FindConferenceById()


//*****************************************************************************
// Purpose	: 
//    Open Conference bard
// Parameters:	
//    none
// Returns:	
//    true = success
//*****************************************************************************
bool CnfBoard::Open(){
 bool brc = false;
 int rc;
    if ( IsSrlState(SRLSTATE_RESERVED, true) ) { 
        rc = cnf_Open(GetName(), 0, this);
        LOG(RCHANDLE(rc), GetName(),
                 "0x%x = cnf_Open(%s,0,0x%x(this))",
                 rc,GetName(),this);
        if (rc == CNF_ERROR) {
            process_cnf_error();
            SetCurrentState(S_FINAL);
            SetSrlState(SRLSTATE_FAILED_FATAL);
        }else {
            brc = true;
            m_srl_handle = rc;
            SetCurrentState(S_OPEN);
            SetSrlState(SRLSTATE_OPENED);
        }
    }else {
       LOG( LOG_ERR1, GetName(),
            "cnf_Open(): (board) - device not reserved");
       SetCurrentState(S_FINAL);
       SetSrlState(SRLSTATE_FAILED_FATAL);
    }
 return brc;
} // End of Open()

//*****************************************************************************
// Purpose	: 
//    Close conference board
// Parameters:	
//    none
// Returns:	
//    true = success
//*****************************************************************************
bool CnfBoard::Close(){
 bool brc = true;
 int rc;

    if( IsSrlState(SRLSTATE_OPENED, true) ){
        if ( IsSrlState(SRLSTATE_WAITEVENT, true) ){
               LOG( LOG_WARNING, GetName(),
                    "cnf_Close() while waiting for event, state = %d %s",
                    GetCurrentState(), state_name(GetCurrentState()));
                    DumpMissingEvents();
        }

        if (m_number_of_parties > 0 ){
               LOG( LOG_WARNING, GetName(),
                    "cnf_Close() while %d parties are still open",
                    m_number_of_parties);
        }
        
        if (m_number_of_conferences > 0 ){
               LOG( LOG_WARNING, GetName(),
                    "cnf_Close() while %d conferences are still open",
                    m_number_of_conferences );
        }

        CNF_CLOSE_INFO CloseInfo;
        rc = cnf_Close(m_srl_handle, &CloseInfo);

//      This is RFU
//      cnf_dump(&CloseInfo); 

        LOG( RC(rc), GetName(),
                     "%d = cnf_close(0x%x)",
                     rc, m_srl_handle);

        brc = (rc == 0);
        if (!brc){
            process_cnf_error();
        } else {
            m_srl_handle = INV_SRL_HANDLE;
        }

        SetCurrentState(S_FINAL);
        SetSrlState(SRLSTATE_ALL, RESET_SRL_STATE);
    }

 return brc;
} // End of Close()

//*****************************************************************************
// Purpose	: 
//    Enable events
// Parameters:	
//    none
// Returns:	
//    true = success
//*****************************************************************************
bool CnfBoard::EnableEvents(){

    CNF_EVENT_INFO CnfEventInfo;
    unsigned int EventList[] = { 
         ECNF_BRD_EVT_CONF_OPENED,
         ECNF_BRD_EVT_CONF_CLOSED,
         ECNF_BRD_EVT_PARTY_ADDED,
         ECNF_BRD_EVT_PARTY_REMOVED,
//         ECNF_BRD_EVT_ACTIVE_TALKER
    };
    CnfEventInfo.unVersion = CNF_EVENT_INFO_VERSION_0;  ///< Structure version
    CnfEventInfo.unEventCount = sizeof(EventList)/sizeof(unsigned int);  ///< Number of events in list
    CnfEventInfo.punEventList = EventList;              ///< Pointer to event list

    bool brc = false;
    int rc;

    rc = cnf_EnableEvents(m_srl_handle, &CnfEventInfo, this);

    cnf_dump(&CnfEventInfo);

    LOG(RC(rc), GetName(), "%d = cnf_EnableEvents(0x%x, CNF_EVENT_INFO, 0x%x(this))",
                            rc,m_srl_handle,this);

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

   return brc;
} // End of EnableEvents()
//*****************************************************************************
// Purpose	: 
//    Disable events
// Parameters:	
//    none
// Returns:	
//    true = success
//*****************************************************************************
bool CnfBoard::DisableEvents(){

    CNF_EVENT_INFO CnfEventInfo;
    unsigned int EventList[] = { 
         ECNF_BRD_EVT_CONF_OPENED,
         ECNF_BRD_EVT_CONF_CLOSED,
         ECNF_BRD_EVT_PARTY_ADDED,
         ECNF_BRD_EVT_PARTY_REMOVED,
//         ECNF_BRD_EVT_ACTIVE_TALKER
    };
    CnfEventInfo.unVersion = CNF_EVENT_INFO_VERSION_0;  ///< Structure version
    CnfEventInfo.unEventCount = sizeof(EventList)/sizeof(unsigned int);  ///< Number of events in list
    CnfEventInfo.punEventList = EventList;              ///< Pointer to event list

    bool brc = false;
    int rc;

    rc = cnf_DisableEvents(m_srl_handle, &CnfEventInfo, this);

    cnf_dump(&CnfEventInfo);

    LOG(RC(rc), GetName(), "%d = cnf_DisableEvents(0x%x, CNF_EVENT_INFO, 0x%x(this))",
                            rc,m_srl_handle,this);

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

   return brc;
} // End of DisableEvents()

//*****************************************************************************
// Purpose	: 
//    Request device count
// Parameters:	
//    none
// Returns:	
//    true = success
//*****************************************************************************
bool CnfBoard::GetDeviceCount(){

   bool brc = false;
   int rc;

   rc = cnf_GetDeviceCount(m_srl_handle,  this);

   LOG(RC(rc), GetName(), "%d = cnf_GetDeviceCount(0x%x, 0x%x(this))",
                           rc,m_srl_handle,this);

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

   return brc;
} // End of GetDeviceCount()

//*****************************************************************************
// Purpose	: 
//    Set attributes
// Parameters:	
//    none
// Returns:	
//    true = success
//*****************************************************************************
bool CnfBoard::SetAttributes(){
    CNF_ATTR CnfAttr[3];
        CnfAttr[0].unVersion   = CNF_ATTR_VERSION_0 ;           ///< Structure version
        CnfAttr[0].unAttribute = ECNF_BRD_ATTR_ACTIVE_TALKER;   ///< Attribute type
        CnfAttr[0].unValue     = brd_ActiveTalker;              ///< Attribute value

        CnfAttr[1].unVersion   = CNF_ATTR_VERSION_0 ;           ///< Structure version
        CnfAttr[1].unAttribute = ECNF_BRD_ATTR_TONE_CLAMPING;   ///< Attribute type
        CnfAttr[1].unValue     = brd_DTMFClamping;              ///< Attribute value

        CnfAttr[2].unVersion   = CNF_ATTR_VERSION_0 ;           ///< Structure version
        CnfAttr[2].unAttribute = ECNF_BRD_ATTR_NOTIFY_INTERVAL; ///< Attribute type
        CnfAttr[2].unValue     = brd_ATInterval;                ///< Attribute value


   CNF_ATTR_INFO CnfAttrInfo;
    CnfAttrInfo.unVersion = CNF_ATTR_INFO_VERSION_0; ///< Structure version
    CnfAttrInfo.unAttrCount = 3;                     ///< Number of attribute structures in list
    CnfAttrInfo.pAttrList = CnfAttr;                 ///< Pointer to attribute structure list

   bool brc = false;
   int rc;

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

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

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

   return brc;
} // End of SetAttributes()

//*****************************************************************************
// Purpose	: 
//    Create conferences
// Parameters:	
//    none
// Returns:	
//    true = success
//*****************************************************************************
bool CnfBoard::CreateConferences(){
bool brc = true;
  if ( m_max_conf_count < (signed)m_pCnfPrmContainer->GetNumberOfConferences() ){
       LOG( LOG_ERR2, GetName(), 
           "Requested: %d conferences: Available = %d",
            m_pCnfPrmContainer->GetNumberOfConferences(), m_max_conf_count);
  }else {
      // Create Conferences
      unsigned int inx = 0;
      PCnfParams pCnfParams;
      CnfConference *pConf;
      while ( m_pCnfPrmContainer->GetConferencePrm(inx++, &pCnfParams) ){
              pConf = new CnfConference(this, m_pCommonParams, pCnfParams);
              push_back(pConf);
      }
  }
  return brc;
} // End of CreateConferences()

//*****************************************************************************
// Purpose	: 
//    Close this board if there are no more conferences
// Parameters:	
//    none
// Returns:	
//    true = success
//*****************************************************************************
bool CnfBoard::TryClose(){
  if (    ( m_number_of_conferences > 0 ) 
       || ( m_number_of_parties > 0 ) ) {
       SetCurrentState(S_WAIT_SUBDEV);
       LOG( LOG_DBG, GetName(),
            "false = TryClose(conferences = %d, parties = %d)",
            m_number_of_conferences, m_number_of_parties );
       return false;
  }

   LOG( LOG_DBG, GetName(),
        "true = TryClose(conferences = %d)",
        m_number_of_conferences);
   DisableEvents();
  return true;
} // End of TryClose()

//*****************************************************************************
// Purpose	: 
//    Dump members
// Parameters:	
//    none
// Returns:	
//    none
//*****************************************************************************
void CnfBoard::Dump(){
    LOG(LOG_APP, GetName(), "--CNF Board parameters");
    LOG(LOG_APP, GetName(), "  brd_ActiveTalker   = '%s'",    YESNO(brd_ActiveTalker));
    LOG(LOG_APP, GetName(), "  brd_ATInterval     = %d",      brd_ATInterval);
    LOG(LOG_APP, GetName(), "  brd_DTMFClamping   = '%s'",    YESNO(brd_DTMFClamping));
    LOG(LOG_APP, GetName(), "  brd_PrivateLog     = %d '%s'", brd_PrivateLog,log_get_msgtype_name(brd_PrivateLog) );
 return;
} // End of Dump()

//*****************************************************************************
// Purpose	: 
//    create new cnf party
// Parameters:	
//    SrlDevice that requests this action
// Returns:	
//    bool true = success
//*****************************************************************************
SRL_DEVICE_HANDLE CnfBoard::OpenParty(PSrlDevice pDev){
  SRL_DEVICE_HANDLE rc;
  rc = cnf_OpenParty(m_srl_handle,0,0, pDev);
   LOG(RCHANDLE(rc), GetName(), "%d = cnf_OpenParty(0x%x,0, 0, &pDev(%s))",
                           rc,m_srl_handle,pDev->GetName());
 
    if (rc == CNF_ERROR) {
        process_cnf_error();
    }

 return rc;
} // End of OpenParty()

//*****************************************************************************
// Purpose	: 
//    close cnf party
// Parameters:	
//    SrlDevice that requests this action
// Returns:	
//    bool true = success
//*****************************************************************************
bool CnfBoard::CloseParty(SRL_DEVICE_HANDLE srl_handle){
bool brc = true;
int rc = cnf_CloseParty(srl_handle, 0);
   LOG(RC(rc), GetName(), "%d = cnf_CloseParty(0x%x,0)",
                           rc,m_srl_handle);
 
    if (rc == CNF_ERROR) {
        process_cnf_error();
        brc = false;
    }

 return brc;
} // End of CloseParty()

⌨️ 快捷键说明

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