mirror of
https://github.com/iperov/DeepFaceLive
synced 2025-08-19 21:13:21 -07:00
update xlib.api.win32
This commit is contained in:
parent
878c14756b
commit
2be3278753
21 changed files with 726 additions and 192 deletions
40
xlib/api/win32/dshow/helper.py
Normal file
40
xlib/api/win32/dshow/helper.py
Normal file
|
@ -0,0 +1,40 @@
|
|||
from typing import List
|
||||
from .. import ole32, uuids, strmif, wintypes, objidl, oaidl
|
||||
|
||||
|
||||
|
||||
def get_video_input_devices_names() -> List[str]:
|
||||
"""
|
||||
returns a list of available names of VideoInputDevice's
|
||||
|
||||
ole32 should be initialized before use
|
||||
"""
|
||||
# based on https://docs.microsoft.com/ru-ru/windows/win32/directshow/selecting-a-capture-device
|
||||
|
||||
names = []
|
||||
sys_dev_enum = strmif.ICreateDevEnum()
|
||||
if ole32.CoCreateInstance(uuids.CLSID_SystemDeviceEnum, None, ole32.CLSCTX.CLSCTX_INPROC_SERVER, strmif.ICreateDevEnum.IID, sys_dev_enum) == wintypes.ERROR.SUCCESS:
|
||||
pEnumCat = objidl.IEnumMoniker()
|
||||
|
||||
if sys_dev_enum.CreateClassEnumerator(uuids.CLSID_VideoInputDeviceCategory, pEnumCat, 0) == wintypes.ERROR.SUCCESS:
|
||||
|
||||
moniker = objidl.IMoniker()
|
||||
|
||||
while pEnumCat.Next(1, moniker, None) == wintypes.ERROR.SUCCESS:
|
||||
|
||||
prop_bag = oaidl.IPropertyBag()
|
||||
if moniker.BindToStorage(None, None, oaidl.IPropertyBag.IID, prop_bag) == wintypes.ERROR.SUCCESS:
|
||||
var = wintypes.VARIANT()
|
||||
|
||||
hr = prop_bag.Read(wintypes.LPCOLESTR('Description'), var, None )
|
||||
if hr != wintypes.ERROR.SUCCESS:
|
||||
hr = prop_bag.Read(wintypes.LPCOLESTR('FriendlyName'), var, None )
|
||||
|
||||
names.append(var.value.bstrVal.value if hr == wintypes.ERROR.SUCCESS else 'unnamed')
|
||||
|
||||
prop_bag.Release()
|
||||
moniker.Release()
|
||||
pEnumCat.Release()
|
||||
sys_dev_enum.Release()
|
||||
|
||||
return names
|
Loading…
Add table
Add a link
Reference in a new issue