This commit is contained in:
2024-08-07 09:16:27 -04:00
parent fdfadd5c7e
commit 5f971cf684
5200 changed files with 731717 additions and 0 deletions

102
dvcap/DeviceEnumerator.cpp Normal file
View File

@@ -0,0 +1,102 @@
#include <com/com.hpp>
#include <com/variant.hpp>
#include <com/comptr.hpp>
#include <dvcap/DeviceEnumerator.hpp>
bool DeviceEnumerator::enumerateCategory(DeviceDescriptors &descriptors,DevCat devCat)
{
switch(devCat)
{
case AudioCaptureSources :
return enumerateCategory(descriptors,CLSID_AudioInputDeviceCategory);
case AudioCompressors :
return enumerateCategory(descriptors,CLSID_AudioCompressorCategory);
case AudioRenderers :
return enumerateCategory(descriptors,CLSID_AudioRendererCategory);
case DeviceControlFilters :
return enumerateCategory(descriptors,CLSID_DeviceControlCategory);
case DirectShowFilters :
return enumerateCategory(descriptors,CLSID_LegacyAmFilterCategory);
case ExternalRenderers :
return enumerateCategory(descriptors,CLSID_TransmitCategory);
case MidiRenderers :
return enumerateCategory(descriptors,CLSID_MidiRendererCategory);
case VideoCaptureSources :
return enumerateCategory(descriptors,CLSID_VideoInputDeviceCategory);
case VideoCompressors :
return enumerateCategory(descriptors,CLSID_VideoCompressorCategory);
case VideoEffects1 :
return enumerateCategory(descriptors,CLSID_VideoEffects1Category);
case VideoEffects2 :
return enumerateCategory(descriptors,CLSID_VideoEffects2Category);
case WDMStreamingDecompressionDevices :
return enumerateCategory(descriptors,KSCATEGORY_DATADECOMPRESSOR);
case WDMStreamingCaptureDevices :
return enumerateCategory(descriptors,AM_KSCATEGORY_CAPTURE);
case WDMStreamingCommunicationTransforms :
return enumerateCategory(descriptors,KSCATEGORY_COMMUNICATIONSTRANSFORM);
case WDMStreamingCrossbarDevices :
return enumerateCategory(descriptors,AM_KSCATEGORY_CROSSBAR);
case WDMStreamingDataTransforms :
return enumerateCategory(descriptors,KSCATEGORY_DATATRANSFORM);
case WDMStreamingInterfaceTransforms :
return enumerateCategory(descriptors,KSCATEGORY_INTERFACETRANSFORM);
case WDMStreamingMixerDevices :
return enumerateCategory(descriptors,KSCATEGORY_MIXER);
case WDMRenderingDevices :
return enumerateCategory(descriptors,AM_KSCATEGORY_RENDER);
case WDMStreamingSystemAudioDevices :
return enumerateCategory(descriptors,KSCATEGORY_AUDIO_DEVICE);
case WDMStreamingTeeSplitterDevices :
return enumerateCategory(descriptors,AM_KSCATEGORY_SPLITTER);
case WDMStreamingTVAudioDevices :
return enumerateCategory(descriptors,AM_KSCATEGORY_TVAUDIO);
case WDMStreamingTVTunerDevices :
return enumerateCategory(descriptors,AM_KSCATEGORY_TVTUNER);
case WDMStreamingVBICodes :
return enumerateCategory(descriptors,AM_KSCATEGORY_VBICODEC);
case ActiveMovieFilterCategories :
return enumerateCategory(descriptors,CLSID_ActiveMovieCategories);
}
return false;
}
bool DeviceEnumerator::enumerateCategory(DeviceDescriptors &descriptors,GUID classID)
{
ComInitializer comInit;
ComPointer<ICreateDevEnum> sysDevEnum;
ComPointer<IEnumMoniker> enumMoniker;
ComPointer<IMoniker> moniker;
ComObj comObj;
ComResult comResult;
BString bstring;
DeviceDescriptor descriptor;
ULONG cFetched;
descriptors.remove();
comResult=sysDevEnum.createInstance(CLSID_SystemDeviceEnum,IID_ICreateDevEnum);
if(comResult.error())return false;
comResult=sysDevEnum->CreateClassEnumerator(classID,(IEnumMoniker**)enumMoniker,0);
if(comResult.error())return false;
while(S_OK==enumMoniker->Next(1,(IMoniker**)moniker,&cFetched))
{
ComPointer<IPropertyBag> propertyBag;
moniker->BindToStorage(0,0,IID_IPropertyBag,(void**)(IPropertyBag**)propertyBag);
Variant varName;
comResult=propertyBag->Read(L"FriendlyName", &varName.getVARIANT(), 0);
if(comResult.success())
{
varName.getData(bstring);
descriptor.setName(bstring.toString());
}
comResult=propertyBag->Read(L"Description",&varName.getVARIANT(), 0);
if(comResult.success())
{
varName.getData(bstring);
descriptor.setDescription(bstring.toString());
}
if(descriptor.getName().isNull()&&descriptor.getDescription().isNull())continue;
descriptors.insert(&descriptor);
}
return true;
}