Finder#

The Finder class allows discovery of NDI® sources on the network. Any discovered sources are then made available as Source instances.

General Usage#

Open the Finder and wait for it to find sources with Finder.wait_for_sources()

>>> from cyndilib.finder import Finder
>>> finder = Finder()
>>> finder.open()
>>> changed = finder.wait_for_sources(timeout=5)
>>> changed
True

Get the names of any sources found on the network using Finder.get_source_names()

>>> source_names = finder.get_source_names()
>>> source_names
['... (Example Video Source)']

You can also iterate the finder to get its Source objects

>>> [source for source in finder]
[<Source: "... (Example Video Source)">]

Get the first Source object and inspect its host_name and stream_name

>>> source = finder.get_source(source_names[0])
>>> source
<Source: "... (Example Video Source)">
>>> source.host_name
'...'
>>> source.stream_name
'Example Video Source'

Note the host_name for this example shows as '...'. In reality, this will typically be the network hostname of the source device (typically socket.gethostname()).

Always be sure to close the finder instance

>>> finder.close()

Alternatively, it may be used as a context manager

>>> with Finder() as finder:
...     changed = finder.wait_for_sources(timeout=5)
...     [source for source in finder]
[<Source: "... (Example Video Source)">]

Change Callback#

A change_callback can be provided which will be called whenever the discovered sources changes. The callback will be invoked with no arguments

>>> import time

>>> finder = Finder()
>>> def change_callback():
...     print(finder.get_source_names())
>>> finder.set_change_callback(change_callback)

>>> with finder:
...     time.sleep(5)
['... (Example Video Source)']