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;
279 _get_property (GESProject * project, guint property_id,
280 GValue * value, GParamSpec * pspec)
282 GESProjectPrivate *priv = project->priv;
284 switch (property_id) {
286 g_value_set_string (value, priv->uri);
289 G_OBJECT_WARN_INVALID_PROPERTY_ID (project, property_id, pspec);
294 _set_property (GESProject * project, guint property_id,
295 const GValue * value, GParamSpec * pspec)
297 switch (property_id) {
299 project->priv->uri = g_value_dup_string (value);
302 G_OBJECT_WARN_INVALID_PROPERTY_ID (project, property_id, pspec);
307 ges_project_class_init (GESProjectClass * klass)
309 GObjectClass *object_class = G_OBJECT_CLASS (klass);
311 g_type_class_add_private (klass, sizeof (GESProjectPrivate));
313 klass->asset_added = NULL;
314 klass->missing_uri = NULL;
315 klass->loading_error = NULL;
316 klass->asset_removed = NULL;
317 object_class->get_property = (GObjectGetPropertyFunc) _get_property;
318 object_class->set_property = (GObjectSetPropertyFunc) _set_property;
323 * The location of the project to use.
325 _properties[PROP_URI] = g_param_spec_string ("uri", "URI",
326 "uri of the project", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
328 g_object_class_install_properties (object_class, PROP_LAST, _properties);
331 * GESProject::asset-added:
332 * @formatter: the #GESProject
333 * @asset: The #GESAsset that has been added to @project
335 _signals[ASSET_ADDED_SIGNAL] =
336 g_signal_new ("asset-added", G_TYPE_FROM_CLASS (klass),
337 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GESProjectClass, asset_added),
338 NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 1, GES_TYPE_ASSET);
341 * GESProject::asset-removed:
342 * @formatter: the #GESProject
343 * @asset: The #GESAsset that has been removed from @project
345 _signals[ASSET_REMOVED_SIGNAL] =
346 g_signal_new ("asset-removed", G_TYPE_FROM_CLASS (klass),
347 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GESProjectClass, asset_removed),
348 NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 1, GES_TYPE_ASSET);
351 * GESProject::loaded:
352 * @project: the #GESProject that is done loading a project.
353 * @timeline: The #GESTimeline that complete loading
355 _signals[LOADED_SIGNAL] =
356 g_signal_new ("loaded", G_TYPE_FROM_CLASS (klass),
357 G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GESProjectClass, loaded),
358 NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE,
359 1, GES_TYPE_TIMELINE);
362 * GESProject::missing-uri:
363 * @project: the #GESProject reporting that a file has moved
364 * @error: The error that happened
365 * @wrong_asset: The asset with the wrong ID, you should us it and its content
366 * only to find out what the new location is.
370 * source_moved_cb (GESProject *project, GError *error, GESAsset *asset_with_error)
372 * return g_strdup ("file:///the/new/uri.ogg");
376 * main (int argc, gchar ** argv)
378 * GESTimeline *timeline;
379 * GESProject *project = ges_project_new ("file:///some/uri.xges");
381 * g_signal_connect (project, "missing-uri", source_moved_cb, NULL);
382 * timeline = ges_asset_extract (GES_ASSET (project));
386 * Returns: (transfer full) (allow-none): The new URI of @wrong_asset
388 _signals[MISSING_URI_SIGNAL] =
389 g_signal_new ("missing-uri", G_TYPE_FROM_CLASS (klass),
390 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GESProjectClass, missing_uri),
391 _uri_missing_accumulator, NULL, g_cclosure_marshal_generic,
392 G_TYPE_STRING, 2, G_TYPE_ERROR, GES_TYPE_ASSET);
395 * GESProject::error-loading-asset:
396 * @project: the #GESProject on which a problem happend when creted a #GESAsset
397 * @error: The #GError defining the error that accured, might be %NULL
398 * @id: The @id of the asset that failed loading
399 * @extractable_type: The @extractable_type of the asset that
402 * Informs you that a #GESAsset could not be created. In case of
403 * missing GStreamer plugins, the error will be set to #GST_CORE_ERROR
404 * #GST_CORE_ERROR_MISSING_PLUGIN
406 _signals[ERROR_LOADING_ASSET] =
407 g_signal_new ("error-loading-asset", G_TYPE_FROM_CLASS (klass),
408 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GESProjectClass, loading_error),
409 NULL, NULL, g_cclosure_marshal_generic,
410 G_TYPE_NONE, 3, G_TYPE_ERROR, G_TYPE_STRING, G_TYPE_GTYPE);
412 object_class->dispose = _dispose;
413 object_class->dispose = _finalize;
415 GES_ASSET_CLASS (klass)->extract = ges_project_extract;
419 ges_project_init (GESProject * project)
421 GESProjectPrivate *priv = project->priv =
422 G_TYPE_INSTANCE_GET_PRIVATE (project,
423 GES_TYPE_PROJECT, GESProjectPrivate);
426 priv->formatters = NULL;
427 priv->formatter_asset = NULL;
428 priv->encoding_profiles = NULL;
429 priv->assets = g_hash_table_new_full (g_str_hash, g_str_equal,
430 g_free, gst_object_unref);
431 priv->loading_assets = g_hash_table_new_full (g_str_hash, g_str_equal,
432 g_free, gst_object_unref);
433 priv->loaded_with_error = g_hash_table_new_full (g_str_hash, g_str_equal,
438 _send_error_loading_asset (GESProject * project, GESAsset * asset,
441 const gchar *id = ges_asset_get_id (asset);
443 GST_DEBUG_OBJECT (project, "Sending error loading asset for %s", id);
444 g_hash_table_remove (project->priv->loading_assets, id);
445 g_hash_table_add (project->priv->loaded_with_error, g_strdup (id));
446 g_signal_emit (project, _signals[ERROR_LOADING_ASSET], 0, error, id,
447 ges_asset_get_extractable_type (asset));
451 ges_project_try_updating_id (GESProject * project, GESAsset * asset,
454 gchar *new_id = NULL;
457 g_return_val_if_fail (GES_IS_PROJECT (project), NULL);
458 g_return_val_if_fail (GES_IS_ASSET (asset), NULL);
459 g_return_val_if_fail (error, NULL);
461 id = ges_asset_get_id (asset);
462 GST_DEBUG_OBJECT (project, "Try to proxy %s", id);
463 if (ges_asset_request_id_update (asset, &new_id, error) == FALSE) {
464 GST_DEBUG_OBJECT (project, "Type: %s can not be proxied for id: %s "
465 "and error: %s", g_type_name (G_OBJECT_TYPE (asset)), id,
467 _send_error_loading_asset (project, asset, error);
472 if (new_id == NULL) {
473 GST_DEBUG_OBJECT (project, "Sending 'missing-uri' signal for %s", id);
474 g_signal_emit (project, _signals[MISSING_URI_SIGNAL], 0, error, asset,
479 GST_DEBUG_OBJECT (project, "new id found: %s", new_id);
480 if (!ges_asset_set_proxy (asset, new_id)) {
486 g_hash_table_remove (project->priv->loading_assets, id);
489 _send_error_loading_asset (project, asset, error);
496 new_asset_cb (GESAsset * source, GAsyncResult * res, GESProject * project)
498 GError *error = NULL;
499 gchar *possible_id = NULL;
500 GESAsset *asset = ges_asset_request_finish (res, &error);
503 possible_id = ges_project_try_updating_id (project, source, error);
505 if (possible_id == NULL)
508 ges_project_create_asset (project, possible_id,
509 ges_asset_get_extractable_type (source));
511 g_free (possible_id);
512 g_error_free (error);
516 ges_project_add_asset (project, asset);
518 gst_object_unref (asset);
522 * ges_project_set_loaded:
523 * @project: The #GESProject from which to emit the "project-loaded" signal
525 * Emits the "loaded" signal. This method should be called by sublasses when
526 * the project is fully loaded.
528 * Returns: %TRUE if the signale could be emitted %FALSE otherwize
531 ges_project_set_loaded (GESProject * project, GESFormatter * formatter)
533 GST_INFO_OBJECT (project, "Emit project loaded");
534 ges_timeline_commit (formatter->timeline);
535 g_signal_emit (project, _signals[LOADED_SIGNAL], 0, formatter->timeline);
537 /* We are now done with that formatter */
538 ges_project_remove_formatter (project, formatter);
543 ges_project_add_loading_asset (GESProject * project, GType extractable_type,
548 if ((asset = ges_asset_cache_lookup (extractable_type, id)))
549 g_hash_table_insert (project->priv->loading_assets, g_strdup (id),
550 gst_object_ref (asset));
553 /**************************************
555 * API Implementation *
557 **************************************/
560 * ges_project_create_asset:
561 * @project: A #GESProject
562 * @id: (allow-none): The id of the asset to create and add to @project
563 * @extractable_type: The #GType of the asset to create
565 * Create and add a #GESAsset to @project. You should connect to the
566 * "asset-added" signal to get the asset when it finally gets added to
569 * Returns: %TRUE if the asset started to be added %FALSE it was already
573 ges_project_create_asset (GESProject * project, const gchar * id,
574 GType extractable_type)
576 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
577 g_return_val_if_fail (g_type_is_a (extractable_type, GES_TYPE_EXTRACTABLE),
581 id = g_type_name (extractable_type);
583 if (g_hash_table_lookup (project->priv->assets, id) ||
584 g_hash_table_lookup (project->priv->loading_assets, id) ||
585 g_hash_table_lookup (project->priv->loaded_with_error, id))
588 /* TODO Add a GCancellable somewhere in our API */
589 ges_asset_request_async (extractable_type, id, NULL,
590 (GAsyncReadyCallback) new_asset_cb, project);
591 ges_project_add_loading_asset (project, extractable_type, id);
597 * ges_project_add_asset:
598 * @project: A #GESProject
599 * @asset: (transfer none): A #GESAsset to add to @project
601 * Adds a #Asset to @project, the project will keep a reference on
604 * Returns: %TRUE if the asset could be added %FALSE it was already
608 ges_project_add_asset (GESProject * project, GESAsset * asset)
610 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
612 if (g_hash_table_lookup (project->priv->assets, ges_asset_get_id (asset)))
615 g_hash_table_insert (project->priv->assets,
616 g_strdup (ges_asset_get_id (asset)), gst_object_ref (asset));
618 g_hash_table_remove (project->priv->loading_assets, ges_asset_get_id (asset));
619 GST_DEBUG_OBJECT (project, "Asset added: %s", ges_asset_get_id (asset));
620 g_signal_emit (project, _signals[ASSET_ADDED_SIGNAL], 0, asset);
626 * ges_project_remove_asset:
627 * @project: A #GESProject
628 * @asset: (transfer none): A #GESAsset to remove from @project
630 * remove a @asset to from @project.
632 * Returns: %TRUE if the asset could be removed %FALSE otherwise
635 ges_project_remove_asset (GESProject * project, GESAsset * asset)
639 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
641 ret = g_hash_table_remove (project->priv->assets, ges_asset_get_id (asset));
642 g_signal_emit (project, _signals[ASSET_REMOVED_SIGNAL], 0, asset);
648 * ges_project_get_asset:
649 * @project: A #GESProject
650 * @id: The id of the asset to retrieve
651 * @extractable_type: The extractable_type of the asset
652 * to retrieve from @object
654 * Returns: (transfer full) (allow-none): The #GESAsset with
655 * @id or %NULL if no asset with @id as an ID
658 ges_project_get_asset (GESProject * project, const gchar * id,
659 GType extractable_type)
663 g_return_val_if_fail (GES_IS_PROJECT (project), NULL);
664 g_return_val_if_fail (g_type_is_a (extractable_type, GES_TYPE_EXTRACTABLE),
667 asset = g_hash_table_lookup (project->priv->assets, id);
670 return gst_object_ref (asset);
676 * ges_project_list_assets:
677 * @project: A #GESProject
678 * @filter: Type of assets to list, #GES_TYPE_EXTRACTABLE will list
681 * List all @asset contained in @project filtering per extractable_type
682 * as defined by @filter. It copies the asset and thus will not be updated
685 * Returns: (transfer full) (element-type GESAsset): The list of
686 * #GESAsset the object contains
689 ges_project_list_assets (GESProject * project, GType filter)
695 g_return_val_if_fail (GES_IS_PROJECT (project), NULL);
697 g_hash_table_iter_init (&iter, project->priv->assets);
698 while (g_hash_table_iter_next (&iter, &key, &value)) {
699 if (g_type_is_a (ges_asset_get_extractable_type (GES_ASSET (value)),
701 ret = g_list_append (ret, gst_object_ref (value));
709 * @project: A #GESProject to save
710 * @timeline: The #GESTimeline to save, it must have been extracted from @project
711 * @uri: The uri where to save @project and @timeline
712 * @formatter_asset: (allow-none): The formatter asset to use or %NULL. If %NULL,
713 * will try to save in the same format as the one from which the timeline as been loaded
714 * or default to the formatter with highest rank
715 * @overwrite: %TRUE to overwrite file if it exists
716 * @error: (out) (allow-none): An error to be set in case something wrong happens or %NULL
718 * Save the timeline of @project to @uri. You should make sure that @timeline
719 * is one of the timelines that have been extracted from @project
720 * (using ges_asset_extract (@project);)
722 * Returns: %TRUE if the project could be save, %FALSE otherwize
725 ges_project_save (GESProject * project, GESTimeline * timeline,
726 const gchar * uri, GESAsset * formatter_asset, gboolean overwrite,
731 GESFormatter *formatter = NULL;
733 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
734 g_return_val_if_fail (formatter_asset == NULL ||
735 g_type_is_a (ges_asset_get_extractable_type (formatter_asset),
736 GES_TYPE_FORMATTER), FALSE);
737 g_return_val_if_fail ((error == NULL || *error == NULL), FALSE);
739 tl_asset = ges_extractable_get_asset (GES_EXTRACTABLE (timeline));
740 if (tl_asset == NULL && project->priv->uri == NULL) {
741 GESAsset *asset = ges_asset_cache_lookup (GES_TYPE_PROJECT, uri);
744 GST_WARNING_OBJECT (project, "Trying to save project to %s but we already"
745 "have %" GST_PTR_FORMAT " for that uri, can not save", uri, asset);
749 GST_DEBUG_OBJECT (project, "Timeline %" GST_PTR_FORMAT " has no asset"
750 " we have no uri set, so setting ourself as asset", timeline);
752 ges_extractable_set_asset (GES_EXTRACTABLE (timeline), GES_ASSET (project));
753 } else if (tl_asset != GES_ASSET (project)) {
754 GST_WARNING_OBJECT (project, "Timeline %" GST_PTR_FORMAT
755 " not created by this project can not save", timeline);
761 if (formatter_asset == NULL)
762 formatter_asset = gst_object_ref (ges_formatter_get_default ());
764 formatter = GES_FORMATTER (ges_asset_extract (formatter_asset, error));
765 if (formatter == NULL) {
766 GST_WARNING_OBJECT (project, "Could not create the formatter %p %s: %s",
767 formatter_asset, ges_asset_get_id (formatter_asset),
768 (error && *error) ? (*error)->message : "Unknown Error");
774 ges_project_add_formatter (project, formatter);
775 ret = ges_formatter_save_to_uri (formatter, timeline, uri, overwrite, error);
776 if (ret && project->priv->uri == NULL)
777 ges_project_set_uri (project, uri);
781 gst_object_unref (formatter_asset);
782 ges_project_remove_formatter (project, formatter);
789 * @uri: (allow-none): The uri to be set after creating the project.
791 * Creates a new #GESProject and sets its uri to @uri if provided. Note that
792 * if @uri is not valid or %NULL, the uri of the project will then be set
793 * the first time you save the project. If you then save the project to
794 * other locations, it will never be updated again and the first valid URI is
795 * the URI it will keep refering to.
797 * Returns: A newly created #GESProject
800 ges_project_new (const gchar * uri)
802 gchar *id = (gchar *) uri;
806 id = g_strdup_printf ("project-%i", nb_projects++);
808 project = GES_PROJECT (ges_asset_request (GES_TYPE_TIMELINE, id, NULL));
811 ges_project_set_uri (project, uri);
818 * @project: A #GESProject that has an @uri set already
819 * @timeline: A blank timeline to load @project into
820 * @error: (out) (allow-none): An error to be set in case something wrong happens or %NULL
822 * Loads @project into @timeline
824 * Returns: %TRUE if the project could be loaded %FALSE otherwize.
827 ges_project_load (GESProject * project, GESTimeline * timeline, GError ** error)
829 g_return_val_if_fail (GES_IS_TIMELINE (timeline), FALSE);
830 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
831 g_return_val_if_fail (ges_project_get_uri (project), FALSE);
832 g_return_val_if_fail (
833 (ges_extractable_get_asset (GES_EXTRACTABLE (timeline)) == NULL), FALSE);
835 if (!_load_project (project, timeline, error))
838 ges_extractable_set_asset (GES_EXTRACTABLE (timeline), GES_ASSET (project));
844 * ges_project_get_uri:
845 * @project: A #GESProject
847 * Retrieve the uri that is currently set on @project
849 * Returns: The uri that is set on @project
852 ges_project_get_uri (GESProject * project)
854 GESProjectPrivate *priv;
856 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
858 priv = project->priv;
860 return g_strdup (priv->uri);
865 * ges_project_add_encoding_profile:
866 * @project: A #GESProject
867 * @profile: A #GstEncodingProfile to add to the project. If a profile with
868 * the same name already exists, it will be replaced
870 * Adds @profile to the project. It lets you save in what format
871 * the project has been renders and keep a reference to those formats.
872 * Also, those formats will be saves to the project file when possible.
874 * Returns: %TRUE if @profile could be added, %FALSE otherwize
877 ges_project_add_encoding_profile (GESProject * project,
878 GstEncodingProfile * profile)
881 GESProjectPrivate *priv;
883 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
884 g_return_val_if_fail (GST_IS_ENCODING_PROFILE (profile), FALSE);
886 priv = project->priv;
887 for (tmp = priv->encoding_profiles; tmp; tmp = tmp->next) {
888 GstEncodingProfile *tmpprofile = GST_ENCODING_PROFILE (tmp->data);
890 if (g_strcmp0 (gst_encoding_profile_get_name (tmpprofile),
891 gst_encoding_profile_get_name (profile)) == 0) {
892 GST_INFO_OBJECT (project, "Already have profile: %s, replacing it",
893 gst_encoding_profile_get_name (profile));
895 gst_object_unref (tmp->data);
896 tmp->data = gst_object_ref (profile);
901 priv->encoding_profiles = g_list_prepend (priv->encoding_profiles,
902 gst_object_ref (profile));
908 * ges_project_list_encoding_profiles:
909 * @project: A #GESProject
911 * Lists the encoding profile that have been set to @project. The first one
912 * is the latest added.
914 * Returns: (transfer none) (element-type GstPbutils.EncodingProfile) (allow-none): The
915 * list of #GstEncodingProfile used in @project
918 ges_project_list_encoding_profiles (GESProject * project)
920 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
922 return project->priv->encoding_profiles;
926 * ges_project_get_loading_assets:
927 * @project: A #GESProject
929 * Get the assets that are being loaded
931 * Returns: (transfer full) (element-type GES.Asset): A set of loading asset
932 * that will be added to @project. Note that those Asset are *not* loaded yet,
933 * and thus can not be used
936 ges_project_get_loading_assets (GESProject * project)
943 g_return_val_if_fail (GES_IS_PROJECT (project), NULL);
945 g_hash_table_iter_init (&iter, project->priv->loading_assets);
946 while (g_hash_table_iter_next (&iter, &key, &value))
947 ret = g_list_prepend (ret, gst_object_ref (value));