summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHyunjun Ko <zzoon.ko@samsung.com>2012-08-31 14:31:35 +0900
committerHyunjun Ko <zzoon.ko@samsung.com>2012-08-31 14:31:35 +0900
commitc4043803b6d52accd65b8dc5db02db58a0602cf7 (patch)
tree608d1b6c773e4fad2f45987e0fa3abeab109998d
parent1bc0fe7e1b8ca4a7c6068448241d32fdfece06cc (diff)
downloadlibmedia-thumbnail-c4043803b6d52accd65b8dc5db02db58a0602cf7.tar.gz
libmedia-thumbnail-c4043803b6d52accd65b8dc5db02db58a0602cf7.tar.bz2
libmedia-thumbnail-c4043803b6d52accd65b8dc5db02db58a0602cf7.zip
Update to the latest
-rw-r--r--packaging/libmedia-thumbnail.spec3
-rwxr-xr-xsrc/include/ipc/media-thumb-ipc.h3
-rwxr-xr-xsrc/include/util/media-thumb-util.h3
-rwxr-xr-xsrc/ipc/media-thumb-ipc.c55
-rwxr-xr-xsrc/media-thumbnail.c26
-rwxr-xr-xsrc/util/media-thumb-util.c14
6 files changed, 83 insertions, 21 deletions
diff --git a/packaging/libmedia-thumbnail.spec b/packaging/libmedia-thumbnail.spec
index c9c13bd..9d79991 100644
--- a/packaging/libmedia-thumbnail.spec
+++ b/packaging/libmedia-thumbnail.spec
@@ -1,6 +1,7 @@
+#sbs-git:slp/pkgs/l/libmedia-thumbnail libmedia-thumbnail 0.1.32 a6b6cb2f372f6a8cca44ef50813ad0300d34a9de
Name: libmedia-thumbnail
Summary: Media thumbnail service library for multimedia applications.
-Version: 0.1.42
+Version: 0.1.44
Release: 0
Group: utils
License: Apache
diff --git a/src/include/ipc/media-thumb-ipc.h b/src/include/ipc/media-thumb-ipc.h
index 7c9f6b0..31b707f 100755
--- a/src/include/ipc/media-thumb-ipc.h
+++ b/src/include/ipc/media-thumb-ipc.h
@@ -37,7 +37,8 @@
#define _MEDIA_THUMB_IPC_H_
#define THUMB_DAEMON_PORT 10000
-#define MAX_PATH_SIZE 4096
+//#define MAX_PATH_SIZE 4096
+#define MAX_PATH_SIZE 2048
#define TIMEOUT_SEC 10
#define MAX_TRIES 3
diff --git a/src/include/util/media-thumb-util.h b/src/include/util/media-thumb-util.h
index 8b455b5..824ff67 100755
--- a/src/include/util/media-thumb-util.h
+++ b/src/include/util/media-thumb-util.h
@@ -62,6 +62,9 @@ _media_thumb_get_file_ext(const char *file_path, char *file_ext, int max_len);
int
_media_thumb_get_file_type(const char *file_full_path);
+int
+_media_thumb_remove_file(const char *path);
+
char
*_media_thumb_generate_hash_name(const char *file);
diff --git a/src/ipc/media-thumb-ipc.c b/src/ipc/media-thumb-ipc.c
index 2504480..fd34f54 100755
--- a/src/ipc/media-thumb-ipc.c
+++ b/src/ipc/media-thumb-ipc.c
@@ -182,6 +182,7 @@ _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg)
int origin_h = 0;
int max_length = 0;
char *thumb_path = NULL;
+ int need_update_db = 0;
if (req_msg == NULL || res_msg == NULL) {
thumb_err("Invalid msg!");
@@ -195,27 +196,57 @@ _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg)
media_thumb_format thumb_format = MEDIA_THUMB_BGRA;
thumb_path = res_msg->dst_path;
+ thumb_path[0] = '\0';
max_length = sizeof(res_msg->dst_path);
+ err = _media_thumb_db_connect();
+ if (err < 0) {
+ thumb_err("_media_thumb_mb_svc_connect failed: %d", err);
+ return MEDIA_THUMB_ERROR_DB;
+ }
+
if (msg_type == THUMB_REQUEST_DB_INSERT) {
+ err = _media_thumb_get_thumb_from_db_with_size(origin_path, thumb_path, max_length, &need_update_db, &origin_w, &origin_h);
+ if (err == 0) {
+ res_msg->origin_width = origin_w;
+ res_msg->origin_width = origin_h;
+ _media_thumb_db_disconnect();
+ return MEDIA_THUMB_ERROR_NONE;
+ } else {
+ if (strlen(thumb_path) == 0) {
+ err = _media_thumb_get_hash_name(origin_path, thumb_path, max_length);
+ if (err < 0) {
+ thumb_err("_media_thumb_get_hash_name failed - %d\n", err);
+ strncpy(thumb_path, THUMB_DEFAULT_PATH, max_length);
+ _media_thumb_db_disconnect();
+ return err;
+ }
+
+ thumb_path[strlen(thumb_path)] = '\0';
+ }
+ }
+
+ } else if (msg_type == THUMB_REQUEST_SAVE_FILE) {
+ 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);
if (err < 0) {
thumb_err("_media_thumb_get_hash_name failed - %d\n", err);
strncpy(thumb_path, THUMB_DEFAULT_PATH, max_length);
+ _media_thumb_db_disconnect();
return err;
}
thumb_path[strlen(thumb_path)] = '\0';
- } else if (msg_type == THUMB_REQUEST_SAVE_FILE) {
- strncpy(thumb_path, req_msg->dst_path, max_length);
}
thumb_dbg("Thumb path : %s", thumb_path);
if (g_file_test(thumb_path,
G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
- thumb_warn("thumb path already exists in file system");
- return 0;
+ thumb_warn("thumb path already exists in file system.. remove the existed file");
+ _media_thumb_remove_file(thumb_path);
}
err = _thumbnail_get_data(origin_path, thumb_type, thumb_format, &data, &thumb_size, &thumb_w, &thumb_h, &origin_w, &origin_h);
@@ -224,6 +255,7 @@ _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg)
SAFE_FREE(data);
strncpy(thumb_path, THUMB_DEFAULT_PATH, max_length);
+ _media_thumb_db_disconnect();
return err;
}
@@ -243,9 +275,10 @@ _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg)
thumb_err("save_to_file_with_evas failed - %d\n", err);
SAFE_FREE(data);
- if (msg_type == THUMB_REQUEST_DB_INSERT)
+ if (msg_type == THUMB_REQUEST_DB_INSERT || msg_type == THUMB_REQUEST_ALL_MEDIA)
strncpy(thumb_path, THUMB_DEFAULT_PATH, max_length);
+ _media_thumb_db_disconnect();
return err;
} else {
thumb_dbg("file save success\n");
@@ -267,7 +300,17 @@ _media_thumb_process(thumbMsg *req_msg, thumbMsg *res_msg)
/* End of fsync */
SAFE_FREE(data);
-
+
+ /* 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);
+ if (err < 0) {
+ thumb_err("_media_thumb_update_db failed : %d", err);
+ }
+ }
+
+ _media_thumb_db_disconnect();
+
return 0;
}
diff --git a/src/media-thumbnail.c b/src/media-thumbnail.c
index 1030279..3e4d3aa 100755
--- a/src/media-thumbnail.c
+++ b/src/media-thumbnail.c
@@ -24,14 +24,14 @@
#include "media-thumb-util.h"
#include "media-thumb-internal.h"
#include "media-thumb-ipc.h"
-#include "media-thumb-db.h"
+//#include "media-thumb-db.h"
#include <glib.h>
int thumbnail_request_from_db(const char *origin_path, char *thumb_path, int max_length)
{
int err = -1;
- int need_update_db = 0;
+ //int need_update_db = 0;
media_thumb_info thumb_info;
if (origin_path == NULL || thumb_path == NULL) {
@@ -59,7 +59,7 @@ int thumbnail_request_from_db(const char *origin_path, char *thumb_path, int max
}
thumb_err("Path : %s", origin_path);
-
+/*
err = _media_thumb_db_connect();
if (err < 0) {
thumb_err("_media_thumb_mb_svc_connect failed: %d", err);
@@ -71,16 +71,16 @@ int thumbnail_request_from_db(const char *origin_path, char *thumb_path, int max
_media_thumb_db_disconnect();
return MEDIA_THUMB_ERROR_NONE;
}
-
+*/
/* Request for thumb file to the daemon "Thumbnail generator" */
err = _media_thumb_request(THUMB_REQUEST_DB_INSERT, MEDIA_THUMB_LARGE, origin_path, thumb_path, max_length, &thumb_info);
if (err < 0) {
thumb_err("_media_thumb_request failed : %d", err);
- _media_thumb_db_disconnect();
+ //_media_thumb_db_disconnect();
return err;
}
-
- /* Need to update DB once generating thumb is done */
+/*
+ // Need to update DB once generating thumb is done
if (need_update_db) {
err = _media_thumb_update_db(origin_path, thumb_path, thumb_info.origin_width, thumb_info.origin_height);
if (err < 0) {
@@ -89,6 +89,7 @@ int thumbnail_request_from_db(const char *origin_path, char *thumb_path, int max
}
_media_thumb_db_disconnect();
+*/
return MEDIA_THUMB_ERROR_NONE;
}
@@ -119,8 +120,7 @@ int thumbnail_request_save_to_file(const char *origin_path, media_thumb_type thu
int thumbnail_request_from_db_with_size(const char *origin_path, char *thumb_path, int max_length, int *origin_width, int *origin_height)
{
int err = -1;
- int need_update_db = 0;
- int width, height = 0;
+ //int need_update_db = 0;
media_thumb_info thumb_info;
if (origin_path == NULL || thumb_path == NULL) {
@@ -153,7 +153,7 @@ int thumbnail_request_from_db_with_size(const char *origin_path, char *thumb_pat
}
thumb_err("Path : %s", origin_path);
-
+/*
err = _media_thumb_db_connect();
if (err < 0) {
thumb_err("_media_thumb_mb_svc_connect failed: %d", err);
@@ -165,19 +165,19 @@ int thumbnail_request_from_db_with_size(const char *origin_path, char *thumb_pat
_media_thumb_db_disconnect();
return MEDIA_THUMB_ERROR_NONE;
}
-
+*/
/* Request for thumb file to the daemon "Thumbnail generator" */
err = _media_thumb_request(THUMB_REQUEST_DB_INSERT, MEDIA_THUMB_LARGE, origin_path, thumb_path, max_length, &thumb_info);
if (err < 0) {
thumb_err("_media_thumb_request failed : %d", err);
- _media_thumb_db_disconnect();
+ //_media_thumb_db_disconnect();
return err;
}
*origin_width = thumb_info.origin_width;
*origin_height = thumb_info.origin_height;
- _media_thumb_db_disconnect();
+ //_media_thumb_db_disconnect();
return MEDIA_THUMB_ERROR_NONE;
}
diff --git a/src/util/media-thumb-util.c b/src/util/media-thumb-util.c
index 88473ac..5029e36 100755
--- a/src/util/media-thumb-util.c
+++ b/src/util/media-thumb-util.c
@@ -181,6 +181,20 @@ int _media_thumb_get_store_type_by_path(const char *full_path)
return -1;
}
+int _media_thumb_remove_file(const char *path)
+{
+ int result = -1;
+
+ result = remove(path);
+ if (result == 0) {
+ thumb_dbg("success to remove file");
+ return TRUE;
+ } else {
+ thumb_err("fail to remove file[%s] result errno = %s", path, strerror(errno));
+ return FALSE;
+ }
+}
+
int
_media_thumb_get_hash_name(const char *file_full_path,
char *thumb_hash_path, size_t max_thumb_path)