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 g_signal_emit (data->project, _signals[LOADED_SIGNAL], 0, data->timeline);
103 ges_timeline_enable_update (data->timeline, TRUE);
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_timeline_enable_update (timeline, FALSE);
205 ges_formatter_load_from_uri (formatter, timeline, priv->uri, &lerr);
207 GST_WARNING_OBJECT (project, "Could not load the timeline,"
208 " returning: %s", lerr->message);
216 g_propagate_error (error, lerr);
221 _uri_missing_accumulator (GSignalInvocationHint * ihint, GValue * return_accu,
222 const GValue * handler_return, gpointer data)
224 const gchar *ret = g_value_get_string (handler_return);
226 if (ret && gst_uri_is_valid (ret)) {
227 g_value_set_string (return_accu, ret);
234 /* GESAsset vmethod implementation */
235 static GESExtractable *
236 ges_project_extract (GESAsset * project, GError ** error)
238 GESTimeline *timeline = ges_timeline_new ();
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, const gchar *old_uri)
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 ges_project_try_updating_id (GESProject * project, GESAsset * asset,
441 gchar *new_id = NULL;
443 g_return_val_if_fail (GES_IS_PROJECT (project), NULL);
444 g_return_val_if_fail (GES_IS_ASSET (asset), NULL);
445 g_return_val_if_fail (error, NULL);
447 GST_DEBUG_OBJECT (project, "Try to proxy %s", ges_asset_get_id (asset));
448 if (ges_asset_request_id_update (asset, &new_id, error) == FALSE) {
449 GST_DEBUG_OBJECT (project, "Type: %s can not be proxied for id: %s",
450 g_type_name (G_OBJECT_TYPE (asset)), ges_asset_get_id (asset));
456 g_signal_emit (project, _signals[MISSING_URI_SIGNAL], 0, error, asset,
460 if (!ges_asset_set_proxy (asset, new_id)) {
466 g_hash_table_remove (project->priv->loading_assets, ges_asset_get_id (asset));
472 new_asset_cb (GESAsset * source, GAsyncResult * res, GESProject * project)
474 GError *error = NULL;
475 gchar *possible_id = NULL;
476 const gchar *id = ges_asset_get_id (source);
477 GESAsset *asset = ges_asset_request_finish (res, &error);
480 possible_id = ges_project_try_updating_id (project, source, error);
481 if (possible_id == NULL) {
482 g_hash_table_remove (project->priv->loading_assets, id);
483 g_hash_table_add (project->priv->loaded_with_error, g_strdup (id));
484 g_signal_emit (project, _signals[ERROR_LOADING_ASSET], 0, error, id,
485 ges_asset_get_extractable_type (source));
490 ges_project_create_asset (project, possible_id,
491 ges_asset_get_extractable_type (source));
493 g_free (possible_id);
494 g_error_free (error);
498 ges_project_add_asset (project, asset);
500 gst_object_unref (asset);
504 * ges_project_set_loaded:
505 * @project: The #GESProject from which to emit the "project-loaded" signal
507 * Emits the "loaded" signal. This method should be called by sublasses when
508 * the project is fully loaded.
510 * Returns: %TRUE if the signale could be emitted %FALSE otherwize
513 ges_project_set_loaded (GESProject * project, GESFormatter * formatter)
515 GST_INFO_OBJECT (project, "Emit project loaded");
516 g_signal_emit (project, _signals[LOADED_SIGNAL], 0, formatter->timeline);
518 /* We are now done with that formatter */
519 ges_project_remove_formatter (project, formatter);
520 ges_timeline_enable_update (formatter->timeline, TRUE);
525 ges_project_add_loading_asset (GESProject * project, GType extractable_type,
530 if ((asset = ges_asset_cache_lookup (extractable_type, id)))
531 g_hash_table_insert (project->priv->loading_assets, g_strdup (id),
532 gst_object_ref (asset));
535 /**************************************
537 * API Implementation *
539 **************************************/
542 * ges_project_create_asset:
543 * @project: A #GESProject
544 * @id: (allow-none): The id of the asset to create and add to @project
545 * @extractable_type: The #GType of the asset to create
547 * Create and add a #GESAsset to @project. You should connect to the
548 * "asset-added" signal to get the asset when it finally gets added to
551 * Returns: %TRUE if the asset started to be added %FALSE it was already
555 ges_project_create_asset (GESProject * project, const gchar * id,
556 GType extractable_type)
558 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
559 g_return_val_if_fail (g_type_is_a (extractable_type, GES_TYPE_EXTRACTABLE),
563 id = g_type_name (extractable_type);
565 if (g_hash_table_lookup (project->priv->assets, id) ||
566 g_hash_table_lookup (project->priv->loading_assets, id) ||
567 g_hash_table_lookup (project->priv->loaded_with_error, id))
570 /* TODO Add a GCancellable somewhere in our API */
571 ges_asset_request_async (extractable_type, id, NULL,
572 (GAsyncReadyCallback) new_asset_cb, project);
573 ges_project_add_loading_asset (project, extractable_type, id);
579 * ges_project_add_asset:
580 * @project: A #GESProject
581 * @asset: (transfer none): A #GESAsset to add to @project
583 * Adds a #Asset to @project, the project will keep a reference on
586 * Returns: %TRUE if the asset could be added %FALSE it was already
590 ges_project_add_asset (GESProject * project, GESAsset * asset)
592 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
594 if (g_hash_table_lookup (project->priv->assets, ges_asset_get_id (asset)))
597 g_hash_table_insert (project->priv->assets,
598 g_strdup (ges_asset_get_id (asset)), gst_object_ref (asset));
600 g_hash_table_remove (project->priv->loading_assets, ges_asset_get_id (asset));
601 GST_DEBUG_OBJECT (project, "Asset added: %s", ges_asset_get_id (asset));
602 g_signal_emit (project, _signals[ASSET_ADDED_SIGNAL], 0, asset);
608 * ges_project_remove_asset:
609 * @project: A #GESProject
610 * @asset: (transfer none): A #GESAsset to remove from @project
612 * remove a @asset to from @project.
614 * Returns: %TRUE if the asset could be removed %FALSE otherwise
617 ges_project_remove_asset (GESProject * project, GESAsset * asset)
621 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
623 ret = g_hash_table_remove (project->priv->assets, ges_asset_get_id (asset));
624 g_signal_emit (project, _signals[ASSET_REMOVED_SIGNAL], 0, asset);
630 * ges_project_get_asset:
631 * @project: A #GESProject
632 * @id: The id of the asset to retrieve
633 * @extractable_type: The extractable_type of the asset
634 * to retrieve from @object
636 * Returns: (transfer full) (allow-none): The #GESAsset with
637 * @id or %NULL if no asset with @id as an ID
640 ges_project_get_asset (GESProject * project, const gchar * id,
641 GType extractable_type)
645 g_return_val_if_fail (GES_IS_PROJECT (project), NULL);
646 g_return_val_if_fail (g_type_is_a (extractable_type, GES_TYPE_EXTRACTABLE),
649 asset = g_hash_table_lookup (project->priv->assets, id);
652 return gst_object_ref (asset);
658 * ges_project_list_assets:
659 * @project: A #GESProject
660 * @filter: Type of assets to list, #GES_TYPE_EXTRACTABLE will list
663 * List all @asset contained in @project filtering per extractable_type
664 * as defined by @filter. It copies the asset and thus will not be updated
667 * Returns: (transfer full) (element-type GESAsset): The list of
668 * #GESAsset the object contains
671 ges_project_list_assets (GESProject * project, GType filter)
677 g_return_val_if_fail (GES_IS_PROJECT (project), NULL);
679 g_hash_table_iter_init (&iter, project->priv->assets);
680 while (g_hash_table_iter_next (&iter, &key, &value)) {
681 if (g_type_is_a (ges_asset_get_extractable_type (GES_ASSET (value)),
683 ret = g_list_append (ret, gst_object_ref (value));
691 * @project: A #GESProject to save
692 * @timeline: The #GESTimeline to save, it must have been extracted from @project
693 * @uri: The uri where to save @project and @timeline
694 * @formatter_asset: (allow-none): The formatter asset to use or %NULL. If %NULL,
695 * will try to save in the same format as the one from which the timeline as been loaded
696 * or default to the formatter with highest rank
697 * @overwrite: %TRUE to overwrite file if it exists
698 * @error: (out) (allow-none): An error to be set in case something wrong happens or %NULL
700 * Save the timeline of @project to @uri. You should make sure that @timeline
701 * is one of the timelines that have been extracted from @project
702 * (using ges_asset_extract (@project);)
704 * Returns: %TRUE if the project could be save, %FALSE otherwize
707 ges_project_save (GESProject * project, GESTimeline * timeline,
708 const gchar * uri, GESAsset * formatter_asset, gboolean overwrite,
713 GESFormatter *formatter = NULL;
715 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
716 g_return_val_if_fail (formatter_asset == NULL ||
717 g_type_is_a (ges_asset_get_extractable_type (formatter_asset),
718 GES_TYPE_FORMATTER), FALSE);
719 g_return_val_if_fail ((error == NULL || *error == NULL), FALSE);
721 tl_asset = ges_extractable_get_asset (GES_EXTRACTABLE (timeline));
722 if (tl_asset == NULL && project->priv->uri == NULL) {
723 GESAsset *asset = ges_asset_cache_lookup (GES_TYPE_PROJECT, uri);
726 GST_WARNING_OBJECT (project, "Trying to save project to %s but we already"
727 "have %" GST_PTR_FORMAT " for that uri, can not save", uri, asset);
731 GST_DEBUG_OBJECT (project, "Timeline %" GST_PTR_FORMAT " has no asset"
732 " we have no uri set, so setting ourself as asset", timeline);
734 ges_extractable_set_asset (GES_EXTRACTABLE (timeline), GES_ASSET (project));
735 } else if (tl_asset != GES_ASSET (project)) {
736 GST_WARNING_OBJECT (project, "Timeline %" GST_PTR_FORMAT
737 " not created by this project can not save", timeline);
743 if (formatter_asset == NULL)
744 formatter_asset = gst_object_ref (ges_formatter_get_default ());
746 formatter = GES_FORMATTER (ges_asset_extract (formatter_asset, error));
747 if (formatter == NULL) {
748 GST_WARNING_OBJECT (project, "Could not create the formatter %p %s: %s",
749 formatter_asset, ges_asset_get_id (formatter_asset),
750 (error && *error) ? (*error)->message : "Unknown Error");
756 ges_project_add_formatter (project, formatter);
757 ret = ges_formatter_save_to_uri (formatter, timeline, uri, overwrite, error);
758 if (ret && project->priv->uri == NULL)
759 ges_project_set_uri (project, uri);
763 gst_object_unref (formatter_asset);
764 ges_project_remove_formatter (project, formatter);
771 * @uri: (allow-none): The uri to be set after creating the project.
773 * Creates a new #GESProject and sets its uri to @uri if provided. Note that
774 * if @uri is not valid or %NULL, the uri of the project will then be set
775 * the first time you save the project. If you then save the project to
776 * other locations, it will never be updated again and the first valid URI is
777 * the URI it will keep refering to.
779 * Returns: A newly created #GESProject
782 ges_project_new (const gchar * uri)
784 gchar *id = (gchar *) uri;
788 id = g_strdup_printf ("project-%i", nb_projects++);
790 project = GES_PROJECT (ges_asset_request (GES_TYPE_TIMELINE, id, NULL));
793 ges_project_set_uri (project, uri);
800 * @project: A #GESProject that has an @uri set already
801 * @timeline: A blank timeline to load @project into
802 * @error: (out) (allow-none): An error to be set in case something wrong happens or %NULL
804 * Loads @project into @timeline
806 * Returns: %TRUE if the project could be loaded %FALSE otherwize.
809 ges_project_load (GESProject * project, GESTimeline * timeline, GError ** error)
811 g_return_val_if_fail (GES_IS_TIMELINE (timeline), FALSE);
812 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
813 g_return_val_if_fail (ges_project_get_uri (project), FALSE);
814 g_return_val_if_fail (
815 (ges_extractable_get_asset (GES_EXTRACTABLE (timeline)) == NULL), FALSE);
817 if (!_load_project (project, timeline, error))
820 ges_extractable_set_asset (GES_EXTRACTABLE (timeline), GES_ASSET (project));
826 * ges_project_get_uri:
827 * @project: A #GESProject
829 * Retrieve the uri that is currently set on @project
831 * Returns: The uri that is set on @project
834 ges_project_get_uri (GESProject * project)
836 GESProjectPrivate *priv;
838 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
840 priv = project->priv;
842 return g_strdup (priv->uri);
847 * ges_project_add_encoding_profile:
848 * @project: A #GESProject
849 * @profile: A #GstEncodingProfile to add to the project. If a profile with
850 * the same name already exists, it will be replaced
852 * Adds @profile to the project. It lets you save in what format
853 * the project has been renders and keep a reference to those formats.
854 * Also, those formats will be saves to the project file when possible.
856 * Returns: %TRUE if @profile could be added, %FALSE otherwize
859 ges_project_add_encoding_profile (GESProject * project,
860 GstEncodingProfile * profile)
863 GESProjectPrivate *priv;
865 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
866 g_return_val_if_fail (GST_IS_ENCODING_PROFILE (profile), FALSE);
868 priv = project->priv;
869 for (tmp = priv->encoding_profiles; tmp; tmp = tmp->next) {
870 GstEncodingProfile *tmpprofile = GST_ENCODING_PROFILE (tmp->data);
872 if (g_strcmp0 (gst_encoding_profile_get_name (tmpprofile),
873 gst_encoding_profile_get_name (profile)) == 0) {
874 GST_INFO_OBJECT (project, "Already have profile: %s, replacing it",
875 gst_encoding_profile_get_name (profile));
877 gst_object_unref (tmp->data);
878 tmp->data = gst_object_ref (profile);
883 priv->encoding_profiles = g_list_prepend (priv->encoding_profiles,
884 gst_object_ref (profile));
890 * ges_project_list_encoding_profiles:
891 * @project: A #GESProject
893 * Lists the encoding profile that have been set to @project. The first one
894 * is the latest added.
896 * Returns: (transfer none) (element-type GstPbutils.EncodingProfile) (allow-none): The
897 * list of #GstEncodingProfile used in @project
900 ges_project_list_encoding_profiles (GESProject * project)
902 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
904 return project->priv->encoding_profiles;
908 * ges_project_get_loading_assets:
909 * @project: A #GESProject
911 * Get the assets that are being loaded
913 * Returns: (transfer full) (element-type GES.Asset): A set of loading asset
914 * that will be added to @project. Note that those Asset are *not* loaded yet,
915 * and thus can not be used
918 ges_project_get_loading_assets (GESProject * project)
925 g_return_val_if_fail (GES_IS_PROJECT (project), NULL);
927 g_hash_table_iter_init (&iter, project->priv->loading_assets);
928 while (g_hash_table_iter_next (&iter, &key, &value))
929 ret = g_list_prepend (ret, gst_object_ref (value));