注册
Filter
//
Creates registry entries for the DLL
The AMovieDllRegisterServer2 function creates registry entries for every component in the g_Templates array. However, this function has some limitations. First, it assigns every filter to the "DirectShow Filters" category (CLSID_LegacyAmFilterCategory), but not every filter belongs in this category. Capture filters and compression filters, for example, have their own categories. Second, if your filter supports a hardware device, you might need to register two additional pieces of information that AMovieDLLRegisterServer2 does not handle: the medium and the pin category. A medium defines a method of communication in a hardware device, such as a bus. The pin category defines the function of a pin. For information on mediums, see KSPIN_MEDIUM in the Microsoft Windows Driver Development Kit (DDK). For a list of pin categories, see Pin Property Set.
REGFILTER2 rf2FilterReg =
{
1, // Version 1 (no pin mediums or pin category).
MERIT_NORMAL, // Merit.
1, // Number of pins.
&sudPins // Pointer to pin information.
};
//Creates registry entries for the DLL
STDAPI DllRegisterServer(
void)
{
HRESULT hr = E_FAIL;
IFilterMapper2 *pFM2 = NULL;
hr = AMovieDllRegisterServer2(TRUE);
//
这个还是要调用的
if (FAILED(hr)) return hr;
hr =
CoCreateInstance(
CLSID_FilterMapper2, NULL,
CLSCTX_INPROC_SERVER,
IID_IFilterMapper2, (void **)&pFM2);
if (FAILED(hr)) return hr;
hr = pFM2->RegisterFilter(
CLSID_SomeFilter, // Filter CLSID.
g_wszName, // Filter name.
NULL, // Device moniker.
&CLSID_VideoCompressorCategory, // Video compressor category.
g_wszName, // Instance data.
&rf2FilterReg // Pointer to filter information.
);
pFM2->Release();
return hr;
}
注销
Filter
//
Removes registry entries for the DLL
//
Removes registry entries for the DLL
STDAPI DllUnregisterServer()
{
HRESULT hr = E_FAIL;
IFilterMapper2* pFM2 = NULL;
hr = AMovieDllRegisterServer2(FALSE);
if (FAILED(hr)) return hr;
hr = CoCreateInstance(CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER,
IID_IFilterMapper2, (void **)&pFM2);
if (FAILED(hr)) return hr;
hr = pFM2->UnregisterFilter(&CLSID_VideoCompressorCategory,
g_wszName, CLSID_SomeFilter);
pFM2->Release();
return hr;
}
给
Filter
起个名字
const
AMOVIESETUP_MEDIATYPE sudPinTypes =
const
AMOVIESETUP_PIN psudPins[] =
L"Input", //
String pin name
1, //
Number of types
&
sudPinTypes
//
Declare filter information
const
AMOVIESETUP_FILTER sudFilter =
2
, // Number of pins
psudPins
// Pin details
//
所以,如果有多个引擎,相应的数组的大小就是引擎的个数。
允许
Filter
应用
// CreateInstance
是
CFactory
的一个接口,在
Filter
内部实现它
CUnknown* WINAPI
CImplement::CreateInstance(
LPUNKNOWN pUnk,
HRESULT *pHr)
{
CImplement *pFilter = new CImplement ();
if (!pFilter)
{
*pHr = E_OUTOFMEMORY;
}
return pFilter;
}
Filter
的
Merit
Merit
:
enum
{
MERIT_PREFERRED = 0x800000,
MERIT_NORMAL = 0x600000,
MERIT_UNLIKELY = 0x400000,
MERIT_DO_NOT_USE = 0x200000,
MERIT_SW_COMPRESSOR = 0x100000,
MERIT_HW_COMPRESSOR = 0x100050
};
确定
Filter
的用途
不同的
Filter
有不同的用途,可以选择不同的基类,实现不同的方法。详见
DirectX
文档。
Filter
的种类,在内进行了详细的描述
root/DirectShow/DirectShow Reference/Constants and GUIDs/Filter Categories
。
添加属性页