psphonetask.cpp
来自「基于sipfoundy 公司开发的sipx协议API」· C++ 代码 · 共 1,582 行 · 第 1/4 页
CPP
1,582 行
assert(false); } break; case PtComponentGroup::OTHER: default: break; } return 1;}void PsPhoneTask::setGainValue(int value){#ifdef _VXWORKS MpCodec_setGain(value); osPrintf("PsPhoneTask::setGain - MpCodec_setGain(%d)\n", value);#endif}UtlBoolean PsPhoneTask::deactivateGroup(PsMsg& rMsg){ TaoMessage *pMsg = (TaoMessage *) &rMsg; int type = atoi(pMsg->getArgList()); return deactivateGroup(type);}UtlBoolean PsPhoneTask::deactivateGroup(int type){ UtlBoolean rc = FALSE; switch(type) { case PtComponentGroup::HEAD_SET: if (mpHeadSetGroup) { rc = mpHeadSetGroup->deactivate(); speakerModeDisable(HEADSET_ENABLED); } break; case PtComponentGroup::HAND_SET: if (mpHandSetGroup) { rc = mpHandSetGroup->deactivate(); speakerModeDisable(HANDSET_ENABLED); } break; case PtComponentGroup::SPEAKER_PHONE: if (mpSpeakerPhoneGroup) { rc = mpSpeakerPhoneGroup->deactivate(); speakerModeDisable(SPEAKERPHONE_ENABLED); } break; case PtComponentGroup::EXTERNAL_SPEAKER: if (mpExtSpeakerGroup) { rc = mpExtSpeakerGroup->deactivate(); speakerModeDisable(EXTSPEAKER_ENABLED); } break; case PtComponentGroup::PHONE_SET: case PtComponentGroup::RINGER: if (mpPhoneSetGroup) { assert(false); rc = mpPhoneSetGroup->deactivate(); speakerModeDisable(RINGER_ENABLED | SOUND_ENABLED); } break; case PtComponentGroup::SOUND: if (mpSpeakerPhoneGroup) { rc = mpSpeakerPhoneGroup->deactivate(); speakerModeDisable(SOUND_ENABLED); } break; case PtComponentGroup::OTHER: default: break; } return TRUE;}void PsPhoneTask::postListenerMessage(const PsMsg& rMsg){ int cnt = mpListenerCnt->getRef(); for (int i = 0; i < cnt; i++) { ((OsServerTask*) mpActiveListeners[i])->postMessage(rMsg); }}// Initialize the platform-specific settings for the keyboard buttonsvoid PsPhoneTask::initPlatformButtonSettings(PsButtonTask* pButtonTask){ int btnEvtMask; int btnIndex; int numButtons; int platformType; // $$$ (rschaaf) // The button information should be maintained in a dictionary so that // we can access the information more efficiently platformType = OsUtil::getPlatformType(); switch (platformType) { case OsUtil::PLATFORM_WIN32: case OsUtil::PLATFORM_LINUX: case OsUtil::PLATFORM_SOLARIS: numButtons = 35; // DWW changed it for all keys on a keyboard.... // really, this should be dynamically allocated. break; case OsUtil::PLATFORM_BRUTUS: case OsUtil::PLATFORM_TCAS1: numButtons = 16; break; case OsUtil::PLATFORM_TCAS2: numButtons = 58; break; case OsUtil::PLATFORM_TCAS3: case OsUtil::PLATFORM_TCAS4: // Note: On the TCAS4, case OsUtil::PLATFORM_TCAS5: // TCAS5, case OsUtil::PLATFORM_TCAS6: // TCAS6 and case OsUtil::PLATFORM_TCAS7: // TCAS7 we turn scroll wheel numButtons = 35; // events into SCROLL_UP/DOWN button break; // presses. default: assert(FALSE); break; } pButtonTask->init(numButtons-1); // set max button index to numButtons-1 btnIndex = 0; btnEvtMask = PsButtonInfo::BUTTON_DOWN | PsButtonInfo::BUTTON_UP; // The following buttons are on all of different versions of the phone pButtonTask->setButtonInfo(btnIndex++, DIAL_0, "0", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, DIAL_1, "1", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, DIAL_2, "2", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, DIAL_3, "3", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, DIAL_4, "4", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, DIAL_5, "5", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, DIAL_6, "6", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, DIAL_7, "7", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, DIAL_8, "8", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, DIAL_9, "9", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, DIAL_POUND, "POUND", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, DIAL_STAR, "STAR", btnEvtMask); // The following buttons are on the Brutus and TCAS1 if ((platformType == OsUtil::PLATFORM_BRUTUS) || (platformType == OsUtil::PLATFORM_TCAS1)) { pButtonTask->setButtonInfo(btnIndex++, FKEY_VOL_UP, "VOL_UP", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_VOL_DOWN, "VOL_DOWN", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_SCROLL_UP, "SCROLL_UP", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_SCROLL_DOWN, "SCROLL_DOWN", btnEvtMask); } // The following buttons are on the TCAS2..TCAS7 if ((platformType == OsUtil::PLATFORM_TCAS2) || (platformType == OsUtil::PLATFORM_TCAS3) || (platformType == OsUtil::PLATFORM_TCAS4) || (platformType == OsUtil::PLATFORM_TCAS5) || (platformType == OsUtil::PLATFORM_TCAS6) || (platformType == OsUtil::PLATFORM_TCAS7) || (platformType == OsUtil::PLATFORM_WIN32) || (platformType == OsUtil::PLATFORM_LINUX) || (platformType == OsUtil::PLATFORM_SOLARIS)) { // Note: Scroll wheel events on the TCAS4 and higher are translated into // SCROLL_UP and SCROLL_DOWN button events pButtonTask->setButtonInfo(btnIndex++, FKEY_SCROLL_UP, "SCROLL_UP", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_SCROLL_DOWN,"SCROLL_DOWN",btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_VOL_UP, "VOL_UP", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_VOL_DOWN, "VOL_DOWN", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_HOLD, "HOLD", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_CONFERENCE, "CONFERENCE", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_TRANSFER, "TRANSFER", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_MUTE, "MUTE", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_SPEAKER, "SPEAKER", btnEvtMask); } // The following additional buttons are on the TCAS2 if (platformType == OsUtil::PLATFORM_TCAS2) { pButtonTask->setButtonInfo(btnIndex++, FKEY_REDIAL, "REDIAL", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_MENU, "MENU", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_SKEY1, "SKEY1", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_SKEY2, "SKEY2", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_SKEY3, "SKEY3", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_PICKUP, "PICKUP", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_SPEED_DIAL, "SPEED_DIAL", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_CANCEL, "CANCEL", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_ACCEPT, "ACCEPT", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_VOICE_MAIL, "VOICE_MAIL", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_PRIVACY, "PRIVACY", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_FORWARD, "FORWARD", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_DO_NOT_DISTURB, "DO_NOT_DISTURB", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_CALL1, "CALL1", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_CALL2, "CALL2", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_CALL3, "CALL3", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_CALL4, "CALL4", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_CALL5, "CALL5", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_CALL6, "CALL6", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_USER1, "USER1", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_USER2, "USER2", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_USER3, "USER3", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_USER4, "USER4", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_USER5, "USER5", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_USER6, "USER6", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_USER7, "USER7", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_USER8, "USER8", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_USER9, "USER9", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_USER10, "USER10", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_USER11, "USER11", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_USER12, "USER12", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_USER13, "USER13", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_USER14, "USER14", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_USER15, "USER15", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_USER16, "USER16", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_USER17, "USER17", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_USER18, "USER18", btnEvtMask); } // The following additional buttons are on the TCAS3..TCAS7 if ((platformType == OsUtil::PLATFORM_TCAS3) || (platformType == OsUtil::PLATFORM_TCAS4) || (platformType == OsUtil::PLATFORM_TCAS5) || (platformType == OsUtil::PLATFORM_TCAS6) || (platformType == OsUtil::PLATFORM_TCAS7) || (platformType == OsUtil::PLATFORM_WIN32) || (platformType == OsUtil::PLATFORM_LINUX) || (platformType == OsUtil::PLATFORM_SOLARIS)) { pButtonTask->setButtonInfo(btnIndex++, FKEY_HEADSET, "HEADSET", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_MORE, "MORE", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_SKEY_L1, "SKEYL1", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_SKEY_L2, "SKEYL2", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_SKEY_L3, "SKEYL3", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_SKEY_L4, "SKEYL4", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_SKEY_R1, "SKEYR1", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_SKEY_R2, "SKEYR2", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_SKEY_R3, "SKEYR3", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_SKEY_R4, "SKEYR4", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_SKEY_B1, "SKEYB1", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_SKEY_B2, "SKEYB2", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_SKEY_B3, "SKEYB3", btnEvtMask); pButtonTask->setButtonInfo(btnIndex++, FKEY_VOICE_MAIL, "VOICE_MAIL", btnEvtMask); }}void PsPhoneTask::initComponentGroups(){ osPrintf(" About to create component groups!\n"); PsTaoComponent* pComponents[6]; int nItems = 5; // Handset group mpTaoButton = new PsTaoButton("Button", PsTaoComponent::BUTTON); mpTaoHooksw = new PsTaoHookswitch("Hookswitch", PsTaoComponent::HOOKSWITCH); mpTaoLamp = new PsTaoLamp("Lamp", PsTaoComponent::LAMP); mpTaoHandsetSpeaker = new PsTaoSpeaker("Handset Speaker", PsTaoComponent::SPEAKER); mpTaoExtSpeaker = new PsTaoSpeaker("External Speaker", PsTaoComponent::SPEAKER); mpTaoHandsetMic = new PsTaoMicrophone("Handset Mic", PsTaoComponent::MICROPHONE); pComponents[0] = mpTaoButton; pComponents[1] = mpTaoLamp; pComponents[2] = mpTaoHandsetSpeaker; pComponents[3] = mpTaoHandsetMic; pComponents[4] = mpTaoHooksw; mpHandSetGroup = new PsTaoComponentGroup(PsTaoComponentGroup::HAND_SET, "Handset Group", pComponents, nItems); // Speakerphone group if(!mpTaoBaseSpeaker) mpTaoBaseSpeaker = new PsTaoSpeaker("Base Speaker", PsTaoComponent::SPEAKER); if(!mpTaoBaseMic) mpTaoBaseMic = new PsTaoMicrophone("Base Mic", PsTaoComponent::MICROPHONE); nItems = 4; pComponents[2] = mpTaoBaseSpeaker; pComponents[3] = mpTaoBaseMic; mpSpeakerPhoneGroup = new PsTaoComponentGroup(PsTaoComponentGroup::SPEAKER_PHONE, "Speakerphone Group", pComponents, nItems); if(!mpTaoRinger) mpTaoRinger = new PsTaoRinger("Ringer", PsTaoComponent::RINGER); nItems = 5; pComponents[4] = mpTaoRinger; mpPhoneSetGroup = new PsTaoComponentGroup(PsTaoComponentGroup::PHONE_SET, "Phoneset Group", pComponents, nItems); // Headset group if(!mpTaoHeadsetSpeaker) mpTaoHeadsetSpeaker = new PsTaoSpeaker("Headset Speaker", PsTaoComponent::SPEAKER); if(!mpTaoHeadsetMic) mpTaoHeadsetMic = new PsTaoMicrophone("Headset Mic", PsTaoComponent::MICROPHONE); nItems = 2; pComponents[0] = mpTaoHeadsetSpeaker; pComponents[1] = mpTaoHeadsetMic; mpHeadSetGroup = new PsTaoComponentGroup(PsTaoComponentGroup::HEAD_SET, "Headset Group", pComponents, nItems); nItems = 1; pComponents[0] = mpTaoExtSpeaker; mpExtSpeakerGroup = new PsTaoComponentGroup(PsTaoComponentGroup::EXTERNAL_SPEAKER, "ExtSpeaker Group", pComponents, nItems);#ifdef _VXWORKS int low; int high; int nominal; // low <= nominal <= high int stepsize; // in .1 dB int splash; int mute; MpCodec_getVolumeRange(low, high, nominal, stepsize, mute, splash, CODEC_ENABLE_HANDSET_SPKR); mpHandSetGroup->setVolumeRange(low, high, nominal, stepsize, mute); MpCodec_getGainRange(low, high, nominal, stepsize, mute, CODEC_ENABLE_HANDSET_MIC); mpHandSetGroup->setGainRange(low, high, nominal, stepsize, mute); MpCodec_getVolumeRange(low, high, nominal, stepsize, mute, splash, CODEC_ENABLE_HEADSET_SPKR); mpHeadSetGroup->setVolumeRange(low, high, nominal, stepsize, mute); MpCodec_getGainRange(low, high, nominal, stepsize, mute, CODEC_ENABLE_HEADSET_MIC); mpHeadSetGroup->setGainRange(low, high, nominal, stepsize, mute); MpCodec_getVolumeRange(low, high, nominal, stepsize, mute, splash, CODEC_ENABLE_BASE_SPKR); mpSpeakerPhoneGroup->setVolumeRange(low, high, nominal, stepsize, mute); mNominal = nominal; mSplash = splash; printf("~~~ initComponentGroups: splash %d\n", mSplash); MpCodec_getGainRange(low, high, nominal, stepsize, mute, CODEC_ENABLE_BASE_MIC); mpSpeakerPhoneGroup->setGainRange(low, high, nominal, stepsize, mute); mpPhoneSetGroup->setGainRange(low, high, nominal, stepsize, mute); MpCodec_getVolumeRange(low, high, nominal, stepsize, mute, splash, CODEC_ENABLE_RINGER_SPKR); mpPhoneSetGroup->setVolumeRange(low, high, nominal, stepsize, mute);#else /* Not running on the actual phone */ mpHandSetGroup->setVolumeRange(0, 100, 50, 10, 0); mpHeadSetGroup->setVolumeRange(0, 100, 50, 10, 0); mpSpeakerPhoneGroup->setVolumeRange(0, 100, 50, 10, 0); mpPhoneSetGroup->setVolumeRange(0, 100, 50, 10, 0); mpHandSetGroup->setGainRange(0, 10, 5, 1, 0); mpHeadSetGroup->setGainRange(0, 10, 5, 1, 0); mpSpeakerPhoneGroup->setGainRange(0, 100, 50, 10, 0); mpPhoneSetGroup->setGainRange(0, 100, 50, 10, 0);#endif}/* ============================ FUNCTIONS ================================= */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?