Class Registry

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public class Registry extends GstObject

One registry holds the metadata of a set of plugins.

Design:

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.

  • Constructor Details

    • Registry

      public Registry(MemorySegment address)
      Create a Registry instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • Registry

      public Registry()
      Create a new Registry.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the Registry class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected Registry asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class GstObject
      Returns:
      the instance as if it were its 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

      public static Registry 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

      public boolean addFeature(PluginFeature feature)

      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

      public boolean addPlugin(Plugin plugin)

      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

      public 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.
      Parameters:
      featureName - the name of the feature (e.g. "oggdemux")
      minMajor - the minimum major version number
      minMinor - the minimum minor version number
      minMicro - 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, and false otherwise.
    • featureFilter

      public List<PluginFeature> 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. If the first flag is set, only the first match is returned (as a list with a single object).
      Parameters:
      filter - the filter to use
      first - only return first match
      Returns:

      a GList of GstPluginFeature. Use gst_plugin_feature_list_free() after usage.

      MT safe.

    • findFeature

      public @Nullable PluginFeature findFeature(String name, Type type)
      Find the pluginfeature with the given name and type in the registry.
      Parameters:
      name - the pluginfeature name to find
      type - 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

      public @Nullable Plugin findPlugin(String name)
      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

      public List<PluginFeature> getFeatureList(Type type)
      Retrieves a GList of GstPluginFeature of type.
      Parameters:
      type - a GType.
      Returns:

      a GList of GstPluginFeature of type. Use gst_plugin_feature_list_free() after use

      MT safe.

    • getFeatureListByPlugin

      public List<PluginFeature> getFeatureListByPlugin(String name)
      Retrieves a GList of features of the plugin with name name.
      Parameters:
      name - a plugin name.
      Returns:
      a GList of GstPluginFeature. 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

      public List<Plugin> getPluginList()
      Get a copy of all plugins registered in the given registry. The refcount of each element in the list in incremented.
      Returns:

      a GList of GstPlugin. Use gst_plugin_list_free() after usage.

      MT safe.

    • lookup

      public @Nullable Plugin lookup(String filename)
      Look up a plugin in the given registry with the given filename. If found, plugin is reffed.
      Parameters:
      filename - the name of the file to look up
      Returns:
      the GstPlugin if found, or null if not. gst_object_unref() after usage.
    • lookupFeature

      public @Nullable PluginFeature lookupFeature(String name)
      Find a GstPluginFeature with name in registry.
      Parameters:
      name - a GstPluginFeature name
      Returns:

      a GstPluginFeature with its refcount incremented, use gst_object_unref() after usage.

      MT safe.

    • pluginFilter

      public List<Plugin> pluginFilter(@Nullable PluginFilter filter, boolean first)
      Runs a filter against all 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). Every plugin is reffed; use gst_plugin_list_free() after use, which will unref again.
      Parameters:
      filter - the filter to use
      first - only return first match
      Returns:

      a GList of GstPlugin. Use gst_plugin_list_free() after usage.

      MT safe.

    • removeFeature

      public void removeFeature(PluginFeature feature)

      Remove the feature from the registry.

      MT safe.

      Parameters:
      feature - the feature to remove
    • removePlugin

      public void removePlugin(Plugin plugin)

      Remove the plugin from the registry.

      MT safe.

      Parameters:
      plugin - the plugin to remove
    • scanPath

      public boolean scanPath(String path)
      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

      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

      public void emitFeatureAdded(@Nullable PluginFeature feature)
      Emits the "feature-added" signal. See onFeatureAdded(Registry.FeatureAddedCallback).
    • onPluginAdded

      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

      public void emitPluginAdded(@Nullable Plugin plugin)
      Emits the "plugin-added" signal. See onPluginAdded(Registry.PluginAddedCallback).
    • builder

      public static Registry.Builder<? extends Registry.Builder> builder()
      A Registry.Builder object constructs a Registry with the specified properties. Use the various set...() methods to set properties, and finish construction with Registry.Builder.build().
      Returns:
      the builder object