GESTimeline: implementation of save_to/load_from uri
authorBrandon Lewis <brandon@collabora.co.uk>
Wed, 29 Sep 2010 11:43:47 +0000 (12:43 +0100)
committerEdward Hervey <edward.hervey@collabora.co.uk>
Sat, 27 Nov 2010 17:08:19 +0000 (18:08 +0100)
docs/libs/ges-sections.txt
ges/ges-timeline.c
ges/ges-timeline.h

index b2d24e3..599c61a 100644 (file)
@@ -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
 <SUBSECTION Standard>
 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
 <SUBSECTION Standard>
 ges_tl_text_overlay_get_type
 GES_IS_TIMELINE_TEXT_OVERLAY
index ba37868..ce9e027 100644 (file)
@@ -223,41 +223,99 @@ ges_timeline_new (void)
 }
 
 /**
+ * ges_timeline_new_from_uri:
+ * @uri: the URI to load from
+ *
+ * Creates a timeline from the given URI.
+ *
+ * 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 (gchar * uri)
+{
+  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
  *
- * Creates a timeline from the contents of given uri.
+ * Loads the contents of URI into the given timeline.
  *
- * NOT_IMPLEMENTED !
- *
- * Returns: A new #GESTimeline if loading was successful, else NULL.
+ * Returns: TRUE if the timeline was loaded successfully, or FALSE if the uri
+ * could not be loaded.
  */
 
-GESTimeline *
-ges_timeline_load_from_uri (gchar * uri)
+gboolean
+ges_timeline_load_from_uri (GESTimeline * timeline, gchar * uri)
 {
-  /* FIXME : IMPLEMENT */
-  return NULL;
+  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
index a3e0eb0..9cf6b28 100644 (file)
@@ -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);