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 gst_object_unref (data->project);
104 gst_object_unref (data->timeline);
105 g_slice_free (EmitLoadedInIdle, data);
111 ges_project_add_formatter (GESProject * project, GESFormatter * formatter)
113 GESProjectPrivate *priv = GES_PROJECT (project)->priv;
115 ges_formatter_set_project (formatter, project);
116 priv->formatters = g_list_append (priv->formatters, formatter);
118 gst_object_ref_sink (formatter);
122 ges_project_remove_formatter (GESProject * project, GESFormatter * formatter)
125 GESProjectPrivate *priv = GES_PROJECT (project)->priv;
127 for (tmp = priv->formatters; tmp; tmp = tmp->next) {
128 if (tmp->data == formatter) {
129 gst_object_unref (formatter);
130 priv->formatters = g_list_delete_link (priv->formatters, tmp);
138 ges_project_set_uri (GESProject * project, const gchar * uri)
140 GESProjectPrivate *priv;
142 g_return_if_fail (GES_IS_PROJECT (project));
144 priv = project->priv;
146 GST_WARNING_OBJECT (project, "Trying to rest URI, this is prohibited");
151 if (uri == NULL || !gst_uri_is_valid (uri)) {
152 GST_LOG_OBJECT (project, "Invalid URI: %s", uri);
156 priv->uri = g_strdup (uri);
158 /* We use that URI as ID */
159 ges_asset_set_id (GES_ASSET (project), uri);
165 _load_project (GESProject * project, GESTimeline * timeline, GError ** error)
168 GESProjectPrivate *priv;
169 GESFormatter *formatter;
171 priv = GES_PROJECT (project)->priv;
173 if (priv->uri == NULL) {
174 EmitLoadedInIdle *data = g_slice_new (EmitLoadedInIdle);
176 GST_LOG_OBJECT (project, "%s, Loading an empty timeline %s"
177 " as no URI set yet", GST_OBJECT_NAME (timeline),
178 ges_asset_get_id (GES_ASSET (project)));
180 data->timeline = gst_object_ref (timeline);
181 data->project = gst_object_ref (project);
183 /* Make sure the signal is emitted after the functions ends */
184 g_idle_add ((GSourceFunc) _emit_loaded_in_idle, data);
188 if (priv->formatter_asset == NULL)
189 priv->formatter_asset = _find_formatter_asset_for_uri (priv->uri);
191 if (priv->formatter_asset == NULL)
194 formatter = GES_FORMATTER (ges_asset_extract (priv->formatter_asset, &lerr));
196 GST_WARNING_OBJECT (project, "Could not create the formatter: %s",
202 ges_project_add_formatter (GES_PROJECT (project), formatter);
203 ges_formatter_load_from_uri (formatter, timeline, priv->uri, &lerr);
205 GST_WARNING_OBJECT (project, "Could not load the timeline,"
206 " returning: %s", lerr->message);
214 g_propagate_error (error, lerr);
219 _uri_missing_accumulator (GSignalInvocationHint * ihint, GValue * return_accu,
220 const GValue * handler_return, gpointer data)
222 const gchar *ret = g_value_get_string (handler_return);
224 if (ret && gst_uri_is_valid (ret)) {
225 g_value_set_string (return_accu, ret);
232 /* GESAsset vmethod implementation */
233 static GESExtractable *
234 ges_project_extract (GESAsset * project, GError ** error)
236 GESTimeline *timeline = ges_timeline_new ();
238 if (_load_project (GES_PROJECT (project), timeline, error))
239 return GES_EXTRACTABLE (timeline);
241 gst_object_unref (timeline);
245 /* GObject vmethod implementation */
247 _dispose (GObject * object)
250 GESProjectPrivate *priv = GES_PROJECT (object)->priv;
253 g_hash_table_unref (priv->assets);
254 if (priv->loading_assets)
255 g_hash_table_unref (priv->loading_assets);
256 if (priv->loaded_with_error)
257 g_hash_table_unref (priv->loaded_with_error);
258 if (priv->formatter_asset)
259 gst_object_unref (priv->formatter_asset);
261 for (tmp = priv->formatters; tmp; tmp = tmp->next)
262 ges_project_remove_formatter (GES_PROJECT (object), tmp->data);;
264 G_OBJECT_CLASS (ges_project_parent_class)->dispose (object);
268 _finalize (GObject * object)
270 GESProjectPrivate *priv = GES_PROJECT (object)->priv;
277 _get_property (GESProject * project, guint property_id,
278 GValue * value, GParamSpec * pspec)
280 GESProjectPrivate *priv = project->priv;
282 switch (property_id) {
284 g_value_set_string (value, priv->uri);
287 G_OBJECT_WARN_INVALID_PROPERTY_ID (project, property_id, pspec);
292 _set_property (GESProject * project, guint property_id,
293 const GValue * value, GParamSpec * pspec)
295 switch (property_id) {
297 project->priv->uri = g_value_dup_string (value);
300 G_OBJECT_WARN_INVALID_PROPERTY_ID (project, property_id, pspec);
305 ges_project_class_init (GESProjectClass * klass)
307 GObjectClass *object_class = G_OBJECT_CLASS (klass);
309 g_type_class_add_private (klass, sizeof (GESProjectPrivate));
311 klass->asset_added = NULL;
312 klass->missing_uri = NULL;
313 klass->loading_error = NULL;
314 klass->asset_removed = NULL;
315 object_class->get_property = (GObjectGetPropertyFunc) _get_property;
316 object_class->set_property = (GObjectSetPropertyFunc) _set_property;
321 * The location of the project to use.
323 _properties[PROP_URI] = g_param_spec_string ("uri", "URI",
324 "uri of the project", NULL, G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
326 g_object_class_install_properties (object_class, PROP_LAST, _properties);
329 * GESProject::asset-added:
330 * @formatter: the #GESProject
331 * @asset: The #GESAsset that has been added to @project
333 _signals[ASSET_ADDED_SIGNAL] =
334 g_signal_new ("asset-added", G_TYPE_FROM_CLASS (klass),
335 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GESProjectClass, asset_added),
336 NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 1, GES_TYPE_ASSET);
339 * GESProject::asset-removed:
340 * @formatter: the #GESProject
341 * @asset: The #GESAsset that has been removed from @project
343 _signals[ASSET_REMOVED_SIGNAL] =
344 g_signal_new ("asset-removed", G_TYPE_FROM_CLASS (klass),
345 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GESProjectClass, asset_removed),
346 NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE, 1, GES_TYPE_ASSET);
349 * GESProject::loaded:
350 * @project: the #GESProject that is done loading a project.
351 * @timeline: The #GESTimeline that complete loading
353 _signals[LOADED_SIGNAL] =
354 g_signal_new ("loaded", G_TYPE_FROM_CLASS (klass),
355 G_SIGNAL_RUN_FIRST, G_STRUCT_OFFSET (GESProjectClass, loaded),
356 NULL, NULL, g_cclosure_marshal_generic, G_TYPE_NONE,
357 1, GES_TYPE_TIMELINE);
360 * GESProject::missing-uri:
361 * @project: the #GESProject reporting that a file has moved
362 * @error: The error that happened
363 * @wrong_asset: The asset with the wrong ID, you should us it and its content
364 * only to find out what the new location is.
368 * source_moved_cb (GESProject *project, GError *error, const gchar *old_uri)
370 * return g_strdup ("file:///the/new/uri.ogg");
374 * main (int argc, gchar ** argv)
376 * GESTimeline *timeline;
377 * GESProject *project = ges_project_new ("file:///some/uri.xges");
379 * g_signal_connect (project, "missing-uri", source_moved_cb, NULL);
380 * timeline = ges_asset_extract (GES_ASSET (project));
384 * Returns: (transfer full) (allow-none): The new URI of @wrong_asset
386 _signals[MISSING_URI_SIGNAL] =
387 g_signal_new ("missing-uri", G_TYPE_FROM_CLASS (klass),
388 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GESProjectClass, missing_uri),
389 _uri_missing_accumulator, NULL, g_cclosure_marshal_generic,
390 G_TYPE_STRING, 2, G_TYPE_ERROR, GES_TYPE_ASSET);
393 * GESProject::error-loading-asset:
394 * @project: the #GESProject on which a problem happend when creted a #GESAsset
395 * @error: The #GError defining the error that accured, might be %NULL
396 * @id: The @id of the asset that failed loading
397 * @extractable_type: The @extractable_type of the asset that
400 * Informs you that a #GESAsset could not be created. In case of
401 * missing GStreamer plugins, the error will be set to #GST_CORE_ERROR
402 * #GST_CORE_ERROR_MISSING_PLUGIN
404 _signals[ERROR_LOADING_ASSET] =
405 g_signal_new ("error-loading-asset", G_TYPE_FROM_CLASS (klass),
406 G_SIGNAL_RUN_LAST, G_STRUCT_OFFSET (GESProjectClass, loading_error),
407 NULL, NULL, g_cclosure_marshal_generic,
408 G_TYPE_NONE, 3, G_TYPE_ERROR, G_TYPE_STRING, G_TYPE_GTYPE);
410 object_class->dispose = _dispose;
411 object_class->dispose = _finalize;
413 GES_ASSET_CLASS (klass)->extract = ges_project_extract;
417 ges_project_init (GESProject * project)
419 GESProjectPrivate *priv = project->priv =
420 G_TYPE_INSTANCE_GET_PRIVATE (project,
421 GES_TYPE_PROJECT, GESProjectPrivate);
424 priv->formatters = NULL;
425 priv->formatter_asset = NULL;
426 priv->encoding_profiles = NULL;
427 priv->assets = g_hash_table_new_full (g_str_hash, g_str_equal,
428 g_free, gst_object_unref);
429 priv->loading_assets = g_hash_table_new_full (g_str_hash, g_str_equal,
430 g_free, gst_object_unref);
431 priv->loaded_with_error = g_hash_table_new_full (g_str_hash, g_str_equal,
436 ges_project_try_updating_id (GESProject * project, GESAsset * asset,
439 gchar *new_id = NULL;
441 g_return_val_if_fail (GES_IS_PROJECT (project), NULL);
442 g_return_val_if_fail (GES_IS_ASSET (asset), NULL);
443 g_return_val_if_fail (error, NULL);
445 GST_DEBUG_OBJECT (project, "Try to proxy %s", ges_asset_get_id (asset));
446 if (ges_asset_request_id_update (asset, &new_id, error) == FALSE) {
447 GST_DEBUG_OBJECT (project, "Type: %s can not be proxied for id: %s",
448 g_type_name (G_OBJECT_TYPE (asset)), ges_asset_get_id (asset));
454 g_signal_emit (project, _signals[MISSING_URI_SIGNAL], 0, error, asset,
458 if (!ges_asset_set_proxy (asset, new_id)) {
464 g_hash_table_remove (project->priv->loading_assets, ges_asset_get_id (asset));
470 new_asset_cb (GESAsset * source, GAsyncResult * res, GESProject * project)
472 GError *error = NULL;
473 gchar *possible_id = NULL;
474 const gchar *id = ges_asset_get_id (source);
475 GESAsset *asset = ges_asset_request_finish (res, &error);
478 possible_id = ges_project_try_updating_id (project, source, error);
479 if (possible_id == NULL) {
480 g_hash_table_remove (project->priv->loading_assets, id);
481 g_hash_table_add (project->priv->loaded_with_error, g_strdup (id));
482 g_signal_emit (project, _signals[ERROR_LOADING_ASSET], 0, error, id,
483 ges_asset_get_extractable_type (source));
488 ges_project_create_asset (project, possible_id,
489 ges_asset_get_extractable_type (source));
491 g_free (possible_id);
492 g_error_free (error);
496 ges_project_add_asset (project, asset);
498 gst_object_unref (asset);
502 * ges_project_set_loaded:
503 * @project: The #GESProject from which to emit the "project-loaded" signal
505 * Emits the "loaded" signal. This method should be called by sublasses when
506 * the project is fully loaded.
508 * Returns: %TRUE if the signale could be emitted %FALSE otherwize
511 ges_project_set_loaded (GESProject * project, GESFormatter * formatter)
513 GST_INFO_OBJECT (project, "Emit project loaded");
514 g_signal_emit (project, _signals[LOADED_SIGNAL], 0, formatter->timeline);
516 /* We are now done with that formatter */
517 ges_project_remove_formatter (project, formatter);
522 ges_project_add_loading_asset (GESProject * project, GType extractable_type,
527 if ((asset = ges_asset_cache_lookup (extractable_type, id)))
528 g_hash_table_insert (project->priv->loading_assets, g_strdup (id),
529 gst_object_ref (asset));
532 /**************************************
534 * API Implementation *
536 **************************************/
539 * ges_project_create_asset:
540 * @project: A #GESProject
541 * @id: The id of the asset to create and add to @project
542 * @extractable_type: The #GType of the asset to create
544 * Create and add a #GESAsset to @project. You should connect to the
545 * "asset-added" signal to get the asset when it finally gets added to
548 * Returns: %TRUE if the asset started to be added %FALSE it was already
552 ges_project_create_asset (GESProject * project, const gchar * id,
553 GType extractable_type)
555 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
556 g_return_val_if_fail (g_type_is_a (extractable_type, GES_TYPE_EXTRACTABLE),
559 if (g_hash_table_lookup (project->priv->assets, id) ||
560 g_hash_table_lookup (project->priv->loading_assets, id) ||
561 g_hash_table_lookup (project->priv->loaded_with_error, id))
564 /* TODO Add a GCancellable somewhere in our API */
565 ges_asset_request_async (extractable_type, id, NULL,
566 (GAsyncReadyCallback) new_asset_cb, project);
567 ges_project_add_loading_asset (project, extractable_type, id);
573 * ges_project_add_asset:
574 * @project: A #GESProject
575 * @asset: (transfer none): A #GESAsset to add to @project
577 * Adds a #Asset to @project, the project will keep a reference on
580 * Returns: %TRUE if the asset could be added %FALSE it was already
584 ges_project_add_asset (GESProject * project, GESAsset * asset)
586 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
588 if (g_hash_table_lookup (project->priv->assets, ges_asset_get_id (asset)))
591 g_hash_table_insert (project->priv->assets,
592 g_strdup (ges_asset_get_id (asset)), gst_object_ref (asset));
594 g_hash_table_remove (project->priv->loading_assets, ges_asset_get_id (asset));
595 GST_DEBUG_OBJECT (project, "Asset added: %s", ges_asset_get_id (asset));
596 g_signal_emit (project, _signals[ASSET_ADDED_SIGNAL], 0, asset);
602 * ges_project_remove_asset:
603 * @project: A #GESProject
604 * @asset: (transfer none): A #GESAsset to remove from @project
606 * remove a @asset to from @project.
608 * Returns: %TRUE if the asset could be removed %FALSE otherwise
611 ges_project_remove_asset (GESProject * project, GESAsset * asset)
615 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
617 ret = g_hash_table_remove (project->priv->assets, ges_asset_get_id (asset));
618 g_signal_emit (project, _signals[ASSET_REMOVED_SIGNAL], 0, asset);
624 * ges_project_get_asset:
625 * @project: A #GESProject
626 * @id: The id of the asset to retrieve
627 * @extractable_type: The extractable_type of the asset
628 * to retrieve from @object
630 * Returns: (transfer full) (allow-none): The #GESAsset with
631 * @id or %NULL if no asset with @id as an ID
634 ges_project_get_asset (GESProject * project, const gchar * id,
635 GType extractable_type)
639 g_return_val_if_fail (GES_IS_PROJECT (project), NULL);
640 g_return_val_if_fail (g_type_is_a (extractable_type, GES_TYPE_EXTRACTABLE),
643 asset = g_hash_table_lookup (project->priv->assets, id);
646 return gst_object_ref (asset);
652 * ges_project_list_assets:
653 * @project: A #GESProject
654 * @filter: Type of assets to list, #GES_TYPE_EXTRACTABLE will list
657 * List all @asset contained in @project filtering per extractable_type
658 * as defined by @filter. It copies the asset and thus will not be updated
661 * Returns: (transfer full) (element-type GESAsset): The list of
662 * #GESAsset the object contains
665 ges_project_list_assets (GESProject * project, GType filter)
671 g_return_val_if_fail (GES_IS_PROJECT (project), NULL);
673 g_hash_table_iter_init (&iter, project->priv->assets);
674 while (g_hash_table_iter_next (&iter, &key, &value)) {
675 if (g_type_is_a (ges_asset_get_extractable_type (GES_ASSET (value)),
677 ret = g_list_append (ret, gst_object_ref (value));
685 * @project: A #GESProject to save
686 * @timeline: The #GESTimeline to save, it must have been extracted from @project
687 * @uri: The uri where to save @project and @timeline
688 * @formatter_asset: (allow-none): The formatter asset to use or %NULL. If %NULL,
689 * will try to save in the same format as the one from which the timeline as been loaded
690 * or default to the formatter with highest rank
691 * @overwrite: %TRUE to overwrite file if it exists
692 * @error: (out) (allow-none): An error to be set in case something wrong happens or %NULL
694 * Save the timeline of @project to @uri. You should make sure that @timeline
695 * is one of the timelines that have been extracted from @project
696 * (using ges_asset_extract (@project);)
698 * Returns: %TRUE if the project could be save, %FALSE otherwize
701 ges_project_save (GESProject * project, GESTimeline * timeline,
702 const gchar * uri, GESAsset * formatter_asset, gboolean overwrite,
707 GESFormatter *formatter = NULL;
709 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
710 g_return_val_if_fail (formatter_asset == NULL ||
711 g_type_is_a (ges_asset_get_extractable_type (formatter_asset),
712 GES_TYPE_FORMATTER), FALSE);
713 g_return_val_if_fail ((error == NULL || *error == NULL), FALSE);
715 tl_asset = ges_extractable_get_asset (GES_EXTRACTABLE (timeline));
716 if (tl_asset == NULL && project->priv->uri == NULL) {
717 GESAsset *asset = ges_asset_cache_lookup (GES_TYPE_PROJECT, uri);
720 GST_WARNING_OBJECT (project, "Trying to save project to %s but we already"
721 "have %" GST_PTR_FORMAT " for that uri, can not save", uri, asset);
725 GST_DEBUG_OBJECT (project, "Timeline %" GST_PTR_FORMAT " has no asset"
726 " we have no uri set, so setting ourself as asset", timeline);
728 ges_extractable_set_asset (GES_EXTRACTABLE (timeline), GES_ASSET (project));
729 } else if (tl_asset != GES_ASSET (project)) {
730 GST_WARNING_OBJECT (project, "Timeline %" GST_PTR_FORMAT
731 " not created by this project can not save", timeline);
737 if (formatter_asset == NULL)
738 formatter_asset = gst_object_ref (ges_formatter_get_default ());
740 formatter = GES_FORMATTER (ges_asset_extract (formatter_asset, error));
741 if (formatter == NULL) {
742 GST_WARNING_OBJECT (project, "Could not create the formatter %p %s: %s",
743 formatter_asset, ges_asset_get_id (formatter_asset),
744 (error && *error) ? (*error)->message : "Unknown Error");
750 ges_project_add_formatter (project, formatter);
751 ret = ges_formatter_save_to_uri (formatter, timeline, uri, overwrite, error);
752 if (ret && project->priv->uri == NULL)
753 ges_project_set_uri (project, uri);
757 gst_object_unref (formatter_asset);
758 ges_project_remove_formatter (project, formatter);
765 * @uri: (allow-none): The uri to be set after creating the project.
767 * Creates a new #GESProject and sets its uri to @uri if provided. Note that
768 * if @uri is not valid or %NULL, the uri of the project will then be set
769 * the first time you save the project. If you then save the project to
770 * other locations, it will never be updated again and the first valid URI is
771 * the URI it will keep refering to.
773 * Returns: A newly created #GESProject
776 ges_project_new (const gchar * uri)
778 gchar *id = (gchar *) uri;
782 id = g_strdup_printf ("project-%i", nb_projects++);
784 project = GES_PROJECT (ges_asset_request (GES_TYPE_TIMELINE, id, NULL));
787 ges_project_set_uri (project, uri);
794 * @project: A #GESProject that has an @uri set already
795 * @timeline: A blank timeline to load @project into
796 * @error: (out) (allow-none): An error to be set in case something wrong happens or %NULL
798 * Loads @project into @timeline
800 * Returns: %TRUE if the project could be loaded %FALSE otherwize.
803 ges_project_load (GESProject * project, GESTimeline * timeline, GError ** error)
805 g_return_val_if_fail (GES_IS_TIMELINE (timeline), FALSE);
806 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
807 g_return_val_if_fail (ges_project_get_uri (project), FALSE);
808 g_return_val_if_fail (
809 (ges_extractable_get_asset (GES_EXTRACTABLE (timeline)) == NULL), FALSE);
811 if (!_load_project (project, timeline, error))
814 ges_extractable_set_asset (GES_EXTRACTABLE (timeline), GES_ASSET (project));
820 * ges_project_get_uri:
821 * @project: A #GESProject
823 * Retrieve the uri that is currently set on @project
825 * Returns: The uri that is set on @project
828 ges_project_get_uri (GESProject * project)
830 GESProjectPrivate *priv;
832 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
834 priv = project->priv;
836 return g_strdup (priv->uri);
841 * ges_project_add_encoding_profile:
842 * @project: A #GESProject
843 * @profile: A #GstEncodingProfile to add to the project. If a profile with
844 * the same name already exists, it will be replaced
846 * Adds @profile to the project. It lets you save in what format
847 * the project has been renders and keep a reference to those formats.
848 * Also, those formats will be saves to the project file when possible.
850 * Returns: %TRUE if @profile could be added, %FALSE otherwize
853 ges_project_add_encoding_profile (GESProject * project,
854 GstEncodingProfile * profile)
857 GESProjectPrivate *priv;
859 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
860 g_return_val_if_fail (GST_IS_ENCODING_PROFILE (profile), FALSE);
862 priv = project->priv;
863 for (tmp = priv->encoding_profiles; tmp; tmp = tmp->next) {
864 GstEncodingProfile *tmpprofile = GST_ENCODING_PROFILE (tmp->data);
866 if (g_strcmp0 (gst_encoding_profile_get_name (tmpprofile),
867 gst_encoding_profile_get_name (profile)) == 0) {
868 GST_INFO_OBJECT (project, "Already have profile: %s, replacing it",
869 gst_encoding_profile_get_name (profile));
871 gst_object_unref (tmp->data);
872 tmp->data = gst_object_ref (profile);
877 priv->encoding_profiles = g_list_prepend (priv->encoding_profiles,
878 gst_object_ref (profile));
884 * ges_project_list_encoding_profiles:
885 * @project: A #GESProject
887 * Lists the encoding profile that have been set to @project. The first one
888 * is the latest added.
890 * Returns: (transfer none) (element-type GstPbutils.EncodingProfile) (allow-none): The
891 * list of #GstEncodingProfile used in @project
894 ges_project_list_encoding_profiles (GESProject * project)
896 g_return_val_if_fail (GES_IS_PROJECT (project), FALSE);
898 return project->priv->encoding_profiles;
902 * ges_project_get_loading_assets:
903 * @project: A #GESProject
905 * Get the assets that are being loaded
907 * Returns: (transfer full) (element-type GES.Asset): A set of loading asset
908 * that will be added to @project. Note that those Asset are *not* loaded yet,
909 * and thus can not be used
912 ges_project_get_loading_assets (GESProject * project)
919 g_return_val_if_fail (GES_IS_PROJECT (project), NULL);
921 g_hash_table_iter_init (&iter, project->priv->loading_assets);
922 while (g_hash_table_iter_next (&iter, &key, &value))
923 ret = g_list_prepend (ret, gst_object_ref (value));