[tracker/gstreamer-with-dlna] build: treat GUPnP-DLNA as another GStreamer backend



commit ec7a70a7805d876e9254bbcf9dd486b4508da246
Author: Aleksander Morgado <aleksander lanedo com>
Date:   Wed Jul 13 11:53:08 2011 +0200

    build: treat GUPnP-DLNA as another GStreamer backend

 configure.ac                                    |  100 +++++++++--------------
 src/tracker-extract/Makefile.am                 |    2 +-
 src/tracker-extract/tracker-extract-gstreamer.c |   89 ++++++++++----------
 3 files changed, 84 insertions(+), 107 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index fc3de7a..ffda2b2 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1517,17 +1517,9 @@ AM_CONDITIONAL(HAVE_GDKPIXBUF, test "x$have_gdkpixbuf" = "xyes")
 
 AC_ARG_ENABLE(generic-media-extractor,
               AS_HELP_STRING([--enable-generic-media-extractor=ARG],
-                             [enables one of the (gupnp-dlna, gstreamer, xine, external, auto) generic media extractor backends [[default=auto]]]),,
+                             [enables one of the (gstreamer, xine, external, auto) generic media extractor backends [[default=auto]]]),,
               [enable_generic_media_extractor=auto])
 
-PKG_CHECK_MODULES(GUPNP_DLNA,
-                  [gupnp-dlna-1.0 >= $GUPNP_DLNA_REQUIRED],
-                  [have_gupnp_dlna=yes],
-                  [have_gupnp_dlna=no])
-
-AC_SUBST(GUPNP_DLNA_CFLAGS)
-AC_SUBST(GUPNP_DLNA_LIBS)
-
 PKG_CHECK_MODULES(GSTREAMER,
                   [gstreamer-0.10 >= $GSTREAMER_REQUIRED
                    gstreamer-tag-0.10 >= $GSTREAMER_REQUIRED],
@@ -1548,11 +1540,7 @@ AC_SUBST(XINE_LIBS)
 if test "x$enable_generic_media_extractor" = "xauto"; then
    if test "$have_libgstreamer" = "yes"; then
       have_generic_media_handler="yes"
-      if test "$have_gupnp_dlna" = "yes"; then
-         have_generic_media_handler_app="GStreamer GUPnP-DLNA"
-      else
-         have_generic_media_handler_app="GStreamer"
-      fi
+      have_generic_media_handler_app="GStreamer"
    elif test "$have_libxine" = "yes"; then
       have_generic_media_handler_app="Xine"
       have_generic_media_handler="yes"
@@ -1560,17 +1548,6 @@ if test "x$enable_generic_media_extractor" = "xauto"; then
       have_generic_media_handler="?"
       have_generic_media_handler_app="An external generic_media player will be called"
    fi
-elif test "x$enable_generic_media_extractor" = "xgupnp-dlna"; then
-   if test "$have_gupnp_dlna" = "yes"; then
-      if test "$have_libgstreamer" = "yes"; then
-         have_generic_media_handler_app="GStreamer GUPnP-DLNA"
-         have_generic_media_handler="yes"
-      else
-         AC_MSG_ERROR([Couldn't find GStreamer >= $GSTREAMER_REQUIRED])
-      fi
-   else
-      AC_MSG_ERROR([Couldn't find GUPnP-DLNA >= $GUPNP_DLNA_REQUIRED])
-   fi
 elif test "x$enable_generic_media_extractor" = "xgstreamer"; then
    if test "$have_libgstreamer" = "yes"; then
       have_generic_media_handler_app="GStreamer"
@@ -1590,71 +1567,70 @@ else
    have_generic_media_handler_app="An external generic media player will be called"
 fi
 
-if test "$have_generic_media_handler_app" = "GStreamer GUPnP-DLNA"; then
-   AC_DEFINE(HAVE_GUPNP_DLNA, [], [Define if we have GUPnP-DLNA])
-   AC_DEFINE(HAVE_GSTREAMER, [], [Define if we have GStreamer])
-   AM_CONDITIONAL(HAVE_GUPNP_DLNA, true)
-   AM_CONDITIONAL(HAVE_GSTREAMER, true)
-   AM_CONDITIONAL(HAVE_LIBXINE, false)
-   AM_CONDITIONAL(USING_EXTERNAL_GENERIC_MEDIA_PLAYER, false)
-elif test "$have_generic_media_handler_app" = "GStreamer"; then
+if test "$have_generic_media_handler_app" = "GStreamer"; then
    AC_DEFINE(HAVE_GSTREAMER, [], [Define if we have GStreamer])
    AM_CONDITIONAL(HAVE_GSTREAMER, true)
-   AM_CONDITIONAL(HAVE_GUPNP_DLNA, false)
    AM_CONDITIONAL(HAVE_LIBXINE, false)
    AM_CONDITIONAL(USING_EXTERNAL_GENERIC_MEDIA_PLAYER, false)
 elif test "$have_generic_media_handler_app" = "Xine"; then
    AC_DEFINE(HAVE_LIBXINE, [], [Define if we have Libxine])
    AM_CONDITIONAL(HAVE_LIBXINE, true)
-   AM_CONDITIONAL(HAVE_GUPNP_DLNA, false)
    AM_CONDITIONAL(HAVE_GSTREAMER, false)
    AM_CONDITIONAL(USING_EXTERNAL_GENERIC_MEDIA_PLAYER, false)
 else
    AC_DEFINE(USING_EXTERNAL_GENERIC_MEDIA_PLAYER, [], [Define that Tracker will try to use external generic media players])
    AM_CONDITIONAL(USING_EXTERNAL_GENERIC_MEDIA_PLAYER, true)
-   AM_CONDITIONAL(HAVE_GUPNP_DLNA, false)
    AM_CONDITIONAL(HAVE_GSTREAMER, false)
    AM_CONDITIONAL(HAVE_LIBXINE, false)
 fi
 
-####################################################################
-# Check for tracker-extract: tagreadbin/decodebin2/discoverer
-#  for gstreamer extractor
-####################################################################
+###########################################################################
+# Check for gstreamer backend: tagreadbin/decodebin2/discoverer/gupnp-dlna
+###########################################################################
 
 AC_ARG_WITH([gstreamer-backend],
             AS_HELP_STRING([--with-gstreamer-backend],
-                           [enables one of the (discoverer, decodebin2, tagreadbin) GStreamer backends [[default=discoverer]]]),,
+                           [enables one of the (gupnp-dlna, discoverer, decodebin2, tagreadbin) GStreamer backends [[default=discoverer]]]),,
               [with_gstreamer_backend=discoverer])
 
-gstreamer_backend="N/A"
-case "x$with_gstreamer_backend" in
-     "xdecodebin2")
-        if test "$have_generic_media_handler_app" = "GStreamer GUPnP-DLNA"; then
-           AC_MSG_ERROR([Cannot use decodebin2 backend in GStreamer when requesting GUPnP-DLNA support])
-        elif test "$have_generic_media_handler_app" = "GStreamer"; then
+if test "$have_generic_media_handler_app" != "GStreamer"; then
+   AC_MSG_WARN([No need to specify a GStreamer backend if not using GStreamer])
+   gstreamer_backend="N/A"
+else
+   case "x$with_gstreamer_backend" in
+        "xdecodebin2")
            gstreamer_backend="Decodebin2"
            AC_DEFINE(GSTREAMER_BACKEND_DECODEBIN2, [], [Define that GStreamer Decodebin2 should be used])
-        fi
-     ;;
-     "xtagreadbin")
-        if test "$have_generic_media_handler_app" = "GStreamer GUPnP-DLNA"; then
-           AC_MSG_ERROR([Cannot use tagreadbin backend in GStreamer when requesting GUPnP-DLNA support])
-        elif test "$have_generic_media_handler_app" = "GStreamer"; then
+        ;;
+        "xtagreadbin")
            gstreamer_backend="Tagreadbin"
            AC_DEFINE(GSTREAMER_BACKEND_TAGREADBIN, [], [Define that GStreamer Tagreadbin should be used])
-        fi
-     ;;
-     "xdiscoverer")
-        if test "$have_generic_media_handler_app" = "GStreamer GUPnP-DLNA" || test "$have_generic_media_handler_app" = "GStreamer"; then
+        ;;
+        "xdiscoverer")
            gstreamer_backend="Discoverer"
            AC_DEFINE(GSTREAMER_BACKEND_DISCOVERER, [], [Define that GStreamer Discoverer should be used])
-        fi
-     ;;
-     # Invalid option value
-     *) AC_MSG_ERROR([Wrong value for --with-gstreamer-backend: $with_gstreamer_backend]) ;;
-esac
-
+        ;;
+        "xgupnp-dlna")
+           PKG_CHECK_MODULES(GUPNP_DLNA,
+                             [gupnp-dlna-1.0 >= $GUPNP_DLNA_REQUIRED],
+                             [have_gupnp_dlna=yes],
+                             [have_gupnp_dlna=no])
+           AC_SUBST(GUPNP_DLNA_CFLAGS)
+           AC_SUBST(GUPNP_DLNA_LIBS)
+
+           if test "x$have_gupnp_dlna" = "xyes"; then
+              gstreamer_backend="GUPnP-DLNA"
+              AC_DEFINE(GSTREAMER_BACKEND_GUPNP_DLNA, [], [Define that GUPnP-DLNA should be used])
+           else
+              AC_MSG_ERROR([Couldn't find GUPnP-DLNA >= $GUPNP_DLNA_REQUIRED])
+           fi
+        ;;
+        # Invalid option value
+        *) AC_MSG_ERROR([Wrong value for --with-gstreamer-backend: $with_gstreamer_backend]) ;;
+   esac
+fi
+
+AM_CONDITIONAL(HAVE_GUPNP_DLNA, test "x$gstreamer_backend" = "xGUPnP-DLNA")
 
 ##################################################################
 # Check for tracker-extract: helixbin for gstreamer
diff --git a/src/tracker-extract/Makefile.am b/src/tracker-extract/Makefile.am
index 192880a..64e0a65 100644
--- a/src/tracker-extract/Makefile.am
+++ b/src/tracker-extract/Makefile.am
@@ -120,7 +120,7 @@ modules_LTLIBRARIES += libextract-gstreamer.la
 rules_DATA += 10-svg.rule 15-gstreamer-guess.rule 90-gstreamer-generic.rule
 endif
 
-# Gstreamer with DLNA support?
+# Gstreamer with GUPnP-DLNA backend?
 if HAVE_GUPNP_DLNA
 rules_DATA += 91-gstreamer-generic-dlna.rule
 endif
diff --git a/src/tracker-extract/tracker-extract-gstreamer.c b/src/tracker-extract/tracker-extract-gstreamer.c
index e3a6237..e726ac9 100644
--- a/src/tracker-extract/tracker-extract-gstreamer.c
+++ b/src/tracker-extract/tracker-extract-gstreamer.c
@@ -21,6 +21,14 @@
 
 #include "config.h"
 
+/* Ensure we have a valid backend enabled */
+#if !defined(GSTREAMER_BACKEND_TAGREADBIN) && \
+	!defined(GSTREAMER_BACKEND_DECODEBIN2) && \
+    !defined(GSTREAMER_BACKEND_DISCOVERER) && \
+    !defined(GSTREAMER_BACKEND_GUPNP_DLNA)
+#error Not a valid GStreamer backend defined
+#endif
+
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -29,12 +37,13 @@
 #include <glib.h>
 #include <glib/gstdio.h>
 
-#if defined(GSTREAMER_BACKEND_DISCOVERER)
+#if defined(GSTREAMER_BACKEND_DISCOVERER) || \
+	defined(GSTREAMER_BACKEND_GUPNP_DLNA)
 #define GST_USE_UNSTABLE_API
 #include <gst/pbutils/pbutils.h>
 #endif
 
-#ifdef HAVE_GUPNP_DLNA
+#if defined(GSTREAMER_BACKEND_GUPNP_DLNA)
 #include <libgupnp-dlna/gupnp-dlna-discoverer.h>
 #endif
 
@@ -46,13 +55,6 @@
 
 #include "tracker-albumart.h"
 
-/* Ensure we have a valid backend enabled */
-#if !defined(GSTREAMER_BACKEND_TAGREADBIN) && \
-	!defined(GSTREAMER_BACKEND_DECODEBIN2) && \
-    !defined(GSTREAMER_BACKEND_DISCOVERER)
-#error Not a valid GStreamer backend defined
-#endif
-
 /* We wait this long (seconds) for NULL state before freeing */
 #define TRACKER_EXTRACT_GUARD_TIMEOUT 3
 
@@ -108,37 +110,44 @@ typedef enum {
 
 typedef struct {
 	ExtractMime     mime;
+	GstTagList     *tagcache;
+	gboolean        is_content_encrypted;
+	unsigned char  *album_art_data;
+	guint           album_art_size;
+	const gchar    *album_art_mime;
 
 #if defined(GSTREAMER_BACKEND_TAGREADBIN) ||	  \
 	defined(GSTREAMER_BACKEND_DECODEBIN2)
-	/* Common pipeline elements */
 	GstElement     *pipeline;
 	GstBus         *bus;
 #endif
 
 #if defined(GSTREAMER_BACKEND_DECODEBIN2)
-	/* Decodebin elements and properties*/
 	GstElement     *bin;
 	GList          *fsinks;
 #endif
 
-#if defined(GSTREAMER_BACKEND_DISCOVERER)
+#if defined(GSTREAMER_BACKEND_DISCOVERER) ||	  \
+	defined(GSTREAMER_BACKEND_GUPNP_DLNA)
 	gboolean        has_image;
 	gboolean        has_audio;
 	gboolean        has_video;
 	GList          *streams;
+#endif
 
-#if !defined(HAVE_GUPNP_DLNA)
-	GstDiscoverer        *discoverer;
-#else
+#if defined(GSTREAMER_BACKEND_DISCOVERER)
+	GstDiscoverer  *discoverer;
+#endif
+
+#if defined(GSTREAMER_BACKEND_GUPNP_DLNA)
 	GUPnPDLNADiscoverer  *discoverer;
 	GUPnPDLNAInformation *dlna_info;
 	const gchar          *dlna_profile;
 #endif
-#endif
 
 #if defined(GSTREAMER_BACKEND_DISCOVERER) ||	  \
-	defined(GSTREAMER_BACKEND_DECODEBIN2)
+	defined(GSTREAMER_BACKEND_DECODEBIN2) ||      \
+	defined(GSTREAMER_BACKEND_GUPNP_DLNA)
 	gint64          duration;
 	gint            audio_channels;
 	gint            audio_samplerate;
@@ -147,16 +156,6 @@ typedef struct {
 	gfloat          aspect_ratio;
 	gfloat          video_fps;
 #endif
-
-	/* Tags and data */
-	GstTagList     *tagcache;
-
-	gboolean        is_content_encrypted;
-
-	unsigned char  *album_art_data;
-	guint           album_art_size;
-	const gchar    *album_art_mime;
-
 } MetadataExtractor;
 
 #if defined(GSTREAMER_BACKEND_TAGREADBIN)
@@ -167,7 +166,8 @@ static void tagreadbin_extract_stream_metadata (MetadataExtractor    *extractor,
 static void decodebin2_extract_stream_metadata (MetadataExtractor    *extractor,
                                                 const gchar          *uri,
                                                 TrackerSparqlBuilder *metadata);
-#elif defined(GSTREAMER_BACKEND_DISCOVERER)
+#elif defined(GSTREAMER_BACKEND_DISCOVERER) ||	  \
+	defined(GSTREAMER_BACKEND_GUPNP_DLNA)
 static void discoverer_extract_stream_metadata (MetadataExtractor    *extractor,
                                                 const gchar          *uri,
                                                 TrackerSparqlBuilder *metadata);
@@ -420,7 +420,7 @@ extract_metadata (MetadataExtractor      *extractor,
 
 			g_free (video_codec);
 			g_free (audio_codec);
-#else /* DISCOVERER... */
+#else /* DISCOVERER/GUPNP-DLNA... */
 			if (extractor->has_video) {
 				extractor->mime = EXTRACT_MIME_VIDEO;
 			} else if (extractor->has_audio) {
@@ -431,7 +431,7 @@ extract_metadata (MetadataExtractor      *extractor,
 				/* default to video */
 				extractor->mime = EXTRACT_MIME_VIDEO;
 			}
-#endif /* defined(GSTREAMER_BACKEND_TAGREADBIN) || defined(GSTREAMER_BACKEND_DECODEBIN2)  */
+#endif
 		}
 
 		/* General */
@@ -811,14 +811,14 @@ extract_metadata (MetadataExtractor      *extractor,
 		tracker_sparql_builder_object_boolean (metadata, TRUE);
 	}
 #else
-#warning TODO: handle encrypted content with the Discoverer API
-#endif /* defined(GSTREAMER_BACKEND_TAGREADBIN) || defined(GSTREAMER_BACKEND_DECODEBIN2) */
+#warning TODO: handle encrypted content with the Discoverer/GUPnP-DLNA backends
+#endif
 
 #if defined(GSTREAMER_BACKEND_TAGREADBIN)
 	tagreadbin_extract_stream_metadata (extractor, uri, metadata);
 #elif defined(GSTREAMER_BACKEND_DECODEBIN2)
 	decodebin2_extract_stream_metadata (extractor, uri, metadata);
-#else /* defined(GSTREAMER_BACKEND_DISCOVERER) */
+#else /* DISCOVERER/GUPnP-DLNA */
 	discoverer_extract_stream_metadata (extractor, uri, metadata);
 #endif
 
@@ -827,9 +827,10 @@ extract_metadata (MetadataExtractor      *extractor,
 	}
 }
 
-/* ----------------------- Discoverer specific implementation --------------- */
+/* ----------------------- Discoverer/GUPnP-DLNA specific implementation --------------- */
 
-#if defined(GSTREAMER_BACKEND_DISCOVERER)
+#if defined(GSTREAMER_BACKEND_DISCOVERER) ||	  \
+	defined(GSTREAMER_BACKEND_GUPNP_DLNA)
 
 static void
 discoverer_shutdown (MetadataExtractor *extractor)
@@ -838,7 +839,7 @@ discoverer_shutdown (MetadataExtractor *extractor)
 		gst_discoverer_stream_info_list_free (extractor->streams);
 	if (extractor->discoverer)
 		g_object_unref (extractor->discoverer);
-#ifdef HAVE_GUPNP_DLNA
+#if defined(GSTREAMER_BACKEND_GUPNP_DLNA)
 	if (extractor->dlna_info)
 		g_object_unref (extractor->dlna_info);
 #endif
@@ -864,7 +865,7 @@ discoverer_init_and_run (MetadataExtractor *extractor,
 	extractor->has_video = FALSE;
 	extractor->has_audio = FALSE;
 
-#ifdef HAVE_GUPNP_DLNA
+#if defined(GSTREAMER_BACKEND_GUPNP_DLNA)
 	extractor->discoverer = gupnp_dlna_discoverer_new (5 * GST_SECOND, TRUE, FALSE);
 
 	/* Uri is const, the API should be const, but it isn't and it
@@ -889,7 +890,7 @@ discoverer_init_and_run (MetadataExtractor *extractor,
 	extractor->dlna_profile = gupnp_dlna_information_get_name (extractor->dlna_info);
 
 	info = (GstDiscovererInfo *) gupnp_dlna_information_get_info (extractor->dlna_info);
-#else
+#else /* DISCOVERER */
 	extractor->discoverer = gst_discoverer_new (5 * GST_SECOND, &error);
 	if (!extractor->discoverer) {
 		g_warning ("Couldn't create discoverer: %s",
@@ -1008,7 +1009,7 @@ discoverer_extract_stream_metadata (MetadataExtractor    *extractor,
 		}
 	}
 
-#if defined(HAVE_GUPNP_DLNA)
+#if defined(GSTREAMER_BACKEND_GUPNP_DLNA)
 	if (extractor->dlna_profile) {
 		tracker_sparql_builder_predicate (metadata, "nmm:dlnaProfile");
 		tracker_sparql_builder_object_string (metadata, extractor->dlna_profile);
@@ -1016,7 +1017,7 @@ discoverer_extract_stream_metadata (MetadataExtractor    *extractor,
 #endif
 }
 
-#endif /* defined(GSTREAMER_BACKEND_DISCOVERER) */
+#endif /* defined(GSTREAMER_BACKEND_DISCOVERER) || defined(GSTREAMER_BACKEND_GUPNP_DLNA) */
 
 /* --------------- Common Tagreadbin and Decodebin2 implementation ---------- */
 
@@ -1644,7 +1645,7 @@ tracker_extract_gstreamer (const gchar          *uri,
 #elif defined(GSTREAMER_BACKEND_DECODEBIN2)
 	if (!decodebin2_init_and_run (extractor, uri))
 		return;
-#else /* defined(GSTREAMER_BACKEND_DISCOVERER) */
+#else /* DISCOVERER/GUPnP-DLNA */
 	if (!discoverer_init_and_run (extractor, uri))
 		return;
 #endif
@@ -1674,7 +1675,7 @@ tracker_extract_gstreamer (const gchar          *uri,
 	tagreadbin_shutdown (extractor);
 #elif defined(GSTREAMER_BACKEND_DECODEBIN2)
 	decodebin2_shutdown (extractor);
-#else /* defined(GSTREAMER_BACKEND_DISCOVERER) */
+#else /* DISCOVERER/GUPnP-DLNA */
 	discoverer_shutdown (extractor);
 #endif
 
@@ -1688,11 +1689,11 @@ tracker_extract_get_metadata (const gchar          *uri,
                               TrackerSparqlBuilder *metadata,
                               GString              *where)
 {
-#ifdef HAVE_GUPNP_DLNA
+#if defined(GSTREAMER_BACKEND_GUPNP_DLNA)
 	if (g_str_has_prefix (mimetype, "dlna/")) {
 		tracker_extract_gstreamer (uri, preupdate, metadata, EXTRACT_MIME_GUESS);
 	} else
-#endif /* HAVE_GUPNP_DLNA */
+#endif
 
 	if (strcmp (mimetype, "image/svg+xml") == 0) {
 		tracker_extract_gstreamer (uri, preupdate, metadata, EXTRACT_MIME_SVG);



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