summaryrefslogtreecommitdiff
path: root/server/thumb-server-internal.c
diff options
context:
space:
mode:
authorhj kim <backto.kim@samsung.com>2020-03-06 07:58:00 (GMT)
committerhj kim <backto.kim@samsung.com>2020-03-13 06:57:42 (GMT)
commit0c6efd9728efa22bb69b5b6a31ea05bea1e129d2 (patch)
tree77ac72d12cecf3a719867ff55f2daa5da61bfb7b /server/thumb-server-internal.c
parent7987cc930a4af11c432f21de47b826332590d8ca (diff)
downloadlibmedia-thumbnail-0c6efd9728efa22bb69b5b6a31ea05bea1e129d2.zip
libmedia-thumbnail-0c6efd9728efa22bb69b5b6a31ea05bea1e129d2.tar.gz
libmedia-thumbnail-0c6efd9728efa22bb69b5b6a31ea05bea1e129d2.tar.bz2
Create New APIs for Creating Image Thumbnailrefs/changes/09/226909/25
To unify duplicated thumbnail extracting codes in libmedia-service, libmedia-thumbnail and thumbnail-uti Change-Id: I4edd9296872b299d6d4fc218d284a6a3fa8f404c
Diffstat (limited to 'server/thumb-server-internal.c')
-rwxr-xr-xserver/thumb-server-internal.c43
1 files changed, 10 insertions, 33 deletions
diff --git a/server/thumb-server-internal.c b/server/thumb-server-internal.c
index d65adf7..294dc80 100755
--- a/server/thumb-server-internal.c
+++ b/server/thumb-server-internal.c
@@ -27,8 +27,6 @@
#include <fcntl.h>
#include <unistd.h>
#include <dirent.h>
-#include <stdio.h>
-#include <string.h>
#include <tzplatform_config.h>
#ifdef LOG_TAG
@@ -48,16 +46,14 @@ static int __thumbnail_get_data(const char *origin_path, char *thumb_path)
thumb_retvm_if(!origin_path, MS_MEDIA_ERR_INVALID_PARAMETER, "Original path is null");
thumb_retvm_if(!g_file_test(origin_path, G_FILE_TEST_IS_REGULAR), MS_MEDIA_ERR_INVALID_PARAMETER, "Original path(%s) does not exist", origin_path);
- thumb_dbg("Origin path : %s", origin_path);
+ thumb_dbg_slog("Origin path : %s", origin_path);
file_type = _media_thumb_get_file_type(origin_path);
if (file_type == THUMB_IMAGE_TYPE) {
- err = _media_thumb_image(origin_path, thumb_path, THUMB_DEFAULT_WIDTH, THUMB_DEFAULT_HEIGHT, NULL);
- thumb_retvm_if(err != MS_MEDIA_ERR_NONE, err, "_media_thumb_image failed");
+ err = create_image_thumbnail_to_file(origin_path, CONTENT_THUMB_DEFAULT_WIDTH, CONTENT_THUMB_DEFAULT_HEIGHT, thumb_path);
} else if (file_type == THUMB_VIDEO_TYPE) {
err = create_video_thumbnail_to_file(origin_path, CONTENT_THUMB_DEFAULT_WIDTH, CONTENT_THUMB_DEFAULT_HEIGHT, thumb_path, true);
- thumb_retvm_if(err != MS_MEDIA_ERR_NONE, err, "create_video_thumbnail_to_file failed");
} else {
thumb_err("invalid file type");
return MS_MEDIA_ERR_THUMB_UNSUPPORTED;
@@ -65,49 +61,30 @@ static int __thumbnail_get_data(const char *origin_path, char *thumb_path)
thumb_dbg("Thumb data is generated successfully");
- return MS_MEDIA_ERR_NONE;
+ return err;
}
static int __thumbnail_get_raw_data(const char *origin_path, unsigned int *width, unsigned int *height, unsigned char **data, size_t *size)
{
int err = MS_MEDIA_ERR_NONE;
- unsigned int thumb_width = 0;
- unsigned int thumb_height = 0;
-
- if (origin_path == NULL || *width == 0 || *height == 0) {
- thumb_err("Invalid parameter");
- return MS_MEDIA_ERR_INVALID_PARAMETER;
- }
+ int file_type = THUMB_NONE_TYPE;
- if (!g_file_test(origin_path, G_FILE_TEST_IS_REGULAR)) {
- thumb_err("Original path (%s) does not exist", origin_path);
- return MS_MEDIA_ERR_INVALID_PARAMETER;
- }
+ thumb_retvm_if(!origin_path, MS_MEDIA_ERR_INVALID_PARAMETER, "Original path is null");
+ thumb_retvm_if(!g_file_test(origin_path, G_FILE_TEST_IS_REGULAR), MS_MEDIA_ERR_INVALID_PARAMETER, "Original path(%s) does not exist", origin_path);
+ 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;
if (file_type == THUMB_IMAGE_TYPE) {
- err = _media_thumb_image(origin_path, NULL, thumb_width, thumb_height, &thumb_info);
- thumb_retvm_if(err != MS_MEDIA_ERR_NONE, err, "_media_thumb_image failed");
+ err = create_image_thumbnail_to_buffer(origin_path, *width, *height, data, size, width, height);
} else if (file_type == THUMB_VIDEO_TYPE) {
- err = create_video_thumbnail_to_buffer(origin_path, thumb_width, thumb_height,
- &thumb_info.data, &thumb_info.size, &thumb_info.width, &thumb_info.height, true);
- thumb_retvm_if(err != MS_MEDIA_ERR_NONE, err, "create_video_thumbnail_to_buffer failed");
+ err = create_video_thumbnail_to_buffer(origin_path, *width, *height, data, size, width, height, true);
} else {
thumb_err("invalid file type");
return MS_MEDIA_ERR_THUMB_UNSUPPORTED;
}
- if (size) *size = thumb_info.size;
- *data = thumb_info.data;
- *width = thumb_info.width;
- *height = thumb_info.height;
-
- return MS_MEDIA_ERR_NONE;
+ return err;
}
static int __media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg)