Push the laste code of libmedia-thumbnail
authorHyunjun Ko <zzoon.ko@samsung.com>
Fri, 10 Feb 2012 05:43:37 +0000 (14:43 +0900)
committerHyunjun Ko <zzoon.ko@samsung.com>
Fri, 10 Feb 2012 05:43:37 +0000 (14:43 +0900)
18 files changed:
CMakeLists.txt
TC/tet_scen
TC/utc/Makefile
TC/utc/tslist
TC/utc/utc_thumbnail_request_from_db_func.c
TC/utc/utc_thumbnail_request_save_to_file_func.c [new file with mode: 0644]
TC/utc/utc_thumbnail_request_save_to_file_func.h [new file with mode: 0644]
debian/changelog
debian/control
include/media-thumb-types.h
packaging/libmedia-thumbnail.spec
src/include/media-thumb-internal.h
src/include/util/media-thumb-db.h
src/include/util/media-thumb-util.h
src/media-thumb-internal.c
src/media-thumbnail.c
src/util/media-thumb-db.c
src/util/media-thumb-util.c

index 1710ff5f876043ae2cd4446e26d6728643154b82..0cd592e560c6909ebf0ab86c6f6a7ef37fe9e21c 100644 (file)
@@ -44,7 +44,7 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src/include
 
 INCLUDE(FindPkgConfig)
 pkg_check_modules(pkgs REQUIRED
-glib-2.0 gthread-2.0 dlog libmedia-service mm-fileinfo drm-service aul
+glib-2.0 gthread-2.0 dlog mm-fileinfo drm-service aul
 libexif ecore-evas evas mmutil-imgp mmutil-jpeg heynoti)
 
 
index b220f82e0227307c647567bac065aebddab4114c..2ff9a16e4709f405f9924b015e0e133959065082 100644 (file)
@@ -1,7 +1,6 @@
 # auto generated tet_scen
 all
        "Starting Full Test Suite"
-       /utc/utc_thumbnail_request_from_db_func
-       /utc/utc_thumbnail_get_data_func
+       :include:/utc/tslist
        "Completed Full Test Suite"
 # EOF
index c5a63ede012bb41ca5f6317b272b50a3629c4878..574231872131e82a604d1ada2e68ded2663bf8b4 100644 (file)
@@ -11,15 +11,13 @@ else
 endif
 
 TS1=utc_thumbnail_request_from_db_func
-TS2=utc_thumbnail_get_data_func
+TS2=utc_thumbnail_request_save_to_file_func
 
-LIBS = `pkg-config --libs libmedia-thumbnail`
-LIBS +=-L/usr/lib/:/usr/lib/pkgconfig
+LIBS = `pkg-config --libs media-thumbnail`
 LIBS +=$(TET_ROOT)/lib/tet3/tcm_s.o
-LIBS +=-L$(TET_ROOT)/lib/tet3 -ltcm_s
-LIBS +=-L$(TET_ROOT)/lib/tet3/ -lapi_s
+LIBS +=-L$(TET_ROOT)/lib/tet3 -ltcm_s -lapi_s
 
-INCS = -I. `pkg-config --cflags  libmedia-thumbnail`
+INCS = -I. `pkg-config --cflags media-thumbnail`
 INCS += -I$(TET_ROOT)/inc/tet3
 INCS += -I/usr/include
 
@@ -27,7 +25,7 @@ CFLAGS = $(INCS)
 CC += $(CFLAGS)
 LDFLAGS = $(LIBS)
 
-all : $(TS10) $(TS11)
+all : $(TS1) $(TS2)
 
 $(TS1): $(TS1).c
        $(CC) -o $(TS1) $(TS1).c $(LDFLAGS)
index 6ff06c437c3d67bfdf53d43d449c1a08fe1698bd..825b84bb5192562e0060f65944f4fc6cdd4a457f 100644 (file)
@@ -1,2 +1,2 @@
-/utc/visual/utc_thumbnail_request_from_db_func
-/utc/visual/utc_thumbnail_get_data_func
+/utc/utc_thumbnail_request_from_db_func
+/utc/utc_thumbnail_request_save_to_file_func
index a64f1b8e5cd8f7ca0981dc4ac4b9597f2f433c45..2d5bd1566cbc60df34adcf9d71868bbcff1d739a 100644 (file)
@@ -40,7 +40,7 @@ void utc_thumbnail_request_from_db_func_01()
 {
        int ret = -1;
         
-       const char *origin_path = "/opt/media/Images and videos/Wallpapers/Home_default.png";
+       const char *origin_path = "/opt/media/Images/Wallpapers/Home_default.jpg";
        char thumb_path[1024] = {0,};
 
        ret = thumbnail_request_from_db(origin_path, thumb_path, sizeof(thumb_path));
diff --git a/TC/utc/utc_thumbnail_request_save_to_file_func.c b/TC/utc/utc_thumbnail_request_save_to_file_func.c
new file mode 100644 (file)
index 0000000..a9bf6e8
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * libmedia-thumbnail
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+/**
+* @file        utc_thumbnail_request_save_to_file_func.c
+* @brief       This is a suit of unit test cases to test thumbnail_request_save_to_file API function
+* @author
+* @version     Initial Creation Version 0.1
+* @date        2011-10-13
+*/
+
+#include "utc_thumbnail_request_save_to_file_func.h"
+
+
+/**
+* @brief       This tests int thumbnail_request_save_to_file() API with valid parameters
+* @par ID      utc_thumbnail_request_save_to_file_func_01
+* @param       [in] 
+* @return      This function returns zero on success, or negative value with error code
+*/
+void utc_thumbnail_request_save_to_file_func_01()
+{
+       int ret = -1;
+        
+       const char *origin_path = "/opt/media/Images/Wallpapers/Home_default.jpg";
+       char thumb_path[255] = { 0, };
+       snprintf(thumb_path, sizeof(thumb_path), "/tmp/test_thumb.jpg");
+
+       media_thumb_type thumb_type = MEDIA_THUMB_LARGE;
+
+       ret = thumbnail_request_save_to_file(origin_path, thumb_type, thumb_path);
+       
+       if (ret < MEDIA_THUMB_ERROR_NONE) {
+               UTC_THUMB_LOG( "unable to save thumbnail file. error code->%d", ret);
+               tet_result(TET_FAIL);
+               return;
+       } else {
+               unlink(thumb_path);
+               tet_result(TET_PASS);
+       }
+       
+       return;
+}
+
+
+/**
+* @brief       This tests int thumbnail_request_save_to_file() API with invalid parameters
+* @par ID      utc_thumbnail_request_save_to_file_func_02
+* @param       [in] 
+* @return      error code on success 
+*/
+void utc_thumbnail_request_save_to_file_func_02()
+{      
+       int ret = -1;
+
+       const char *origin_path = NULL;
+       char thumb_path[255] = { 0, };
+
+       media_thumb_type thumb_type = MEDIA_THUMB_LARGE;
+
+       ret = thumbnail_request_save_to_file(origin_path, thumb_type, thumb_path);
+       if (ret < MEDIA_THUMB_ERROR_NONE) {
+               UTC_THUMB_LOG("abnormal condition test for null, error code->%d", ret);
+               tet_result(TET_PASS);
+       } else {
+               UTC_THUMB_LOG("Creating thumbnail file should be failed because the origin_path is NULL");
+               tet_result(TET_FAIL);
+       }
+
+       return ;
+}
+
diff --git a/TC/utc/utc_thumbnail_request_save_to_file_func.h b/TC/utc/utc_thumbnail_request_save_to_file_func.h
new file mode 100644 (file)
index 0000000..c0f4389
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * libmedia-thumbnail
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+
+/**
+* @file                utc_thumbnail_request_save_to_file_func.h
+* @author
+* @brief       This is the implementaion file for the test case of thumbnail_request_save_to_file API function
+* @version     Initial Creation Version 0.1
+* @date                2011-10-13
+*/
+
+#ifndef __UTS_thumbnail_request_save_to_file__FUNC_H_
+#define __UTS_thumbnail_request_save_to_file__FUNC_H_
+
+
+#include "utc_media_thumb_common.h"
+
+/* Initialize TCM data structures */
+void (*tet_startup)() = NULL;
+void (*tet_cleanup)() = NULL;
+
+void utc_thumbnail_request_save_to_file_func_01();
+void utc_thumbnail_request_save_to_file_func_02();
+
+struct tet_testlist tet_testlist[] = {
+       {utc_thumbnail_request_save_to_file_func_01, 1},
+       {utc_thumbnail_request_save_to_file_func_02, 2},
+       {NULL, 0}
+};
+
+
+#endif // __UTS_thumbnail_request_save_to_file__FUNC_H_
+
index bac81d5cde99921209d1b8837a07fdfe64c7a0a0..455bed969d087640bda63214c8b4eb59f3ef71a2 100755 (executable)
@@ -1,10 +1,20 @@
+libmedia-thumbnail (0.2.0-4) unstable; urgency=low
+
+  * Change thumbnail policy - Large: 320x240, Small: 160x120
+  * Remove libmedia-service dependancy
+  * Change of DB schema in media.db
+  * Git : pkgs/l/libmedia-thumbnail
+  * Tag : libmedia-thumbnail_0.2.0-4
+
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Tue, 10 Feb 2012 18:30:00 +0900
+
 libmedia-thumbnail (0.2.0-3) unstable; urgency=low
 
   * Separates md5 codes to another shared object
   * Git : pkgs/l/libmedia-thumbnail
   * Tag : libmedia-thumbnail_0.2.0-3
 
- -- Hyunjun Ko <zzoon.ko@samsung.com>  Tue, 3 Jan 2011 18:30:00 +0900
+ -- Hyunjun Ko <zzoon.ko@samsung.com>  Tue, 3 Jan 2012 18:30:00 +0900
 
 libmedia-thumbnail (0.2.0-2) unstable; urgency=low
 
index a5573b92e8bfd7b14d05c5f8866df4a72459eaa5..3a94b7153bd08bda5e3c74abb7d5e101aa501ac2 100755 (executable)
@@ -5,7 +5,6 @@ Maintainer: Hyunjun Ko<zzoon.ko@samsung.com>, Byungwook Jang <bw.jang@samsung.co
 Uploaders: Hyunjun Ko<zzoon.ko@samsung.com>
 Build-Depends: debhelper (>= 5), libglib2.0-dev,
                dlog-dev,
-               libmedia-service-dev,
                libmm-fileinfo-dev,
                libmm-utility-dev,
                drm-service-dev,
@@ -38,7 +37,7 @@ Description: Media thumbnail service library for multimedia applications.
 Package: libmedia-thumbnail-dev
 Section: libdevel
 Architecture: any
-Depends: libmedia-thumbnail (= ${Source-Version}), libmedia-service-dev, libmm-fileinfo-dev, libmm-utility-dev, libglib2.0-dev, dlog-dev, drm-service-dev, libevas-dev, libecore-dev, libexif-dev, libaul-1-dev
+Depends: libmedia-thumbnail (= ${Source-Version}), libmm-fileinfo-dev, libmm-utility-dev, libglib2.0-dev, dlog-dev, drm-service-dev, libevas-dev, libecore-dev, libexif-dev, libaul-1-dev
 Description: Media thumbnail service library for multimedia applications. (development)
 
 Package: libmedia-thumbnail-dbg
index c20e8ba108c930d7fe67fe2ef800110a2208aa5e..c73289d98b4e990f592451a60cb6d7bd31ff8471 100755 (executable)
@@ -25,8 +25,8 @@
 #define _MEDIA_THUMB_TYPES_H_
 
 typedef enum {
-       MEDIA_THUMB_LARGE,                      /* 256x256 */
-       MEDIA_THUMB_SMALL,                      /* 96x96 */
+       MEDIA_THUMB_LARGE,
+       MEDIA_THUMB_SMALL,
 } media_thumb_type;
 
 typedef enum {
index 4512f0371b143ab5539d60c169caa2ff713fa6fe..18d1785fd129416679da396092c7cd5eab428d56 100644 (file)
@@ -7,7 +7,6 @@ License:    TO_BE/FILLED_IN
 Source0:    %{name}-%{version}.tar.gz
 BuildRequires: cmake
 BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(libmedia-service)
 BuildRequires: pkgconfig(mm-fileinfo)
 BuildRequires: pkgconfig(mmutil-imgp)
 BuildRequires: pkgconfig(mmutil-jpeg)
index 192524a174e42cd09d846e098b03bbe63701f3e3..ac19f66af67a210b88f1378cf620f16c83a0c115 100755 (executable)
 /* The maximum of resolution to be able to get thumbnail is 3000 x 3000, except for only jpeg */
 #define THUMB_MAX_ALLOWED_MEM_FOR_THUMB 9000000
 
+#define THUMB_LARGE_WIDTH 320
+#define THUMB_LARGE_HEIGHT 240
+#define THUMB_SMALL_WIDTH 160
+#define THUMB_SMALL_HEIGHT 120
 
 typedef struct {
        int size;
@@ -54,14 +58,16 @@ enum Exif_Orientation {
 };
 
 int
-_media_thumb_image(const char *origin_path, 
-                                       int thumb_length, 
-                                       media_thumb_format format, 
+_media_thumb_image(const char *origin_path,
+                                       int thumb_width,
+                                       int thumb_height,
+                                       media_thumb_format format,
                                        media_thumb_info *thumb_info);
 
 int
-_media_thumb_video(const char *origin_path, 
-                                       int thumb_length, 
+_media_thumb_video(const char *origin_path,
+                                       int thumb_width,
+                                       int thumb_height,
                                        media_thumb_format format,
                                        media_thumb_info *thumb_info);
 
index 1c1fd133418fb38bd62fd1473bd81f57099407d5..10b08d2f26d228e0d6033093cf85df98900973fa 100755 (executable)
 #ifndef _MEDIA_THUMB_DB_H_
 #define _MEDIA_THUMB_DB_H_
 
+int
+_media_thumb_db_connect();
+
+int
+_media_thumb_db_disconnect();
+
 int
 _media_thumb_get_thumb_from_db(const char *origin_path,
                                                                char *thumb_path,
index 387fe61e14bd707686f3320f4cf0936ddd0127f7..71851004bc0d1cf03d3b6371ebb43a5253bca6b7 100755 (executable)
@@ -69,6 +69,12 @@ _media_thumb_save_to_file_with_evas(unsigned char *data,
                                                                                        int h,
                                                                                        char *thumb_path);
 
+int
+_media_thumb_get_width(media_thumb_type thumb_type);
+
+int
+_media_thumb_get_height(media_thumb_type thumb_type);
+
 /**
  *     _thumbnail_get_data:
  *  This function generates thumbnail raw data, which is wanted by user
index 7b5b47a4b3ed553714e0f9d01c57856f6ff37f11..513ccb46fb467f45ac31746d568a4093070a1d49 100755 (executable)
 #include <Ecore_Evas.h>
 #include <libexif/exif-data.h>
 
+int _media_thumb_get_proper_thumb_size(media_thumb_type thumb_type,
+                                                               int orig_w, int orig_h,
+                                                               int *thumb_w, int *thumb_h)
+{
+       thumb_dbg("orig w: %d orig h: %d thumb type: %d", orig_w, orig_h, thumb_type);
+
+       BOOL portrait = FALSE;
+       double ratio;
+
+       if (orig_w < orig_h) {
+               portrait = TRUE;
+       }
+
+       if (portrait) {
+               if (orig_h < _media_thumb_get_width(thumb_type)) {
+                       *thumb_h = orig_h;
+               } else {
+                       *thumb_h = _media_thumb_get_width(thumb_type);
+               }
+
+               ratio = (double)orig_w / (double)orig_h;
+               *thumb_w = *thumb_h * ratio;
+       } else {
+               if (orig_w < _media_thumb_get_width(thumb_type)) {
+                       *thumb_w = orig_w;
+               } else {
+                       *thumb_w = _media_thumb_get_width(thumb_type);
+               }
+
+               ratio = (double)orig_h / (double)orig_w;
+               *thumb_h = *thumb_w * ratio;
+       }
+
+       thumb_dbg("proper thumb w: %d h: %d", *thumb_w, *thumb_h);
+
+       return 0;
+}
+
 int _media_thumb_get_exif_info(ExifData *ed, char *buf, int max_size, int *value,
                     int ifdtype, long tagtype)
 {
@@ -161,13 +199,6 @@ _media_thumb_get_thumb_from_exif(ExifData *ed,
 
                thumb_height = value;
        }
-/*
-       if (thumb_width < required_width && 
-                       thumb_height < required_height) {
-               thumb_dbg("Size of thumb from exif is small");
-               return -1;
-       }
-*/
 
        if (ed->data && ed->size) {
                thumb_dbg("Size: %d, thumb: 0x%x\n", ed->size, ed->data);
@@ -256,7 +287,71 @@ _media_thumb_get_thumb_from_exif(ExifData *ed,
        }
 
        thumb_dbg("size:%d, w:%d, h:%d\n", decoded.size, decoded.width, decoded.height);
-#if 1
+
+       thumb_width = decoded.width;
+       thumb_height = decoded.height;
+
+       media_thumb_type thumb_type;
+       int need_resize = 0;
+       unsigned int buf_size = decoded.size;
+
+       if (required_width == _media_thumb_get_width(MEDIA_THUMB_LARGE)) {
+               thumb_type = MEDIA_THUMB_LARGE;
+       } else {
+               thumb_type = MEDIA_THUMB_SMALL;
+       }
+
+       if (thumb_type == MEDIA_THUMB_LARGE) {
+               if (thumb_width < _media_thumb_get_width(MEDIA_THUMB_LARGE)) {
+                       thumb_dbg("Thumb data in exif is too small for MEDIA_THUMB_LARGE");
+                       SAFE_FREE(decoded.data);
+                       return -1;
+               }
+       } else {
+               if (thumb_width > _media_thumb_get_width(MEDIA_THUMB_SMALL)) {
+                       need_resize = 1;
+               }
+       }
+
+       if (need_resize == 1) {
+               int resized_w = _media_thumb_get_width(MEDIA_THUMB_LARGE);
+               int resized_h = _media_thumb_get_height(MEDIA_THUMB_LARGE);
+
+               err = mm_util_get_image_size(MM_UTIL_IMG_FMT_RGB888, resized_w, resized_h, &buf_size);
+               if (err < 0) {
+                       thumb_dbg("mm_util_get_image_size failed : %d", err);
+
+                       SAFE_FREE(decoded.data);
+                       return err;
+               }
+
+               thumb_dbg("size(RGB888) : %d", buf_size);
+
+               unsigned char *dst = (unsigned char *)malloc(buf_size);
+               if (dst == NULL) {
+                       thumb_err("Failed to allocate memory!");
+                       SAFE_FREE(decoded.data);
+                       return -1;
+               }
+
+               if (mm_util_resize_image(decoded.data, thumb_width,
+                               thumb_height, MM_UTIL_IMG_FMT_RGB888,
+                               dst, (unsigned int *)&resized_w,
+                               (unsigned int *)&resized_h) < 0) {
+                       thumb_err("Failed to resize the thumbnails");
+
+                       SAFE_FREE(decoded.data);
+                       SAFE_FREE(dst);
+
+                       return -1;
+               }
+
+               SAFE_FREE(decoded.data);
+               decoded.data = dst;
+               decoded.width = thumb_width = resized_w;
+               decoded.height = thumb_height = resized_h;
+       }
+
        if (orientation == ROT_90 || orientation == ROT_180 || orientation == ROT_270) {
                /* Start to decode to rotate */
                unsigned char *rotated = NULL;
@@ -278,11 +373,10 @@ _media_thumb_get_thumb_from_exif(ExifData *ed,
                err = mm_util_get_image_size(MM_UTIL_IMG_FMT_RGB888, r_w, r_h, &r_size);
                if (err < 0) {
                        thumb_dbg("mm_util_get_image_size failed : %d", err);
-                       
                        SAFE_FREE(decoded.data);
                        return err;
                }
-       
+
                thumb_dbg("Size of Rotated : %d", r_size);
 
 #if 1
@@ -369,30 +463,16 @@ _media_thumb_get_thumb_from_exif(ExifData *ed,
                thumb_info->width = r_w;
                thumb_info->height = r_h;
        } else if (orientation == NORMAL) {
-#endif
-               unsigned int buf_size = 0;
-
-               err = mm_util_get_image_size(MM_UTIL_IMG_FMT_RGB888, decoded.width, decoded.height, &buf_size);
-               if (err < 0) {
-                       thumb_dbg("mm_util_get_image_size failed : %d", err);
-                       
-                       SAFE_FREE(decoded.data);
-                       return err;
-               }
-
-               thumb_dbg("size(RGB888) : %d", buf_size);
-
                thumb_info->data = decoded.data;
                thumb_info->size = buf_size;
-               thumb_info->width = decoded.width;
-               thumb_info->height = decoded.height;
-#if 1
+               thumb_info->width = thumb_width;
+               thumb_info->height = thumb_height;
        } else {
                thumb_warn("Unknown orientation");
                SAFE_FREE(decoded.data);
                return -1;
        }
-#endif
+
        return 0;
 }
 
@@ -481,34 +561,18 @@ int _media_thumb_get_wh_with_evas(const char *origin_path, int *width, int *heig
        return 0;
 }
 
-int _media_thumb_decode_with_evas(const char *origin_path, int thumb_length, 
+int _media_thumb_decode_with_evas(const char *origin_path,
+                                       int thumb_width, int thumb_height,
                                        media_thumb_info *thumb_info, int need_scale)
 {
        ecore_evas_init();
 
-       Ecore_Evas *ee = ecore_evas_buffer_new(
-                                               thumb_length, thumb_length);
-       if (!ee) {
-               thumb_err("Failed to create a ecore evas\n");
-               ecore_evas_shutdown();
-               return -1;
-       }
-
-       Evas *evas = ecore_evas_get(ee);
-       if (!evas) {
-               thumb_err("Failed to ecore_evas_get\n");
-               ecore_evas_free(ee);
-               ecore_evas_shutdown();
-               return -1;
-       }
-
        Ecore_Evas *resize_img_ee;
        resize_img_ee =
-               ecore_evas_buffer_new(thumb_length, thumb_length);
+               ecore_evas_buffer_new(thumb_width, thumb_height);
 
        if (!resize_img_ee) {
                thumb_err("Failed to create a new ecore evas buffer\n");
-               ecore_evas_free(ee);
                ecore_evas_shutdown();
                return -1;
        }
@@ -516,7 +580,6 @@ int _media_thumb_decode_with_evas(const char *origin_path, int thumb_length,
        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(ee);
                ecore_evas_free(resize_img_ee);
                ecore_evas_shutdown();
                return -1;
@@ -526,13 +589,11 @@ int _media_thumb_decode_with_evas(const char *origin_path, int thumb_length,
        if (!source_img) {
                thumb_dbg
                        ("evas_object_image_add failed\n");
-               ecore_evas_free(ee);
                ecore_evas_free(resize_img_ee);
                ecore_evas_shutdown();
                return -1;
        }
 
-       evas_object_image_load_size_set(source_img, thumb_length, thumb_length);
        evas_object_image_load_orientation_set(source_img, 1);
        evas_object_image_file_set(source_img, origin_path, NULL);
 
@@ -550,42 +611,83 @@ int _media_thumb_decode_with_evas(const char *origin_path, int thumb_length,
                evas_object_image_load_scale_down_set(source_img, 10);
        }
 
+       int err = -1;
+       media_thumb_type thumb_type;
+
+       if (thumb_width == _media_thumb_get_width(MEDIA_THUMB_LARGE)) {
+               thumb_type = MEDIA_THUMB_LARGE;
+       } else {
+               thumb_type = MEDIA_THUMB_SMALL;
+       }
+
+       err = _media_thumb_get_proper_thumb_size(thumb_type,
+                                                                       thumb_info->origin_width, thumb_info->origin_height,
+                                                                       &thumb_width, &thumb_height);
+       if (err < 0) {
+               thumb_err("_media_thumb_get_proper_thumb_size failed: %d", err);
+               ecore_evas_free(resize_img_ee);
+               ecore_evas_shutdown();
+               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_length,
-                                       thumb_length);
+                                       thumb_width,
+                                       thumb_height);
        evas_object_image_filled_set(source_img, 1);
        evas_object_resize(source_img,
-                               thumb_length,
-                               thumb_length);
+                               thumb_width,
+                               thumb_height);
        evas_object_show(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);
+               ecore_evas_shutdown();
+               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);
+               ecore_evas_shutdown();
+               return -1;
+       }
+
        Evas_Object *ret_image =
-               evas_object_image_add(evas);
+               evas_object_image_add(target_evas);
 
        evas_object_image_size_set(ret_image,
-                                       thumb_length,
-                                       thumb_length);
+                                       thumb_width,
+                                       thumb_height);
 
        evas_object_image_fill_set(ret_image, 0,
                                        0,
-                                       thumb_length,
-                                       thumb_length);
+                                       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_length,
-                       thumb_length);
+       evas_object_image_data_update_add(ret_image, 0, 0, thumb_width,
+                       thumb_height);
 
        unsigned int buf_size = 0;
 
-       if (mm_util_get_image_size(MM_UTIL_IMG_FMT_BGRA8888, thumb_length,
-                       thumb_length, &buf_size) < 0) {
+       if (mm_util_get_image_size(MM_UTIL_IMG_FMT_BGRA8888, thumb_width,
+                       thumb_height, &buf_size) < 0) {
                thumb_err("Failed to get buffer size");
 
-               ecore_evas_free(ee);
                ecore_evas_free(resize_img_ee);
+               ecore_evas_free(target_ee);
                ecore_evas_shutdown();
 
                return MEDIA_THUMB_ERROR_MM_UTIL;
@@ -594,12 +696,12 @@ int _media_thumb_decode_with_evas(const char *origin_path, int thumb_length,
        thumb_dbg("mm_util_get_image_size : %d", buf_size);
 
        thumb_info->size = buf_size;
-       thumb_info->width = thumb_length;
-       thumb_info->height = thumb_length;
+       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(ee);
+       ecore_evas_free(target_ee);
        ecore_evas_free(resize_img_ee);
        ecore_evas_shutdown();
 
@@ -714,19 +816,34 @@ int _media_thumb_convert_format(media_thumb_info *thumb_info,
        return 0;
 }
 
-int _media_thumb_agif(const char *origin_path, 
+int _media_thumb_agif(const char *origin_path,
                                        ImgImageInfo *image_info,
-                                       int thumb_length,
+                                       int thumb_width,
+                                       int thumb_height,
                                        media_thumb_format format,
                                        media_thumb_info *thumb_info)
 {
        int err = -1;
-       int thumb_width = thumb_length;
-       int thumb_height = thumb_length;
        unsigned int *thumb = NULL;
+       media_thumb_type thumb_type;
 
        thumb = ImgGetFirstFrameAGIFAtSize(origin_path, image_info);
-       
+
+       if (thumb_width == _media_thumb_get_width(MEDIA_THUMB_LARGE)) {
+               thumb_type = MEDIA_THUMB_LARGE;
+       } else {
+               thumb_type = MEDIA_THUMB_SMALL;
+       }
+
+       err = _media_thumb_get_proper_thumb_size(thumb_type,
+                                                                       thumb_info->origin_width, thumb_info->origin_height,
+                                                                       &thumb_width, &thumb_height);
+       if (err < 0) {
+               thumb_err("_media_thumb_get_proper_thumb_size failed: %d", err);
+               SAFE_FREE(thumb);
+               return err;
+       }
+
        err = _media_thumb_resize_data((unsigned char *)thumb, 
                                                                        image_info->width,
                                                                        image_info->height,
@@ -753,13 +870,14 @@ int _media_thumb_agif(const char *origin_path,
        return 0;
 }
 
-int _media_thumb_png(const char *origin_path, 
-                                       int thumb_length,
+int _media_thumb_png(const char *origin_path,
+                                       int thumb_width,
+                                       int thumb_height,
                                        media_thumb_format format,
                                        media_thumb_info *thumb_info)
 {
        int err = -1;
-       err = _media_thumb_decode_with_evas(origin_path, thumb_length, thumb_info, 0);
+       err = _media_thumb_decode_with_evas(origin_path, thumb_width, thumb_height, thumb_info, 0);
 
        if (err < 0) {
                thumb_err("decode_with_evas failed : %d", err);
@@ -776,13 +894,14 @@ int _media_thumb_png(const char *origin_path,
        return 0;
 }
 
-int _media_thumb_bmp(const char *origin_path, 
-                                       int thumb_length,
+int _media_thumb_bmp(const char *origin_path,
+                                       int thumb_width,
+                                       int thumb_height,
                                        media_thumb_format format,
                                        media_thumb_info *thumb_info)
 {
        int err = -1;
-       err = _media_thumb_decode_with_evas(origin_path, thumb_length, thumb_info, 0);
+       err = _media_thumb_decode_with_evas(origin_path, thumb_width, thumb_height, thumb_info, 0);
 
        if (err < 0) {
                thumb_err("decode_with_evas failed : %d", err);
@@ -799,13 +918,14 @@ int _media_thumb_bmp(const char *origin_path,
        return 0;
 }
 
-int _media_thumb_wbmp(const char *origin_path, 
-                                       int thumb_length,
+int _media_thumb_wbmp(const char *origin_path,
+                                       int thumb_width,
+                                       int thumb_height,
                                        media_thumb_format format,
                                        media_thumb_info *thumb_info)
 {
        int err = -1;
-       err = _media_thumb_decode_with_evas(origin_path, thumb_length, thumb_info, 0);
+       err = _media_thumb_decode_with_evas(origin_path, thumb_width, thumb_height, thumb_info, 0);
 
        if (err < 0) {
                thumb_err("decode_with_evas failed : %d", err);
@@ -823,12 +943,13 @@ int _media_thumb_wbmp(const char *origin_path,
 }
 
 int _media_thumb_gif(const char *origin_path, 
-                                       int thumb_length,
+                                       int thumb_width,
+                                       int thumb_height,
                                        media_thumb_format format,
                                        media_thumb_info *thumb_info)
 {
        int err = -1;
-       err = _media_thumb_decode_with_evas(origin_path, thumb_length, thumb_info, 0);
+       err = _media_thumb_decode_with_evas(origin_path, thumb_width, thumb_height, thumb_info, 0);
 
        if (err < 0) {
                thumb_err("decode_with_evas failed : %d", err);
@@ -845,8 +966,9 @@ int _media_thumb_gif(const char *origin_path,
        return 0;
 }
 
-int _media_thumb_jpeg(const char *origin_path, 
-                                       int thumb_length,
+int _media_thumb_jpeg(const char *origin_path,
+                                       int thumb_width,
+                                       int thumb_height,
                                        media_thumb_format format,
                                        media_thumb_info *thumb_info)
 {
@@ -869,7 +991,7 @@ int _media_thumb_jpeg(const char *origin_path,
                thumb_dbg("Orientation: %d", orientation);
 
                /* Second, Get thumb from exif */
-               err = _media_thumb_get_thumb_from_exif(ed, origin_path, orientation, thumb_length, thumb_length, thumb_info);
+               err = _media_thumb_get_thumb_from_exif(ed, origin_path, orientation, thumb_width, thumb_height, thumb_info);
 
                if (err < 0) {
                        thumb_dbg("_media_thumb_get_thumb_from_exif failed");
@@ -898,7 +1020,7 @@ int _media_thumb_jpeg(const char *origin_path,
 
        if (!thumb_done) {
 
-               err = _media_thumb_decode_with_evas(origin_path, thumb_length, thumb_info, 0);
+               err = _media_thumb_decode_with_evas(origin_path, thumb_width, thumb_height, thumb_info, 0);
        
                if (err < 0) {
                        thumb_err("decode_with_evas failed : %d", err);
@@ -917,8 +1039,9 @@ int _media_thumb_jpeg(const char *origin_path,
 }
 
 int
-_media_thumb_image(const char *origin_path, 
-                                       int thumb_length, 
+_media_thumb_image(const char *origin_path,
+                                       int thumb_width,
+                                       int thumb_height,
                                        media_thumb_format format,
                                        media_thumb_info *thumb_info)
 {
@@ -943,15 +1066,15 @@ _media_thumb_image(const char *origin_path,
        }
 
        if (image_type == IMG_CODEC_AGIF) {
-               err = _media_thumb_agif(origin_path, &image_info, thumb_length, format, thumb_info);
+               err = _media_thumb_agif(origin_path, &image_info, thumb_width, thumb_height, format, thumb_info);
        } else if (image_type == IMG_CODEC_JPEG) {
-               err = _media_thumb_jpeg(origin_path, thumb_length, format, thumb_info);
+               err = _media_thumb_jpeg(origin_path, thumb_width, thumb_height, format, thumb_info);
        } else if (image_type == IMG_CODEC_PNG) {
-               err = _media_thumb_png(origin_path, thumb_length, format, thumb_info);
+               err = _media_thumb_png(origin_path, thumb_width, thumb_height, format, thumb_info);
        } else if (image_type == IMG_CODEC_GIF) {
-               err = _media_thumb_gif(origin_path, thumb_length, format, thumb_info);
+               err = _media_thumb_gif(origin_path, thumb_width, thumb_height, format, thumb_info);
        } else if (image_type == IMG_CODEC_BMP) {
-               err = _media_thumb_bmp(origin_path, thumb_length, format, thumb_info);
+               err = _media_thumb_bmp(origin_path, thumb_width, thumb_height, format, thumb_info);
        } else {
                char file_ext[10];
                err = _media_thumb_get_file_ext(origin_path, file_ext, sizeof(file_ext));
@@ -977,7 +1100,7 @@ _media_thumb_image(const char *origin_path,
                                thumb_info->origin_width = wbmp_width;
                                thumb_info->origin_height = wbmp_height;
 
-                               err = _media_thumb_wbmp(origin_path, thumb_length, format, thumb_info);
+                               err = _media_thumb_wbmp(origin_path, thumb_width, thumb_height, format, thumb_info);
 
                                return err;
                        }
@@ -992,7 +1115,8 @@ _media_thumb_image(const char *origin_path,
 
 int
 _media_thumb_video(const char *origin_path, 
-                                       int thumb_length, 
+                                       int thumb_width,
+                                       int thumb_height,
                                        media_thumb_format format,
                                        media_thumb_info *thumb_info)
 {
@@ -1056,14 +1180,14 @@ _media_thumb_video(const char *origin_path,
                        return MEDIA_THUMB_ERROR_MM_UTIL;
                }
 
-               if (width > thumb_length || height > thumb_length) {
+               if (width > thumb_width || height > thumb_height) {
                        err = _media_thumb_resize_data(frame,
                                                                                width,
-                                                                               height, 
+                                                                               height,
                                                                                MM_UTIL_IMG_FMT_RGB888,
                                                                                thumb_info,
-                                                                               thumb_length,
-                                                                               thumb_length);
+                                                                               thumb_width,
+                                                                               thumb_height);
 
                        if (err < 0) {
                                thumb_err("_media_thumb_resize_data failed - %d", err);
index 585be8cced730d7b16f82fd7409a89e800ce13b2..7d7165cabe0ad0eb3a24c4378d65103b352f02f1 100755 (executable)
@@ -27,7 +27,6 @@
 #include "media-thumb-db.h"
 
 #include <glib.h>
-#include <media-svc.h>
 
 int thumbnail_request_from_db(const char *origin_path, char *thumb_path, int max_length)
 {
@@ -61,11 +60,16 @@ int thumbnail_request_from_db(const char *origin_path, char *thumb_path, int max
 
        thumb_err("Path : %s", origin_path);
 
-       err = minfo_init();
+       //err = minfo_init();
+       err = _media_thumb_db_connect();
+       if (err < 0) {
+               thumb_err("_media_thumb_mb_svc_connect failed: %d", err);
+               return MEDIA_THUMB_ERROR_DB;
+       }
 
        err = _media_thumb_get_thumb_from_db(origin_path, thumb_path, max_length, &need_update_db);
        if (err == 0) {
-               minfo_finalize();
+               _media_thumb_db_disconnect();
                return MEDIA_THUMB_ERROR_NONE;
        }
 
@@ -73,7 +77,7 @@ int thumbnail_request_from_db(const char *origin_path, char *thumb_path, int max
        err = _media_thumb_request(THUMB_REQUEST_DB, MEDIA_THUMB_LARGE, origin_path, thumb_path, max_length, &thumb_info);
        if (err < 0) {
                thumb_err("_media_thumb_request failed : %d", err);
-               minfo_finalize();
+               _media_thumb_db_disconnect();
                return err;
        }
 
@@ -85,7 +89,7 @@ int thumbnail_request_from_db(const char *origin_path, char *thumb_path, int max
                }
        }
 
-       minfo_finalize();
+       _media_thumb_db_disconnect();
        return MEDIA_THUMB_ERROR_NONE;
 }
 
index f0e41ad3d8a38e0de2c424ceff071a7b797b3d88..8893f0b485d4e1cffcdbc3a1ac3898a6e9a94734 100755 (executable)
  */
 
 #include "media-thumb-db.h"
-#include <media-svc.h>
+//#include <media-svc.h>
+//#include <visual-svc.h>
 #include <glib.h>
 #include <string.h>
+#include <unistd.h>
+#include <util-func.h>
+
+//__thread MediaSvcHandle *mb_svc_handle = NULL;
+__thread sqlite3 *db_handle;
+const char *MEDIA_DATABASE_NAME = "/opt/dbspace/.media.db";
+const char *SELECT_MEDIA_BY_PATH = "SELECT thumbnail_path FROM visual_media WHERE path='%q';";
+const char *UPDATE_THUMB_BY_PATH = "UPDATE visual_media SET thumbnail_path = '%q' WHERE path='%q';";
+const char *UPDATE_WH_BY_PATH = "UPDATE image_meta SET width=%d,height=%d WHERE visual_uuid=(SELECT visual_uuid FROM visual_media WHERE path='%q');";
+
+static int _media_thumb_busy_handler(void *pData, int count)
+{
+       usleep(50000);
+       thumb_dbg("_media_thumb_busy_handler called : %d\n", count);
+
+       return 100 - count;
+}
+
+int
+_media_thumb_sqlite_connect(sqlite3 **handle)
+{
+       int err = -1;
+       err = db_util_open(MEDIA_DATABASE_NAME, handle,
+                        DB_UTIL_REGISTER_HOOK_METHOD);
+
+       if (SQLITE_OK != err) {
+               *handle = NULL;
+               return -1;
+       }
+
+       /*Register busy handler*/
+       err = sqlite3_busy_handler(*handle, _media_thumb_busy_handler, NULL);
+       if (SQLITE_OK != err) {
+               if (*handle) thumb_err("[sqlite] %s\n", sqlite3_errmsg(*handle));
+
+               db_util_close(*handle);
+               *handle = NULL;
+
+               return -1;
+       }
+
+       return MEDIA_THUMB_ERROR_NONE;
+}
+
+int
+_media_thumb_sqlite_disconnect(sqlite3 *handle)
+{
+       int err = -1;
+       if (handle != NULL) {
+               err = db_util_close(handle);
+
+               if (SQLITE_OK != err) {
+                       handle = NULL;
+                       return -1;
+               }
+       }
+
+       return MEDIA_THUMB_ERROR_NONE;
+}
+
+int
+_media_thumb_get_thumb_path_from_db(sqlite3 *handle,
+                                                                       const char *origin_path,
+                                                                       char *thumb_path,
+                                                                       int max_length)
+{
+       thumb_dbg("Origin path : %s", origin_path);
+
+       if (handle == NULL) {
+               thumb_err("DB handle is NULL");
+               return -1;
+       }
+
+       int err = -1;
+       char *path_string = NULL;
+       char *query_string = NULL;
+       sqlite3_stmt *stmt = NULL;
+
+       path_string = sqlite3_mprintf("%s", origin_path);
+       query_string = sqlite3_mprintf(SELECT_MEDIA_BY_PATH, path_string);
+
+       thumb_dbg("Query: %s", query_string);
+
+       err = sqlite3_prepare_v2(handle, query_string, strlen(query_string), &stmt, NULL);
+
+       sqlite3_free(query_string);
+       sqlite3_free(path_string);
+
+       if (SQLITE_OK != err) {
+               thumb_err("prepare error [%s]\n", sqlite3_errmsg(handle));
+               return -1;
+       }
+
+       err = sqlite3_step(stmt);
+       if (err != SQLITE_ROW) {
+               thumb_err("end of row [%s]\n", sqlite3_errmsg(handle));
+               sqlite3_finalize(stmt);
+               return -1;
+       }
+
+       strncpy(thumb_path, (const char *)sqlite3_column_text(stmt, 0), max_length);
+       sqlite3_finalize(stmt);
+
+       return MEDIA_THUMB_ERROR_NONE;
+}
+
+int
+_media_thumb_update_thumb_path_to_db(sqlite3 *handle,
+                                                                       const char *origin_path,
+                                                                       char *thumb_path)
+{
+       thumb_dbg("");
+       int err = -1;
+       char *path_string = NULL;
+       char *thumbpath_string = NULL;
+       char *query_string = NULL;
+       char *err_msg = NULL;
+
+       if (handle == NULL) {
+               thumb_err("DB handle is NULL");
+               return -1;
+       }
+
+       path_string = sqlite3_mprintf("%s", origin_path);
+       thumbpath_string = sqlite3_mprintf("%s", thumb_path);
+       query_string = sqlite3_mprintf(UPDATE_THUMB_BY_PATH, thumbpath_string, path_string);
+
+       err = sqlite3_exec(handle, query_string, NULL, NULL, &err_msg);
+
+       thumb_dbg("Query : %s", query_string);
+
+       sqlite3_free(query_string);
+       sqlite3_free(thumbpath_string);
+       sqlite3_free(path_string);
+
+       if (SQLITE_OK != err) {
+               if (err_msg) {
+                       thumb_err("Failed to query[ %s ]", err_msg);
+                       sqlite3_free(err_msg);
+                       err_msg = NULL;
+               }
+
+               return -1;
+       }
+
+       if (err_msg)
+               sqlite3_free(err_msg);
+
+       thumb_dbg("Query success");
+
+       return MEDIA_THUMB_ERROR_NONE;
+}
+
+int
+_media_thumb_update_wh_to_db(sqlite3 *handle,
+                                                               const char *origin_path,
+                                                               int width,
+                                                               int height)
+{
+       thumb_dbg("");
+       int err = -1;
+       char *path_string = NULL;
+       char *query_string = NULL;
+       char *err_msg = NULL;
+
+       if (handle == NULL) {
+               thumb_err("DB handle is NULL");
+               return -1;
+       }
+
+       path_string = sqlite3_mprintf("%s", origin_path);
+       query_string = sqlite3_mprintf(UPDATE_WH_BY_PATH, width, height, path_string);
+
+       err = sqlite3_exec(handle, query_string, NULL, NULL, &err_msg);
+
+       thumb_dbg("Query : %s", query_string);
+
+       sqlite3_free(query_string);
+       sqlite3_free(path_string);
+
+       if (SQLITE_OK != err) {
+               if (err_msg) {
+                       thumb_err("Failed to query[ %s ]", err_msg);
+                       sqlite3_free(err_msg);
+                       err_msg = NULL;
+               }
+
+               return -1;
+       }
+
+       if (err_msg)
+               sqlite3_free(err_msg);
+
+       thumb_dbg("Query success");
+
+       return MEDIA_THUMB_ERROR_NONE;
+}
+
+int
+_media_thumb_db_connect()
+{
+       int err = -1;
+/*
+       err = media_svc_connect(&mb_svc_handle);
+       if (err < 0) {
+               thumb_err("media_svc_connect failed: %d", err);
+               mb_svc_handle = NULL;
+               return err;
+       }
+*/
+       err = _media_thumb_sqlite_connect(&db_handle);
+       if (err < 0) {
+               thumb_err("_media_thumb_sqlite_connect failed: %d", err);
+               db_handle = NULL;
+               return err;
+       }
+
+       return MEDIA_THUMB_ERROR_NONE;
+}
+
+int
+_media_thumb_db_disconnect()
+{
+       int err = -1;
+/*
+       err = media_svc_disconnect(mb_svc_handle);
+
+       if (err < 0) {
+               thumb_err("media_svc_disconnect failed: %d", err);
+       }
+
+       mb_svc_handle = NULL;
+*/
+       err = _media_thumb_sqlite_disconnect(db_handle);
+       if (err < 0) {
+               thumb_err("_media_thumb_sqlite_disconnect failed: %d", err);
+               db_handle = NULL;
+               return err;
+       }
+
+       db_handle = NULL;
+       return err;
+}
 
 int
 _media_thumb_get_thumb_from_db(const char *origin_path,
@@ -33,7 +277,8 @@ _media_thumb_get_thumb_from_db(const char *origin_path,
        thumb_dbg("");
        int err = -1;
 
-       err = minfo_get_thumb_path(origin_path, thumb_path, max_length);
+       //err = minfo_get_thumb_path(mb_svc_handle, origin_path, thumb_path, max_length);
+       err = _media_thumb_get_thumb_path_from_db(db_handle, origin_path, thumb_path, max_length);
        if (err < 0) {
                thumb_warn("Original path doesn't exist in DB");
                return -1;
@@ -56,7 +301,7 @@ _media_thumb_get_thumb_from_db(const char *origin_path,
                thumb_dbg("This thumb path already exist");
        }
 
-       return 0;
+       return MEDIA_THUMB_ERROR_NONE;
 }
 
 int
@@ -67,15 +312,17 @@ _media_thumb_update_db(const char *origin_path,
 {
        thumb_dbg("");
        int err = -1;
+
+#if 0
        Mitem *item = NULL;
 
-       err = minfo_get_item(origin_path, &item);
+       err = minfo_get_item(mb_svc_handle, origin_path, &item);
        if (err < 0) {
                thumb_err("minfo_get_item (%s) failed: %d", origin_path, err);
                return MEDIA_THUMB_ERROR_DB;
        }
 
-       err = minfo_update_media_thumb(item->uuid, thumb_path);
+       err = minfo_update_media_thumb(mb_svc_handle, item->uuid, thumb_path);
        if (err < 0) {
                thumb_err("minfo_update_media_thumb (ID:%s, %s) failed: %d",
                                                        item->uuid, thumb_path, err);
@@ -84,8 +331,9 @@ _media_thumb_update_db(const char *origin_path,
        }
 
        if (item->type == MINFO_ITEM_IMAGE) {
-               err = minfo_update_image_meta_info_int(item->uuid, MINFO_IMAGE_META_WIDTH, width,
-                                                                                                       MINFO_IMAGE_META_HEIGHT, height, -1);
+               err = minfo_update_image_meta_info_int(mb_svc_handle, item->uuid, 
+                                                                                               MINFO_IMAGE_META_WIDTH, width,
+                                                                                               MINFO_IMAGE_META_HEIGHT, height, -1);
        
                if (err < 0) {
                        thumb_err("minfo_update_image_meta_info_int failed: %d", err);
@@ -95,9 +343,22 @@ _media_thumb_update_db(const char *origin_path,
        }
        
        err = minfo_destroy_mtype_item(item);
+#endif
+
+       err = _media_thumb_update_thumb_path_to_db(db_handle, origin_path, thumb_path);
+       if (err < 0) {
+               thumb_err("_media_thumb_update_thumb_path_to_db (%s) failed: %d", origin_path, err);
+               return MEDIA_THUMB_ERROR_DB;
+       }
+
+       err = _media_thumb_update_wh_to_db(db_handle, origin_path, width, height);
+       if (err < 0) {
+               thumb_err("_media_thumb_update_wh_to_db (%s) failed: %d", origin_path, err);
+               return MEDIA_THUMB_ERROR_DB;
+       }
 
        thumb_dbg("_media_thumb_update_db success");
 
-       return 0;
+       return MEDIA_THUMB_ERROR_NONE;
 }
 
index 7d34a7a5e3e0b9b0664638b85aa137848f296e64..f224c170e5858b2e056531ebeb95c2e64eac1fa9 100755 (executable)
 #include <Evas.h>
 #include <Ecore_Evas.h>
 
-int _media_thumb_get_length(media_thumb_type thumb_type)
+int _media_thumb_get_width(media_thumb_type thumb_type)
 {
        if (thumb_type == MEDIA_THUMB_LARGE) {
-               return 256;
+               return THUMB_LARGE_WIDTH;
        } else if (thumb_type == MEDIA_THUMB_SMALL) {
-               return  96;
+               return  THUMB_SMALL_WIDTH;
+       } else {
+               return -1;
+       }
+}
+
+int _media_thumb_get_height(media_thumb_type thumb_type)
+{
+       if (thumb_type == MEDIA_THUMB_LARGE) {
+               return THUMB_LARGE_HEIGHT;
+       } else if (thumb_type == MEDIA_THUMB_SMALL) {
+               return  THUMB_SMALL_HEIGHT;
        } else {
                return -1;
        }
@@ -256,7 +267,8 @@ int _thumbnail_get_data(const char *origin_path,
                                                int *origin_height)
 {
        int err = -1;
-       int thumb_length = -1;
+       int thumb_width = -1;
+       int thumb_height = -1;
 
        if (origin_path == NULL || size == NULL 
                        || width == NULL || height == NULL) {
@@ -275,8 +287,14 @@ int _thumbnail_get_data(const char *origin_path,
                        return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
        }
 
-       thumb_length = _media_thumb_get_length(thumb_type);
-       if (thumb_length < 0) {
+       thumb_width = _media_thumb_get_width(thumb_type);
+       if (thumb_width < 0) {
+               thumb_err("media_thumb_type is invalid");
+               return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
+       }
+
+       thumb_height = _media_thumb_get_height(thumb_type);
+       if (thumb_height < 0) {
                thumb_err("media_thumb_type is invalid");
                return MEDIA_THUMB_ERROR_INVALID_PARAMETER;
        }
@@ -288,14 +306,14 @@ int _thumbnail_get_data(const char *origin_path,
        file_type = _media_thumb_get_file_type(origin_path);
 
        if (file_type == THUMB_IMAGE_TYPE) {
-               err = _media_thumb_image(origin_path, thumb_length, format, &thumb_info);
+               err = _media_thumb_image(origin_path, thumb_width, thumb_height, format, &thumb_info);
                if (err < 0) {
                        thumb_err("_media_thumb_image failed");
                        return err;
                }
 
        } else if (file_type == THUMB_VIDEO_TYPE) {
-               err = _media_thumb_video(origin_path, thumb_length, format, &thumb_info);
+               err = _media_thumb_video(origin_path, thumb_width, thumb_height, format, &thumb_info);
                if (err < 0) {
                        thumb_err("_media_thumb_image failed");
                        return err;