A Asset in the GStreamer Editing Services represents a resources that can be used.
In particular, any class that implements the Extractable interface may have some associated assets with a corresponding extractable_type, from which its objects can be extracted using extract. Some examples would be Clip, Formatter and TrackElement.
All assets that are created within GES are stored in a cache; one per each id and extractable_type pair. These assets can be fetched, and initialized if they do not yet exist in the cache, using Asset.request.
``` c GESAsset *effect_asset; GESEffect *effect;
// You create an asset for an effect effect_asset = ges_asset_request (GES_TYPE_EFFECT, "agingtv", NULL);
// And now you can extract an instance of GESEffect from that asset effect = GES_EFFECT (ges_asset_extract (effect_asset));
```
The advantage of using assets, rather than simply creating the object directly, is that the currently loaded resources can be listed with list_assets and displayed to an end user. For example, to show which media files have been loaded, and a standard list of effects. In fact, the GES library already creates assets for TransitionClip and Formatter, which you can use to list all the available transition types and supported formats.
The other advantage is that Asset implements MetaContainer , so metadata can be set on the asset, with some subclasses automatically creating this metadata on initiation.
For example, to display information about the supported formats, you could do the following:
GList *formatter_assets, *tmp;
// List all the transitions
formatter_assets = ges_list_assets (GES_TYPE_FORMATTER);
// Print some infos about the formatter GESAsset
for (tmp = formatter_assets; tmp; tmp = tmp->next) {
gst_print ("Name of the formatter: %s, file extension it produces: %s",
ges_meta_container_get_string (
GES_META_CONTAINER (tmp->data), GES_META_FORMATTER_NAME),
ges_meta_container_get_string (
GES_META_CONTAINER (tmp->data), GES_META_FORMATTER_EXTENSION));
}
g_list_free (transition_assets);
Each asset is uniquely defined in the cache by its extractable_type and id. Depending on the extractable_type, the id can be used to parametrise the creation of the object upon extraction. By default, a class that implements Extractable will only have a single associated asset, with an id set to the type name of its objects. However, this is overwritten by some implementations, which allow a class to have multiple associated assets. For example, for TransitionClip the id will be a nickname of the vtype. You should check the documentation for each extractable type to see if they differ from the default.
Moreover, each extractable_type may also associate itself with a specific asset subclass. In such cases, when their asset is requested, an asset of this subclass will be returned instead.
You can use a Project to easily manage the assets of a Timeline.
Some assets can (temporarily) act as the proxy of another asset. When the original asset is requested from the cache, the proxy will be returned in its place. This can be useful if, say, you want to substitute a UriClipAsset corresponding to a high resolution media file with the asset of a lower resolution stand in.
An asset may even have several proxies, the first of which will act as its default and be returned on requests, but the others will be ordered to take its place once it is removed. You can add a proxy to an asset, or set its default, using set_proxy, and you can remove them with unproxy.