GES.Asset¶
- Subclasses:
Methods¶
- Inherited:
GObject.Object (37), GES.MetaContainer (40), Gio.AsyncInitable (4), Gio.Initable (2)
- Structs:
class |
|
class |
|
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
|
|
|
|
|
|
|
|
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/co |
The type of the Object that can be extracted out of the asset |
||
r/w/co |
The unique identifier of the asset |
||
r/w |
The asset default proxy. |
||
r |
The target of a proxy asset. |
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent |
r |
Class Details¶
- class GES.Asset(**kwargs)¶
- Bases:
GObject.Object
,GES.MetaContainer
,Gio.AsyncInitable
,Gio.Initable
- Abstract:
No
- Structure:
A
GES.Asset
in the GStreamer Editing Services represents a resources that can be used. In particular, any class that implements theGES.Extractable
interface may have some associated assets with a correspondingGES.Asset
:extractable-type
, from which its objects can be extracted usingGES.Asset.extract
(). Some examples would beGES.Clip
,GES.Formatter
andGES.TrackElement
.All assets that are created within GES are stored in a cache; one per each
GES.Asset
:id
andGES.Asset
:extractable-type
pair. These assets can be fetched, and initialized if they do not yet exist in the cache, usingGES.Asset.request
().``` c
GES.Asset
*effect_asset;GES.Effect
*effect;// You create an asset for an effect effect_asset =
GES.Asset.request
(GES_TYPE_EFFECT, “agingtv”,None
);// And now you can extract an instance of
GES.Effect
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
GES.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 forGES.TransitionClip
andGES.Formatter
, which you can use to list all the available transition types and supported formats.The other advantage is that
GES.Asset
implementsGES.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);
- ID
Each asset is uniquely defined in the cache by its
GES.Asset
:extractable-type
andGES.Asset
:id
. Depending on theGES.Asset
:extractable-type
, theGES.Asset
:id
can be used to parametrise the creation of the object upon extraction. By default, a class that implementsGES.Extractable
will only have a single associated asset, with anGES.Asset
: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, forGES.TransitionClip
theGES.Asset
:id
will be a nickname of theGES.TransitionClip
:vtype
. You should check the documentation for each extractable type to see if they differ from the default.Moreover, each
GES.Asset
: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.- Managing
You can use a
GES.Project
to easily manage the assets of aGES.Timeline
.- Proxies
Some assets can (temporarily) act as the
GES.Asset
: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 aGES.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
GES.Asset.set_proxy
(), and you can remove them withGES.Asset.unproxy
().- classmethod needs_reload(extractable_type, id)[source]¶
- Parameters:
extractable_type (
GObject.GType
) – TheGES.Asset
:extractable-type
of the asset that needs reloadingid (
str
orNone
) – TheGES.Asset
:id
of the asset asset that needs reloading
- Returns:
True
if the specified asset exists in the cache and could be marked for reloading.- Return type:
Indicate that an existing
GES.Asset
in the cache should be reloaded upon the next request. This can be used when some condition has changed, which may require that an existing asset should be updated. For example, if an external resource has changed or now become available.Note, the asset is not immediately changed, but will only actually reload on the next call to
GES.Asset.request
() orGES.Asset.request_async
().
- classmethod request(extractable_type, id)[source]¶
- Parameters:
extractable_type (
GObject.GType
) – TheGES.Asset
:extractable-type
of the asset
- Raises:
- Returns:
A reference to the requested asset, or
None
if an error occurred.- Return type:
Returns an asset with the given properties. If such an asset already exists in the cache (it has been previously created in GES), then a reference to the existing asset is returned. Otherwise, a newly created asset is returned, and also added to the cache.
If the requested asset has been loaded with an error, then error is set, if given, and
None
will be returned instead.Note that the given id may not be exactly the
GES.Asset
:id
that is set on the returned asset. For instance, it may be adjusted into a standard format. Or, if aGES.Extractable
type does not have its extraction parametrised, as is the case by default, then the given id may be ignored entirely and theGES.Asset
:id
set to some standard, in which case aNone
id can be given.Similarly, the given extractable_type may not be exactly the
GES.Asset
:extractable-type
that is set on the returned asset. Instead, the actual extractable type may correspond to a subclass of the given extractable_type, depending on the given id.Moreover, depending on the given extractable_type, the returned asset may belong to a subclass of
GES.Asset
.Finally, if the requested asset has a
GES.Asset
:proxy
, then the proxy that is found at the end of the chain of proxies is returned (a proxy’s proxy will take its place, and so on, unless it has no proxy).Some asset subclasses only support asynchronous construction of its assets, such as
GES.UriClip
. For such assets this method will fail, and you should useGES.Asset.request_async
() instead. In the case ofGES.UriClip
, you can useGES.UriClipAsset.request_sync
() if you only want to wait for the request to finish.
- classmethod request_async(extractable_type, id, cancellable, callback, *user_data)[source]¶
- Parameters:
extractable_type (
GObject.GType
) – TheGES.Asset
:extractable-type
of the assetcancellable (
Gio.Cancellable
orNone
) – An object to allow cancellation of the asset request, orNone
to ignorecallback (
Gio.AsyncReadyCallback
orNone
) – A function to call when the initialization is finished
Requests an asset with the given properties asynchronously (see
GES.Asset.request
()). When the asset has been initialized or fetched from the cache, the given callback function will be called. The asset can then be retrieved in the callback using theGES.Asset.request_finish
() method on the givenGio.AsyncResult
.Note that the source object passed to the callback will be the
GES.Asset
corresponding to the request, but it may not have loaded correctly and therefore can not be used as is. Instead,GES.Asset.request_finish
() should be used to fetch a usable asset, or indicate that an error occurred in the asset’s creation.Note that the callback will be called in the
GLib.MainLoop
running under the sameGLib.MainContext
thatGES.init
() was called in. So, if you wish the callback to be invoked outside the defaultGLib.MainContext
, you can callGLib.MainContext.push_thread_default
() in a new thread before callingGES.init
().Example of an asynchronous asset request: ``` c // The request callback static void asset_loaded_cb (
GES.Asset
* source,Gio.AsyncResult
* res,object
user_data) {GES.Asset
*asset;GLib.Error
*error =None
;asset =
GES.Asset.request_finish
(res, &error); if (asset) { gst_print (“The file: %s is usable as aGES.UriClip
",GES.Asset.get_id
(asset)); } else { gst_print (“The file: %s is *not* usable as aGES.UriClip
because: %s”,GES.Asset.get_id
(source), error->message); }Gst.Object.unref
(asset); }// The request:
GES.Asset.request_async
(GES_TYPE_URI_CLIP, some_uri,None
, (Gio.AsyncReadyCallback
) asset_loaded_cb, user_data); ```
- classmethod request_finish(res)[source]¶
- Parameters:
res (
Gio.AsyncResult
) – The task result to fetch the asset from- Raises:
- Returns:
The requested asset, or
None
if an error occurred.- Return type:
Fetches an asset requested by
GES.Asset.request_async
(), which finalises the request.
- extract()[source]¶
- Raises:
- Returns:
A newly created object, or
None
if an error occurred.- Return type:
Extracts a new
GES.Asset
:extractable-type
object from the asset. TheGES.Asset
:id
of the asset may determine the properties and state of the newly created object.
- get_error()[source]¶
- Returns:
The error set on asset, or
None
if no error occurred when asset was loaded.- Return type:
GLib.Error
orNone
Retrieve the error that was set on the asset when it was loaded.
New in version 1.8.
- get_extractable_type()[source]¶
- Returns:
The extractable type of self.
- Return type:
Gets the
GES.Asset
:extractable-type
of the asset.
- get_proxy_target()[source]¶
-
Gets the
GES.Asset
:proxy-target
of the asset.Note that the proxy target may have loaded with an error, so you should call
GES.Asset.get_error
() on the returned target.
- list_proxies()[source]¶
- Returns:
The list of proxies that self has.
- Return type:
Get all the proxies that the asset has. The first item of the list will be the default
GES.Asset
:proxy
. The second will be the proxy that is ‘next in line’ to be default, and so on.
- set_proxy(proxy)[source]¶
- Parameters:
- Returns:
True
if proxy was successfully set as the default for self.- Return type:
Sets the
GES.Asset
:proxy
for the asset.If proxy is among the existing proxies of the asset (see
GES.Asset.list_proxies
()) it will be moved to become the default proxy. Otherwise, if proxy is notNone
, it will be added to the list of proxies, as the new default. The previous default proxy will become ‘next in line’ for if the new one is removed, and so on. As such, this will **not** actually remove the previous default proxy (useGES.Asset.unproxy
() for that).Note that an asset can only act as a proxy for one other asset.
As a special case, if proxy is
None
, then this method will actually remove **all** proxies from the asset.
- unproxy(proxy)[source]¶
- Parameters:
proxy (
GES.Asset
) – An existing proxy of self- Returns:
True
if proxy was successfully removed from self's proxy list.- Return type:
Removes the proxy from the available list of proxies for the asset. If the given proxy is the default proxy of the list, then the next proxy in the available list (see
GES.Asset.list_proxies
()) will become the default. If there are no other proxies, then the asset will no longer have a defaultGES.Asset
:proxy
.
- do_extract() virtual¶
- Returns:
A newly created object, or
None
if an error occurred.- Return type:
Extracts a new
GES.Asset
:extractable-type
object from the asset. TheGES.Asset
:id
of the asset may determine the properties and state of the newly created object.
- do_proxied(proxy) virtual¶
- Parameters:
proxy (
GES.Asset
) –
Deprecated: 1.18: This vmethod is no longer called.
- do_request_id_update(proposed_new_id, error) virtual¶
- Parameters:
proposed_new_id (
str
) –error (
GLib.Error
) –
- Return type:
A method called by a
GES.Project
when an asset has failed to load. error is the error given byGES.Asset.request_finish
(). Returns:True
if a new id for self was passed to proposed_new_id.
- do_start_loading() virtual¶
- Return type:
A method to be called when an asset is being requested asynchronously. This will be after the properties of the asset have been set, so it is tasked with (re)loading the ‘state’ of the asset. The return value should indicated whether the loading is complete, is carrying on asynchronously, or an error occurred. The default implementation will simply return that loading is already complete (the asset is already in a usable state after the properties have been set).
Property Details¶
- GES.Asset.props.extractable_type¶
- Name:
extractable-type
- Type:
- Default Value:
<GType GObject>
- Flags:
The
GES.Extractable
object type that can be extracted from the asset.
- GES.Asset.props.id¶
- Name:
id
- Type:
- Default Value:
- Flags:
The ID of the asset. This should be unique amongst all assets with the same
GES.Asset
:extractable-type
. Depending on the associatedGES.Extractable
implementation, this id may convey some information about theGObject.Object
that should be extracted. Note that, as such, the ID will have an expected format, and you can not choose this value arbitrarily. By default, this will be set to the type name of theGES.Asset
:extractable-type
, but you should check the documentation of the extractable type to see whether they differ from the default behaviour.
- GES.Asset.props.proxy¶
-
The default proxy for this asset, or
None
if it has no proxy. A proxy will act as a substitute for the original asset when the original is requested (seeGES.Asset.request
()).Setting this property will not usually remove the existing proxy, but will replace it as the default (see
GES.Asset.set_proxy
()).
- GES.Asset.props.proxy_target¶
-
The asset that this asset is a proxy for, or
None
if it is not a proxy for another asset.Note that even if this asset is acting as a proxy for another asset, but this asset is not the default
GES.Asset
:proxy
, then proxy-target will *still* point to this other asset. So you should check theGES.Asset
:proxy
property of target-proxy before assuming it is the current default proxy for the target.Note that the
GObject.Object
::notify
for this property is emitted after theGES.Asset
:proxy
GObject.Object
::notify
for the corresponding (if any) asset it is now the proxy of/no longer the proxy of.