Class DeviceProvider
- All Implemented Interfaces:
Proxy
- Direct Known Subclasses:
DeviceProvider.DeviceProviderImpl
GstDeviceProvider
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 GstDeviceProvider
subclass is a singleton, a plugin should
normally provide a single subclass for all devices.
Applications would normally use a GstDeviceMonitor
to monitor devices
from all relevant providers.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
DeviceProvider.Builder<B extends DeviceProvider.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static class
The structure of the baseGstDeviceProviderClass
static class
The DeviceProviderImpl type represents a native instance of the abstract DeviceProvider class.static interface
Functional interface declaration of theProviderHiddenCallback
callback.static interface
Functional interface declaration of theProviderUnhiddenCallback
callback.Nested classes/interfaces inherited from class org.freedesktop.gstreamer.gst.GstObject
GstObject.DeepNotifyCallback, GstObject.ObjectClass, GstObject.ObjectImpl
Nested classes/interfaces inherited from class org.gnome.gobject.InitiallyUnowned
InitiallyUnowned.InitiallyUnownedClass
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback
-
Constructor Summary
ConstructorDescriptionDeviceProvider
(MemorySegment address) Create a DeviceProvider proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected DeviceProvider
asParent()
Returns this instance as if it were its parent type.static DeviceProvider.Builder
<? extends DeviceProvider.Builder> builder()
ADeviceProvider.Builder
object constructs aDeviceProvider
with the specified properties.boolean
void
Posts a message on the provider'sGstBus
to inform applications that a new device has been added.void
deviceChanged
(Device device, Device changedDevice) This function is used whenchangedDevice
was modified into its new formdevice
.void
deviceRemove
(Device device) Posts a message on the provider'sGstBus
to inform applications that a device has been removed.void
emitProviderHidden
(String object) void
emitProviderUnhidden
(String object) getBus()
Gets theGstBus
of thisGstDeviceProvider
Gets a list of devices that this provider understands.Retrieves the factory that was used to create this device provider.String[]
Get the provider factory names of theGstDeviceProvider
instances that are hidden by this DeviceProvider.static MemoryLayout
The memory layout of the native struct.getMetadata
(String key) Get metadata withkey
in this DeviceProvider.static Type
getType()
Get the GType of the DeviceProvider classvoid
hideProvider
(String name) Make this DeviceProvider hide the devices from the factory withname
.boolean
This function can be used to know if the this DeviceProvider was successfully started.protected List
<MemorySegment> probe()
Returns a list of devices that are currently available.static boolean
Create a new device providerfactory capable of instantiating objects of thetype
and add the factory toplugin
.boolean
start()
Starts providering the devices.void
stop()
Decreases the use-count by one.void
unhideProvider
(String name) Make this DeviceProvider unhide the devices from factoryname
.Methods inherited from class org.freedesktop.gstreamer.gst.GstObject
addControlBinding, checkUniqueness, deepNotify, defaultDeepNotify, defaultError, emitDeepNotify, getControlBinding, getControlRate, getGValueArray, getName, getParent, getPathString, getValue, getValueArray, hasActiveControlBindings, hasAncestor, hasAsAncestor, hasAsParent, onDeepNotify, ref, refSink, removeControlBinding, replace, setControlBindingDisabled, setControlBindingsDisabled, setControlRate, setName, setParent, suggestNextSync, syncValues, unparent, unref
Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
DeviceProvider
Create a DeviceProvider proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
-
Method Details
-
getType
-
getMemoryLayout
The memory layout of the native struct.- Returns:
- the memory layout
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
register
Create a new device providerfactory capable of instantiating objects of thetype
and add the factory toplugin
.- Parameters:
plugin
-GstPlugin
to register the device provider with, ornull
for a static device provider.name
- name of device providers of this typerank
- rank of device provider (higher rank means more importance when autoplugging)type
- GType of device provider to register- Returns:
true
, if the registering succeeded,false
on error
-
canMonitor
public boolean canMonitor() -
deviceAdd
Posts a message on the provider'sGstBus
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 gst_object_ref_sink()).- Parameters:
device
- aGstDevice
that has been added
-
deviceChanged
This function is used whenchangedDevice
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.GstDevice
is immutable for MT. safety purposes so this is an "atomic" way of letting the application know when a device was modified.- Parameters:
device
- the new version ofchangedDevice
changedDevice
- the old version of the device that has been updated
-
deviceRemove
Posts a message on the provider'sGstBus
to inform applications that a device has been removed.This is for use by subclasses.
- Parameters:
device
- aGstDevice
that has been removed
-
getBus
-
getDevices
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
GstDevice
objedcts that have been returned by theGST_MESSAGE_DEVICE_ADDED
messages.- Returns:
- a
GList
ofGstDevice
-
getFactory
Retrieves the factory that was used to create this device provider.- Returns:
- the
GstDeviceProviderFactory
used for creating this device provider. no refcounting is needed.
-
getHiddenProviders
Get the provider factory names of theGstDeviceProvider
instances that are hidden by this DeviceProvider.- Returns:
- a list of hidden providers factory names or
null
when nothing is hidden by this DeviceProvider. Free with g_strfreev.
-
getMetadata
-
hideProvider
Make this DeviceProvider hide the devices from the factory withname
.This function is used when this DeviceProvider will also provide the devices reported by provider factory
name
. A monitor should stop monitoring the device provider withname
to avoid duplicate devices.- Parameters:
name
- a provider factory name
-
isStarted
public boolean isStarted()This function can be used to know if the this DeviceProvider was successfully started. -
start
public boolean start()Starts providering the devices. This will causeGST_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
GstDeviceProvider
is a singleton, gst_device_provider_start() may already have been called by another user of the object, gst_device_provider_stop() needs to be called the same number of times.After this function has been called, gst_device_provider_get_devices() will return the same objects that have been received from the
GST_MESSAGE_DEVICE_ADDED
messages and will no longer probe.- Returns:
true
if the device providering could be started
-
stop
public void stop()Decreases the use-count by one. If the use count reaches zero, thisGstDeviceProvider
will stop providering the devices. This needs to be called the same number of times that gst_device_provider_start() was called. -
unhideProvider
Make this DeviceProvider unhide the devices from factoryname
.This function is used when this DeviceProvider will no longer provide the devices reported by provider factory
name
. A monitor should start monitoring the devices from provider factoryname
in order to see all devices again.- Parameters:
name
- a provider factory name
-
probe
Returns a list of devices that are currently available. This should never block. The devices should not have a parent and should be floating. -
onProviderHidden
public SignalConnection<DeviceProvider.ProviderHiddenCallback> onProviderHidden(DeviceProvider.ProviderHiddenCallback handler) - See Also:
-
emitProviderHidden
-
builder
ADeviceProvider.Builder
object constructs aDeviceProvider
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withDeviceProvider.Builder.build()
.
-