Thursday, May 03, 2007

Enumerating the List of DirectX transform Effects in a system

I developed the sample application to enumerate the list of filters already available in a system.

I added tne strmiids.lib for this application.

CLSID_VideoEffects1Category - 1 input filters
CLSID_VideoEffects2Category - 2 input filters


The "Video Effects (1 input)" and "Video Effects (2 inputs)" categories contain video effects and transitions for DirectShow Editing Services.


we can search the following GUIDs in a registry.

it is in the following category
HKEY_CURRENT_USER->Software-> Microsoft ->ActiveSetup ->Active movie ->DevEnum->{CC7BFB42-F175-11D1-A392-00E0291F3959}(CLSID_VideoEffects1Category ->have the
list of filters available in a system.


#include "atlbase.h"
#include "dshow.h"
#include "conio.h"


EXTERN_GUID(CLSID_VideoEffects1Category, 0xcc7bfb42, 0xf175, 0x11d1, 0xa3, 0x92, 0x0, 0xe0, 0x29, 0x1f, 0x39, 0x59);
EXTERN_GUID(CLSID_VideoEffects2Category, 0xcc7bfb43, 0xf175, 0x11d1, 0xa3, 0x92, 0x0, 0xe0, 0x29, 0x1f, 0x39, 0x59);

/*
EXTERN_GUID(CLSID_VideoEffects1Category, 0xcc7bfb42, 0xf175, 0x11d1, 0xa3, 0x92, 0x0, 0xe0, 0x29, 0x1f, 0x39, 0x59);
EXTERN_GUID(CLSID_VideoEffects2Category, 0xcc7bfb43, 0xf175, 0x11d1, 0xa3, 0x92, 0x0, 0xe0, 0x29, 0x1f, 0x39, 0x59);
EXTERN_GUID(CLSID_AudioEffects1Category, 0xcc7bfb44, 0xf175, 0x11d1, 0xa3, 0x92, 0x0, 0xe0, 0x29, 0x1f, 0x39, 0x59);
EXTERN_GUID(CLSID_AudioEffects2Category, 0xcc7bfb45, 0xf175, 0x11d1, 0xa3, 0x92, 0x0, 0xe0, 0x29, 0x1f, 0x39, 0x59);

*/

// Enumerate all of the effects.
HRESULT EnumerateEffects(CLSID searchType)
{
// Once again, code stolen from the DX9 SDK.

// Create the System Device Enumerator.
ICreateDevEnum *pSysDevEnum = NULL;
HRESULT hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL,
CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void **)&pSysDevEnum);
if (FAILED(hr))
{
return hr;
}

// Obtain a class enumerator for the effect category.
IEnumMoniker *pEnumCat = NULL;
hr = pSysDevEnum->CreateClassEnumerator(searchType, &pEnumCat, 0);

if (hr == S_OK)
{
// Enumerate the monikers.
IMoniker *pMoniker = NULL;
ULONG cFetched;
while (pEnumCat->Next(1, &pMoniker, &cFetched) == S_OK)
{
// Bind the first moniker to an object.
IPropertyBag *pPropBag;
hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag,
(void **)&pPropBag);
if (SUCCEEDED(hr))
{
// To retrieve the filter's friendly name, do the following:
VARIANT varName;
VariantInit(&varName);
hr = pPropBag->Read(L"FriendlyName", &varName, 0);
if (SUCCEEDED(hr))
{
wprintf(L"Effect: %s\n", varName.bstrVal);
}
VariantClear(&varName);
pPropBag->Release();
}
pMoniker->Release();
}
pEnumCat->Release();
}
pSysDevEnum->Release();
return hr;
}

// A very simple program to list DES effects using DirectShow.
//
int main(int argc, char* argv[])
{

// Initialize the COM library.
HRESULT hr = CoInitialize(NULL);
if (FAILED(hr))
{
// We'll send our error messages to the console.
printf("ERROR - Could not initialize COM library");
return hr;
}

// OK, so now we want to build the filter graph
// using an AudioCapture filter.
// But there are several to choose from,
// so we need to enumerate them, then pick one.
hr = EnumerateEffects(CLSID_VideoEffects1Category);

getch();
hr = EnumerateEffects(CLSID_VideoEffects2Category);
CoUninitialize();
getch();


return 0;
}

No comments: