Package org.freedesktop.gstreamer.gst
Class DeviceMonitor
java.lang.Object
org.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;
}
- Since:
- 1.4
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classDeviceMonitor.Builder<B extends DeviceMonitor.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static classOpaque device monitor class structure.Nested classes/interfaces inherited from class org.freedesktop.gstreamer.gst.GstObject
GstObject.DeepNotifyCallback, GstObject.Object$Impl, GstObject.ObjectClassNested classes/interfaces inherited from class org.gnome.gobject.InitiallyUnowned
InitiallyUnowned.InitiallyUnownedClassNested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback -
Constructor Summary
ConstructorsConstructorDescriptionCreates a new DeviceMonitor.DeviceMonitor(MemorySegment address) Create a DeviceMonitor proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionintAdds a filter for whichGstDevicewill be monitored, any device that matches all these classes and theGstCapswill be returned.protected DeviceMonitorasParent()Returns this instance as if it were its parent type.static DeviceMonitor.Builder<? extends DeviceMonitor.Builder> builder()ADeviceMonitor.Builderobject constructs aDeviceMonitorwith the specified properties.getBus()Gets theGstBusof thisGstDeviceMonitorGets a list of devices from all of the relevant monitors.static MemoryLayoutThe memory layout of the native struct.String[]Get a list of the currently selected device provider factories.booleanGet if this DeviceMonitor is currently showing all devices, even those from hidden providers.static @Nullable TypegetType()Get the GType of the DeviceMonitor classbooleanremoveFilter(int filterId) Removes a filter from theGstDeviceMonitorusing the id that was returned by gst_device_monitor_add_filter().voidsetShowAllDevices(boolean showAll) Set if all devices should be visible, even those devices from hidden providers.booleanstart()Starts monitoring the devices, one this has succeeded, theMessageType.DEVICE_ADDEDandMessageType.DEVICE_REMOVEDmessages will be emitted on the bus when the list of devices changes.voidstop()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, unrefMethods 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, 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, withPropertiesMethods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, cast, getPrivate, readGClass, writeGClassMethods inherited from class org.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()Creates a new DeviceMonitor.
-
-
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 Javasuperkeyword, 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 whichGstDevicewill be monitored, any device that matches all these classes and theGstCapswill 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
GstCapssupported 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
GstDeviceMonitoris started.- Parameters:
classes- device classes to use as filter ornullfor any classcaps- theGstCapsto filter ornullfor ANY- Returns:
- The id of the new filter or 0 if no provider matched the filter's classes.
- Since:
- 1.4
-
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
nullwhen nothing is being monitored. - Since:
- 1.6
-
getShowAllDevices
public boolean getShowAllDevices()Get if this DeviceMonitor is currently showing all devices, even those from hidden providers.- Returns:
truewhen all devices will be shown.- Since:
- 1.6
-
removeFilter
public boolean removeFilter(int filterId) Removes a filter from theGstDeviceMonitorusing the id that was returned by gst_device_monitor_add_filter().- Parameters:
filterId- the id of the filter- Returns:
trueof the filter id was valid,falseotherwise- Since:
- 1.4
-
setShowAllDevices
public void setShowAllDevices(boolean showAll) Set if all devices should be visible, even those devices from hidden providers. SettingshowAllto true might show some devices multiple times.- Parameters:
showAll- show all devices- Since:
- 1.6
-
start
public boolean start()Starts monitoring the devices, one this has succeeded, theMessageType.DEVICE_ADDEDandMessageType.DEVICE_REMOVEDmessages will be emitted on the bus when the list of devices changes.- Returns:
trueif the device monitoring could be started, i.e. at least a single device provider was started successfully.- Since:
- 1.4
-
stop
public void stop()Stops monitoring the devices.- Since:
- 1.4
-
builder
ADeviceMonitor.Builderobject constructs aDeviceMonitorwith the specified properties. Use the variousset...()methods to set properties, and finish construction withDeviceMonitor.Builder.build().- Returns:
- the builder object
-