mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-10-05 10:12:20 +00:00
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:
parent
2cd77406e1
commit
45c7f609da
4 changed files with 52 additions and 36 deletions
|
@ -32,8 +32,6 @@
|
||||||
*
|
*
|
||||||
* To save/load a timeline, you can use the ges_timeline_load_from_uri() and
|
* 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
|
* 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"
|
#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
|
* Returns: A new timeline if the uri was loaded successfully, or NULL if the
|
||||||
* uri could not be loaded
|
* uri could not be loaded
|
||||||
*/
|
*/
|
||||||
|
|
||||||
GESTimeline *
|
GESTimeline *
|
||||||
ges_timeline_new_from_uri (const gchar * uri, GError ** error)
|
ges_timeline_new_from_uri (const gchar * uri, GError ** error)
|
||||||
{
|
{
|
||||||
GESTimeline *ret;
|
GESTimeline *ret;
|
||||||
|
GESProject *project = ges_project_new (uri);
|
||||||
|
|
||||||
/* FIXME : we should have a GError** argument so the user can know why
|
ret = GES_TIMELINE (ges_asset_extract (GES_ASSET (project), error));
|
||||||
* it wasn't able to load the uri
|
gst_object_unref (ret);
|
||||||
*/
|
|
||||||
|
|
||||||
ret = ges_timeline_new ();
|
|
||||||
|
|
||||||
if (!ges_timeline_load_from_uri (ret, uri, error)) {
|
|
||||||
g_object_unref (ret);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ges_timeline_load_from_uri:
|
* ges_timeline_load_from_uri:
|
||||||
* @timeline: an empty #GESTimeline into which to load the formatter
|
* @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
|
* Returns: TRUE if the timeline was loaded successfully, or FALSE if the uri
|
||||||
* could not be loaded.
|
* could not be loaded.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
ges_timeline_load_from_uri (GESTimeline * timeline, const gchar * uri,
|
ges_timeline_load_from_uri (GESTimeline * timeline, const gchar * uri,
|
||||||
GError ** error)
|
GError ** error)
|
||||||
{
|
{
|
||||||
GST_FIXME ("This should be reimplemented");
|
GESProject *project;
|
||||||
return FALSE;
|
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:
|
* ges_timeline_save_to_uri:
|
||||||
* @timeline: a #GESTimeline
|
* @timeline: a #GESTimeline
|
||||||
* @uri: The location to save to
|
* @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
|
* Saves the timeline to the given location
|
||||||
*
|
*
|
||||||
* Returns: TRUE if the timeline was successfully saved to the given location,
|
* Returns: TRUE if the timeline was successfully saved to the given location,
|
||||||
* else FALSE.
|
* else FALSE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
ges_timeline_save_to_uri (GESTimeline * timeline, const gchar * uri,
|
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");
|
gboolean ret, created_proj;
|
||||||
return FALSE;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -48,6 +48,13 @@ G_BEGIN_DECLS
|
||||||
#define GES_TIMELINE_GET_TRACKS(obj) (GES_TIMELINE (obj)->tracks)
|
#define GES_TIMELINE_GET_TRACKS(obj) (GES_TIMELINE (obj)->tracks)
|
||||||
#define GES_TIMELINE_GET_LAYERS(obj) (GES_TIMELINE (obj)->layers)
|
#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;
|
typedef struct _GESTimelinePrivate GESTimelinePrivate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -95,8 +102,8 @@ GESTimeline* ges_timeline_new (void);
|
||||||
GESTimeline* ges_timeline_new_from_uri (const gchar *uri, GError **error);
|
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_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);
|
gboolean ges_timeline_add_layer (GESTimeline *timeline, GESTimelineLayer *layer);
|
||||||
GESTimelineLayer * ges_timeline_append_layer (GESTimeline * timeline);
|
GESTimelineLayer * ges_timeline_append_layer (GESTimeline * timeline);
|
||||||
gboolean ges_timeline_remove_layer (GESTimeline *timeline, GESTimelineLayer *layer);
|
gboolean ges_timeline_remove_layer (GESTimeline *timeline, GESTimelineLayer *layer);
|
||||||
|
|
|
@ -1239,7 +1239,7 @@ app_add_transition (App * app)
|
||||||
static void
|
static void
|
||||||
app_save_to_uri (App * app, gchar * uri)
|
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
|
static void
|
||||||
|
@ -1377,20 +1377,10 @@ fail:
|
||||||
static gboolean
|
static gboolean
|
||||||
load_file_async (App * app)
|
load_file_async (App * app)
|
||||||
{
|
{
|
||||||
|
ges_timeline_load_from_uri (app->timeline, app->pending_uri, NULL);
|
||||||
#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);
|
|
||||||
|
|
||||||
g_free (app->pending_uri);
|
g_free (app->pending_uri);
|
||||||
app->pending_uri = NULL;
|
app->pending_uri = NULL;
|
||||||
#endif
|
|
||||||
|
|
||||||
GST_FIXME ("This should be reimplemented");
|
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
g_error ("couldn't create uri for '%s", save_path);
|
||||||
goto failure;
|
goto failure;
|
||||||
}
|
}
|
||||||
ges_timeline_save_to_uri (timeline, uri, NULL);
|
ges_timeline_save_to_uri (timeline, uri, NULL, TRUE, NULL);
|
||||||
g_free (uri);
|
g_free (uri);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue