From: Jiyong Min Date: Tue, 16 Aug 2016 23:39:18 +0000 (+0900) Subject: Remove build warning for deprecated API X-Git-Tag: accepted/tizen/common/20160818.144406~2^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F14%2F84114%2F4;p=platform%2Fcore%2Fmultimedia%2Flibmedia-service.git Remove build warning for deprecated API Change-Id: Ifee2398fa7dfe833125a980b94f199742adf6216 Signed-off-by: Jiyong Min --- diff --git a/packaging/libmedia-service.spec b/packaging/libmedia-service.spec index c222a7a..f8eb229 100644 --- a/packaging/libmedia-service.spec +++ b/packaging/libmedia-service.spec @@ -1,6 +1,6 @@ Name: libmedia-service Summary: Media information service library for multimedia applications -Version: 0.2.77 +Version: 0.2.78 Release: 0 Group: Multimedia/Libraries License: Apache-2.0 and public domain diff --git a/src/common/media-svc-util.c b/src/common/media-svc-util.c index d0c3421..4b4fc01 100755 --- a/src/common/media-svc-util.c +++ b/src/common/media-svc-util.c @@ -634,6 +634,100 @@ static char *__media_svc_get_thumb_path(uid_t uid) return result_passwd; } +static int __media_svc_encode_jpeg(unsigned char *src, unsigned long width, unsigned long height, image_util_colorspace_e colorspace, int quality, unsigned char **dst, unsigned long long *dst_size) { + int res = IMAGE_UTIL_ERROR_NONE; + image_util_encode_h encoder = NULL; + res = image_util_encode_create(IMAGE_UTIL_JPEG , &encoder); + if (res != IMAGE_UTIL_ERROR_NONE) { + media_svc_error("image_util_encode_create failed! (%d)", res); + return MS_MEDIA_ERR_INTERNAL; + } + res = image_util_encode_set_input_buffer(encoder, src); + if (res != IMAGE_UTIL_ERROR_NONE) { + media_svc_error("image_util_encode_set_input_buffer failed! (%d)", res); + image_util_encode_destroy(encoder); + return MS_MEDIA_ERR_INTERNAL; + } + res = image_util_encode_set_colorspace(encoder, colorspace); + if (res != IMAGE_UTIL_ERROR_NONE) { + media_svc_error("image_util_encode_set_colorspace failed! (%d)", res); + image_util_encode_destroy(encoder); + return MS_MEDIA_ERR_INTERNAL; + } + res = image_util_encode_set_resolution(encoder, width, height); + if (res != IMAGE_UTIL_ERROR_NONE) { + media_svc_error("image_util_encode_set_resolution failed! (%d)", res); + image_util_encode_destroy(encoder); + return MS_MEDIA_ERR_INTERNAL; + } + res = image_util_encode_set_quality(encoder, quality); + if (res != IMAGE_UTIL_ERROR_NONE) { + media_svc_error("image_util_encode_set_quality failed! (%d)", res); + image_util_encode_destroy(encoder); + return MS_MEDIA_ERR_INTERNAL; + } + res = image_util_encode_set_output_buffer(encoder, dst); + if (res != IMAGE_UTIL_ERROR_NONE) { + media_svc_error("image_util_decode_set_output_buffer failed! (%d)", res); + image_util_encode_destroy(encoder); + return MS_MEDIA_ERR_INTERNAL; + } + res = image_util_encode_run(encoder, dst_size); + if (res != IMAGE_UTIL_ERROR_NONE) { + media_svc_error("image_util_encode_run failed! (%d)", res); + image_util_encode_destroy(encoder); + return MS_MEDIA_ERR_INTERNAL; + } + res = image_util_encode_destroy(encoder); + if (res != IMAGE_UTIL_ERROR_NONE) { + media_svc_error("image_util_encode_destroy failed! (%d)", res); + return MS_MEDIA_ERR_INTERNAL; + } + + return MS_MEDIA_ERR_NONE; +} + +static int __media_svc_decode_jpeg(unsigned char *src, unsigned long long size, image_util_colorspace_e colorspace, unsigned char **dst, unsigned long *width, unsigned long *height, unsigned long long *dst_size) { + int res = IMAGE_UTIL_ERROR_NONE; + image_util_decode_h decoder = NULL; + res = image_util_decode_create(&decoder); + if (res != IMAGE_UTIL_ERROR_NONE) { + media_svc_error("image_util_decode_create failed! (%d)", res); + return MS_MEDIA_ERR_INTERNAL; + } + res = image_util_decode_set_input_buffer(decoder, src, size); + if (res != IMAGE_UTIL_ERROR_NONE) { + media_svc_error("image_util_decode_set_input_buffer failed! (%d)", res); + image_util_decode_destroy(decoder); + return MS_MEDIA_ERR_INTERNAL; + } + res = image_util_decode_set_colorspace(decoder, colorspace); + if (res != IMAGE_UTIL_ERROR_NONE) { + media_svc_error("image_util_decode_set_colorspace failed! (%d)", res); + image_util_decode_destroy(decoder); + return MS_MEDIA_ERR_INTERNAL; + } + res = image_util_decode_set_output_buffer(decoder, dst); + if (res != IMAGE_UTIL_ERROR_NONE) { + media_svc_error("image_util_decode_set_output_buffer failed! (%d)", res); + image_util_decode_destroy(decoder); + return MS_MEDIA_ERR_INTERNAL; + } + res = image_util_decode_run(decoder, width, height, dst_size); + if (res != IMAGE_UTIL_ERROR_NONE) { + media_svc_error("image_util_decode_run failed! (%d)", res); + image_util_decode_destroy(decoder); + return MS_MEDIA_ERR_INTERNAL; + } + res = image_util_decode_destroy(decoder); + if (res != IMAGE_UTIL_ERROR_NONE) { + media_svc_error("image_util_decode_destroy failed! (%d)", res); + return MS_MEDIA_ERR_INTERNAL; + } + + return MS_MEDIA_ERR_NONE; +} + static int __media_svc_resize_artwork(unsigned char *image, unsigned int size, const char *img_format, unsigned char **resize_image, unsigned int *resize_size) { int ret = MS_MEDIA_ERR_NONE; @@ -645,13 +739,21 @@ static int __media_svc_resize_artwork(unsigned char *image, unsigned int size, c int resized_width = 0; int resized_height = 0; unsigned int buf_size = 0; + image_util_colorspace_e colorspace = IMAGE_UTIL_COLORSPACE_RGB888; if ((strstr(img_format, "jpeg") != NULL) || (strstr(img_format, "jpg") != NULL) || (strstr(img_format, "JPG") != NULL)) { media_svc_debug("type [jpeg] size [%d]", size); /* decoding */ - ret = image_util_decode_jpeg_from_memory(image, size, IMAGE_UTIL_COLORSPACE_RGB888, &raw_image, &width, &height, &raw_size); + ret = __media_svc_decode_jpeg(image, (unsigned long long)size, colorspace, &raw_image, (unsigned long *)&width, (unsigned long *)&height, (unsigned long long *)&raw_size); if (ret != MS_MEDIA_ERR_NONE) { - media_svc_error("image_util_decode_jpeg_from_memory failed"); + media_svc_error("__media_svc_decode_jpeg failed"); + *resize_image = image; + *resize_size = size; + return MS_MEDIA_ERR_NONE; + } + + if (raw_image == NULL) { + media_svc_error("raw_image is null"); *resize_image = image; *resize_size = size; return MS_MEDIA_ERR_NONE; @@ -673,7 +775,7 @@ static int __media_svc_resize_artwork(unsigned char *image, unsigned int size, c resized_height = height * MEDIA_SVC_ARTWORK_SIZE / width; } - image_util_calculate_buffer_size(resized_width, resized_height, IMAGE_UTIL_COLORSPACE_RGB888 , &buf_size); + image_util_calculate_buffer_size(resized_width, resized_height, colorspace, &buf_size); resized_raw_image = malloc(buf_size); @@ -687,7 +789,7 @@ static int __media_svc_resize_artwork(unsigned char *image, unsigned int size, c memset(resized_raw_image, 0, buf_size); - ret = image_util_resize(resized_raw_image, &resized_width, &resized_height, raw_image, width, height, IMAGE_UTIL_COLORSPACE_RGB888); + ret = image_util_resize(resized_raw_image, &resized_width, &resized_height, raw_image, width, height, colorspace); if (ret != MS_MEDIA_ERR_NONE) { media_svc_error("image_util_resize failed"); *resize_image = image; @@ -699,9 +801,9 @@ static int __media_svc_resize_artwork(unsigned char *image, unsigned int size, c SAFE_FREE(raw_image); /* encoding */ - ret = image_util_encode_jpeg_to_memory(resized_raw_image, resized_width, resized_height, IMAGE_UTIL_COLORSPACE_RGB888, 90, resize_image, resize_size); + ret = __media_svc_encode_jpeg(resized_raw_image, (unsigned long)resized_width, (unsigned long)resized_height, colorspace, 90, resize_image, (unsigned long long *)resize_size); if (ret != MS_MEDIA_ERR_NONE) { - media_svc_error("image_util_encode_jpeg_to_memory failed"); + media_svc_error("__media_svc_encode_jpeg failed"); *resize_image = image; *resize_size = size; SAFE_FREE(resized_raw_image); @@ -709,6 +811,12 @@ static int __media_svc_resize_artwork(unsigned char *image, unsigned int size, c } SAFE_FREE(resized_raw_image); + if (*resize_image == NULL) { + media_svc_error("*resize_image is null"); + *resize_image = image; + *resize_size = size; + return MS_MEDIA_ERR_NONE; + } } else if ((strstr(img_format, "png") != NULL) || (strstr(img_format, "PNG") != NULL)) { media_svc_debug("type [png] size [%d]", size); *resize_image = image; @@ -1726,7 +1834,7 @@ int _media_svc_extract_music_metadata_for_update(sqlite3 *handle, media_svc_cont if (mmf_error != FILEINFO_ERROR_NONE) { media_svc_error("fail to free tag attr - err(%x)", mmf_error); } - } else { + } else { /* in case of file size 0, MMFW Can't parsting tag info but add it to Music DB. */ char *no_tag_title = NULL; media_svc_error("no tag information");