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 = ges_timeline_new ();
239 if (_load_project (GES_PROJECT (project), timeline, error))
240 return GES_EXTRACTABLE (timeline);
242 gst_object_unref (timeline);
246 /* GObject vmethod implementation */
248 _dispose (GObject * object)
251 GESProjectPrivate *priv = GES_PROJECT (object)->priv;
254 g_hash_table_unref (priv->assets);
255 if (priv->loading_assets)
256 g_hash_table_unref (priv->loading_assets);
257 if (priv->loaded_with_error)
258 g_hash_table_unref (priv->loaded_with_error);
259 if (priv->formatter_asset)
260 gst_object_unref (priv->formatter_asset);
262 for (tmp = priv->formatters; tmp; tmp = tmp->next)
263 ges_project_remove_formatter (GES_PROJECT (object), tmp->data);;
265 G_OBJECT_CLASS (ges_project_parent_class)->dispose (object);
269 _finalize (GObject * object)
271 GESProjectPrivate *priv = GES_PROJECT (object)->priv;
278 _get_property (GESProject * project, guint property_id,
279 GValue * value, GParamSpec * pspec)
281 GESProjectPrivate *priv = project->priv;
283 switch (property_id) {
285 g_value_set_string (value, priv->uri);
288 G_OBJECT_WARN_INVALID_PROPERTY_ID (project, property_id, pspec);
293 _set_property (GESProject * project, guint property_id,
294 const GValue * value, GParamSpec * pspec)
296 switch (property_id) {
298 project->priv->uri = g_value_dup_string (value);
301 G_OBJECT_WARN_INVALID_PROPERTY_ID (project, property_id, pspec);
306 ges_project_class_init (GESProjectClass * klass)
308 GObjectClass *object_class = G_OBJECT_CLASS (klass);
310 g_type_class_add_private (klass, sizeof (GESProjectPrivate));
312 klass->asset_added = NULL;
313 klass->missing_uri = NULL;
314 klass->loading_error = NULL;
315 klass->asset_removed = NULL;
316 object_class->get_property = (GObjectGetPropertyFunc) _get_property;
317 object_class->set_property = (GObjectSetPropertyFunc) _set_property;
322 * The location of the project to use.
324 _properties[PROP_URI] = g_param_spec_string ("uri", "URI",
325 "uri of the project", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
327 g_object_class_install_properties (object_class, PROP_LAST, _properties);
330 * GESProject::asset-added:
331 * @formatter: the #GESProject
332 * @asset: The #GESAsset that has been added to @project
334 _signals[ASSET_ADDED_SIGNAL] =
335 g_signal_new ("asset-added", G_TYPE_FROM_CLASS (klass),
336 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GESProjectClass, asset_added),
337 NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 1, GES_TYPE_ASSET);
340 * GESProject::asset-removed:
341 * @formatter: the #GESProject
342 * @asset: The #GESAsset that has been removed from @project
344 _signals[ASSET_REMOVED_SIGNAL] =
345 g_signal_new ("asset-removed", G_TYPE_FROM_CLASS (klass),
346 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GESProjectClass, asset_removed),
347 NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 1, GES_TYPE_ASSET);
350 * GESProject::loaded:
351 * @project: the #GESProject that is done loading a project.
352 * @timeline: The #GESTimeline that complete loading
354 _signals[LOADED_SIGNAL] =
355 g_signal_new ("loaded", G_TYPE_FROM_CLASS (klass),
356 G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GESProjectClass, loaded),
357 NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE,
358 1, GES_TYPE_TIMELINE);
361 * GESProject::missing-uri:
362 * @project: the #GESProject reporting that a file has moved
363 * @error: The error that happened
364 * @wrong_asset: The asset with the wrong ID, you should us it and its content
365 * only to find out what the new location is.
369 * source_moved_cb (GESProject *project, GError *error, GESAsset *asset_with_error)
371 * return g_strdup ("file:///the/new/uri.ogg");
375 * main (int argc, gchar ** argv)
377 * GESTimeline *timeline;
378 * GESProject *project = ges_project_new ("file:///some/uri.xges");
380 * g_signal_connect (project, "missing-uri", source_moved_cb, NULL);
381 * timeline = ges_asset_extract (GES_ASSET (project));
385 * Returns: (transfer full) (allow-none): The new URI of @wrong_asset
387 _signals[MISSING_URI_SIGNAL] =
388 g_signal_new ("missing-uri", G_TYPE_FROM_CLASS (klass),
389 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GESProjectClass, missing_uri),
390 _uri_missing_accumulator, NULL, g_cclosure_marshal_generic,
391 G_TYPE_STRING, 2, G_TYPE_ERROR, GES_TYPE_ASSET);
394 * GESProject::error-loading-asset:
395 * @project: the #GESProject on which a problem happend when creted a #GESAsset
396 * @error: The #GError defining the error that accured, might be %NULL
397 * @id: The @id of the asset that failed loading
398 * @extractable_type: The @extractable_type of the asset that
401 * Informs you that a #GESAsset could not be created. In case of
402 * missing GStreamer plugins, the error will be set to #GST_CORE_ERROR
403 * #GST_CORE_ERROR_MISSING_PLUGIN
405 _signals[ERROR_LOADING_ASSET] =
406 g_signal_new ("error-loading-asset", G_TYPE_FROM_CLASS (klass),
407 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GESProjectClass, loading_error),
408 NULL, NULL, g_cclosure_marshal_generic,
409 G_TYPE_NONE, 3, G_TYPE_ERROR, G_TYPE_STRING, G_TYPE_GTYPE);
411 object_class->dispose = _dispose;
412 object_class->dispose = _finalize;
414 GES_ASSET_CLASS (klass)->extract = ges_project_extract;
418 ges_project_init (GESProject * project)
420 GESProjectPrivate *priv = project->priv =
421 G_TYPE_INSTANCE_GET_PRIVATE (project,
422 GES_TYPE_PROJECT, GESProjectPrivate);
425 priv->formatters = NULL;
426 priv->formatter_asset = NULL;
427 priv->encoding_profiles = NULL;
428 priv->assets = g_hash_table_new_full (g_str_hash, g_str_equal,
429 g_free, gst_object_unref);
430 priv->loading_assets = g_hash_table_new_full (g_str_hash, g_str_equal,
431 g_free, gst_object_unref);
432 priv->loaded_with_error = g_hash_table_new_full (g_str_hash, g_str_equal,
437 _send_error_loading_asset (GESProject * project, GESAsset * asset,
440 const gchar *id = ges_asset_get_id (asset);
442 GST_DEBUG_OBJECT (project, "Sending error loading asset for %s", id);
443 g_hash_table_remove (project->priv->loading_assets, id);
444 g_hash_table_add (project->priv->loaded_with_error, g_strdup (id));
445 g_signal_emit (project, _signals[ERROR_LOADING_ASSET], 0, error, id,
446 ges_asset_get_extractable_type (asset));
450 ges_project_try_updating_id (GESProject * project, GESAsset * asset,
453 gchar *new_id = NULL;
456 g_return_val_if_fail (GES_IS_PROJECT (project), NULL);
457 g_return_val_if_fail (GES_IS_ASSET (asset), NULL);
458 g_return_val_if_fail (error, NULL);
460 id = ges_asset_get_id (asset);
461 GST_DEBUG_OBJECT (project, "Try to proxy %s", id);
462 if (ges_asset_request_id_update (asset, &new_id, error) == FALSE) {
463 GST_DEBUG_OBJECT (project, "Type: %s can not be proxied for id: %s",
464 g_type_name (G_OBJECT_TYPE (asset)), id);
465 _send_error_loading_asset (project, asset, error);
470 if (new_id == NULL) {
471 GST_DEBUG_OBJECT (project, "Sending 'missing-uri' signal for %s", id);
472 g_signal_emit (project, _signals[MISSING_URI_SIGNAL], 0, error, asset,
477 GST_DEBUG_OBJECT (project, "new id found: %s", new_id);
478 if (!ges_asset_set_proxy (asset, new_id)) {
484 g_hash_table_remove (project->priv->loading_assets, id);
487 _send_error_loading_asset (project, asset, error);
494 new_asset_cb (GESAsset * source, GAsyncResult * res, GESProject * project)
496 GError *error = NULL;
497 gchar *possible_id = NULL;
498 GESAsset *asset = ges_asset_request_finish (res, &error);
501 possible_id = ges_project_try_updating_id (project, source, error);
503 if (possible_id == NULL)
506 ges_project_create_asset (project, possible_id,
507 ges_asset_get_extractable_type (source));
509 g_free (possible_id);
510 g_error_free (error);
514 ges_project_add_asset (project, asset);
516 gst_object_unref (asset);
520 * ges_project_set_loaded:
521 * @project: The #GESProject from which to emit the "project-loaded" signal
523 * Emits the "loaded" signal. This method should be called by sublasses when
524 * the project is fully loaded.
526 * Returns: %TRUE if the signale could be emitted %FALSE otherwize
529 ges_project_set_loaded (GESProject * project, GESFormatter * formatter)
531 GST_INFO_OBJECT (project, "Emit project loaded");
532 ges_timeline_commit (formatter->timeline);
533 g_signal_emit (project, _signals[LOADED_SIGNAL], 0, formatter->timeline);
535 /* We are now done with that formatter */
536 ges_project_remove_formatter (project, formatter);
541 ges_project_add_loading_asset (GESProject * project, GType extractable_type,
546 if ((asset = ges_asset_cache_lookup (extractable_type, id)))
547 g_hash_table_insert (project->priv->loading_assets, g_strdup (id),
548 gst_object_ref (asset));
551 /**************************************
553 * API Implementation *
555 **************************************/
558 * ges_project_create_asset:
559 * @project: A #GESProject
560 * @id: (allow-none): The id of the asset to create and add to @project
561 * @extractable_type: The #GType of the asset to create
563 * Create and add a #GESAsset to @project. You should connect to the
564 * "asset-added" signal to get the asset when it finally gets added to
567 * Returns: %TRUE if the asset started to be added %FALSE it was already
571 ges_project_create_asset (GESProject * project, const gchar * id,
572 GType extractable_type)
574 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
575 g_return_val_if_fail (g_type_is_a (extractable_type, GES_TYPE_EXTRACTABLE),
579 id = g_type_name (extractable_type);
581 if (g_hash_table_lookup (project->priv->assets, id) ||
582 g_hash_table_lookup (project->priv->loading_assets, id) ||
583 g_hash_table_lookup (project->priv->loaded_with_error, id))
586 /* TODO Add a GCancellable somewhere in our API */
587 ges_asset_request_async (extractable_type, id, NULL,
588 (GAsyncReadyCallback) new_asset_cb, project);
589 ges_project_add_loading_asset (project, extractable_type, id);
595 * ges_project_add_asset:
596 * @project: A #GESProject
597 * @asset: (transfer none): A #GESAsset to add to @project
599 * Adds a #Asset to @project, the project will keep a reference on
602 * Returns: %TRUE if the asset could be added %FALSE it was already
606 ges_project_add_asset (GESProject * project, GESAsset * asset)
608 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
610 if (g_hash_table_lookup (project->priv->assets, ges_asset_get_id (asset)))
613 g_hash_table_insert (project->priv->assets,
614 g_strdup (ges_asset_get_id (asset)), gst_object_ref (asset));
616 g_hash_table_remove (project->priv->loading_assets, ges_asset_get_id (asset));
617 GST_DEBUG_OBJECT (project, "Asset added: %s", ges_asset_get_id (asset));
618 g_signal_emit (project, _signals[ASSET_ADDED_SIGNAL], 0, asset);
624 * ges_project_remove_asset:
625 * @project: A #GESProject
626 * @asset: (transfer none): A #GESAsset to remove from @project
628 * remove a @asset to from @project.
630 * Returns: %TRUE if the asset could be removed %FALSE otherwise
633 ges_project_remove_asset (GESProject * project, GESAsset * asset)
637 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
639 ret = g_hash_table_remove (project->priv->assets, ges_asset_get_id (asset));
640 g_signal_emit (project, _signals[ASSET_REMOVED_SIGNAL], 0, asset);
646 * ges_project_get_asset:
647 * @project: A #GESProject
648 * @id: The id of the asset to retrieve
649 * @extractable_type: The extractable_type of the asset
650 * to retrieve from @object
652 * Returns: (transfer full) (allow-none): The #GESAsset with
653 * @id or %NULL if no asset with @id as an ID
656 ges_project_get_asset (GESProject * project, const gchar * id,
657 GType extractable_type)
661 g_return_val_if_fail (GES_IS_PROJECT (project), NULL);
662 g_return_val_if_fail (g_type_is_a (extractable_type, GES_TYPE_EXTRACTABLE),
665 asset = g_hash_table_lookup (project->priv->assets, id);
668 return gst_object_ref (asset);
674 * ges_project_list_assets:
675 * @project: A #GESProject
676 * @filter: Type of assets to list, #GES_TYPE_EXTRACTABLE will list
679 * List all @asset contained in @project filtering per extractable_type
680 * as defined by @filter. It copies the asset and thus will not be updated
683 * Returns: (transfer full) (element-type GESAsset): The list of
684 * #GESAsset the object contains
687 ges_project_list_assets (GESProject * project, GType filter)
693 g_return_val_if_fail (GES_IS_PROJECT (project), NULL);
695 g_hash_table_iter_init (&iter, project->priv->assets);
696 while (g_hash_table_iter_next (&iter, &key, &value)) {
697 if (g_type_is_a (ges_asset_get_extractable_type (GES_ASSET (value)),
699 ret = g_list_append (ret, gst_object_ref (value));
707 * @project: A #GESProject to save
708 * @timeline: The #GESTimeline to save, it must have been extracted from @project
709 * @uri: The uri where to save @project and @timeline
710 * @formatter_asset: (allow-none): The formatter asset to use or %NULL. If %NULL,
711 * will try to save in the same format as the one from which the timeline as been loaded
712 * or default to the formatter with highest rank
713 * @overwrite: %TRUE to overwrite file if it exists
714 * @error: (out) (allow-none): An error to be set in case something wrong happens or %NULL
716 * Save the timeline of @project to @uri. You should make sure that @timeline
717 * is one of the timelines that have been extracted from @project
718 * (using ges_asset_extract (@project);)
720 * Returns: %TRUE if the project could be save, %FALSE otherwize
723 ges_project_save (GESProject * project, GESTimeline * timeline,
724 const gchar * uri, GESAsset * formatter_asset, gboolean overwrite,
729 GESFormatter *formatter = NULL;
731 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
732 g_return_val_if_fail (formatter_asset == NULL ||
733 g_type_is_a (ges_asset_get_extractable_type (formatter_asset),
734 GES_TYPE_FORMATTER), FALSE);
735 g_return_val_if_fail ((error == NULL || *error == NULL), FALSE);
737 tl_asset = ges_extractable_get_asset (GES_EXTRACTABLE (timeline));
738 if (tl_asset == NULL && project->priv->uri == NULL) {
739 GESAsset *asset = ges_asset_cache_lookup (GES_TYPE_PROJECT, uri);
742 GST_WARNING_OBJECT (project, "Trying to save project to %s but we already"
743 "have %" GST_PTR_FORMAT " for that uri, can not save", uri, asset);
747 GST_DEBUG_OBJECT (project, "Timeline %" GST_PTR_FORMAT " has no asset"
748 " we have no uri set, so setting ourself as asset", timeline);
750 ges_extractable_set_asset (GES_EXTRACTABLE (timeline), GES_ASSET (project));
751 } else if (tl_asset != GES_ASSET (project)) {
752 GST_WARNING_OBJECT (project, "Timeline %" GST_PTR_FORMAT
753 " not created by this project can not save", timeline);
759 if (formatter_asset == NULL)
760 formatter_asset = gst_object_ref (ges_formatter_get_default ());
762 formatter = GES_FORMATTER (ges_asset_extract (formatter_asset, error));
763 if (formatter == NULL) {
764 GST_WARNING_OBJECT (project, "Could not create the formatter %p %s: %s",
765 formatter_asset, ges_asset_get_id (formatter_asset),
766 (error && *error) ? (*error)->message : "Unknown Error");
772 ges_project_add_formatter (project, formatter);
773 ret = ges_formatter_save_to_uri (formatter, timeline, uri, overwrite, error);
774 if (ret && project->priv->uri == NULL)
775 ges_project_set_uri (project, uri);
779 gst_object_unref (formatter_asset);
780 ges_project_remove_formatter (project, formatter);
787 * @uri: (allow-none): The uri to be set after creating the project.
789 * Creates a new #GESProject and sets its uri to @uri if provided. Note that
790 * if @uri is not valid or %NULL, the uri of the project will then be set
791 * the first time you save the project. If you then save the project to
792 * other locations, it will never be updated again and the first valid URI is
793 * the URI it will keep refering to.
795 * Returns: A newly created #GESProject
798 ges_project_new (const gchar * uri)
800 gchar *id = (gchar *) uri;
804 id = g_strdup_printf ("project-%i", nb_projects++);
806 project = GES_PROJECT (ges_asset_request (GES_TYPE_TIMELINE, id, NULL));
809 ges_project_set_uri (project, uri);
816 * @project: A #GESProject that has an @uri set already
817 * @timeline: A blank timeline to load @project into
818 * @error: (out) (allow-none): An error to be set in case something wrong happens or %NULL
820 * Loads @project into @timeline
822 * Returns: %TRUE if the project could be loaded %FALSE otherwize.
825 ges_project_load (GESProject * project, GESTimeline * timeline, GError ** error)
827 g_return_val_if_fail (GES_IS_TIMELINE (timeline), FALSE);
828 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
829 g_return_val_if_fail (ges_project_get_uri (project), FALSE);
830 g_return_val_if_fail (
831 (ges_extractable_get_asset (GES_EXTRACTABLE (timeline)) == NULL), FALSE);
833 if (!_load_project (project, timeline, error))
836 ges_extractable_set_asset (GES_EXTRACTABLE (timeline), GES_ASSET (project));
842 * ges_project_get_uri:
843 * @project: A #GESProject
845 * Retrieve the uri that is currently set on @project
847 * Returns: The uri that is set on @project
850 ges_project_get_uri (GESProject * project)
852 GESProjectPrivate *priv;
854 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
856 priv = project->priv;
858 return g_strdup (priv->uri);
863 * ges_project_add_encoding_profile:
864 * @project: A #GESProject
865 * @profile: A #GstEncodingProfile to add to the project. If a profile with
866 * the same name already exists, it will be replaced
868 * Adds @profile to the project. It lets you save in what format
869 * the project has been renders and keep a reference to those formats.
870 * Also, those formats will be saves to the project file when possible.
872 * Returns: %TRUE if @profile could be added, %FALSE otherwize
875 ges_project_add_encoding_profile (GESProject * project,
876 GstEncodingProfile * profile)
879 GESProjectPrivate *priv;
881 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
882 g_return_val_if_fail (GST_IS_ENCODING_PROFILE (profile), FALSE);
884 priv = project->priv;
885 for (tmp = priv->encoding_profiles; tmp; tmp = tmp->next) {
886 GstEncodingProfile *tmpprofile = GST_ENCODING_PROFILE (tmp->data);
888 if (g_strcmp0 (gst_encoding_profile_get_name (tmpprofile),
889 gst_encoding_profile_get_name (profile)) == 0) {
890 GST_INFO_OBJECT (project, "Already have profile: %s, replacing it",
891 gst_encoding_profile_get_name (profile));
893 gst_object_unref (tmp->data);
894 tmp->data = gst_object_ref (profile);
899 priv->encoding_profiles = g_list_prepend (priv->encoding_profiles,
900 gst_object_ref (profile));
906 * ges_project_list_encoding_profiles:
907 * @project: A #GESProject
909 * Lists the encoding profile that have been set to @project. The first one
910 * is the latest added.
912 * Returns: (transfer none) (element-type GstPbutils.EncodingProfile) (allow-none): The
913 * list of #GstEncodingProfile used in @project
916 ges_project_list_encoding_profiles (GESProject * project)
918 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
920 return project->priv->encoding_profiles;
924 * ges_project_get_loading_assets:
925 * @project: A #GESProject
927 * Get the assets that are being loaded
929 * Returns: (transfer full) (element-type GES.Asset): A set of loading asset
930 * that will be added to @project. Note that those Asset are *not* loaded yet,
931 * and thus can not be used
934 ges_project_get_loading_assets (GESProject * project)
941 g_return_val_if_fail (GES_IS_PROJECT (project), NULL);
943 g_hash_table_iter_init (&iter, project->priv->loading_assets);
944 while (g_hash_table_iter_next (&iter, &key, &value))
945 ret = g_list_prepend (ret, gst_object_ref (value));