BOOL CMyPhoneConnection::OnAlerting(const H323SignalPDU &, const PString & user) { CString fixuser = m_dialog->FindContactName(*this); m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_RINGSTR), S_SYSTEM, (const char *)fixuser); CString allStr; allStr.Format((LPCTSTR)LoadStringLang(IDS_RING1STR), (const char*) fixuser); m_dialog->m_caller.SetWindowText((LPCTSTR)allStr); return TRUE; }
static PTSTR __LoadLocalizedString(const UINT stringId, va_list args) { static TCHAR msg[512]; msg[0] = 0; LoadStringLang(stringId, GetGUILanguage(), msg, _countof(msg), args); return msg; }
int LoadLocalizedStringBuf(PTSTR buffer, int bufferSize, const UINT stringId, ...) { va_list args; va_start(args, stringId); int len = LoadStringLang(stringId, GetGUILanguage(), buffer, bufferSize, args); va_end(args); return len; }
static PTSTR LangListEntry(const UINT stringId, const LANGID langId, ...) { static TCHAR str[128]; va_list args; va_start(args, langId); LoadStringLang(stringId, langId, str, _countof(str), args); va_end(args); return str; }
void CMyPhoneEndPoint::OnConnectionCleared(H323Connection & connection, const PString & clearedCallToken) { if(connection.GetCallEndReason()==H323Connection::EndedByRemoteBusy) m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_CALLBUSYSTR), S_SYSTEM, m_dialog->FindContactName(connection)); // clearing statistic m_stat.iSecs=0; m_stat.ibSent=0; m_stat.ibRcvd=0; m_stat.iDelay=0; // UI change m_dialog->OnConnectionCleared(m_dialog->FindContactName(connection)); }
int LocalizedTime(const time_t t, LPTSTR buf, size_t size) { /* Convert Unix timestamp to Win32 SYSTEMTIME */ FILETIME lft; SYSTEMTIME st; LONGLONG tmp = Int32x32To64(t, 10000000) + 116444736000000000; FILETIME ft = { .dwLowDateTime = (DWORD) tmp, .dwHighDateTime = tmp >> 32}; FileTimeToLocalFileTime(&ft, &lft); FileTimeToSystemTime(&lft, &st); int date_size = 0, time_size = 0; LCID locale = MAKELCID(GetGUILanguage(), SORT_DEFAULT); if (size > 0) { date_size = GetDateFormat(locale, DATE_SHORTDATE, &st, NULL, buf, size); if (date_size) buf[date_size - 1] = ' '; } if (size - date_size > 0) { time_size = GetTimeFormat(locale, TIME_NOSECONDS, &st, NULL, buf + date_size, size - date_size); } return date_size + time_size; } static int LoadStringLang(UINT stringId, LANGID langId, PTSTR buffer, int bufferSize, va_list args) { PWCH entry; PTSTR resBlockId = MAKEINTRESOURCE(stringId / 16 + 1); int resIndex = stringId & 15; /* find resource block for string */ HRSRC res = FindResourceLang(RT_STRING, resBlockId, langId); if (res == NULL) goto err; /* get pointer to first entry in resource block */ entry = (PWCH) LoadResource(o.hInstance, res); if (entry == NULL) goto err; /* search for string in block */ for (int i = 0; i < 16; i++) { /* skip over this entry */ if (i != resIndex) { entry += ((*entry) + 1); continue; } /* string does not exist */ if (i == resIndex && *entry == 0) break; /* string found, copy it */ PTSTR formatStr = (PTSTR) malloc((*entry + 1) * sizeof(TCHAR)); if (formatStr == NULL) break; formatStr[*entry] = 0; wcsncpy(formatStr, entry + 1, *entry); _vsntprintf(buffer, bufferSize, formatStr, args); buffer[bufferSize - 1] = 0; free(formatStr); return _tcslen(buffer); } err: /* not found, try again with the default language */ if (langId != fallbackLangId) return LoadStringLang(stringId, fallbackLangId, buffer, bufferSize, args); return 0; }
BOOL CMyPhoneEndPoint::FindGatekeeper() { if (GetGatekeeper() != NULL) { if (gatekeeper->IsRegistered()) // If registered, then unregister m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_GKUNREGSTR), S_SYSTEM, (const char *)gatekeeper->GetName()); RemoveGatekeeper(); } if (!config.GetBoolean(UseGatekeeperConfigKey, FALSE)) return TRUE; SetGatekeeperPassword(config.GetString(GatekeeperPassConfigKey)); PString gkHost = config.GetString(GatekeeperHostConfigKey, ""); PString gkid = config.GetString(GatekeeperIdConfigKey, ""); PString iface = ""; int iMode = config.GetInteger(DiscoverGatekeeperConfigKey, -1); switch(iMode) { case -1: return TRUE; break; case 0: gkHost = ""; gkid = ""; iface = ""; break; case 1: gkid = ""; iface = ""; break; case 2: gkHost = ""; iface = ""; break; } m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_GKSRCHSTR), S_SYSTEM); m_dialog->m_cstatus.UpdateWindow(); AfxGetApp()->DoWaitCursor(1); if (UseGatekeeper(gkHost, gkid, iface)) { m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_GKREGSTR), S_SYSTEM, (const char *)gatekeeper->GetName()); } AfxGetApp()->DoWaitCursor(0); BOOL gkRequired = config.GetBoolean(RequireGatekeeperConfigKey, FALSE); if (GetGatekeeper() != NULL) { unsigned reason = gatekeeper->GetRegistrationFailReason(); switch (reason) { case H323Gatekeeper::InvalidListener : m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_ERRSTR),S_SYSTEM, (LPCTSTR)LoadStringLang(IDS_GKERRPORTSTR)); break; case H323Gatekeeper::DuplicateAlias : m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_ERRSTR),S_SYSTEM, (LPCTSTR)LoadStringLang(IDS_GKERRALIASSTR)); break; case H323Gatekeeper::SecurityDenied : m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_ERRSTR),S_SYSTEM, (LPCTSTR)LoadStringLang(IDS_GKERRSECSTR)); break; case H323Gatekeeper::TransportError : m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_ERRSTR),S_SYSTEM, (LPCTSTR)LoadStringLang(IDS_GKERRTRNSTR)); break; default : if ((reason&H323Gatekeeper::RegistrationRejectReasonMask) != 0) { CString strRes; strRes.Format((LPCTSTR)LoadStringLang(IDS_GKERRUNSTR),(int) reason&(H323Gatekeeper::RegistrationRejectReasonMask-1)); m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_ERRSTR), S_SYSTEM, (LPCTSTR) strRes); } break; } } else { if (!gkHost.IsEmpty()) { if (!gkid.IsEmpty()) m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_GKERRFINDSTR), S_SYSTEM, (const char *)gkid, (const char *)gkHost); else m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_GKERRFIND1STR), S_SYSTEM, (const char *)gkHost); } else { if (!gkid.IsEmpty()) m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_GKERRFIND2STR), S_SYSTEM, (const char *)gkid); else { if (gkRequired) m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_GKERRFIND3STR), S_SYSTEM); else m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_GKERRFIND4STR), S_SYSTEM); } } } return !gkRequired; }
BOOL CMyPhoneEndPoint::OpenVideoChannel(H323Connection & connection, BOOL isEncoding, H323VideoCodec & codec) { PVideoChannel * channel = new PVideoChannel; PVideoDevice * displayDevice = NULL; if (isEncoding) { // Transmitter part if(!autoStartTransmitVideo) return FALSE; codec.SetTxQualityLevel(config.GetInteger(VideoQualityConfigKey,15)); codec.SetBackgroundFill(2); int videoOutMaxBitRate = config.GetInteger(VideoOutMaxbandWidthKey, 320); videoOutMaxBitRate = 1024 * PMAX(16, PMIN(10240, videoOutMaxBitRate)); H323Channel * lchannel = codec.GetLogicalChannel(); const H323Capability & capability = lchannel->GetCapability(); PString cname = capability.GetFormatName(); PINDEX suffixPos = cname.Find("H.263"); if(suffixPos == P_MAX_INDEX) suffixPos = cname.Find("H.261"); int videoSize = config.GetInteger(VideoOutSizeConfigKey, 2); int width=352, height=288; suffixPos = P_MAX_INDEX; switch(videoSize) { case 0: //QCIF width = 176; height = 144; break; case 1: //QVGA if(suffixPos == P_MAX_INDEX) { width = 320; height = 240; break; } case 2: //CIF width = 352; height = 288; break; case 3: //VGA if(suffixPos == P_MAX_INDEX) { width = 640; height = 480; break; } case 5: //SVGA if(suffixPos == P_MAX_INDEX) { width = 800; height = 600; break; } case 6: //XVGA if(suffixPos == P_MAX_INDEX) { width = 1024; height = 768; break; } case 4: //4CIF width = 704; height = 576; break; case 7: //HD 720 if(suffixPos == P_MAX_INDEX) { width = 1280; height = 720; break; } case 8: //SXGA if(suffixPos == P_MAX_INDEX) { width = 1280; height = 1024; break; } case 9: //16CIF width = 1408; height = 1152; break; case 10: //UXGA if(suffixPos == P_MAX_INDEX) { width = 1600; height = 1200; break; } case 11: //HD 1080 if(suffixPos == P_MAX_INDEX) { width = 1920; height = 1080; break; } default: break; } PTRACE(1, "Video device videoSize=" << videoSize << " width=" << width << " height=" << height); codec.SetVideoSize(width, height); width = codec.GetWidth(); height = codec.GetHeight(); PTRACE(1, "Accepted video device width=" << width << " height=" << height); int curMBR = codec.GetMaxBitRate(); if(curMBR > videoOutMaxBitRate) codec.SetMaxBitRate(videoOutMaxBitRate); int videoFramesPS = config.GetInteger(VideoFPSKey, 10); codec.SetGeneralCodecOption("Frame Rate",videoFramesPS); //Create grabber. bool NoDevice = false; PString deviceName = config.GetString(VideoDeviceConfigKey, deviceName); if (deviceName.IsEmpty()) { PStringArray devices = PVideoInputDevice::GetDriversDeviceNames(VideoInputDriver); if (!devices.IsEmpty()) deviceName = devices[0]; else NoDevice = true; } PVideoInputDevice * grabber = NULL; if (deviceName.Find("fake") == 0) NoDevice = true; // else if (deviceName.Find("screen") == 0) grabber = PVideoInputDevice::CreateDevice("ScreenVideo"); else grabber = PVideoInputDevice::CreateDeviceByName(deviceName,VideoInputDriver); if (NoDevice || !grabber->Open(deviceName, FALSE) || !grabber->SetFrameSize(width, height) || !grabber->SetColourFormatConverter("YUV420P") || !grabber->SetVFlipState(localFlip)) { if(!NoDevice) { char sSrc[64]; m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_ERRVDEVSTR), S_SYSTEM, (const char *) deviceName, itoa(config.GetInteger(VideoSourceConfigKey,0), sSrc, 10)); PTRACE(1, "Failed to open or configure the video device \"" << deviceName << '"'); } if(grabber) delete grabber; grabber = PVideoInputDevice::CreateDevice("FakeVideo"); grabber->SetColourFormat("YUV420P"); grabber->SetVideoFormat(PVideoDevice::PAL); grabber->SetFrameSize(width, height); grabber->SetVFlipState(localFlip); grabber->SetChannel(4); } if(videoFramesPS >0 && videoFramesPS<30) grabber->SetFrameRate(videoFramesPS); grabber->Start(); channel->AttachVideoReader(grabber); /* if (localVideo) { BOOL curVFlip = config.GetBoolean(VideoOutVFlipConfigKey, FALSE); BOOL curHFlip = config.GetBoolean(VideoOutHFlipConfigKey, FALSE); displayDevice = new CVideoOutputDevice(m_dialog, connection.GetLocalPartyName(), curVFlip, curHFlip, TRUE, FALSE); } else */ displayDevice = PVideoOutputDevice::CreateDevice("NULLOutput"); } else { // Receiver part if(!autoStartReceiveVideo) return FALSE; BOOL curVFlip = config.GetBoolean(VideoInVFlipConfigKey, FALSE); BOOL curHFlip = config.GetBoolean(VideoInHFlipConfigKey, FALSE); displayDevice = new CVideoOutputDevice( m_vdlg, (LPCTSTR)m_dialog->FindContactName(connection), curVFlip, curHFlip, FALSE, localVideo); } if(displayDevice) { int width = codec.GetWidth(); int height = codec.GetHeight(); // if( m_dialog->autohideVideoPan && !m_dialog->showVideoPan) // m_dialog->ShowVideoPanels(TRUE); // show Video panel if it's hiden displayDevice->SetColourFormat("RGB32"); displayDevice->SetColourFormatConverter("YUV420P"); displayDevice->SetFrameSize(width, height); //Give the video window refreshing class to the channel. channel->AttachVideoPlayer((PVideoOutputDevice *)displayDevice); } return codec.AttachChannel(channel,TRUE); }
BOOL CMyPhoneEndPoint::Initialise(CMyPhoneDlg *dlg, CVideoDlg *vdlg) { m_dialog = dlg; m_vdlg = vdlg; isIncomingCall = FALSE; SetAudioJitterDelay(50, config.GetInteger(JitterConfigKey, GetMaxAudioJitterDelay())); SetSoundChannelBufferDepth(config.GetInteger(BufferCountConfigKey, GetSoundChannelBufferDepth())); // UserInput mode // Backward compatibility configuration entry unsigned mode = H323Connection::SendUserInputAsString; m_fDtmfAsString=true; if (config.HasKey(DtmfAsStringConfigKey)) { if (!config.GetBoolean(DtmfAsStringConfigKey)) { mode = H323Connection::SendUserInputAsTone; m_fDtmfAsString=false; } config.DeleteKey(DtmfAsStringConfigKey); } mode = config.GetInteger(UserInputModeConfigKey, mode); SetSendUserInputMode((H323Connection::SendUserInputModes)mode); // SetSoundChannelPlayDriver("WindowsMutimedia"); // SetSoundChannelRecordDriver("WindowsMultimedia"); // SetSoundChannelPlayDriver("DirectSound"); // SetSoundChannelRecordDriver("DirectSound"); PString soundPlayStr = config.GetString(SoundPlayConfigKey, GetSoundChannelPlayDevice()); PStringArray soundPlayer = soundPlayStr.Tokenise('\t'); BOOL fPlayerAvailable; if(soundPlayer.GetSize()==1) { SetSoundChannelPlayDriver("WindowsMutimedia"); fPlayerAvailable = SetSoundChannelPlayDevice(soundPlayer[0]); PTRACE(1, "MyPhone\tSetSoundPlayer Driver:WindowsMultimedia, Device:" << soundPlayer[0]); } else { SetSoundChannelPlayDriver(soundPlayer[0]); fPlayerAvailable = SetSoundChannelPlayDevice(soundPlayer[1]); PTRACE(1, "MyPhone\tSetSoundPlayer Driver:" << soundPlayer[0] << ", Device:" << soundPlayer[1]); } PString soundRecordStr = config.GetString(SoundRecordConfigKey, GetSoundChannelRecordDevice()); PStringArray soundRecorder = soundRecordStr.Tokenise('\t'); BOOL fRecorderAvailable; if(soundRecorder.GetSize()==1) { SetSoundChannelRecordDriver("WindowsMutimedia"); fRecorderAvailable = SetSoundChannelRecordDevice(soundRecorder[0]); PTRACE(1, "MyPhone\tSetSoundRecorder Driver:WindowsMultimedia, Device:" << soundRecorder[0]); } else { SetSoundChannelRecordDriver(soundRecorder[0]); fRecorderAvailable = SetSoundChannelRecordDevice(soundRecorder[1]); PTRACE(1, "MyPhone\tSetSoundRecorder Driver:" << soundRecorder[0] << ", Device:" << soundRecorder[1]); } m_fAECOn = config.GetBoolean(AECEnableConfigKey, FALSE); m_fAGCOn = config.GetInteger(AGCEnableConfigKey, FALSE); SetAECAlgo(m_fAECOn); agc = m_fAGCOn; // set some oter settings from Config m_fNoFastStart = config.GetBoolean(NoFastStartConfigKey, FALSE); DisableFastStart(m_fNoFastStart); m_fStrictSingleLine = config.GetBoolean(StrictSingleLineConfigKey, FALSE); StrictSingleLine(m_fStrictSingleLine); m_fDoH245Tunnelling = !(config.GetBoolean(NoTunnelingConfigKey, FALSE)); DisableH245Tunneling(!m_fDoH245Tunnelling); m_fSilenceOn = config.GetBoolean(SilenceDetectConfigKey, TRUE); SetSilenceDetectionMode(m_fSilenceOn ? H323AudioCodec::AdaptiveSilenceDetection : H323AudioCodec::NoSilenceDetection); SetLocalUserName(config.GetString(UsernameConfigKey, GetLocalUserName())); SetInitialBandwidth((unsigned)(config.GetReal(BandwidthConfigKey, 10000)*20)); SetRtpIpTypeofService(config.GetInteger(IpTosConfigKey, GetRtpIpTypeofService())); SetRtpIpPorts(config.GetInteger(RTPPortBaseConfigKey, GetRtpIpPortBase()), config.GetInteger(RTPPortMaxConfigKey, GetRtpIpPortBase())); if(config.HasKey(RouterConfigKey)) m_router = config.GetString(RouterConfigKey, m_router.AsString()); m_fAutoAnswer = config.GetBoolean(AutoAnswerConfigKey, false); m_fAutoMute = config.GetBoolean(AutoMuteConfigKey, false); CString alias, aliases; aliases = CString((const char *)config.GetString(AliasConfigKey, _T(""))); aliases.TrimLeft(); int iPos=0; while ((iPos = aliases.Find(_T("|")))>0) // loading user aliases { alias = aliases.Left(iPos); aliases.Delete(0,iPos+1); AddAliasName((LPCTSTR)alias); } // The order in which capabilities are added to the capability table // determines which one is selected by default. LoadCapabilities(); PString interfaces = config.GetString(ListenerInterfaceConfigKey, "*"); if(StartListeners(interfaces.Tokenise(','))) { m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_MPREADY1STR), S_SYSTEM, (const char *)strProgName); return true; } else { m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_ERRLSNSTR), S_SYSTEM, (const char *)strProgName, (const char *)interfaces); return false; } }
void CMyPhoneConnection::OnUserInputString(const PString & value) { m_dialog->OutputStatusStr((LPCTSTR)LoadStringLang(IDS_REPLMSGSTR), S_INMSG, ""/*m_dialog->FindContactName(*this)*//*(const char *) this->GetRemotePartyName()*/, (const char *) value); }
void CVisualPage::TranslateDlg() { // changing window languge GetDlgItem(IDC_VDEVSTATIC)->SetWindowText((LPCTSTR)LoadStringLang(IDS_DEVSTR)); GetDlgItem(IDC_VDEVCHSTATIC)->SetWindowText((LPCTSTR)LoadStringLang(IDS_DEVCHSTR)); GetDlgItem(IDC_CHECK_SEND_VIDEO)->SetWindowText((LPCTSTR)LoadStringLang(IDS_VSENDSTR)); GetDlgItem(IDC_CHECK_RECEIVE_VIDEO)->SetWindowText((LPCTSTR)LoadStringLang(IDS_VRCVDSTR)); GetDlgItem(IDC_CHECK_LOCALVIDEO)->SetWindowText((LPCTSTR)LoadStringLang(IDS_VLOCSTR)); GetDlgItem(IDC_VIEWSTATIC)->SetWindowText((LPCTSTR)LoadStringLang(IDS_VIEWSTR)); GetDlgItem(IDC_LVFLIP)->SetWindowText((LPCTSTR)LoadStringLang(IDS_LVFLIPSTR)); GetDlgItem(IDC_LOCFLIPCHECK)->SetWindowText((LPCTSTR)LoadStringLang(IDS_LOCFLIPSTR)); GetDlgItem(IDC_RVFLIP)->SetWindowText((LPCTSTR)LoadStringLang(IDS_RVFLIPSTR)); GetDlgItem(IDC_QTYSTATIC)->SetWindowText((LPCTSTR)LoadStringLang(IDS_QTYSTR)); GetDlgItem(IDC_BPSSTATIC)->SetWindowText((LPCTSTR)LoadStringLang(IDS_MBPSSTR)); // GetDlgItem(IDC_FPSSTATIC)->SetWindowText((LPCTSTR)LoadStringLang(IDS_FPSSTR)); GetDlgItem(IDC_CSSTATIC)->SetWindowText((LPCTSTR)LoadStringLang(IDS_CODECSSTR)); // GetDlgItem(IDC_CS_UP_BUTTON)->SetWindowText((LPCTSTR)LoadStringLang(IDS_CSUPSTR)); GetDlgItem(IDC_CS_ENABLED_CHECK)->SetWindowText((LPCTSTR)LoadStringLang(IDS_CSENBLSTR)); // GetDlgItem(IDC_CS_DOWN_BUTTON)->SetWindowText((LPCTSTR)LoadStringLang(IDS_CSDOWNSTR)); // SetWindowText((LPCTSTR)LoadStringLang(IDS_AUDIOSTR)); }