Tizen 2.1 base
authorJinkun Jang <jinkun.jang@samsung.com>
Tue, 12 Mar 2013 16:45:58 +0000 (01:45 +0900)
committerJinkun Jang <jinkun.jang@samsung.com>
Tue, 12 Mar 2013 16:45:58 +0000 (01:45 +0900)
36 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-content-media-content.manifest [new file with mode: 0644]
capi-content-media-content.pc.in [new file with mode: 0644]
include/media_audio.h [new file with mode: 0755]
include/media_bookmark.h [new file with mode: 0755]
include/media_content.h [new file with mode: 0755]
include/media_content_type.h [new file with mode: 0755]
include/media_filter.h [new file with mode: 0755]
include/media_folder.h [new file with mode: 0755]
include/media_group.h [new file with mode: 0755]
include/media_image.h [new file with mode: 0755]
include/media_info.h [new file with mode: 0755]
include/media_info_private.h [new file with mode: 0755]
include/media_playlist.h [new file with mode: 0755]
include/media_tag.h [new file with mode: 0755]
include/media_util_private.h [new file with mode: 0755]
include/media_video.h [new file with mode: 0755]
packaging/capi-content-media-content.spec [new file with mode: 0755]
src/media_audio.c [new file with mode: 0755]
src/media_bookmark.c [new file with mode: 0755]
src/media_content.c [new file with mode: 0755]
src/media_db.c [new file with mode: 0755]
src/media_filter.c [new file with mode: 0755]
src/media_folder.c [new file with mode: 0755]
src/media_group.c [new file with mode: 0755]
src/media_image.c [new file with mode: 0755]
src/media_info.c [new file with mode: 0755]
src/media_playlist.c [new file with mode: 0755]
src/media_tag.c [new file with mode: 0755]
src/media_util_private.c [new file with mode: 0755]
src/media_video.c [new file with mode: 0755]
test/CMakeLists.txt [new file with mode: 0755]
test/media-content_test.c [new file with mode: 0755]

diff --git a/AUTHORS b/AUTHORS
new file mode 100755 (executable)
index 0000000..677fb81
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1,2 @@
+Haejeong Kim <backto.kim at samsung dot com>
+Hyunjun Ko <zzoon.ko at samsung dot com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..6632a6a
--- /dev/null
@@ -0,0 +1,96 @@
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+SET(fw_name "capi-content-media-content")
+
+PROJECT(${fw_name})
+
+SET(CMAKE_INSTALL_PREFIX /usr)
+SET(PREFIX ${CMAKE_INSTALL_PREFIX})
+
+SET(INC_DIR include)
+INCLUDE_DIRECTORIES(${INC_DIR})
+
+SET(dependents "dlog libmedia-service media-thumbnail libmedia-utils capi-base-common")
+SET(pc_dependents "dlog capi-base-common")
+
+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}" STREQUAL "arm")
+    ADD_DEFINITIONS("-DTARGET")
+ENDIF("${ARCH}" STREQUAL "arm")
+
+ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
+ADD_DEFINITIONS("-DTIZEN_DEBUG")
+
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib")
+
+aux_source_directory(src SOURCES)
+ADD_LIBRARY(${fw_name} SHARED ${SOURCES})
+
+TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS})
+
+SET_TARGET_PROPERTIES(${fw_name}
+     PROPERTIES
+     VERSION ${FULLVER}
+     SOVERSION ${MAJORVER}
+     CLEAN_DIRECT_OUTPUT 1
+)
+
+INSTALL(TARGETS ${fw_name} DESTINATION lib)
+INSTALL(
+        DIRECTORY ${INC_DIR}/ DESTINATION include/media-content
+        FILES_MATCHING
+        PATTERN "*_private.h" EXCLUDE
+        PATTERN "${INC_DIR}/*.h"
+        )
+
+SET(PC_NAME ${fw_name})
+SET(PC_REQUIRED ${pc_dependents})
+SET(PC_LDFLAGS -l${fw_name})
+
+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/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..5554685
--- /dev/null
@@ -0,0 +1,204 @@
+                                 Apache License\r
+                           Version 2.0, January 2004\r
+                        http://www.apache.org/licenses/\r
+\r
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\r
+\r
+   1. Definitions.\r
+\r
+      "License" shall mean the terms and conditions for use, reproduction,\r
+      and distribution as defined by Sections 1 through 9 of this document.\r
+\r
+      "Licensor" shall mean the copyright owner or entity authorized by\r
+      the copyright owner that is granting the License.\r
+\r
+      "Legal Entity" shall mean the union of the acting entity and all\r
+      other entities that control, are controlled by, or are under common\r
+      control with that entity. For the purposes of this definition,\r
+      "control" means (i) the power, direct or indirect, to cause the\r
+      direction or management of such entity, whether by contract or\r
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the\r
+      outstanding shares, or (iii) beneficial ownership of such entity.\r
+\r
+      "You" (or "Your") shall mean an individual or Legal Entity\r
+      exercising permissions granted by this License.\r
+\r
+      "Source" form shall mean the preferred form for making modifications,\r
+      including but not limited to software source code, documentation\r
+      source, and configuration files.\r
+\r
+      "Object" form shall mean any form resulting from mechanical\r
+      transformation or translation of a Source form, including but\r
+      not limited to compiled object code, generated documentation,\r
+      and conversions to other media types.\r
+\r
+      "Work" shall mean the work of authorship, whether in Source or\r
+      Object form, made available under the License, as indicated by a\r
+      copyright notice that is included in or attached to the work\r
+      (an example is provided in the Appendix below).\r
+\r
+      "Derivative Works" shall mean any work, whether in Source or Object\r
+      form, that is based on (or derived from) the Work and for which the\r
+      editorial revisions, annotations, elaborations, or other modifications\r
+      represent, as a whole, an original work of authorship. For the purposes\r
+      of this License, Derivative Works shall not include works that remain\r
+      separable from, or merely link (or bind by name) to the interfaces of,\r
+      the Work and Derivative Works thereof.\r
+\r
+      "Contribution" shall mean any work of authorship, including\r
+      the original version of the Work and any modifications or additions\r
+      to that Work or Derivative Works thereof, that is intentionally\r
+      submitted to Licensor for inclusion in the Work by the copyright owner\r
+      or by an individual or Legal Entity authorized to submit on behalf of\r
+      the copyright owner. For the purposes of this definition, "submitted"\r
+      means any form of electronic, verbal, or written communication sent\r
+      to the Licensor or its representatives, including but not limited to\r
+      communication on electronic mailing lists, source code control systems,\r
+      and issue tracking systems that are managed by, or on behalf of, the\r
+      Licensor for the purpose of discussing and improving the Work, but\r
+      excluding communication that is conspicuously marked or otherwise\r
+      designated in writing by the copyright owner as "Not a Contribution."\r
+\r
+      "Contributor" shall mean Licensor and any individual or Legal Entity\r
+      on behalf of whom a Contribution has been received by Licensor and\r
+      subsequently incorporated within the Work.\r
+\r
+   2. Grant of Copyright License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      copyright license to reproduce, prepare Derivative Works of,\r
+      publicly display, publicly perform, sublicense, and distribute the\r
+      Work and such Derivative Works in Source or Object form.\r
+\r
+   3. Grant of Patent License. Subject to the terms and conditions of\r
+      this License, each Contributor hereby grants to You a perpetual,\r
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\r
+      (except as stated in this section) patent license to make, have made,\r
+      use, offer to sell, sell, import, and otherwise transfer the Work,\r
+      where such license applies only to those patent claims licensable\r
+      by such Contributor that are necessarily infringed by their\r
+      Contribution(s) alone or by combination of their Contribution(s)\r
+      with the Work to which such Contribution(s) was submitted. If You\r
+      institute patent litigation against any entity (including a\r
+      cross-claim or counterclaim in a lawsuit) alleging that the Work\r
+      or a Contribution incorporated within the Work constitutes direct\r
+      or contributory patent infringement, then any patent licenses\r
+      granted to You under this License for that Work shall terminate\r
+      as of the date such litigation is filed.\r
+\r
+   4. Redistribution. You may reproduce and distribute copies of the\r
+      Work or Derivative Works thereof in any medium, with or without\r
+      modifications, and in Source or Object form, provided that You\r
+      meet the following conditions:\r
+\r
+      (a) You must give any other recipients of the Work or\r
+          Derivative Works a copy of this License; and\r
+\r
+      (b) You must cause any modified files to carry prominent notices\r
+          stating that You changed the files; and\r
+\r
+      (c) You must retain, in the Source form of any Derivative Works\r
+          that You distribute, all copyright, patent, trademark, and\r
+          attribution notices from the Source form of the Work,\r
+          excluding those notices that do not pertain to any part of\r
+          the Derivative Works; and\r
+\r
+      (d) If the Work includes a "NOTICE" text file as part of its\r
+          distribution, then any Derivative Works that You distribute must\r
+          include a readable copy of the attribution notices contained\r
+          within such NOTICE file, excluding those notices that do not\r
+          pertain to any part of the Derivative Works, in at least one\r
+          of the following places: within a NOTICE text file distributed\r
+          as part of the Derivative Works; within the Source form or\r
+          documentation, if provided along with the Derivative Works; or,\r
+          within a display generated by the Derivative Works, if and\r
+          wherever such third-party notices normally appear. The contents\r
+          of the NOTICE file are for informational purposes only and\r
+          do not modify the License. You may add Your own attribution\r
+          notices within Derivative Works that You distribute, alongside\r
+          or as an addendum to the NOTICE text from the Work, provided\r
+          that such additional attribution notices cannot be construed\r
+          as modifying the License.\r
+\r
+      You may add Your own copyright statement to Your modifications and\r
+      may provide additional or different license terms and conditions\r
+      for use, reproduction, or distribution of Your modifications, or\r
+      for any such Derivative Works as a whole, provided Your use,\r
+      reproduction, and distribution of the Work otherwise complies with\r
+      the conditions stated in this License.\r
+\r
+   5. Submission of Contributions. Unless You explicitly state otherwise,\r
+      any Contribution intentionally submitted for inclusion in the Work\r
+      by You to the Licensor shall be under the terms and conditions of\r
+      this License, without any additional terms or conditions.\r
+      Notwithstanding the above, nothing herein shall supersede or modify\r
+      the terms of any separate license agreement you may have executed\r
+      with Licensor regarding such Contributions.\r
+\r
+   6. Trademarks. This License does not grant permission to use the trade\r
+      names, trademarks, service marks, or product names of the Licensor,\r
+      except as required for reasonable and customary use in describing the\r
+      origin of the Work and reproducing the content of the NOTICE file.\r
+\r
+   7. Disclaimer of Warranty. Unless required by applicable law or\r
+      agreed to in writing, Licensor provides the Work (and each\r
+      Contributor provides its Contributions) on an "AS IS" BASIS,\r
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\r
+      implied, including, without limitation, any warranties or conditions\r
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\r
+      PARTICULAR PURPOSE. You are solely responsible for determining the\r
+      appropriateness of using or redistributing the Work and assume any\r
+      risks associated with Your exercise of permissions under this License.\r
+\r
+   8. Limitation of Liability. In no event and under no legal theory,\r
+      whether in tort (including negligence), contract, or otherwise,\r
+      unless required by applicable law (such as deliberate and grossly\r
+      negligent acts) or agreed to in writing, shall any Contributor be\r
+      liable to You for damages, including any direct, indirect, special,\r
+      incidental, or consequential damages of any character arising as a\r
+      result of this License or out of the use or inability to use the\r
+      Work (including but not limited to damages for loss of goodwill,\r
+      work stoppage, computer failure or malfunction, or any and all\r
+      other commercial damages or losses), even if such Contributor\r
+      has been advised of the possibility of such damages.\r
+\r
+   9. Accepting Warranty or Additional Liability. While redistributing\r
+      the Work or Derivative Works thereof, You may choose to offer,\r
+      and charge a fee for, acceptance of support, warranty, indemnity,\r
+      or other liability obligations and/or rights consistent with this\r
+      License. However, in accepting such obligations, You may act only\r
+      on Your own behalf and on Your sole responsibility, not on behalf\r
+      of any other Contributor, and only if You agree to indemnify,\r
+      defend, and hold each Contributor harmless for any liability\r
+      incurred by, or claims asserted against, such Contributor by reason\r
+      of your accepting any such warranty or additional liability.\r
+\r
+   END OF TERMS AND CONDITIONS\r
+\r
+   APPENDIX: How to apply the Apache License to your work.\r
+\r
+      To apply the Apache License to your work, attach the following\r
+      boilerplate notice, with the fields enclosed by brackets "[]"\r
+      replaced with your own identifying information. (Don't include\r
+      the brackets!)  The text should be enclosed in the appropriate\r
+      comment syntax for the file format. We also recommend that a\r
+      file or class name and description of purpose be included on the\r
+      same "printed page" as the copyright notice for easier\r
+      identification within third-party archives.\r
+\r
+   Copyright [yyyy] [name of copyright owner]\r
+\r
+   Licensed under the Apache License, Version 2.0 (the "License");\r
+   you may not use this file except in compliance with the License.\r
+   You may obtain a copy of the License at\r
+\r
+       http://www.apache.org/licenses/LICENSE-2.0\r
+\r
+   Unless required by applicable law or agreed to in writing, software\r
+   distributed under the License is distributed on an "AS IS" BASIS,\r
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+   See the License for the specific language governing permissions and\r
+   limitations under the License.\r
+\r
+\r
+\r
diff --git a/NOTICE b/NOTICE
new file mode 100644 (file)
index 0000000..ffbca8e
--- /dev/null
+++ b/NOTICE
@@ -0,0 +1,4 @@
+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-content-media-content.manifest b/capi-content-media-content.manifest
new file mode 100644 (file)
index 0000000..ca37499
--- /dev/null
@@ -0,0 +1,6 @@
+<manifest>
+       <request>
+               <domain name="_" />
+       </request>
+</manifest>
+
diff --git a/capi-content-media-content.pc.in b/capi-content-media-content.pc.in
new file mode 100644 (file)
index 0000000..69956a2
--- /dev/null
@@ -0,0 +1,15 @@
+
+# Package Information for pkg-config
+
+prefix=@PREFIX@
+exec_prefix=/usr
+libdir=/usr/lib
+includedir=/usr/include/media-content
+
+Name: @PC_NAME@
+Description: @PACKAGE_DESCRIPTION@
+Version: @VERSION@
+Requires: @PC_REQUIRED@ 
+Libs: -L${libdir} @PC_LDFLAGS@
+Cflags: -I${includedir}
+
diff --git a/include/media_audio.h b/include/media_audio.h
new file mode 100755 (executable)
index 0000000..54ba328
--- /dev/null
@@ -0,0 +1,356 @@
+/*
+* 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_AUDIO_META_H__
+#define __TIZEN_AUDIO_META_H__
+
+#include <media_content_type.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @addtogroup CAPI_CONTENT_MEDIA_AUDIO_META_MODULE
+ * @{
+ *
+ * @file audio_meta.h
+ * @brief This file contains the audio metadata API and related structure and enumeration. \n
+ *        Description of the audio content involves: album, artist, author, genre and description tags. \n
+ *        Parameters of the recording are also supported, as: format, bitrate, duration, size etc.
+ */
+
+
+/**
+ * @brief Destroys audio metadata.
+ *
+ * @param [in] audio The handle to audio metadata.
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre Get copy of audio metadata handle handle by calling audio_meta_clone()
+ * @see audio_meta_clone()
+ */
+int audio_meta_destroy(audio_meta_h audio);
+
+/**
+ * @brief Clones audio metadata.
+ * @details Function copies the audio metadata handle handle from source to destination.
+ *
+ * @remark The destination handle must be released with audio_meta_destroy() by you.
+ *
+ * @param [out] dst A destination handle to audio metadata
+ * @param [in] src The source handle to audio metadata
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see audio_meta_destroy()
+ */
+int audio_meta_clone(audio_meta_h *dst, audio_meta_h src);
+
+/**
+ * @brief Gets id of audio of given audio metadata.
+ *
+ * @remarks @a audio id must be released with free() by you.
+ *
+ * @param [in] audio The handle to audio metadata
+ * @param [out] media_id The id of the audio
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int audio_meta_get_media_id(audio_meta_h audio, char **media_id);
+
+/**
+ * @brief Gets title of audio of given audio metadata.
+ *
+ * @remarks @a audio title must be released with free() by you.
+ *
+ * @param [in] audio The handle to audio metadata
+ * @param [out] title The title of the audio
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int audio_meta_get_title(audio_meta_h audio, char **title);
+
+/**
+ * @brief Gets name of album of given audio metadata.\n
+ * If the value is an empty string, the method returns "Unknown".
+ *
+ * @remarks @a album_name must be released with free() by you.
+ *
+ * @param [in] audio The handle to audio metadata
+ * @param [out] album_name The name of the album
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int audio_meta_get_album(audio_meta_h audio, char **album_name);
+
+/**
+ * @brief Gets name of artist of given audio metadata.\n
+ * If the value is an empty string, the method returns "Unknown".
+ *
+ * @remarks @a artist_name must be released with free() by you.
+ *
+ * @param [in] audio The handle to audio metadata
+ * @param [out] artist_name The name of the artist
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int audio_meta_get_artist(audio_meta_h audio, char **artist_name);
+
+/**
+ * @brief Gets name of genre of given audio metadata.\n
+ * If the value is an empty string, the method returns "Unknown".
+ *
+ * @remarks @a genre_name must be released with free() by you.
+ *
+ * @param [in] audio The handle to audio metadata
+ * @param [out] genre_name The name of the genre
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int audio_meta_get_genre(audio_meta_h audio, char **genre_name);
+
+/**
+ * @brief Gets name of composer of given audio metadata.\n
+ * If the value is an empty string, the method returns "Unknown".
+ *
+ * @remarks @a author_name must be released with free() by you.
+ *
+ * @param [in] audio The handle to audio metadata
+ * @param [out] author_name The name of the author of audio
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int audio_meta_get_composer(audio_meta_h audio, char **composer_name);
+
+/**
+ * @brief Gets year of given audio metadata.\n
+ * If the value is an empty string, the method returns "Unknown".
+ *
+ * @remarks @a year must be released with free() by you.
+ *
+ * @param [in] audio The handle to audio metadata
+ * @param [out] year The year of the audio file
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int audio_meta_get_year(audio_meta_h audio, char **year);
+
+/**
+ * @brief Gets recorded date of given audio metadata.
+ *
+ * @remarks @a recorded date must be released with free() by you.
+ *
+ * @param [in] audio The handle to audio metadata
+ * @param [out] recorded_date The recorded date of the audio file
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int audio_meta_get_recorded_date(audio_meta_h audio, char **recorded_date);
+
+/**
+ * @brief Gets copyright notice of given audio metadata.
+ *
+ * @remarks @a copyright must be released with free() by you.
+ *
+ * @param [in] audio The handle to audio metadata
+ * @param [out] copyright The audio copyright notice
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int audio_meta_get_copyright(audio_meta_h audio, char **copyright);
+
+/**
+ * @brief Gets track number of given audio metadata. \n
+ * If the value is an empty string, the method returns "Unknown".
+ *
+ * @param [in] audio The handle to audio metadata
+ * @param [out] track_num The audio track number
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int audio_meta_get_track_num(audio_meta_h audio, char **track_num);
+
+/**
+ * @brief Gets bitrate of given audio metadata in bitrate per second.
+ *
+ * @param [in] audio The handle to audio metadata
+ * @param [out] bit_rate The audio bitrate in bit per second [bps]
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int audio_meta_get_bit_rate(audio_meta_h audio, int *bit_rate);
+
+/**
+ * @brief Gets sample rate of given audio metadata.
+ *
+ * @param [in] audio The handle to audio metadata
+ * @param [out] sample_rate The audio sample rate[hz]
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int audio_meta_get_sample_rate(audio_meta_h audio, int *sample_rate);
+
+/**
+ * @brief Gets channel of given audio metadata.
+ *
+ * @param [in] audio The handle to audio metadata
+ * @param [out] channel The channel of audio
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int audio_meta_get_channel(audio_meta_h audio, int *channel);
+
+/**
+ * @brief Gets track duration of given audio metadata.
+ *
+ * @param [in] audio The handle to audio metadata
+ * @param [out] duration The audio file duration
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int audio_meta_get_duration(audio_meta_h audio, int *duration);
+
+/**
+ * @brief Gets number which represents how many times given audio has been played.
+ *
+ * @param [in] audio The handle to audio metadata
+ * @param [out] count_played The counter of audio played
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int audio_meta_get_played_count(audio_meta_h audio, int *played_count);
+
+/**
+ * @brief Gets the audio's played time parameter.
+ * @details Function returns audio's elapsed playback time parameter as period
+ * starting from the beginning of the track.
+ *
+ * @param [in] audio The handle to audio metadata
+ * @param [out] played_time The elapsed time of the audio
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int audio_meta_get_played_time(audio_meta_h audio, time_t *played_time);
+
+/**
+ * @brief Gets the audio's played position parameter.
+ * @details Function returns audio's elapsed playback position parameter as period
+ * starting from the beginning of the track.
+ *
+ * @param [in] audio The handle to audio metadata
+ * @param [out] played_position The elapsed time of the audio
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int audio_meta_get_played_position(audio_meta_h audio, int *played_position);
+
+/**
+ * @brief Sets the played count to audio meta handle.
+ *
+ * @param [in] audio The handle to audio metadata
+ * @param [in] played_count The played count of audio
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @post audio_meta_update_to_db()
+ */
+int audio_meta_set_played_count(audio_meta_h audio, int played_count);
+
+/**
+ * @brief Sets the played time to audio meta handle.
+ *
+ * @param [in] audio The handle to audio metadata
+ * @param [in] played_time The played time of audio
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @post audio_meta_update_to_db() 
+ */
+int audio_meta_set_played_time(audio_meta_h audio, time_t played_time);
+
+/**
+ * @brief Sets the played position to audio meta handle.
+ *
+ * @param [in] audio The handle to audio metadata
+ * @param [in] played_position The played position of audio
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @post audio_meta_update_to_db()
+ */
+int audio_meta_set_played_position(audio_meta_h audio, int played_position);
+
+/**
+ * @brief Updates audio metadata which is modified attributes to the media database.
+ *
+ * @details The function updates the given audio meta in the media database.\n
+ * The function should be called after any change in the attributes, to be updated to the media database.\n
+ * For example, after using audio_meta_set_played_count() for changing the count of the played,
+ * audio_meta_update_to_db() function should be called so as to update the given the attibutes in the media database.
+ *
+ * @param [in] audio The handle to audio metadata
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ * @see audio_meta_set_played_count()
+ * @see audio_meta_set_played_time()
+ * @see audio_meta_set_played_position()
+ */
+int audio_meta_update_to_db(audio_meta_h audio);
+
+/**
+ * @}
+ */
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*__TIZEN_AUDIO_META_H__*/
diff --git a/include/media_bookmark.h b/include/media_bookmark.h
new file mode 100755 (executable)
index 0000000..ce974c2
--- /dev/null
@@ -0,0 +1,158 @@
+/*
+* 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_MEDIA_BOOKMARK_H__
+#define __TIZEN_MEDIA_BOOKMARK_H__
+
+#include <media_content_type.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/**
+ * @addtogroup CAPI_CONTENT_MEDIA_BOOKMARK_MODULE
+ * @{
+ */
+
+/**
+ * @brief Inserts a new bookmark in media on specified time offset to the media database.
+ *
+ * @param [in] media_id The id of media
+ * @param [in] time The bookmark time offset(in seconds)
+ * @param [in] thumbnail_path The thumbnail path of video bookmark. If the media type is audio, then thumbnail is null.
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ * @see media_bookmark_delete_from_db()
+ *
+ */
+int media_bookmark_insert_to_db(const char *media_id, time_t time, const char *thumbnail_path);
+
+/**
+ * @brief Removes media bookmark from the media database.
+ *
+ * @param [in] bookmark The handle to media bookmark
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ * @see media_bookmark_insert_to_db()
+ *
+ */
+int media_bookmark_delete_from_db(int bookmark_id);
+
+/**
+ * @brief Gets number of bookmark with optional filter from media database.
+ *
+ * @param [in] filter  The handle to media filter
+ * @param [out] bookmark_count The count of media bookmark
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ */
+int media_bookmark_get_bookmark_count_from_db(filter_h filter, int *bookmark_count);
+
+/**
+ * @brief Clones media bookmark.
+ * @details This function copies the media bookmark handle from a source to destination. There is no media_bookmark_create() function.
+ * The media_bookmark_h is created internally and available through media bookmark foreach function such as media_info_foreach_bookmark_from_db().
+ * To use this handle outside of these foreach functions, use this function.
+ *
+ * @remark The destination handle must be released with media_bookmark_destroy() by you.
+ *
+ * @param [out] dst A destination handle to media bookmark
+ * @param [in] src The source handle to media bookmark
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see media_bookmark_destroy()
+ * @see media_info_foreach_bookmark_from_db()
+ *
+ */
+int media_bookmark_clone(media_bookmark_h *dst, media_bookmark_h src);
+
+/**
+ * @brief Destroys media bookmark.
+ * @details Function frees all resources related to bookmark handle. This handle
+ * no longer can be used to perform any operation. A new handle has to
+ * be created before the next use.
+ *
+ * @param [in] bookmark The handle to media bookmark
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre Get copy of bookmark handle by calling media_bookmark_clone()
+ * @see media_bookmark_clone()
+ */
+int media_bookmark_destroy(media_bookmark_h bookmark);
+
+/**
+ * @brief Gets bookmark's id.
+ *
+ * @param [in] bookmark The handle to media bookmark
+ * @param [out] bookmark_id The id of media bookmark
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int media_bookmark_get_bookmark_id(media_bookmark_h bookmark, int *bookmark_id);
+
+/**
+ * @brief Gets bookmark's time marked parameter.
+ * @details Function returns time offset in milliseconds from beginning of the movie on which bookmark
+ * was placed.
+ *
+ * @param [in] bookmark The handle to media bookmark
+ * @param [out] marked_time The bookmark time offset(in milliseconds)
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int media_bookmark_get_marked_time(media_bookmark_h bookmark, time_t *marked_time);
+
+/**
+ * @brief Gets the media bookmark's thumbnail.
+ *
+ * @remarks @a path must be released with free() by you.
+ *
+ * @param [in] bookmark The handle to media bookmark
+ * @param [out] path The thumbnail path of media bookmark
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int media_bookmark_get_thumbnail_path(media_bookmark_h bookmark, char **path);
+
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /*__TIZEN_MEDIA_BOOKMARK_H__*/
diff --git a/include/media_content.h b/include/media_content.h
new file mode 100755 (executable)
index 0000000..8e6a566
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+* 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_MEDIA_CONTENT_H__
+#define __TIZEN_MEDIA_CONTENT_H__
+
+#include <media_audio.h>
+#include <media_content_type.h>
+#include <media_filter.h>
+#include <media_folder.h>
+#include <media_image.h>
+#include <media_info.h>
+#include <media_tag.h>
+#include <media_video.h>
+#include <media_group.h>
+#include <media_playlist.h>
+#include <media_bookmark.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ * @addtogroup CAPI_MEDIA_CONTENT_MODULE
+ * @{
+ */
+
+
+/**
+ * @brief Connects to the media content service.
+ * @details Any media content related function call should be invoked after this function call.
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB operation failed
+ * @post media_content_disconnect()
+ * @see media_content_disconnect()
+ *
+ */
+int media_content_connect(void);
+
+/**
+ * @brief Disconnects from the media content service.
+ * @details This function closes connection to the media content service. Any further media content related operation
+ * cannot be performed after this function is called.
+ *
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB operation failed
+ * @pre media_content_connect()
+ * @see media_content_connect()
+ *
+ */
+int media_content_disconnect(void);
+
+/**
+ * @brief Requests to scan a media file.
+ * @details This function requests to scan a media file to media server.
+ * @param[in] path The file path
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ *
+ */
+int media_content_scan_file(const char *path);
+
+
+/**
+ * @brief Requests to scan a media folder, asynchronously.
+ * @details This function requests to scan a media folder to media server with given completed callback fucntion.
+ * #media_scan_completed_cb() function will be called when the scanning is finished.
+ * The sub folders are also scanned, if there are sub folder in that folder. \n
+ * If you want that the any folders are not scanned, you have to create a blank file ".scan_ignore" in that folder.
+ * @param[in] path The folder path
+ * @param[in] callback The callback to invoke when the scanning is finished
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @see media_scan_completed_cb()
+ *
+ */
+int media_content_scan_folder(const char *path, media_scan_completed_cb callback, void *user_data);
+
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __TIZEN_MEDIA_CONTENT_H__ */
diff --git a/include/media_content_type.h b/include/media_content_type.h
new file mode 100755 (executable)
index 0000000..a399bfc
--- /dev/null
@@ -0,0 +1,536 @@
+/*
+* 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_MEDIA_CONTENT_TYPE_H__
+#define __TIZEN_MEDIA_CONTENT_TYPE_H__
+
+#include <time.h>
+#include <tizen.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+#ifndef DEPRECATED_API
+#define DEPRECATED_API __attribute__ ((deprecated))
+#endif
+
+/**
+* @addtogroup CAPI_MEDIA_CONTENT_MODULE
+* @{
+*/
+
+/**
+ * @ingroup CAPI_MEDIA_CONTENT_MODULE
+ * @brief The enumerations of the media file format.
+ */
+typedef enum
+{
+       MEDIA_CONTENT_TYPE_IMAGE                = 0,            /**<The type of image */
+       MEDIA_CONTENT_TYPE_VIDEO                = 1,            /**<The type of video */
+       MEDIA_CONTENT_TYPE_SOUND        = 2,            /**<The type of sound */
+       MEDIA_CONTENT_TYPE_MUSIC                = 3,            /**<The type of music */
+       MEDIA_CONTENT_TYPE_OTHERS       = 4,            /**<The type of other */
+} media_content_type_e;
+
+/**
+ * @ingroup CAPI_CONTENT_MEDIA_FOLDER_MODULE
+ * @brief The enumerations of the storage type.
+ * @detail This information is used to establish where the folder is.
+ */
+typedef enum
+{
+       MEDIA_CONTENT_STORAGE_INTERNAL  = 0,            /**< The device's internal storage */
+       MEDIA_CONTENT_STORAGE_EXTERNAL  = 1,            /**< The device's external storage */
+} media_content_storage_e;
+
+/**
+ * @ingroup CAPI_CONTENT_MEDIA_INFO_MODULE
+ * @brief The type of orientation.
+ */
+typedef enum {
+       MEDIA_CONTENT_ORIENTATION_NOT_AVAILABLE         = 0,            /**< Not available*/
+       MEDIA_CONTENT_ORIENTATION_NORMAL                        = 1,            /**< Normal*/
+       MEDIA_CONTENT_ORIENTATION_HFLIP                         = 2,            /**< Flip horizontal*/
+       MEDIA_CONTENT_ORIENTATION_ROT_180                       = 3,            /**< Rotate 180 degrees*/
+       MEDIA_CONTENT_ORIENTATION_VFLIP                         = 4,            /**< Flip vertical*/
+       MEDIA_CONTENT_ORIENTATION_TRANSPOSE                     = 5,            /**< Transpose*/
+       MEDIA_CONTENT_ORIENTATION_ROT_90                        = 6,            /**< Rotate 90 degrees*/
+       MEDIA_CONTENT_ORIENTATION_TRANSVERSE            = 7,            /**< Transverse*/
+       MEDIA_CONTENT_ORIENTATION_ROT_270                       = 8,            /**< Rotate 270 degrees*/
+} media_content_orientation_e;
+
+/**
+ * @ingroup CAPI_MEDIA_CONTENT_MODULE
+ * @brief The enumerations of ordering.
+ */
+typedef enum
+{
+       MEDIA_CONTENT_ORDER_ASC         = 0,            /**< ascending order*/
+       MEDIA_CONTENT_ORDER_DESC        = 1,            /**< descending order*/
+} media_content_order_e;
+
+/**
+ * @ingroup CAPI_MEDIA_CONTENT_MODULE
+ * @brief The enumerations of collations.
+ */
+typedef enum
+{
+       MEDIA_CONTENT_COLLATE_DEFAULT   = 0,            /**< default collation BINARY */
+       MEDIA_CONTENT_COLLATE_NOCASE    = 1,            /**< collation NOCASE, not case sensitive */
+       MEDIA_CONTENT_COLLATE_RTRIM             = 2,            /**< collation RTRIM, trailing space characters are ignored */
+} media_content_collation_e;
+
+/**
+ * @ingroup CAPI_MEDIA_CONTENT_MODULE
+ * @brief The enumerations of media content error
+ */
+typedef enum
+{
+       MEDIA_CONTENT_ERROR_NONE                                        = TIZEN_ERROR_NONE,                                     /**< Successful */
+       MEDIA_CONTENT_ERROR_INVALID_PARAMETER           = TIZEN_ERROR_INVALID_PARAMETER,        /**< Invalid parameter */
+       MEDIA_CONTENT_ERROR_OUT_OF_MEMORY                       = TIZEN_ERROR_OUT_OF_MEMORY,            /**< Out of memory */
+       MEDIA_CONTENT_ERROR_INVALID_OPERATION           = TIZEN_ERROR_INVALID_OPERATION,        /**< Invalid Operation */
+       MEDIA_CONTENT_FILE_NO_SPACE_ON_DEVICE           = TIZEN_ERROR_FILE_NO_SPACE_ON_DEVICE, /**< No space left on device */
+       MEDIA_CONTENT_ERROR_DB_FAILED                           = TIZEN_ERROR_CONTENT_CLASS | 0x01,     /**< DB operation failed */
+       MEDIA_CONTENT_ERROR_DB_BUSY                             = TIZEN_ERROR_CONTENT_CLASS | 0x02,     /**< DB operation BUSY */
+       MEDIA_CONTENT_ERROR_NETWORK                                     = TIZEN_ERROR_CONTENT_CLASS | 0x03,     /**< Network Fail */
+       MEDIA_CONTENT_ERROR_UNSUPPORTED_CONTENT         = TIZEN_ERROR_CONTENT_CLASS | 0x04,     /**< Unsupported Content */
+} media_content_error_e;
+
+/**
+ * @ingroup CAPI_MEDIA_CONTENT_MODULE
+ * @brief The enumerations of media group
+ */
+typedef enum {
+       MEDIA_CONTENT_GROUP_DISPLAY_NAME = 0,
+       MEDIA_CONTENT_GROUP_TYPE,
+       MEDIA_CONTENT_GROUP_MIME_TYPE,
+       MEDIA_CONTENT_GROUP_SIZE,
+       MEDIA_CONTENT_GROUP_ADDED_TIME,
+       MEDIA_CONTENT_GROUP_MODIFIED_TIME,
+       MEDIA_CONTENT_GROUP_TITLE,
+       MEDIA_CONTENT_GROUP_ARTIST,
+       MEDIA_CONTENT_GROUP_GENRE,
+       MEDIA_CONTENT_GROUP_COMPOSER,
+       MEDIA_CONTENT_GROUP_YEAR,
+       MEDIA_CONTENT_GROUP_RECORDED_DATE,
+       MEDIA_CONTENT_GROUP_COPYRIGHT,
+       MEDIA_CONTENT_GROUP_TRACK_NUM,
+       MEDIA_CONTENT_GROUP_DESCRIPTION,
+       MEDIA_CONTENT_GROUP_LONGITUDE,
+       MEDIA_CONTENT_GROUP_LATITUDE,
+       MEDIA_CONTENT_GROUP_ALTITUDE,
+       MEDIA_CONTENT_GROUP_RATING,
+       MEDIA_CONTENT_GROUP_AUTHOR,
+       MEDIA_CONTENT_GROUP_PROVIDER,
+       MEDIA_CONTENT_GROUP_CONTENT_NAME,
+       MEDIA_CONTENT_GROUP_CATEGORY,
+       MEDIA_CONTENT_GROUP_LOCATION_TAG,
+       MEDIA_CONTENT_GROUP_AGE_RATING,
+       MEDIA_CONTENT_GROUP_KEYWORD
+} media_group_e;
+
+/**
+ * @ingroup CAPI_CONTENT_MEDIA_INFO_MODULE
+ * @brief The handle to media info.
+ */
+typedef struct media_info_s *media_info_h;
+
+/**
+ * @ingroup CAPI_CONTENT_MEDIA_FOLDER_MODULE
+ * @brief The handle to media folder.
+ */
+typedef struct media_folder_s *media_folder_h;
+
+/**
+ * @ingroup CAPI_CONTENT_MEDIA_PLAYLIST_MODULE
+ * @brief The handle to media playlist.
+ */
+typedef struct media_playlist_s *media_playlist_h;
+
+/**
+ * @ingroup CAPI_CONTENT_MEDIA_TAG_MODULE
+ * @brief The handle to media tag.
+ */
+typedef struct media_tag_s *media_tag_h;
+
+/**
+ * @ingroup CAPI_CONTENT_MEDIA_BOOKMARK_MODULE
+ * @brief The handle to media bookmark.
+ */
+typedef struct media_bookmark_s *media_bookmark_h;
+
+/**
+ * @ingroup CAPI_CONTENT_MEDIA_ALBUM_MODULE
+ * @brief The handle to media album.
+ */
+typedef struct media_album_s *media_album_h;
+
+
+typedef struct media_artist_s *media_artist_h;
+typedef struct media_genre_s *media_genre_h;
+typedef struct media_composer_s *media_composer_h;
+typedef struct media_year_s *media_year_h;
+
+/**
+ * @ingroup CAPI_CONTENT_MEDIA_IMAGE_MODULE
+ * @brief The handle to image metadata.
+ */
+typedef struct image_meta_s *image_meta_h;
+
+/**
+ * @ingroup CAPI_CONTENT_MEDIA_VIDEO_META_MODULE
+ * @brief The handle to video metadata.
+ */
+typedef struct video_meta_s *video_meta_h;
+
+/**
+ * @ingroup CAPI_CONTENT_MEDIA_AUDIO_META_MODULE
+ * @brief The handle to audio metadata.
+ */
+typedef struct audio_meta_s *audio_meta_h;
+
+/**
+ * @ingroup CAPI_CONTENT_MEDIA_FILTER_MODULE
+ * @brief The handle to media filter.
+ */
+typedef struct filter_s *filter_h;
+
+/**
+ * @ingroup CAPI_MEDIA_CONTENT_MODULE
+ * @brief Called when the media scanning is finished.
+ *
+ * @param[in] error The error code
+ * @param[in] user_data The user data passed from the foreach function
+ * @pre media_content_scan()
+ * @see media_content_scan()
+ *
+ */
+typedef void (*media_scan_completed_cb)(media_content_error_e error, void * user_data);
+
+
+/**
+ * @ingroup CAPI_CONTENT_MEDIA_INFO_MODULE
+ * @brief Iterates over a list of media info.
+ *
+ * @details This callback is called for every available media info.\n
+ *
+ * @remarks To use the @a media outside this function, copy the handle with #media_info_clone() function.
+ *
+ * @param[in] media The handle to media info
+ * @param[in] user_data The user data passed from the foreach function
+ * @return true to continue with the next iteration of the loop,
+ * @return false to break out of the loop.
+ * @pre media_tag_foreach_media_from_db(), media_playlist_foreach_media_from_db(), media_genre_foreach_media_from_db(),
+ *     media_info_foreach_media_from_db(), media_folder_foreach_media_from_db() will invoke this function.
+ * @see media_info_clone()
+ * @see media_album_foreach_media_from_db()
+ * @see media_playlist_foreach_media_from_db()
+ * @see media_tag_foreach_media_from_db()
+ * @see media_info_foreach_media_from_db()
+ * @see media_folder_foreach_media_from_db()
+ */
+typedef bool (*media_info_cb)(media_info_h media, void *user_data);
+
+/**
+ * @ingroup CAPI_CONTENT_MEDIA_INFO_MODULE
+ * @brief Called when batch of media items is being inserted to media database.
+ *
+ * @param[in] error The error code
+ * @param[in] current The current count which is inserted
+ * @param[in] total The total count which will be inserted
+ * @pre media_info_insert_batch_to_db()
+ * @see media_info_insert_batch_to_db()
+ *
+ */
+typedef void (*media_insert_progress_cb)(media_content_error_e error, unsigned int current, unsigned int total, void *user_data);
+
+/**
+ * @ingroup CAPI_CONTENT_MEDIA_INFO_MODULE
+ * @brief Called when media items is inserted completely.
+ *
+ *
+ * @param[in] media The handle to media info
+ * @param[in] user_data The user data passed from the foreach function
+ * @pre media_info_insert_batch_to_db()
+ * @see media_info_insert_batch_to_db()
+ *
+ */
+typedef void (*media_insert_completed_cb)(media_content_error_e error, void * user_data);
+
+
+
+/**
+ * @ingroup CAPI_CONTENT_MEDIA_INFO_MODULE
+ * @brief Creates a thumbnail image.
+ *
+ * @details This callback is called for completion of generating the thumbnail image.\n
+ *
+ * @param[in] error The Error code
+ * @param[in] path The Path of thumbnail which is generated
+ * @param[in] user_data The user data passed from the foreach function
+ * @pre media_info_create_thumbnail()
+ * @see media_info_create_thumbnail()
+ */
+typedef void (*media_thumbnail_completed_cb)(media_content_error_e error, const char *path, void *user_data);
+
+
+/**
+ * @ingroup CAPI_CONTENT_MEDIA_FOLDER_MODULE
+ * @brief Iterates over a list of folders.
+ *
+ * @details This callback is called for every available media folder.\n
+ *
+ * @remarks To use the @a folder outside this function, copy the handle with #media_folder_clone() function.
+ *
+ * @param[in] folder The handle to media folder
+ * @param[in] user_data The user data passed from the foreach function
+ * @return true to continue with the next iteration of the loop,
+ * @return false to break out of the loop.
+ * @pre media_folder_foreach_folder_from_db() will invoke this function.
+ * @see media_folder_clone()
+ * @see media_folder_foreach_folder_from_db()
+ */
+typedef bool (*media_folder_cb)(media_folder_h folder, void *user_data);
+
+/**
+ * @ingroup CAPI_CONTENT_MEDIA_PLAYLIST_MODULE
+ * @brief Iterates over playlist list.
+ *
+ * @details This callback is called for every playlist in obtained list of playlists.\n
+ *
+ * @remarks To use the @a playlist outside this function, copy the handle with #media_playlist_clone() function.
+ *
+ * @param[in] playlist The handle to media playlist
+ * @param[in] user_data The user data passed from the foreach function
+ * @return true to continue with the next iteration of the loop,
+ * @return false to break out of the loop.
+ * @pre media_playlist_foreach_playlist_from_db() will invoke this function.
+ * @see media_playlist_clone()
+ * @see media_playlist_foreach_playlist_from_db()
+ */
+typedef bool (*media_playlist_cb)(media_playlist_h playlist, void *user_data);
+
+/**
+ * @ingroup CAPI_CONTENT_MEDIA_PLAYLIST_MODULE
+ * @brief Iterates over playlist member.
+ *
+ * @details This callback is called for every media info with playlist member ID in obtained list of media info.\n
+ *
+ * @remarks To use the @a media outside this function, copy the handle with #media_info_clone() function.
+ *
+ * @param[in] playlist_member_id The ID to member of playlist
+ * @param[in] media The handle to media info
+ * @param[in] user_data The user data passed from the foreach function
+ * @return true to continue with the next iteration of the loop,
+ * @return false to break out of the loop.
+ * @pre media_playlist_foreach_media_from_db() will invoke this function.
+ * @see media_info_clone()
+ * @see media_playlist_foreach_media_from_db()
+ */
+typedef bool(* playlist_member_cb)(int playlist_member_id, media_info_h media, void *user_data);
+
+/**
+ * @ingroup CAPI_CONTENT_MEDIA_TAG_MODULE
+ * @brief Iterates over a list of tags
+ *
+ * @details This callback is called for every tag in the obtained list of tags.\n
+ *
+ * @remarks To use the @a tag outside this function, copy the handle with #media_tag_clone() function.
+ *
+ * @param[in] tag The handle to media tag
+ * @param[in] user_data The user data passed from the foreach function
+ * @return true to continue with the next iteration of the loop,
+ * @return false to break out of the loop.
+ * @pre media_tag_foreach_tag_from_db(), media_info_foreach_tag_from_db() will invoke this function.
+ * @see media_tag_clone()
+ * @see media_tag_foreach_tag_from_db()
+ * @see media_info_foreach_tag_from_db()
+ */
+typedef bool (*media_tag_cb)(media_tag_h tag, void *user_data);
+
+/**
+ * @ingroup CAPI_CONTENT_MEDIA_BOOKMARK_MODULE
+ * @brief Iterates over bookmark list
+ *
+ * @details This callback is called for every bookmark in obtained list of bookmarks.\n
+ *
+ * @remarks To use the @a bookmark outside this function, copy the handle with #media_bookmark_clone() function.
+ *
+ * @param[in] bookmark The handle to video bookmark
+ * @param[in] user_data The user data passed from the foreach function
+ * @return true to continue with the next iteration of the loop,
+ * @return false to break out of the loop.
+ * @pre media_info_foreach_bookmark_from_db() will invoke this function.
+ * @see media_info_foreach_bookmark_from_db()
+ */
+typedef bool (*media_bookmark_cb)(media_bookmark_h bookmark, void *user_data);
+
+/**
+ * @ingroup CAPI_CONTENT_MEDIA_ALBUM_MODULE
+ * @brief Iterates over album list
+ *
+ * @details This callback is called for every album in obtained list of groups.\n
+ *
+ * @remarks To use the @a album outside this function, copy the handle with #media_album_clone() function.
+ *
+ * @param[in] album The handle to media album
+ * @param[in] user_data The user data passed from the foreach function
+ * @return true to continue with the next iteration of the loop,
+ * @return false to break out of the loop.
+ * @pre media_album_foreach_album_from_db() will invoke this function.
+ * @see media_album_clone()
+ * @see media_album_foreach_album_from_db()
+ */
+typedef bool (*media_album_cb)(media_album_h album, void *user_data);
+
+typedef bool (*media_artist_cb)(const char *artist, void *user_data);
+typedef bool (*media_genre_cb)(const char *genre, void *user_data);
+typedef bool (*media_composer_cb)(const char *composer, void *user_data);
+typedef bool (*media_year_cb)(const char *year, void *user_data);
+
+/**
+ * @ingroup CAPI_CONTENT_MEDIA_GROUP_MODULE
+ * @brief Iterates over media group list
+ *
+ * @details This callback is called for every group in obtained list of groups.\n
+ *
+ * @remarks You should not free group_name returned by this function.
+ *
+ * @param[in] group_name The name of media group
+ * @param[in] user_data The user data passed from the foreach function
+ * @return true to continue with the next iteration of the loop,
+ * @return false to break out of the loop.
+ * @pre media_group_foreach_group_from_db() will invoke this function.
+ * @see media_group_foreach_group_from_db()
+ */
+typedef bool (*media_group_cb)(const char *group_name, void *user_data);
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_CONTENT_MEDIA_INFO_MODULE
+ * @{
+ *
+ */
+#define MEDIA_ID "MEDIA_ID"    /**< media id */
+#define MEDIA_PATH "MEDIA_PATH"        /**< media full path */
+#define MEDIA_DISPLAY_NAME "MEDIA_DISPLAY_NAME"        /**< media base name */
+#define MEDIA_TYPE "MEDIA_TYPE"                /**< media type. 0-image, 1-video, 2-sound, 3-music, 4-other*/
+#define MEDIA_MIME_TYPE "MEDIA_MIME_TYPE"      /**< media mime type */
+#define MEDIA_SIZE "MEDIA_SIZE"                                /**< media mime size */
+#define MEDIA_ADDED_TIME "MEDIA_ADDED_TIME"    /**< media added time */
+#define MEDIA_MODIFIED_TIME "MEDIA_MODIFIED_TIME"              /**< media modified time */
+#define MEDIA_THUMBNAIL_PATH "MEDIA_THUMBNAIL_PATH"    /**< media thumbnail path */
+#define MEDIA_TITLE "MEDIA_TITLE"              /**< media title get from tag or file name */
+#define MEDIA_ALBUM "MEDIA_ALBUM"      /**< media album name*/
+#define MEDIA_ARTIST "MEDIA_ARTIST"            /**< media artist*/
+#define MEDIA_GENRE "MEDIA_GENRE"              /**< media genre*/
+#define MEDIA_COMPOSER "MEDIA_COMPOSER"        /**< media composer*/
+#define MEDIA_YEAR "MEDIA_YEAR"                /**< media year*/
+#define MEDIA_RECORDED_DATE "MEDIA_RECORDED_DATE"      /**< media recorded date*/
+#define MEDIA_COPYRIGHT "MEDIA_COPYRIGHT"              /**< media copyright*/
+#define MEDIA_TRACK_NUM "MEDIA_TRACK_NUM"      /**< media track number*/
+#define MEDIA_DESCRIPTION "MEDIA_DESCRIPTION"  /**< media description*/
+#define MEDIA_BITRATE "MEDIA_BITRATE"          /**< media bitrate*/
+#define MEDIA_SAMPLERATE "MEDIA_SAMPLERATE"    /**< media sample rate*/
+#define MEDIA_CHANNEL "MEDIA_CHANNEL"  /**< media channel*/
+#define MEDIA_DURATION "MEDIA_DURATION"        /**< media duration */
+#define MEDIA_LONGITUDE "MEDIA_LONGITUDE"              /**< media longitude */
+#define MEDIA_LATITUDE "MEDIA_LATITUDE"        /**< media latitude */
+#define MEDIA_ALTITUDE "MEDIA_ALTITUDE"        /**< media altitude */
+#define MEDIA_WIDTH "MEDIA_WIDTH"      /**< media width*/
+#define MEDIA_HEIGHT "MEDIA_HEIGHT"    /**< media height*/
+#define MEDIA_DATETAKEN "MEDIA_DATETAKEN"      /**< media datetaken*/
+#define MEDIA_ORIENTATION "MEDIA_ORIENTATION"  /**< media orientation*/
+#define MEDIA_PLAYED_COUNT "MEDIA_PLAYED_COUNT"        /**< media playedcount*/
+#define MEDIA_LAST_PLAYED_TIME "MEDIA_LAST_PLAYED_TIME"        /**< media last played time*/
+#define MEDIA_LAST_PLAYED_POSITION "MEDIA_LAST_PLAYED_POSITION"        /**< media last played position of file*/
+#define MEDIA_RATING "MEDIA_RATING"    /**< media rating*/
+#define MEDIA_FAVOURITE "MEDIA_FAVORITE"       /**< 0-not favourite, 1-favourite*/
+#define MEDIA_AUTHOR "MEDIA_AUTHOR"    /**< media authore*/
+#define MEDIA_PROVIDER "MEDIA_PROVIDER"        /**< media provider*/
+#define MEDIA_CONTENT_NAME "MEDIA_CONTENT_NAME"        /**< media content name*/
+#define MEDIA_CATEGORY "MEDIA_CATEGORY"        /**< media category*/
+#define MEDIA_LOCATION_TAG "MEDIA_LOCATION_TAG"        /**< media location tag*/
+#define MEDIA_AGE_RATING "MEDIA_AGE_RATING"    /**< media age rating*/
+#define MEDIA_KEYWORD "MEDIA_KEYWORD"  /**< media keyword*/
+#define MEDIA_IS_DRM "MEDIA_IS_DRM"    /**< is drm. 0-not drm, 1-drm*/
+#define MEDIA_STORAGE_TYPE "MEDIA_STORAGE_TYPE"        /**< media storage. 0-internal storage, 1-external storage*/
+/**
+ * @}
+ */
+
+
+/**
+
+ * @addtogroup CAPI_CONTENT_MEDIA_FOLDER_MODULE
+ * @{
+ */
+#define FOLDER_ID "FOLDER_ID"  /**< folder id */
+#define FOLDER_PATH "FOLDER_PATH"      /**< folder full path */
+#define FOLDER_NAME "FOLDER_NAME"              /**< folder base name */
+#define FOLDER_MODIFIED_TIME "FOLDER_MODIFIED_TIME"    /**< folder modified time */
+#define FOLDER_STORAGE_TYPE "FOLDER_STORAGE_TYPE"      /**< folder storage. 0-internal storage, 1-external storage*/
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_CONTENT_MEDIA_PLAYLIST_MODULE
+ * @{
+ */
+#define PLAYLIST_NAME "PLAYLIST_NAME"  /**< playlist name */
+#define PLAYLIST_MEMBER_ORDER "PLAYLIST_MEMBER_ORDER"  /**< playlist name */
+#define PLAYLIST_MEDIA_COUNT "PLAYLIST_MEDIA_COUNT" /**< media count in playlist view */
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_CONTENT_MEDIA_TAG_MODULE
+ * @{
+ */
+#define TAG_NAME "TAG_NAME"    /**< tag name */
+#define TAG_MEDIA_COUNT "TAG_MEDIA_COUNT"      /**< media count in tag view */
+
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup CAPI_CONTENT_MEDIA_BOOKMARK_MODULE
+ * @{
+ */
+#define BOOKMARK_MARKED_TIME "BOOKMARK_MARKED_TIME"    /**< bookmark marked time */
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+
+#endif /*__TIZEN_MEDIA_CONTENT_TYPE_H__*/
diff --git a/include/media_filter.h b/include/media_filter.h
new file mode 100755 (executable)
index 0000000..0592961
--- /dev/null
@@ -0,0 +1,166 @@
+/*
+* 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_MEDIA_FILTER_H__
+#define __TIZEN_MEDIA_FILTER_H__
+
+#include <media_content_type.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ * @addtogroup CAPI_CONTENT_MEDIA_FILTER_MODULE
+ * @{
+ */
+
+/**
+ * @brief Creates a media filter handle.
+ * @details This function creates a media filter handle. The handle can be
+ * used to get filtered information based on filter properties i.e. offset, count, condition for searching and order.
+ * @remarks The @a filter handle must be released with media_info_filter_destroy() by you.
+ * @param[out] filter A handle to media filter
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see media_filter_destroy()
+ *
+ */
+int media_filter_create(filter_h *filter);
+
+/**
+ * @brief Destroys a media filter handle.
+ * @details The function frees all resources related to the media filter handle. The filter
+ * handle no longer can be used to perform any operation. A new filter handle
+ * has to be created before the next usage.
+ *
+ * @param[in] filter The handle to media filter
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see media_filter_create()
+ *
+ */
+int media_filter_destroy(filter_h filter);
+
+/**
+ * @brief Set the media filter's offset and count.
+ * @details This function set the @a offset and @a count for the given filter used to limit number of items returned.
+ * For example, if you set the @a offset as 10 and @a count as 5, then only searched data from 10 to 14 will be returned when the filter is used with foreach functions.
+ *
+ * @param[in] filter The handle to media filter
+ * @param[in] offset The start position of the given filter(Starting from zero).
+ * @param[in] count The number of items to be searched with respect to offset
+ * @return return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see media_filter_create()
+ * @see media_filter_destroy()
+ */
+int media_filter_set_offset(filter_h filter, int offset, int count);
+
+/**
+ * @brief Set the @a condition for given @a filter.
+ *
+ * @param[in] filter The handle to media filter
+ * @param[in] condition The condition which is used WHERE clause on a query
+ * @param[in] collate_type The collate type for comparing two strings
+ * @return return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see media_filter_create()
+ * @see media_filter_destroy()
+ */
+int media_filter_set_condition(filter_h filter, const char *condition, media_content_collation_e collate_type);
+
+/**
+ * @brief Set the media filter's content @a order and @a order @a keyword either descending or ascending.
+ *
+ * @param[in] filter The handle to media filter
+ * @param[in] order_type The search order type
+ * @param[in] order_keyword The search order keyword
+ * @param[in] collate_type The collate type for comparing two strings
+ * @return return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see media_filter_create()
+ * @see media_filter_destroy()
+ */
+int media_filter_set_order(filter_h filter, media_content_order_e order_type, const char *order_keyword, media_content_collation_e collate_type);
+
+/**
+ * @brief Gets the @a offset and @a count for the given @a filter used to limit number of items returned.
+ *
+ * @param[in] filter The handle to Media filter
+ * @param[out] offset The start position of the given filter(Starting from zero)
+ * @param[out] count The number of items to be searched with respect to offset
+ * @return return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see media_filter_create()
+ * @see media_filter_destroy()
+ */
+int media_filter_get_offset(filter_h filter, int *offset, int *count);
+
+/**
+ * @brief Get the @a condition for given @a filter.
+ *
+ * @remarks @a condition must be released with free() by you.
+ * @param[in] filter The handle to media info filter
+ * @param[out] condition The condition which is used WHERE clause on a query
+ * @param[out] collate_type The collate type for comparing two strings
+ * @return return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see media_filter_create()
+ * @see media_filter_destroy()
+ */
+int media_filter_get_condition(filter_h filter, char **condition, media_content_collation_e *collate_type);
+
+/**
+ * @brief Get the media filter's content @a order and @a order @a keyword either descending or ascending.
+ *
+ * @remarks @a order_keyword must be released with free() by you.
+ * @param[in] filter The handle to media filter
+ * @param[out] order_type The search order type
+ * @param[out] order_keyword The search order keyword
+ * @param[out] collate_type The collate type for comparing two strings
+ * @return return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see media_filter_create()
+ * @see media_filter_destroy()
+ */
+int media_filter_get_order(filter_h filter, media_content_order_e* order_type, char **order_keyword, media_content_collation_e *collate_type);
+
+
+/**
+ * @}
+ */
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __TIZEN_MEDIA_FILTER_H__ */
diff --git a/include/media_folder.h b/include/media_folder.h
new file mode 100755 (executable)
index 0000000..38f7899
--- /dev/null
@@ -0,0 +1,269 @@
+/*
+* 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_MEDIA_FOLDER_H__
+#define __TIZEN_MEDIA_FOLDER_H__
+
+
+#include <media_content_type.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ * @addtogroup CAPI_CONTENT_MEDIA_FOLDER_MODULE
+ * @{
+ */
+
+/**
+ * @brief Gets the number of folder for the passed @a filter from the media database.
+ *
+ * @param[in] filter The handle to filter. \n To allow searching over different content types, you should use @a filter_h.
+ * @param[out] folder_count The count of media folder
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB operation failed
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ *
+ */
+int media_folder_get_folder_count_from_db(filter_h filter, int *folder_count);
+
+/**
+ * @brief Iterates through available media folders with optional @a filter from the media database.
+ * @details This function gets media folder handles meeting the given 
+ * @a filter. The @a callback function will be invoked for every retrieved
+ * folder. If NULL is passed to the @a filter, no filtering is applied.
+ *
+ * @param[in] filter The handle to media folder filter
+ * @param[in] callback The callback function to invoke
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @pre A filter handle has to be created by calling media_folder_filter_create()
+ * @post This function invokes media_folder_cb()
+ * @see media_content_connect()
+ * @see #media_folder_cb
+ * @see media_filter_create()
+ */
+int media_folder_foreach_folder_from_db(filter_h filter, media_folder_cb callback, void *user_data);
+
+/**
+ * @brief Gets the number of media files for the passed @a filter in the given @a folder from the media database.
+ *
+ * @param[in] folder_id The ID of media folder
+ * @param[in] filter The filter of media content
+ * @param[out] media_count The count of media folder items
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB operation failed
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ *
+ */
+int media_folder_get_media_count_from_db(const char *folder_id, filter_h filter, int *media_count);
+
+/**
+ * @brief Iterates through the media files with optional @a filter in the given @a folder from the media database.
+ * @details This function gets all media files associated with the given folder and
+ * meeting desired filter option and calls registered callback function for
+ * every retrieved media item. If NULL is passed to the @a filter, no filtering is applied.
+ *
+ * @param[in] folder_id The ID of media folder
+ * @param[in] filter The handle to media info filter
+ * @param[in] callback The callback function to invoke
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @post This function invokes media_info_cb()
+ * @see #media_info_cb
+ * @see media_content_connect()
+ * @see media_folder_filter_create()
+ */
+int media_folder_foreach_media_from_db(const char *folder_id, filter_h filter, media_info_cb callback, void *user_data);
+
+/**
+ * @brief Clones the media folder.
+ * @details This function copies the media folder handle from a source to
+ * destination. There is no media_folder_create() function. The media_folder_h is created internally and available through 
+ * media folder foreach function such as media_folder_foreach_folder_from_db(). To use this handle outside of these foreach functions, 
+ * use this function.
+ * @remark The destination handle must be released with media_folder_destroy() by you.
+ * @param[out] dst A destination handle to media folder
+ * @param[in] src The source handle to media folder
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see media_folder_destroy()
+ * @see media_folder_foreach_folder_from_db()
+ */
+int media_folder_clone(media_folder_h *dst, media_folder_h src);
+
+/**
+ * @brief Destroys the media folder.
+ * @details The function frees all resources related to the folder handle. This handle
+ * no longer can be used to perform any operation. A new handle has to
+ * be created before the next use.
+ *
+ * @param[in] folder The handle to media folder
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre A copy of the media folder handle created by calling media_folder_clone()
+ * @see media_folder_clone()
+ */
+int media_folder_destroy(media_folder_h folder);
+
+/**
+ * @brief Gets media folder's ID.
+ *
+ * @remarks @a folder_id must be released with free() by you.
+ *
+ * @param [in] folder The handle to media folder
+ * @param [out] folder_id The ID of media folder
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int media_folder_get_folder_id(media_folder_h folder, char **folder_id);
+
+/**
+ * @brief Gets the absolute path to the folder.
+ *
+ * @remarks @a path must be released with free() by you.
+ *
+ * @param[in] folder The handle to media folder
+ * @param[out] path The path of the media folder
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ */
+int media_folder_get_path(media_folder_h folder, char **path);
+
+/**
+ * @brief Gets the folder name.
+ *
+ * @remarks @a folder_name must be released with free() by you.
+ *
+ * @param[in] folder The handle to media folder
+ * @param[out] folder_name The name of the media folder
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ */
+int media_folder_get_name(media_folder_h folder, char **folder_name);
+
+/**
+ * @brief Gets the modified date of the folder.
+ *
+ * @param[in] folder The handle to media folder
+ * @param[out] date The modified date of folder
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ */
+int media_folder_get_modified_time(media_folder_h folder, time_t *date);
+
+/**
+ * @brief Gets the folder storage type.
+ *
+ * @param[in] folder The handle to media folder
+ * @param[out] storage_type The storage type of the media folder
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ */
+int media_folder_get_storage_type(media_folder_h folder, media_content_storage_e *storage_type);
+
+/**
+ * @brief Gets the media folder from the media database.
+ *
+ * @details This function creates a new media folder handle from the media database by the given folder_id.
+ * media folder will be created, which is filled with folder information.
+ *
+ * @remarks @a folder must be released with media_folder_destroy() by you.
+ *
+ * @param[in] folder_id The ID of media folder
+ * @param[out] folder The media folder handle associated with the folder ID
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ * @see media_folder_destroy()
+ *
+ */
+int media_folder_get_folder_from_db(const char *folder_id, media_folder_h *folder);
+
+/**
+ * @brief Updates the media folder to the media database.
+ *
+ * @details The function updates the given media folder in the media database. The function should be called after any change in folder attributes, to be updated to the media 
+ * database. For example, after using media_folder_set_name() for setting the name of the folder, media_folder_update_to_db() function should be called so as to update 
+ * the given folder attibutes in the media database.
+ *
+ * @param[in] folder The handle to media folder
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ * @see media_folder_destroy()
+ * @see media_folder_set_name()
+ *
+ */
+int media_folder_update_to_db(media_folder_h folder);
+
+/**
+ * @brief Sets the folder name.
+ *
+ * @param[in] folder The handle to media folder
+ * @param[in] name The name of the media folder
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @post media_folder_update_to_db()
+ *
+ */
+int media_folder_set_name(media_folder_h folder, const char *name);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __TIZEN_MEDIA_FOLDER_H__ */
diff --git a/include/media_group.h b/include/media_group.h
new file mode 100755 (executable)
index 0000000..9159a85
--- /dev/null
@@ -0,0 +1,312 @@
+/*
+* 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_MEDIA_GROUP_H__
+#define __TIZEN_MEDIA_GROUP_H__
+
+
+#include <media_content_type.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+/**
+ * @addtogroup CAPI_CONTENT_MEDIA_ALBUM_MODULE
+ * @{
+ */
+
+/**
+ * @brief Gets the number of album for the passed @a filter from the media database.
+ *
+ * @param[in] filter The handle to media filter.
+ * @param[out] album_count The count of media album
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB operation failed
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ *
+ */
+int media_album_get_album_count_from_db(filter_h filter, int *album_count);
+
+/**
+ * @brief Iterates through the media album with optional @a filter from the media database.
+ * @details This function gets all media album handles meeting the given filter.
+ * The callback function will be invoked for every retrieved media album.
+ * If NULL is passed to the filter, no filtering is applied.
+ *
+ * @param [in] filter The handle to media filter
+ * @param [in] callback The callback function to invoke
+ * @param [in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @post This function invokes media_album_cb().
+ * @see #media_album_cb
+ * @see media_content_connect()
+ * @see media_filter_create()
+ *
+ */
+int media_album_foreach_album_from_db(filter_h filter, media_album_cb callback, void *user_data);
+
+/**
+ * @brief Gets number of media info for the given album present in the media database.
+ *
+ * @param [in] album_id The ID of media album
+ * @param [in] filter The handle to media filter
+ * @param [out] media_count A count of album
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ */
+int media_album_get_media_count_from_db (int album_id, filter_h filter, int *media_count);
+
+/**
+ * @brief Iterates through the media files with optional @a filter in the given @a media @a album from the media database.
+ * @details This function gets all media files associated with the given media album and
+ * meeting desired filter option and calls registered callback function for
+ * every retrieved media info. If NULL is passed to the @a filter, no filtering is applied.
+ *
+ * @param [in] album_id The ID of media album
+ * @param [in] filter The handle to media filter
+ * @param [in] callback The callback function to invoke
+ * @param [in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @post This function invokes media_info_cb().
+ * @see #media_info_cb
+ * @see media_content_connect()
+ * @see media_filter_create()
+ */
+int media_album_foreach_media_from_db(int album_id, filter_h filter, media_info_cb callback, void *user_data);
+
+/**
+ * @brief Destroys album handle.
+ * @details Function frees all resources related to album handle. This handle
+ * no longer can be used to perform any operation. A new handle has to
+ * be created before the next use.
+ *
+ * @param [in] album The handle to media album
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre Get copy of album handle by calling media_album_clone()
+ * @see media_album_clone()
+ */
+int media_album_destroy(media_album_h album);
+
+/**
+ * @brief Clones media album.
+ * @details This function copies the media album handle from a source to
+ * destination. There is no media_album_create() function. The media_album_h is created internally and available through 
+ * media album foreach function such as media_album_foreach_album_from_db(). To use this handle outside of these foreach functions, 
+ * use this function.
+ *
+ * @remark The destination handle must be released with media_album_destroy() by you.
+ *
+ * @param [in] src The source handle to media album
+ * @param [out] dst A destination handle to media album
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see media_album_destroy()
+ * @see media_album_foreach_album_from_db()
+ */
+int media_album_clone(media_album_h *dst, media_album_h src);
+
+/**
+ * @brief Gets a ID of the album.
+ *
+ * @param [in] album The handle to media album
+ * @param [out] album_id A ID of media album
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see media_album_foreach_album_from_db()
+ *
+ */
+int media_album_get_album_id(media_album_h album, int *album_id);
+
+/**
+ * @brief Gets a name of the album.
+ *
+ * @remarks @a album_name must be released with free() by you.
+ *
+ * @param [in] album The handle to media album
+ * @param [out] album_name A name of media album handle
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ */
+int media_album_get_name(media_album_h album, char **album_name);
+
+/**
+ * @brief Gets a name of the artist from album.
+ *
+ * @remarks @a artist must be released with free() by you.
+ *
+ * @param [in] album The handle to media album
+ * @param [out] artist A name of media artist
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ */
+int media_album_get_artist(media_album_h album, char **artist);
+
+/**
+ * @brief Gets a album art path from album.
+ *
+ * @remarks @a album_art must be released with free() by you.
+ *
+ * @param [in] album The handle to media album
+ * @param [out] album_art A path of media album_art
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ */
+int media_album_get_album_art(media_album_h album, char **album_art);
+
+/**
+ * @brief Gets the media album from the media database.
+ *
+ * @details This function creates a new media album handle from the media database by the given album_id.
+ * media album will be created, which is filled with album information.
+ *
+ * @remarks @a folder must be released with media_album_destroy() by you.
+ *
+ * @param[in] album_id The ID of media album
+ * @param[out] album The album handle associated with the album ID
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ * @see media_album_destroy()
+ *
+ */
+int media_album_get_album_from_db(int album_id, media_album_h *album);
+
+
+/**
+ * @}
+ */
+
+
+/**
+* @addtogroup CAPI_CONTENT_MEDIA_GROUP_MODULE
+* @{
+*/
+
+ /**
+ * @brief Gets the number of group for the passed @a filter from the media database.
+ *
+ * @param[in] filter The handle to media filter
+ * @param [in] group The type of media group
+ * @param[out] group_count The count of media group
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB operation failed
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ *
+ */
+int media_group_get_group_count_from_db(filter_h filter, media_group_e group, int *group_count);
+
+ /**
+ * @brief Iterates through the media group with optional @a filter from the media database.
+ * @details This function gets the names of media group meeting the given filter.
+ * The callback function will be invoked for every retrieved media group.
+ * If NULL is passed to the filter, no filtering is applied.
+ *
+ * @param [in] filter The handle to media filter
+ * @param [in] group The type of media group
+ * @param [in] callback The callback function to invoke
+ * @param [in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @post This function invokes media_group_cb().
+ * @see #media_group_cb
+ * @see media_content_connect()
+ * @see media_filter_create()
+ */
+int media_group_foreach_group_from_db(filter_h filter, media_group_e group, media_group_cb callback, void *user_data);
+
+ /**
+ * @brief Gets number of media info for the given media group present in the media database.
+ *
+ * @param [in] group_name The name of media group
+ * @param [in] group The type of media group
+ * @param [in] filter The handle to media filter
+ * @param [out] media_count The count of media
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ */
+int media_group_get_media_count_from_db(const char *group_name, media_group_e group, filter_h filter, int *media_count);
+
+ /**
+ * @brief Iterates through the media files with optional @a filter in the given @a group from the media database.
+ * @details This function gets all media files associated with the given group and
+ * meeting desired filter option and calls registered callback function for
+ * every retrieved media info. If NULL is passed to the @a filter, no filtering is applied.
+ *
+ * @param [in] group_name The name of media group
+ * @param [in] group The type of media group
+ * @param [in] filter The handle to media filter
+ * @param [in] callback The callback function to invoke
+ * @param [in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @post This function invokes media_info_cb().
+ * @see #media_info_cb
+ * @see media_content_connect()
+ * @see media_filter_create()
+ */
+int media_group_foreach_media_from_db(const char *group_name, media_group_e group, filter_h filter, media_info_cb callback, void *user_data);
+
+ /**
+  * @}
+  */
+
+#ifdef __cplusplus
+ }
+#endif /* __cplusplus */
+
+#endif /* __TIZEN_MEDIA_GROUP_H__ */
diff --git a/include/media_image.h b/include/media_image.h
new file mode 100755 (executable)
index 0000000..e6d7762
--- /dev/null
@@ -0,0 +1,158 @@
+/*
+* 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_IMAGE_META_H__
+#define __TIZEN_IMAGE_META_H__
+
+#include <media_content_type.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/**
+ * @addtogroup CAPI_CONTENT_MEDIA_IMAGE_MODULE
+ * @{
+ */
+
+/**
+ * @brief Clones image metadata.
+ * @details Function copies the image metadata handle from source to destination.
+ *
+ * @remark The destination handle must be released with image_meta_destroy() by you.
+ *
+ * @param [out] dst A destination handle to image metadata
+ * @param [in] src The source handle to image metadata
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see image_meta_destroy()
+ */
+int image_meta_clone(image_meta_h *dst, image_meta_h src);
+
+/**
+ * @brief Destroys image metadata.
+ * @details The function frees all resources related to the image metadata handle. This handle
+ * no longer can be used to perform any operation. A new handle has to
+ * be created before next usage.
+ *
+ * @param [in] image The handle to image metadata
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @pre Get copy of image_meta handle by calling image_meta_clone()
+ * @see image_meta_clone()
+ */
+int image_meta_destroy(image_meta_h image);
+
+/**
+ * @brief Gets the ID of image.
+ *
+ * @param [in] image The handle to image metadata
+ * @param [out] media_id The ID of image
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int image_meta_get_media_id(image_meta_h image, char **media_id);
+
+/**
+ * @brief Gets image's width in pixels.
+ *
+ * @param [in] image The handle to image metadata
+ * @param [out] width The image width in pixels
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int image_meta_get_width(image_meta_h image, int *width);
+
+/**
+ * @brief Gets image's height in pixels.
+ *
+ * @param [in] image The handle to image metadata
+ * @param [out] height The image height in pixels
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int image_meta_get_height(image_meta_h image, int *height);
+
+/**
+ * @brief Gets the image orientation.
+ *
+ * @param [in] image The handle to image metadata
+ * @param [out] orientation The image orientation
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int image_meta_get_orientation(image_meta_h image, media_content_orientation_e *orientation);
+
+/**
+ * @brief Gets the date, when image was created as time_t structure.
+ *
+ * @param [in] image The handle to image metadata
+ * @param [out] date_taken The time, when image was taken (in seconds, since the Epoch)
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int image_meta_get_date_taken(image_meta_h image, char **date_taken);
+
+/**
+ * @brief Sets the image orientation.
+ *
+ * @param [in] image The handle to image metadata
+ * @param [in] orientation The image orientation
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @post image_meta_update_to_db()
+ */
+int image_meta_set_orientation(image_meta_h image, media_content_orientation_e orientation);
+
+/**
+ * @brief Updates the image to the media database.
+ *
+ * @details The function updates the given image meta in the media database. The function should be called after any change in image attributes, to be updated to the media 
+ * database. For example, after using image_meta_set_orientation() for setting the orientation of the image, image_meta_update_to_db() function should be called so as to update 
+ * the given image attibutes in the media database.
+ *
+ * @param[in] image The handle to image
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ * @see image_meta_set_orientation()
+ *
+ */
+int image_meta_update_to_db(image_meta_h image);
+
+/**
+ * @}
+ */
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /*__TIZEN_IMAGE_META_H__*/
diff --git a/include/media_info.h b/include/media_info.h
new file mode 100755 (executable)
index 0000000..5f6e17a
--- /dev/null
@@ -0,0 +1,945 @@
+/*
+* 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_MEDIA_INFORMATION_H__
+#define __TIZEN_MEDIA_INFORMATION_H__
+
+#include <media_content_type.h>
+
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/**
+ * @addtogroup CAPI_CONTENT_MEDIA_INFO_MODULE
+ * @{
+ */
+
+/**
+ * @brief Inserts media file into the media database.
+ * @details This function inserts an media item into the content storage.
+ * Normally, inserting a media file in database is done automatically by media server, without calling this function.
+ * This function is only called when media server is busy and user needs to get quick result of inserting
+ * e.g. Taking a photo while media server is busy and user want to see the quick snapshot of the photo taken.
+ * @remark The handle must be released with media_info_destroy() by you.
+ *
+ * @param[in] path The path to the media file
+ * @param[out] info The handle to the media info
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ */
+int media_info_insert_to_db (const char *path, media_info_h *info);
+
+/**
+ * @brief Insert media files into the media database, asynchronously.
+ * @details This function insert an media items into the content storage.
+ * Normally, inserting a media file in database is done automatically by media server, without calling this function.
+ * This function invokes media_insert_completed_cb callback function.
+ * #media_insert_completed_cb will be called when insertion to media database is finished.
+ *
+ * @param[in] path_array The path array to the media files
+ * @param[in] array_length The length of array
+ * @param[in] callback The callback to invoke when media items inserted completely
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB operation failed
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ * @see media_insert_completed_cb()
+ */
+int media_info_insert_batch_to_db(const char **path_array,unsigned int array_length, media_insert_completed_cb callback, void *user_data);
+
+
+/**
+ * @brief Deletes media file from the media database.
+ * @details This function deletes an media item from the content storage.
+ * Normally, deleting a media file in database is done automatically by media server, without calling this function.
+ * This function is only called when media server is busy and user needs to get quick result of deleting
+ *
+ * @param[in] media_id The ID to the media file
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ */
+int media_info_delete_from_db(const char *media_id);
+
+/**
+ * @brief Deletes media files from the media database. The media files to delete can be specified as a condition in a filter.
+ * @details This function deletes the media items from the content storage.
+ * Normally, deleting  media files in database are done automatically by media server, without calling this function.
+ * This function is only called when media server is busy and user needs to get quick result of deleting
+ *
+ * @param[in] filter The handle to filter
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ */
+int media_info_delete_batch_from_db(filter_h filter);
+
+
+/**
+ * @brief Destroys the media info.
+ * @details The function frees all resources related to the media info handle. This handle
+ * no longer can be used to perform any operation. New media info handle has to
+ * be created before next usage.
+ *
+ * @param[in] media The handle to media info
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre Get copy of media_info handle by calling media_info_clone()
+ * @see media_info_clone()
+ */
+int media_info_destroy(media_info_h media);
+
+/**
+ * @brief Clones the media info handle.
+ *
+ * @details This function copies the media info handle from a source to destination.
+ * There is no media_info_create() function. The media_info_h is created internally and
+ * available through media info foreach function such as media_info_foreach_media_from_db().
+ * To use this handle outside of these foreach functions, use this function.
+ * @remark The destination handle must be released with media_info_destroy() by you.
+ *
+ * @param[out] dst A destination handle to media info
+ * @param[in] src The source handle to media info
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see media_info_destroy()
+ * @see media_album_foreach_media_from_db()
+ * @see media_playlist_foreach_media_from_db()
+ * @see media_group_foreach_media_from_db
+ * @see media_tag_foreach_media_from_db()
+ * @see media_info_foreach_media_from_db()
+ * @see media_folder_foreach_media_from_db()
+ *
+ */
+int media_info_clone(media_info_h *dst, media_info_h src);
+
+/**
+ * @brief Gets the number of media info for the passed @a filter from the media database.
+ *
+ * @param[in] filter The handle to filter.
+ * @param[out] media_count The count of media tag
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB operation failed
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ *
+ */
+int media_info_get_media_count_from_db(filter_h filter, int *media_count);
+
+/**
+ * @brief Iterates through media info from the media database.
+ * @details This function gets all media info handles meeting the given @a filter. The @a callback function will be invoked for every retrieved media info.
+ * If NULL is passed to the @a filter, no filtering is applied.
+ * @param[in] filter The handle to media info filter
+ * @param[in] callback The callback function to invoke
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @post This function invokes media_info_cb().
+ * @see media_content_connect()
+ * @see #media_info_cb
+ * @see media_info_filter_create()
+ *
+ */
+int media_info_foreach_media_from_db(filter_h filter, media_info_cb callback, void *user_data);
+
+/**
+ * @brief Gets the number of media tag for the passed @a filter in the given @a media ID from the media database.
+ *
+ * @param[in] media_id The ID of media info
+ * @param[in] filter The handle to media filter
+ * @param[out] tag_count The count of media tag
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB operation failed
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ *
+ */
+int media_info_get_tag_count_from_db(const char *media_id, filter_h filter, int *tag_count);
+
+/**
+ * @brief Iterates through the media tag in the given @a media @a info from the media database.
+ * @details This function gets all media tag associated with the given @a media and calls registered callback function for every retrieved media tag.
+ * @param[in] media_id The ID of media info
+ * @param[in] filter The handle to media filter
+ * @param[in] callback The callback function to invoke
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @post This function invokes media_tag_cb().
+ * @see media_content_connect()
+ * @see #media_tag_cb
+ */
+int media_info_foreach_tag_from_db(const char *media_id, filter_h filter, media_tag_cb callback, void *user_data);
+
+/**
+ * @brief Gets the number of bookmark for the passed @a filter in the given @a media ID from the media database.
+ *
+ * @param[in] media_id The ID of media info
+ * @param[in] filter The handle to media filter
+ * @param[out] bookmark_count The count of media tag
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB operation failed
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ *
+ */
+int media_info_get_bookmark_count_from_db(const char *media_id, filter_h filter, int *bookmark_count);
+
+/**
+ * @brief Iterates through the media bookmark in the given @a media @a info from the media database.
+ * @details This function gets all media bookmark associated with the given @a media and calls registered callback function for every retrieved media bookmark.
+ * @param[in] media_id The ID of media info
+ * @param[in] filter The handle to media filter
+ * @param[in] callback The callback function to invoke
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @post This function invokes media_bookmark_cb().
+ * @see media_content_connect()
+ * @see #media_bookmark_cb
+ */
+int media_info_foreach_bookmark_from_db (const char *media_id, filter_h filter, media_bookmark_cb callback, void *user_data);
+
+/**
+ * @brief Gets image metadata for a given media info.
+ * @details This function returns an image metadata handle retrieved from the media info.
+ *
+ * @remark The @a image handle must be released with image_meta_destroy() by you.
+ *
+ * @param [in] media The handle to media info
+ * @param[out] image A handle to image meta
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see image_meta_destroy()
+ */
+int media_info_get_image(media_info_h media, image_meta_h *image);
+
+/**
+ * @brief Gets video metadata for a given media info.
+ * @details This function returns a video metadata handle retrieved from the media info handle.
+ *
+ * @remark The @a video handle must be released with video_meta_destroy() by you.
+ *
+ * @param [in] media The handle to media info
+ * @param[out] video A handle to the video meta
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see video_meta_destroy()
+ *
+ */
+int media_info_get_video(media_info_h media, video_meta_h *video);
+
+/**
+ * @brief Gets audio metadata for a given media info.
+ * @details This function returns an audio metadata handle retrieved from the media info handle.
+ *
+ * @remark The @a audio handle must be released with audio_meta_destroy() by you.
+ *
+ * @param [in] media The handle to media info
+ * @param[out] audio A handle to the audio meta
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see audio_meta_destroy()
+ */
+int media_info_get_audio(media_info_h media, audio_meta_h *audio);
+
+/**
+ * @brief Gets ID to media info.
+ *
+ *
+ * @param [in] media_id The ID if media info
+ * @param [out] media_id The ID of media tag
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int media_info_get_media_id(media_info_h media, char **media_id);
+
+/**
+ * @brief Gets path to media info.
+ *
+ * @remarks @a path must be released with free() by you.
+ *
+ * @param[in] media The handle to media info
+ * @param[out] path The path of media info
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ */
+int media_info_get_file_path(media_info_h media, char **path);
+
+/**
+ * @brief Gets name to media info.
+ *
+ * @remarks @a name must be released with free() by you.
+ *
+ * @param[in] media The handle to media info
+ * @param[out] name The name of media info
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ */
+int media_info_get_display_name(media_info_h media, char **name);
+
+/**
+ * @brief Gets media info's content type.
+ *
+ * @param[in] media The handle to media info
+ * @param[out] type The type of media content(#media_content_type_e)
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ */
+int media_info_get_media_type(media_info_h media, media_content_type_e *type);
+
+/**
+ * @brief Gets name to media info.
+ *
+ * @remarks @a mime_type must be released with free() by you.
+ *
+ * @param[in] media The handle to media info
+ * @param[out] mime_type The mime type of media info
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ */
+int media_info_get_mime_type(media_info_h media, char **mime_type);
+
+/**
+ * @brief Gets media file's size.
+ *
+ * @param[in] media The handle to media info
+ * @param[out] size The type of media content
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ */
+int media_info_get_size(media_info_h media, unsigned long long *size);
+
+/**
+ * @brief Gets added time.
+ *
+ * @param[in] media The handle to media info
+ * @param[out] added_time The added time
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ */
+int media_info_get_added_time(media_info_h media, time_t *added_time);
+
+/**
+ * @brief Gets media info's date of modification.
+ *
+ * @param[in] media The handle to media info
+ * @param[out] time The date of modification
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ */
+int media_info_get_modified_time(media_info_h media, time_t *time);
+
+/**
+ * @brief Gets the thumbnail to media info.
+ *
+ * @remarks @a path must be released with free() by you.
+ *
+ * @param[in] media The handle to media info
+ * @param[out] path The path to thumbnail of media info
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ */
+int media_info_get_thumbnail_path(media_info_h media, char **path);
+
+/**
+ * @brief Gets the description to media info.
+ *
+ * @remarks @a description must be released with free() by you.
+ *
+ * @param[in] media The handle to media info
+ * @param[out] description The description of media info
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ */
+int media_info_get_description(media_info_h media, char **description);
+
+/**
+ * @brief Gets media info's longitude.
+ *
+ * @param[in] media The handle to media info
+ * @param[out] longitude The longitude of media info
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ */
+int media_info_get_longitude(media_info_h media, double* longitude);
+
+/**
+ * @brief Gets media info's latitude.
+ *
+ * @param[in] media The handle to media info
+ * @param[out] latitude The latitude of media info
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ */
+int media_info_get_latitude(media_info_h media, double* latitude);
+
+/**
+ * @brief Gets media info's altitude of modification.
+ *
+ * @param[in] media The handle to media info
+ * @param[out] altitude The altitude of media info
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ */
+int media_info_get_altitude(media_info_h media, double* altitude);
+
+/**
+ * @brief Gets media info's rating.
+ *
+ * @param[in] media The handle to media info
+ * @param[out] rating The rating of media info
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ */
+int media_info_get_rating(media_info_h media, int *rating);
+
+/**
+ * @brief Gets the given media info's favorite status.
+ *
+ * @param [in] media The handle to media info
+ * @param [out] favorite The media favorite status(non zero if favorite, 0 if not favorite)
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ */
+int media_info_get_favorite(media_info_h media, bool* favorite);
+
+/**
+ * @brief Gets the author to media info.
+ *
+ * @remarks @a author must be released with free() by you.
+ *
+ * @param[in] media The handle to media info
+ * @param[out] author The author of media info
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ */
+int media_info_get_author(media_info_h media, char **author);
+
+/**
+ * @brief Gets the provider to media info.
+ *
+ * @remarks @a provider must be released with free() by you.
+ *
+ * @param[in] media The handle to media info
+ * @param[out] provider The provider of media info
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ */
+int media_info_get_provider(media_info_h media, char **provider);
+
+/**
+ * @brief Gets the content name to media info.
+ *
+ * @remarks @a content_name must be released with free() by you.
+ *
+ * @param[in] media The handle to media info
+ * @param[out] content_name The content name of media info
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ */
+int media_info_get_content_name(media_info_h media, char **content_name);
+
+/**
+ * @brief Gets the provider to media info.
+ *
+ * @remarks @a category must be released with free() by you.
+ *
+ * @param[in] media The handle to media info
+ * @param[out] category The category of media info
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ */
+int media_info_get_category(media_info_h media, char **category);
+
+/**
+ * @brief Gets the location_tag to media info.
+ *
+ * @remarks @a location_tag must be released with free() by you.
+ *
+ * @param[in] media The handle to media info
+ * @param[out] location_tag The location of media info
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ */
+int media_info_get_location_tag(media_info_h media, char **location_tag);
+
+/**
+ * @brief Gets the age_rating to media info.
+ *
+ * @remarks @a age_rating must be released with free() by you.
+ *
+ * @param[in] media The handle to media info
+ * @param[out] age_rating The age rating of media info
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ */
+int media_info_get_age_rating(media_info_h media, char **age_rating);
+
+/**
+ * @brief Gets the keyword to media info.
+ *
+ * @remarks @a keyword must be released with free() by you.
+ *
+ * @param[in] media The handle to media info
+ * @param[out] keyword The keyword of media info
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ */
+int media_info_get_keyword(media_info_h media, char **keyword);
+
+/**
+ * @brief Checks whether the media is protected via drm.
+ *
+ * @param[in] media The handle to media info
+ * @param[out] is_drm /@a true if the drm media,
+ *                    /@a false if not drm.
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ */
+int media_info_is_drm(media_info_h media, bool *is_drm);
+
+/**
+ * @brief Gets media info's storage_type.
+ *
+ * @param[in] media The handle to media info
+ * @param[out] storage_type The storage type of media info
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ */
+int media_info_get_storage_type(media_info_h media, media_content_storage_e *storage_type);
+
+/**
+ * @brief Gets the media info from the media database.
+ *
+ * @details This function creates a new media handle from the media database by the given media_id.
+ * media info will be created, which is filled with info information.
+ *
+ * @remarks @a media must be released with media_tag_destroy() by you.
+ *
+ * @param[in] media_id The ID of media info
+ * @param[out] media The media handle associated with the media ID
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ * @see media_info_destroy()
+ *
+ */
+int media_info_get_media_from_db(const char *media_id, media_info_h *media);
+
+/**
+ * @brief Sets display name to media info.
+ *
+ * @param[in] media The handle to media info
+ * @param[in] display_name The display name of media info
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @post media_info_update_to_db()
+ *
+ */
+int media_info_set_display_name(media_info_h media, const char *display_name);
+
+/**
+ * @brief Sets description to media info.
+ *
+ * @param[in] media The handle to media info
+ * @param[in] description The description of media info
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @post media_info_update_to_db()
+ *
+ */
+int media_info_set_description(media_info_h media, const char *description);
+
+/**
+ * @brief Sets longitude to media info.
+ *
+ * @param[in] media The handle to media info
+ * @param[in] longitude The longitude of media info
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @post media_info_update_to_db()
+ *
+ */
+int media_info_set_longitude(media_info_h media, double longitude);
+
+/**
+ * @brief Sets latitude to media info.
+ *
+ * @param[in] media The handle to media info
+ * @param[in] latitude The latitude of media info
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @post media_info_update_to_db()
+ *
+ */
+int media_info_set_latitude(media_info_h media, double latitude);
+
+/**
+ * @brief Sets altitude to media info.
+ *
+ * @param[in] media The handle to media info
+ * @param[in] altitude The altitude of media info
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @post media_info_update_to_db()
+ *
+ */
+int media_info_set_altitude(media_info_h media, double altitude);
+
+/**
+ * @brief Sets rating to media info.
+ *
+ * @param[in] media The handle to media info
+ * @param[in] rating The rating of media info
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @post media_info_update_to_db()
+ *
+ */
+int media_info_set_rating(media_info_h media, int rating);
+
+/**
+ * @brief Sets favorite to media info.
+ *
+ * @param[in] media The handle to media info
+ * @param[in] favorite The favorite of media info
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ */
+int media_info_set_favorite(media_info_h media, bool favorite);
+
+/**
+ * @brief Sets author to media info.
+ *
+ * @param[in] media The handle to media info
+ * @param[in] author The author of media info
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ */
+int media_info_set_author(media_info_h media, const char *author);
+
+/**
+ * @brief Sets provider to media info.
+ *
+ * @param[in] media The handle to media info
+ * @param[in] provider The provider of media info
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ */
+int media_info_set_provider(media_info_h media, const char *provider);
+
+/**
+ * @brief Sets content name to media info.
+ *
+ * @param[in] media The handle to media info
+ * @param[in] content_name The content name of media info
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @post media_info_update_to_db()
+ *
+ */
+int media_info_set_content_name(media_info_h media, const char *content_name);
+
+/**
+ * @brief Sets category to media info.
+ *
+ * @param[in] media The handle to media info
+ * @param[in] category The category of media info
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @post media_info_update_to_db()
+ *
+ */
+int media_info_set_category(media_info_h media, const char *category);
+
+/**
+ * @brief Sets location tag to media info.
+ *
+ * @param[in] media The handle to media info
+ * @param[in] location_tag The location of media info
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @post media_info_update_to_db()
+ *
+ */
+int media_info_set_location_tag(media_info_h media, const char *location_tag);
+
+/**
+ * @brief Sets age rating to media info.
+ *
+ * @param[in] media The handle to media info
+ * @param[in] age_rating The age rating of media info
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @post media_info_update_to_db()
+ *
+ */
+int media_info_set_age_rating(media_info_h media, const char *age_rating);
+
+/**
+ * @brief Sets keyword to media info.
+ *
+ * @param[in] media The handle to media info
+ * @param[in] keyword The keyword of media info
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @post media_info_update_to_db()
+ *
+ */
+int media_info_set_keyword(media_info_h media, const char *keyword);
+
+/**
+ * @brief Updates the media info to the media database.
+ *
+ * @details The function updates the given media info in the media database. The function should be called after any change in media, to be updated to the media
+ * database. For example, after using media_info_set_display_name() for setting the name of the media, media_info_update_to_db() function should be called so as to update
+ * the given media info attibutes in the media database.
+ *
+ * @param[in] media The handle to media info
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ * @see media_info_set_display_name()
+ * @see media_info_set_description()
+ * @see media_info_set_longitude()
+ * @see media_info_set_latitude()
+ * @see media_info_set_altitude()
+ * @see media_info_set_rating()
+ * @see media_info_set_favorite()
+ * @see media_info_set_author()
+ * @see media_info_set_provider()
+ * @see media_info_set_content_name()
+ * @see media_info_set_category()
+ * @see media_info_set_location_tag()
+ * @see media_info_set_age_rating()
+ *
+ */
+int media_info_update_to_db(media_info_h media);
+
+/**
+ * @brief Refresh the metadata of media to media database.
+ *
+ * @param[in] media_id The ID of media info
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB operation failed
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ *
+ */
+int media_info_refresh_metadata_to_db(const char *media_id);
+
+/**
+ * @brief Sets added_time to media info.
+ *
+ * @param[in] media The handle to media info
+ * @param[in] added_time The added time of media info
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @post media_info_update_to_db()
+ *
+ */
+int media_info_set_added_time(media_info_h media, time_t added_time);
+
+/**
+ * @brief Moves the media info to the given destination path in the media database.
+ *
+ * @param[in] media The handle to media info
+ * @param[in] dst_path The path of destination
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB operation failed
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ *
+ */
+int media_info_move_to_db(media_info_h media, const char* dst_path);
+
+/**
+ * @brief Creates a thumbnail image for given the media, asynchronously.
+ * @details This function creates an thumbnail image for given media item and and calls registered callback function for completion of creating the thumbnail.
+ * If there already exist a thumbnail for given media, then the path of thumbnail will be return in callback function.
+ *
+ * @param[in] media The handle to media info
+ * @param[in] callback The callback function to invoke
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB operation failed
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ */
+int media_info_create_thumbnail(media_info_h media, media_thumbnail_completed_cb callback, void *user_data);
+
+
+/**
+ * @brief Cancel to creates a thumbnail image for given the media.
+ *
+ * @param[in] media The handle to media info
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ */
+int media_info_cancel_thumbnail(media_info_h media);
+
+/**
+ * @}
+ */
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __TIZEN_MEDIA_INFORMATION_H__ */
diff --git a/include/media_info_private.h b/include/media_info_private.h
new file mode 100755 (executable)
index 0000000..9d1d6bb
--- /dev/null
@@ -0,0 +1,750 @@
+/*
+* 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_MEDIA_INFO_PRIVATE_H__
+#define __TIZEN_MEDIA_INFO_PRIVATE_H__
+
+
+#include <unistd.h>
+#include <asm/unistd.h>
+#include <string.h>
+#include <sqlite3.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <glib.h>
+#include <media-svc.h>
+#include <media_content_type.h>
+#include <dlog.h>
+#include <media-util.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "CAPI_CONTENT_MEDIA_CONTENT"
+
+#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)
+#define SQLITE3_FINALIZE(x)    {if(x != NULL) {sqlite3_finalize(x);}}
+
+#define MEDIA_CONTENT_PATH_PHONE       MEDIA_ROOT_PATH_INTERNAL        /**< File path prefix of files stored in phone */
+#define MEDIA_CONTENT_PATH_MMC                 MEDIA_ROOT_PATH_SDCARD          /**< File path prefix of files stored in mmc card */
+#define MEDIA_CONTENT_THUMB_DEFAULT_PATH       MEDIA_DATA_PATH"/.thumb/thumb_default.png"
+#define MEDIA_CONTENT_INSERT_FILES_PATH                MEDIA_DATA_PATH"/"
+
+#define MAX_QUERY_SIZE 4096
+#define MIN_QUERY_SIZE 256
+#define DEFAULT_QUERY_SIZE 1024
+#define MAX_KEYWORD_SIZE 2048
+#define COLLATE_STR_SIZE 32
+#define MEDIA_CONTENT_UUID_SIZE        36
+#define BATCH_REQUEST_MAX 300
+
+typedef enum {
+       MEDIA_CONTENT_TYPE = 0,
+       MEDIA_THUMBNAIL_TYPE,
+       MEDIA_REGISTER_TYPE
+} media_info_error_type_e;
+
+typedef enum {
+       Table_Media,
+       Table_Folder,
+       Table_Bookmark,
+       Table_Tag,
+       Table_TagMap,
+} media_info_table_e;
+
+typedef enum {
+       MEDIA_TAG_ADD,
+       MEDIA_TAG_REMOVE,
+       MEDIA_TAG_UPDATE_TAG_NAME,
+} tag_function_e;
+
+typedef enum {
+       MEDIA_PLAYLIST_ADD,
+       MEDIA_PLAYLIST_REMOVE,
+       MEDIA_PLAYLIST_UPDATE_PLAYLIST_NAME,
+       MEDIA_PLAYLIST_UPDATE_PLAY_ORDER,
+} playlist_function_e;
+
+typedef enum {
+       MEDIA_GROUP_NONE,
+       MEDIA_GROUP_ALBUM,
+       MEDIA_GROUP_FOLDER,
+       MEDIA_GROUP_PLAYLIST,
+       MEDIA_GROUP_TAG,
+       MEDIA_GROUP_BOOKMARK,
+       MEDIA_GROUP_TAG_BY_MEDIA_ID,
+       MEDIA_GROUP_BOOKMARK_BY_MEDIA_ID,
+} group_list_e;
+
+typedef struct _filter_s
+{
+       char *condition;
+       char *order_keyword;
+       media_content_order_e order_type;
+       media_content_collation_e condition_collate_type;
+       media_content_collation_e order_collate_type;
+       int offset;
+       int count;
+}filter_s;
+
+typedef struct
+{
+       char *folder_id;                                //image id, audio id, video id
+       char *path;
+       char *name;
+       time_t modified_time;
+       media_content_storage_e storage_type;
+}media_folder_s;
+
+typedef struct
+{
+       int tag_id;
+       char *name;
+}media_tag_s;
+
+typedef struct
+{
+       int bookmark_id;
+       char *media_id;
+       time_t marked_time;
+       char *thumbnail_path;
+}media_bookmark_s;
+
+typedef struct
+{
+       int album_id;
+       char *name;
+       char *artist;
+       char *album_art_path;
+}media_album_s;
+
+typedef struct
+{
+       int playlist_id;        //playlist id
+       char *name;             // playlist name
+}media_playlist_s;
+
+typedef struct
+{
+       char *media_id;
+       int width;
+       int height;
+       char *date_taken;
+       media_content_orientation_e orientation;
+}image_meta_s;
+
+typedef struct
+{
+       char *media_id;
+       char *title;
+       char *album;
+       char *artist;
+       char *genre;
+       char *composer;
+       char *year;
+       char *recorded_date;
+       char *copyright;
+       char *track_num;
+       int bitrate;
+       int duration;
+       int width;
+       int height;
+       int played_count;
+       time_t played_time;
+       int played_position;
+}video_meta_s;
+
+typedef struct
+{
+       char *media_id;
+       char *title;
+       char *album;
+       char *artist;
+       char *genre;
+       char *composer;
+       char *year;
+       char *recorded_date;
+       char *copyright;
+       char *track_num;
+       int bitrate;
+       int samplerate;
+       int channel;
+       int duration;
+       int played_count;
+       time_t played_time;
+       int played_position;
+}audio_meta_s;
+
+typedef struct
+{
+       char *media_id;                         //image id, audio id, video id
+       char *file_path;
+       char *display_name;
+       media_content_type_e media_type;
+       char *mime_type;
+       unsigned long long size;
+       time_t added_time;
+       time_t modified_time;
+       char *thumbnail_path;
+       char *description;
+       double longitude;
+       double latitude;
+       double altitude;
+       int rating;
+       int favourite;
+       char *author;
+       char *provider;
+       char *content_name;
+       char *category;
+       char *location_tag;
+       char *age_rating;
+       char *keyword;
+       int is_drm;
+       int storage_type;
+       image_meta_s *image_meta;
+       video_meta_s *video_meta;
+       audio_meta_s *audio_meta;
+}media_info_s;
+
+typedef struct
+{
+       char *name;
+}media_artist_s;
+
+typedef struct
+{
+       char *name;
+}media_genre_s;
+
+typedef struct
+{
+       char *name;
+}media_composer_s;
+
+typedef struct
+{
+       char *name;
+}media_year_s;
+
+typedef struct
+{
+       char *media_id;         // media_uuid
+       int function;                   // Add, remove, modify
+       char *tag_name;         // tag_name
+}media_tag_item_s;
+
+typedef struct
+{
+       char *media_id;         // media_uuid
+       int function;                   // Add, remove, modify
+       char *playlist_name;    // playlist_name
+       int playlist_member_id; // playlist unique id of media. Same content which has same media_id can be added to Playlist
+       int play_order;         //play_order
+}media_playlist_item_s;
+
+typedef struct _attribute_map_s
+{
+       GHashTable *attr_map;
+}attribute_s;
+
+typedef struct
+{
+       media_info_s *handle;
+       void *user_data;
+       media_thumbnail_completed_cb thumbnail_completed_cb;
+}media_thumbnail_cb_s;
+
+typedef struct
+{
+       media_insert_completed_cb insert_completed_cb;
+       char *insert_list_path;
+       void *user_data;
+} media_insert_cb_s;
+
+typedef struct attribute_s *attribute_h;
+
+
+typedef struct _media_content_cb_data {
+       media_scan_completed_cb callback;
+       void *user_data;
+} media_content_scan_cb_data;
+
+
+/* DB Table */
+#define DB_TABLE_MEDIA                 "media"
+#define DB_TABLE_FOLDER                "folder"
+#define DB_TABLE_ALBUM                 "album"
+#define DB_TABLE_TAG                   "tag"
+#define DB_TABLE_TAG_MAP               "tag_map"
+#define DB_TABLE_PLAYLIST              "playlist"
+#define DB_TABLE_PLAYLIST_MAP  "playlist_map"
+#define DB_TABLE_BOOKMARK              "bookmark"
+
+/* DB View */
+#define DB_VIEW_PLAYLIST       "playlist_view"
+#define DB_VIEW_TAG                    "tag_view"
+
+/* DB Table Alias */
+#define DB_TABLE_ALIAS_MEDIA                   "m"
+#define DB_TABLE_ALIAS_FOLDER                  "f"
+#define DB_TABLE_ALIAS_PLAYLIST                        "p"
+#define DB_TABLE_ALIAS_PLAYLIST_MAP    "pm"
+#define DB_TABLE_ALIAS_TAG                             "t"
+#define DB_TABLE_ALIAS_BOOKMARK                "b"
+#define DB_TABLE_ALIAS_ALBUM                   "a"
+
+/* DB field for media */
+#define DB_FIELD_MEDIA_ID                                      "media_uuid"
+#define DB_FIELD_MEDIA_PATH                            "path"
+#define DB_FIELD_MEDIA_DISPLAY_NAME            "file_name"
+#define DB_FIELD_MEDIA_TYPE                                    "media_type"
+#define DB_FIELD_MEDIA_MIME_TYPE                       "mime_type"
+#define DB_FIELD_MEDIA_SIZE                                    "size"
+#define DB_FIELD_MEDIA_ADDED_TIME                      "added_time"
+#define DB_FIELD_MEDIA_MODIFIED_TIME           "modified_time"
+#define DB_FIELD_MEDIA_THUMBNAIL_PATH  "thumbnail_path"
+#define DB_FIELD_MEDIA_TITLE                           "title"
+#define DB_FIELD_MEDIA_ALBUM                           "album"
+#define DB_FIELD_MEDIA_ARTIST                          "artist"
+#define DB_FIELD_MEDIA_GENRE                           "genre"
+#define DB_FIELD_MEDIA_COMPOSER                        "composer"
+#define DB_FIELD_MEDIA_YEAR                            "year"
+#define DB_FIELD_MEDIA_RECORDED_DATE           "recorded_date"
+#define DB_FIELD_MEDIA_COPYRIGHT                       "copyright"
+#define DB_FIELD_MEDIA_TRACK_NUM                       "track_num"
+#define DB_FIELD_MEDIA_DESCRIPTION                     "description"
+#define DB_FIELD_MEDIA_BITRATE                         "bitrate"
+#define DB_FIELD_MEDIA_SAMPLERATE                      "samplerate"
+#define DB_FIELD_MEDIA_CHANNEL                 "channel"
+#define DB_FIELD_MEDIA_DURATION                        "duration"
+#define DB_FIELD_MEDIA_LONGITUDE                       "longitude"
+#define DB_FIELD_MEDIA_LATITUDE                        "latitude"
+#define DB_FIELD_MEDIA_ALTITUDE                        "altitude"
+#define DB_FIELD_MEDIA_WIDTH                           "width"
+#define DB_FIELD_MEDIA_HEIGHT                          "height"
+#define DB_FIELD_MEDIA_DATETAKEN                       "datetaken"
+#define DB_FIELD_MEDIA_ORIENTATION             "orientation"
+#define DB_FIELD_MEDIA_PLAYED_COUNT            "played_count"
+#define DB_FIELD_MEDIA_LAST_PLAYED_TIME                "last_played_time"
+#define DB_FIELD_MEDIA_LAST_PLAYED_POSITION    "last_played_position"
+#define DB_FIELD_MEDIA_RATING                          "rating"
+#define DB_FIELD_MEDIA_FAVOURITE                       "favourite"
+#define DB_FIELD_MEDIA_AUTHOR                          "author"
+#define DB_FIELD_MEDIA_PROVIDER                        "provider"
+#define DB_FIELD_MEDIA_CONTENT_NAME            "content_name"
+#define DB_FIELD_MEDIA_CATEGORY                        "category"
+#define DB_FIELD_MEDIA_LOCATION_TAG            "location_tag"
+#define DB_FIELD_MEDIA_AGE_RATING                      "age_rating"
+#define DB_FIELD_MEDIA_KEYWORD                 "keyword"
+#define DB_FIELD_MEDIA_IS_DRM                          "is_drm"
+#define DB_FIELD_MEDIA_STORAGE_TYPE            "storage_type"
+
+/* DB field for folder */
+#define DB_FIELD_FOLDER_ID                             "folder_uuid"
+#define DB_FIELD_FOLDER_PATH                   "path"
+#define DB_FIELD_FOLDER_NAME                   "name"
+#define DB_FIELD_FOLDER_MODIFIED_TIME  "modified_time"
+#define DB_FIELD_FOLDER_STORAGE_TYPE   "storage_type"
+
+/* DB field for playlist */
+#define DB_FIELD_PLAYLIST_ID                                   "playlist_id"
+#define DB_FIELD_PLAYLIST_NAME                         "name"
+#define DB_FIELD_PLAYLIST_MEMBER_ORDER "play_order"
+#define DB_FIELD_PLAYLIST_MEDIA_COUNT                  "media_count"
+
+/* DB field for tag */
+#define DB_FIELD_TAG_ID                        "tag_id"
+#define DB_FIELD_TAG_NAME              "name"
+#define DB_FIELD_TAG_MEDIA_COUNT                       "media_count"
+
+/* DB field for bookmark */
+#define DB_FIELD_BOOKMARK_ID   "bookmark_id"
+#define DB_FIELD_BOOKMARK_MARKED_TIME  "marked_time"
+
+/* DB field for album*/
+#define DB_FIELD_ALBUM_ID                      "album_id"
+#define DB_FIELD_ALBUM_NAME            "name"
+#define DB_FIELD_ALBUM_ARTIST          "artist"
+
+/* DB Query Keyword */
+#define QUERY_KEYWORD_AND "AND"
+#define QUERY_KEYWORD_OR "OR"
+#define QUERY_KEYWORD_ORDER_BY "ORDER BY"
+#define QUERY_KEYWORD_LIMIT "limit"
+#define QUERY_KEYWORD_DESC "DESC"
+#define QUERY_KEYWORD_SPACE " "
+#define QUERY_KEYWORD_BRACKET ")"
+#define UPDATE_SQL "UPDATE %s SET %s WHERE %s"
+
+/* DB TABLE JOIN */
+#define SELECT_EMPTY_PLAYLIST          "SELECT playlist_id, name FROM "DB_TABLE_PLAYLIST" WHERE playlist_id NOT IN (select playlist_id from "DB_TABLE_PLAYLIST_MAP")"
+#define SELECT_EMPTY_TAG                       "SELECT tag_id, name FROM "DB_TABLE_TAG" WHERE tag_id NOT IN (SELECT tag_id FROM "DB_TABLE_TAG_MAP")"
+#define FOLDER_MEDIA_JOIN                                      "("DB_TABLE_FOLDER" AS f INNER JOIN "DB_TABLE_MEDIA" AS m ON f.folder_uuid=m.folder_uuid) WHERE m.validity=1"
+#define PLAYLISTMAP_MEDIA_JOIN                         "("DB_TABLE_PLAYLIST_MAP" AS pm INNER JOIN "DB_TABLE_MEDIA" AS m \
+                                                                                       ON (pm.media_uuid = m.media_uuid)) WHERE m.validity=1"
+#define SELECT_PLAYLIST_FROM_PLAYLIST_PLAYLISTMAP_MEDIA_JOIN           "SELECT DISTINCT p.playlist_id, p.name FROM "DB_TABLE_PLAYLIST" AS p INNER JOIN "DB_TABLE_PLAYLIST_MAP" AS pm INNER JOIN "DB_TABLE_MEDIA" AS m \
+                                                                                       ON (p.playlist_id=pm.playlist_id AND pm.media_uuid = m.media_uuid) WHERE m.validity=1"
+#define SELECT_TAG_FROM_TAG_TAGMAP_MEDIA_JOIN                                  "SELECT DISTINCT t.tag_id, t.name FROM "DB_TABLE_TAG" AS t INNER JOIN "DB_TABLE_MEDIA" AS m INNER JOIN "DB_TABLE_TAG_MAP" AS tm \
+                                                                                       ON (tm.media_uuid = m.media_uuid and tm.tag_id=t.tag_id) WHERE m.validity=1"
+#define BOOKMARK_MEDIA_JOIN                            "("DB_TABLE_BOOKMARK" AS b INNER JOIN "DB_TABLE_MEDIA" AS m \
+                                                                                       ON (b.media_uuid = m.media_uuid)) WHERE m.validity=1"
+#define ALBUM_MEDIA_JOIN                                       "("DB_TABLE_ALBUM" AS a INNER JOIN "DB_TABLE_MEDIA" AS m \
+                                                                                       ON (a.album_id = m.album_id)) WHERE m.validity=1"
+
+/* Get Group List */
+#define SELECT_ALBUM_LIST                      "SELECT DISTINCT a.album_id, a.name, a.artist, a.album_art FROM "ALBUM_MEDIA_JOIN
+#define SELECT_ARTIST_LIST                     "SELECT DISTINCT artist FROM "DB_TABLE_MEDIA" WHERE validity=1"
+#define SELECT_GENRE_LIST                      "SELECT DISTINCT genre FROM "DB_TABLE_MEDIA" WHERE validity=1"
+#define SELECT_COMPOSER_LIST           "SELECT DISTINCT composer FROM "DB_TABLE_MEDIA" WHERE validity=1 "
+#define SELECT_YEAR_LIST                               "SELECT DISTINCT year FROM "DB_TABLE_MEDIA" WHERE validity=1 "
+#define SELECT_MEDIA_GROUP_LIST        "SELECT DISTINCT %s FROM "DB_TABLE_MEDIA" WHERE validity=1 "
+
+#define SELECT_FOLDER_LIST                     "SELECT DISTINCT f.folder_uuid, f.path, f.name, f.storage_type, f.modified_time FROM "FOLDER_MEDIA_JOIN
+//#define SELECT_TAG_LIST                              SELECT_EMPTY_TAG" UNION "SELECT_TAG_FROM_TAG_TAGMAP_MEDIA_JOIN
+//#define SELECT_PLAYLIST_LIST                 SELECT_EMPTY_PLAYLIST" UNION "SELECT_PLAYLIST_FROM_PLAYLIST_PLAYLISTMAP_MEDIA_JOIN
+#define SELECT_TAG_LIST                                "SELECT DISTINCT tag_id, name FROM "DB_VIEW_TAG" WHERE 1 "
+#define SELECT_PLAYLIST_LIST           "SELECT DISTINCT playlist_id, name FROM "DB_VIEW_PLAYLIST" WHERE 1 "
+#define SELECT_BOOKMARK_LIST           "SELECT DISTINCT b.bookmark_id, b.media_uuid, b.marked_time, b.thumbnail_path FROM "BOOKMARK_MEDIA_JOIN
+
+/* Get Group Count */
+#define SELECT_ALBUM_COUNT             "SELECT COUNT(DISTINCT a.album_id) FROM "ALBUM_MEDIA_JOIN
+#define SELECT_ARTIST_COUNT            "SELECT COUNT(DISTINCT artist) FROM "DB_TABLE_MEDIA" WHERE validity=1"
+#define SELECT_GENRE_COUNT                     "SELECT COUNT(DISTINCT genre) FROM "DB_TABLE_MEDIA" WHERE validity=1"
+#define SELECT_COMPOSER_COUNT  "SELECT COUNT(DISTINCT composer) FROM "DB_TABLE_MEDIA" WHERE validity=1"
+#define SELECT_YEAR_COUNT                      "SELECT COUNT(DISTINCT year) FROM "DB_TABLE_MEDIA" WHERE validity=1"
+#define SELECT_FOLDER_COUNT            "SELECT COUNT(DISTINCT f.folder_uuid) FROM "FOLDER_MEDIA_JOIN
+//#define SELECT_TAG_COUNT                     "SELECT COUNT(*) FROM ("SELECT_TAG_LIST
+//#define SELECT_PLAYLIST_COUNT                "SELECT COUNT(*) FROM ("SELECT_PLAYLIST_LIST
+#define SELECT_TAG_COUNT                       "SELECT COUNT(DISTINCT tag_id) FROM "DB_VIEW_TAG" WHERE 1 "
+#define SELECT_PLAYLIST_COUNT          "SELECT COUNT(DISTINCT playlist_id) FROM "DB_VIEW_PLAYLIST" WHERE 1 "
+#define SELECT_BOOKMARK_COUNT  "SELECT COUNT(DISTINCT b.bookmark_id) FROM "BOOKMARK_MEDIA_JOIN
+#define SELECT_MEDIA_GROUP_COUNT       "SELECT COUNT(*) FROM ("SELECT_MEDIA_GROUP_LIST
+/*count(distinct x) count only non-null values, but select distinct X returns include null. so sync the result of count and list, don't use count(distinct x)*/
+
+/* Get Media Count of Group */
+#define SELECT_MEDIA_COUNT_FROM_MEDIA                  "SELECT COUNT(*) FROM ("SELECT_MEDIA_ITEM               //to apply limit condition. "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1"
+#define SELECT_MEDIA_COUNT_FROM_ALBUM                  "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 AND album_id='%d'"
+#define SELECT_MEDIA_COUNT_FROM_ARTIST                 "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 AND artist='%q'"
+#define SELECT_MEDIA_COUNT_FROM_GENRE                  "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 AND genre='%q'"
+#define SELECT_MEDIA_COUNT_FROM_COMPOSER               "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 AND composer='%q'"
+#define SELECT_MEDIA_COUNT_FROM_YEAR                           "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 AND year='%q'"
+#define SELECT_MEDIA_COUNT_FROM_GROUP                  "SELECT COUNT(*) FROM ("SELECT_MEDIA_FROM_GROUP         //to apply limit condition.
+#define SELECT_MEDIA_COUNT_FROM_GROUP_NULL             "SELECT COUNT(*) FROM ("SELECT_MEDIA_FROM_GROUP_NULL    //to apply limit condition.
+#define SELECT_MEDIA_COUNT_FROM_FOLDER                 "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 AND folder_uuid='%q'"
+//#define SELECT_MEDIA_COUNT_FROM_TAG                          "SELECT COUNT(*) FROM "DB_TABLE_TAG_MAP" WHERE tag_id=%d AND media_uuid IN                                                                                                      (SELECT media_uuid FROM "DB_TABLE_MEDIA" WHERE validity=1"
+//#define SELECT_MEDIA_COUNT_FROM_PLAYLIST             "SELECT COUNT(*) FROM "DB_TABLE_PLAYLIST_MAP" WHERE playlist_id=%d AND media_uuid IN                                                                                                    (SELECT media_uuid FROM "DB_TABLE_MEDIA" WHERE validity=1"
+#define SELECT_MEDIA_COUNT_FROM_TAG                            "SELECT COUNT(*) FROM "DB_VIEW_TAG" WHERE (tag_id=%d AND media_count>0) "
+#define SELECT_MEDIA_COUNT_FROM_PLAYLIST               "SELECT COUNT(*) FROM "DB_VIEW_PLAYLIST" WHERE (playlist_id=%d and media_count>0) "
+
+/* Get Group Info by Group ID*/
+#define SELECT_ALBUM_FROM_ALBUM                "SELECT * FROM "DB_TABLE_ALBUM" WHERE album_id=%d"
+#define SELECT_FOLDER_FROM_FOLDER              "SELECT * FROM "DB_TABLE_FOLDER" WHERE folder_uuid='%s'"
+#define SELECT_FOLDER_BY_PATH                  "SELECT * FROM "DB_TABLE_FOLDER" WHERE path='%q'"
+#define SELECT_PLAYLIST_FROM_PLAYLIST  "SELECT * FROM "DB_TABLE_PLAYLIST" WHERE playlist_id=%d"
+#define SELECT_TAG_FROM_TAG                    "SELECT * FROM "DB_TABLE_TAG" WHERE tag_id=%d"
+#define SELECT_TAG_BY_NAME                             "SELECT * FROM "DB_TABLE_TAG" WHERE name='%q'"
+
+/* Tag info*/
+#define INSERT_TAG_TO_TAG                                              "INSERT INTO "DB_TABLE_TAG" (name) VALUES (%Q)"
+#define REMOVE_TAG_ITEM_FROM_TAG_MAP           "DELETE FROM "DB_TABLE_TAG_MAP" WHERE tag_id=%d AND media_uuid='%q'"
+#define UPDATE_TAG_NAME_FROM_TAG                       "UPDATE "DB_TABLE_TAG" SET name='%q' WHERE tag_id=%d"
+//#define SELECT_TAG_COUNT_BY_MEDIA_ID                 "SELECT COUNT(*) FROM "DB_TABLE_TAG" WHERE tag_id IN (SELECT tag_id FROM "DB_TABLE_TAG_MAP" WHERE media_uuid = '%q')"
+//#define SELECT_TAG_LIST_BY_MEDIA_ID                          "SELECT * FROM "DB_TABLE_TAG" WHERE tag_id IN (SELECT tag_id FROM "DB_TABLE_TAG_MAP" WHERE media_uuid = '%s')"
+#define SELECT_TAG_COUNT_BY_MEDIA_ID                   "SELECT COUNT(*) FROM "DB_VIEW_TAG" WHERE media_uuid = '%q'"
+#define SELECT_TAG_LIST_BY_MEDIA_ID                            "SELECT tag_id, name FROM "DB_VIEW_TAG" WHERE media_uuid = '%s'"
+
+/* Playlist Info */
+#define INSERT_PLAYLIST_TO_PLAYLIST                                            "INSERT INTO "DB_TABLE_PLAYLIST" (name) VALUES (%Q)"
+#define UPDATE_PLAYLIST_NAME_FROM_PLAYLIST                     "UPDATE "DB_TABLE_PLAYLIST" SET name='%q' WHERE playlist_id=%d"
+#define SELECT_PLAYLIST_ID_FROM_PLAYLIST                               "SELECT playlist_id FROM "DB_TABLE_PLAYLIST" WHERE name='%q'"
+//#define SELECT_PLAYLIST_ITEM_ID_FROM_PLAYLIST_MAP            "SELECT pm._id, pm.media_uuid FROM "PLAYLISTMAP_MEDIA_JOIN" AND pm.playlist_id=%d"
+#define SELECT_PLAYLIST_ITEM_ID_FROM_PLAYLIST_VIEW             "SELECT pm_id, media_uuid FROM "DB_VIEW_PLAYLIST" WHERE playlist_id=%d "
+
+//#define SELECT_PLAY_ORDER_FROM_PLAYLIST_MAP                  "SELECT play_order FROM "DB_TABLE_PLAYLIST_MAP" WHERE playlist_id=%d and _id=%d"
+#define SELECT_PLAY_ORDER_FROM_PLAYLIST_VIEW                   "SELECT play_order FROM "DB_VIEW_PLAYLIST" WHERE playlist_id=%d and pm_id=%d"
+//#define SELECT_MAX_PLAY_ORDER_FROM_PLAYLIST_MAP      "SELECT MAX(play_order) FROM "DB_TABLE_PLAYLIST_MAP" WHERE playlist_id=%d"
+#define SELECT_MAX_PLAY_ORDER_FROM_PLAYLIST_VIEW       "SELECT MAX(play_order) FROM "DB_VIEW_PLAYLIST" WHERE playlist_id=%d"
+#define REMOVE_PLAYLIST_ITEM_FROM_PLAYLIST_MAP         "DELETE FROM "DB_TABLE_PLAYLIST_MAP" WHERE playlist_id=%d AND _id=%d"
+#define UPDATE_PLAYLIST_ORDER_FROM_PLAYLIST_MAP                "UPDATE "DB_TABLE_PLAYLIST_MAP" SET play_order=%d WHERE playlist_id=%d AND _id=%d"
+
+/* Bookmark */
+#define INSERT_BOOKMARK_TO_BOOKMARK    "INSERT INTO "DB_TABLE_BOOKMARK" (media_uuid, marked_time, thumbnail_path) VALUES ('%q', '%d', %Q)"
+#define SELECT_BOOKMARK_COUNT_BY_MEDIA_ID      "SELECT COUNT(*) FROM "DB_TABLE_BOOKMARK" WHERE media_uuid='%q'"
+#define SELECT_BOOKMARK_LIST_BY_MEDIA_ID       "SELECT * FROM "DB_TABLE_BOOKMARK" WHERE media_uuid='%q'"
+#define SELECT_BOOKMARK_LIST_BY_MEDIA_ID_USUAL "SELECT * FROM "DB_TABLE_BOOKMARK" WHERE media_uuid='%s'"
+
+/* Get Meta */
+#define MEDIA_AV_META                  "media_uuid, title, album, artist, genre, composer, year, recorded_date, copyright, track_num, bitrate, duration, played_count, last_played_time, last_played_position"
+#define MEDIA_IMAGE_META               "media_uuid, width, height, datetaken, orientation"
+#define SELECT_IMAGE_FROM_MEDIA        "SELECT "MEDIA_IMAGE_META" FROM "DB_TABLE_MEDIA" WHERE media_uuid='%s'"
+#define SELECT_AUDIO_FROM_MEDIA        "SELECT "MEDIA_AV_META", samplerate, channel FROM "DB_TABLE_MEDIA" WHERE media_uuid='%s'"
+#define SELECT_VIDEO_FROM_MEDIA        "SELECT "MEDIA_AV_META", width, height FROM "DB_TABLE_MEDIA" WHERE media_uuid='%s'"
+
+/* Update Meta*/
+#define UPDATE_AV_META_FROM_MEDIA      "UPDATE "DB_TABLE_MEDIA" SET played_count=%d, last_played_time=%d, last_played_position=%d WHERE media_uuid='%q'"
+#define UPDATE_IMAGE_META_FROM_MEDIA   "UPDATE "DB_TABLE_MEDIA" SET orientation=%d WHERE media_uuid='%q'"
+
+/* Get Media list of Group */
+//#define MEDIA_INFO_ITEM "media_uuid, path, file_name, media_type, mime_type, size, added_time, modified_time, thumbnail_path, description,
+//                                                     rating, favourite, author, provider, content_name, category, location_tag, age_rating, is_drm, storage_type"
+#define MEDIA_INFO_ITEM "media_uuid, path, file_name, media_type, mime_type, size, added_time, modified_time, thumbnail_path, description, \
+                                                       rating, favourite, author, provider, content_name, category, location_tag, age_rating, keyword, is_drm, storage_type, longitude, latitude, altitude, width, height, datetaken, orientation, title, album, artist, genre, composer, year, recorded_date, copyright, track_num, bitrate, duration, played_count, last_played_time, last_played_position, samplerate, channel"
+
+#define SELECT_MEDIA_ITEM                                      "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1"
+#define SELECT_MEDIA_FROM_MEDIA                        "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND media_uuid='%s'"
+#define SELECT_MEDIA_BY_PATH                           "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND path='%q'"
+#define SELECT_MEDIA_FROM_ALBUM                        "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND album_id=%d"
+#define SELECT_MEDIA_FROM_ARTIST                       "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND artist='%q'"
+#define SELECT_MEDIA_FROM_GENRE                        "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND genre='%q'"
+#define SELECT_MEDIA_FROM_COMPOSER             "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND author='%q'"
+#define SELECT_MEDIA_FROM_YEAR                 "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND year='%q'"
+#define SELECT_MEDIA_FROM_GROUP                        "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND %s='%q'"
+#define SELECT_MEDIA_FROM_GROUP_NULL   "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND %s IS NULL"
+#define SELECT_MEDIA_FROM_FOLDER                       "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND folder_uuid='%q'"
+#define SELECT_MEDIA_FROM_TAG                          "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE media_uuid IN (SELECT media_uuid FROM "DB_TABLE_TAG_MAP" WHERE tag_id=%d) AND validity=1"
+#define SELECT_MEDIA_FROM_PLAYLIST             "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE media_uuid IN (SELECT media_uuid FROM "DB_TABLE_PLAYLIST_MAP" WHERE playlist_id=%d) AND validity=1"
+
+/* Delete */
+#define DELETE_MEDIA_FROM_MEDIA                                "DELETE FROM "DB_TABLE_MEDIA" WHERE media_uuid='%q'"
+#define DELETE_MEDIA_FROM_MEDIA_BATCH          "DELETE FROM "DB_TABLE_MEDIA" WHERE %s"
+#define DELETE_FOLDER_FROM_FOLDER                      "DELETE FROM "DB_TABLE_FOLDER" WHERE folder_uuid='%q'"
+#define DELETE_PLAYLIST_FROM_PLAYLIST                  "DELETE FROM "DB_TABLE_PLAYLIST" WHERE playlist_id=%d"
+#define DELETE_TAG_FROM_TAG                                    "DELETE FROM "DB_TABLE_TAG" WHERE tag_id=%d"
+#define DELETE_BOOKMARK_FROM_BOOKMARK          "DELETE FROM "DB_TABLE_BOOKMARK" WHERE bookmark_id=%d"
+
+
+/**
+ *@internal
+ */
+int _content_query_prepare(sqlite3_stmt **stmt, char *select_query, char *condition_query, char *option_query);
+
+/**
+ *@internal
+ */
+int _content_error_capi(int type, int cotent_error);
+
+/**
+ *@internal
+ */
+int _content_query_sql(char *query_str);
+
+/**
+ *@internal
+ */
+MediaSvcHandle* _content_get_db_handle(void);
+
+/**
+ *@internal
+ */
+attribute_h _content_get_attirbute_handle(void);
+
+/**
+ *@internal
+ */
+attribute_h _content_get_alias_attirbute_handle(void);
+
+/**
+ *@internal
+ */
+void _media_info_item_get_detail(sqlite3_stmt *stmt, media_info_h media);
+
+/**
+ *@internal
+ */
+int _media_db_get_group_count(filter_h filter, group_list_e group_type, int *group_count);
+
+/**
+ *@internal
+ */
+int _media_db_get_media_group_count(media_group_e group, filter_h filter, int *group_count);
+
+/**
+ *@internal
+ */
+int _media_db_get_media_group(media_group_e group, filter_h filter, media_group_cb callback, void *user_data);
+
+/**
+ *@internal
+ */
+int _media_db_get_album(filter_h filter, media_album_cb callback, void *user_data);
+
+/**
+ *@internal
+ */
+int _media_db_get_folder(filter_h filter, media_folder_cb callback, void *user_data);
+
+/**
+ *@internal
+ */
+int _media_db_get_playlist(filter_h filter, media_playlist_cb callback, void *user_data);
+
+/**
+ *@internal
+ */
+int _media_db_get_playlist_item(int playlist_id, filter_h filter, playlist_member_cb callback, void *user_data);
+
+/**
+ *@internal
+ */
+int _media_db_get_tag(const char *media_id, filter_h filter, media_tag_cb callback, void *user_data);
+
+/**
+ *@internal
+ */
+int _media_db_get_bookmark(const char *media_id, filter_h filter, media_bookmark_cb callback, void *user_data);
+
+/**
+ *@internal
+ */
+int _media_db_get_group_item_count_by_id(int group_id, filter_h filter, group_list_e group_type, int *item_count);
+
+/**
+ *@internal
+ */
+int _media_db_get_group_item_count(const char *group_name, filter_h filter, group_list_e group_type, int *item_count);
+
+/**
+ *@internal
+ */
+int _media_db_get_group_item_by_id(int group_id, filter_h filter, media_info_cb callback, void *user_data, group_list_e group_type);
+
+/**
+ *@internal
+ */
+int _media_db_get_group_item(const char *group_name, filter_h filter, media_info_cb callback, void *user_data, group_list_e group_type);
+
+/**
+ *@internal
+ */
+int _media_db_get_media_group_item_count(const char *group_name, media_group_e group, filter_h filter, int *item_count);
+
+/**
+ *@internal
+ */
+int _media_db_get_media_group_item(const char *group_name, media_group_e group, filter_h filter, media_info_cb callback, void *user_data);
+
+/**
+ * @brief Creates a media filter attribute handle.
+ * @details This function creates a media filter attribute handle. The handle can be
+ * used to convert to attributes of database from attributes of user.
+ * @remarks The @a handle must be released with media_filter_attribute_destory() by you.
+ * @param[out] filter A handle to media filter attribute
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see media_filter_attribute_destory()
+ *
+ */
+int _media_filter_attribute_create(attribute_h *attr);
+
+/**
+ * @brief Add the attributes to the handle.
+ * @details This function add the attribute to handle.
+ * @param[in] filter The handle to media filter attribute
+ * @param[in] user_attr The user attribute
+ * @param[in] platform_attr The platform attribute
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see media_filter_attribute_remove()
+ *
+ */
+int _media_filter_attribute_add(attribute_h atrr, char *user_attr, char *platform_attr);
+
+/**
+ * @brief Destroys a media filter attribute handle.
+ * @details The function frees all resources related to the media filter attribute handle. The filter attribute
+ * handle no longer can be used to perform any operation. A new handle
+ * has to be created before the next usage.
+ *
+ * @param[in] filter The handle to media filter attribute
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see media_filter_create()
+ *
+ */
+int _media_filter_attribute_destory(attribute_h attr);
+
+/**
+ * @brief Replace to platform attributes from user attributes.
+ * @details This function replace to platform attributes from user attributes to generate the WHERE clause
+ * @param[in] filter The handle to media filter attribute
+ * @param[in] user_attr The user attribute
+ * @param[in] platform_attr The platform attribute
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see media_filter_attribute_create()
+ * @see media_filter_attribute_destory()
+ *
+ */
+int _media_filter_attribute_generate(attribute_h attr, char *condition, media_content_collation_e collate_type, char **generated_condition);
+int _media_filter_attribute_option_generate(attribute_h attr, filter_h filter, char **generated_option);
+
+#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 media_content_gettid() syscall(__NR_gettid)
+
+#define media_content_retv_if(expr, val) do { \
+                       if(expr) { \
+                               LOGE(FONT_COLOR_RED"[%d]", media_content_gettid());    \
+                               return (val); \
+                       } \
+               } while (0)
+
+#define media_content_debug(fmt, arg...) do { \
+                       LOGD(FONT_COLOR_RESET"[%d]"fmt"", media_content_gettid(), ##arg);     \
+               } while (0)
+
+#define media_content_info(fmt, arg...) do { \
+                       LOGD(FONT_COLOR_GREEN"[%d]"fmt"", media_content_gettid() ,##arg);     \
+               } while (0)
+
+#define media_content_error(fmt, arg...) do { \
+                       LOGE(FONT_COLOR_RED"[%d]"fmt"",media_content_gettid(), ##arg);     \
+               } while (0)
+
+#define media_content_debug_func() do { \
+                       LOGD(FONT_COLOR_RESET"[%d]", media_content_gettid());     \
+               } while (0)
+
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /*__TIZEN_MEDIA_INFO_PRIVATE_H__*/
diff --git a/include/media_playlist.h b/include/media_playlist.h
new file mode 100755 (executable)
index 0000000..5786395
--- /dev/null
@@ -0,0 +1,327 @@
+/*
+* 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_MEDIA_PLAYLIST_H__
+#define __TIZEN_MEDIA_PLAYLIST_H__
+
+#include <media_content_type.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+
+/**
+ * @addtogroup CAPI_CONTENT_MEDIA_PLAYLIST_MODULE
+ * @{
+ */
+
+/**
+ * @brief Gets the number of playlist for the passed @a filter from the media database.
+ *
+ * @param[in] filter The handle to filter.
+ * @param[out] playlist_count The count of media playlist
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB operation failed
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ *
+ */
+int media_playlist_get_playlist_count_from_db(filter_h filter, int *playlist_count);
+
+/**
+ * @brief Iterates through the media playlist with optional @a filter from the media database.
+ * @details This function gets all media playlist handles meeting the given filter.
+ * The callback function will be invoked for every retrieved media playlist.
+ * If NULL is passed to the filter, no filtering is applied.
+ *
+ * @param [in] filter The handle to audio filter
+ * @param [in] callback The callback function to invoke
+ * @param [in] user_data User data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @post This function invokes media_playlist_cb().
+ * @see #media_playlist_cb
+ * @see media_content_connect()
+ * @see media_filter_create()
+ *
+ */
+int media_playlist_foreach_playlist_from_db(filter_h filter, media_playlist_cb callback, void *user_data);
+
+/**
+ * @brief Gets number of media info for the given playlist present in the media database.
+ *
+ * @param [in] playlist_id The ID of media playlist
+ * @param [in] filter The handle to media filter
+ * @param [out] media_count The number of media items
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ *
+ */
+int media_playlist_get_media_count_from_db(int playlist_id, filter_h filter, int *media_count);
+
+/**
+ * @brief Iterates through the media files with optional @a filter in the given @a audio @a playlist from the media database.
+ * @details This function gets all media files associated with the given media playlist and
+ * meeting desired filter option and calls registered callback function for
+ * every retrieved media info. If NULL is passed to the @a filter, no filtering is applied.
+ *
+ * @param [in] playlist_id The ID of media playlist
+ * @param [in] filter The handle to audio filter
+ * @param [in] callback The callback function to invoke
+ * @param [in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @post This function invokes media_info_cb().
+ * @see #media_info_cb
+ * @see media_content_connect()
+ * @see media_filter_create()
+ *
+ */
+int media_playlist_foreach_media_from_db(int playlist_id, filter_h filter, playlist_member_cb callback, void *user_data);
+
+/**
+ * @brief Inserts a new playlist with given name in the media database.
+ *
+ * @remark The created handle must be released with media_playlist_destroy() by you.
+ * @param [in] name The name of the inserted playlist
+ * @param [out] playlist A created handle to media playlist
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ * @see media_playlist_delete_from_db()
+ *
+ */
+int media_playlist_insert_to_db(const char *name, media_playlist_h *playlist);
+
+/**
+ * @brief Deletes the given playlist from the media database.
+ *
+ * @param [in] playlist The handle to media playlist
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ * @see media_playlist_insert_to_db()
+ *
+ */
+int media_playlist_delete_from_db(int playlist_id);
+
+/**
+ * @brief Gets the media playlist from the media database.
+ *
+ * @details This function creates a new media playlist handle from the media database by the given playlist_id.
+ * media playlist will be created, which is filled with playlist information.
+ *
+ * @remarks @a playlist must be released with media_playlist_destroy() by you.
+ *
+ * @param[in] playlist_id The ID of media playlist
+ * @param [in] filter The handle to audio filter
+ * @param[out] playlist The media playlist handle associated with the playlist ID
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ * @see media_playlist_destroy()
+ *
+ */
+int media_playlist_get_playlist_from_db(int playlist_id, filter_h filter, media_playlist_h *playlist);
+
+/**
+ * @brief Destroys a playlist handle.
+ * @details Function frees all resources related to playlist handle. This
+ * handle no longer can be used to perform any operation. New handle has to
+ * be created before next usage.
+ *
+ * @param [in] playlist The handle to media playlist
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see media_playlist_clone()
+ * @pre Get copy of playlist handle by calling media_playlist_clone() or media_playlist_insert_to_db()
+ * @see media_playlist_clone()
+ *
+ */
+int media_playlist_destroy(media_playlist_h playlist);
+
+/**
+ * @brief Clones playlist handle.
+ * @details This function copies the media playlist handle from a source to
+ * destination. There is no media_playlist_create() function. The media_playlist_h is created internally and available through 
+ * media playlist foreach function such as media_playlist_foreach_playlist_from_db(). To use this handle outside of these foreach functions, 
+ * use this function.
+ *
+ * @remark The destination handle must be released with media_playlist_destroy() by you.
+ *
+ * @param [in] src The source handle to media playlist
+ * @param [out] dst A destination handle to media playlist
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see media_playlist_destroy()
+ * @see media_playlist_foreach_playlist_from_db()
+ */
+int media_playlist_clone(media_playlist_h *dst, media_playlist_h src);
+
+/**
+ * @brief Gets media playlist's ID.
+ *
+ * @param [in] playlist The handle to media playlist
+ * @param [out] playlist_id The ID of media playlist
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int media_playlist_get_playlist_id(media_playlist_h playlist, int *playlist_id);
+
+/**
+ * @brief Gets a name of the playlist.
+ *
+ * @remarks @a playlist_name must be released with free() by you.
+ *
+ * @param [in] playlist The handle to media playlist
+ * @param [out] playlist_name The playlist name
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ */
+int media_playlist_get_name(media_playlist_h playlist, char **playlist_name);
+
+/**
+ * @brief Sets the playlist name.
+ *
+ * @param[in] playlist The handle to media playlist
+ * @param[in] playlist_name The name of the media playlist
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @post media_playlist_update_to_db()
+ *
+ */
+int media_playlist_set_name(media_playlist_h playlist, const char *playlist_name);
+
+/**
+ * @brief Sets the played order in the playlist.
+ *
+ * @param[in] playlist The handle to media playlist
+ * @param[in] playlist_member_id The ID to member of playlist
+ * @param[in] play_order The played order
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @post media_playlist_update_to_db()
+ *
+ */
+int media_playlist_set_play_order(media_playlist_h playlist, int playlist_member_id, int play_order);
+
+/**
+ * @brief Adds a new media info to the playlist.
+ *
+ * @param[in] playlist The handle to media playlist
+ * @param[in] media_id The ID to media info which is added
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @post media_playlist_update_to_db()
+ * @see media_content_connect()
+ * @see media_playlist_remove_media()
+ *
+ */
+int media_playlist_add_media(media_playlist_h playlist, const char *media_id);
+
+/**
+ * @brief Removes the playlist member related with media from the given playlist.
+ *
+ * @param[in] playlist The handle to media playlist
+ * @param[in] playlist_member_id The ID to member of playlist
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @post media_playlist_update_to_db()
+ * @see media_content_connect()
+ * @see media_playlist_add_media()
+ *
+ */
+int media_playlist_remove_media(media_playlist_h playlist, int playlist_member_id);
+
+/**
+ * @brief Gets the played order in the playlist.
+ *
+ * @param[in] playlist The handle to media playlist
+ * @param[in] playlist_member_id The ID to member of playlist
+ * @param [out] play_order The played order
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int media_playlist_get_play_order(media_playlist_h playlist, int playlist_member_id, int *play_order);
+
+/**
+ * @brief Updates the media playlist to the media database.
+ *
+ * @details The function updates the given media playlist in the media database. The function should be called after any change in playlist, to be updated to the media 
+ * database. For example, after using media_playlist_set_name() for setting the name of the playlist, media_playlist_update_to_db() function should be called so as to update 
+ * the given playlist attibutes in the media database.
+ *
+ * @param[in] playlist The handle to media playlist
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ * @see media_playlist_destroy()
+ * @see media_playlist_add_media()
+ * @see media_playlist_remove_media()
+ * @see media_playlist_set_name()
+ * @see media_playlist_set_play_order()
+ *
+ */
+int media_playlist_update_to_db(media_playlist_h playlist);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /*__TIZEN_MEDIA_PLAYLIST_H__*/
diff --git a/include/media_tag.h b/include/media_tag.h
new file mode 100755 (executable)
index 0000000..2d0eee8
--- /dev/null
@@ -0,0 +1,300 @@
+/*
+* 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_MEDIA_TAG_H__
+#define __TIZEN_MEDIA_TAG_H__
+
+#include <media_content_type.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/**
+ * @addtogroup CAPI_CONTENT_MEDIA_TAG_MODULE
+ * @{
+ */
+
+/**
+ * @brief Inserts a new tag in the media database.
+ *
+ * @remark The created tag handle must be released with media_tag_destroy() by you.
+ *
+ * @param[in] tag_name The tag name to be inserted
+ * @param[out] tag A created handle to media tag
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ * @see media_tag_delete_from_db()
+ * @see media_tag_destroy()
+ *
+ */
+int media_tag_insert_to_db(const char *tag_name, media_tag_h *tag);
+
+/**
+ * @brief Deletes a given tag from the media database.
+ *
+ * @param[in] tag The handle to media tag
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ * @see media_tag_insert_to_db()
+ *
+ */
+int media_tag_delete_from_db(int tag_id);
+
+/**
+ * @brief Gets the number of tag for the passed @a filter from the media database.
+ *
+ * @param[in] filter The handle to filter
+ * @param[out] tag_count The count of media tag
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB operation failed
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ *
+ */
+int media_tag_get_tag_count_from_db(filter_h filter, int *tag_count);
+
+/**
+ * @brief Iterates through tags from the media database.
+ * @details This function gets all tags meeting a desired @a filter
+ * and calls a registered callback function for every retrieved tag. If NULL is passed to the @a filter, no filtering is applied.
+ *
+ * @param[in] filter The handle to tag filter
+ * @param[in] callback The callback function to invoke
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @post This function invokes media_tag_cb().
+ * @see media_content_connect()
+ * @see #media_tag_cb
+ * @see media_filter_create()
+ *
+ */
+int media_tag_foreach_tag_from_db (filter_h filter, media_tag_cb callback, void *user_data);
+
+/**
+ * @brief Gets the number of media files for the passed @a filter in the given @a tag from the media database.
+ *
+ * @param[in] tag_id The ID of media tag
+ * @param[in] filter The handle to media filter
+ * @param[out] media_count The count of media items
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB operation failed
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ *
+ */
+int media_tag_get_media_count_from_db (int tag_id, filter_h filter, int *media_count);
+
+/**
+ * @brief Iterates through media items for a given tag from the media database.
+ * @details This function gets all media items associated with a given tag and
+ * meeting a desired @a filter and calls a registered callback function for
+ * every retrieved media item. If NULL is passed to the @a filter, no filtering is applied.
+ *
+ * @param[in] tag_id The ID of media tag
+ * @param[in] filter The handle to media filter
+ * @param[in] callback The callback function to invoke
+ * @param[in] user_data The user data to be passed to the callback function
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @post This function invokes media_info_cb().
+ * @see media_content_connect()
+ * @see #media_info_cb
+ * @see media_filter_create()
+ */
+int media_tag_foreach_media_from_db(int tag_id, filter_h filter, media_info_cb callback, void *user_data);
+
+/**
+ * @brief Clones the media tag.
+ * @details This function copies the media tag handle from a source to destination.
+ * There is no media_tag_create() function. The media_tag_h is created internally and available through media tag foreach function 
+ * such as media_tag_foreach_tag_from_db().
+ * To use this handle outside of these foreach functions, use this function.
+ * @remark The destination handle must be released with media_tag_destroy() by you.
+ *
+ * @param[out] dst A destination handle to media tag
+ * @param[in] src The source handle to media tag
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @see media_tag_destroy()
+ *
+ */
+int media_tag_clone(media_tag_h *dst, media_tag_h src);
+
+/**
+ * @brief Destroys the media tag.
+ * @details This function frees all resources related to the tag handle. The tag handle can no longer
+ * be used for any operation. A new tag handle has to be created before next usage.
+ *
+ * @param[in] tag The media tag handle
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre A copy of the media tag handle created by calling media_tag_clone() or media_tag_insert_to_db()
+ * @see media_tag_clone()
+ * @see media_tag_insert_to_db()
+ *
+ */
+int media_tag_destroy(media_tag_h tag);
+
+/**
+ * @brief Gets media tag's ID.
+ *
+ *
+ * @param [in] tag The handle to media tag
+ * @param [out] tag_id The ID of media tag
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int media_tag_get_tag_id(media_tag_h tag, int *tag_id);
+
+/**
+ * @brief Gets the tag name.
+ *
+ * @remarks @a tag_name must be released with free() by you.
+ *
+ * @param[in] tag The handle to media tag
+ * @param[out] tag_name The name of the tag
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ *
+ */
+int media_tag_get_name(media_tag_h tag, char **tag_name);
+
+/**
+ * @brief Gets the media tag from the media database.
+ *
+ * @details This function creates a new media tag handle from the media database by the given tag_id.
+ * media tag will be created, which is filled with tag information.
+ *
+ * @remarks @a folder must be released with media_tag_destroy() by you.
+ *
+ * @param[in] tag_id The ID of media tag
+ * @param[out] tag The media tag handle associated with the tag ID
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ * @see media_tag_destroy()
+ *
+ */
+int media_tag_get_tag_from_db(int tag_id, media_tag_h *tag);
+
+/**
+ * @brief Adds a new media info to the tag.
+ *
+ * @param[in] tag The handle to media tag
+ * @param[in] media_id The ID to media info which is added
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @post media_tag_update_to_db()
+ * @see media_content_connect()
+ * @see media_tag_remove_media()
+ *
+ */
+int media_tag_add_media(media_tag_h tag, const char *media_id);
+
+/**
+ * @brief Removes the media info from the given tag.
+ *
+ * @param[in] tag The handle to media tag
+ * @param[in] media_id The ID to media info which is removed
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @post media_tag_update_to_db()
+ * @see media_content_connect()
+ * @see media_tag_add_media()
+ *
+ */
+int media_tag_remove_media(media_tag_h tag, const char *media_id);
+
+/**
+ * @brief Sets the tag name.
+ *
+ * @param[in] tag The handle to media tag
+ * @param[in] tag_name The name of the media tag
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @post media_tag_update_to_db()
+ *
+ */
+int media_tag_set_name(media_tag_h tag, char *tag_name);
+
+/**
+ * @brief Updates the media tag to the media database.
+ *
+ * @details The function updates the given media tag in the media database. The function should be called after any change in tag attributes, to be updated to the media 
+ * database. For example, after using media_tag_set_name() for setting the name of the tag, media_tag_update_to_db() function should be called so as to update 
+ * the given tag attibutes in the media database.
+ *
+ * @param[in] tag The handle to media tag
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ * @see media_tag_destroy()
+ * @see media_tag_add_media()
+ * @see media_tag_remove_media()
+ * @see media_tag_set_name()
+ *
+ */
+int media_tag_update_to_db(media_tag_h tag);
+
+/**
+ * @}
+ */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __TIZEN_MEDIA_TAG_H__ */
diff --git a/include/media_util_private.h b/include/media_util_private.h
new file mode 100755 (executable)
index 0000000..59dd538
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+* 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_MEDIA_UTIL_PRIVATE_H__
+#define __TIZEN_MEDIA_UTIL_PRIVATE_H__
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/**
+ *@internal
+ */
+int _media_util_get_store_type_by_path(const char *path, int *storage_type);
+
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /*__TIZEN_MEDIA_UTIL_PRIVATE_H__*/
diff --git a/include/media_video.h b/include/media_video.h
new file mode 100755 (executable)
index 0000000..acd3262
--- /dev/null
@@ -0,0 +1,359 @@
+/*
+* 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_VIDEO_META_H__
+#define __TIZEN_VIDEO_META_H__
+
+#include <media_content_type.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+
+/**
+ * @addtogroup CAPI_CONTENT_MEDIA_VIDEO_META_MODULE
+ * @{
+ */
+
+/**
+ * @brief Clones video metadata.
+ * @details This function copies the video metadata handle from a source to
+ * destination.
+
+ * @remark The destination handle must be released with video_meta_destroy() by you.
+ *
+ * @param [out] dst A destination handle to video metadata
+ * @param [in] src The source handle to video metadata
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ * @see video_meta_destroy()
+ */
+int video_meta_clone(video_meta_h *dst, video_meta_h src);
+
+/**
+ * @brief Destroys video metadata.
+ * @details Function frees all resources related to video metadata handle. This handle
+ * no longer can be used to perform any operation. A new handle has to
+ * be created before the next use.
+ *
+ * @param [in] video The handle to video metadata
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre Get copy of video metadata handle by calling video_meta_clone()
+ * @see video_meta_clone()
+ *
+ */
+int video_meta_destroy(video_meta_h video);
+
+/**
+ * @brief Gets id of media of given video metadata.
+ *
+ * @remarks @a media id must be released with free() by you.
+ *
+ * @param [in] video The handle to video metadata
+ * @param [out] media_id The id of the video
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int video_meta_get_media_id(video_meta_h video, char **media_id);
+
+/**
+ * @brief Gets the video's title.
+ *
+ * @remarks @a title must be released with free() by you.
+ *
+ * @param [in] video The handle to video metadata
+ * @param [out] title The title of video metadata
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int video_meta_get_title(video_meta_h video, char **title);
+
+/**
+ * @brief Gets the video's album.
+ * If the value is an empty string, the method returns "Unknown".
+ *
+ * @remarks @a album must be released with free() by you.
+ *
+ * @param [in] video The handle to video metadata
+ * @param [out] album The video album or NULL
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int video_meta_get_album(video_meta_h video, char **album);
+
+/**
+ * @brief Gets the video's artist.
+ * If the value is an empty string, the method returns "Unknown".
+ *
+ * @remarks @a artist must be released with free() by you.
+ *
+ * @param [in] video The handle to video metadata
+ * @param [out] artist The artist of video metadata
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int video_meta_get_artist(video_meta_h video, char **artist);
+
+/**
+ * @brief Gets the video's genre.
+ * If the value is an empty string, the method returns "Unknown".
+ *
+ * @remarks @a genre must be released with free() by you.
+ *
+ * @param [in] video The handle to video metadata
+ * @param [out] genre The genre of video metadata
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int video_meta_get_genre(video_meta_h video, char **genre);
+
+/**
+ * @brief Gets the video's composer.
+ * If the value is an empty string, the method returns "Unknown".
+ *
+ * @remarks @a composer must be released with free() by you.
+ *
+ * @param [in] video The handle to video metadata
+ * @param [out] composer The composer of video metadata
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int video_meta_get_composer(video_meta_h video, char **composer);
+
+/**
+ * @brief Gets the video's year.
+ * If the value is an empty string, the method returns "Unknown".
+ *
+ * @remarks @a year must be released with free() by you.
+ *
+ * @param [in] video The handle to video metadata
+ * @param [out] year The year of video metadata
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int video_meta_get_year(video_meta_h video, char **year);
+
+/**
+ * @brief Gets the video's recorded_date.
+ *
+ * @remarks @a recorded_date must be released with free() by you.
+ *
+ * @param [in] video The handle to video metadata
+ * @param [out] recorded_date The recorded_date of video metadata
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int video_meta_get_recorded_date(video_meta_h video, char **recorded_date);
+
+/**
+ * @brief Gets the video's copyright.
+ *
+ * @remarks @a copyright must be released with free() by you.
+ *
+ * @param [in] video The handle to video metadata
+ * @param [out] copyright The copyright of video metadata
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int video_meta_get_copyright(video_meta_h video, char **copyright);
+
+/**
+ * @brief Gets the video's track number.
+ * If the value is an empty string, the method returns "Unknown".
+ *
+ * @remarks @a track_num must be released with free() by you.
+ *
+ * @param [in] video The handle to video metadata
+ * @param [out] track_num The track number of video metadata
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int video_meta_get_track_num(video_meta_h video, char **track_num);
+
+/**
+ * @brief Gets the video's bit rate.
+ *
+ * @remarks @a bit_rate must be released with free() by you.
+ *
+ * @param [in] video The handle to video metadata
+ * @param [out] bit_rate The bit rate of video metadata
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
+ */
+int video_meta_get_bit_rate(video_meta_h video, int *bit_rate);
+
+/**
+ * @brief Gets duration of video metadata.
+ *
+ * @param [in] video The handle to video metadata
+ * @param [out] duration The video duration in milliseconds
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int video_meta_get_duration(video_meta_h video, int *duration);
+
+/**
+ * @brief Gets the video's width in pixels.
+ *
+ * @param [in] video The handle to video metadata
+ * @param [out] width The video width in pixels
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int video_meta_get_width(video_meta_h video, int *width);
+
+/**
+ * @brief Gets the video's height in pixels.
+ *
+ * @param [in] video The handle to video metadata
+ * @param [out] height The video height in pixels
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int video_meta_get_height(video_meta_h video, int *height);
+
+/**
+ * @brief Gets the video's played count.
+ *
+ * @param [in] video The handle to video metadata
+ * @param [out] played_count The number of played
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int video_meta_get_played_count(video_meta_h video, int *played_count);
+
+/**
+ * @brief Gets the video's time last played parameter.
+ *
+ * @param [in] video The handle to video metadata
+ * @param [out] played_time The time last played in the video
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int video_meta_get_played_time(video_meta_h video, time_t *played_time);
+
+/**
+ * @brief Gets the video's position played parameter.
+ * @details Function returns video's elapsed playback time parameter as period
+ * starting from the beginning of the movie.
+ *
+ * @param [in] video The handle to video metadata
+ * @param [out] played_position The position from the beginning of the video (in milliseconds)
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ */
+int video_meta_get_played_position(video_meta_h video, int *played_position);
+
+/**
+ * @brief Sets the video's played count.
+ *
+ * @param [in] video The handle to video metadata
+ * @param [in] played_count The number of played
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @post video_meta_update_to_db()
+ */
+int video_meta_set_played_count(video_meta_h video, int played_count);
+
+/**
+ * @brief Sets the video's time last played parameter.
+ *
+ * @param [in] video The handle to video metadata
+ * @param [in] played_time The time last played in the video
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @post video_meta_update_to_db()
+ */
+int video_meta_set_played_time(video_meta_h video, time_t played_time);
+
+/**
+ * @brief Sets the video's position played parameter.
+ * @details Function returns video's elapsed playback time parameter as period
+ * starting from the beginning of the movie.
+ *
+ * @param [in] video The handle to video metadata
+ * @param [in] played_position The position from the beginning of the video (in milliseconds)
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @post video_meta_update_to_db()
+ */
+int video_meta_set_played_position(video_meta_h video, int played_position);
+
+/**
+ * @brief Updates the video to the media database.
+ *
+ * @details The function updates the given video meta in the media database. The function should be called after any change in video attributes, to be updated to the media
+ * database. For example, after using video_meta_get_played_time() for setting the played time of the video, video_meta_update_to_db() function should be called so as to update
+ * the given video attibutes in the media database.
+ *
+ * @param[in] image The handle to image
+ * @return 0 on success, otherwise a negative error value.
+ * @retval #MEDIA_CONTENT_ERROR_NONE Successful
+ * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
+ * @pre This function requires opened connection to content service by media_content_connect().
+ * @see media_content_connect()
+ * @see video_meta_set_played_time()
+ * @see video_meta_set_played_count()
+ * @see video_meta_set_played_position()
+ */
+int video_meta_update_to_db(video_meta_h video);
+
+/**
+ *@}
+ */
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /*__TIZEN_VIDEO_META_H__*/
diff --git a/packaging/capi-content-media-content.spec b/packaging/capi-content-media-content.spec
new file mode 100755 (executable)
index 0000000..539cb5a
--- /dev/null
@@ -0,0 +1,64 @@
+Name:       capi-content-media-content
+Summary:    A Media content library in SLP C API
+Version: 0.2.36
+Release:    0
+Group:      System/Libraries
+License:    Apache License, Version 2.0
+Source0:    %{name}-%{version}.tar.gz
+BuildRequires:  cmake
+BuildRequires:  pkgconfig(dlog)
+BuildRequires:  pkgconfig(capi-base-common)
+BuildRequires:  pkgconfig(libmedia-service)
+BuildRequires:  pkgconfig(media-thumbnail)
+BuildRequires:  pkgconfig(libmedia-utils)
+
+
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
+
+%description
+
+
+%package devel
+Summary:  A Media content library in SLP C API (Development)
+Group:    Development/Libraries
+Requires: %{name} = %{version}-%{release}
+
+%description devel
+
+%prep
+%setup -q
+
+
+%build
+MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
+cmake . -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER}
+
+
+make %{?jobs:-j%jobs}
+
+%install
+rm -rf %{buildroot}
+%make_install
+
+#License
+mkdir -p %{buildroot}/%{_datadir}/license
+cp -rf %{_builddir}/%{name}-%{version}/LICENSE.APLv2.0 %{buildroot}/%{_datadir}/license/%{name}
+
+%post -p /sbin/ldconfig
+
+%postun -p /sbin/ldconfig
+
+
+%files
+%manifest capi-content-media-content.manifest
+%{_libdir}/libcapi-content-media-content.so.*
+#License
+%{_datadir}/license/%{name}
+
+%files devel
+%{_includedir}/media-content/*.h
+%{_libdir}/pkgconfig/*.pc
+%{_libdir}/libcapi-content-media-content.so
+
+
diff --git a/src/media_audio.c b/src/media_audio.c
new file mode 100755 (executable)
index 0000000..651b6bf
--- /dev/null
@@ -0,0 +1,718 @@
+/*
+* 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_content.h>
+#include <media_info_private.h>
+
+
+int audio_meta_destroy(audio_meta_h audio)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       audio_meta_s *_audio = (audio_meta_s*)audio;
+
+       if(_audio)
+       {
+               SAFE_FREE(_audio->media_id);
+               SAFE_FREE(_audio->title);
+               SAFE_FREE(_audio->album);
+               SAFE_FREE(_audio->artist);
+               SAFE_FREE(_audio->genre);
+               SAFE_FREE(_audio->composer);
+               SAFE_FREE(_audio->year);
+               SAFE_FREE(_audio->recorded_date);
+               SAFE_FREE(_audio->copyright);
+               SAFE_FREE(_audio->track_num);
+               SAFE_FREE(_audio);
+
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int audio_meta_clone(audio_meta_h *dst, audio_meta_h src)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       audio_meta_s *_src = (audio_meta_s*)src;
+
+       if(_src != NULL)
+       {
+               audio_meta_s *_dst = (audio_meta_s*)calloc(1, sizeof(audio_meta_s));
+
+               if(_dst == NULL)
+               {
+
+                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+               }
+
+               if(STRING_VALID(_src->media_id))
+               {
+                       _dst->media_id = strdup(_src->media_id);
+                       if(_dst->media_id == NULL)
+                       {
+                               audio_meta_destroy((audio_meta_h)_dst);
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+
+               if(STRING_VALID(_src->title))
+               {
+                       _dst->title = strdup(_src->title);
+                       if(_dst->title == NULL)
+                       {
+                               audio_meta_destroy((audio_meta_h)_dst);
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+
+               if(STRING_VALID(_src->album))
+               {
+                       _dst->album = strdup(_src->album);
+                       if(_dst->album == NULL)
+                       {
+                               audio_meta_destroy((audio_meta_h)_dst);
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+
+               if(STRING_VALID(_src->artist))
+               {
+                       _dst->artist = strdup(_src->artist);
+                       if(_dst->artist == NULL)
+                       {
+                               audio_meta_destroy((audio_meta_h)_dst);
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+
+               if(STRING_VALID(_src->genre))
+               {
+                       _dst->genre = strdup(_src->genre);
+                       if(_dst->genre == NULL)
+                       {
+                               audio_meta_destroy((audio_meta_h)_dst);
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+
+               if(STRING_VALID(_src->composer))
+               {
+                       _dst->composer = strdup(_src->composer);
+                       if(_dst->composer == NULL)
+                       {
+                               audio_meta_destroy((audio_meta_h)_dst);
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+
+               if(STRING_VALID(_src->year))
+               {
+                       _dst->year = strdup(_src->year);
+                       if(_dst->year == NULL)
+                       {
+                               audio_meta_destroy((audio_meta_h)_dst);
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+
+               if(STRING_VALID(_src->recorded_date))
+               {
+                       _dst->recorded_date = strdup(_src->recorded_date);
+                       if(_dst->recorded_date == NULL)
+                       {
+                               audio_meta_destroy((audio_meta_h)_dst);
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+
+               if(STRING_VALID(_src->copyright))
+               {
+                       _dst->copyright = strdup(_src->copyright);
+                       if(_dst->copyright == NULL)
+                       {
+                               audio_meta_destroy((audio_meta_h)_dst);
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+
+               if(STRING_VALID(_src->track_num))
+               {
+                       _dst->track_num = strdup(_src->track_num);
+                       if(_dst->track_num == NULL)
+                       {
+                               audio_meta_destroy((audio_meta_h)_dst);
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+
+               _dst->bitrate = _src->bitrate;
+               _dst->samplerate = _src->samplerate;
+               _dst->channel = _src->channel;
+               _dst->duration = _src->duration;
+               _dst->played_count = _src->played_count;
+               _dst->played_time = _src->played_time;
+               _dst->played_position = _src->played_position;
+
+               *dst = (audio_meta_h)_dst;
+
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int audio_meta_get_media_id(audio_meta_h audio, char **media_id)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       audio_meta_s *_audio = (audio_meta_s*)audio;
+       if(_audio)
+       {
+               if(STRING_VALID(_audio->media_id))
+               {
+                       *media_id = strdup(_audio->media_id);
+                       if(*media_id == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       *media_id = NULL;
+               }
+               ret = MEDIA_CONTENT_ERROR_NONE;
+
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int audio_meta_get_title(audio_meta_h audio, char **title)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       audio_meta_s *_audio = (audio_meta_s*)audio;
+       if(_audio)
+       {
+               if(STRING_VALID(_audio->title))
+               {
+                       *title = strdup(_audio->title);
+                       if(*title == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       *title = NULL;
+               }
+               ret = MEDIA_CONTENT_ERROR_NONE;
+
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int audio_meta_get_album(audio_meta_h audio, char **album_name)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       audio_meta_s *_audio = (audio_meta_s*)audio;
+       if(_audio)
+       {
+               if(STRING_VALID(_audio->album))
+               {
+                       *album_name = strdup(_audio->album);
+                       if(*album_name == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       *album_name = NULL;
+               }
+               ret = MEDIA_CONTENT_ERROR_NONE;
+
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int audio_meta_get_artist(audio_meta_h audio, char **artist_name)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       audio_meta_s *_audio = (audio_meta_s*)audio;
+
+       if(_audio)
+       {
+               if(STRING_VALID(_audio->artist))
+               {
+                       *artist_name = strdup(_audio->artist);
+                       if(*artist_name == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       *artist_name = NULL;
+               }
+               ret = MEDIA_CONTENT_ERROR_NONE;
+
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int audio_meta_get_genre(audio_meta_h audio, char **genre_name)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       audio_meta_s *_audio = (audio_meta_s*)audio;
+       if(_audio)
+       {
+               if(STRING_VALID(_audio->genre))
+               {
+                       *genre_name = strdup(_audio->genre);
+                       if(*genre_name == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       *genre_name = NULL;
+               }
+
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int audio_meta_get_composer(audio_meta_h audio, char **composer_name)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       audio_meta_s *_audio = (audio_meta_s*)audio;
+       if(_audio)
+       {
+               if(STRING_VALID(_audio->composer))
+               {
+                       *composer_name = strdup(_audio->composer);
+                       if(*composer_name == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       *composer_name = NULL;
+               }
+
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int audio_meta_get_year(audio_meta_h audio, char **year)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       audio_meta_s *_audio = (audio_meta_s*)audio;
+       if(_audio)
+       {
+               if(STRING_VALID(_audio->year))
+               {
+                       *year = strdup(_audio->year);
+                       if(*year == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       *year = NULL;
+               }
+
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int audio_meta_get_recorded_date(audio_meta_h audio, char **recorded_date)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       audio_meta_s *_audio = (audio_meta_s*)audio;
+       if(_audio)
+       {
+               if(STRING_VALID(_audio->recorded_date))
+               {
+                       *recorded_date = strdup(_audio->recorded_date);
+                       if(*recorded_date == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       *recorded_date = NULL;
+               }
+
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int audio_meta_get_copyright(audio_meta_h audio, char **copyright)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       audio_meta_s *_audio = (audio_meta_s*)audio;
+       if(_audio)
+       {
+               if(STRING_VALID(_audio->copyright))
+               {
+                       *copyright = strdup(_audio->copyright);
+                       if(*copyright == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       *copyright = NULL;
+               }
+
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int audio_meta_get_track_num(audio_meta_h audio, char **track_num)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       audio_meta_s *_audio = (audio_meta_s*)audio;
+       if(_audio)
+       {
+               if(STRING_VALID(_audio->track_num))
+               {
+                       *track_num = strdup(_audio->track_num);
+                       if(*track_num == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       *track_num = NULL;
+               }
+
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int audio_meta_get_bit_rate(audio_meta_h audio, int *bit_rate)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       audio_meta_s *_audio = (audio_meta_s*)audio;
+
+       if(_audio && bit_rate)
+       {
+               *bit_rate = _audio->bitrate;
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int audio_meta_get_sample_rate(audio_meta_h audio, int *sample_rate)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       audio_meta_s *_audio = (audio_meta_s*)audio;
+
+       if(_audio && sample_rate)
+       {
+               *sample_rate = _audio->samplerate;
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int audio_meta_get_channel(audio_meta_h audio, int *channel)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       audio_meta_s *_audio = (audio_meta_s*)audio;
+
+       if(_audio && channel)
+       {
+               *channel = _audio->channel;
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int audio_meta_get_duration(audio_meta_h audio, int *duration)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       audio_meta_s *_audio = (audio_meta_s*)audio;
+
+       if(_audio)
+       {
+               *duration = _audio->duration;
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int audio_meta_get_played_count(audio_meta_h audio, int *played_count)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       audio_meta_s *_audio = (audio_meta_s*)audio;
+
+       if(_audio)
+       {
+               *played_count = _audio->played_count;
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int audio_meta_get_played_time(audio_meta_h audio, time_t* played_time)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       audio_meta_s *_audio = (audio_meta_s*)audio;
+
+       if(_audio)
+       {
+               *played_time = _audio->played_time;
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int audio_meta_get_played_position(audio_meta_h audio, int *played_position)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       audio_meta_s *_audio = (audio_meta_s*)audio;
+
+       if(_audio)
+       {
+               *played_position = _audio->played_position;
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int audio_meta_set_played_count(audio_meta_h audio, int played_count)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       audio_meta_s *_audio = (audio_meta_s*)audio;
+
+       if((_audio != NULL) && (played_count >= 0))
+       {
+               _audio->played_count = played_count;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int audio_meta_set_played_time(audio_meta_h audio, time_t played_time)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       audio_meta_s *_audio = (audio_meta_s*)audio;
+
+       if((_audio != NULL) && (played_time >= 0))
+       {
+               _audio->played_time = played_time;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int audio_meta_set_played_position(audio_meta_h audio, int played_position)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       audio_meta_s *_audio = (audio_meta_s*)audio;
+
+       if((_audio != NULL) && (played_position >= 0))
+       {
+               _audio->played_position = played_position;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int audio_meta_update_to_db(audio_meta_h audio)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       audio_meta_s *_audio = (audio_meta_s*)audio;
+       char *sql = NULL;
+
+       if(_audio != NULL && STRING_VALID(_audio->media_id))
+       {
+               sql = sqlite3_mprintf(UPDATE_AV_META_FROM_MEDIA, _audio->played_count, _audio->played_time, _audio->played_position, _audio->media_id);
+               ret = _content_query_sql(sql);
+               sqlite3_free(sql);
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
diff --git a/src/media_bookmark.c b/src/media_bookmark.c
new file mode 100755 (executable)
index 0000000..0ce1f24
--- /dev/null
@@ -0,0 +1,222 @@
+/*
+* 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_content.h>
+#include <media_info_private.h>
+#include <media-svc.h>
+
+
+int media_bookmark_insert_to_db(const char *media_id, time_t time, const char *thumbnail_path)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       char *sql = NULL;
+
+       if(STRING_VALID(media_id))
+       {
+               sql = sqlite3_mprintf(INSERT_BOOKMARK_TO_BOOKMARK, media_id, time, thumbnail_path);
+               ret = _content_query_sql(sql);
+               sqlite3_free(sql);
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_bookmark_delete_from_db(int bookmark_id)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       char *query_str = NULL;
+
+       if(bookmark_id < 0)
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       query_str = sqlite3_mprintf(DELETE_BOOKMARK_FROM_BOOKMARK, bookmark_id);
+
+       ret = _content_query_sql(query_str);
+
+       sqlite3_free(query_str);
+
+       return ret;
+}
+
+int media_bookmark_get_bookmark_count_from_db(filter_h filter, int *bookmark_count)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       media_content_debug_func();
+
+       if (bookmark_count == NULL)
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _media_db_get_group_count(filter, MEDIA_GROUP_BOOKMARK, bookmark_count);
+
+       return ret;
+}
+
+int media_bookmark_destroy(media_bookmark_h bookmark)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_bookmark_s *_bookmark = (media_bookmark_s*)bookmark;
+
+       if(_bookmark)
+       {
+               SAFE_FREE(_bookmark->media_id);
+               SAFE_FREE(_bookmark->thumbnail_path);
+               free(_bookmark);
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+int media_bookmark_clone(media_bookmark_h *dst, media_bookmark_h src)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       if((src != NULL))
+       {
+               media_bookmark_s *_src = (media_bookmark_s*)src;
+               media_bookmark_s *_dst = (media_bookmark_s*)calloc(1, sizeof(media_bookmark_s));
+
+               if(NULL == _dst)
+               {
+                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+               }
+
+               _dst->bookmark_id = _src->bookmark_id;
+
+               if(STRING_VALID(_src->media_id))
+               {
+                       _dst->media_id = (char*)strdup(_src->media_id);
+                       if(_dst->media_id == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               media_bookmark_destroy((media_bookmark_h)_dst);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+
+               _dst->marked_time = _src->marked_time;
+
+               if(STRING_VALID(_src->thumbnail_path))
+               {
+                       _dst->thumbnail_path = (char*)strdup(_src->thumbnail_path);
+                       if(_dst->thumbnail_path == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               media_bookmark_destroy((media_bookmark_h)_dst);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+
+               *dst = (media_bookmark_h)_dst;
+
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_bookmark_get_bookmark_id(media_bookmark_h bookmark, int *bookmark_id)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_bookmark_s *_bookmark = (media_bookmark_s*)bookmark;
+
+       if(_bookmark)
+       {
+               *bookmark_id = _bookmark->bookmark_id;
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_bookmark_get_marked_time(media_bookmark_h bookmark, time_t* marked_time)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_bookmark_s *_bookmark = (media_bookmark_s*)bookmark;
+
+       if(_bookmark)
+       {
+               *marked_time = _bookmark->marked_time;
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_bookmark_get_thumbnail_path(media_bookmark_h bookmark, char **path)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_bookmark_s *_bookmark = (media_bookmark_s*)bookmark;
+
+       if(_bookmark)
+       {
+               if(STRING_VALID(_bookmark->thumbnail_path))
+               {
+                       *path = strdup(_bookmark->thumbnail_path);
+                       if(*path == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       *path = NULL;
+               }
+
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
diff --git a/src/media_content.c b/src/media_content.c
new file mode 100755 (executable)
index 0000000..161cd17
--- /dev/null
@@ -0,0 +1,742 @@
+/*
+* 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-thumb-error.h>
+#include <media_content.h>
+#include <media_info_private.h>
+#include <media-util.h>
+
+
+static attribute_h g_attr_handle = NULL;
+static attribute_h g_alias_attr_handle = NULL;
+static MediaSvcHandle *db_handle = NULL;
+static int ref_count = 0;
+
+
+static int __media_content_create_attr_handle(void);
+static int __media_content_create_alias_attr_handle(void);
+static int __media_content_create_attribute_handle(void);
+static int __media_content_destroy_attribute_handle(void);
+
+
+static int __media_content_create_attr_handle(void)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       ret = _media_filter_attribute_create(&g_attr_handle);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       /* Media Info */
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_ID, DB_FIELD_MEDIA_ID);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_PATH, DB_FIELD_MEDIA_PATH);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_DISPLAY_NAME, DB_FIELD_MEDIA_DISPLAY_NAME);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_TYPE, DB_FIELD_MEDIA_TYPE);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_MIME_TYPE, DB_FIELD_MEDIA_MIME_TYPE);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_SIZE, DB_FIELD_MEDIA_SIZE);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_ADDED_TIME, DB_FIELD_MEDIA_ADDED_TIME);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_MODIFIED_TIME, DB_FIELD_MEDIA_MODIFIED_TIME);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_THUMBNAIL_PATH, DB_FIELD_MEDIA_THUMBNAIL_PATH);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_TITLE, DB_FIELD_MEDIA_TITLE);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_ALBUM, DB_FIELD_MEDIA_ALBUM);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_ARTIST, DB_FIELD_MEDIA_ARTIST);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_GENRE, DB_FIELD_MEDIA_GENRE);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_COMPOSER, DB_FIELD_MEDIA_COMPOSER);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_YEAR, DB_FIELD_MEDIA_YEAR);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_RECORDED_DATE, DB_FIELD_MEDIA_RECORDED_DATE);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_COPYRIGHT, DB_FIELD_MEDIA_COPYRIGHT);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_TRACK_NUM, DB_FIELD_MEDIA_TRACK_NUM);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_DESCRIPTION, DB_FIELD_MEDIA_DESCRIPTION);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_BITRATE, DB_FIELD_MEDIA_BITRATE);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_SAMPLERATE, DB_FIELD_MEDIA_SAMPLERATE);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_CHANNEL, DB_FIELD_MEDIA_CHANNEL);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_DURATION, DB_FIELD_MEDIA_DURATION);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_LONGITUDE, DB_FIELD_MEDIA_LONGITUDE);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_LATITUDE, DB_FIELD_MEDIA_LATITUDE);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_ALTITUDE, DB_FIELD_MEDIA_ALTITUDE);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_WIDTH, DB_FIELD_MEDIA_WIDTH);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_HEIGHT, DB_FIELD_MEDIA_HEIGHT);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_DATETAKEN, DB_FIELD_MEDIA_DATETAKEN);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_ORIENTATION, DB_FIELD_MEDIA_ORIENTATION);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_PLAYED_COUNT, DB_FIELD_MEDIA_PLAYED_COUNT);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_LAST_PLAYED_TIME, DB_FIELD_MEDIA_LAST_PLAYED_TIME);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_LAST_PLAYED_POSITION, DB_FIELD_MEDIA_LAST_PLAYED_POSITION);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_RATING, DB_FIELD_MEDIA_RATING);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_FAVOURITE, DB_FIELD_MEDIA_FAVOURITE);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_AUTHOR, DB_FIELD_MEDIA_AUTHOR);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_PROVIDER, DB_FIELD_MEDIA_PROVIDER);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_CONTENT_NAME, DB_FIELD_MEDIA_CONTENT_NAME);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_CATEGORY, DB_FIELD_MEDIA_CATEGORY);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_LOCATION_TAG, DB_FIELD_MEDIA_LOCATION_TAG);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_AGE_RATING, DB_FIELD_MEDIA_AGE_RATING);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_KEYWORD, DB_FIELD_MEDIA_KEYWORD);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_IS_DRM, DB_FIELD_MEDIA_IS_DRM);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, MEDIA_STORAGE_TYPE, DB_FIELD_MEDIA_STORAGE_TYPE);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       /* Playlist*/
+       ret = _media_filter_attribute_add(g_attr_handle, PLAYLIST_NAME, DB_FIELD_PLAYLIST_NAME);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_attr_handle, PLAYLIST_MEMBER_ORDER, DB_FIELD_PLAYLIST_MEMBER_ORDER);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       /* Playlist View */
+       ret = _media_filter_attribute_add(g_attr_handle, PLAYLIST_MEDIA_COUNT, DB_FIELD_PLAYLIST_MEDIA_COUNT);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       /* Tag*/
+       ret = _media_filter_attribute_add(g_attr_handle, TAG_NAME, DB_FIELD_TAG_NAME);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       /* Tag View */
+       ret = _media_filter_attribute_add(g_attr_handle, TAG_MEDIA_COUNT, DB_FIELD_TAG_MEDIA_COUNT);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       /* Bookmark*/
+       ret = _media_filter_attribute_add(g_attr_handle, BOOKMARK_MARKED_TIME, DB_FIELD_BOOKMARK_MARKED_TIME);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       return ret;
+}
+
+static int __media_content_create_alias_attr_handle(void)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       ret = _media_filter_attribute_create(&g_alias_attr_handle);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       /* Media Info */
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_ID, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_ID);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_PATH, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_PATH);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_DISPLAY_NAME, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_DISPLAY_NAME);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_TYPE, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_TYPE);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_MIME_TYPE, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_MIME_TYPE);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_SIZE, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_SIZE);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_ADDED_TIME, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_ADDED_TIME);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_MODIFIED_TIME, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_MODIFIED_TIME);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_THUMBNAIL_PATH, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_THUMBNAIL_PATH);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_TITLE, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_TITLE);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_ALBUM, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_ALBUM);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_ARTIST, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_ARTIST);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_GENRE, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_GENRE);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_COMPOSER, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_COMPOSER);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_YEAR, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_YEAR);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_RECORDED_DATE, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_RECORDED_DATE);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_COPYRIGHT, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_COPYRIGHT);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_TRACK_NUM, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_TRACK_NUM);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_DESCRIPTION, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_DESCRIPTION);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_BITRATE, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_BITRATE);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_SAMPLERATE, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_SAMPLERATE);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_CHANNEL, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_CHANNEL);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_DURATION, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_DURATION);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_LONGITUDE, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_LONGITUDE);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_LATITUDE, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_LATITUDE);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_ALTITUDE, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_ALTITUDE);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_WIDTH, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_WIDTH);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_HEIGHT, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_HEIGHT);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_DATETAKEN, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_DATETAKEN);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_ORIENTATION, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_ORIENTATION);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_PLAYED_COUNT, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_PLAYED_COUNT);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_LAST_PLAYED_TIME, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_LAST_PLAYED_TIME);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_LAST_PLAYED_POSITION, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_LAST_PLAYED_POSITION);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_RATING, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_RATING);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_FAVOURITE, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_FAVOURITE);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_AUTHOR, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_AUTHOR);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_PROVIDER, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_PROVIDER);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_CONTENT_NAME, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_CONTENT_NAME);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_CATEGORY, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_CATEGORY);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_LOCATION_TAG, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_LOCATION_TAG);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_AGE_RATING, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_AGE_RATING);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_KEYWORD, DB_TABLE_ALIAS_MEDIA"."MEDIA_KEYWORD);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_IS_DRM, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_IS_DRM);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_STORAGE_TYPE, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_STORAGE_TYPE);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       /* Folder */
+       ret = _media_filter_attribute_add(g_alias_attr_handle, FOLDER_ID, DB_TABLE_ALIAS_FOLDER"."DB_FIELD_FOLDER_ID);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, FOLDER_PATH, DB_TABLE_ALIAS_FOLDER"."DB_FIELD_FOLDER_PATH);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, FOLDER_NAME, DB_TABLE_ALIAS_FOLDER"."DB_FIELD_FOLDER_NAME);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, FOLDER_MODIFIED_TIME, DB_TABLE_ALIAS_FOLDER"."DB_FIELD_FOLDER_MODIFIED_TIME);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, FOLDER_STORAGE_TYPE, DB_TABLE_ALIAS_FOLDER"."DB_FIELD_FOLDER_STORAGE_TYPE);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       /* Playlist*/
+       ret = _media_filter_attribute_add(g_alias_attr_handle, PLAYLIST_NAME, DB_TABLE_ALIAS_PLAYLIST"."DB_FIELD_PLAYLIST_NAME);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_add(g_alias_attr_handle, PLAYLIST_MEMBER_ORDER, DB_TABLE_ALIAS_PLAYLIST_MAP"."DB_FIELD_PLAYLIST_MEMBER_ORDER);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       /* Tag*/
+       ret = _media_filter_attribute_add(g_alias_attr_handle, TAG_NAME, DB_TABLE_ALIAS_TAG"."DB_FIELD_TAG_NAME);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       /* Bookmark*/
+       ret = _media_filter_attribute_add(g_alias_attr_handle, BOOKMARK_MARKED_TIME, DB_TABLE_ALIAS_BOOKMARK"."DB_FIELD_BOOKMARK_MARKED_TIME);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       /* Album */
+
+       return ret;
+}
+
+static int __media_content_create_attribute_handle(void)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       ret = __media_content_create_attr_handle();
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = __media_content_create_alias_attr_handle();
+
+       return ret;
+}
+
+static int __media_content_destroy_attribute_handle(void)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       ret = _media_filter_attribute_destory(g_attr_handle);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = _media_filter_attribute_destory(g_alias_attr_handle);
+
+       return ret;
+}
+
+attribute_h _content_get_attirbute_handle(void)
+{
+       return g_attr_handle;
+}
+
+attribute_h _content_get_alias_attirbute_handle(void)
+{
+       return g_alias_attr_handle;
+}
+
+MediaSvcHandle* _content_get_db_handle(void)
+{
+       return db_handle;
+}
+
+int _content_query_prepare(sqlite3_stmt **stmt, char *select_query, char *condition_query, char *option_query)
+{
+       int len = 0;
+       int err = MEDIA_CONTENT_ERROR_NONE;
+       char query[MAX_QUERY_SIZE];
+       memset(query, '\0', sizeof(query));
+
+       if(db_handle == NULL)
+       {
+               media_content_error("DB_FAILED(0x%08x) database is not connected", MEDIA_CONTENT_ERROR_DB_FAILED);
+               return MEDIA_CONTENT_ERROR_DB_FAILED;
+       }
+
+       if(STRING_VALID(select_query)) {
+               if(!STRING_VALID(condition_query)) {
+                       condition_query = " ";
+               }
+
+               if(!STRING_VALID(option_query)) {
+                       option_query = " ";
+
+               }
+
+               //query = sqlite3_mprintf("%s %s %s", select_query, condition_query, option_query);
+               len = snprintf(query, sizeof(query), "%s %s %s", select_query, condition_query, option_query);
+               if (len > 0) {
+                       query[len] = '\0';
+               } else {
+                       media_content_error("snprintf failed");
+                       return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+               }
+
+               media_content_info("Query : [%s]", query);
+
+               err = sqlite3_prepare_v2((sqlite3*)db_handle, query, strlen(query), stmt, NULL);
+               if(err != SQLITE_OK)
+               {
+                       media_content_error("DB_FAILED(0x%08x) fail to sqlite3_prepare(), %s", MEDIA_CONTENT_ERROR_DB_FAILED, sqlite3_errmsg((sqlite3*)db_handle));
+
+                       if (err == SQLITE_BUSY)
+                               return MEDIA_CONTENT_ERROR_DB_BUSY;
+                       else
+                               return MEDIA_CONTENT_ERROR_DB_FAILED;
+               }
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return MEDIA_CONTENT_ERROR_NONE;
+}
+
+int _content_error_capi(int type, int content_error)
+{
+       media_content_debug("[type : %d] content_error : %d ", type, content_error);
+
+       if(type == MEDIA_CONTENT_TYPE)
+       {
+               if(content_error == MEDIA_INFO_ERROR_NONE)
+                       return MEDIA_CONTENT_ERROR_NONE;
+               else if(content_error == MEDIA_INFO_ERROR_INVALID_PARAMETER)
+                       return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+               else if((content_error == MEDIA_INFO_ERROR_DATABASE_CONNECT) || (content_error == MEDIA_INFO_ERROR_DATABASE_DISCONNECT) ||
+                               (content_error == MEDIA_INFO_ERROR_DATABASE_NO_RECORD) ||(content_error == MEDIA_INFO_ERROR_DATABASE_INTERNAL))
+                       return MEDIA_CONTENT_ERROR_DB_FAILED;
+               else if((content_error == MS_MEDIA_ERR_SOCKET_CONN) ||(content_error == MS_MEDIA_ERR_SOCKET_INTERNAL) ||
+                               (content_error == MS_MEDIA_ERR_SOCKET_SEND) ||(content_error == MS_MEDIA_ERR_SOCKET_RECEIVE) || (content_error == MS_MEDIA_ERR_SOCKET_RECEIVE_TIMEOUT))
+                       return MEDIA_CONTENT_ERROR_NETWORK;
+       } else if(type == MEDIA_THUMBNAIL_TYPE) {
+               if(content_error == MEDIA_THUMB_ERROR_NONE)
+                       return MEDIA_CONTENT_ERROR_NONE;
+               else if(content_error == MEDIA_THUMB_ERROR_INVALID_PARAMETER)
+                       return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+               else if(content_error == MEDIA_THUMB_ERROR_DB)
+                       return MEDIA_CONTENT_ERROR_DB_FAILED;
+               else if(content_error == MEDIA_THUMB_ERROR_NETWORK)
+                       return MEDIA_CONTENT_ERROR_NETWORK;
+               else if(content_error == MEDIA_THUMB_ERROR_TIMEOUT)
+                       return MEDIA_CONTENT_ERROR_NETWORK;
+               else if(content_error == MEDIA_THUMB_ERROR_MM_UTIL)                     /* Error in mm-util lib */
+                       return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
+               else if(content_error == MEDIA_THUMB_ERROR_HASHCODE)            /* Failed to generate hash code */
+                       return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
+               else if(content_error == MEDIA_THUMB_ERROR_TOO_BIG)                     /* Original is too big to make thumb */
+                       return MEDIA_CONTENT_ERROR_UNSUPPORTED_CONTENT;
+               else if(content_error == MEDIA_THUMB_ERROR_UNSUPPORTED) /* Unsupported type */
+                       return MEDIA_CONTENT_ERROR_UNSUPPORTED_CONTENT;
+
+       } else if(type == MEDIA_REGISTER_TYPE) {
+               if(content_error == MS_MEDIA_ERR_NONE)
+                       return MEDIA_CONTENT_ERROR_NONE;
+               else if(content_error == MS_MEDIA_ERR_INVALID_PARAMETER || content_error == MS_MEDIA_ERR_INVALID_PATH)
+                       return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+               else if(content_error == MS_MEDIA_ERR_DB_INSERT_FAIL || content_error == MS_MEDIA_ERR_DRM_REGISTER_FAIL)
+                       return MEDIA_CONTENT_ERROR_DB_FAILED;
+               else if(content_error == MS_MEDIA_ERR_SCANNING_BUSY)
+                       return MEDIA_CONTENT_ERROR_DB_BUSY;
+               else if(content_error == MS_MEDIA_ERR_VCONF_GET_FAIL)
+                       return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
+       }
+
+       return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
+}
+
+int _content_query_sql(char *query_str)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       //DB will be updated by Media Server.
+       ret = media_svc_request_update_db(query_str);
+
+       return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+
+#if 0
+       int err = MEDIA_CONTENT_ERROR_NONE;
+       char *err_msg;
+
+       if(db_handle == NULL)
+       {
+               media_content_error("DB_FAILED(0x%08x) database is not connected", MEDIA_CONTENT_ERROR_DB_FAILED);
+               return MEDIA_CONTENT_ERROR_DB_FAILED;
+       }
+
+       err = sqlite3_exec(db_handle, query_str, NULL, NULL, &err_msg);
+       if(SQLITE_OK != err)
+       {
+               if(err_msg)
+               {
+                       media_content_error("DB_FAILED : %s", err_msg);
+                       media_content_error("DB_FAILED SQL: %s", query_str);
+                       sqlite3_free(err_msg);
+               }
+
+               media_content_error("DB_FAILED(0x%08x) database operation is failed", MEDIA_CONTENT_ERROR_DB_FAILED);
+
+               if (err == SQLITE_BUSY)
+                       return MEDIA_CONTENT_ERROR_DB_BUSY;
+               else
+                       return MEDIA_CONTENT_ERROR_DB_FAILED;
+       }
+       else
+       {
+               media_content_info("DB_SUCCESS: %s", query_str);
+       }
+
+       if(err_msg)
+               sqlite3_free(err_msg);
+
+       return MEDIA_CONTENT_ERROR_NONE;
+#endif
+}
+
+int media_content_connect(void)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       if(ref_count == 0)
+       {
+               if(db_handle == NULL)
+               {
+                       ret = media_svc_connect(&db_handle);
+               }
+
+               ret = _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+
+               if(ret == MEDIA_CONTENT_ERROR_NONE) {
+                       ret = __media_content_create_attribute_handle();
+               }
+       }
+
+       ref_count++;
+
+       return ret;
+}
+
+int media_content_disconnect(void)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       if(ref_count > 0)
+       {
+               ref_count--;
+       }
+       else
+       {
+               media_content_error("DB_FAILED(0x%08x) database is not connected", MEDIA_CONTENT_ERROR_DB_FAILED);
+               return MEDIA_CONTENT_ERROR_DB_FAILED;
+       }
+
+       if(ref_count == 0)
+       {
+               if(db_handle != NULL)
+               {
+                       ret = media_svc_disconnect(db_handle);
+                       ret = _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+                       if(ret == MEDIA_CONTENT_ERROR_NONE)
+                       {
+                               ret = __media_content_destroy_attribute_handle();
+                               db_handle = NULL;
+                       }
+               }
+       }
+
+       return ret;
+}
+
+int media_content_scan_file(const char *path)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       if (!STRING_VALID(path)) {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       media_content_debug("Path : %s", path);
+
+       if (g_file_test(path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
+               /* This means this path has to be inserted or refreshed */
+               media_content_debug("This path exists in file system.");
+
+               media_svc_media_type_e media_type;
+               media_svc_storage_type_e storage_type;
+               char mime_type[255];
+
+               ret = media_svc_get_storage_type(path, &storage_type);
+               if (ret < 0) {
+                       media_content_error("media_svc_get_storage_type failed : %d (%s)", ret, path);
+                       return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+               }
+
+               ret = media_svc_get_mime_type(path, mime_type);
+               if (ret < 0) {
+                       media_content_error("media_svc_get_mime_type failed : %d (%s)", ret, path);
+                       return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+               }
+
+               ret = media_svc_get_media_type(path, mime_type, &media_type);
+               if (ret < 0) {
+                       media_content_error("media_svc_get_media_type failed : %d (%s)", ret, path);
+                       return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+               }
+
+               ret = media_svc_check_item_exist_by_path(_content_get_db_handle(), path);
+               if (ret == MEDIA_INFO_ERROR_NONE) {
+                       /* Refresh */
+                       ret = media_svc_refresh_item(_content_get_db_handle(), storage_type, path, media_type);
+                       if (ret < 0) {
+                               media_content_error("media_svc_refresh_item failed : %d", ret);
+                               return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+                       }
+
+               } else if (ret == MEDIA_INFO_ERROR_DATABASE_NO_RECORD) {
+                       /* Insert */
+                       ret = media_svc_insert_item_immediately(_content_get_db_handle(), storage_type, path, mime_type, media_type);
+                       if (ret < 0) {
+                               media_content_error("media_svc_insert_item_immediately failed : %d", ret);
+                               return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+                       }
+
+               } else {
+                       media_content_error("media_svc_check_item_exist_by_path failed : %d", ret);
+                       return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+               }
+       } else if(g_file_test(path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR)) {
+               /* Dierectory is not accpted in this function */
+               media_content_error("This path is directory");
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       } else {
+               /* This means this path has to be deleted */
+               media_content_debug("This path doesn't exists in file system... So now start to delete it from DB");
+               ret = media_svc_delete_item_by_path(_content_get_db_handle(), path);
+               if (ret < 0) {
+                       media_content_error("media_svc_delete_item_by_path failed : %d", ret);
+                       return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+               }
+       }
+
+       return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+}
+
+void _media_content_scan_cb(media_request_result_s* result, void *user_data)
+{
+       int err = -1;
+       media_content_scan_cb_data *cb_data = user_data;
+
+       err = result->result;
+
+       if (cb_data && cb_data->callback) {
+               media_content_debug("User callback is being called now");
+               cb_data->callback(err, cb_data->user_data);
+       }
+
+       SAFE_FREE(cb_data);
+
+       return;
+}
+
+int media_content_scan_folder(const char *path, media_scan_completed_cb callback, void *user_data)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       if (!STRING_VALID(path)) {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       media_content_scan_cb_data *cb_data = NULL;
+       cb_data = (media_content_scan_cb_data *)malloc(sizeof(media_content_scan_cb_data));
+       if (cb_data == NULL) {
+               media_content_error("malloc failed");
+               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+       }
+
+       cb_data->callback = callback;
+       cb_data->user_data = user_data;
+
+       ret = media_directory_scanning_async(path, TRUE, _media_content_scan_cb, cb_data);
+       if (ret < 0) {
+               media_content_error("media_directory_scanning_async failed : %d", ret);
+       }
+
+       return _content_error_capi(MEDIA_REGISTER_TYPE, ret);
+}
diff --git a/src/media_db.c b/src/media_db.c
new file mode 100755 (executable)
index 0000000..0846bac
--- /dev/null
@@ -0,0 +1,1359 @@
+/*
+* 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_content.h>
+#include <media_info_private.h>
+
+static char * __media_db_get_group_name(media_group_e group);
+
+static char * __media_db_get_group_name(media_group_e group)
+{
+       switch(group)
+       {
+               case MEDIA_CONTENT_GROUP_DISPLAY_NAME:
+                       return DB_FIELD_MEDIA_DISPLAY_NAME;
+               case MEDIA_CONTENT_GROUP_TYPE:
+                       return DB_FIELD_MEDIA_TYPE;
+               case MEDIA_CONTENT_GROUP_MIME_TYPE:
+                       return DB_FIELD_MEDIA_MIME_TYPE;
+               case MEDIA_CONTENT_GROUP_SIZE:
+                       return DB_FIELD_MEDIA_SIZE;
+               case MEDIA_CONTENT_GROUP_ADDED_TIME:
+                       return DB_FIELD_MEDIA_ADDED_TIME;
+               case MEDIA_CONTENT_GROUP_MODIFIED_TIME:
+                       return DB_FIELD_MEDIA_MODIFIED_TIME;
+               case MEDIA_CONTENT_GROUP_TITLE:
+                       return DB_FIELD_MEDIA_TITLE;
+               case MEDIA_CONTENT_GROUP_ARTIST:
+                       return DB_FIELD_MEDIA_ARTIST;
+               case MEDIA_CONTENT_GROUP_GENRE:
+                       return DB_FIELD_MEDIA_GENRE;
+               case MEDIA_CONTENT_GROUP_COMPOSER:
+                       return DB_FIELD_MEDIA_COMPOSER;
+               case MEDIA_CONTENT_GROUP_YEAR:
+                       return DB_FIELD_MEDIA_YEAR;
+               case MEDIA_CONTENT_GROUP_RECORDED_DATE:
+                       return DB_FIELD_MEDIA_RECORDED_DATE;
+               case MEDIA_CONTENT_GROUP_COPYRIGHT:
+                       return DB_FIELD_MEDIA_COPYRIGHT;
+               case MEDIA_CONTENT_GROUP_TRACK_NUM:
+                       return DB_FIELD_MEDIA_TRACK_NUM;
+               case MEDIA_CONTENT_GROUP_DESCRIPTION:
+                       return DB_FIELD_MEDIA_DESCRIPTION;
+               case MEDIA_CONTENT_GROUP_LONGITUDE:
+                       return DB_FIELD_MEDIA_LONGITUDE;
+               case MEDIA_CONTENT_GROUP_LATITUDE:
+                       return DB_FIELD_MEDIA_LATITUDE;
+               case MEDIA_CONTENT_GROUP_ALTITUDE:
+                       return DB_FIELD_MEDIA_ALTITUDE;
+               case MEDIA_CONTENT_GROUP_RATING:
+                       return DB_FIELD_MEDIA_RATING;
+               case MEDIA_CONTENT_GROUP_AUTHOR:
+                       return DB_FIELD_MEDIA_AUTHOR;
+               case MEDIA_CONTENT_GROUP_PROVIDER:
+                       return DB_FIELD_MEDIA_PROVIDER;
+               case MEDIA_CONTENT_GROUP_CONTENT_NAME:
+                       return DB_FIELD_MEDIA_CONTENT_NAME;
+               case MEDIA_CONTENT_GROUP_CATEGORY:
+                       return DB_FIELD_MEDIA_CATEGORY;
+               case MEDIA_CONTENT_GROUP_LOCATION_TAG:
+                       return DB_FIELD_MEDIA_LOCATION_TAG;
+               case MEDIA_CONTENT_GROUP_AGE_RATING:
+                       return DB_FIELD_MEDIA_AGE_RATING;
+               case MEDIA_CONTENT_GROUP_KEYWORD:
+                       return DB_FIELD_MEDIA_KEYWORD;
+               default:
+                       return NULL;
+       }
+
+       return NULL;
+}
+
+int _media_db_get_group_count(filter_h filter, group_list_e group_type, int *group_count)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       sqlite3_stmt *stmt = NULL;
+       filter_s *_filter = NULL;
+       char select_query[DEFAULT_QUERY_SIZE];
+       char *condition_query = NULL;
+       char *option_query = NULL;
+       attribute_h attr;
+
+       media_content_debug_func();
+
+       memset(select_query, 0x00, sizeof(select_query));
+
+       attr = _content_get_attirbute_handle();
+
+       switch(group_type) {
+               case MEDIA_GROUP_NONE:
+               case MEDIA_GROUP_TAG_BY_MEDIA_ID:
+               case MEDIA_GROUP_BOOKMARK_BY_MEDIA_ID:
+                       {
+                               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+                               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+                       }
+                       break;
+               case MEDIA_GROUP_ALBUM:
+                       attr = _content_get_alias_attirbute_handle();
+                       //snprintf(select_query, sizeof(select_query), SELECT_ALBUM_COUNT);
+                       if(!SAFE_STRLCPY(select_query, SELECT_ALBUM_COUNT, sizeof(select_query)))
+                       {
+                               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+                               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+                       }
+
+                       break;
+               case MEDIA_GROUP_FOLDER:
+                       attr = _content_get_alias_attirbute_handle();
+                       //snprintf(select_query, sizeof(select_query), SELECT_FOLDER_COUNT);
+                       if(!SAFE_STRLCPY(select_query, SELECT_FOLDER_COUNT, sizeof(select_query)))
+                       {
+                               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+                               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+                       }
+                       break;
+               case MEDIA_GROUP_PLAYLIST:
+                       //attr = _content_get_alias_attirbute_handle();
+                       //snprintf(select_query, sizeof(select_query), SELECT_PLAYLIST_COUNT);
+                       if(!SAFE_STRLCPY(select_query, SELECT_PLAYLIST_COUNT, sizeof(select_query)))
+                       {
+                               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+                               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+                       }
+                       break;
+               case MEDIA_GROUP_TAG:
+                       //attr = _content_get_alias_attirbute_handle();
+                       //snprintf(select_query, sizeof(select_query), SELECT_TAG_COUNT);
+                       if(!SAFE_STRLCPY(select_query, SELECT_TAG_COUNT, sizeof(select_query)))
+                       {
+                               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+                               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+                       }
+                       break;
+               case MEDIA_GROUP_BOOKMARK:
+                       attr = _content_get_alias_attirbute_handle();
+                       //snprintf(select_query, sizeof(select_query), SELECT_BOOKMARK_COUNT);
+                       if(!SAFE_STRLCPY(select_query, SELECT_BOOKMARK_COUNT, sizeof(select_query)))
+                       {
+                               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+                               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+                       }
+                       break;
+       }
+
+       if(filter != NULL)
+       {
+               _filter = (filter_s*)filter;
+
+               if(STRING_VALID(_filter->condition))
+               {
+                       ret = _media_filter_attribute_generate(attr, _filter->condition, _filter->condition_collate_type, &condition_query);
+                       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+               }
+
+               ret = _media_filter_attribute_option_generate(attr, filter, &option_query);
+               if(ret != MEDIA_CONTENT_ERROR_NONE)
+               {
+                       SAFE_FREE(condition_query);
+                       return ret;
+               }
+
+               if(STRING_VALID(condition_query))
+               {
+                       SAFE_STRLCAT(select_query, QUERY_KEYWORD_SPACE, sizeof(select_query));
+                       SAFE_STRLCAT(select_query, QUERY_KEYWORD_AND, sizeof(select_query));
+               }
+       }
+
+       ret = _content_query_prepare(&stmt, select_query, condition_query, option_query);
+       SAFE_FREE(condition_query);
+       SAFE_FREE(option_query);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       while(sqlite3_step(stmt) == SQLITE_ROW)
+       {
+               *group_count = (int)sqlite3_column_int(stmt, 0);
+               media_content_debug("group count : [%d]", *group_count);
+       }
+
+       SQLITE3_FINALIZE(stmt);
+
+       return ret;
+}
+
+int _media_db_get_media_group_count(media_group_e group, filter_h filter, int *group_count)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       sqlite3_stmt *stmt = NULL;
+       filter_s *_filter = NULL;
+       char select_query[DEFAULT_QUERY_SIZE];
+       char *condition_query = NULL;
+       char *option_query = NULL;
+
+       media_content_debug_func();
+
+       memset(select_query, 0x00, sizeof(select_query));
+
+       snprintf(select_query, sizeof(select_query), SELECT_MEDIA_GROUP_COUNT, __media_db_get_group_name(group));
+
+       if(filter != NULL)
+       {
+               _filter = (filter_s*)filter;
+
+               if(STRING_VALID(_filter->condition))
+               {
+                       ret = _media_filter_attribute_generate(_content_get_attirbute_handle(), _filter->condition, _filter->condition_collate_type, &condition_query);
+                       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+               }
+
+               ret = _media_filter_attribute_option_generate(_content_get_attirbute_handle(), filter, &option_query);
+               if(ret != MEDIA_CONTENT_ERROR_NONE)
+               {
+                       SAFE_FREE(condition_query);
+                       return ret;
+               }
+
+               if(STRING_VALID(condition_query))
+               {
+                       SAFE_STRLCAT(select_query, QUERY_KEYWORD_SPACE, sizeof(select_query));
+                       SAFE_STRLCAT(select_query, QUERY_KEYWORD_AND, sizeof(select_query));
+               }
+
+               SAFE_STRLCAT(select_query, QUERY_KEYWORD_SPACE, sizeof(select_query));
+               if(STRING_VALID(condition_query))
+                       SAFE_STRLCAT(select_query, condition_query, sizeof(select_query));
+               if(STRING_VALID(option_query))
+                       SAFE_STRLCAT(select_query, option_query, sizeof(select_query));
+
+               SAFE_FREE(condition_query);
+               SAFE_FREE(option_query);
+       }
+
+       SAFE_STRLCAT(select_query, QUERY_KEYWORD_BRACKET, sizeof(select_query));
+
+       ret = _content_query_prepare(&stmt, select_query, condition_query, option_query);
+       SAFE_FREE(condition_query);
+       SAFE_FREE(option_query);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       while(sqlite3_step(stmt) == SQLITE_ROW)
+       {
+               *group_count = (int)sqlite3_column_int(stmt, 0);
+               media_content_debug("group count : [%d]", *group_count);
+       }
+
+       SQLITE3_FINALIZE(stmt);
+
+       return ret;
+}
+
+int _media_db_get_media_group(media_group_e group, filter_h filter, media_group_cb callback, void *user_data)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       char select_query[DEFAULT_QUERY_SIZE];
+       char *condition_query = NULL;
+       char *option_query = NULL;
+       char *name = NULL;
+       sqlite3_stmt *stmt = NULL;
+       filter_s *_filter = NULL;
+
+       memset(select_query, 0x00, sizeof(select_query));
+
+       snprintf(select_query, sizeof(select_query), SELECT_MEDIA_GROUP_LIST, __media_db_get_group_name(group));
+
+       if(filter != NULL)
+       {
+               _filter = (filter_s*)filter;
+
+               if(_filter->condition)
+               {
+                       ret = _media_filter_attribute_generate(_content_get_attirbute_handle(), _filter->condition, _filter->condition_collate_type, &condition_query);
+                       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+               }
+
+               ret = _media_filter_attribute_option_generate(_content_get_attirbute_handle(), filter, &option_query);
+               if(ret != MEDIA_CONTENT_ERROR_NONE)
+               {
+                       SAFE_FREE(condition_query);
+                       return ret;
+               }
+
+               if(STRING_VALID(condition_query))
+               {
+                       SAFE_STRLCAT(select_query, QUERY_KEYWORD_SPACE, sizeof(select_query));
+                       SAFE_STRLCAT(select_query, QUERY_KEYWORD_AND, sizeof(select_query));
+               }
+       }
+
+       ret = _content_query_prepare(&stmt, select_query, condition_query, option_query);
+       SAFE_FREE(condition_query);
+       SAFE_FREE(option_query);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       while(sqlite3_step(stmt) == SQLITE_ROW)
+       {
+               if(STRING_VALID((const char *)sqlite3_column_text(stmt, 0)))
+               {
+                       name = strdup((const char *)sqlite3_column_text(stmt, 0));
+                       media_content_debug("group name : [%s]", name);
+               }
+
+               if(callback(name, user_data) == false)
+               {
+                       SAFE_FREE(name);
+                       break;
+               }
+
+               SAFE_FREE(name);
+       }
+
+       SQLITE3_FINALIZE(stmt);
+
+       return ret;
+}
+
+int _media_db_get_album(filter_h filter, media_album_cb callback, void *user_data)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       char select_query[DEFAULT_QUERY_SIZE];
+       char *condition_query = NULL;
+       char *option_query = NULL;
+       sqlite3_stmt *stmt = NULL;
+       filter_s *_filter = NULL;
+
+       memset(select_query, 0x00, sizeof(select_query));
+
+       //snprintf(select_query, sizeof(select_query), SELECT_ALBUM_LIST);
+       if(!SAFE_STRLCPY(select_query, SELECT_ALBUM_LIST, sizeof(select_query)))
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       if(filter != NULL)
+       {
+               _filter = (filter_s*)filter;
+
+               if(_filter->condition)
+               {
+                       ret = _media_filter_attribute_generate(_content_get_alias_attirbute_handle(), _filter->condition, _filter->condition_collate_type, &condition_query);
+                       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+               }
+
+               ret = _media_filter_attribute_option_generate(_content_get_alias_attirbute_handle(), filter, &option_query);
+               if(ret != MEDIA_CONTENT_ERROR_NONE)
+               {
+                       SAFE_FREE(condition_query);
+                       return ret;
+               }
+
+               if(STRING_VALID(condition_query))
+               {
+                       SAFE_STRLCAT(select_query, QUERY_KEYWORD_SPACE, sizeof(select_query));
+                       SAFE_STRLCAT(select_query, QUERY_KEYWORD_AND, sizeof(select_query));
+               }
+       }
+
+       ret = _content_query_prepare(&stmt, select_query, condition_query, option_query);
+       SAFE_FREE(condition_query);
+       SAFE_FREE(option_query);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       while(sqlite3_step(stmt) == SQLITE_ROW)
+       {
+               media_album_s *album = (media_album_s*)calloc(1, sizeof(media_album_s));
+
+               if(album == NULL)
+               {
+                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                       SQLITE3_FINALIZE(stmt);
+                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+               }
+
+               album->album_id = (int)sqlite3_column_int(stmt, 0);
+
+               if(STRING_VALID((const char *)sqlite3_column_text(stmt, 1)))
+                       album->name = strdup((const char *)sqlite3_column_text(stmt, 1));
+
+               if(STRING_VALID((const char *)sqlite3_column_text(stmt, 2)))
+                       album->artist = strdup((const char *)sqlite3_column_text(stmt, 2));
+
+               if(STRING_VALID((const char *)sqlite3_column_text(stmt, 3)))
+                       album->album_art_path = strdup((const char *)sqlite3_column_text(stmt, 3));
+
+               if(callback((media_album_h)album, user_data) == false)
+               {
+                       media_album_destroy((media_album_h)album);
+                       break;
+               }
+
+               media_album_destroy((media_album_h)album);
+       }
+
+       SQLITE3_FINALIZE(stmt);
+
+       return ret;
+}
+
+int _media_db_get_folder(filter_h filter, media_folder_cb callback, void *user_data)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       char select_query[DEFAULT_QUERY_SIZE];
+       char *condition_query = NULL;
+       char *option_query = NULL;
+       sqlite3_stmt *stmt = NULL;
+       filter_s *_filter = NULL;
+
+       memset(select_query, 0x00, sizeof(select_query));
+
+       //snprintf(select_query, sizeof(select_query), SELECT_FOLDER_LIST);
+       if(!SAFE_STRLCPY(select_query, SELECT_FOLDER_LIST, sizeof(select_query)))
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       if(filter != NULL)
+       {
+               _filter = (filter_s*)filter;
+
+               if(_filter->condition)
+               {
+                       ret = _media_filter_attribute_generate(_content_get_alias_attirbute_handle(), _filter->condition, _filter->condition_collate_type, &condition_query);
+                       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+               }
+
+               ret = _media_filter_attribute_option_generate(_content_get_alias_attirbute_handle(), filter, &option_query);
+               if(ret != MEDIA_CONTENT_ERROR_NONE)
+               {
+                       SAFE_FREE(condition_query);
+                       return ret;
+               }
+
+               if(STRING_VALID(condition_query))
+               {
+                       SAFE_STRLCAT(select_query, QUERY_KEYWORD_SPACE, sizeof(select_query));
+                       SAFE_STRLCAT(select_query, QUERY_KEYWORD_AND, sizeof(select_query));
+               }
+       }
+
+       ret = _content_query_prepare(&stmt, select_query, condition_query, option_query);
+       SAFE_FREE(condition_query);
+       SAFE_FREE(option_query);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       while(sqlite3_step(stmt) == SQLITE_ROW)
+       {
+               media_folder_s *_folder = (media_folder_s*)calloc(1, sizeof(media_folder_s));
+
+               if(_folder == NULL)
+               {
+                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                       SQLITE3_FINALIZE(stmt);
+                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+               }
+
+               if(STRING_VALID((const char *)sqlite3_column_text(stmt, 0)))
+                       _folder->folder_id = strdup((const char *)sqlite3_column_text(stmt, 0));
+
+               if(STRING_VALID((const char *)sqlite3_column_text(stmt, 1)))
+                       _folder->path = strdup((const char *)sqlite3_column_text(stmt, 1));
+
+               if(STRING_VALID((const char *)sqlite3_column_text(stmt, 2)))
+                       _folder->name = strdup((const char *)sqlite3_column_text(stmt, 2));
+
+               _folder->storage_type = (int)sqlite3_column_int(stmt,3);
+
+               _folder->modified_time = (int)sqlite3_column_int(stmt,4);
+
+               if(callback((media_folder_h)_folder, user_data) == false)
+               {
+                       media_folder_destroy((media_folder_h) _folder);
+                       break;
+               }
+
+               media_folder_destroy((media_folder_h) _folder);
+       }
+
+       SQLITE3_FINALIZE(stmt);
+
+       return ret;
+}
+
+int _media_db_get_playlist(filter_h filter, media_playlist_cb callback, void *user_data)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       char select_query[DEFAULT_QUERY_SIZE];
+       char *condition_query = NULL;
+       char *option_query = NULL;
+       sqlite3_stmt *stmt = NULL;
+       filter_s *_filter = NULL;
+
+       memset(select_query, 0x00, sizeof(select_query));
+
+       //snprintf(select_query, sizeof(select_query), SELECT_PLAYLIST_LIST);
+       if(!SAFE_STRLCPY(select_query, SELECT_PLAYLIST_LIST, sizeof(select_query)))
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+
+       if(filter != NULL)
+       {
+               _filter = (filter_s*)filter;
+
+               if(_filter->condition)
+               {
+                       //ret = _media_filter_attribute_generate(_content_get_alias_attirbute_handle(), _filter->condition, _filter->condition_collate_type, &condition_query);
+                       ret = _media_filter_attribute_generate(_content_get_attirbute_handle(), _filter->condition, _filter->condition_collate_type, &condition_query);
+                       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+               }
+
+               //ret = _media_filter_attribute_option_generate(_content_get_alias_attirbute_handle(), filter, &option_query);
+               ret = _media_filter_attribute_option_generate(_content_get_attirbute_handle(), filter, &option_query);
+               if(ret != MEDIA_CONTENT_ERROR_NONE)
+               {
+                       SAFE_FREE(condition_query);
+                       return ret;
+               }
+
+               if(STRING_VALID(condition_query))
+               {
+                       SAFE_STRLCAT(select_query, QUERY_KEYWORD_SPACE, sizeof(select_query));
+                       SAFE_STRLCAT(select_query, QUERY_KEYWORD_AND, sizeof(select_query));
+               }
+       }
+
+       ret = _content_query_prepare(&stmt, select_query, condition_query, option_query);
+       SAFE_FREE(condition_query);
+       SAFE_FREE(option_query);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       while(sqlite3_step(stmt) == SQLITE_ROW)
+       {
+               media_playlist_s *_playlist = (media_playlist_s*)calloc(1, sizeof(media_playlist_s));
+
+               if(_playlist == NULL)
+               {
+                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                       SQLITE3_FINALIZE(stmt);
+                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+               }
+
+               _playlist->playlist_id = (int)sqlite3_column_int(stmt, 0);
+
+               if(STRING_VALID((const char *)sqlite3_column_text(stmt, 1)))
+                       _playlist->name = strdup((const char *)sqlite3_column_text(stmt, 1));
+
+               if(callback((media_playlist_h)_playlist, user_data) == false)
+               {
+                       media_playlist_destroy((media_playlist_h)_playlist);
+                       break;
+               }
+               media_playlist_destroy((media_playlist_h)_playlist);
+       }
+
+       SQLITE3_FINALIZE(stmt);
+
+       return ret;
+}
+
+int _media_db_get_playlist_item(int playlist_id, filter_h filter, playlist_member_cb callback, void *user_data)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       char select_query[DEFAULT_QUERY_SIZE];
+       char *condition_query = NULL;
+       char *option_query = NULL;
+       sqlite3_stmt *stmt = NULL;
+       filter_s *_filter = NULL;
+
+       memset(select_query, 0x00, sizeof(select_query));
+
+       snprintf(select_query, sizeof(select_query), SELECT_PLAYLIST_ITEM_ID_FROM_PLAYLIST_VIEW, playlist_id);
+
+       if(filter != NULL)
+       {
+               _filter = (filter_s*)filter;
+
+               if(_filter->condition)
+               {
+                       //ret = _media_filter_attribute_generate(_content_get_alias_attirbute_handle(), _filter->condition, _filter->condition_collate_type, &condition_query);
+                       ret = _media_filter_attribute_generate(_content_get_attirbute_handle(), _filter->condition, _filter->condition_collate_type, &condition_query);
+                       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+               }
+
+               //ret = _media_filter_attribute_option_generate(_content_get_alias_attirbute_handle(), filter, &option_query);
+               ret = _media_filter_attribute_option_generate(_content_get_attirbute_handle(), filter, &option_query);
+               if(ret != MEDIA_CONTENT_ERROR_NONE)
+               {
+                       SAFE_FREE(condition_query);
+                       return ret;
+               }
+
+               if(STRING_VALID(condition_query))
+               {
+                       SAFE_STRLCAT(select_query, QUERY_KEYWORD_SPACE, sizeof(select_query));
+                       SAFE_STRLCAT(select_query, QUERY_KEYWORD_AND, sizeof(select_query));
+               }
+       }
+
+       ret = _content_query_prepare(&stmt, select_query, condition_query, option_query);
+       SAFE_FREE(condition_query);
+       SAFE_FREE(option_query);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       while(sqlite3_step(stmt) == SQLITE_ROW)
+       {
+               int playlist_member_id = 0;
+               char media_uuid[MEDIA_CONTENT_UUID_SIZE+1];
+               media_info_h media = NULL;
+               memset(media_uuid, 0x00, sizeof(media_uuid));
+
+               playlist_member_id = (int)sqlite3_column_int(stmt, 0);
+
+               if(STRING_VALID((const char *)sqlite3_column_text(stmt, 1)))
+                       strncpy(media_uuid, (const char *)sqlite3_column_text(stmt, 1), MEDIA_CONTENT_UUID_SIZE);
+
+               ret = media_info_get_media_from_db(media_uuid, &media);
+
+               if(callback(playlist_member_id, media, user_data) == false)
+               {
+                       media_info_destroy(media);
+                       break;
+               }
+               media_info_destroy(media);
+       }
+
+       SQLITE3_FINALIZE(stmt);
+
+       return ret;
+}
+
+//same as _media_db_get_playlist
+int _media_db_get_tag(const char *media_id, filter_h filter, media_tag_cb callback, void *user_data)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       char select_query[DEFAULT_QUERY_SIZE];
+       char *condition_query = NULL;
+       char *option_query = NULL;
+       sqlite3_stmt *stmt = NULL;
+       filter_s *_filter = NULL;
+       attribute_h attr;
+
+       memset(select_query, 0x00, sizeof(select_query));
+
+       if(!STRING_VALID(media_id))
+       {
+               //attr = _content_get_alias_attirbute_handle();
+               attr = _content_get_attirbute_handle();
+               //snprintf(select_query, sizeof(select_query), SELECT_TAG_LIST);
+               if(!SAFE_STRLCPY(select_query, SELECT_TAG_LIST, sizeof(select_query)))
+               {
+                       media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+                       return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+               }
+       }
+       else
+       {
+               attr = _content_get_attirbute_handle();
+               snprintf(select_query, sizeof(select_query), SELECT_TAG_LIST_BY_MEDIA_ID, media_id);
+       }
+
+       if(filter != NULL)
+       {
+               _filter = (filter_s*)filter;
+
+               if(_filter->condition)
+               {
+                       ret = _media_filter_attribute_generate(attr, _filter->condition, _filter->condition_collate_type, &condition_query);
+                       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+               }
+
+               ret = _media_filter_attribute_option_generate(attr, filter, &option_query);
+               if(ret != MEDIA_CONTENT_ERROR_NONE)
+               {
+                       SAFE_FREE(condition_query);
+                       return ret;
+               }
+
+               if(STRING_VALID(condition_query))
+               {
+                       SAFE_STRLCAT(select_query, QUERY_KEYWORD_SPACE, sizeof(select_query));
+                       SAFE_STRLCAT(select_query, QUERY_KEYWORD_AND, sizeof(select_query));
+               }
+       }
+
+       SAFE_STRLCAT(select_query, QUERY_KEYWORD_SPACE, sizeof(select_query));
+
+       ret = _content_query_prepare(&stmt, select_query, condition_query, option_query);
+       SAFE_FREE(condition_query);
+       SAFE_FREE(option_query);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       while(sqlite3_step(stmt) == SQLITE_ROW)
+       {
+               media_tag_s *_tag = (media_tag_s*)calloc(1, sizeof(media_tag_s));
+
+               if(_tag == NULL)
+               {
+                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                       SQLITE3_FINALIZE(stmt);
+                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+               }
+
+               _tag->tag_id = (int)sqlite3_column_int(stmt, 0);
+
+               if(STRING_VALID((const char *)sqlite3_column_text(stmt, 1)))
+                       _tag->name = strdup((const char *)sqlite3_column_text(stmt, 1));
+
+               if(callback((media_tag_h)_tag, user_data) == false)
+               {
+                       media_tag_destroy((media_tag_h)_tag);
+                       break;
+               }
+               media_tag_destroy((media_tag_h)_tag);
+       }
+
+       SQLITE3_FINALIZE(stmt);
+
+       return ret;
+}
+
+int _media_db_get_bookmark(const char *media_id, filter_h filter, media_bookmark_cb callback, void *user_data)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       char select_query[DEFAULT_QUERY_SIZE];
+       char *condition_query = NULL;
+       char *option_query = NULL;
+       sqlite3_stmt *stmt = NULL;
+       filter_s *_filter = NULL;
+       attribute_h attr;
+
+       memset(select_query, 0x00, sizeof(select_query));
+
+       if(!STRING_VALID(media_id))
+       {
+               attr = _content_get_alias_attirbute_handle();
+               //snprintf(select_query, sizeof(select_query), SELECT_BOOKMARK_LIST);
+               if(!SAFE_STRLCPY(select_query, SELECT_BOOKMARK_LIST, sizeof(select_query)))
+               {
+                       media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+                       return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+               }
+       }
+       else
+       {
+               attr = _content_get_attirbute_handle();
+               snprintf(select_query, sizeof(select_query), SELECT_BOOKMARK_LIST_BY_MEDIA_ID_USUAL, media_id);
+       }
+
+       if(filter != NULL)
+       {
+               _filter = (filter_s*)filter;
+
+               if(_filter->condition)
+               {
+                       ret = _media_filter_attribute_generate(attr, _filter->condition, _filter->condition_collate_type, &condition_query);
+                       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+               }
+
+               ret = _media_filter_attribute_option_generate(attr, filter, &option_query);
+               if(ret != MEDIA_CONTENT_ERROR_NONE)
+               {
+                       SAFE_FREE(condition_query);
+                       return ret;
+               }
+
+               if(STRING_VALID(condition_query))
+               {
+                       SAFE_STRLCAT(select_query, QUERY_KEYWORD_SPACE, sizeof(select_query));
+                       SAFE_STRLCAT(select_query, QUERY_KEYWORD_AND, sizeof(select_query));
+               }
+       }
+
+       ret = _content_query_prepare(&stmt, select_query, condition_query, option_query);
+       SAFE_FREE(condition_query);
+       SAFE_FREE(option_query);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       while(sqlite3_step(stmt) == SQLITE_ROW)
+       {
+               media_bookmark_s *bookmark = (media_bookmark_s*)calloc(1, sizeof(media_bookmark_s));
+
+               if(bookmark == NULL)
+               {
+                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                       SQLITE3_FINALIZE(stmt);
+                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+               }
+
+               bookmark->bookmark_id = (int)sqlite3_column_int(stmt, 0);
+
+               if(STRING_VALID((const char *)sqlite3_column_text(stmt, 1)))
+                       bookmark->media_id = strdup((const char *)sqlite3_column_text(stmt, 1));
+
+               bookmark->marked_time = (int)sqlite3_column_int(stmt, 2);
+
+               if(STRING_VALID((const char *)sqlite3_column_text(stmt, 3)))
+                       bookmark->thumbnail_path = strdup((const char *)sqlite3_column_text(stmt, 3));
+
+               if(callback((media_bookmark_h)bookmark, user_data) == false)
+               {
+                       media_bookmark_destroy((media_bookmark_h)bookmark);
+                       break;
+               }
+
+               media_bookmark_destroy((media_bookmark_h)bookmark);
+       }
+
+       SQLITE3_FINALIZE(stmt);
+
+       return ret;
+
+}
+
+int _media_db_get_group_item_count_by_id(int group_id, filter_h filter, group_list_e group_type, int *item_count)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       sqlite3_stmt *stmt = NULL;
+       filter_s *_filter = NULL;
+       char select_query[DEFAULT_QUERY_SIZE];
+       char *condition_query = NULL;
+       char *option_query = NULL;
+       attribute_h attr = NULL;
+
+       media_content_debug_func();
+
+       memset(select_query, 0x00, sizeof(select_query));
+
+       if(group_type == MEDIA_GROUP_ALBUM)
+       {
+               attr = _content_get_attirbute_handle();
+               snprintf(select_query, sizeof(select_query), SELECT_MEDIA_COUNT_FROM_ALBUM, group_id);
+       }
+       else if(group_type == MEDIA_GROUP_PLAYLIST)
+       {
+               //attr = _content_get_alias_attirbute_handle();
+               attr = _content_get_attirbute_handle();
+               snprintf(select_query, sizeof(select_query), SELECT_MEDIA_COUNT_FROM_PLAYLIST, group_id);
+       }
+       else if(group_type == MEDIA_GROUP_TAG)
+       {
+               attr = _content_get_attirbute_handle();
+               snprintf(select_query, sizeof(select_query), SELECT_MEDIA_COUNT_FROM_TAG, group_id);
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       if(filter != NULL)
+       {
+               _filter = (filter_s*)filter;
+
+               if(_filter->condition)
+               {
+                       ret = _media_filter_attribute_generate(attr, _filter->condition, _filter->condition_collate_type, &condition_query);
+                       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+               }
+
+               ret = _media_filter_attribute_option_generate(attr, filter, &option_query);
+               if(ret != MEDIA_CONTENT_ERROR_NONE)
+               {
+                       SAFE_FREE(condition_query);
+                       return ret;
+               }
+
+               if(STRING_VALID(condition_query))
+               {
+                       SAFE_STRLCAT(select_query, QUERY_KEYWORD_SPACE, sizeof(select_query));
+                       SAFE_STRLCAT(select_query, QUERY_KEYWORD_AND, sizeof(select_query));
+               }
+       }
+/*
+       if((group_type == MEDIA_GROUP_PLAYLIST) || (group_type == MEDIA_GROUP_TAG))
+       {
+               strncat(select_query, QUERY_KEYWORD_SPACE, strlen(QUERY_KEYWORD_SPACE));
+
+               if(STRING_VALID(condition_query))
+                       strncat(select_query, condition_query, strlen(condition_query));
+               if(STRING_VALID(option_query))
+                       strncat(select_query, option_query, strlen(option_query));
+
+               strncat(select_query, QUERY_KEYWORD_BRACKET, strlen(QUERY_KEYWORD_BRACKET));
+
+               SAFE_FREE(condition_query);
+               SAFE_FREE(option_query);
+       }
+*/
+       ret = _content_query_prepare(&stmt, select_query, condition_query, option_query);
+       SAFE_FREE(condition_query);
+       SAFE_FREE(option_query);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       while(sqlite3_step(stmt) == SQLITE_ROW)
+       {
+               *item_count = (int)sqlite3_column_int(stmt, 0);
+               media_content_debug("group item count : [%d]", *item_count);
+       }
+
+       SQLITE3_FINALIZE(stmt);
+
+       return ret;
+}
+
+int _media_db_get_group_item_count(const char *group_name, filter_h filter, group_list_e group_type, int *item_count)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       sqlite3_stmt *stmt = NULL;
+       filter_s *_filter = NULL;
+       char complete_select_query[DEFAULT_QUERY_SIZE];
+       char *select_query = NULL;
+       char *condition_query = NULL;
+       char *option_query = NULL;
+
+       media_content_debug_func();
+
+       if(group_type == MEDIA_GROUP_NONE)
+       {
+               select_query = sqlite3_mprintf(SELECT_MEDIA_COUNT_FROM_MEDIA);
+       }
+       else if(group_type == MEDIA_GROUP_FOLDER)
+       {
+               select_query = sqlite3_mprintf(SELECT_MEDIA_COUNT_FROM_FOLDER, group_name);
+       }
+       else if(group_type == MEDIA_GROUP_TAG_BY_MEDIA_ID)
+       {
+               select_query = sqlite3_mprintf(SELECT_TAG_COUNT_BY_MEDIA_ID, group_name);
+       }
+       else if(group_type == MEDIA_GROUP_BOOKMARK_BY_MEDIA_ID)
+       {
+               select_query = sqlite3_mprintf(SELECT_BOOKMARK_COUNT_BY_MEDIA_ID, group_name);
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       if(filter != NULL)
+       {
+               _filter = (filter_s*)filter;
+
+               if(_filter->condition)
+               {
+                       ret = _media_filter_attribute_generate(_content_get_attirbute_handle(), _filter->condition, _filter->condition_collate_type, &condition_query);
+                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                       {
+                               sqlite3_free(select_query);
+                               return ret;
+                       }
+               }
+
+               ret = _media_filter_attribute_option_generate(_content_get_attirbute_handle(), filter, &option_query);
+               if(ret != MEDIA_CONTENT_ERROR_NONE)
+               {
+                       sqlite3_free(select_query);
+                       SAFE_FREE(condition_query);
+                       return ret;
+               }
+
+               if(STRING_VALID(condition_query))
+               {
+                       snprintf(complete_select_query, sizeof(complete_select_query), "%s %s", select_query, QUERY_KEYWORD_AND);
+               }
+               else
+               {
+                       snprintf(complete_select_query, sizeof(complete_select_query), "%s", select_query);
+               }
+       } else {
+               snprintf(complete_select_query, sizeof(complete_select_query), "%s", select_query);
+       }
+
+       if(group_type == MEDIA_GROUP_NONE)
+       {
+               SAFE_STRLCAT(complete_select_query, QUERY_KEYWORD_SPACE, sizeof(complete_select_query));
+               if(STRING_VALID(condition_query))
+                       SAFE_STRLCAT(complete_select_query, condition_query, sizeof(complete_select_query));
+               if(STRING_VALID(option_query))
+                       SAFE_STRLCAT(complete_select_query, option_query, sizeof(complete_select_query));
+
+               SAFE_STRLCAT(complete_select_query, QUERY_KEYWORD_BRACKET, sizeof(complete_select_query));
+
+               SAFE_FREE(condition_query);
+               SAFE_FREE(option_query);
+       }
+
+       ret = _content_query_prepare(&stmt, complete_select_query, condition_query, option_query);
+       sqlite3_free(select_query);
+       SAFE_FREE(condition_query);
+       SAFE_FREE(option_query);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       while(sqlite3_step(stmt) == SQLITE_ROW)
+       {
+               *item_count = (int)sqlite3_column_int(stmt, 0);
+               media_content_debug("group item count : [%d]", *item_count);
+       }
+
+       SQLITE3_FINALIZE(stmt);
+
+       return ret;
+}
+
+int _media_db_get_group_item_by_id(int group_id, filter_h filter, media_info_cb callback, void *user_data, group_list_e group_type)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       char select_query[DEFAULT_QUERY_SIZE];
+       char *condition_query = NULL;
+       char *option_query = NULL;
+       sqlite3_stmt *stmt = NULL;
+       filter_s *_filter = NULL;
+
+       memset(select_query, 0x00, sizeof(select_query));
+
+       if(group_type == MEDIA_GROUP_ALBUM)
+       {
+               snprintf(select_query, sizeof(select_query), SELECT_MEDIA_FROM_ALBUM, group_id);
+       }
+       else if(group_type == MEDIA_GROUP_PLAYLIST)
+       {
+               snprintf(select_query, sizeof(select_query), SELECT_MEDIA_FROM_PLAYLIST, group_id);
+       }
+       else if(group_type == MEDIA_GROUP_TAG)
+       {
+               snprintf(select_query, sizeof(select_query), SELECT_MEDIA_FROM_TAG, group_id);
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       if(filter != NULL)
+       {
+               _filter = (filter_s*)filter;
+
+               if(_filter->condition)
+               {
+                       ret = _media_filter_attribute_generate(_content_get_attirbute_handle(), _filter->condition, _filter->condition_collate_type, &condition_query);
+                       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+               }
+
+               ret = _media_filter_attribute_option_generate(_content_get_attirbute_handle(), filter, &option_query);
+               if(ret != MEDIA_CONTENT_ERROR_NONE)
+               {
+                       SAFE_FREE(condition_query);
+                       return ret;
+               }
+
+               if(STRING_VALID(condition_query))
+               {
+                       SAFE_STRLCAT(select_query, QUERY_KEYWORD_SPACE, sizeof(select_query));
+                       SAFE_STRLCAT(select_query, QUERY_KEYWORD_AND, sizeof(select_query));
+               }
+       }
+
+       ret = _content_query_prepare(&stmt, select_query, condition_query, option_query);
+       SAFE_FREE(condition_query);
+       SAFE_FREE(option_query);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       while(sqlite3_step(stmt) == SQLITE_ROW)
+       {
+               media_info_s *item = (media_info_s*)calloc(1, sizeof(media_info_s));
+               if(item == NULL)
+               {
+                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                       SQLITE3_FINALIZE(stmt);
+                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+               }
+
+               _media_info_item_get_detail(stmt, (media_info_h)item);
+
+               if(callback((media_info_h)item, user_data) == false)
+               {
+                       media_info_destroy((media_info_h)item);
+                       break;
+               }
+
+               media_info_destroy((media_info_h)item);
+       }
+
+       SQLITE3_FINALIZE(stmt);
+
+       return ret;
+}
+
+int _media_db_get_group_item(const char *group_name, filter_h filter, media_info_cb callback, void *user_data, group_list_e group_type)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       char complete_select_query[DEFAULT_QUERY_SIZE];
+       char *select_query = NULL;
+       char *condition_query = NULL;
+       char *option_query = NULL;
+       sqlite3_stmt *stmt = NULL;
+       filter_s *_filter = NULL;
+
+       if(group_type == MEDIA_GROUP_NONE)
+       {
+               select_query = sqlite3_mprintf(SELECT_MEDIA_ITEM);
+       }
+       else if(group_type == MEDIA_GROUP_FOLDER)
+       {
+               select_query = sqlite3_mprintf(SELECT_MEDIA_FROM_FOLDER, group_name);
+       }
+       else if(group_type == MEDIA_GROUP_BOOKMARK_BY_MEDIA_ID)
+       {
+               select_query = sqlite3_mprintf(SELECT_BOOKMARK_LIST_BY_MEDIA_ID, group_name);
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       if(filter != NULL)
+       {
+               _filter = (filter_s*)filter;
+
+               if(_filter->condition)
+               {
+                       ret = _media_filter_attribute_generate(_content_get_attirbute_handle(), _filter->condition, _filter->condition_collate_type, &condition_query);
+                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                       {
+                               sqlite3_free(select_query);
+                               return ret;
+                       }
+               }
+
+               ret = _media_filter_attribute_option_generate(_content_get_attirbute_handle(), filter, &option_query);
+               if(ret != MEDIA_CONTENT_ERROR_NONE)
+               {
+                       sqlite3_free(select_query);
+                       SAFE_FREE(condition_query);
+                       return ret;
+               }
+
+               if(STRING_VALID(condition_query))
+               {
+                       snprintf(complete_select_query, sizeof(complete_select_query), "%s %s", select_query, QUERY_KEYWORD_AND);
+               }
+               else
+               {
+                       snprintf(complete_select_query, sizeof(complete_select_query), "%s", select_query);
+               }
+       } else {
+               snprintf(complete_select_query, sizeof(complete_select_query), "%s", select_query);
+       }
+
+       ret = _content_query_prepare(&stmt, complete_select_query, condition_query, option_query);
+       sqlite3_free(select_query);
+       SAFE_FREE(condition_query);
+       SAFE_FREE(option_query);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       while(sqlite3_step(stmt) == SQLITE_ROW)
+       {
+               media_info_s *item = (media_info_s*)calloc(1, sizeof(media_info_s));
+               if(item == NULL)
+               {
+                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                       SQLITE3_FINALIZE(stmt);
+                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+               }
+
+               _media_info_item_get_detail(stmt, (media_info_h)item);
+
+               if(callback((media_info_h)item, user_data) == false)
+               {
+                       media_info_destroy((media_info_h)item);
+                       break;
+               }
+
+               media_info_destroy((media_info_h)item);
+       }
+
+       SQLITE3_FINALIZE(stmt);
+
+       return ret;
+}
+
+int _media_db_get_media_group_item_count(const char *group_name, media_group_e group, filter_h filter, int *item_count)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       sqlite3_stmt *stmt = NULL;
+       filter_s *_filter = NULL;
+       char complete_select_query[DEFAULT_QUERY_SIZE];
+       char *select_query = NULL;
+       char *condition_query = NULL;
+       char *option_query = NULL;
+
+       media_content_debug_func();
+
+       if(group_name != NULL)
+               select_query = sqlite3_mprintf(SELECT_MEDIA_COUNT_FROM_GROUP, __media_db_get_group_name(group), group_name);
+       else
+               select_query = sqlite3_mprintf(SELECT_MEDIA_COUNT_FROM_GROUP_NULL, __media_db_get_group_name(group));
+
+       if(filter != NULL)
+       {
+               _filter = (filter_s*)filter;
+
+               if(_filter->condition)
+               {
+                       ret = _media_filter_attribute_generate(_content_get_attirbute_handle(), _filter->condition, _filter->condition_collate_type, &condition_query);
+                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                       {
+                               sqlite3_free(select_query);
+                               return ret;
+                       }
+               }
+
+               ret = _media_filter_attribute_option_generate(_content_get_attirbute_handle(), filter, &option_query);
+               if(ret != MEDIA_CONTENT_ERROR_NONE)
+               {
+                       sqlite3_free(select_query);
+                       SAFE_FREE(condition_query);
+                       return ret;
+               }
+
+               if(STRING_VALID(condition_query))
+               {
+                       snprintf(complete_select_query, sizeof(complete_select_query), "%s %s", select_query, QUERY_KEYWORD_AND);
+               }
+               else
+               {
+                       snprintf(complete_select_query, sizeof(complete_select_query), "%s", select_query);
+               }
+       } else {
+               snprintf(complete_select_query, sizeof(complete_select_query), "%s", select_query);
+       }
+
+       SAFE_STRLCAT(complete_select_query, QUERY_KEYWORD_SPACE, sizeof(complete_select_query));
+       if(STRING_VALID(condition_query))
+               SAFE_STRLCAT(complete_select_query, condition_query, sizeof(complete_select_query));
+       if(STRING_VALID(option_query))
+               SAFE_STRLCAT(complete_select_query, option_query, sizeof(complete_select_query));
+
+       SAFE_STRLCAT(complete_select_query, QUERY_KEYWORD_BRACKET, sizeof(complete_select_query));
+
+       SAFE_FREE(condition_query);
+       SAFE_FREE(option_query);
+
+       ret = _content_query_prepare(&stmt, complete_select_query, condition_query, option_query);
+       sqlite3_free(select_query);
+       SAFE_FREE(condition_query);
+       SAFE_FREE(option_query);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       while(sqlite3_step(stmt) == SQLITE_ROW)
+       {
+               *item_count = (int)sqlite3_column_int(stmt, 0);
+               media_content_debug("group item count : [%d]", *item_count);
+       }
+
+       SQLITE3_FINALIZE(stmt);
+
+       return ret;
+}
+
+int _media_db_get_media_group_item(const char *group_name, media_group_e group, filter_h filter, media_info_cb callback, void *user_data)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       char complete_select_query[DEFAULT_QUERY_SIZE];
+       char *select_query = NULL;
+       char *condition_query = NULL;
+       char *option_query = NULL;
+       sqlite3_stmt *stmt = NULL;
+       filter_s *_filter = NULL;
+
+       media_content_debug_func();
+
+       if(group_name != NULL)
+               select_query = sqlite3_mprintf(SELECT_MEDIA_FROM_GROUP, __media_db_get_group_name(group), group_name);
+       else
+               select_query = sqlite3_mprintf(SELECT_MEDIA_FROM_GROUP_NULL, __media_db_get_group_name(group));
+
+       if(filter != NULL)
+       {
+               _filter = (filter_s*)filter;
+
+               if(_filter->condition)
+               {
+                       ret = _media_filter_attribute_generate(_content_get_attirbute_handle(), _filter->condition, _filter->condition_collate_type, &condition_query);
+                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                       {
+                               sqlite3_free(select_query);
+                               return ret;
+                       }
+               }
+
+               ret = _media_filter_attribute_option_generate(_content_get_attirbute_handle(), filter, &option_query);
+               if(ret != MEDIA_CONTENT_ERROR_NONE)
+               {
+                       sqlite3_free(select_query);
+                       SAFE_FREE(condition_query);
+                       return ret;
+               }
+
+               if(STRING_VALID(condition_query))
+               {
+                       snprintf(complete_select_query, sizeof(complete_select_query), "%s %s", select_query, QUERY_KEYWORD_AND);
+               }
+               else
+               {
+                       snprintf(complete_select_query, sizeof(complete_select_query), "%s", select_query);
+               }
+       } else {
+               snprintf(complete_select_query, sizeof(complete_select_query), "%s", select_query);
+       }
+
+       ret = _content_query_prepare(&stmt, complete_select_query, condition_query, option_query);
+       sqlite3_free(select_query);
+       SAFE_FREE(condition_query);
+       SAFE_FREE(option_query);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       while(sqlite3_step(stmt) == SQLITE_ROW)
+       {
+               media_info_s *item = (media_info_s*)calloc(1, sizeof(media_info_s));
+               if(item == NULL)
+               {
+                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                       SQLITE3_FINALIZE(stmt);
+                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+               }
+
+               _media_info_item_get_detail(stmt, (media_info_h)item);
+
+               if(callback((media_info_h)item, user_data) == false)
+               {
+                       media_info_destroy((media_info_h)item);
+                       break;
+               }
+
+               media_info_destroy((media_info_h)item);
+       }
+
+       SQLITE3_FINALIZE(stmt);
+
+       return ret;
+}
diff --git a/src/media_filter.c b/src/media_filter.c
new file mode 100755 (executable)
index 0000000..be78a06
--- /dev/null
@@ -0,0 +1,1230 @@
+/*
+* 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_content.h>
+#include <media_info_private.h>
+#include <media-svc.h>
+
+static char *media_token[] =
+{
+       " ",
+       "\"",
+       "'",
+       "(",
+       ")",
+       "=",
+       "<=",
+       "<",
+       ">=",
+       ">",
+};
+
+
+typedef struct _token_t
+{
+       int type;
+       char *str;
+}token_t;
+
+
+#define MAX_LEFT_VALUE 512
+#define SPACE_LEN 1
+#define SPACE " "
+#define UNKNOWN_TYPE 1000
+#define STRING_TYPE 100
+
+static char *__get_order_str(media_content_order_e order_enum);
+static char *__get_collate_str(media_content_collation_e collate_type);
+static void __filter_attribute_free_value(gpointer key, gpointer value, gpointer user_data);
+static char *__media_filter_replace_attr(attribute_h attr, char *name);
+static int __tokenize_operator(token_t *token, const char *str, int op_type);
+static int __tokenize(GList **token_list, const char *str);
+
+static char *__get_order_str(media_content_order_e order_enum)
+{
+       switch(order_enum) {
+               case MEDIA_CONTENT_ORDER_ASC:
+                       return "ASC";
+               case MEDIA_CONTENT_ORDER_DESC:
+                       return "DESC";
+               default:
+                       return " ";
+       }
+}
+
+static char *__get_collate_str(media_content_collation_e collate_type)
+{
+       switch(collate_type) {
+               case MEDIA_CONTENT_COLLATE_NOCASE:
+                       return "NOCASE";
+               case MEDIA_CONTENT_COLLATE_RTRIM:
+                       return "RTRIM";
+               default: return " ";
+       }
+}
+
+static void __filter_attribute_free_value(gpointer key, gpointer value, gpointer user_data)
+{
+       SAFE_FREE(key);
+       SAFE_FREE(value);
+}
+
+static char *__media_filter_replace_attr(attribute_h attr, char *name)
+{
+       char *key_temp;
+       char *generated_value;
+       attribute_s *_attr = (attribute_s *)attr;
+
+       if(!g_hash_table_lookup_extended(_attr->attr_map,
+                                                                               name,
+                                                                               (gpointer)&key_temp, (gpointer)&generated_value))
+       {
+               //can't find the value
+               //media_content_error("NOT_FOUND_VALUE(%s)", name);
+               return NULL;
+       }
+
+       if(STRING_VALID(generated_value))
+       {
+               return strdup(generated_value);
+       }
+
+       media_content_error("__media_filter_replace_attr fail");
+
+       return NULL;
+}
+
+static int __tokenize_operator(token_t *token, const char *str, int op_type)
+{
+       int ret = 0;
+       const char *tmp = str;
+
+       if(token != NULL && STRING_VALID(tmp))
+       {
+               token->type = op_type;
+               int token_size = strlen(media_token[op_type]);
+               if(token_size == 0)
+               {
+                       media_content_error("Invalid token_size. op_type[%d]", op_type);
+                       return -1;
+               }
+
+               token->str = (char*)calloc(token_size+1, sizeof(char));
+               if(token->str == NULL)
+               {
+                       media_content_error("OUT_OF_MEMORY");
+                       return -1;
+               }
+
+               strncpy(token->str, tmp, token_size);
+               //media_content_debug("type : [%d] str : [%s]", token->type, token->str);
+               ret = token_size;
+       }
+       else
+       {
+               ret = -1;
+       }
+
+       return ret;
+}
+
+static int __tokenize_string(token_t *token, const char *str, int size)
+{
+       int ret = size;
+       const char *tmp = str;
+
+       if(token != NULL && STRING_VALID(tmp) && size > 0)
+       {
+               token->str = (char*)calloc(size+1, sizeof(char));
+               if(token->str == NULL)
+               {
+                       media_content_error("OUT_OF_MEMORY");
+                       return -1;
+               }
+               token->type = UNKNOWN_TYPE;
+               strncpy(token->str, tmp, size);
+               //media_content_debug("type : [%d] str : [%s]", token->type, token->str);
+       }
+       else
+       {
+               ret = -1;
+       }
+
+       return ret;
+}
+
+static int __tokenize_attribute(GList **token_list, const char *str)
+{
+       int ret = 0;
+       int idx = 0;
+
+       if(!STRING_VALID(str)) {
+               media_content_error("Parameter string in invalid");
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       const char *tmp = str;
+       const char *dst_ptr = str + strlen(str);
+
+       for (idx = 0; (*(tmp+idx)) && (tmp < dst_ptr); idx++)
+       {
+               //media_content_debug("[%d] '%c'", idx, tmp[idx]);
+               if(tmp[idx] == ' ')             //" "
+               {
+                       if(idx == 0)            // ignore the space.
+                       {
+                               tmp++;
+                               idx = -1;
+                               continue;
+                       }
+                       token_t *token = (token_t*)calloc(1, sizeof(token_t));
+                       token->type = UNKNOWN_TYPE;
+                       token->str = (char*)calloc(idx+1, sizeof(char));
+                       strncpy(token->str, tmp, idx);
+                       media_content_debug("type : [%d] str : [%s]", token->type, token->str);
+                       *token_list = g_list_append(*token_list, token);
+                       tmp = tmp +idx + strlen(media_token[0]);
+                       idx = -1;
+               }
+               else if(tmp[idx] == ',')        // " , "
+               {
+                       if(idx != 0)
+                       {
+                               token_t *token = (token_t*)calloc(1, sizeof(token_t));
+                               if(token == NULL)
+                               {
+                                       media_content_error("OUT_OF_MEMORY");
+                                       return -1;
+                               }
+                               ret = __tokenize_string(token, tmp, idx);
+                               if (ret < 0)
+                               {
+                                       SAFE_FREE(token);
+                                       media_content_error("tokenize error occued");
+                                       return -1;
+                               }
+                               else
+                               {
+                                       *token_list = g_list_append(*token_list, token);
+                                       tmp = tmp + idx;
+                               }
+                       }
+
+                       token_t *token = (token_t*)calloc(1, sizeof(token_t));
+                       int size = __tokenize_operator(token, tmp,3);
+
+                       if(token != NULL && STRING_VALID(token->str))
+                       {
+                               *token_list = g_list_append(*token_list, token);
+                               tmp += size;
+                               idx = -1;
+                       }
+                       else
+                       {
+                               SAFE_FREE(token);
+                               media_content_error("tokenize error occued");
+                               return -1;
+                       }
+               }
+       }
+
+       if(*tmp)                        //remained string
+       {
+               token_t *token = (token_t*)calloc(1, sizeof(token_t));
+               if(token == NULL)
+               {
+                       media_content_error("OUT_OF_MEMORY");
+                       return -1;
+               }
+
+               ret = __tokenize_string(token, tmp, idx);
+               if (ret < 0)
+               {
+                       SAFE_FREE(token);
+                       media_content_error("tokenize error occued");
+                       return -1;
+               }
+
+               if(token != NULL && STRING_VALID(token->str))
+               {
+                       *token_list = g_list_append(*token_list, token);
+               }
+               else
+               {
+                       SAFE_FREE(token);
+                       media_content_error("tokenize error occued");
+                       return -1;
+               }
+       }
+
+       return MEDIA_CONTENT_ERROR_NONE;
+}
+
+static int __tokenize(GList **token_list, const char *str)
+{
+       int ret = 0;
+       int idx = 0;
+
+       if(!STRING_VALID(str)) {
+               media_content_error("Parameter string in invalid");
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       const char *tmp = str;
+       const char *dst_ptr = str + strlen(str);
+
+       for (idx = 0; (*(tmp+idx)) && (tmp < dst_ptr); idx++)
+       {
+               //media_content_debug("[%d] '%c'", idx, tmp[idx]);
+               if(tmp[idx] == media_token[0][0])               //" "
+               {
+                       if(idx == 0)            // ignore the space.
+                       {
+                               tmp++;
+                               idx = -1;
+                               continue;
+                       }
+
+                       token_t *token = (token_t*)calloc(1, sizeof(token_t));
+                       token->type = UNKNOWN_TYPE;
+                       token->str = (char*)calloc(idx+1, sizeof(char));
+                       strncpy(token->str, tmp, idx);
+                       //media_content_debug("type : [%d] str : [%s]", token->type, token->str);
+                       *token_list = g_list_append(*token_list, token);
+                       tmp = tmp +idx + strlen(media_token[0]);
+                       idx = -1;
+               }
+               else if(tmp[idx] == media_token[1][0])  // " \" "
+               {
+                       int j;
+                       bool flag = false;
+                       for(j = idx+1; tmp[j]; j++)     //find next quotation
+                       {
+                               if(tmp[j] == media_token[1][0] && tmp[j+1] == media_token[1][0])
+                               {
+                                       j += 2;
+                                       continue;
+                               }
+                               if(tmp[j] == media_token[1][0])
+                               {
+                                       token_t *token = (token_t*)calloc(1, sizeof(token_t));
+                                       token->str = (char*) calloc(j+1+1, sizeof(char));
+                                       token->type = STRING_TYPE;
+                                       strncpy(token->str, tmp, j+1);
+                                       media_content_debug("type : [%d] str : [%s], j : %d", token->type, token->str, j);
+                                       *token_list = g_list_append(*token_list, token);
+                                       tmp = tmp + strlen(token->str);
+                                       idx = -1;
+                                       flag = true;
+                                       break;
+                               }
+                       }
+
+                       if(!flag && *tmp != '\0' && tmp[j]=='\0')
+                       {
+                               token_t *token = (token_t*)calloc(1, sizeof(token_t));
+                               token->str = (char*) calloc(j+1,sizeof(char));
+                               token->type = UNKNOWN_TYPE;
+                               strncpy(token->str, tmp,j);
+                               media_content_debug("type : [%d] str : [%s]", token->type, token->str);
+                               *token_list = g_list_append(*token_list, token);
+                               tmp = tmp +strlen(token->str);
+                               idx = -1;
+                       }
+               }
+               else if(tmp[idx] == media_token[2][0])  // " \' "
+               {
+                       int j;
+                       bool flag = false;
+                       for(j = idx+1; tmp[j]; j++)
+                       {
+                               if(tmp[j] == media_token[2][0] && tmp[j+1] == media_token[2][0])
+                               {
+                                       j += 2;
+                                       continue;
+                               }
+                               if(tmp[j] == media_token[2][0])
+                               {
+                                       token_t *token = (token_t*)calloc(1, sizeof(token_t));
+                                       token->str = (char*) calloc(j+1+1, sizeof(char));
+                                       token->type = STRING_TYPE;
+                                       strncpy(token->str, tmp, j+1);
+                                       //media_content_debug("type : [%d] str : [%s]", token->type, token->str);
+                                       *token_list = g_list_append(*token_list, token);
+                                       tmp = tmp + strlen(token->str);
+                                       idx = -1;
+                                       flag = true;
+                                       break;
+                               }
+                       }
+
+                       if(!flag && *tmp != '\0' && tmp[j]=='\0')
+                       {
+                               token_t *token = (token_t*)calloc(1, sizeof(token_t));
+                               token->str = (char*) calloc(j+1,sizeof(char));
+                               token->type = UNKNOWN_TYPE;
+                               strncpy(token->str, tmp,j);
+                               media_content_debug("type : [%d] str : [%s]", token->type, token->str);
+                               *token_list = g_list_append(*token_list, token);
+                               tmp = tmp + strlen(token->str);
+                               idx = -1;
+                       }
+               }
+               else if(tmp[idx] == media_token[3][0])  //"("
+               {
+                       if(idx != 0)
+                       {
+                               token_t *token = (token_t*)calloc(1, sizeof(token_t));
+                               if(token == NULL)
+                               {
+                                       media_content_error("OUT_OF_MEMORY");
+                                       return -1;
+                               }
+                               ret = __tokenize_string(token, tmp, idx);
+                               if (ret < 0)
+                               {
+                                       SAFE_FREE(token);
+                                       media_content_error("tokenize error occued");
+                                       return -1;
+                               }
+                               else
+                               {
+                                       *token_list = g_list_append(*token_list, token);
+                                       tmp = tmp + idx;
+                               }
+                       }
+                       token_t *token = (token_t*)calloc(1, sizeof(token_t));
+                       int size = __tokenize_operator(token, tmp,3);
+
+                       if(token != NULL && STRING_VALID(token->str))
+                       {
+                               *token_list = g_list_append(*token_list, token);
+                               tmp += size;
+                               idx = -1;
+                       }
+                       else
+                       {
+                               SAFE_FREE(token);
+                               media_content_error("tokenize error occued");
+                               return -1;
+                       }
+
+               }
+               else if(tmp[idx] == media_token[4][0])  //")"
+               {
+                       if(idx != 0)
+                       {
+                               token_t *token = (token_t*)calloc(1, sizeof(token_t));
+                               if(token == NULL)
+                               {
+                                       media_content_error("OUT_OF_MEMORY");
+                                       return -1;
+                               }
+
+                               ret = __tokenize_string(token, tmp, idx);
+                               if (ret < 0)
+                               {
+                                       SAFE_FREE(token);
+                                       media_content_error("tokenize error occued");
+                                       return -1;
+                               }
+                               else
+                               {
+                                       *token_list = g_list_append(*token_list, token);
+                                       tmp = tmp + idx;
+                               }
+                       }
+                       token_t *token = (token_t*)calloc(1, sizeof(token_t));
+                       int size = __tokenize_operator(token, tmp,4);
+
+                       if(token != NULL && STRING_VALID(token->str))
+                       {
+                               *token_list = g_list_append(*token_list, token);
+                               tmp += size;
+                               idx = -1;
+                       }
+                       else
+                       {
+                               SAFE_FREE(token);
+                               media_content_error("tokenize error occued");
+                               return -1;
+                       }
+
+               }
+               else if(tmp[idx] == media_token[5][0])  //"="
+               {
+                       if(idx != 0)
+                       {
+                               token_t *token = (token_t*)calloc(1, sizeof(token_t));
+                               if(token == NULL)
+                               {
+                                       media_content_error("OUT_OF_MEMORY");
+                                       return -1;
+                               }
+
+                               ret = __tokenize_string(token, tmp, idx);
+                               if (ret < 0)
+                               {
+                                       SAFE_FREE(token);
+                                       media_content_error("tokenize error occued");
+                                       return -1;
+                               }
+                               else
+                               {
+                                       *token_list = g_list_append(*token_list, token);
+                                       tmp = tmp + idx;
+                               }
+                       }
+                       token_t *token = (token_t*)calloc(1, sizeof(token_t));
+                       int size = __tokenize_operator(token, tmp,5);
+
+                       if(token != NULL && STRING_VALID(token->str))
+                       {
+                               *token_list = g_list_append(*token_list, token);
+                               tmp += size;
+                               idx = -1;
+                       }
+                       else
+                       {
+                               SAFE_FREE(token);
+                               media_content_error("tokenize error occued");
+                               return -1;
+                       }
+
+               }
+               else if(tmp[idx] == media_token[6][0] && tmp[idx+1] == media_token[6][1])       //"<=",
+               {
+                       if(idx != 0)
+                       {
+                               token_t *token = (token_t*)calloc(1, sizeof(token_t));
+                               if(token == NULL)
+                               {
+                                       media_content_error("OUT_OF_MEMORY");
+                                       return -1;
+                               }
+
+                               ret = __tokenize_string(token, tmp, idx);
+                               if (ret < 0)
+                               {
+                                       SAFE_FREE(token);
+                                       media_content_error("tokenize error occued");
+                                       return -1;
+                               }
+                               else
+                               {
+                                       *token_list = g_list_append(*token_list, token);
+                                       tmp = tmp + idx;
+                               }
+                       }
+                       token_t *token = (token_t*)calloc(1, sizeof(token_t));
+                       int size = __tokenize_operator(token, tmp,6);
+
+                       if(token != NULL && STRING_VALID(token->str))
+                       {
+                               *token_list = g_list_append(*token_list, token);
+                               tmp += size;
+                               idx = -1;
+                       }
+                       else
+                       {
+                               SAFE_FREE(token);
+                               media_content_error("tokenize error occued");
+                               return -1;
+                       }
+
+               }
+               else if(tmp[idx] == media_token[7][0])  //"<",
+               {
+                       if(idx != 0)
+                       {
+                               token_t *token = (token_t*)calloc(1, sizeof(token_t));
+                               if(token == NULL)
+                               {
+                                       media_content_error("OUT_OF_MEMORY");
+                                       return -1;
+                               }
+
+                               ret = __tokenize_string(token, tmp, idx);
+                               if (ret < 0)
+                               {
+                                       SAFE_FREE(token);
+                                       media_content_error("tokenize error occued");
+                                       return -1;
+                               }
+                               else
+                               {
+                                       *token_list = g_list_append(*token_list, token);
+                                       tmp = tmp + idx;
+                               }
+                       }
+                       token_t *token = (token_t*)calloc(1, sizeof(token_t));
+                       int size = __tokenize_operator(token, tmp,7);
+
+                       if(token != NULL && STRING_VALID(token->str))
+                       {
+                               *token_list = g_list_append(*token_list, token);
+                               tmp += size;
+                               idx = -1;
+                       }
+                       else
+                       {
+                               SAFE_FREE(token);
+                               media_content_error("tokenize error occued");
+                               return -1;
+                       }
+
+               }
+               else if(tmp[idx] == media_token[8][0] && tmp[idx+1] == media_token[8][1])       //">=",
+               {
+                       if(idx != 0)
+                       {
+                               token_t *token = (token_t*)calloc(1, sizeof(token_t));
+                               if(token == NULL)
+                               {
+                                       media_content_error("OUT_OF_MEMORY");
+                                       return -1;
+                               }
+
+                               ret = __tokenize_string(token, tmp, idx);
+                               if (ret < 0)
+                               {
+                                       SAFE_FREE(token);
+                                       media_content_error("tokenize error occued");
+                                       return -1;
+                               }
+                               else
+                               {
+                                       *token_list = g_list_append(*token_list, token);
+                                       tmp = tmp + idx;
+                               }
+                       }
+                       token_t *token = (token_t*)calloc(1, sizeof(token_t));
+                       int size = __tokenize_operator(token, tmp,8);
+
+                       if(token != NULL && STRING_VALID(token->str))
+                       {
+                               *token_list = g_list_append(*token_list, token);
+                               tmp += size;
+                               idx = -1;
+                       }
+                       else
+                       {
+                               SAFE_FREE(token);
+                               media_content_error("tokenize error occued");
+                               return -1;
+                       }
+
+               }
+               else if(tmp[idx] == media_token[9][0])  //">",
+               {
+                       if(idx != 0)
+                       {
+                               token_t *token = (token_t*)calloc(1, sizeof(token_t));
+                               if(token == NULL)
+                               {
+                                       media_content_error("OUT_OF_MEMORY");
+                                       return -1;
+                               }
+
+                               ret = __tokenize_string(token, tmp, idx);
+                               if (ret < 0)
+                               {
+                                       SAFE_FREE(token);
+                                       media_content_error("tokenize error occued");
+                                       return -1;
+                               }
+                               else
+                               {
+                                       *token_list = g_list_append(*token_list, token);
+                                       tmp = tmp + idx;
+                               }
+                       }
+                       token_t *token = (token_t*)calloc(1, sizeof(token_t));
+                       int size = __tokenize_operator(token, tmp,9);
+
+                       if(token != NULL && STRING_VALID(token->str))
+                       {
+                               *token_list = g_list_append(*token_list, token);
+                               tmp += size;
+                               idx = -1;
+                       }
+                       else
+                       {
+                               SAFE_FREE(token);
+                               media_content_error("tokenize error occued");
+                               return -1;
+                       }
+
+               }
+       }
+
+       if(*tmp)                        //remained string
+       {
+               token_t *token = (token_t*)calloc(1, sizeof(token_t));
+               if(token == NULL)
+               {
+                       media_content_error("OUT_OF_MEMORY");
+                       return -1;
+               }
+
+               ret = __tokenize_string(token, tmp, idx);
+               if (ret < 0)
+               {
+                       SAFE_FREE(token);
+                       media_content_error("tokenize error occued");
+                       return -1;
+               }
+
+               if(token != NULL && STRING_VALID(token->str))
+               {
+                       *token_list = g_list_append(*token_list, token);
+               }
+               else
+               {
+                       SAFE_FREE(token);
+                       media_content_error("tokenize error occued");
+                       return -1;
+               }
+       }
+
+       return MEDIA_CONTENT_ERROR_NONE;
+}
+
+int _media_filter_attribute_create(attribute_h *attr)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       if(attr == NULL)
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       attribute_s *_attr = (attribute_s*)calloc(1, sizeof(attribute_s));
+
+       if(_attr == NULL)
+       {
+               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+               ret = MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+       }
+       else
+       {
+               _attr->attr_map = g_hash_table_new (g_str_hash, g_str_equal);
+               *attr = (attribute_h)_attr;
+       }
+
+       return ret;
+}
+
+int _media_filter_attribute_add(attribute_h attr, char *user_attr, char *platform_attr)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       char *_user = NULL;
+       char *_platform = NULL;
+       attribute_s *_attr = (attribute_s*)attr;
+
+       if(_attr != NULL)
+       {
+               if(STRING_VALID(user_attr) && STRING_VALID(platform_attr))
+               {
+                       _user = strdup(user_attr);
+                       if(_user == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+
+                       _platform = strdup(platform_attr);
+                       if(_platform == NULL)
+                       {
+                               SAFE_FREE(_user);
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+
+                       g_hash_table_insert (_attr->attr_map, _user, _platform);
+               }
+               else
+               {
+                       media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+                       return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+               }
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int _media_filter_attribute_destory(attribute_h attr)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       attribute_s *_attr = (attribute_s*)attr;
+
+       if(_attr != NULL)
+       {
+               if(_attr->attr_map != NULL)
+               {
+                       g_hash_table_foreach(_attr->attr_map, __filter_attribute_free_value, NULL);
+                       g_hash_table_destroy(_attr->attr_map);
+               }
+
+               SAFE_FREE(_attr);
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int _media_filter_attribute_generate(attribute_h attr, char *condition, media_content_collation_e collate_type, char **generated_condition)
+{
+       int idx = 0;
+       GList *token_list = NULL;
+       int size = 0;
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       int total_str_size = 0;
+       token_t *token;
+
+       if((condition == NULL) || (generated_condition == NULL))
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x):Invalid the condition", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       if(attr != NULL)
+       {
+               if(__tokenize(&token_list, condition) < 0)
+               {
+                       media_content_error("INVALID_PARAMETER(0x%08x):Invalid the condition", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+                       return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+               }
+
+               for(idx = 0; idx < g_list_length(token_list); idx++)
+               {
+                       token = (token_t*)g_list_nth_data(token_list, idx);
+
+                       if(token->type == UNKNOWN_TYPE)
+                       {
+                               char *replace_str = __media_filter_replace_attr(attr, token->str);
+                               if(STRING_VALID(replace_str))
+                               {
+                                       SAFE_FREE(token->str);
+                                       token->str = replace_str;
+                               }
+                       }
+
+                       total_str_size += strlen(token->str)+1;
+                       //media_content_debug("[%d][type:%d]:%s", idx, token->type, token->str);
+               }
+
+               //make the statment
+               size = total_str_size + COLLATE_STR_SIZE + 1;
+               * generated_condition = (char*)calloc(size, sizeof(char));
+
+               for(idx = 0; idx < g_list_length(token_list); idx++)
+               {
+                       token = (token_t*)g_list_nth_data(token_list, idx);
+
+                       if((token != NULL) && STRING_VALID(token->str))
+                       {
+                               SAFE_STRLCAT(*generated_condition, token->str, size);
+                               SAFE_STRLCAT(*generated_condition, SPACE, size);
+
+                               SAFE_FREE(token->str);
+                               SAFE_FREE(token);
+                       }
+               }
+
+               if(collate_type == MEDIA_CONTENT_COLLATE_NOCASE || collate_type == MEDIA_CONTENT_COLLATE_RTRIM) {
+                       SAFE_STRLCAT(*generated_condition, "COLLATE ", size);
+                       SAFE_STRLCAT(*generated_condition, __get_collate_str(collate_type), size);
+                       SAFE_STRLCAT(*generated_condition, SPACE, size);
+               }
+
+               media_content_debug("statement : %s(%d) (total:%d)", *generated_condition, strlen(*generated_condition), total_str_size);
+               media_content_debug("Condition : %s", *generated_condition);
+
+               //if(*generated_condition != NULL)
+               //      res = 1;
+
+               if(token_list != NULL)
+                       g_list_free(token_list);
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int _media_filter_attribute_option_generate(attribute_h attr, filter_h filter, char **generated_option)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       filter_s *_filter = NULL;
+       char option_query[DEFAULT_QUERY_SIZE] = {0, };
+       char condition[DEFAULT_QUERY_SIZE] = {0, };
+       int size = 0;
+       //bool order_by = true;
+
+       media_content_debug_func();
+
+       if(filter == NULL)
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       if(attr == NULL)
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       _filter = (filter_s*)filter;
+
+       memset(option_query, 0x00, sizeof(option_query));
+
+       /* Order by*/
+       if(STRING_VALID(_filter->order_keyword) && ((_filter->order_type == MEDIA_CONTENT_ORDER_ASC) ||(_filter->order_type == MEDIA_CONTENT_ORDER_DESC)))
+       {
+               int idx = 0;
+               int total_str_size = 0;
+               GList *token_list = NULL;
+               token_t *token;
+               char *attr_str;
+
+               media_content_debug("Tokenize for [%s]", _filter->order_keyword);
+               if(__tokenize_attribute(&token_list, _filter->order_keyword) < 0)
+               {
+                       media_content_error("INVALID_PARAMETER(0x%08x):Invalid the condition", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+                       return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+               }
+
+               for(idx = 0; idx < g_list_length(token_list); idx++)
+               {
+                       token = (token_t*)g_list_nth_data(token_list, idx);
+
+                       if(token->type == UNKNOWN_TYPE)
+                       {
+                               char *replace_str = __media_filter_replace_attr(attr, token->str);
+                               if(STRING_VALID(replace_str))
+                               {
+                                       attr_str = (char*)calloc(strlen(replace_str) + COLLATE_STR_SIZE + 1, sizeof(char));
+
+                                       if(_filter->order_collate_type == MEDIA_CONTENT_COLLATE_NOCASE || _filter->order_collate_type == MEDIA_CONTENT_COLLATE_RTRIM) {
+                                               snprintf(attr_str, strlen(replace_str) + COLLATE_STR_SIZE + 1, "%s COLLATE %s %s", replace_str, __get_collate_str(_filter->order_collate_type), __get_order_str(_filter->order_type));
+                                       } else {
+                                               snprintf(attr_str, strlen(replace_str) + COLLATE_STR_SIZE + 1, "%s %s", replace_str, __get_order_str(_filter->order_type));
+                                       }
+
+                                       SAFE_FREE(token->str);
+                                       token->str = attr_str;
+                                       SAFE_FREE(replace_str);
+                               }
+                               else
+                               {
+                                       media_content_error("There is no matched db field for %s", token->str);
+                               }
+                       }
+
+                       total_str_size += strlen(token->str) + 1;
+                       media_content_debug("[%d][type:%d]:%s", idx, token->type, token->str);
+               }
+
+               //make the statment
+               char *generated_condition = NULL;
+               size = total_str_size + COLLATE_STR_SIZE + 1;
+               generated_condition = (char*)calloc(size, sizeof(char));
+
+               for(idx = 0; idx < g_list_length(token_list); idx++)
+               {
+                       token = (token_t*)g_list_nth_data(token_list, idx);
+
+                       if((token != NULL) && STRING_VALID(token->str))
+                       {
+                               media_content_debug("[%d] %s", idx, token->str);
+                               SAFE_STRLCAT(generated_condition, token->str, size);
+                               SAFE_STRLCAT(generated_condition, SPACE, size);
+
+                               SAFE_FREE(token->str);
+                               SAFE_FREE(token);
+                       }
+               }
+
+               snprintf(condition, sizeof(condition), "ORDER BY %s", generated_condition);
+               SAFE_STRLCAT(option_query, condition, sizeof(option_query));
+
+               if(token_list != NULL)
+                       g_list_free(token_list);
+
+               SAFE_FREE(generated_condition);
+       }
+
+       /* offset */
+       SAFE_STRLCAT(option_query, SPACE, sizeof(option_query));
+       snprintf(condition, sizeof(condition), "LIMIT %d, %d", _filter->offset, _filter->count);
+       SAFE_STRLCAT(option_query, condition, sizeof(option_query));
+
+       if(STRING_VALID(option_query))
+       {
+               *generated_option = strdup(option_query);
+       }
+       else
+       {
+               *generated_option = NULL;
+       }
+
+       return ret;
+}
+
+int media_filter_create(filter_h *filter)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       if(filter == NULL)
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       filter_s *_filter = (filter_s*)calloc(1, sizeof(filter_s));
+
+       if(_filter == NULL)
+       {
+               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+               ret = MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+       }
+       else
+       {
+               _filter->condition = NULL;
+               _filter->order_keyword = NULL;
+               _filter->order_type = -1;
+               _filter->condition_collate_type = MEDIA_CONTENT_COLLATE_DEFAULT;
+               _filter->order_collate_type = MEDIA_CONTENT_COLLATE_DEFAULT;
+               _filter->offset = -1;
+               _filter->count = -1;
+
+               *filter = (filter_h)_filter;
+       }
+
+       return ret;
+}
+
+int media_filter_destroy(filter_h filter)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       filter_s *_filter = (filter_s*)filter;
+
+       if(_filter)
+       {
+               SAFE_FREE(_filter->condition);
+               SAFE_FREE(_filter->order_keyword);
+               SAFE_FREE(_filter);
+
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_filter_set_offset(filter_h filter, int offset, int count)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       filter_s *_filter = (filter_s*)filter;
+
+       if(_filter != NULL)
+       {
+               _filter->offset = offset;
+               _filter->count = count;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_filter_set_condition(filter_h filter, const char *condition, media_content_collation_e collate_type)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       filter_s *_filter = (filter_s*)filter;
+
+       if((_filter != NULL) && STRING_VALID(condition)
+               && ((collate_type >= MEDIA_CONTENT_COLLATE_DEFAULT) && (collate_type <= MEDIA_CONTENT_COLLATE_RTRIM)))
+       {
+               if(STRING_VALID(_filter->condition))
+               {
+                       SAFE_FREE(_filter->condition);
+               }
+
+               _filter->condition = strdup(condition);
+               if(_filter->condition == NULL)
+               {
+                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+               }
+
+               media_content_debug("Condition string : %s", _filter->condition);
+
+               _filter->condition_collate_type = collate_type;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_filter_set_order(filter_h filter, media_content_order_e order_type, const char *order_keyword, media_content_collation_e collate_type)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       filter_s *_filter = (filter_s*)filter;
+
+       if((_filter != NULL) && STRING_VALID(order_keyword)
+               && ((order_type == MEDIA_CONTENT_ORDER_ASC) ||(order_type == MEDIA_CONTENT_ORDER_DESC))
+               && ((collate_type >= MEDIA_CONTENT_COLLATE_DEFAULT) && (collate_type <= MEDIA_CONTENT_COLLATE_RTRIM)))
+       {
+               SAFE_FREE(_filter->order_keyword);
+
+               if(STRING_VALID(order_keyword))
+               {
+                       _filter->order_keyword = strdup(order_keyword);
+
+                       if(_filter->order_keyword == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+                       _filter->order_type = order_type;
+                       _filter->order_collate_type = collate_type;
+               }
+               else
+               {
+                       media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+                       ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+               }
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_filter_get_offset(filter_h filter, int *offset, int *count)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       filter_s *_filter = (filter_s*)filter;
+
+       if(_filter)
+       {
+               *offset = _filter->offset;
+               *count = _filter->count;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_filter_get_condition(filter_h filter, char **condition, media_content_collation_e *collate_type)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       filter_s *_filter = (filter_s*)filter;
+
+       if(_filter)
+       {
+               if(STRING_VALID(_filter->condition))
+               {
+                       *condition = strdup(_filter->condition);
+                       if(*condition == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       *condition = NULL;
+               }
+
+               *collate_type = _filter->condition_collate_type;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_filter_get_order(filter_h filter, media_content_order_e* order_type, char **order_keyword, media_content_collation_e *collate_type)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       filter_s *_filter = (filter_s*)filter;
+
+       if(_filter)
+       {
+               if(STRING_VALID(_filter->order_keyword))
+               {
+                       *order_keyword = strdup(_filter->order_keyword);
+                       if(*order_keyword == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       *order_keyword = NULL;
+               }
+
+               *order_type = _filter->order_type;
+               *collate_type = _filter->order_collate_type;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
diff --git a/src/media_folder.c b/src/media_folder.c
new file mode 100755 (executable)
index 0000000..8de45eb
--- /dev/null
@@ -0,0 +1,467 @@
+ /*
+ * 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_content.h>
+#include <media_info_private.h>
+#include <media_util_private.h>
+
+static char *g_src_path = NULL;
+
+static char *__media_folder_get_update_folder_sql(media_folder_h folder);
+
+static char *__media_folder_get_update_folder_sql(media_folder_h folder)
+{
+       media_folder_s *_folder = (media_folder_s*)folder;
+       char *return_sql = NULL;
+
+       return_sql = sqlite3_mprintf("%q='%q', %q='%q', %q=%d ",
+                                                                                       DB_FIELD_FOLDER_PATH, _folder->path,
+                                                                                       DB_FIELD_FOLDER_NAME, _folder->name,
+                                                                                       DB_FIELD_FOLDER_MODIFIED_TIME, _folder->modified_time);
+
+       return return_sql;
+}
+
+int media_folder_get_folder_count_from_db(filter_h filter, int *folder_count)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       media_content_debug_func();
+
+       if(!folder_count)
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _media_db_get_group_count(filter, MEDIA_GROUP_FOLDER, folder_count);
+
+       return ret;
+}
+
+int media_folder_foreach_folder_from_db(filter_h filter, media_folder_cb callback, void *user_data)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       media_content_debug_func();
+
+       if(callback == NULL)
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _media_db_get_folder(filter, callback, user_data);
+
+       return ret;
+}
+
+int media_folder_get_media_count_from_db(const char *folder_id, filter_h filter, int *media_count)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       media_content_debug_func();
+
+       if(STRING_VALID(folder_id) && media_count)
+       {
+               ret = _media_db_get_group_item_count(folder_id, filter, MEDIA_GROUP_FOLDER, media_count);
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_folder_foreach_media_from_db(const char *folder_id, filter_h filter, media_info_cb callback, void *user_data)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       media_content_debug_func();
+
+       if((callback != NULL) && STRING_VALID(folder_id))
+       {
+               ret = _media_db_get_group_item(folder_id, filter, callback, user_data, MEDIA_GROUP_FOLDER);
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_folder_destroy(media_folder_h folder)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_folder_s *_folder = (media_folder_s*)folder;
+       if(_folder)
+       {
+               SAFE_FREE(_folder->path);
+               SAFE_FREE(_folder->name);
+               SAFE_FREE(_folder->folder_id);
+               SAFE_FREE(_folder);
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+int media_folder_clone(media_folder_h *dst, media_folder_h src)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_folder_s *_src = (media_folder_s*)src;
+
+       if(_src != NULL)
+       {
+               media_folder_s *_dst = (media_folder_s*)calloc(1, sizeof(media_folder_s));
+               if(_dst == NULL)
+               {
+                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+               }
+
+               if(STRING_VALID(_src->folder_id))
+               {
+                       _dst->folder_id = strdup(_src->folder_id);
+                       if(_dst->folder_id == NULL)
+                       {
+                               SAFE_FREE(_dst);
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+
+               _dst->storage_type = _src->storage_type;
+
+               if(STRING_VALID(_src->name))
+               {
+                       _dst->name = strdup(_src->name);
+                       if(_dst->name == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               media_folder_destroy((media_folder_h)_dst);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+
+               if(STRING_VALID(_src->path))
+               {
+                       _dst->path = strdup(_src->path);
+                       if(_dst->path == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               media_folder_destroy((media_folder_h)_dst);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+
+               *dst = (media_folder_h)_dst;
+
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_folder_get_folder_id(media_folder_h folder, char **folder_id)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_folder_s *_folder = (media_folder_s*)folder;
+
+       if(_folder)
+       {
+               if(STRING_VALID(_folder->folder_id))
+               {
+                       *folder_id = strdup(_folder->folder_id);
+                       if(*folder_id == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       *folder_id = NULL;
+               }
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_folder_get_path(media_folder_h folder, char **path)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_folder_s *_folder = (media_folder_s*)folder;
+       if(_folder)
+       {
+               if(STRING_VALID(_folder->path))
+               {
+                       *path = strdup(_folder->path);
+                       if(*path == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       *path = NULL;
+               }
+               ret = MEDIA_CONTENT_ERROR_NONE;
+
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+
+}
+
+int media_folder_get_name(media_folder_h folder, char **name)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_folder_s *_folder = (media_folder_s*)folder;
+       if(_folder)
+       {
+               if(STRING_VALID(_folder->name))
+               {
+                       *name = strdup(_folder->name);
+                       if(*name == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       *name = NULL;
+               }
+               ret = MEDIA_CONTENT_ERROR_NONE;
+
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_folder_get_modified_time(media_folder_h folder, time_t* time)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_folder_s *_folder = (media_folder_s*)folder;
+       if(_folder)
+       {
+               *time = _folder->modified_time;
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_folder_get_storage_type(media_folder_h folder, media_content_storage_e* storage_type)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_folder_s *_folder = (media_folder_s*)folder;
+       if(_folder)
+       {
+               *storage_type = _folder->storage_type;
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_folder_get_folder_from_db(const char *folder_id, media_folder_h *folder)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       sqlite3_stmt *stmt = NULL;
+       char select_query[DEFAULT_QUERY_SIZE];
+
+       if(!STRING_VALID(folder_id))
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       memset(select_query, 0x00, sizeof(select_query));
+
+       snprintf(select_query, sizeof(select_query), SELECT_FOLDER_FROM_FOLDER, folder_id);
+
+       ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       while(sqlite3_step(stmt) == SQLITE_ROW)
+       {
+               media_folder_s *_folder = (media_folder_s*)calloc(1, sizeof(media_folder_s));
+
+               if(_folder == NULL)
+               {
+                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                       SQLITE3_FINALIZE(stmt);
+                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+               }
+
+               if(STRING_VALID((const char *)sqlite3_column_text(stmt, 0)))
+                       _folder->folder_id = strdup((const char *)sqlite3_column_text(stmt, 0));
+
+               if(STRING_VALID((const char *)sqlite3_column_text(stmt, 1)))
+                       _folder->path = strdup((const char *)sqlite3_column_text(stmt, 1));
+
+               if(STRING_VALID((const char *)sqlite3_column_text(stmt, 2)))
+                       _folder->name = strdup((const char *)sqlite3_column_text(stmt, 2));
+
+               *folder = (media_folder_h)_folder;
+       }
+
+       SQLITE3_FINALIZE(stmt);
+
+       return ret;
+}
+
+int media_folder_update_to_db(media_folder_h folder)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       int len = 0;
+       media_folder_s *_folder = (media_folder_s*)folder;
+
+       char sql[MAX_QUERY_SIZE];
+       memset(sql, '\0', sizeof(sql));
+       char *set_sql = NULL;
+       char *where_sql = NULL;
+
+       if((_folder != NULL) && STRING_VALID(_folder->folder_id) && g_src_path)
+       {
+               /* Set modified time */
+               time_t date;
+               time(&date);
+               _folder->modified_time = date;
+
+               set_sql = __media_folder_get_update_folder_sql((media_folder_h)_folder);
+               if(set_sql == NULL)
+               {
+                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+               }
+
+               where_sql = sqlite3_mprintf("folder_uuid='%q'", _folder->folder_id);
+
+               len = snprintf(sql, sizeof(sql), UPDATE_SQL, DB_TABLE_FOLDER, set_sql, where_sql);
+               if (len > 0) {
+                       sql[len] = '\0';
+               } else {
+                       media_content_error("snprintf failed");
+                       return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+               }
+
+               ret = _content_query_sql(sql);
+
+               sqlite3_free(set_sql);
+               sqlite3_free(where_sql);
+
+               /* Do folder rename operation using libmedia-service */
+               ret = media_svc_rename_folder(_content_get_db_handle(), g_src_path, _folder->path);
+               return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_folder_set_name(media_folder_h folder, const char *name)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_folder_s *_folder = (media_folder_s*)folder;
+
+       if(_folder != NULL && STRING_VALID(name))
+       {
+               if (STRING_VALID(_folder->path) && STRING_VALID(_folder->name)) {
+                       char *folder_path = NULL;
+                       char new_folder_path[MAX_QUERY_SIZE] = {0,};
+
+                       folder_path = g_path_get_dirname(_folder->path);
+                       media_content_debug("Existed Folder Path : %s", _folder->path);
+                       snprintf(new_folder_path, sizeof(new_folder_path), "%s/%s", folder_path, name); 
+                       media_content_debug("New Path : %s", new_folder_path);
+
+                       SAFE_FREE(g_src_path);
+                       g_src_path = strdup(_folder->path);
+
+                       SAFE_FREE(_folder->path);
+                       SAFE_FREE(_folder->name);
+                       _folder->path = strdup(new_folder_path);
+
+                       if(_folder->path == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+
+               _folder->name = strdup(name);
+               if(_folder->name == NULL)
+               {
+                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+               }
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
diff --git a/src/media_group.c b/src/media_group.c
new file mode 100755 (executable)
index 0000000..3312fbf
--- /dev/null
@@ -0,0 +1,418 @@
+/*
+* 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_filter.h>
+#include <media_info.h>
+#include <media_info_private.h>
+#include <media_group.h>
+
+
+int media_album_get_album_count_from_db(filter_h filter, int *album_count)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       media_content_debug_func();
+
+       if(album_count != NULL)
+       {
+               ret = _media_db_get_group_count(filter, MEDIA_GROUP_ALBUM, album_count);
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_album_foreach_album_from_db(filter_h filter, media_album_cb callback, void *user_data)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       media_content_debug_func();
+
+       if(callback == NULL)
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _media_db_get_album(filter, callback, user_data);
+
+       return ret;
+}
+
+int media_album_get_media_count_from_db(int album_id, filter_h filter, int *media_count)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       media_content_debug_func();
+
+       if((album_id > 0) && (media_count != NULL))
+       {
+               ret = _media_db_get_group_item_count_by_id(album_id, filter, MEDIA_GROUP_ALBUM, media_count);
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_album_foreach_media_from_db(int album_id, filter_h filter, media_info_cb callback, void *user_data)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       media_content_debug_func();
+
+       if((album_id > 0) && (callback != NULL))
+       {
+               ret = _media_db_get_group_item_by_id(album_id, filter, callback, user_data, MEDIA_GROUP_ALBUM);
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_album_get_album_from_db(int album_id, media_album_h *album)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       sqlite3_stmt *stmt = NULL;
+       char select_query[DEFAULT_QUERY_SIZE];
+
+       media_content_debug_func();
+
+       if(album_id < 0)
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       memset(select_query, 0x00, sizeof(select_query));
+
+       snprintf(select_query, sizeof(select_query), SELECT_ALBUM_FROM_ALBUM, album_id);
+
+       ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       while(sqlite3_step(stmt) == SQLITE_ROW)
+       {
+               media_album_s *_album = (media_album_s*)calloc(1, sizeof(media_album_s));
+
+               _album->album_id = (int)sqlite3_column_int(stmt, 0);
+
+               if(STRING_VALID((const char *)sqlite3_column_text(stmt, 1)))
+                       _album->name = strdup((const char *)sqlite3_column_text(stmt, 1));
+
+               if(STRING_VALID((const char *)sqlite3_column_text(stmt, 2)))
+                       _album->artist = strdup((const char *)sqlite3_column_text(stmt, 2));
+
+               *album = (media_album_h)_album;
+       }
+
+       if(stmt != NULL)
+       {
+               sqlite3_finalize(stmt);
+       }
+
+       return ret;
+}
+
+int media_album_destroy(media_album_h album)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_album_s *_album = (media_album_s*)album;
+
+       media_content_debug_func();
+
+       if(_album)
+       {
+               SAFE_FREE(_album->name);
+               SAFE_FREE(_album->artist);
+               SAFE_FREE(_album->album_art_path);
+               SAFE_FREE(_album);
+
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_album_clone(media_album_h *dst, media_album_h src)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_album_s *_src = (media_album_s*)src;
+
+       if(_src != NULL)
+       {
+               media_album_s *_dst = (media_album_s*)calloc(1, sizeof(media_album_s));
+
+               if(_dst == NULL)
+               {
+                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+               }
+
+               _dst->album_id = _src->album_id;
+
+               if(STRING_VALID(_src->name))
+               {
+                       _dst->name = strdup(_src->name);
+                       if(_dst->name == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               media_album_destroy((media_album_h)_dst);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+
+               if(STRING_VALID(_src->artist))
+               {
+                       _dst->artist = strdup(_src->artist);
+                       if(_dst->artist == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               media_album_destroy((media_album_h)_dst);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+
+               if(STRING_VALID(_src->album_art_path))
+               {
+                       _dst->album_art_path = strdup(_src->album_art_path);
+                       if(_dst->album_art_path == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               media_album_destroy((media_album_h)_dst);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+
+               *dst = (media_album_h)_dst;
+
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_album_get_album_id(media_album_h album, int *album_id)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_album_s *_album = (media_album_s*)album;
+
+       if(_album && album_id)
+       {
+               *album_id = _album->album_id;
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_album_get_name(media_album_h album, char **name)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_album_s *_album = (media_album_s*)album;
+
+       if(_album)
+       {
+               if(STRING_VALID(_album->name))
+               {
+                       *name = strdup(_album->name);
+                       if(*name == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       *name = NULL;
+               }
+
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_album_get_artist(media_album_h album, char **artist)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_album_s *_album = (media_album_s*)album;
+
+       if(_album)
+       {
+               if(STRING_VALID(_album->artist))
+               {
+                       *artist = strdup(_album->artist);
+                       if(*artist == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       *artist = NULL;
+               }
+
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_album_get_album_art(media_album_h album, char **album_art)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_album_s *_album = (media_album_s*)album;
+
+       if(_album)
+       {
+               if(STRING_VALID(_album->album_art_path))
+               {
+                       *album_art = strdup(_album->album_art_path);
+                       if(*album_art == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       *album_art = NULL;
+               }
+
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_group_get_group_count_from_db(filter_h filter, media_group_e group, int *group_count)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       media_content_debug_func();
+
+       if((group < MEDIA_CONTENT_GROUP_DISPLAY_NAME) || (group > MEDIA_CONTENT_GROUP_KEYWORD) || (group_count == NULL))
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+       else
+       {
+               ret = _media_db_get_media_group_count(group, filter, group_count);
+       }
+
+       return ret;
+}
+
+int media_group_foreach_group_from_db(filter_h filter, media_group_e group, media_group_cb callback, void *user_data)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       media_content_debug_func();
+
+       if((callback == NULL) || (group < MEDIA_CONTENT_GROUP_DISPLAY_NAME) || (group > MEDIA_CONTENT_GROUP_KEYWORD))
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+       else
+       {
+               ret = _media_db_get_media_group(group, filter, callback, user_data);
+       }
+
+       return ret;
+}
+
+int media_group_get_media_count_from_db(const char *group_name, media_group_e group, filter_h filter, int *media_count)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       media_content_debug_func();
+
+       if((media_count == NULL) || (group < MEDIA_CONTENT_GROUP_DISPLAY_NAME) || (group > MEDIA_CONTENT_GROUP_KEYWORD))
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+       else
+       {
+               ret = _media_db_get_media_group_item_count(group_name, group, filter, media_count);
+       }
+
+       return ret;
+}
+
+int media_group_foreach_media_from_db(const char *group_name, media_group_e group, filter_h filter, media_info_cb callback, void *user_data)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       media_content_debug_func();
+
+       if((callback == NULL) || (group < MEDIA_CONTENT_GROUP_DISPLAY_NAME) || (group > MEDIA_CONTENT_GROUP_KEYWORD))
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+       else
+       {
+               ret = _media_db_get_media_group_item(group_name, group, filter, callback, user_data);
+       }
+
+       return ret;
+}
diff --git a/src/media_image.c b/src/media_image.c
new file mode 100755 (executable)
index 0000000..c317654
--- /dev/null
@@ -0,0 +1,268 @@
+/*
+* 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_image.h>
+#include <media_content.h>
+#include <media_info_private.h>
+#include <media-svc.h>
+
+
+int image_meta_destroy(image_meta_h image)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       image_meta_s *_image = (image_meta_s*)image;
+
+       media_content_debug_func();
+
+       if(_image)
+       {
+               SAFE_FREE(_image->media_id);
+               SAFE_FREE(_image->date_taken);
+               SAFE_FREE(_image);
+
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int image_meta_clone(image_meta_h *dst, image_meta_h src)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       image_meta_s *_src = (image_meta_s*)src;
+
+       media_content_debug_func();
+
+       if(_src != NULL)
+       {
+               image_meta_s *_dst = (image_meta_s*)calloc(1, sizeof(image_meta_s));
+               if(NULL == _dst)
+               {
+                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+               }
+
+               if(STRING_VALID(_src->media_id))
+               {
+                       _dst->media_id = strdup(_src->media_id);
+                       if(_dst->media_id == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               image_meta_destroy((image_meta_h)_dst);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+                       _dst->media_id = strdup(_src->media_id);
+               }
+
+               if(STRING_VALID(_src->date_taken))
+               {
+                       _dst->date_taken = strdup(_src->date_taken);
+                       if(_dst->date_taken == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               image_meta_destroy((image_meta_h)_dst);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+                       _dst->date_taken = strdup(_src->date_taken);
+               }
+
+               _dst->width = _src->width;
+               _dst->height = _src->height;
+               _dst->orientation = _src->orientation;
+
+               *dst = (image_meta_h)_dst;
+
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int image_meta_get_media_id(image_meta_h image, char **media_id)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       image_meta_s *_image = (image_meta_s*)image;
+
+       if(_image)
+       {
+               if(STRING_VALID(_image->media_id))
+               {
+                       char *new_string = strdup(_image->media_id);
+                       if(NULL == new_string)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+                       *media_id = new_string;
+               }
+               else
+               {
+                       *media_id = NULL;
+               }
+               ret = MEDIA_CONTENT_ERROR_NONE;
+
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+
+}
+
+int image_meta_get_width(image_meta_h image, int *width)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       image_meta_s *_image = (image_meta_s*)image;
+
+       if(_image && width)
+       {
+               *width = _image->width;
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+int image_meta_get_height(image_meta_h image, int *height)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       image_meta_s *_image = (image_meta_s*)image;
+
+       if(_image && height)
+       {
+               *height = _image->height;
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int image_meta_get_orientation(image_meta_h image, media_content_orientation_e* orientation)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       image_meta_s *_image = (image_meta_s*)image;
+       if(_image)
+       {
+               *orientation = _image->orientation;
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int image_meta_get_date_taken(image_meta_h image, char **date_taken)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       image_meta_s *_image = (image_meta_s*)image;
+
+       if(_image)
+       {
+               if(STRING_VALID(_image->date_taken))
+               {
+                       char *new_string = strdup(_image->date_taken);
+                       if(NULL == new_string)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+                       *date_taken = new_string;
+               }
+               else
+               {
+                       *date_taken = NULL;
+               }
+
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int image_meta_set_orientation(image_meta_h image, media_content_orientation_e orientation)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       image_meta_s *_image = (image_meta_s*)image;
+
+       if(_image == NULL)
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       if((orientation < MEDIA_CONTENT_ORIENTATION_NOT_AVAILABLE) || (orientation > MEDIA_CONTENT_ORIENTATION_ROT_270))
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       _image->orientation = orientation;
+
+       return ret;
+}
+
+int image_meta_update_to_db(image_meta_h image)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       image_meta_s *_image = (image_meta_s*)image;
+       char *sql = NULL;
+
+       if(_image != NULL && STRING_VALID(_image->media_id))
+       {
+               sql = sqlite3_mprintf(UPDATE_IMAGE_META_FROM_MEDIA, _image->orientation, _image->media_id);
+               ret = _content_query_sql(sql);
+               sqlite3_free(sql);
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
\ No newline at end of file
diff --git a/src/media_info.c b/src/media_info.c
new file mode 100755 (executable)
index 0000000..2e24b11
--- /dev/null
@@ -0,0 +1,2600 @@
+/*
+* 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 <unistd.h>
+#include <media_content.h>
+#include <media-thumbnail.h>
+#include <media_info_private.h>
+#include <media_util_private.h>
+#include <media-svc.h>
+#include <media-util.h>
+
+static int __media_info_get_media_info_from_db(char *path, media_info_h media);
+static void __media_info_insert_completed_cb(media_request_result_s *result, void *user_data);
+static void __media_info_thumbnail_completed_cb(int error, const char *path, void *user_data);
+static bool __media_info_delete_batch_cb(media_info_h media, void *user_data);
+
+static int __media_info_get_media_info_from_db(char *path, media_info_h media)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       sqlite3_stmt *stmt = NULL;
+       char *select_query = NULL;
+       media_info_s *_media = (media_info_s*)media;
+
+       if(_media == NULL)
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       select_query = sqlite3_mprintf(SELECT_MEDIA_BY_PATH, path);
+
+       ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
+       sqlite3_free(select_query);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       if(sqlite3_step(stmt) == SQLITE_ROW)
+       {
+               _media_info_item_get_detail(stmt, (media_info_h)_media);
+               media_content_debug("New Media ID: %s", _media->media_id);
+       } else {
+               media_content_debug("There's no media!!");
+       }
+/*
+       while(sqlite3_step(stmt) == SQLITE_ROW)
+       {
+               _media_info_item_get_detail(stmt, (media_info_h)_media);
+               media_content_debug("New Media ID: %s", _media->media_id);
+       }
+*/
+       SQLITE3_FINALIZE(stmt);
+
+       return ret;
+}
+
+static void __media_info_insert_completed_cb(media_request_result_s *result, void *user_data)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_insert_cb_s *_cb_data = (media_insert_cb_s *)user_data;
+
+       if (_cb_data && _cb_data->insert_completed_cb) {
+               if (result) {
+                       ret = _content_error_capi(MEDIA_CONTENT_TYPE, result->result);
+               }
+
+               _cb_data->insert_completed_cb(ret, _cb_data->user_data);
+
+               if (STRING_VALID(_cb_data->insert_list_path)) {
+                       if (unlink(_cb_data->insert_list_path) < 0) {
+                               media_content_error("failed to delete : %s", strerror(errno));
+                       }
+                       SAFE_FREE(_cb_data->insert_list_path);
+               }
+       }
+
+       SAFE_FREE(_cb_data);
+
+       return;
+}
+
+static void __media_info_thumbnail_completed_cb(int error, const char *path, void *user_data)
+{
+       int error_value = MEDIA_CONTENT_ERROR_NONE;
+
+       media_thumbnail_cb_s *_thumb_cb = (media_thumbnail_cb_s *)user_data;
+       media_info_s *media = NULL;
+
+       if(_thumb_cb != NULL)
+       {
+               media = _thumb_cb->handle;
+               if((media != NULL) && STRING_VALID(path))
+               {
+                       SAFE_FREE(media->thumbnail_path);
+                       media->thumbnail_path = strdup(path);
+               }
+
+               media_content_debug("error [%d], thumbnail_path [%s]", error, path);
+               error_value = _content_error_capi(MEDIA_THUMBNAIL_TYPE, error);
+               if (_thumb_cb->thumbnail_completed_cb)
+                       _thumb_cb->thumbnail_completed_cb(error_value, path, _thumb_cb->user_data);
+       }
+
+       SAFE_FREE(_thumb_cb);
+
+       return;
+}
+
+static bool __media_info_delete_batch_cb(media_info_h media, void *user_data)
+{
+       char *thumb_path = NULL;
+       media_content_type_e media_type = 0;
+
+       if(media == NULL)
+       {
+               media_content_debug("NO Item \n");
+               return true;
+       }
+
+       media_info_get_media_type(media, &media_type);
+       media_content_debug("media_type : [%d] \n", media_type);
+
+       media_info_get_thumbnail_path(media, &thumb_path);
+       if (STRING_VALID(thumb_path)) {
+               if (strncmp(MEDIA_CONTENT_THUMB_DEFAULT_PATH, thumb_path, strlen(MEDIA_CONTENT_THUMB_DEFAULT_PATH)) != 0) {
+                       media_content_debug("Deleting thumbnail : [%s] \n", thumb_path);
+                       if (unlink(thumb_path) < 0) {
+                               media_content_error("failed to delete : %s", strerror(errno));
+                       }
+               }
+
+               SAFE_FREE(thumb_path);
+       }
+
+       return true;
+}
+
+void _media_info_item_get_detail(sqlite3_stmt* stmt, media_info_h media)
+{
+//#define MEDIA_INFO_ITEM "media_uuid, path, file_name, media_type, mime_type, size, added_time, modified_time, thumbnail_path, description,
+//                                                     rating, favourite, author, provider, content_name, category, location_tag, age_rating, keyword, is_drm, storage_type, longitude, latitude, altitude, width, height, datetaken, orientation, title, album, artist, genre, composer, year, recorded_date, copyright, track_num, bitrate, duration, played_count, last_played_time, last_played_position, samplerate, channel"
+
+       media_info_s *_media = (media_info_s*)media;
+
+       if(STRING_VALID((const char *)sqlite3_column_text(stmt, 0)))
+               _media->media_id = strdup((const char *)sqlite3_column_text(stmt, 0));
+
+       if(STRING_VALID((const char *)sqlite3_column_text(stmt, 1)))
+               _media->file_path = strdup((const char *)sqlite3_column_text(stmt, 1));
+
+       if(STRING_VALID((const char *)sqlite3_column_text(stmt, 2)))
+               _media->display_name = strdup((const char *)sqlite3_column_text(stmt, 2));
+
+       _media->media_type = (int)sqlite3_column_int(stmt, 3);
+
+       if(STRING_VALID((const char *)sqlite3_column_text(stmt, 4)))
+               _media->mime_type = strdup((const char *)sqlite3_column_text(stmt, 4));
+
+       _media->size = (unsigned long long)sqlite3_column_int64(stmt, 5);
+
+       _media->added_time = (int)sqlite3_column_int(stmt, 6);
+
+       _media->modified_time = (int)sqlite3_column_int(stmt, 7);
+
+       if(STRING_VALID((const char *)sqlite3_column_text(stmt, 8)))
+               _media->thumbnail_path= strdup((const char *)sqlite3_column_text(stmt, 8));
+
+       if(STRING_VALID((const char *)sqlite3_column_text(stmt, 9)))
+               _media->description = strdup((const char *)sqlite3_column_text(stmt, 9));
+
+       _media->rating = (int)sqlite3_column_int(stmt,10);
+
+       _media->favourite = (int)sqlite3_column_int(stmt, 11);
+
+       if(STRING_VALID((const char *)sqlite3_column_text(stmt, 12)))
+               _media->author = strdup((const char *)sqlite3_column_text(stmt, 12));
+
+       if(STRING_VALID((const char *)sqlite3_column_text(stmt, 13)))
+               _media->provider = strdup((const char *)sqlite3_column_text(stmt, 13));
+
+       if(STRING_VALID((const char *)sqlite3_column_text(stmt, 14)))
+               _media->content_name = strdup((const char *)sqlite3_column_text(stmt, 14));
+
+       if(STRING_VALID((const char *)sqlite3_column_text(stmt, 15)))
+               _media->category = strdup((const char *)sqlite3_column_text(stmt, 15));
+
+       if(STRING_VALID((const char *)sqlite3_column_text(stmt, 16)))
+               _media->location_tag = strdup((const char *)sqlite3_column_text(stmt, 16));
+
+       if(STRING_VALID((const char *)sqlite3_column_text(stmt, 17)))
+               _media->age_rating = strdup((const char *)sqlite3_column_text(stmt, 17));
+
+       if(STRING_VALID((const char *)sqlite3_column_text(stmt, 18)))
+               _media->keyword = strdup((const char *)sqlite3_column_text(stmt, 18));
+
+       _media->is_drm = (int)sqlite3_column_int(stmt, 19);
+
+       _media->storage_type = (int)sqlite3_column_int(stmt, 20);
+
+       _media->longitude = (double)sqlite3_column_double(stmt, 21);
+       _media->latitude = (double)sqlite3_column_double(stmt, 22);
+       _media->altitude = (double)sqlite3_column_double(stmt, 23);
+
+       if(_media->media_type == MEDIA_CONTENT_TYPE_IMAGE) {
+               _media->image_meta = (image_meta_s *)calloc(1, sizeof(image_meta_s));
+               if(_media->image_meta) {
+                       if(STRING_VALID(_media->media_id))
+                               _media->image_meta->media_id = strdup(_media->media_id);
+
+                       _media->image_meta->width = sqlite3_column_int(stmt, 24);
+                       _media->image_meta->height = sqlite3_column_int(stmt, 25);
+
+                       if(STRING_VALID((const char *)sqlite3_column_text(stmt, 26)))
+                               _media->image_meta->date_taken = strdup((const char *)sqlite3_column_text(stmt, 26));
+               
+                       _media->image_meta->orientation = sqlite3_column_int(stmt, 27);
+               }
+
+       } else if(_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) {
+               _media->video_meta = (video_meta_s *)calloc(1, sizeof(video_meta_s));
+               if(_media->video_meta) {
+                       if(STRING_VALID(_media->media_id))
+                               _media->video_meta->media_id = strdup(_media->media_id);
+
+                       if(STRING_VALID((const char *)sqlite3_column_text(stmt, 28)))
+                               _media->video_meta->title = strdup((const char *)sqlite3_column_text(stmt, 28));
+
+                       if(STRING_VALID((const char *)sqlite3_column_text(stmt, 29)))
+                               _media->video_meta->album = strdup((const char *)sqlite3_column_text(stmt, 29));
+
+                       if(STRING_VALID((const char *)sqlite3_column_text(stmt, 30)))
+                               _media->video_meta->artist = strdup((const char *)sqlite3_column_text(stmt, 30));
+
+                       if(STRING_VALID((const char *)sqlite3_column_text(stmt, 31)))
+                               _media->video_meta->genre = strdup((const char *)sqlite3_column_text(stmt, 31));
+
+                       if(STRING_VALID((const char *)sqlite3_column_text(stmt, 32)))
+                               _media->video_meta->composer = strdup((const char *)sqlite3_column_text(stmt, 32));
+
+                       if(STRING_VALID((const char *)sqlite3_column_text(stmt, 33)))
+                               _media->video_meta->year = strdup((const char *)sqlite3_column_text(stmt, 33));
+
+                       if(STRING_VALID((const char *)sqlite3_column_text(stmt, 34)))
+                               _media->video_meta->recorded_date = strdup((const char *)sqlite3_column_text(stmt, 34));
+
+                       if(STRING_VALID((const char *)sqlite3_column_text(stmt, 35)))
+                               _media->video_meta->copyright = strdup((const char *)sqlite3_column_text(stmt, 35));
+
+                       if(STRING_VALID((const char *)sqlite3_column_text(stmt, 36)))
+                               _media->video_meta->track_num = strdup((const char *)sqlite3_column_text(stmt, 36));
+
+                       _media->video_meta->bitrate = sqlite3_column_int(stmt, 37);
+                       _media->video_meta->duration = sqlite3_column_int(stmt, 38);
+                       _media->video_meta->played_count = sqlite3_column_int(stmt, 39);
+                       _media->video_meta->played_time = sqlite3_column_int(stmt, 40);
+                       _media->video_meta->played_position = sqlite3_column_int(stmt, 41);
+                       _media->video_meta->width = sqlite3_column_int(stmt, 24);
+                       _media->video_meta->height = sqlite3_column_int(stmt, 25);
+               }
+
+       }
+       else if((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) {
+               _media->audio_meta = (audio_meta_s *)calloc(1, sizeof(audio_meta_s));
+               if(_media->audio_meta) {
+                       if(STRING_VALID(_media->media_id))
+                               _media->audio_meta->media_id = strdup(_media->media_id);
+
+                       if(STRING_VALID((const char *)sqlite3_column_text(stmt, 28)))
+                               _media->audio_meta->title = strdup((const char *)sqlite3_column_text(stmt, 28));
+
+                       if(STRING_VALID((const char *)sqlite3_column_text(stmt, 29)))
+                               _media->audio_meta->album = strdup((const char *)sqlite3_column_text(stmt, 29));
+
+                       if(STRING_VALID((const char *)sqlite3_column_text(stmt, 30)))
+                               _media->audio_meta->artist = strdup((const char *)sqlite3_column_text(stmt, 30));
+
+                       if(STRING_VALID((const char *)sqlite3_column_text(stmt, 31)))
+                               _media->audio_meta->genre = strdup((const char *)sqlite3_column_text(stmt, 31));
+
+                       if(STRING_VALID((const char *)sqlite3_column_text(stmt, 32)))
+                               _media->audio_meta->composer = strdup((const char *)sqlite3_column_text(stmt, 32));
+
+                       if(STRING_VALID((const char *)sqlite3_column_text(stmt, 33)))
+                               _media->audio_meta->year = strdup((const char *)sqlite3_column_text(stmt, 33));
+
+                       if(STRING_VALID((const char *)sqlite3_column_text(stmt, 34)))
+                               _media->audio_meta->recorded_date = strdup((const char *)sqlite3_column_text(stmt, 34));
+
+                       if(STRING_VALID((const char *)sqlite3_column_text(stmt, 35)))
+                               _media->audio_meta->copyright = strdup((const char *)sqlite3_column_text(stmt, 35));
+
+                       if(STRING_VALID((const char *)sqlite3_column_text(stmt, 36)))
+                               _media->audio_meta->track_num = strdup((const char *)sqlite3_column_text(stmt, 36));
+
+                       _media->audio_meta->bitrate = sqlite3_column_int(stmt, 37);
+                       _media->audio_meta->duration = sqlite3_column_int(stmt, 38);
+                       _media->audio_meta->played_count = sqlite3_column_int(stmt, 39);
+                       _media->audio_meta->played_time = sqlite3_column_int(stmt, 40);
+                       _media->audio_meta->played_position = sqlite3_column_int(stmt, 41);
+                       _media->audio_meta->samplerate = sqlite3_column_int(stmt, 42);
+                       _media->audio_meta->channel = sqlite3_column_int(stmt, 43);
+               }
+
+       }
+}
+
+int media_info_insert_to_db (const char *path, media_info_h *info)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       if(!STRING_VALID(path))
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       if(info == NULL)
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       media_content_debug("Register: %s", path);
+       ret = media_file_register(path);
+       if(ret != MS_MEDIA_ERR_NONE)
+       {
+               media_content_error("media_file_register failed");
+               return _content_error_capi(MEDIA_REGISTER_TYPE, ret);
+       }
+
+       media_info_s *_media = (media_info_s*)calloc(1, sizeof(media_info_s));
+       if(_media == NULL)
+       {
+               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+       }
+
+       _media->file_path = strdup(path);
+       if(_media->file_path == NULL)
+       {
+               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+               SAFE_FREE(_media);
+               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+       }
+
+       ret = __media_info_get_media_info_from_db(_media->file_path, (media_info_h)_media);
+
+       *info = (media_info_h)_media;
+
+       return ret;
+}
+
+int media_info_insert_batch_to_db(
+                                       const char **path_array,
+                                       unsigned int array_length,
+                                       media_insert_completed_cb completed_cb,
+                                       void *user_data)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       if (path_array == NULL)
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       if (array_length <= 0)
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       FILE *fp = NULL;
+       char list_path[255] = {0,};
+       int i;
+       int nwrites = 0;
+
+       for (i = 0; i < BATCH_REQUEST_MAX; i++) {
+               snprintf(list_path, sizeof(list_path), "%s/request-%ld-%d", MEDIA_CONTENT_INSERT_FILES_PATH, media_content_gettid(), i);
+
+               if (g_file_test(list_path, G_FILE_TEST_EXISTS | G_FILE_TEST_IS_REGULAR)) {
+                       memset(list_path, 0x00, sizeof(list_path));
+                       continue;
+               } else {
+                       media_content_debug("The request file list path : %s", list_path);
+                       break;
+               }
+       }
+
+       if (i == BATCH_REQUEST_MAX) {
+               media_content_error("Too many batch request for one thread");
+               return MEDIA_CONTENT_ERROR_DB_BUSY;
+       }
+
+       fp = fopen(list_path, "w");
+       if (fp == NULL) {
+               media_content_error("failed to open file : %s [%s]", list_path, strerror(errno));
+               return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
+       }
+
+       for (i = 0; i < array_length; i++) {
+               if (STRING_VALID(path_array[i])) {
+                       int size = strlen(path_array[i]);
+
+                       nwrites = fwrite(path_array[i], 1, size, fp);
+                       if (nwrites != size) {
+                               media_content_error("failed to write thumbnail : %s", strerror(errno));
+                               fclose(fp);
+                               if (unlink(list_path) < 0) {
+                                       media_content_error("failed to delete : %s", strerror(errno));
+                               }
+                               return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
+                       }
+
+                       nwrites = fwrite("\n", 1, 1, fp);
+                       if (nwrites != 1) {
+                               media_content_error("failed to write thumbnail : %s", strerror(errno));
+                               fclose(fp);
+                               if (unlink(list_path) < 0) {
+                                       media_content_error("failed to delete : %s", strerror(errno));
+                               }
+                               return MEDIA_CONTENT_ERROR_INVALID_OPERATION;
+                       }
+               } else {
+                       media_content_error("path[%d] is invalid string", i);
+               }
+       }
+
+       fclose(fp);
+
+       media_insert_cb_s *_cb_data = (media_insert_cb_s *)calloc(1, sizeof(media_insert_cb_s));
+       _cb_data->insert_completed_cb = completed_cb;
+       _cb_data->user_data = user_data;
+       _cb_data->insert_list_path = strdup(list_path);
+
+       ret = media_files_register(list_path, __media_info_insert_completed_cb, _cb_data);
+
+       if (ret < 0) {
+               media_content_error("media_files_register failed : %d", ret);
+               if (unlink(list_path) < 0) {
+                       media_content_error("failed to delete : %s", strerror(errno));
+               }
+               return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+       }
+
+#if 0
+       ret = media_svc_insert_item_begin(_content_get_db_handle(), array_length);
+       if (ret < 0)
+       {
+               media_content_error("media_svc_insert_item_begin failed : %d", ret);
+               return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+       }
+
+       char *path = NULL;
+       media_svc_media_type_e media_type;
+       media_svc_storage_type_e storage_type;
+       char mime_type[255];
+
+       for (i = 0; i < array_length; i++) {
+               memset(mime_type, 0x00, sizeof(mime_type));
+               path = (char*)path_array[i];
+
+               ret = media_svc_get_storage_type(path, &storage_type);
+               if (ret < 0) {
+                       media_content_error("media_svc_get_storage_type failed : %d (%s)", ret, path);
+                       continue;
+               }
+
+               ret = media_svc_get_mime_type(path, mime_type);
+               if (ret < 0) {
+                       media_content_error("media_svc_get_mime_type failed : %d (%s)", ret, path);
+                       continue;
+               }
+
+               ret = media_svc_get_media_type(path, mime_type, &media_type);
+               if (ret < 0) {
+                       media_content_error("media_svc_get_media_type failed : %d (%s)", ret, path);
+                       continue;
+               }
+
+               ret = media_svc_insert_item_bulk(_content_get_db_handle(), storage_type, path, mime_type, media_type);
+               if (ret < 0) {
+                       media_content_error("media_svc_insert_item_bulk failed : %d (%s)", ret, path);
+                       continue;
+               }
+       }
+
+       ret = media_svc_insert_item_end(_content_get_db_handle());
+       if (ret < 0)
+       {
+               media_content_error("media_svc_insert_item_end failed : %d", ret);
+               return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+       }
+
+       if (completed_cb) {
+               completed_cb(MEDIA_CONTENT_ERROR_NONE, user_data);
+       }
+#endif
+       return ret;
+}
+
+int media_info_delete_from_db(const char *media_id)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       char *query_string = NULL;
+
+       if(!STRING_VALID(media_id))
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       query_string = sqlite3_mprintf(DELETE_MEDIA_FROM_MEDIA, media_id);
+
+       ret = _content_query_sql(query_string);
+
+       sqlite3_free(query_string);
+
+       return ret;
+}
+
+int media_info_delete_batch_from_db(filter_h filter)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       char *query_string = NULL;
+       filter_s *_filter = NULL;
+       attribute_h attr;
+       char *condition_query = NULL;
+
+       if(filter == NULL)
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       /* Delete thumbnail of each item */
+       ret = _media_db_get_group_item(NULL, filter, __media_info_delete_batch_cb, NULL, MEDIA_GROUP_NONE);
+
+       _filter = (filter_s*)filter;
+       attr = _content_get_attirbute_handle();
+
+       if(_filter->condition)
+       {
+               ret = _media_filter_attribute_generate(attr, _filter->condition, _filter->condition_collate_type, &condition_query);
+               media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+       }
+
+       if(STRING_VALID(condition_query))
+       {
+               query_string = sqlite3_mprintf(DELETE_MEDIA_FROM_MEDIA_BATCH, condition_query);
+       }
+       else
+       {
+               SAFE_FREE(condition_query);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _content_query_sql(query_string);
+
+       SAFE_FREE(condition_query);
+       sqlite3_free(query_string);
+
+       return ret;
+}
+
+int media_info_destroy(media_info_h media)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+
+       if(_media)
+       {
+               SAFE_FREE(_media->media_id);
+               SAFE_FREE(_media->file_path);
+               SAFE_FREE(_media->display_name);
+               SAFE_FREE(_media->mime_type);
+               SAFE_FREE(_media->thumbnail_path);
+               SAFE_FREE(_media->description);
+               SAFE_FREE(_media->author);
+               SAFE_FREE(_media->provider);
+               SAFE_FREE(_media->content_name);
+               SAFE_FREE(_media->category);
+               SAFE_FREE(_media->location_tag);
+               SAFE_FREE(_media->age_rating);
+               SAFE_FREE(_media->keyword);
+
+               if(_media->image_meta) {
+                       SAFE_FREE(_media->image_meta->media_id);
+                       SAFE_FREE(_media->image_meta->date_taken);
+
+                       SAFE_FREE(_media->image_meta);
+               } else if(_media->video_meta) {
+                       SAFE_FREE(_media->video_meta->media_id);
+                       SAFE_FREE(_media->video_meta->title);
+                       SAFE_FREE(_media->video_meta->album);
+                       SAFE_FREE(_media->video_meta->artist);
+                       SAFE_FREE(_media->video_meta->genre);
+                       SAFE_FREE(_media->video_meta->composer);
+                       SAFE_FREE(_media->video_meta->year);
+                       SAFE_FREE(_media->video_meta->recorded_date);
+                       SAFE_FREE(_media->video_meta->copyright);
+                       SAFE_FREE(_media->video_meta->track_num);
+
+                       SAFE_FREE(_media->video_meta);
+               } else if(_media->audio_meta) {
+                       SAFE_FREE(_media->audio_meta->media_id);
+                       SAFE_FREE(_media->audio_meta->title);
+                       SAFE_FREE(_media->audio_meta->album);
+                       SAFE_FREE(_media->audio_meta->artist);
+                       SAFE_FREE(_media->audio_meta->genre);
+                       SAFE_FREE(_media->audio_meta->composer);
+                       SAFE_FREE(_media->audio_meta->year);
+                       SAFE_FREE(_media->audio_meta->recorded_date);
+                       SAFE_FREE(_media->audio_meta->copyright);
+                       SAFE_FREE(_media->audio_meta->track_num);
+
+                       SAFE_FREE(_media->audio_meta);
+               }
+
+               SAFE_FREE(_media);
+
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_clone(media_info_h *dst, media_info_h src)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_src = (media_info_s*)src;
+
+
+       if(_src != NULL)
+       {
+               media_info_s *_dst = (media_info_s*)calloc(1, sizeof(media_info_s));
+
+               if(_dst == NULL)
+               {
+                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+               }
+
+               if(STRING_VALID(_src->media_id))
+               {
+                       _dst->media_id = strdup(_src->media_id);
+                       if(_dst->media_id == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               media_info_destroy((media_info_h)_dst);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               if(STRING_VALID(_src->file_path))
+               {
+                       _dst->file_path = strdup(_src->file_path);
+                       if(_dst->file_path == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               media_info_destroy((media_info_h)_dst);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               if(STRING_VALID(_src->display_name))
+               {
+                       _dst->display_name = strdup(_src->display_name);
+                       if(_dst->display_name == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               media_info_destroy((media_info_h)_dst);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               if(STRING_VALID(_src->mime_type))
+               {
+                       _dst->mime_type = strdup(_src->mime_type);
+                       if(_dst->mime_type == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               media_info_destroy((media_info_h)_dst);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               if(STRING_VALID(_src->thumbnail_path))
+               {
+                       _dst->thumbnail_path = strdup(_src->thumbnail_path);
+                       if(_dst->thumbnail_path == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               media_info_destroy((media_info_h)_dst);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               if(STRING_VALID(_src->description))
+               {
+                       _dst->description = strdup(_src->description);
+                       if(_dst->description == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               media_info_destroy((media_info_h)_dst);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               if(STRING_VALID(_src->author))
+               {
+                       _dst->author = strdup(_src->author);
+                       if(_dst->author == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               media_info_destroy((media_info_h)_dst);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               if(STRING_VALID(_src->provider))
+               {
+                       _dst->provider = strdup(_src->provider);
+                       if(_dst->provider == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               media_info_destroy((media_info_h)_dst);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               if(STRING_VALID(_src->content_name))
+               {
+                       _dst->content_name = strdup(_src->content_name);
+                       if(_dst->content_name == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               media_info_destroy((media_info_h)_dst);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               if(STRING_VALID(_src->category))
+               {
+                       _dst->category = strdup(_src->category);
+                       if(_dst->category == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               media_info_destroy((media_info_h)_dst);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               if(STRING_VALID(_src->location_tag))
+               {
+                       _dst->location_tag = strdup(_src->location_tag);
+                       if(_dst->location_tag == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               media_info_destroy((media_info_h)_dst);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               if(STRING_VALID(_src->age_rating))
+               {
+                       _dst->age_rating = strdup(_src->age_rating);
+                       if(_dst->age_rating == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               media_info_destroy((media_info_h)_dst);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               if(STRING_VALID(_src->keyword))
+               {
+                       _dst->keyword = strdup(_src->keyword);
+                       if(_dst->keyword == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               media_info_destroy((media_info_h)_dst);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+
+               _dst->media_type = _src->media_type;
+               _dst->size = _src->size;
+               _dst->added_time = _src->added_time;
+               _dst->modified_time = _src->modified_time;
+               _dst->longitude = _src->longitude;
+               _dst->latitude = _src->latitude;
+               _dst->altitude = _src->altitude;
+               _dst->rating = _src->rating;
+               _dst->favourite = _src->favourite;
+               _dst->is_drm = _src->is_drm;
+
+               if(_src->media_type == MEDIA_CONTENT_TYPE_IMAGE && _src->image_meta) {
+                       _dst->image_meta = (image_meta_s *)calloc(1, sizeof(image_meta_s));
+                       if(_dst->image_meta == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               media_info_destroy((media_info_h)_dst);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+
+                       if(STRING_VALID(_src->image_meta->media_id))
+                       {
+                               _dst->image_meta->media_id = strdup(_src->image_meta->media_id);
+                               if(_dst->image_meta->media_id == NULL)
+                               {
+                                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                                       media_info_destroy((media_info_h)_dst);
+                                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                               }
+                       }
+                       if(STRING_VALID(_src->image_meta->date_taken))
+                       {
+                               _dst->image_meta->date_taken = strdup(_src->image_meta->date_taken);
+                               if(_dst->image_meta->date_taken == NULL)
+                               {
+                                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                                       media_info_destroy((media_info_h)_dst);
+                                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                               }
+                       }
+
+                       _dst->image_meta->width = _src->image_meta->width;
+                       _dst->image_meta->height = _src->image_meta->height;
+                       _dst->image_meta->orientation = _src->image_meta->orientation;
+
+               } else if(_src->media_type == MEDIA_CONTENT_TYPE_VIDEO && _src->video_meta) {
+                       _dst->video_meta = (video_meta_s *)calloc(1, sizeof(video_meta_s));
+                       if(_dst->video_meta == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               media_info_destroy((media_info_h)_dst);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+
+                       if(STRING_VALID(_src->video_meta->media_id))
+                       {
+                               _dst->video_meta->media_id = strdup(_src->video_meta->media_id);
+                               if(_dst->video_meta->media_id == NULL)
+                               {
+                                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                                       media_info_destroy((media_info_h)_dst);
+                                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                               }
+                       }
+                       if(STRING_VALID(_src->video_meta->title))
+                       {
+                               _dst->video_meta->title = strdup(_src->video_meta->title);
+                               if(_dst->video_meta->title == NULL)
+                               {
+                                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                                       media_info_destroy((media_info_h)_dst);
+                                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                               }
+                       }
+                       if(STRING_VALID(_src->video_meta->album))
+                       {
+                               _dst->video_meta->album = strdup(_src->video_meta->album);
+                               if(_dst->video_meta->album == NULL)
+                               {
+                                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                                       media_info_destroy((media_info_h)_dst);
+                                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                               }
+                       }
+                       if(STRING_VALID(_src->video_meta->artist))
+                       {
+                               _dst->video_meta->artist = strdup(_src->video_meta->artist);
+                               if(_dst->video_meta->artist == NULL)
+                               {
+                                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                                       media_info_destroy((media_info_h)_dst);
+                                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                               }
+                       }
+                       if(STRING_VALID(_src->video_meta->genre))
+                       {
+                               _dst->video_meta->genre = strdup(_src->video_meta->genre);
+                               if(_dst->video_meta->genre == NULL)
+                               {
+                                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                                       media_info_destroy((media_info_h)_dst);
+                                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                               }
+                       }
+                       if(STRING_VALID(_src->video_meta->composer))
+                       {
+                               _dst->video_meta->composer = strdup(_src->video_meta->composer);
+                               if(_dst->video_meta->composer == NULL)
+                               {
+                                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                                       media_info_destroy((media_info_h)_dst);
+                                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                               }
+                       }
+                       if(STRING_VALID(_src->video_meta->year))
+                       {
+                               _dst->video_meta->year = strdup(_src->video_meta->year);
+                               if(_dst->video_meta->year == NULL)
+                               {
+                                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                                       media_info_destroy((media_info_h)_dst);
+                                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                               }
+                       }
+                       if(STRING_VALID(_src->video_meta->recorded_date))
+                       {
+                               _dst->video_meta->recorded_date = strdup(_src->video_meta->recorded_date);
+                               if(_dst->video_meta->recorded_date == NULL)
+                               {
+                                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                                       media_info_destroy((media_info_h)_dst);
+                                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                               }
+                       }
+                       if(STRING_VALID(_src->video_meta->copyright))
+                       {
+                               _dst->video_meta->copyright = strdup(_src->video_meta->copyright);
+                               if(_dst->video_meta->copyright == NULL)
+                               {
+                                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                                       media_info_destroy((media_info_h)_dst);
+                                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                               }
+                       }
+                       if(STRING_VALID(_src->video_meta->track_num))
+                       {
+                               _dst->video_meta->track_num = strdup(_src->video_meta->track_num);
+                               if(_dst->video_meta->track_num == NULL)
+                               {
+                                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                                       media_info_destroy((media_info_h)_dst);
+                                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                               }
+                       }
+
+                       _dst->video_meta->width = _src->video_meta->width;
+                       _dst->video_meta->height = _src->video_meta->height;
+                       _dst->video_meta->duration = _src->video_meta->duration;
+                       _dst->video_meta->bitrate = _src->video_meta->bitrate;
+                       _dst->video_meta->played_count = _src->video_meta->played_count;
+                       _dst->video_meta->played_time = _src->video_meta->played_time;
+                       _dst->video_meta->played_position = _src->video_meta->played_position;
+
+               } else if((_src->media_type == MEDIA_CONTENT_TYPE_MUSIC || _src->media_type == MEDIA_CONTENT_TYPE_SOUND) && _src->audio_meta) {
+                       _dst->audio_meta = (audio_meta_s *)calloc(1, sizeof(audio_meta_s));
+                       if(_dst->audio_meta == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               media_info_destroy((media_info_h)_dst);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+
+                       if(STRING_VALID(_src->audio_meta->media_id))
+                       {
+                               _dst->audio_meta->media_id = strdup(_src->audio_meta->media_id);
+                               if(_dst->audio_meta->media_id == NULL)
+                               {
+                                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                                       media_info_destroy((media_info_h)_dst);
+                                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                               }
+                       }
+                       if(STRING_VALID(_src->audio_meta->title))
+                       {
+                               _dst->audio_meta->title = strdup(_src->audio_meta->title);
+                               if(_dst->audio_meta->title == NULL)
+                               {
+                                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                                       media_info_destroy((media_info_h)_dst);
+                                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                               }
+                       }
+                       if(STRING_VALID(_src->audio_meta->album))
+                       {
+                               _dst->audio_meta->album = strdup(_src->audio_meta->album);
+                               if(_dst->audio_meta->album == NULL)
+                               {
+                                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                                       media_info_destroy((media_info_h)_dst);
+                                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                               }
+                       }
+                       if(STRING_VALID(_src->audio_meta->artist))
+                       {
+                               _dst->audio_meta->artist = strdup(_src->audio_meta->artist);
+                               if(_dst->audio_meta->artist == NULL)
+                               {
+                                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                                       media_info_destroy((media_info_h)_dst);
+                                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                               }
+                       }
+                       if(STRING_VALID(_src->audio_meta->genre))
+                       {
+                               _dst->audio_meta->genre = strdup(_src->audio_meta->genre);
+                               if(_dst->audio_meta->genre == NULL)
+                               {
+                                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                                       media_info_destroy((media_info_h)_dst);
+                                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                               }
+                       }
+                       if(STRING_VALID(_src->audio_meta->composer))
+                       {
+                               _dst->audio_meta->composer = strdup(_src->audio_meta->composer);
+                               if(_dst->audio_meta->composer == NULL)
+                               {
+                                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                                       media_info_destroy((media_info_h)_dst);
+                                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                               }
+                       }
+                       if(STRING_VALID(_src->audio_meta->year))
+                       {
+                               _dst->audio_meta->year = strdup(_src->audio_meta->year);
+                               if(_dst->audio_meta->year == NULL)
+                               {
+                                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                                       media_info_destroy((media_info_h)_dst);
+                                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                               }
+                       }
+                       if(STRING_VALID(_src->audio_meta->recorded_date))
+                       {
+                               _dst->audio_meta->recorded_date = strdup(_src->audio_meta->recorded_date);
+                               if(_dst->audio_meta->recorded_date == NULL)
+                               {
+                                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                                       media_info_destroy((media_info_h)_dst);
+                                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                               }
+                       }
+                       if(STRING_VALID(_src->audio_meta->copyright))
+                       {
+                               _dst->audio_meta->copyright = strdup(_src->audio_meta->copyright);
+                               if(_dst->audio_meta->copyright == NULL)
+                               {
+                                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                                       media_info_destroy((media_info_h)_dst);
+                                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                               }
+                       }
+                       if(STRING_VALID(_src->audio_meta->track_num))
+                       {
+                               _dst->audio_meta->track_num = strdup(_src->audio_meta->track_num);
+                               if(_dst->audio_meta->track_num == NULL)
+                               {
+                                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                                       media_info_destroy((media_info_h)_dst);
+                                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                               }
+                       }
+
+                       _dst->audio_meta->channel = _src->audio_meta->channel;
+                       _dst->audio_meta->samplerate = _src->audio_meta->samplerate;
+                       _dst->audio_meta->duration = _src->audio_meta->duration;
+                       _dst->audio_meta->bitrate = _src->audio_meta->bitrate;
+                       _dst->audio_meta->played_count = _src->audio_meta->played_count;
+                       _dst->audio_meta->played_time = _src->audio_meta->played_time;
+                       _dst->audio_meta->played_position = _src->audio_meta->played_position;
+
+               }
+               *dst = (media_info_h)_dst;
+
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_get_media_count_from_db(filter_h filter, int *media_count)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       media_content_debug_func();
+
+       if(media_count == NULL)
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+
+               return ret;
+       }
+
+       ret = _media_db_get_group_item_count(NULL, filter, MEDIA_GROUP_NONE, media_count);
+
+       return ret;
+}
+
+int media_info_foreach_media_from_db(filter_h filter, media_info_cb callback, void *user_data)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       media_content_debug_func();
+
+       if(callback == NULL)
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _media_db_get_group_item(NULL, filter, callback, user_data, MEDIA_GROUP_NONE);
+
+       return ret;
+}
+
+int media_info_get_tag_count_from_db(const char *media_id, filter_h filter, int *tag_count)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       media_content_debug_func();
+
+       if(STRING_VALID(media_id) && tag_count)
+       {
+               ret = _media_db_get_group_item_count(media_id, filter, MEDIA_GROUP_TAG_BY_MEDIA_ID, tag_count);
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_foreach_tag_from_db(const char *media_id, filter_h filter, media_tag_cb callback, void *user_data)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       media_content_debug_func();
+
+       if((callback != NULL) && STRING_VALID(media_id))
+       {
+               ret = _media_db_get_tag(media_id, filter, callback, user_data);
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_get_bookmark_count_from_db(const char *media_id, filter_h filter, int *bookmark_count)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       media_content_debug_func();
+
+       if(STRING_VALID(media_id) && bookmark_count)
+       {
+               ret = _media_db_get_group_item_count(media_id, filter, MEDIA_GROUP_BOOKMARK_BY_MEDIA_ID, bookmark_count);
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_foreach_bookmark_from_db (const char *media_id, filter_h filter, media_bookmark_cb callback, void *user_data)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       media_content_debug_func();
+
+       if((callback != NULL) && STRING_VALID(media_id))
+       {
+               ret = _media_db_get_bookmark(media_id, filter, callback, user_data);
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_get_image(media_info_h media, image_meta_h *image)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       media_info_s *_media = (media_info_s*)media;
+       media_content_debug_func();
+
+       if(_media == NULL)
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       if(_media->media_type != MEDIA_CONTENT_TYPE_IMAGE)
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       if(_media->image_meta == NULL)
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       image_meta_s *_image = (image_meta_s*)calloc(1, sizeof(image_meta_s));
+
+       if(_image == NULL)
+       {
+               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+       }
+
+       if(STRING_VALID(_media->media_id)) {
+               _image->media_id = strdup(_media->media_id);
+       }
+
+       _image->width = _media->image_meta->width;
+       _image->height = _media->image_meta->height;
+       _image->orientation = _media->image_meta->orientation;
+
+       if(STRING_VALID(_media->image_meta->date_taken)) {
+               _image->date_taken = strdup(_media->image_meta->date_taken);
+       }
+
+       *image = (image_meta_h)_image;
+
+       return ret;
+}
+
+int media_info_get_video(media_info_h media, video_meta_h *video)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       media_info_s *_media = (media_info_s*)media;
+       media_content_debug_func();
+
+       if(_media == NULL)
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       if(_media->media_type != MEDIA_CONTENT_TYPE_VIDEO)
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       if(_media->video_meta == NULL)
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       video_meta_s *_video = (video_meta_s*)calloc(1, sizeof(video_meta_s));
+
+       if(_video == NULL)
+       {
+               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+       }
+
+       if(STRING_VALID(_media->media_id)) {
+               _video->media_id = strdup(_media->media_id);
+       }
+
+       if(STRING_VALID(_media->video_meta->title)) {
+               _video->title = strdup(_media->video_meta->title);
+       }
+       if(STRING_VALID(_media->video_meta->album)) {
+               _video->album = strdup(_media->video_meta->album);
+       }
+       if(STRING_VALID(_media->video_meta->artist)) {
+               _video->artist = strdup(_media->video_meta->artist);
+       }
+       if(STRING_VALID(_media->video_meta->genre)) {
+               _video->genre = strdup(_media->video_meta->genre);
+       }
+       if(STRING_VALID(_media->video_meta->composer)) {
+               _video->composer = strdup(_media->video_meta->composer);
+       }
+       if(STRING_VALID(_media->video_meta->year)) {
+               _video->year = strdup(_media->video_meta->year);
+       }
+       if(STRING_VALID(_media->video_meta->recorded_date)) {
+               _video->recorded_date = strdup(_media->video_meta->recorded_date);
+       }
+       if(STRING_VALID(_media->video_meta->copyright)) {
+               _video->copyright = strdup(_media->video_meta->copyright);
+       }
+       if(STRING_VALID(_media->video_meta->track_num)) {
+               _video->track_num = strdup(_media->video_meta->track_num);
+       }
+
+       _video->width = _media->video_meta->width;
+       _video->height = _media->video_meta->height;
+       _video->duration = _media->video_meta->duration;
+       _video->bitrate = _media->video_meta->bitrate;
+       _video->played_count = _media->video_meta->played_count;
+       _video->played_time = _media->video_meta->played_time;
+       _video->played_position = _media->video_meta->played_position;
+
+       *video = (video_meta_h)_video;
+
+       return ret;
+}
+
+int media_info_get_audio(media_info_h media, audio_meta_h *audio)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       media_info_s *_media = (media_info_s*)media;
+       media_content_debug_func();
+
+       if(_media == NULL)
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       if(_media->media_type != MEDIA_CONTENT_TYPE_MUSIC && _media->media_type != MEDIA_CONTENT_TYPE_SOUND)
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       if(_media->audio_meta == NULL)
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       audio_meta_s *_audio = (audio_meta_s*)calloc(1, sizeof(audio_meta_s));
+
+       if(_audio == NULL)
+       {
+               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+       }
+
+       if(STRING_VALID(_media->media_id)) {
+               _audio->media_id = strdup(_media->media_id);
+       }
+
+       if(STRING_VALID(_media->audio_meta->title)) {
+               _audio->title = strdup(_media->audio_meta->title);
+       }
+       if(STRING_VALID(_media->audio_meta->album)) {
+               _audio->album = strdup(_media->audio_meta->album);
+       }
+       if(STRING_VALID(_media->audio_meta->artist)) {
+               _audio->artist = strdup(_media->audio_meta->artist);
+       }
+       if(STRING_VALID(_media->audio_meta->genre)) {
+               _audio->genre = strdup(_media->audio_meta->genre);
+       }
+       if(STRING_VALID(_media->audio_meta->composer)) {
+               _audio->composer = strdup(_media->audio_meta->composer);
+       }
+       if(STRING_VALID(_media->audio_meta->year)) {
+               _audio->year = strdup(_media->audio_meta->year);
+       }
+       if(STRING_VALID(_media->audio_meta->recorded_date)) {
+               _audio->recorded_date = strdup(_media->audio_meta->recorded_date);
+       }
+       if(STRING_VALID(_media->audio_meta->copyright)) {
+               _audio->copyright = strdup(_media->audio_meta->copyright);
+       }
+       if(STRING_VALID(_media->audio_meta->track_num)) {
+               _audio->track_num = strdup(_media->audio_meta->track_num);
+       }
+
+       _audio->duration = _media->audio_meta->duration;
+       _audio->bitrate = _media->audio_meta->bitrate;
+       _audio->samplerate = _media->audio_meta->samplerate;
+       _audio->channel = _media->audio_meta->channel;
+       _audio->played_time = _media->audio_meta->played_time;
+       _audio->played_count = _media->audio_meta->played_count;
+       _audio->played_position = _media->audio_meta->played_position;
+
+       *audio = (audio_meta_h)_audio;
+
+       return ret;
+}
+
+int media_info_get_media_id(media_info_h media, char **media_id)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+
+       if(_media && media_id)
+       {
+               if(STRING_VALID(_media->media_id))
+               {
+                       *media_id = strdup(_media->media_id);
+                       if(*media_id == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       *media_id = NULL;
+               }
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_get_file_path(media_info_h media, char **path)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+
+       if(_media && path)
+       {
+               if(STRING_VALID(_media->file_path))
+               {
+                       *path = strdup(_media->file_path);
+                       if(*path == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       *path = NULL;
+               }
+               ret = MEDIA_CONTENT_ERROR_NONE;
+
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_get_display_name(media_info_h media, char **name)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+       if(_media && name)
+       {
+               if(STRING_VALID(_media->display_name))
+               {
+                       *name = strdup(_media->display_name);
+                       if(*name == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       *name = NULL;
+               }
+               ret = MEDIA_CONTENT_ERROR_NONE;
+
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_get_media_type(media_info_h media, media_content_type_e *type)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+       if(_media && type)
+       {
+               *type = _media->media_type;
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_get_mime_type(media_info_h media, char **mime_type)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+
+       if(_media && mime_type)
+       {
+               if(STRING_VALID(_media->mime_type))
+               {
+                       *mime_type = strdup(_media->mime_type);
+                       if(*mime_type == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       *mime_type = NULL;
+               }
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_get_size(media_info_h media, unsigned long long *size)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+
+       if(_media && size)
+       {
+               *size = _media->size;
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_get_added_time(media_info_h media, time_t *added_time)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+       if(_media && added_time)
+       {
+               *added_time = _media->added_time;
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_get_modified_time(media_info_h media, time_t* time)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+       if(_media && time)
+       {
+               *time = _media->modified_time;
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_get_thumbnail_path(media_info_h media, char **path)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+       if(_media && path)
+       {
+               if(STRING_VALID(_media->thumbnail_path))
+               {
+                       *path = strdup(_media->thumbnail_path);
+                       if(*path == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       *path = NULL;
+               }
+               ret = MEDIA_CONTENT_ERROR_NONE;
+
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_get_description(media_info_h media, char **description)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+
+       if(_media && description)
+       {
+               if(STRING_VALID(_media->description))
+               {
+                       *description = strdup(_media->description);
+                       if(*description == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       *description = NULL;
+               }
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_get_longitude(media_info_h media, double* longitude)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+
+       if(_media && longitude)
+       {
+               *longitude = _media->longitude;
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+int media_info_get_latitude(media_info_h media, double* latitude)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+
+       if(_media && latitude)
+       {
+               *latitude = _media->latitude;
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_get_altitude(media_info_h media, double *altitude)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+
+       if(_media && altitude)
+       {
+               *altitude = _media->altitude;
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_get_rating(media_info_h media, int *rating)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+
+       if(_media && rating)
+       {
+               *rating = _media->rating;
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_get_favorite(media_info_h media, bool* favorite)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+
+       if(_media && favorite)
+       {
+
+               *favorite = _media->favourite;
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_get_author(media_info_h media, char **author)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+
+       if(_media && author)
+       {
+               if(STRING_VALID(_media->author))
+               {
+                       *author = strdup(_media->author);
+                       if(*author == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       *author = NULL;
+               }
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_get_provider(media_info_h media, char **provider)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+
+       if(_media && provider)
+       {
+               if(STRING_VALID(_media->provider))
+               {
+                       *provider = strdup(_media->provider);
+                       if(*provider == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       *provider = NULL;
+               }
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_get_content_name(media_info_h media, char **content_name)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+
+       if(_media && content_name)
+       {
+               if(STRING_VALID(_media->content_name))
+               {
+                       *content_name = strdup(_media->content_name);
+                       if(*content_name == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       *content_name = NULL;
+               }
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_get_category(media_info_h media, char **category)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+
+       if(_media && category)
+       {
+               if(STRING_VALID(_media->category))
+               {
+                       *category = strdup(_media->category);
+                       if(*category == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       *category = NULL;
+               }
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_get_location_tag(media_info_h media, char **location_tag)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+
+       if(_media && location_tag)
+       {
+               if(STRING_VALID(_media->location_tag))
+               {
+                       *location_tag = strdup(_media->location_tag);
+                       if(*location_tag == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       *location_tag = NULL;
+               }
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_get_age_rating(media_info_h media, char **age_rating)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+
+       if(_media && age_rating)
+       {
+               if(STRING_VALID(_media->age_rating))
+               {
+                       *age_rating = strdup(_media->age_rating);
+                       if(*age_rating == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       *age_rating = NULL;
+               }
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_get_keyword(media_info_h media, char **keyword)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+
+       if(_media && keyword)
+       {
+               if(STRING_VALID(_media->keyword))
+               {
+                       *keyword = strdup(_media->keyword);
+                       if(*keyword == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       *keyword = NULL;
+               }
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_is_drm(media_info_h media, bool *is_drm)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+
+       if(_media)
+       {
+               *is_drm = _media->is_drm;
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_get_storage_type(media_info_h media, media_content_storage_e *storage_type)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+
+       if(_media && storage_type)
+       {
+               *storage_type = _media->storage_type;
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_get_media_from_db(const char *media_id, media_info_h *media)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       char select_query[DEFAULT_QUERY_SIZE];
+       sqlite3_stmt *stmt = NULL;
+
+       if(!STRING_VALID(media_id) || (media == NULL))
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       memset(select_query, 0x00, sizeof(select_query));
+
+       snprintf(select_query, sizeof(select_query), SELECT_MEDIA_FROM_MEDIA, media_id);
+       ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       while(sqlite3_step(stmt) == SQLITE_ROW)
+       {
+               media_info_s *_media = (media_info_s*)calloc(1, sizeof(media_info_s));
+
+               if(_media == NULL)
+               {
+                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                       SQLITE3_FINALIZE(stmt);
+                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+               }
+
+               _media_info_item_get_detail(stmt, (media_info_h)_media);
+
+               *media = (media_info_h)_media;
+       }
+
+       SQLITE3_FINALIZE(stmt);
+
+       return ret;
+}
+
+int media_info_set_display_name(media_info_h media, const char *display_name)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+
+       if(_media != NULL && STRING_VALID(display_name))
+       {
+               SAFE_FREE(_media->display_name);
+
+               _media->display_name = strdup(display_name);
+               if(_media->display_name == NULL)
+               {
+                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+               }
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_set_description(media_info_h media, const char *description)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+
+       if(_media != NULL)
+       {
+               SAFE_FREE(_media->description);
+
+               if(STRING_VALID(description))
+               {
+                       _media->description = strdup(description);
+
+                       if(_media->description == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       _media->description = NULL;
+               }
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_set_longitude(media_info_h media, double longitude)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+
+       if(_media != NULL)
+       {
+               _media->longitude = longitude;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_set_latitude(media_info_h media, double latitude)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+
+       if(_media != NULL)
+       {
+               _media->latitude = latitude;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_set_altitude(media_info_h media, double altitude)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+
+       if(_media != NULL)
+       {
+               _media->altitude = altitude;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_set_rating(media_info_h media, int rating)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+
+       if(_media != NULL)
+       {
+               _media->rating = rating;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_set_added_time(media_info_h media, time_t added_time)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       media_info_s *_media = (media_info_s*)media;
+
+       if((_media != NULL) && (added_time >= 0))
+       {
+               _media->added_time = added_time;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_set_favorite(media_info_h media, bool favorite)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+
+       if(_media != NULL)
+       {
+               _media->favourite = favorite;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_set_author(media_info_h media, const char *author)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+
+       if(_media != NULL)
+       {
+               if(STRING_VALID(author))
+               {
+                       _media->author = strdup(author);
+                       if(_media->author == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       _media->author = NULL;
+               }
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_set_provider(media_info_h media, const char *provider)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+
+       if(_media != NULL)
+       {
+               SAFE_FREE(_media->provider);
+
+               if(STRING_VALID(provider))
+               {
+                       _media->provider = strdup(provider);
+                       if(_media->provider == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       _media->provider = NULL;
+               }
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_set_content_name(media_info_h media, const char *content_name)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+
+       if(_media != NULL)
+       {
+               SAFE_FREE(_media->content_name);
+
+               if(STRING_VALID(content_name))
+               {
+                       _media->content_name = strdup(content_name);
+                       if(_media->content_name == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       _media->content_name = NULL;
+               }
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_set_category(media_info_h media, const char *category)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+
+       if(_media != NULL)
+       {
+               SAFE_FREE(_media->category);
+
+               if(STRING_VALID(category))
+               {
+                       _media->category = strdup(category);
+                       if(_media->category == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       _media->category = NULL;
+               }
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_set_location_tag(media_info_h media, const char *location_tag)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+
+       if(_media != NULL)
+       {
+               SAFE_FREE(_media->location_tag);
+
+               if(STRING_VALID(location_tag))
+               {
+                       _media->location_tag = strdup(location_tag);
+                       if(_media->location_tag == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       _media->location_tag = NULL;
+               }
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_set_age_rating(media_info_h media, const char *age_rating)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+
+       if(_media != NULL)
+       {
+               SAFE_FREE(_media->age_rating);
+
+               if(STRING_VALID(age_rating))
+               {
+                       _media->age_rating = strdup(age_rating);
+                       if(_media->age_rating == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       _media->age_rating = NULL;
+               }
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_set_keyword(media_info_h media, const char *keyword)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+
+       if(_media != NULL)
+       {
+               SAFE_FREE(_media->keyword);
+
+               if(STRING_VALID(keyword))
+               {
+                       _media->keyword = strdup(keyword);
+                       if(_media->keyword == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       _media->keyword = NULL;
+               }
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_update_to_db(media_info_h media)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       int len = 0;
+       media_info_s *_media = (media_info_s*)media;
+       char *set_sql = NULL;
+       char sql[MAX_QUERY_SIZE];
+       memset(sql, '\0', sizeof(sql));
+
+       if(_media != NULL && STRING_VALID(_media->media_id))
+       {
+               /* This sql is due to sqlite3_mprintf's wrong operation when using floating point in the text format */
+               /* This code will be removed when sqlite3_mprintf works clearly */
+               char *test_sql = sqlite3_mprintf("%f, %f, %f", _media->longitude, _media->latitude, _media->altitude);
+               sqlite3_free(test_sql);
+
+               set_sql = sqlite3_mprintf("file_name=%Q, added_time=%d, description=%Q, longitude=%f, latitude=%f, altitude=%f, \
+                       rating=%d, favourite=%d, author=%Q, provider=%Q, content_name=%Q, category=%Q, location_tag=%Q, age_rating=%Q, keyword=%Q",
+                       _media->display_name, _media->added_time, _media->description, _media->longitude, _media->latitude, _media->altitude, _media->rating, _media->favourite,
+                       _media->author, _media->provider, _media->content_name, _media->category, _media->location_tag, _media->age_rating, _media->keyword);
+
+               len = snprintf(sql, sizeof(sql), "UPDATE %s SET %s WHERE media_uuid='%s'", DB_TABLE_MEDIA, set_sql, _media->media_id);
+               sqlite3_free(set_sql);
+               if (len > 0) {
+                       sql[len] = '\0';
+               } else {
+                       media_content_error("snprintf failed");
+                       return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+               }
+
+               ret = _content_query_sql(sql);
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_refresh_metadata_to_db(const char *media_id)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_h media = NULL;
+       char *file_path = NULL;
+       media_content_type_e media_type = 0;
+       media_content_storage_e storage_type = 0;
+
+       if(!STRING_VALID(media_id))
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = media_info_get_media_from_db(media_id, &media);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+       {
+               media_info_destroy(media);
+               return ret;
+       }
+
+       ret = media_info_get_media_type(media, &media_type);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+       {
+               media_info_destroy(media);
+               return ret;
+       }
+
+       ret = media_info_get_storage_type(media, &storage_type);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+       {
+               media_info_destroy(media);
+               return ret;
+       }
+
+       ret = media_info_get_file_path(media, &file_path);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+       {
+               media_info_destroy(media);
+               return ret;
+       }
+
+       ret = media_svc_refresh_item(_content_get_db_handle(), storage_type, file_path, media_type);
+
+       SAFE_FREE(file_path);
+       media_info_destroy(media);
+
+       return ret;
+}
+
+int media_info_move_to_db(media_info_h media, const char* dst_path)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       int src_storage_type = 0;
+       int dst_storage_type = 0;
+
+       if(media == NULL || !STRING_VALID(dst_path))
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       media_info_s *_media = (media_info_s*)media;
+
+       ret = _media_util_get_store_type_by_path(_media->file_path, &src_storage_type);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+       ret = _media_util_get_store_type_by_path(dst_path, &dst_storage_type);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       ret = media_svc_move_item(_content_get_db_handle(), src_storage_type, _media->file_path, dst_storage_type, dst_path);
+       return _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+}
+
+int media_info_create_thumbnail(media_info_h media, media_thumbnail_completed_cb callback, void *user_data)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+
+       if(_media != NULL && STRING_VALID(_media->media_id) && STRING_VALID(_media->file_path))
+       {
+               media_thumbnail_cb_s *_thumb_cb = (media_thumbnail_cb_s*)calloc(1, sizeof(media_thumbnail_cb_s));
+               _thumb_cb->handle = _media;
+               _thumb_cb->user_data = user_data;
+               _thumb_cb->thumbnail_completed_cb = callback;
+
+               ret = thumbnail_request_from_db_async(_media->file_path, (ThumbFunc)__media_info_thumbnail_completed_cb, (void *)_thumb_cb);
+               ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_info_cancel_thumbnail(media_info_h media)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_s *_media = (media_info_s*)media;
+
+       if(_media != NULL && STRING_VALID(_media->media_id) && STRING_VALID(_media->file_path))
+       {
+               ret = thumbnail_request_cancel_media(_media->file_path);
+               ret = _content_error_capi(MEDIA_THUMBNAIL_TYPE, ret);
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
diff --git a/src/media_playlist.c b/src/media_playlist.c
new file mode 100755 (executable)
index 0000000..d4dc1f8
--- /dev/null
@@ -0,0 +1,656 @@
+/*
+* 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_filter.h>
+#include <media_info.h>
+#include <media_info_private.h>
+#include <media_playlist.h>
+
+
+static __thread GList *g_playlist_item_list = NULL;
+
+static void __media_playlist_item_add(media_playlist_item_s *item_s);
+static void __media_playlist_item_release(void);
+static int __media_playlist_insert_playlist_record(const char *playlist_name, int *playlist_id);
+static int __media_playlist_insert_item_to_playlist(int playlist_id, const char *media_id);
+static int __media_playlist_remove_item_from_playlist(int playlist_id, int playlist_member_id);
+static int __media_playlist_update_playlist_name(int playlist_id, const char *playlist_name);
+static int __media_playlist_update_play_order(int playlist_id, int playlist_member_id, int play_order);
+
+static void __media_playlist_item_add(media_playlist_item_s *item_s)
+{
+       g_playlist_item_list = g_list_append(g_playlist_item_list, item_s);
+}
+
+static void __media_playlist_item_release(void)
+{
+       int idx = 0;
+       int list_cnt = 0;
+       media_playlist_item_s *item = NULL;
+
+       list_cnt = g_list_length(g_playlist_item_list);
+
+       media_content_debug("list_cnt : [%d]", list_cnt);
+
+       for(idx = 0; idx < list_cnt; idx++)
+       {
+               item = (media_playlist_item_s*)g_list_nth_data(g_playlist_item_list, idx);
+               if(item != NULL)
+               {
+                       SAFE_FREE(item->media_id);
+                       SAFE_FREE(item->playlist_name);
+                       SAFE_FREE(item);
+               }
+       }
+
+       g_list_free(g_playlist_item_list);
+       g_playlist_item_list = NULL;
+
+}
+
+static int __media_playlist_insert_playlist_record(const char *playlist_name, int *playlist_id)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       char *query_str = NULL;
+       char *select_query = NULL;
+       sqlite3_stmt *stmt = NULL;
+
+       query_str = sqlite3_mprintf(INSERT_PLAYLIST_TO_PLAYLIST, playlist_name);
+
+       ret = _content_query_sql(query_str);
+       sqlite3_free(query_str);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       select_query = sqlite3_mprintf(SELECT_PLAYLIST_ID_FROM_PLAYLIST, playlist_name);
+
+       ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
+       sqlite3_free(select_query);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       while(sqlite3_step(stmt) == SQLITE_ROW)
+       {
+               *playlist_id = (int)sqlite3_column_int(stmt,0);
+       }
+
+       SQLITE3_FINALIZE(stmt);
+
+       return MEDIA_CONTENT_ERROR_NONE;
+}
+
+static int __media_playlist_insert_item_to_playlist(int playlist_id, const char *media_id)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       sqlite3_stmt *stmt = NULL;
+       char select_query[DEFAULT_QUERY_SIZE];
+       char *query_str = NULL;
+       int play_order = 0;
+
+       memset(select_query, 0x00, sizeof(select_query));
+
+       snprintf(select_query, sizeof(select_query), SELECT_MAX_PLAY_ORDER_FROM_PLAYLIST_VIEW, playlist_id);
+
+       /* get the max play_order */
+       ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       while(sqlite3_step(stmt) == SQLITE_ROW)
+       {
+               play_order = (int)sqlite3_column_int(stmt, 0);
+       }
+
+       SQLITE3_FINALIZE(stmt);
+
+       ++play_order;
+
+       query_str = sqlite3_mprintf("INSERT INTO %q (playlist_id, media_uuid, play_order) values (%d, '%q', %d)",
+                       DB_TABLE_PLAYLIST_MAP, playlist_id, media_id, play_order);
+       ret = _content_query_sql(query_str);
+       sqlite3_free(query_str);
+
+       return ret;
+}
+
+static int __media_playlist_remove_item_from_playlist(int playlist_id, int playlist_member_id)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       char *query_str = NULL;
+
+       query_str = sqlite3_mprintf(REMOVE_PLAYLIST_ITEM_FROM_PLAYLIST_MAP, playlist_id, playlist_member_id);
+
+       ret = _content_query_sql(query_str);
+       sqlite3_free(query_str);
+
+       return ret;
+}
+
+static int __media_playlist_update_playlist_name(int playlist_id, const char *playlist_name)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       char *query_str = NULL;
+
+       query_str = sqlite3_mprintf(UPDATE_PLAYLIST_NAME_FROM_PLAYLIST, playlist_name, playlist_id);
+
+       ret = _content_query_sql(query_str);
+       sqlite3_free(query_str);
+
+       return ret;
+}
+
+static int __media_playlist_update_play_order(int playlist_id, int playlist_member_id, int play_order)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       char *query_str = NULL;
+
+       query_str = sqlite3_mprintf(UPDATE_PLAYLIST_ORDER_FROM_PLAYLIST_MAP, play_order, playlist_id, playlist_member_id);
+
+       ret = _content_query_sql(query_str);
+       sqlite3_free(query_str);
+
+       return ret;
+}
+
+int media_playlist_insert_to_db(const char *name, media_playlist_h *playlist)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       int playlist_id = 0;
+
+       if(!STRING_VALID(name))
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       media_playlist_s *_playlist = (media_playlist_s*)calloc(1, sizeof(media_playlist_s));
+
+       if(_playlist == NULL)
+       {
+               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+       }
+
+       ret = __media_playlist_insert_playlist_record(name, &playlist_id);
+
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+       {
+               SAFE_FREE(_playlist);
+               return ret;
+       }
+
+       _playlist->playlist_id = playlist_id;
+       _playlist->name = strdup(name);
+
+       if(_playlist->name == NULL)
+       {
+               SAFE_FREE(_playlist);
+               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+       }
+
+       *playlist = (media_playlist_h)_playlist;
+
+       return ret;
+}
+
+int media_playlist_delete_from_db(int playlist_id)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       char *query_str = NULL;
+
+       if(playlist_id < 0)
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       query_str = sqlite3_mprintf(DELETE_PLAYLIST_FROM_PLAYLIST, playlist_id);
+
+       ret = _content_query_sql(query_str);
+
+       sqlite3_free(query_str);
+
+       return ret;
+}
+
+int media_playlist_get_playlist_count_from_db(filter_h filter, int *playlist_count)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       media_content_debug_func();
+
+       if(playlist_count != NULL)
+       {
+               ret = _media_db_get_group_count(filter, MEDIA_GROUP_PLAYLIST, playlist_count);
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_playlist_foreach_playlist_from_db(filter_h filter, media_playlist_cb callback, void *user_data)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       media_content_debug_func();
+
+       if(callback == NULL)
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _media_db_get_playlist(filter, callback, user_data);
+
+       return ret;
+}
+
+int media_playlist_get_media_count_from_db(int playlist_id, filter_h filter, int *media_count)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       media_content_debug_func();
+
+       if((playlist_id > 0) && (media_count != NULL))
+       {
+               ret = _media_db_get_group_item_count_by_id(playlist_id, filter, MEDIA_GROUP_PLAYLIST, media_count);
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_playlist_foreach_media_from_db(int playlist_id, filter_h filter, playlist_member_cb callback, void *user_data)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       media_content_debug_func();
+
+       if((playlist_id > 0) && (callback != NULL))
+       {
+               //ret = _media_db_get_group_item_by_id(playlist_id, filter, callback, user_data, MEDIA_GROUP_PLAYLIST);
+               ret = _media_db_get_playlist_item(playlist_id, filter, callback, user_data);
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_playlist_destroy(media_playlist_h playlist)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_playlist_s *_playlist = (media_playlist_s*)playlist;
+
+       media_content_debug_func();
+
+       if(_playlist)
+       {
+               SAFE_FREE(_playlist->name);
+               SAFE_FREE(_playlist);
+
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_playlist_clone(media_playlist_h *dst, media_playlist_h src)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_playlist_s *_src = (media_playlist_s*)src;
+
+       media_content_debug_func();
+
+       if(_src != NULL)
+       {
+               media_playlist_s *_dst = (media_playlist_s*)calloc(1, sizeof(media_playlist_s));
+               if(_dst == NULL)
+               {
+                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+               }
+
+               _dst->playlist_id = _src->playlist_id;
+
+               if(STRING_VALID(_src->name))
+               {
+                       _dst->name = strdup(_src->name);
+                       if(_dst->name == NULL)
+                       {
+                               media_playlist_destroy((media_playlist_h)_dst);
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+
+               *dst = (media_playlist_h)_dst;
+
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_playlist_get_playlist_from_db(int playlist_id, filter_h filter, media_playlist_h *playlist)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       sqlite3_stmt *stmt = NULL;
+       char select_query[DEFAULT_QUERY_SIZE];
+
+       if(playlist_id > 0)
+       {
+               memset(select_query, 0x00, sizeof(select_query));
+
+               snprintf(select_query, sizeof(select_query), SELECT_PLAYLIST_FROM_PLAYLIST, playlist_id);
+
+               ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
+               media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+               while(sqlite3_step(stmt) == SQLITE_ROW)
+               {
+                       media_playlist_s *_playlist = (media_playlist_s*)calloc(1, sizeof(media_playlist_s));
+
+                       _playlist->playlist_id = (int)sqlite3_column_int(stmt, 0);
+                       if(STRING_VALID((const char *)sqlite3_column_text(stmt, 1)))
+                               _playlist->name = strdup((const char *)sqlite3_column_text(stmt, 1));
+
+                       *playlist = (media_playlist_h)_playlist;
+               }
+
+               SQLITE3_FINALIZE(stmt);
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_playlist_get_playlist_id(media_playlist_h playlist, int *playlist_id)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       media_playlist_s *_playlist = (media_playlist_s*)playlist;
+
+       if((_playlist != NULL) && (playlist_id != NULL))
+       {
+               *playlist_id = _playlist->playlist_id;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_playlist_get_name(media_playlist_h playlist, char **name)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_playlist_s *_playlist = (media_playlist_s*)playlist;
+       if(_playlist)
+       {
+               if(STRING_VALID(_playlist->name))
+               {
+                       *name = strdup(_playlist->name);
+                       if(*name == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       *name = NULL;
+               }
+
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_playlist_get_play_order(media_playlist_h playlist, int playlist_member_id, int *play_order)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_playlist_s *_playlist = (media_playlist_s*)playlist;
+       int playlist_id = 0;
+       sqlite3_stmt *stmt = NULL;
+       char select_query[DEFAULT_QUERY_SIZE];
+
+       if((_playlist == NULL) || (playlist_member_id < 0) || (play_order == NULL))
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       playlist_id = _playlist->playlist_id;
+
+       memset(select_query, 0x00, sizeof(select_query));
+
+       snprintf(select_query, sizeof(select_query), SELECT_PLAY_ORDER_FROM_PLAYLIST_VIEW, playlist_id, playlist_member_id);
+
+       ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       while(sqlite3_step(stmt) == SQLITE_ROW)
+       {
+               *play_order = (int)sqlite3_column_int(stmt, 0);
+       }
+
+       SQLITE3_FINALIZE(stmt);
+
+       return ret;
+}
+
+int media_playlist_set_name(media_playlist_h playlist, const char *playlist_name)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_playlist_s *_playlist = (media_playlist_s*)playlist;
+
+       if(_playlist != NULL && STRING_VALID(playlist_name))
+       {
+               SAFE_FREE(_playlist->name);
+
+               media_playlist_item_s *item = (media_playlist_item_s*)calloc(1, sizeof(media_playlist_item_s));
+
+               item->playlist_name = strdup(playlist_name);
+               item->function = MEDIA_PLAYLIST_UPDATE_PLAYLIST_NAME;
+               if(item->playlist_name == NULL)
+               {
+                       SAFE_FREE(item);
+                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+               }
+
+               _playlist->name = strdup(playlist_name);
+               if(_playlist->name == NULL)
+               {
+                       SAFE_FREE(item->playlist_name);
+                       SAFE_FREE(item);
+                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+               }
+
+               __media_playlist_item_add(item);
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_playlist_set_play_order(media_playlist_h playlist, int playlist_member_id, int play_order)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_playlist_s *_playlist = (media_playlist_s*)playlist;
+
+       if((_playlist != NULL) && (playlist_member_id > 0) && (play_order >= 0))
+       {
+               media_playlist_item_s *item = (media_playlist_item_s*)calloc(1, sizeof(media_playlist_item_s));
+
+               item->playlist_member_id = playlist_member_id;
+               item->function = MEDIA_PLAYLIST_UPDATE_PLAY_ORDER;
+               item->play_order = play_order;
+
+               __media_playlist_item_add(item);
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_playlist_add_media(media_playlist_h playlist, const char *media_id)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_playlist_s *_playlist = (media_playlist_s*)playlist;
+
+       if(_playlist != NULL && STRING_VALID(media_id))
+       {
+               media_playlist_item_s *item = (media_playlist_item_s*)calloc(1, sizeof(media_playlist_item_s));
+
+               item->media_id = strdup(media_id);
+               item->function = MEDIA_PLAYLIST_ADD;
+
+               if(item->media_id == NULL)
+               {
+                       SAFE_FREE(item);
+                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+               }
+
+               __media_playlist_item_add(item);
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+
+int media_playlist_remove_media(media_playlist_h playlist, int playlist_member_id)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_playlist_s *_playlist = (media_playlist_s*)playlist;
+
+       if((_playlist != NULL) && (playlist_member_id > 0))
+       {
+               media_playlist_item_s *item = (media_playlist_item_s*)calloc(1, sizeof(media_playlist_item_s));
+
+               item->playlist_member_id = playlist_member_id;
+               item->function = MEDIA_PLAYLIST_REMOVE;
+
+               __media_playlist_item_add(item);
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_playlist_update_to_db(media_playlist_h playlist)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_playlist_s *_playlist = (media_playlist_s*)playlist;
+       int idx = 0;
+       int length = 0;
+       media_playlist_item_s *_playlist_item = NULL;
+
+       if(_playlist == NULL)
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       length = g_list_length(g_playlist_item_list);
+
+       for (idx = 0; idx < length; idx++) {
+               _playlist_item = (media_playlist_item_s*)g_list_nth_data(g_playlist_item_list, idx);
+               if(_playlist_item != NULL) {
+                       switch(_playlist_item->function) {
+                               case MEDIA_PLAYLIST_ADD:
+                               {
+                                       ret = __media_playlist_insert_item_to_playlist(_playlist->playlist_id, _playlist_item->media_id);
+                               }
+                               break;
+
+                               case MEDIA_PLAYLIST_REMOVE:
+                               {
+                                       ret = __media_playlist_remove_item_from_playlist(_playlist->playlist_id, _playlist_item->playlist_member_id);
+                               }
+                               break;
+
+                               case MEDIA_PLAYLIST_UPDATE_PLAYLIST_NAME:
+                               {
+                                       ret = __media_playlist_update_playlist_name(_playlist->playlist_id, _playlist_item->playlist_name);
+                               }
+                               break;
+
+                               case MEDIA_PLAYLIST_UPDATE_PLAY_ORDER:
+                               {
+                                       ret = __media_playlist_update_play_order(_playlist->playlist_id, _playlist_item->playlist_member_id, _playlist_item->play_order);
+                               }
+                               break;
+                       }
+               }
+       }
+
+       __media_playlist_item_release();
+
+       return ret;
+}
diff --git a/src/media_tag.c b/src/media_tag.c
new file mode 100755 (executable)
index 0000000..8522023
--- /dev/null
@@ -0,0 +1,556 @@
+/*
+* 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_content.h>
+#include <media_info_private.h>
+
+
+static __thread GList *g_tag_item_list = NULL;
+
+static void __media_tag_item_add(media_tag_item_s *item_s);
+static void __media_tag_item_release(void);
+static int __media_tag_insert_item_to_tag(int tag_id, const char *media_id);
+static int __media_tag_remove_item_from_tag(int tag_id, const char *media_id);
+static int __media_tag_update_tag_name(int tag_id, const char *tag_name);
+static int __media_tag_get_tag_info_from_db(const char *name, media_tag_h tag);
+
+static void __media_tag_item_add(media_tag_item_s *item_s)
+{
+       g_tag_item_list = g_list_append(g_tag_item_list, item_s);
+}
+
+static void __media_tag_item_release(void)
+{
+       int idx = 0;
+       int list_cnt = 0;
+       media_tag_item_s *item = NULL;
+
+       list_cnt = g_list_length(g_tag_item_list);
+
+       media_content_debug("list_cnt : [%d]", list_cnt);
+
+       for(idx = 0; idx < list_cnt; idx++)
+       {
+               item = (media_tag_item_s*)g_list_nth_data(g_tag_item_list, idx);
+               if(item != NULL)
+               {
+                       SAFE_FREE(item->media_id);
+                       SAFE_FREE(item->tag_name);
+                       SAFE_FREE(item);
+               }
+       }
+
+       g_list_free(g_tag_item_list);
+       g_tag_item_list = NULL;
+
+}
+
+static int __media_tag_insert_item_to_tag(int tag_id, const char *media_id)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       char *query_str = NULL;
+
+       query_str = sqlite3_mprintf("INSERT INTO %q (tag_id, media_uuid) values (%d, '%q')",
+                       DB_TABLE_TAG_MAP, tag_id, media_id);
+       ret = _content_query_sql(query_str);
+       sqlite3_free(query_str);
+
+       return ret;
+}
+
+static int __media_tag_remove_item_from_tag(int tag_id, const char *media_id)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       char *query_str = NULL;
+
+       query_str = sqlite3_mprintf(REMOVE_TAG_ITEM_FROM_TAG_MAP, tag_id, media_id);
+
+       ret = _content_query_sql(query_str);
+       sqlite3_free(query_str);
+
+       return ret;
+}
+
+static int __media_tag_update_tag_name(int tag_id, const char *tag_name)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       char *query_str = NULL;
+
+       query_str = sqlite3_mprintf(UPDATE_TAG_NAME_FROM_TAG, tag_name, tag_id);
+
+       ret = _content_query_sql(query_str);
+       sqlite3_free(query_str);
+
+       return ret;
+}
+
+static int __media_tag_get_tag_info_from_db(const char *name, media_tag_h tag)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       sqlite3_stmt *stmt = NULL;
+       char *select_query = NULL;
+       media_tag_s *_tag = (media_tag_s*)tag;
+
+       if(_tag == NULL)
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       select_query = sqlite3_mprintf(SELECT_TAG_BY_NAME, name);
+
+       ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
+       sqlite3_free(select_query);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       while(sqlite3_step(stmt) == SQLITE_ROW)
+       {
+               _tag->tag_id = (int)sqlite3_column_int(stmt,0);
+
+               if(STRING_VALID((const char *)sqlite3_column_text(stmt, 1)))
+               {
+                       _tag->name = strdup((const char *)sqlite3_column_text(stmt, 1));
+               }
+       }
+
+       SQLITE3_FINALIZE(stmt);
+
+       return ret;
+}
+
+int media_tag_insert_to_db(const char *tag_name, media_tag_h *tag)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       char *query_str = NULL;
+
+       if(!STRING_VALID(tag_name))
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       query_str = sqlite3_mprintf(INSERT_TAG_TO_TAG, tag_name);
+       ret = _content_query_sql(query_str);
+       sqlite3_free(query_str);
+
+       if(ret == MEDIA_CONTENT_ERROR_NONE)
+       {
+               media_tag_s *_tag = (media_tag_s*)calloc(1, sizeof(media_tag_s));
+               if(_tag == NULL)
+               {
+                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+               }
+
+               ret = __media_tag_get_tag_info_from_db(tag_name, (media_tag_h)_tag);
+               *tag = (media_tag_h)_tag;
+       }
+
+       return ret;
+}
+
+int media_tag_delete_from_db(int tag_id)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       char *query_str = NULL;
+
+       if(tag_id < 0)
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       query_str = sqlite3_mprintf(DELETE_TAG_FROM_TAG, tag_id);
+
+       ret = _content_query_sql(query_str);
+
+       sqlite3_free(query_str);
+
+       return ret;
+}
+
+int media_tag_get_tag_count_from_db(filter_h filter, int *tag_count)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       media_content_debug_func();
+
+       if(tag_count != NULL)
+       {
+               ret = _media_db_get_group_count(filter, MEDIA_GROUP_TAG, tag_count);
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_tag_foreach_tag_from_db (filter_h filter, media_tag_cb callback, void *user_data)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       media_content_debug_func();
+
+       if(callback == NULL)
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _media_db_get_tag(NULL, filter, callback, user_data);
+
+       return ret;
+}
+
+int media_tag_get_media_count_from_db(int tag_id, filter_h filter, int *media_count)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       media_content_debug_func();
+
+       if((tag_id > 0) && (media_count != NULL))
+       {
+               ret = _media_db_get_group_item_count_by_id(tag_id, filter, MEDIA_GROUP_TAG, media_count);
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_tag_foreach_media_from_db(int tag_id, filter_h filter, media_info_cb callback, void *user_data)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       media_content_debug_func();
+
+       if(callback == NULL)
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       ret = _media_db_get_group_item_by_id(tag_id, filter, callback, user_data, MEDIA_GROUP_TAG);
+
+       return ret;
+}
+
+int media_tag_destroy(media_tag_h tag)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_tag_s *_tag = (media_tag_s*)tag;
+       if(_tag)
+       {
+               SAFE_FREE(_tag->name);
+               SAFE_FREE(_tag);
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+int media_tag_clone(media_tag_h *dst, media_tag_h src)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_tag_s *_src = (media_tag_s*)src;
+       media_tag_s *_dst = NULL;
+
+       if((_src != NULL))
+       {
+               _dst = (media_tag_s*)calloc(1, sizeof(media_tag_s));
+
+               if(_dst == NULL)
+               {
+                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+               }
+
+               _dst->tag_id = _src->tag_id;
+
+               if(STRING_VALID(_src->name))
+               {
+                       _dst->name = strdup(_src->name);
+                       if(_dst->name == NULL)
+                       {
+                               SAFE_FREE(_dst);
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               *dst = (media_tag_h)_dst;
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_tag_get_tag_id(media_tag_h tag, int *tag_id)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_tag_s *_tag = (media_tag_s*)tag;
+
+       if((_tag != NULL) && (tag_id != NULL))
+       {
+               *tag_id = _tag->tag_id;
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_tag_get_name(media_tag_h tag, char **name)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_tag_s *_tag = (media_tag_s*)tag;
+       if(_tag)
+       {
+               if(STRING_VALID(_tag->name))
+               {
+                       *name = strdup(_tag->name);
+                       if(*name == NULL)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+               else
+               {
+                       *name = NULL;
+               }
+               ret = MEDIA_CONTENT_ERROR_NONE;
+
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_tag_get_tag_from_db(int tag_id, media_tag_h *tag)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       sqlite3_stmt *stmt = NULL;
+       char select_query[DEFAULT_QUERY_SIZE];
+
+       if(tag_id <= 0)
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       memset(select_query, 0x00, sizeof(select_query));
+
+       snprintf(select_query, sizeof(select_query), SELECT_TAG_FROM_TAG, tag_id);
+
+       ret = _content_query_prepare(&stmt, select_query, NULL, NULL);
+       media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret);
+
+       while(sqlite3_step(stmt) == SQLITE_ROW)
+       {
+               media_tag_s *_tag = (media_tag_s*)calloc(1, sizeof(media_tag_s));
+
+               if(_tag == NULL)
+               {
+                       SQLITE3_FINALIZE(stmt);
+                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+               }
+
+               _tag->tag_id = (int)sqlite3_column_int(stmt, 0);
+
+               if(STRING_VALID((const char *)sqlite3_column_text(stmt, 1)))
+               {
+                       _tag->name = strdup((const char *)sqlite3_column_text(stmt, 1));
+               }
+
+               *tag = (media_tag_h)_tag;
+       }
+
+       SQLITE3_FINALIZE(stmt);
+
+       return ret;
+}
+
+int media_tag_add_media(media_tag_h tag, const char *media_id)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_tag_s *_tag = (media_tag_s*)tag;
+
+       if((_tag != NULL) && STRING_VALID(media_id))
+       {
+               media_tag_item_s *_item = (media_tag_item_s*)calloc(1, sizeof(media_tag_item_s));
+
+               _item->media_id = strdup(media_id);
+               _item->function = MEDIA_TAG_ADD;
+
+               if(_item->media_id == NULL)
+               {
+                       SAFE_FREE(_item);
+                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+               }
+
+               __media_tag_item_add(_item);
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_tag_remove_media(media_tag_h tag, const char *media_id)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_tag_s *_tag = (media_tag_s*)tag;
+
+       if(_tag != NULL && STRING_VALID(media_id))
+       {
+               media_tag_item_s *_item = (media_tag_item_s*)calloc(1, sizeof(media_tag_item_s));
+
+               _item->media_id = strdup(media_id);
+               _item->function = MEDIA_TAG_REMOVE;
+
+               if(_item->media_id == NULL)
+               {
+                       SAFE_FREE(_item);
+                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+               }
+
+               __media_tag_item_add(_item);
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_tag_set_name(media_tag_h tag, char *tag_name)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_tag_s *_tag = (media_tag_s*)tag;
+
+       if(_tag != NULL && STRING_VALID(tag_name))
+       {
+               SAFE_FREE(_tag->name);
+
+               media_tag_item_s *_item = (media_tag_item_s*)calloc(1, sizeof(media_tag_item_s));
+
+               _item->tag_name = strdup(tag_name);
+               _item->function = MEDIA_TAG_UPDATE_TAG_NAME;
+
+               if(_item->tag_name == NULL)
+               {
+                       SAFE_FREE(_item);
+                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+               }
+
+               _tag->name = strdup(tag_name);
+               if(_tag->name == NULL)
+               {
+                       SAFE_FREE(_item->tag_name);
+                       SAFE_FREE(_item);
+                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+               }
+
+               __media_tag_item_add(_item);
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int media_tag_update_to_db(media_tag_h tag)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_tag_s *_tag = (media_tag_s*)tag;
+       int idx = 0;
+       int length = 0;
+       media_tag_item_s *_tag_item = NULL;
+
+       if(_tag == NULL)
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       length = g_list_length(g_tag_item_list);
+
+       for (idx = 0; idx < length; idx++) {
+               _tag_item = (media_tag_item_s*)g_list_nth_data(g_tag_item_list, idx);
+               if(_tag_item != NULL) {
+                       switch(_tag_item->function) {
+                               case MEDIA_TAG_ADD:
+                               {
+                                       ret = __media_tag_insert_item_to_tag(_tag->tag_id, _tag_item->media_id);
+                               }
+                               break;
+
+                               case MEDIA_TAG_REMOVE:
+                               {
+                                       ret = __media_tag_remove_item_from_tag(_tag->tag_id, _tag_item->media_id);
+                               }
+                               break;
+
+                               case MEDIA_TAG_UPDATE_TAG_NAME:
+                               {
+                                       ret = __media_tag_update_tag_name(_tag->tag_id, _tag_item->tag_name);
+                               }
+                               break;
+                       }
+               }
+       }
+
+       __media_tag_item_release();
+
+       return ret;
+}
diff --git a/src/media_util_private.c b/src/media_util_private.c
new file mode 100755 (executable)
index 0000000..10d518f
--- /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.
+*/
+
+
+#include <string.h>
+#include <sys/stat.h>
+#include <media_util_private.h>
+#include <media_info_private.h>
+#include <media_content_type.h>
+
+
+int _media_util_get_store_type_by_path(const char *path, int *storage_type)
+{
+       if(STRING_VALID(path))
+       {
+               if(strncmp(path, MEDIA_CONTENT_PATH_PHONE, strlen(MEDIA_CONTENT_PATH_PHONE)) == 0)
+               {
+                       *storage_type = MEDIA_CONTENT_STORAGE_INTERNAL;
+               }
+               else if(strncmp (path, MEDIA_CONTENT_PATH_MMC, strlen(MEDIA_CONTENT_PATH_MMC)) == 0)
+               {
+                       *storage_type = MEDIA_CONTENT_STORAGE_EXTERNAL;
+               }
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return MEDIA_CONTENT_ERROR_NONE;
+}
diff --git a/src/media_video.c b/src/media_video.c
new file mode 100755 (executable)
index 0000000..e8aa927
--- /dev/null
@@ -0,0 +1,727 @@
+/*
+* 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_content.h>
+#include <media_info_private.h>
+#include <media-svc.h>
+
+
+int video_meta_destroy(video_meta_h video)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       video_meta_s *_video = (video_meta_s*)video;
+
+       if(_video)
+       {
+               SAFE_FREE(_video->media_id);
+               SAFE_FREE(_video->title);
+               SAFE_FREE(_video->album);
+               SAFE_FREE(_video->artist);
+               SAFE_FREE(_video->genre);
+               SAFE_FREE(_video->composer);
+               SAFE_FREE(_video->year);
+               SAFE_FREE(_video->recorded_date);
+               SAFE_FREE(_video->copyright);
+               SAFE_FREE(_video->track_num);
+               SAFE_FREE(_video);
+
+               SAFE_FREE(_video);
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int video_meta_clone(video_meta_h *dst, video_meta_h src)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       video_meta_s *_src = (video_meta_s*)src;
+
+       if(_src != NULL)
+       {
+               video_meta_s *_dst = (video_meta_s*)calloc(1, sizeof(video_meta_s));
+
+               if(_dst == NULL)
+               {
+
+                       media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                       return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+               }
+
+               if(STRING_VALID(_src->media_id))
+               {
+                       _dst->media_id = strdup(_src->media_id);
+                       if(_dst->media_id == NULL)
+                       {
+                               video_meta_destroy((video_meta_h)_dst);
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+
+               if(STRING_VALID(_src->title))
+               {
+                       _dst->title = strdup(_src->title);
+                       if(_dst->title == NULL)
+                       {
+                               video_meta_destroy((video_meta_h)_dst);
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+
+               if(STRING_VALID(_src->album))
+               {
+                       _dst->album = strdup(_src->album);
+                       if(_dst->album == NULL)
+                       {
+                               video_meta_destroy((video_meta_h)_dst);
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+
+               if(STRING_VALID(_src->artist))
+               {
+                       _dst->artist = strdup(_src->artist);
+                       if(_dst->artist == NULL)
+                       {
+                               video_meta_destroy((video_meta_h)_dst);
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+
+               if(STRING_VALID(_src->genre))
+               {
+                       _dst->genre = strdup(_src->genre);
+                       if(_dst->genre == NULL)
+                       {
+                               video_meta_destroy((video_meta_h)_dst);
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+
+               if(STRING_VALID(_src->composer))
+               {
+                       _dst->composer = strdup(_src->composer);
+                       if(_dst->composer == NULL)
+                       {
+                               video_meta_destroy((video_meta_h)_dst);
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+
+               if(STRING_VALID(_src->year))
+               {
+                       _dst->year = strdup(_src->year);
+                       if(_dst->year == NULL)
+                       {
+                               video_meta_destroy((video_meta_h)_dst);
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+
+               if(STRING_VALID(_src->recorded_date))
+               {
+                       _dst->recorded_date = strdup(_src->recorded_date);
+                       if(_dst->recorded_date == NULL)
+                       {
+                               video_meta_destroy((video_meta_h)_dst);
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+
+               if(STRING_VALID(_src->copyright))
+               {
+                       _dst->copyright = strdup(_src->copyright);
+                       if(_dst->copyright == NULL)
+                       {
+                               video_meta_destroy((video_meta_h)_dst);
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+
+               if(STRING_VALID(_src->track_num))
+               {
+                       _dst->track_num = strdup(_src->track_num);
+                       if(_dst->track_num == NULL)
+                       {
+                               video_meta_destroy((video_meta_h)_dst);
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+               }
+
+               _dst->bitrate = _src->bitrate;
+               _dst->duration = _src->duration;
+               _dst->width = _src->width;
+               _dst->height = _src->height;
+               _dst->played_count = _src->played_count;
+               _dst->played_time = _src->played_time;
+               _dst->played_position = _src->played_position;
+
+               *dst = (video_meta_h)_dst;
+
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int video_meta_get_media_id(video_meta_h video, char **media_id)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       video_meta_s *_video = (video_meta_s*)video;
+       if(_video)
+       {
+               if(STRING_VALID(_video->media_id))
+               {
+                       char *new_string = strdup(_video->media_id);
+                       if(NULL == new_string)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+                       *media_id = new_string;
+               }
+               else
+               {
+                       *media_id = NULL;
+               }
+               ret = MEDIA_CONTENT_ERROR_NONE;
+
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int video_meta_get_title(video_meta_h video, char **title)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       video_meta_s *_video = (video_meta_s*)video;
+       if(_video)
+       {
+               if(STRING_VALID(_video->title))
+               {
+                       char *new_string = strdup(_video->title);
+                       if(NULL == new_string)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+                       *title = new_string;
+               }
+               else
+               {
+                       *title = NULL;
+               }
+               ret = MEDIA_CONTENT_ERROR_NONE;
+
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int video_meta_get_album(video_meta_h video, char **album)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       video_meta_s *_video = (video_meta_s*)video;
+       if(_video)
+       {
+               if(STRING_VALID(_video->album))
+               {
+                       char *new_string = strdup(_video->album);
+                       if(NULL == new_string)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+                       *album = new_string;
+               }
+               else
+               {
+                       *album = NULL;
+               }
+               ret = MEDIA_CONTENT_ERROR_NONE;
+
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+
+}
+int video_meta_get_artist(video_meta_h video, char **artist)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       video_meta_s *_video = (video_meta_s*)video;
+       if(_video)
+       {
+               if(STRING_VALID(_video->artist))
+               {
+                       char *new_string = strdup(_video->artist);
+                       if(NULL == new_string)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+                       *artist = new_string;
+               }
+               else
+               {
+                       *artist = NULL;
+               }
+               ret = MEDIA_CONTENT_ERROR_NONE;
+
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+
+}
+
+int video_meta_get_genre(video_meta_h video, char **genre)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       video_meta_s *_video = (video_meta_s*)video;
+       if(_video)
+       {
+               if(STRING_VALID(_video->genre))
+               {
+                       char *new_string = strdup(_video->genre);
+                       if(NULL == new_string)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+                       *genre = new_string;
+               }
+               else
+               {
+                       *genre = NULL;
+               }
+
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int video_meta_get_composer(video_meta_h video, char **composer)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       video_meta_s *_video = (video_meta_s*)video;
+       if(_video)
+       {
+               if(STRING_VALID(_video->composer))
+               {
+                       char *new_string = strdup(_video->composer);
+                       if(NULL == new_string)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+                       *composer = new_string;
+               }
+               else
+               {
+                       *composer = NULL;
+               }
+
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int video_meta_get_year(video_meta_h video, char **year)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       video_meta_s *_video = (video_meta_s*)video;
+       if(_video)
+       {
+               if(STRING_VALID(_video->year))
+               {
+                       char *new_string = strdup(_video->year);
+                       if(NULL == new_string)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+                       *year = new_string;
+               }
+               else
+               {
+                       *year = NULL;
+               }
+
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int video_meta_get_recorded_date(video_meta_h video, char **recorded_date)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       video_meta_s *_video = (video_meta_s*)video;
+       if(_video)
+       {
+               if(STRING_VALID(_video->recorded_date))
+               {
+                       char *new_string = strdup(_video->recorded_date);
+                       if(NULL == new_string)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+                       *recorded_date = new_string;
+               }
+               else
+               {
+                       *recorded_date = NULL;
+               }
+
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int video_meta_get_copyright(video_meta_h video, char **copyright)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       video_meta_s *_video = (video_meta_s*)video;
+       if(_video)
+       {
+               if(STRING_VALID(_video->copyright))
+               {
+                       char *new_string = strdup(_video->copyright);
+                       if(NULL == new_string)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+                       *copyright = new_string;
+               }
+               else
+               {
+                       *copyright = NULL;
+               }
+
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int video_meta_get_track_num(video_meta_h video, char **track_num)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       video_meta_s *_video = (video_meta_s*)video;
+       if(_video)
+       {
+               if(STRING_VALID(_video->track_num))
+               {
+                       char *new_string = strdup(_video->track_num);
+                       if(NULL == new_string)
+                       {
+                               media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
+                               return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
+                       }
+                       *track_num = new_string;
+               }
+               else
+               {
+                       *track_num = NULL;
+               }
+
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int video_meta_get_bit_rate(video_meta_h video, int *bit_rate)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       video_meta_s *_video = (video_meta_s*)video;
+
+       if(_video && bit_rate)
+       {
+               *bit_rate = _video->bitrate;
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int video_meta_get_duration(video_meta_h video, int *duration)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       video_meta_s *_video = (video_meta_s*)video;
+
+       if(_video && duration)
+       {
+               *duration = _video->duration;
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int video_meta_get_width(video_meta_h video, int *width)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       video_meta_s *_video = (video_meta_s*)video;
+
+       if(_video && width)
+       {
+               *width = _video->width;
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int video_meta_get_height(video_meta_h video, int *height)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       video_meta_s *_video = (video_meta_s*)video;
+       if(_video && height)
+       {
+               *height = _video->height;
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int video_meta_get_played_count(video_meta_h video, int *played_count)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       video_meta_s *_video = (video_meta_s*)video;
+
+       if(_video && played_count)
+       {
+               *played_count = _video->played_count;
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int video_meta_get_played_time(video_meta_h video, time_t* played_time)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       video_meta_s *_video = (video_meta_s*)video;
+
+       if(_video)
+       {
+               *played_time = _video->played_time;
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int video_meta_get_played_position(video_meta_h video, int *played_position)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       video_meta_s *_video = (video_meta_s*)video;
+
+       if(_video)
+       {
+               *played_position = _video->played_position;
+               ret = MEDIA_CONTENT_ERROR_NONE;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int video_meta_set_played_count(video_meta_h video, int played_count)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       video_meta_s *_video = (video_meta_s*)video;
+
+       if(_video != NULL)
+       {
+               _video->played_count = played_count;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int video_meta_set_played_time(video_meta_h video, time_t played_time)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       video_meta_s *_video = (video_meta_s*)video;
+
+       if(_video != NULL)
+       {
+               _video->played_time = played_time;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int video_meta_set_played_position(video_meta_h video, int played_position)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       video_meta_s *_video = (video_meta_s*)video;
+
+       if(_video != NULL)
+       {
+               _video->played_position = played_position;
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
+
+int video_meta_update_to_db(video_meta_h video)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       video_meta_s *_video = (video_meta_s*)video;
+       char *sql = NULL;
+
+       if(_video != NULL && STRING_VALID(_video->media_id))
+       {
+               sql = sqlite3_mprintf(UPDATE_AV_META_FROM_MEDIA, _video->played_count, _video->played_time, _video->played_position, _video->media_id);
+               ret = _content_query_sql(sql);
+               sqlite3_free(sql);
+       }
+       else
+       {
+               media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
+               ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
+       }
+
+       return ret;
+}
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
new file mode 100755 (executable)
index 0000000..7097377
--- /dev/null
@@ -0,0 +1,18 @@
+SET(fw_name "capi-content-media-content")
+SET(fw_test "${fw_name}-test")
+
+INCLUDE(FindPkgConfig)
+pkg_check_modules(${fw_test} REQUIRED glib-2.0 dlog libmedia-service capi-base-common libmedia-utils)
+FOREACH(flag ${${fw_test}_CFLAGS})
+    SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall")
+
+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/media-content_test.c b/test/media-content_test.c
new file mode 100755 (executable)
index 0000000..86c0f59
--- /dev/null
@@ -0,0 +1,2769 @@
+/*
+* 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 <sys/time.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <media_content.h>
+#include <media_info_private.h>
+#include <dlog.h>
+#include <pthread.h>
+#include <glib.h>
+
+filter_h g_filter = NULL;
+filter_h g_filter_g = NULL;    //filter for group like folder, tag, playlist, album, year ...
+
+GMainLoop *g_loop = NULL;
+static int g_cnt = 0;
+static int g_media_cnt = 0;
+
+#define test_audio_id  "0f999626-6218-450c-a4ad-181a3bab6ebf"
+#define test_video_id  "c1a92494-cc5b-4d74-aa7d-253199234548"
+#define test_image_id "db1c184c-6f31-43b4-b924-8c00ac5b6197"
+
+bool get_audio_meta(audio_meta_h audio)
+{
+       char *c_value = NULL;
+       int i_value = 0;
+       time_t t_value = 0;
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       media_content_debug("=== audio meta ===");
+
+       ret = audio_meta_get_media_id(audio, &c_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get meta : [%d]", ret);
+       media_content_debug("audio_id : [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = audio_meta_get_title(audio, &c_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get meta : [%d]", ret);
+       media_content_debug("title : [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = audio_meta_get_album(audio, &c_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get meta : [%d]", ret);
+       media_content_debug("album : [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = audio_meta_get_artist(audio, &c_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get meta : [%d]", ret);
+       media_content_debug("artist : [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = audio_meta_get_genre(audio, &c_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get meta : [%d]", ret);
+       media_content_debug("genre : [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = audio_meta_get_composer(audio, &c_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get meta : [%d]", ret);
+       media_content_debug("composer : [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = audio_meta_get_year(audio, &c_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get meta : [%d]", ret);
+       media_content_debug("year : [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = audio_meta_get_recorded_date(audio, &c_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get meta : [%d]", ret);
+       media_content_debug("recorded_date : [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = audio_meta_get_copyright(audio, &c_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get meta : [%d]", ret);
+       media_content_debug("copyright : [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = audio_meta_get_track_num(audio, &c_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get meta : [%d]", ret);
+       media_content_debug("track_num : [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = audio_meta_get_bit_rate(audio, &i_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get meta : [%d]", ret);
+       media_content_debug("bitrate : [%d]", i_value);
+
+       ret = audio_meta_get_sample_rate(audio, &i_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get meta : [%d]", ret);
+       media_content_debug("samplerate : [%d]", i_value);
+
+       ret = audio_meta_get_channel(audio, &i_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get meta : [%d]", ret);
+       media_content_debug("channel : [%d]", i_value);
+
+       ret = audio_meta_get_duration(audio, &i_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get meta : [%d]", ret);
+       media_content_debug("duration : [%d]", i_value);
+
+       ret = audio_meta_get_played_count(audio, &i_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get meta : [%d]", ret);
+       media_content_debug("played_count : [%d]", i_value);
+
+       ret = audio_meta_get_played_time(audio, &t_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get meta : [%d]", ret);
+       media_content_debug("played_time : [%d]", t_value);
+
+       ret = audio_meta_get_played_position(audio, &i_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get meta : [%d]", ret);
+       media_content_debug("played_position : [%d]", i_value);
+
+       return true;
+}
+
+bool get_video_meta(video_meta_h video)
+{
+       char *c_value = NULL;
+       int i_value = 0;
+       time_t t_value = 0;
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       media_content_debug("=== video meta ===");
+
+       ret = video_meta_get_media_id(video, &c_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get meta : [%d]", ret);
+       media_content_debug("video_id : [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = video_meta_get_title(video, &c_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get meta : [%d]", ret);
+       media_content_debug("title : [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = video_meta_get_album(video, &c_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get meta : [%d]", ret);
+       media_content_debug("album : [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = video_meta_get_artist(video, &c_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get meta : [%d]", ret);
+       media_content_debug("artist : [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = video_meta_get_genre(video, &c_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get meta : [%d]", ret);
+       media_content_debug("genre : [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = video_meta_get_composer(video, &c_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get meta : [%d]", ret);
+       media_content_debug("omposer : [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = video_meta_get_year(video, &c_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get meta : [%d]", ret);
+       media_content_debug("year : [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = video_meta_get_recorded_date(video, &c_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get meta : [%d]", ret);
+       media_content_debug("recorded_date : [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = video_meta_get_copyright(video, &c_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get meta : [%d]", ret);
+       media_content_debug("copyright : [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = video_meta_get_track_num(video, &c_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get meta : [%d]", ret);
+       media_content_debug("track_num : [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = video_meta_get_bit_rate(video, &i_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get meta : [%d]", ret);
+       media_content_debug("bitrate : [%d]", i_value);
+
+       ret = video_meta_get_duration(video, &i_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get meta : [%d]", ret);
+       media_content_debug("duration : [%d]", i_value);
+
+       ret = video_meta_get_width(video, &i_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get meta : [%d]", ret);
+       media_content_debug("width : [%d]", i_value);
+
+       ret = video_meta_get_height(video, &i_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get meta : [%d]", ret);
+       media_content_debug("height : [%d]", i_value);
+
+       ret = video_meta_get_played_count(video, &i_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get meta : [%d]", ret);
+       media_content_debug("played_count : [%d]", i_value);
+
+       ret = video_meta_get_played_time(video, &t_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get meta : [%d]", ret);
+       media_content_debug("played_time : [%d]", t_value);
+
+       ret = video_meta_get_played_position(video, &i_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get meta : [%d]", ret);
+       media_content_debug("played_position : [%d]", i_value);
+
+       return true;
+}
+
+bool gallery_folder_list_cb(media_folder_h folder, void *user_data)
+{
+       media_folder_h new_folder = NULL;
+       media_folder_clone(&new_folder, folder);
+
+       GList **list = (GList**)user_data;
+       *list = g_list_append(*list, new_folder);
+
+       return true;
+}
+
+bool gallery_media_item_cb(media_info_h media, void *user_data)
+{
+       media_info_h new_media = NULL;
+       media_info_clone(&new_media, media);
+
+       GList **list = (GList**)user_data;
+       *list = g_list_append(*list, new_media);
+
+       return true;
+}
+
+bool gallery_tag_item_cb(media_tag_h tag, void *user_data)
+{
+       media_tag_h new_tag = NULL;
+       media_tag_clone(&new_tag, tag);
+
+       GList **list = (GList**)user_data;
+       *list = g_list_append(*list, new_tag);
+
+       return true;
+}
+
+bool gallery_bookmarks_cb(media_bookmark_h bookmark, void *user_data)
+{
+       media_bookmark_h new_bm = NULL;
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       ret = media_bookmark_clone(&new_bm, bookmark);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_bookmark_clone : [%d]", ret);
+
+       GList **list = (GList**)user_data;
+       *list = g_list_append(*list, new_bm);
+
+       return true;
+}
+
+bool media_item_cb(media_info_h media, void *user_data)
+{
+       char *c_value = NULL;
+       char *media_id = NULL;
+       int i_value = 0;
+       time_t t_value = 0;
+       bool b_value = false;
+       media_content_type_e media_type = 0;
+       unsigned long long size = 0;
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       if(media == NULL)
+       {
+               media_content_debug("NO Item");
+               return true;
+       }
+
+       ret = media_info_get_media_type(media, &media_type);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get info : [%d]", ret);
+       media_content_debug("media_type : [%d]", media_type);
+
+       ret = media_info_get_media_id(media, &media_id);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get info : [%d]", ret);
+       media_content_debug("media_id : [%s]", media_id);
+
+#if 1
+       if(media_type == MEDIA_CONTENT_TYPE_MUSIC)
+       {
+               audio_meta_h audio;
+
+               if(media_info_get_audio(media, &audio) == MEDIA_CONTENT_ERROR_NONE)
+               {
+                       get_audio_meta(audio);
+                       ret = audio_meta_destroy(audio);
+                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                               media_content_error("error audio_meta_destroy : [%d]", ret);
+               }
+               else
+                       media_content_error("[audio_error]");
+
+       }
+       else if(media_type == MEDIA_CONTENT_TYPE_IMAGE)
+       {
+               image_meta_h image;
+               media_content_orientation_e orientation = 0;
+
+               if(media_info_get_image(media, &image) == MEDIA_CONTENT_ERROR_NONE)
+               {
+                       ret = image_meta_get_orientation(image, &orientation);
+                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                               media_content_error("error image_meta_get_orientation : [%d]", ret);
+                       else
+                               media_content_debug("[image] orientation : %d", orientation);
+
+                       ret = image_meta_destroy(image);
+                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                               media_content_error("error image_meta_destroy : [%d]", ret);
+               }
+               else
+                       media_content_error("[image_error]");
+
+       }
+       else if(media_type == MEDIA_CONTENT_TYPE_VIDEO)
+       {
+               video_meta_h video;
+
+               if(media_info_get_video(media, &video) == MEDIA_CONTENT_ERROR_NONE)
+               {
+                       get_video_meta(video);
+                       ret = video_meta_destroy(video);
+                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                               media_content_error("error video_meta_destroy : [%d]", ret);
+               }
+               else
+                       media_content_error("[video_error]");
+
+       }
+       else
+       {
+               media_content_debug("Other Content");
+       }
+
+       media_content_debug("=== media_info ===");
+       ret = media_info_get_file_path(media, &c_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get info : [%d]", ret);
+       media_content_debug("file_path : [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = media_info_get_display_name(media, &c_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get info : [%d]", ret);
+       media_content_debug("display_name : [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = media_info_get_mime_type(media, &c_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get info : [%d]", ret);
+       media_content_debug("mime_type : [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = media_info_get_thumbnail_path(media, &c_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get info : [%d]", ret);
+       media_content_debug("thumbnail_path : [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = media_info_get_description(media, &c_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get info : [%d]", ret);
+       media_content_debug("description : [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = media_info_get_author(media, &c_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get info : [%d]", ret);
+       media_content_debug("author : [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = media_info_get_provider(media, &c_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get info : [%d]", ret);
+       media_content_debug("provider : [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = media_info_get_content_name(media, &c_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get info : [%d]", ret);
+       media_content_debug("content_name : [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = media_info_get_category(media, &c_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get info : [%d]", ret);
+       media_content_debug("category : [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = media_info_get_location_tag(media, &c_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get info : [%d]", ret);
+       media_content_debug("location_tag : [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = media_info_get_age_rating(media, &c_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get info : [%d]", ret);
+       media_content_debug("age_rating : [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = media_info_get_keyword(media, &c_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get info : [%d]", ret);
+       media_content_debug("keyword : [%s]", c_value);
+       SAFE_FREE(c_value);
+
+       ret = media_info_get_size(media, &size);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get info : [%d]", ret);
+       media_content_debug("size : [%lld]", size);
+
+       ret = media_info_get_added_time(media, &t_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get info : [%d]", ret);
+       media_content_debug("added_time : [%d]", t_value);
+
+       ret = media_info_get_modified_time(media, &t_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get info : [%d]", ret);
+       media_content_debug("modified_time : [%d]", t_value);
+
+       ret = media_info_get_rating(media, &i_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get info : [%d]", ret);
+       media_content_debug("rating : [%d]", i_value);
+
+       ret = media_info_get_favorite(media, &b_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get info : [%d]", ret);
+       media_content_debug("favorite : [%d]", b_value);
+
+       ret = media_info_is_drm(media, &b_value);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error when get info : [%d]", ret);
+       media_content_debug("is_drm : [%d]", b_value);
+
+       /* Media server can't update when another db handle holds DB connection by sqlite3_prepare */
+       //ret = media_info_set_location_tag(media, "Test location tag");
+       //media_info_update_to_db(media);
+       SAFE_FREE(media_id);
+#endif
+       return true;
+}
+
+bool folder_list_cb(media_folder_h folder, void *user_data)
+{
+       int item_count;
+       char *folder_id = NULL;
+       char *folder_path = NULL;
+       char *folder_name = NULL;
+       media_content_storage_e storage_type;
+       bool ret;
+       media_folder_h *_folder = (media_folder_h*)user_data;
+
+       if(folder != NULL)
+       {
+               media_folder_clone(_folder, folder);
+
+               if(media_folder_get_folder_id(folder, &folder_id) != MEDIA_CONTENT_ERROR_NONE)
+               {
+                       media_content_error("[ERROR] media_folder_get_folder_id is failed");
+                       return false;
+               }
+               media_content_debug("folder_id = [%s]", folder_id);
+
+               if(media_folder_get_path(folder, &folder_path) != MEDIA_CONTENT_ERROR_NONE)
+               {
+                       SAFE_FREE(folder_id);
+                       media_content_error("[ERROR] media_folder_get_path is failed");
+                       return false;
+               }
+               media_content_debug("folder_path = [%s]", folder_path);
+               SAFE_FREE(folder_path);
+
+               if(media_folder_get_name(folder, &folder_name) != MEDIA_CONTENT_ERROR_NONE)
+               {
+                       SAFE_FREE(folder_id);
+                       SAFE_FREE(folder_path);
+                       media_content_error("[ERROR] media_folder_get_name is failed");
+                       return false;
+               }
+               media_content_debug("folder_name = [%s]", folder_name);
+               SAFE_FREE(folder_name);
+
+               if(media_folder_get_storage_type(folder, &storage_type) != MEDIA_CONTENT_ERROR_NONE)
+               {
+                       SAFE_FREE(folder_id);
+                       SAFE_FREE(folder_path);
+                       SAFE_FREE(folder_name);
+                       media_content_error("[ERROR] media_folder_get_storage_type is failed");
+                       return false;
+               }
+               media_content_debug("storage_type = [%d]", storage_type);
+
+               if(media_folder_get_media_count_from_db(folder_id, g_filter, &item_count) != MEDIA_CONTENT_ERROR_NONE)
+               {
+                       SAFE_FREE(folder_id);
+                       SAFE_FREE(folder_path);
+                       SAFE_FREE(folder_name);
+                       media_content_error("[ERROR] media_folder_get_media_count_from_db is failed");
+                       return false;
+               }
+
+               if(media_folder_foreach_media_from_db(folder_id, g_filter, media_item_cb, NULL) != MEDIA_CONTENT_ERROR_NONE)
+               {
+                       SAFE_FREE(folder_id);
+                       SAFE_FREE(folder_path);
+                       SAFE_FREE(folder_name);
+                       media_content_error("[ERROR] media_folder_foreach_media_from_db is failed");
+                       return false;
+               }
+
+               SAFE_FREE(folder_id);
+               SAFE_FREE(folder_path);
+               SAFE_FREE(folder_name);
+
+               ret = true;
+       }
+       else
+       {
+               ret = false;
+       }
+
+       return ret;
+}
+
+bool test_album_from_db(int album_id)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_album_h album_h;
+       int test_album_id = 0;
+       char *album_name = NULL;
+       char *artist = NULL;
+
+       ret = media_album_get_album_from_db(album_id, &album_h);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+       {
+               media_content_error("error when get album");
+               return false;
+       }
+
+       if(media_album_get_album_id(album_h, &test_album_id) != MEDIA_CONTENT_ERROR_NONE)
+       {
+               media_album_destroy(album_h);
+               return false;
+       }
+
+       media_content_debug("test_album_id : [%d]", test_album_id);
+
+       if(media_album_get_name(album_h, &album_name) != MEDIA_CONTENT_ERROR_NONE)
+       {
+               media_album_destroy(album_h);
+               return false;
+       }
+
+       media_content_debug("album_name : [%s]", album_name);
+
+       if(media_album_get_artist(album_h, &artist) != MEDIA_CONTENT_ERROR_NONE)
+       {
+               media_album_destroy(album_h);
+               return false;
+       }
+
+       media_content_debug("artist : [%s]", artist);
+
+       SAFE_FREE(album_name);
+       SAFE_FREE(artist);
+
+       media_album_destroy(album_h);
+
+       return true;
+}
+
+bool playlist_list_cb(media_playlist_h playlist, void *user_data)
+{
+       int playlist_id = 0;
+       char *playlist_name = NULL;
+       media_playlist_h playlist_h;
+
+       media_content_debug("playlist_list_cb ======");
+
+       GList **list = (GList**)user_data;
+
+       if(playlist == NULL)
+       {
+               media_content_debug(" playlist handle is NULL");
+               return false;
+       }
+
+       media_playlist_get_playlist_id(playlist, &playlist_id);
+       media_content_debug("playlist_id : %d", playlist_id);
+
+       if(user_data != NULL)
+               *list = g_list_append(*list, (gpointer)playlist_id);
+
+       media_playlist_get_name(playlist, &playlist_name);
+       media_content_debug("playlist_name : %s", playlist_name);
+       SAFE_FREE(playlist_name);
+
+       media_playlist_get_playlist_from_db(playlist_id, NULL, &playlist_h);
+
+       media_playlist_destroy(playlist_h);
+
+       return true;
+}
+
+bool tag_list_cb(media_tag_h tag, void *user_data)
+{
+       int tag_id = 0;
+       char *tag_name = NULL;
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       if(tag == NULL)
+       {
+               media_content_debug(" tag handle is NULL");
+               return false;
+       }
+
+       ret = media_tag_get_tag_id(tag, &tag_id);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_tag_get_tag_id : [%d]", ret);
+       else
+               media_content_debug("tag_id : %d", tag_id);
+
+       ret = media_tag_get_name(tag, &tag_name);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_tag_get_name : [%d]", ret);
+       else
+               media_content_debug("tag_name : %s", tag_name);
+       SAFE_FREE(tag_name);
+
+       return true;
+}
+
+bool bookmarks_cb(media_bookmark_h bookmark, void *user_data)
+{
+       media_bookmark_h *_bookmark = (media_bookmark_h*)bookmark;
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       if(_bookmark != NULL)
+       {
+               char *name = NULL;
+               time_t time = 0;
+               int bookmark_id = 0;
+
+               ret = media_bookmark_get_bookmark_id(bookmark, &bookmark_id);
+               if(ret != MEDIA_CONTENT_ERROR_NONE)
+                       media_content_error("error media_bookmark_get_bookmark_id : [%d]", ret);
+               else
+                       media_content_debug("bookmark_id : %d", bookmark_id);
+
+               ret = media_bookmark_get_thumbnail_path(bookmark, &name);
+               if(ret != MEDIA_CONTENT_ERROR_NONE)
+                       media_content_error("error media_bookmark_get_thumbnail_path : [%d]", ret);
+               else
+                       media_content_debug("bookmark thumbnail_path : %s", name);
+               SAFE_FREE(name);
+
+               ret = media_bookmark_get_marked_time(bookmark, &time);
+               if(ret != MEDIA_CONTENT_ERROR_NONE)
+                       media_content_error("error media_bookmark_get_marked_time : [%d]", ret);
+               else
+                       media_content_debug("bookmark marked_time : %d", time);
+       }
+
+       return true;
+}
+
+bool album_list_cb(media_album_h album, void *user_data)
+{
+       int album_id = 0;
+       char *album_name = NULL;
+       char *artist = NULL;
+       char *album_art = NULL;
+       int media_count = 0;
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       filter_h filter = NULL;
+
+       /*Set Filter*/
+       char *condition = "MEDIA_TYPE=3";       /*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music, 4-other*/
+
+       ret = media_filter_create(&filter);
+       if(ret != MEDIA_CONTENT_ERROR_NONE) {
+               media_content_error("Fail to create filter");
+               return ret;
+       }
+       ret = media_filter_set_condition(filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT);
+       if(ret != MEDIA_CONTENT_ERROR_NONE) {
+               media_filter_destroy(filter);
+               media_content_error("Fail to set condition");
+               return ret;
+       }
+       ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_TITLE, MEDIA_CONTENT_COLLATE_NOCASE);
+       if(ret != MEDIA_CONTENT_ERROR_NONE) {
+               media_filter_destroy(filter);
+               media_content_error("Fail to set order");
+               return ret;
+       }
+
+       if(album != NULL)
+       {
+               if(media_album_get_album_id(album, &album_id) != MEDIA_CONTENT_ERROR_NONE)
+               {
+                       media_filter_destroy(filter);
+                       return false;
+               }
+
+               media_content_debug("album_id : [%d]", album_id);
+
+               if(media_album_get_name(album, &album_name) != MEDIA_CONTENT_ERROR_NONE)
+               {
+                       media_filter_destroy(filter);
+                       return false;
+               }
+
+               media_content_debug("album_name : [%s]", album_name);
+
+               if(media_album_get_artist(album, &artist) != MEDIA_CONTENT_ERROR_NONE)
+               {
+                       media_filter_destroy(filter);
+                       return false;
+               }
+
+               media_content_debug("artist : [%s]", artist);
+
+               if(media_album_get_album_art(album, &album_art) != MEDIA_CONTENT_ERROR_NONE)
+               {
+                       media_filter_destroy(filter);
+                       return false;
+               }
+
+               media_content_debug("album_art : [%s]", album_art);
+
+               SAFE_FREE(album_name);
+               SAFE_FREE(artist);
+               SAFE_FREE(album_art);
+
+               if(media_album_get_media_count_from_db(album_id, filter, &media_count) != MEDIA_CONTENT_ERROR_NONE)
+               {
+                       media_filter_destroy(filter);
+                       return false;
+               }
+
+               media_content_debug("media_count : [%d]", media_count);
+
+               if(media_album_foreach_media_from_db(album_id, filter, media_item_cb, NULL) != MEDIA_CONTENT_ERROR_NONE)
+               {
+                       media_filter_destroy(filter);
+                       return false;
+               }
+
+               test_album_from_db(album_id);
+       }
+       else
+       {
+               media_content_error("album item not Found!!");
+       }
+
+       media_filter_destroy(filter);
+
+       return true;
+}
+
+bool group_list_cb(const char *group_name, void *user_data)
+{
+       int media_count = 0;
+       int *idx = user_data;
+
+       media_content_debug("group item : [%s] [%d]", group_name, *idx);
+
+       if(media_group_get_media_count_from_db(group_name, *idx, g_filter, &media_count) != MEDIA_CONTENT_ERROR_NONE)
+               return false;
+
+       media_content_debug("media_count : [%d]", media_count);
+
+       if(media_group_foreach_media_from_db(group_name, *idx, g_filter, media_item_cb, NULL) != MEDIA_CONTENT_ERROR_NONE)
+               return false;
+
+       return true;
+}
+
+bool playlist_item_cb(int playlist_member_id, media_info_h media, void *user_data)
+{
+       media_content_debug("playlist_member_id : [%d]", playlist_member_id);
+
+       GList **list = (GList**)user_data;
+       *list = g_list_append(*list, (gpointer)playlist_member_id);
+
+       //media_item_cb(media, user_data);
+
+       return true;
+}
+
+int test_filter_create(void)
+{
+       media_content_debug("\n============Filter Create============\n\n");
+
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       /* Filter for media */
+       char *condition = "MEDIA_TYPE=0";       /*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music, 4-other*/
+       //char *condition = "MEDIA_TYPE IS NOT 0 AND MEDIA_DESCRIPTION IS NOT NULL";    /*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music, 4-other*/
+
+       ret = media_filter_create(&g_filter);
+
+       /* Set condition and collate
+        * Condition string : You can make where statement of sql.
+        * Colation : You can use collation when comparing.
+        * Ex) In case of FILE_NAME='Samsung' as condition string,
+        *     if you want to compare with NOCASE collation,
+        *     call media_filter_set_condition(g_filter, condition, MEDIA_CONTENT_COLLATE_NOCASE);
+        *     if you want to compare in case-sensitive,
+        *     call media_filter_set_condition(g_filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT);
+        */
+       ret = media_filter_set_condition(g_filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT);
+
+       /* Collation of ordering
+        * If you want to get list, which is sorted by NOCASE,
+        * call media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_ARTIST, MEDIA_CONTENT_COLLATE_NOCASE);
+        * Or,
+        * call media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_ARTIST, MEDIA_CONTENT_COLLATE_DEFAULT);
+        */
+       ret = media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_ARTIST, MEDIA_CONTENT_COLLATE_DEFAULT);
+
+       /* Filter for group */
+       char *g_condition = "TAG_NAME like \"\%my\%\"";
+       //char *g_condition = "BOOKMARK_MARKED_TIME > 300";
+
+       ret = media_filter_create(&g_filter_g);
+
+       ret = media_filter_set_condition(g_filter_g, g_condition, MEDIA_CONTENT_COLLATE_DEFAULT);
+       ret = media_filter_set_order(g_filter_g, MEDIA_CONTENT_ORDER_DESC, TAG_NAME, MEDIA_CONTENT_COLLATE_DEFAULT);
+
+       return ret;
+}
+
+int test_filter_destroy(void)
+{
+       media_content_debug("\n============Filter Create============\n\n");
+
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       ret = media_filter_destroy(g_filter);
+
+       return ret;
+}
+
+int test_connect_database(void)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       media_content_debug("\n============DB Connection Test============\n\n");
+
+       ret = media_content_connect();
+
+       if(ret == MEDIA_CONTENT_ERROR_NONE)
+       {
+               media_content_debug("connection is success\n\n");
+       }
+       else
+               media_content_error("connection is failed\n\n");
+
+       return ret;
+}
+
+int test_gallery_scenario(void)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       int i;
+       filter_h filter = NULL;
+
+       int count;
+       GList *folder_list = NULL;
+       media_folder_h folder_handle = NULL;
+
+       /* First, Get folder list */
+       ret = media_folder_foreach_folder_from_db(filter, gallery_folder_list_cb, &folder_list);
+       if(ret != MEDIA_CONTENT_ERROR_NONE) {
+               media_content_error("media_folder_foreach_folder_from_db failed: %d", ret);
+               return -1;
+       } else {
+               media_content_debug("media_folder_foreach_folder_from_db success!!");
+               char *folder_id = NULL;
+               char *folder_name = NULL;
+               char *folder_path = NULL;
+
+               for(i = 0; i < g_list_length(folder_list); i++) {
+                       folder_handle = (media_folder_h)g_list_nth_data(folder_list, i);
+
+                       ret = media_folder_get_folder_id(folder_handle, &folder_id);
+                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                               media_content_error("media_folder_get_folder_id failed: %d", ret);
+                       ret = media_folder_get_name(folder_handle, &folder_name);
+                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                               media_content_error("media_folder_get_name failed: %d", ret);
+                       ret = media_folder_get_path(folder_handle, &folder_path);
+                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                               media_content_error("media_folder_get_path failed: %d", ret);
+
+                       media_content_debug("folder_id [%d] : %s", i, folder_id);
+                       media_content_debug("folder_name [%d] : %s", i, folder_name);
+                       media_content_debug("folder_path [%d] : %s", i, folder_path);
+
+
+                       ret = media_folder_get_media_count_from_db(folder_id, filter, &count);
+                       /* User should free these string */
+                       SAFE_FREE(folder_id);
+                       SAFE_FREE(folder_name);
+                       SAFE_FREE(folder_path);
+                       if(ret != MEDIA_CONTENT_ERROR_NONE) {
+                               media_content_error("media_folder_get_media_count_from_db failed: %d", ret);
+                               return -1;
+                       } else {
+                               media_content_debug("media count [%d] : %d", i, count);
+                       }
+               }
+       }
+
+       /* To check performance */
+       struct timeval start, end;
+       gettimeofday(&start, NULL);
+
+       /* Second, Get all item list */
+       media_info_h media_handle = NULL;
+       GList *all_item_list = NULL;
+
+       media_content_collation_e collate_type = MEDIA_CONTENT_COLLATE_NOCASE;
+       media_content_order_e order_type = MEDIA_CONTENT_ORDER_DESC;
+       ret = media_filter_create(&filter);
+       if(ret != MEDIA_CONTENT_ERROR_NONE) {
+               media_content_error("Fail to create filter");
+               return ret;
+       }
+       ret = media_filter_set_condition(filter, "MEDIA_TYPE = 0", collate_type);
+       if(ret != MEDIA_CONTENT_ERROR_NONE) {
+               media_filter_destroy(filter);
+               media_content_error("Fail to set condition");
+               return ret;
+       }
+       ret = media_filter_set_order(filter, order_type, MEDIA_DISPLAY_NAME, collate_type);
+       if(ret != MEDIA_CONTENT_ERROR_NONE) {
+               media_filter_destroy(filter);
+               media_content_error("Fail to set order");
+               return ret;
+       }
+
+       ret = media_info_foreach_media_from_db(filter, gallery_media_item_cb, &all_item_list);
+       if(ret != MEDIA_CONTENT_ERROR_NONE) {
+               media_content_error("media_info_foreach_media_from_db failed: %d", ret);
+               media_filter_destroy(filter);
+               return -1;
+       } else {
+               media_content_debug("media_info_foreach_media_from_db success");
+               media_content_type_e media_type;
+               char *media_id = NULL;
+               char *media_name = NULL;
+               char *media_path = NULL;
+
+               for(i = 0; i < g_list_length(all_item_list); i++) {
+                       media_handle = (media_info_h)g_list_nth_data(all_item_list, i);
+
+                       ret = media_info_get_media_id(media_handle, &media_id);
+                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                               media_content_error("media_info_get_media_id failed: %d", ret);
+                       ret = media_info_get_media_type(media_handle, &media_type);
+                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                               media_content_error("media_info_get_media_type failed: %d", ret);
+                       ret = media_info_get_display_name(media_handle, &media_name);
+                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                               media_content_error("media_info_get_display_name failed: %d", ret);
+                       ret = media_info_get_file_path(media_handle, &media_path);
+                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                               media_content_error("media_info_get_file_path failed: %d", ret);
+
+                       if(media_type == MEDIA_CONTENT_TYPE_IMAGE) {
+                               image_meta_h image_handle;
+                               int width = 0, height = 0;
+                               media_content_orientation_e orientation = 0;
+                               char *datetaken = NULL;
+
+                               ret = media_info_get_image(media_handle, &image_handle);
+                               if(ret != MEDIA_CONTENT_ERROR_NONE) {
+                                       media_content_error("media_info_get_image failed: %d", ret);
+                               } else {
+                                       ret = image_meta_get_width(image_handle, &width);
+                                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                                               media_content_error("error image_meta_get_width : [%d]", ret);
+                                       ret = image_meta_get_height(image_handle, &height);
+                                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                                               media_content_error("error image_meta_get_height : [%d]", ret);
+                                       ret = image_meta_get_orientation(image_handle, &orientation);
+                                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                                               media_content_error("error image_meta_get_orientation : [%d]", ret);
+                                       ret = image_meta_get_date_taken(image_handle, &datetaken);
+                                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                                               media_content_error("error image_meta_get_date_taken : [%d]", ret);
+
+                                       media_content_debug("This is Image");
+                                       media_content_debug("Width : %d, Height : %d, Orientation : %d, Date taken : %s", width, height, orientation, datetaken);
+                               }
+
+                               SAFE_FREE(datetaken);
+                               ret = image_meta_destroy(image_handle);
+                               if(ret != MEDIA_CONTENT_ERROR_NONE)
+                                       media_content_error("error image_meta_destroy : [%d]", ret);
+
+                       } else if(media_type == MEDIA_CONTENT_TYPE_VIDEO) {
+                               video_meta_h video_handle;
+                               char *title = NULL, *artist = NULL, *album = NULL;
+                               int duration = 0;
+                               time_t time_played = 0;
+
+                               ret = media_info_get_video(media_handle, &video_handle);
+                               if(ret != MEDIA_CONTENT_ERROR_NONE) {
+                                       media_content_error("media_info_get_video failed: %d", ret);
+                               } else {
+                                       ret = video_meta_get_title(video_handle, &title);
+                                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                                               media_content_error("error video_meta_get_title : [%d]", ret);
+                                       ret = video_meta_get_artist(video_handle, &artist);
+                                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                                               media_content_error("error video_meta_get_artist : [%d]", ret);
+                                       ret = video_meta_get_album(video_handle, &album);
+                                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                                               media_content_error("error video_meta_get_album : [%d]", ret);
+                                       ret = video_meta_get_duration(video_handle, &duration);
+                                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                                               media_content_error("error video_meta_get_duration : [%d]", ret);
+                                       ret = video_meta_get_played_time(video_handle, &time_played);
+                                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                                               media_content_error("error video_meta_get_played_time : [%d]", ret);
+
+                                       media_content_debug("This is Video");
+                                       media_content_debug("Title: %s, Album: %s, Artist: %s\nDuration: %d, Played time: %d", title, artist, album, duration, time_played);
+                               }
+
+                               SAFE_FREE(title);
+                               SAFE_FREE(artist);
+                               SAFE_FREE(album);
+
+                               ret = video_meta_destroy(video_handle);
+                               if(ret != MEDIA_CONTENT_ERROR_NONE)
+                                       media_content_error("error video_meta_destroy : [%d]", ret);
+                       }
+                       //media_content_debug("media_id [%d] : %s", i, media_id);
+                       //media_content_debug("media_name [%d] : %s", i, media_name);
+                       //media_content_debug("media_path [%d] : %s", i, media_path);
+
+                       SAFE_FREE(media_id);
+                       SAFE_FREE(media_name);
+                       SAFE_FREE(media_path);
+               }
+       }
+
+       media_filter_destroy(filter);
+       filter = NULL;
+
+       /* To check performance */
+       gettimeofday(&end, NULL);
+       long time = (end.tv_sec * 1000000 + end.tv_usec) - (start.tv_sec * 1000000 + start.tv_usec);
+       printf("Time : %ld\n", time);
+
+       /* Third, Get item list of a folder */
+       GList *item_list = NULL;
+
+       for(i = 0; i < g_list_length(folder_list); i++) {
+               int j = 0;
+               char *folder_id = NULL;
+               char *folder_name = NULL;
+               folder_handle = (media_folder_h)g_list_nth_data(folder_list, i);
+
+               media_folder_get_folder_id(folder_handle, &folder_id);
+               media_folder_get_name(folder_handle, &folder_name);
+
+               ret = media_folder_foreach_media_from_db(folder_id, filter, gallery_media_item_cb, &item_list);
+               SAFE_FREE(folder_id);
+               SAFE_FREE(folder_name);
+
+               if(ret != MEDIA_CONTENT_ERROR_NONE) {
+                       media_content_error("media_folder_foreach_media_from_db failed: %d", ret);
+                       return -1;
+               } else {
+                       media_content_error("media_folder_foreach_media_from_db success!", ret);
+                       char *media_id = NULL;
+                       char *media_name = NULL;
+                       char *media_path = NULL;
+                       media_content_type_e media_type = 0;
+
+                       for(j = 0; j < g_list_length(item_list); j++) {
+                               media_handle = (media_info_h)g_list_nth_data(item_list, j);
+
+                               ret = media_info_get_media_id(media_handle, &media_id);
+                               if(ret != MEDIA_CONTENT_ERROR_NONE)
+                                       media_content_error("media_info_get_media_id failed: %d", ret);
+                               ret = media_info_get_display_name(media_handle, &media_name);
+                               if(ret != MEDIA_CONTENT_ERROR_NONE)
+                                       media_content_error("media_info_get_display_name failed: %d", ret);
+                               ret = media_info_get_file_path(media_handle, &media_path);
+                               if(ret != MEDIA_CONTENT_ERROR_NONE)
+                                       media_content_error("media_info_get_file_path failed: %d", ret);
+                               ret = media_info_get_media_type(media_handle, &media_type);
+                               if(ret != MEDIA_CONTENT_ERROR_NONE)
+                                       media_content_error("media_info_get_media_type failed: %d", ret);
+
+                               media_content_debug("[%s] media_id [%d] : %s", folder_name, j, media_id);
+                               media_content_debug("[%s] media_type [%d] : %d", folder_name, j, media_type);
+                               media_content_debug("[%s] media_name [%d] : %s", folder_name, j, media_name);
+                               media_content_debug("[%s] media_path [%d] : %s", folder_name, j, media_path);
+
+                               if(media_type == MEDIA_CONTENT_TYPE_IMAGE) {
+                                       image_meta_h image_handle;
+                                       int width = 0, height = 0;
+                                       media_content_orientation_e orientation = 0;
+                                       char *datetaken = NULL;
+
+                                       ret = media_info_get_image(media_handle, &image_handle);
+                                       if(ret != MEDIA_CONTENT_ERROR_NONE) {
+                                               media_content_error("media_info_get_image failed: %d", ret);
+                                       } else {
+                                               ret = image_meta_get_width(image_handle, &width);
+                                               if(ret != MEDIA_CONTENT_ERROR_NONE)
+                                                       media_content_error("error image_meta_get_width : [%d]", ret);
+                                               ret = image_meta_get_height(image_handle, &height);
+                                               if(ret != MEDIA_CONTENT_ERROR_NONE)
+                                                       media_content_error("error image_meta_get_height : [%d]", ret);
+                                               ret = image_meta_get_orientation(image_handle, &orientation);
+                                               if(ret != MEDIA_CONTENT_ERROR_NONE)
+                                                       media_content_error("error image_meta_get_orientation : [%d]", ret);
+                                               ret = image_meta_get_date_taken(image_handle, &datetaken);
+                                               if(ret != MEDIA_CONTENT_ERROR_NONE)
+                                                       media_content_error("error image_meta_get_date_taken : [%d]", ret);
+
+                                               media_content_debug("This is Image");
+                                               media_content_debug("Width : %d, Height : %d, Orientation : %d, Date taken : %s", width, height, orientation, datetaken);
+                                       }
+
+                                       SAFE_FREE(datetaken);
+                                       ret = image_meta_destroy(image_handle);
+                                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                                               media_content_error("error image_meta_destroy : [%d]", ret);
+
+                               } else if(media_type == MEDIA_CONTENT_TYPE_VIDEO) {
+                                       video_meta_h video_handle;
+                                       char *title = NULL, *artist = NULL, *album = NULL;
+                                       int duration = 0;
+                                       time_t time_played;
+
+                                       ret = media_info_get_video(media_handle, &video_handle);
+                                       if(ret != MEDIA_CONTENT_ERROR_NONE) {
+                                               media_content_error("media_info_get_video failed: %d", ret);
+                                       } else {
+                                               ret = video_meta_get_title(video_handle, &title);
+                                               if(ret != MEDIA_CONTENT_ERROR_NONE)
+                                                       media_content_error("error video_meta_get_title : [%d]", ret);
+                                               ret = video_meta_get_artist(video_handle, &artist);
+                                               if(ret != MEDIA_CONTENT_ERROR_NONE)
+                                                       media_content_error("error video_meta_get_artist : [%d]", ret);
+                                               ret = video_meta_get_album(video_handle, &album);
+                                               if(ret != MEDIA_CONTENT_ERROR_NONE)
+                                                       media_content_error("error video_meta_get_album : [%d]", ret);
+                                               ret = video_meta_get_duration(video_handle, &duration);
+                                               if(ret != MEDIA_CONTENT_ERROR_NONE)
+                                                       media_content_error("error video_meta_get_duration : [%d]", ret);
+                                               ret = video_meta_get_played_time(video_handle, &time_played);
+                                               if(ret != MEDIA_CONTENT_ERROR_NONE)
+                                                       media_content_error("error video_meta_get_played_time : [%d]", ret);
+
+                                               media_content_debug("This is Video");
+                                               media_content_debug("Title: %s, Album: %s, Artist: %s\nDuration: %d, Played time: %d\n", title, artist, album, duration, time_played);
+                                       }
+
+                                       SAFE_FREE(title);
+                                       SAFE_FREE(artist);
+                                       SAFE_FREE(album);
+
+                                       ret = video_meta_destroy(video_handle);
+                                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                                               media_content_error("error video_meta_destroy : [%d]", ret);
+
+                                       /* Get bookmar list in case of video */
+                                       media_bookmark_h bm_handle;
+                                       GList *bm_list = NULL;
+
+                                       ret = media_info_foreach_bookmark_from_db(media_id, filter, gallery_bookmarks_cb, &bm_list);
+                                       if(ret != MEDIA_CONTENT_ERROR_NONE) {
+                                               media_content_error("media_info_foreach_bookmark_from_db failed: %d", ret);
+                                       } else {
+                                               media_content_debug("media_info_foreach_bookmark_from_db success");
+
+                                               int k = 0;
+
+                                               for(k = 0; k < g_list_length(bm_list); k++) {
+                                                       bm_handle = (media_bookmark_h)g_list_nth_data(bm_list, k);
+                                                       time_t marked_time;
+                                                       char *thumb_path = NULL;
+
+                                                       ret = media_bookmark_get_marked_time(bm_handle, &marked_time);
+                                                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                                                               media_content_error("error media_bookmark_get_marked_time : [%d]", ret);
+                                                       ret = media_bookmark_get_thumbnail_path(bm_handle, &thumb_path);
+                                                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                                                               media_content_error("error media_bookmark_get_thumbnail_path : [%d]", ret);
+
+                                                       media_content_debug("Bookmark time : %d\nBookmar thumb: %s", marked_time, thumb_path);
+                                                       SAFE_FREE(thumb_path);
+                                               }
+
+                                               /* Remove bookmark list */
+                                               int l = 0;
+                                               if(bm_list) {
+                                                       for(l = 0; l < g_list_length(bm_list); l++) {
+                                                               bm_handle = (media_bookmark_h)g_list_nth_data(bm_list, l);
+                                                               ret = media_bookmark_destroy(bm_handle);
+                                                               if(ret != MEDIA_CONTENT_ERROR_NONE)
+                                                                       media_content_error("error media_bookmark_destroy : [%d]", ret);
+                                                       }
+
+                                                       g_list_free(bm_list);
+                                               }
+
+                                       }
+                               }
+
+                               SAFE_FREE(media_id);
+                               SAFE_FREE(media_name);
+                               SAFE_FREE(media_path);
+                       }
+               }
+       }
+
+       /* Get tag list */
+       media_tag_h tag_handle = NULL;
+       GList *tag_list = NULL;
+       GList *media_list_in_tag = NULL;
+
+       ret = media_tag_foreach_tag_from_db (filter, gallery_tag_item_cb, &tag_list);
+
+       if(ret != MEDIA_CONTENT_ERROR_NONE) {
+               media_content_error("media_tag_foreach_tag_from_db failed: %d", ret);
+               return -1;
+       } else {
+               media_content_error("media_tag_foreach_tag_from_db success");
+               char *tag_name = NULL;
+               int tag_id;
+
+               for(i = 0; i < g_list_length(tag_list); i++) {
+                       tag_handle = (media_tag_h)g_list_nth_data(tag_list, i);
+                       media_tag_get_tag_id(tag_handle, &tag_id);
+                       media_tag_get_name(tag_handle, &tag_name);
+
+                       printf("[%d] %s", tag_id, tag_name);
+
+                       ret = media_tag_foreach_media_from_db(tag_id, filter, gallery_media_item_cb, &media_list_in_tag);
+                       if(ret != MEDIA_CONTENT_ERROR_NONE) {
+                               media_content_error("media_tag_foreach_media_from_db failed: %d", ret);
+                               return -1;
+                       } else {
+                               media_content_error("media_tag_foreach_media_from_db success");
+                               int j = 0;
+                               media_info_h tag_media_handle;
+                               char *media_id = NULL;
+                               char *media_name = NULL;
+                               char *media_path = NULL;
+                               media_content_type_e media_type = 0;
+
+                               for(j = 0; j < g_list_length(media_list_in_tag); j++) {
+                                       tag_media_handle = (media_info_h)g_list_nth_data(media_list_in_tag, j);
+                                       ret = media_info_get_media_id(tag_media_handle, &media_id);
+                                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                                               media_content_error("media_info_get_media_id failed: %d", ret);
+                                       ret = media_info_get_display_name(tag_media_handle, &media_name);
+                                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                                               media_content_error("media_info_get_display_name failed: %d", ret);
+                                       ret = media_info_get_file_path(tag_media_handle, &media_path);
+                                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                                               media_content_error("media_info_get_file_path failed: %d", ret);
+                                       ret = media_info_get_media_type(tag_media_handle, &media_type);
+                                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                                               media_content_error("media_info_get_media_type failed: %d", ret);
+
+                                       media_content_debug("[%s] media_id [%d] : %s", tag_name, j, media_id);
+                                       media_content_debug("[%s] media_type [%d] : %d", tag_name, j, media_type);
+                                       media_content_debug("[%s] media_name [%d] : %s", tag_name, j, media_name);
+                                       media_content_debug("[%s] media_path [%d] : %s", tag_name, j, media_path);
+                               }
+                               SAFE_FREE(media_id);
+                               SAFE_FREE(media_name);
+                               SAFE_FREE(media_path);
+                       }
+                       SAFE_FREE(tag_name);
+               }
+       }
+
+       /* Remove folder list */
+       if(folder_list) {
+               for(i = 0; i < g_list_length(folder_list); i++) {
+                       folder_handle = (media_folder_h)g_list_nth_data(folder_list, i);
+                       media_folder_destroy(folder_handle);
+               }
+
+               g_list_free(folder_list);
+       }
+
+       /* Remove all items list */
+       if(all_item_list) {
+               for(i = 0; i < g_list_length(all_item_list); i++) {
+                       media_handle = (media_info_h)g_list_nth_data(all_item_list, i);
+                       ret = media_info_destroy(media_handle);
+                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                               media_content_error("media_info_destroy failed: %d", ret);
+               }
+
+               g_list_free(all_item_list);
+       }
+
+       /* Remove items list */
+       if(item_list) {
+               for(i = 0; i < g_list_length(item_list); i++) {
+                       media_handle = (media_info_h)g_list_nth_data(item_list, i);
+                       ret = media_info_destroy(media_handle);
+                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                               media_content_error("media_info_destroy failed: %d", ret);
+               }
+
+               g_list_free(item_list);
+       }
+
+       /* Remove tag list */
+       if(tag_list) {
+               for(i = 0; i < g_list_length(tag_list); i++) {
+                       tag_handle = (media_tag_h)g_list_nth_data(tag_list, i);
+                       ret = media_tag_destroy(tag_handle);
+                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                               media_content_error("error media_tag_destroy : [%d]", ret);
+               }
+
+               g_list_free(tag_list);
+       }
+
+       /* Remove media list in a tag */
+       if(media_list_in_tag) {
+               for(i = 0; i < g_list_length(media_list_in_tag); i++) {
+                       media_handle = (media_info_h)g_list_nth_data(media_list_in_tag, i);
+                       ret = media_info_destroy(media_handle);
+                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                               media_content_error("media_info_destroy failed: %d", ret);
+               }
+
+               g_list_free(media_list_in_tag);
+       }
+
+       return MEDIA_CONTENT_ERROR_NONE;
+}
+
+/*Get All Music file. sort by Title and not case sensitive*/
+int test_get_all_music_files(void)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       int media_count = 0;
+       filter_h filter;
+
+       /*Set Filter*/
+       char *condition = "MEDIA_TYPE=3";       /*0-image, 1-video, 2-sound, 3-music, 4-other*/
+
+       ret = media_filter_create(&filter);
+       if(ret != MEDIA_CONTENT_ERROR_NONE) {
+               media_content_error("Fail to create filter");
+               return ret;
+       }
+       ret = media_filter_set_condition(filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT);
+       if(ret != MEDIA_CONTENT_ERROR_NONE) {
+               media_filter_destroy(filter);
+               media_content_error("Fail to set condition");
+               return ret;
+       }
+       ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_TITLE, MEDIA_CONTENT_COLLATE_NOCASE);
+       if(ret != MEDIA_CONTENT_ERROR_NONE) {
+               media_filter_destroy(filter);
+               media_content_error("Fail to set order");
+               return ret;
+       }
+
+       /*Get Media Count*/
+       ret = media_info_get_media_count_from_db(filter, &media_count);
+       if(ret != MEDIA_CONTENT_ERROR_NONE) {
+               media_filter_destroy(filter);
+               media_content_error("Fail to get media count");
+               return ret;
+       }
+
+       media_content_debug("media_count : [%d]", media_count);
+
+       ret = media_info_foreach_media_from_db(filter, media_item_cb, NULL);
+       if(ret != MEDIA_CONTENT_ERROR_NONE) {
+               media_filter_destroy(filter);
+               media_content_error("Fail to get media");
+               return ret;
+       }
+
+       ret = media_filter_destroy(filter);
+
+       return ret;
+}
+
+int test_media_info_operation(void)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       int media_count = 0;
+
+       media_content_debug("\n============Media info Test============\n\n");
+
+       test_filter_create();
+
+       ret = media_info_get_media_count_from_db(g_filter, &media_count);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("media_info_get_media_count_from_db failed: %d", ret);
+       else
+               media_content_debug("media_count : [%d]", media_count);
+
+       ret = media_info_foreach_media_from_db(g_filter, media_item_cb, NULL);
+       if(ret == MEDIA_CONTENT_ERROR_NONE)
+               media_content_debug("media_info_foreach_media_from_db is success");
+       else
+               media_content_error("media_info_foreach_media_from_db is failed");
+
+       test_filter_destroy();
+
+       return ret;
+}
+
+int test_media_info_operation_2(void)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       int bookmark_count = 0;
+
+       media_content_debug("\n============Media info Test 2============\n\n");
+
+       test_filter_create();
+
+#if 0
+       /* Bookmark */
+       char *thumbnail_path1 = "/opt/media/Images and videos/My video clips/teat11.jpg";
+       media_bookmark_insert_to_db(test_video_id, 100, thumbnail_path1);
+       media_bookmark_insert_to_db(test_video_id, 200, thumbnail_path1);
+
+       media_info_get_bookmark_count_from_db(test_video_id, g_filter_g, &bookmark_count);
+
+       media_content_debug("bookmark_count : [%d]", bookmark_count);
+
+       ret = media_info_foreach_bookmark_from_db(test_video_id, g_filter_g, bookmarks_cb, NULL);
+#endif
+
+       /* Tag */
+       ret = media_info_get_tag_count_from_db(test_audio_id, g_filter_g, &bookmark_count);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("media_info_get_tag_count_from_db failed: %d", ret);
+       else
+               media_content_debug("tag_count : [%d]", bookmark_count);
+
+       ret = media_info_foreach_tag_from_db(test_audio_id, g_filter_g, tag_list_cb, NULL);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("media_info_foreach_tag_from_db failed: %d", ret);
+
+       test_filter_destroy();
+
+       return ret;
+}
+
+int test_folder_operation(void)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       filter_h filter;
+       media_folder_h folder = NULL;
+       char *folder_id = NULL;
+       int folder_count = 0;
+
+       media_content_debug("\n============Folder Test============\n\n");
+
+       test_filter_create();
+
+       ret = media_filter_create(&filter);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+       {
+               media_content_error("[ERROR] media_folder_filter_create is failed");
+               return ret;
+       }
+
+       media_filter_set_condition(filter, "(MEDIA_TYPE = 0 or MEDIA_TYPE = 1) and MEDIA_STORAGE_TYPE=0", MEDIA_CONTENT_COLLATE_DEFAULT);       /*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music, 4-other*/
+       media_filter_set_offset(filter, 0,5);
+       media_filter_set_order(filter,MEDIA_CONTENT_ORDER_DESC, MEDIA_PATH, MEDIA_CONTENT_COLLATE_NOCASE);
+
+       ret = media_folder_get_folder_count_from_db(filter, &folder_count);
+       media_content_debug("Folder count : %d", folder_count);
+
+       ret = media_folder_foreach_folder_from_db(filter, folder_list_cb, &folder);
+
+       //test.3 get the media list in first folder
+       filter_h m_filter = NULL;
+       ret = media_filter_create(&m_filter);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+       {
+               test_filter_destroy();
+               media_filter_destroy(filter);
+               media_content_error("[ERROR] media_info_filter_create is failed");
+               return ret;
+       }
+
+       media_filter_set_condition(m_filter, "MEDIA_TYPE=1 and MEDIA_STORAGE_TYPE=0", MEDIA_CONTENT_COLLATE_DEFAULT);   /*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music, 4-other*/
+       media_filter_set_offset(m_filter, 0,5);
+       media_filter_set_order(m_filter,MEDIA_CONTENT_ORDER_DESC, MEDIA_PATH, MEDIA_CONTENT_COLLATE_NOCASE);
+
+       media_folder_get_folder_id(folder, &folder_id);
+       media_content_debug("folder_id : %s", folder_id);
+
+       ret = media_folder_foreach_media_from_db(folder_id, m_filter, media_item_cb, NULL);
+
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+       {
+               media_content_error("[ERROR] media_folder_foreach_media_from_db is failed, error code : %d", ret);
+       }
+
+       media_filter_destroy(filter);
+       media_filter_destroy(m_filter);
+
+       test_filter_destroy();
+
+       return ret;
+}
+
+int test_playlist_operation(void)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_playlist_h playlist_1 = NULL;
+       media_playlist_h playlist_2 = NULL;
+       media_playlist_h playlist_3 = NULL;
+       int playlist_id_1 = 0;
+       int playlist_id_2 = 0;
+       int playlist_id_3 = 0;
+       char *playlist_name_1 = "myPlaylist_1";
+       char *playlist_name_2 = "myPlaylist_2";
+       char *playlist_name_3 = "myPlaylist_3";
+       int playlist_count = 0;
+       int media_count = 0;
+       int order_1 = 0;
+       int order_2 = 0;
+       int order_3 = 0;
+       int order_4 = 0;
+       int order_5 = 0;
+       filter_h filter = NULL;
+       filter_h m_filter = NULL;
+
+       media_content_debug("\n============Playlist Test============\n\n");
+
+       /* Filter for playlist */
+
+       char *condition = "(MEDIA_TYPE=1 or MEDIA_TYPE=3)";     /*0-image, 1-video, 2-sound, 3-music, 4-other*/
+
+       ret = media_filter_create(&filter);
+       ret = media_filter_set_condition(filter, condition, MEDIA_CONTENT_COLLATE_NOCASE);
+       ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_ASC, PLAYLIST_NAME, MEDIA_CONTENT_COLLATE_NOCASE);
+
+       /* Create Playlist */
+       media_playlist_insert_to_db(playlist_name_1, &playlist_1);
+       media_playlist_insert_to_db(playlist_name_2, &playlist_2);
+       media_playlist_insert_to_db(playlist_name_3, &playlist_3);
+
+       if(playlist_1 != NULL)
+       {
+               /* Add media to Playlist */
+               media_playlist_add_media(playlist_1, test_audio_id);
+               media_playlist_add_media(playlist_1, test_audio_id);
+               media_playlist_add_media(playlist_1, test_video_id);
+               media_playlist_update_to_db(playlist_1);
+       }
+
+       if(playlist_2 != NULL)
+       {
+               media_playlist_add_media(playlist_2, test_audio_id);
+               media_playlist_add_media(playlist_2, test_audio_id);
+               media_playlist_update_to_db(playlist_2);
+       }
+
+       /* Get Playlist Count*/
+       media_playlist_get_playlist_count_from_db(filter, &playlist_count);
+       media_content_debug("playlist_count [%d]", playlist_count);
+
+       /* Get Playlist*/
+       GList *playlist_id_list = NULL;
+       media_playlist_foreach_playlist_from_db(filter, playlist_list_cb, &playlist_id_list);
+
+       /* Get Playlist id*/
+       playlist_id_1 = (int)g_list_nth_data(playlist_id_list, 0);
+       playlist_id_2 = (int)g_list_nth_data(playlist_id_list, 1);
+       playlist_id_3 = (int)g_list_nth_data(playlist_id_list, 2);
+       media_content_debug("playlist_id_1 [%d]", playlist_id_1);
+       media_content_debug("playlist_id_2 [%d]", playlist_id_2);
+       media_content_debug("playlist_id_3 [%d]", playlist_id_3);
+
+       /* Filter for media*/
+       ret = media_filter_create(&m_filter);
+
+       ret = media_filter_set_condition(m_filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT);
+
+       ret = media_filter_set_order(m_filter, MEDIA_CONTENT_ORDER_ASC, PLAYLIST_MEMBER_ORDER, MEDIA_CONTENT_COLLATE_DEFAULT);
+
+       /* Get media count */
+       media_playlist_get_media_count_from_db(playlist_id_1, m_filter, &media_count);
+       media_content_debug("playlist_1_media_count [%d]", media_count);
+
+       media_playlist_get_media_count_from_db(playlist_id_2, m_filter, &media_count);
+       media_content_debug("playlist_2_media_count [%d]", media_count);
+
+       media_playlist_get_media_count_from_db(playlist_id_3, m_filter, &media_count);
+       media_content_debug("playlist_3_media_count [%d]", media_count);
+
+       /* Get media of playlist */
+       GList *playlist_member_id_list = NULL;
+       GList *playlist_member_id_list_1 = NULL;
+
+       media_playlist_foreach_media_from_db(playlist_id_1, m_filter, playlist_item_cb, &playlist_member_id_list);
+       media_playlist_foreach_media_from_db(playlist_id_2, m_filter, playlist_item_cb, &playlist_member_id_list_1);
+
+       int playlist_member_id_1_1 =0;
+       int playlist_member_id_1_2 =0;
+       int playlist_member_id_1_3 =0;
+       int playlist_member_id_2_1 =0;
+       int playlist_member_id_2_2 =0;
+
+       playlist_member_id_1_1 = (int)g_list_nth_data(playlist_member_id_list, 0);
+       playlist_member_id_1_2 = (int)g_list_nth_data(playlist_member_id_list, 1);
+       playlist_member_id_1_3 = (int)g_list_nth_data(playlist_member_id_list, 2);
+       playlist_member_id_2_1 = (int)g_list_nth_data(playlist_member_id_list_1, 0);
+       playlist_member_id_2_2 = (int)g_list_nth_data(playlist_member_id_list_1, 1);
+
+       media_content_debug("playlist_member_id_1_1 [%d]", playlist_member_id_1_1);
+       media_content_debug("playlist_member_id_1_2 [%d]", playlist_member_id_1_2);
+       media_content_debug("playlist_member_id_1_3 [%d]", playlist_member_id_1_3);
+       media_content_debug("playlist_member_id_2_1 [%d]", playlist_member_id_2_1);
+       media_content_debug("playlist_member_id_2_2 [%d]", playlist_member_id_2_2);
+
+       media_playlist_get_play_order(playlist_1, playlist_member_id_1_1, &order_1);
+       media_playlist_get_play_order(playlist_1, playlist_member_id_1_2, &order_2);
+       media_playlist_get_play_order(playlist_1, playlist_member_id_1_3, &order_3);
+       media_playlist_get_play_order(playlist_2, playlist_member_id_2_1, &order_4);
+       media_playlist_get_play_order(playlist_2, playlist_member_id_2_2, &order_5);
+       media_content_debug("order_1 [%d] order_2 [%d] order_3 [%d] order_4 [%d] order_5 [%d]", order_1, order_2, order_3, order_4, order_5);
+
+       /* Update Playlist */
+       media_playlist_remove_media(playlist_2, playlist_member_id_2_1);
+       media_playlist_add_media(playlist_2, test_video_id);
+       media_playlist_set_name(playlist_2, "test_playlist");
+       media_playlist_set_play_order(playlist_2, playlist_member_id_2_2, order_5+100);
+       media_playlist_update_to_db(playlist_2);
+
+       /* Get Updated Playlist*/
+       media_playlist_foreach_playlist_from_db(filter, playlist_list_cb, NULL);
+
+       /* deletes the playlist */
+       //media_playlist_delete_from_db(playlist_id_1);
+       //media_playlist_delete_from_db(playlist_id_2);
+
+       if(playlist_1 != NULL)
+               media_playlist_destroy(playlist_1);
+       if(playlist_2 != NULL)
+               media_playlist_destroy(playlist_2);
+       if(playlist_3 != NULL)
+               media_playlist_destroy(playlist_3);
+
+       g_list_free(playlist_id_list);
+       g_list_free(playlist_member_id_list);
+       g_list_free(playlist_member_id_list_1);
+
+       if(filter != NULL)
+               ret = media_filter_destroy(filter);
+       if(m_filter != NULL)
+               ret = media_filter_destroy(m_filter);
+
+       return ret;
+}
+
+int test_tag_operation(void)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_tag_h tag_1;
+       media_tag_h tag_2;
+       media_tag_h tag_3;
+       int tag_id_1 = 0;
+       int tag_id_2 = 0;
+       int tag_id_3 = 0;
+       char *tag_name_1 = "myTag_1";
+       char *tag_name_2 = "myTag_2";
+       char *tag_name_3 = "myTag_3";
+       int tag_count = 0;
+       int media_count = 0;
+       filter_h filter;
+
+       media_content_debug("\n============Tag Test============\n\n");
+
+       char *g_condition = "TAG_NAME like \"%%my%%\"";
+
+       ret = media_filter_create(&filter);
+
+       ret = media_filter_set_condition(filter, g_condition, MEDIA_CONTENT_COLLATE_DEFAULT);
+
+       ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_DESC, TAG_NAME, MEDIA_CONTENT_COLLATE_DEFAULT);
+
+       /* Create Tag */
+       ret = media_tag_insert_to_db(tag_name_1, &tag_1);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_tag_insert_to_db : [%d]", ret);
+       ret = media_tag_insert_to_db(tag_name_2, &tag_2);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_tag_insert_to_db : [%d]", ret);
+       ret = media_tag_insert_to_db(tag_name_3, &tag_3);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_tag_insert_to_db : [%d]", ret);
+
+       /* Add media to Tag */
+       ret = media_tag_add_media(tag_1, test_audio_id);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_tag_add_media : [%d]", ret);
+       ret = media_tag_add_media(tag_1, test_video_id);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_tag_add_media : [%d]", ret);
+       ret = media_tag_update_to_db(tag_1);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_tag_update_to_db : [%d]", ret);
+
+       ret = media_tag_add_media(tag_2, test_audio_id);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_tag_add_media : [%d]", ret);
+       ret = media_tag_update_to_db(tag_2);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_tag_update_to_db : [%d]", ret);
+
+       /* Get Tag Count*/
+       ret = media_tag_get_tag_count_from_db(filter, &tag_count);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_tag_get_tag_count_from_db : [%d]", ret);
+       else
+               media_content_debug("tag_count [%d]", tag_count);
+
+       /* Get Tag*/
+       ret = media_tag_foreach_tag_from_db(filter, tag_list_cb, NULL);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_tag_foreach_tag_from_db : [%d]", ret);
+
+       /* Get Tag id*/
+       ret = media_tag_get_tag_id(tag_1, &tag_id_1);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_tag_get_tag_id : [%d]", ret);
+       else
+               media_content_debug("tag_id_1 [%d]", tag_id_1);
+
+       ret = media_tag_get_tag_id(tag_2, &tag_id_2);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_tag_get_tag_id : [%d]", ret);
+       else
+               media_content_debug("tag_id_2 [%d]", tag_id_2);
+
+       ret = media_tag_get_tag_id(tag_3, &tag_id_3);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_tag_get_tag_id : [%d]", ret);
+       else
+               media_content_debug("tag_id_3 [%d]", tag_id_3);
+
+       /* Get media count */
+       ret = media_tag_get_media_count_from_db(tag_id_1, NULL, &media_count);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_tag_get_media_count_from_db : [%d]", ret);
+       else
+               media_content_debug("tag_1_media_count [%d]", media_count);
+
+       ret = media_tag_get_media_count_from_db(tag_id_2, NULL, &media_count);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_tag_get_media_count_from_db : [%d]", ret);
+       else
+               media_content_debug("tag_2_media_count [%d]", media_count);
+
+       /* Get media of Tag */
+       ret = media_tag_foreach_media_from_db(tag_id_1, NULL, media_item_cb, NULL);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_tag_foreach_media_from_db : [%d]", ret);
+
+       ret = media_tag_foreach_media_from_db(tag_id_2, NULL, media_item_cb, NULL);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_tag_foreach_media_from_db : [%d]", ret);
+
+       /* Update Tag */
+       ret = media_tag_add_media(tag_2, test_video_id);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_tag_add_media : [%d]", ret);
+       ret = media_tag_set_name(tag_2, "test_tag");
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_tag_set_name : [%d]", ret);
+       ret = media_tag_update_to_db(tag_2);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_tag_update_to_db : [%d]", ret);
+
+       /* Get Updated Tag*/
+       ret = media_tag_foreach_tag_from_db(filter, tag_list_cb, NULL);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_tag_foreach_tag_from_db : [%d]", ret);
+
+       /* deletes the tag */
+       ret = media_tag_delete_from_db(tag_id_1);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_tag_delete_from_db : [%d]", ret);
+       ret = media_tag_delete_from_db(tag_id_2);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_tag_delete_from_db : [%d]", ret);
+
+       ret = media_tag_destroy(tag_1);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_tag_destroy : [%d]", ret);
+       ret = media_tag_destroy(tag_2);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_tag_destroy : [%d]", ret);
+       ret = media_filter_destroy(filter);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_filter_destroy : [%d]", ret);
+
+       return ret;
+}
+
+
+int test_bookmark_operation(void)
+{
+       //bookmark is only supported for video information.
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       int bookmark_count = 0;
+       filter_h filter;
+
+       media_content_debug("\n============Bookmark Test============\n\n");
+
+       char *g_condition = "BOOKMARK_MARKED_TIME > 300";
+
+       ret = media_filter_create(&filter);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_filter_create : [%d]", ret);
+
+       ret = media_filter_set_condition(filter, g_condition, MEDIA_CONTENT_COLLATE_DEFAULT);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_filter_set_condition : [%d]", ret);
+
+       ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_DESC, BOOKMARK_MARKED_TIME, MEDIA_CONTENT_COLLATE_DEFAULT);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_filter_set_order : [%d]", ret);
+
+       //insert bookmark to video
+       char *thumbnail_path1 = "/opt/usr/media/Images and videos/My video clips/teat11.jpg";
+       ret = media_bookmark_insert_to_db(test_video_id, 400, thumbnail_path1);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_bookmark_insert_to_db : [%d]", ret);
+
+       ret = media_bookmark_insert_to_db(test_video_id, 600, thumbnail_path1);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_bookmark_insert_to_db : [%d]", ret);
+
+       ret = media_bookmark_get_bookmark_count_from_db(filter, &bookmark_count);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_bookmark_get_bookmark_count_from_db : [%d]", ret);
+       else
+               media_content_debug("bookmark_count = [%d]", bookmark_count);
+
+       ret = media_filter_destroy(filter);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_filter_destroy : [%d]", ret);
+
+       return ret;
+}
+
+int test_album_list(void)
+{
+       media_content_debug("\n============Album Test============\n\n");
+
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       int album_count = 0;
+       filter_h filter;
+
+       /*Set Filter*/
+       char *condition = "MEDIA_TYPE=3";       /*0-image, 1-video, 2-sound, 3-music, 4-other*/
+
+       ret = media_filter_create(&filter);
+       if(ret != MEDIA_CONTENT_ERROR_NONE) {
+               media_content_error("Fail to create filter");
+               return ret;
+       }
+       ret = media_filter_set_condition(filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT);
+       if(ret != MEDIA_CONTENT_ERROR_NONE) {
+               media_filter_destroy(filter);
+               media_content_error("Fail to set condition");
+               return ret;
+       }
+       ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_ALBUM, MEDIA_CONTENT_COLLATE_NOCASE);
+       if(ret != MEDIA_CONTENT_ERROR_NONE) {
+               media_filter_destroy(filter);
+               media_content_error("Fail to set order");
+               return ret;
+       }
+
+       ret = media_album_get_album_count_from_db(filter, &album_count);
+       if(ret != MEDIA_CONTENT_ERROR_NONE) {
+               media_filter_destroy(filter);
+               return ret;
+       } else {
+               media_content_debug("album_count [%d]", album_count);
+       }
+
+       ret = media_album_foreach_album_from_db(filter, album_list_cb, NULL);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_album_foreach_album_from_db : [%d]", ret);
+
+       ret = media_filter_destroy(filter);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("error media_filter_destroy : [%d]", ret);
+
+       return ret;
+}
+
+int test_group_operation(void)
+{
+       media_content_debug("\n============Group Test============\n\n");
+
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       int group_count = 0;
+       int idx = 0;
+
+       ret = test_filter_create();
+       if(ret != MEDIA_CONTENT_ERROR_NONE) {
+               media_content_error("[%d]error(0x%08x)", __LINE__, ret);
+               return ret;
+       }
+
+       for(idx = 0; idx <= MEDIA_CONTENT_GROUP_KEYWORD; idx++)
+       {
+               ret = media_group_get_group_count_from_db(g_filter, idx, &group_count);
+               if(ret != MEDIA_CONTENT_ERROR_NONE) {
+                       test_filter_destroy();
+                       media_content_error("media_group_get_group_count_from_db fail. idx=[%d]", ret, idx);
+                       return ret;
+               } else {
+                       media_content_debug("[%2d]group_count [%d]", idx, group_count);
+               }
+
+               ret = media_group_foreach_group_from_db(g_filter, idx, group_list_cb, &idx);
+       }
+       ret = test_filter_destroy();
+
+       return ret;
+}
+
+int test_update_operation()
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       int i;
+       media_info_h media_handle = NULL;
+       GList *all_item_list = NULL;
+
+       /* Get all item list */
+       ret = media_info_foreach_media_from_db(NULL, gallery_media_item_cb, &all_item_list);
+       if(ret != MEDIA_CONTENT_ERROR_NONE) {
+               media_content_error("media_info_foreach_media_from_db failed: %d", ret);
+               return -1;
+       } else {
+               media_content_debug("media_info_foreach_media_from_db success");
+               char *media_id = NULL;
+               char *media_path = NULL;
+               media_content_type_e media_type = 0;
+
+               for(i = 0; i < g_list_length(all_item_list); i++) {
+                       media_handle = (media_info_h)g_list_nth_data(all_item_list, i);
+
+                       ret = media_info_get_media_id(media_handle, &media_id);
+                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                               media_content_error("media_info_get_media_id failed: %d", ret);
+                       ret = media_info_get_file_path(media_handle, &media_path);
+                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                               media_content_error("media_info_get_file_path failed: %d", ret);
+                       ret = media_info_get_media_type(media_handle, &media_type);
+                       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                               media_content_error("media_info_get_media_type failed: %d", ret);
+
+                       media_content_debug("media_id [%d] : %s", i, media_id);
+                       media_content_debug("media_type [%d] : %d", i, media_type);
+                       media_content_debug("media_path [%d] : %s", i, media_path);
+#if 0
+                       if(media_type == MEDIA_CONTENT_TYPE_IMAGE) {
+                               image_meta_h image_handle;
+                               media_content_orientation_e orientation;
+
+                               ret = media_info_get_image(media_handle, &image_handle);
+                               if(ret != MEDIA_CONTENT_ERROR_NONE) {
+                                       media_content_error("media_info_get_image failed: %d", ret);
+                               } else {
+                                       media_content_debug("media_info_get_image success");
+
+                                       //update image meta
+                                       orientation = MEDIA_CONTENT_ORIENTATION_ROT_180;
+                                       image_meta_set_orientation(image_handle, orientation);
+
+                                       ret = image_meta_update_to_db(image_handle);
+                                       if(ret != MEDIA_CONTENT_ERROR_NONE) {
+                                               media_content_error("image_meta_update_to_db failed: %d", ret);
+                                       } else {
+                                               media_content_debug("image_meta_update_to_db success");
+                                       }
+                               }
+
+                       } else if(media_type == MEDIA_CONTENT_TYPE_VIDEO) {
+                               video_meta_h video_handle;
+
+                               ret = media_info_get_video(media_handle, &video_handle);
+                               if(ret != MEDIA_CONTENT_ERROR_NONE) {
+                                       media_content_error("media_info_get_video failed: %d", ret);
+                               } else {
+                                       media_content_debug("media_info_get_video success");
+
+                                       //update video meta
+                                       video_meta_set_played_count(video_handle,5);
+                                       video_meta_set_played_time(video_handle,5);
+                                       video_meta_set_played_position(video_handle,5);
+                                       video_meta_update_to_db(video_handle);
+
+                                       ret = video_meta_update_to_db(video_handle);
+                                       if(ret != MEDIA_CONTENT_ERROR_NONE) {
+                                               media_content_error("video_meta_update_to_db failed: %d", ret);
+                                       } else {
+                                               media_content_debug("video_meta_update_to_db success");
+                                       }
+                               }
+                       } else if(media_type == MEDIA_CONTENT_TYPE_MUSIC) {//update audio meta
+                               audio_meta_h audio_handle = NULL;
+                               ret = media_info_get_audio(media_handle, &audio_handle);
+                               if(ret != MEDIA_CONTENT_ERROR_NONE) {
+                                       media_content_error("media_info_get_audio failed: %d", ret);
+                               } else {
+                                       media_content_debug("media_info_get_audio success");
+
+                                       audio_meta_set_played_count(audio_handle,5);
+                                       audio_meta_set_played_time(audio_handle,1000);
+                                       audio_meta_set_played_position(audio_handle,180);
+
+                                       ret = audio_meta_update_to_db(audio_handle);
+                                       if(ret != MEDIA_CONTENT_ERROR_NONE) {
+                                               media_content_error("audio_meta_update_to_db failed: %d", ret);
+                                       } else {
+                                               media_content_debug("audio_meta_update_to_db success");
+                                       }
+                               }
+
+                       }
+#endif
+               }
+       }
+
+       return MEDIA_CONTENT_ERROR_NONE;
+}
+
+int test_insert(void)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       //char *path = "/opt/media/Images/Default.jpg";
+       char *path = "/opt/usr/media/Others/other.txt";
+       //char *path = NULL;
+       media_info_h media_item = NULL;
+       media_content_debug("\n============DB Insert Test============\n\n");
+
+       ret = media_info_insert_to_db(path, &media_item);
+
+       if((ret == MEDIA_CONTENT_ERROR_NONE) && (media_item != NULL))
+       {
+               media_content_debug("Insertion is success");
+       }
+       else
+       {
+               media_content_error("Insertion is failed");
+               ret = media_info_destroy(media_item);
+               return ret;
+       }
+
+       char *media_id = NULL;
+
+       ret = media_info_get_media_id(media_item, &media_id);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("media_info_get_media_id failed: %d", ret);
+       else
+               media_content_debug("Media ID: %s", media_id);
+
+       SAFE_FREE(media_id);
+
+       ret = media_info_update_to_db(media_item);
+       if(ret == MEDIA_CONTENT_ERROR_NONE)
+               media_content_debug("media_info_update_to_db is success");
+       else
+               media_content_error("media_info_update_to_db is failed");
+
+       ret = media_info_destroy(media_item);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("media_info_destroy failed: %d", ret);
+
+       return ret;
+}
+
+int test_move(void)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       const char *move_media_id = "60aea677-4742-408e-b5f7-f2628062d06d";
+       char *dst_path = "/opt/usr/media/Images/XX/Default1.jpg";
+       media_info_h move_media = NULL;
+
+       ret = media_info_get_media_from_db(move_media_id, &move_media);
+       if(ret == MEDIA_CONTENT_ERROR_NONE)
+               media_content_debug("media_info_get_media_from_db success");
+       else
+               media_content_error("media_info_get_media_from_db failed: %d", ret);
+
+       media_content_debug("\n============DB Move Test============\n\n");
+
+       if(move_media) {
+               ret = media_info_move_to_db(move_media, dst_path);
+
+               if(ret == MEDIA_CONTENT_ERROR_NONE)
+                       media_content_debug("Move is success");
+               else
+                       media_content_error("Move is failed");
+
+               ret = media_info_destroy(move_media);
+       } else {
+               media_content_debug("There is no item : %s", move_media_id);
+       }
+
+       return ret;
+}
+
+void thumbnail_completed_cb(media_content_error_e error, const char *path, void *user_data)
+{
+       char *thumbnail_path = NULL;
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       g_cnt++;
+
+       media_content_debug("=================[%d][%d]", g_media_cnt, g_cnt);
+       media_content_debug("error_code [%d]", error);
+       media_content_debug("thumbnail_path [%s]", path);
+       if(user_data != NULL)
+       {
+               media_info_h media = (media_info_h)user_data;
+               ret = media_info_get_thumbnail_path(media, &thumbnail_path);
+               if(ret != MEDIA_CONTENT_ERROR_NONE)
+                       media_content_error("media_info_get_thumbnail_path failed: %d", ret);
+               else
+                       media_content_debug("thumbnail_path get from media[%s]", thumbnail_path);
+               SAFE_FREE(thumbnail_path);
+               ret = media_info_destroy(media);
+               if(ret != MEDIA_CONTENT_ERROR_NONE)
+                       media_content_error("media_info_destroy failed: %d", ret);
+       }
+
+       if(g_cnt == g_media_cnt)
+               g_main_loop_quit(g_loop);
+
+       return;
+}
+
+bool thumbnail_create_cb(media_info_h media, void *user_data)
+{
+       char *media_id = NULL;
+       media_info_h dst = NULL;
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       if(media == NULL)
+       {
+               media_content_debug("NO Item");
+               return true;
+       }
+
+       ret = media_info_get_media_id(media, &media_id);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("media_info_get_media_id failed: %d", ret);
+       else
+               media_content_debug("media_id : [%s]", media_id);
+
+       ret = media_info_clone(&dst, media);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("media_info_clone failed: %d", ret);
+       else
+       {
+               ret = media_info_create_thumbnail(dst, thumbnail_completed_cb, dst);
+               if(ret != MEDIA_CONTENT_ERROR_NONE)
+                       media_content_error("media_info_create_thumbnail failed: %d", ret);
+       }
+
+       return true;
+}
+
+bool thumbnail_cancel_cb(media_info_h media, void *user_data)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       char *media_id = NULL;
+       media_info_h dst = NULL;
+
+       g_cnt++;
+
+       if(media == NULL)
+       {
+               media_content_debug("NO Item");
+               return true;
+       }
+
+       ret = media_info_get_media_id(media, &media_id);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("media_info_get_media_id failed: %d", ret);
+       else
+               media_content_debug("media_id : [%s]", media_id);
+
+       ret = media_info_clone(&dst, media);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("media_info_clone failed: %d", ret);
+
+       ret = media_info_cancel_thumbnail(dst);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("media_info_cancel_thumbnail failed: %d", ret);
+
+       ret = media_info_destroy(dst);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+                       media_content_error("media_info_destroy failed: %d", ret);
+
+       if(g_cnt == g_media_cnt)
+               g_main_loop_quit(g_loop);
+
+       return true;
+}
+
+gboolean create_thumbnail_start(gpointer data)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       ret = media_info_foreach_media_from_db(g_filter, thumbnail_create_cb, NULL);
+
+       if(ret == MEDIA_CONTENT_ERROR_NONE)
+               media_content_debug("media_info_foreach_media_from_db is success");
+       else
+               media_content_error("media_info_foreach_media_from_db is failed");
+
+       return false;
+}
+
+gboolean cancel_thumbnail_start(gpointer data)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       ret = media_info_foreach_media_from_db(g_filter, thumbnail_cancel_cb, NULL);
+
+       if(ret == MEDIA_CONTENT_ERROR_NONE)
+               media_content_debug("media_info_foreach_media_from_db is success");
+       else
+               media_content_error("media_info_foreach_media_from_db is failed");
+
+       return false;
+}
+
+int test_create_thumbnail(int cancel)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       GSource *source = NULL;
+       GMainContext *context = NULL;
+
+       test_filter_create();
+
+       ret = media_info_get_media_count_from_db(g_filter, &g_media_cnt);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("media_info_get_media_count_from_db failed: %d", ret);
+       else
+               media_content_debug("media_count : [%d]", g_media_cnt);
+
+       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, create_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_thumbnail_start, NULL, NULL);
+               g_source_attach (cancel_src, context);
+       }
+
+       g_main_loop_run(g_loop);
+       g_main_loop_unref(g_loop);
+
+       test_filter_destroy();
+
+       return ret;
+}
+
+int test_disconnect_database(void)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_content_debug("\n============DB Disconnection Test============\n\n");
+
+       ret = media_content_disconnect();
+
+       if(ret == MEDIA_CONTENT_ERROR_NONE)
+               media_content_debug("disconnection is success");
+       else
+               media_content_error("disconnection is failed");
+
+       return ret;
+}
+
+int test_request_update_db(void)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       media_info_h media = NULL;
+
+       //get the content of Over the horizon
+       ret = media_info_get_media_from_db("0f999626-6218-450c-a4ad-181a3bab6ebf", &media);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("media_info_get_media_from_db failed: %d", ret);
+
+       test_disconnect_database();
+
+       ret = media_info_set_content_name(media, "TEST_content_name");
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("media_info_set_content_name failed: %d", ret);
+
+       ret = media_info_update_to_db(media);
+       if(ret == MEDIA_CONTENT_ERROR_NONE)
+               media_content_debug("media_info_update_to_db is success");
+       else
+               media_content_error("media_info_update_to_db is failed");
+
+       if(media != NULL)
+               media_info_destroy(media);
+
+       return ret;
+}
+
+int g_total_photo_size = 0;
+int g_total_video_size = 0;
+int g_total_mp3_size = 0;
+int g_total_voice_memo_size = 0;
+
+bool dft_cb(media_info_h media, void *user_data)
+{
+       unsigned long long file_size = 0;
+       media_content_type_e media_type = -1;
+       char *mime_type = NULL;
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       if(media == NULL)
+       {
+               return true;
+       }
+
+       ret = media_info_get_media_type(media, &media_type);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("media_info_get_media_type failed: %d", ret);
+       ret = media_info_get_size(media, &file_size);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("media_info_get_size failed: %d", ret);
+       ret = media_info_get_mime_type(media, &mime_type);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               media_content_error("media_info_get_mime_type failed: %d", ret);
+
+       if(media_type == MEDIA_CONTENT_TYPE_IMAGE)
+       {
+               g_total_photo_size += file_size;
+       }
+       else if(media_type == MEDIA_CONTENT_TYPE_VIDEO)
+       {
+               g_total_video_size += file_size;
+       }
+       else if(media_type == MEDIA_CONTENT_TYPE_SOUND)
+       {
+               g_total_voice_memo_size += file_size;
+       }
+       else if(media_type == MEDIA_CONTENT_TYPE_MUSIC)
+       {
+               if((mime_type != NULL) && (!strcmp("audio/mpeg", mime_type)))
+               {
+                       g_total_mp3_size += file_size;
+               }
+               else
+               {
+                       g_total_voice_memo_size += file_size;
+               }
+       }
+       else
+       {
+               printf("invalid media_type");
+       }
+
+       if(mime_type != NULL)
+               free(mime_type);
+
+       return true;
+
+}
+
+int DFT_test(void)
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+       printf("\n============DFT_test============\n\n");
+
+       filter_h filter = NULL;
+       int media_cnt = 0;
+
+       /*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music, 4-other*/
+
+       ret = media_filter_create(&filter);
+
+/*Internal Memory*/
+       printf("[Internal Memory]\n");
+       /*1. Photo ============================================================*/
+       ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=0 AND MEDIA_TYPE=0", MEDIA_CONTENT_COLLATE_DEFAULT);
+
+       /*Get Photo Count*/
+       ret = media_info_get_media_count_from_db(filter, &media_cnt);
+       printf("Photo count = [%d]\n", media_cnt);
+
+       /*Get Photo Size*/
+       ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
+       printf("Photo size = [%d]\n", g_total_photo_size);
+
+       /*2. Video ============================================================*/
+       ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=0 AND MEDIA_TYPE=1", MEDIA_CONTENT_COLLATE_DEFAULT);
+
+       /*Get Video Count*/
+       ret = media_info_get_media_count_from_db(filter, &media_cnt);
+       printf("Video count = [%d]\n", media_cnt);
+
+       /*Get Video Size*/
+       ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
+       printf("Video size = [%d]\n", g_total_video_size);
+
+       /*3. MP3 ============================================================*/
+       ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=0 AND MEDIA_TYPE=3 AND MEDIA_MIME_TYPE=\"audio/mpeg\"", MEDIA_CONTENT_COLLATE_DEFAULT);
+
+       /*Get MP3 Count*/
+       ret = media_info_get_media_count_from_db(filter, &media_cnt);
+       printf("MP3 count = [%d]\n", media_cnt);
+
+       /*Get MP3 Size*/
+       ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
+       printf("MP3 size = [%d]\n", g_total_mp3_size);
+
+       /*4. Voice Memo ============================================================*/
+       ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=0 AND (MEDIA_MIME_TYPE=\"audio/AMR\" OR MEDIA_MIME_TYPE=\"audio/mp4\")", MEDIA_CONTENT_COLLATE_DEFAULT);
+
+       /*Get Voice Memo Count*/
+       ret = media_info_get_media_count_from_db(filter, &media_cnt);
+       printf("Voice Memo count = [%d]\n", media_cnt);
+
+       /*Get Voice Memo Size*/
+       ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
+       printf("Voice Memo size = [%d]\n", g_total_voice_memo_size);
+
+       g_total_photo_size = 0;
+       g_total_video_size = 0;
+       g_total_mp3_size = 0;
+       g_total_voice_memo_size = 0;
+
+/*External Memory*/
+       printf("\n[External Memory]\n");
+       /*1. Photo ============================================================*/
+       ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=1 AND MEDIA_TYPE=0", MEDIA_CONTENT_COLLATE_DEFAULT);
+
+       /*Get Photo Count*/
+       ret = media_info_get_media_count_from_db(filter, &media_cnt);
+       printf("Photo count = [%d]\n", media_cnt);
+
+       /*Get Photo Size*/
+       ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
+       printf("Photo size = [%d]\n", g_total_photo_size);
+
+       /*2. Video ============================================================*/
+       ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=1 AND MEDIA_TYPE=1", MEDIA_CONTENT_COLLATE_DEFAULT);
+
+       /*Get Video Count*/
+       ret = media_info_get_media_count_from_db(filter, &media_cnt);
+       printf("Video count = [%d]\n", media_cnt);
+
+       /*Get Video Size*/
+       ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
+       printf("Video size = [%d]\n", g_total_video_size);
+
+       /*3. MP3 ============================================================*/
+       ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=1 AND MEDIA_TYPE=3 AND MEDIA_MIME_TYPE=\"audio/mpeg\"", MEDIA_CONTENT_COLLATE_DEFAULT);
+
+       /*Get MP3 Count*/
+       ret = media_info_get_media_count_from_db(filter, &media_cnt);
+       printf("MP3 count = [%d]\n", media_cnt);
+
+       /*Get MP3 Size*/
+       ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
+       printf("MP3 size = [%d]\n", g_total_mp3_size);
+
+       /*4. Voice Memo ============================================================*/
+       ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=1 AND (MEDIA_MIME_TYPE=\"audio/AMR\" OR MEDIA_MIME_TYPE=\"audio/mp4\")", MEDIA_CONTENT_COLLATE_DEFAULT);
+
+       /*Get Voice Memo Count*/
+       ret = media_info_get_media_count_from_db(filter, &media_cnt);
+       printf("Voice Memo count = [%d]\n", media_cnt);
+
+       /*Get Voice Memo Size*/
+       ret = media_info_foreach_media_from_db(filter, dft_cb, NULL);
+       printf("Voice Memo size = [%d]\n", g_total_voice_memo_size);
+       ret = media_filter_destroy(filter);
+
+       return 0;
+}
+
+void insert_batch_cb(media_content_error_e error, void * user_data)
+{
+       printf("media_info_insert_batch_to_db completed!\n");
+}
+
+int test_batch_operations()
+{
+       int ret = -1;
+       int i;
+       char *file_list[10];
+
+       for (i = 0; i < 10; i++) {
+               char filepath[255] = {0,};
+               snprintf(filepath, sizeof(filepath), "%s%d.jpg", "/opt/usr/media/test/image", i+1);
+               media_content_debug("File : %s\n", filepath);
+               file_list[i] = strdup(filepath);
+       }
+
+       ret = media_info_insert_batch_to_db((const char **)file_list, 10, insert_batch_cb, NULL);
+       if(ret != MEDIA_CONTENT_ERROR_NONE) {
+               media_content_error("media_info_insert_batch_to_db failed : %d\n", ret);
+       }
+
+       filter_h filter;
+       char *condition = "MEDIA_PATH LIKE \'/opt/usr/media/test/image%%jpg\'";
+
+       ret = media_filter_create(&filter);
+       if(ret != MEDIA_CONTENT_ERROR_NONE) {
+               media_content_error("Fail to create filter");
+               return ret;
+       }
+
+       ret = media_filter_set_condition(filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT);
+       if(ret != MEDIA_CONTENT_ERROR_NONE) {
+               media_filter_destroy(filter);
+               media_content_error("Fail to set condition");
+               return ret;
+       }
+
+       ret = media_info_delete_batch_from_db(filter);
+       if(ret != MEDIA_CONTENT_ERROR_NONE) {
+               media_filter_destroy(filter);
+               media_content_error("media_info_delete_batch_from_db failed : %d\n", ret);
+               return ret;
+       }
+
+       ret = media_filter_destroy(filter);
+
+       return ret;
+}
+
+void _scan_cb(media_content_error_e err, void *user_data)
+{
+       printf("scan callback is called : %d\n", err);
+       g_main_loop_quit(g_loop);
+
+       return;
+}
+
+int test_scan_file()
+{
+       int ret = -1;
+
+       const char *file_path = "/opt/usr/media/test/image1.jpg";
+
+       ret = media_content_scan_file(file_path);
+       if(ret != MEDIA_CONTENT_ERROR_NONE) {
+               media_content_error("Fail to media_content_scan_file : %d", ret);
+               return ret;
+       }
+
+       return 0;
+}
+
+gboolean test_scan_dir_start(gpointer data)
+{
+       int ret = -1;
+
+       const char *dir_path = "/opt/usr/media";
+
+       ret = media_content_scan_folder(dir_path, _scan_cb, NULL);
+
+       if(ret != MEDIA_CONTENT_ERROR_NONE) {
+               media_content_error("Fail to media_content_scan_file : %d", ret);
+               return ret;
+       }
+
+       return 0;
+}
+
+int test_scan_dir()
+{
+       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, test_scan_dir_start, NULL, NULL);
+       g_source_attach (source, context);
+
+       g_main_loop_run(g_loop);
+       g_main_loop_unref(g_loop);
+
+       return 0;
+}
+
+int main(int argc, char *argv[])
+{
+       int ret = MEDIA_CONTENT_ERROR_NONE;
+
+       media_content_debug("--- content manager test start ---\n\n");
+
+       ret = test_connect_database();
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               return MEDIA_CONTENT_ERROR_NONE;
+
+#if 0
+       ret = test_move();
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               return ret;
+
+       ret = test_gallery_scenario();
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               return ret;
+
+       ret = test_get_all_music_files();
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               return ret;
+
+       ret = test_media_info_operation();
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               return ret;
+
+       ret = test_folder_operation();
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               return ret;
+
+       ret = test_playlist_operation();
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               return ret;
+
+       ret = test_tag_operation();
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               return ret;
+
+       ret = test_bookmark_operation();
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               return ret;
+
+       ret = test_album_list();
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               return ret;
+
+       ret = test_group_operation();
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               return ret;
+
+       ret = test_update_operation();
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               return ret;
+
+       ret = test_insert();
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               return ret;
+
+       ret = test_move();
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               return ret;
+
+       ret = test_create_thumbnail(TRUE);
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               return ret;
+
+       ret = test_request_update_db();
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               return ret;
+
+       ret = DFT_test();
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               return ret;
+
+       ret = test_batch_operations();
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               return MEDIA_CONTENT_ERROR_NONE;
+
+       ret = test_scan_file();
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               return MEDIA_CONTENT_ERROR_NONE;
+
+       ret = test_scan_dir();
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               return MEDIA_CONTENT_ERROR_NONE;
+#endif
+
+       ret = test_disconnect_database();
+       if(ret != MEDIA_CONTENT_ERROR_NONE)
+               return ret;
+
+       media_content_debug("--- content manager test end ---\n");
+
+       return ret;
+}