INCLUDE(FindPkgConfig)
pkg_check_modules(pkgs REQUIRED
glib-2.0 gthread-2.0 dlog mm-fileinfo drm-client aul
-libexif ecore ecore-evas evas mmutil-imgp mmutil-jpeg heynoti libmedia-utils vconf libtzplatform-config)
+libexif mmutil-imgp mmutil-jpeg heynoti libmedia-utils vconf libtzplatform-config gdk-pixbuf-2.0)
FOREACH(flag ${pkgs_CFLAGS})
BuildRequires: pkgconfig(aul)
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(drm-client)
-BuildRequires: pkgconfig(ecore)
-BuildRequires: pkgconfig(evas)
BuildRequires: pkgconfig(heynoti)
BuildRequires: pkgconfig(libexif)
BuildRequires: pkgconfig(libmedia-utils)
BuildRequires: pkgconfig(mmutil-jpeg)
BuildRequires: pkgconfig(vconf)
BuildRequires: pkgconfig(libtzplatform-config)
+BuildRequires: pkgconfig(gdk-pixbuf-2.0)
Requires: media-server
%description
#include <dirent.h>
#include <stdio.h>
#include <string.h>
-#include <Ecore_Evas.h>
#include <vconf.h>
#ifdef LOG_TAG
thumb_dbg("sqlite3 handle is alive. So disconnect to sqlite3");
}
- /* Shutdown ecore-evas */
- ecore_evas_shutdown();
-
+ g_main_loop_quit(g_thumb_server_mainloop);
+
return;
}
if(recv_msg.msg_type == THUMB_REQUEST_KILL_SERVER) {
thumb_warn("Shutting down...");
- ecore_main_loop_quit();
+ g_main_loop_quit(g_thumb_server_mainloop);
}
return TRUE;
#include <vconf.h>
//#include <signal.h>
//#include <glib-unix.h>
-#include <Ecore.h>
-#include <Ecore_Evas.h>
#ifdef LOG_TAG
thumb_dbg("Singal Hander for HEYNOTI \"power_off_start\"");
if (g_thumb_server_mainloop)
- ecore_main_loop_quit();
+ g_main_loop_quit(g_thumb_server_mainloop);
else
exit(1);
return -1;
}
- context = g_main_context_default ();
+ g_thumb_server_mainloop = g_main_loop_new(context, FALSE);
/* Create new channel to watch udp socket */
channel = g_io_channel_unix_new(sockfd);
g_source_set_callback(source, (GSourceFunc)_thumb_server_read_socket, NULL, NULL);
g_source_attach(source, context);
- GSource *source_evas_init = NULL;
- source_evas_init = g_idle_source_new ();
- g_source_set_callback (source_evas_init, _thumb_daemon_start_jobs, NULL, NULL);
- g_source_attach (source_evas_init, context);
+ GSource *source_init = NULL;
+ source_init = g_idle_source_new ();
+ g_source_set_callback (source_init, _thumb_daemon_start_jobs, NULL, NULL);
+ g_source_attach (source_init, context);
/* Would be used when glib 2.32 is installed
GSource *sig_handler_src = NULL;
g_source_set_callback(sig_handler_src, (GSourceFunc)_media_thumb_signal_handler, NULL, NULL);
g_source_attach(sig_handler_src, context);
*/
- ecore_evas_init();
thumb_dbg("************************************");
thumb_dbg("*** Thumbnail server is running ***");
thumb_dbg("************************************");
- ecore_main_loop_begin();
-
+ g_main_loop_run(g_thumb_server_mainloop);
+
thumb_dbg("Thumbnail server is shutting down...");
g_io_channel_shutdown(channel, FALSE, NULL);
#include "media-thumb-error.h"
#include "media-thumb-types.h"
#include "media-thumb-debug.h"
+#include <gdk-pixbuf/gdk-pixbuf.h>
#ifndef _MEDIA_THUMB_INTERNAL_H_
#define _MEDIA_THUMB_INTERNAL_H_
int height;
int origin_width;
int origin_height;
- int alpha;
- unsigned char *data;
+ gboolean alpha;
+ GdkPixbuf *data;
} media_thumb_info;
enum Exif_Orientation {
#include "media-thumb-debug.h"
#include "media-util.h"
#include <tzplatform_config.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
#ifndef _MEDIA_THUMB_UTIL_H_
#define _MEDIA_THUMB_UTIL_H_
char *thumb_hash_path, size_t max_thumb_path, uid_t uid);
int
-_media_thumb_save_to_file_with_evas(unsigned char *data,
+_media_thumb_save_to_file_with_gdk(GdkPixbuf *data,
int w,
int h,
- int alpha,
+ gboolean alpha,
char *thumb_path);
int
_media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg, uid_t uid)
{
int err = -1;
- unsigned char *data = NULL;
+ GdkPixbuf *data = NULL;
int thumb_size = 0;
int thumb_w = 0;
int thumb_h = 0;
err = _thumbnail_get_data(origin_path, thumb_type, thumb_format, &data, &thumb_size, &thumb_w, &thumb_h, &origin_w, &origin_h, &alpha, uid);
if (err < 0) {
thumb_err("_thumbnail_get_data failed - %d\n", err);
- SAFE_FREE(data);
+ g_object_unref(data);
strncpy(thumb_path, _media_thumb_get_default_path(uid), max_length);
_media_thumb_db_disconnect();
thumb_dbg("Thumb path is changed : %s", thumb_path);
}
- err = _media_thumb_save_to_file_with_evas(data, thumb_w, thumb_h, alpha, thumb_path);
+ err = _media_thumb_save_to_file_with_gdk(data, thumb_w, thumb_h, alpha, thumb_path);
if (err < 0) {
- thumb_err("save_to_file_with_evas failed - %d\n", err);
- SAFE_FREE(data);
+ thumb_err("save_to_file_with_gdk failed - %d\n", err);
+ g_object_unref(data);
if (msg_type == THUMB_REQUEST_DB_INSERT || msg_type == THUMB_REQUEST_ALL_MEDIA)
strncpy(thumb_path, _media_thumb_get_default_path(uid), max_length);
}
/* End of fsync */
- SAFE_FREE(data);
+ g_object_unref(data);
/* DB update if needed */
if (need_update_db == 1) {
#include <mm_error.h>
#include <mm_util_imgp.h>
#include <mm_util_jpeg.h>
-#include <Evas.h>
-#include <Ecore_Evas.h>
#include <libexif/exif-data.h>
+#include <gdk-pixbuf/gdk-pixbuf.h>
#define MEDA_THUMB_ROUND_UP_4(num) (((num)+3)&~3)
return 0;
}
-int _media_thumb_get_wh_with_evas(const char *origin_path, int *width, int *height)
-{
- /* using evas to get w/h */
- Ecore_Evas *ee =
- ecore_evas_buffer_new(0, 0);
- if (!ee) {
- thumb_err("ecore_evas_new fails");
- return -1;
- }
- Evas *evas = ecore_evas_get(ee);
- if (!evas) {
- thumb_err("ecore_evas_get fails");
- ecore_evas_free(ee);
- return -1;
- }
+int _media_thumb_get_wh_with_gdk(const char *origin_path, int *width, int *height)
+{
- Evas_Object *image_object =
- evas_object_image_add(evas);
- if (!image_object) {
- thumb_err
- ("evas_object_image_add fails");
- ecore_evas_free(ee);
+ GdkPixbuf *pixbuf = NULL;
+ GError *error = NULL;
+
+ pixbuf = gdk_pixbuf_new_from_file(origin_path, &error);
+ if (error) {
+ thumb_err ("Error loading image file %s",origin_path);
+ g_error_free (error);
return -1;
}
- evas_object_image_file_set(image_object,
- origin_path,
- NULL);
- evas_object_image_size_get(image_object,
- width, height);
-
- thumb_dbg("Width:%d, Height:%d", *width, *height);
-
- ecore_evas_free(ee);
+ /* Get w/h of original image */
+ *width = gdk_pixbuf_get_width(pixbuf);
+ *height = gdk_pixbuf_get_height(pixbuf);
return 0;
}
-int _media_thumb_decode_with_evas(const char *origin_path,
+int _media_thumb_decode_with_gdk(const char *origin_path,
int thumb_width, int thumb_height,
media_thumb_info *thumb_info, int need_scale, int orientation)
{
- Ecore_Evas *resize_img_ee;
- resize_img_ee =
- ecore_evas_buffer_new(thumb_width, thumb_height);
+ GdkPixbuf *pixbuf = NULL;
+ GError *error = NULL;
- if (!resize_img_ee) {
- thumb_err("Failed to create a new ecore evas buffer\n");
+ pixbuf = gdk_pixbuf_new_from_file(origin_path, &error);
+ if (error) {
+ thumb_err ("Error loading image file %s",origin_path);
+ g_error_free (error);
return -1;
}
- Evas *resize_img_e = ecore_evas_get(resize_img_ee);
- if (!resize_img_e) {
- thumb_err("Failed to ecore_evas_get\n");
- ecore_evas_free(resize_img_ee);
- return -1;
- }
-
- Evas_Object *source_img = evas_object_image_add(resize_img_e);
- if (!source_img) {
- thumb_err("evas_object_image_add failed\n");
- ecore_evas_free(resize_img_ee);
- return -1;
- }
-
- evas_object_image_file_set(source_img, origin_path, NULL);
-
/* Get w/h of original image */
- int width = 0;
- int height = 0;
+ int width = gdk_pixbuf_get_width(pixbuf);
+ int height = gdk_pixbuf_get_height(pixbuf);
- evas_object_image_size_get(source_img, &width, &height);
thumb_info->origin_width = width;
thumb_info->origin_height = height;
- //thumb_dbg("origin width:%d, origin height:%d", width, height);
- if ((need_scale == 1) && (width * height > THUMB_MAX_ALLOWED_MEM_FOR_THUMB)) {
- thumb_dbg("This is too large image. so this's scale is going to be down");
- evas_object_image_load_scale_down_set(source_img, 10);
- }
- evas_object_image_load_orientation_set(source_img, 1);
+ pixbuf = gdk_pixbuf_apply_embedded_orientation(pixbuf);
int rotated_orig_w = 0;
int rotated_orig_h = 0;
rotated_orig_h = height;
}
- //thumb_dbg("rotated - origin width:%d, origin height:%d", rotated_orig_w, rotated_orig_h);
-
int err = -1;
media_thumb_type thumb_type;
&thumb_width, &thumb_height);
if (err < 0) {
thumb_err("_media_thumb_get_proper_thumb_size failed: %d", err);
- ecore_evas_free(resize_img_ee);
+ g_object_unref(pixbuf);
return err;
}
- ecore_evas_resize(resize_img_ee, thumb_width, thumb_height);
-
- evas_object_image_load_size_set(source_img, thumb_width, thumb_height);
- evas_object_image_fill_set(source_img,
- 0, 0,
- thumb_width,
- thumb_height);
-
- evas_object_image_filled_set(source_img, 1);
- evas_object_resize(source_img,
- thumb_width,
- thumb_height);
- evas_object_show(source_img);
-
- /* Set alpha from original */
- thumb_info->alpha = evas_object_image_alpha_get(source_img);
-
- /* Create target buffer and copy origin resized img to it */
- Ecore_Evas *target_ee = ecore_evas_buffer_new(
- thumb_width, thumb_height);
- if (!target_ee) {
- thumb_err("Failed to create a ecore evas\n");
- ecore_evas_free(resize_img_ee);
- return -1;
- }
-
- Evas *target_evas = ecore_evas_get(target_ee);
- if (!target_evas) {
- thumb_err("Failed to ecore_evas_get\n");
- ecore_evas_free(resize_img_ee);
- ecore_evas_free(target_ee);
- return -1;
- }
-
- Evas_Object *ret_image =
- evas_object_image_add(target_evas);
-
- evas_object_image_size_set(ret_image,
- thumb_width,
- thumb_height);
-
- evas_object_image_fill_set(ret_image, 0,
- 0,
- thumb_width,
- thumb_height);
-
- evas_object_image_filled_set(ret_image, EINA_TRUE);
- evas_object_image_data_set(ret_image,
- (int *)ecore_evas_buffer_pixels_get(resize_img_ee));
- evas_object_image_data_update_add(ret_image, 0, 0, thumb_width,
- thumb_height);
+ pixbuf = gdk_pixbuf_scale_simple(pixbuf, thumb_width, thumb_height, GDK_INTERP_NEAREST);
unsigned int buf_size = 0;
thumb_height, &buf_size) < 0) {
thumb_err("Failed to get buffer size");
- ecore_evas_free(resize_img_ee);
- ecore_evas_free(target_ee);
+ g_object_unref(pixbuf);
return MEDIA_THUMB_ERROR_MM_UTIL;
}
- //thumb_dbg("mm_util_get_image_size : %d", buf_size);
-
thumb_info->size = buf_size;
+ thumb_info->alpha = gdk_pixbuf_get_has_alpha(pixbuf);
thumb_info->width = thumb_width;
thumb_info->height = thumb_height;
- thumb_info->data = malloc(buf_size);
- memcpy(thumb_info->data, evas_object_image_data_get(ret_image, 1), buf_size);
-
- ecore_evas_free(target_ee);
- ecore_evas_free(resize_img_ee);
+ thumb_info->data = gdk_pixbuf_copy(pixbuf);
+ g_object_unref(pixbuf);
return 0;
}
}
}
-
int _media_thumb_convert_data(media_thumb_info *thumb_info,
int thumb_width,
int thumb_height,
media_thumb_info *thumb_info)
{
int err = -1;
- err = _media_thumb_decode_with_evas(origin_path, thumb_width, thumb_height, thumb_info, 0, NORMAL);
-
+ err = _media_thumb_decode_with_gdk(origin_path, thumb_width, thumb_height, thumb_info, 0, NORMAL);
+
if (err < 0) {
- thumb_err("decode_with_evas failed : %d", err);
+ thumb_err("decode_with_gdk failed : %d", err);
return err;
}
media_thumb_info *thumb_info)
{
int err = -1;
- err = _media_thumb_decode_with_evas(origin_path, thumb_width, thumb_height, thumb_info, 0, NORMAL);
+ err = _media_thumb_decode_with_gdk(origin_path, thumb_width, thumb_height, thumb_info, 0, NORMAL);
if (err < 0) {
- thumb_err("decode_with_evas failed : %d", err);
+ thumb_err("decode_with_gdk failed : %d", err);
return err;
}
media_thumb_info *thumb_info)
{
int err = -1;
- err = _media_thumb_decode_with_evas(origin_path, thumb_width, thumb_height, thumb_info, 0, NORMAL);
+ err = _media_thumb_decode_with_gdk(origin_path, thumb_width, thumb_height, thumb_info, 0, NORMAL);
if (err < 0) {
- thumb_err("decode_with_evas failed : %d", err);
+ thumb_err("decode_with_gdk failed : %d", err);
return err;
}
media_thumb_info *thumb_info)
{
int err = -1;
- err = _media_thumb_decode_with_evas(origin_path, thumb_width, thumb_height, thumb_info, 0, NORMAL);
+ err = _media_thumb_decode_with_gdk(origin_path, thumb_width, thumb_height, thumb_info, 0, NORMAL);
if (err < 0) {
- thumb_err("decode_with_evas failed : %d", err);
+ thumb_err("decode_with_gdk failed : %d", err);
return err;
}
if (!thumb_done) {
- err = _media_thumb_decode_with_evas(origin_path, thumb_width, thumb_height, thumb_info, 0, orientation);
-
+ err = _media_thumb_decode_with_gdk(origin_path, thumb_width, thumb_height, thumb_info, 0, orientation);
+
if (err < 0) {
- thumb_err("decode_with_evas failed : %d", err);
+ thumb_err("decode_with_gdk failed : %d", err);
return err;
}
int wbmp_width = 0;
int wbmp_height = 0;
- err = _media_thumb_get_wh_with_evas(origin_path, &wbmp_width, &wbmp_height);
+ err = _media_thumb_get_wh_with_gdk(origin_path, &wbmp_width, &wbmp_height);
if (err < 0) {
- thumb_err("_media_thumb_get_wh_with_evas in WBMP : %d", err);
+ thumb_err("_media_thumb_get_wh_with_gdk in WBMP : %d", err);
return err;
}
#include <aul.h>
#include <string.h>
#include <drm_client.h>
-
-#include <Evas.h>
-#include <Ecore_Evas.h>
+#include <sys/stat.h>
#include <grp.h>
#include <pwd.h>
+#include <sys/smack.h>
#define GLOBAL_USER 0 //#define tzplatform_getenv(TZ_GLOBAL) //TODO
return 0;
}
-
-int _media_thumb_save_to_file_with_evas(unsigned char *data,
+int _media_thumb_save_to_file_with_gdk(GdkPixbuf *data,
int w,
int h,
- int alpha,
+ gboolean alpha,
char *thumb_path)
{
- Ecore_Evas *ee =
- ecore_evas_buffer_new(w, h);
- if (ee == NULL) {
- thumb_err("Failed to create a new ecore evas buffer\n");
- return -1;
- }
-
- Evas *evas = ecore_evas_get(ee);
- if (evas == NULL) {
- thumb_err("Failed to ecore_evas_get\n");
- ecore_evas_free(ee);
+ GError *error = NULL;
+
+ gdk_pixbuf_save(data,thumb_path,"jpeg", &error, NULL);
+ if (error) {
+ thumb_dbg ("Error saving image file %s", thumb_path);
+ g_error_free (error);
return -1;
}
- Evas_Object *img = NULL;
- img = evas_object_image_add(evas);
-
- if (img == NULL) {
- thumb_err("image object is NULL\n");
- ecore_evas_free(ee);
+ if(smack_setlabel(thumb_path, "User", SMACK_LABEL_ACCESS)){
+ thumb_dbg("failed chsmack -a \"User\" %s", thumb_path);
return -1;
- }
-
- evas_object_image_colorspace_set(img, EVAS_COLORSPACE_ARGB8888);
- evas_object_image_size_set(img, w, h);
- evas_object_image_fill_set(img, 0, 0, w, h);
-
- if (alpha) evas_object_image_alpha_set(img, 1);
-
- evas_object_image_data_set(img, data);
- evas_object_image_data_update_add(img, 0, 0, w, h);
-
- if (evas_object_image_save
- (img, thumb_path, NULL, "quality=100 compress=1")) {
- thumb_dbg("evas_object_image_save success\n");
- ecore_evas_free(ee);
-
- return 0;
} else {
- thumb_dbg("evas_object_image_save failed\n");
- ecore_evas_free(ee);
- return -1;
+ thumb_dbg("chsmack -a \"User\" %s", thumb_path);
}
-}
+ return 0;
+}
int _thumbnail_get_data(const char *origin_path,
media_thumb_type thumb_type,
#include <stdlib.h>
#include <string.h>
#include <pthread.h>
-#include <Evas.h>
-#include <Ecore_Evas.h>
#include <mm_util_imgp.h>
#include <mm_util_jpeg.h>
#include "media-thumb-ipc.h"
#include "media-thumb-util.h"
-int save_to_file_with_evas(unsigned char *data, int w, int h, int is_bgra)
+int save_to_file_with_gdk(unsigned char *data, int w, int h, int is_bgra)
{
- ecore_evas_init();
+ GError *error = NULL;
- Ecore_Evas *ee =
- ecore_evas_buffer_new(w, h);
- Evas *evas = ecore_evas_get(ee);
-
- Evas_Object *img = NULL;
- img = evas_object_image_add(evas);
-
- if (img == NULL) {
- printf("image object is NULL\n");
- ecore_evas_free(ee);
- ecore_evas_shutdown();
- return -1;
- }
-
- evas_object_image_colorspace_set(img, EVAS_COLORSPACE_ARGB8888);
- evas_object_image_size_set(img, w, h);
- evas_object_image_fill_set(img, 0, 0, w, h);
-
- if (!is_bgra) {
- unsigned char *m = NULL;
- m = evas_object_image_data_get(img, 1);
-#if 1 /* Use self-logic to convert from RGB888 to RGBA */
- int i = 0, j;
- for (j = 0; j < w * 3 * h;
- j += 3) {
- m[i++] = (data[j + 2]);
- m[i++] = (data[j + 1]);
- m[i++] = (data[j]);
- m[i++] = 0x0;
- }
-
-#else /* Use mmf api to convert from RGB888 to RGBA */
- int mm_ret = 0;
- if ((mm_ret =
- mm_util_convert_colorspace(data,
- w,
- h,
- MM_UTIL_IMG_FMT_RGB888,
- m,
- MM_UTIL_IMG_FMT_BGRA8888))
- < 0) {
- printf
- ("Failed to change from rgb888 to argb8888 %d\n",
- mm_ret);
+ gdk_pixbuf_save(data,"/mnt/nfs/test.jpg","jpeg", &error, NULL);
+ if (error) {
+ thumb_dbg ("Error saving image file /mnt/nfs/test.jpg ");
+ g_error_free (error);
return -1;
}
-#endif /* End of use mmf api to convert from RGB888 to RGBA */
-
- evas_object_image_data_set(img, m);
- evas_object_image_data_update_add(img, 0, 0, w, h);
- } else {
- evas_object_image_data_set(img, data);
- evas_object_image_data_update_add(img, 0, 0, w, h);
- }
-
- if (evas_object_image_save
- (img, "/mnt/nfs/test.jpg", NULL,
- "quality=50 compress=2")) {
- printf("evas_object_image_save success\n");
- } else {
- printf("evas_object_image_save failed\n");
- }
-
- ecore_evas_shutdown();
-
return 0;
}
if (origin_path && (mode == 1)) {
printf("Test _thumbnail_get_data\n");
- unsigned char *data = NULL;
+ GdkPixbuf *data = NULL;
int thumb_size = 0;
int thumb_w = 0;
int thumb_h = 0;
printf("Size : %d, W:%d, H:%d\n", thumb_size, thumb_w, thumb_h);
printf("Origin W:%d, Origin H:%d\n", origin_w, origin_h);
- err = save_to_file_with_evas(data, thumb_w, thumb_h, is_bgra);
+ err = save_to_file_with_gdk(data, thumb_w, thumb_h, is_bgra);
if (err < 0) {
printf("_thumbnail_get_data failed - %d\n", err);
return -1;