#undef __USE_XOPEN
#endif
#include <string.h>
+#include <system_info.h>
#include <sys/vfs.h>
#include <glib/gstdio.h>
#include <sys/stat.h>
#include <aul/aul.h>
#include <mm_file.h>
#include <libexif/exif-data.h>
-#include <media-thumbnail.h>
#include <media-util.h>
#include <uuid/uuid.h>
-#include <img-codec-parser.h>
-#include <image_util.h>
-#include <image_util_internal.h>
+#include <mm_util_magick.h>
#include "media-util-err.h"
#include "media-svc-util.h"
#include "media-svc-db-utils.h"
#include "media-svc-env.h"
#include "media-svc-hash.h"
#include "media-svc-album.h"
-#include "media-svc-localize-utils.h"
#include "media-svc-localize_ch.h"
#define MEDIA_SVC_FILE_EXT_LEN_MAX 6 /**< Maximum file ext lenth*/
#define _MP4_FILE ".mp4"
#define _ASF_FILE ".asf"
#define MEDIA_SVC_ARTWORK_SIZE 2000
+#define MEDIA_SVC_DEFAULT_FORMAT_LEN 19
+
+
+static int media_svc_pinyin_support = -1;
typedef struct {
char content_type[15];
return uuid_unparsed;
}
-void _strncpy_safe(char *x_dst, const char *x_src, int max_len)
-{
- if (!x_src || strlen(x_src) == 0) {
- media_svc_error("x_src is NULL");
- return;
- }
-
- if (max_len < 1) {
- media_svc_error("length is Wrong");
- return;
- }
-
- strncpy(x_dst, x_src, max_len - 1);
- x_dst[max_len - 1] = '\0';
-}
-
static int __media_svc_split_to_double(char *input, double *arr)
{
char tmp_arr[255] = {0, };
if (t.tm_isdst != 0)
media_svc_debug("DST %d", t.tm_isdst);
- modified_t = mktime(&t);
+ /* If time string has timezone */
+ if (strptime(timstr, "%Y:%m:%d %H:%M:%S %z", &t) || strptime(timstr, "%Y-%m-%d %H:%M:%S %z", &t)) {
+ GTimeVal timeval;
+ char tim_tmp_str[255] = { 0, };
+
+ /* ISO8601 Time string format */
+ strftime(tim_tmp_str, 255, "%Y-%m-%dT%H:%M:%S%z", &t);
+ g_time_val_from_iso8601(tim_tmp_str, &timeval);
+ modified_t = timeval.tv_sec;
+ media_svc_debug("Calibrated timeval : [%d][%s]", modified_t, tim_tmp_str);
+ } else {
+ /* Just localtime */
+ modified_t = mktime(&t);
+ }
+
if (modified_t > 0)
return modified_t;
else
}
}
- /*check music file in soun files. */
+ /*check music file in sound files. */
if (*category & MEDIA_SVC_CATEGORY_SOUND) {
int prefix_len = strlen(content_category[0].content_type) + 1;
for (i = strlen(file_path); i >= 0; i--) {
if (file_path[i] == '.') {
- _strncpy_safe(file_ext, &file_path[i + 1], MEDIA_SVC_FILE_EXT_LEN_MAX);
+ SAFE_STRLCPY(file_ext, &file_path[i + 1], MEDIA_SVC_FILE_EXT_LEN_MAX);
return true;
}
return MS_MEDIA_ERR_NONE;
}
-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;
- unsigned char *encoded_data = 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_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_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_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_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_output_buffer(encoder, &encoded_data);
- 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;
- }
- if (encoded_data != NULL) {
- *dst = (unsigned char *)calloc(1, *dst_size);
- if (*dst == NULL) {
- media_svc_error("memory allocation failed! (%lld)", *dst_size);
- image_util_encode_destroy(encoder);
- return MS_MEDIA_ERR_INTERNAL;
- }
- memcpy(*dst, encoded_data, *dst_size);
- }
- 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;
- }
- SAFE_FREE(encoded_data);
- 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)
+static int __media_svc_resize_artwork(const char *path, const char *img_format)
{
int ret = MS_MEDIA_ERR_NONE;
- unsigned char *raw_image = NULL;
- int width = 0;
- int height = 0;
- unsigned long long raw_size = 0;
- void *resized_raw_image = NULL;
- int resized_width = 0;
- int resized_height = 0;
- unsigned int buf_size = 0;
- image_util_colorspace_e colorspace = IMAGE_UTIL_COLORSPACE_RGB888;
+ unsigned int width = 0;
+ unsigned int height = 0;
+ unsigned int resized_width = 0;
+ unsigned int resized_height = 0;
+ mm_util_img_codec_type img_type = IMG_CODEC_UNKNOWN_TYPE;
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 = __media_svc_decode_jpeg(image, (unsigned long long)size, colorspace, &raw_image, (unsigned long *)&width, (unsigned long *)&height, &raw_size);
- if (ret != MS_MEDIA_ERR_NONE) {
- media_svc_error("__media_svc_decode_jpeg failed");
- *resize_image = image;
- *resize_size = size;
- return MS_MEDIA_ERR_NONE;
- }
+ media_svc_debug("type [jpeg]");
- if (raw_image == NULL) {
- media_svc_error("raw_image is null");
- *resize_image = image;
- *resize_size = size;
- return MS_MEDIA_ERR_NONE;
- }
+ mm_util_extract_image_info(path, &img_type, &width, &height);
if (width <= MEDIA_SVC_ARTWORK_SIZE || height <= MEDIA_SVC_ARTWORK_SIZE) {
media_svc_debug("No need resizing");
- *resize_image = image;
- *resize_size = size;
- SAFE_FREE(raw_image);
return MS_MEDIA_ERR_NONE;
}
+
/* resizing */
if (width > height) {
resized_height = MEDIA_SVC_ARTWORK_SIZE;
resized_height = height * MEDIA_SVC_ARTWORK_SIZE / width;
}
- image_util_calculate_buffer_size(resized_width, resized_height, colorspace, &buf_size);
-
- resized_raw_image = malloc(buf_size);
-
- if (resized_raw_image == NULL) {
- media_svc_error("malloc failed");
- *resize_image = image;
- *resize_size = size;
- SAFE_FREE(raw_image);
- return MS_MEDIA_ERR_NONE;
- }
-
- memset(resized_raw_image, 0, buf_size);
-
- 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;
- *resize_size = size;
- SAFE_FREE(raw_image);
- SAFE_FREE(resized_raw_image);
- return MS_MEDIA_ERR_NONE;
- }
- SAFE_FREE(raw_image);
-
- /* encoding */
- ret = __media_svc_encode_jpeg((unsigned char *)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("__media_svc_encode_jpeg failed");
- *resize_image = image;
- *resize_size = size;
- SAFE_FREE(resized_raw_image);
- return MS_MEDIA_ERR_NONE;
- }
- SAFE_FREE(resized_raw_image);
+ ret = mm_util_resize_P_P(path, resized_width, resized_height, path);
- 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;
- *resize_size = size;
-
+ media_svc_debug("type [png]");
} else {
media_svc_debug("Not proper img format");
- *resize_image = image;
- *resize_size = size;
}
return ret;
return title;
}
+bool __media_svc_check_support_pinyin()
+{
+ int ret = SYSTEM_INFO_ERROR_NONE;
+ bool is_supported = false;
+
+ if (media_svc_pinyin_support == -1) {
+ ret = system_info_get_platform_bool("http://tizen.org/feature/content.filter.pinyin", &is_supported);
+ if (ret != SYSTEM_INFO_ERROR_NONE) {
+ media_svc_debug("SYSTEM_INFO_ERROR: content.filter.pinyin [%d]", ret);
+ return false;
+ }
+
+ media_svc_pinyin_support = is_supported;
+ }
+
+ return media_svc_pinyin_support;
+}
int _media_svc_rename_file(const char *old_name, const char *new_name)
{
if ((old_name == NULL) || (new_name == NULL)) {
int _media_svc_remove_all_files_in_dir(const char *dir_path)
{
- struct dirent entry;
- struct dirent *result;
- struct stat st;
char filename[MEDIA_SVC_PATHNAME_SIZE] = {0, };
- DIR *dir = NULL;
-
- dir = opendir(dir_path);
- if (dir == NULL) {
+ GDir *dir = NULL;
+ GError *error = NULL;
+ const char *name;
+
+ dir = g_dir_open(dir_path, 0, &error);
+ if (dir != NULL && error == NULL) {
+ while ((name = g_dir_read_name(dir))) {
+ memset(filename, 0, sizeof(filename));
+ snprintf(filename, sizeof(filename), "%s/%s", dir_path, name);
+
+ if (g_file_test(filename, G_FILE_TEST_IS_REGULAR)) {
+ if (unlink(filename) != 0)
+ media_svc_stderror("failed to remove");
+ }
+ }
+ } else {
media_svc_error("%s is not exist", dir_path);
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
- while (!readdir_r(dir, &entry, &result)) {
- if (result == NULL)
- break;
-
- if (strcmp(entry.d_name, ".") == 0 || strcmp(entry.d_name, "..") == 0)
- continue;
-
- snprintf(filename, sizeof(filename), "%s/%s", dir_path, entry.d_name);
-
- if (stat(filename, &st) != 0)
- continue;
-
- if (S_ISDIR(st.st_mode))
- continue;
-
- if (unlink(filename) != 0) {
- media_svc_stderror("failed to remove");
- closedir(dir);
- return MS_MEDIA_ERR_INTERNAL;
- }
- }
-
- closedir(dir);
- return MS_MEDIA_ERR_NONE;
-}
-
-static int __media_svc_check_thumb_dir(const char *thumb_dir)
-{
- DIR *dir = NULL;
-
- dir = opendir(thumb_dir);
- if (dir != NULL)
- closedir(dir);
- else
- return MS_MEDIA_ERR_INTERNAL;
+ g_dir_close(dir);
return MS_MEDIA_ERR_NONE;
}
-int _media_svc_get_thumbnail_path(media_svc_storage_type_e storage_type, char *thumb_path, const char *pathname, const char *img_format, uid_t uid)
+int _media_svc_get_thumbnail_path(media_svc_storage_type_e storage_type, media_svc_media_type_e media_type, char *thumb_path, const char *pathname, const char *img_format, uid_t uid)
{
int ret = MS_MEDIA_ERR_NONE;
- char savename[MEDIA_SVC_PATHNAME_SIZE] = {0, };
char file_ext[MEDIA_SVC_FILE_EXT_LEN_MAX + 1] = {0, };
- char *thumb_dir = NULL;
char hash[255 + 1] = {0, };
+ char *thumb_dir = NULL;
char *thumbfile_ext = NULL;
- char *internal_thumb_path = NULL;
- char *external_thumb_path = NULL;
- ret = ms_user_get_default_thumb_store_path(uid, &internal_thumb_path);
- ret = ms_user_get_mmc_thumb_store_path(uid, &external_thumb_path);
-
- if (!STRING_VALID(internal_thumb_path) || !STRING_VALID(external_thumb_path)) {
- media_svc_error("fail to get thumbnail path");
- SAFE_FREE(internal_thumb_path);
- SAFE_FREE(external_thumb_path);
+ ret = ms_user_get_thumb_store_path(uid, storage_type, &thumb_dir);
+ if (!STRING_VALID(thumb_dir)) {
+ media_svc_error("ms_user_get_thumb_store_path failed");
return MS_MEDIA_ERR_INTERNAL;
}
- thumb_dir = (storage_type == MEDIA_SVC_STORAGE_INTERNAL) ? internal_thumb_path : external_thumb_path;
-
- ret = __media_svc_check_thumb_dir(thumb_dir);
- if (ret != MS_MEDIA_ERR_NONE) {
- media_svc_error("__media_svc_check_thumb_dir");
- SAFE_FREE(internal_thumb_path);
- SAFE_FREE(external_thumb_path);
+ if (!g_file_test(thumb_dir, G_FILE_TEST_IS_DIR)) {
+ media_svc_error("Wrong path[%s]", thumb_dir);
+ SAFE_FREE(thumb_dir);
return MS_MEDIA_ERR_INTERNAL;
}
ret = mb_svc_generate_hash_code(pathname, hash, sizeof(hash));
if (ret != MS_MEDIA_ERR_NONE) {
media_svc_error("mb_svc_generate_hash_code failed : %d", ret);
- SAFE_FREE(internal_thumb_path);
- SAFE_FREE(external_thumb_path);
+ SAFE_FREE(thumb_dir);
return MS_MEDIA_ERR_INTERNAL;
}
- /*media_svc_debug("img format is [%s]", img_format); */
+ if (media_type == MEDIA_SVC_MEDIA_TYPE_MUSIC) {
+ if ((strstr(img_format, "jpeg") != NULL) || (strstr(img_format, "jpg") != NULL) || (strstr(img_format, "JPG") != NULL)) {
+ thumbfile_ext = (char *)"jpg";
+ } else if ((strstr(img_format, "png") != NULL) || (strstr(img_format, "PNG") != NULL)) {
+ thumbfile_ext = (char *)"png";
+ } else if ((strstr(img_format, "gif") != NULL) || (strstr(img_format, "GIF") != NULL)) {
+ thumbfile_ext = (char *)"gif";
+ } else if ((strstr(img_format, "bmp") != NULL) || (strstr(img_format, "BMP") != NULL)) {
+ thumbfile_ext = (char *)"bmp";
+ } else {
+ media_svc_error("Not proper img format");
+ SAFE_FREE(thumb_dir);
+ return MS_MEDIA_ERR_INTERNAL;
+ }
- if ((strstr(img_format, "jpeg") != NULL) || (strstr(img_format, "jpg") != NULL) || (strstr(img_format, "JPG") != NULL)) {
- thumbfile_ext = (char *)"jpg";
- } else if ((strstr(img_format, "png") != NULL) || (strstr(img_format, "PNG") != NULL)) {
- thumbfile_ext = (char *)"png";
- } else if ((strstr(img_format, "gif") != NULL) || (strstr(img_format, "GIF") != NULL)) {
- thumbfile_ext = (char *)"gif";
- } else if ((strstr(img_format, "bmp") != NULL) || (strstr(img_format, "BMP") != NULL)) {
- thumbfile_ext = (char *)"bmp";
+ snprintf(thumb_path, MEDIA_SVC_PATHNAME_SIZE, "%s/.%s-%s.%s", thumb_dir, file_ext, hash, thumbfile_ext);
} else {
- media_svc_error("Not proper img format");
- SAFE_FREE(internal_thumb_path);
- SAFE_FREE(external_thumb_path);
- return MS_MEDIA_ERR_INTERNAL;
+ if (strcasecmp(file_ext, "PNG") == 0)
+ snprintf(thumb_path, MEDIA_SVC_PATHNAME_SIZE, "%s/.%s-%s.png", thumb_dir, file_ext, hash);
+ else
+ snprintf(thumb_path, MEDIA_SVC_PATHNAME_SIZE, "%s/.%s-%s.jpg", thumb_dir, file_ext, hash);
}
- snprintf(savename, sizeof(savename), "%s/.%s-%s.%s", thumb_dir, file_ext, hash, thumbfile_ext);
- _strncpy_safe(thumb_path, savename, MEDIA_SVC_PATHNAME_SIZE);
- /*media_svc_debug("thumb_path is [%s]", thumb_path); */
-
- SAFE_FREE(internal_thumb_path);
- SAFE_FREE(external_thumb_path);
+ SAFE_FREE(thumb_dir);
return MS_MEDIA_ERR_NONE;
}
{
int ret = MS_MEDIA_ERR_NONE;
char * media_uuid = NULL;
- char * file_name = NULL;
bool drm_type = false;
char mime_type[256] = {0, };
content_info->media_uuid = g_strdup(media_uuid);
media_svc_retv_del_if(content_info->media_uuid == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
- file_name = g_path_get_basename(path);
- content_info->file_name = g_strdup(file_name);
- SAFE_FREE(file_name);
+ content_info->file_name = g_path_get_basename(path);
media_svc_retv_del_if(content_info->file_name == NULL, MS_MEDIA_ERR_INTERNAL, content_info);
/* if the file is DRM file, drm_type value is DRM_TRUE(1).
FILE *fp = NULL;
long app1_size = 0;
int size = 1;
- unsigned char exif_header[4];
- unsigned char exif_app1[2];
- unsigned char exif_app1_xmp[2];
+ unsigned char exif_header[4] = {0, };
+ unsigned char exif_app1[2] = {0, };
+ unsigned char exif_app1_xmp[2] = {0, };
long exif_app1_xmp_size = 0;
- unsigned char exif_app1_xmp_t[2];
+ unsigned char exif_app1_xmp_t[2] = {0, };
char *xmp_data = NULL;
int size1 = 0;
int size2 = 0;
int fdata = 0;
int temp = 0;
+ memset(exif_header, 0x00, sizeof(exif_header));
+ memset(exif_app1, 0x00, sizeof(exif_app1));
+ memset(exif_app1_xmp, 0x00, sizeof(exif_app1_xmp));
+ memset(exif_app1_xmp_t, 0x00, sizeof(exif_app1_xmp_t));
+
fp = fopen(path, "rb");
if (fp == NULL)
goto ERROR;
exif_app1_xmp_size = size1 * 256 + size2 - 2;
- xmp_data = (char *)malloc(exif_app1_xmp_size);
- if (xmp_data != NULL) {
+ if (exif_app1_xmp_size > 0) {
+ xmp_data = (char *)malloc(exif_app1_xmp_size);
memset(xmp_data, 0x0, exif_app1_xmp_size);
+
ptr = xmp_data;
while (exif_app1_xmp_size >= 0) {
SAFE_FREE(xmp_data);
} else {
- media_svc_error("malloc failed");
+ media_svc_error("invalid exif_app1_xmp_size [%ld]", exif_app1_xmp_size);
}
if (fp) {
/*Get image width, height*/
unsigned int img_width = 0;
unsigned int img_height = 0;
- ImgCodecType img_type = IMG_CODEC_NONE;
+ mm_util_img_codec_type img_type = IMG_CODEC_UNKNOWN_TYPE;
- ImgGetImageInfo(path, &img_type, &img_width, &img_height);
+ mm_util_extract_image_info(path, &img_type, &img_width, &img_height);
if (content_info->media_meta.width == 0)
content_info->media_meta.width = img_width;
if (mmf_error == FILEINFO_ERROR_NONE) {
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ALBUM, &p, &size, NULL);
- if (mmf_error == FILEINFO_ERROR_NONE && size > 0) {
+ if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
content_info->media_meta.album = g_strdup(p);
- } else {
+ else
SAFE_FREE(err_attr_name);
- }
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ARTIST, &p, &size, NULL);
- if (mmf_error == FILEINFO_ERROR_NONE && size > 0) {
+ if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
content_info->media_meta.artist = g_strdup(p);
- } else {
+ else
SAFE_FREE(err_attr_name);
- }
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ALBUM_ARTIST, &p, &size, NULL);
- if (mmf_error == FILEINFO_ERROR_NONE && size > 0) {
+ if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
content_info->media_meta.album_artist = g_strdup(p);
- } else {
+ else
SAFE_FREE(err_attr_name);
- }
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_GENRE, &p, &size, NULL);
if (mmf_error == FILEINFO_ERROR_NONE && size > 0) {
}
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_DESCRIPTION, &p, &size, NULL);
- if (mmf_error == FILEINFO_ERROR_NONE && size > 0) {
+ if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
content_info->media_meta.description = g_strdup(p);
- } else {
+ else
SAFE_FREE(err_attr_name);
- }
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_AUTHOR, &p, &size, NULL);
- if (mmf_error == FILEINFO_ERROR_NONE && size > 0) {
+ if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
content_info->media_meta.composer = g_strdup(p);
- } else {
+ else
SAFE_FREE(err_attr_name);
- }
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_COPYRIGHT, &p, &size, NULL);
- if (mmf_error == FILEINFO_ERROR_NONE && size > 0) {
+ if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
content_info->media_meta.copyright = g_strdup(p);
- } else {
+ else
SAFE_FREE(err_attr_name);
- }
mmf_error = mm_file_destroy_tag_attrs(tag);
if (mmf_error != FILEINFO_ERROR_NONE)
unsigned int size = 0;
int mmf_error = FILEINFO_ERROR_NONE;
char *err_attr_name = NULL;
- bool extract_thumbnail = FALSE;
- bool append_album = FALSE;
int album_id = 0;
int ret = MS_MEDIA_ERR_NONE;
int cdis_value = 0;
- unsigned int resize_size = 0;
- unsigned char *resize_image = NULL;
/*Get Content Tag attribute ===========*/
mmf_error = mm_file_create_tag_attrs(&tag, content_info->path);
if (mmf_error == FILEINFO_ERROR_NONE) {
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ALBUM, &p, &size, NULL);
- if (mmf_error == FILEINFO_ERROR_NONE && size > 0) {
+ if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
content_info->media_meta.album = g_strdup(p);
- } else {
+ else
SAFE_FREE(err_attr_name);
- }
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ARTIST, &p, &size, NULL);
- if (mmf_error == FILEINFO_ERROR_NONE && size > 0) {
+ if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
content_info->media_meta.artist = g_strdup(p);
- } else {
+ else
SAFE_FREE(err_attr_name);
- }
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ALBUM_ARTIST, &p, &size, NULL);
- if (mmf_error == FILEINFO_ERROR_NONE && size > 0) {
+ if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
content_info->media_meta.album_artist = g_strdup(p);
- } else {
+ else
SAFE_FREE(err_attr_name);
- }
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_GENRE, &p, &size, NULL);
if (mmf_error == FILEINFO_ERROR_NONE && size > 0) {
}
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_DESCRIPTION, &p, &size, NULL);
- if (mmf_error == FILEINFO_ERROR_NONE && size > 0) {
+ if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
content_info->media_meta.description = g_strdup(p);
- } else {
+ else
SAFE_FREE(err_attr_name);
- }
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_SPHERICAL, &content_info->media_meta.is_360, NULL);
if (mmf_error != FILEINFO_ERROR_NONE)
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_RECDATE, &p, &size, NULL);
if ((mmf_error == FILEINFO_ERROR_NONE) && (size > 0)) {
- if (content_info->media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO) {
+ char mime_type[255] = {0, };
+ ret = __media_svc_get_mime_type(content_info->path, mime_type);
+ /*if 3gp that audio only, media_type is music */
+ if ((ret == MS_MEDIA_ERR_NONE) &&
+ ((content_info->media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO && strcmp(mime_type, "video/mp4") == 0) ||
+ (content_info->media_type == MEDIA_SVC_MEDIA_TYPE_VIDEO && strcmp(mime_type, "video/3gpp") == 0) ||
+ (content_info->media_type == MEDIA_SVC_MEDIA_TYPE_MUSIC && strcmp(mime_type, "video/3gpp") == 0) ||
+ (content_info->media_type == MEDIA_SVC_MEDIA_TYPE_MUSIC && strcmp(mime_type, "audio/mp4") == 0))) {
/*Creation time format is 2013-01-01 00:00:00. change it to 2013:01:01 00:00:00 like exif time format*/
- char *time_info = (char*)calloc(1, (size + 1));
+ char *time_info = g_strdup_printf("0000:00:00 00:00:00 +0000");
char *p_value = p;
char *time_value = time_info;
if (time_info != NULL) {
time_value++;
p_value++;
}
- *time_value = '\0';
content_info->media_meta.recorded_date = g_strdup(time_info);
SAFE_FREE(time_info);
} else {
media_svc_error("memory allocation error");
- ret = MS_MEDIA_ERR_OUT_OF_MEMORY;
}
} else {
content_info->media_meta.recorded_date = g_strdup(p);
}
if (STRING_VALID(content_info->media_meta.recorded_date)) {
- /* This is same as datetaken */
- content_info->media_meta.datetaken = g_strdup(content_info->media_meta.recorded_date);
-
content_info->timeline = __media_svc_get_timeline_from_str(content_info->media_meta.recorded_date);
if (content_info->timeline == 0)
content_info->timeline = content_info->modified_time;
else
media_svc_debug("Timeline : %ld", content_info->timeline);
+
+ /* This is same as datetaken */
+ /* Remove compensation string */
+ if (strlen(content_info->media_meta.recorded_date) > MEDIA_SVC_DEFAULT_FORMAT_LEN) {
+ content_info->media_meta.datetaken = g_strndup(content_info->media_meta.recorded_date, MEDIA_SVC_DEFAULT_FORMAT_LEN);
+ G_SAFE_FREE(content_info->media_meta.recorded_date);
+ content_info->media_meta.recorded_date = g_strdup(content_info->media_meta.datetaken);
+ } else {
+ content_info->media_meta.datetaken = g_strdup(content_info->media_meta.recorded_date);
+ }
}
} else {
SAFE_FREE(err_attr_name);
}
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_AUTHOR, &p, &size, NULL);
- if (mmf_error == FILEINFO_ERROR_NONE && size > 0) {
+ if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
content_info->media_meta.composer = g_strdup(p);
- } else {
+ else
SAFE_FREE(err_attr_name);
- }
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_COPYRIGHT, &p, &size, NULL);
- if (mmf_error == FILEINFO_ERROR_NONE && size > 0) {
+ if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
content_info->media_meta.copyright = g_strdup(p);
- } else {
+ else
SAFE_FREE(err_attr_name);
- }
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_TRACK_NUM, &p, &size, NULL);
- if (mmf_error == FILEINFO_ERROR_NONE && size > 0) {
+ if (mmf_error == FILEINFO_ERROR_NONE && size > 0)
content_info->media_meta.track_num = g_strdup(p);
- } else {
+ else
SAFE_FREE(err_attr_name);
- }
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_DATE, &p, &size, NULL);
if (mmf_error == FILEINFO_ERROR_NONE && size == 4) {
int year = 0;
- if ((p != NULL) && (__media_svc_safe_atoi(p, &year) == MS_MEDIA_ERR_NONE)) {
+ if ((p != NULL) && (__media_svc_safe_atoi(p, &year) == MS_MEDIA_ERR_NONE))
content_info->media_meta.year = g_strdup(p);
- } else {
+ else
media_svc_debug("Wrong Year Information [%s]", p);
- }
} else {
SAFE_FREE(err_attr_name);
}
content_info->media_meta.rating = 0;
}
- /*Initialize album_id to 0. below code will set the album_id*/
- content_info->album_id = album_id;
- ret = _media_svc_get_album_id(handle, content_info->media_meta.album, content_info->media_meta.artist, &album_id);
-
- if (ret != MS_MEDIA_ERR_NONE) {
- if (ret == MS_MEDIA_ERR_DB_NO_RECORD) {
- media_svc_debug("album does not exist. So start to make album art");
- extract_thumbnail = TRUE;
- append_album = TRUE;
- } else {
- extract_thumbnail = TRUE;
- append_album = FALSE;
- }
- } else {
- content_info->album_id = album_id;
- append_album = FALSE;
-
- if ((!g_strcmp0(content_info->media_meta.album, MEDIA_SVC_TAG_UNKNOWN)) ||
- (!g_strcmp0(content_info->media_meta.artist, MEDIA_SVC_TAG_UNKNOWN))) {
- media_svc_debug("Unknown album or artist already exists. Extract thumbnail for Unknown.");
- extract_thumbnail = TRUE;
- } else {
- media_svc_debug("album already exists. don't need to make album art");
- ret = _media_svc_get_album_art_by_album_id(handle, album_id, &content_info->thumbnail_path);
- extract_thumbnail = TRUE;
- }
- }
-
/*Do not extract artwork for the USB Storage content*/
- if (content_info->storage_type == MEDIA_SVC_STORAGE_EXTERNAL_USB)
- extract_thumbnail = FALSE;
-
- if (extract_thumbnail == TRUE) {
+ if (content_info->storage_type != MEDIA_SVC_STORAGE_EXTERNAL_USB) {
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ARTWORK, &image, &size, NULL);
if (mmf_error != FILEINFO_ERROR_NONE) {
media_svc_error("fail to get tag artwork - err(%x)", mmf_error);
} else {
/*media_svc_debug("artwork size2 [%d]", size); */
}
+
if (image != NULL && size > 0) {
char thumb_path[MEDIA_SVC_PATHNAME_SIZE] = "\0";
int artwork_mime_size = -1;
mmf_error = mm_file_get_attrs(tag, &err_attr_name, MM_FILE_TAG_ARTWORK_MIME, &p, &artwork_mime_size, NULL);
if ((mmf_error == FILEINFO_ERROR_NONE) && (artwork_mime_size > 0)) {
- ret = _media_svc_get_thumbnail_path(content_info->storage_type, thumb_path, content_info->path, p, uid);
+ ret = _media_svc_get_thumbnail_path(content_info->storage_type, content_info->media_type, thumb_path, content_info->path, p, uid);
if (ret != MS_MEDIA_ERR_NONE)
media_svc_error("Fail to Get Thumbnail Path");
- /* albumart resizing */
- __media_svc_resize_artwork(image, size, p, &resize_image, &resize_size);
- } else {
- SAFE_FREE(err_attr_name);
- }
- if (strlen(thumb_path) > 0) {
- ret = __media_svc_save_image(resize_image, resize_size, thumb_path, uid);
- if (ret != MS_MEDIA_ERR_NONE) {
- media_svc_error("Fail to Save Thumbnail Image");
- } else {
- content_info->thumbnail_path = g_strdup(thumb_path);
+ if (strlen(thumb_path) > 0) {
+ ret = __media_svc_save_image(image, size, thumb_path, uid);
+ if (ret != MS_MEDIA_ERR_NONE) {
+ media_svc_error("Fail to Save Image");
+ } else {
+ /* albumart resizing */
+ ret = __media_svc_resize_artwork(thumb_path, p);
+ if (ret != MS_MEDIA_ERR_NONE) {
+ media_svc_error("Fail to Make Thumbnail Image");
+ _media_svc_remove_file(thumb_path);
+
+ } else {
+ content_info->thumbnail_path = g_strdup(thumb_path);
+ }
+ }
}
+ } else {
+ SAFE_FREE(err_attr_name);
}
}
}
- if (append_album == TRUE) {
- if ((g_strcmp0(content_info->media_meta.album, MEDIA_SVC_TAG_UNKNOWN)) &&
- (g_strcmp0(content_info->media_meta.artist, MEDIA_SVC_TAG_UNKNOWN)))
- ret = _media_svc_append_album(handle, content_info->media_meta.album, content_info->media_meta.artist, content_info->thumbnail_path, &album_id, uid);
- else
- ret = _media_svc_append_album(handle, content_info->media_meta.album, content_info->media_meta.artist, NULL, &album_id, uid);
+ /*Initialize album_id to 0. below code will set the album_id*/
+ content_info->album_id = album_id;
+ ret = _media_svc_get_album_id(handle, content_info->media_meta.album, content_info->media_meta.artist, &album_id);
+ if (ret != MS_MEDIA_ERR_NONE) {
+ if (ret == MS_MEDIA_ERR_DB_NO_RECORD) {
+ media_svc_debug("album does not exist. So start to make album art");
+ if ((g_strcmp0(content_info->media_meta.album, MEDIA_SVC_TAG_UNKNOWN)) &&
+ (g_strcmp0(content_info->media_meta.artist, MEDIA_SVC_TAG_UNKNOWN)))
+ ret = _media_svc_append_album(handle, content_info->media_meta.album, content_info->media_meta.artist, content_info->thumbnail_path, &album_id, uid);
+ else
+ ret = _media_svc_append_album(handle, content_info->media_meta.album, content_info->media_meta.artist, NULL, &album_id, uid);
+ content_info->album_id = album_id;
+ }
+ } else {
content_info->album_id = album_id;
}
return;
}
-char *_media_svc_replace_path(char *s, const char *olds, const char *news)
+int __media_svc_get_proper_thumb_size(unsigned int orig_w, unsigned int orig_h, unsigned int *thumb_w, unsigned int *thumb_h)
{
- char result[MEDIA_SVC_PATHNAME_SIZE + 1] = {0, };
- memset(result, 0x00, sizeof(result));
-
- if (STRING_VALID(s) && STRING_VALID(olds) && STRING_VALID(news)) {
- if (strncmp(s, olds, strlen(olds)) == 0) {
- snprintf(result, sizeof(result), "%s%s", news, s + strlen(olds));
- }
+ bool portrait = false;
+ double ratio;
+
+ 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;
}
- if (STRING_VALID(result))
- return g_strdup(result);
- else
- return NULL;
+ media_svc_debug("proper thumb w: %d h: %d", *thumb_w, *thumb_h);
+
+ return MS_MEDIA_ERR_NONE;
}
-int _media_svc_request_thumbnail(const char *path, char *thumb_path, int max_length, uid_t uid)
+int _media_svc_create_thumbnail(const char *path, char *thumb_path, int max_length, 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;
+
+ if (path == NULL || thumb_path == NULL) {
+ media_svc_error("Invalid parameter");
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
+ }
- ret = thumbnail_request_from_db(path, thumb_path, max_length, uid);
+ if (!g_file_test(path, G_FILE_TEST_IS_REGULAR)) {
+ media_svc_error("Original path(%s) doesn't exist.", path);
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
+ }
+
+ if (max_length <= 0) {
+ media_svc_error("Length is invalid");
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
+ }
+
+ ms_user_storage_type_e store_type = -1;
+ ret = ms_user_get_storage_type(uid, path, &store_type);
+
+ if ((ret != MS_MEDIA_ERR_NONE) || ((store_type != MS_USER_STORAGE_INTERNAL) && (store_type != MS_USER_STORAGE_EXTERNAL))) {
+ media_svc_sec_error("origin path(%s) is invalid. err : [%d] store_type [%d]", path, ret, store_type);
+ return MS_MEDIA_ERR_INVALID_PARAMETER;
+ }
+
+ media_svc_sec_debug("Path[%s] Type[%d]", path, media_type);
+
+ //1. make hash path
+ ret = _media_svc_get_thumbnail_path(store_type, media_type, thumb_path, path, THUMB_EXT, uid);
if (ret != MS_MEDIA_ERR_NONE) {
- media_svc_error("thumbnail_request_from_db failed: %d", ret);
- ret = MS_MEDIA_ERR_INTERNAL;
+ media_svc_error("_media_svc_get_thumbnail_path failed - %d", ret);
+ SAFE_STRLCPY(thumb_path, "", MAX_FILEPATH_LEN);
+ return ret;
+ }
+
+ //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 != MS_MEDIA_ERR_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_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 {
- media_svc_sec_debug("thumbnail_request_from_db success: thumbnail path[%s]", thumb_path);
+ MMHandleType content = (MMHandleType) NULL;
+ MMHandleType tag = (MMHandleType) NULL;
+
+ char *p = NULL;
+ int cdis_value = 0;
+ void *frame = NULL;
+ int video_track_num = 0;
+ char *err_msg = NULL;
+ int size = 0;
+ mm_util_image_h img = NULL;
+ mm_util_image_h resize_img = NULL;
+
+ /* Get Content Tag attribute for orientation */
+ ret = mm_file_create_tag_attrs(&tag, path);
+ mm_util_magick_rotate_type rot_type = MM_UTIL_ROTATE_NUM;
+
+ if (ret == FILEINFO_ERROR_NONE) {
+ ret = mm_file_get_attrs(tag, &err_msg, MM_FILE_TAG_ROTATE, &p, &size, NULL);
+ if (ret == FILEINFO_ERROR_NONE && size >= 0) {
+ if (p == NULL) {
+ rot_type = MM_UTIL_ROTATE_0;
+ } else {
+ if (strncmp(p, "90", size) == 0)
+ rot_type = MM_UTIL_ROTATE_90;
+ else if (strncmp(p, "180", size) == 0)
+ rot_type = MM_UTIL_ROTATE_180;
+ else if (strncmp(p, "270", size) == 0)
+ rot_type = MM_UTIL_ROTATE_270;
+ else
+ rot_type = MM_UTIL_ROTATE_0;
+ }
+ media_svc_debug("There is tag rotate : %d", rot_type);
+ } else {
+ media_svc_debug("There is NOT tag rotate");
+ rot_type = MM_UTIL_ROTATE_0;
+ SAFE_FREE(err_msg);
+ }
+
+ ret = mm_file_get_attrs(tag, &err_msg, MM_FILE_TAG_CDIS, &cdis_value, NULL);
+ if (ret != FILEINFO_ERROR_NONE) {
+ cdis_value = 0;
+ SAFE_FREE(err_msg);
+ }
+ } else {
+ rot_type = MM_UTIL_ROTATE_0;
+ cdis_value = 0;
+ }
+
+ ret = mm_file_destroy_tag_attrs(tag);
+ if (ret != FILEINFO_ERROR_NONE) {
+ media_svc_error("fail to free tag attr - err(%x)", ret);
+ }
+
+ if (cdis_value == 1) {
+ media_svc_debug("This is CDIS vlaue 1");
+ ret = mm_file_create_content_attrs_safe(&content, path);
+ } else {
+ ret = mm_file_create_content_attrs(&content, path);
+ }
+
+ if (ret != FILEINFO_ERROR_NONE) {
+ media_svc_error("mm_file_create_content_attrs fails : %d", ret);
+ return MS_MEDIA_ERR_INTERNAL;
+ }
+
+ ret = mm_file_get_attrs(content, &err_msg, MM_FILE_CONTENT_VIDEO_TRACK_COUNT, &video_track_num, NULL);
+ if (ret != FILEINFO_ERROR_NONE) {
+ media_svc_error("mm_file_get_attrs fails : %s", err_msg);
+ SAFE_FREE(err_msg);
+ goto ERROR;
+ }
+
+ if (video_track_num > 0) {
+ ret = mm_file_get_attrs(content, &err_msg,
+ MM_FILE_CONTENT_VIDEO_WIDTH,
+ &origin_w,
+ MM_FILE_CONTENT_VIDEO_HEIGHT,
+ &origin_h,
+ MM_FILE_CONTENT_VIDEO_THUMBNAIL, &frame, /* raw image is RGB888 format */
+ &size, NULL);
+
+ if (ret != FILEINFO_ERROR_NONE) {
+ media_svc_error("mm_file_get_attrs fails : %s", err_msg);
+ SAFE_FREE(err_msg);
+ goto ERROR;
+ }
+
+ media_svc_debug("W[%d] H[%d] Size[%d] Frame[%p] Rotate[%d]", origin_w, origin_h, size, frame, rot_type);
+ if (frame == NULL || origin_w == 0 || origin_h == 0) {
+ media_svc_error("Failed to get frame data");
+ goto ERROR;
+ }
+
+ ret = __media_svc_get_proper_thumb_size(origin_w, origin_h, &thumb_w, &thumb_h);
+ if (thumb_w <= 0 || thumb_h <= 0) {
+ media_svc_error("Failed to get thumb size");
+ goto ERROR;
+ }
+
+ media_svc_debug("Origin:W[%d] H[%d] Proper:W[%d] H[%d]", origin_w, origin_h, thumb_w, thumb_h);
+
+ ret = mm_util_create_handle(&img, (unsigned char *)frame, origin_w, origin_h, size, MM_UTIL_COLOR_RGB24);
+ if (origin_w > thumb_w || origin_h > thumb_h) {
+ if (rot_type != MM_UTIL_ROTATE_0) {
+ ret = mm_util_resize_B_B(img, thumb_w, thumb_h, &resize_img);
+ if (ret != MM_UTIL_ERROR_NONE)
+ goto ERROR;
+ ret = mm_util_rotate_B_P(resize_img, rot_type, thumb_path);
+ } else {
+ ret = mm_util_resize_B_P(img, thumb_w, thumb_h, thumb_path);
+ }
+ } else {
+ if (rot_type != MM_UTIL_ROTATE_0)
+ ret = mm_util_rotate_B_P(img, rot_type, thumb_path);
+ else
+ ret = mm_util_resize_B_P(img, origin_w, origin_h, thumb_path);
+ }
+ }
+
+ ERROR:
+ mm_util_destroy_handle(img);
+ mm_util_destroy_handle(resize_img);
+ mm_file_destroy_content_attrs(content);
+
+ if (ret != MS_MEDIA_ERR_NONE)
+ return MS_MEDIA_ERR_INTERNAL;
+
+ return MS_MEDIA_ERR_NONE;
}
return ret;
bool _media_svc_check_pinyin_support(void)
{
- /*Check CSC*/
- return TRUE;
+ /* Check CSC : TODO : need to check CSC */
+
+ /* Check content.filter.pinyin feature */
+ return __media_svc_check_support_pinyin();
}
int _media_svc_get_media_type(const char *path, int *mediatype)
media_svc_media_type_e media_type = MEDIA_SVC_MEDIA_TYPE_OTHER;
ret = __media_svc_get_mime_type(path, mime_type);
- if (ret == MS_MEDIA_ERR_NONE) {
+ if (ret == MS_MEDIA_ERR_NONE)
__media_svc_get_media_type(path, mime_type, &media_type);
- } else {
+ else
media_svc_error("__media_svc_get_mime_type failed");
- }
*mediatype = media_type;