使用 intelligent connection 連接後面的 Filters 是很方便的作法, 尤其是你不想寫程式的時候, intelligent 是上天送給你的禮物.
但是, 當你在寫 DirectShow 程式專案時, Bugs就像是鬼魅般地一直糾纏著你, 卻找不到任何蛛絲馬跡.
特別是裝了 K-Lite package 或其他一堆 Filters 時, multi-thread 的同步問題以及 timing 的問題已經夠棘手了, 別又告訴我 xvid.ax 與 ffmpeg filters 之間的程式行為有所不同 (他們確實不同!).
知道你應用程式中負責處理的 Filters 資訊就很重要. 專注一個 Filter 然後, 再解決另一個 filter 的問題. 應該是解決問題的方法.
When you are debugging in a DirectShow project, these information are crucial that determine what time you can go home.
Enumerating DirectShow filters!
I need this for a long time. To get the job done, you can use IEnumFilters to enumerate the filters in your program.
How to use? The detail is listed as follows.
-------------------------------- code ------------------------------
#include <streams.h>
// 印出 Grpah Manager中管理的所有 Filters 名稱
HRESULT PrintAllFilter(IGraphBuilder *pGB){
HRESULT hr;
CComPtr<IEnumFilters> pEnum = NULL;
IBaseFilter *pFilter = NULL;
IPin *pPin;
ULONG ulFetched;
// Verify graph builder interface
if (!pGB)
return E_NOINTERFACE;
// Get filter enumerator
hr = pGB->EnumFilters(&pEnum);
if (FAILED(hr))
return hr;
pEnum->Reset();
// Enumerate all filters in the graph
while((pEnum->Next(1, &pFilter, &ulFetched) == S_OK)){
// Read filter name for debugging purposes
FILTER_INFO FilterInfo;
TCHAR szName[256];
hr = pFilter->QueryFilterInfo(&FilterInfo);
if (SUCCEEDED(hr)){
// Show filter name
lstrcpyn(szName, FilterInfo.achName, 256);
FilterInfo.pGraph->Release();
}
pFilter->Release();
TRACE(_T("Filter name=%s\n"),szName);
szName[255] = 0; // Null-terminate
}
return hr;
}
-------------------------------- end of code --------------------------
Based on this code, I can exactly understand what filters is plugged in my programming. If you don't like program, you can use graphedit.exe to do the same thing.
Enjoy.
by Jing
沒有留言:
張貼留言