Class Registry
- All Implemented Interfaces:
Proxy
<emphasis role="bold">Design:</emphasis>
The GstRegistry
object is a list of plugins and some functions for dealing
with them. Each GstPlugin
is matched 1-1 with a file on disk, and may or may
not be loaded at a given time.
The primary source, at all times, of plugin information is each plugin file itself. Thus, if an application wants information about a particular plugin, or wants to search for a feature that satisfies given criteria, the primary means of doing so is to load every plugin and look at the resulting information that is gathered in the default registry. Clearly, this is a time consuming process, so we cache information in the registry file. The format and location of the cache file is internal to gstreamer.
On startup, plugins are searched for in the plugin search path. The following locations are checked in this order:
- location from --gst-plugin-path commandline option.
- the GST_PLUGIN_PATH environment variable.
- the GST_PLUGIN_SYSTEM_PATH environment variable.
- default locations (if GST_PLUGIN_SYSTEM_PATH is not set).
Those default locations are:
$XDG_DATA_HOME/gstreamer-$GST_API_VERSION/plugins/
and$prefix/libs/gstreamer-$GST_API_VERSION/
. $XDG_DATA_HOME defaults to$HOME/.local/share
.
The registry cache file is loaded from
$XDG_CACHE_HOME/gstreamer-$GST_API_VERSION/registry-$ARCH.bin
(where $XDG_CACHE_HOME defaults to $HOME/.cache
) or the file listed in the GST_REGISTRY
env var. One reason to change the registry location is for testing.
For each plugin that is found in the plugin search path, there could be 3 possibilities for cached information:
- the cache may not contain information about a given file.
- the cache may have stale information.
- the cache may have current information.
In the first two cases, the plugin is loaded and the cache updated. In addition to these cases, the cache may have entries for plugins that are not relevant to the current process. These are marked as not available to the current process. If the cache is updated for whatever reason, it is marked dirty.
A dirty cache is written out at the end of initialization. Each entry is checked to make sure the information is minimally valid. If not, the entry is simply dropped.
Implementation notes:
The "cache" and "registry" are different concepts and can represent
different sets of plugins. For various reasons, at init time, the cache is
stored in the default registry, and plugins not relevant to the current
process are marked with the PluginFlags.CACHED
bit. These plugins are
removed at the end of initialization.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Registry.Builder<B extends Registry.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static interface
Functional interface declaration of theFeatureAddedCallback
callback.static interface
Functional interface declaration of thePluginAddedCallback
callback.static class
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
ConstructorDescriptionRegistry
(MemorySegment address) Create a Registry proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionboolean
addFeature
(PluginFeature feature) Add the feature to the registry.boolean
Add the plugin to the registry.protected Registry
asParent()
Returns this instance as if it were its parent type.static Registry.Builder
<? extends Registry.Builder> builder()
ARegistry.Builder
object constructs aRegistry
with the specified properties.boolean
checkFeatureVersion
(String featureName, int minMajor, int minMinor, int minMicro) Checks whether a plugin feature by the given name exists in this Registry and whether its version is at least the version required.void
emitFeatureAdded
(PluginFeature feature) Emits the "feature-added" signal.void
emitPluginAdded
(Plugin plugin) Emits the "plugin-added" signal.featureFilter
(PluginFeatureFilter filter, boolean first) Runs a filter against all features of the plugins in the registry and returns a GList with the results.findFeature
(String name, Type type) Find the pluginfeature with the given name and type in the registry.findPlugin
(String name) Find the plugin with the given name in the registry.static boolean
By default GStreamer will perform scanning and rebuilding of the registry file using a helper child process.static void
forkSetEnabled
(boolean enabled) Applications might want to disable/enable spawning of a child helper process when rebuilding the registry.static Registry
get()
Retrieves the singleton plugin registry.getFeatureList
(Type type) Retrieves aGList
ofGstPluginFeature
oftype
.getFeatureListByPlugin
(String name) Retrieves aGList
of features of the plugin with namename
.int
Returns the registry's feature list cookie.static MemoryLayout
The memory layout of the native struct.Get a copy of all plugins registered in the given registry.static Type
getType()
Get the GType of the Registry classLook up a plugin in the given registry with the given filename.lookupFeature
(String name) Find aGstPluginFeature
withname
in this Registry.Signals that a feature has been added to the registry (possibly replacing a previously-added one by the same name)Signals that a plugin has been added to the registry (possibly replacing a previously-added one by the same name)pluginFilter
(PluginFilter filter, boolean first) Runs a filter against all plugins in the registry and returns aGList
with the results.void
removeFeature
(PluginFeature feature) Remove the feature from the registry.void
removePlugin
(Plugin plugin) Remove the plugin from the registry.boolean
Scan the given path for plugins to add to the registry.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
-
Registry
Create a Registry 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. -
forkIsEnabled
public static boolean forkIsEnabled()By default GStreamer will perform scanning and rebuilding of the registry file using a helper child process.Applications might want to disable this behaviour with the gst_registry_fork_set_enabled() function, in which case new plugins are scanned (and loaded) into the application process.
- Returns:
true
if GStreamer will use the child helper process when rebuilding the registry.
-
forkSetEnabled
public static void forkSetEnabled(boolean enabled) Applications might want to disable/enable spawning of a child helper process when rebuilding the registry. See gst_registry_fork_is_enabled() for more information.- Parameters:
enabled
- whether rebuilding the registry can use a temporary child helper process.
-
get
Retrieves the singleton plugin registry. The caller does not own a reference on the registry, as it is alive as long as GStreamer is initialized.- Returns:
- the
GstRegistry
.
-
addFeature
Add the feature to the registry. The feature-added signal will be emitted.feature
's reference count will be incremented, and any floating reference will be removed (see gst_object_ref_sink())- Parameters:
feature
- the feature to add- Returns:
true
on success.MT safe.
-
addPlugin
Add the plugin to the registry. The plugin-added signal will be emitted.plugin
's reference count will be incremented, and any floating reference will be removed (see gst_object_ref_sink())- Parameters:
plugin
- the plugin to add- Returns:
true
on success.MT safe.
-
checkFeatureVersion
Checks whether a plugin feature by the given name exists in this Registry and whether its version is at least the version required.- Parameters:
featureName
- the name of the feature (e.g. "oggdemux")minMajor
- the minimum major version numberminMinor
- the minimum minor version numberminMicro
- the minimum micro version number- Returns:
true
if the feature could be found and the version is the same as the required version or newer, andfalse
otherwise.
-
featureFilter
Runs a filter against all features of the plugins in the registry and returns a GList with the results. If the first flag is set, only the first match is returned (as a list with a single object).- Parameters:
filter
- the filter to usefirst
- only return first match- Returns:
- a
GList
ofGstPluginFeature
. Use gst_plugin_feature_list_free() after usage.MT safe.
-
findFeature
Find the pluginfeature with the given name and type in the registry.- Parameters:
name
- the pluginfeature name to findtype
- the pluginfeature type to find- Returns:
- the pluginfeature with the
given name and type or
null
if the plugin was not found. gst_object_unref() after usage.MT safe.
-
findPlugin
Find the plugin with the given name in the registry. The plugin will be reffed; caller is responsible for unreffing.- Parameters:
name
- the plugin name to find- Returns:
- the plugin with the given name
or
null
if the plugin was not found. gst_object_unref() after usage.MT safe.
-
getFeatureList
Retrieves aGList
ofGstPluginFeature
oftype
.- Parameters:
type
- aGType
.- Returns:
- a
GList
ofGstPluginFeature
oftype
. Use gst_plugin_feature_list_free() after useMT safe.
-
getFeatureListByPlugin
Retrieves aGList
of features of the plugin with namename
.- Parameters:
name
- a plugin name.- Returns:
- a
GList
ofGstPluginFeature
. Use gst_plugin_feature_list_free() after usage.
-
getFeatureListCookie
public int getFeatureListCookie()Returns the registry's feature list cookie. This changes every time a feature is added or removed from the registry.- Returns:
- the feature list cookie.
-
getPluginList
-
lookup
-
lookupFeature
Find aGstPluginFeature
withname
in this Registry.- Parameters:
name
- aGstPluginFeature
name- Returns:
- a
GstPluginFeature
with its refcount incremented, use gst_object_unref() after usage.MT safe.
-
pluginFilter
Runs a filter against all plugins in the registry and returns aGList
with the results. If the first flag is set, only the first match is returned (as a list with a single object). Every plugin is reffed; use gst_plugin_list_free() after use, which will unref again.- Parameters:
filter
- the filter to usefirst
- only return first match- Returns:
- a
GList
ofGstPlugin
. Use gst_plugin_list_free() after usage.MT safe.
-
removeFeature
Remove the feature from the registry.MT safe.
- Parameters:
feature
- the feature to remove
-
removePlugin
Remove the plugin from the registry.MT safe.
- Parameters:
plugin
- the plugin to remove
-
scanPath
Scan the given path for plugins to add to the registry. The syntax of the path is specific to the registry.- Parameters:
path
- the path to scan- Returns:
true
if registry changed
-
onFeatureAdded
public SignalConnection<Registry.FeatureAddedCallback> onFeatureAdded(Registry.FeatureAddedCallback handler) Signals that a feature has been added to the registry (possibly replacing a previously-added one by the same name)- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitFeatureAdded
Emits the "feature-added" signal. SeeonFeatureAdded(org.freedesktop.gstreamer.gst.Registry.FeatureAddedCallback)
. -
onPluginAdded
public SignalConnection<Registry.PluginAddedCallback> onPluginAdded(Registry.PluginAddedCallback handler) Signals that a plugin has been added to the registry (possibly replacing a previously-added one by the same name)- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitPluginAdded
Emits the "plugin-added" signal. SeeonPluginAdded(org.freedesktop.gstreamer.gst.Registry.PluginAddedCallback)
. -
builder
ARegistry.Builder
object constructs aRegistry
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withRegistry.Builder.build()
.
-