DeviceProvider

Added in version 1.4.

class DeviceProvider(**properties: Any)

Superclasses: Object, InitiallyUnowned, Object

A DeviceProvider subclass is provided by a plugin that handles devices if there is a way to programmatically list connected devices. It can also optionally provide updates to the list of connected devices.

Each DeviceProvider subclass is a singleton, a plugin should normally provide a single subclass for all devices.

Applications would normally use a DeviceMonitor to monitor devices from all relevant providers.

Methods

class DeviceProvider
classmethod add_metadata(key: str, value: str) None
Parameters:
  • key

  • value

classmethod add_static_metadata(key: str, value: str) None
Parameters:
  • key

  • value

can_monitor() bool
device_add(device: Device) None

Posts a message on the provider’s Bus to inform applications that a new device has been added.

This is for use by subclasses.

device’s reference count will be incremented, and any floating reference will be removed (see ref_sink()).

Added in version 1.4.

Parameters:

device – a Device that has been added

device_changed(device: Device, changed_device: Device) None

This function is used when changed_device was modified into its new form device. This will post a DEVICE_CHANGED message on the bus to let the application know that the device was modified. Device is immutable for MT. safety purposes so this is an “atomic” way of letting the application know when a device was modified.

Added in version 1.16.

Parameters:
  • device – the new version of changed_device

  • changed_device – the old version of the device that has been updated

device_remove(device: Device) None

Posts a message on the provider’s Bus to inform applications that a device has been removed.

This is for use by subclasses.

Added in version 1.4.

Parameters:

device – a Device that has been removed

get_bus() Bus

Gets the Bus of this DeviceProvider

Added in version 1.4.

get_devices() list[Device]

Gets a list of devices that this provider understands. This may actually probe the hardware if the provider is not currently started.

If the provider has been started, this will returned the same Device objedcts that have been returned by the GST_MESSAGE_DEVICE_ADDED messages.

Added in version 1.4.

get_factory() DeviceProviderFactory | None

Retrieves the factory that was used to create this device provider.

Added in version 1.4.

get_hidden_providers() list[str]

Get the provider factory names of the DeviceProvider instances that are hidden by provider.

Added in version 1.6.

get_metadata(key: str) str

Get metadata with key in provider.

Added in version 1.14.

Parameters:

key – the key to get

hide_provider(name: str) None

Make provider hide the devices from the factory with name.

This function is used when provider will also provide the devices reported by provider factory name. A monitor should stop monitoring the device provider with name to avoid duplicate devices.

Added in version 1.6.

Parameters:

name – a provider factory name

is_started() bool

This function can be used to know if the provider was successfully started.

Added in version 1.20.

register(plugin: Plugin | None, name: str, rank: int, type: type) bool

Create a new device providerfactory capable of instantiating objects of the type and add the factory to plugin.

Added in version 1.4.

Parameters:
  • pluginPlugin to register the device provider with, or None for a static device provider.

  • name – name of device providers of this type

  • rank – rank of device provider (higher rank means more importance when autoplugging)

  • type – GType of device provider to register

classmethod set_metadata(longname: str, classification: str, description: str, author: str) None
Parameters:
  • longname

  • classification

  • description

  • author

classmethod set_static_metadata(longname: str, classification: str, description: str, author: str) None
Parameters:
  • longname

  • classification

  • description

  • author

start() bool

Starts providering the devices. This will cause GST_MESSAGE_DEVICE_ADDED and GST_MESSAGE_DEVICE_REMOVED messages to be posted on the provider’s bus when devices are added or removed from the system.

Since the DeviceProvider is a singleton, start() may already have been called by another user of the object, stop() needs to be called the same number of times.

After this function has been called, get_devices() will return the same objects that have been received from the GST_MESSAGE_DEVICE_ADDED messages and will no longer probe.

Added in version 1.4.

stop() None

Decreases the use-count by one. If the use count reaches zero, this DeviceProvider will stop providering the devices. This needs to be called the same number of times that start() was called.

Added in version 1.4.

unhide_provider(name: str) None

Make provider unhide the devices from factory name.

This function is used when provider will no longer provide the devices reported by provider factory name. A monitor should start monitoring the devices from provider factory name in order to see all devices again.

Added in version 1.6.

Parameters:

name – a provider factory name

Signals

class DeviceProvider.signals
provider_hidden(object: str) None
Parameters:

object

provider_unhidden(object: str) None
Parameters:

object

Virtual Methods

class DeviceProvider
do_start() bool

Starts providering the devices. This will cause GST_MESSAGE_DEVICE_ADDED and GST_MESSAGE_DEVICE_REMOVED messages to be posted on the provider’s bus when devices are added or removed from the system.

Since the DeviceProvider is a singleton, start() may already have been called by another user of the object, stop() needs to be called the same number of times.

After this function has been called, get_devices() will return the same objects that have been received from the GST_MESSAGE_DEVICE_ADDED messages and will no longer probe.

Added in version 1.4.

do_stop() None

Decreases the use-count by one. If the use count reaches zero, this DeviceProvider will stop providering the devices. This needs to be called the same number of times that start() was called.

Added in version 1.4.

Fields

class DeviceProvider
devices

A GList of the Device objects

parent

The parent Object

priv