0

I am writing a Directshow application which connects a file source to a MPEG4s DMO.
The graph looks like:
File Source -> DMO Wrapper Filter -> Video Renderer.
Here are my questions:
1. How can I add a file source filter in the graph ? I got this piece of code which graphedit plus generated. Is this piece of code correct ? I see that it uses "CComPtr" which needs "atlbase.h". With VS2010 Express edition I don't have the atl headers.

LPCOLESTR srcFile1 = L"C:\\Users\shyam\\Downloads\\sample.avi";
CComPtr<IBaseFilter> pBaseFilter;
hr = pBaseFilter.CoCreateInstance(CLSID_AsyncReader);
CComQIPtr<IFileSourceFilter> pFileSourceFilter = pBaseFilter;
ATLASSERT(pFileSourceFilter);
pFileSourceFilter->Load(srcFile1, NULL);
hr = pGB->AddFilter(pBaseFilter, L"File Source (Async.)"); 

2. I manually downloaded "atlbase.h" from net and I am encountering several build errors. What can be done in this case.

Please help me in moving in the right direction !!

Thanks,
Shyam

4

2 回答 2

0

可以在没有 ATL 的情况下为 Directshow 编写 C++ 代码,但我强烈不推荐它,除非您喜欢带有泄漏的意大利面条。这是您的代码的样子

IBaseFilter* pBaseFilter;
CoCreateInstance(CLSID_AsyncReader, NULL, CLSCTX_INPROC_SERVER, IID_IBaseFilter, (void**)&pBaseFilter);

IFileSourceFilter* pFileSourceFilter = NULL;
hr = pBaseFilter->QueryInterface(IID_IFileSourceFilter, (void**)&pFileSourceFilter);

ASSERT(pFileSourceFilter != NULL);

hr = pFileSourceFilter->Load(L"C:\\Users\shyam\\Downloads\\sample.avi", NULL);

if (pFileSourceFilter)
    pFileSourceFilter->Release();

hr = pFileSourceFilter->AddFilter(pBaseFilter, L"AsyncReader");

您还需要在每一步检查 hr 是否有错误。最新的 Windows SDK 可能没有所有的 Directshow 接口,所以我建议 Microsoft Windows SDK Update for Windows Vista (for qedit.h)。但是请不要在没有 ATL 的情况下编写 Directshow 或 COM 代码,即使是 c# 中的 DirectshowLib 对于简单的应用程序也会更容易。

于 2013-09-26T01:49:44.660 回答
0

上面生成的代码是正确的。为了摆脱编译错误,下载并安装最新的 windows sdk。它应该具有正确的 atl 标头。

于 2013-07-21T11:22:58.797 回答