Package org.freedesktop.gstreamer.gst
Class DeviceMonitor
java.lang.Object
io.github.jwharm.javagi.base.ProxyInstance
org.gnome.gobject.TypeInstance
org.gnome.gobject.GObject
org.gnome.gobject.InitiallyUnowned
org.freedesktop.gstreamer.gst.GstObject
org.freedesktop.gstreamer.gst.DeviceMonitor
- All Implemented Interfaces:
Proxy
Applications should create a
GstDeviceMonitor
when they want
to probe, list and monitor devices of a specific type. The
GstDeviceMonitor
will create the appropriate
GstDeviceProvider
objects and manage them. It will then post
messages on its GstBus
for devices that have been added and
removed.
The device monitor will monitor all devices matching the filters that the application has set.
The basic use pattern of a device monitor is as follows:
static gboolean
my_bus_func (GstBus * bus, GstMessage * message, gpointer user_data)
{
GstDevice *device;
gchar *name;
switch (GST_MESSAGE_TYPE (message)) {
case GST_MESSAGE_DEVICE_ADDED:
gst_message_parse_device_added (message, &device);
name = gst_device_get_display_name (device);
g_print("Device added: %s\\n", name);
g_free (name);
gst_object_unref (device);
break;
case GST_MESSAGE_DEVICE_REMOVED:
gst_message_parse_device_removed (message, &device);
name = gst_device_get_display_name (device);
g_print("Device removed: %s\\n", name);
g_free (name);
gst_object_unref (device);
break;
default:
break;
}
return G_SOURCE_CONTINUE;
}
GstDeviceMonitor *
setup_raw_video_source_device_monitor (void) {
GstDeviceMonitor *monitor;
GstBus *bus;
GstCaps *caps;
monitor = gst_device_monitor_new ();
bus = gst_device_monitor_get_bus (monitor);
gst_bus_add_watch (bus, my_bus_func, NULL);
gst_object_unref (bus);
caps = gst_caps_new_empty_simple ("video/x-raw");
gst_device_monitor_add_filter (monitor, "Video/Source", caps);
gst_caps_unref (caps);
gst_device_monitor_start (monitor);
return monitor;
}
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
DeviceMonitor.Builder<B extends DeviceMonitor.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static class
Opaque device monitor class structure.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
ConstructorDescriptionCreate a newGstDeviceMonitor
DeviceMonitor
(MemorySegment address) Create a DeviceMonitor proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionint
Adds a filter for whichGstDevice
will be monitored, any device that matches all these classes and theGstCaps
will be returned.protected DeviceMonitor
asParent()
Returns this instance as if it were its parent type.static DeviceMonitor.Builder
<? extends DeviceMonitor.Builder> builder()
ADeviceMonitor.Builder
object constructs aDeviceMonitor
with the specified properties.getBus()
Gets theGstBus
of thisGstDeviceMonitor
Gets a list of devices from all of the relevant monitors.static MemoryLayout
The memory layout of the native struct.String[]
Get a list of the currently selected device provider factories.boolean
Get if this DeviceMonitor is currently showing all devices, even those from hidden providers.static Type
getType()
Get the GType of the DeviceMonitor classboolean
removeFilter
(int filterId) Removes a filter from theGstDeviceMonitor
using the id that was returned by gst_device_monitor_add_filter().void
setShowAllDevices
(boolean showAll) Set if all devices should be visible, even those devices from hidden providers.boolean
start()
Starts monitoring the devices, one this has succeeded, theMessageType.DEVICE_ADDED
andMessageType.DEVICE_REMOVED
messages will be emitted on the bus when the list of devices changes.void
stop()
Stops monitoring the devices.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
-
DeviceMonitor
Create a DeviceMonitor proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
DeviceMonitor
public DeviceMonitor()Create a newGstDeviceMonitor
-
-
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. -
addFilter
Adds a filter for whichGstDevice
will be monitored, any device that matches all these classes and theGstCaps
will be returned.If this function is called multiple times to add more filters, each will be matched independently. That is, adding more filters will not further restrict what devices are matched.
The
GstCaps
supported by the device as returned by gst_device_get_caps() are not intersected with caps filters added using this function.Filters must be added before the
GstDeviceMonitor
is started.- Parameters:
classes
- device classes to use as filter ornull
for any classcaps
- theGstCaps
to filter ornull
for ANY- Returns:
- The id of the new filter or 0 if no provider matched the filter's classes.
-
getBus
-
getDevices
-
getProviders
Get a list of the currently selected device provider factories.This
- Returns:
- A list of device provider factory names that are currently being
monitored by this DeviceMonitor or
null
when nothing is being monitored.
-
getShowAllDevices
public boolean getShowAllDevices()Get if this DeviceMonitor is currently showing all devices, even those from hidden providers.- Returns:
true
when all devices will be shown.
-
removeFilter
public boolean removeFilter(int filterId) Removes a filter from theGstDeviceMonitor
using the id that was returned by gst_device_monitor_add_filter().- Parameters:
filterId
- the id of the filter- Returns:
true
of the filter id was valid,false
otherwise
-
setShowAllDevices
public void setShowAllDevices(boolean showAll) Set if all devices should be visible, even those devices from hidden providers. SettingshowAll
to true might show some devices multiple times.- Parameters:
showAll
- show all devices
-
start
public boolean start()Starts monitoring the devices, one this has succeeded, theMessageType.DEVICE_ADDED
andMessageType.DEVICE_REMOVED
messages will be emitted on the bus when the list of devices changes.- Returns:
true
if the device monitoring could be started, i.e. at least a single device provider was started successfully.
-
stop
public void stop()Stops monitoring the devices. -
builder
ADeviceMonitor.Builder
object constructs aDeviceMonitor
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withDeviceMonitor.Builder.build()
.
-