Added epdf plugin.

Err... maybe I forgot to svn add some files in my previous commit...



SVN revision: 40277
This commit is contained in:
Rafael Antognolli 2009-04-21 23:03:50 +00:00
parent 4aea12e286
commit 939afcb3ea
11 changed files with 271 additions and 3 deletions

View File

@ -60,6 +60,17 @@ if $USE_MODULE_EMOTION ; then
requirement_ethumb="$requirement_ethumb emotion"
fi
AM_CONDITIONAL(HAVE_EPDF, false)
define([CHECK_MODULE_EPDF],
[
AC_ETH_CHECK_PKG(EPDF, epdf, [], [EPDF=false])
])
AC_ETH_OPTIONAL_MODULE([epdf], true, [CHECK_MODULE_EPDF])
if $USE_MODULE_EPDF ; then
requirement_ethumb="$requirement_ethumb epdf"
fi
AC_SUBST(requirement_ethumb)
AC_OUTPUT([
@ -70,6 +81,7 @@ src/bin/Makefile
src/lib/Makefile
src/plugins/Makefile
src/plugins/emotion/Makefile
src/plugins/epdf/Makefile
data/Makefile
data/frames/Makefile
m4/Makefile

View File

@ -118,6 +118,8 @@ const Ecore_Getopt optdesc = {
('k', "key", "key inside eet file to read image from."),
ECORE_GETOPT_STORE_DOUBLE
('v', "video_time", "time of video frame to use as thumbnail."),
ECORE_GETOPT_STORE_INT
('p', "document_page", "document page to use as thumbnail."),
ECORE_GETOPT_LICENSE('L', "license"),
ECORE_GETOPT_COPYRIGHT('C', "copyright"),
ECORE_GETOPT_VERSION('V', "version"),
@ -149,6 +151,7 @@ main(int argc, char *argv[])
const char *thumb_path = NULL;
const char *thumb_key = NULL;
double video_time = 0;
int page = 0;
int arg_index;
int i;
@ -165,6 +168,7 @@ main(int argc, char *argv[])
ECORE_GETOPT_VALUE_PTR_CAST(frame),
ECORE_GETOPT_VALUE_STR(src_key),
ECORE_GETOPT_VALUE_DOUBLE(video_time),
ECORE_GETOPT_VALUE_INT(page),
ECORE_GETOPT_VALUE_BOOL(quit_option),
ECORE_GETOPT_VALUE_BOOL(quit_option),
ECORE_GETOPT_VALUE_BOOL(quit_option),
@ -212,6 +216,8 @@ main(int argc, char *argv[])
}
if (video_time > 0)
ethumb_video_time_set(e, video_time);
if (page > 0)
ethumb_document_page_set(e, page);
if (r && arg_index < argc)
ef = ethumb_file_new(e, argv[arg_index++], src_key);
@ -226,7 +232,7 @@ main(int argc, char *argv[])
r = ethumb_file_generate(ef, _finished_thumb, NULL);
}
if (r)
if (r && !quit_option)
ecore_main_loop_begin();
ethumb_file_free(ef);

View File

@ -500,6 +500,14 @@ ethumb_video_time_set(Ethumb *e, float time)
e->video.time = time;
}
EAPI void
ethumb_document_page_set(Ethumb *e, int page)
{
EINA_SAFETY_ON_NULL_RETURN(e);
e->document.page = page;
}
EAPI Ethumb_File *
ethumb_file_new(Ethumb *e, const char *path, const char *key)
{

View File

@ -89,11 +89,14 @@ struct _Ethumb
{
double time;
} video;
struct
{
int page;
} document;
Ethumb_Frame *frame;
Ecore_Evas *ee, *sub_ee;
Evas *e, *sub_e;
Evas_Object *o, *img;
Evas_Object *plugin_img;
Ecore_Idler *finished_idler;
ethumb_generate_callback_t finished_cb;
void *cb_data;
@ -139,6 +142,7 @@ EAPI void ethumb_thumb_category_set(Ethumb *e, const char *category) EINA_ARG_NO
EAPI const char * ethumb_thumb_category_get(Ethumb *e) EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1) EINA_PURE;
EAPI void ethumb_video_time_set(Ethumb *e, float time) EINA_ARG_NONNULL(1);
EAPI void ethumb_document_page_set(Ethumb *e, int page) EINA_ARG_NONNULL(1);
EAPI Ethumb_File * ethumb_file_new(Ethumb *e, const char *path, const char *key) EINA_MALLOC EINA_WARN_UNUSED_RESULT EINA_ARG_NONNULL(1, 2);
EAPI void ethumb_file_free(Ethumb_File *ef);

View File

@ -0,0 +1,23 @@
#ifndef _ETHUMB_PLUGIN_H_
#define _ETHUMB_PLUGIN_H_
#include <Ethumb.h>
#include <Eina.h>
#include <Evas.h>
typedef struct _Ethumb_Plugin Ethumb_Plugin;
struct _Ethumb_Plugin
{
const char **extensions;
int (*generate_thumb)(Ethumb_File *);
void (*shutdown)(Ethumb_Plugin *);
};
void ethumb_calculate_aspect(Ethumb *e, int iw, int ih, int *w, int *h);
void ethumb_calculate_fill(Ethumb *e, int iw, int ih, int *fx, int *fy, int *fw, int *fh);
int ethumb_plugin_image_resize(Ethumb_File *ef, int w, int h);
int ethumb_image_save(Ethumb_File *ef);
void ethumb_finished_callback_call(Ethumb_File *ef);
#endif /* _ETHUMB_PLUGIN_H_ */

View File

@ -5,7 +5,7 @@ AM_CPPFLAGS = \
-I$(top_builddir) \
@EVAS_CFLAGS@ @ECORE_EVAS_CFLAGS@ @ECORE_FILE_CFLAGS@ @EDJE_CFLAGS@
include_HEADERS = Ethumb.h
include_HEADERS = Ethumb.h Ethumb_Plugin.h
noinst_HEADERS = md5.h
lib_LTLIBRARIES = libethumb.la

View File

@ -0,0 +1,15 @@
MAINTAINERCLEANFILES = Makefile.in
SUBDIRS =
if USE_MODULE_EMOTION
SUBDIRS += emotion
endif
if USE_MODULE_EMOTION
SUBDIRS += epdf
endif
DIST_SUBDIRS = \
emotion \
epdf

View File

@ -0,0 +1,12 @@
MAINTAINERCLEANFILES = Makefile.in
AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_srcdir)/src/plugins/emotion \
@EVAS_CFLAGS@ @EINA_CFLAGS@ @EMOTION_CFLAGS@ @ECORE_CFLAGS@
pkgdir = $(pluginsdir)
pkg_LTLIBRARIES = emotion.la
emotion_la_SOURCES = emotion.c
emotion_la_DEPENDENCIES = $(top_builddir)/config.h
emotion_la_LIBADD = $(top_builddir)/src/lib/libethumb.la \
@EVAS_LIBS@ @EINA_LIBS@ @EMOTION_LIBS@ @ECORE_LIBS@
emotion_la_LDFLAGS = -module -avoid-version

View File

@ -0,0 +1,93 @@
#include "Ethumb.h"
#include "Ethumb_Plugin.h"
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <Eina.h>
#include <Evas.h>
#include <Emotion.h>
#include <Ecore.h>
struct cb_data {
Ethumb_File *ef;
ethumb_generate_callback_t finished_cb;
void *data;
};
static Evas_Object *_emotion = NULL;
static void
_shutdown(Ethumb_Plugin *plugin)
{
ecore_shutdown();
}
static void
_frame_decoded_cb(void *data, Evas_Object *o, void *event_info)
{
Ethumb_File *ef = data;
Ethumb *e = ef->ethumb;
Evas_Coord ww, hh;
Evas_Coord mw, mh;
emotion_object_size_get(o, &mw, &mh);
ethumb_calculate_aspect(e, mw, mh, &ww, &hh);
ethumb_plugin_image_resize(ef, ww, hh);
evas_object_resize(o, ww, hh);
evas_object_move(o, 0, 0);
ethumb_image_save(ef);
evas_object_smart_callback_del(o, "frame_decode", _frame_decoded_cb);
emotion_object_play_set(o, 0);
evas_object_del(o);
ethumb_finished_callback_call(ef);
}
static int
_generate_thumb(Ethumb_File *ef)
{
Ethumb *e = ef->ethumb;
Evas_Object *o;
int r;
o = emotion_object_add(e->sub_e);
r = emotion_object_init(o, "xine");
if (!r)
{
fprintf(stderr, "ERROR: could not start emotion using gstreamer"
" plugin.\n");
evas_object_del(o);
return r;
}
emotion_object_file_set(o, ef->src_path);
emotion_object_position_set(o, e->video.time);
emotion_object_play_set(o, 1);
evas_object_smart_callback_add(o, "frame_decode", _frame_decoded_cb, ef);
evas_object_show(o);
_emotion = o;
return 1;
}
Ethumb_Plugin *
ethumb_plugin_init(void)
{
static const char *extensions[] = { "avi", NULL };
static Ethumb_Plugin plugin =
{
extensions,
_generate_thumb,
_shutdown
};
ecore_init();
return &plugin;
}

View File

@ -0,0 +1,12 @@
MAINTAINERCLEANFILES = Makefile.in
AM_CPPFLAGS = -I$(top_srcdir)/src/lib -I$(top_srcdir)/src/plugins/epdf \
@EINA_CFLAGS@ @EVAS_CFLAGS@ @ECORE_CFLAGS@ @EPDF_CFLAGS@
pkgdir = $(pluginsdir)
pkg_LTLIBRARIES = epdf.la
epdf_la_SOURCES = epdf.c
epdf_la_DEPENDENCIES = $(top_builddir)/config.h
epdf_la_LIBADD = $(top_builddir)/src/lib/libethumb.la \
@EINA_LIBS@ @EVAS_LIBS@ @ECORE_LIBS@ @EPDF_LIBS@
epdf_la_LDFLAGS = -module -avoid-version

View File

@ -0,0 +1,83 @@
#include "Ethumb.h"
#include "Ethumb_Plugin.h"
#include "config.h"
#include <stdio.h>
#include <stdlib.h>
#include <Evas.h>
#include <Epdf.h>
static void
_shutdown(Ethumb_Plugin *plugin)
{
epdf_shutdown();
}
static int
_generate_thumb(Ethumb_File *ef)
{
Ethumb *e = ef->ethumb;
Epdf_Document *document;
Epdf_Page *page;
Evas_Object *o;
int w, h, ww, hh;
int fx, fy, fw, fh;
int npages;
document = epdf_document_new(ef->src_path);
if (!document)
{
fprintf(stderr, "ERROR: could not read document: %s\n", ef->src_path);
return 0;
}
page = epdf_page_new(document);
if (!page)
{
fprintf(stderr, "ERROR: could not read document: %s\n", ef->src_path);
epdf_document_delete(document);
return 0;
}
npages = epdf_document_page_count_get(document);
if (e->document.page < npages)
epdf_page_page_set(page, e->document.page);
epdf_page_size_get(page, &w, &h);
ethumb_calculate_aspect(e, w, h, &ww, &hh);
ethumb_plugin_image_resize(ef, ww, hh);
o = evas_object_image_add(e->sub_e);
epdf_page_render(page, o);
evas_object_resize(o, ww, hh);
evas_object_move(o, 0, 0);
ethumb_calculate_fill(e, w, h, &fx, &fy, &fw, &fh);
evas_object_image_fill_set(o, fx, fy, fw, fh);
evas_object_show(o);
ethumb_image_save(ef);
evas_object_del(o);
epdf_page_delete(page);
epdf_document_delete(document);
ethumb_finished_callback_call(ef);
return 1;
}
Ethumb_Plugin *
ethumb_plugin_init(void)
{
static const char *extensions[] = { "pdf", NULL };
static Ethumb_Plugin plugin =
{
extensions,
_generate_thumb,
_shutdown
};
epdf_init();
return &plugin;
}