timeline: Make use of the Project API for timeline saving

API:
    *  Add a formatter_type paramatter to ges_timeline_save_to_uri
This commit is contained in:
Thibault Saunier 2012-11-24 00:09:28 -03:00
parent 2cd77406e1
commit 45c7f609da
4 changed files with 52 additions and 36 deletions

View file

@ -32,8 +32,6 @@
*
* To save/load a timeline, you can use the ges_timeline_load_from_uri() and
* ges_timeline_save_to_uri() methods to use the default format. If you wish
* to specify the format to save/load the timeline from, please consult the
* documentation about #GESFormatter.
*/
#include "ges-internal.h"
@ -1653,27 +1651,18 @@ ges_timeline_new (void)
* Returns: A new timeline if the uri was loaded successfully, or NULL if the
* uri could not be loaded
*/
GESTimeline *
ges_timeline_new_from_uri (const gchar * uri, GError ** error)
{
GESTimeline *ret;
GESProject *project = ges_project_new (uri);
/* FIXME : we should have a GError** argument so the user can know why
* it wasn't able to load the uri
*/
ret = ges_timeline_new ();
if (!ges_timeline_load_from_uri (ret, uri, error)) {
g_object_unref (ret);
return NULL;
}
ret = GES_TIMELINE (ges_asset_extract (GES_ASSET (project), error));
gst_object_unref (ret);
return ret;
}
/**
* ges_timeline_load_from_uri:
* @timeline: an empty #GESTimeline into which to load the formatter
@ -1684,32 +1673,62 @@ ges_timeline_new_from_uri (const gchar * uri, GError ** error)
* Returns: TRUE if the timeline was loaded successfully, or FALSE if the uri
* could not be loaded.
*/
gboolean
ges_timeline_load_from_uri (GESTimeline * timeline, const gchar * uri,
GError ** error)
{
GST_FIXME ("This should be reimplemented");
return FALSE;
GESProject *project;
gboolean ret = FALSE;
g_return_val_if_fail (GES_IS_TIMELINE (timeline), FALSE);
g_return_val_if_fail ((ges_extractable_get_asset (GES_EXTRACTABLE
(timeline)) == NULL), FALSE);
project = ges_project_new (uri);
ret = ges_project_load (project, timeline, error);
gst_object_unref (project);
return ret;
}
/**
* ges_timeline_save_to_uri:
* @timeline: a #GESTimeline
* @uri: The location to save to
* @formatter_asset: (allow-none): The formatter asset to use or %NULL. If %NULL,
* will try to save in the same format as the one from which the timeline as been loaded
* or default to the formatter with highest rank
* @overwrite: %TRUE to overwrite file if it exists
* @error: (out) (allow-none): An error to be set in case something wrong happens or %NULL
*
* Saves the timeline to the given location
*
* Returns: TRUE if the timeline was successfully saved to the given location,
* else FALSE.
*/
gboolean
ges_timeline_save_to_uri (GESTimeline * timeline, const gchar * uri,
GError ** error)
GESAsset * formatter_asset, gboolean overwrite, GError ** error)
{
GST_FIXME ("This should be reimplemented");
return FALSE;
gboolean ret, created_proj;
GESProject *project;
g_return_val_if_fail (GES_IS_TIMELINE (timeline), FALSE);
project =
GES_PROJECT (ges_extractable_get_asset (GES_EXTRACTABLE (timeline)));
if (project == NULL) {
project = ges_project_new (NULL);
created_proj = TRUE;
}
ret = ges_project_save (project, timeline, uri, formatter_asset, overwrite,
error);
if (created_proj)
gst_object_unref (project);
return ret;
}
/**

View file

@ -48,6 +48,13 @@ G_BEGIN_DECLS
#define GES_TIMELINE_GET_TRACKS(obj) (GES_TIMELINE (obj)->tracks)
#define GES_TIMELINE_GET_LAYERS(obj) (GES_TIMELINE (obj)->layers)
/**
* ges_timeline_get_project:
*
* Helper macro to retrieve the project from which a #GESTimeline as been extracted
*/
#define ges_timeline_get_project(obj) (GES_TIMELINE (ges_extractable_get_asset (obj))
typedef struct _GESTimelinePrivate GESTimelinePrivate;
/**
@ -95,8 +102,8 @@ GESTimeline* ges_timeline_new (void);
GESTimeline* ges_timeline_new_from_uri (const gchar *uri, GError **error);
gboolean ges_timeline_load_from_uri (GESTimeline *timeline, const gchar *uri, GError **error);
gboolean ges_timeline_save_to_uri (GESTimeline *timeline, const gchar *uri, GError **error);
gboolean ges_timeline_save_to_uri (GESTimeline * timeline, const gchar * uri,
GESAsset *formatter_asset, gboolean overwrite, GError ** error);
gboolean ges_timeline_add_layer (GESTimeline *timeline, GESTimelineLayer *layer);
GESTimelineLayer * ges_timeline_append_layer (GESTimeline * timeline);
gboolean ges_timeline_remove_layer (GESTimeline *timeline, GESTimelineLayer *layer);

View file

@ -1239,7 +1239,7 @@ app_add_transition (App * app)
static void
app_save_to_uri (App * app, gchar * uri)
{
ges_timeline_save_to_uri (app->timeline, uri, NULL);
ges_timeline_save_to_uri (app->timeline, uri, NULL, FALSE, NULL);
}
static void
@ -1377,20 +1377,10 @@ fail:
static gboolean
load_file_async (App * app)
{
#if 0
GESFormatter *formatter;
g_printf ("%s\n", app->pending_uri);
formatter = ges_formatter_new_for_uri (app->pending_uri);
ges_formatter_load_from_uri (formatter, app->timeline, app->pending_uri,
NULL);
ges_timeline_load_from_uri (app->timeline, app->pending_uri, NULL);
g_free (app->pending_uri);
app->pending_uri = NULL;
#endif
GST_FIXME ("This should be reimplemented");
return FALSE;
}

View file

@ -275,7 +275,7 @@ create_pipeline (gchar * load_path, gchar * save_path, int argc, char **argv,
g_error ("couldn't create uri for '%s", save_path);
goto failure;
}
ges_timeline_save_to_uri (timeline, uri, NULL);
ges_timeline_save_to_uri (timeline, uri, NULL, TRUE, NULL);
g_free (uri);
}