添加DMO到directshow filter graph中

这里我主要是碰上了一个
 
要添加进我的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


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值