return;
}
-int _thumb_daemon_process_job(thumbMsg *req_msg, thumbMsg *res_msg, uid_t uid)
+int _thumb_daemon_process_job(thumbMsg *req_msg, thumbMsg *res_msg)
{
int err = MS_MEDIA_ERR_NONE;
- err = _media_thumb_process(req_msg, res_msg, uid);
+ err = _media_thumb_process(req_msg, res_msg);
if (err != MS_MEDIA_ERR_NONE) {
if (req_msg->msg_type == THUMB_REQUEST_SAVE_FILE) {
thumb_err("_media_thumb_process is failed: %d", err);
err = _media_thumb_process_raw(req_msg, res_msg);
if (err != MS_MEDIA_ERR_NONE) {
- if (err != MS_MEDIA_ERR_FILE_NOT_EXIST) {
- thumb_warn("_media_thumb_process is failed: %d, So use default thumb", err);
- res_msg->status = THUMB_SUCCESS;
- } else {
- thumb_warn("_media_thumb_process is failed: %d, (file not exist) ", err);
- res_msg->status = THUMB_FAIL;
- }
+ thumb_warn("_media_thumb_process is failed: %d", err);
+ res_msg->status = THUMB_FAIL;
} else {
res_msg->status = THUMB_SUCCESS;
}
memset(&res_msg, 0x00, sizeof(thumbMsg));
recv_msg.msg_type = THUMB_REQUEST_DB_INSERT;
+ recv_msg.uid = uid;
strncpy(recv_msg.org_path, path, sizeof(recv_msg.org_path));
recv_msg.org_path[sizeof(recv_msg.org_path) - 1] = '\0';
- err = _thumb_daemon_process_job(&recv_msg, &res_msg, uid);
+ err = _thumb_daemon_process_job(&recv_msg, &res_msg);
if (err == MS_MEDIA_ERR_FILE_NOT_EXIST) {
thumb_err("Thumbnail processing is failed : %d", err);
} else {
} else if (recv_msg.msg_type == THUMB_REQUEST_KILL_SERVER) {
thumb_warn("received KILL msg from thumbnail agent.");
} else {
- _thumb_daemon_process_job(&recv_msg, &res_msg, recv_msg.uid);
+ _thumb_daemon_process_job(&recv_msg, &res_msg);
}
if (res_msg.msg_type == 0)
file_type = _media_thumb_get_file_type(origin_path);
thumb_width = *width;
thumb_height = *height;
- if (thumb_width == 0) {
+ if (thumb_width == 0 || thumb_height == 0) {
thumb_width = THUMB_DEFAULT_WIDTH;
thumb_height = THUMB_DEFAULT_HEIGHT;
}
+ thumb_info.is_raw = FALSE;
+
if (file_type == THUMB_IMAGE_TYPE) {
- err = _media_thumb_image(origin_path, thumb_path, thumb_width, thumb_height, format, &thumb_info, FALSE);
+ err = _media_thumb_image(origin_path, thumb_path, thumb_width, thumb_height, format, &thumb_info);
if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_image failed");
return err;
if (alpha) *alpha = thumb_info.alpha;
if (is_saved) *is_saved = thumb_info.is_saved;
- thumb_dbg("Thumb data is generated successfully (Size:%d, W:%d, H:%d) 0x%x",
- *size, *width, *height, *data);
+ thumb_dbg("Thumb data is generated successfully (Size:%d, W:%d, H:%d) 0x%x", *size, *width, *height, *data);
return MS_MEDIA_ERR_NONE;
}
return MS_MEDIA_ERR_INVALID_PARAMETER;
}
-// thumb_dbg_slog("Origin path : %s", origin_path);
-
int file_type = THUMB_NONE_TYPE;
media_thumb_info thumb_info = {0,};
file_type = _media_thumb_get_file_type(origin_path);
thumb_width = *width;
thumb_height = *height;
+ thumb_info.is_raw = TRUE;
if (file_type == THUMB_IMAGE_TYPE) {
- err = _media_thumb_image(origin_path, thumb_path, thumb_width, thumb_height, format, &thumb_info, TRUE);
+ err = _media_thumb_image(origin_path, thumb_path, thumb_width, thumb_height, format, &thumb_info);
if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_image failed");
return err;
*width = thumb_info.width;
*height = thumb_info.height;
- //thumb_dbg("Thumb data is generated successfully (Size:%d, W:%d, H:%d) 0x%x", *size, *width, *height, *data);
-
return MS_MEDIA_ERR_NONE;
}
-int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg, uid_t uid)
+int _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg)
{
int err = MS_MEDIA_ERR_NONE;
unsigned char *data = NULL;
return MS_MEDIA_ERR_FILE_NOT_EXIST;
}
- err = _media_thumb_db_connect(uid);
+ err = _media_thumb_db_connect(req_msg->uid);
if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_mb_svc_connect failed: %d", err);
return err;
return MS_MEDIA_ERR_NONE;
} else {
if (strlen(thumb_path) == 0) {
- err = _media_thumb_get_hash_name(origin_path, thumb_path, max_length, uid);
+ err = _media_thumb_get_hash_name(origin_path, thumb_path, max_length, req_msg->uid);
if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_get_hash_name failed - %d", err);
strncpy(thumb_path, THUMB_EMPTY_STR, max_length);
strncpy(thumb_path, req_msg->dst_path, max_length);
} else if (msg_type == THUMB_REQUEST_ALL_MEDIA) {
- err = _media_thumb_get_hash_name(origin_path, thumb_path, max_length, uid);
+ err = _media_thumb_get_hash_name(origin_path, thumb_path, max_length, req_msg->uid);
if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_get_hash_name failed - %d", err);
strncpy(thumb_path, THUMB_EMPTY_STR, max_length);
DB_UPDATE:
/* DB update if needed */
if (need_update_db == 1) {
- err = _media_thumb_update_db(origin_path, thumb_path, res_msg->origin_width, res_msg->origin_height, uid);
+ err = _media_thumb_update_db(origin_path, thumb_path, res_msg->origin_width, res_msg->origin_height, req_msg->uid);
if (err != MS_MEDIA_ERR_NONE) {
thumb_err("_media_thumb_update_db failed : %d", err);
}
thumb_w = req_msg->thumb_width;
thumb_h = req_msg->thumb_height;
- //thumb_dbg("origin_path : %s, thumb_w : %d, thumb_h : %d ", origin_path, thumb_w, thumb_h);
-
- if (!g_file_test(origin_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
- thumb_err("origin_path does not exist in file system.");
- return MS_MEDIA_ERR_FILE_NOT_EXIST;
- }
-
err = _thumbnail_get_raw_data(origin_path, thumb_format, &thumb_w, &thumb_h, &data, &thumb_size);
if (err != MS_MEDIA_ERR_NONE) {
res_msg->thumb_data = malloc(thumb_size * sizeof(unsigned char));
memcpy(res_msg->thumb_data, data, thumb_size);
- //thumb_dbg("Size : %d, W:%d, H:%d", thumb_size, thumb_w, thumb_h);
SAFE_FREE(data);
return MS_MEDIA_ERR_NONE;
media_thumb_info *thumb_info)
{
int err = MS_MEDIA_ERR_NONE;
- ExifData *ed = NULL;
int thumb_done = 0;
int orientation = NORMAL;
+ ExifData *ed = NULL;
- /* Load an ExifData object from an EXIF file */
- ed = exif_data_new_from_file(origin_path);
-
- if (ed) {
- /* First, Get orientation from exif */
- err = _media_thumb_get_exif_info(ed, NULL, 0, &orientation, EXIF_IFD_0, EXIF_TAG_ORIENTATION);
+ if (!thumb_info->is_raw) {
+ /* Load an ExifData object from an EXIF file */
+ ed = exif_data_new_from_file(origin_path);
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_warn("_media_thumb_get_exif_info failed");
- }
+ if (ed) {
+ /* First, Get orientation from exif */
+ err = _media_thumb_get_exif_info(ed, NULL, 0, &orientation, EXIF_IFD_0, EXIF_TAG_ORIENTATION);
- /* Second, Get thumb from exif */
- err = _media_thumb_get_thumb_from_exif(ed, origin_path, thumb_path, orientation, thumb_width, thumb_height, thumb_info);
+ if (err != MS_MEDIA_ERR_NONE) {
+ thumb_warn("_media_thumb_get_exif_info failed");
+ }
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_dbg("_media_thumb_get_thumb_from_exif failed");
- } else {
- thumb_done = 1;
- thumb_dbg("_media_thumb_get_thumb_from_exif succeed");
+ /* Second, Get thumb from exif */
+ err = _media_thumb_get_thumb_from_exif(ed, origin_path, thumb_path, orientation, thumb_width, thumb_height, thumb_info);
- /* The case that original image's size is not in exif header. Use evas to get w/h */
- if (thumb_info->origin_width == 0 || thumb_info->origin_height == 0) {
- thumb_warn("original image's size is not in exif header. Use evas to get w/h");
- err = _media_thumb_get_wh_with_evas(origin_path, &(thumb_info->origin_width), &(thumb_info->origin_height));
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("Couldn't get w/h using evas : %s", origin_path);
- } else {
- thumb_dbg("origin w : %d, origin h : %d", thumb_info->origin_width, thumb_info->origin_height);
+ if (err != MS_MEDIA_ERR_NONE) {
+ thumb_dbg("_media_thumb_get_thumb_from_exif failed");
+ } else {
+ thumb_done = 1;
+ thumb_dbg("_media_thumb_get_thumb_from_exif succeed");
+
+ /* The case that original image's size is not in exif header. Use evas to get w/h */
+ if (thumb_info->origin_width == 0 || thumb_info->origin_height == 0) {
+ thumb_warn("original image's size is not in exif header. Use evas to get w/h");
+ err = _media_thumb_get_wh_with_evas(origin_path, &(thumb_info->origin_width), &(thumb_info->origin_height));
+ if (err != MS_MEDIA_ERR_NONE) {
+ thumb_err("Couldn't get w/h using evas : %s", origin_path);
+ } else {
+ thumb_dbg("origin w : %d, origin h : %d", thumb_info->origin_width, thumb_info->origin_height);
+ }
}
- }
- if (thumb_info->is_saved == FALSE) {
- mm_util_img_format dst_format = _media_thumb_get_format(format);
+ if (thumb_info->is_saved == FALSE) {
+ mm_util_img_format dst_format = _media_thumb_get_format(format);
- err = _media_thumb_convert_data(thumb_info,
- thumb_info->width,
- thumb_info->height,
- MM_UTIL_IMG_FMT_RGB888,
- dst_format);
+ err = _media_thumb_convert_data(thumb_info,
+ thumb_info->width,
+ thumb_info->height,
+ MM_UTIL_IMG_FMT_RGB888,
+ dst_format);
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("_media_thumb_convert_data failed : %d", err);
- exif_data_unref(ed);
- return err;
+ if (err != MS_MEDIA_ERR_NONE) {
+ thumb_err("_media_thumb_convert_data failed : %d", err);
+ exif_data_unref(ed);
+ return err;
+ }
}
}
- }
- exif_data_unref(ed);
+ exif_data_unref(ed);
+ }
}
if (!thumb_done) {
return err;
}
-int _media_thumb_jpeg_for_raw(const char *origin_path,
- const char *thumb_path,
- int thumb_width,
- int thumb_height,
- media_thumb_format format,
- media_thumb_info *thumb_info)
-{
- int err = MS_MEDIA_ERR_NONE;
- int orientation = NORMAL;
-
- err = _media_thumb_decode_with_evas(origin_path, thumb_width, thumb_height, thumb_info, 1, orientation);
-
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("decode_with_evas failed : %d", err);
- return err;
- }
-
- err = _media_thumb_convert_format(thumb_info, MEDIA_THUMB_BGRA, format);
- if (err != MS_MEDIA_ERR_NONE) {
- thumb_err("_media_thumb_convert_format falied: %d", err);
- SAFE_FREE(thumb_info->data);
- return err;
- }
- return err;
-}
-
int _media_thumb_image(const char *origin_path,
const char *thumb_path,
int thumb_width,
int thumb_height,
media_thumb_format format,
- media_thumb_info *thumb_info,
- bool is_req_raw)
+ media_thumb_info *thumb_info)
{
int err = MS_MEDIA_ERR_NONE;
ImgCodecType image_type = 0;
thumb_info->origin_width = origin_w;
thumb_info->origin_height = origin_h;
- //thumb_dbg("image type is %d, width:%d, height:%d", image_type, origin_w, origin_h);
-
if ((image_type != IMG_CODEC_JPEG) &&
(origin_w * origin_h > THUMB_MAX_ALLOWED_MEM_FOR_THUMB)) {
thumb_warn("This original image is too big");
if (image_type == IMG_CODEC_AGIF) {
err = _media_thumb_agif(origin_path, origin_w, origin_h, thumb_width, thumb_height, format, thumb_info);
} else if (image_type == IMG_CODEC_JPEG) {
- if (is_req_raw == TRUE) {
- err = _media_thumb_jpeg_for_raw(origin_path, thumb_path, thumb_width, thumb_height, format, thumb_info);
- } else {
- err = _media_thumb_jpeg(origin_path, thumb_path, thumb_width, thumb_height, format, thumb_info);
- }
+ err = _media_thumb_jpeg(origin_path, thumb_path, thumb_width, thumb_height, format, thumb_info);
} else if (image_type == IMG_CODEC_PNG) {
err = _media_thumb_png(origin_path, thumb_width, thumb_height, format, thumb_info);
} else if (image_type == IMG_CODEC_GIF) {