/*----------------------------------------------------------------------------- -----------------------------------------------------------------------------*/ int CWsHook::GetAddrInfoW(PCWSTR pNodeName, PCWSTR pServiceName, const ADDRINFOW * pHints, PADDRINFOW * ppResult) { int ret = WSAEINVAL; bool overrideDNS = false; void * context = NULL; CString name = CW2T(pNodeName); CAtlArray<DWORD> addresses; if( dlg && pNodeName ) overrideDNS = dlg->DnsLookupStart( name, context, addresses ); if( _GetAddrInfoW && !overrideDNS ) ret = _GetAddrInfoW(CT2W((LPCWSTR)name), pServiceName, pHints, ppResult); else if( overrideDNS ) { if( addresses.IsEmpty() ) ret = EAI_NONAME; else { // build the response structure with the addresses we looked up ret = 0; DWORD count = addresses.GetCount(); ADDRINFOW_ADDR * result = (ADDRINFOW_ADDR *)malloc(sizeof(ADDRINFOW_ADDR) * count); for (DWORD i = 0; i < count; i++) { memset( &result[i], 0, sizeof(ADDRINFOW_ADDR) ); result->info.ai_family = AF_INET; result->info.ai_addrlen = sizeof(struct sockaddr_in); result->info.ai_addr = (struct sockaddr *)&(result->addr); result->addr.sin_family = AF_INET; result->addr.sin_addr.S_un.S_addr = addresses[i]; if( i < count - 1 ) result->info.ai_next = (PADDRINFOW)&result[i+1]; } addrInfo.AddTail(result); *ppResult = (PADDRINFOW)result; } } if (!ret && dlg) { PADDRINFOW addr = *ppResult; while (addr) { if (addr->ai_canonname) dlg->DnsLookupAlias(name, addr->ai_canonname); if (context && addr->ai_addrlen >= sizeof(struct sockaddr_in) && addr->ai_family == AF_INET ) { struct sockaddr_in * ipName = (struct sockaddr_in *)addr->ai_addr; dlg->DnsLookupAddress(context, ipName->sin_addr); } addr = addr->ai_next; } if (context) dlg->DnsLookupDone(context); } return ret; }
BOOL COther::GetMsnReceiveDir( CAtlArray<CString>& ReceiveDirArray ) { HKEY hKey = NULL; CString SubKeyPath = L"Software\\Microsoft\\MSNMessenger"; CAtlArray<HKEY> OtherUserCurReg; HRESULT hr = COtherUserCurReg::GetOtherUsrCurReg( OtherUserCurReg ); if ( FAILED(hr) ) { return FALSE; } size_t Num = OtherUserCurReg.GetCount(); size_t i = 0; for (; i<Num; ++i ) { hKey = OtherUserCurReg[i]; CRegKey MsnMainKey; LONG Result = ERROR_SUCCESS; Result = MsnMainKey.Open( hKey, SubKeyPath, KEY_READ ); if ( ERROR_SUCCESS != Result ) { continue; } WCHAR TmpMsnReceivePath[MAX_PATH+1] ={0}; DWORD BufByteNum = (MAX_PATH+1)*sizeof(TCHAR); Result = MsnMainKey.QueryBinaryValue( L"FtReceiveFolder", TmpMsnReceivePath, &BufByteNum ); TmpMsnReceivePath[MAX_PATH] = NULL; if ( ERROR_SUCCESS == Result ) { BOOL bAdd = TRUE; size_t NumRv = ReceiveDirArray.GetCount(); size_t j = 0; for (; j<NumRv; ++j ) { if ( 0 == ReceiveDirArray[j].CompareNoCase(TmpMsnReceivePath) ) { bAdd = FALSE; break; } } if ( bAdd ) { ReceiveDirArray.Add( TmpMsnReceivePath ); } } } size_t nNum = OtherUserCurReg.GetCount(); size_t Index = 0; for(; Index<nNum; ++Index ) { ::RegCloseKey( OtherUserCurReg[Index] ); } if ( ReceiveDirArray.IsEmpty() ) { return FALSE; } return TRUE; }
CString CBaseSplitterOutputPin::GetMediaTypeDesc(CAtlArray<CMediaType>& mts, LPCWSTR pName, CBaseFilter* pFilter) { if (mts.IsEmpty()) { return pName; } CLSID clSID; HRESULT hr = pFilter->GetClassID(&clSID); if ((clSID == __uuidof(CMpegSourceFilter)) || (clSID == __uuidof(CMpegSplitterFilter))) { return pName; } CAtlList<CString> Infos; const CMediaType* pmt = &mts[0]; if (pmt->majortype == MEDIATYPE_Video) { const VIDEOINFOHEADER *pVideoInfo = NULL; const VIDEOINFOHEADER2 *pVideoInfo2 = NULL; BOOL bAdd = FALSE; if (pmt->formattype == FORMAT_VideoInfo) { pVideoInfo = GetFormatHelper(pVideoInfo, pmt); } else if (pmt->formattype == FORMAT_MPEGVideo) { Infos.AddTail(L"MPEG"); const MPEG1VIDEOINFO *pInfo = GetFormatHelper(pInfo, pmt); pVideoInfo = &pInfo->hdr; bAdd = TRUE; } else if (pmt->formattype == FORMAT_MPEG2_VIDEO) { const MPEG2VIDEOINFO *pInfo = GetFormatHelper(pInfo, pmt); pVideoInfo2 = &pInfo->hdr; bool bIsAVC = false; bool bIsMPEG2 = false; if (pInfo->hdr.bmiHeader.biCompression == FCC('AVC1') || pInfo->hdr.bmiHeader.biCompression == FCC('H264')) { bIsAVC = true; Infos.AddTail(L"AVC (H.264)"); bAdd = TRUE; } else if (pInfo->hdr.bmiHeader.biCompression == FCC('AMVC')) { bIsAVC = true; Infos.AddTail(L"MVC (Full)"); bAdd = TRUE; } else if (pInfo->hdr.bmiHeader.biCompression == FCC('EMVC')) { bIsAVC = true; Infos.AddTail(L"MVC (Subset)"); bAdd = TRUE; } else if (pInfo->hdr.bmiHeader.biCompression == 0) { Infos.AddTail(L"MPEG2"); bIsMPEG2 = true; bAdd = TRUE; } if (bIsMPEG2) { Infos.AddTail(MPEG2_Profile[pInfo->dwProfile]); } else if (pInfo->dwProfile) { if (bIsAVC) { switch (pInfo->dwProfile) { case 44: Infos.AddTail(L"CAVLC Profile"); break; case 66: Infos.AddTail(L"Baseline Profile"); break; case 77: Infos.AddTail(L"Main Profile"); break; case 88: Infos.AddTail(L"Extended Profile"); break; case 100: Infos.AddTail(L"High Profile"); break; case 110: Infos.AddTail(L"High 10 Profile"); break; case 118: Infos.AddTail(L"Multiview High Profile"); break; case 122: Infos.AddTail(L"High 4:2:2 Profile"); break; case 244: Infos.AddTail(L"High 4:4:4 Profile"); break; case 128: Infos.AddTail(L"Stereo High Profile"); break; default: Infos.AddTail(FormatString(L"Profile %d", pInfo->dwProfile)); break; } } else { Infos.AddTail(FormatString(L"Profile %d", pInfo->dwProfile)); } } if (bIsMPEG2) { Infos.AddTail(MPEG2_Level[pInfo->dwLevel]); } else if (pInfo->dwLevel) { if (bIsAVC) { Infos.AddTail(FormatString(L"Level %1.1f", double(pInfo->dwLevel)/10.0)); } else { Infos.AddTail(FormatString(L"Level %d", pInfo->dwLevel)); } } } else if (pmt->formattype == FORMAT_VIDEOINFO2) { const VIDEOINFOHEADER2 *pInfo = GetFormatHelper(pInfo, pmt); pVideoInfo2 = pInfo; } if (!bAdd) { BITMAPINFOHEADER bih; bool fBIH = ExtractBIH(pmt, &bih); if (fBIH) { CString codecName = CMediaTypeEx::GetVideoCodecName(pmt->subtype, bih.biCompression); if (codecName.GetLength() > 0) { Infos.AddTail(codecName); } } } if (pVideoInfo2) { if (pVideoInfo2->bmiHeader.biWidth && pVideoInfo2->bmiHeader.biHeight) { Infos.AddTail(FormatString(L"%dx%d", pVideoInfo2->bmiHeader.biWidth, pVideoInfo2->bmiHeader.biHeight)); } if (pVideoInfo2->AvgTimePerFrame) { Infos.AddTail(FormatString(L"%.3f fps", 10000000.0/double(pVideoInfo2->AvgTimePerFrame))); } if (pVideoInfo2->dwBitRate) { Infos.AddTail(FormatBitrate(pVideoInfo2->dwBitRate)); } } else if (pVideoInfo) { if (pVideoInfo->bmiHeader.biWidth && pVideoInfo->bmiHeader.biHeight) { Infos.AddTail(FormatString(L"%dx%d", pVideoInfo->bmiHeader.biWidth, pVideoInfo->bmiHeader.biHeight)); } if (pVideoInfo->AvgTimePerFrame) { Infos.AddTail(FormatString(L"%.3f fps", 10000000.0/double(pVideoInfo->AvgTimePerFrame))); } if (pVideoInfo->dwBitRate) { Infos.AddTail(FormatBitrate(pVideoInfo->dwBitRate)); } } } else if (pmt->majortype == MEDIATYPE_Audio) { if (pmt->formattype == FORMAT_WaveFormatEx) { const WAVEFORMATEX *pInfo = GetFormatHelper(pInfo, pmt); if (pmt->subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO) { Infos.AddTail(L"DVD LPCM"); } else if (pmt->subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO) { const WAVEFORMATEX_HDMV_LPCM *pInfoHDMV = GetFormatHelper(pInfoHDMV, pmt); UNREFERENCED_PARAMETER(pInfoHDMV); Infos.AddTail(L"HDMV LPCM"); } if (pmt->subtype == MEDIASUBTYPE_DOLBY_DDPLUS) { Infos.AddTail(L"Dolby Digital Plus"); } else { switch (pInfo->wFormatTag) { case WAVE_FORMAT_MPEG: { const MPEG1WAVEFORMAT* pInfoMPEG1 = GetFormatHelper(pInfoMPEG1, pmt); int layer = GetHighestBitSet32(pInfoMPEG1->fwHeadLayer) + 1; Infos.AddTail(FormatString(L"MPEG1 - Layer %d", layer)); } break; default: { CString codecName = CMediaTypeEx::GetAudioCodecName(pmt->subtype, pInfo->wFormatTag); if (codecName.GetLength() > 0) { Infos.AddTail(codecName); } } break; } } if (pInfo->nSamplesPerSec) { Infos.AddTail(FormatString(L"%.1f kHz", double(pInfo->nSamplesPerSec)/1000.0)); } if (pInfo->nChannels) { Infos.AddTail(FormatString(L"%d chn", pInfo->nChannels)); } if (pInfo->wBitsPerSample) { Infos.AddTail(FormatString(L"%d bit", pInfo->wBitsPerSample)); } if (pInfo->nAvgBytesPerSec) { Infos.AddTail(FormatBitrate(pInfo->nAvgBytesPerSec * 8)); } } else if (pmt->formattype == FORMAT_VorbisFormat) { const VORBISFORMAT *pInfo = GetFormatHelper(pInfo, pmt); Infos.AddTail(CMediaTypeEx::GetAudioCodecName(pmt->subtype, 0)); if (pInfo->nSamplesPerSec) { Infos.AddTail(FormatString(L"%.1f kHz", double(pInfo->nSamplesPerSec)/1000.0)); } if (pInfo->nChannels) { Infos.AddTail(FormatString(L"%d chn", pInfo->nChannels)); } if (pInfo->nAvgBitsPerSec) { Infos.AddTail(FormatString(L"%d bit", pInfo->nAvgBitsPerSec)); } if (pInfo->nAvgBitsPerSec) { Infos.AddTail(FormatBitrate(pInfo->nAvgBitsPerSec * 8)); } } else if (pmt->formattype == FORMAT_VorbisFormat2) { const VORBISFORMAT2 *pInfo = GetFormatHelper(pInfo, pmt); Infos.AddTail(CMediaTypeEx::GetAudioCodecName(pmt->subtype, 0)); if (pInfo->SamplesPerSec) { Infos.AddTail(FormatString(L"%.1f kHz", double(pInfo->SamplesPerSec)/1000.0)); } if (pInfo->Channels) { Infos.AddTail(FormatString(L"%d chn", pInfo->Channels)); } } } if (!Infos.IsEmpty()) { CString Ret = pName; Ret += " ("; bool bFirst = true; for (POSITION pos = Infos.GetHeadPosition(); pos; Infos.GetNext(pos)) { const CString& String = Infos.GetAt(pos); if (bFirst) { Ret += String; } else { Ret += L", " + String; } bFirst = false; } Ret += ')'; return Ret; } return pName; }
void CPlayerSubresyncBar::UpdatePreview() { if (m_mode == VOBSUB || m_mode == TEXTSUB) { if (0/*m_fUnlink*/) { for (int i = 0, j = (int)m_sts.GetCount(); i < j; i++) { bool fStartMod, fEndMod, fStartAdj, fEndAdj; GetCheck(i, fStartMod, fEndMod, fStartAdj, fEndAdj); m_sts[i].start = (fStartMod || fStartAdj) ? m_subtimes[i].newstart : m_subtimes[i].orgstart; m_sts[i].end = (fEndMod || fEndAdj) ? m_subtimes[i].newend : m_subtimes[i].orgend; } } else { CAtlArray<int> schk; for (int i = 0, j = (int)m_sts.GetCount(); i < j;) { schk.RemoveAll(); int start = i, end; for (end = i; end < j; end++) { int data = (int)m_list.GetItemData(end); if ((data & TSEP) && end > i) { break; } if (data & (TSMOD | TSADJ)) { schk.Add(end); } } if (schk.IsEmpty()) { for (; start < end; start++) { m_sts[start].start = m_subtimes[start].orgstart; m_sts[start].end = m_subtimes[start].orgend; } } else if (schk.GetCount() == 1) { int k = schk[0]; int dt = m_subtimes[k].newstart - m_subtimes[k].orgstart; for (; start < end; start++) { m_sts[start].start = m_subtimes[start].orgstart + dt; m_sts[start].end = (m_list.GetItemData(start)&TEMOD) ? m_subtimes[start].newend : (m_subtimes[start].orgend + dt); } } else if (schk.GetCount() >= 2) { int i0 = 0; int i1 = 0; int ti0 = 0; int ds = 0; double m = 0; int k, l; for (k = 0, l = (int)schk.GetCount() - 1; k < l; k++) { i0 = schk[k]; i1 = schk[k + 1]; ti0 = m_subtimes[i0].orgstart; ds = m_subtimes[i1].orgstart - ti0; if (ds == 0) { SetSTS0(start, i1, ti0); } else { m = double(m_subtimes[i1].newstart - m_subtimes[i0].newstart) / ds; SetSTS1(start, i1, ti0, m, i0); } } ASSERT(k > 0); if (ds == 0) { SetSTS0(start, end, ti0); } else { SetSTS1(start, end, ti0, m, i0); } } i = end; } } m_sts.CreateSegments(); for (int i = 0, j = (int)m_sts.GetCount(); i < j; i++) { TCHAR buff[32]; FormatTime(i, buff, _countof(buff), 2, false); m_list.SetItemText(i, COL_PREVSTART, buff); FormatTime(i, buff, _countof(buff), 2, true); m_list.SetItemText(i, COL_PREVEND, buff); } if (IsWindowVisible()) { SaveSubtitle(); } } }
// Define an array of chars CAtlArray<char> cArray; // Add an element cArray.Add('a'); // Confirm array is not empty ATLASSERT(!cArray.IsEmpty()); // Remove all elements cArray.RemoveAll(); // Confirm array is empty ATLASSERT(cArray.IsEmpty());
void CPlayerSubresyncBar::UpdatePreview() { if (m_mode == VOBSUB || m_mode == TEXTSUB) { if (0/*m_bUnlink*/) { for (int i = 0, j = (int)m_sts.GetCount(); i < j; i++) { bool bStartMod, bEndMod, bStartAdj, bEndAdj; GetCheck(i, bStartMod, bEndMod, bStartAdj, bEndAdj); m_sts[i].start = (bStartMod || bStartAdj) ? m_subtimes[i].newStart : m_subtimes[i].orgStart; m_sts[i].end = (bEndMod || bEndAdj) ? m_subtimes[i].newEnd : m_subtimes[i].orgEnd; } } else { CAtlArray<int> schk; for (int i = 0, j = (int)m_sts.GetCount(); i < j;) { schk.RemoveAll(); int start = i, end; for (end = i; end < j; end++) { int data = m_displayData[end].flags; if ((data & TSEP) && end > i) { break; } if (data & (TSMOD | TSADJ)) { schk.Add(end); } } if (schk.IsEmpty()) { for (; start < end; start++) { m_sts[start].start = m_subtimes[start].orgStart; m_sts[start].end = m_subtimes[start].orgEnd; } } else if (schk.GetCount() == 1) { int k = schk[0]; int dt = m_subtimes[k].newStart - m_subtimes[k].orgStart; for (; start < end; start++) { m_sts[start].start = m_subtimes[start].orgStart + dt; m_sts[start].end = (m_displayData[start].flags & TEMOD) ? m_subtimes[start].newEnd : (m_subtimes[start].orgEnd + dt); } } else if (schk.GetCount() >= 2) { int i0 = 0; int i1 = 0; int ti0 = 0; int ds = 0; double m = 0; int k, l; for (k = 0, l = (int)schk.GetCount() - 1; k < l; k++) { i0 = schk[k]; i1 = schk[k + 1]; ti0 = m_subtimes[i0].orgStart; ds = m_subtimes[i1].orgStart - ti0; if (ds == 0) { SetSTS0(start, i1, ti0); } else { m = double(m_subtimes[i1].newStart - m_subtimes[i0].newStart) / ds; SetSTS1(start, i1, ti0, m, i0); } } ASSERT(k > 0); if (ds == 0) { SetSTS0(start, end, ti0); } else { SetSTS1(start, end, ti0, m, i0); } } i = end; } } m_sts.CreateSegments(); for (size_t i = 0, j = m_sts.GetCount(); i < j; i++) { m_displayData[i].tPrevStart = m_sts[i].start; m_displayData[i].tPrevEnd = m_sts[i].end; } m_list.Invalidate(); if (IsWindowVisible()) { SaveSubtitle(); } } }