Last active
October 8, 2015 15:08
-
-
Save gyakoo/68734f0481f2b450ef4d to your computer and use it in GitHub Desktop.
Code to print all filter categories supported in DirectShow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ----------------------------------------------------------------- | |
// Enumerate all objects in this category, printing the name | |
// ----------------------------------------------------------------- | |
void enum_cat(REFGUID cat) | |
{ | |
HRESULT hr; | |
ICreateDevEnum *pSysDevEnum = NULL; | |
IEnumMoniker *pEnum = NULL; | |
IMoniker *pMoniker = NULL; | |
VARIANT var; | |
hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, | |
IID_ICreateDevEnum, (void**)&pSysDevEnum); | |
if (FAILED(hr)) | |
return; | |
hr = pSysDevEnum->CreateClassEnumerator(cat, &pEnum, 0); | |
if (hr == S_OK && pEnum) | |
{ | |
while (S_OK == pEnum->Next(1, &pMoniker, NULL)) | |
{ | |
if ( !pMoniker ) continue; | |
IPropertyBag *pPropBag = NULL; | |
pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pPropBag); | |
if ( !pPropBag ) continue; | |
VariantInit(&var); | |
hr = pPropBag->Read(L"FriendlyName", &var, 0); | |
if (SUCCEEDED(hr)) | |
printf("\t%S\n", var.bstrVal); | |
VariantClear(&var); | |
if (pPropBag) pPropBag->Release(); | |
if (pMoniker) pMoniker->Release(); | |
} | |
} | |
if ( pSysDevEnum ) pSysDevEnum->Release(); | |
if ( pEnum ) pEnum->Release(); | |
} | |
// ----------------------------------------------------------------- | |
// Enumerate all categories in the array | |
// ----------------------------------------------------------------- | |
void enum_categories() | |
{ | |
#define catentry(n) {#n,n} | |
struct cat { const char* catname; GUID g; }; | |
cat cats[] = { | |
catentry(CLSID_VideoInputDeviceCategory), | |
catentry(CLSID_LegacyAmFilterCategory), | |
catentry(CLSID_VideoCompressorCategory), | |
catentry(CLSID_AudioCompressorCategory), | |
catentry(CLSID_AudioInputDeviceCategory), | |
catentry(CLSID_AudioRendererCategory), | |
catentry(CLSID_MidiRendererCategory), | |
catentry(CLSID_TransmitCategory), | |
catentry(CLSID_DeviceControlCategory), | |
catentry(CLSID_ActiveMovieCategories), | |
catentry(CLSID_DVDHWDecodersCategory), | |
catentry(CLSID_MediaEncoderCategory), | |
catentry(CLSID_MediaMultiplexerCategory), | |
}; | |
if ( SUCCEEDED(CoInitializeEx(NULL, COINIT_MULTITHREADED)) ) | |
{ | |
for (int i = 0; i < ARRAYSIZE(cats); ++i) | |
{ | |
printf("*** %s\n", cats[i].catname); | |
enum_cat(cats[i].g); | |
} | |
CoUninitialize(); | |
} | |
#undef catentry | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment