您的位置:首页 > 其它

添加DMO到directshow filter graph中

2012-12-16 16:50 134 查看


添加DMO到directshow filter graph中

2012-04-04 20:32 196人阅读 评论(0) 收藏 举报

这里我主要是碰上了一个




要添加进我的graph的问题。(DMO不同于,Filter,但是可以通过IWrapperFilter 来使用DMO --象Filter一样使用 但是有局限性)

这里截图下,陆书上的dmo的描述:





书上也有一些关于添加DMO到Filter Graph的例子:

我这里写出我的代码:

使用这个之前要先说清楚几个东西:dmo 这个东西还需要包含头文件DMOReg.h 这个头文件包含于:dmo.h

这个头文件里面有定义:

DMO Category DirectShow Equivalent

DMOCATEGORY_AUDIO_ENCODER CLSID_AudioCompressorCategory

DMOCATEGORY_AUDIO_DECODER CLSID_LegacyAmFilterCategory

DMOCATEGORY_VIDEO_ENCODER CLSID_VideoCompressorCategory

DMOCATEGORY_VIDEO_DECODER CLSID_LegacyAmFilterCategory

所以是必不可少的。

单单是这样还是不行的,会弹出这样的错误:

CLSID_DMOWrapperFilter 标示符没有声明

这事应为缺少:dmodshow.h 这个头文件

之后编译能通过,但是链接会出现:

error LNK2001: unresolved external symbol _IID_IDMOWrapperFilter

这是因为缺少:dmoguids.lib

所以:#pragma comment(lib,"dmoguids.lib")

一下这序列是graphedit上显示的 filter moniker:

@device:dmo:{2A11BAE2-FE6E-4249-864B-9E9ED6E8DBC2}{4A69B442-28BE-4991-969C-B500ADF5D8A8}

IDMOWrapperFilter::Init

The Init method initializes the DMO Wrapper filter with the specified DMO.

Syntax

HRESULT Init(

REFCLSID clsidDMO,

REFCLSID catDMO

);

Parameters

clsidDMO

Class identifier (CLSID) of the DMO.

catDMO

CLSID that specifies the category of the DMO.

clsidDMO 指就是串的前面括号的:2A11BAE2-FE6E-4249-864B-9E9ED6E8DBC2

后面的}{4A69B442-28BE-4991-969C-B500ADF5D8A8}就是 catDMO

可以在 DMOReg.h这里找到

// 4a69b442-28be-4991-969c-b500adf5d8a8

DEFINE_GUID(DMOCATEGORY_VIDEO_DECODER, 0x4a69b442,0x28be,0x4991,0x96,0x9c,0xb5,0x00,0xad,0xf5,0xd8,0xa8);

HRESULT CPlayer::AddDMOWrapperFilter(IFilterGraph *pfG,

IBaseFilter ** ppF,

const CLSID clsidDMO,

const CLSID catDMO ,

LPCWSTR wszName)

{

if(!pfG||!ppF)

return E_POINTER;

*ppF = NULL ;

IBaseFilter * pFilter =NULL;

HRESULT hr = CoCreateInstance(CLSID_DMOWrapperFilter,

NULL,CLSCTX_INPROC_SERVER,IID_IBaseFilter,reinterpret_cast<void **>(&pFilter));

if(SUCCEEDED(hr))

{

IDMOWrapperFilter * pDmoWrapper =NULL;

hr = pFilter->QueryInterface(IID_IDMOWrapperFilter,

reinterpret_cast<void **>(&pDmoWrapper));

if(SUCCEEDED(hr))

{

hr = pDmoWrapper->Init(clsidDMO,catDMO);

pDmoWrapper->Release();

if(SUCCEEDED(hr))

{

(*ppF) = pFilter ;

hr =pfG->AddFilter(*ppF,wszName);

if(SUCCEEDED(hr))

return S_OK ;

}

}

}

return hr ;


}

Limitations comes from csdn
There are some limitations when using DMOs in DirectShow:

The DMO Wrapper filter does not support DMOs with zero inputs, multiple inputs, or zero outputs.
All pin connections on the DMO Wrapper Filter use the IMemInputPin interface.
The current version of DirectShow Editing Services does not support DMO-based effects or transitions

分享到:

上一篇:tmp
下一篇:Source Filer 的手动连接 注意事项
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: