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");
}
//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)