[gnac/devel: 1/5] Partial refactoring Need some bugfixes



commit f11edb34632c2592ebf7d5dda87d773346f416d9
Author: David Joaquim <djoaquim src gnome org>
Date:   Tue Jan 12 18:45:05 2010 +0100

    Partial refactoring
    Need some bugfixes

 libgnac/Makefile.am         |    5 +
 libgnac/libgnac-converter.c |  342 +++++++++++++++----------------------------
 libgnac/libgnac-converter.h |   45 +------
 libgnac/libgnac-gst.c       |  288 ++++++------------------------------
 libgnac/libgnac-gst.h       |   60 +-------
 libgnac/libgnac-metadata.c  |   14 +-
 libgnac/libgnac-output.c    |   16 +-
 libgnac/libgnac-output.h    |    3 +-
 8 files changed, 202 insertions(+), 571 deletions(-)
---
diff --git a/libgnac/Makefile.am b/libgnac/Makefile.am
index 6280cc4..786816b 100644
--- a/libgnac/Makefile.am
+++ b/libgnac/Makefile.am
@@ -4,8 +4,13 @@ libgnac_la_SOURCES = \
 	libgnac-metadata-tags.h \
 	libgnac-metadata.h \
 	libgnac-metadata.c \
+	libgnac-profile.h \
+	libgnac-gst-utils.h \
+	libgnac-gst-utils.c \
 	libgnac-gst.h \
 	libgnac-gst.c \
+  libgnac-media-item.h \
+  libgnac-media-item.c \
 	libgnac-converter.h \
 	libgnac-converter.c \
 	libgnac-output.h \
diff --git a/libgnac/libgnac-converter.c b/libgnac/libgnac-converter.c
index ac71591..1a5196a 100644
--- a/libgnac/libgnac-converter.c
+++ b/libgnac/libgnac-converter.c
@@ -30,12 +30,15 @@
 #include <glib/gi18n.h>
 
 #include "libgnac-converter.h"
+#include "libgnac-profile.h"
 #include "libgnac-debug.h"
 #include "libgnac-error.h"
 #include "libgnac-gst.h"
 #include "libgnac-marshallers.h"
 #include "libgnac-output.h"
 
+
+// TODO add WARNING and PAUSED, and RESUMED ?
 enum 
 {
   OVERWRITE,
@@ -75,15 +78,13 @@ struct LibgnacConverterPrivate
   GQueue               *queue;
   GQueue               *queue_copy;
   //GHashTableIter        iter;
-  LibgnacConverterItem *current;
+  LibgnacMediaItem     *current;
   gint                  n_converted;
   guint64               elapsed_duration;
   guint64               total_duration;
 
   gboolean              strip_special;
-  gchar                *audio_description;
-  gchar                *muxer_description;
-  gchar                *video_description;
+  LibgnacProfile       *profile;
   gchar                *rename_pattern;
   gint                  folder_type;
   gchar                *folder_hierarchy;
@@ -114,17 +115,22 @@ libgnac_converter_init(LibgnacConverter *self)
   priv->queue = g_queue_new();
   priv->queue_copy = NULL;
 
+  /* TODO replace this when profiles */
   priv->file_table = g_hash_table_new_full(g_str_hash, 
         g_str_equal, 
         g_free, 
-        (GDestroyNotify)libgnac_converter_item_free);
+        (GDestroyNotify)libgnac_item_free);
+
+  priv->profile = (LibgnacProfile*)g_malloc(sizeof(LibgnacProfile));
+  priv->profile->audio_desc = NULL;
+  priv->profile->video_desc = NULL;
+  priv->profile->muxer_desc = NULL;
 
   priv->current = NULL;
   priv->n_converted = -1;
   priv->total_duration = 0;
   priv->elapsed_duration = 0;
 
-  priv->audio_description = NULL;
   priv->folder_path = NULL;
   priv->extension = NULL;
   priv->rename_pattern = NULL;
@@ -160,8 +166,20 @@ libgnac_converter_finalize(GObject *gobject)
 {
   LibgnacConverter *self = LIBGNAC_CONVERTER(gobject);
 
-  if (self->priv->audio_description) {
-    g_free(self->priv->audio_description);
+  if (self->priv->profile->audio_desc) {
+    g_free(self->priv->profile->audio_desc);
+  }
+
+  if (self->priv->profile->muxer_desc) {
+    g_free(self->priv->profile->muxer_desc);
+  }
+
+  if (self->priv->profile->video_desc) {
+    g_free(self->priv->profile->video_desc);
+  }
+
+  if (self->priv->profile) {
+    g_free(self->priv->profile);
   }
 
   if (self->priv->extension) {
@@ -190,15 +208,15 @@ libgnac_converter_get_property(GObject    *object,
   switch (property_id) 
   {
     case PROP_AUDIO_PIPELINE_DESC:
-      g_value_set_string(value, self->priv->audio_description);
+      g_value_set_string(value, self->priv->profile->audio_desc);
     break;
 
     case PROP_MUXER_PIPELINE_DESC:
-      g_value_set_string(value, self->priv->muxer_description);
+      g_value_set_string(value, self->priv->profile->muxer_desc);
     break;
 
     case PROP_VIDEO_PIPELINE_DESC:
-      g_value_set_string(value, self->priv->video_description);
+      g_value_set_string(value, self->priv->profile->video_desc);
     break;
 
     case PROP_STRIP_SPECIAL:
@@ -248,21 +266,21 @@ libgnac_converter_set_property(GObject      *object,
   switch (property_id) 
   {
     case PROP_AUDIO_PIPELINE_DESC:
-      g_free(self->priv->audio_description);
-      self->priv->audio_description = NULL;
-      self->priv->audio_description = g_value_dup_string(value);
+      g_free(self->priv->profile->audio_desc);
+      self->priv->profile->audio_desc = NULL;
+      self->priv->profile->audio_desc = g_value_dup_string(value);
     break;
 
     case PROP_MUXER_PIPELINE_DESC:
-      g_free(self->priv->muxer_description);
-      self->priv->muxer_description = NULL;
-      self->priv->muxer_description = g_value_dup_string(value);
+      g_free(self->priv->profile->muxer_desc);
+      self->priv->profile->muxer_desc = NULL;
+      self->priv->profile->muxer_desc = g_value_dup_string(value);
     break;
 
     case PROP_VIDEO_PIPELINE_DESC:
-      g_free(self->priv->video_description);
-      self->priv->video_description = NULL;
-      self->priv->video_description = g_value_dup_string(value);
+      g_free(self->priv->profile->video_desc);
+      self->priv->profile->video_desc = NULL;
+      self->priv->profile->video_desc = g_value_dup_string(value);
     break;
 
     case PROP_STRIP_SPECIAL:
@@ -540,7 +558,7 @@ libgnac_converter_start_next(LibgnacConverter *self)
 {
   LibgnacConverterPrivate *priv;
   GError *err = NULL;
-  LibgnacConverterItem *item = NULL;
+  LibgnacMediaItem        *item = NULL;
   gchar *key = NULL;
   gchar *uri = NULL;
 
@@ -572,9 +590,9 @@ libgnac_converter_start_next(LibgnacConverter *self)
 
     g_signal_emit(self, signals[FILE_STARTED], 0, uri);
     libgnac_info("File started %s", uri);
-    libgnac_converter_item_run(item, &err);
+    libgnac_item_run(item, &err);
     if (err)  {
-      g_signal_emit(item->converter, signals[ERROR], 0, uri, err->message, err);
+      g_signal_emit(self, signals[ERROR], 0, uri, err->message, err);
     }
 
     // TODO why not retrieveing error ?
@@ -607,7 +625,7 @@ libgnac_converter_restart_current(LibgnacConverter *self)
 
   if (priv->current) 
   {
-      libgnac_converter_item_run(priv->current, &err);
+      libgnac_item_run(priv->current, &err);
       if (err) {
         g_clear_error(&err);
         return FALSE;
@@ -634,7 +652,7 @@ libgnac_converter_add(LibgnacConverter  *self,
                       GError           **error)
 {
   LibgnacConverterPrivate *priv;
-  LibgnacConverterItem *item;
+  LibgnacMediaItem *item;
   gchar *uri;
   gchar *dup_uri;
 
@@ -651,7 +669,7 @@ libgnac_converter_add(LibgnacConverter  *self,
   {
     LibgnacTags *tags;
 
-    item = libgnac_converter_item_new(self, file);
+    item = libgnac_item_new(file, priv->profile, self);
     // dup uri is freed within the hashtable
     g_queue_push_head(priv->queue, dup_uri);
     g_hash_table_insert(priv->file_table, dup_uri, item);
@@ -704,7 +722,7 @@ libgnac_converter_remove(LibgnacConverter  *self,
     g_return_if_fail(elem);
    
     tags = libgnac_metadata_extract(metadata, 
-                    ((LibgnacConverterItem*)item)->source, NULL);
+                    ((LibgnacMediaItem*)item)->source, NULL);
     if (libgnac_metadata_tags_exist(tags, GST_TAG_DURATION, NULL))
     {
       priv->total_duration -= g_value_get_uint64(
@@ -771,7 +789,7 @@ libgnac_converter_start(LibgnacConverter  *self,
 
   g_signal_emit(self, signals[STARTED], 0);
 
-  dbg_msg = g_strdup_printf(_("Encoding pipeline: %s"), priv->audio_description);
+  dbg_msg = g_strdup_printf(_("Encoding pipeline: %s"), priv->profile->audio_desc);
   libgnac_info(dbg_msg);
   g_free(dbg_msg);
 
@@ -794,7 +812,7 @@ libgnac_converter_stop(LibgnacConverter  *self,
 
   priv = LIBGNAC_CONVERTER_GET_PRIVATE(self);
 
-  libgnac_converter_item_stop(priv->current, &err);
+  libgnac_item_stop(priv->current, &err);
   if (err) {
     g_propagate_error(error, err);
     return;
@@ -815,6 +833,9 @@ libgnac_converter_pause(LibgnacConverter  *self,
   g_return_if_fail(error == NULL || *error == NULL);
 
   priv = LIBGNAC_CONVERTER_GET_PRIVATE(self);
+  // TODO
+  //libgnac_item_pause(priv->current, &err);
+  // SIGNAL ?
   libgnac_gst_pause(priv->current, error);
 }
 
@@ -828,170 +849,13 @@ libgnac_converter_resume(LibgnacConverter  *self,
   g_return_if_fail(error == NULL || *error == NULL);
 
   priv = LIBGNAC_CONVERTER_GET_PRIVATE(self);
+  // TODO 
+  //libgnac_item_resume(priv->current, &err);
+  // SIGNAL ?
   libgnac_gst_run(priv->current, error);
 }
 
 
-/* LibgnacConverterItem functions */
-
-LibgnacConverterItem *
-libgnac_converter_item_new(LibgnacConverter *self, 
-                           GFile            *source)
-{
-  LibgnacConverterItem *item;
-
-  g_return_val_if_fail(LIBGNAC_IS_CONVERTER(self), NULL);
-
-  item = (LibgnacConverterItem*)g_malloc(sizeof(LibgnacConverterItem));
-  
-  g_object_ref(self);
-  item->converter = self;
-  item->source = g_file_dup(source);
-  item->destination = NULL;
-  item->pipeline = NULL;
-  item->audio_encoder = NULL;
-  item->bus = NULL;
-  item->timeout_id = 0;
-  item->pos = 0;
-
-  return item;
-}
-
-
-void
-libgnac_converter_item_build(LibgnacConverterItem  *item, 
-                             GError               **error)
-{
-  gboolean has_video = FALSE;
-  GError *err = NULL;
-  LibgnacTags *tags;
-
-  g_return_if_fail(error == NULL || *error == NULL);
-
-  /* is it a video file? */
-  // TODO why not passing error ?
-  tags = libgnac_metadata_extract(metadata, item->source, NULL);
-  if (tags && libgnac_metadata_tag_exists(tags, GNAC_TAG_HAS_VIDEO)) {
-    has_video = TRUE;
-  }
-
-  libgnac_gst_build_pipeline(item, has_video, &err);
-  if (err) {
-    libgnac_warning("Unable to build pipeline");
-    libgnac_gst_clean_pipeline(item);
-    g_propagate_error(error, err);
-  }
-}
-
-
-void
-libgnac_converter_item_run(LibgnacConverterItem  *item, 
-                           GError               **error)
-{
-  GError *err = NULL;
-  g_return_if_fail(error == NULL || *error == NULL);
-
-  /* Build pipeline if doesn't exist */
-  if (!item->pipeline) {
-    libgnac_converter_item_build(item, &err);
-    if(err)
-    {
-      g_propagate_error(error, err);
-      return;
-    }
-  }
-
-  libgnac_converter_item_initialize_event_source(item);
-  
-  libgnac_gst_run(item, &err);
-  if (err) {
-    libgnac_warning("Unable to run pipeline");
-    libgnac_gst_clean_pipeline(item);
-    g_propagate_error(error, err);
-    return;
-  }
-}
-
-
-void
-libgnac_converter_item_stop(LibgnacConverterItem  *item, 
-                            GError               **error)
-{
-  GError *err = NULL;
-  g_return_if_fail(error == NULL || *error == NULL);
-
-  libgnac_converter_item_clear_event_source(item);
-  libgnac_gst_stop(item, &err);
-  // TODO propagate error here
-  //g_propagate_error(error, err);
-
-  /* Remove not completed file */
-  if (G_IS_FILE(item->destination)) 
-  {
-    g_file_delete(item->destination, NULL, &err);
-    if (err) {
-      // Warning, but not critical
-      libgnac_warning("Unable to remove partial file");
-      g_clear_error(&err);
-    }
-  }
-}
-
-
-/*void
-libgnac_converter_item_pause(LibgnacConverterItem  *item, 
-                             GError               **error)
-{
-  g_return_if_fail(error == NULL || *error == NULL);
-}
-
-
-void
-libgnac_converter_item_resume(LibgnacConverterItem  *item, 
-                              GError               **error)
-{
-  g_return_if_fail(error == NULL || *error == NULL);
-}*/
-
-
-void
-libgnac_converter_item_free(LibgnacConverterItem *item)
-{
-  libgnac_converter_item_clear_event_source(item);
-  g_object_unref(item->converter);
-  item->converter = NULL;
-
-  g_object_unref(item->source);
-  item->source = NULL;
-  if (item->destination) {
-    g_object_unref(item->destination);
-    item->destination = NULL;
-  }
-
-  libgnac_gst_clean_pipeline(item);
-
-  g_free(item);
-}
-
-
-void
-libgnac_converter_item_initialize_event_source(LibgnacConverterItem *item)
-{
-  item->timeout_id = g_timeout_add(PROGRESS_TIMEOUT, 
-      (GSourceFunc)libgnac_converter_percentage_cb, item);
-}
-
-
-void
-libgnac_converter_item_clear_event_source(LibgnacConverterItem *item)
-{
-  if (item->timeout_id) {
-    g_source_remove(item->timeout_id);
-    item->timeout_id = 0;
-  }
-}
-
-
 /* Callbacks */
 
 void
@@ -999,21 +863,24 @@ libgnac_converter_eos_cb(GstBus     *bus,
                          GstMessage *message, 
                          gpointer    data)
 {
-  LibgnacConverterItem *item;
+  LibgnacConverter *converter = NULL;
+  LibgnacMediaItem *item = NULL;
   gchar *uri;
 
-  item = (LibgnacConverterItem*)data;
-  libgnac_converter_item_clear_event_source(item);
+  converter = (LibgnacConverter*)data;
 
+  g_return_if_fail(LIBGNAC_IS_CONVERTER(converter));
+
+  item = converter->priv->current;
   uri = g_file_get_uri(item->source);
 
-  g_signal_emit(item->converter, signals[FILE_COMPLETED], 0, uri);
+  g_signal_emit(converter, signals[FILE_COMPLETED], 0, uri);
 
   /* Start next file conversion */
-  if (!libgnac_converter_start_next(item->converter))
+  if (!libgnac_converter_start_next(converter))
   {
-    item->converter->priv->n_converted = -1;
-    g_signal_emit(item->converter, signals[COMPLETION], 0);
+    converter->priv->n_converted = -1;
+    g_signal_emit(converter, signals[COMPLETION], 0);
   }
 }
 
@@ -1025,12 +892,15 @@ libgnac_converter_error_cb(GstBus      *bus,
 {
   GError *error = NULL;
   GstObject *src = NULL;
-  LibgnacConverterItem *item = NULL;
+  LibgnacConverter *converter = NULL;
+  LibgnacMediaItem *item = NULL;
   gchar *uri;
   gchar *name;
 
-  item = (LibgnacConverterItem*)data;
-  libgnac_converter_item_clear_event_source(item);
+  converter = (LibgnacConverter*)data;
+  g_return_if_fail(LIBGNAC_IS_CONVERTER(converter));
+
+  item = converter->priv->current;
 
   src = GST_MESSAGE_SRC(message);
   name = gst_object_get_name(src);
@@ -1038,6 +908,7 @@ libgnac_converter_error_cb(GstBus      *bus,
   uri = g_file_get_uri(item->source);
 
   gst_message_parse_error(message, &error, NULL);
+  libgnac_debug("An error occured for file %s", uri);
 
   if (g_str_has_prefix(name, "giosink"))
   {
@@ -1048,15 +919,23 @@ libgnac_converter_error_cb(GstBus      *bus,
       /* Create missing directory */
       GError *err = NULL;
       GFile *folder;
+      gchar *furi;
+
 
       folder = g_file_get_parent(item->destination);
+      
+      furi = g_file_get_uri(folder);
+      libgnac_debug("Creating missing directory: %s", furi);
+      g_free(furi);
+
       g_file_make_directory_with_parents(folder, NULL, &err);
       g_object_unref(folder);
       if (err) {
-        g_signal_emit(item->converter, signals[ERROR], 0, uri, 
+        libgnac_debug("Unable to create missing directory");
+        g_signal_emit(converter, signals[ERROR], 0, uri, 
                         _("Unable to create destination directory"), NULL);
         g_clear_error(&err);
-      } else if (libgnac_converter_restart_current(item->converter)) return;
+      } else if (libgnac_converter_restart_current(converter)) return;
 
     } else if (g_error_matches(error,
                   GST_RESOURCE_ERROR,
@@ -1064,18 +943,23 @@ libgnac_converter_error_cb(GstBus      *bus,
     {
       if (g_file_test(g_file_get_path(item->destination), G_FILE_TEST_EXISTS))
       {
+
+        libgnac_debug("Destination file exists");
         gboolean overwrite = FALSE;
-        g_signal_emit(item->converter, signals[OVERWRITE], 0, 
+        g_signal_emit(converter, signals[OVERWRITE], 0, 
                         item->destination, &overwrite);
         if (overwrite)
         {
           GError *err = NULL;
+          
+
+          libgnac_debug("Delete file for overwrite");
           g_file_delete(item->destination, NULL, &err);
           if (err) {
             libgnac_warning("Unable to overwrite file %s: %s", uri, err->message);
             g_clear_error(&err);
-          }
-          if (!err && libgnac_converter_restart_current(item->converter)) 
+          } 
+          else if (libgnac_converter_restart_current(converter)) 
           {
             g_clear_error(&error);
             g_free(name);
@@ -1087,31 +971,40 @@ libgnac_converter_error_cb(GstBus      *bus,
         {
           gchar  *msg;
           GError *err = NULL;
+
+
+          libgnac_debug("Do nothing, overwrite forbidden");
           msg = g_strdup_printf(_("Destination file %s already exists"), uri);
           g_set_error_literal(&err, LIBGNAC_ERROR, 
               LIBGNAC_ERROR_FILE_EXISTS, msg);
-          g_signal_emit(item->converter, signals[ERROR], 0, uri, msg, err);
+          g_signal_emit(converter, signals[ERROR], 0, uri, msg, err);
           g_clear_error(&err);
           g_free(msg);
         }
       } 
       else
       {
-        g_signal_emit(item->converter, signals[ERROR], 0, uri, 
+        libgnac_debug("Unable to access destination file");
+        g_signal_emit(converter, signals[ERROR], 0, uri, 
                           _("Unable to access destination file"), error);
       }
     }
   } else if (g_str_has_prefix(name, "giosrc")) {
-    g_signal_emit(item->converter, signals[ERROR], 0, uri, 
+
+    libgnac_debug("Unable to read source file");
+    g_signal_emit(converter, signals[ERROR], 0, uri, 
                     _("Unable to read source file"), error);
   } else {
     GError *err = NULL;
+
+    libgnac_debug("Removing partial file");
     g_file_delete(item->destination, NULL, &err);
     if (err) {
+      libgnac_debug("Unable to remove partial file");
       libgnac_warning("Unable to remove partial file %s: %s", uri, err->message);
       g_clear_error(&err);
     }
-    g_signal_emit(item->converter, signals[ERROR], 0, uri, 
+    g_signal_emit(converter, signals[ERROR], 0, uri, 
                     _("An error occured during conversion"), error);
   }
 
@@ -1122,10 +1015,10 @@ libgnac_converter_error_cb(GstBus      *bus,
   g_free(name);
   g_free(uri);
 
-  if (!libgnac_converter_start_next(item->converter))
+  if (!libgnac_converter_start_next(converter))
   {
-    item->converter->priv->n_converted = -1;
-    g_signal_emit(item->converter, signals[COMPLETION], 0);
+    converter->priv->n_converted = -1;
+    g_signal_emit(converter, signals[COMPLETION], 0);
   }     
 
   //libgnac_converter_restart_current(item->converter);
@@ -1136,34 +1029,38 @@ void
 libgnac_converter_missing_plugin_result_cb(GstInstallPluginsReturn result,
                                            gpointer                data)
 {
-  LibgnacConverterItem *item;
+  LibgnacConverter *converter = NULL;
+  LibgnacMediaItem *item = NULL;
   gchar *uri;
 
-  item = (LibgnacConverterItem*)data;
+  converter = (LibgnacConverter*)data;
+  g_return_if_fail(LIBGNAC_IS_CONVERTER(converter));
+
+  item = converter->priv->current;
 
   if (result == GST_INSTALL_PLUGINS_SUCCESS)
   {
-    if (libgnac_converter_restart_current(item->converter))
+    if (libgnac_converter_restart_current(converter))
     {
       return;
     }
   } else {
     uri = g_file_get_uri(item->source);
-    g_signal_emit(item->converter, signals[ERROR], 0, uri, 
+    g_signal_emit(converter, signals[ERROR], 0, uri, 
                     _("Unable to handle this format"), NULL);
     g_free(uri);
   }
 
-  if (!libgnac_converter_start_next(item->converter))
+  if (!libgnac_converter_start_next(converter))
   {
-    item->converter->priv->n_converted = -1;
-    g_signal_emit(item->converter, signals[COMPLETION], 0);
+    converter->priv->n_converted = -1;
+    g_signal_emit(converter, signals[COMPLETION], 0);
   }     
 }
 
 
 gboolean
-libgnac_converter_percentage_cb(LibgnacConverterItem *item)
+libgnac_converter_percentage_cb(LibgnacConverter *converter)
 {
   gint64      pos = 0;
   gint64      len = 0;
@@ -1172,10 +1069,13 @@ libgnac_converter_percentage_cb(LibgnacConverterItem *item)
   GstState    pending_state;
   gfloat      result = 0.0;
   LibgnacConverterPrivate *priv;
+  LibgnacMediaItem *item = NULL;
 
   static GstFormat format = GST_FORMAT_TIME;
 
-  priv = LIBGNAC_CONVERTER_GET_PRIVATE(item->converter);
+
+  priv = LIBGNAC_CONVERTER_GET_PRIVATE(converter);
+  item = priv->current;
 
   gst_element_get_state(item->pipeline, &state, &pending_state, 0);
 
@@ -1202,7 +1102,7 @@ libgnac_converter_percentage_cb(LibgnacConverterItem *item)
         if (priv->total_duration > processed) 
                 time_left = priv->total_duration - processed;
       }
-      g_signal_emit(item->converter, signals[PROGRESS], 0, 
+      g_signal_emit(converter, signals[PROGRESS], 0, 
                       priv->n_converted+1, result, time_left);
     }
   }
diff --git a/libgnac/libgnac-converter.h b/libgnac/libgnac-converter.h
index e8c3e78..65063a0 100644
--- a/libgnac/libgnac-converter.h
+++ b/libgnac/libgnac-converter.h
@@ -32,6 +32,7 @@
 #include <gst/gst.h>
 #include <gst/pbutils/pbutils.h>
 
+#include "libgnac-media-item.h"
 #include "libgnac-metadata.h"
 #include "libgnac-metadata-tags.h"
 
@@ -62,6 +63,7 @@ typedef struct
 
 } LibgnacConverter;
 
+
 typedef struct
 {
   GObjectClass parent_class;
@@ -83,20 +85,6 @@ typedef struct
 
 } LibgnacConverterClass;
 
-/* Encoder item that handle a file conversion */
-typedef struct 
-{
-  LibgnacConverter   *converter;
-  GFile              *source;
-  GFile              *destination;
-  GstElement         *pipeline;
-  GstElement         *audio_encoder;
-  GstElement         *muxer;
-  GstElement         *video_encoder;
-  GstBus             *bus;
-  guint               timeout_id;
-  gint64              pos;
-} LibgnacConverterItem;
 
 GType 
 libgnac_converter_get_type(void);
@@ -133,33 +121,6 @@ void
 libgnac_converter_resume(LibgnacConverter  *self,
                          GError           **error);
 
-/* LibgnacConverterItem functions */
-
-LibgnacConverterItem *
-libgnac_converter_item_new(LibgnacConverter *self,
-                           GFile            *source);
-
-void
-libgnac_converter_item_build(LibgnacConverterItem  *item,
-                             GError               **error);
-
-void
-libgnac_converter_item_run(LibgnacConverterItem  *item,
-                           GError               **error);
-
-void
-libgnac_converter_item_stop(LibgnacConverterItem  *item,
-                            GError               **error);
-
-void
-libgnac_converter_item_free(LibgnacConverterItem *item);
-
-void
-libgnac_converter_item_initialize_event_source(LibgnacConverterItem *item);
-
-void
-libgnac_converter_item_clear_event_source(LibgnacConverterItem *item);
-
 /* Callbacks */
 
 void
@@ -176,7 +137,7 @@ libgnac_converter_missing_plugin_result_cb(GstInstallPluginsReturn result,
                                            gpointer                user_data);
 
 gboolean
-libgnac_converter_percentage_cb(LibgnacConverterItem *item);
+libgnac_converter_percentage_cb(LibgnacConverter *converter);
 
 G_END_DECLS
 
diff --git a/libgnac/libgnac-gst.c b/libgnac/libgnac-gst.c
index d2beb7e..14f6dcd 100644
--- a/libgnac/libgnac-gst.c
+++ b/libgnac/libgnac-gst.c
@@ -29,9 +29,9 @@
 
 #include <glib/gi18n.h>
 
-#include "libgnac-converter.h"
 #include "libgnac-debug.h"
 #include "libgnac-error.h"
+#include "libgnac-gst-utils.h"
 #include "libgnac-gst.h"
 
 
@@ -39,7 +39,7 @@
     gst_element_add_pad(element, gst_ghost_pad_new(name, pad))
 
 void
-libgnac_gst_run(LibgnacConverterItem  *item, 
+libgnac_gst_run(LibgnacMediaItem  *item, 
                 GError               **error)
 {
   g_return_if_fail(!error || !*error);
@@ -49,7 +49,7 @@ libgnac_gst_run(LibgnacConverterItem  *item,
 
 
 void
-libgnac_gst_pause(LibgnacConverterItem  *item,
+libgnac_gst_pause(LibgnacMediaItem  *item,
                   GError               **error)
 {
   g_return_if_fail(!error || !*error);
@@ -59,7 +59,7 @@ libgnac_gst_pause(LibgnacConverterItem  *item,
 
 
 void
-libgnac_gst_stop(LibgnacConverterItem  *item, 
+libgnac_gst_stop(LibgnacMediaItem  *item, 
                  GError               **error)
 {
   g_return_if_fail(!error || !*error);
@@ -70,163 +70,12 @@ libgnac_gst_stop(LibgnacConverterItem  *item,
 }
 
 
-GstElement *
-libgnac_gst_make_pipeline_element(GstElement   *bin,
-                                  const gchar  *element,
-                                  const gchar  *name,
-                                  GError      **error)
-{
-  GstElement *elem;
-
-  elem = gst_element_factory_make(element, name);
-  if (!elem) {
-    libgnac_debug("Failed to create %s element", element);
-    g_set_error(error,
-        LIBGNAC_ERROR,
-        LIBGNAC_ERROR_MISSING_PLUGIN,
-        _("Failed to create %s element"),
-        element);
-    return NULL;
-  }
-
-  if (!gst_bin_add(GST_BIN(bin), elem)) {
-    libgnac_debug("Failed to add %s element to the bin", element);
-    g_set_error(error,
-        LIBGNAC_ERROR,
-        LIBGNAC_ERROR_PIPELINE_CREATION,
-        _("Failed to add %s element"),
-        element);
-    return NULL;
-  }
-
-  return elem;
-}
-
-
-GstElement *
-libgnac_gst_pipeline_new(GError **error)
-{
-  GstElement *pipeline;
-  pipeline = gst_pipeline_new("pipeline");
-  if (!pipeline) {
-    libgnac_warning("Pipeline creation failed");
-    g_set_error(error,
-        LIBGNAC_ERROR,
-        LIBGNAC_ERROR_PIPELINE_CREATION,
-        _("Unable to create pipeline"));
-    return NULL;
-  }
-
-  return pipeline;
-}
-
-
-gboolean
-libgnac_gst_bin_add(GstElement  *bin,
-                    GstElement  *elem,
-                    GError     **error)
-{
-  gchar *name;
-
-  name = gst_element_get_name(elem);
-
-  if (!gst_bin_add(GST_BIN(bin), elem)) {
-    libgnac_debug("Failed to add %s element to the bin", name);
-    g_set_error(error,
-        LIBGNAC_ERROR,
-        LIBGNAC_ERROR_PIPELINE_CREATION,
-        _("Failed to add %s element"),
-        name);
-    return FALSE;
-  }
-
-  return TRUE;
-}
-
-
-gboolean
-libgnac_gst_element_link(GstElement  *src,
-                         GstElement  *dst,
-                         GError     **error)
-{
-  gboolean ret;
-  ret = gst_element_link(src, dst);
-  if (!ret) {
-    libgnac_debug("Failed to link element %s to %s",
-        gst_element_get_name(src), gst_element_get_name(dst));
-    g_set_error(error,
-        LIBGNAC_ERROR,
-        LIBGNAC_ERROR_PIPELINE_CREATION,
-        _("Unable to link element %s to %s"),
-        gst_element_get_name(src), gst_element_get_name(dst));
-  }
-
-  return ret;
-}
-
-
-GstPadLinkReturn
-libgnac_gst_pad_link(GstPad  *src,
-                     GstPad  *sink,
-                     GError **error)
-{
-  GstPadLinkReturn ret;
-  ret = gst_pad_link(src, sink);
-  if (ret != GST_PAD_LINK_OK) {
-    libgnac_debug("Failed to link pad %s to %s",
-        gst_pad_get_name(src), gst_pad_get_name(sink));
-    g_set_error(error,
-        LIBGNAC_ERROR,
-        LIBGNAC_ERROR_PIPELINE_CREATION,
-        _("Unable to link pad %s to %s"),
-        gst_pad_get_name(src), gst_pad_get_name(sink));
-  }
-
-  return ret;
-}
-
-
-static gboolean
-libgnac_gst_get_compatible_pad(GstElement   *element,
-                               GstPad       *pad,
-                               GstCaps      *caps,
-                               const gchar  *type)
-{
-  GstPad *sink_pad;
-  sink_pad = gst_element_get_compatible_pad(element, pad, caps);
-  if (!sink_pad) {
-    libgnac_debug("Unable to find a compatible %s pad "
-        "(sink_pad = %s, caps = %s\n)", type, gst_pad_get_name(pad),
-        gst_caps_to_string(caps));
-    gst_caps_unref(caps);
-    return FALSE;
-  }
-
-  libgnac_debug("%s: %s -> %s", type,
-      gst_pad_get_name(pad), gst_pad_get_name(sink_pad));
-
-  if (GST_PAD_IS_LINKED(sink_pad)) {
-    libgnac_debug("%s pad %s is already linked", type,
-        gst_pad_get_name(sink_pad));
-    g_object_unref(sink_pad);
-    gst_caps_unref(caps);
-    return FALSE;
-  }
-
-  g_return_val_if_fail(
-      libgnac_gst_pad_link(pad, sink_pad, NULL) == GST_PAD_LINK_OK,
-      FALSE);
-  g_object_unref(sink_pad);
-
-  return TRUE;
-}
-
 
 static GstElement *
-libgnac_gst_get_audio_bin(LibgnacConverterItem  *item,
+libgnac_gst_get_audio_bin(LibgnacMediaItem  *item,
+                          LibgnacProfile    *profile,
                           GError               **error)
 {
-  gchar      *descr;
   GstElement *bin;
   GstElement *conv;
   GstElement *enc;
@@ -236,20 +85,17 @@ libgnac_gst_get_audio_bin(LibgnacConverterItem  *item,
 
   bin = gst_bin_new("audio_bin");
 
-  g_object_get(G_OBJECT(item->converter), "audio-description", &descr, NULL);
-
-  conv = libgnac_gst_make_pipeline_element(bin, "audioconvert", NULL, error);
+  conv = libgnac_gstu_make_pipeline_element(bin, "audioconvert", NULL, error);
   g_return_val_if_fail(conv, NULL);
 
-  resample = libgnac_gst_make_pipeline_element(bin, "audioresample",
+  resample = libgnac_gstu_make_pipeline_element(bin, "audioresample",
       NULL, error);
   g_return_val_if_fail(resample, NULL);
 
-  rate = libgnac_gst_make_pipeline_element(bin, "audiorate", NULL, error);
+  rate = libgnac_gstu_make_pipeline_element(bin, "audiorate", NULL, error);
   g_return_val_if_fail(rate, NULL);
 
-  enc = gst_parse_bin_from_description(descr, TRUE, error);
-  g_free(descr);
+  enc = gst_parse_bin_from_description(profile->audio_desc, TRUE, error);
   g_return_val_if_fail(enc && gst_bin_add(GST_BIN(bin), enc), NULL);
 
   g_return_val_if_fail(
@@ -270,10 +116,10 @@ libgnac_gst_get_audio_bin(LibgnacConverterItem  *item,
 
 
 static GstElement *
-libgnac_gst_get_video_bin(LibgnacConverterItem  *item,
+libgnac_gst_get_video_bin(LibgnacMediaItem  *item,
+                          LibgnacProfile    *profile,
                           GError               **error)
 {
-  gchar      *descr;
   GstElement *bin;
   GstElement *conv;
   GstElement *enc;
@@ -282,17 +128,15 @@ libgnac_gst_get_video_bin(LibgnacConverterItem  *item,
 
   bin = gst_bin_new("video_bin");
 
-  g_object_get(G_OBJECT(item->converter), "video-description", &descr, NULL);
 
-  conv = libgnac_gst_make_pipeline_element(bin, "ffmpegcolorspace",
+  conv = libgnac_gstu_make_pipeline_element(bin, "ffmpegcolorspace",
       NULL, error);
   g_return_val_if_fail(conv, NULL);
 
-  rate = libgnac_gst_make_pipeline_element(bin, "videorate", NULL, error);
+  rate = libgnac_gstu_make_pipeline_element(bin, "videorate", NULL, error);
   g_return_val_if_fail(rate, NULL);
 
-  enc = gst_parse_bin_from_description(descr, TRUE, error);
-  g_free(descr);
+  enc = gst_parse_bin_from_description(profile->video_desc, TRUE, error);
   g_return_val_if_fail(enc && gst_bin_add(GST_BIN(bin), enc), NULL);
 
   g_return_val_if_fail(
@@ -313,8 +157,9 @@ libgnac_gst_get_video_bin(LibgnacConverterItem  *item,
 
 
 void
-libgnac_gst_build_pipeline(LibgnacConverterItem  *item,
-                           gboolean               has_video,
+libgnac_gst_build_pipeline(LibgnacMediaItem  *item,
+                           LibgnacProfile    *profile,
+                           gboolean           has_video,
                            GError               **error)
 {
   gboolean    linked;
@@ -327,7 +172,7 @@ libgnac_gst_build_pipeline(LibgnacConverterItem  *item,
   g_return_if_fail(!error || !*error);
 
   /* pipeline */
-  item->pipeline = libgnac_gst_pipeline_new(&encoder_error);
+  item->pipeline = libgnac_gstu_pipeline_new(&encoder_error);
   if (encoder_error) {
     g_propagate_error(error, encoder_error);
     return;
@@ -346,7 +191,7 @@ libgnac_gst_build_pipeline(LibgnacConverterItem  *item,
   gst_bus_add_signal_watch(item->bus);
 
  /* source */
-  source = libgnac_gst_make_pipeline_element(item->pipeline, "giosrc", NULL,
+  source = libgnac_gstu_make_pipeline_element(item->pipeline, "giosrc", NULL,
       &encoder_error);
   if (encoder_error) {
     g_propagate_error(error, encoder_error);
@@ -355,14 +200,14 @@ libgnac_gst_build_pipeline(LibgnacConverterItem  *item,
   g_object_set(G_OBJECT(source), "file", item->source, NULL);
 
   /* decodebin */
-  decodebin = libgnac_gst_make_pipeline_element(item->pipeline, "decodebin",
+  decodebin = libgnac_gstu_make_pipeline_element(item->pipeline, "decodebin",
       NULL, &encoder_error);
   if (encoder_error) {
     g_propagate_error(error, encoder_error);
     return;
   }
 
-  linked = libgnac_gst_element_link(source, decodebin, &encoder_error);
+  linked = libgnac_gstu_element_link(source, decodebin, &encoder_error);
   if (encoder_error) {
     libgnac_debug("link source->decodebin failed");
     g_propagate_error(error, encoder_error);
@@ -370,7 +215,7 @@ libgnac_gst_build_pipeline(LibgnacConverterItem  *item,
   }
 
   /* audio_bin */
-  audio_bin = libgnac_gst_get_audio_bin(item, &encoder_error);
+  audio_bin = libgnac_gst_get_audio_bin(item, profile, &encoder_error);
   if (encoder_error) {
     libgnac_debug("audio_bin creation failed");
     g_propagate_error(error, encoder_error);
@@ -379,14 +224,14 @@ libgnac_gst_build_pipeline(LibgnacConverterItem  *item,
 
   item->audio_encoder = audio_bin;
 
-  libgnac_gst_bin_add(item->pipeline, audio_bin, &encoder_error);
+  libgnac_gstu_bin_add(item->pipeline, audio_bin, &encoder_error);
   if (encoder_error) {
     g_propagate_error(error, encoder_error);
     return;
   }
 
   /* sink */
-  sink = libgnac_gst_make_pipeline_element(item->pipeline, "giosink", NULL,
+  sink = libgnac_gstu_make_pipeline_element(item->pipeline, "giosink", NULL,
       &encoder_error);
   if (encoder_error) {
     g_propagate_error(error, encoder_error);
@@ -396,25 +241,21 @@ libgnac_gst_build_pipeline(LibgnacConverterItem  *item,
 
   if (has_video)
   {
-    gchar *muxer_descr;
     GstElement *audio_queue;
     GstElement *mux;
     GstElement *video_bin;
     GstElement *video_queue;
 
     /* muxer */
-    g_object_get(G_OBJECT(item->converter), "muxer-description",
-        &muxer_descr, NULL);
-    mux = libgnac_gst_make_pipeline_element(item->pipeline, muxer_descr,
+    mux = libgnac_gstu_make_pipeline_element(item->pipeline, profile->muxer_desc,
         NULL, &encoder_error);
-    g_free(muxer_descr);
     if (encoder_error) {
       g_propagate_error(error, encoder_error);
       return;
     }
     item->muxer = mux;
 
-    linked = libgnac_gst_element_link(mux, sink, &encoder_error);
+    linked = libgnac_gstu_element_link(mux, sink, &encoder_error);
     if (encoder_error) {
       libgnac_debug("link encoder->sink failed");
       g_propagate_error(error, encoder_error);
@@ -422,7 +263,7 @@ libgnac_gst_build_pipeline(LibgnacConverterItem  *item,
     }
 
     /* audio */
-    audio_queue = libgnac_gst_make_pipeline_element(item->pipeline, "queue",
+    audio_queue = libgnac_gstu_make_pipeline_element(item->pipeline, "queue",
         "audio_queue", &encoder_error);
     if (encoder_error) {
       g_propagate_error(error, encoder_error);
@@ -439,7 +280,7 @@ libgnac_gst_build_pipeline(LibgnacConverterItem  *item,
     }
 
     /* video */
-    video_queue = libgnac_gst_make_pipeline_element(item->pipeline, "queue",
+    video_queue = libgnac_gstu_make_pipeline_element(item->pipeline, "queue",
         "video_queue", &encoder_error);
     if (encoder_error) {
       g_propagate_error(error, encoder_error);
@@ -447,14 +288,14 @@ libgnac_gst_build_pipeline(LibgnacConverterItem  *item,
     }
     item->video_encoder = video_queue;
 
-    video_bin = libgnac_gst_get_video_bin(item, &encoder_error);
+    video_bin = libgnac_gst_get_video_bin(item, profile, &encoder_error);
     if (encoder_error) {
       libgnac_debug("video_bin creation failed");
       g_propagate_error(error, encoder_error);
       return;
     }
 
-    libgnac_gst_bin_add(item->pipeline, video_bin, &encoder_error);
+    libgnac_gstu_bin_add(item->pipeline, video_bin, &encoder_error);
     if (encoder_error) {
       g_propagate_error(error, encoder_error);
       return;
@@ -470,7 +311,7 @@ libgnac_gst_build_pipeline(LibgnacConverterItem  *item,
   }
   else /* audio file */
   {
-    linked = libgnac_gst_element_link(audio_bin, sink, &encoder_error);
+    linked = libgnac_gstu_element_link(audio_bin, sink, &encoder_error);
     if (encoder_error) {
       libgnac_debug("link encoder->sink failed");
       g_propagate_error(error, encoder_error);
@@ -480,31 +321,17 @@ libgnac_gst_build_pipeline(LibgnacConverterItem  *item,
 
   /* Connect callbacks */
   
-  g_signal_connect(G_OBJECT(item->bus), "message::element", 
-      G_CALLBACK(libgnac_gst_element_cb), item);
-  g_signal_connect(G_OBJECT(item->bus), "message::eos", 
-      G_CALLBACK(libgnac_gst_eos_cb), item);
-  g_signal_connect(G_OBJECT(item->bus), "message::error", 
-      G_CALLBACK(libgnac_gst_error_cb), item);
-
   g_signal_connect(decodebin, "new-decoded-pad", 
       G_CALLBACK(libgnac_gst_newpad_cb), item);
+  /*
   g_signal_connect(decodebin, "unknown-type", 
-      G_CALLBACK(libgnac_gst_unknown_type_cb), item);
+      G_CALLBACK(libgnac_gst_unknown_type_cb), item); */
 
-  /* Converter Callbacks */
-
-  g_signal_connect(G_OBJECT(item->bus), "message::error", 
-      G_CALLBACK(libgnac_converter_error_cb), item);
-  g_signal_connect(G_OBJECT(item->bus), "message::eos", 
-      G_CALLBACK(libgnac_converter_eos_cb), item);
-
-  gst_object_unref(item->bus);
 }
 
 
 void
-libgnac_gst_clean_pipeline(LibgnacConverterItem *item)
+libgnac_gst_clean_pipeline(LibgnacMediaItem *item)
 {
   if (item->pipeline) {
     if (!gst_element_set_state(item->pipeline, GST_STATE_NULL))
@@ -527,9 +354,9 @@ libgnac_gst_newpad_cb(GstElement *decodebin,
 	GstCaps *caps;
 	GstStructure *structure;
 	const gchar *mimetype;
-  LibgnacConverterItem *item;
+  LibgnacMediaItem *item;
 
-  item = (LibgnacConverterItem*)data;
+  item = (LibgnacMediaItem*)data;
 	caps = gst_pad_get_caps(pad);
 
 	if (gst_caps_is_empty(caps) || gst_caps_is_any(caps)) {
@@ -542,13 +369,13 @@ libgnac_gst_newpad_cb(GstElement *decodebin,
 	mimetype = gst_structure_get_name(structure);
 
 	if (g_str_has_prefix(mimetype, "audio/")) {
-	  if (!libgnac_gst_get_compatible_pad(item->audio_encoder, pad,
+	  if (!libgnac_gstu_get_compatible_pad(item->audio_encoder, pad,
         caps, "audio"))
     {
       return;
     }
 	} else if (g_str_has_prefix(mimetype, "video/")) {
-	  if (!libgnac_gst_get_compatible_pad(item->video_encoder, pad,
+	  if (!libgnac_gstu_get_compatible_pad(item->video_encoder, pad,
         caps, "video"))
     {
       return;
@@ -561,31 +388,6 @@ libgnac_gst_newpad_cb(GstElement *decodebin,
 }
 
 
-void
-libgnac_gst_eos_cb(GstBus     *bus, 
-                   GstMessage *message, 
-                   gpointer    data)
-{
-  LibgnacConverterItem *item;
-
-  item = (LibgnacConverterItem*)data;
-  libgnac_gst_clean_pipeline(item);
-}
-
-
-void
-libgnac_gst_error_cb(GstBus     *bus, 
-                     GstMessage *message, 
-                     gpointer    data)
-{
-  LibgnacConverterItem *item;
-
-  item = (LibgnacConverterItem*)data;
-
-  libgnac_gst_clean_pipeline(item);
-}
-
-
 /*void
 libgnac_gst_tags_cb(GstBus     *bus,
                     GstMessage *message,
@@ -603,6 +405,8 @@ libgnac_gst_tags_cb(GstBus     *bus,
 }*/
 
 
+/*
+
 void
 libgnac_gst_element_cb(GstBus     *bus,
                        GstMessage *message,
@@ -610,7 +414,7 @@ libgnac_gst_element_cb(GstBus     *bus,
 {
   gchar *details;
 
-  /* This code handle missing plugins installer */
+  // This code handle missing plugins installer 
   if (gst_is_missing_plugin_message(message))
   {
     // TODO free details, but where ?
@@ -618,19 +422,22 @@ libgnac_gst_element_cb(GstBus     *bus,
     if (details)
     {
       gst_install_plugins_async(&details, NULL, 
+      // TODO, what to do ?
             libgnac_converter_missing_plugin_result_cb, data);
     }
   }
 }
 
+*/
 
+
+  /*
 void
 libgnac_gst_unknown_type_cb(GstElement *decodebin, 
                             GstPad     *pad, 
                             GstCaps    *caps, 
                             gpointer    data)
 {
-  /*
 	if (!gst_caps_is_empty (caps) && !gst_caps_is_any (caps)) {
 		GstStructure *structure;
 		const gchar *mimetype;
@@ -656,5 +463,4 @@ libgnac_gst_unknown_type_cb(GstElement *decodebin,
 		g_free (msg);
 	}
 #endif
-  */
-}
+} */
diff --git a/libgnac/libgnac-gst.h b/libgnac/libgnac-gst.h
index 954678b..218c808 100644
--- a/libgnac/libgnac-gst.h
+++ b/libgnac/libgnac-gst.h
@@ -32,54 +32,33 @@
 #include <gst/gst.h>
 #include <gst/pbutils/pbutils.h>
 
+#include "libgnac-profile.h"
+#include "libgnac-media-item.h"
 #include "libgnac-converter.h"
 #include "libgnac-output.h"
 
 G_BEGIN_DECLS
 
 void
-libgnac_gst_run(LibgnacConverterItem  *item, 
+libgnac_gst_run(LibgnacMediaItem  *item, 
                 GError               **error);
 
 void
-libgnac_gst_stop(LibgnacConverterItem  *item, 
+libgnac_gst_stop(LibgnacMediaItem  *item, 
                  GError               **error);
 
 void
-libgnac_gst_pause(LibgnacConverterItem  *item, 
+libgnac_gst_pause(LibgnacMediaItem  *item, 
                   GError               **error);
 
 void
-libgnac_gst_build_pipeline(LibgnacConverterItem  *item,
-                           gboolean               has_video,
+libgnac_gst_build_pipeline(LibgnacMediaItem  *item,
+                           LibgnacProfile    *profile,
+                           gboolean           has_video,
                            GError               **error);
 
 void
-libgnac_gst_clean_pipeline(LibgnacConverterItem *item);
-
-GstElement *
-libgnac_gst_make_pipeline_element(GstElement   *bin,
-                                  const gchar  *element,
-                                  const gchar  *name,
-                                  GError      **error);
-
-GstPadLinkReturn
-libgnac_gst_pad_link(GstPad  *src,
-                     GstPad  *sink,
-                     GError **error);
-
-GstElement *
-libgnac_gst_pipeline_new(GError **error);
-
-gboolean
-libgnac_gst_bin_add(GstElement  *bin,
-                    GstElement  *elem,
-                    GError     **error);
-
-gboolean
-libgnac_gst_element_link(GstElement  *src,
-                         GstElement  *dst,
-                         GError     **error);
+libgnac_gst_clean_pipeline(LibgnacMediaItem *item);
 
 void
 libgnac_gst_newpad_cb(GstElement *decodebin,
@@ -87,27 +66,6 @@ libgnac_gst_newpad_cb(GstElement *decodebin,
                       gboolean    last,
                       gpointer    data);
 
-void
-libgnac_gst_eos_cb(GstBus     *bus, 
-                   GstMessage *message, 
-                   gpointer    data);
-
-void
-libgnac_gst_error_cb(GstBus     *bus, 
-                     GstMessage *message, 
-                     gpointer    data);
-
-void
-libgnac_gst_element_cb(GstBus     *bus,
-                       GstMessage *message,
-                       gpointer    data);
-
-void
-libgnac_gst_unknown_type_cb(GstElement *decodebin, 
-                            GstPad     *pad, 
-                            GstCaps    *caps,
-                            gpointer    data);
-
 G_END_DECLS
 
 #endif /* __LIBGNAC_GST_H__ */
diff --git a/libgnac/libgnac-metadata.c b/libgnac/libgnac-metadata.c
index d71c46f..76a053b 100644
--- a/libgnac/libgnac-metadata.c
+++ b/libgnac/libgnac-metadata.c
@@ -35,7 +35,7 @@
 
 #include "libgnac-debug.h"
 #include "libgnac-error.h"
-#include "libgnac-gst.h"
+#include "libgnac-gst-utils.h"
 #include "libgnac-metadata.h"
 
 static LibgnacTags *dummy_tags;
@@ -476,7 +476,7 @@ libgnac_metadata_new_decoded_pad_cb(GstElement      *element,
   }
 
   g_return_if_fail(
-      libgnac_gst_pad_link(pad, sink_pad, NULL) == GST_PAD_LINK_OK);
+      libgnac_gstu_pad_link(pad, sink_pad, NULL) == GST_PAD_LINK_OK);
 
   caps = gst_pad_get_caps(pad);
   if (gst_caps_is_empty(caps) || gst_caps_is_any(caps)) 
@@ -613,13 +613,13 @@ libgnac_metadata_extract(LibgnacMetadata  *md,
     /* store file-size, location and filename */
     libgnac_metadata_get_file_info(uri, md);
 
-    pipeline = libgnac_gst_pipeline_new(&metadata_error);
+    pipeline = libgnac_gstu_pipeline_new(&metadata_error);
     if (metadata_error) {
       g_propagate_error(error, metadata_error);
       return NULL;
     }
 
-    source = libgnac_gst_make_pipeline_element(pipeline, "giosrc",
+    source = libgnac_gstu_make_pipeline_element(pipeline, "giosrc",
         NULL, &metadata_error);
     if (metadata_error) {
       libgnac_debug("source creation failed");
@@ -628,14 +628,14 @@ libgnac_metadata_extract(LibgnacMetadata  *md,
     }
     g_object_set(G_OBJECT(source), "file", md->priv->uri, NULL);
 
-    decodebin = libgnac_gst_make_pipeline_element(pipeline, "decodebin2",
+    decodebin = libgnac_gstu_make_pipeline_element(pipeline, "decodebin2",
         NULL, &metadata_error);
     if (metadata_error) {
       g_propagate_error(error, metadata_error);
       return NULL;
     }
 
-    md->priv->sink = libgnac_gst_make_pipeline_element(pipeline, "fakesink",
+    md->priv->sink = libgnac_gstu_make_pipeline_element(pipeline, "fakesink",
         NULL, &metadata_error);
     if (metadata_error) {
       g_propagate_error(error, metadata_error);
@@ -648,7 +648,7 @@ libgnac_metadata_extract(LibgnacMetadata  *md,
         G_CALLBACK(libgnac_metadata_new_decoded_pad_cb), md, 0);
 
     g_return_val_if_fail(
-        libgnac_gst_element_link(source, decodebin, error),
+        libgnac_gstu_element_link(source, decodebin, error),
         FALSE);
     md->priv->pipeline = pipeline;
 
diff --git a/libgnac/libgnac-output.c b/libgnac/libgnac-output.c
index 8e5a4b1..e546d96 100644
--- a/libgnac/libgnac-output.c
+++ b/libgnac/libgnac-output.c
@@ -339,7 +339,7 @@ libgnac_output_rename_pattern_process(LibgnacRenamePattern  *pattern,
 
 
 static gchar *
-libgnac_output_get_filename(LibgnacConverterItem *item, 
+libgnac_output_get_filename(LibgnacMediaItem *item, 
                             const gchar          *rename_pattern, 
                             GError              **error)
 {
@@ -384,7 +384,7 @@ libgnac_output_finalize(void)
 
 
 void
-libgnac_output_build_output(LibgnacConverterItem  *item,
+libgnac_output_build_output(LibgnacMediaItem  *item,
                             GError               **error)
 {
   GError *output_error = NULL;
@@ -402,12 +402,12 @@ libgnac_output_build_output(LibgnacConverterItem  *item,
 
   g_return_if_fail(!error || !*error);
 
-  g_object_get(item->converter, "extension", &extension, NULL);
-  g_object_get(item->converter, "strip-special", &strip_special, NULL);
-  g_object_get(item->converter, "folder-hierarchy", &folder_hierarchy, NULL); 
-  g_object_get(item->converter, "folder-path", &folder_path, NULL); 
-  g_object_get(item->converter, "rename-pattern", &rename_pattern, NULL);
-  g_object_get(item->converter, "folder-type", &folder_type, NULL);
+  g_object_get(item->parent, "extension", &extension, NULL);
+  g_object_get(item->parent, "strip-special", &strip_special, NULL);
+  g_object_get(item->parent, "folder-hierarchy", &folder_hierarchy, NULL); 
+  g_object_get(item->parent, "folder-path", &folder_path, NULL); 
+  g_object_get(item->parent, "rename-pattern", &rename_pattern, NULL);
+  g_object_get(item->parent, "folder-type", &folder_type, NULL);
 
   filename = libgnac_output_get_filename(item, rename_pattern, &output_error);
   if (output_error) {  
diff --git a/libgnac/libgnac-output.h b/libgnac/libgnac-output.h
index 0c4bf11..2aad2cf 100644
--- a/libgnac/libgnac-output.h
+++ b/libgnac/libgnac-output.h
@@ -29,6 +29,7 @@
 #include <gio/gio.h>
 #include <glib.h>
 
+#include "libgnac-media-item.h"
 #include "libgnac-converter.h"
 
 G_BEGIN_DECLS
@@ -85,7 +86,7 @@ void
 libgnac_output_finalize(void);
 
 void
-libgnac_output_build_output(LibgnacConverterItem  *item, 
+libgnac_output_build_output(LibgnacMediaItem  *item, 
                             GError               **error);
 
 gchar *



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]