1 /* GStreamer Editing Services
3 * Copyright (C) <2012> Thibault Saunier <thibault.saunier@collabora.com>
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
15 * You should have received a copy of the GNU Library General Public
16 * License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 * Boston, MA 02111-1307, USA.
21 * SECTION: ges-project
22 * @short_description: A GESAsset that is used to manage projects
24 * The #GESProject is used to control a set of #GESAsset and is a
25 * #GESAsset with #GES_TYPE_TIMELINE as @extractable_type itself. That
26 * means that you can extract #GESTimeline from a project as followed:
29 * GESProject *project;
30 * GESTimeline *timeline;
32 * project = ges_project_new ("file:///path/to/a/valid/project/uri");
34 * // Here you can connect to the various signal to get more infos about
35 * // what is happening and recover from errors if possible
38 * timeline = ges_asset_extract (GES_ASSET (project));
41 * The #GESProject class offers a higher level API to handle #GESAsset-s.
42 * It lets you request new asset, and it informs you about new assets through
43 * a set of signals. Also it handles problem such as missing files/missing
44 * #GstElement and lets you try to recover from those.
47 #include "ges-internal.h"
49 /* TODO We should rely on both extractable_type and @id to identify
50 * a Asset, not only @id
52 G_DEFINE_TYPE (GESProject, ges_project, GES_TYPE_ASSET);
54 struct _GESProjectPrivate
57 /* Set of asset ID being loaded */
58 GHashTable *loading_assets;
59 GHashTable *loaded_with_error;
60 GESAsset *formatter_asset;
66 GList *encoding_profiles;
69 typedef struct EmitLoadedInIdle
72 GESTimeline *timeline;
85 static guint _signals[LAST_SIGNAL] = { 0 };
87 static guint nb_projects = 0;
96 static GParamSpec *_properties[LAST_SIGNAL] = { 0 };
99 _emit_loaded_in_idle (EmitLoadedInIdle * data)
101 ges_timeline_commit (data->timeline);
102 g_signal_emit (data->project, _signals[LOADED_SIGNAL], 0, data->timeline);
104 gst_object_unref (data->project);
105 gst_object_unref (data->timeline);
106 g_slice_free (EmitLoadedInIdle, data);
112 ges_project_add_formatter (GESProject * project, GESFormatter * formatter)
114 GESProjectPrivate *priv = GES_PROJECT (project)->priv;
116 ges_formatter_set_project (formatter, project);
117 priv->formatters = g_list_append (priv->formatters, formatter);
119 gst_object_ref_sink (formatter);
123 ges_project_remove_formatter (GESProject * project, GESFormatter * formatter)
126 GESProjectPrivate *priv = GES_PROJECT (project)->priv;
128 for (tmp = priv->formatters; tmp; tmp = tmp->next) {
129 if (tmp->data == formatter) {
130 gst_object_unref (formatter);
131 priv->formatters = g_list_delete_link (priv->formatters, tmp);
139 ges_project_set_uri (GESProject * project, const gchar * uri)
141 GESProjectPrivate *priv;
143 g_return_if_fail (GES_IS_PROJECT (project));
145 priv = project->priv;
147 GST_WARNING_OBJECT (project, "Trying to rest URI, this is prohibited");
152 if (uri == NULL || !gst_uri_is_valid (uri)) {
153 GST_LOG_OBJECT (project, "Invalid URI: %s", uri);
157 priv->uri = g_strdup (uri);
159 /* We use that URI as ID */
160 ges_asset_set_id (GES_ASSET (project), uri);
166 _load_project (GESProject * project, GESTimeline * timeline, GError ** error)
169 GESProjectPrivate *priv;
170 GESFormatter *formatter;
172 priv = GES_PROJECT (project)->priv;
174 if (priv->uri == NULL) {
175 EmitLoadedInIdle *data = g_slice_new (EmitLoadedInIdle);
177 GST_LOG_OBJECT (project, "%s, Loading an empty timeline %s"
178 " as no URI set yet", GST_OBJECT_NAME (timeline),
179 ges_asset_get_id (GES_ASSET (project)));
181 data->timeline = gst_object_ref (timeline);
182 data->project = gst_object_ref (project);
184 /* Make sure the signal is emitted after the functions ends */
185 g_idle_add ((GSourceFunc) _emit_loaded_in_idle, data);
189 if (priv->formatter_asset == NULL)
190 priv->formatter_asset = _find_formatter_asset_for_uri (priv->uri);
192 if (priv->formatter_asset == NULL)
195 formatter = GES_FORMATTER (ges_asset_extract (priv->formatter_asset, &lerr));
197 GST_WARNING_OBJECT (project, "Could not create the formatter: %s",
203 ges_project_add_formatter (GES_PROJECT (project), formatter);
204 ges_formatter_load_from_uri (formatter, timeline, priv->uri, &lerr);
206 GST_WARNING_OBJECT (project, "Could not load the timeline,"
207 " returning: %s", lerr->message);
215 g_propagate_error (error, lerr);
220 _uri_missing_accumulator (GSignalInvocationHint * ihint, GValue * return_accu,
221 const GValue * handler_return, gpointer data)
223 const gchar *ret = g_value_get_string (handler_return);
225 if (ret && gst_uri_is_valid (ret)) {
226 g_value_set_string (return_accu, ret);
233 /* GESAsset vmethod implementation */
234 static GESExtractable *
235 ges_project_extract (GESAsset * project, GError ** error)
237 GESTimeline *timeline = g_object_new (GES_TYPE_TIMELINE, NULL);
239 ges_extractable_set_asset (GES_EXTRACTABLE (timeline), GES_ASSET (project));
240 if (_load_project (GES_PROJECT (project), timeline, error))
241 return GES_EXTRACTABLE (timeline);
243 gst_object_unref (timeline);
247 /* GObject vmethod implementation */
249 _dispose (GObject * object)
252 GESProjectPrivate *priv = GES_PROJECT (object)->priv;
255 g_hash_table_unref (priv->assets);
256 if (priv->loading_assets)
257 g_hash_table_unref (priv->loading_assets);
258 if (priv->loaded_with_error)
259 g_hash_table_unref (priv->loaded_with_error);
260 if (priv->formatter_asset)
261 gst_object_unref (priv->formatter_asset);
263 for (tmp = priv->formatters; tmp; tmp = tmp->next)
264 ges_project_remove_formatter (GES_PROJECT (object), tmp->data);;
266 G_OBJECT_CLASS (ges_project_parent_class)->dispose (object);
270 _finalize (GObject * object)
272 GESProjectPrivate *priv = GES_PROJECT (object)->priv;
277 G_OBJECT_CLASS (ges_project_parent_class)->finalize (object);
281 _get_property (GESProject * project, guint property_id,
282 GValue * value, GParamSpec * pspec)
284 GESProjectPrivate *priv = project->priv;
286 switch (property_id) {
288 g_value_set_string (value, priv->uri);
291 G_OBJECT_WARN_INVALID_PROPERTY_ID (project, property_id, pspec);
296 _set_property (GESProject * project, guint property_id,
297 const GValue * value, GParamSpec * pspec)
299 switch (property_id) {
301 project->priv->uri = g_value_dup_string (value);
304 G_OBJECT_WARN_INVALID_PROPERTY_ID (project, property_id, pspec);
309 ges_project_class_init (GESProjectClass * klass)
311 GObjectClass *object_class = G_OBJECT_CLASS (klass);
313 g_type_class_add_private (klass, sizeof (GESProjectPrivate));
315 klass->asset_added = NULL;
316 klass->missing_uri = NULL;
317 klass->loading_error = NULL;
318 klass->asset_removed = NULL;
319 object_class->get_property = (GObjectGetPropertyFunc) _get_property;
320 object_class->set_property = (GObjectSetPropertyFunc) _set_property;
325 * The location of the project to use.
327 _properties[PROP_URI] = g_param_spec_string ("uri", "URI",
328 "uri of the project", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
330 g_object_class_install_properties (object_class, PROP_LAST, _properties);
333 * GESProject::asset-added:
334 * @formatter: the #GESProject
335 * @asset: The #GESAsset that has been added to @project
337 _signals[ASSET_ADDED_SIGNAL] =
338 g_signal_new ("asset-added", G_TYPE_FROM_CLASS (klass),
339 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GESProjectClass, asset_added),
340 NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 1, GES_TYPE_ASSET);
343 * GESProject::asset-removed:
344 * @formatter: the #GESProject
345 * @asset: The #GESAsset that has been removed from @project
347 _signals[ASSET_REMOVED_SIGNAL] =
348 g_signal_new ("asset-removed", G_TYPE_FROM_CLASS (klass),
349 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GESProjectClass, asset_removed),
350 NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 1, GES_TYPE_ASSET);
353 * GESProject::loaded:
354 * @project: the #GESProject that is done loading a project.
355 * @timeline: The #GESTimeline that complete loading
357 _signals[LOADED_SIGNAL] =
358 g_signal_new ("loaded", G_TYPE_FROM_CLASS (klass),
359 G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GESProjectClass, loaded),
360 NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE,
361 1, GES_TYPE_TIMELINE);
364 * GESProject::missing-uri:
365 * @project: the #GESProject reporting that a file has moved
366 * @error: The error that happened
367 * @wrong_asset: The asset with the wrong ID, you should us it and its content
368 * only to find out what the new location is.
372 * source_moved_cb (GESProject *project, GError *error, GESAsset *asset_with_error)
374 * return g_strdup ("file:///the/new/uri.ogg");
378 * main (int argc, gchar ** argv)
380 * GESTimeline *timeline;
381 * GESProject *project = ges_project_new ("file:///some/uri.xges");
383 * g_signal_connect (project, "missing-uri", source_moved_cb, NULL);
384 * timeline = ges_asset_extract (GES_ASSET (project));
388 * Returns: (transfer full) (allow-none): The new URI of @wrong_asset
390 _signals[MISSING_URI_SIGNAL] =
391 g_signal_new ("missing-uri", G_TYPE_FROM_CLASS (klass),
392 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GESProjectClass, missing_uri),
393 _uri_missing_accumulator, NULL, g_cclosure_marshal_generic,
394 G_TYPE_STRING, 2, G_TYPE_ERROR, GES_TYPE_ASSET);
397 * GESProject::error-loading-asset:
398 * @project: the #GESProject on which a problem happend when creted a #GESAsset
399 * @error: The #GError defining the error that accured, might be %NULL
400 * @id: The @id of the asset that failed loading
401 * @extractable_type: The @extractable_type of the asset that
404 * Informs you that a #GESAsset could not be created. In case of
405 * missing GStreamer plugins, the error will be set to #GST_CORE_ERROR
406 * #GST_CORE_ERROR_MISSING_PLUGIN
408 _signals[ERROR_LOADING_ASSET] =
409 g_signal_new ("error-loading-asset", G_TYPE_FROM_CLASS (klass),
410 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GESProjectClass, loading_error),
411 NULL, NULL, g_cclosure_marshal_generic,
412 G_TYPE_NONE, 3, G_TYPE_ERROR, G_TYPE_STRING, G_TYPE_GTYPE);
414 object_class->dispose = _dispose;
415 object_class->dispose = _finalize;
417 GES_ASSET_CLASS (klass)->extract = ges_project_extract;
421 ges_project_init (GESProject * project)
423 GESProjectPrivate *priv = project->priv =
424 G_TYPE_INSTANCE_GET_PRIVATE (project,
425 GES_TYPE_PROJECT, GESProjectPrivate);
428 priv->formatters = NULL;
429 priv->formatter_asset = NULL;
430 priv->encoding_profiles = NULL;
431 priv->assets = g_hash_table_new_full (g_str_hash, g_str_equal,
432 g_free, gst_object_unref);
433 priv->loading_assets = g_hash_table_new_full (g_str_hash, g_str_equal,
434 g_free, gst_object_unref);
435 priv->loaded_with_error = g_hash_table_new_full (g_str_hash, g_str_equal,
440 _send_error_loading_asset (GESProject * project, GESAsset * asset,
443 const gchar *id = ges_asset_get_id (asset);
445 GST_DEBUG_OBJECT (project, "Sending error loading asset for %s", id);
446 g_hash_table_remove (project->priv->loading_assets, id);
447 g_hash_table_add (project->priv->loaded_with_error, g_strdup (id));
448 g_signal_emit (project, _signals[ERROR_LOADING_ASSET], 0, error, id,
449 ges_asset_get_extractable_type (asset));
453 ges_project_try_updating_id (GESProject * project, GESAsset * asset,
456 gchar *new_id = NULL;
459 g_return_val_if_fail (GES_IS_PROJECT (project), NULL);
460 g_return_val_if_fail (GES_IS_ASSET (asset), NULL);
461 g_return_val_if_fail (error, NULL);
463 id = ges_asset_get_id (asset);
464 GST_DEBUG_OBJECT (project, "Try to proxy %s", id);
465 if (ges_asset_request_id_update (asset, &new_id, error) == FALSE) {
466 GST_DEBUG_OBJECT (project, "Type: %s can not be proxied for id: %s "
467 "and error: %s", g_type_name (G_OBJECT_TYPE (asset)), id,
469 _send_error_loading_asset (project, asset, error);
474 if (new_id == NULL) {
475 GST_DEBUG_OBJECT (project, "Sending 'missing-uri' signal for %s", id);
476 g_signal_emit (project, _signals[MISSING_URI_SIGNAL], 0, error, asset,
481 GST_DEBUG_OBJECT (project, "new id found: %s", new_id);
482 if (!ges_asset_set_proxy (asset, new_id)) {
488 g_hash_table_remove (project->priv->loading_assets, id);
491 _send_error_loading_asset (project, asset, error);
498 new_asset_cb (GESAsset * source, GAsyncResult * res, GESProject * project)
500 GError *error = NULL;
501 gchar *possible_id = NULL;
502 GESAsset *asset = ges_asset_request_finish (res, &error);
505 possible_id = ges_project_try_updating_id (project, source, error);
507 if (possible_id == NULL)
510 ges_project_create_asset (project, possible_id,
511 ges_asset_get_extractable_type (source));
513 g_free (possible_id);
514 g_error_free (error);
518 ges_project_add_asset (project, asset);
520 gst_object_unref (asset);
524 * ges_project_set_loaded:
525 * @project: The #GESProject from which to emit the "project-loaded" signal
527 * Emits the "loaded" signal. This method should be called by sublasses when
528 * the project is fully loaded.
530 * Returns: %TRUE if the signale could be emitted %FALSE otherwize
533 ges_project_set_loaded (GESProject * project, GESFormatter * formatter)
535 GST_INFO_OBJECT (project, "Emit project loaded");
536 ges_timeline_commit (formatter->timeline);
537 g_signal_emit (project, _signals[LOADED_SIGNAL], 0, formatter->timeline);
539 /* We are now done with that formatter */
540 ges_project_remove_formatter (project, formatter);
545 ges_project_add_loading_asset (GESProject * project, GType extractable_type,
550 if ((asset = ges_asset_cache_lookup (extractable_type, id)))
551 g_hash_table_insert (project->priv->loading_assets, g_strdup (id),
552 gst_object_ref (asset));
555 /**************************************
557 * API Implementation *
559 **************************************/
562 * ges_project_create_asset:
563 * @project: A #GESProject
564 * @id: (allow-none): The id of the asset to create and add to @project
565 * @extractable_type: The #GType of the asset to create
567 * Create and add a #GESAsset to @project. You should connect to the
568 * "asset-added" signal to get the asset when it finally gets added to
571 * Returns: %TRUE if the asset started to be added %FALSE it was already
575 ges_project_create_asset (GESProject * project, const gchar * id,
576 GType extractable_type)
578 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
579 g_return_val_if_fail (g_type_is_a (extractable_type, GES_TYPE_EXTRACTABLE),
583 id = g_type_name (extractable_type);
585 if (g_hash_table_lookup (project->priv->assets, id) ||
586 g_hash_table_lookup (project->priv->loading_assets, id) ||
587 g_hash_table_lookup (project->priv->loaded_with_error, id))
590 /* TODO Add a GCancellable somewhere in our API */
591 ges_asset_request_async (extractable_type, id, NULL,
592 (GAsyncReadyCallback) new_asset_cb, project);
593 ges_project_add_loading_asset (project, extractable_type, id);
599 * ges_project_add_asset:
600 * @project: A #GESProject
601 * @asset: (transfer none): A #GESAsset to add to @project
603 * Adds a #Asset to @project, the project will keep a reference on
606 * Returns: %TRUE if the asset could be added %FALSE it was already
610 ges_project_add_asset (GESProject * project, GESAsset * asset)
612 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
614 if (g_hash_table_lookup (project->priv->assets, ges_asset_get_id (asset)))
617 g_hash_table_insert (project->priv->assets,
618 g_strdup (ges_asset_get_id (asset)), gst_object_ref (asset));
620 g_hash_table_remove (project->priv->loading_assets, ges_asset_get_id (asset));
621 GST_DEBUG_OBJECT (project, "Asset added: %s", ges_asset_get_id (asset));
622 g_signal_emit (project, _signals[ASSET_ADDED_SIGNAL], 0, asset);
628 * ges_project_remove_asset:
629 * @project: A #GESProject
630 * @asset: (transfer none): A #GESAsset to remove from @project
632 * remove a @asset to from @project.
634 * Returns: %TRUE if the asset could be removed %FALSE otherwise
637 ges_project_remove_asset (GESProject * project, GESAsset * asset)
641 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
643 ret = g_hash_table_remove (project->priv->assets, ges_asset_get_id (asset));
644 g_signal_emit (project, _signals[ASSET_REMOVED_SIGNAL], 0, asset);
650 * ges_project_get_asset:
651 * @project: A #GESProject
652 * @id: The id of the asset to retrieve
653 * @extractable_type: The extractable_type of the asset
654 * to retrieve from @object
656 * Returns: (transfer full) (allow-none): The #GESAsset with
657 * @id or %NULL if no asset with @id as an ID
660 ges_project_get_asset (GESProject * project, const gchar * id,
661 GType extractable_type)
665 g_return_val_if_fail (GES_IS_PROJECT (project), NULL);
666 g_return_val_if_fail (g_type_is_a (extractable_type, GES_TYPE_EXTRACTABLE),
669 asset = g_hash_table_lookup (project->priv->assets, id);
672 return gst_object_ref (asset);
678 * ges_project_list_assets:
679 * @project: A #GESProject
680 * @filter: Type of assets to list, #GES_TYPE_EXTRACTABLE will list
683 * List all @asset contained in @project filtering per extractable_type
684 * as defined by @filter. It copies the asset and thus will not be updated
687 * Returns: (transfer full) (element-type GESAsset): The list of
688 * #GESAsset the object contains
691 ges_project_list_assets (GESProject * project, GType filter)
697 g_return_val_if_fail (GES_IS_PROJECT (project), NULL);
699 g_hash_table_iter_init (&iter, project->priv->assets);
700 while (g_hash_table_iter_next (&iter, &key, &value)) {
701 if (g_type_is_a (ges_asset_get_extractable_type (GES_ASSET (value)),
703 ret = g_list_append (ret, gst_object_ref (value));
711 * @project: A #GESProject to save
712 * @timeline: The #GESTimeline to save, it must have been extracted from @project
713 * @uri: The uri where to save @project and @timeline
714 * @formatter_asset: (allow-none): The formatter asset to use or %NULL. If %NULL,
715 * will try to save in the same format as the one from which the timeline as been loaded
716 * or default to the formatter with highest rank
717 * @overwrite: %TRUE to overwrite file if it exists
718 * @error: (out) (allow-none): An error to be set in case something wrong happens or %NULL
720 * Save the timeline of @project to @uri. You should make sure that @timeline
721 * is one of the timelines that have been extracted from @project
722 * (using ges_asset_extract (@project);)
724 * Returns: %TRUE if the project could be save, %FALSE otherwize
727 ges_project_save (GESProject * project, GESTimeline * timeline,
728 const gchar * uri, GESAsset * formatter_asset, gboolean overwrite,
733 GESFormatter *formatter = NULL;
735 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
736 g_return_val_if_fail (formatter_asset == NULL ||
737 g_type_is_a (ges_asset_get_extractable_type (formatter_asset),
738 GES_TYPE_FORMATTER), FALSE);
739 g_return_val_if_fail ((error == NULL || *error == NULL), FALSE);
741 tl_asset = ges_extractable_get_asset (GES_EXTRACTABLE (timeline));
742 if (tl_asset == NULL && project->priv->uri == NULL) {
743 GESAsset *asset = ges_asset_cache_lookup (GES_TYPE_PROJECT, uri);
746 GST_WARNING_OBJECT (project, "Trying to save project to %s but we already"
747 "have %" GST_PTR_FORMAT " for that uri, can not save", uri, asset);
751 GST_DEBUG_OBJECT (project, "Timeline %" GST_PTR_FORMAT " has no asset"
752 " we have no uri set, so setting ourself as asset", timeline);
754 ges_extractable_set_asset (GES_EXTRACTABLE (timeline), GES_ASSET (project));
755 } else if (tl_asset != GES_ASSET (project)) {
756 GST_WARNING_OBJECT (project, "Timeline %" GST_PTR_FORMAT
757 " not created by this project can not save", timeline);
763 if (formatter_asset == NULL)
764 formatter_asset = gst_object_ref (ges_formatter_get_default ());
766 formatter = GES_FORMATTER (ges_asset_extract (formatter_asset, error));
767 if (formatter == NULL) {
768 GST_WARNING_OBJECT (project, "Could not create the formatter %p %s: %s",
769 formatter_asset, ges_asset_get_id (formatter_asset),
770 (error && *error) ? (*error)->message : "Unknown Error");
776 ges_project_add_formatter (project, formatter);
777 ret = ges_formatter_save_to_uri (formatter, timeline, uri, overwrite, error);
778 if (ret && project->priv->uri == NULL)
779 ges_project_set_uri (project, uri);
783 gst_object_unref (formatter_asset);
784 ges_project_remove_formatter (project, formatter);
791 * @uri: (allow-none): The uri to be set after creating the project.
793 * Creates a new #GESProject and sets its uri to @uri if provided. Note that
794 * if @uri is not valid or %NULL, the uri of the project will then be set
795 * the first time you save the project. If you then save the project to
796 * other locations, it will never be updated again and the first valid URI is
797 * the URI it will keep refering to.
799 * Returns: A newly created #GESProject
802 ges_project_new (const gchar * uri)
804 gchar *id = (gchar *) uri;
808 id = g_strdup_printf ("project-%i", nb_projects++);
810 project = GES_PROJECT (ges_asset_request (GES_TYPE_TIMELINE, id, NULL));
813 ges_project_set_uri (project, uri);
820 * @project: A #GESProject that has an @uri set already
821 * @timeline: A blank timeline to load @project into
822 * @error: (out) (allow-none): An error to be set in case something wrong happens or %NULL
824 * Loads @project into @timeline
826 * Returns: %TRUE if the project could be loaded %FALSE otherwize.
829 ges_project_load (GESProject * project, GESTimeline * timeline, GError ** error)
831 g_return_val_if_fail (GES_IS_TIMELINE (timeline), FALSE);
832 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
833 g_return_val_if_fail (ges_project_get_uri (project), FALSE);
834 g_return_val_if_fail (
835 (ges_extractable_get_asset (GES_EXTRACTABLE (timeline)) == NULL), FALSE);
837 if (!_load_project (project, timeline, error))
840 ges_extractable_set_asset (GES_EXTRACTABLE (timeline), GES_ASSET (project));
846 * ges_project_get_uri:
847 * @project: A #GESProject
849 * Retrieve the uri that is currently set on @project
851 * Returns: The uri that is set on @project
854 ges_project_get_uri (GESProject * project)
856 GESProjectPrivate *priv;
858 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
860 priv = project->priv;
862 return g_strdup (priv->uri);
867 * ges_project_add_encoding_profile:
868 * @project: A #GESProject
869 * @profile: A #GstEncodingProfile to add to the project. If a profile with
870 * the same name already exists, it will be replaced
872 * Adds @profile to the project. It lets you save in what format
873 * the project has been renders and keep a reference to those formats.
874 * Also, those formats will be saves to the project file when possible.
876 * Returns: %TRUE if @profile could be added, %FALSE otherwize
879 ges_project_add_encoding_profile (GESProject * project,
880 GstEncodingProfile * profile)
883 GESProjectPrivate *priv;
885 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
886 g_return_val_if_fail (GST_IS_ENCODING_PROFILE (profile), FALSE);
888 priv = project->priv;
889 for (tmp = priv->encoding_profiles; tmp; tmp = tmp->next) {
890 GstEncodingProfile *tmpprofile = GST_ENCODING_PROFILE (tmp->data);
892 if (g_strcmp0 (gst_encoding_profile_get_name (tmpprofile),
893 gst_encoding_profile_get_name (profile)) == 0) {
894 GST_INFO_OBJECT (project, "Already have profile: %s, replacing it",
895 gst_encoding_profile_get_name (profile));
897 gst_object_unref (tmp->data);
898 tmp->data = gst_object_ref (profile);
903 priv->encoding_profiles = g_list_prepend (priv->encoding_profiles,
904 gst_object_ref (profile));
910 * ges_project_list_encoding_profiles:
911 * @project: A #GESProject
913 * Lists the encoding profile that have been set to @project. The first one
914 * is the latest added.
916 * Returns: (transfer none) (element-type GstPbutils.EncodingProfile) (allow-none): The
917 * list of #GstEncodingProfile used in @project
920 ges_project_list_encoding_profiles (GESProject * project)
922 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
924 return project->priv->encoding_profiles;
928 * ges_project_get_loading_assets:
929 * @project: A #GESProject
931 * Get the assets that are being loaded
933 * Returns: (transfer full) (element-type GES.Asset): A set of loading asset
934 * that will be added to @project. Note that those Asset are *not* loaded yet,
935 * and thus can not be used
938 ges_project_get_loading_assets (GESProject * project)
945 g_return_val_if_fail (GES_IS_PROJECT (project), NULL);
947 g_hash_table_iter_init (&iter, project->priv->loading_assets);
948 while (g_hash_table_iter_next (&iter, &key, &value))
949 ret = g_list_prepend (ret, gst_object_ref (value));