本文整理汇总了C++中IFilterGraph::AddFilter方法的典型用法代码示例。如果您正苦于以下问题:C++ IFilterGraph::AddFilter方法的具体用法?C++ IFilterGraph::AddFilter怎么用?C++ IFilterGraph::AddFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFilterGraph
的用法示例。
在下文中一共展示了IFilterGraph::AddFilter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TryToLoadCorrectionFile
//.........这里部分代码省略.........
ZeroMemory(pszFileNameC, sizeof(WCHAR)*MAX_PATH);
int cch = lstrlenW(pszFileName);
CopyMemory(pszFileNameC, pszFileName, cch*sizeof(WCHAR));
pszFileNameC[cch] = 'c';
IFilterGraph* pFG = GetFilterGraph();
// Search in the graph in case the source filter with correction file already exist
hr = pFG->EnumFilters(&pEnumFilers);
IF_FAIL_BREAK(hr);
while(pEnumFilers->Next(1, &pSrcFilterCorr, 0) == S_OK)
{
HRESULT lhr;
lhr = pSrcFilterCorr->QueryInterface(IID_IFileSourceFilter, (void**)&pFSFCorr);
if(SUCCEEDED(lhr))
{
LPOLESTR pszFileNameCandidate = NULL;
pFSFCorr->GetCurFile(&pszFileNameCandidate, NULL);
if(memcmp(pszFileNameCandidate,pszFileNameC,(cch+1)*sizeof(WCHAR)) == 0)
{
// This is the good file
bSrcFileAlreadyLoaded = TRUE;
if(pszFileNameCandidate != NULL)
{
CoTaskMemFree(pszFileNameCandidate);
}
break;
}
if(pszFileNameCandidate != NULL)
{
CoTaskMemFree(pszFileNameCandidate);
}
}
pSrcFilterCorr->Release();
pSrcFilterCorr = NULL;
}
if(bSrcFileAlreadyLoaded == FALSE)
{
// Create new file source filter
hr = CoCreateInstance(CLSID_AsyncReader,
NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter,
(void**)&pSrcFilterCorr);
IF_FAIL_BREAK(hr);
hr = pFG->AddFilter(pSrcFilterCorr, pszFileNameC);
IF_FAIL_BREAK(hr);
hr = pSrcFilterCorr->QueryInterface(IID_IFileSourceFilter, (void**)&pFSFCorr);
IF_FAIL_BREAK(hr);
hr = pFSFCorr->Load(pszFileNameC, NULL);
IF_FAIL_BREAK(hr);
}
// Get first pin and connect it
hr = pSrcFilterCorr->EnumPins(&pEnum);
IF_FAIL_BREAK(hr);
if(pEnum->Next(1, &pPinNew, 0) == S_OK)
{
hr = pFG->ConnectDirect(pPinNew, m_pInputPinCorr, NULL);
bCorrectionFileLoaded = SUCCEEDED(hr);
}
} while(0);
if((bCorrectionFileLoaded == FALSE) && (pSrcFilterCorr != NULL))
{
IFilterGraph* pFG = GetFilterGraph();
pFG->RemoveFilter(pSrcFilterCorr);
}
// Cleanup
SAFE_RELEASE(pPinNew);
SAFE_RELEASE(pEnum);
SAFE_RELEASE(pEnumFilers);
SAFE_RELEASE(pFSFCorr);
SAFE_RELEASE(pSrcFilterCorr);
if(pszFileName != NULL)
{
CoTaskMemFree(pszFileName);
}
SAFE_RELEASE(pFSF);
SAFE_RELEASE(pPinOutSrc);
#undef IF_FAIL_BREAK
m_bDontTryToLoadCorrectionFileAgain = bCorrectionFileLoaded;
if(bCorrectionFileLoaded)
{
DebugLog("<=== Leaving TryToLoadCorrectionFile successfull 0x%08X", GetCurrentThreadId());
}
else
{
DebugLog("<=== Leaving TryToLoadCorrectionFile FAILED 0x%08X", GetCurrentThreadId());
}
return hr;
}
示例2: Open
HRESULT fsPartMediaPlayer::Open(HANDLE hFile, UINT64 uMaxAvail)
{
HRESULT hr;
Close ();
m_stream.Attach (hFile, uMaxAvail);
if (m_stream.Get_MediaType () == NULL)
return E_FAIL;
m_reader.Set_MediaType (m_stream.Get_MediaType ());
RIF (CoCreateInstance (CLSID_FilterGraph, NULL, CLSCTX_INPROC,
IID_IGraphBuilder, (void**) &m_pGB));
IFilterGraph* pFG = NULL;
RIF (m_pGB->QueryInterface (IID_IFilterGraph, (void**)&pFG));
RIF (pFG->AddFilter (&m_reader, NULL));
pFG->Release ();
RIF (m_pGB->Render (m_reader.GetPin (0)));
RIF (m_pGB->QueryInterface (IID_IMediaControl, (void**)&m_pMC));
RIF (m_pGB->QueryInterface (IID_IMediaEventEx, (void**)&m_pME));
RIF (m_pGB->QueryInterface (IID_IMediaSeeking, (void**)&m_pMS));
m_pGB->QueryInterface (IID_IVideoWindow, (void**)&m_pVW);
m_pGB->QueryInterface (IID_IBasicAudio, (void**)&m_pBA);
IBasicVideo* pBV = NULL;
m_pGB->QueryInterface (IID_IBasicVideo, (void**) &pBV);
if (pBV != NULL)
{
long nW, nH;
pBV->get_VideoWidth (&nW);
pBV->get_VideoHeight (&nH);
m_fVideoRatio = (double)nW / nH;
pBV->Release ();
}
else
{
m_fVideoRatio = 1;
}
if (m_pVW)
{
if (FAILED (m_pVW->put_MessageDrain ((OAHWND)m_hOutWnd)))
{
SAFE_RELEASE (m_pVW);
}
}
RIF (m_pME->SetNotifyWindow ((OAHWND)m_hOutWnd, WM_VIDEONOTIFY, LONG(this)));
if (m_pVW)
{
m_pVW->put_Visible (OAFALSE);
m_pVW->put_WindowStyle (WS_CHILD);
m_pVW->put_Owner ((OAHWND)m_hOutWnd);
AutoSize ();
m_pVW->put_Visible (OATRUE);
m_pVW->SetWindowForeground (-1);
}
m_state = VFPS_STOPPED;
return S_OK;
}