diff options
author | seunggi.hong <seunggi.hong@samsung.com> | 2015-06-19 14:47:19 +0900 |
---|---|---|
committer | seunggi.hong <seunggi.hong@samsung.com> | 2015-06-19 14:48:05 +0900 |
commit | 7a18395cf8bd49edc3f7ae7b9f1d6f57751d56f8 (patch) | |
tree | 1c8f89a3f39f20cc952c4a634ab7176c1cc88b54 | |
parent | 0c78f588f22be45e99047f0ba1685f70ab46f13f (diff) | |
download | msg-service-7a18395cf8bd49edc3f7ae7b9f1d6f57751d56f8.tar.gz msg-service-7a18395cf8bd49edc3f7ae7b9f1d6f57751d56f8.tar.bz2 msg-service-7a18395cf8bd49edc3f7ae7b9f1d6f57751d56f8.zip |
Change making thumbnail method
Change-Id: Ide76f430ed831ad1c62f5fba411bd61b9ba6e759
-rwxr-xr-x | packaging/msg-service.spec | 3 | ||||
-rwxr-xr-x | plugin/mms_plugin/CMakeLists.txt | 2 | ||||
-rwxr-xr-x | plugin/mms_plugin/MmsPluginUtil.cpp | 77 |
3 files changed, 73 insertions, 9 deletions
diff --git a/packaging/msg-service.spec b/packaging/msg-service.spec index 0eb2a36..92debec 100755 --- a/packaging/msg-service.spec +++ b/packaging/msg-service.spec @@ -45,7 +45,8 @@ BuildRequires: pkgconfig(libcurl) BuildRequires: pkgconfig(libsystemd-daemon) BuildRequires: pkgconfig(libxml-2.0) BuildRequires: pkgconfig(libwbxml2) -BuildRequires: pkgconfig(media-thumbnail) +BuildRequires: pkgconfig(capi-media-thumbnail-util) +BuildRequires: pkgconfig(capi-media-image-util) BuildRequires: pkgconfig(mm-fileinfo) BuildRequires: pkgconfig(mm-player) BuildRequires: pkgconfig(mm-session) diff --git a/plugin/mms_plugin/CMakeLists.txt b/plugin/mms_plugin/CMakeLists.txt index 55dba8b..0d8f267 100755 --- a/plugin/mms_plugin/CMakeLists.txt +++ b/plugin/mms_plugin/CMakeLists.txt @@ -45,7 +45,7 @@ INCLUDE_DIRECTORIES( ) INCLUDE(FindPkgConfig) -pkg_check_modules(mms_plugin_pkgs REQUIRED glib-2.0 libcurl mm-fileinfo mmutil-imgp mmutil-jpeg vconf dlog media-thumbnail capi-network-connection db-util) +pkg_check_modules(mms_plugin_pkgs REQUIRED glib-2.0 libcurl mm-fileinfo mmutil-imgp mmutil-jpeg vconf dlog capi-media-thumbnail-util capi-media-image-util capi-network-connection db-util) FOREACH(flag ${mms_plugin_pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") diff --git a/plugin/mms_plugin/MmsPluginUtil.cpp b/plugin/mms_plugin/MmsPluginUtil.cpp index 64cd536..4bcb74b 100755 --- a/plugin/mms_plugin/MmsPluginUtil.cpp +++ b/plugin/mms_plugin/MmsPluginUtil.cpp @@ -17,16 +17,53 @@ #include <mm_file.h> #include <mm_util_jpeg.h> #include <mm_util_imgp.h> -#include <media-thumbnail.h> +#include <thumbnail_util.h> +#include <image_util.h> + #include <ctype.h> #include <errno.h> #include <sys/stat.h> #include "MsgUtilFile.h" +#include "MsgMutex.h" #include "MmsPluginDebug.h" #include "MmsPluginUtil.h" #include <string> + using namespace std; + +Mutex g_mx; +CndVar g_cv; + +void thumbnail_completed_cb(thumbnail_util_error_e error, const char *request_id, + int thumb_width, int thumb_height, + unsigned char *thumb_data, int thumb_size, void *user_data) +{ + if (!user_data) { + MSG_DEBUG("dstPath is NULL"); + return; + } + + MSG_BEGIN(); + + g_mx.lock(); + MSG_DEBUG("=================[RESULT]"); + MSG_DEBUG("error_code [%d]", error); + MSG_DEBUG("request id [%s]", request_id); + MSG_DEBUG("width [%d], height [%d]", thumb_width, thumb_height); + MSG_DEBUG("raw_data [0x%x], size [%d]", *thumb_data, thumb_size); + + int ret = 0; + ret = image_util_encode_jpeg(thumb_data, thumb_width, thumb_height, IMAGE_UTIL_COLORSPACE_BGRA8888, 90, (char *)user_data);; + if (ret != IMAGE_UTIL_ERROR_NONE) + MSG_DEBUG("image_util_encode_jpeg() is failed"); + + g_cv.signal(); + g_mx.unlock(); + + MSG_END(); +} + bool MmsMakeImageThumbnail(char *srcPath, char *dstPath) { if (srcPath == NULL || dstPath == NULL) { @@ -38,11 +75,38 @@ bool MmsMakeImageThumbnail(char *srcPath, char *dstPath) MSG_DEBUG("not exist source file [%s]", srcPath); return false; } -#ifndef MSG_CONTACTS_SERVICE_NOT_SUPPORTED - int err = -1; - err = thumbnail_request_save_to_file(srcPath, MEDIA_THUMB_LARGE, dstPath); - if (err < 0) { - MSG_DEBUG("Make thumbnail: failed, err = %d", err); + + g_mx.lock(); + + int time_ret = 0; + + int ret = THUMBNAIL_UTIL_ERROR_NONE; + char *req_id = NULL; + thumbnail_h thumb_h; + thumbnail_util_create(&thumb_h); +// thumbnail_util_set_size(thumb_h, 240, 240); + thumbnail_util_set_path(thumb_h, srcPath); + MSG_DEBUG("thumbnail_util_extract"); + + ret = thumbnail_util_extract(thumb_h, thumbnail_completed_cb, dstPath, &req_id); + thumbnail_util_destroy(thumb_h); + if (req_id) { + g_free(req_id); + req_id = NULL; + } + + if (ret != THUMBNAIL_UTIL_ERROR_NONE) { + MSG_DEBUG("thumbnail_util_extract is failed"); + g_mx.unlock(); + return false; + } + + time_ret = g_cv.timedwait(g_mx.pMutex(), 5); + + g_mx.unlock(); + + if (time_ret == ETIMEDOUT) { + MSG_INFO("@@ WAKE by timeout@@"); return false; } @@ -52,7 +116,6 @@ bool MmsMakeImageThumbnail(char *srcPath, char *dstPath) } MSG_DEBUG("Make thumbnail: success [%s]", dstPath); -#endif return true; } |