We should give as much information as possible to the user when serialization/deserialization doesn't work.
static void ges_formatter_dispose (GObject * object);
static gboolean load_from_uri (GESFormatter * formatter, GESTimeline *
- timeline, const gchar * uri);
+ timeline, const gchar * uri, GError ** error);
static gboolean save_to_uri (GESFormatter * formatter, GESTimeline *
- timeline, const gchar * uri);
-static gboolean default_can_load_uri (const gchar * uri);
-static gboolean default_can_save_uri (const gchar * uri);
+ timeline, const gchar * uri, GError ** error);
+static gboolean default_can_load_uri (const gchar * uri, GError ** error);
+static gboolean default_can_save_uri (const gchar * uri, GError ** error);
static void discovery_error_cb (GESTimeline * timeline,
GESTimelineFileSource * tfs, GError * error, GESFormatter * formatter);
GESFormatter *
ges_formatter_new_for_uri (const gchar * uri)
{
- if (ges_formatter_can_load_uri (uri))
+ if (ges_formatter_can_load_uri (uri, NULL))
return GES_FORMATTER (ges_keyfile_formatter_new ());
return NULL;
}
}
static gboolean
-default_can_load_uri (const gchar * uri)
+default_can_load_uri (const gchar * uri, GError ** error)
{
GST_ERROR ("No 'can_load_uri' vmethod implementation");
return FALSE;
}
static gboolean
-default_can_save_uri (const gchar * uri)
+default_can_save_uri (const gchar * uri, GError ** error)
{
GST_ERROR ("No 'can_save_uri' vmethod implementation");
return FALSE;
/**
* ges_formatter_can_load_uri:
* @uri: a #gchar * pointing to the URI
+ * @error: A #GError that will be set in case of error
*
* Checks if there is a #GESFormatter available which can load a #GESTimeline
* from the given URI.
*/
gboolean
-ges_formatter_can_load_uri (const gchar * uri)
+ges_formatter_can_load_uri (const gchar * uri, GError ** error)
{
if (!(gst_uri_is_valid (uri))) {
GST_ERROR ("Invalid uri!");
/**
* ges_formatter_can_save_uri:
* @uri: a #gchar * pointing to a URI
+ * @error: A #GError that will be set in case of error
*
* Returns TRUE if there is a #GESFormatter available which can save a
* #GESTimeline to the given URI.
*/
gboolean
-ges_formatter_can_save_uri (const gchar * uri)
+ges_formatter_can_save_uri (const gchar * uri, GError ** error)
{
if (!(gst_uri_is_valid (uri))) {
GST_ERROR ("%s invalid uri!", uri);
* @formatter: a #GESFormatter
* @timeline: a #GESTimeline
* @uri: a #gchar * pointing to a URI
+ * @error: A #GError that will be set in case of error
*
* Load data from the given URI into timeline.
*
gboolean
ges_formatter_load_from_uri (GESFormatter * formatter, GESTimeline * timeline,
- const gchar * uri)
+ const gchar * uri, GError ** error)
{
gboolean ret = FALSE;
GESFormatterClass *klass = GES_FORMATTER_GET_CLASS (formatter);
if (klass->load_from_uri) {
ges_timeline_enable_update (timeline, FALSE);
formatter->timeline = timeline;
- ret = klass->load_from_uri (formatter, timeline, uri);
+ ret = klass->load_from_uri (formatter, timeline, uri, error);
ges_timeline_enable_update (timeline, TRUE);
}
static gboolean
load_from_uri (GESFormatter * formatter, GESTimeline * timeline,
- const gchar * uri)
+ const gchar * uri, GError ** error)
{
gchar *location;
GError *e = NULL;
* @formatter: a #GESFormatter
* @timeline: a #GESTimeline
* @uri: a #gchar * pointing to a URI
+ * @error: A #GError that will be set in case of error
*
* Save data from timeline to the given URI.
*
gboolean
ges_formatter_save_to_uri (GESFormatter * formatter, GESTimeline *
- timeline, const gchar * uri)
+ timeline, const gchar * uri, GError ** error)
{
GESFormatterClass *klass = GES_FORMATTER_GET_CLASS (formatter);
if (klass->save_to_uri)
- return klass->save_to_uri (formatter, timeline, uri);
+ return klass->save_to_uri (formatter, timeline, uri, error);
GST_ERROR ("not implemented!");
static gboolean
save_to_uri (GESFormatter * formatter, GESTimeline * timeline,
- const gchar * uri)
+ const gchar * uri, GError ** error)
{
gchar *location;
GError *e = NULL;
gpointer _ges_reserved[GES_PADDING - 1];
};
-typedef gboolean (*GESFormatterCanLoadURIMethod) (const gchar * uri);
-typedef gboolean (*GESFormatterCanSaveURIMethod) (const gchar * uri);
+typedef gboolean (*GESFormatterCanLoadURIMethod) (const gchar * uri, GError **error);
+typedef gboolean (*GESFormatterCanSaveURIMethod) (const gchar * uri, GError **error);
/**
* GESFormatterLoadFromURIMethod:
* else FALSE.
**/
typedef gboolean (*GESFormatterLoadFromURIMethod) (GESFormatter *formatter,
- GESTimeline *timeline,
- const gchar * uri);
+ GESTimeline *timeline,
+ const gchar * uri,
+ GError **error);
/**
* GESFormatterSaveToURIMethod:
* else FALSE.
*/
typedef gboolean (*GESFormatterSaveToURIMethod) (GESFormatter *formatter,
- GESTimeline *timeline,
- const gchar * uri);
+ GESTimeline *timeline,
+ const gchar * uri, GError **error);
typedef gboolean (*GESFormatterSaveMethod) (GESFormatter * formatter,
- GESTimeline * timeline);
+ GESTimeline * timeline);
typedef gboolean (*GESFormatterLoadMethod) (GESFormatter * formatter,
- GESTimeline * timeline);
+ GESTimeline * timeline);
/**
* GESFormatterSourceMovedMethod:
* Returns: %TRUE if the source URI could be modified properly, %FALSE otherwize.
*/
typedef gboolean (*GESFormatterSourceMovedMethod) (GESFormatter *formatter,
- GESTimelineFileSource *tfs, gchar *new_uri);
+ GESTimelineFileSource *tfs, gchar *new_uri);
/**
* GESFormatterLoadedMethod:
GESFormatter *ges_formatter_new_for_uri (const gchar *uri);
GESFormatter *ges_default_formatter_new (void);
-gboolean ges_formatter_can_load_uri (const gchar * uri);
-gboolean ges_formatter_can_save_uri (const gchar * uri);
+gboolean ges_formatter_can_load_uri (const gchar * uri, GError **error);
+gboolean ges_formatter_can_save_uri (const gchar * uri, GError **error);
gboolean ges_formatter_load_from_uri (GESFormatter * formatter,
- GESTimeline *timeline,
- const gchar *uri);
+ GESTimeline *timeline,
+ const gchar *uri,
+ GError **error);
gboolean ges_formatter_save_to_uri (GESFormatter * formatter,
- GESTimeline *timeline,
- const gchar *uri);
+ GESTimeline *timeline,
+ const gchar *uri,
+ GError **error);
gboolean
ges_formatter_update_source_uri (GESFormatter * formatter,
- GESTimelineFileSource * source, gchar * new_uri);
+ GESTimelineFileSource * source,
+ gchar * new_uri);
/*< protected >*/
gboolean
/* Non-standard methods. WILL BE DEPRECATED */
gboolean ges_formatter_load (GESFormatter * formatter,
- GESTimeline * timeline);
+ GESTimeline * timeline);
gboolean ges_formatter_save (GESFormatter * formatter,
- GESTimeline * timeline);
+ GESTimeline * timeline);
void ges_formatter_set_data (GESFormatter * formatter,
- void *data, gsize length);
+ void *data, gsize length);
void *ges_formatter_get_data (GESFormatter *formatter,
- gsize *length);
+ gsize *length);
void ges_formatter_clear_data (GESFormatter *formatter);
/* The PiTiVi etree formatter is 0.1 we set GES one to 0.2 */
#define VERSION "0.2"
+
+/* FIXME Properly set the GError when needed */
static gboolean save_pitivi_timeline_to_uri (GESFormatter * formatter,
- GESTimeline * timeline, const gchar * uri);
+ GESTimeline * timeline, const gchar * uri, GError ** error);
static gboolean load_pitivi_file_from_uri (GESFormatter * self,
- GESTimeline * timeline, const gchar * uri);
+ GESTimeline * timeline, const gchar * uri, GError ** error);
static void ges_pitivi_formatter_finalize (GObject * object);
static gboolean pitivi_formatter_update_source_uri (GESFormatter * formatter,
GESTimelineFileSource * tfs, gchar * new_uri);
{
GESFormatterClass *formatter_klass;
GObjectClass *object_class;
+
+ GST_DEBUG_CATEGORY_INIT (ges_pitivi_formatter_debug, "ges_pitivi_formatter",
+ GST_DEBUG_FG_YELLOW, "ges pitivi formatter");
+
object_class = G_OBJECT_CLASS (klass);
formatter_klass = GES_FORMATTER_CLASS (klass);
g_type_class_add_private (klass, sizeof (GESPitiviFormatterPrivate));
{
GESPitiviFormatterPrivate *priv;
- GST_DEBUG_CATEGORY_INIT (ges_pitivi_formatter_debug, "ges_pitivi_formatter",
- GST_DEBUG_FG_YELLOW, "ges pitivi formatter");
-
self->priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
GES_TYPE_PITIVI_FORMATTER, GESPitiviFormatterPrivate);
static gboolean
save_pitivi_timeline_to_uri (GESFormatter * formatter,
- GESTimeline * timeline, const gchar * uri)
+ GESTimeline * timeline, const gchar * uri, GError ** error)
{
xmlTextWriterPtr writer;
GList *list = NULL, *layers = NULL;
static gboolean
load_pitivi_file_from_uri (GESFormatter * self,
- GESTimeline * timeline, const gchar * uri)
+ GESTimeline * timeline, const gchar * uri, GError ** error)
{
xmlDocPtr doc;
GESTimelineLayer *layer;
*/
GESTimeline *
-ges_timeline_new_from_uri (const gchar * uri)
+ges_timeline_new_from_uri (const gchar * uri, GError ** error)
{
GESTimeline *ret;
ret = ges_timeline_new ();
- if (!ges_timeline_load_from_uri (ret, uri)) {
+ if (!ges_timeline_load_from_uri (ret, uri, error)) {
g_object_unref (ret);
return NULL;
}
*/
gboolean
-ges_timeline_load_from_uri (GESTimeline * timeline, const gchar * uri)
+ges_timeline_load_from_uri (GESTimeline * timeline, const gchar * uri,
+ GError ** error)
{
GESFormatter *p = NULL;
gboolean ret = FALSE;
goto fail;
}
- if (!ges_formatter_load_from_uri (p, timeline, uri)) {
+ if (!ges_formatter_load_from_uri (p, timeline, uri, error)) {
GST_ERROR ("error deserializing formatter");
goto fail;
}
*/
gboolean
-ges_timeline_save_to_uri (GESTimeline * timeline, const gchar * uri)
+ges_timeline_save_to_uri (GESTimeline * timeline, const gchar * uri,
+ GError ** error)
{
GESFormatter *p = NULL;
gboolean ret = FALSE;
* will be saved with the same one by default ? We need to make this
* easy from an API perspective */
- /* FIXME : we should have a GError** argument so the user can know why
- * it wasn't able to save
- */
-
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)) {
+ if (!ges_formatter_save_to_uri (p, timeline, uri, error)) {
GST_ERROR ("error serializing formatter");
goto fail;
}
GType ges_timeline_get_type (void);
GESTimeline* ges_timeline_new (void);
-GESTimeline* ges_timeline_new_from_uri (const gchar *uri);
+GESTimeline* ges_timeline_new_from_uri (const gchar *uri, GError **error);
-gboolean ges_timeline_load_from_uri (GESTimeline *timeline, const gchar *uri);
-gboolean ges_timeline_save_to_uri (GESTimeline *timeline, const gchar *uri);
+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_add_layer (GESTimeline *timeline, GESTimelineLayer *layer);
GESTimelineLayer * ges_timeline_append_layer (GESTimeline * timeline);
GES_TYPE_TIMELINE_STANDARD_TRANSITION;
GES_TYPE_TIMELINE_OVERLAY;
+ /* register formatter types with the system */
+ GES_TYPE_PITIVI_FORMATTER;
+ GES_TYPE_KEYFILE_FORMATTER;
+
/* check the gnonlin elements are available */
if (!ges_check_gnonlin_availability ())
return FALSE;
return;
}
- ges_formatter_load_from_uri (formatter, timeline, uri);
+ ges_formatter_load_from_uri (formatter, timeline, uri, NULL);
g_timeout_add (1000, (GSourceFunc) g_main_loop_quit, mainloop);
g_main_loop_run (mainloop);
formatter = GES_FORMATTER (ges_pitivi_formatter_new ());
- ges_formatter_save_to_uri (formatter, timeline, save_uri);
+ ges_formatter_save_to_uri (formatter, timeline, save_uri, NULL);
formatter = GES_FORMATTER (ges_pitivi_formatter_new ());
- ges_formatter_load_from_uri (formatter, expected, uri);
+ ges_formatter_load_from_uri (formatter, expected, uri, NULL);
g_timeout_add (1000, (GSourceFunc) g_main_loop_quit, mainloop);
g_main_loop_run (mainloop);
mainloop = g_main_loop_new (NULL, FALSE);
ges_timeline_pipeline_add_timeline (pipeline, timeline);
- ges_formatter_load_from_uri (formatter, timeline, uri);
+ ges_formatter_load_from_uri (formatter, timeline, uri, NULL);
ges_timeline_pipeline_set_mode (pipeline, TIMELINE_MODE_PREVIEW_VIDEO);
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);
gst_bus_add_signal_watch (bus);
static void
app_save_to_uri (App * app, gchar * uri)
{
- ges_timeline_save_to_uri (app->timeline, uri);
+ ges_timeline_save_to_uri (app->timeline, uri, NULL);
}
static void
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);
+ ges_formatter_load_from_uri (formatter, app->timeline, app->pending_uri,
+ NULL);
g_free (app->pending_uri);
app->pending_uri = NULL;
goto failure;
}
g_printf ("reading from '%s' (arguments ignored)\n", load_path);
- if (!(timeline = ges_timeline_new_from_uri (uri))) {
+ if (!(timeline = ges_timeline_new_from_uri (uri, NULL))) {
g_error ("failed to create timeline from file '%s'", load_path);
goto failure;
}
g_error ("couldn't create uri for '%s", save_path);
goto failure;
}
- ges_timeline_save_to_uri (timeline, uri);
+ ges_timeline_save_to_uri (timeline, uri, NULL);
g_free (uri);
}
mainloop = g_main_loop_new (NULL, FALSE);
ges_timeline_pipeline_add_timeline (pipeline, timeline);
- ges_formatter_load_from_uri (formatter, timeline, uri);
+ ges_formatter_load_from_uri (formatter, timeline, uri, NULL);
ges_timeline_pipeline_set_mode (pipeline, TIMELINE_MODE_PREVIEW_VIDEO);
gst_element_set_state (GST_ELEMENT (pipeline), GST_STATE_PLAYING);