Initialize package. 75/40475/2
authorMinje Ahn <minje.ahn@samsung.com>
Thu, 4 Jun 2015 06:39:02 +0000 (15:39 +0900)
committerMinje Ahn <minje.ahn@samsung.com>
Mon, 8 Jun 2015 00:47:47 +0000 (09:47 +0900)
Change-Id: I6383e15518c9fccff8af952bc83d3e7439acac8b
Signed-off-by: Minje Ahn <minje.ahn@samsung.com>
14 files changed:
AUTHORS [new file with mode: 0755]
CMakeLists.txt [new file with mode: 0755]
LICENSE.APLv2.0 [new file with mode: 0755]
NOTICE [new file with mode: 0644]
capi-media-thumbnail-util.manifest [new file with mode: 0755]
capi-media-thumbnail-util.pc.in [new file with mode: 0755]
doc/thumbnail_util_doc.h [new file with mode: 0755]
include/thumbnail_util.h [new file with mode: 0755]
include/thumbnail_util_private.h [new file with mode: 0755]
include/thumbnail_util_type.h [new file with mode: 0755]
packaging/capi-media-thumbnail-util.spec [new file with mode: 0755]
src/thumbnail_util.c [new file with mode: 0755]
test/CMakeLists.txt [new file with mode: 0755]
test/thumbnail_util_test.c [new file with mode: 0755]

diff --git a/AUTHORS b/AUTHORS
new file mode 100755 (executable)
index 0000000..4fe6589
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1 @@
+Haejeong Kim <backto.kim at samsung dot com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..5dd6f4a
--- /dev/null
@@ -0,0 +1,114 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+
+SET(Services
+        "application"
+        "base"
+        "content"
+        "location"
+        "media"
+        "messaging"
+        "network"
+        "social"
+        "telephony"
+        "system"
+   )
+
+
+# project
+SET(project_prefix "capi")
+SET(prefix "/usr")
+SET(version "0.0.1")
+SET(maintainer "Haejeong Kim <backto.kim@samsung.com>")
+SET(description "A Thumbnail Extractor library in Tizen Native API")
+SET(service "media")
+SET(submodule "thumbnail-util")
+
+# for package file
+SET(dependents "dlog glib-2.0 capi-base-common media-thumbnail libmedia-utils")
+SET(fw_name "${project_prefix}-${service}-${submodule}")
+
+PROJECT(${fw_name})
+
+SET(CMAKE_INSTALL_PREFIX ${prefix})
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+SET(VERSION ${version})
+
+SET(INC_DIR include)
+INCLUDE_DIRECTORIES(${INC_DIR})
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${fw_name} REQUIRED ${dependents})
+FOREACH(flag ${${fw_name}_CFLAGS})
+    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror")
+SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
+
+IF("${ARCH}" MATCHES "^arm.*")
+    ADD_DEFINITIONS("-DTARGET")
+ENDIF("${ARCH}" MATCHES "^arm.*")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DTIZEN_DEBUG")
+ADD_DEFINITIONS("-D_FILE_OFFSET_BITS=64")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}")
+
+aux_source_directory(src SOURCES)
+ADD_LIBRARY(${fw_name} SHARED ${SOURCES})
+
+TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS})
+
+INSTALL(TARGETS ${fw_name} DESTINATION ${LIB_INSTALL_DIR})
+INSTALL(
+        DIRECTORY ${INC_DIR}/ DESTINATION include/${service}
+        FILES_MATCHING
+        PATTERN "*_private.h" EXCLUDE
+        PATTERN "${INC_DIR}/*.h"
+        )
+
+SET(PC_NAME ${fw_name})
+SET(PC_REQUIRED ${dependents})
+SET(PC_LDFLAGS -l${fw_name})
+SET(PC_CFLAGS -I\${includedir}/${service})
+
+CONFIGURE_FILE(
+    ${fw_name}.pc.in
+    ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc
+    @ONLY
+)
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+
+ADD_SUBDIRECTORY(test)
+
+IF(UNIX)
+
+ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution)
+ADD_CUSTOM_COMMAND(
+        DEPENDS clean
+        COMMENT "distribution clean"
+        COMMAND find
+        ARGS    .
+        -not -name config.cmake -and \(
+        -name tester.c -or
+        -name Testing -or
+        -name CMakeFiles -or
+        -name cmake.depends -or
+        -name cmake.check_depends -or
+        -name CMakeCache.txt -or
+        -name cmake.check_cache -or
+        -name *.cmake -or
+        -name Makefile -or
+        -name core -or
+        -name core.* -or
+        -name gmon.out -or
+        -name install_manifest.txt -or
+        -name *.pc -or
+        -name *~ \)
+        | grep -v TC | xargs rm -rf
+        TARGET  distclean
+        VERBATIM
+)
+
+ENDIF(UNIX)
diff --git a/LICENSE.APLv2.0 b/LICENSE.APLv2.0
new file mode 100755 (executable)
index 0000000..261eeb9
--- /dev/null
@@ -0,0 +1,201 @@
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   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.
diff --git a/NOTICE b/NOTICE
new file mode 100644 (file)
index 0000000..ccdad52
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,3 @@
+Copyright (c) Samsung Electronics Co., Ltd. All rights reserved.
+Except as noted, this software is licensed under Apache License, Version 2.
+Please, see the LICENSE file for Apache License terms and conditions.
diff --git a/capi-media-thumbnail-util.manifest b/capi-media-thumbnail-util.manifest
new file mode 100755 (executable)
index 0000000..a76fdba
--- /dev/null
@@ -0,0 +1,5 @@
+<manifest>
+       <request>
+               <domain name="_" />
+       </request>
+</manifest>
diff --git a/capi-media-thumbnail-util.pc.in b/capi-media-thumbnail-util.pc.in
new file mode 100755 (executable)
index 0000000..52582d8
--- /dev/null
@@ -0,0 +1,15 @@
+
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=/usr
+libdir=/usr/lib
+includedir=/usr/include/media
+
+Name: @PC_NAME@
+Description: @PACKAGE_DESCRIPTION@
+Version: @VERSION@
+Requires: @PC_REQUIRED@
+Libs: -L${libdir} @PC_LDFLAGS@
+Cflags: -I${includedir} @PC_CFLAGS@
+
diff --git a/doc/thumbnail_util_doc.h b/doc/thumbnail_util_doc.h
new file mode 100755 (executable)
index 0000000..77daafa
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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 __TIZEN_THUMBNAIL_UTIL_DOC_H__
+#define __TIZEN_THUMBNAIL_UTIL_DOC_H__
+
+/**
+ * @file thumbnail_util_doc.h
+ * @brief File contains the high level documentation for the Thumbnail Util API.
+ *
+ */
+
+/**
+ * @defgroup CAPI_MEDIA_THUMBNAIL_UTIL_MODULE Thumbnail Util
+ * @ingroup CAPI_MEDIA_FRAMEWORK
+ */
+
+/**
+ * @addtogroup CAPI_MEDIA_THUMBNAIL_UTIL_MODULE
+ * @brief The @ref CAPI_MEDIA_THUMBNAIL_UTIL_MODULE API provides functions for creating the thumbnail from an input media file.
+ * @ingroup CAPI_MEDIA_FRAMEWORK
+  * @section CAPI_MEDIA_THUMBNAIL_UTIL_MODULE_HEADER Required Header
+ *    \#include <thumbnail_util.h>
+ *
+ * @section CAPI_MEDIA_THUMBNAIL_UTIL_OVERVIEW Overview
+ * The @ref CAPI_MEDIA_THUMBNAIL_UTIL_MODULE API allows you to create the thumbnail from a media file. To extract a thumbnail(#thumbnail_util_extract()), create/destory the handle(#thumbnail_util_create()/#thumbnail_util_destroy). To set the path, width and height for extracting, and cancel thumbnail_util_cancel().
+ */
+
+#endif /* __TIZEN_THUMBNAIL_UTIL_DOC_H__ */
+
+
diff --git a/include/thumbnail_util.h b/include/thumbnail_util.h
new file mode 100755 (executable)
index 0000000..588159c
--- /dev/null
@@ -0,0 +1,188 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* 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 __TIZEN_THUMBNAIL_UTIL_H__
+#define __TIZEN_THUMBNAIL_UTIL_H__
+
+#include <thumbnail_util_type.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ * @file thumbnail_util.h
+ * @brief This file contains the thumbnail util API and functions related with handling thumbnail. \n
+ *        Functions include operations to get the various size thumbnail from media file.
+ */
+
+/**
+ * @addtogroup CAPI_MEDIA_THUMBNAIL_UTIL_MODULE
+ * @{
+ */
+
+/**
+ * @brief Creates thumbnail info handle.
+ * @since_tizen 2.4
+ * @remarks You must release @a thumb info using thumbnail_util_destroy().
+ *
+ * @param[in] thumb The handle to thumbnail info
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ * @retval #THUMBNAIL_UTIL_ERROR_NONE Successful
+ * @retval #THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #THUMBNAIL_UTIL_ERROR_OUT_OF_MEMORY Not enough memory is available
+ * @retval #THUMBNAIL_UTIL_ERROR_PERMISSION_DENIED Permission denied
+ * @see thumbnail_util_destroy()
+ */
+int thumbnail_util_create(thumbnail_h *thumb);
+
+/**
+ * @brief Extracts the thumbnail for the given media, asynchronously.
+ * @details This function extracts the thumbnail for given media item and calls registered
+ *         callback function for completion of extracting the thumbnail.\n
+ *
+ * @since_tizen 2.4
+ *
+ * @remarks You must release @a request_id using free(). \n
+ *                http://tizen.org/privilege/mediastorage is needed if input or output path are relevant to media storage. \n
+ *                http://tizen.org/privilege/externalstorage is needed if input or output path are relevant to external storage. \n
+ *                If you don't set the size, the thumbnail size will be set default size. Default size is 320x240. \n
+ *                Color space of the generated thumbnail is BGRA. \n
+ *
+ * @param[in] thumb     The thumbnail info handle
+ * @param[in] callback  The callback function to be invoked
+ * @param[in] user_data The user data to be passed to the callback function
+ * @param[out] request_id The request id for the thumbnail extraction request
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ *
+ * @retval #THUMBNAIL_UTIL_ERROR_NONE              Successful
+ * @retval #THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #THUMBNAIL_UTIL_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @pre Create a thumbnail info handle by calling thumbnail_util_create().
+ *
+ * @see thumbnail_util_create()
+ */
+int thumbnail_util_extract(thumbnail_h thumb, thumbnail_extracted_cb callback, void *user_data, char **request_id);
+
+/**
+ * @brief Sets the path of original media file.
+ * @since_tizen 2.4
+ *
+ * @param[in] thumb     The thumbnail info handle
+ * @param[in] path        The path of the original media file
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ *
+ * @retval #THUMBNAIL_UTIL_ERROR_NONE              Successful
+ * @retval #THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #THUMBNAIL_UTIL_ERROR_PERMISSION_DENIED Permission denied
+ */
+int thumbnail_util_set_path(thumbnail_h thumb, const char *path);
+
+/**
+ * @brief Sets the size of thumbnail to be extracted.
+ * @since_tizen 2.4
+ * @remarks If you don't set the size, the thumbnail size will be set default size. Default size is 320x240. \n
+ *                  If the set width is not a multiple of 8, it can be changed by inner process. the width will be a multiple of 8 greater than the set value.
+ *
+ * @param[in] thumb    The thumbnail info handle
+ * @param[in] width      The width of the thumbnail
+ * @param[in] height     The height of the thumbnail
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ *
+ * @retval #THUMBNAIL_UTIL_ERROR_NONE              Successful
+ * @retval #THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #THUMBNAIL_UTIL_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @pre Create a thumbnail info handle by calling thumbnail_util_create().
+ * @see thumbnail_util_extract()
+ */
+int thumbnail_util_set_size(thumbnail_h thumb, int width, int height);
+
+/**
+ * @brief Cancels the thumbnail extraction request for the given media.
+ * @since_tizen 2.4
+ *
+ * @param[in] thumb         The media thumbnail info handle
+ * @param[in] request_id   The generated request id by thumbnail extraction request
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ *
+ * @retval #THUMBNAIL_UTIL_ERROR_NONE              Successful
+ * @retval #THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #THUMBNAIL_UTIL_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @pre Create a thumbnail info handle by calling thumbnail_util_create().
+ * @post thumbnail_util_extract()
+ */
+int thumbnail_util_cancel(thumbnail_h thumb, const char *request_id);
+
+/**
+ * @brief Cancels all thumbnail extraction requests associated with the given thumbnail info handle.
+ * @since_tizen 2.4
+ *
+ * @param[in] thumb The media thumbnail info handle
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ *
+ * @retval #THUMBNAIL_UTIL_ERROR_NONE              Successful
+ * @retval #THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #THUMBNAIL_UTIL_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @pre Create a thumbnail info handle by calling thumbnail_util_create().
+ * @post thumbnail_util_extract()
+ */
+int thumbnail_util_cancel_all(thumbnail_h thumb);
+
+/**
+ * @brief Destroys thumbnail info handle.
+ * @details The function frees all resources related to the thumbnail info handle. This handle
+ *          can no longer be used to perform any operation. New thumbnail info handle has to
+ *          be created before the next usage.
+ *
+ * @since_tizen 2.4
+ *
+ * @param[in]  thumb  The thumbnail info handle
+ *
+ * @return @c 0 on success,
+ *         otherwise a negative error value
+ *
+ * @retval #THUMBNAIL_UTIL_ERROR_NONE              Successful
+ * @retval #THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #THUMBNAIL_UTIL_ERROR_PERMISSION_DENIED Permission denied
+ *
+ * @pre Create a thumbnail info handle by calling thumbnail_util_create().
+ */
+int thumbnail_util_destroy(thumbnail_h thumb);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __TIZEN_THUMBNAIL_UTIL_H__ */
diff --git a/include/thumbnail_util_private.h b/include/thumbnail_util_private.h
new file mode 100755 (executable)
index 0000000..2295401
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* 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 __TIZEN_THUMBNAIL_UTIL_PRIVATE_H__
+#define __TIZEN_THUMBNAIL_UTIL_PRIVATE_H__
+
+
+#include <unistd.h>
+#include <asm/unistd.h>
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <glib.h>
+#include <thumbnail_util_type.h>
+#include <dlog.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "CAPI_MEDIA_THUMBNAIL_UTIL"
+
+#define SAFE_STRLCPY(dst, src, n)      ((g_strlcpy(dst, src, n) < n) ? TRUE : FALSE)
+#define SAFE_STRLCAT(dst, src, n)      g_strlcat(dst, src, n);
+#define SAFE_FREE(src)         {if(src) {free(src); src = NULL;}}
+#define STRING_VALID(str)              ((str != NULL && strlen(str) > 0) ? TRUE : FALSE)
+
+typedef struct
+{
+       int request_id;
+       char *file_path;
+       int dst_width;
+       int dst_height;
+       int thumb_size;
+       unsigned char *thumb_data;
+}thumbnail_s;
+
+typedef struct
+{
+       thumbnail_s *handle;
+       thumbnail_extracted_cb thumb_extract_cb;
+       void *user_data;
+}thumbnail_extract_cb_s;
+
+#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 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)
+
+#define thumbnail_util_debug(fmt, arg...) do { \
+                       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)
+
+#define thumbnail_util_error(fmt, arg...) do { \
+                       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)
+
+#define thumbnail_util_sec_debug(fmt, arg...) do { \
+                       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)
+
+#define thumbnail_util_sec_error(fmt, arg...) do { \
+                       SECURE_LOGE(FONT_COLOR_RED"[%d]"fmt"",thumbnail_util_gettid(), ##arg);     \
+               } while (0)
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /*__TIZEN_THUMBNAIL_UTIL_PRIVATE_H__*/
diff --git a/include/thumbnail_util_type.h b/include/thumbnail_util_type.h
new file mode 100755 (executable)
index 0000000..c486355
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* 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 __TIZEN_THUMBNAIL_UTIL_TYPE_H__
+#define __TIZEN_THUMBNAIL_UTIL_TYPE_H__
+
+#include <time.h>
+#include <tizen.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+#ifndef DEPRECATED_API
+#define DEPRECATED_API __attribute__ ((deprecated))
+#endif
+
+/**
+ * @file thumbnail_util_type.h
+ * @brief This file contains API related to thumbnail_util enumerations for classes of errors. \n
+ *        Listed APIs are called when extracting thumbnail from media files,  \n
+ */
+
+/**
+* @addtogroup CAPI_MEDIA_THUMBNAIL_UTIL_MODULE
+ * @{
+ */
+
+/**
+ * @ingroup CAPI_MEDIA_THUMBNAIL_UTIL_MODULE
+ * @brief Enumeration for a thumbnail util error.
+ * @since_tizen 2.4
+ */
+ typedef enum
+{
+    THUMBNAIL_UTIL_ERROR_NONE                    = TIZEN_ERROR_NONE,                    /**< Successful */
+    THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER       = TIZEN_ERROR_INVALID_PARAMETER,       /**< Invalid parameter */
+    THUMBNAIL_UTIL_ERROR_OUT_OF_MEMORY           = TIZEN_ERROR_OUT_OF_MEMORY,           /**< Out of memory */
+    THUMBNAIL_UTIL_ERROR_INVALID_OPERATION       = TIZEN_ERROR_INVALID_OPERATION,       /**< Invalid Operation */
+    THUMBNAIL_UTIL_ERROR_FILE_NO_SPACE_ON_DEVICE       = TIZEN_ERROR_FILE_NO_SPACE_ON_DEVICE, /**< No space left on device */
+    THUMBNAIL_UTIL_ERROR_PERMISSION_DENIED             = TIZEN_ERROR_PERMISSION_DENIED,                  /**< Permission denied */
+} thumbnail_util_error_e;
+
+
+/**
+ * @ingroup CAPI_MEDIA_THUMBNAIL_UTIL_MODULE
+ * @brief The structure type for the thumbnail info handle.
+ * @since_tizen 2.4
+ */
+typedef struct thumbnail_s *thumbnail_h;
+
+
+/**
+ * @ingroup CAPI_MEDIA_THUMBNAIL_UTIL_MODULE
+ * @brief Called when creating the thumbnail.
+ * @since_tizen 2.4
+ * @remarks Color space of the generated thumbnail is BGRA.
+ *
+ * @details This callback is called for completion of generating the thumbnail.
+ *
+ * @param[in] error     The error code
+ * @param[in] request_id       The generated request id by thumbnail extraction request
+ * @param[in] thumb_width    The width of the thumbnail which is generated
+ * @param[in] thumb_height   The height of the thumbnail which is generated
+ * @param[in] thumb_data     The raw data of the thumbnail which is generated
+ * @param[in] thumb_size      The size of the thumbnail which is generated
+ * @param[in] user_data        The user data passed from the thumbnail_util_extract() fuction
+ *
+ * @pre thumbnail_util_extract()
+ *
+ * @see thumbnail_util_extract()
+ */
+typedef void (*thumbnail_extracted_cb)(thumbnail_util_error_e error, const char *request_id, int thumb_width, int thumb_height, unsigned char *thumb_data, int thumb_size, void *user_data);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /*__TIZEN_THUMBNAIL_UTIL_TYPE_H__*/
diff --git a/packaging/capi-media-thumbnail-util.spec b/packaging/capi-media-thumbnail-util.spec
new file mode 100755 (executable)
index 0000000..a8e7510
--- /dev/null
@@ -0,0 +1,53 @@
+Name:       capi-media-thumbnail-util
+Summary:    A media thumbnail util library in SLP C API
+Version: 0.1.0
+Release:    1
+Group:      System/Libraries
+License:    Apache-2.0
+Source0:    %{name}-%{version}.tar.gz
+BuildRequires:  cmake
+BuildRequires:  pkgconfig(dlog)
+BuildRequires:  pkgconfig(glib-2.0)
+BuildRequires:  pkgconfig(libmedia-utils)
+BuildRequires:  pkgconfig(capi-base-common)
+BuildRequires:  pkgconfig(media-thumbnail)
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+
+%description
+A media thumbnail util  library in SLP C API
+
+%package devel
+Summary:  A media thumbnail util  library in SLP C API (Development)
+Group:    TO_BE/FILLED_IN
+Requires: %{name} = %{version}-%{release}
+
+%description devel
+A media thumbnail util  library in SLP C API
+
+%prep
+%setup -q
+
+
+%build
+MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
+%cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
+make %{?jobs:-j%jobs}
+
+%install
+%make_install
+
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+
+%files
+%manifest capi-media-thumbnail-util.manifest
+%{_libdir}/libcapi-media-thumbnail-util.so
+%{_datadir}/license/%{name}
+
+%files devel
+%{_includedir}/media/*.h
+%{_libdir}/pkgconfig/capi-media-thumbnail-util.pc
diff --git a/src/thumbnail_util.c b/src/thumbnail_util.c
new file mode 100755 (executable)
index 0000000..181d372
--- /dev/null
@@ -0,0 +1,205 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* 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-thumbnail.h>
+#include <thumbnail_util.h>
+#include <thumbnail_util_private.h>
+
+#define MAX_SIZE 16
+
+void __thumbnail_util_convert_itoa(int request_id, char **req_str)
+{
+       char *buf = NULL;
+
+       buf = malloc(MAX_SIZE * sizeof(char));
+       snprintf(buf, MAX_SIZE, "%d", request_id);
+       *req_str = strndup(buf, strlen(buf));
+       SAFE_FREE(buf);
+}
+void __thumbnail_util_extract_completed_cb(int error, int request_id, const char *path, int thumb_width, int thumb_height, unsigned char *thumb_data, int thumb_size, void *user_data)
+{
+       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);
+               __thumbnail_util_convert_itoa(request_id, &request_id_str);
+               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);
+               }
+       }
+       SAFE_FREE(_thumb_cb);
+}
+
+int thumbnail_util_create(thumbnail_h *thumb)
+{
+       int ret = THUMBNAIL_UTIL_ERROR_NONE;
+
+       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_util_error("OUT_OF_MEMORY(0x%08x)", THUMBNAIL_UTIL_ERROR_OUT_OF_MEMORY);
+               return THUMBNAIL_UTIL_ERROR_OUT_OF_MEMORY;
+       }
+
+       _thumb->request_id = 0;
+       _thumb->file_path = NULL;
+       _thumb->dst_width = 0;
+       _thumb->dst_height = 0;
+       _thumb->thumb_size = 0;
+       _thumb->thumb_data = NULL;
+
+       *thumb = (thumbnail_h)_thumb;
+
+       return ret;
+}
+
+int thumbnail_util_extract(thumbnail_h thumb, thumbnail_extracted_cb callback, void *user_data, char **request_id)
+{
+       int ret = THUMBNAIL_UTIL_ERROR_NONE;
+       static int g_thumbnail_req_id = 0;
+       thumbnail_s *_thumb = (thumbnail_s*)thumb;
+
+       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));
+               _thumb_cb->handle = _thumb;
+               _thumb_cb->user_data = user_data;
+               _thumb_cb->thumb_extract_cb= callback;
+
+               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
+       {
+               thumbnail_util_error("INVALID_PARAMETER(0x%08x)", THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER);
+               ret = THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int thumbnail_util_set_path(thumbnail_h thumb, const char *path)
+{
+       int ret = THUMBNAIL_UTIL_ERROR_NONE;
+       thumbnail_s *_thumb = (thumbnail_s*)thumb;
+
+       if(_thumb != NULL && path != NULL)
+       {
+               if(_thumb->file_path)
+                       SAFE_FREE(_thumb->file_path);
+               _thumb->file_path = strndup(path, strlen(path));
+       }
+       else
+       {
+               thumbnail_util_error("INVALID_PARAMETER(0x%08x)", THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER);
+               ret = THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int thumbnail_util_set_size(thumbnail_h thumb, int width, int height)
+{
+       int ret = THUMBNAIL_UTIL_ERROR_NONE;
+       thumbnail_s *_thumb = (thumbnail_s*)thumb;
+
+       if(_thumb != NULL && width > 0 && height > 0)
+       {
+               _thumb->dst_width = width;
+               _thumb->dst_height = height;
+       }
+       else
+       {
+               thumbnail_util_error("INVALID_PARAMETER(0x%08x)", THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER);
+               ret = THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int thumbnail_util_cancel(thumbnail_h thumb, const char *request_id)
+{
+       int ret = THUMBNAIL_UTIL_ERROR_NONE;
+       thumbnail_s *_thumb = (thumbnail_s*)thumb;
+
+       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
+       {
+               thumbnail_util_error("INVALID_PARAMETER(0x%08x)", THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER);
+               ret = THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int thumbnail_util_cancel_all(thumbnail_h thumb)
+{
+       int ret = THUMBNAIL_UTIL_ERROR_NONE;
+       thumbnail_s *_thumb = (thumbnail_s*)thumb;
+
+       if(_thumb != NULL)
+       {
+               ret = thumbnail_request_cancel_all(true);
+       }
+       else
+       {
+               thumbnail_util_error("INVALID_PARAMETER(0x%08x)", THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER);
+               ret = THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+
+int thumbnail_util_destroy(thumbnail_h thumb)
+{
+       int ret = THUMBNAIL_UTIL_ERROR_NONE;
+       thumbnail_s *_thumb = (thumbnail_s*)thumb;
+
+       if(_thumb)
+       {
+               SAFE_FREE(_thumb->file_path);
+               SAFE_FREE(_thumb->thumb_data);
+               SAFE_FREE(_thumb);
+       }
+       else
+       {
+               thumbnail_util_error("INVALID_PARAMETER(0x%08x)", THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER);
+               ret = THUMBNAIL_UTIL_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..b62d2d4
--- /dev/null
@@ -0,0 +1,18 @@
+SET(fw_test "${fw_name}-test")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${fw_test} REQUIRED glib-2.0 libmedia-utils capi-base-common)
+
+FOREACH(flag ${${fw_test}_CFLAGS})
+    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -pie")
+
+aux_source_directory(. sources)
+FOREACH(src ${sources})
+    GET_FILENAME_COMPONENT(src_name ${src} NAME_WE)
+    MESSAGE("${src_name}")
+    ADD_EXECUTABLE(${src_name} ${src})
+    TARGET_LINK_LIBRARIES(${src_name} ${fw_name} ${${fw_test}_LDFLAGS})
+ENDFOREACH()
diff --git a/test/thumbnail_util_test.c b/test/thumbnail_util_test.c
new file mode 100755 (executable)
index 0000000..babc915
--- /dev/null
@@ -0,0 +1,161 @@
+/*
+* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
+*
+* 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 <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <stdbool.h>
+#include <glib.h>
+#include <thumbnail_util.h>
+#include <thumbnail_util_private.h>
+
+#define MAX_SIZE 16
+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)
+{
+#if 0
+       FILE *fp;
+       fp = fopen( "test.raw", "w");
+    fwrite(raw_data, 1, raw_size, fp);
+       fclose(fp);
+#endif
+       thumbnail_util_debug("=================[RESULT]");
+       thumbnail_util_debug("error_code [%d]", error);
+       thumbnail_util_debug("request id [%s]", request_id);
+       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)
+               g_main_loop_quit(g_loop);
+}
+
+void __convert_i_to_a(unsigned int request_id, char **req_str)
+{
+       char *buf = NULL;
+       buf = malloc(MAX_SIZE * sizeof(char));
+       snprintf(buf, MAX_SIZE, "%d", request_id);
+       *req_str = strndup(buf, strlen(buf));
+       SAFE_FREE(buf);
+}
+
+gboolean extract_thumbnail_start(gpointer data)
+{
+       int ret = THUMBNAIL_UTIL_ERROR_NONE;
+#if 1
+       int i;
+       thumbnail_h test_info;
+       thumbnail_util_create(&test_info);
+       thumbnail_util_set_size(test_info, 512, 288);
+
+       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);
+               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_util_debug("GENERATED ID [%s]", g_id);
+       }
+#else
+       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);
+       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)
+               thumbnail_util_debug("extract raw data is success");
+       else
+               thumbnail_util_error("extract raw data is failed");
+
+       return false;
+}
+
+
+gboolean cancel_all(gpointer data)
+{
+       int ret = THUMBNAIL_UTIL_ERROR_NONE;
+       thumbnail_h _media_thumb;
+       thumbnail_util_create(&_media_thumb);
+#if 0
+       ret = thumbnail_util_cancel_all(_media_thumb);
+
+       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");
+#else
+       int i, num;
+       num = atoi(g_id);
+       char *req_str = NULL;
+       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)
+                       thumbnail_util_debug("thumbnail_util_cancel[%d] is success", i);
+               else
+                       thumbnail_util_error("thumbnail_util_cancel[%d] is failed", i);
+       }
+#endif
+       thumbnail_util_destroy(_media_thumb);
+
+       return false;
+}
+
+int test_extract_thumbnail(bool cancel)
+{
+       int ret = THUMBNAIL_UTIL_ERROR_NONE;
+       GSource *source = NULL;
+       GMainContext *context = NULL;
+
+       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);
+
+       /* 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_main_loop_run(g_loop);
+       g_main_loop_unref(g_loop);
+
+       return ret;
+}
+
+int main(int argc, char *argv[])
+{
+       int ret = THUMBNAIL_UTIL_ERROR_NONE;
+
+       thumbnail_util_debug("--- Thumbnail util test start ---\n\n");
+
+       ret = test_extract_thumbnail(false);
+       if(ret != THUMBNAIL_UTIL_ERROR_NONE)
+               return ret;
+
+       thumbnail_util_debug("--- Thumbnail util test end ---\n");
+
+       return ret;
+}