#define SAFE_FREE(src) {if(src) {free(src); src = NULL;}}
#define STRING_VALID(str) ((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
-typedef struct
-{
+typedef struct {
int request_id;
char *file_path;
int dst_width;
unsigned char *thumb_data;
}thumbnail_s;
-typedef struct
-{
+typedef struct {
thumbnail_s *handle;
thumbnail_extracted_cb thumb_extract_cb;
void *user_data;
#define thumbnail_util_gettid() syscall(__NR_gettid)
#define thumbnail_util_retv_if(expr, val) do { \
- if(expr) { \
- LOGE(FONT_COLOR_RED"[%d]", media_content_gettid()); \
- return (val); \
- } \
- } while (0)
+ if(expr) { \
+ LOGE(FONT_COLOR_RED"[%d]", media_content_gettid()); \
+ return (val); \
+ } \
+ } while (0)
#define thumbnail_util_debug(fmt, arg...) do { \
- LOGD(FONT_COLOR_RESET"[%d]"fmt"", thumbnail_util_gettid(), ##arg); \
- } while (0)
+ LOGD(FONT_COLOR_RESET"[%d]"fmt"", thumbnail_util_gettid(), ##arg); \
+ } while (0)
#define thumbnail_util_info(fmt, arg...) do { \
- LOGI(FONT_COLOR_GREEN"[%d]"fmt"", thumbnail_util_gettid() ,##arg); \
- } while (0)
+ LOGI(FONT_COLOR_GREEN"[%d]"fmt"", thumbnail_util_gettid() ,##arg); \
+ } while (0)
#define thumbnail_util_error(fmt, arg...) do { \
- LOGE(FONT_COLOR_RED"[%d]"fmt"",thumbnail_util_gettid(), ##arg); \
- } while (0)
+ LOGE(FONT_COLOR_RED"[%d]"fmt"",thumbnail_util_gettid(), ##arg); \
+ } while (0)
#define thumbnail_util_debug_func() do { \
- LOGD(FONT_COLOR_RESET"[%d]", thumbnail_util_gettid()); \
- } while (0)
+ LOGD(FONT_COLOR_RESET"[%d]", thumbnail_util_gettid()); \
+ } while (0)
#define thumbnail_util_sec_debug(fmt, arg...) do { \
- SECURE_LOGD(FONT_COLOR_RESET"[%d]"fmt"", thumbnail_util_gettid(), ##arg); \
- } while (0)
+ SECURE_LOGD(FONT_COLOR_RESET"[%d]"fmt"", thumbnail_util_gettid(), ##arg); \
+ } while (0)
#define thumbnail_util_sec_warn(fmt, arg...) do { \
- SECURE_LOGW(FONT_COLOR_GREEN"[%d]"fmt"",thumbnail_util_gettid(), ##arg); \
- } while (0)
+ SECURE_LOGW(FONT_COLOR_GREEN"[%d]"fmt"",thumbnail_util_gettid(), ##arg); \
+ } while (0)
#define thumbnail_util_sec_error(fmt, arg...) do { \
- SECURE_LOGE(FONT_COLOR_RED"[%d]"fmt"",thumbnail_util_gettid(), ##arg); \
- } while (0)
+ SECURE_LOGE(FONT_COLOR_RED"[%d]"fmt"",thumbnail_util_gettid(), ##arg); \
+ } while (0)
#ifdef __cplusplus
}
Name: capi-media-thumbnail-util
Summary: A media thumbnail util library in SLP C API
-Version: 0.1.0
+Version: 0.1.1
Release: 1
Group: System/Libraries
License: Apache-2.0
thumbnail_extract_cb_s *_thumb_cb = (thumbnail_extract_cb_s *)user_data;
char *request_id_str = NULL;
- if(_thumb_cb != NULL)
- {
- //media_content_debug("error [%d], thumbnail_size [%d]", error, thumb_size);
+ if (_thumb_cb != NULL) {
+ /*media_content_debug("error [%d], thumbnail_size [%d]", error, thumb_size); */
__thumbnail_util_convert_itoa(request_id, &request_id_str);
- if (_thumb_cb->thumb_extract_cb){
+ if (_thumb_cb->thumb_extract_cb) {
_thumb_cb->thumb_extract_cb(error, request_id_str, thumb_width, thumb_height, thumb_data, thumb_size, _thumb_cb->user_data);
}
}
{
int ret = THUMBNAIL_UTIL_ERROR_NONE;
- if(thumb == NULL)
- {
+ if (thumb == NULL) {
thumbnail_util_error("INVALID_PARAMETER(0x%08x)", THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER);
return THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER;
}
- thumbnail_s *_thumb = (thumbnail_s*)malloc(sizeof(thumbnail_s));
- if(_thumb == NULL)
- {
+ thumbnail_s *_thumb = (thumbnail_s *)malloc(sizeof(thumbnail_s));
+ if (_thumb == NULL) {
thumbnail_util_error("OUT_OF_MEMORY(0x%08x)", THUMBNAIL_UTIL_ERROR_OUT_OF_MEMORY);
return THUMBNAIL_UTIL_ERROR_OUT_OF_MEMORY;
}
{
int ret = THUMBNAIL_UTIL_ERROR_NONE;
static int g_thumbnail_req_id = 0;
- thumbnail_s *_thumb = (thumbnail_s*)thumb;
+ thumbnail_s *_thumb = (thumbnail_s *)thumb;
- if(_thumb != NULL && STRING_VALID(_thumb->file_path))
- {
+ if (_thumb != NULL && STRING_VALID(_thumb->file_path)) {
g_thumbnail_req_id++;
_thumb->request_id = g_thumbnail_req_id;
__thumbnail_util_convert_itoa(_thumb->request_id, request_id);
- thumbnail_extract_cb_s *_thumb_cb = (thumbnail_extract_cb_s*)calloc(1, sizeof(thumbnail_extract_cb_s));
+ thumbnail_extract_cb_s *_thumb_cb = (thumbnail_extract_cb_s *)calloc(1, sizeof(thumbnail_extract_cb_s));
_thumb_cb->handle = _thumb;
_thumb_cb->user_data = user_data;
- _thumb_cb->thumb_extract_cb= callback;
+ _thumb_cb->thumb_extract_cb = callback;
- if(_thumb->dst_width == 0 || _thumb->dst_height == 0)
- {
+ if (_thumb->dst_width == 0 || _thumb->dst_height == 0) {
_thumb->dst_width = 320;
_thumb->dst_height = 240;
}
ret = thumbnail_request_extract_raw_data_async(_thumb->request_id, _thumb->file_path, _thumb->dst_width, _thumb->dst_height, (ThumbRawFunc)__thumbnail_util_extract_completed_cb, (void *)_thumb_cb);
- }
- else
- {
+ } else {
thumbnail_util_error("INVALID_PARAMETER(0x%08x)", THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER);
ret = THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER;
}
int thumbnail_util_set_path(thumbnail_h thumb, const char *path)
{
int ret = THUMBNAIL_UTIL_ERROR_NONE;
- thumbnail_s *_thumb = (thumbnail_s*)thumb;
+ thumbnail_s *_thumb = (thumbnail_s *)thumb;
- if(_thumb != NULL && path != NULL)
- {
- if(_thumb->file_path)
+ if (_thumb != NULL && path != NULL) {
+ if (_thumb->file_path)
SAFE_FREE(_thumb->file_path);
_thumb->file_path = strndup(path, strlen(path));
- }
- else
- {
+ } else {
thumbnail_util_error("INVALID_PARAMETER(0x%08x)", THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER);
ret = THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER;
}
int thumbnail_util_set_size(thumbnail_h thumb, int width, int height)
{
int ret = THUMBNAIL_UTIL_ERROR_NONE;
- thumbnail_s *_thumb = (thumbnail_s*)thumb;
+ thumbnail_s *_thumb = (thumbnail_s *)thumb;
- if(_thumb != NULL && width > 0 && height > 0)
- {
+ if (_thumb != NULL && width > 0 && height > 0) {
_thumb->dst_width = width;
_thumb->dst_height = height;
- }
- else
- {
+ } else {
thumbnail_util_error("INVALID_PARAMETER(0x%08x)", THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER);
ret = THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER;
}
int thumbnail_util_cancel(thumbnail_h thumb, const char *request_id)
{
int ret = THUMBNAIL_UTIL_ERROR_NONE;
- thumbnail_s *_thumb = (thumbnail_s*)thumb;
+ thumbnail_s *_thumb = (thumbnail_s *)thumb;
- if(_thumb != NULL && STRING_VALID(request_id))
- {
+ if (_thumb != NULL && STRING_VALID(request_id)) {
unsigned int request_id_integer = atoi(request_id);
ret = thumbnail_request_cancel_raw_data(request_id_integer);
- }
- else
- {
+ } else {
thumbnail_util_error("INVALID_PARAMETER(0x%08x)", THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER);
ret = THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER;
}
int thumbnail_util_cancel_all(thumbnail_h thumb)
{
int ret = THUMBNAIL_UTIL_ERROR_NONE;
- thumbnail_s *_thumb = (thumbnail_s*)thumb;
+ thumbnail_s *_thumb = (thumbnail_s *)thumb;
- if(_thumb != NULL)
- {
+ if (_thumb != NULL) {
ret = thumbnail_request_cancel_all(true);
- }
- else
- {
+ } else {
thumbnail_util_error("INVALID_PARAMETER(0x%08x)", THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER);
ret = THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER;
}
int thumbnail_util_destroy(thumbnail_h thumb)
{
int ret = THUMBNAIL_UTIL_ERROR_NONE;
- thumbnail_s *_thumb = (thumbnail_s*)thumb;
+ thumbnail_s *_thumb = (thumbnail_s *)thumb;
- if(_thumb)
- {
+ if (_thumb) {
SAFE_FREE(_thumb->file_path);
SAFE_FREE(_thumb->thumb_data);
SAFE_FREE(_thumb);
- }
- else
- {
+ } else {
thumbnail_util_error("INVALID_PARAMETER(0x%08x)", THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER);
ret = THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER;
}
GMainLoop *g_loop = NULL;
char *g_id = NULL;
-void thumbnail_completed_cb(thumbnail_util_error_e error, const char *request_id, int raw_width, int raw_height, unsigned char *raw_data, int raw_size, void*user_data)
+void thumbnail_completed_cb(thumbnail_util_error_e error, const char *request_id, int raw_width, int raw_height, unsigned char *raw_data, int raw_size, void *user_data)
{
#if 0
FILE *fp;
- fp = fopen( "test.raw", "w");
- fwrite(raw_data, 1, raw_size, fp);
+ fp = fopen("test.raw", "w");
+ fwrite(raw_data, 1, raw_size, fp);
fclose(fp);
#endif
thumbnail_util_debug("=================[RESULT]");
thumbnail_util_debug("width [%d], height [%d]", raw_width, raw_height);
thumbnail_util_debug("raw_data [0x%x], size [%d]", *raw_data, raw_size);
- if(strncmp(request_id, "50", 2) == 0)
+ if (strncmp(request_id, "50", 2) == 0)
g_main_loop_quit(g_loop);
}
for (i = 0; i < 50; i++) {
char filepath[255] = {0,};
- snprintf(filepath, sizeof(filepath), "%s%d.jpg", "/opt/usr/media/Images/test_image", i+1);
+ snprintf(filepath, sizeof(filepath), "%s%d.jpg", "/opt/usr/media/Images/test_image", i + 1);
thumbnail_util_debug("File : %s\n", filepath);
thumbnail_util_set_path(test_info, filepath);
ret = thumbnail_util_extract(test_info, thumbnail_completed_cb, test_info, &g_id);
thumbnail_h test_info;
thumbnail_util_create(&test_info);
thumbnail_util_set_path(test_info, "/opt/usr/media/Images/test_image1.jpg");
- //thumbnail_util_set_size(test_info, 511, 288);
+ /*thumbnail_util_set_size(test_info, 511, 288); */
ret = thumbnail_util_extract(test_info, thumbnail_completed_cb, test_info, &g_id);
#endif
thumbnail_util_destroy(test_info);
- if(ret == THUMBNAIL_UTIL_ERROR_NONE)
+ if (ret == THUMBNAIL_UTIL_ERROR_NONE)
thumbnail_util_debug("extract raw data is success");
else
thumbnail_util_error("extract raw data is failed");
#if 0
ret = thumbnail_util_cancel_all(_media_thumb);
- if(ret == THUMBNAIL_UTIL_ERROR_NONE)
+ if (ret == THUMBNAIL_UTIL_ERROR_NONE)
thumbnail_util_debug("thumbnail_util_cancel_all is success");
else
thumbnail_util_error("thumbnail_util_cancel_all is failed");
for (i = num - 20; i < num; i++) {
__convert_i_to_a(i, &req_str);
ret = thumbnail_util_cancel(_media_thumb, req_str);
- if(ret == THUMBNAIL_UTIL_ERROR_NONE)
+ if (ret == THUMBNAIL_UTIL_ERROR_NONE)
thumbnail_util_debug("thumbnail_util_cancel[%d] is success", i);
else
thumbnail_util_error("thumbnail_util_cancel[%d] is failed", i);
g_loop = g_main_loop_new(NULL, false);
context = g_main_loop_get_context(g_loop);
source = g_idle_source_new();
- g_source_set_callback (source, extract_thumbnail_start, NULL, NULL);
- g_source_attach (source, context);
+ g_source_set_callback(source, extract_thumbnail_start, NULL, NULL);
+ g_source_attach(source, context);
/* Logic to cancel */
if (cancel) {
GSource *cancel_src = NULL;
cancel_src = g_idle_source_new();
- g_source_set_callback (cancel_src, cancel_all, NULL, NULL);
- g_source_attach (cancel_src, context);
+ g_source_set_callback(cancel_src, cancel_all, NULL, NULL);
+ g_source_attach(cancel_src, context);
}
g_main_loop_run(g_loop);
thumbnail_util_debug("--- Thumbnail util test start ---\n\n");
ret = test_extract_thumbnail(false);
- if(ret != THUMBNAIL_UTIL_ERROR_NONE)
+ if (ret != THUMBNAIL_UTIL_ERROR_NONE)
return ret;
thumbnail_util_debug("--- Thumbnail util test end ---\n");