diff --git a/docs/libs/ges-sections.txt b/docs/libs/ges-sections.txt index b2d24e3826..599c61a644 100644 --- a/docs/libs/ges-sections.txt +++ b/docs/libs/ges-sections.txt @@ -210,7 +210,7 @@ ges_timeline_add_track ges_timeline_remove_track ges_timeline_get_track_for_pad ges_timeline_load_from_uri -ges_timeline_save +ges_timeline_save_to_uri ges_timeline_get_tracks ges_timeline_get_type @@ -443,6 +443,7 @@ GES_TIMELINE_TITLE_SOURCE_GET_CLASS GESTimelineTextOverlay GESTimelineTextOverlayClass ges_timeline_text_overlay_new +ges_timeline_new_from_uri ges_tl_text_overlay_get_type GES_IS_TIMELINE_TEXT_OVERLAY diff --git a/ges/ges-timeline.c b/ges/ges-timeline.c index ba378681cb..ce9e0271f7 100644 --- a/ges/ges-timeline.c +++ b/ges/ges-timeline.c @@ -223,41 +223,99 @@ ges_timeline_new (void) } /** - * ges_timeline_load_from_uri: - * @uri: The URI to load from + * ges_timeline_new_from_uri: + * @uri: the URI to load from * - * Creates a timeline from the contents of given uri. + * Creates a timeline from the given URI. * - * NOT_IMPLEMENTED ! - * - * Returns: A new #GESTimeline if loading was successful, else NULL. + * Returns: A new timeline if the uri was loaded successfully, or NULL if the + * uri could not be loaded */ GESTimeline * -ges_timeline_load_from_uri (gchar * uri) +ges_timeline_new_from_uri (gchar * uri) { - /* FIXME : IMPLEMENT */ - return NULL; + GESTimeline *ret; + + ret = ges_timeline_new (); + + if (!ges_timeline_load_from_uri (ret, uri)) { + g_object_unref (ret); + return NULL; + } + + return ret; +} + + +/** + * ges_timeline_load_from_uri: + * @timeline: an empty #GESTimeline into which to load the formatter + * @uri: The URI to load from + * + * Loads the contents of URI into the given timeline. + * + * 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, gchar * uri) +{ + GESFormatter *p = NULL; + gboolean ret = FALSE; + + if (!(p = ges_formatter_new_for_uri (uri))) { + GST_ERROR ("unsupported uri '%s'", uri); + goto fail; + } + + if (!ges_formatter_load_from_uri (p, timeline, uri)) { + GST_ERROR ("error deserializing formatter"); + goto fail; + } + + ret = TRUE; + +fail: + if (p) + g_object_unref (p); + return ret; } /** - * ges_timeline_save: + * ges_timeline_save_to_uri: * @timeline: a #GESTimeline * @uri: The location to save to * * Saves the timeline to the given location * - * NOT_IMPLEMENTED ! - * * Returns: TRUE if the timeline was successfully saved to the given location, * else FALSE. */ gboolean -ges_timeline_save (GESTimeline * timeline, gchar * uri) +ges_timeline_save_to_uri (GESTimeline * timeline, gchar * uri) { - /* FIXME : IMPLEMENT */ - return FALSE; + GESFormatter *p = NULL; + gboolean ret = FALSE; + + if (!(p = ges_formatter_new_for_uri (uri))) { + GST_ERROR ("unsupported uri '%s'", uri); + goto fail; + } + + if (!ges_formatter_save_to_uri (p, timeline, uri)) { + GST_ERROR ("error serializing formatter"); + goto fail; + } + + ret = TRUE; + +fail: + if (p) + g_object_unref (p); + return ret; } static void diff --git a/ges/ges-timeline.h b/ges/ges-timeline.h index a3e0eb0c8c..9cf6b28527 100644 --- a/ges/ges-timeline.h +++ b/ges/ges-timeline.h @@ -83,11 +83,10 @@ struct _GESTimelineClass { GType ges_timeline_get_type (void); GESTimeline* ges_timeline_new (void); +GESTimeline* ges_timeline_new_from_uri (gchar *uri); - -GESTimeline* ges_timeline_load_from_uri (gchar *uri); - -gboolean ges_timeline_save (GESTimeline *timeline, gchar *uri); +gboolean ges_timeline_load_from_uri (GESTimeline *timeline, gchar *uri); +gboolean ges_timeline_save_to_uri (GESTimeline *timeline, gchar *uri); gboolean ges_timeline_add_layer (GESTimeline *timeline, GESTimelineLayer *layer); gboolean ges_timeline_remove_layer (GESTimeline *timeline, GESTimelineLayer *layer);