#include "tct_common.h"
#include <glib.h>
-#include <limits.h>
#include <thumbnail_util.h>
#define THUMB_WIDTH 320
#define THUMB_HEIGHT 240
-#define API_NAMESPACE "[THUMBNAIL-UTIL]"
-
static int _retv = 0;
-static const char *image = "res/sample.jpg";
-static const char *video = "res/sample.mp4";
-static const char *unsupported_image = "res/sample.tif";
-static const char *thumb = "res/thumbnail.jpg";
-static const char *unsupported_thumb = "res/thumbnail.png";
-
-static char g_image_path[PATH_MAX + 1] = { 0, };
-static char g_video_path[PATH_MAX + 1] = { 0, };
-static char g_unsupported_image_path[PATH_MAX + 1] = { 0, };
-static char g_thumb_path[PATH_MAX + 1] = { 0, };
-static char g_unsupported_thumb_path[PATH_MAX + 1] = { 0, };
-
-GSource *source = NULL;
-GMainContext *context = NULL;
+
+static char *g_image_path;
+static char *g_video_path;
+static char *g_unsupported_image_path;
+static char *g_thumb_path;
+static char *g_unsupported_thumb_path;
+
GMainLoop *g_loop = NULL;
/**
{
char pszValue[CONFIG_VALUE_LEN_MAX] = { 0, };
- if (true == GetValueForTCTSetting("DEVICE_SUITE_TARGET_30", pszValue, API_NAMESPACE)) {
- PRINT_UTC_LOG("[Line : %d][%s] 'DEVICE_SUITE_TARGET_30' Values Received = %s\\n", __LINE__, API_NAMESPACE, pszValue);
-
- snprintf(g_image_path, PATH_MAX, "%s/%s", pszValue, image);
- snprintf(g_video_path, PATH_MAX, "%s/%s", pszValue, video);
- snprintf(g_unsupported_image_path, PATH_MAX, "%s/%s", pszValue, unsupported_image);
- snprintf(g_thumb_path, PATH_MAX, "%s/%s", pszValue, thumb);
- snprintf(g_unsupported_thumb_path, PATH_MAX, "%s/%s", pszValue, unsupported_thumb);
- } else {
- PRINT_UTC_LOG("[Line : %d][%s] GetValueForTCTSetting returned error for 'DEVICE_SUITE_TARGET_30'\\n", __LINE__, API_NAMESPACE);
+ if (!GetValueForTCTSetting("DEVICE_SUITE_TARGET_30", pszValue, "[THUMBNAIL-UTIL]")) {
+ FPRINTF("[Line : %d] GetValueForTCTSetting failed\\n", __LINE__);
+ return;
}
+
+ g_image_path = g_strdup_printf("%s/res/sample.jpg", pszValue);
+ g_video_path = g_strdup_printf("%s/res/sample.mp4", pszValue);
+ g_unsupported_image_path = g_strdup_printf("%s/res/sample.tif", pszValue);
+ g_thumb_path = g_strdup_printf("%s/res/thumbnail.jpg", pszValue);
+ g_unsupported_thumb_path = g_strdup_printf("%s/res/thumbnail.png", pszValue);
}
/**
*/
void utc_thumbnail_util_cleanup(void)
{
- memset(&g_image_path, 0, PATH_MAX + 1);
- memset(&g_video_path, 0, PATH_MAX + 1);
- memset(&g_unsupported_image_path, 0, PATH_MAX + 1);
- memset(&g_thumb_path, 0, PATH_MAX + 1);
- memset(&g_unsupported_thumb_path, 0, PATH_MAX + 1);
+ FREE_MEMORY(g_image_path);
+ FREE_MEMORY(g_video_path);
+ FREE_MEMORY(g_unsupported_image_path);
+ FREE_MEMORY(g_thumb_path);
+ FREE_MEMORY(g_unsupported_thumb_path);
}
/**
return 0;
}
-void thumbnail_completed_cb(thumbnail_util_error_e e, const char *id, int width, int height, unsigned char *data, int size, void *user_data)
+static void __completed_cb(thumbnail_util_error_e e, const char *id, int width, int height, unsigned char *data, int size, void *user_data)
{
_retv = e;
- PRINT_UTC_LOG("[Line : %d][%s] thumbnail_completed_cb returned %d(%0x) error\\n", __LINE__, API_NAMESPACE, e, e);
g_main_loop_quit(g_loop);
}
-gboolean extract_thumbnail_start(gpointer data)
+static gboolean __extract_cb(gpointer data)
{
int ret = THUMBNAIL_UTIL_ERROR_NONE;
char *request_id = NULL;
if (ret != THUMBNAIL_UTIL_ERROR_NONE)
goto FINALIZE;
- ret = thumbnail_util_extract(test_info, thumbnail_completed_cb, NULL, &request_id);
+ ret = thumbnail_util_extract(test_info, __completed_cb, NULL, &request_id);
FREE_MEMORY(request_id);
FINALIZE:
ret = thumbnail_util_create(&test_info);
assert_eq(ret, THUMBNAIL_UTIL_ERROR_NONE);
- ret = thumbnail_util_extract(test_info, thumbnail_completed_cb, NULL, &request_id);
+ ret = thumbnail_util_extract(test_info, __completed_cb, NULL, &request_id);
assert_eq(ret, THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER);
FREE_MEMORY(request_id);
*/
int utc_thumbnail_util_extract_n2(void)
{
- 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, (gpointer) g_unsupported_image_path, NULL);
- g_source_attach(source, context);
+ g_loop = g_main_loop_new(NULL, FALSE);
+ g_idle_add(__extract_cb, (gpointer) g_unsupported_image_path);
g_main_loop_run(g_loop);
g_main_loop_unref(g_loop);
*/
int utc_thumbnail_util_extract_p(void)
{
- 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, (gpointer) g_image_path, NULL);
- g_source_attach(source, context);
+ g_loop = g_main_loop_new(NULL, FALSE);
+ g_idle_add(__extract_cb, (gpointer) g_image_path);
g_main_loop_run(g_loop);
g_main_loop_unref(g_loop);
return 0;
}
-void thumbnail_cancel_cb(thumbnail_util_error_e e, const char *id, int width, int height, unsigned char *data, int size, void *user_data)
+static void __cancel_cb(thumbnail_util_error_e e, const char *id, int width, int height, unsigned char *data, int size, void *user_data)
{
}
thumbnail_util_set_path(test_info, g_image_path);
thumbnail_util_set_size(test_info, THUMB_WIDTH, THUMB_HEIGHT);
- ret = thumbnail_util_extract(test_info, thumbnail_cancel_cb, NULL, &request_id);
+ ret = thumbnail_util_extract(test_info, __cancel_cb, NULL, &request_id);
FREE_MEMORY(request_id);
- ret = thumbnail_util_extract(test_info, thumbnail_cancel_cb, NULL, &request_id);
+ ret = thumbnail_util_extract(test_info, __cancel_cb, NULL, &request_id);
assert_eq(ret, THUMBNAIL_UTIL_ERROR_NONE);
ret = thumbnail_util_cancel(test_info, request_id);