Copyright | Will Thompson Iñaki García Etxebarria and Jonas Platte |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria (inaki@blueleaf.cc) |
Safe Haskell | None |
Language | Haskell2010 |
One registry holds the metadata of a set of plugins.
<emphasis role="bold">Design:</emphasis>
The Registry
object is a list of plugins and some functions for dealing
with them. Each Plugin
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 PluginFlagsCached
bit. These plugins are
removed at the end of initialization.
Synopsis
- newtype Registry = Registry (ManagedPtr Registry)
- class (GObject o, IsDescendantOf Registry o) => IsRegistry o
- toRegistry :: (MonadIO m, IsRegistry o) => o -> m Registry
- noRegistry :: Maybe Registry
- registryAddFeature :: (HasCallStack, MonadIO m, IsRegistry a, IsPluginFeature b) => a -> b -> m Bool
- registryAddPlugin :: (HasCallStack, MonadIO m, IsRegistry a, IsPlugin b) => a -> b -> m Bool
- registryCheckFeatureVersion :: (HasCallStack, MonadIO m, IsRegistry a) => a -> Text -> Word32 -> Word32 -> Word32 -> m Bool
- registryFeatureFilter :: (HasCallStack, MonadIO m, IsRegistry a) => a -> PluginFeatureFilter -> Bool -> m [PluginFeature]
- registryFindFeature :: (HasCallStack, MonadIO m, IsRegistry a) => a -> Text -> GType -> m (Maybe PluginFeature)
- registryFindPlugin :: (HasCallStack, MonadIO m, IsRegistry a) => a -> Text -> m (Maybe Plugin)
- registryForkIsEnabled :: (HasCallStack, MonadIO m) => m Bool
- registryForkSetEnabled :: (HasCallStack, MonadIO m) => Bool -> m ()
- registryGet :: (HasCallStack, MonadIO m) => m Registry
- registryGetFeatureList :: (HasCallStack, MonadIO m, IsRegistry a) => a -> GType -> m [PluginFeature]
- registryGetFeatureListByPlugin :: (HasCallStack, MonadIO m, IsRegistry a) => a -> Text -> m [PluginFeature]
- registryGetFeatureListCookie :: (HasCallStack, MonadIO m, IsRegistry a) => a -> m Word32
- registryGetPluginList :: (HasCallStack, MonadIO m, IsRegistry a) => a -> m [Plugin]
- registryLookup :: (HasCallStack, MonadIO m, IsRegistry a) => a -> Text -> m (Maybe Plugin)
- registryLookupFeature :: (HasCallStack, MonadIO m, IsRegistry a) => a -> Text -> m PluginFeature
- registryPluginFilter :: (HasCallStack, MonadIO m, IsRegistry a) => a -> PluginFilter -> Bool -> m [Plugin]
- registryRemoveFeature :: (HasCallStack, MonadIO m, IsRegistry a, IsPluginFeature b) => a -> b -> m ()
- registryRemovePlugin :: (HasCallStack, MonadIO m, IsRegistry a, IsPlugin b) => a -> b -> m ()
- registryScanPath :: (HasCallStack, MonadIO m, IsRegistry a) => a -> [Char] -> m Bool
- type C_RegistryFeatureAddedCallback = Ptr () -> Ptr PluginFeature -> Ptr () -> IO ()
- type RegistryFeatureAddedCallback = PluginFeature -> IO ()
- afterRegistryFeatureAdded :: (IsRegistry a, MonadIO m) => a -> RegistryFeatureAddedCallback -> m SignalHandlerId
- genClosure_RegistryFeatureAdded :: MonadIO m => RegistryFeatureAddedCallback -> m (GClosure C_RegistryFeatureAddedCallback)
- mk_RegistryFeatureAddedCallback :: C_RegistryFeatureAddedCallback -> IO (FunPtr C_RegistryFeatureAddedCallback)
- noRegistryFeatureAddedCallback :: Maybe RegistryFeatureAddedCallback
- onRegistryFeatureAdded :: (IsRegistry a, MonadIO m) => a -> RegistryFeatureAddedCallback -> m SignalHandlerId
- wrap_RegistryFeatureAddedCallback :: RegistryFeatureAddedCallback -> C_RegistryFeatureAddedCallback
- type C_RegistryPluginAddedCallback = Ptr () -> Ptr Plugin -> Ptr () -> IO ()
- type RegistryPluginAddedCallback = Plugin -> IO ()
- afterRegistryPluginAdded :: (IsRegistry a, MonadIO m) => a -> RegistryPluginAddedCallback -> m SignalHandlerId
- genClosure_RegistryPluginAdded :: MonadIO m => RegistryPluginAddedCallback -> m (GClosure C_RegistryPluginAddedCallback)
- mk_RegistryPluginAddedCallback :: C_RegistryPluginAddedCallback -> IO (FunPtr C_RegistryPluginAddedCallback)
- noRegistryPluginAddedCallback :: Maybe RegistryPluginAddedCallback
- onRegistryPluginAdded :: (IsRegistry a, MonadIO m) => a -> RegistryPluginAddedCallback -> m SignalHandlerId
- wrap_RegistryPluginAddedCallback :: RegistryPluginAddedCallback -> C_RegistryPluginAddedCallback
Exported types
Memory-managed wrapper type.
Instances
GObject Registry Source # | |
Defined in GI.Gst.Objects.Registry gobjectType :: IO GType # | |
HasParentTypes Registry Source # | |
Defined in GI.Gst.Objects.Registry | |
type ParentTypes Registry Source # | |
Defined in GI.Gst.Objects.Registry |
class (GObject o, IsDescendantOf Registry o) => IsRegistry o Source #
Type class for types which can be safely cast to Registry
, for instance with toRegistry
.
Instances
(GObject o, IsDescendantOf Registry o) => IsRegistry o Source # | |
Defined in GI.Gst.Objects.Registry |
toRegistry :: (MonadIO m, IsRegistry o) => o -> m Registry Source #
Methods
addFeature
:: (HasCallStack, MonadIO m, IsRegistry a, IsPluginFeature b) | |
=> a |
|
-> b |
|
-> m Bool | Returns: MT safe. |
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()
)
addPlugin
:: (HasCallStack, MonadIO m, IsRegistry a, IsPlugin b) | |
=> a |
|
-> b |
|
-> m Bool | Returns: MT safe. |
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()
)
checkFeatureVersion
registryCheckFeatureVersion Source #
:: (HasCallStack, MonadIO m, IsRegistry a) | |
=> a |
|
-> Text |
|
-> Word32 |
|
-> Word32 |
|
-> Word32 |
|
-> m Bool | Returns: |
Checks whether a plugin feature by the given name exists in
registry
and whether its version is at least the
version required.
featureFilter
registryFeatureFilter Source #
:: (HasCallStack, MonadIO m, IsRegistry a) | |
=> a |
|
-> PluginFeatureFilter |
|
-> Bool |
|
-> m [PluginFeature] | Returns: a MT safe. |
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).
findFeature
:: (HasCallStack, MonadIO m, IsRegistry a) | |
=> a |
|
-> Text |
|
-> GType |
|
-> m (Maybe PluginFeature) | Returns: the pluginfeature with the
given name and type or MT safe. |
Find the pluginfeature with the given name and type in the registry.
findPlugin
:: (HasCallStack, MonadIO m, IsRegistry a) | |
=> a |
|
-> Text |
|
-> m (Maybe Plugin) | Returns: the plugin with the given name
or MT safe. |
Find the plugin with the given name in the registry. The plugin will be reffed; caller is responsible for unreffing.
forkIsEnabled
registryForkIsEnabled Source #
:: (HasCallStack, MonadIO m) | |
=> m Bool | Returns: |
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
registryForkSetEnabled
function, in which case new plugins
are scanned (and loaded) into the application process.
forkSetEnabled
registryForkSetEnabled Source #
:: (HasCallStack, MonadIO m) | |
=> Bool |
|
-> m () |
Applications might want to disable/enable spawning of a child helper process
when rebuilding the registry. See registryForkIsEnabled
for more
information.
get
:: (HasCallStack, MonadIO m) | |
=> m Registry | Returns: the |
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.
getFeatureList
registryGetFeatureList Source #
:: (HasCallStack, MonadIO m, IsRegistry a) | |
=> a |
|
-> GType |
|
-> m [PluginFeature] | Returns: a MT safe. |
Retrieves a List
of PluginFeature
of type
.
getFeatureListByPlugin
registryGetFeatureListByPlugin Source #
:: (HasCallStack, MonadIO m, IsRegistry a) | |
=> a |
|
-> Text |
|
-> m [PluginFeature] | Returns: a |
Retrieves a List
of features of the plugin with name name
.
getFeatureListCookie
registryGetFeatureListCookie Source #
:: (HasCallStack, MonadIO m, IsRegistry a) | |
=> a |
|
-> m Word32 | Returns: the feature list cookie. |
Returns the registry's feature list cookie. This changes every time a feature is added or removed from the registry.
getPluginList
registryGetPluginList Source #
:: (HasCallStack, MonadIO m, IsRegistry a) | |
=> a |
|
-> m [Plugin] | Returns: a MT safe. |
Get a copy of all plugins registered in the given registry. The refcount of each element in the list in incremented.
lookup
:: (HasCallStack, MonadIO m, IsRegistry a) | |
=> a |
|
-> Text |
|
-> m (Maybe Plugin) | Returns: the |
Look up a plugin in the given registry with the given filename. If found, plugin is reffed.
lookupFeature
registryLookupFeature Source #
:: (HasCallStack, MonadIO m, IsRegistry a) | |
=> a |
|
-> Text |
|
-> m PluginFeature | Returns: a MT safe. |
Find a PluginFeature
with name
in registry
.
pluginFilter
:: (HasCallStack, MonadIO m, IsRegistry a) | |
=> a |
|
-> PluginFilter |
|
-> Bool |
|
-> m [Plugin] | Returns: a MT safe. |
Runs a filter against all plugins in the registry and returns a List
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 pluginListFree
after use, which
will unref again.
removeFeature
registryRemoveFeature Source #
:: (HasCallStack, MonadIO m, IsRegistry a, IsPluginFeature b) | |
=> a |
|
-> b |
|
-> m () |
Remove the feature from the registry.
MT safe.
removePlugin
:: (HasCallStack, MonadIO m, IsRegistry a, IsPlugin b) | |
=> a |
|
-> b |
|
-> m () |
Remove the plugin from the registry.
MT safe.
scanPath
:: (HasCallStack, MonadIO m, IsRegistry a) | |
=> a |
|
-> [Char] |
|
-> m Bool | Returns: |
Scan the given path for plugins to add to the registry. The syntax of the path is specific to the registry.
Signals
featureAdded
type C_RegistryFeatureAddedCallback = Ptr () -> Ptr PluginFeature -> Ptr () -> IO () Source #
Type for the callback on the (unwrapped) C side.
type RegistryFeatureAddedCallback Source #
= PluginFeature |
|
-> IO () |
Signals that a feature has been added to the registry (possibly replacing a previously-added one by the same name)
afterRegistryFeatureAdded :: (IsRegistry a, MonadIO m) => a -> RegistryFeatureAddedCallback -> m SignalHandlerId Source #
Connect a signal handler for the “feature-added
” signal, to be run after the default handler.
When overloading is enabled, this is equivalent to
after
registry #featureAdded callback
genClosure_RegistryFeatureAdded :: MonadIO m => RegistryFeatureAddedCallback -> m (GClosure C_RegistryFeatureAddedCallback) Source #
Wrap the callback into a GClosure
.
mk_RegistryFeatureAddedCallback :: C_RegistryFeatureAddedCallback -> IO (FunPtr C_RegistryFeatureAddedCallback) Source #
Generate a function pointer callable from C code, from a C_RegistryFeatureAddedCallback
.
noRegistryFeatureAddedCallback :: Maybe RegistryFeatureAddedCallback Source #
A convenience synonym for
.Nothing
:: Maybe
RegistryFeatureAddedCallback
onRegistryFeatureAdded :: (IsRegistry a, MonadIO m) => a -> RegistryFeatureAddedCallback -> m SignalHandlerId Source #
Connect a signal handler for the “feature-added
” signal, to be run before the default handler.
When overloading is enabled, this is equivalent to
on
registry #featureAdded callback
wrap_RegistryFeatureAddedCallback :: RegistryFeatureAddedCallback -> C_RegistryFeatureAddedCallback Source #
Wrap a RegistryFeatureAddedCallback
into a C_RegistryFeatureAddedCallback
.
pluginAdded
type C_RegistryPluginAddedCallback = Ptr () -> Ptr Plugin -> Ptr () -> IO () Source #
Type for the callback on the (unwrapped) C side.
type RegistryPluginAddedCallback Source #
Signals that a plugin has been added to the registry (possibly replacing a previously-added one by the same name)
afterRegistryPluginAdded :: (IsRegistry a, MonadIO m) => a -> RegistryPluginAddedCallback -> m SignalHandlerId Source #
Connect a signal handler for the “plugin-added
” signal, to be run after the default handler.
When overloading is enabled, this is equivalent to
after
registry #pluginAdded callback
genClosure_RegistryPluginAdded :: MonadIO m => RegistryPluginAddedCallback -> m (GClosure C_RegistryPluginAddedCallback) Source #
Wrap the callback into a GClosure
.
mk_RegistryPluginAddedCallback :: C_RegistryPluginAddedCallback -> IO (FunPtr C_RegistryPluginAddedCallback) Source #
Generate a function pointer callable from C code, from a C_RegistryPluginAddedCallback
.
noRegistryPluginAddedCallback :: Maybe RegistryPluginAddedCallback Source #
A convenience synonym for
.Nothing
:: Maybe
RegistryPluginAddedCallback
onRegistryPluginAdded :: (IsRegistry a, MonadIO m) => a -> RegistryPluginAddedCallback -> m SignalHandlerId Source #
Connect a signal handler for the “plugin-added
” signal, to be run before the default handler.
When overloading is enabled, this is equivalent to
on
registry #pluginAdded callback