Remove check functions to reduce duplication 22/281422/2 accepted/tizen_7.0_unified accepted/tizen_7.0_unified_hotfix tizen_7.0 tizen_7.0_hotfix accepted/tizen/7.0/unified/20221110.063744 accepted/tizen/7.0/unified/hotfix/20221116.104851 accepted/tizen/unified/20220920.110707 tizen_7.0_m2_release
authorminje.ahn <minje.ahn@samsung.com>
Sun, 18 Sep 2022 23:52:52 +0000 (08:52 +0900)
committerminje.ahn <minje.ahn@samsung.com>
Mon, 19 Sep 2022 04:48:38 +0000 (13:48 +0900)
Modified to check the path and the media type in libmedia-thumbnail.

Change-Id: I7d47e879b34369955f3f390cacfb6676347bc7e2
Signed-off-by: minje.ahn <minje.ahn@samsung.com>
CMakeLists.txt
include/thumbnail_util_private.h
include/thumbnail_util_type.h
packaging/capi-media-thumbnail-util.spec
src/thumbnail_util.c
test/CMakeLists.txt

index f52470f..5761e67 100755 (executable)
@@ -26,7 +26,7 @@ SET(submodule "thumbnail-util")
 SET(fw_name "${project_prefix}-${service}-${submodule}")
 
 # for package file
-SET(dependents "dlog glib-2.0 capi-base-common media-thumbnail libmedia-utils aul")
+SET(dependents "dlog glib-2.0 capi-base-common media-thumbnail libmedia-utils")
 SET(pc_dependents "capi-base-common")
 
 PROJECT(${fw_name})
index e6ef700..ff25077 100755 (executable)
 
 
 #include <unistd.h>
-#include <asm/unistd.h>
 #include <string.h>
 #include <stdlib.h>
 #include <stdio.h>
-#include <glib.h>
 #include <thumbnail_util_type.h>
 #include <dlog.h>
-#include <tzplatform_config.h>
 
 
 #ifdef __cplusplus
@@ -41,56 +38,17 @@ extern "C" {
 
 #define LOG_TAG "CAPI_MEDIA_THUMBNAIL_UTIL"
 
-typedef enum {
-       THUMBNAIL_UTIL_IMAGE    = 0,
-       THUMBNAIL_UTIL_VIDEO,
-} thumbnail_util_media_type_e;
-
 typedef struct {
        int request_id;
 } thumbnail_s;
 
 #define FONT_COLOR_RESET    "\033[0m"
-#define FONT_COLOR_RED      "\033[31m"
 #define FONT_COLOR_GREEN    "\033[32m"
-#define FONT_COLOR_YELLOW   "\033[33m"
-#define FONT_COLOR_BLUE     "\033[34m"
-#define FONT_COLOR_PURPLE   "\033[35m"
-#define FONT_COLOR_CYAN     "\033[36m"
-#define FONT_COLOR_GRAY     "\033[37m"
-
-#define THUMB_GETTID() syscall(__NR_gettid)
-
-#define THUMB_RETV_IF(expr, val) do { \
-                       if (expr) { \
-                               LOGE(FONT_COLOR_RED"[%ld]"FONT_COLOR_RESET, THUMB_GETTID());    \
-                               return (val); \
-                       } \
-               } while (0)
-
-#define THUMB_RETVM_IF(expr, val, fmt, arg...) do { \
-                       if (expr) { \
-                               LOGE(FONT_COLOR_RED"[%ld]"fmt""FONT_COLOR_RESET, THUMB_GETTID(), ##arg);     \
-                               return (val); \
-                       } \
-               } while (0)
 
 #define THUMB_WARN(fmt, arg...) do { \
                LOGW(FONT_COLOR_GREEN""fmt""FONT_COLOR_RESET, ##arg);     \
        } while (0)
 
-#define THUMB_DBG(fmt, arg...) do { \
-               LOGD(FONT_COLOR_RESET""fmt""FONT_COLOR_RESET, ##arg); \
-       } while (0)
-
-#define THUMB_ERR(fmt, arg...) do { \
-               LOGE(FONT_COLOR_RED""fmt""FONT_COLOR_RESET, ##arg); \
-       } while (0)
-
-#define THUMB_SDBG(fmt, arg...) do { \
-               SECURE_LOGD(FONT_COLOR_RESET""fmt""FONT_COLOR_RESET, ##arg); \
-       } while (0)
-
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index efb6eec..7d8ddde 100755 (executable)
@@ -18,7 +18,7 @@
 #ifndef __TIZEN_MULTIMEDIA_THUMBNAIL_UTIL_TYPE_H__
 #define __TIZEN_MULTIMEDIA_THUMBNAIL_UTIL_TYPE_H__
 
-#include <time.h>
+#include <stddef.h>
 #include <tizen.h>
 
 #ifdef __cplusplus
index 5b8a2f3..43921d0 100644 (file)
@@ -1,6 +1,6 @@
 Name:       capi-media-thumbnail-util
 Summary:    A media thumbnail util library in Tizen Native API
-Version:    0.1.29
+Version:    0.1.30
 Release:    0
 Group:      Multimedia/API
 License:    Apache-2.0
@@ -11,7 +11,6 @@ BuildRequires:  pkgconfig(glib-2.0)
 BuildRequires:  pkgconfig(libmedia-utils)
 BuildRequires:  pkgconfig(capi-base-common)
 BuildRequires:  pkgconfig(media-thumbnail)
-BuildRequires:  pkgconfig(aul)
 Requires(post): /sbin/ldconfig
 Requires(postun): /sbin/ldconfig
 
index f279654..e7ba103 100644 (file)
@@ -18,7 +18,6 @@
 #include <thumbnail_util_private.h>
 #include <media-thumbnail.h>
 #include <media-util.h>
-#include <aul.h>
 
 // LCOV_EXCL_START
 static int __thumbnail_util_error_capi(int internal_error)
@@ -75,83 +74,15 @@ int thumbnail_util_destroy(thumbnail_h thumb)
        return THUMBNAIL_UTIL_ERROR_NONE;
 }
 // LCOV_EXCL_STOP
-static int __thumbnail_util_check_media_type(const char *path, thumbnail_util_media_type_e *type)
-{
-       int ret = THUMBNAIL_UTIL_ERROR_NONE;
-       char mimetype[255] = {0,};
-       const char *unsupported_type = "image/tiff";
-       const char *supported_type = "application/vnd.ms-asf";
-
-       // Check file is existed
-       THUMB_RETV_IF(path == NULL, THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER);
-       THUMB_SDBG("path [%s]", path);
-       if (access(path, R_OK) < 0) {
-               THUMB_RETVM_IF(errno == EACCES || errno == EPERM, THUMBNAIL_UTIL_ERROR_PERMISSION_DENIED, "Open failed: Permission Denied");
-
-               THUMB_ERR("Open failed: Invalid Path");
-               return THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER;
-       }
-
-       // Check media type
-       ret = aul_get_mime_from_file(path, mimetype, sizeof(mimetype));
-       THUMB_RETVM_IF(ret < 0, THUMBNAIL_UTIL_ERROR_INVALID_OPERATION, "aul_get_mime_from_file failed");
-
-       THUMB_DBG("mime type : %s", mimetype);
-
-       /* categorize from mimetype */
-       if (strstr(mimetype, "image") != NULL) {
-               THUMB_RETVM_IF(!strcmp(mimetype, unsupported_type), THUMBNAIL_UTIL_ERROR_UNSUPPORTED_CONTENT, "This is unsupport file type");
-               *type = THUMBNAIL_UTIL_IMAGE;
-               return THUMBNAIL_UTIL_ERROR_NONE;
-       } else if (strstr(mimetype, "video") != NULL) {
-               *type = THUMBNAIL_UTIL_VIDEO;
-               return THUMBNAIL_UTIL_ERROR_NONE;
-       } else if (strstr(mimetype, supported_type) != NULL) {
-               *type = THUMBNAIL_UTIL_VIDEO;
-               return THUMBNAIL_UTIL_ERROR_NONE;
-       }
-
-       return THUMBNAIL_UTIL_ERROR_UNSUPPORTED_CONTENT;
-}
 
 int thumbnail_util_extract_to_buffer(const char *path, unsigned int width, unsigned int height, unsigned char **thumb_buffer, size_t *thumb_size, unsigned int *thumb_width, unsigned int *thumb_height)
 {
-       int ret = THUMBNAIL_UTIL_ERROR_NONE;
-       thumbnail_util_media_type_e type;
-
-       /* check media type */
-       ret = __thumbnail_util_check_media_type(path, &type);
-       THUMB_RETVM_IF(ret != THUMBNAIL_UTIL_ERROR_NONE, ret, "__thumbnail_util_check_media_type failed");
-
-       /* If image, check support format */
-       if (type == THUMBNAIL_UTIL_IMAGE)
-               ret = create_image_thumbnail_to_buffer(path, width, height, thumb_buffer, thumb_size, thumb_width, thumb_height);
-       else
-               ret = create_video_thumbnail_to_buffer(path, width, height, thumb_buffer, thumb_size, thumb_width, thumb_height);
-
+       int ret = create_thumbnail_to_buffer(path, width, height, thumb_buffer, thumb_size, thumb_width, thumb_height);
        return __thumbnail_util_error_capi(ret);
 }
 
 int thumbnail_util_extract_to_file(const char *path, unsigned int width, unsigned int height, const char *thumbnail_path)
 {
-       int ret = THUMBNAIL_UTIL_ERROR_NONE;
-       thumbnail_util_media_type_e type;
-
-       /* check media type */
-       ret = __thumbnail_util_check_media_type(path, &type);
-       THUMB_RETVM_IF(ret != THUMBNAIL_UTIL_ERROR_NONE, ret, "__thumbnail_util_check_media_type failed");
-
-       /* If image, check support format */
-       if (type == THUMBNAIL_UTIL_IMAGE) {
-               ret = create_image_thumbnail_to_file(path, width, height, thumbnail_path, false);
-       } else {
-               if (!g_regex_match_simple("[^/]\\.jpe?g$", thumbnail_path, G_REGEX_CASELESS, 0)) {
-                       THUMB_ERR("Unsupported path or extensions [%s]", thumbnail_path);
-                       return THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER;
-               }
-
-               ret = create_video_thumbnail_to_file(path, width, height, thumbnail_path, false);
-       }
-
+       int ret = create_thumbnail_to_file(path, width, height, thumbnail_path);
        return __thumbnail_util_error_capi(ret);
-}
+}
\ No newline at end of file
index 67e5f57..45662ae 100755 (executable)
@@ -1,7 +1,7 @@
 SET(fw_test "${fw_name}-test")
 
 INCLUDE(FindPkgConfig)
-pkg_check_modules(${fw_test} REQUIRED glib-2.0 libmedia-utils capi-base-common libtzplatform-config)
+pkg_check_modules(${fw_test} REQUIRED capi-base-common)
 
 FOREACH(flag ${${fw_test}_CFLAGS})
     SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")