vidhubcontrol.discovery

class vidhubcontrol.discovery.AddedMessage(info: vidhubcontrol.discovery.ServiceInfo)[source]

Bases: vidhubcontrol.discovery.BrowserMessage

class vidhubcontrol.discovery.BMDDiscovery(*args, **kwargs)[source]

Bases: vidhubcontrol.discovery.Listener

Zeroconf listener for Blackmagic devices

vidhubs

Contains discovered Videohub devices. This DictProperty can be used to subscribe to changes.

Type

dict

smart_views

Contains discovered SmartView devices. This DictProperty can be used to subscribe to changes.

Type

dict

smart_scopes

Contains discovered SmartScope devices. This DictProperty can be used to subscribe to changes.

Type

dict

class vidhubcontrol.discovery.BrowserMessage(info: vidhubcontrol.discovery.ServiceInfo)[source]

Bases: vidhubcontrol.discovery.Message

class vidhubcontrol.discovery.Listener(*args, **kwargs)[source]

Bases: pydispatch.dispatch.Dispatcher

An async zeroconf service listener

Allows async communication with zeroconf.Zeroconf through asyncio.AbstractEventLoop.run_in_executor() calls.

Parameters
  • mainloop (asyncio.BaseEventLoop) – asyncio event loop instance

  • service_type (str) – The fully qualified service type name to subscribe to

services

All services currently discovered as instances of ServiceInfo. Stored using ServiceInfo.id as keys

Type

dict

message_queue

Used to communicate actions and events with instances of Message

Type

asyncio.Queue

published_services

Stores services that have been published using publish_service() as ServiceInfo instances.

Type

dict

async add_message(msg: vidhubcontrol.discovery.Message)[source]

Adds a message to the message_queue

Parameters

msg (Message) – Message to send

async publish_service(type_: str, port: int, name: Optional[str] = None, addresses: Optional[Union[str, bytes, ipaddress.IPv4Address]] = None, properties: Optional[Dict] = None, ttl: Optional[int] = 60)[source]

Publishes a service on the network

Parameters
  • type (str) – Fully qualified service type

  • port (int) – The service port

  • name (str, optional) – Fully qualified service name. If not provided, this will be generated from the type_ and the hostname detected by get_local_hostname()

  • addresses (optional) – If provided, an iterable of IP addresses to publish. Can be ipaddress.IPv4Address or any type that can be parsed by ipaddress.ip_address()

  • properties (dict, optional) – Custom properties for the service

  • ttl (int, optional) – The TTL value to publish. Defaults to PUBLISH_TTL

async republish_service(type_: str, port: int, name: Optional[str] = None, addresses: Optional[Union[str, bytes, ipaddress.IPv4Address]] = None, properties: Optional[Dict] = None, ttl: Optional[int] = 60)[source]

Update an existing ServiceInfo and republish it

async run()[source]

Main loop for communicating with zeroconf.Zeroconf

Waits for messages on the message_queue and processes them. The loop will exit if an object placed on the queue is not an instance of Message.

run_zeroconf()[source]

Starts zeroconf.Zeroconf and zeroconf.ServiceBrowser instances

async start()[source]

Starts the service listener

async stop()[source]

Stops the service listener

async stop_zeroconf()[source]

Closes the zeroconf.Zeroconf instance

async unpublish_service(type_: str, name: Optional[str] = None)[source]

Removes a service published through publish_service()

Parameters
  • type (str) – Fully qualified service type

  • name (str, optional) – Fully qualified service name. If not provided, this will be generated from the type_ and the hostname detected by get_local_hostname()

class vidhubcontrol.discovery.Message(info: vidhubcontrol.discovery.ServiceInfo)[source]

Bases: object

A message to communicate actions to and from Listener

info

The ServiceInfo related to the message

Note

This class and its subclasses are not meant to be used directly. They are used internally in Listener methods.

class vidhubcontrol.discovery.PublishMessage(info: vidhubcontrol.discovery.ServiceInfo)[source]

Bases: vidhubcontrol.discovery.RegistrationMessage

class vidhubcontrol.discovery.RegistrationMessage(info: vidhubcontrol.discovery.ServiceInfo)[source]

Bases: vidhubcontrol.discovery.Message

class vidhubcontrol.discovery.RemovedMessage(info: vidhubcontrol.discovery.ServiceInfo)[source]

Bases: vidhubcontrol.discovery.BrowserMessage

class vidhubcontrol.discovery.RepublishMessage(info: vidhubcontrol.discovery.ServiceInfo)[source]

Bases: vidhubcontrol.discovery.RegistrationMessage

class vidhubcontrol.discovery.ServiceInfo(*args, **kwargs)[source]

Bases: pydispatch.dispatch.Dispatcher

Container for Zeroconf service information

Closely related to zeroconf.ServiceInfo

type

Fully qualified service type

Type

str

name

Fully qualified service name

Type

str

server

Fully qualified name for service host (defaults to name)

Type

str

addresses

The service ip address

port

The service port

Type

int

properties

Custom properties for the service

Type

dict

property address: Optional[ipaddress.IPv4Address]

The first element of addresses

classmethod from_zc_info(info: zeroconf.ServiceInfo)vidhubcontrol.discovery.ServiceInfo[source]

Creates an instance from a zeroconf.ServiceInfo object

Parameters

info (zeroconf.ServiceInfo) –

Returns

An instance of ServiceInfo

property id: Tuple[str, str]

Unique id for the service as a tuple of (type, name)

to_zc_info()zeroconf.ServiceInfo[source]

Creates a copy as an instance of zeroconf.ServiceInfo

update(other: vidhubcontrol.discovery.ServiceInfo)[source]

Updates the properties from another ServiceInfo instance

class vidhubcontrol.discovery.UnPublishMessage(info: vidhubcontrol.discovery.ServiceInfo)[source]

Bases: vidhubcontrol.discovery.RegistrationMessage

class vidhubcontrol.discovery.UpdateMessage(info: vidhubcontrol.discovery.ServiceInfo)[source]

Bases: vidhubcontrol.discovery.BrowserMessage