summaryrefslogtreecommitdiff
path: root/src/include/util
diff options
context:
space:
mode:
authorJinkun Jang <jinkun.jang@samsung.com>2013-03-13 01:49:53 +0900
committerJinkun Jang <jinkun.jang@samsung.com>2013-03-13 01:49:53 +0900
commitb8ccdef0306cf19cde9511ec244fd43b4ae1d863 (patch)
treeedfb6fbb5a168525e60cbcf918d84217bd667586 /src/include/util
parent06e2dff413544d0e1465e0cb4897fe32e4de2c22 (diff)
downloadlibmedia-thumbnail-b8ccdef0306cf19cde9511ec244fd43b4ae1d863.tar.gz
libmedia-thumbnail-b8ccdef0306cf19cde9511ec244fd43b4ae1d863.tar.bz2
libmedia-thumbnail-b8ccdef0306cf19cde9511ec244fd43b4ae1d863.zip
Tizen 2.1 base
Diffstat (limited to 'src/include/util')
-rwxr-xr-xsrc/include/util/media-thumb-db.h79
-rwxr-xr-xsrc/include/util/media-thumb-debug.h81
-rwxr-xr-xsrc/include/util/media-thumb-util.h146
3 files changed, 306 insertions, 0 deletions
diff --git a/src/include/util/media-thumb-db.h b/src/include/util/media-thumb-db.h
new file mode 100755
index 0000000..f8e37f9
--- /dev/null
+++ b/src/include/util/media-thumb-db.h
@@ -0,0 +1,79 @@
+/*
+ * libmedia-thumbnail
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include <sqlite3.h>
+#include <media-util.h>
+#include "media-thumb-error.h"
+#include "media-thumb-types.h"
+#include "media-thumb-debug.h"
+
+#ifndef _MEDIA_THUMB_DB_H_
+#define _MEDIA_THUMB_DB_H_
+
+#define MEDIA_DATABASE_NAME MEDIA_DB_NAME /* defined in media-util.h */
+
+#ifndef _USE_NEW_MEDIA_DB_
+#define SELECT_PATH_FROM_UNEXTRACTED_THUMB_MEDIA "SELECT path from visual_media where thumbnail_path='' and valid=1;"
+#define SELECT_MEDIA_BY_PATH "SELECT thumbnail_path FROM visual_media WHERE path='%q';"
+#define SELECT_TYPE_BY_PATH "SELECT content_type FROM visual_media WHERE path='%q';"
+#define UPDATE_THUMB_BY_PATH "UPDATE visual_media SET thumbnail_path = '%q' WHERE path='%q';"
+#define UPDATE_WH_BY_PATH "UPDATE image_meta SET width=%d,height=%d WHERE visual_uuid=(SELECT visual_uuid FROM visual_media WHERE path='%q');"
+
+#else
+#define SELECT_PATH_FROM_UNEXTRACTED_THUMB_MEDIA "SELECT path from media where thumbnail_path is null and validity=1 and (media_type=0 or media_type=1);"
+#define SELECT_MEDIA_BY_PATH "SELECT thumbnail_path FROM media WHERE path='%q';"
+#define SELECT_TYPE_BY_PATH "SELECT media_type FROM media WHERE path='%q';"
+#define SELECT_WH_BY_PATH "SELECT width, height FROM media WHERE path='%q';"
+#define UPDATE_THUMB_BY_PATH "UPDATE media SET thumbnail_path = '%q' WHERE path='%q';"
+#define UPDATE_WH_BY_PATH "UPDATE media SET width=%d,height=%d WHERE path='%q';"
+#define UPDATE_THUMB_WH_BY_PATH "UPDATE media SET thumbnail_path = '%q', width=%d,height=%d WHERE path='%q';"
+#endif
+
+sqlite3 *_media_thumb_db_get_handle();
+
+int
+_media_thumb_db_connect();
+
+int
+_media_thumb_db_disconnect();
+
+int
+_media_thumb_get_thumb_from_db(const char *origin_path,
+ char *thumb_path,
+ int max_length,
+ int *need_update_db);
+
+int
+_media_thumb_get_thumb_from_db_with_size(const char *origin_path,
+ char *thumb_path,
+ int max_length,
+ int *need_update_db,
+ int *width,
+ int *height);
+
+int
+_media_thumb_update_db(const char *origin_path,
+ char *thumb_path,
+ int width,
+ int height);
+
+#endif /*_MEDIA_THUMB_DB_H_*/
+
diff --git a/src/include/util/media-thumb-debug.h b/src/include/util/media-thumb-debug.h
new file mode 100755
index 0000000..65ca53f
--- /dev/null
+++ b/src/include/util/media-thumb-debug.h
@@ -0,0 +1,81 @@
+/*
+ * libmedia-thumbnail
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#ifndef _MEDIA_THUMB_DEBUG_H_
+#define _MEDIA_THUMB_DEBUG_H_
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <dlog.h>
+
+#include <unistd.h>
+#include <asm/unistd.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+
+#define _PERFORMANCE_CHECK_
+
+
+#define LOG_TAG "MEDIA_THUMBNAIL"
+
+static pid_t gettid(void)
+{
+ return syscall(__NR_gettid);
+}
+
+#define FONT_COLOR_RESET "\033[0m"
+#define FONT_COLOR_RED "\033[31m"
+#define FONT_COLOR_GREEN "\033[32m"
+#define FONT_COLOR_YELLOW "\033[33m"
+#define FONT_COLOR_BLUE "\033[34m"
+#define FONT_COLOR_PURPLE "\033[35m"
+#define FONT_COLOR_CYAN "\033[36m"
+#define FONT_COLOR_GRAY "\033[37m"
+
+#define thumb_dbg(fmt, arg...) LOGD(FONT_COLOR_RESET"[%d] " fmt "\n", gettid(), ##arg)
+#define thumb_warn(fmt, arg...) LOGW(FONT_COLOR_GREEN"[%d] " fmt "\n", gettid(), ##arg)
+#define thumb_err(fmt, arg...) LOGE(FONT_COLOR_RED"[%d] " fmt "\n", gettid(), ##arg)
+
+#ifdef _USE_LOG_FILE_
+void thumb_init_file_debug();
+void thumb_close_file_debug();
+FILE* get_fp();
+#define thumb_file_dbg(fmt,arg...) fprintf( get_fp(), "[%s: %d] " fmt "\n", __FUNCTION__, __LINE__, ##arg)
+
+#endif
+
+
+#ifdef _PERFORMANCE_CHECK_
+long
+thumb_get_debug_time(void);
+void
+thumb_reset_debug_time(void);
+void
+thumb_print_debug_time(char* time_string);
+void
+thumb_print_debug_time_ex(long start, long end, const char* func_name, char* time_string);
+#endif
+
+#endif /*_MEDIA_THUMB_DEBUG_H_*/
+
diff --git a/src/include/util/media-thumb-util.h b/src/include/util/media-thumb-util.h
new file mode 100755
index 0000000..335c4a5
--- /dev/null
+++ b/src/include/util/media-thumb-util.h
@@ -0,0 +1,146 @@
+/*
+ * libmedia-thumbnail
+ *
+ * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+ *
+ * Contact: Hyunjun Ko <zzoon.ko@samsung.com>
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+#include "media-thumb-error.h"
+#include "media-thumb-types.h"
+#include "media-thumb-debug.h"
+#include "media-util.h"
+
+#ifndef _MEDIA_THUMB_UTIL_H_
+#define _MEDIA_THUMB_UTIL_H_
+
+#define SAFE_FREE(src) { if(src) {free(src); src = NULL;}}
+
+#ifndef _USE_NEW_MEDIA_DB_
+#define THUMB_NONE_TYPE 0x00000000 /* None */
+#define THUMB_IMAGE_TYPE 0x00000001 /* Image */
+#define THUMB_VIDEO_TYPE 0x00000002 /* Video */
+#else
+#define THUMB_NONE_TYPE -1 /* None */
+#define THUMB_IMAGE_TYPE 0 /* Image */
+#define THUMB_VIDEO_TYPE 1 /* Video */
+#endif
+
+#define THUMB_PATH_PHONE MEDIA_ROOT_PATH_INTERNAL /**< File path prefix of files stored in phone */
+#define THUMB_PATH_MMC MEDIA_ROOT_PATH_SDCARD /**< File path prefix of files stored in mmc card */
+
+#define THUMB_PHONE_PATH MEDIA_DATA_PATH"/.thumb/phone"
+#define THUMB_MMC_PATH MEDIA_DATA_PATH"/.thumb/mmc"
+
+#define THUMB_DEFAULT_PATH MEDIA_DATA_PATH"/.thumb/thumb_default.png"
+
+typedef enum
+{
+ THUMB_PHONE, /**< Stored only in phone */
+ THUMB_MMC /**< Stored only in MMC */
+} media_thumb_store_type;
+
+int _media_thumb_get_length(media_thumb_type thumb_type);
+
+int _media_thumb_get_store_type_by_path(const char *full_path);
+
+int
+_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);
+
+int
+_media_thumb_get_hash_name(const char *file_full_path,
+ char *thumb_hash_path, size_t max_thumb_path);
+
+int
+_media_thumb_save_to_file_with_evas(unsigned char *data,
+ int w,
+ int h,
+ int alpha,
+ char *thumb_path);
+
+int
+_media_thumb_get_width(media_thumb_type thumb_type);
+
+int
+_media_thumb_get_height(media_thumb_type thumb_type);
+
+/**
+ * _thumbnail_get_data:
+ * This function generates thumbnail raw data, which is wanted by user
+ * This api is closed for a while until being independent from evas object to be thread-safe
+ *
+ * @return This function returns zero(MEDIA_THUMB_ERROR_NONE) on success, or negative value with error code.
+ * Please refer 'media-thumb-error.h' to know the exact meaning of the error.
+ * @param[in] origin_path The path of the original image
+ * @param[in] thumb_type The type of the returned thumbnail data
+ * @param[in] format The format of the returned data
+ * @param[out] data The data of generated thumbnail.
+ * @param[out] size The size of generated thumbnail.
+ * @param[out] width The width of generated thumbnail.
+ * @param[out] height The height of generated thumbnail.
+ * @param[out] origin_width The width of original image.
+ * @param[out] origin_height The height of original image.
+ * @see None.
+ * @pre None.
+ * @post None.
+ * @remark None.
+ * @par example
+ * @code
+
+#include <media-thumbnail.h>
+
+void test_get_thumb_data()
+{
+ int ret = MEDIA_THUMB_ERROR_NONE;
+ int thumb_type = 0;
+ const char *origin_path = "/opt/usr/media/test.jpg";
+ void *data = NULL;
+
+
+ ret = _thumbnail_get_data(origin_path, thumb_type, thumb_path, &data);
+
+ if (ret < 0)
+ {
+ printf( "_thumbnail_get_data fails. error code->%d", ret);
+ }
+
+ return;
+}
+
+ * @endcode
+*/
+int _thumbnail_get_data(const char *origin_path,
+ media_thumb_type thumb_type,
+ media_thumb_format format,
+ unsigned char **data,
+ int *size,
+ int *width,
+ int *height,
+ int *origin_width,
+ int *origin_height,
+ int *alpha);
+
+#endif /*_MEDIA_THUMB_UTIL_H_*/
+