Plugin

class Plugin(**properties: Any)

Superclasses: Object, InitiallyUnowned, Object

GStreamer is extensible, so Element instances can be loaded at runtime. A plugin system can provide one or more of the basic GStreamer PluginFeature subclasses.

A plugin should export a symbol gst_plugin_desc that is a struct of type GstPluginDesc. the plugin loader will check the version of the core library the plugin was linked against and will create a new Plugin. It will then call the PluginInitFunc function that was provided in the gst_plugin_desc.

Once you have a handle to a Plugin (e.g. from the Registry), you can add any object that subclasses PluginFeature.

Usually plugins are always automatically loaded so you don’t need to call load() explicitly to bring it into memory. There are options to statically link plugins to an app or even use GStreamer without a plugin repository in which case load() can be needed to bring the plugin into memory.

Methods

class Plugin
add_dependency(env_vars: Sequence[str] | None, paths: Sequence[str] | None, names: Sequence[str] | None, flags: PluginDependencyFlags) None

Make GStreamer aware of external dependencies which affect the feature set of this plugin (ie. the elements or typefinders associated with it).

GStreamer will re-inspect plugins with external dependencies whenever any of the external dependencies change. This is useful for plugins which wrap other plugin systems, e.g. a plugin which wraps a plugin-based visualisation library and makes visualisations available as GStreamer elements, or a codec loader which exposes elements and/or caps dependent on what external codec libraries are currently installed.

Parameters:
  • env_vars

    None-terminated array of environment variables affecting the feature set of the plugin (e.g. an environment variable containing paths where to look for additional modules/plugins of a library), or None. Environment variable names may be followed by a path component

    which will be added to the content of the environment variable, e.g. “HOME/.mystuff/plugins”.

  • pathsNone-terminated array of directories/paths where dependent files may be, or None.

  • namesNone-terminated array of file names (or file name suffixes, depending on flags) to be used in combination with the paths from paths and/or the paths extracted from the environment variables in env_vars, or None.

  • flags – optional flags, or GST_PLUGIN_DEPENDENCY_FLAG_NONE

add_dependency_simple(env_vars: str | None, paths: str | None, names: str | None, flags: PluginDependencyFlags) None

Make GStreamer aware of external dependencies which affect the feature set of this plugin (ie. the elements or typefinders associated with it).

GStreamer will re-inspect plugins with external dependencies whenever any of the external dependencies change. This is useful for plugins which wrap other plugin systems, e.g. a plugin which wraps a plugin-based visualisation library and makes visualisations available as GStreamer elements, or a codec loader which exposes elements and/or caps dependent on what external codec libraries are currently installed.

Convenience wrapper function for add_dependency() which takes simple strings as arguments instead of string arrays, with multiple arguments separated by predefined delimiters (see above).

Parameters:
  • env_vars – one or more environment variables (separated by ‘:’, ‘;’ or ‘,’), or None. Environment variable names may be followed by a path component which will be added to the content of the environment variable, e.g. “HOME/.mystuff/plugins:MYSTUFF_PLUGINS_PATH”

  • paths – one ore more directory paths (separated by ‘:’ or ‘;’ or ‘,’), or None. Example: “/usr/lib/mystuff/plugins”

  • names – one or more file names or file name suffixes (separated by commas), or None

  • flags – optional flags, or GST_PLUGIN_DEPENDENCY_FLAG_NONE

get_cache_data() Structure | None

Gets the plugin specific data cache. If it is None there is no cached data stored. This is the case when the registry is getting rebuilt.

get_description() str

Get the long descriptive name of the plugin

get_filename() str | None

get the filename of the plugin

get_license() str

get the license of the plugin

get_name() str

Get the short name of the plugin

get_origin() str

get the URL where the plugin comes from

get_package() str

get the package the plugin belongs to.

get_release_date_string() str | None

Get the release date (and possibly time) in form of a string, if available.

For normal GStreamer plugin releases this will usually just be a date in the form of “YYYY-MM-DD”, while pre-releases and builds from git may contain a time component after the date as well, in which case the string will be formatted like “YYYY-MM-DDTHH:MMZ” (e.g. “2012-04-30T09:30Z”).

There may be plugins that do not have a valid release date set on them.

get_source() str

get the source module the plugin belongs to.

get_version() str

get the version of the plugin

is_loaded() bool

queries if the plugin is loaded into memory

list_free(list: list[Plugin]) None

Unrefs each member of list, then frees the list.

Parameters:

list – list of Plugin

load() Plugin | None

Loads plugin. Note that the return value is the loaded plugin; plugin is untouched. The normal use pattern of this function goes like this:

GstPlugin *loaded_plugin;
loaded_plugin = gst_plugin_load (plugin);
// presumably, we're no longer interested in the potentially-unloaded plugin
gst_object_unref (plugin);
plugin = loaded_plugin;
load_by_name(name: str) Plugin | None

Load the named plugin. Refs the plugin.

Parameters:

name – name of plugin to load

load_file(filename: str) Plugin

Loads the given plugin and refs it. Caller needs to unref after use.

Parameters:

filename – the plugin filename to load

register_static(major_version: int, minor_version: int, name: str, description: str, init_func: Callable[[Plugin], bool], version: str, license: str, source: str, package: str, origin: str) bool

Registers a static plugin, ie. a plugin which is private to an application or library and contained within the application or library (as opposed to being shipped as a separate module file).

You must make sure that GStreamer has been initialised (with init() or via init_get_option_group()) before calling this function.

Parameters:
  • major_version – the major version number of the GStreamer core that the plugin was compiled for, you can just use GST_VERSION_MAJOR here

  • minor_version – the minor version number of the GStreamer core that the plugin was compiled for, you can just use GST_VERSION_MINOR here

  • name – a unique name of the plugin (ideally prefixed with an application- or library-specific namespace prefix in order to avoid name conflicts in case a similar plugin with the same name ever gets added to GStreamer)

  • description – description of the plugin

  • init_func – pointer to the init function of this plugin.

  • version – version string of the plugin

  • license – effective license of plugin. Must be one of the approved licenses (see GstPluginDesc above) or the plugin will not be registered.

  • source – source module plugin belongs to

  • package – shipped package plugin belongs to

  • origin – URL to provider of plugin

register_static_full(major_version: int, minor_version: int, name: str, description: str, init_full_func: Callable[[...], bool], version: str, license: str, source: str, package: str, origin: str, *user_data: Any) bool

Registers a static plugin, ie. a plugin which is private to an application or library and contained within the application or library (as opposed to being shipped as a separate module file) with a PluginInitFullFunc which allows user data to be passed to the callback function (useful for bindings).

You must make sure that GStreamer has been initialised (with init() or via init_get_option_group()) before calling this function.

Parameters:
  • major_version – the major version number of the GStreamer core that the plugin was compiled for, you can just use GST_VERSION_MAJOR here

  • minor_version – the minor version number of the GStreamer core that the plugin was compiled for, you can just use GST_VERSION_MINOR here

  • name – a unique name of the plugin (ideally prefixed with an application- or library-specific namespace prefix in order to avoid name conflicts in case a similar plugin with the same name ever gets added to GStreamer)

  • description – description of the plugin

  • init_full_func – pointer to the init function with user data of this plugin.

  • version – version string of the plugin

  • license – effective license of plugin. Must be one of the approved licenses (see GstPluginDesc above) or the plugin will not be registered.

  • source – source module plugin belongs to

  • package – shipped package plugin belongs to

  • origin – URL to provider of plugin

  • user_data – gpointer to user data

set_cache_data(cache_data: Structure) None

Adds plugin specific data to cache. Passes the ownership of the structure to the plugin.

The cache is flushed every time the registry is rebuilt.

Parameters:

cache_data – a structure containing the data to cache