Skip to content
Saunier Thibault edited this page Mar 3, 2015 · 1 revision

#GES.Asset

The Assets in the GStreamer Editing Services represent the resources that can be used. You can create assets for any type that implements the GES.Extractable interface, for example (FIXME broken link)GESClips, GES.Formatter, and GES.TrackElement do implement it. This means that assets will represent for example a (FIXME broken link)GESUriClips, GES.BaseEffect etc, and then you can extract objects of those types with the appropriate parameters from the asset using the (FIXME broken link)ges_asset_extract method:

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));

In that example, the advantages of having a GES.Asset are that you can know what effects you are working with and let your user know about the avalaible ones, you can add metadata to the GES.Asset through the GES.MetaContainer interface and you have a model for your custom effects. Note that GES.Asset management is making easier thanks to the GES.Project class.

Each asset is represented by a pair of @extractable_type and @id (string). Actually the @extractable_type is the type that implements the GES.Extractable interface, that means that for example for a GES.UriClip, the type that implements the GES.Extractable interface is GES.Clip. The identifier represents different things depending on the @extractable_type and you should check the documentation of each type to know what the ID of GES.Asset actually represents for that type. By default, we only have one GES.Asset per type, and the @id is the name of the type, but this behaviour is overriden to be more useful. For example, for GESTransitionClips, the ID is the vtype of the transition you will extract from it (ie crossfade, box-wipe-rc etc..) For GES.Effect the ID is the @bin-description property of the extracted objects (ie the gst-launch style description of the bin that will be used).

Each and every GES.Asset is cached into GES, and you can query those with the (FIXME broken link)ges_list_assets function. Also the system will automatically register (FIXME broken link)GESAssets for (FIXME broken link)GESFormatters and (FIXME broken link)GESTransitionClips and standard effects (actually not implemented yet) and you can simply query those calling:

   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) {
     g_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);

You can request the creation of (FIXME broken link)GESAssets using either (FIXME broken link)ges_asset_request_async or (FIXME broken link)ges_asset_request_async. All the (FIXME broken link)GESAssets are cached and thus any asset that has already been created can be requested again without overhead.

##GES.Asset.extract (self) self: The GES.Asset to get extract an object from

Returns: A newly created GES.Extractable

Extracts a new GObject.Object from @asset. The type of the object is defined by the extractable-type of @asset, you can check what type will be extracted from @asset using (FIXME broken link)ges_asset_get_extractable_type

##GES.Asset.get_extractable_type (self) self: The GES.Asset

Returns: the type of object that can be extracted from self

Gets the type of object that can be extracted from self

##GES.Asset.get_id (self) self: The GES.Asset to get ID from

Returns: The ID of self

Gets the ID of a GES.Asset

##GES.Asset.request_async (extractable_type, id, cancellable, callback, user_data) extractable_type: The GLib.Type of the object that can be extracted from the new asset. The class must implement the GES.Extractable interface.

id: The Identifier of the asset we want to create. This identifier depends of the extractable, type you want. By default it is the name of the class itself (or NULL), but for example for a GESEffect, it will be the pipeline description, for a GESUriClip it will be the name of the file, etc... You should refer to the documentation of the GES.Extractable type you want to create a GES.Asset for.

cancellable: optional %GCancellable object, NULL to ignore.

callback: a Gio.AsyncReadyCallback to call when the initialization is finished, Note that the @source of the callback will be the GES.Asset, but you need to make sure that the asset is properly loaded using the (FIXME broken link)ges_asset_request_finish method. This asset can not be used as is.

user_data: The user data to pass when callback is called

Returns: FIXME empty description

Request a new GES.Asset asyncronously, callback will be called when the materail is ready to be used or if an error occured.

Example of request of a GESAsset async:

// The request callback
static void
asset_loaded_cb (GESAsset * source, GAsyncResult * res, gpointer user_data)
{
  GESAsset *asset;
  GError *error = NULL;

  asset = ges_asset_request_finish (res, &error);
  if (asset) {
   g_print ("The file: %s is usable as a FileSource",
       ges_asset_get_id (asset));
  } else {
   g_print ("The file: %s is *not* usable as a FileSource because: %s",
       ges_asset_get_id (source), error->message);
  }

  gst_object_unref (mfs);
}

// The request:
ges_asset_request_async (GES_TYPE_URI_CLIP, some_uri, NULL,
   (GAsyncReadyCallback) asset_loaded_cb, user_data);

##GES.Asset.request_finish (res) res: The Gio.AsyncResult from which to get the newly created GES.Asset

Returns: The GES.Asset previously requested

Finalize the request of an async GES.Asset

##GES.Asset.request (extractable_type, id) extractable_type: The GLib.Type of the object that can be extracted from the new asset.

id: The Identifier or NULL

Returns: A reference to the wanted GES.Asset or NULL

Create a GES.Asset in the most simple cases, you should look at the extractable_type documentation to see if that constructor can be called for this particular type

As it is recommanded not to instanciate assets for GESUriClip synchronously, it will not work with this method, but you can instead use the specific (FIXME broken link)ges_uri_clip_asset_request_sync method if you really want to.

Clone this wiki locally