summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLionel Le Folgoc <mrpouit@ubuntu.com>2010-03-06 00:21:47 +0100
committerJannis Pohlmann <jannis@xfce.org>2010-07-16 12:32:38 +0200
commit2621ee8d1db623ef28f8b4aabd7fb246f9e8991e (patch)
treedd8abe6f2a8da3688e2c527347c3959d4323a750
parent50b035316092be7c22f652bc65fb8c133453b7d1 (diff)
downloadtumbler-2621ee8d1db623ef28f8b4aabd7fb246f9e8991e.tar.gz
Add a video thumbnailer (using libffmpegthumbnailer).
Signed-off-by: Jannis Pohlmann <jannis@xfce.org>
-rw-r--r--acinclude.m423
-rw-r--r--configure.ac23
-rw-r--r--plugins/Makefile.am1
-rw-r--r--plugins/ffmpeg-thumbnailer/Makefile.am58
-rw-r--r--plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer-plugin.c92
-rw-r--r--plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer-provider.c142
-rw-r--r--plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer-provider.h44
-rw-r--r--plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer.c307
-rw-r--r--plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer.h44
-rw-r--r--po/POTFILES.in3
10 files changed, 729 insertions, 8 deletions
diff --git a/acinclude.m4 b/acinclude.m4
index 568b4d7..ca93400 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -121,6 +121,29 @@ AC_MSG_RESULT([$ac_tumbler_jpeg_thumbnailer])
])
+dnl TUMBLER_FFMPEG_THUMBNAILER()
+dnl
+dnl Check whether to build and install the ffmpeg video thumbnailer plugin.
+dnl
+AC_DEFUN([TUMBLER_FFMPEG_THUMBNAILER],
+[
+AC_ARG_ENABLE([ffmpeg-thumbnailer], [AC_HELP_STRING([--disable-ffmpeg-thumbnailer], [Don't build the ffmpeg video thumbnailer plugin])],
+ [ac_tumbler_ffmpeg_thumbnailer=$enableval], [ac_tumbler_ffmpeg_thumbnailer=yes])
+if test x"$ac_tumbler_ffmpeg_thumbnailer" = x"yes"; then
+ dnl Check for gdk-pixbuf
+ PKG_CHECK_MODULES([GDK_PIXBUF], [gdk-pixbuf-2.0 >= 2.14],
+ [
+ dnl Check for libffmpegthumbnailer
+ PKG_CHECK_MODULES([FFMPEGTHUMBNAILER], [libffmpegthumbnailer >= 2.0.0], [], [ac_tumbler_ffmpeg_thumbnailer=no])
+ ], [ac_tumbler_ffmpeg_thumbnailer=no])
+fi
+
+AC_MSG_CHECKING([whether to build the ffmpeg video thumbnailer plugin])
+AM_CONDITIONAL([TUMBLER_FFMPEG_THUMBNAILER], [test x"$ac_tumbler_ffmpeg_thumbnailer" = x"yes"])
+AC_MSG_RESULT([$ac_tumbler_ffmpeg_thumbnailer])
+])
+
+
dnl TUMBLER_XDG_CACHE()
dnl
diff --git a/configure.ac b/configure.ac
index 5db2e4e..599ccc8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -153,6 +153,7 @@ dnl *************************
TUMBLER_FONT_THUMBNAILER()
TUMBLER_JPEG_THUMBNAILER()
TUMBLER_PIXBUF_THUMBNAILER()
+TUMBLER_FFMPEG_THUMBNAILER()
TUMBLER_XDG_CACHE()
dnl ***********************************
@@ -181,6 +182,7 @@ plugins/Makefile
plugins/font-thumbnailer/Makefile
plugins/jpeg-thumbnailer/Makefile
plugins/pixbuf-thumbnailer/Makefile
+plugins/ffmpeg-thumbnailer/Makefile
plugins/xdg-cache/Makefile
po/Makefile.in
tumbler/Makefile
@@ -200,23 +202,28 @@ echo
echo "Plugins:"
echo
if test x"$ac_tumbler_pixbuf_thumbnailer" = x"yes"; then
-echo " * GdkPixbuf thumbnailer plugin: yes"
+echo " * GdkPixbuf thumbnailer plugin: yes"
else
-echo " * GdkPixbuf thumbnailer plugin: no"
+echo " * GdkPixbuf thumbnailer plugin: no"
fi
if test x"$ac_tumbler_font_thumbnailer" = x"yes"; then
-echo " * FreeType font thumbnailer plugin: yes"
+echo " * FreeType font thumbnailer plugin: yes"
else
-echo " * FreeType font thumbnailer plugin: no"
+echo " * FreeType font thumbnailer plugin: no"
fi
if test x"$ac_tumbler_jpeg_thumbnailer" = x"yes"; then
-echo " * JPEG thumbnailer plugin with EXIF support: yes"
+echo " * JPEG thumbnailer plugin with EXIF support: yes"
else
-echo " * JPEG thumbnailer plugin with EXIF support: no"
+echo " * JPEG thumbnailer plugin with EXIF support: no"
+fi
+if test x"$ac_tumbler_ffmpeg_thumbnailer" = x"yes"; then
+echo " * Video thumbnailer plugin using ffmpegthumbnailer: yes"
+else
+echo " * Video thumbnailer plugin using ffmpegthumbnailer: no"
fi
if test x"$ac_tumbler_xdg_cache" = x"yes"; then
-echo " * Freedesktop.org cache plugin: yes"
+echo " * Freedesktop.org cache plugin: yes"
else
-echo " * Freedesktop.org cache plugin: no"
+echo " * Freedesktop.org cache plugin: no"
fi
echo
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 983884b..1320b14 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -21,4 +21,5 @@ SUBDIRS = \
font-thumbnailer \
jpeg-thumbnailer \
pixbuf-thumbnailer \
+ ffmpeg-thumbnailer \
xdg-cache
diff --git a/plugins/ffmpeg-thumbnailer/Makefile.am b/plugins/ffmpeg-thumbnailer/Makefile.am
new file mode 100644
index 0000000..1aae717
--- /dev/null
+++ b/plugins/ffmpeg-thumbnailer/Makefile.am
@@ -0,0 +1,58 @@
+# vi:set ts=8 sw=8 noet ai nocindent:
+# -
+# Copyright (c) 2009 Jannis Pohlmann <jannis@xfce.org>
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program 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 General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with this program; if not, write to the Free
+# Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+# Boston, MA 02110-1301, USA.
+
+if TUMBLER_FFMPEG_THUMBNAILER
+
+tumbler_plugindir = $(libdir)/tumbler-$(TUMBLER_VERSION_API)/plugins
+tumbler_plugin_LTLIBRARIES = \
+ tumbler-ffmpeg-thumbnailer.la
+
+tumbler_ffmpeg_thumbnailer_la_SOURCES = \
+ ffmpeg-thumbnailer-plugin.c \
+ ffmpeg-thumbnailer-provider.c \
+ ffmpeg-thumbnailer-provider.h \
+ ffmpeg-thumbnailer.c \
+ ffmpeg-thumbnailer.h
+
+tumbler_ffmpeg_thumbnailer_la_CFLAGS = \
+ -I$(top_builddir) \
+ -I$(top_builddir)/plugins \
+ -I$(top_srcdir) \
+ -I$(top_srcdir)/plugins \
+ -DG_LOG_DOMAIN=\"tumbler-ffmpeg-thumbnailer\" \
+ -DPACKAGE_LOCALE_DIR=\"$(localedir)\" \
+ $(GDK_PIXBUF_CFLAGS) \
+ $(GIO_CFLAGS) \
+ $(GLIB_CFLAGS) \
+ $(FFMPEGTHUMBNAILER_CFLAGS) \
+ $(PLATFORM_CPPFLAGS)
+
+tumbler_ffmpeg_thumbnailer_la_LDFLAGS = \
+ -avoid-version \
+ -export-dynamic \
+ -module \
+ $(PLATFORM_LDFLAGS)
+
+tumbler_ffmpeg_thumbnailer_la_LIBADD = \
+ $(GDK_PIXBUF_LIBS) \
+ $(GIO_LIBS) \
+ $(GLIB_LIBS) \
+ $(FFMPEGTHUMBNAILER_LIBS)
+
+endif
diff --git a/plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer-plugin.c b/plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer-plugin.c
new file mode 100644
index 0000000..93fec59
--- /dev/null
+++ b/plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer-plugin.c
@@ -0,0 +1,92 @@
+/* vi:set et ai sw=2 sts=2 ts=2: */
+/*-
+ * Copyright (c) 2009 Jannis Pohlmann <jannis@xfce.org>
+ * Copyright (c) 2010 Lionel Le Folgoc <mrpouit@ubuntu.com>
+ *
+ * This 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.
+ *
+ * This 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 this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <glib-object.h>
+
+#include <tumbler/tumbler.h>
+
+#include <ffmpeg-thumbnailer/ffmpeg-thumbnailer-provider.h>
+#include <ffmpeg-thumbnailer/ffmpeg-thumbnailer.h>
+
+
+
+G_MODULE_EXPORT void tumbler_plugin_initialize (TumblerProviderPlugin *plugin);
+G_MODULE_EXPORT void tumbler_plugin_shutdown (void);
+G_MODULE_EXPORT void tumbler_plugin_get_types (const GType **types,
+ gint *n_types);
+
+
+
+static GType type_list[1];
+
+
+
+void
+tumbler_plugin_initialize (TumblerProviderPlugin *plugin)
+{
+ const gchar *mismatch;
+
+ /* verify that the tumbler versions are compatible */
+ mismatch = tumbler_check_version (TUMBLER_MAJOR_VERSION, TUMBLER_MINOR_VERSION,
+ TUMBLER_MICRO_VERSION);
+ if (G_UNLIKELY (mismatch != NULL))
+ {
+ g_warning (_("Version mismatch: %s"), mismatch);
+ return;
+ }
+
+#ifdef DEBUG
+ g_message (_("Initializing the Tumbler ffmpeg video thumbnailer plugin"));
+#endif
+
+ /* register the types provided by this plugin */
+ ffmpeg_thumbnailer_register (plugin);
+ ffmpeg_thumbnailer_provider_register (plugin);
+
+ /* set up the plugin provider type list */
+ type_list[0] = TYPE_FFMPEG_THUMBNAILER_PROVIDER;
+}
+
+
+
+void
+tumbler_plugin_shutdown (void)
+{
+#ifdef DEBUG
+ g_message (_("Shutting down the Tumbler ffmpeg video thumbnailer plugin"));
+#endif
+}
+
+
+
+void
+tumbler_plugin_get_types (const GType **types,
+ gint *n_types)
+{
+ *types = type_list;
+ *n_types = G_N_ELEMENTS (type_list);
+}
diff --git a/plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer-provider.c b/plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer-provider.c
new file mode 100644
index 0000000..09ff768
--- /dev/null
+++ b/plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer-provider.c
@@ -0,0 +1,142 @@
+/* vi:set et ai sw=2 sts=2 ts=2: */
+/*-
+ * Copyright (c) 2009 Jannis Pohlmann <jannis@xfce.org>
+ * Copyright (c) 2010 Lionel Le Folgoc <mrpouit@ubuntu.com>
+ *
+ * This 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.
+ *
+ * This 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 this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <glib.h>
+#include <glib-object.h>
+
+#include <gdk-pixbuf/gdk-pixbuf.h>
+
+#include <tumbler/tumbler.h>
+
+#include <ffmpeg-thumbnailer/ffmpeg-thumbnailer-provider.h>
+#include <ffmpeg-thumbnailer/ffmpeg-thumbnailer.h>
+
+
+
+static void ffmpeg_thumbnailer_provider_thumbnailer_provider_init (TumblerThumbnailerProviderIface *iface);
+static GList *ffmpeg_thumbnailer_provider_get_thumbnailers (TumblerThumbnailerProvider *provider);
+
+
+
+struct _FfmpegThumbnailerProviderClass
+{
+ GObjectClass __parent__;
+};
+
+struct _FfmpegThumbnailerProvider
+{
+ GObject __parent__;
+};
+
+
+
+G_DEFINE_DYNAMIC_TYPE_EXTENDED (FfmpegThumbnailerProvider,
+ ffmpeg_thumbnailer_provider,
+ G_TYPE_OBJECT,
+ 0,
+ TUMBLER_ADD_INTERFACE (TUMBLER_TYPE_THUMBNAILER_PROVIDER,
+ ffmpeg_thumbnailer_provider_thumbnailer_provider_init));
+
+
+
+void
+ffmpeg_thumbnailer_provider_register (TumblerProviderPlugin *plugin)
+{
+ ffmpeg_thumbnailer_provider_register_type (G_TYPE_MODULE (plugin));
+}
+
+
+
+static void
+ffmpeg_thumbnailer_provider_class_init (FfmpegThumbnailerProviderClass *klass)
+{
+ GObjectClass *gobject_class;
+
+ gobject_class = G_OBJECT_CLASS (klass);
+}
+
+
+
+static void
+ffmpeg_thumbnailer_provider_class_finalize (FfmpegThumbnailerProviderClass *klass)
+{
+}
+
+
+
+static void
+ffmpeg_thumbnailer_provider_thumbnailer_provider_init (TumblerThumbnailerProviderIface *iface)
+{
+ iface->get_thumbnailers = ffmpeg_thumbnailer_provider_get_thumbnailers;
+}
+
+
+
+static void
+ffmpeg_thumbnailer_provider_init (FfmpegThumbnailerProvider *provider)
+{
+}
+
+
+
+static GList *
+ffmpeg_thumbnailer_provider_get_thumbnailers (TumblerThumbnailerProvider *provider)
+{
+ static const gchar *mime_types[] =
+ {
+ "video/jpeg",
+ "video/mp4",
+ "video/mpeg",
+ "video/quicktime",
+ "video/x-ms-asf",
+ "video/x-ms-wm",
+ "video/x-ms-wmv",
+ "video/x-msvideo",
+ "video/x-flv",
+ "application/x-flash-video",
+ "video/3gpp",
+ "video/x-matroska",
+ NULL
+ };
+ FfmpegThumbnailer *thumbnailer;
+ GList *thumbnailers = NULL;
+ GStrv uri_schemes;
+
+ /* determine the URI schemes supported by GIO */
+ uri_schemes = tumbler_util_get_supported_uri_schemes ();
+
+ /* create the pixbuf thumbnailer */
+ thumbnailer = g_object_new (TYPE_FFMPEG_THUMBNAILER,
+ "uri-schemes", uri_schemes, "mime-types", mime_types,
+ NULL);
+
+ /* add the thumbnailer to the list */
+ thumbnailers = g_list_append (thumbnailers, thumbnailer);
+
+ /* free URI schemes */
+ g_strfreev (uri_schemes);
+
+ return thumbnailers;
+}
diff --git a/plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer-provider.h b/plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer-provider.h
new file mode 100644
index 0000000..699e6ba
--- /dev/null
+++ b/plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer-provider.h
@@ -0,0 +1,44 @@
+/* vi:set et ai sw=2 sts=2 ts=2: */
+/*-
+ * Copyright (c) 2009 Jannis Pohlmann <jannis@xfce.org>
+ * Copyright (c) 2010 Lionel Le Folgoc <mrpouit@ubuntu.com>
+ *
+ * This 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.
+ *
+ * This 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 this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __FFMPEG_THUMBNAILER_PROVIDER_H__
+#define __FFMPEG_THUMBNAILER_PROVIDER_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS;
+
+#define TYPE_FFMPEG_THUMBNAILER_PROVIDER (ffmpeg_thumbnailer_provider_get_type ())
+#define FFMPEG_THUMBNAILER_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FFMPEG_THUMBNAILER_PROVIDER, FfmpegThumbnailerProvider))
+#define FFMPEG_THUMBNAILER_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_FFMPEG_THUMBNAILER_PROVIDER, FfmpegThumbnailerProviderClass))
+#define IS_FFMPEG_THUMBNAILER_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FFMPEG_THUMBNAILER_PROVIDER))
+#define IS_FFMPEG_THUMBNAILER_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_FFMPEG_THUMBNAILER_PROVIDER)
+#define FFMPEG_THUMBNAILER_PROVIDER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_FFMPEG_THUMBNAILER_PROVIDER, FfmpegThumbnailerProviderClass))
+
+typedef struct _FfmpegThumbnailerProviderClass FfmpegThumbnailerProviderClass;
+typedef struct _FfmpegThumbnailerProvider FfmpegThumbnailerProvider;
+
+GType ffmpeg_thumbnailer_provider_get_type (void) G_GNUC_CONST;
+void ffmpeg_thumbnailer_provider_register (TumblerProviderPlugin *plugin);
+
+G_END_DECLS;
+
+#endif /* !__FFMPEG_THUMBNAILER_PROVIDER_H__ */
diff --git a/plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer.c b/plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer.c
new file mode 100644
index 0000000..04cbb9d
--- /dev/null
+++ b/plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer.c
@@ -0,0 +1,307 @@
+/* vi:set et ai sw=2 sts=2 ts=2: */
+/*-
+ * Copyright (c) 2009 Jannis Pohlmann <jannis@xfce.org>
+ * Copyright (c) 2010 Lionel Le Folgoc <mrpouit@ubuntu.com>
+ *
+ * This 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.
+ *
+ * This 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 this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <math.h>
+
+#include <glib.h>
+#include <glib/gi18n.h>
+#include <glib-object.h>
+
+#include <gdk-pixbuf/gdk-pixbuf.h>
+
+#include <libffmpegthumbnailer/videothumbnailerc.h>
+
+#include <tumbler/tumbler.h>
+
+#include <ffmpeg-thumbnailer/ffmpeg-thumbnailer.h>
+
+
+static void ffmpeg_thumbnailer_finalize (GObject *object);
+static void ffmpeg_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
+ GCancellable *cancellable,
+ TumblerFileInfo *info);
+
+
+
+struct _FfmpegThumbnailerClass
+{
+ TumblerAbstractThumbnailerClass __parent__;
+};
+
+struct _FfmpegThumbnailer
+{
+ TumblerAbstractThumbnailer __parent__;
+
+ video_thumbnailer *video;
+};
+
+
+
+G_DEFINE_DYNAMIC_TYPE (FfmpegThumbnailer,
+ ffmpeg_thumbnailer,
+ TUMBLER_TYPE_ABSTRACT_THUMBNAILER);
+
+
+
+void
+ffmpeg_thumbnailer_register (TumblerProviderPlugin *plugin)
+{
+ ffmpeg_thumbnailer_register_type (G_TYPE_MODULE (plugin));
+}
+
+
+
+static void
+ffmpeg_thumbnailer_class_init (FfmpegThumbnailerClass *klass)
+{
+ TumblerAbstractThumbnailerClass *abstractthumbnailer_class;
+ GObjectClass *gobject_class;
+
+ gobject_class = G_OBJECT_CLASS (klass);
+ gobject_class->finalize = ffmpeg_thumbnailer_finalize;
+
+ abstractthumbnailer_class = TUMBLER_ABSTRACT_THUMBNAILER_CLASS (klass);
+ abstractthumbnailer_class->create = ffmpeg_thumbnailer_create;
+}
+
+
+
+static void
+ffmpeg_thumbnailer_class_finalize (FfmpegThumbnailerClass *klass)
+{
+}
+
+
+
+static void
+ffmpeg_thumbnailer_init (FfmpegThumbnailer *thumbnailer)
+{
+ /* initialize libffmpegthumbnailer with default parameters */
+ thumbnailer->video = video_thumbnailer_create ();
+ thumbnailer->video->seek_percentage = 15;
+ thumbnailer->video->overlay_film_strip = 1;
+ thumbnailer->video->thumbnail_image_type = Png;
+}
+
+
+
+static void
+ffmpeg_thumbnailer_finalize (GObject *object)
+{
+ FfmpegThumbnailer *thumbnailer = FFMPEG_THUMBNAILER (object);
+
+ /* release the libffmpegthumbnailer video object */
+ video_thumbnailer_destroy (thumbnailer->video);
+
+ (*G_OBJECT_CLASS (ffmpeg_thumbnailer_parent_class)->finalize) (object);
+}
+
+
+
+static GdkPixbuf *
+generate_pixbuf (GdkPixbuf *source,
+ gint dest_width,
+ gint dest_height)
+{
+ gdouble hratio;
+ gdouble wratio;
+ gint source_width;
+ gint source_height;
+
+ /* determine the source pixbuf dimensions */
+ source_width = gdk_pixbuf_get_width (source);
+ source_height = gdk_pixbuf_get_height (source);
+
+ /* return the same pixbuf if no scaling is required */
+ if (source_width <= dest_width && source_height <= dest_height)
+ return g_object_ref (source);
+
+ /* determine which axis needs to be scaled down more */
+ wratio = (gdouble) source_width / (gdouble) dest_width;
+ hratio = (gdouble) source_height / (gdouble) dest_height;
+
+ /* adjust the other axis */
+ if (hratio > wratio)
+ dest_width = rint (source_width / hratio);
+ else
+ dest_height = rint (source_height / wratio);
+
+ /* scale the pixbuf down to the desired size */
+ return gdk_pixbuf_scale_simple (source, MAX (dest_width, 1), MAX (dest_height, 1),
+ GDK_INTERP_BILINEAR);
+}
+
+
+
+static void
+ffmpeg_thumbnailer_create (TumblerAbstractThumbnailer *thumbnailer,
+ GCancellable *cancellable,
+ TumblerFileInfo *info)
+{
+ image_data *v_data;
+ GInputStream *v_stream;
+ GdkPixbuf *v_pixbuf;
+ FfmpegThumbnailer *ffmpeg_thumbnailer = FFMPEG_THUMBNAILER (thumbnailer);
+ TumblerThumbnailFlavor *flavor;
+ TumblerThumbnail *thumbnail;
+ TumblerImageData data;
+ GdkPixbuf *pixbuf;
+ GFile *file;
+ GError *error = NULL;
+ gint dest_width;
+ gint dest_height;
+ gchar *path;
+ const gchar *uri;
+
+ g_return_if_fail (IS_FFMPEG_THUMBNAILER (thumbnailer));
+ g_return_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable));
+ g_return_if_fail (TUMBLER_IS_FILE_INFO (info));
+
+ /* do nothing if cancelled */
+ if (g_cancellable_is_cancelled (cancellable))
+ return;
+
+ /* fetch required info */
+ thumbnail = tumbler_file_info_get_thumbnail (info);
+ g_assert (thumbnail != NULL);
+ flavor = tumbler_thumbnail_get_flavor (thumbnail);
+ tumbler_thumbnail_flavor_get_size (flavor, &dest_width, &dest_height);
+ g_object_unref (flavor);
+
+ /* prepare the video thumbnailer */
+ ffmpeg_thumbnailer->video->thumbnail_size = MAX (dest_width, dest_height);
+ v_data = video_thumbnailer_create_image_data ();
+
+ uri = tumbler_file_info_get_uri (info);
+
+ /* try to open the source file for reading */
+ file = g_file_new_for_uri (uri);
+
+ if (g_file_is_native (file))
+ {
+ path = g_file_get_path (file);
+ }
+ else
+ {
+ /* there was an error, emit error signal */
+ g_set_error (&error, TUMBLER_ERROR, TUMBLER_ERROR_INVALID_FORMAT,
+ _("Thumbnail could not be inferred from file contents"));
+ g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message);
+ g_error_free (error);
+
+ /* clean up */
+ g_object_unref (file);
+ g_object_unref (thumbnail);
+ video_thumbnailer_destroy_image_data (v_data);
+ return;
+ }
+ g_object_unref (file);
+
+ /* try to generate a thumbnail */
+ if (video_thumbnailer_generate_thumbnail_to_buffer (ffmpeg_thumbnailer->video, path, v_data) != 0)
+ {
+ /* there was an error, emit error signal */
+ g_set_error (&error, TUMBLER_ERROR, TUMBLER_ERROR_INVALID_FORMAT,
+ _("Thumbnail could not be inferred from file contents"));
+ g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message);
+ g_error_free (error);
+
+ /* clean up */
+ g_free (path);
+ g_object_unref (thumbnail);
+ video_thumbnailer_destroy_image_data (v_data);
+ return;
+ }
+ g_free (path);
+
+ v_stream = g_memory_input_stream_new_from_data (v_data->image_data_ptr,
+ v_data->image_data_size, NULL);
+
+ if (v_stream == NULL)
+ {
+ /* there was an error, emit error signal */
+ g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message);
+ g_error_free (error);
+
+ /* clean up */
+ g_object_unref (thumbnail);
+ video_thumbnailer_destroy_image_data (v_data);
+ return;
+ }
+
+ v_pixbuf = gdk_pixbuf_new_from_stream (v_stream, cancellable, &error);
+
+ g_object_unref (v_stream);
+ video_thumbnailer_destroy_image_data (v_data);
+
+ if (v_pixbuf == NULL)
+ {
+ /* emit an error signal */
+ g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message);
+ g_error_free (error);
+
+ /* clean up */
+ g_object_unref (thumbnail);
+
+ return;
+ }
+
+ /* generate a valid thumbnail */
+ pixbuf = generate_pixbuf (v_pixbuf, dest_width, dest_height);
+
+ g_assert (pixbuf != NULL);
+
+ /* compose the image data */
+ data.data = gdk_pixbuf_get_pixels (pixbuf);
+ data.has_alpha = gdk_pixbuf_get_has_alpha (pixbuf);
+ data.bits_per_sample = gdk_pixbuf_get_bits_per_sample (pixbuf);
+ data.width = gdk_pixbuf_get_width (pixbuf);
+ data.height = gdk_pixbuf_get_height (pixbuf);
+ data.rowstride = gdk_pixbuf_get_rowstride (pixbuf);
+ data.colorspace = (TumblerColorspace) gdk_pixbuf_get_colorspace (pixbuf);
+
+ /* save the thumbnail */
+ tumbler_thumbnail_save_image_data (thumbnail, &data,
+ tumbler_file_info_get_mtime (info),
+ NULL, &error);
+
+ /* check if there was an error */
+ if (error != NULL)
+ {
+ /* emit an error signal */
+ g_signal_emit_by_name (thumbnailer, "error", uri, error->code, error->message);
+ g_error_free (error);
+ }
+ else
+ {
+ /* otherwise, the thumbnail is now ready */
+ g_signal_emit_by_name (thumbnailer, "ready", uri);
+ }
+
+ /* clean up */
+ g_object_unref (thumbnail);
+ g_object_unref (pixbuf);
+ g_object_unref (v_pixbuf);
+}
diff --git a/plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer.h b/plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer.h
new file mode 100644
index 0000000..62de709
--- /dev/null
+++ b/plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer.h
@@ -0,0 +1,44 @@
+/* vi:set et ai sw=2 sts=2 ts=2: */
+/*-
+ * Copyright (c) 2009 Jannis Pohlmann <jannis@xfce.org>
+ * Copyright (c) 2010 Lionel Le Folgoc <mrpouit@ubuntu.com>
+ *
+ * This 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.
+ *
+ * This 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 this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ */
+
+#ifndef __FFMPEG_THUMBNAILER_H__
+#define __FFMPEG_THUMBNAILER_H__
+
+#include <glib-object.h>
+
+G_BEGIN_DECLS;
+
+#define TYPE_FFMPEG_THUMBNAILER (ffmpeg_thumbnailer_get_type ())
+#define FFMPEG_THUMBNAILER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FFMPEG_THUMBNAILER, FfmpegThumbnailer))
+#define FFMPEG_THUMBNAILER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_FFMPEG_THUMBNAILER, FfmpegThumbnailerClass))
+#define IS_FFMPEG_THUMBNAILER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FFMPEG_THUMBNAILER))
+#define IS_FFMPEG_THUMBNAILER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_FFMPEG_THUMBNAILER)
+#define FFMPEG_THUMBNAILER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_FFMPEG_THUMBNAILER, FfmpegThumbnailerClass))
+
+typedef struct _FfmpegThumbnailerClass FfmpegThumbnailerClass;
+typedef struct _FfmpegThumbnailer FfmpegThumbnailer;
+
+GType ffmpeg_thumbnailer_get_type (void) G_GNUC_CONST;
+void ffmpeg_thumbnailer_register (TumblerProviderPlugin *plugin);
+
+G_END_DECLS;
+
+#endif /* !__FFMPEG_THUMBNAILER_H__ */
diff --git a/po/POTFILES.in b/po/POTFILES.in
index c68c85b..58e6832 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -27,6 +27,9 @@ plugins/font-thumbnailer/font-thumbnailer-provider.c
plugins/jpeg-thumbnailer/jpeg-thumbnailer.c
plugins/jpeg-thumbnailer/jpeg-thumbnailer-plugin.c
plugins/jpeg-thumbnailer/jpeg-thumbnailer-provider.c
+plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer.c
+plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer-plugin.c
+plugins/ffmpeg-thumbnailer/ffmpeg-thumbnailer-provider.c
plugins/xdg-cache/xdg-cache-thumbnail.c
plugins/xdg-cache/xdg-cache-plugin.c
plugins/xdg-cache/xdg-cache-cache.c