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
Nested ClassesModifier and TypeClassDescriptionstatic classRegistry.Builder<B extends Registry.Builder<B>>Inner class implementing a builder pattern to construct a GObject with properties.static interfaceFunctional interface declaration of theFeatureAddedCallbackcallback.static interfaceFunctional interface declaration of thePluginAddedCallbackcallback.static classNested 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
ConstructorsConstructorDescriptionRegistry()Creates a new Registry.Registry(MemorySegment address) Create a Registry proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionbooleanaddFeature(PluginFeature feature) Add the feature to the registry.booleanAdd the plugin to the registry.protected RegistryasParent()Returns this instance as if it were its parent type.static Registry.Builder<? extends Registry.Builder> builder()ARegistry.Builderobject constructs aRegistrywith the specified properties.booleancheckFeatureVersion(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.voidemitFeatureAdded(@Nullable PluginFeature feature) Emits the "feature-added" signal.voidemitPluginAdded(@Nullable Plugin plugin) Emits the "plugin-added" signal.featureFilter(@Nullable PluginFeatureFilter filter, boolean first) Runs a filter against all features of the plugins in the registry and returns a GList with the results.@Nullable PluginFeaturefindFeature(String name, Type type) Find the pluginfeature with the given name and type in the registry.@Nullable PluginfindPlugin(String name) Find the plugin with the given name in the registry.static booleanBy default GStreamer will perform scanning and rebuilding of the registry file using a helper child process.static voidforkSetEnabled(boolean enabled) Applications might want to disable/enable spawning of a child helper process when rebuilding the registry.static Registryget()Retrieves the singleton plugin registry.getFeatureList(Type type) Retrieves aGListofGstPluginFeatureoftype.getFeatureListByPlugin(String name) Retrieves aGListof features of the plugin with namename.intReturns the registry's feature list cookie.static MemoryLayoutThe memory layout of the native struct.Get a copy of all plugins registered in the given registry.static @Nullable TypegetType()Get the GType of the Registry class@Nullable PluginLook up a plugin in the given registry with the given filename.@Nullable PluginFeaturelookupFeature(String name) Find aGstPluginFeaturewithnameinregistry.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(@Nullable PluginFilter filter, boolean first) Runs a filter against all plugins in the registry and returns aGListwith the results.voidremoveFeature(PluginFeature feature) Remove the feature from the registry.voidremovePlugin(Plugin plugin) Remove the plugin from the registry.booleanScan 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, 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
-
Registry
Create a Registry proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
Registry
public Registry()Creates a new Registry.
-
-
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. -
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:
trueif 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'sreference count will be incremented, and any floating reference will be removed (see gst_object_ref_sink())- Parameters:
feature- the feature to add- Returns:
trueon success.MT safe.
-
addPlugin
Add the plugin to the registry. The plugin-added signal will be emitted.plugin'sreference count will be incremented, and any floating reference will be removed (see gst_object_ref_sink())- Parameters:
plugin- the plugin to add- Returns:
trueon 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:
trueif the feature could be found and the version is the same as the required version or newer, andfalseotherwise.
-
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
GListofGstPluginFeature. 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
nullif 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
nullif the plugin was not found. gst_object_unref() after usage.MT safe.
-
getFeatureList
Retrieves aGListofGstPluginFeatureoftype.- Parameters:
type- aGType.- Returns:
- a
GListofGstPluginFeatureoftype.Use gst_plugin_feature_list_free() after useMT safe.
-
getFeatureListByPlugin
Retrieves aGListof features of the plugin with namename.- Parameters:
name- a plugin name.- Returns:
- a
GListofGstPluginFeature. 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 aGstPluginFeaturewithnameinregistry.- Parameters:
name- aGstPluginFeaturename- Returns:
- a
GstPluginFeaturewith its refcount incremented, use gst_object_unref() after usage.MT safe.
-
pluginFilter
Runs a filter against all plugins in the registry and returns aGListwith 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
GListofGstPlugin. 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:
trueif 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.Builderobject constructs aRegistrywith the specified properties. Use the variousset...()methods to set properties, and finish construction withRegistry.Builder.build().- Returns:
- the builder object
-