DeviceProvider#
Added in version 1.4.
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
-
- device_add(device: Device) None#
Posts a message on the provider’s
Busto 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 (seeref_sink()).Added in version 1.4.
- Parameters:
device – a
Devicethat has been added
- device_changed(device: Device, changed_device: Device) None#
This function is used when
changed_devicewas modified into its new formdevice. This will post aDEVICE_CHANGEDmessage on the bus to let the application know that the device was modified.Deviceis 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_devicechanged_device – the old version of the device that has been updated
- device_remove(device: Device) None#
Posts a message on the provider’s
Busto inform applications that a device has been removed.This is for use by subclasses.
Added in version 1.4.
- Parameters:
device – a
Devicethat has been removed
- get_bus() Bus#
Gets the
Busof thisDeviceProviderAdded 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
Deviceobjedcts that have been returned by theGST_MESSAGE_DEVICE_ADDEDmessages.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 the provider factory names of the
DeviceProviderinstances that are hidden byprovider.Added in version 1.6.
- get_metadata(key: str) str#
Get metadata with
keyinprovider.Added in version 1.14.
- Parameters:
key – the key to get
- hide_provider(name: str) None#
Make
providerhide the devices from the factory withname.This function is used when
providerwill also provide the devices reported by provider factoryname. A monitor should stop monitoring the device provider withnameto 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
providerwas successfully started.Added in version 1.20.
- classmethod register(name: str, rank: int, type: GType) bool#
Create a new device providerfactory capable of instantiating objects of the
typeand add the factory toplugin.Added in version 1.4.
- Parameters:
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_ADDEDandGST_MESSAGE_DEVICE_REMOVEDmessages to be posted on the provider’s bus when devices are added or removed from the system.Since the
DeviceProvideris 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 theGST_MESSAGE_DEVICE_ADDEDmessages 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
DeviceProviderwill stop providering the devices. This needs to be called the same number of times thatstart()was called.Added in version 1.4.
- unhide_provider(name: str) None#
Make
providerunhide the devices from factoryname.This function is used when
providerwill no longer provide the devices reported by provider factoryname. A monitor should start monitoring the devices from provider factorynamein order to see all devices again.Added in version 1.6.
- Parameters:
name – a provider factory name
Signals#
- class DeviceProvider.signals
The type of the None singleton.
- Parameters:
object
The type of the None singleton.
- Parameters:
object
Virtual Methods#
- class DeviceProvider
- do_start() bool#
Starts providering the devices. This will cause
GST_MESSAGE_DEVICE_ADDEDandGST_MESSAGE_DEVICE_REMOVEDmessages to be posted on the provider’s bus when devices are added or removed from the system.Since the
DeviceProvideris 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 theGST_MESSAGE_DEVICE_ADDEDmessages 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
DeviceProviderwill stop providering the devices. This needs to be called the same number of times thatstart()was called.Added in version 1.4.