diff options
author | jk7744.park <jk7744.park@samsung.com> | 2015-02-01 13:45:51 +0900 |
---|---|---|
committer | jk7744.park <jk7744.park@samsung.com> | 2015-02-01 13:45:51 +0900 |
commit | 8fd54917d4b857eadd36c02ba32e642165b1f85d (patch) | |
tree | 0f11c6a7ce48c9808e7516e2b3fe3f8ddc76f083 | |
parent | 75ef5e99ce0dbfd2ab096b40c57a1c28fa9cf34f (diff) | |
download | libmedia-thumbnail-tizen_2.3.tar.gz libmedia-thumbnail-tizen_2.3.tar.bz2 libmedia-thumbnail-tizen_2.3.zip |
tizen 2.3 releasetizen_2.3_releasesubmit/tizen_2.3/20150202.062859tizen_2.3
-rw-r--r-- | CMakeLists.txt | 12 | ||||
-rw-r--r-- | md5/md5.c | 7 | ||||
-rw-r--r-- | packaging/libmedia-thumbnail.spec | 15 | ||||
-rwxr-xr-x | server/include/thumb-server-internal.h | 2 | ||||
-rwxr-xr-x | server/thumb-server-internal.c | 110 | ||||
-rwxr-xr-x | server/thumb-server.c | 7 | ||||
-rw-r--r-- | src/codec/IfegDecodeAGIF.c | 67 | ||||
-rw-r--r-- | src/codec/img-codec-osal.c | 19 | ||||
-rwxr-xr-x | src/include/media-thumb-internal.h | 8 | ||||
-rwxr-xr-x | src/ipc/media-thumb-ipc.c | 20 | ||||
-rwxr-xr-x | src/media-thumb-internal.c | 134 | ||||
-rwxr-xr-x | src/util/media-thumb-util.c | 108 |
12 files changed, 256 insertions, 253 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 77e1777..1e8d8aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,7 @@ SET(VERSION "${VERSION_MAJOR}.0.0") SET(MEDIATHUMB-LIB "media-thumbnail") SET(MEDIAHASH-LIB "media-hash") -SET(SRCS +SET(SRCS src/media-thumbnail.c src/util/media-thumb-debug.c src/util/media-thumb-util.c @@ -46,12 +46,7 @@ MESSAGE("Build type: ${CMAKE_BUILD_TYPE}") INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/src/include ${CMAKE_SOURCE_DIR}/src/include/util ${CMAKE_SOURCE_DIR}/src/include/codec ${CMAKE_SOURCE_DIR}/src/include/util ${CMAKE_SOURCE_DIR}/src/include/ipc ${CMAKE_SOURCE_DIR}/server/include ${CMAKE_SOURCE_DIR}/md5) INCLUDE(FindPkgConfig) - -IF ( TIZEN_W ) -pkg_check_modules(pkgs REQUIRED glib-2.0 gthread-2.0 dlog mm-fileinfo drm-client aul libexif ecore-evas evas mmutil-imgp mmutil-jpeg libmedia-utils vconf dbus-glib-1 deviced) -ELSE ( TIZEN_W ) -pkg_check_modules(pkgs REQUIRED glib-2.0 gthread-2.0 dlog mm-fileinfo drm-client aul libexif ecore-evas evas mmutil-imgp mmutil-jpeg libmedia-utils vconf dbus-glib-1 pmapi) -ENDIF ( TIZEN_W ) + pkg_check_modules(pkgs REQUIRED glib-2.0 gthread-2.0 dlog mm-fileinfo aul libexif ecore-evas evas mmutil-imgp mmutil-jpeg libmedia-utils vconf dbus-glib-1 deviced) FOREACH(flag ${pkgs_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") @@ -74,9 +69,6 @@ ADD_DEFINITIONS("-DPACKAGE_NAME=\"${PKGNAME}\"") ADD_DEFINITIONS("-DPREFIX=\"${PREFIX}\"") #ADD_DEFINITIONS("-D_PERFORMANCE_CHECK_") ADD_DEFINITIONS("-D_FILE_OFFSET_BITS=64") -IF ( TIZEN_W ) -ADD_DEFINITIONS("-DTIZEN_W") -ENDIF ( TIZEN_W ) SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--hash-style=both") CONFIGURE_FILE(media-thumbnail.pc.in media-thumbnail.pc @ONLY) @@ -143,15 +143,12 @@ void MD5Final(unsigned char digest[16], MD5_CTX *ctx) byteReverse(ctx->in, 14); /* Append length in bits and transform */ -// ((uint32_t *) ctx->in)[14] = ctx->bits[0]; -// ((uint32_t *) ctx->in)[15] = ctx->bits[1]; - ctx->in[14] = ctx->bits[0]; - ctx->in[15] = ctx->bits[1]; + memcpy(((uint32_t *) ctx->in)+14, ctx->bits, sizeof(uint32_t)*2); MD5Transform(ctx->buf, (uint32_t *) ctx->in); byteReverse((unsigned char *)ctx->buf, 4); memcpy(digest, ctx->buf, 16); - memset((char *)ctx, 0, sizeof(ctx)); /* In case it's sensitive */ + memset((char *)ctx, 0, sizeof(*ctx)); /* In case it's sensitive */ } /* The four core functions - F1 is optimized somewhat */ diff --git a/packaging/libmedia-thumbnail.spec b/packaging/libmedia-thumbnail.spec index ee947f2..658c284 100644 --- a/packaging/libmedia-thumbnail.spec +++ b/packaging/libmedia-thumbnail.spec @@ -1,6 +1,6 @@ Name: libmedia-thumbnail Summary: Media thumbnail service library for multimedia applications. -Version: 0.1.102 +Version: 0.1.116 Release: 1 Group: utils License: Apache license v2.0 and public domain @@ -12,7 +12,6 @@ BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(mm-fileinfo) BuildRequires: pkgconfig(mmutil-imgp) BuildRequires: pkgconfig(mmutil-jpeg) -BuildRequires: pkgconfig(drm-client) BuildRequires: pkgconfig(libexif) BuildRequires: pkgconfig(evas) BuildRequires: pkgconfig(ecore) @@ -21,12 +20,8 @@ BuildRequires: pkgconfig(vconf) BuildRequires: pkgconfig(libmedia-utils) BuildRequires: pkgconfig(dbus-glib-1) #exclude tizen_w -%if %{_repository} == "wearable" BuildRequires: pkgconfig(deviced) -%else -BuildRequires: pkgconfig(pmapi) -%endif - +BuildRequires: pkgconfig(capi-appfw-application) %description Description: Media thumbnail service library for multimedia applications. @@ -63,11 +58,7 @@ export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE" export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE" %endif -cmake \ -%if %{_repository} == "wearable" - -DTIZEN_W=YES \ -%endif - . -DCMAKE_INSTALL_PREFIX=%{_prefix} +cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} make %{?jobs:-j%jobs} diff --git a/server/include/thumb-server-internal.h b/server/include/thumb-server-internal.h index d3ada9b..49c28d9 100755 --- a/server/include/thumb-server-internal.h +++ b/server/include/thumb-server-internal.h @@ -50,6 +50,7 @@ void _thumb_daemon_finish_jobs(void); void _thumb_daemon_power_off_cb(void* data); void _thumb_daemon_mmc_eject_vconf_cb(keynode_t *key, void* data); void _thumb_daemon_vconf_cb(keynode_t *key, void* data); +void _thumb_daemon_camera_vconf_cb(keynode_t *key, void* data); gboolean _thumb_server_prepare_socket(int *sock_fd); gboolean _thumb_server_read_socket(GIOChannel *src, GIOCondition condition, gpointer data); bool _thumb_sever_set_power_mode(_server_status_e status); @@ -60,6 +61,7 @@ int _thumb_sever_poweoff_event_receiver(power_off_cb user_callback, void *user_d int _thumbnail_get_data(const char *origin_path, media_thumb_type thumb_type, media_thumb_format format, + char *thumb_path, unsigned char **data, int *size, int *width, diff --git a/server/thumb-server-internal.c b/server/thumb-server-internal.c index a8f8bfd..64b724f 100755 --- a/server/thumb-server-internal.c +++ b/server/thumb-server-internal.c @@ -28,11 +28,7 @@ #include <stdio.h> #include <string.h> #include <Ecore_Evas.h> -#ifdef TIZEN_W #include <dd-display.h> -#else -#include <pmapi.h> -#endif #ifdef LOG_TAG #undef LOG_TAG #endif @@ -48,8 +44,13 @@ static __thread int g_cur_idx = 0; GMainLoop *g_thumb_server_mainloop; // defined in thumb-server.c as extern +guint g_source_id; +bool g_extract_all_status; + static gboolean __thumb_server_send_msg_to_agent(int msg_type); static void __thumb_daemon_stop_job(void); +static int __thumb_daemon_all_extract(void); +int _thumb_daemon_process_queue_jobs(gpointer data); gboolean _thumb_daemon_start_jobs(gpointer data) { @@ -168,6 +169,42 @@ void _thumb_daemon_vconf_cb(keynode_t *key, void* data) return; } +void _thumb_daemon_camera_vconf_cb(keynode_t *key, void* data) +{ + int err = -1; + int camera_state = -1; + + err = vconf_get_int(VCONFKEY_CAMERA_STATE, &camera_state); + if (err == 0) { + thumb_dbg("camera state: %d", camera_state); + } else { + thumb_err("vconf_get_int failed: %d", err); + return; + } + + if (camera_state >= VCONFKEY_CAMERA_STATE_PREVIEW) { + thumb_warn("CAMERA is running. Do not create thumbnail"); + + if (g_source_id > 0) { + __thumb_daemon_stop_job(); + g_source_remove(g_source_id); + g_source_id = 0; + } + thumb_warn("q_source_id = %d", g_source_id); + } else { + if (g_extract_all_status == true) { + /*add queue job again*/ + thumb_warn("q_source_id = %d", g_source_id); + if (g_source_id == 0) { + __thumb_daemon_all_extract(); + g_source_id = g_idle_add(_thumb_daemon_process_queue_jobs, NULL); + } + } + } + + return; +} + static void __thumb_daemon_stop_job() { int i = 0; @@ -187,9 +224,6 @@ static int __thumb_daemon_process_job(thumbMsg *req_msg, thumbMsg *res_msg) { int err = -1; - if (_thumb_sever_set_power_mode(THUMB_START) == FALSE) - thumb_err("_thumb_sever_set_power_mode failed"); - err = _media_thumb_process(req_msg, res_msg); if (err < 0) { if (req_msg->msg_type == THUMB_REQUEST_SAVE_FILE) { @@ -208,9 +242,6 @@ static int __thumb_daemon_process_job(thumbMsg *req_msg, thumbMsg *res_msg) res_msg->status = THUMB_SUCCESS; } - if (_thumb_sever_set_power_mode(THUMB_END) == FALSE) - thumb_err("_thumb_sever_set_power_mode failed"); - return err; } @@ -239,7 +270,7 @@ static int __thumb_daemon_all_extract(void) } else { snprintf(query_string, sizeof(query_string), SELECT_PATH_FROM_UNEXTRACTED_THUMB_INTERNAL_MEDIA); } - + thumb_warn("Query: %s", query_string); err = sqlite3_prepare_v2(sqlite_db_handle, query_string, strlen(query_string), &sqlite_stmt, NULL); @@ -276,6 +307,22 @@ static int __thumb_daemon_all_extract(void) return MEDIA_THUMB_ERROR_NONE; } + static int __thumb_daemon_get_camera_state() +{ + int err = -1; + int camera_state = -1; + + err = vconf_get_int(VCONFKEY_CAMERA_STATE, &camera_state); + if (err == 0) { + thumb_dbg("camera state: %d", camera_state); + return camera_state; + } else { + thumb_err("vconf_get_int failed: %d", err); + } + + return camera_state; +} + int _thumb_daemon_process_queue_jobs(gpointer data) { int err = -1; @@ -329,6 +376,7 @@ int _thumb_daemon_process_queue_jobs(gpointer data) //_media_thumb_db_disconnect(); __thumb_server_send_msg_to_agent(MS_MSG_THUMB_EXTRACT_ALL_DONE); // MS_MSG_THUMB_EXTRACT_ALL_DONE + g_source_id = 0; return FALSE; } @@ -368,9 +416,14 @@ gboolean _thumb_server_read_socket(GIOChannel *src, if (recv_msg.msg_type == THUMB_REQUEST_ALL_MEDIA) { if (g_idx == 0) { - thumb_warn("All thumbnails are being extracted now"); - __thumb_daemon_all_extract(); - g_idle_add(_thumb_daemon_process_queue_jobs, NULL); + if (__thumb_daemon_get_camera_state() < VCONFKEY_CAMERA_STATE_PREVIEW) { + if (g_source_id == 0) { + thumb_warn("All thumbnails are being extracted now"); + __thumb_daemon_all_extract(); + g_source_id = g_idle_add(_thumb_daemon_process_queue_jobs, NULL); + } + } + g_extract_all_status = true; } else { thumb_warn("All thumbnails are already being extracted."); } @@ -404,7 +457,7 @@ gboolean _thumb_server_read_socket(GIOChannel *src, if(recv_msg.msg_type == THUMB_REQUEST_KILL_SERVER) { thumb_warn("Shutting down..."); -#if 0 +#if 1 if (_thumb_sever_set_power_mode(THUMB_END) == FALSE) thumb_err("_thumb_sever_set_power_mode failed"); #endif @@ -476,20 +529,12 @@ bool _thumb_sever_set_power_mode(_server_status_e status) switch (status) { case THUMB_START: -#ifdef TIZEN_W err = display_lock_state(LCD_OFF, STAY_CUR_STATE, 0); -#else - err = pm_lock_state(LCD_OFF, STAY_CUR_STATE, 0); -#endif if (err != 0) res = FALSE; break; case THUMB_END: -#ifdef TIZEN_W err = display_unlock_state(LCD_OFF, STAY_CUR_STATE); -#else - err = pm_unlock_state(LCD_OFF, STAY_CUR_STATE); -#endif if (err != 0) res = FALSE; break; @@ -608,6 +653,7 @@ int _thumb_sever_poweoff_event_receiver(power_off_cb user_callback, void *user_d int _thumbnail_get_data(const char *origin_path, media_thumb_type thumb_type, media_thumb_format format, + char *thumb_path, unsigned char **data, int *size, int *width, @@ -659,10 +705,10 @@ int _thumbnail_get_data(const char *origin_path, if (file_type == THUMB_IMAGE_TYPE) { if (is_drm) { - thumb_err("DRM file is not supported"); + thumb_err("DRM IMAGE IS NOT SUPPORTED"); return MEDIA_THUMB_ERROR_UNSUPPORTED; } else { - err = _media_thumb_image(origin_path, thumb_width, thumb_height, format, &thumb_info); + err = _media_thumb_image(origin_path, thumb_path, thumb_width, thumb_height, format, &thumb_info); if (err < 0) { thumb_err("_media_thumb_image failed"); return err; @@ -774,20 +820,20 @@ _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg) thumb_dbg_slog("Thumb path : %s", thumb_path); - if (g_file_test(thumb_path, - G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) { + if (g_file_test(thumb_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) { thumb_warn("thumb path already exists in file system.. remove the existed file"); _media_thumb_remove_file(thumb_path); } - err = _thumbnail_get_data(origin_path, thumb_type, thumb_format, &data, &thumb_size, &thumb_w, &thumb_h, &origin_w, &origin_h, &alpha, &is_saved); + err = _thumbnail_get_data(origin_path, thumb_type, thumb_format, thumb_path, &data, &thumb_size, &thumb_w, &thumb_h, &origin_w, &origin_h, &alpha, &is_saved); if (err < 0) { thumb_err("_thumbnail_get_data failed - %d", err); SAFE_FREE(data); strncpy(thumb_path, THUMB_DEFAULT_PATH, max_length); - _media_thumb_db_disconnect(); - return err; + goto DB_UPDATE; +// _media_thumb_db_disconnect(); +// return err; } //thumb_dbg("Size : %d, W:%d, H:%d", thumb_size, thumb_w, thumb_h); @@ -814,7 +860,7 @@ _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg) thumb_dbg_slog("Thumb path is changed : %s", thumb_path); } - if (is_saved == FALSE) { + if (is_saved == FALSE && data != NULL) { err = _media_thumb_save_to_file_with_evas(data, thumb_w, thumb_h, alpha, thumb_path); if (err < 0) { thumb_err("save_to_file_with_evas failed - %d", err); @@ -848,7 +894,7 @@ _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg) /* End of fsync */ SAFE_FREE(data); - +DB_UPDATE: /* DB update if needed */ if (need_update_db == 1) { err = _media_thumb_update_db(origin_path, thumb_path, res_msg->origin_width, res_msg->origin_height); diff --git a/server/thumb-server.c b/server/thumb-server.c index ec98d49..3e35027 100755 --- a/server/thumb-server.c +++ b/server/thumb-server.c @@ -73,6 +73,11 @@ int main(void) if (err == -1) thumb_err("vconf_notify_key_changed : %s fails", VCONFKEY_SYSMAN_MMC_STATUS); + /* Set VCONFKEY_CAMERA_STATE callback to get status of camera */ + err = vconf_notify_key_changed(VCONFKEY_CAMERA_STATE, (vconf_callback_fn) _thumb_daemon_camera_vconf_cb, NULL); + if (err == -1) + thumb_err("vconf_notify_key_changed : %s fails", VCONFKEY_CAMERA_STATE); + /* Create and bind new UDP socket */ if (!_thumb_server_prepare_socket(&sockfd)) { thumb_err("Failed to create socket"); @@ -105,7 +110,7 @@ int main(void) thumb_dbg("*** Thumbnail server is running ***"); thumb_dbg("************************************"); -#if 0 +#if 1 if (_thumb_sever_set_power_mode(THUMB_START) == FALSE) thumb_err("_thumb_sever_set_power_mode failed"); #endif diff --git a/src/codec/IfegDecodeAGIF.c b/src/codec/IfegDecodeAGIF.c index d52ba56..10b951a 100644 --- a/src/codec/IfegDecodeAGIF.c +++ b/src/codec/IfegDecodeAGIF.c @@ -43,7 +43,7 @@ AGifFrameInfo *FastImgCreateAGIFFrameData(unsigned int width, unsigned int heigh int transIndex = 0; int inputPos = 0; - AGifFrameInfo *pFrameData; + AGifFrameInfo *pFrameData; if (0 == (pFrameData = IfegMemAlloc(sizeof(AGifFrameInfo)))) { return 0; } @@ -106,7 +106,7 @@ AGifFrameInfo *FastImgCreateAGIFFrameData(unsigned int width, unsigned int heigh backcolor_parsing = (unsigned short)((pEncodedData[inputPos+backcolor_index*3] >> 3)<<11) | ((pEncodedData[inputPos+backcolor_index*3+1] >> 2)<<5) | (pEncodedData[inputPos+backcolor_index*3+2] >> 3); } - /* graphic extension block */ + /* graphic extension block */ if (pEncodedData[14+header_temp] == 0xF9 || pEncodedData[14+19+header_temp] == 0xF9) { if (transparent == 1 && backcolor_index == transIndex) { @@ -502,9 +502,16 @@ int __FastImgGetNextFrameAGIF_NoBuffer(AGifFrameInfo *pFrameData, BOOL bCenterAl unsigned short *prefix = pFrameData->pPrefix; unsigned char *dstack = pFrameData->pDstack; unsigned char *suffix = pFrameData->pSuffix; + unsigned char *done_prefix = 0; inputPos = pFrameData->offset; + done_prefix = IfegMemAlloc(sizeof(unsigned char)*(MAX_CODES+1)); + if (done_prefix == 0) + { + thumb_err("Failed to allocate memory for check buffer."); + return -1; + } IfegMemset(prefix, 0, sizeof(unsigned short)*(MAX_CODES+1)); IfegMemset(dstack, 0, sizeof(unsigned char)*(MAX_CODES+1)); IfegMemset(suffix, 0, sizeof(unsigned char)*(MAX_CODES+1)); @@ -538,6 +545,8 @@ int __FastImgGetNextFrameAGIF_NoBuffer(AGifFrameInfo *pFrameData, BOOL bCenterAl IfegMemFree(pDecBuf); pDecBuf = 0; } + IfegMemFree(done_prefix); + done_prefix = 0; return -1; } @@ -564,6 +573,8 @@ int __FastImgGetNextFrameAGIF_NoBuffer(AGifFrameInfo *pFrameData, BOOL bCenterAl IfegMemFree(pDecBuf); pDecBuf = 0; } + IfegMemFree(done_prefix); + done_prefix = 0; return 0; } @@ -637,8 +648,12 @@ int __FastImgGetNextFrameAGIF_NoBuffer(AGifFrameInfo *pFrameData, BOOL bCenterAl for (i = 0; i < expected_width * expected_height; i++) { *pImage16++ = ui_backcolor; } + IfegMemFree(done_prefix); + done_prefix = 0; return 1; } else { + IfegMemFree(done_prefix); + done_prefix = 0; return 0; } } @@ -654,6 +669,8 @@ int __FastImgGetNextFrameAGIF_NoBuffer(AGifFrameInfo *pFrameData, BOOL bCenterAl pDecBuf = 0; } if (pFrameData->imgCount == 0) { + IfegMemFree(done_prefix); + done_prefix = 0; return -1; } pFrameData->imgCount = 0; @@ -666,7 +683,7 @@ int __FastImgGetNextFrameAGIF_NoBuffer(AGifFrameInfo *pFrameData, BOOL bCenterAl if (pFrameData->nLoopCount == -1) { break; } else if (pFrameData->bLoop || (pFrameData->nRepeatCount <= pFrameData->nLoopCount) || (pFrameData->nLoopCount == 0)) { - /* Background Color */ + /* Background Color */ pImage16 = (unsigned short *)pFrameData->pPrevImg; for (i = 0; i < expected_width * expected_height; i++) { @@ -677,6 +694,8 @@ int __FastImgGetNextFrameAGIF_NoBuffer(AGifFrameInfo *pFrameData, BOOL bCenterAl continue; } else { /* if there is last frame and bLoop is FALSE, return 2. */ + IfegMemFree(done_prefix); + done_prefix = 0; return 2; } #else @@ -686,8 +705,12 @@ int __FastImgGetNextFrameAGIF_NoBuffer(AGifFrameInfo *pFrameData, BOOL bCenterAl for (i = 0; i < expected_width * expected_height; i++) { *pImage16++ = backcolor; } + IfegMemFree(done_prefix); + done_prefix = 0; return 1; } else { + IfegMemFree(done_prefix); + done_prefix = 0; return 0; } #endif @@ -704,6 +727,8 @@ int __FastImgGetNextFrameAGIF_NoBuffer(AGifFrameInfo *pFrameData, BOOL bCenterAl IfegMemFree(pDecBuf); pDecBuf = 0; } + IfegMemFree(done_prefix); + done_prefix = 0; return -1; } @@ -727,6 +752,8 @@ int __FastImgGetNextFrameAGIF_NoBuffer(AGifFrameInfo *pFrameData, BOOL bCenterAl IfegMemFree(pDecBuf); pDecBuf = 0; } + IfegMemFree(done_prefix); + done_prefix = 0; return -1; } } @@ -744,6 +771,8 @@ int __FastImgGetNextFrameAGIF_NoBuffer(AGifFrameInfo *pFrameData, BOOL bCenterAl IfegMemFree(pDecBuf); pDecBuf = 0; } + IfegMemFree(done_prefix); + done_prefix = 0; return -1; } } @@ -762,6 +791,8 @@ int __FastImgGetNextFrameAGIF_NoBuffer(AGifFrameInfo *pFrameData, BOOL bCenterAl IfegMemFree(pDecBuf); pDecBuf = 0; } + IfegMemFree(done_prefix); + done_prefix = 0; return -1; } } @@ -797,6 +828,8 @@ int __FastImgGetNextFrameAGIF_NoBuffer(AGifFrameInfo *pFrameData, BOOL bCenterAl IfegMemFree(pDecBuf); pDecBuf = 0; } + IfegMemFree(done_prefix); + done_prefix = 0; return -1; } #endif @@ -822,6 +855,8 @@ int __FastImgGetNextFrameAGIF_NoBuffer(AGifFrameInfo *pFrameData, BOOL bCenterAl IfegMemFree(pDecBuf); pDecBuf = 0; } + IfegMemFree(done_prefix); + done_prefix = 0; return 0; } IfegMemset(decoderline, 0, orgwdt); @@ -838,6 +873,8 @@ int __FastImgGetNextFrameAGIF_NoBuffer(AGifFrameInfo *pFrameData, BOOL bCenterAl IfegMemFree(pDecBuf); pDecBuf = 0; } + IfegMemFree(done_prefix); + done_prefix = 0; return 0; } @@ -854,6 +891,8 @@ int __FastImgGetNextFrameAGIF_NoBuffer(AGifFrameInfo *pFrameData, BOOL bCenterAl IfegMemFree(pDecBuf); pDecBuf = 0; } + IfegMemFree(done_prefix); + done_prefix = 0; return 0; } IfegMemset(pDecBuf, 0, decwdt * dechgt * 4); @@ -910,6 +949,8 @@ int __FastImgGetNextFrameAGIF_NoBuffer(AGifFrameInfo *pFrameData, BOOL bCenterAl IfegMemFree(pDecBuf); pDecBuf = 0; } + IfegMemFree(done_prefix); + done_prefix = 0; return -1; } @@ -1356,8 +1397,26 @@ int __FastImgGetNextFrameAGIF_NoBuffer(AGifFrameInfo *pFrameData, BOOL bCenterAl code = oc; *sp++ = (unsigned char)fc; } + + IfegMemset(done_prefix, 0, sizeof(unsigned char)*(MAX_CODES+1)); while (code >= newcodes) { *sp++ = suffix[code]; + if ((code == prefix[code]) || (done_prefix[code] == 1)) + { + thumb_err("Circular entry in table."); + if (decoderline != 0) { + IfegMemFree(decoderline); + decoderline = 0; + } + if (pDecBuf != 0) { + IfegMemFree(pDecBuf); + pDecBuf = 0; + } + IfegMemFree(done_prefix); + done_prefix = 0; + return 0; + } + done_prefix[code] = 1; code = prefix[code]; } @@ -1516,6 +1575,8 @@ int __FastImgGetNextFrameAGIF_NoBuffer(AGifFrameInfo *pFrameData, BOOL bCenterAl IfegMemFree(pDecBuf); pDecBuf = 0; } + IfegMemFree(done_prefix); + done_prefix = 0; pFrameData->offset = inputPos; pFrameData->imgCount++; diff --git a/src/codec/img-codec-osal.c b/src/codec/img-codec-osal.c index 46eb130..c8483fa 100644 --- a/src/codec/img-codec-osal.c +++ b/src/codec/img-codec-osal.c @@ -24,9 +24,7 @@ #include <stdio.h> #include <stdlib.h> #include <string.h> - -//#include <drm-service.h> -#include <drm_client.h> +#include <errno.h> void *IfegMemAlloc(unsigned int size) { @@ -65,20 +63,7 @@ static BOOL _is_real_drm = FALSE; HFile DrmOpenFile(const char *szPathName) { - int ret = 0; - drm_bool_type_e drm_type; - - ret = drm_is_drm_file(szPathName, &drm_type); - if (ret < 0) { - thumb_err("drm_is_drm_file falied : %d", ret); - drm_type = DRM_FALSE; - } - - if (drm_type == DRM_TRUE) { - _is_real_drm = TRUE; - } else { - _is_real_drm = FALSE; - } + _is_real_drm = FALSE; if (!_is_real_drm) { FILE *fp = fopen(szPathName, "rb"); diff --git a/src/include/media-thumb-internal.h b/src/include/media-thumb-internal.h index 8560e49..31dced8 100755 --- a/src/include/media-thumb-internal.h +++ b/src/include/media-thumb-internal.h @@ -67,13 +67,7 @@ typedef struct { int _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_drm_image(const char *origin_path, + const char *thumb_path, int thumb_width, int thumb_height, media_thumb_format format, diff --git a/src/ipc/media-thumb-ipc.c b/src/ipc/media-thumb-ipc.c index 99d7098..104565a 100755 --- a/src/ipc/media-thumb-ipc.c +++ b/src/ipc/media-thumb-ipc.c @@ -68,7 +68,12 @@ int __media_thumb_pop_req_queue(const char *path, bool shutdown_channel) if (strncmp(path, req->path, strlen(path)) == 0) { //thumb_dbg("Popped %s", path); if (shutdown_channel) { - g_source_destroy(g_main_context_find_source_by_id(g_main_context_get_thread_default(), req->source_id)); + GSource *source_id = g_main_context_find_source_by_id(g_main_context_get_thread_default(), req->source_id); + if (source_id != NULL) { + g_source_destroy(source_id); + } else { + thumb_err("G_SOURCE_ID is NULL"); + } g_io_channel_shutdown(req->channel, TRUE, NULL); g_io_channel_unref(req->channel); @@ -370,8 +375,14 @@ gboolean _media_thumb_write_socket(GIOChannel *src, GIOCondition condition, gpoi if ((err = _media_thumb_recv_msg(sock, header_size, &recv_msg)) < 0) { thumb_err("_media_thumb_recv_msg failed "); - g_io_channel_shutdown(src, TRUE, NULL); - g_io_channel_unref(src); +// g_io_channel_shutdown(src, TRUE, NULL); +// g_io_channel_unref(src); + if (recv_msg.origin_path_size > 0) { + __media_thumb_pop_req_queue(recv_msg.org_path, TRUE); + } else { + thumb_err("origin path size is wrong."); + } + return FALSE; } @@ -386,7 +397,8 @@ gboolean _media_thumb_write_socket(GIOChannel *src, GIOCondition condition, gpoi if (data) { thumbUserData* cb = (thumbUserData*)data; - cb->func(err, recv_msg.dst_path, cb->user_data); + if (cb->func != NULL) + cb->func(err, recv_msg.dst_path, cb->user_data); } __media_thumb_pop_req_queue(recv_msg.org_path, FALSE); diff --git a/src/media-thumb-internal.c b/src/media-thumb-internal.c index a87fde0..4f41dcf 100755 --- a/src/media-thumb-internal.c +++ b/src/media-thumb-internal.c @@ -37,8 +37,6 @@ #include <fcntl.h> #include <unistd.h> -#include <drm_client.h> - #include <mm_file.h> #include <mm_error.h> #include <mm_util_imgp.h> @@ -47,7 +45,7 @@ #include <Ecore_Evas.h> #include <libexif/exif-data.h> -#define MEDA_THUMB_ROUND_UP_4(num) (((num)+3)&~3) +#define MEDIA_THUMB_ROUND_UP_8(num) (((num)+7)&~7) int _media_thumb_resize_data(unsigned char *src_data, int src_width, @@ -116,8 +114,8 @@ int _media_thumb_get_proper_thumb_size(media_thumb_type thumb_type, } #endif - /* The width of RGB888 raw data has to be rounded by 4 */ -// *thumb_w = MEDA_THUMB_ROUND_UP_4(*thumb_w); + /** CAUTION :: The width of RGB888 raw data has to be rounded by 8 **/ + *thumb_w = MEDIA_THUMB_ROUND_UP_8(*thumb_w); thumb_dbg("proper thumb w: %d h: %d", *thumb_w, *thumb_h); @@ -141,7 +139,7 @@ int _media_thumb_get_exif_info(ExifData *ed, char *buf, int max_size, int *value entry = exif_content_get_entry(ed->ifd[ifd], tag); if (entry) { if (tag == EXIF_TAG_ORIENTATION || - tag == EXIF_TAG_PIXEL_X_DIMENSION || + tag == EXIF_TAG_PIXEL_X_DIMENSION || tag == EXIF_TAG_PIXEL_Y_DIMENSION) { if (value == NULL) { @@ -243,7 +241,7 @@ static int _media_thumb_get_data_from_exif(ExifData *ed, *thumb_height = atoi(height); } else { thumb_warn("EXIF_TAG_IMAGE_LENGTH does not exist"); - *thumb_width = 0; + *thumb_height = 0; } thumb_dbg("thumb width : height [%d:%d]", *thumb_width, *thumb_height); @@ -282,6 +280,7 @@ static int _media_thumb_get_data_from_exif(ExifData *ed, int _media_thumb_get_thumb_from_exif(ExifData *ed, const char *file_full_path, + const char *thumb_path, int orientation, int required_width, int required_height, @@ -441,15 +440,6 @@ _media_thumb_get_thumb_from_exif(ExifData *ed, } }else { /*in this case, just write raw data in file */ - char thumb_path[1024]; - - err = _media_thumb_get_hash_name(file_full_path, thumb_path, sizeof(thumb_path)); - if (err < 0) { - thumb_err("_media_thumb_get_hash_name failed"); - SAFE_FREE(thumb); - return err; - } - thumb_dbg_slog("Thumb is :%s", thumb_path); int nwrite; @@ -496,7 +486,7 @@ int _media_thumb_resize_data(unsigned char *src_data, int thumb_width = dst_width; int thumb_height = dst_height; unsigned int buf_size = 0; - + if (mm_util_get_image_size(src_format, thumb_width, thumb_height, &buf_size) < 0) { thumb_err("Failed to get buffer size"); @@ -530,7 +520,7 @@ int _media_thumb_resize_data(unsigned char *src_data, } 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); @@ -572,9 +562,8 @@ int _media_thumb_decode_with_evas(const char *origin_path, 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); + resize_img_ee = ecore_evas_buffer_new(thumb_width, thumb_height); if (!resize_img_ee) { thumb_err("Failed to create a new ecore evas buffer"); return -1; @@ -610,7 +599,8 @@ int _media_thumb_decode_with_evas(const char *origin_path, evas_object_image_load_scale_down_set(source_img, 10); } - evas_object_image_load_orientation_set(source_img, 1); + if (orientation != TRANSPOSE) + evas_object_image_load_orientation_set(source_img, 1); int rotated_orig_w = 0; int rotated_orig_h = 0; @@ -622,7 +612,6 @@ int _media_thumb_decode_with_evas(const char *origin_path, rotated_orig_w = width; rotated_orig_h = height; } - //thumb_dbg("rotated - origin width:%d, origin height:%d", rotated_orig_w, rotated_orig_h); int err = -1; @@ -634,9 +623,7 @@ int _media_thumb_decode_with_evas(const char *origin_path, thumb_type = MEDIA_THUMB_SMALL; } - err = _media_thumb_get_proper_thumb_size(thumb_type, - rotated_orig_w, rotated_orig_h, - &thumb_width, &thumb_height); + err = _media_thumb_get_proper_thumb_size(thumb_type, rotated_orig_w, rotated_orig_h, &thumb_width, &thumb_height); if (err < 0) { thumb_err("_media_thumb_get_proper_thumb_size failed: %d", err); ecore_evas_free(resize_img_ee); @@ -646,15 +633,10 @@ int _media_thumb_decode_with_evas(const char *origin_path, 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_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_resize(source_img, thumb_width, thumb_height); evas_object_show(source_img); /* Set alpha from original */ @@ -662,8 +644,7 @@ int _media_thumb_decode_with_evas(const char *origin_path, if (thumb_info->alpha) ecore_evas_alpha_set(resize_img_ee, EINA_TRUE); /* Create target buffer and copy origin resized img to it */ - Ecore_Evas *target_ee = ecore_evas_buffer_new( - thumb_width, thumb_height); + Ecore_Evas *target_ee = ecore_evas_buffer_new(thumb_width, thumb_height); if (!target_ee) { thumb_err("Failed to create a ecore evas"); ecore_evas_free(resize_img_ee); @@ -678,26 +659,15 @@ int _media_thumb_decode_with_evas(const char *origin_path, 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 *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); - unsigned int buf_size = 0; + 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); + unsigned int 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"); @@ -707,7 +677,6 @@ int _media_thumb_decode_with_evas(const char *origin_path, return MEDIA_THUMB_ERROR_MM_UTIL; } - //thumb_dbg("mm_util_get_image_size : %d", buf_size); thumb_info->size = buf_size; @@ -725,9 +694,9 @@ int _media_thumb_decode_with_evas(const char *origin_path, mm_util_img_format _media_thumb_get_format(media_thumb_format src_format) { switch(src_format) { - case MEDIA_THUMB_BGRA: + case MEDIA_THUMB_BGRA: return MM_UTIL_IMG_FMT_BGRA8888; - case MEDIA_THUMB_RGB888: + case MEDIA_THUMB_RGB888: return MM_UTIL_IMG_FMT_RGB888; default: return -1; @@ -736,7 +705,7 @@ mm_util_img_format _media_thumb_get_format(media_thumb_format src_format) int _media_thumb_convert_data(media_thumb_info *thumb_info, - int thumb_width, + int thumb_width, int thumb_height, mm_util_img_format src_format, mm_util_img_format dst_format) @@ -777,7 +746,7 @@ int _media_thumb_convert_data(media_thumb_info *thumb_info, src_format, dst_data, dst_format); - + if (err < 0) { thumb_err("Failed to change from rgb888 to argb8888 %d", err); SAFE_FREE(dst_data); @@ -816,10 +785,10 @@ int _media_thumb_convert_format(media_thumb_info *thumb_info, return MEDIA_THUMB_ERROR_UNSUPPORTED; } - err = _media_thumb_convert_data(thumb_info, - thumb_info->width, + err = _media_thumb_convert_data(thumb_info, + thumb_info->width, thumb_info->height, - src_mm_format, + src_mm_format, dst_mm_format); if (err < 0) { @@ -863,7 +832,7 @@ int _media_thumb_agif(const char *origin_path, return err; } - err = _media_thumb_resize_data((unsigned char *)thumb, + err = _media_thumb_resize_data((unsigned char *)thumb, image_info->width, image_info->height, MM_UTIL_IMG_FMT_RGB888, @@ -896,7 +865,7 @@ int _media_thumb_png(const char *origin_path, 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_evas(origin_path, thumb_width, thumb_height, thumb_info, 1, NORMAL); if (err < 0) { thumb_err("decode_with_evas failed : %d", err); @@ -920,7 +889,7 @@ int _media_thumb_bmp(const char *origin_path, 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_evas(origin_path, thumb_width, thumb_height, thumb_info, 1, NORMAL); if (err < 0) { thumb_err("decode_with_evas failed : %d", err); @@ -944,7 +913,7 @@ int _media_thumb_wbmp(const char *origin_path, 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_evas(origin_path, thumb_width, thumb_height, thumb_info, 1, NORMAL); if (err < 0) { thumb_err("decode_with_evas failed : %d", err); @@ -961,14 +930,14 @@ int _media_thumb_wbmp(const char *origin_path, return 0; } -int _media_thumb_gif(const char *origin_path, +int _media_thumb_gif(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_width, thumb_height, thumb_info, 0, NORMAL); + err = _media_thumb_decode_with_evas(origin_path, thumb_width, thumb_height, thumb_info, 1, NORMAL); if (err < 0) { thumb_err("decode_with_evas failed : %d", err); @@ -986,6 +955,7 @@ int _media_thumb_gif(const char *origin_path, } int _media_thumb_jpeg(const char *origin_path, + const char *thumb_path, int thumb_width, int thumb_height, media_thumb_format format, @@ -1008,7 +978,7 @@ int _media_thumb_jpeg(const char *origin_path, } /* Second, Get thumb from exif */ - err = _media_thumb_get_thumb_from_exif(ed, origin_path, orientation, thumb_width, thumb_height, thumb_info); + err = _media_thumb_get_thumb_from_exif(ed, origin_path, thumb_path, orientation, thumb_width, thumb_height, thumb_info); if (err < 0) { thumb_dbg("_media_thumb_get_thumb_from_exif failed"); @@ -1049,8 +1019,8 @@ int _media_thumb_jpeg(const char *origin_path, if (!thumb_done) { - err = _media_thumb_decode_with_evas(origin_path, thumb_width, thumb_height, thumb_info, 0, orientation); - + err = _media_thumb_decode_with_evas(origin_path, thumb_width, thumb_height, thumb_info, 1, orientation); + if (err < 0) { thumb_err("decode_with_evas failed : %d", err); return err; @@ -1069,6 +1039,7 @@ int _media_thumb_jpeg(const char *origin_path, int _media_thumb_image(const char *origin_path, + const char *thumb_path, int thumb_width, int thumb_height, media_thumb_format format, @@ -1090,13 +1061,13 @@ _media_thumb_image(const char *origin_path, if ((image_type != IMG_CODEC_JPEG) && (origin_w * origin_h > THUMB_MAX_ALLOWED_MEM_FOR_THUMB)) { thumb_warn("This original image is too big"); -// return MEDIA_THUMB_ERROR_UNSUPPORTED; //temporary commeting for fix PLM issue P130912-05026 + return MEDIA_THUMB_ERROR_UNSUPPORTED; //temporary commeting for fix PLM issue P130912-05026 } if (image_type == IMG_CODEC_AGIF) { 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_width, thumb_height, format, thumb_info); + err = _media_thumb_jpeg(origin_path, thumb_path, thumb_width, thumb_height, format, thumb_info); } else if (image_type == IMG_CODEC_PNG) { err = _media_thumb_png(origin_path, thumb_width, thumb_height, format, thumb_info); } else if (image_type == IMG_CODEC_GIF) { @@ -1122,7 +1093,7 @@ _media_thumb_image(const char *origin_path, if (wbmp_width * wbmp_height > THUMB_MAX_ALLOWED_MEM_FOR_THUMB) { thumb_warn("This original image is too big"); -// return MEDIA_THUMB_ERROR_UNSUPPORTED; //temporary commeting for fix PLM issue P130912-05026 + return MEDIA_THUMB_ERROR_UNSUPPORTED; //temporary commeting for fix PLM issue P130912-05026 } thumb_info->origin_width = wbmp_width; @@ -1142,14 +1113,14 @@ _media_thumb_image(const char *origin_path, } int -_media_thumb_video(const char *origin_path, +_media_thumb_video(const char *origin_path, int thumb_width, int thumb_height, media_thumb_format format, media_thumb_info *thumb_info) { int err = -1; - + MMHandleType content = (MMHandleType) NULL; void *frame = NULL; int video_track_num = 0; @@ -1158,14 +1129,7 @@ _media_thumb_video(const char *origin_path, int size = 0; int width = 0; int height = 0; - int ret = 0; - drm_bool_type_e drm_type = DRM_FALSE; - - ret = drm_is_drm_file(origin_path, &drm_type); - if (ret != DRM_RETURN_SUCCESS) { - thumb_err("drm_is_drm_file falied : %d", ret); - drm_type = DRM_FALSE; - } + bool drm_type = FALSE; is_drm = drm_type; @@ -1328,7 +1292,7 @@ _media_thumb_video(const char *origin_path, rotated = (unsigned char *)malloc(r_size); err = mm_util_rotate_image(thumb_info->data, thumb_info->width, thumb_info->height, MM_UTIL_IMG_FMT_RGB888, - rotated, &r_w, &r_h, + rotated, &r_w, &r_h, rot_type); if (err < 0) { @@ -1457,10 +1421,8 @@ int _media_thumb_save_to_file_with_evas(unsigned char *data, return 0; } else { - thumb_dbg("evas_object_image_save failed"); + thumb_err("evas_object_image_save failed"); ecore_evas_free(ee); return -1; } } - - diff --git a/src/util/media-thumb-util.c b/src/util/media-thumb-util.c index e4dc496..4b2225c 100755 --- a/src/util/media-thumb-util.c +++ b/src/util/media-thumb-util.c @@ -25,104 +25,60 @@ #include <glib.h> #include <aul.h> #include <string.h> -#include <drm_client.h> int _media_thumb_get_file_type(const char *file_full_path, int *is_drm) { int ret = 0; - drm_bool_type_e drm_type = DRM_FALSE; - drm_file_type_e drm_file_type = DRM_TYPE_UNDEFINED; char mimetype[255] = {0,}; + char *unsupported_type = "image/tiff"; if (file_full_path == NULL) return MEDIA_THUMB_ERROR_INVALID_PARAMETER; - ret = drm_is_drm_file(file_full_path, &drm_type); - if (ret != DRM_RETURN_SUCCESS) { - thumb_err("drm_is_drm_file falied : %d", ret); - drm_type = DRM_FALSE; - } - - *is_drm = drm_type; - - if (drm_type == DRM_TRUE) { - thumb_dbg_slog("DRM file : %s", file_full_path); + /* get content type and mime type from file. */ + ret = aul_get_mime_from_file(file_full_path, mimetype, sizeof(mimetype)); + if (ret < 0) { + thumb_warn + ("aul_get_mime_from_file fail.. Now trying to get type by extension"); - ret = drm_get_file_type(file_full_path, &drm_file_type); - if (ret != DRM_RETURN_SUCCESS) { - thumb_err("drm_get_file_type falied : %d", ret); + char ext[255] = { 0 }; + int ret = _media_thumb_get_file_ext(file_full_path, ext, sizeof(ext)); + if (ret < 0) { + thumb_err("_media_thumb_get_file_ext failed"); return THUMB_NONE_TYPE; } - if (drm_file_type == DRM_TYPE_UNDEFINED) { - return THUMB_NONE_TYPE; + if (strcasecmp(ext, "JPG") == 0 || + strcasecmp(ext, "JPEG") == 0 || + strcasecmp(ext, "PNG") == 0 || + strcasecmp(ext, "GIF") == 0 || + strcasecmp(ext, "AGIF") == 0 || + strcasecmp(ext, "XWD") == 0 || + strcasecmp(ext, "BMP") == 0 || + strcasecmp(ext, "WBMP") == 0) { + return THUMB_IMAGE_TYPE; + } else if (strcasecmp(ext, "AVI") == 0 || + strcasecmp(ext, "MPEG") == 0 || + strcasecmp(ext, "MP4") == 0 || + strcasecmp(ext, "DCF") == 0 || + strcasecmp(ext, "WMV") == 0 || + strcasecmp(ext, "3GPP") == 0 || + strcasecmp(ext, "3GP") == 0) { + return THUMB_VIDEO_TYPE; } else { - if (drm_file_type == DRM_TYPE_OMA_V1 - || drm_file_type == DRM_TYPE_OMA_V2 - || drm_file_type == DRM_TYPE_OMA_PD) { - drm_content_info_s contentInfo; - memset(&contentInfo, 0x00, sizeof(drm_content_info_s)); - - ret = drm_get_content_info(file_full_path, &contentInfo); - if (ret != DRM_RETURN_SUCCESS) { - thumb_err("drm_get_content_info() fails. : %d", ret); - return THUMB_NONE_TYPE; - } - thumb_dbg("DRM mime type: %s", contentInfo.mime_type); - - strncpy(mimetype, contentInfo.mime_type, sizeof(mimetype) - 1); - mimetype[sizeof(mimetype) - 1] = '\0'; - - goto findtype; - } else { - thumb_dbg("Use aul to get mime type"); - } - } - } - - { - /* get content type and mime type from file. */ - ret = aul_get_mime_from_file(file_full_path, mimetype, sizeof(mimetype)); - if (ret < 0) { - thumb_warn - ("aul_get_mime_from_file fail.. Now trying to get type by extension"); - - char ext[255] = { 0 }; - int ret = _media_thumb_get_file_ext(file_full_path, ext, sizeof(ext)); - if (ret < 0) { - thumb_err("_media_thumb_get_file_ext failed"); - return THUMB_NONE_TYPE; - } - - if (strcasecmp(ext, "JPG") == 0 || - strcasecmp(ext, "JPEG") == 0 || - strcasecmp(ext, "PNG") == 0 || - strcasecmp(ext, "GIF") == 0 || - strcasecmp(ext, "AGIF") == 0 || - strcasecmp(ext, "XWD") == 0 || - strcasecmp(ext, "BMP") == 0 || - strcasecmp(ext, "WBMP") == 0) { - return THUMB_IMAGE_TYPE; - } else if (strcasecmp(ext, "AVI") == 0 || - strcasecmp(ext, "MPEG") == 0 || - strcasecmp(ext, "MP4") == 0 || - strcasecmp(ext, "DCF") == 0 || - strcasecmp(ext, "WMV") == 0 || - strcasecmp(ext, "3GPP") == 0 || - strcasecmp(ext, "3GP") == 0) { - return THUMB_VIDEO_TYPE; - } else { - return THUMB_NONE_TYPE; - } + return THUMB_NONE_TYPE; } } -findtype: thumb_dbg("mime type : %s", mimetype); /* categorize from mimetype */ if (strstr(mimetype, "image") != NULL) { + if (!strcmp(mimetype, unsupported_type)) { + thumb_warn("This is unsupport file type"); + return THUMB_NONE_TYPE; + } return THUMB_IMAGE_TYPE; } else if (strstr(mimetype, "video") != NULL) { return THUMB_VIDEO_TYPE; |