cyndilib.router#

Module implementing the NDI Routing API.

New in version 0.1.1.

Router#

class cyndilib.router.Router#

Bases: object

Class representing an NDI® router instance

With NDI® routing, you can create virtual outputs on the network which ‘look’ like normal sources, but are actually just routing to other sources on the network.

Parameters:
  • name (str) – The name of the router instance. This is the name that will appear on the network.

  • groups (str, optional) – The groups that this router instance belongs to. This is a comma-separated list of group names. Defaults to “”.

New in version 0.1.1.

name#

The name of the router instance. This is the name that will appear on the network.

Type:

str, readonly

groups#

The groups that this router instance belongs to. This is a comma-separated list of group names.

Type:

str, readonly

source#

The current source that this router is routing from. This will be None if there is no source currently connected.

Type:

Source, readonly

dest#

The current destination that this router is routing to. This will be None if there is no destination currently connected.

Type:

Source, readonly

close(self)#

Close the routing instance

dest_host_name#

The current host_name of the dest

This will be None if there is no dest currently connected.

dest_stream_name#

The current stream_name of the dest

This will be None if there is no dest currently connected.

get_num_connections(self)#

Get the current number of receivers connected to this router

is_active#

Whether the routing instance is currently active (i.e. has a valid source connected and is open)

is_open#

Whether the routing instance is currently open

open(self)#

Open the routing instance

routing_change(self, source: Source)#

Change the routing to the specified source

Raises:

RuntimeError – If the router is not open.

routing_clear(self)#

Clear the current routing

Raises:

RuntimeError – If the router is not open.

source_host_name#

The current host_name of the source

This will be None if there is no source currently connected.

source_stream_name#

The current stream_name of the source

This will be None if there is no source currently connected.

RoutingMatrix#

class cyndilib.router.RoutingMatrix#

Bases: object

Class representing a routing matrix, which manages multiple Router instances and their routing definitions.

This class also manages its own Finder instance to discover available sources on the network.

New in version 0.1.1.

finder#

The Finder instance used to discover sources on the network.

Type:

Finder, readonly

add_router(self, router: Router)#

Add the given router to the routing matrix

Raises:

KeyError – If a router with the same name as the given router already exists in the routing matrix

add_router_by_name(self, name: str, groups: str = '')#

Add a router with the given name to the routing matrix

Raises:

KeyError – If a router with the given name already exists in the routing matrix

clear_route(self, dest_name: str)#

Clear the route for the router with the given name

Note

This will not remove the router from the routing matrix, it will just clear its current routing to any source.

Raises:

KeyError – If a router with the given name does not exist in the routing matrix

close(self)#

Close the routing matrix and all contained routers

get_router_by_name(self, name: str)#

Get a router with the given name from the routing matrix

Raises:

KeyError – If a router with the given name does not exist in the routing matrix

get_routing_table(self)#

Get the current routing table as a dictionary mapping router names to source names

The returned dictionary is formatted as {router_name: source_name, ...} and is a copy of the internal routing table, so modifying it will not affect the routing matrix.

For routers that do not have a source currently connected, the source name will be None.

is_open#

Whether the routing matrix is currently open

make_route(self, dest_name: str, source_name: str)#

Make a route from the source with the given name to the router with the given name

If a router with the given destination name does not already exist, it will be created.

open(self)#

Open the routing matrix and all contained routers

remove_router(self, router: Router)#

Remove the given router from the routing matrix

Raises:

KeyError – If the given router does not exist in the routing matrix

remove_router_by_name(self, name: str)#

Remove a router with the given name from the routing matrix

Raises:

KeyError – If a router with the given name does not exist in the routing matrix

router_exists(self, name: str)#

Check if a router with the given name exists in the routing matrix

set_finder_callback(self, cb)#

Set a callback function to be called whenever the finder’s change_callback is triggered

set_routing_table(self, routing_table: dict)#

Set the routing table from a dictionary mapping router names to source names

The routing_table argument should be formatted as {router_name: source_name, ...}.

For routers that do not have a source currently connected, the source name should be None.