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
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 (seeref_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 formdevice
. This will post aDEVICE_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 thisDeviceProvider
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 theGST_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 the provider factory names of the
DeviceProvider
instances that are hidden byprovider
.Added in version 1.6.
- get_metadata(key: str) str #
Get metadata with
key
inprovider
.Added in version 1.14.
- Parameters:
key – the key to get
- hide_provider(name: str) None #
Make
provider
hide the devices from the factory withname
.This function is used when
provider
will also provide the devices reported by provider factoryname
. A monitor should stop monitoring the device provider withname
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.
- classmethod register(name: str, rank: int, type: GType) bool #
Create a new device providerfactory capable of instantiating objects of the
type
and 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_ADDED
andGST_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 theGST_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 thatstart()
was called.Added in version 1.4.
- unhide_provider(name: str) None #
Make
provider
unhide the devices from factoryname
.This function is used when
provider
will no longer provide the devices reported by provider factoryname
. A monitor should start monitoring the devices from provider factoryname
in 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_ADDED
andGST_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 theGST_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 thatstart()
was called.Added in version 1.4.