📄 sipxmgr.cpp
字号:
sipxCallConnect(m_hCall, szSipUrl, addresses[i].id, pDisplay) ; */ sipxCallConnect(m_hCall, szSipUrl, 0, &display) ; return bRC ;}// release the singleton instance of this classvoid sipXmgr::release(){ if (sipXmgr::spSipXmgr) { delete sipXmgr::spSipXmgr; sipXmgr::spSipXmgr = NULL; sipXezPhoneSettings::getInstance().saveSettings(); }}void sipXmgr::removeCurrentLine(){ if (sipXmgr::spSipXmgr) { sipxLineRemove(sipXmgr::spSipXmgr->m_hLine); } }const SIPX_CONF sipXmgr::getCurrentConference() const{ return m_hConf;}void sipXmgr::setCurrentConference(const SIPX_CONF hConf){ m_hConf = hConf;}// get the "Speaker" volume - can be 1 - 10const int sipXmgr::getSpeakerVolume() const{ int volume; sipxAudioGetVolume(m_hInst, SPEAKER, volume); return volume;}// get the "Ringer" volume - can be 1 - 10const int sipXmgr::getRingerVolume() const{ int volume; sipxAudioGetVolume(m_hInst, RINGER, volume); return volume;}// get the Mic gain - can be 1 - 10const int sipXmgr::getMicGain() const{ int gain; sipxAudioGetGain(m_hInst, gain); return gain;}// sets the Speaker volumevoid sipXmgr::setSpeakerVolume(const int volume){ int myVol = volume; if (volume > VOLUME_MAX) { myVol = VOLUME_MAX; } // not yet implemented in the Linux #ifdef _WIN32 sipxAudioSetVolume(m_hInst, SPEAKER, myVol); #endif}// sets the Ringer volumevoid sipXmgr::setRingerVolume(const int volume){ int myVol = volume; if (volume > VOLUME_MAX) { myVol = VOLUME_MAX; } sipxAudioSetVolume(m_hInst, RINGER, myVol);}// sets the Mic gainvoid sipXmgr::setMicGain(const int gain){ int myGain = gain; if (gain > GAIN_MAX) { myGain = GAIN_MAX; } // not yet implemented in the Linux #ifdef _WIN32 sipxAudioSetGain(m_hInst, myGain); #endif }// sets the current call handlevoid sipXmgr::setCurrentCall(const SIPX_CALL hCall){ m_hCall = hCall;}// gets the current line handleconst SIPX_LINE sipXmgr::getCurrentLine() const{ return m_hLine;}const SIPX_CALL sipXmgr::getCurrentCall() const{ return m_hCall;}void sipXmgr::holdCurrentCall(){ // if a conference in progress hold all // conference members. if (m_hConf) { sipxConferenceHold(m_hConf, true) ; } else { // hold the 'main' call sipxCallHold(m_hCall); } } void sipXmgr::unholdCurrentCall(){ // if a conference in progress unhold all // conference members. if (m_hConf) { sipxConferenceUnhold(m_hConf) ; } else { sipxCallUnhold(m_hCall); }}void sipXmgr::setInTransfer(const bool bXfer){ mTransferInProgress = bXfer; return;}const bool sipXmgr::getInTransfer() const{ return mTransferInProgress;}void sipXmgr::stopTone(){ sipxCallStopTone(this->m_hCall);} void sipXmgr::UnRegister(){ sipxLineRegister(m_hLine, false);}bool sipXmgr::addConfParty(const char* const szParty){ bool bRet = false; // first, check to see whether or not a conference already exists if (0 == m_hConf) // if there is no current conference { SIPX_CALL hCurrentCall = sipXmgr::getInstance().getCurrentCall(); // create a conference if (SIPX_RESULT_SUCCESS != sipxConferenceCreate(m_hInst, &m_hConf) ) { // TODO - log a failure here & alert user } else { setCurrentConference(m_hConf); if (hCurrentCall) // if there was a 'current call', join it in with the // conference { sipxConferenceJoin(m_hConf, hCurrentCall); } } } if (m_hConf) // if we have a conference { SIPX_CALL hNewCall = 0; SIPX_VIDEO_DISPLAY* pDisplay = new SIPX_VIDEO_DISPLAY; // TODO - clean up the memory leak introduced above pDisplay->cbSize = sizeof(SIPX_VIDEO_DISPLAY); pDisplay->handle = sipXmgr::getInstance().getVideoWindow(); pDisplay->type = SIPX_WINDOW_HANDLE_TYPE; if (SIPX_RESULT_SUCCESS == sipxConferenceAdd(m_hConf, getCurrentLine(), szParty, &hNewCall, 0, pDisplay )) { mConfCallHandleMap.insertKeyAndValue(new UtlString(szParty), new UtlInt(hNewCall)); bRet = true; } } return bRet;}bool sipXmgr::removeConfParty(const char* const szParty){ bool bRet = false; UtlInt* pHandle = NULL; UtlString key(szParty); pHandle = (UtlInt*)mConfCallHandleMap.findValue(&key); if (pHandle && SIPX_RESULT_SUCCESS == sipxConferenceRemove(m_hConf, pHandle->getValue())) { bRet = true; } if (pHandle) { mConfCallHandleMap.destroy(&key); bRet = true; } if (mConfCallHandleMap.entries() == 0) { sipxConferenceDestroy(m_hConf); m_hConf = 0; } return bRet;}bool sipXmgr::getCodecPreferences(int* pCodecPref){ bool rc = false; if (pCodecPref) { if (sipxConfigGetAudioCodecPreferences(m_hInst, (SIPX_AUDIO_BANDWIDTH_ID*)pCodecPref) == SIPX_RESULT_SUCCESS) { rc = true; } } return rc;}bool sipXmgr::getCodecList(UtlString& codecList){ bool rc = false; int numCodecs; SIPX_AUDIO_CODEC codec; UtlString sBandWidth; codecList = ""; if (sipxConfigGetNumAudioCodecs(m_hInst, &numCodecs) == SIPX_RESULT_SUCCESS) { for (int i=0; i<numCodecs; i++) { if (sipxConfigGetAudioCodec(m_hInst, i, &codec) == SIPX_RESULT_SUCCESS) { switch (codec.iBandWidth) { case AUDIO_CODEC_BW_VARIABLE: sBandWidth = " (Variable)"; break; case AUDIO_CODEC_BW_LOW: sBandWidth = " (Low)"; break; case AUDIO_CODEC_BW_NORMAL: sBandWidth = " (Normal)"; break; case AUDIO_CODEC_BW_HIGH: sBandWidth = " (High)"; break; } codecList = codecList + codec.cName + sBandWidth + "\n"; } } rc = true; } return rc;}bool sipXmgr::getVideoCodecPreferences(int* pCodecPref){ bool rc = false; if (pCodecPref) { if (sipxConfigGetVideoCodecPreferences(m_hInst, (SIPX_VIDEO_BANDWIDTH_ID*)pCodecPref) == SIPX_RESULT_SUCCESS) { rc = true; } } return rc;}bool sipXmgr::getVideoCodecList(UtlString& codecList){ bool rc = false; int numCodecs; SIPX_VIDEO_CODEC codec; UtlString sBandWidth; codecList = ""; if (sipxConfigGetNumVideoCodecs(m_hInst, &numCodecs) == SIPX_RESULT_SUCCESS) { for (int i=0; i<numCodecs; i++) { if (sipxConfigGetVideoCodec(m_hInst, i, &codec) == SIPX_RESULT_SUCCESS) { switch (codec.iBandWidth) { case AUDIO_CODEC_BW_VARIABLE: sBandWidth = " (Variable)"; break; case AUDIO_CODEC_BW_LOW: sBandWidth = " (Low)"; break; case AUDIO_CODEC_BW_NORMAL: sBandWidth = " (Normal)"; break; case AUDIO_CODEC_BW_HIGH: sBandWidth = " (High)"; break; } codecList = codecList + codec.cName + sBandWidth + "\n"; } } rc = true; } return rc;}bool sipXmgr::setAudioCodecByName(const char* name){ bool rc = false; if (sipxConfigSetAudioCodecByName(m_hInst, name) == SIPX_RESULT_SUCCESS) { rc = true; } return rc;}bool sipXmgr::setVideoCodecByName(const char* name){ bool rc = false; if (sipxConfigSetVideoCodecByName(m_hInst, name) == SIPX_RESULT_SUCCESS) { rc = true; } return rc;}void sipXmgr::setPreviewWindow(void* pWnd){ mpPreviewDisplay->type = SIPX_WINDOW_HANDLE_TYPE; mpPreviewDisplay->handle = pWnd;#ifdef VIDEO sipxConfigSetVideoPreviewDisplay(sipXmgr::getInstance().getSipxInstance(), mpPreviewDisplay);#endif}void* sipXmgr::getPreviewWindow(){ return mpPreviewDisplay->handle;}void sipXmgr::setVideoWindow(void* pWnd){ mpVideoDisplay->handle = pWnd;}void* sipXmgr::getVideoWindow(){ return mpVideoDisplay->handle;}bool sipXmgr::setCodecPreferences(int codecPref){ bool rc = false; if (sipxConfigSetAudioCodecPreferences(m_hInst, (SIPX_AUDIO_BANDWIDTH_ID)codecPref) == SIPX_RESULT_SUCCESS) { rc = true; } return rc;}bool sipXmgr::setVideoCodecPreferences(int codecPref){ bool rc = false; if (sipxConfigSetVideoCodecPreferences(m_hInst, (SIPX_VIDEO_BANDWIDTH_ID)codecPref) == SIPX_RESULT_SUCCESS) { rc = true; } return rc;}bool sipXmgr::setVideoParameters(int iQuality, int iBitRate, int iFrameRate){ bool rc = false;#ifdef VIDEO if (sipxConfigSetVideoQuality(m_hInst, (SIPX_VIDEO_QUALITY_ID)iQuality) == SIPX_RESULT_SUCCESS) { if (sipxConfigSetVideoParameters(m_hInst, iBitRate, iFrameRate) == SIPX_RESULT_SUCCESS) { rc = true; } }#endif return rc;}bool sipXmgr::isAECEnabled(){ bool rc = false; sipxAudioIsAECEnabled(m_hInst, rc); return rc;}void sipXmgr::enableAEC(bool bEnable){ sipxAudioEnableAEC(m_hInst, bEnable);}bool sipXmgr::isOutOfBandDTMFEnabled(){ bool rc = false; sipxConfigIsOutOfBandDTMFEnabled(m_hInst, rc); return rc;}void sipXmgr::enableOutOfBandDTMF(bool bEnable){ sipxConfigEnableOutOfBandDTMF(m_hInst, bEnable);}bool sipXmgr::isSRTPEnabled(){ bool rc = false; return rc;}void sipXmgr::enableSRTP(bool bEnable){}void sipXmgr::toggleMute(){ bool rc = false; sipxAudioIsMuted(m_hInst, rc); sipxAudioMute(m_hInst, !rc); return;}void sipXmgr::addToEventLog(SIPX_EVENT_CATEGORY category, void* pInfo, void* pUserData){ char cLogLine[1024] ; memset(cLogLine, 0, sizeof(cLogLine)) ; wxDateTime now = wxDateTime::Now() ; sipxEventToString(category, pInfo, cLogLine, sizeof(cLogLine)-1) ; mEventLog[mEventLogIndex] = now.FormatISODate() ; mEventLog[mEventLogIndex].append(" ") ; mEventLog[mEventLogIndex].append(now.FormatISOTime()) ; mEventLog[mEventLogIndex].append(" ") ; mEventLog[mEventLogIndex].append(cLogLine) ; mEventLogIndex = (mEventLogIndex + 1) % MAX_EVENT_LOG_ENTRIES ; }void sipXmgr::getEventLog(wxString& contents) const{ contents.Clear() ; int index = mEventLogIndex ; while (index != abs((mEventLogIndex -1)) % MAX_EVENT_LOG_ENTRIES) { if (mEventLog[index].Length()) { contents.append(mEventLog[index]) ; contents.append("\r\n") ; } index = (index + 1) % MAX_EVENT_LOG_ENTRIES ; }}void sipXmgr::clearEventLog() { // Clearing log for (int i=0; i<MAX_EVENT_LOG_ENTRIES; i++) { mEventLog[i] = wxEmptyString ; } mEventLogIndex = 0 ; }SIPX_INST sipXmgr::getSipxInstance(){ return m_hInst;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -