For the record.... 

Updating the previously incorrect patch with the attached version
(created via git revert this time) we run into yet another problem.

We have both lua 5.1 and 5.2 in the debian archive.

Old libquvi pulls in lua 5.1 and grilo-plugins-0.2 pulls in lua 5.2.

With totem-pl-parser rebuilt with the attached patch it means
totem will now crash on startup in lua (via grilo-plugins)....
likely caused by both lua versions being loaded at the same time
(without symbol versioning).

If I understand things correctly, when we get libquvi 0.9 this problem
is avoided since quvi (0.9 still uses lua 5.1 in debian) and
grilo-plugins runs in different processes.

Regards,
Andreas Henriksson
Revert "plparse: Port to libquvi 0.9"

This reverts commit 24970018abfcedcaa4965e1f0f987aaf63323f31.

Conflicts:
	configure.ac
	plparse/videosite-parser.c

--- a/configure.ac
+++ b/configure.ac
@@ -45,7 +45,7 @@ AC_PATH_PROG([GLIB_MKENUMS],[glib-mkenums])
 # Requirements
 GLIB_REQS=2.31.0
 GIO_REQS=2.24.0
-QUVI_REQS=0.9.1
+QUVI_REQS=0.2.15
 LIBARCHIVE_REQS=3.0
 LIBSOUP_REQS=2.43.0
 
@@ -114,18 +114,18 @@ AC_ARG_ENABLE(quvi,
 			     [enable_quvi=auto])
 if test "x$enable_quvi" != "xno" ; then
 	PKG_CHECK_MODULES(QUVI,
-			  libquvi-0.9 >= $QUVI_REQS glib-2.0,
+			  libquvi >= $QUVI_REQS,
 			  [have_quvi=yes], [have_quvi=no])
 	if test "x$enable_quvi" = "xyes" -a "x$have_quvi" = "xno" ; then
 		AC_MSG_ERROR([Quvi support requested but not available.])
 	fi
 	if test "x$have_quvi" = "xyes" ; then
-		QUVI="libquvi-0.9"
+		pkg_modules="$pkg_modules libquvi"
+		QUVI="libquvi"
 		AC_DEFINE(HAVE_QUVI, 1, [libquvi available in the system])
 	fi
 fi
 AC_SUBST(QUVI, $QUVI)
-AM_CONDITIONAL([HAVE_QUVI], [test "$have_quvi" = "yes"])
 
 ##################################
 # Checking libarchive dependency
diff --git a/plparse/Makefile.am b/plparse/Makefile.am
index 949975b..aee6393 100644
--- a/plparse/Makefile.am
+++ b/plparse/Makefile.am
@@ -72,7 +72,6 @@ libtotem_plparser_la_CPPFLAGS = \
 	-I$(top_srcdir)/lib			\
 	-I$(top_builddir)/plparse		\
 	-DGNOMELOCALEDIR=\""$(datadir)/locale"\"\
-	-DLIBEXECDIR=\""$(libexecdir)"\"	\
 	$(DISABLE_DEPRECATED)			\
 	$(AM_CPPFLAGS)
 
@@ -134,7 +133,6 @@ libtotem_plparser_mini_la_CPPFLAGS = \
 	-I$(top_srcdir)/lib		\
 	-I$(top_builddir)/plparse	\
 	-DTOTEM_PL_PARSER_MINI		\
-	-DLIBEXECDIR=\""$(libexecdir)"\"\
 	$(DISABLE_DEPRECATED)		\
 	$(AM_CPPFLAGS)
 
@@ -182,13 +180,6 @@ EXTRA_DIST =				\
 	plparser.symbols		\
 	plparser-mini.symbols
 
-if HAVE_QUVI
-libexec_PROGRAMS = totem-pl-parser-videosite
-totem_pl_parser_videosite_SOURCES = videosite-parser.c
-totem_pl_parser_videosite_CFLAGS = $(QUVI_CFLAGS) -DLIBEXECDIR=\""$(libexecdir)"\"
-totem_pl_parser_videosite_LDADD = $(QUVI_LIBS)
-endif
-
 # Introspection
 -include $(INTROSPECTION_MAKEFILE)
 INTROSPECTION_GIRS =
diff --git a/plparse/totem-pl-parser-videosite.c b/plparse/totem-pl-parser-videosite.c
index 743ef7f..631f4ca 100644
--- a/plparse/totem-pl-parser-videosite.c
+++ b/plparse/totem-pl-parser-videosite.c
@@ -24,41 +24,36 @@
 #include <string.h>
 #include <glib.h>
 
+#ifndef TOTEM_PL_PARSER_MINI
+#include "totem-disc.h"
+#endif /* !TOTEM_PL_PARSER_MINI */
+
+#ifdef HAVE_QUVI
+#include <quvi/quvi.h>
+#endif /* HAVE_QUVI */
+
 #include "totem-pl-parser-mini.h"
 #include "totem-pl-parser-videosite.h"
 #include "totem-pl-parser-private.h"
 
-#define BASE 20
-
 gboolean
 totem_pl_parser_is_videosite (const char *uri, gboolean debug)
 {
 #ifdef HAVE_QUVI
-	const char *args[] = {
-		LIBEXECDIR "/totem-pl-parser-videosite",
-		"--check",
-		"--url",
-		NULL,
-		NULL
-	};
-	char *out;
-
-	args[3] = uri;
-	g_spawn_sync (NULL,
-		      (char **) args,
-		      NULL,
-		      0,
-		      NULL,
-		      NULL,
-		      &out,
-		      NULL,
-		      NULL,
-		      NULL);
+	quvi_t handle;
+	QUVIcode rc;
+
+	if (quvi_init (&handle) != QUVI_OK)
+		return FALSE;
+
+	rc = quvi_supported(handle, (char *) uri);
+	quvi_close (&handle);
+
 	if (debug)
-		g_print ("Checking videosite for URI '%s' returned '%s' (%s)\n",
-			 uri, out, g_strcmp0 (out, "TRUE") == 0 ? "true" : "false");
+		g_print ("Checking videosite for URI '%s' returned %d (%s)\n",
+			 uri, rc, (rc == QUVI_OK) ? "true" : "false");
 
-	return (g_strcmp0 (out, "TRUE") == 0);
+	return (rc == QUVI_OK);
 #else
 	return FALSE;
 #endif /* HAVE_QUVI */
@@ -66,6 +61,10 @@ totem_pl_parser_is_videosite (const char *uri, gboolean debug)
 
 #ifndef TOTEM_PL_PARSER_MINI
 
+#define getprop(prop, p)					\
+	if (quvi_getprop (v, prop, &p) != QUVI_OK)		\
+		p = NULL;
+
 TotemPlParserResult
 totem_pl_parser_add_videosite (TotemPlParser *parser,
 			       GFile *file,
@@ -74,64 +73,75 @@ totem_pl_parser_add_videosite (TotemPlParser *parser,
 			       gpointer data)
 {
 #ifdef HAVE_QUVI
-	const char *args[] = {
-		LIBEXECDIR "/totem-pl-parser-videosite",
-		"--url",
-		NULL,
-		NULL
-	};
+	QUVIcode rc;
+	quvi_t handle;
+	quvi_media_t v;
 	char *uri;
-	char *out = NULL;
-	char **lines;
-	guint i;
-	GHashTable *ht;
-	char *new_uri = NULL;
+	/* properties */
+	const char *video_uri;
+	double length;
+	char *length_str;
+	const char *title;
+	const char *id;
+	const char *page_uri;
+	const char *starttime;
+	const char *content_type;
+	const char *thumb_url;
+	double duration;
+	char *duration_str;
+
+	if (quvi_init (&handle) != QUVI_OK)
+		return TOTEM_PL_PARSER_RESULT_ERROR;
 
-	uri = g_file_get_uri (file);
+	quvi_setopt(handle, QUVIOPT_NOVERIFY, TRUE);
+	quvi_setopt(handle, QUVIOPT_FORMAT, "best");
 
-	args[2] = uri;
-	g_spawn_sync (NULL,
-		      (char **) args,
-		      NULL,
-		      0,
-		      NULL,
-		      NULL,
-		      &out,
-		      NULL,
-		      NULL,
-		      NULL);
-	if (totem_pl_parser_is_debugging_enabled (parser))
-		g_print ("Parsing videosite for URI '%s' returned '%s'\n", uri, out);
-
-	if (out != NULL) {
-		if (g_str_equal (out, "TOTEM_PL_PARSER_RESULT_ERROR"))
-			return TOTEM_PL_PARSER_RESULT_ERROR;
-		if (g_str_equal (out, "TOTEM_PL_PARSER_RESULT_UNHANDLED"))
+	uri = g_file_get_uri (file);
+	rc = quvi_parse(handle, uri, &v);
+	if (rc != QUVI_OK) {
+		if (totem_pl_parser_is_debugging_enabled (parser))
+			g_print ("quvi_parse for '%s' returned %d\n", uri, rc);
+		g_free (uri);
+		quvi_close (&handle);
+		if (rc == QUVI_NOSUPPORT)
 			return TOTEM_PL_PARSER_RESULT_UNHANDLED;
-	} else {
-		/* totem-pl-parser-videosite failed to launch */
 		return TOTEM_PL_PARSER_RESULT_ERROR;
 	}
 
-	ht = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
-	lines = g_strsplit (out, "\n", -1);
-	g_free (out);
-	for (i = 0; lines[i] != NULL && *lines[i] != '\0'; i++) {
-		char **line;
-
-		line = g_strsplit (lines[i], "=", 2);
-		if (g_strcmp0 (line[0], TOTEM_PL_PARSER_FIELD_URI) == 0) {
-			if (new_uri == NULL)
-				new_uri = g_strdup (line[1]);
-		} else {
-			g_hash_table_insert (ht, g_strdup (line[0]), g_strdup (line[1]));
-		}
-		g_strfreev (line);
-	}
-	g_strfreev (lines);
-
-	totem_pl_parser_add_hash_table (parser, ht, new_uri, FALSE);
-	g_free (new_uri);
+	getprop (QUVIPROP_MEDIAURL, video_uri);
+	if (quvi_getprop (v, QUVIPROP_MEDIACONTENTLENGTH, &length) == QUVI_OK && length)
+		length_str = g_strdup_printf ("%f", length);
+	else
+		length_str = NULL;
+	getprop (QUVIPROP_PAGETITLE, title);
+	getprop (QUVIPROP_MEDIAID, id);
+	getprop (QUVIPROP_PAGEURL, page_uri);
+	getprop (QUVIPROP_STARTTIME, starttime);
+	getprop (QUVIPROP_MEDIACONTENTTYPE, content_type);
+	getprop (QUVIPROP_MEDIATHUMBNAILURL, thumb_url);
+	if (quvi_getprop (v, QUVIPROP_MEDIADURATION, &duration) == QUVI_OK && duration)
+		duration_str = g_strdup_printf ("%f", duration);
+	else
+		duration_str = NULL;
+
+	if (video_uri != NULL)
+		totem_pl_parser_add_uri (parser,
+					 TOTEM_PL_PARSER_FIELD_TITLE, title,
+					 TOTEM_PL_PARSER_FIELD_ID, id,
+					 TOTEM_PL_PARSER_FIELD_MOREINFO, page_uri,
+					 TOTEM_PL_PARSER_FIELD_URI, video_uri,
+					 TOTEM_PL_PARSER_FIELD_FILESIZE, length_str,
+					 TOTEM_PL_PARSER_FIELD_STARTTIME, starttime,
+					 TOTEM_PL_PARSER_FIELD_CONTENT_TYPE, content_type,
+					 TOTEM_PL_PARSER_FIELD_IMAGE_URI, thumb_url,
+					 TOTEM_PL_PARSER_FIELD_DURATION, duration_str,
+					 NULL);
+	g_free (uri);
+	g_free (length_str);
+	g_free (duration_str);
+
+	quvi_parse_close (&v);
+	quvi_close (&handle);
 
 	return TOTEM_PL_PARSER_RESULT_SUCCESS;
 #else
diff --git a/plparse/videosite-parser.c b/plparse/videosite-parser.c
deleted file mode 100644
index be374aa..0000000
--- a/plparse/videosite-parser.c
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
-   Copyright (C) 2013 Bastien Nocera <had...@hadess.net>
-
-   The Gnome Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Library General Public License as
-   published by the Free Software Foundation; either version 2 of the
-   License, or (at your option) any later version.
-
-   The Gnome Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Library General Public License for more details.
-
-   You should have received a copy of the GNU Library General Public
-   License along with the Gnome Library; see the file COPYING.LIB.  If not,
-   write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301  USA.
-
-   Author: Bastien Nocera <had...@hadess.net>
- */
-
-#include "config.h"
-
-#include <locale.h>
-
-#include <glib.h>
-#include <quvi.h>
-#include "totem-pl-parser.h"
-
-#define BASE 20
-
-static char *url = NULL;
-static gboolean check = FALSE;
-static gboolean debug = FALSE;
-
-const GOptionEntry options[] = {
-	{ "url", 'u', 0, G_OPTION_ARG_FILENAME, &url, "URL of the video site page", NULL },
-	{ "check", 'c', 0, G_OPTION_ARG_NONE, &check, "Check whether this URL is supported", NULL },
-	{ "debug", 'd', 0, G_OPTION_ARG_NONE, &debug, "Turn on debug mode", NULL },
-	{ NULL }
-};
-
-static gboolean
-supports_uri (const char *uri)
-{
-	quvi_t q;
-	QuviBoolean r;
-
-	q = quvi_new ();
-	r = quvi_supports (q, uri, QUVI_SUPPORTS_MODE_OFFLINE, QUVI_SUPPORTS_TYPE_ANY);
-	quvi_free (q);
-
-	return r;
-}
-
-static struct {
-	const char *container;
-	const char *content_type;
-} containers [] = {
-	{ "webm", "video/webm" },
-};
-
-static const char *
-container_to_content_type (const char *container)
-{
-	guint i;
-
-	if (container == NULL)
-		return NULL;
-	for (i = 0; i < G_N_ELEMENTS (containers); i++) {
-		if (g_str_equal (container, containers[i].container))
-			return containers[i].content_type;
-	}
-	return NULL;
-}
-
-static void
-print (const char *name,
-       const char *value)
-{
-	g_return_if_fail (name != NULL);
-
-	if (value == NULL)
-		return;
-
-	g_print ("%s=%s\n", name, value);
-}
-
-static void
-parse_videosite (const char *uri)
-{
-	quvi_t q;
-	quvi_media_t qm;
-	/* properties */
-	const char *video_uri;
-	const char *title;
-	const char *id;
-	const char *content_type;
-	const char *thumb_url;
-	const char *container;
-	double duration;
-	double starttime;
-	char *duration_str = NULL;
-	char *starttime_str = NULL;
-
-	if (!supports_uri (uri)) {
-		g_print ("TOTEM_PL_PARSER_RESULT_UNHANDLED");
-		return;
-	}
-
-	q = quvi_new ();
-	qm = quvi_media_new (q, uri);
-
-	/* Empty results list? */
-	if (quvi_media_stream_next(qm) != QUVI_TRUE) {
-		if (debug)
-			g_print ("Parsing '%s' failed with error: %s\n",
-				 uri, quvi_errmsg (q));
-		g_print ("TOTEM_PL_PARSER_RESULT_ERROR");
-		goto out;
-	}
-
-	/* Choose the best stream */
-	quvi_media_stream_choose_best (qm);
-
-	quvi_media_get (qm, QUVI_MEDIA_PROPERTY_TITLE, &title);
-	quvi_media_get (qm, QUVI_MEDIA_PROPERTY_ID, &id);
-	quvi_media_get (qm, QUVI_MEDIA_PROPERTY_THUMBNAIL_URL, &thumb_url);
-	quvi_media_get (qm, QUVI_MEDIA_PROPERTY_DURATION_MS, &duration);
-	if (duration)
-		duration_str = g_strdup_printf ("%f", duration);
-	quvi_media_get (qm, QUVI_MEDIA_STREAM_PROPERTY_URL, &video_uri);
-	quvi_media_get (qm, QUVI_MEDIA_PROPERTY_START_TIME_MS, &starttime);
-	if (starttime)
-		starttime_str = g_strdup_printf ("%f", starttime);
-
-	quvi_media_get (qm, QUVI_MEDIA_STREAM_PROPERTY_CONTAINER, &container);
-	content_type = container_to_content_type (container);
-
-	if (video_uri != NULL) {
-		print (TOTEM_PL_PARSER_FIELD_TITLE, title);
-		print (TOTEM_PL_PARSER_FIELD_ID, id);
-		print (TOTEM_PL_PARSER_FIELD_MOREINFO, uri);
-		print (TOTEM_PL_PARSER_FIELD_URI, video_uri);
-		print (TOTEM_PL_PARSER_FIELD_STARTTIME, starttime_str);
-		print (TOTEM_PL_PARSER_FIELD_CONTENT_TYPE, content_type);
-		print (TOTEM_PL_PARSER_FIELD_IMAGE_URI, thumb_url);
-		print (TOTEM_PL_PARSER_FIELD_DURATION, duration_str);
-	}
-
-	g_free (starttime_str);
-	g_free (duration_str);
-
-out:
-	quvi_media_free (qm);
-	quvi_free (q);
-}
-
-int main (int argc, char **argv)
-{
-	GOptionContext *context;
-
-	setlocale (LC_ALL, "");
-
-	context = g_option_context_new (NULL);
-	g_option_context_set_summary (context, "totem-pl-parser libquvi Helper");
-	g_option_context_add_main_entries (context, options, NULL);
-	g_option_context_parse (context, &argc, &argv, NULL);
-
-	if (url == NULL) {
-		char *txt;
-
-		txt = g_option_context_get_help (context, FALSE, NULL);
-		g_print ("%s", txt);
-		g_free (txt);
-
-		g_option_context_free (context);
-
-		return 1;
-	}
-	g_option_context_free (context);
-
-	if (check) {
-		g_print ("%s", supports_uri (url) ? "TRUE" : "FALSE");
-		return 0;
-	}
-
-	parse_videosite (url);
-
-	return 0;
-}
diff --git a/totem-plparser-mini-uninstalled.pc.in b/totem-plparser-mini-uninstalled.pc.in
index fb22f66..cb6c437 100644
--- a/totem-plparser-mini-uninstalled.pc.in
+++ b/totem-plparser-mini-uninstalled.pc.in
@@ -7,6 +7,6 @@ Name: totem-plparser
 Description: Totem Playlist Parser library
 Version: @VERSION@
 Requires: glib-2.0 gobject-2.0 gio-2.0
-Requires.private: gthread-2.0
+Requires.private: gthread-2.0 @QUVI@
 Libs: ${pc_top_builddir}/${pcfiledir}/plparse/libtotem-plparser-mini.la
 Cflags: -I${pc_top_builddir}/${pcfiledir}/plparse
diff --git a/totem-plparser-mini.pc.in b/totem-plparser-mini.pc.in
index 29ae520..777b93b 100644
--- a/totem-plparser-mini.pc.in
+++ b/totem-plparser-mini.pc.in
@@ -7,6 +7,6 @@ Name: totem-plparser-mini
 Description: Totem Playlist Parser library, mini version
 Version: @VERSION@
 Requires: glib-2.0 gobject-2.0 gio-2.0
-Requires.private: gthread-2.0
+Requires.private: gthread-2.0 @QUVI@
 Libs: -L${libdir} -ltotem-plparser-mini
 Cflags: -I${includedir}/totem-pl-parser/1/plparser
diff --git a/totem-plparser-uninstalled.pc.in b/totem-plparser-uninstalled.pc.in
index 7264037..6a3d0be 100644
--- a/totem-plparser-uninstalled.pc.in
+++ b/totem-plparser-uninstalled.pc.in
@@ -7,7 +7,7 @@ Name: totem-plparser
 Description: Totem Playlist Parser library
 Version: @VERSION@
 Requires: glib-2.0 gobject-2.0 gio-2.0
-Requires.private: gthread-2.0 libxml-2.0 @GMIME@
+Requires.private: gthread-2.0 libxml-2.0 @GMIME@ @QUVI@
 Libs: ${pc_top_builddir}/${pcfiledir}/plparse/libtotem-plparser.la
 Libs.private: @LIBGCRYPT_LIBS@
 Cflags: -I${pc_top_builddir}/${pcfiledir}/plparse @LIBGCRYPT_CFLAGS@
diff --git a/totem-plparser.pc.in b/totem-plparser.pc.in
index 16f9240..abf3cdd 100644
--- a/totem-plparser.pc.in
+++ b/totem-plparser.pc.in
@@ -7,7 +7,7 @@ Name: totem-plparser
 Description: Totem Playlist Parser library
 Version: @VERSION@
 Requires: glib-2.0 gobject-2.0 gio-2.0
-Requires.private: gthread-2.0 libxml-2.0 @GMIME@ @ARCHIVE@
+Requires.private: gthread-2.0 libxml-2.0 @GMIME@ @QUVI@ @ARCHIVE@
 Libs: -L${libdir} -ltotem-plparser
 Libs.private: @LIBGCRYPT_LIBS@
 Cflags: -I${includedir}/totem-pl-parser/1/plparser @LIBGCRYPT_CFLAGS@
-- 
2.0.0.rc0

Reply via email to