mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-27 10:40:34 +00:00
project: Add a method to create assets synchronously
This allows to create a add an asset to a project in a synchronous way. API: ges_project_create_asset_sync https://bugzilla.gnome.org/show_bug.cgi?id=740716
This commit is contained in:
parent
58d525a4e7
commit
55c88a726e
2 changed files with 78 additions and 0 deletions
|
@ -709,6 +709,80 @@ ges_project_create_asset (GESProject * project, const gchar * id,
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* ges_project_create_asset_sync:
|
||||
* @project: A #GESProject
|
||||
* @id: (allow-none): The id of the asset to create and add to @project
|
||||
* @extractable_type: The #GType of the asset to create
|
||||
* @error: A #GError to be set in case of error
|
||||
*
|
||||
* Create and add a #GESAsset to @project. You should connect to the
|
||||
* "asset-added" signal to get the asset when it finally gets added to
|
||||
* @project
|
||||
*
|
||||
* Returns: The newly created #GESAsset
|
||||
*/
|
||||
GESAsset *
|
||||
ges_project_create_asset_sync (GESProject * project, const gchar * id,
|
||||
GType extractable_type, GError ** error)
|
||||
{
|
||||
GESAsset *asset;
|
||||
gchar *possible_id = NULL;
|
||||
gboolean retry = TRUE;
|
||||
|
||||
g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
|
||||
g_return_val_if_fail (g_type_is_a (extractable_type, GES_TYPE_EXTRACTABLE),
|
||||
FALSE);
|
||||
|
||||
if (id == NULL)
|
||||
id = g_type_name (extractable_type);
|
||||
|
||||
if ((asset = g_hash_table_lookup (project->priv->assets, id)))
|
||||
return asset;
|
||||
else if (g_hash_table_lookup (project->priv->loading_assets, id) ||
|
||||
g_hash_table_lookup (project->priv->loaded_with_error, id))
|
||||
return NULL;
|
||||
|
||||
/* TODO Add a GCancellable somewhere in our API */
|
||||
while (retry) {
|
||||
|
||||
if (g_type_is_a (extractable_type, GES_TYPE_URI_CLIP)) {
|
||||
asset = GES_ASSET (ges_uri_clip_asset_request_sync (id, error));
|
||||
} else {
|
||||
asset = ges_asset_request (extractable_type, id, error);
|
||||
}
|
||||
|
||||
if (asset) {
|
||||
retry = FALSE;
|
||||
|
||||
if (possible_id) {
|
||||
g_free (possible_id);
|
||||
ges_uri_assets_validate_uri (id);
|
||||
}
|
||||
|
||||
break;
|
||||
} else {
|
||||
GESAsset *tmpasset;
|
||||
|
||||
tmpasset = ges_asset_cache_lookup (extractable_type, id);
|
||||
possible_id = ges_project_try_updating_id (project, tmpasset, *error);
|
||||
|
||||
if (possible_id == NULL)
|
||||
return NULL;
|
||||
|
||||
g_clear_error (error);
|
||||
if (error)
|
||||
*error = NULL;
|
||||
|
||||
id = possible_id;
|
||||
}
|
||||
}
|
||||
|
||||
ges_project_add_asset (project, asset);
|
||||
|
||||
return asset;
|
||||
}
|
||||
|
||||
/**
|
||||
* ges_project_add_asset:
|
||||
* @project: A #GESProject
|
||||
|
|
|
@ -96,6 +96,10 @@ gboolean ges_project_create_asset (GESProject * project,
|
|||
const gchar *id,
|
||||
GType extractable_type);
|
||||
|
||||
GESAsset * ges_project_create_asset_sync (GESProject * project,
|
||||
const gchar * id,
|
||||
GType extractable_type,
|
||||
GError **error);
|
||||
GList * ges_project_get_loading_assets (GESProject * project);
|
||||
|
||||
gboolean ges_project_add_encoding_profile (GESProject *project,
|
||||
|
|
Loading…
Reference in a new issue