Skip to content

Commit 9e75772

Browse files
committed
Added enumeratable device listing functions
1 parent 3be597e commit 9e75772

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

src/ffmpegio/devices.py

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,28 @@ def gather_device_info(dev_type, hook):
8282
SINKS = gather_device_info("sinks", "device_sink_api")
8383

8484

85-
plugin_devices = {name: api for name, api in plugins.get_hook().device_source_api()}
86-
SOURCES = {k: check_plugin(plugin_devices, k, v) for k, v in get_devices("sources")}
85+
def _list_devices(devs, mtype):
86+
return [
87+
dev
88+
for dev, info in devs.items()
89+
if "list" in info and any((k.startswith(mtype) for k in info["list"].keys()))
90+
]
8791

88-
plugin_devices = {name: api for name, api in plugins.get_hook().device_sink_api()}
89-
SINKS = {k: check_plugin(plugin_devices, k, v) for k, v in get_devices("sinks")}
9092

93+
def list_video_sources():
94+
return _list_devices(SOURCES, "v")
95+
96+
97+
def list_audio_sources():
98+
return _list_devices(SOURCES, "a")
99+
100+
101+
def list_video_sinks():
102+
return _list_devices(SINKS, "v")
103+
104+
105+
def list_audio_sinks():
106+
return _list_devices(SINKS, "a")
91107

92108
def resolve_source(url, opts):
93109
try:

0 commit comments

Comments
 (0)