Use new image thumbnail extracting APIs provided by libmedia-thumbnail 03/227403/7 accepted/tizen/unified/20200318.130543 submit/tizen/20200316.031954
authorhj kim <backto.kim@samsung.com>
Thu, 12 Mar 2020 00:48:18 +0000 (09:48 +0900)
committerhj kim <backto.kim@samsung.com>
Mon, 16 Mar 2020 02:09:17 +0000 (02:09 +0000)
Change-Id: I3b8c5879a645e98ee99dd7ba21c8f08c83dd2b59

packaging/libmedia-service.spec
src/common/media-svc-util.c
src/include/common/media-svc-env.h

index d2cb99a..b03bf60 100644 (file)
@@ -1,6 +1,6 @@
 Name:       libmedia-service
 Summary:    Media information service library for multimedia applications
-Version: 0.4.9
+Version: 0.4.10
 Release:    0
 Group:      Multimedia/Libraries
 License:    Apache-2.0 and PD
index fb5d0c8..faf616c 100644 (file)
@@ -1383,45 +1383,9 @@ void _media_svc_destroy_content_info(media_svc_content_info_s *content_info)
        SAFE_FREE(content_info->media_meta.description_pinyin);
 }
 
-static void __media_svc_get_proper_thumb_size(unsigned int orig_w, unsigned int orig_h, unsigned int *thumb_w, unsigned int *thumb_h)
-{
-       bool portrait = false;
-       double ratio = 0.0;
-
-       media_svc_retm_if(!orig_w, "Invalid orig_w");
-       media_svc_retm_if(!orig_h, "Invalid orig_h");
-       media_svc_retm_if(!thumb_w, "Invalid thumb_w");
-       media_svc_retm_if(!thumb_h, "Invalid thumb_h");
-
-       if (orig_w < orig_h)
-               portrait = true;
-
-       /* Set smaller length to default size */
-       if (portrait) {
-               if (orig_w < *thumb_w)
-                       *thumb_w = orig_w;
-               ratio = (double)orig_h / (double)orig_w;
-               *thumb_h = *thumb_w * ratio;
-       } else {
-               if (orig_h < *thumb_h)
-                       *thumb_h = orig_h;
-               ratio = (double)orig_w / (double)orig_h;
-               *thumb_w = *thumb_h * ratio;
-       }
-
-       media_svc_debug("proper thumb w: %d h: %d", *thumb_w, *thumb_h);
-
-       return;
-}
-
 int _media_svc_create_thumbnail(const char *path, char *thumb_path, media_svc_media_type_e media_type, uid_t uid)
 {
        int ret = MS_MEDIA_ERR_NONE;
-       unsigned int origin_w = 0;
-       unsigned int origin_h = 0;
-       unsigned int thumb_w = THUMB_WIDTH;
-       unsigned int thumb_h = THUMB_HEIGHT;
-       mm_util_img_codec_type image_type = IMG_CODEC_UNKNOWN_TYPE;
 
        media_svc_retvm_if(!path, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid path");
        media_svc_retvm_if(!thumb_path, MS_MEDIA_ERR_INVALID_PARAMETER, "Invalid thumb_path");
@@ -1446,37 +1410,11 @@ int _media_svc_create_thumbnail(const char *path, char *thumb_path, media_svc_me
        }
 
        //2. save thumbnail
-       if (media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE) {
-               ret = mm_util_extract_image_info(path, &image_type, &origin_w, &origin_h);
-               if (ret != MM_UTIL_ERROR_NONE) {
-                       media_svc_error("Getting image info is failed err: %d", ret);
-                       SAFE_STRLCPY(thumb_path, "", MAX_FILEPATH_LEN);
-                       return MS_MEDIA_ERR_INTERNAL;
-               }
-
-               if (image_type == IMG_CODEC_UNKNOWN_TYPE) {
-                       media_svc_error("Unsupported image codec");
-                       return MS_MEDIA_ERR_UNSUPPORTED_CONTENT;
-               }
-
-               if ((image_type != IMG_CODEC_JPEG) && (origin_w * origin_h > THUMB_MAX_ALLOWED_MEM)) {
-                       media_svc_error("This original image is too big");
-                       SAFE_STRLCPY(thumb_path, "", MAX_FILEPATH_LEN);
-                       return MS_MEDIA_ERR_THUMB_TOO_BIG;
-               }
-
-               __media_svc_get_proper_thumb_size(origin_w, origin_h, &thumb_w, &thumb_h);
-               ret = mm_util_resize_P_P(path, thumb_w, thumb_h, thumb_path);
-               if (ret != MM_UTIL_ERROR_NONE) {
-                       media_svc_error("mm_util_resize_P_P err: %d", ret);
-                       SAFE_STRLCPY(thumb_path, "", MAX_FILEPATH_LEN);
-                       return MS_MEDIA_ERR_INTERNAL;
-               }
-       } else {
+       if (media_type == MEDIA_SVC_MEDIA_TYPE_IMAGE)
+               return create_image_thumbnail_to_file(path, CONTENT_THUMB_DEFAULT_WIDTH, CONTENT_THUMB_DEFAULT_HEIGHT, thumb_path);
+       else
                return create_video_thumbnail_to_file(path, CONTENT_THUMB_DEFAULT_WIDTH, CONTENT_THUMB_DEFAULT_HEIGHT, thumb_path, true);
-       }
 
-       return ret;
 }
 
 int _media_svc_get_pinyin_str(const char *src_str, char **pinyin_str)
index bdd0104..e7c3b63 100755 (executable)
@@ -131,10 +131,6 @@ extern "C" {
 
 #define MEDIA_SVC_TAG_UNKNOWN                          ""
 
-#define THUMB_MAX_ALLOWED_MEM 9000000
-#define THUMB_WIDTH 320
-#define THUMB_HEIGHT 240
-
 enum Exif_Orientation {
        NOT_AVAILABLE = 0,
        NORMAL = 1,