mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-08 16:35:40 +00:00
asset: Add a way to set asset as "needing reload"
Allowing application to force the asset system to recheck if an asset has been "fixed" and can be used again API: + ges_asset_needs_reload Differential Revision: https://phabricator.freedesktop.org/D584
This commit is contained in:
parent
08f927ca68
commit
f473386b88
3 changed files with 74 additions and 9 deletions
|
@ -1083,6 +1083,7 @@ ges_asset_set_proxy
|
|||
ges_asset_list_proxies
|
||||
ges_asset_get_proxy_target
|
||||
ges_asset_get_proxy
|
||||
ges_asset_needs_reload
|
||||
<SUBSECTION Standard>
|
||||
GESAssetPrivate
|
||||
GES_ASSET
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/* GStreamer Editing Services
|
||||
*
|
||||
* Copyright (C) 2012 Thibault Saunier <thibault.saunier@collabora.com>
|
||||
* Copyright (C) 2012-2015 Thibault Saunier <thibault.saunier@collabora.com>
|
||||
* Copyright (C) 2012 Volodymyr Rudyi <vladimir.rudoy@gmail.com>
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
|
@ -106,6 +106,7 @@ typedef enum
|
|||
ASSET_NOT_INITIALIZED,
|
||||
ASSET_INITIALIZING, ASSET_INITIALIZED_WITH_ERROR,
|
||||
ASSET_PROXIED,
|
||||
ASSET_NEEDS_RELOAD,
|
||||
ASSET_INITIALIZED
|
||||
} GESAssetState;
|
||||
|
||||
|
@ -199,20 +200,21 @@ _check_and_update_parameters (GType * extractable_type, const gchar * id,
|
|||
return real_id;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
start_loading (GESAsset * asset)
|
||||
{
|
||||
ges_asset_cache_put (gst_object_ref (asset), NULL);
|
||||
return ges_asset_cache_set_loaded (asset->priv->extractable_type,
|
||||
asset->priv->id, NULL);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
initable_init (GInitable * initable, GCancellable * cancellable,
|
||||
GError ** error)
|
||||
{
|
||||
gboolean ret;
|
||||
GESAsset *asset = GES_ASSET (initable);
|
||||
|
||||
ges_asset_cache_put (gst_object_ref (asset), NULL);
|
||||
ret = ges_asset_cache_set_loaded (asset->priv->extractable_type,
|
||||
asset->priv->id, NULL);
|
||||
|
||||
g_clear_error (error);
|
||||
|
||||
return ret;
|
||||
return start_loading (GES_ASSET (initable));
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -937,6 +939,11 @@ ges_asset_request (GType extractable_type, const gchar * id, GError ** error)
|
|||
asset = ges_asset_get_proxy (asset);
|
||||
|
||||
break;
|
||||
case ASSET_NEEDS_RELOAD:
|
||||
GST_DEBUG_OBJECT (asset, "Asset in cache and needs reload");
|
||||
start_loading (asset);
|
||||
|
||||
goto done;
|
||||
case ASSET_INITIALIZED_WITH_ERROR:
|
||||
GST_WARNING_OBJECT (asset, "Initialized with error, not returning");
|
||||
if (asset->priv->error && error)
|
||||
|
@ -1078,6 +1085,12 @@ ges_asset_request_async (GType extractable_type,
|
|||
goto done;
|
||||
}
|
||||
break;
|
||||
case ASSET_NEEDS_RELOAD:
|
||||
GST_DEBUG_OBJECT (asset, "Asset in cache and needs reload");
|
||||
ges_asset_cache_append_task (extractable_type, real_id, task);
|
||||
GES_ASSET_GET_CLASS (asset)->start_loading (asset, &error);
|
||||
|
||||
goto done;
|
||||
case ASSET_INITIALIZED_WITH_ERROR:
|
||||
g_task_return_error (task,
|
||||
error ? error : g_error_copy (asset->priv->error));
|
||||
|
@ -1098,6 +1111,55 @@ done:
|
|||
g_free (real_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* ges_asset_needs_reload
|
||||
* @extractable_type: The #GType of the object that can be extracted from the
|
||||
* asset to be reloaded.
|
||||
* @id: The identifier of the asset to mark as needing reload
|
||||
*
|
||||
* Sets an asset from the internal cache as needing reload. An asset needs reload
|
||||
* in the case where, for example, we were missing a GstPlugin to use it and that
|
||||
* plugin has been installed, or, that particular asset content as changed
|
||||
* meanwhile (in the case of the usage of proxies).
|
||||
*
|
||||
* Once an asset has been set as "needs reload", requesting that asset again
|
||||
* will lead to it being re discovered, and reloaded as if it was not in the
|
||||
* cache before.
|
||||
*
|
||||
* Returns: %TRUE if the asset was in the cache and could be set as needing reload,
|
||||
* %FALSE otherwise.
|
||||
*/
|
||||
gboolean
|
||||
ges_asset_needs_reload (GType extractable_type, const gchar * id)
|
||||
{
|
||||
gchar *real_id;
|
||||
GESAsset *asset;
|
||||
GError *error = NULL;
|
||||
|
||||
real_id = _check_and_update_parameters (&extractable_type, id, &error);
|
||||
if (error) {
|
||||
_unsure_material_for_wrong_id (id, extractable_type, error);
|
||||
real_id = g_strdup (id);
|
||||
}
|
||||
|
||||
asset = ges_asset_cache_lookup (extractable_type, real_id);
|
||||
|
||||
if (real_id) {
|
||||
g_free (real_id);
|
||||
}
|
||||
|
||||
if (asset) {
|
||||
GST_DEBUG_OBJECT (asset,
|
||||
"Asset with id %s switch state to ASSET_NEEDS_RELOAD",
|
||||
ges_asset_get_id (asset));
|
||||
asset->priv->state = ASSET_NEEDS_RELOAD;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
GST_DEBUG ("Asset with id %s not found in cache", id);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* ges_asset_get_id:
|
||||
* @self: The #GESAsset to get ID from
|
||||
|
|
|
@ -109,6 +109,8 @@ gboolean ges_asset_set_proxy (GESAsset *asset, GESAsset *proxy);
|
|||
GList * ges_asset_list_proxies (GESAsset *asset);
|
||||
GESAsset * ges_asset_get_proxy_target(GESAsset *proxy);
|
||||
GESAsset * ges_asset_get_proxy (GESAsset *asset);
|
||||
gboolean ges_asset_needs_reload (GType extractable_type,
|
||||
const gchar * id);
|
||||
|
||||
G_END_DECLS
|
||||
#endif /* _GES_ASSET */
|
||||
|
|
Loading…
Reference in a new issue