discovery module¶
-
class
vidhubcontrol.discovery.
BMDDiscovery
(mainloop, service_type='_blackmagic._tcp.local.')[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.
Listener
(mainloop, service_type)[source]¶ Bases:
pydispatch.dispatch.Dispatcher
An async zeroconf service listener
Allows async communication with
zeroconf.Zeroconf
throughasyncio.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 usingServiceInfo.id
as keysType: 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()
asServiceInfo
instances.Type: dict
-
coroutine
add_message
(msg)[source]¶ Adds a message to the
message_queue
Parameters: msg ( Message
) – Message to send
-
coroutine
publish_service
(type_, port, name=None, addresses=None, properties=None, ttl=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 byget_local_hostname()
- addresses (optional) – If provided, an
iterable
of IP addresses to publish. Can beipaddress.IPv4Address
or any type that can be parsed byipaddress.ip_address()
- properties (dict, optional) – Custom properties for the service
- ttl (int, optional) – The TTL value to publish.
Defaults to
PUBLISH_TTL
-
coroutine
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 ofMessage
.When the loop exits, the
zeroconf.Zeroconf
instance will be closed.
-
run_zeroconf
()[source]¶ Starts
zeroconf.Zeroconf
andzeroconf.ServiceBrowser
instancesThis is meant to be called inside of an
concurrent.futures.Executor
and not used directly.
-
coroutine
start
()[source]¶ Starts the service listener
Runs
zeroconf.Zeroconf
in anExecutor
instance through asyncio.AbstractEventLoop.run_in_executor (seerun_zeroconf()
).
-
stop_zeroconf
()[source]¶ Closes the
zeroconf.Zeroconf
instanceThis is meant to be called inside of an
concurrent.futures.Executor
and not used directly.
-
coroutine
unpublish_service
(type_, port, name=None, addresses=None, properties=None)[source]¶ Removes a service published through
publish_service()
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 byget_local_hostname()
- addresses (optional) – If provided, an
iterable
of IP addresses to unpublish. Can beipaddress.IPv4Address
or any type that can be parsed byipaddress.ip_address()
- properties (dict, optional) – Custom properties for the service
- mainloop (
-
class
vidhubcontrol.discovery.
Message
(info)[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.
ServiceInfo
(**kwargs)[source]¶ Bases:
pydispatch.dispatch.Dispatcher
Container for Zeroconf service information
Closely related to
zeroconf.ServiceInfo
-
address
¶ The service ip address
Type: ipaddress.IPv4Address
-
classmethod
from_zc_info
(info)[source]¶ Creates an instance from a
zeroconf.ServiceInfo
objectParameters: info ( zeroconf.ServiceInfo
) –Returns: An instance of ServiceInfo
-
update
(other)[source]¶ Updates the
properties
from anotherServiceInfo
instance
-