[rygel-gst-0-10-plugins/wip/port-to-new-gupnp-dlna] wip: Port to gupnp-dlna-2.0.



commit ad52b45b8caa217a9c70cd0eee69a5b482bca430
Author: Krzesimir Nowak <krnowak openismus com>
Date:   Fri Feb 15 11:24:28 2013 +0100

    wip: Port to gupnp-dlna-2.0.
    
    Does not work yet - there are many criticals e.g. about not being able
    to register a GstObject type.
    
    Maybe somehow GStreamer-1.0 gets loaded by accident.

 configure.ac                                       |    6 +-
 .../rygel-media-export-harvesting-task.c           |   31 +++--
 src/media-export/rygel-media-export-item-factory.c |  145 +++++++++++++------
 src/media-export/rygel-media-export-item-factory.h |   45 +-----
 .../rygel-media-export-metadata-extractor.c        |  156 ++++++++++++--------
 .../rygel-media-export-metadata-extractor.h        |    3 +-
 src/media-export/rygel-media-export-plugin.c       |    3 +
 7 files changed, 229 insertions(+), 160 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index f7a11db..7929d9f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -30,7 +30,7 @@ dnl Required versions of library packages
 LIBRYGEL_SERVER_REQUIRED=0.17.4
 GUPNP_REQUIRED=0.19.0
 GUPNP_AV_REQUIRED=0.11.2
-GUPNP_DLNA_REQUIRED=0.5.0
+GUPNP_DLNA_REQUIRED=0.9.5
 GSTREAMER_REQUIRED=0.10.36
 GSTPBU_REQUIRED=0.10.35
 GIO_REQUIRED=2.26
@@ -42,9 +42,9 @@ GSTREAMER_APP_REQUIRED=0.10.28
 LIBSQLITE3_REQUIRED=3.5
 
 
-RYGEL_BASE_MODULES='gupnp-1.0 >= $GUPNP_REQUIRED gee-0.8 >= $GEE_REQUIRED'
+RYGEL_BASE_MODULES="gupnp-1.0 >= $GUPNP_REQUIRED gee-0.8 >= $GEE_REQUIRED"
 RYGEL_COMMON_MODULES="$RYGEL_BASE_MODULES gupnp-av-1.0 >= $GUPNP_AV_REQUIRED"
-PKG_CHECK_MODULES([DEPS], [$RYGEL_COMMON_MODULES rygel-server-2.0 >= $LIBRYGEL_SERVER_REQUIRED gio-2.0 >= 
$GIO_REQUIRED gstreamer-0.10 >= $GSTREAMER_REQUIRED gstreamer-pbutils-0.10 >= $GSTPBU_REQUIRED gupnp-dlna-1.0 
= $GUPNP_DLNA_REQUIRED gstreamer-tag-0.10 >= $GSTREAMER_TAG_REQUIRED gstreamer-app-0.10 >= 
$GSTREAMER_TAG_REQUIRED sqlite3 >= $LIBSQLITE3_REQUIRED])
+PKG_CHECK_MODULES([DEPS], [$RYGEL_COMMON_MODULES rygel-server-2.0 >= $LIBRYGEL_SERVER_REQUIRED gio-2.0 >= 
$GIO_REQUIRED gstreamer-0.10 >= $GSTREAMER_REQUIRED gstreamer-pbutils-0.10 >= $GSTPBU_REQUIRED gupnp-dlna-2.0 
= $GUPNP_DLNA_REQUIRED gupnp-dlna-gst-legacy-2.0 >= $GUPNP_DLNA_REQUIRED gstreamer-tag-0.10 >= 
$GSTREAMER_TAG_REQUIRED gstreamer-app-0.10 >= $GSTREAMER_TAG_REQUIRED sqlite3 >= $LIBSQLITE3_REQUIRED])
 
 AC_CHECK_HEADER([unistr.h],
                 AC_CHECK_LIB([unistring],
diff --git a/src/media-export/rygel-media-export-harvesting-task.c 
b/src/media-export/rygel-media-export-harvesting-task.c
index a8e1ae2..9e36bf3 100644
--- a/src/media-export/rygel-media-export-harvesting-task.c
+++ b/src/media-export/rygel-media-export-harvesting-task.c
@@ -20,7 +20,7 @@
  */
 
 #include <glib/gi18n-lib.h>
-#include <libgupnp-dlna/gupnp-dlna-information.h>
+#include <libgupnp-dlna/gupnp-dlna.h>
 
 #include "rygel-media-export-dummy-container.h"
 #include "rygel-media-export-errors.h"
@@ -467,7 +467,8 @@ rygel_media_export_harvesting_task_do_update (RygelMediaExportHarvestingTask *se
 static void
 rygel_media_export_harvesting_task_on_extracted_cb (RygelMediaExportHarvestingTask *self,
                                                     GFile                          *file,
-                                                    GUPnPDLNAInformation           *dlna,
+                                                    GstDiscovererInfo              *info,
+                                                    GUPnPDLNAProfile               *profile,
                                                     GFileInfo                      *file_info) {
   RygelMediaExportHarvestingTaskPrivate *priv;
   gboolean ignore;
@@ -477,7 +478,8 @@ rygel_media_export_harvesting_task_on_extracted_cb (RygelMediaExportHarvestingTa
 
   g_return_if_fail (RYGEL_MEDIA_EXPORT_IS_HARVESTING_TASK (self));
   g_return_if_fail (G_IS_FILE (file));
-  g_return_if_fail (dlna == NULL || GUPNP_IS_DLNA_INFORMATION (dlna));
+  g_return_if_fail (info == NULL || GST_IS_DISCOVERER_INFO (info));
+  g_return_if_fail (profile == NULL || GUPNP_IS_DLNA_PROFILE (profile));
   g_return_if_fail (G_IS_FILE_INFO (file_info));
 
   priv = self->priv;
@@ -496,10 +498,14 @@ rygel_media_export_harvesting_task_on_extracted_cb (RygelMediaExportHarvestingTa
   }
   container = RYGEL_MEDIA_CONTAINER (g_queue_peek_head (priv->containers));
 
-  if (!dlna) {
+  if (!info) {
     item = rygel_media_export_item_factory_create_simple (container, file, file_info);
   } else {
-    item = rygel_media_export_item_factory_create_from_info (container, file, dlna, file_info);
+    item = rygel_media_export_item_factory_create_from_info (container,
+                                                             file,
+                                                             info,
+                                                             profile,
+                                                             file_info);
   }
   if (item) {
     rygel_media_object_set_parent_ref (RYGEL_MEDIA_OBJECT (item), container);
@@ -515,11 +521,16 @@ rygel_media_export_harvesting_task_on_extracted_cb (RygelMediaExportHarvestingTa
 
 static void
 rygel_media_export_harvesting_task_on_extracted_cb_rygel_media_export_metadata_extractor_extraction_done 
(RygelMediaExportMetadataExtractor *sender G_GNUC_UNUSED,
-                                                                                                             
          GFile                             *file,
-                                                                                                             
          GUPnPDLNAInformation              *dlna,
-                                                                                                             
          GFileInfo                         *file_info,
-                                                                                                             
          gpointer                           self) {
-  rygel_media_export_harvesting_task_on_extracted_cb (self, file, dlna, file_info);
+                                                                                                          
GFile                             *file,
+                                                                                                          
GstDiscovererInfo                 *info,
+                                                                                                          
GUPnPDLNAProfile                  *profile,
+                                                                                                          
GFileInfo                         *file_info,
+                                                                                                          
gpointer                           self) {
+  rygel_media_export_harvesting_task_on_extracted_cb (self,
+                                                      file,
+                                                      info,
+                                                      profile,
+                                                      file_info);
 }
 
 static void
diff --git a/src/media-export/rygel-media-export-item-factory.c 
b/src/media-export/rygel-media-export-item-factory.c
index 9309875..9f7f759 100644
--- a/src/media-export/rygel-media-export-item-factory.c
+++ b/src/media-export/rygel-media-export-item-factory.c
@@ -27,6 +27,38 @@
 #include "rygel-media-export-item-factory.h"
 #include "rygel-media-export-jpeg-writer.h"
 
+static RygelMediaItem *
+rygel_media_export_item_factory_fill_photo_item (RygelMediaExportPhotoItem *item,
+                                                 GFile                     *file,
+                                                 GstDiscovererInfo         *info,
+                                                 GUPnPDLNAProfile          *profile,
+                                                 GstDiscovererVideoInfo    *video_info,
+                                                 GFileInfo                 *file_info);
+
+static RygelMediaItem *
+rygel_media_export_item_factory_fill_video_item (RygelMediaExportVideoItem *item,
+                                                 GFile                     *file,
+                                                 GstDiscovererInfo         *info,
+                                                 GUPnPDLNAProfile          *profile,
+                                                 GstDiscovererVideoInfo    *video_info,
+                                                 GstDiscovererAudioInfo    *audio_info,
+                                                 GFileInfo                 *file_info);
+
+static RygelMediaItem *
+rygel_media_export_item_factory_fill_music_item (RygelMediaExportMusicItem *item,
+                                                 GFile                     *file,
+                                                 GstDiscovererInfo         *info,
+                                                 GUPnPDLNAProfile          *profile,
+                                                 GstDiscovererAudioInfo    *audio_info,
+                                                 GFileInfo                 *file_info);
+
+static void
+rygel_media_export_item_factory_fill_media_item (RygelMediaItem       *item,
+                                                 GFile                *file,
+                                                 GstDiscovererInfo    *info,
+                                                 GUPnPDLNAProfile     *profile,
+                                                 GFileInfo            *file_info);
+
 RygelMediaItem *
 rygel_media_export_item_factory_create_simple (RygelMediaContainer *parent,
                                                GFile               *file,
@@ -71,26 +103,26 @@ rygel_media_export_item_factory_create_simple (RygelMediaContainer *parent,
 }
 
 RygelMediaItem *
-rygel_media_export_item_factory_create_from_info (RygelMediaContainer  *parent,
-                                                  GFile                *file,
-                                                  GUPnPDLNAInformation *dlna_info,
-                                                  GFileInfo            *file_info) {
+rygel_media_export_item_factory_create_from_info (RygelMediaContainer *parent,
+                                                  GFile               *file,
+                                                  GstDiscovererInfo   *info,
+                                                  GUPnPDLNAProfile    *profile,
+                                                  GFileInfo           *file_info) {
   RygelMediaItem *result;
   gchar *id;
-  const GstDiscovererInfo *discoverer_info;
   GList *audio_streams;
   GList *video_streams;
 
   g_return_val_if_fail (RYGEL_IS_MEDIA_CONTAINER (parent), NULL);
   g_return_val_if_fail (G_IS_FILE (file), NULL);
-  g_return_val_if_fail (GUPNP_IS_DLNA_INFORMATION (dlna_info), NULL);
+  g_return_val_if_fail (GST_IS_DISCOVERER_INFO (info), NULL);
+  g_return_val_if_fail (profile == NULL || GUPNP_IS_DLNA_PROFILE (profile), NULL);
   g_return_val_if_fail (G_IS_FILE_INFO (file_info), NULL);
 
   id = rygel_media_export_media_cache_get_id (file);
-  discoverer_info = gupnp_dlna_information_get_info (dlna_info);
 
-  audio_streams = gst_discoverer_info_get_audio_streams ((GstDiscovererInfo *) discoverer_info);
-  video_streams = gst_discoverer_info_get_video_streams ((GstDiscovererInfo *) discoverer_info);
+  audio_streams = gst_discoverer_info_get_audio_streams (info);
+  video_streams = gst_discoverer_info_get_video_streams (info);
 
   if (!audio_streams && !video_streams) {
     gchar *uri = g_file_get_uri (file);
@@ -108,7 +140,8 @@ rygel_media_export_item_factory_create_from_info (RygelMediaContainer  *parent,
 
     result = rygel_media_export_item_factory_fill_photo_item (item,
                                                               file,
-                                                              dlna_info,
+                                                              info,
+                                                              profile,
                                                               (GstDiscovererVideoInfo *) video_streams->data,
                                                               file_info);
   } else if (video_streams) {
@@ -126,7 +159,8 @@ rygel_media_export_item_factory_create_from_info (RygelMediaContainer  *parent,
 
     result = rygel_media_export_item_factory_fill_video_item (item,
                                                               file,
-                                                              dlna_info,
+                                                              info,
+                                                              profile,
                                                               (GstDiscovererVideoInfo *) video_streams->data,
                                                               audio_info,
                                                               file_info);
@@ -138,7 +172,8 @@ rygel_media_export_item_factory_create_from_info (RygelMediaContainer  *parent,
 
     result = rygel_media_export_item_factory_fill_music_item (item,
                                                               file,
-                                                              dlna_info,
+                                                              info,
+                                                              profile,
                                                               (GstDiscovererAudioInfo*) audio_streams->data,
                                                               file_info);
   } else {
@@ -153,19 +188,19 @@ rygel_media_export_item_factory_create_from_info (RygelMediaContainer  *parent,
   return result;
 }
 
-void
+static void
 rygel_media_export_item_factory_fill_audio_item (RygelAudioItem         *item,
-                                                 GUPnPDLNAInformation   *dlna_info,
+                                                 GstDiscovererInfo      *info,
+                                                 GUPnPDLNAProfile       *profile,
                                                  GstDiscovererAudioInfo *audio_info) {
-  const GstDiscovererInfo *info;
   GstClockTime duration;
   const GstTagList *tags;
 
   g_return_if_fail (RYGEL_IS_AUDIO_ITEM (item));
-  g_return_if_fail (GUPNP_IS_DLNA_INFORMATION (dlna_info));
+  g_return_if_fail (GST_IS_DISCOVERER_INFO (info));
+  g_return_if_fail (profile == NULL || GUPNP_IS_DLNA_PROFILE (profile));
   g_return_if_fail (audio_info == NULL || GST_IS_DISCOVERER_AUDIO_INFO (audio_info));
 
-  info = gupnp_dlna_information_get_info (dlna_info);
   duration = gst_discoverer_info_get_duration (info);
   if (duration > (GstClockTime) 0) {
     rygel_audio_item_set_duration (item, (glong) (duration / GST_SECOND));
@@ -191,10 +226,11 @@ rygel_media_export_item_factory_fill_audio_item (RygelAudioItem         *item,
                                     (gint) gst_discoverer_audio_info_get_sample_rate (audio_info));
 }
 
-RygelMediaItem *
+static RygelMediaItem *
 rygel_media_export_item_factory_fill_video_item (RygelMediaExportVideoItem *item,
                                                  GFile                     *file,
-                                                 GUPnPDLNAInformation      *dlna_info,
+                                                 GstDiscovererInfo         *info,
+                                                 GUPnPDLNAProfile          *profile,
                                                  GstDiscovererVideoInfo    *video_info,
                                                  GstDiscovererAudioInfo    *audio_info,
                                                  GFileInfo                 *file_info) {
@@ -204,14 +240,22 @@ rygel_media_export_item_factory_fill_video_item (RygelMediaExportVideoItem *item
 
   g_return_val_if_fail (RYGEL_MEDIA_EXPORT_IS_VIDEO_ITEM (item), NULL);
   g_return_val_if_fail (G_IS_FILE (file), NULL);
-  g_return_val_if_fail (GUPNP_IS_DLNA_INFORMATION (dlna_info), NULL);
+  g_return_val_if_fail (GST_IS_DISCOVERER_INFO (info), NULL);
+  g_return_val_if_fail (profile == NULL || GUPNP_IS_DLNA_PROFILE (profile), NULL);
   g_return_val_if_fail (GST_IS_DISCOVERER_VIDEO_INFO (video_info), NULL);
   g_return_val_if_fail (audio_info == NULL || GST_IS_DISCOVERER_AUDIO_INFO (audio_info), NULL);
   g_return_val_if_fail (G_IS_FILE_INFO (file_info), NULL);
 
-  rygel_media_export_item_factory_fill_audio_item (RYGEL_AUDIO_ITEM (item), dlna_info, audio_info);
+  rygel_media_export_item_factory_fill_audio_item (RYGEL_AUDIO_ITEM (item),
+                                                   info,
+                                                   profile,
+                                                   audio_info);
   media_item = RYGEL_MEDIA_ITEM (item);
-  rygel_media_export_item_factory_fill_media_item (media_item, file, dlna_info, file_info);
+  rygel_media_export_item_factory_fill_media_item (media_item,
+                                                   file,
+                                                   info,
+                                                   profile,
+                                                   file_info);
   visual_item = RYGEL_VISUAL_ITEM (item);
 
   rygel_visual_item_set_width (visual_item,
@@ -226,10 +270,11 @@ rygel_media_export_item_factory_fill_video_item (RygelMediaExportVideoItem *item
   return media_item;
 }
 
-RygelMediaItem *
+static RygelMediaItem *
 rygel_media_export_item_factory_fill_photo_item (RygelMediaExportPhotoItem *item,
                                                  GFile                     *file,
-                                                 GUPnPDLNAInformation      *dlna_info,
+                                                 GstDiscovererInfo         *info,
+                                                 GUPnPDLNAProfile          *profile,
                                                  GstDiscovererVideoInfo    *video_info,
                                                  GFileInfo                 *file_info) {
   RygelVisualItem *visual_item;
@@ -238,14 +283,16 @@ rygel_media_export_item_factory_fill_photo_item (RygelMediaExportPhotoItem *item
 
   g_return_val_if_fail (RYGEL_MEDIA_EXPORT_IS_PHOTO_ITEM (item), NULL);
   g_return_val_if_fail (G_IS_FILE (file), NULL);
-  g_return_val_if_fail (GUPNP_IS_DLNA_INFORMATION (dlna_info), NULL);
+  g_return_val_if_fail (GST_IS_DISCOVERER_INFO (info), NULL);
+  g_return_val_if_fail (profile == NULL || GUPNP_IS_DLNA_PROFILE (profile), NULL);
   g_return_val_if_fail (GST_IS_DISCOVERER_VIDEO_INFO (video_info), NULL);
   g_return_val_if_fail (G_IS_FILE_INFO (file_info), NULL);
 
   media_item = RYGEL_MEDIA_ITEM (item);
   rygel_media_export_item_factory_fill_media_item (media_item,
                                                    file,
-                                                   dlna_info,
+                                                   info,
+                                                   profile,
                                                    file_info);
 
   visual_item = RYGEL_VISUAL_ITEM (item);
@@ -261,10 +308,11 @@ rygel_media_export_item_factory_fill_photo_item (RygelMediaExportPhotoItem *item
   return media_item;
 }
 
-RygelMediaItem *
+static RygelMediaItem *
 rygel_media_export_item_factory_fill_music_item (RygelMediaExportMusicItem *item,
                                                  GFile                     *file,
-                                                 GUPnPDLNAInformation      *dlna_info,
+                                                 GstDiscovererInfo         *info,
+                                                 GUPnPDLNAProfile          *profile,
                                                  GstDiscovererAudioInfo    *audio_info,
                                                  GFileInfo                 *file_info) {
   RygelMediaItem *media_item;
@@ -280,17 +328,20 @@ rygel_media_export_item_factory_fill_music_item (RygelMediaExportMusicItem *item
 
   g_return_val_if_fail (RYGEL_MEDIA_EXPORT_IS_MUSIC_ITEM (item), NULL);
   g_return_val_if_fail (G_IS_FILE (file), NULL);
-  g_return_val_if_fail (GUPNP_IS_DLNA_INFORMATION (dlna_info), NULL);
+  g_return_val_if_fail (GST_IS_DISCOVERER_INFO (info), NULL);
+  g_return_val_if_fail (profile == NULL || GUPNP_IS_DLNA_PROFILE (profile), NULL);
   g_return_val_if_fail (audio_info == NULL || GST_IS_DISCOVERER_AUDIO_INFO (audio_info), NULL);
   g_return_val_if_fail (G_IS_FILE_INFO (file_info), NULL);
 
   rygel_media_export_item_factory_fill_audio_item (RYGEL_AUDIO_ITEM (item),
-                                                   dlna_info,
+                                                   info,
+                                                   profile,
                                                    audio_info);
   media_item = RYGEL_MEDIA_ITEM (item);
   rygel_media_export_item_factory_fill_media_item (media_item,
                                                    file,
-                                                   dlna_info,
+                                                   info,
+                                                   profile,
                                                    file_info);
 
   if (!audio_info) {
@@ -371,30 +422,26 @@ rygel_media_export_item_factory_fill_music_item (RygelMediaExportMusicItem *item
   return media_item;
 }
 
-void
+static void
 rygel_media_export_item_factory_fill_media_item (RygelMediaItem       *item,
                                                  GFile                *file,
-                                                 GUPnPDLNAInformation *dlna_info,
+                                                 GstDiscovererInfo    *info,
+                                                 GUPnPDLNAProfile     *profile,
                                                  GFileInfo            *file_info) {
-  const GstDiscovererInfo *info;
   const GstTagList *tags;
   gchar *title;
   GDate *date;
   guint64 mtime;
-  const gchar *name;
   RygelMediaObject *media_object;
   gchar *uri;
+  gboolean mime_set;
 
   g_return_if_fail (RYGEL_IS_MEDIA_ITEM (item));
   g_return_if_fail (G_IS_FILE (file));
-  g_return_if_fail (GUPNP_IS_DLNA_INFORMATION (dlna_info));
+  g_return_if_fail (GST_IS_DISCOVERER_INFO (info));
+  g_return_if_fail (profile == NULL || GUPNP_IS_DLNA_PROFILE (profile));
   g_return_if_fail (G_IS_FILE_INFO (file_info));
 
-  info = gupnp_dlna_information_get_info (dlna_info);
-  if (!info) {
-    return;
-  }
-
   tags = gst_discoverer_info_get_tags (info);
   title = NULL;
   if (!tags || !gst_tag_list_get_string (tags, GST_TAG_TITLE, &title)) {
@@ -436,12 +483,18 @@ rygel_media_export_item_factory_fill_media_item (RygelMediaItem       *item,
   rygel_media_item_set_size (item, (gint64) g_file_info_get_size (file_info));
   rygel_media_object_set_modified (media_object, (guint64) mtime);
 
-  name = gupnp_dlna_information_get_name (dlna_info);
-  if (name) {
-    rygel_media_item_set_dlna_profile (item, name);
+  mime_set = FALSE;
+  if (profile) {
+    const gchar *name = gupnp_dlna_profile_get_name (profile);
 
-    rygel_media_item_set_mime_type (item, gupnp_dlna_information_get_mime (dlna_info));
-  } else {
+    if (name) {
+      mime_set = TRUE;
+      rygel_media_item_set_dlna_profile (item, name);
+
+      rygel_media_item_set_mime_type (item, gupnp_dlna_profile_get_mime (profile));
+    }
+  }
+  if (!mime_set) {
     const gchar *content_type = g_file_info_get_content_type (file_info);
     gchar *content_type_mime_type = g_content_type_get_mime_type (content_type);
 
diff --git a/src/media-export/rygel-media-export-item-factory.h 
b/src/media-export/rygel-media-export-item-factory.h
index da11fc6..b06a764 100644
--- a/src/media-export/rygel-media-export-item-factory.h
+++ b/src/media-export/rygel-media-export-item-factory.h
@@ -25,7 +25,8 @@
 #include <glib.h>
 #include <gio/gio.h>
 #include <rygel-server.h>
-#include <libgupnp-dlna/gupnp-dlna-information.h>
+#include <gst/pbutils/pbutils.h>
+#include <libgupnp-dlna/gupnp-dlna.h>
 
 #include "rygel-media-export-music-item.h"
 #include "rygel-media-export-photo-item.h"
@@ -47,43 +48,11 @@ rygel_media_export_item_factory_create_playlist_item (GFile *file,
                                                       const gchar *fallback_title);
 
 RygelMediaItem *
-rygel_media_export_item_factory_create_from_info (RygelMediaContainer  *parent,
-                                                  GFile                *file,
-                                                  GUPnPDLNAInformation *dlna_info,
-                                                  GFileInfo            *file_info);
-
-RygelMediaItem *
-rygel_media_export_item_factory_fill_photo_item (RygelMediaExportPhotoItem *item,
-                                                 GFile                     *file,
-                                                 GUPnPDLNAInformation      *dlna_info,
-                                                 GstDiscovererVideoInfo    *video_info,
-                                                 GFileInfo                 *file_info);
-
-RygelMediaItem *
-rygel_media_export_item_factory_fill_video_item (RygelMediaExportVideoItem *item,
-                                                 GFile                     *file,
-                                                 GUPnPDLNAInformation      *dlna_info,
-                                                 GstDiscovererVideoInfo    *video_info,
-                                                 GstDiscovererAudioInfo    *audio_info,
-                                                 GFileInfo                 *file_info);
-
-RygelMediaItem *
-rygel_media_export_item_factory_fill_music_item (RygelMediaExportMusicItem *item,
-                                                 GFile                     *file,
-                                                 GUPnPDLNAInformation      *dlna_info,
-                                                 GstDiscovererAudioInfo    *audio_info,
-                                                 GFileInfo                 *file_info);
-
-void
-rygel_media_export_item_factory_fill_audio_item (RygelAudioItem         *item,
-                                                 GUPnPDLNAInformation   *dlna_info,
-                                                 GstDiscovererAudioInfo *audio_info);
-
-void
-rygel_media_export_item_factory_fill_media_item (RygelMediaItem       *item,
-                                                 GFile                *file,
-                                                 GUPnPDLNAInformation *dlna_info,
-                                                 GFileInfo            *file_info);
+rygel_media_export_item_factory_create_from_info (RygelMediaContainer *parent,
+                                                  GFile               *file,
+                                                  GstDiscovererInfo   *info,
+                                                  GUPnPDLNAProfile    *profile,
+                                                  GFileInfo           *file_info);
 
 G_END_DECLS
 
diff --git a/src/media-export/rygel-media-export-metadata-extractor.c 
b/src/media-export/rygel-media-export-metadata-extractor.c
index a5c28b7..602b56f 100644
--- a/src/media-export/rygel-media-export-metadata-extractor.c
+++ b/src/media-export/rygel-media-export-metadata-extractor.c
@@ -24,8 +24,8 @@
  */
 
 #include "rygel-media-export-harvesting-task.h"
-#include <libgupnp-dlna/gupnp-dlna-discoverer.h>
-#include <libgupnp-dlna/gupnp-dlna-information.h>
+#include <libgupnp-dlna/gupnp-dlna.h>
+#include <libgupnp-dlna/gupnp-dlna-gst-utils.h>
 #include <gst/pbutils/pbutils.h>
 #include <glib/gi18n-lib.h>
 #include "rygel-media-export-plugin.h"
@@ -33,9 +33,10 @@
 G_DEFINE_TYPE (RygelMediaExportMetadataExtractor, rygel_media_export_metadata_extractor, G_TYPE_OBJECT)
 
 struct _RygelMediaExportMetadataExtractorPrivate {
-  GUPnPDLNADiscoverer *discoverer;
+  GstDiscoverer *discoverer;
   GeeHashMap *file_hash;
   gboolean extract_metadata;
+  GUPnPDLNAProfileGuesser *guesser;
 };
 
 enum {
@@ -88,21 +89,23 @@ rygel_media_export_metadata_extractor_new (void) {
  * calls dlna_discoverer_done.
  */
 static void
-rygel_media_export_metadata_extractor_on_done_gupnp_dlna_discoverer_done (GUPnPDLNADiscoverer  *sender 
G_GNUC_UNUSED,
-                                                                          GUPnPDLNAInformation *dlna,
-                                                                          GError               *err,
-                                                                          gpointer              self);
+rygel_media_export_metadata_extractor_on_done_gst_discoverer_done (GstDiscoverer     *sender G_GNUC_UNUSED,
+                                                                  GstDiscovererInfo *dlna,
+                                                                  GError            *err,
+                                                                  gpointer           self);
 
 static void
 rygel_media_export_metadata_extractor_extract_basic_information (RygelMediaExportMetadataExtractor *self,
                                                                  GFile                             *file,
-                                                                 GUPnPDLNAInformation              *dlna) {
+                                                                 GstDiscovererInfo                 *info,
+                                                                 GUPnPDLNAProfile                  *profile) 
{
   GError *error;
   GFileInfo *file_info;
 
   g_return_if_fail (RYGEL_MEDIA_EXPORT_IS_METADATA_EXTRACTOR (self));
   g_return_if_fail (G_IS_FILE (file));
-  g_return_if_fail (dlna == NULL || GUPNP_IS_DLNA_INFORMATION (dlna));
+  g_return_if_fail (info == NULL || GST_IS_DISCOVERER_INFO (info));
+  g_return_if_fail (profile == NULL || GUPNP_IS_DLNA_INFORMATION (profile));
 
   error = NULL;
   file_info = g_file_query_info (file,
@@ -122,72 +125,88 @@ rygel_media_export_metadata_extractor_extract_basic_information (RygelMediaExpor
     g_error_free (error);
     return;
   }
-  g_signal_emit (self, signals[EXTRACTION_DONE], 0, file, dlna, file_info);
+  g_signal_emit (self, signals[EXTRACTION_DONE], 0, file, info, profile, file_info);
   g_object_unref (file_info);
 }
 
 static void
 rygel_media_export_metadata_extractor_on_done (RygelMediaExportMetadataExtractor *self,
-                                               GUPnPDLNAInformation              *dlna,
+                                               GstDiscovererInfo                 *gst_info,
                                                GError                            *err) {
   RygelMediaExportMetadataExtractorPrivate *priv;
   guint signal_id;
-  const GstDiscovererInfo *gst_info;
   const gchar *uri;
   GeeAbstractMap *abstract_file_hash;
   GstDiscovererResult result;
   GFile *file;
 
   g_return_if_fail (RYGEL_MEDIA_EXPORT_IS_METADATA_EXTRACTOR (self));
-  g_return_if_fail (GUPNP_IS_DLNA_INFORMATION (dlna));
+  g_return_if_fail (GST_IS_DISCOVERER_INFO (gst_info));
 
   priv = self->priv;
-  signal_id = 0;
-  g_signal_parse_name ("done", GUPNP_TYPE_DLNA_DISCOVERER, &signal_id, NULL, FALSE);
-  g_signal_handlers_disconnect_matched (priv->discoverer,
-                                        G_SIGNAL_MATCH_ID |
-                                        G_SIGNAL_MATCH_FUNC |
-                                        G_SIGNAL_MATCH_DATA, signal_id,
-                                        0,
-                                        NULL,
-                                        G_CALLBACK 
(rygel_media_export_metadata_extractor_on_done_gupnp_dlna_discoverer_done),
-                                        self);
-
-  g_object_unref (priv->discoverer);
-  priv->discoverer = NULL;
-  gst_info = gupnp_dlna_information_get_info (dlna);
-  uri = gst_discoverer_info_get_uri (gst_info);
-  abstract_file_hash = GEE_ABSTRACT_MAP (priv->file_hash);
-  file = G_FILE (gee_abstract_map_get (abstract_file_hash, uri));
-  if (!file) {
-    g_warning ("File %s already handled, ignoring event", uri);
-    return;
+  if (priv->discoverer) {
+    signal_id = 0;
+    g_signal_parse_name ("done", GST_TYPE_DISCOVERER, &signal_id, NULL, FALSE);
+    g_signal_handlers_disconnect_matched (priv->discoverer,
+                                          G_SIGNAL_MATCH_ID |
+                                          G_SIGNAL_MATCH_FUNC |
+                                          G_SIGNAL_MATCH_DATA, signal_id,
+                                          0,
+                                          NULL,
+                                          G_CALLBACK 
(rygel_media_export_metadata_extractor_on_done_gst_discoverer_done),
+                                          self);
+
+    g_object_unref (priv->discoverer);
+    priv->discoverer = NULL;
   }
-  gee_abstract_map_unset (abstract_file_hash, uri, NULL);
-  result = gst_discoverer_info_get_result (gst_info);
-
-  if ((result & GST_DISCOVERER_ERROR) == GST_DISCOVERER_ERROR) {
-    g_signal_emit (self, signals[ERROR], 0, file, err);
-  } else {
-    if ((result & GST_DISCOVERER_TIMEOUT) == GST_DISCOVERER_TIMEOUT) {
-      gchar* file_uri = g_file_get_uri (file);
-
-      g_debug ("Extraction timed out on %s", file_uri);
-      g_free (file_uri);
-      dlna = NULL;
+  if (gst_info) {
+    uri = gst_discoverer_info_get_uri (gst_info);
+    abstract_file_hash = GEE_ABSTRACT_MAP (priv->file_hash);
+    file = G_FILE (gee_abstract_map_get (abstract_file_hash, uri));
+    if (!file) {
+      g_warning ("File %s already handled, ignoring event", uri);
+      return;
+    }
+    gee_abstract_map_unset (abstract_file_hash, uri, NULL);
+    result = gst_discoverer_info_get_result (gst_info);
+
+    if ((result & GST_DISCOVERER_ERROR) == GST_DISCOVERER_ERROR) {
+      g_signal_emit (self, signals[ERROR], 0, file, err);
+    } else {
+      GUPnPDLNAProfile *dlna_profile;
+
+      if ((result & GST_DISCOVERER_TIMEOUT) == GST_DISCOVERER_TIMEOUT) {
+       gchar* file_uri = g_file_get_uri (file);
+
+       g_debug ("Extraction timed out on %s", file_uri);
+       g_free (file_uri);
+       dlna_profile = NULL;
+      } else {
+       GUPnPDLNAInformation *dlna_info = gupnp_dlna_gst_utils_information_from_discoverer_info (gst_info);
+
+       dlna_profile = gupnp_dlna_profile_guesser_guess_profile_from_info (priv->guesser,
+                                                                          dlna_info);
+       g_object_unref (dlna_info);
+      }
+
+      rygel_media_export_metadata_extractor_extract_basic_information (self,
+                                                                      file,
+                                                                      gst_info,
+                                                                      dlna_profile);
     }
-    rygel_media_export_metadata_extractor_extract_basic_information (self, file, dlna);
+  } else {
+    g_signal_emit (self, signals[ERROR], 0, NULL, err);
   }
 
   g_object_unref (file);
 }
 
 static void
-rygel_media_export_metadata_extractor_on_done_gupnp_dlna_discoverer_done (GUPnPDLNADiscoverer  *sender 
G_GNUC_UNUSED,
-                                                                          GUPnPDLNAInformation *dlna,
-                                                                          GError               *err,
-                                                                          gpointer              self) {
-  rygel_media_export_metadata_extractor_on_done (self, dlna, err);
+rygel_media_export_metadata_extractor_on_done_gst_discoverer_done (GstDiscoverer     *sender G_GNUC_UNUSED,
+                                                                  GstDiscovererInfo *info,
+                                                                  GError            *err,
+                                                                  gpointer           self) {
+  rygel_media_export_metadata_extractor_on_done (self, info, err);
 }
 
 void
@@ -203,26 +222,38 @@ rygel_media_export_metadata_extractor_extract (RygelMediaExportMetadataExtractor
   if (priv->extract_metadata) {
     gchar *uri;
     GstClockTime gst_timeout;
-    GUPnPDLNADiscoverer *discoverer;
+    GstDiscoverer *discoverer;
+    GError *error = NULL;
+    GUPnPDLNAProfileGuesser *guesser;
 
-    uri = g_file_get_uri (file);
-    gee_abstract_map_set (GEE_ABSTRACT_MAP (priv->file_hash), uri, file);
     gst_timeout = (GstClockTime) (EXTRACTOR_TIMEOUT * GST_SECOND);
-    discoverer = gupnp_dlna_discoverer_new (gst_timeout, TRUE, TRUE);
+    discoverer = gst_discoverer_new (gst_timeout, &error);
+    if (error) {
+      g_signal_emit (self, signals[ERROR], 0, file, error);
+      g_error_free (error);
+      return;
+    }
     if (priv->discoverer) {
       g_object_unref (priv->discoverer);
     }
     priv->discoverer = discoverer;
+    uri = g_file_get_uri (file);
+    gee_abstract_map_set (GEE_ABSTRACT_MAP (priv->file_hash), uri, file);
     g_signal_connect_object (discoverer,
                              "done",
-                             G_CALLBACK 
(rygel_media_export_metadata_extractor_on_done_gupnp_dlna_discoverer_done),
+                             G_CALLBACK (rygel_media_export_metadata_extractor_on_done_gst_discoverer_done),
                              self,
                              0);
-    gupnp_dlna_discoverer_start (discoverer);
-    gupnp_dlna_discoverer_discover_uri (discoverer, uri);
+    gst_discoverer_start (discoverer);
+    gst_discoverer_discover_uri_async (discoverer, uri);
     g_free (uri);
+    guesser = gupnp_dlna_profile_guesser_new (TRUE, TRUE);
+    if (priv->guesser) {
+      g_object_unref (priv->guesser);
+    }
+    priv->guesser = guesser;
   } else {
-    rygel_media_export_metadata_extractor_extract_basic_information (self, file, NULL);
+    rygel_media_export_metadata_extractor_extract_basic_information (self, file, NULL, NULL);
   }
 }
 
@@ -232,7 +263,7 @@ rygel_media_export_metadata_extractor_dispose (GObject *object) {
   RygelMediaExportMetadataExtractorPrivate *priv = self->priv;
 
   if (priv->discoverer) {
-    GUPnPDLNADiscoverer *discoverer = priv->discoverer;
+    GstDiscoverer *discoverer = priv->discoverer;
 
     priv->discoverer = NULL;
     g_object_unref (discoverer);
@@ -290,9 +321,10 @@ rygel_media_export_metadata_extractor_class_init (RygelMediaExportMetadataExtrac
                                            NULL,
                                            NULL, /* libffi based marshaller */
                                            G_TYPE_NONE,
-                                           3,
+                                           4,
                                            G_TYPE_FILE,
-                                           GUPNP_TYPE_DLNA_INFORMATION,
+                                           GST_TYPE_DISCOVERER_INFO,
+                                           GUPNP_TYPE_DLNA_PROFILE,
                                            G_TYPE_FILE_INFO);
   /**
    * Signalize that an error occured during metadata extraction
diff --git a/src/media-export/rygel-media-export-metadata-extractor.h 
b/src/media-export/rygel-media-export-metadata-extractor.h
index 8b6e1ce..7ffd8f5 100644
--- a/src/media-export/rygel-media-export-metadata-extractor.h
+++ b/src/media-export/rygel-media-export-metadata-extractor.h
@@ -52,7 +52,8 @@ struct _RygelMediaExportMetadataExtractorClass {
 GType
 rygel_media_export_metadata_extractor_get_type (void) G_GNUC_CONST;
 
-RygelMediaExportMetadataExtractor *rygel_media_export_metadata_extractor_new (void);
+RygelMediaExportMetadataExtractor *
+rygel_media_export_metadata_extractor_new (void);
 
 void
 rygel_media_export_metadata_extractor_extract (RygelMediaExportMetadataExtractor *self,
diff --git a/src/media-export/rygel-media-export-plugin.c b/src/media-export/rygel-media-export-plugin.c
index fb71196..ea41821 100644
--- a/src/media-export/rygel-media-export-plugin.c
+++ b/src/media-export/rygel-media-export-plugin.c
@@ -19,6 +19,7 @@
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  */
 
+#include <gst/gst.h>
 
 #include "rygel-media-export-plugin.h"
 #include "rygel-media-export-root-container.h"
@@ -39,6 +40,8 @@ void module_init (RygelPluginLoader *loader) {
     return;
   }
 
+  gst_init (NULL, NULL);
+
   error = NULL;
   /* Instantiate the plugin object */
   plugin = rygel_media_export_plugin_new (&error);


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